Colon implementation in SH

Post Reply
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Colon implementation in SH

Post by laz0r »

I think something's wrong: when I do
CODE:
code here%54:

As I understand it, it ought to go left so what is executed is:
% []
5 [5]
4 [5,4]
: []
4 [4]
5 [4,5]
% [4,5]
e [4,5]
d [4,5] etc

What I actually get is it attempting to go up - is it that it turns 90 degrees left then? If so, could that be written into the instructions please?
There is no spoon.
Karian
Posts: 75
Joined: Wed Jan 09, 2008 10:21 am

Post by Karian »

the instructions aren't saying that you will go left, but that you turn left, and this is indeed a turn of 90 degrees. you can see it as a conditional '/' '\' or ' '. It is always relative to the direction you are going.
To be sure what a command is exactly doing, you can always check the php implementation, or experiment with the implementation.
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

Thanks!
There is no spoon.
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

New question (sorry!)

Code: Select all

         \
/ w15*48 /
\!
how will this work - does it put spaces in, line breaks etc, down to (5,1) in the code, or is there just this isolated space sitting at (5,1), surrounded by nothing, not even spaces?
There is no spoon.
Karian
Posts: 75
Joined: Wed Jan 09, 2008 10:21 am

Post by Karian »

I have no clue, and I don't see the use of what you are doing. Why would you want to change a code value that you aren't processing.
If you really want to know, you have ways to find this on yourself. 2 ways spring to mind:
1. You check the implementation of Superhack, and see how it is working. At the same time, you can increase your knowledge about php.
2. Maybe a bit easier, write a program where you try to execute the code value you just inserted, and see how it behaves. For this, I would certainly use the php implementation, if you want to be sure that the result is as expected when you try to use this in a challenge.
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

This is just for the purpose of writing an interpreter - I want it to be able to cover things like this (Delphi will throw an access violation if I try to write somewhere which doesn't exist, but no such violation occurs in the PHP implementation). Thanks for the ideas - I couldn't find the PHP source (stupid given that there is a link at the top of the page :) )
There is no spoon.
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

No-ops in SH

Post by laz0r »

The implementation in PHP takes no-ops as being one cycle; the Javascript implementation just skips them out. Try the third example given:

Code: Select all

9&\0000@\!
  s  /\ @
 /\  || @
 p7  || @
 \/  || |
$====/\=/
The PHP one includes all the '=', '|' etc, while the JS one does not.
There is no spoon.
Karian
Posts: 75
Joined: Wed Jan 09, 2008 10:21 am

Post by Karian »

have you read the note that comes together with the JavaScript implementation?
[NOTE: the JavaScript version is just for casual experimentation on this page, it may not always behave exactly the same as the implementation used to judge the challenge submissions)
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

Yes, I have (I just thought perhaps if a bug was found it might be fixed!)
There is no spoon.
tails
Posts: 191
Joined: Tue Jun 10, 2008 7:51 pm
Location: Tokyo

Post by tails »

The example runs exactly the same way on both PHP and JS to me.
What difference do you have?
What do you mean by "include"?
User avatar
laz0r
Posts: 290
Joined: Thu Feb 04, 2010 4:18 pm
Location: Within the depths of Unix

Post by laz0r »

I'm sorry, I think I must be going bonkers at last - now they run the same. I could have sworn that the JS version just skipped out the no-ops whereas the PHP version included them as an operation (so a thread can be delayed with no-ops in the PHP but not in the JS)
There is no spoon.
Post Reply