You are presented with an infinite number of clocks, each featuring a dial that displays positions from 0 to 59. Each clock is equipped with a button on top that, when pressed, advances the clock by one increment. If the dial transitions from 59 back to 0, a bell within the clock will sound once.
The dials of these clocks are concealed, allowing interaction only through the button and the audible bell. A special instruction allows reading the positions of the dials to read out the result of computations.
An instruction sheet provides sequences in which the clocks should be manipulated. The following operations can be performed:
TICK <#clock>
Press button on the clock identified by#clock
once.GO <label> ON PING
If the preceding command triggered a ping sound, navigate to the line labeled<label>
.GO <label> ON SILENCE
If the preceding command did not trigger a ping sound (i.e., it was silent), navigate to the line labeled<label>
.REVEAL
Reveal the current positions of all clock dials.
labels are unique strings and are designated by the label followed by a colon in an empty line. For example, label:
.
Advance the dial 1 by one increment
TICK 1
Set dial to zero
We can set a dial to zero by advancing it until it pings.
loop1:
TICK 1
GO loop1 ON SILENCE
copy inverted dial 1 to dial 2, destroys content of dial 1
loop1:
TICK 2
GO loop1 ON SILENCE
loop2:
TICK 2
TICK 1
GO loop1 ON SILENCE
Copy dial 1 to dial 2, using dial 3 as a temporary register
First, we'll set dials 2 and 3 to zero:
loop1:
TICK 2
GO loop1 ON SILENCE
loop2:
TICK 3
GO loop2 ON SILENCE
loop3:
TICK 3
TICK 1
GO loop3 ON SILENCE
loop4:
TICK 2
TICK 3
GO loop4 ON SILENCE
Instead of advancing a dial, the TICK
instruction can also be used on another TICK
instruction to advanced the clock number it is pointing to. This allows for self-modifying code and can be used to implement a pointer.
Example:
TICK pointer
pointer:
TICK 1 ; will be increased to 2
REVEAL
The first TICK instruction advances the pointer of the next instruction. Therefore, instead of increasing the dial 1, it will increase the dial of clock 1 + 1 = 2
Some relation to Smallfuck. Consider that the pointer is replaced with a direct declaration of cell addresses or a pointer based on self-modifying code.
A compact language for the same architecture, called 'K'
The compact language is a more concise way to write instructions for the clock dials.
#
once. Numbers are be separated by spaces.Instead of clock numbers, also variables can be defined. Variables are strings of letters. They are defined by
<variable> = <#>
. For example,a = 1
defines variablea
as clock 1. Variables can be used in place of clock numbers in the compact language.It is also possible to define macros. Macros are defined by
@macro(a,b,c) = { }
wherea
,b
, andc
are the arguments of the macro. Macros can use labels in place of clock numbers. Example:@macro(a,b,c)
Examples
Advance the dial 1 by one increment
Set dial 1 to zero
We can set a dial to zero by advancing it until it pings.
Copy inverted dial 1 to dial 2, destroys content of dial 1
Copy dial 1 to dial 2, using dial 3 as a temporary register
Define a variable and use it
Clear dial 1 declaring it as variable
dial1
.Define a macro and use it
Define a macro that clears a dial and use it to clear dial 1.
Define a macro that copies the content of dial a to dial b, using dial
tmp
as a temporary register. The content of a is retainedDefine a macro that adds the content of dial a to dial b, using dial
tmp
as a temporary register.