Tugger the SLUGger!SLUG Mailing List Archives

[befunge] Re: [coders] RubySIG Lesson Code


This one time, at band camp, Mark Sargent wrote:
>Sridhar and Mark's solution.
>
>#!/usr/bin/ruby
>
>amount = ARGV[0].to_f
>
>remainder = amount % 5
>base_amount = amount - remainder
>
>if (remainder> 2)
>       x = 5
>else
>       x = 0
>end
>
>puts (base_amount + x)

befunge:

vARGV       5
[201g5%01g-`|
            0 
            >.@

Things to note:
1. I dunno how to parse ARGV in befunge so I faked it and instead you should
insert the value on the A of ARGV ;-)
1. I'm not parsing a float value, only an int, and only in the range 0-9, so
it's pretty useless ;-)
1. I haven't tested this either ;-)

And now for the Whitespace version:






(not really)