27 lines
509 B
Text
27 lines
509 B
Text
dim doors%(100)
|
|
|
|
print "Finding solution to the 100 Doors Problem"
|
|
|
|
rem - all doors are initially closed
|
|
for i% = 1 to 100
|
|
doors%(i%) = 0
|
|
next i%
|
|
|
|
rem - pass through at increasing intervals
|
|
for i% = 1 to 100
|
|
for j% = i% to 100 step i%
|
|
rem - flip each door encountered
|
|
doors%(j%) = 1 - doors%(j%)
|
|
next j%
|
|
next i%
|
|
|
|
rem - show which doors are open
|
|
print "The open doors are: ";
|
|
for i% = 1 to 100
|
|
if doors%(i%) = 1 then print i%;
|
|
next i%
|
|
|
|
print
|
|
print "Thanks for consulting the puzzle guru!"
|
|
|
|
end
|