Here is my "boring" solution!

out=: >:i.100
f=: 0=3|out
b=: 0=5|out
t=: (>./"1 f,.(2*b),.(3*f*.b))
ndx=: I.0<t
into=: (<:t-.0) { 'fizz';'buzz';'fizzbuzz'
into ndx } <&>out 

I tried to run yours to see if the output was OK but got a domain error
when I ran pr=:...

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of June Kim
> Sent: Wednesday, 7 March 2007 09:33
> To: Programming forum
> Subject: [Jprogramming] FizzBuzz
> 
> FizzBuzz is a very simple toy problem for screening 
> programming applicants at interviews.
> 
> The problem is:
> 
>     Write a program that prints the numbers from 1 to 100. 
> But for multiples of three print "Fizz" instead of the number 
> and for the multiples of five print "Buzz". For numbers which 
> are multiples of both three and five print "FizzBuzz".
> 
> see some solutions in various languages at:
>  * 
> http://mult.ifario.us/articles/2007/01/25/laziness-and-fizzbuz
z-in-haskell
>  * 
> http://tickletux.wordpress.com/2007/01/24/using-fizzbuzz-to-fi
nd-developers-who-grok-coding/
>  * http://programming.reddit.com/info/10d7w/comments
>  * http://www.ittutor.net/forums/index.php?showtopic=31262
>  * http://tkyte.blogspot.com/2007/02/what-is-your-fizzbuzz-factor.html
> 
> How short and simple solution in J can you write for this problem?
> 
> 
> Following are my trials:
> 
> f=:0=3&|
> b=:0=5&|
> pr=:[: ; (('';'fizz') {~ f) , ('';'buzz') {~ b fb=:":[EMAIL PROTECTED](f+.b)"0
> 
> s=:(('';'fizz') {~ f ) , each ('';'buzz') {~ b ll=:,:~ s&>
> fb2=:[: ":&> (a: = [EMAIL PROTECTED])[EMAIL PROTECTED]@:(<"0)
> 
> assert   (fb -: fb2) >:i.100
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to