On 6/4/07, Ball, Donald A Jr (Library) <donald.ball / nashville.gov> wrote:
> I'll add my solutions to the thundering horde. My first solution was
> moderately clever:
>
> puts
> (1..100).map{|n|[[3,'fizz'],[5,'buzz']].inject(n){|s,a|s.is_a?(Fixnum)?s
> =a[1]:s+=a[1] if n%a[0]==0;s}}
>
> then I tried to use as few characters as possible:
>
> puts (1..100).map{|n|n%15==0?:fizzbuzz:n%5==0?:buzz:n%3==0?:fizz:n}
> puts (1..100).map{|n|n%15>0?n%5>0?n%3>0?n:'fizz':'buzz':'fizzbuzz'}
>
> - donald
>
>
That takes care of inject, what a great response time Donald ;)!
Robert