Marcos Cruz wrote:
En/Je/On 2010-11-26 17:17, P Witte escribió / skribis / wrote :
The rules are simple -
write out the values 1 to 100 on screen
If the value is divisble by 3 write 'FIZZ' after the number
If the value is divisble by 5 write 'BUZZ' after the number
If the value is divisble by 3 and 5 write 'FIZZBUZZ' after the number
Maybe the shortest thus far? -- calcutations instead of conditional
structures, kind of Forth's style:
1for i=1to 100:print i!"FIZZ"(to 4*not i mod 3);"BUZZ"(to 4*not i mod 5)
(73 bytes including LF).
More alternatives:
1for i=1to 100:print i!"FI"(to 2*not i mod 3);"BU"(to 2*not i mod 5);"ZZ"
(74 bytes including LF).
1deffn m(n):ret 4*not i mod n:enddef:for i=1to 100:print i!"FIZZ"(to
m(3));"BUZZ"(to m(5))
(91 bytes including LF).
1deffn t$(a$,n):ret (a$&"ZZ")(to 4*not i mod n):enddef:for i=1to 100:print
i!t$("FI",3);t$("BU",5)
(99 bytes including LF).
1deffn t$(a$,n):ret a$(to 4*not i mod n):enddef:for i=1to 100:print
i!t$("FIZZ",3);t$("BUZZ",5)
(95 bytes including LF).
A pretty waste of time :-)
Very nice ;o) I'd like to raise your 73 to 72: You dont need the line
number unless you start with a def* (You could remove the lf too, but
then you cant LOAD or DO it. ;o)
Per
_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm