Added solutions to Generic/FizzBuzz
This commit is contained in:
20
Generic/FIZZBUZZ/desc.yml
Normal file
20
Generic/FIZZBUZZ/desc.yml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
title: FizzBuzz
|
||||||
|
url: http://projecteuler.net/problem=1
|
||||||
|
|
||||||
|
desc: |
|
||||||
|
The classical coding challenge. Write a program that prints the numbers from 1 to 100. But for multiples of three print <20>Fizz<7A> instead of the number and for the multiples of five print <20>Buzz<7A>. For numbers which are multiples of both three and five print <20>FizzBuzz<7A>.
|
||||||
|
|
||||||
|
solution: |
|
||||||
|
See the code...
|
||||||
|
|
||||||
|
solutions:
|
||||||
|
solve.php:
|
||||||
|
desc: Basic solution
|
||||||
|
usage:
|
||||||
|
language: php
|
||||||
|
solve.rb:
|
||||||
|
desc: Basic solution in Ruby
|
||||||
|
language: ruby
|
||||||
|
solve.c:
|
||||||
|
desc: ANSI C solution (Tested with TCC)
|
||||||
|
language: c
|
22
Generic/FIZZBUZZ/solve.c
Normal file
22
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
Generic/FIZZBUZZ/solve.php
Normal file
13
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
Generic/FIZZBUZZ/solve.rb
Normal file
12
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
|
6
ProjectEuler/desc.yml
Normal file
6
ProjectEuler/desc.yml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
title: ProjectEuler.net
|
||||||
|
url: http://projecteuler.net/
|
||||||
|
|
||||||
|
desc: |
|
||||||
|
Project Euler is a series of challenging mathematical/computer programming problems that will require more than just mathematical insights to solve. Although mathematics will help you arrive at elegant and efficient methods, the use of a computer and programming skills will be required to solve most problems.
|
||||||
|
|
Reference in New Issue
Block a user