shortest progam to scan a line and print it using befunge!

2

well, I'm newly introduced to befunge. it seems to be an amazing language but a bit hard to start with! anyway after about 2 hours of hard work I've created a code which could read a line from stdin and write same line into stdout(I'm using line -1 as buffer in this code):

0> :~:a-#v_$$v vg-10:-1< >$>:#,_@
 ^+1p-10\<   >0>\:    #^_^

since I'm new to this language I wanted to know if there is a shorter code to do such a thing. I'm currently using Rc/funge-98 v2 interpreter. note that none-trailing whitespaces are counted in your code.

Ali1S232

Posted 2012-03-19T09:41:57.070

Reputation: 417

Answers

1

since it seems no one could create 7 character program, here is what I did. it works at least with befunge!

Befunge, 7

~:,a`j@

Ali1S232

Posted 2012-03-19T09:41:57.070

Reputation: 417

@ajax333221 here is my code. – Ali1S232 – 2012-03-21T14:13:49.527

but this does not output the newline. – marinus – 2012-03-24T21:40:08.693

@marinus that's no big deal, just putting "," at the third character will solve that! the whole idea is to use "j" instead of "!#@_" – Ali1S232 – 2012-03-24T23:20:41.517

6

Befunge-98, 4

~,#@

Try it online!

It works because ~ acts like r when there is no more input (credit to David Holderness for finding this in the funge-98 spec)

Brian Gradin

Posted 2012-03-19T09:41:57.070

Reputation: 569

2

Befunge, 10

~:,a`!#@_

You were thinking a bit too hard about it I think :)

marinus

Posted 2012-03-19T09:41:57.070

Reputation: 30 224

now I see what you did there, it seems to be complete answer. I was going to later use input string to parse as a "single precision floating point", which seems to be not possible using your method. – Ali1S232 – 2012-03-19T11:15:27.827

the only reason I'm not accepting your answer is because I know an answer of 7 characters. – Ali1S232 – 2012-03-20T13:52:29.167

@Gajet you should post it

– ajax333221 – 2012-03-20T16:02:26.860

@ajax333221 I want to give other people opportunity to get 15 rep. – Ali1S232 – 2012-03-20T17:43:37.953