----------------------------------------------------------
-- Solution to the '100 doors' problem
-- http://rosettacode.org/wiki/100_doors
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)
___ ___ ___ ___ ___
/\ \ /\ \ /\ \ /\__\ /\ \
/::\ \ /::\ \ \:\ \ /::| | \:\ \
/:/\:\ \ /:/\:\ \ \:\ \ /:|:| | \:\ \
/::\~\:\ \ /:/ \:\ \ ___ /::\ \ /:/|:| |__ /::\ \
/:/\:\ \:\__\ /:/__/ \:\__\ /\ /:/\:\__\ /:/ |:| /\__\ /:/\:\__\
\/__\:\/:/ / \:\ \ /:/ / \:\/:/ \/__/ \/__|:|/:/ / /:/ \/__/
\::/ / \:\ /:/ / \::/__/ |:/:/ / /:/ /
\/__/ \:\/:/ / \:\ \ |::/ / \/__/
\::/ / \:\__\ /:/ /
\/__/ \/__/ \/__/
___ ___ ___ ___
/\__\ /\ \ /\ \ /\ \ Pointless (0.1.0)
/:/ / /::\ \ /::\ \ /::\ \
/:/ / /:/\:\ \ /:/\ \ \ /:/\ \ \ A scripting language
/:/ / /::\~\:\ \ _\:\~\ \ \ _\:\~\ \ \ for learning and fun
/:/__/ /:/\:\ \:\__\ /\ \:\ \ \__\ /\ \:\ \ \__\
\:\ \ \:\~\:\ \/__/ \:\ \:\ \/__/ \:\ \:\ \/__/ copyright (c) 2020
\:\ \ \:\ \:\__\ \:\ \:\__\ \:\ \:\__\
\:\ \ \:\ \/__/ \:\/:/ / \:\/:/ / Avery N. Nortonsmith
\:\__\ \:\__\ \::/ / \::/ /
\/__/ \/__/ \/__/ \/__/ https://plts.dev
----------
- Enter code in the editor on the left
- Output is displayed here on the right
- (imports and user input disabled are, everything else should work, *albeit slowly*)
----------