From: P.L.Hayes on
Thomas Bakketun <thomas-news-2006(a)bakketun.net> writes:

> Richard M Kreuter wrote:
>
>> Here's one that avoids the explicit FizzBuzz, and adds /seven/
>> squiggles to my first stab:
>>
>> (dotimes (i 100)
>> (format t "~[~[~3@*~A~A~:;~3@*~A~]~:;~[~4@*~A~:;~D~]~]~%"
>> (mod i 3) (mod i 5) i "Fizz" "Buzz"))
>>
>> Better?
>
> Is this the shortest version possible?
>
> (defun fizz-buzz ()
> (loop for i from 1 to 100 do
> (format t "~&~[Fizz~]~[Buzz~:;~0@*~[~:;~*~A~]~]"
> (mod i 3) (mod i 5) i)))


I think it would be if if it wasn't for the loop. When I had a go at
this at http://golf.shinh.org/p.rb?FizzBuzz the only way I could find
to get it down to the 90 characters others had managed was this:

(dotimes (i 101)
(format t "~[~:;~&~[Fizz~[Buzz~]~:;~[Buzz~:;~A~]~]~]"
i (mod i 3) (mod i 5) i))

[If you remove all unnecessary whitespace, it's 90 bytes long]

Cheers,
Paul.
From: Vassil Nikolov on

On 1 Mar 2007 12:06:24 -0800, "Pillsy" <pillsbury(a)gmail.com> said:
|| On Mar 1, 12:14 am, Vassil Nikolov <vnikolov+use...(a)pobox.com> wrote:
||
|| > On 28 Feb 2007 12:01:22 -0800, "Pillsy" <pillsb...(a)gmail.com> said:
|| > | ...
|| > | (apply #'format t "~@{ ~2@{~D ~}~^~*Fizz ~D ~*Buzz~
|| > | ~*Fizz ~2@{~D ~} ~*Buzz ~D ~*Fizz~
|| > | ~2@{~D ~} ~*FizzBuzz ~%~}"
|| > | (loop
|| > | :for i :from 1 to 100
|| > | :collect i))
|| > But you want it to work for arbitrarily large values of 100...
||
|| Good point!
||
|| (setf (symbol-value '|100|) 100)

Er, I was objecting to the use of APPLY (see also CALL-ARGUMENTS-LIMIT).

---Vassil.


--
mind mate, n.
One of two persons mentally compatible with each other (cf. soul mate).
From: Luke J Crook on
Frank Buss wrote:
> The code below creates buttons like this:
>
> http://www.frank-buss.de/tmp/buttons.png
>
> In LispWorks 4.3.7 it is not very fast, but SBCL needs not many seconds :-)
>

You know there is this little-known package called lispbuilder-sdl that
can also be used for the back-end rendering. ;)

- Luke
From: Brian Adkins on
P.L.Hayes wrote:
> I think it would be if if it wasn't for the loop. When I had a go at
> this at http://golf.shinh.org/p.rb?FizzBuzz the only way I could find
> to get it down to the 90 characters others had managed was this:

I'm extremely upset with you for posting that golf url! :)

I just wasted way too much time trying to squeeze my Ruby version down
and can't get below 71 bytes. I'd love to know how the top guy did it in
56. Sorry for being off topic with Ruby, but my Lisp chops aren't up to
the challenge yet:

1.upto(100){|i|puts"FizzBuzz#{i}"[i%3==0?0: i%5==0?4: 8,i%15==0?8: 4]}

I know there's a way to compute the substring indices mathematically
instead of logically, but I haven't found it yet.

> (dotimes (i 101)
> (format t "~[~:;~&~[Fizz~[Buzz~]~:;~[Buzz~:;~A~]~]~]"
> i (mod i 3) (mod i 5) i))
>
> [If you remove all unnecessary whitespace, it's 90 bytes long]
>
> Cheers,
> Paul.
From: Brian Adkins on
Brian Adkins wrote:
> P.L.Hayes wrote:
>> I think it would be if if it wasn't for the loop. When I had a go at
>> this at http://golf.shinh.org/p.rb?FizzBuzz the only way I could find
>> to get it down to the 90 characters others had managed was this:
>
> I'm extremely upset with you for posting that golf url! :)
>
> I just wasted way too much time trying to squeeze my Ruby version down
> and can't get below 71 bytes. I'd love to know how the top guy did it in
> 56. Sorry for being off topic with Ruby, but my Lisp chops aren't up to
> the challenge yet:
>
> 1.upto(100){|i|puts"FizzBuzz#{i}"[i%3==0?0: i%5==0?4: 8,i%15==0?8: 4]}

Got it down to 65 bytes: http://golf.shinh.org/p.rb?FizzBuzz
Something is definitely wrong when you get a bit of a thrill realizing
you can shave off a few bytes by transforming x==0 to x<1 in a few spots.

1.upto(100){|i|puts"FizzBuzz#{i}"[i%3<1?0:i%5<1?4:8,i%15<1?8:4]}

> I know there's a way to compute the substring indices mathematically
> instead of logically, but I haven't found it yet.
>
>> (dotimes (i 101)
>> (format t "~[~:;~&~[Fizz~[Buzz~]~:;~[Buzz~:;~A~]~]~]"
>> i (mod i 3) (mod i 5) i))
>>
>> [If you remove all unnecessary whitespace, it's 90 bytes long]
>>
>> Cheers,
>> Paul.