Page 1 of 2
String Reversal
Posted: Mon Dec 29, 2008 7:10 am
by tog
Yeah, we crossed the river! (Though that straight alley from King Rat looks a bit unnatural.

)
Posted: Mon Dec 29, 2008 7:54 am
by adum
Posted: Mon Dec 29, 2008 6:18 pm
by MerickOWA
That was interesting. I miss the ability to drop off the top of item in the stack.
Posted: Mon Dec 29, 2008 6:21 pm
by adum
you still have that ability, in disguise...
Posted: Mon Dec 29, 2008 8:42 pm
by therethinker
I'm pretty excited for this new system/language. Befunge always had a certain charm to it...
I like the shortcuts that were added... , is great. I also liked how it automatically null-terminated the input.
Are g and w for modifying the code? I'm assuming they deal w/ ASCII values?
Threads: do they terminate with ! as well, or will that terminate the entire program?
Posted: Mon Dec 29, 2008 9:06 pm
by gfoot
Judging by the third example program, ! terminates the whole program - it uses a timing construct to allow the second thread to run a certain number of cycles before ending the program.
This is fun to work with, although there are some oddities. You could do more with the 2Dness, e.g. all branches should have a built-in direction change, and : could automatically send program execution either left, right, or straight ahead, depending on its result. It would be more compact that way.
@ could have been "rotate" (right->up, up->left, etc), and that would have been useful.
I find the use of "s" before loops a bit inelegant.
Posted: Mon Dec 29, 2008 9:15 pm
by therethinker
Rather than change @ and :, there could possibly be more additions? O and #, per-se?
And although s before loops does seem a bit redundant, think of it as an unconditional ?. This language looks like it can handle loops much much easier.
Posted: Mon Dec 29, 2008 10:56 pm
by ShardFire
Nah, # looks like a grate, and when it is executed the PC falls into the memory table and starts executing that instead! You can just make up anything...
Posted: Mon Dec 29, 2008 11:10 pm
by adum
as you say, befunge was one of the inspirations, along with SNUSP, and of course HVM. the code can be self-modifying, yes.
i thought about having thread terminators, but wasn't sure there was a need. threads can always loop themselves. if someone makes a strong case for this i can add it.
gfoot, i like your ideas. i think i'm going to change the : operator. rotate is a neat idea but i'm not sure it adds that much.
Posted: Mon Jan 12, 2009 4:56 pm
by tails
Sorry for refering to an old topic.
adum wrote:i thought about having thread terminators, but wasn't sure there was a need. threads can always loop themselves. if someone makes a strong case for this i can add it.
I think we must not have thread terminators. If we had one, we would always have to consider making a thread everywhere in the code.
For example, when we want to add 1 to the current value in a code, we usually just write like this:
But if we had a thread terminator (#), we would consider writing like this, because it will save 1 cycle:
Posted: Mon Jan 12, 2009 7:40 pm
by adum
hmmn, interesting point. of course, it's slightly non-trivial, because the main thread will have to sit waiting for the add to complete before messing with the stack. but i think you're right in general.
Posted: Sat Jan 02, 2010 4:48 am
by Schubert
Hey,
Just wanted to show off my amazing code...
Code: Select all
777**s/,x?\+ s/Px777**-?\!
\ / \ /
Lol, thank god they didn't input 343...
I'm curious to see how others did it the actual proper way, 'cause I'm not sure how...
Posted: Sat Jan 02, 2010 12:58 pm
by teebee
The strings are zero terminated. So, 0 can be used instead of 343. Moreover, the two loops can be joined into one to shorten the code.
Posted: Tue Jan 05, 2010 4:13 pm
by teebee
One-liners are often the key to shorter solutions. The following program of size 21 passes all the test cases:
Posted: Tue Sep 06, 2011 4:40 pm
by AMindForeverVoyaging
My solution:
Code: Select all
%0s/,0^\
0
\ :!
\? s/0^\
0
\ P:!
!
Not the best - but it passed
