Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

(removed note on 5-byte solutions because there's actually a ton of them that print all sorts of numbers)
Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998

Wumpus, 4 bytes

" O@

Try it online!

" O@" O@

Try it online!

The normal code prints 32 and the doubled one prints 64.

Explanation

" works like it does in many other Fungeoids: it toggles string mode, where each individual character code is pushed to the stack, instead of executing the command. However, in contrast to most other Fungeoids, Wumpus's playfield doesn't wrap around, so the IP will instead reflect off the end and bounce back and forth through the code.

So for the single program, the following code is actually executed:

" O@O " O@

The string pushes 32, 79, 64, 79, 32. Then the space does nothing, the O prints 32, and the @ terminates the program.

For the doubled program, the string is instead terminated before the IP bounces back, so the code is only traversed once:

" O@" O@

This time, the string pushes 32, 79, 64, the O prints the 64 and the @ terminates the program.

This appears to be the only 4-byte solution. There are several 5-byte solutions, most of which are essentially the same, but there's one that prints 1 and 2 instead:

":O@ 

(Note that there's a trailing space.) : is integer division, so in the single program this computes 79 / 58, which is 1, but in the double program it computes 64 / 32, which is 2.

Wumpus, 4 bytes

" O@

Try it online!

" O@" O@

Try it online!

The normal code prints 32 and the doubled one prints 64.

Explanation

" works like it does in many other Fungeoids: it toggles string mode, where each individual character code is pushed to the stack, instead of executing the command. However, in contrast to most other Fungeoids, Wumpus's playfield doesn't wrap around, so the IP will instead reflect off the end and bounce back and forth through the code.

So for the single program, the following code is actually executed:

" O@O " O@

The string pushes 32, 79, 64, 79, 32. Then the space does nothing, the O prints 32, and the @ terminates the program.

For the doubled program, the string is instead terminated before the IP bounces back, so the code is only traversed once:

" O@" O@

This time, the string pushes 32, 79, 64, the O prints the 64 and the @ terminates the program.

This appears to be the only 4-byte solution. There are several 5-byte solutions, most of which are essentially the same, but there's one that prints 1 and 2 instead:

":O@ 

(Note that there's a trailing space.) : is integer division, so in the single program this computes 79 / 58, which is 1, but in the double program it computes 64 / 32, which is 2.

Wumpus, 4 bytes

" O@

Try it online!

" O@" O@

Try it online!

The normal code prints 32 and the doubled one prints 64.

Explanation

" works like it does in many other Fungeoids: it toggles string mode, where each individual character code is pushed to the stack, instead of executing the command. However, in contrast to most other Fungeoids, Wumpus's playfield doesn't wrap around, so the IP will instead reflect off the end and bounce back and forth through the code.

So for the single program, the following code is actually executed:

" O@O " O@

The string pushes 32, 79, 64, 79, 32. Then the space does nothing, the O prints 32, and the @ terminates the program.

For the doubled program, the string is instead terminated before the IP bounces back, so the code is only traversed once:

" O@" O@

This time, the string pushes 32, 79, 64, the O prints the 64 and the @ terminates the program.

This appears to be the only 4-byte solution.

Source Link
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998

Wumpus, 4 bytes

" O@

Try it online!

" O@" O@

Try it online!

The normal code prints 32 and the doubled one prints 64.

Explanation

" works like it does in many other Fungeoids: it toggles string mode, where each individual character code is pushed to the stack, instead of executing the command. However, in contrast to most other Fungeoids, Wumpus's playfield doesn't wrap around, so the IP will instead reflect off the end and bounce back and forth through the code.

So for the single program, the following code is actually executed:

" O@O " O@

The string pushes 32, 79, 64, 79, 32. Then the space does nothing, the O prints 32, and the @ terminates the program.

For the doubled program, the string is instead terminated before the IP bounces back, so the code is only traversed once:

" O@" O@

This time, the string pushes 32, 79, 64, the O prints the 64 and the @ terminates the program.

This appears to be the only 4-byte solution. There are several 5-byte solutions, most of which are essentially the same, but there's one that prints 1 and 2 instead:

":O@ 

(Note that there's a trailing space.) : is integer division, so in the single program this computes 79 / 58, which is 1, but in the double program it computes 64 / 32, which is 2.

AltStyle によって変換されたページ (->オリジナル) /