Inspired by the first example I solved it with
0,s/x?\?/x?\!
___\,=/ \P=/
String Reversal
The "memory pointers" description is not quite clear.
Would be nice to have real VM source available.
The http://www.hacker.org/sh/shphp.phps gives 404 here:
Thanks!
Would be nice to have real VM source available.
The http://www.hacker.org/sh/shphp.phps gives 404 here:
Code: Select all
Not Found
The requested URL /sh/shphp.phps was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
I posted it to pastebin. Get it here: http://pastebin.com/AyEQ8xid
String Reversal
Even smaller and without restrictions:teebee wrote:One-liners are often the key to shorter solutions. The following program of size 21 passes all the test cases:
Code: Select all
0@@@@@@@@=,x?$+x?s!P$
Code: Select all
!:^1=/?@\
$P/%0s\,x/
At first I looked at the SHVM documentation and instantly hated all of it. Put it away for a few years.
Now, that I tried it, it's kinda fun. Definitely more than the HVM.
I took a pretty straight forward approach to this one. But looking at the other solutions, I'm already learning.
* first loop reads stuff (and copies it for comparison)
* then it increases the counter (if stuff != 0)
* if it was, double jump (clear stack top) into second loop
* second loop decreases counter (jump to ! if 0) and prints
/%____,x?\?/_20<x?\!
\>02+1<02/_\P>02-1/
I can see the beauty of the other zero-termination solutions because they don't need a counter.
The deal with @ in the loop to reset is also quite nice.
Now, that I tried it, it's kinda fun. Definitely more than the HVM.
I took a pretty straight forward approach to this one. But looking at the other solutions, I'm already learning.
* first loop reads stuff (and copies it for comparison)
* then it increases the counter (if stuff != 0)
* if it was, double jump (clear stack top) into second loop
* second loop decreases counter (jump to ! if 0) and prints
/%____,x?\?/_20<x?\!
\>02+1<02/_\P>02-1/
I can see the beauty of the other zero-termination solutions because they don't need a counter.
The deal with @ in the loop to reset is also quite nice.