Restructuring
This commit is contained in:
17
solutions/Generic/FIZZBUZZ/desc.yml
Normal file
17
solutions/Generic/FIZZBUZZ/desc.yml
Normal file
@ -0,0 +1,17 @@
|
||||
title: FizzBuzz
|
||||
url: http://imranontech.com/2007/01/24/using-fizzbuzz-to-find-developers-who-grok-coding/
|
||||
|
||||
desc: The classical coding challenge. 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.
|
||||
|
||||
solution: See the code...
|
||||
|
||||
solutions:
|
||||
solve.php:
|
||||
desc: Basic solution
|
||||
language: php
|
||||
solve.rb:
|
||||
desc: Basic solution in Ruby
|
||||
language: ruby
|
||||
solve.c:
|
||||
desc: ANSI C solution (Tested with TCC)
|
||||
language: c
|
22
solutions/Generic/FIZZBUZZ/solve.c
Normal file
22
solutions/Generic/FIZZBUZZ/solve.c
Normal file
@ -0,0 +1,22 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main( )
|
||||
{
|
||||
int i = 0;
|
||||
for(i = 1; i <= 100; i++)
|
||||
{
|
||||
if(i % 3 == 0)
|
||||
{
|
||||
printf( "Fizz" );
|
||||
}
|
||||
if(i % 5 == 0)
|
||||
{
|
||||
printf( "Buzz" );
|
||||
}
|
||||
if(i % 3 && i % 5)
|
||||
{
|
||||
printf( "%d", i );
|
||||
}
|
||||
printf( "\n" );
|
||||
}
|
||||
}
|
13
solutions/Generic/FIZZBUZZ/solve.php
Normal file
13
solutions/Generic/FIZZBUZZ/solve.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
for($i=1; $i<=100; $i++) {
|
||||
if($i % 3 == 0) {
|
||||
print "Fizz";
|
||||
}
|
||||
if($i % 5 == 0) {
|
||||
print "Buzz";
|
||||
}
|
||||
if($i % 3 AND $i % 5) {
|
||||
print $i;
|
||||
}
|
||||
print PHP_EOL;
|
||||
}
|
12
solutions/Generic/FIZZBUZZ/solve.rb
Normal file
12
solutions/Generic/FIZZBUZZ/solve.rb
Normal file
@ -0,0 +1,12 @@
|
||||
(1..100).each do |i|
|
||||
if(i % 3 == 0)
|
||||
print "Fizz";
|
||||
end
|
||||
if(i % 5 == 0)
|
||||
print "Buzz"
|
||||
end
|
||||
if(i % 3 != 0 and i % 5 != 0)
|
||||
print i
|
||||
end
|
||||
print "\n";
|
||||
end
|
Reference in New Issue
Block a user