Skip to main content
1 of 13
Wheat Wizard
  • 99.6k
  • 21
  • 280
  • 656

Lost, 57 bytes

v<<<<<<<<<<<>>>>>>>>>>>>>
>%?!|"Hello, World v"(1+@
   v

Explanation

Lost is a 2 dimensional language in which the start location and direction are entirely random. As you might imagine it is rather difficult to write deterministic programs in lost. However the language has a couple of design features that allow for deterministic programs to be written.

Here's how this one works:

I'll first give you some information on the operations in Lost that are important here, so you don't have to read the github. I will leave out the more obvious ones.

  • @ exits, but only if the "safety" is off. The safety begins on.

  • % turns the safety on.

  • ? Pops the TOS and jumps if it is non-zero.

  • ! jumps unconditionally.

  • ( pops a value and saves it for later.

Ok now we are read to dive in.

The main code is the following line

"Hello, World v"(1+@

This pushes the string Hello, World v, pops the v with a ( and increments the by one to get a !, and then terminates the program (we assume the safety is off)

However we have to get to this program so we create a line of arrows to catch the randomly moving pointers

v<<<<<<<<<<<<<<<<<<<<<
>%"Hello, World v"(1+@

We also add a % to turn the safety off once we have corralled the programs. We can now see that the v is in the string to redirect ips that start inside the string.

Now the problem is that some of the programs accumulate junk before we catch them, for example if you start on the 1 you might get a 1, or even worse if you start in the string going west you will get %>@+!(. So we add some code to clear the stack. >?!| should do the trick, and if we use the > from earlier we can save a byte.

v<<<<<<<<<<<<<<<<<<<<<<<<
>%?!|"Hello, World v"(1+@

Now there is just one problem. If the program starts on ! going north or south, it will jump the stream back to itself and loop forever. To fix this we add a v below the !.

v<<<<<<<<<<<<<<<<<<<<<<<<
>%?!|"Hello, World v"(1+@
   v

Lastly I reversed some of the upper string. This just makes the program a little faster, doesn't lose me any bytes so why not.

Wheat Wizard
  • 99.6k
  • 21
  • 280
  • 656