do you fail at FizzBuzz? simple prog test

bockman at virgilio.it bockman at virgilio.it
Mon May 12 03:55:25 EDT 2008


On 12 Mag, 09:00, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Sat, 10 May 2008 22:12:37 -0300, globalrev <skanem... at yahoo.se> escribió:
>
>
>
>
>
> >http://reddit.com/r/programming/info/18td4/comments
>
> > claims people take a lot of time to write a simple program like this:
>
> > "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".
>
> > for i in range(1,101):
> >     if i%3 == 0 and i%5 != 0:
> >         print "Fizz"
> >     elif i%5 == 0 and i%3 != 0:
> >         print "Buzz"
> >     elif i%5 == 0 and i%3 == 0:
> >         print "FizzBuzz"
> >     else:
> >         print i
>
> > is there a better way than my solution? is mine ok?
>
> Is it correct? Did you get at it in less than 15 minutes? If so, then it's OK.
> The original test was not "write the most convoluted algorithm you can think of", nor "write the best program to solve this". It was a *practical* test: if you can't get anything remotely working for such a simple problem in 15 minutes, we're not interested in your services.
>
> (We used this question last year - some people gave a sensible answer in less than 5 minutes, but others did not even know how to start)
>
> --
> Gabriel Genellina- Nascondi testo tra virgolette -
>
> - Mostra testo tra virgolette -

As a test, I would leave out the last sentence, and see how many
people (and how fast) figure out than a number can be multiple of
three _and_ five and that the requirement is somehow incomplete ...

Ciao
-----
FB



More information about the Python-list mailing list