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 Revisions

2 of 2
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/

Befunge, 15 bytes, James Holderness

<:0:+1_@#%9,:g-

Try it online!

Explanation

The catch here is that the loop terminates when the current character is divisible by 9, which is only the case for -. Hence, that needs to go at the end.

< Run code from right to left.
 - There will always be 2 zeros on top of the stack at this
 point, and this just reduces them to 1 zero.
 g Get the character at the coordinates given by the top
 two stack values, (0, 0) initially.
 ,: Print a copy of that character.
 %9 Modulo 9.
 _@# Terminate if that is 0.
 +1 Increment the x coordinate.
 : Duplicate it.
 :0 Push two zeros.
Martin Ender
  • 198.2k
  • 67
  • 455
  • 998

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