Yenya's World

Mon, 28 Jan 2008


Pete Zaitcev mentions an interesting programming challenge (read on only if you have several minutes of free time, so that you can try it yourself):

Write on paper, as fast as you can, a program, which prints out the numbers from 1 to 100, but instead of numbers divisible by three it prints "Fizz", instead of numbers divisible by five, it prints "Buzz", and instead of numbers divisible by both 3 and 5 it prints "FizzBuzz".

Pete mentions that even some comp.sci graduates cannot solve this problem. The difficulty of course varies with the programming language used. My own solution in C took me about 3.5 minutes, and the short part of this time I have not been busy writing I spent thinking about a clever way of doing it using conditional expressions in one command, instead of writing the obvious solution.

Anyway, here is the original FizzBuzz article, and there is also a Golf challenge: I am at 60 characters now (in Perl, of course), but they do not accept the command-line switches, so the actual solution has 63 chars instead.

Section: /computers (RSS feed) | Permanent link | 3 writebacks


Yenya's World: Linux and beyond - Yenya's blog.


RSS feed

Jan "Yenya" Kasprzak

The main page of this blog



Blog roll:

alphabetically :-)