> 8
> 8
> 8
> 8
> 9
> 6
> Input
>> 5-6
>> 5-55
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 8
> 7
>> 9+9
>> 9*7
>> 55-56
>> 57⋅58
> 8
> 8
> 8
> 8
> 8
>> 58+55
>> 59+56
>> 66÷65
>> Output 67
Try it online!
Let me outline the problem with using Whispers:
Whispers is a single-expression, line-based programming language. Each line consists of a single mathematical expression. However, if the line starts with >>
, the numbers used have different values to what they would normally express.
When a line begins with >
(such as > 8
) the value returned is the number shown, so that example would return 8
when referenced. Input
returns an evaluated line from STDIN.
However, when the line starts with >>
, such as >> 5-6
, the numbers are interpreted as line references, i.e. the above line would call line 5
, then line 6
, then subtract the results.
Let's create a program that half-sticks to the rules first. This program doesn't use 0
, 1
, 2
, 3
, or 4
to represent those numbers, but does use them as line references. This 'half' solution is 96 bytes:
> 6
> 9
> Input
>> 2-1
>> 1=1
>> 4-5
>> 6*3
>> 7⋅4
>> 6+6
>> 8+9
>> 2+5
>> 10÷11
>> Output 12
Try it online!
Unfortunately, the challenge disallows the characters 0
, 1
, 2
, 3
, and 4
from appearing in the program, irregardless of what they represent. So, to work around this, we have to use line references with only the numbers 5
, 6
, 7
, 8
and 9
in their digits. This has the consequence that we cannot use any lines between 10
and 54
, which is what the massive chain of > 8
are. In fact, all lines that represent a forbidden line reference has > 8
, just for consistency.
So, let's remove those lines, but pretend they're still there, we just can't see them:
> 9
> 6
> Input
>> 5-6
>> 5-55
> 7
>> 9+9
>> 9*7
>> 55-56
>> 57⋅58
>> 58+55
>> 59+56
>> 66÷65
>> Output 67
Which is a very similar structure to the 'half' solution. Here's how this shortened solution works, with an input 11
:
> 9 ; Line 5: Yield 9
> 6 ; Line 6: Yield 6
> Input ; Line 7: Yield a line of input (11)
>> 5-6 ; Line 8: Yield 3 - 9 - 6
>> 5-55 ; Line 9: Yield 2 - 9 - 7
⋮
> 7 ; Line 55: Yield 7
>> 9+9 ; Line 56: Yield 4 - 2 + 2
>> 9*7 ; Line 57: Yield 2048 - 2 ^ 11
>> 55-56 ; Line 58: Yield 3 - 7 - 4
>> 57⋅58 ; Line 59: Yield 6144 - 2048 ⋅ 3
⋮
>> 58+55 ; Line 65: Yield 10 - 3 + 7
>> 59+56 ; Line 66: Yield 6148 - 6144 + 4
>> 66÷65 ; Line 67: Yield 614.8 - 6148 ÷ 10
>> Output 67 ; Line 68: Output 614.8