100 doors: Difference between revisions

→‎{{header|Euler}}: Use Mediawiki markup for syntax highlighting
(→‎{{header|ALGOL 60}}: Syntax highlight with Mediawiki markup)
(→‎{{header|Euler}}: Use Mediawiki markup for syntax highlighting)
Line 5,389:
=={{header|Euler}}==
In Euler, all variables have the value <code>undefined</code> until assigned another value. <code>isu x</code> returns <code>true</code> if x is currently undefined and the and/or operators short-circuit.
'''begin''' '''new''' doors; '''new''' i; '''label''' doorLoop; '''label''' outDoors;
<syntaxhighlight lang="euler">
begin new doors; new i; label doorLoop doors &lt;- label'''list''' outDoors100;
doors <-i list 100 &lt;- 0;
doorLoop: '''if''' [ i <&lt;- i + 1 ] <&lt;= '''length''' doors '''then''' '''begin'''
i <- 0;
'''new''' j; '''label''' flipLoop;
doorLoop: if [ i <- i + 1 ] <= length doors then begin
new j; label flipLoop&lt;- 0;
flipLoop: '''if''' [ j &lt;- J + i ] &lt;= '''length''' doors '''then''' '''begin'''
j <- 0;
flipLoop: if doors[ j <] &lt;- J'''isu''' +doors[ ij ] <='''or''' length'''not''' doors[ thenj begin];
doors[ j'''goto''' ] <- isu doors[ j ] or not doors[ j ];flipLoop
'''end''' '''else''' goto flipLoop0;
end else'''goto''' 0;doorLoop
'''end''' '''else''' goto doorLoop0;
end elsei &lt;- 0;
outDoors: '''if''' [ i &lt;- i + 1 ] &lt;= '''length''' doors '''then''' '''begin'''
i <- 0;
outDoors: if [ i <- i + 1 ] <= length '''if''' doors[ i ] '''then''' '''out''' i '''else''' begin0;
if doors['''goto''' i ] then out i else 0;outDoors
'''end''' '''else''' goto outDoors0
'''end''' $
end else 0
end $
</syntaxhighlight>
 
=={{header|Euler Math Toolbox}}==
3,025

edits