Recently I came across an article where the author finds most of the candidates interviewed for the post of a developer can't write basic code, so he gave everyone a simple test called "FizzBuzz Test", which is as follows:
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".
Read more here http://imranontech.com/2007/01/24/us...o-grok-coding/
Some newbies in the forum might consider posting a solution the problem in wichever language they wish to.
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 27May2009,19:19 | #2 |
|
Lets make it interesting.
I request G4EF members to write the above mentioned program in ANY language of their choice, provided the same language has not been used by any other member in any of the previous posts in this thread. Let me start with C Code: c
|
|
Newbie Member
|
|
| 28May2009,01:12 | #3 |
|
this is really cool...
! I have it here in perl Code:
perl -le 'print (($_%15)?(($_%3)?(($_%5)?$_:"Buzz"):"Fizz"):"FizzBuzz") for 1..100' Code:
#!/usr/bin/perl
for (1..100){
print (($_%15)?(($_%3)?(($_%5)?$_."\n":"Buzz\n"):"Fizz\n"):"FizzBuzz\n");
}
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 28May2009,09:40 | #4 |
|
Please ALWAYS post code inside code-blocks. (I request shabbir to edit the above post.)
I would really wish to see the FizzBuzz program in some esoteric programming language
|
|
Go4Expert Founder
|
![]() |
| 28May2009,10:03 | #5 |
|
Done
|
|
Go4Expert Founder
|
![]() |
| 28May2009,10:23 | #6 |
|
Code: Cpp
|
|
~ Б0ЯИ Τ0 С0δЭ ~
|
![]() |
| 28May2009,12:11 | #7 |
What was that shabbir ?!Where is the main func ? Writing the whole code in a single line, significantly reduces the readability of your code. |
|
Team Leader
|
![]() |
| 28May2009,12:52 | #8 |
|
Mine in shell script
Code: sh
|
|
Go4Expert Founder
|
![]() |
| 28May2009,13:36 | #9 |
|
Mentor
|
![]() |
| 28May2009,13:51 | #10 |
|
Forth (developed and tested with Win32Forth)
Code:
variable test3 variable test5 variable prt : prog 1 0 0 test3 ! test5 ! prt ! 20 1 do test3 @ 1 + dup test3 ! 3 = if ." fizz" 0 0 prt ! test3 ! then test5 @ 1 + dup test5 ! 5 = if ." buzz" 0 0 prt ! test5 ! then prt @ if i . else ." " then 1 prt ! loop ; |


!

What was that shabbir ?!
