[Jprogramming] FizzBuzz

June Kim juneaftn at gmail.com
Wed Mar 7 11:46:56 HKT 2007


I was lying on the bed just before falling asleep when I came up with
this vector solution, which takes similar approach with yours;
however, much longer than yours:

sti=:[: #.@|: 0=5 3|/]
ali=:(-@]+[*0=]) sti
fb3=:[: > ali { [: ,&('FizzBuzz';'Buzz';'Fizz' ) [: ":&.> 0&,
fb3 >:i.100

2007/3/7, Devon McCormick <devonmcc at gmail.com>:
> You could use agenda:
>   replfb=: ":`('Fizz'&[)`('Buzz'&[)`('FizzBuzz'&[) @. ([: #. 0 = 5 3 | ])
>   replfb&>:>i.100
> 1
> 2
> Fizz
> 4
> Buzz
> Fizz
> 7
> 8
> Fizz
> Buzz
> 11
> Fizz
> 13
> 14
> FizzBuzz
> 16
> ...
>
> On 3/6/07, Roger Hui <rhui000 at shaw.ca> wrote:
> >
> > Well:
> >    FB  =: (": [^:(0=*@#@]) Fizz,Buzz)"0
> >    FB1 =: (": (] , #@] }. [) Fizz,Buzz)"0
> >
> >    (FB -: FB1) >: i.100
> > 1
> >    # ;: 5!:5 <'FB'
> > 19
> >    # ;: 5!:5 <'FB1'
> > 17
> >
> > I could also move the "0 from the definition
> > to the expression  FB"0 >:i.100 .  That'd get
> > rid of the overall parens.
> >
> >
> >
> > ----- Original Message -----
> > From: Raul Miller <rauldmiller at gmail.com>
> > Date: Tuesday, March 6, 2007 2:54 pm
> > Subject: Re: [Jprogramming] FizzBuzz
> >
> > > On 3/6/07, Roger Hui <rhui000 at shaw.ca> wrote:
> > > > Fizz=: 'Fizz' #~ 0 = 3&|
> > > > Buzz=: 'Buzz' #~ 0 = 5&|
> > > > FB  =: (": [^:(0&=@#@]) Fizz,Buzz)"0
> > > > FB >: i.100
> > >
> > > That's shorter than what I was going to do.
> > >
> > > That said, FB could be
> > >
> > > FB=: (": [^:(0=#@]) Fizz,Buzz)"0
> > ----------------------------------------------------------------------
> > For information about J forums see http://www.jsoftware.com/forums.htm
> >
>
>
>
> --
> Devon McCormick, CFA
> ^me^ at acm.
> org is my
> preferred e-mail
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>


More information about the Programming mailing list