RosettaCodeData/Task/100-doors/Pointless/100-doors.pointless
2023-07-01 13:44:08 -04:00

19 lines
474 B
Text

output =
range(1, 100)
|> map(visit(100))
|> println
----------------------------------------------------------
toggle(state) =
if state == Closed then Open else Closed
----------------------------------------------------------
-- Door state on iteration i is recursively
-- defined in terms of previous door state
visit(i, index) = cond {
case (i == 0) Closed
case (index % i == 0) toggle(lastState)
else lastState
} where lastState = visit(i - 1, index)