Skip to main content
added 21 characters in body
Source Link

Whispers, 35 bytes / 3 versions = 11.66

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Try it online! (Whispers v1)

Try it online! (Whispers v2)

Unfortunately, Whispers v3 isn't currently on TIO, so you'll have to download it from the repo to try it.

How they work

This relies on the feature in Whispers which removes lines that contain (among other things) invalid instructions from the code before numbering the lines for execution.

All three programs work by calling line 3 and outputting the number on that line. However, by removing lines that contain invalid instructions, we change which line line 3 actually is. As they all just output line 3's result, I'll focus the explanations on which line is line 3 and why.

v1

In version 1, neither of the first two lines are valid instructions. Therefore, the code passes to the executor is

> 3
> 2
> 1
>> Output 3

and line 3 simply returns \$1\$

v2

In version 2, the first line >> R2 is now a valid instruction: it takes a vector and outputs its polar form (i.e. magnitude and angle). However, the second line >> -1 is not yet valid, so the interpreter sees

>> R2
> 3
> 2
> 1
>> Output 3

The first line shifts line 3 to refer to > 2, which just returns \$2\$.

v3

The entire program is valid in the latest version Whispers, which includes a massive expansion of builtins, but the shortest new addition is the negate command: >> -1, which does not return \$-1\$, rather it takes in an argument and negates in. Therefore, the interpreter sees

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Meaning that line 3 is now > 3, which, you guessed it, returns \$3\$.

Whispers, 35 bytes

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Try it online! (Whispers v1)

Try it online! (Whispers v2)

Unfortunately, Whispers v3 isn't currently on TIO, so you'll have to download it from the repo to try it.

How they work

This relies on the feature in Whispers which removes lines that contain (among other things) invalid instructions from the code before numbering the lines for execution.

All three programs work by calling line 3 and outputting the number on that line. However, by removing lines that contain invalid instructions, we change which line line 3 actually is. As they all just output line 3's result, I'll focus the explanations on which line is line 3 and why.

v1

In version 1, neither of the first two lines are valid instructions. Therefore, the code passes to the executor is

> 3
> 2
> 1
>> Output 3

and line 3 simply returns \$1\$

v2

In version 2, the first line >> R2 is now a valid instruction: it takes a vector and outputs its polar form (i.e. magnitude and angle). However, the second line >> -1 is not yet valid, so the interpreter sees

>> R2
> 3
> 2
> 1
>> Output 3

The first line shifts line 3 to refer to > 2, which just returns \$2\$.

v3

The entire program is valid in the latest version Whispers, which includes a massive expansion of builtins, but the shortest new addition is the negate command: >> -1, which does not return \$-1\$, rather it takes in an argument and negates in. Therefore, the interpreter sees

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Meaning that line 3 is now > 3, which, you guessed it, returns \$3\$.

Whispers, 35 bytes / 3 versions = 11.66

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Try it online! (Whispers v1)

Try it online! (Whispers v2)

Unfortunately, Whispers v3 isn't currently on TIO, so you'll have to download it from the repo to try it.

How they work

This relies on the feature in Whispers which removes lines that contain (among other things) invalid instructions from the code before numbering the lines for execution.

All three programs work by calling line 3 and outputting the number on that line. However, by removing lines that contain invalid instructions, we change which line line 3 actually is. As they all just output line 3's result, I'll focus the explanations on which line is line 3 and why.

v1

In version 1, neither of the first two lines are valid instructions. Therefore, the code passes to the executor is

> 3
> 2
> 1
>> Output 3

and line 3 simply returns \$1\$

v2

In version 2, the first line >> R2 is now a valid instruction: it takes a vector and outputs its polar form (i.e. magnitude and angle). However, the second line >> -1 is not yet valid, so the interpreter sees

>> R2
> 3
> 2
> 1
>> Output 3

The first line shifts line 3 to refer to > 2, which just returns \$2\$.

v3

The entire program is valid in the latest version Whispers, which includes a massive expansion of builtins, but the shortest new addition is the negate command: >> -1, which does not return \$-1\$, rather it takes in an argument and negates in. Therefore, the interpreter sees

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Meaning that line 3 is now > 3, which, you guessed it, returns \$3\$.

Source Link

Whispers, 35 bytes

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Try it online! (Whispers v1)

Try it online! (Whispers v2)

Unfortunately, Whispers v3 isn't currently on TIO, so you'll have to download it from the repo to try it.

How they work

This relies on the feature in Whispers which removes lines that contain (among other things) invalid instructions from the code before numbering the lines for execution.

All three programs work by calling line 3 and outputting the number on that line. However, by removing lines that contain invalid instructions, we change which line line 3 actually is. As they all just output line 3's result, I'll focus the explanations on which line is line 3 and why.

v1

In version 1, neither of the first two lines are valid instructions. Therefore, the code passes to the executor is

> 3
> 2
> 1
>> Output 3

and line 3 simply returns \$1\$

v2

In version 2, the first line >> R2 is now a valid instruction: it takes a vector and outputs its polar form (i.e. magnitude and angle). However, the second line >> -1 is not yet valid, so the interpreter sees

>> R2
> 3
> 2
> 1
>> Output 3

The first line shifts line 3 to refer to > 2, which just returns \$2\$.

v3

The entire program is valid in the latest version Whispers, which includes a massive expansion of builtins, but the shortest new addition is the negate command: >> -1, which does not return \$-1\$, rather it takes in an argument and negates in. Therefore, the interpreter sees

>> R2
>> -1
> 3
> 2
> 1
>> Output 3

Meaning that line 3 is now > 3, which, you guessed it, returns \$3\$.