Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(4 edits)

Definitely put something at the level for INTERCAL that the .5 variable should be interpreted in your way. Otherwise there is no way to know.

Regarding Whenever you need to explain how the read() should be interpreted and please make a comma, so the syntax is correct.

Also it would need to be stated how to interpret the order of execution, since Whenever does not guarantee the order. Otherwise the sequence could as well start with "D E" or "F". For what it is worth the complete sequence could even be "F A B". Though with defining the order it would take all the fun of Whenever.

(That's the main reason I really dislike this level. I doesn't give you a fair chance.)

Also, regardless of the start, the way it is now your code will end up in an endless loop with line 6 being executed forever. (Line 3 actually has chance to be completely removed from the todo list.) So none of the solutions is correct for end is never reached. This can be easily fixed the same way as it is done for line 3.

I guess you will have to come up with some other code to make this work.

Are you overlooking the effect of "defer"? AFAICT in your screenshot execution order is deterministic up to conditions, and the program terminates successfully (i.e. with empty "to-do list").

Anyway the hints are now available in-game, and I've also placed print() statements on separate lines (the spec, while being somewhat loose, doesn't allow both print() and lines specifications on the same line).

"... A Whenever program is executed by a language interpreter ... . It takes the program code and treats each line as an item in a to-do list. The interpreter chooses an item from the list at random, with equal probability, to execute, and executes the statement. ..."

https://www.dangermouse.net/esoteric/whenever.html

Heh, the practice of reading language specs selectively. You're in good company, that has failed me more than once...

Am I missing something?

"... [Whenever] takes the program code and treats each line as an item in a to-do list. The interpreter chooses an item from the list at random, with equal probability, to execute, and executes the statement. ... When the interpreter is finished with a statement, it chooses another at random from the to-do list. ..."

This would mean the following could happen

1) all lines are placed on the todo list [1,2,3,4,5,6,7,8]

2) pick line 7 -> tests as false -> print "F", add line 2 on todo list, make sure line 4 is only once on todo list, add line 5 to todo list, remove line 7 from todo list [1,2,2,3,4,5,5,6,8]

3) pick line 2 -> tests as false -> print "A B", remove or make sure line 3 is only once on todo list (assume read is 0 to remove line 3 from todo list), make sure line 7 is only once on todo list [1,2,4,5,5,6,7,8]

4) pick line 1 -> print "statues" [2,4,5,5,6,7,8]

5) pick line 2 -> print "A B", remove or make sure line 3 is only once on todo list (assume read is 0 to remove line 3 from todo list), make sure line 7 is only once on todo list [4,5,5,6,7,8]

6) pick line 4 -> print "C" [5,5,6,7,8]

7) pick line 5 -> print "D E", assume read is 1 [5,6,7,8]

7) pick line 5 -> print "D E", assume read is 1 [6,7,8]

8) pick line 8 -> print "G" [6]

9) pick line 6 [6] ... endless loop

Output was "F A B A B C D E D E G"

Line 7 can't be the first to execute because its defer expression initially evaluates to true.

The longer version:

  • "In some cases, the statement will contain a clause that specifies that it cannot be executed until certain conditions apply. This results in the statement being deferred and placed back on the to-do list."
  • "The defer statement takes a boolean argument. If the argument is true, the statement is deferred - i.e. the remainder of the statement is not executed and the line number of the defer statement remains on the to-do list."
  • "The following standard [...] boolean operators work as expected: [...] &&, ||, !."
  • "An integer used in a boolean context evaluates to false if the line of that number is not currently on the to-do list and to true if it is on the to-do list at least once."

The initial to-do list includes all lines so all defer expressions evaluate to true:

  • Line 2: (T && T) --> T
  • Lines 4 and 8: (T || T) --> T
  • Line 5: ((T || !T) && T) --> T
  • Line 7: (T || !T) --> T

Therefore, the executable lines are {1,3,6}. Executing lines 3 and 6 any number of times doesn't modify the to-do list, so they can be ignored (except for determining halting). "Eventually", line 1 will be picked, executed and removed from the to-do list.

Once that is done, the defer exression of line 2 will be the only one that evaluates to false:

  • (1 && 7) --> F && T --> F

Therefore, the executable lines will be {2,3,6}, line 2 will ultimately get picked, and "A B" will be printed.

Then, depending on whether read() returns 1 or 0, we'll have a to-do list of either [3,4,5,6,7,8] or [4,5,6,7,8], the executable lines will be either {3,5,6} or {4,6}, and either "D E" or "C" will get printed (all respectively). And so on...