From ad93eae8a1d8dd6476c7d392e04eaf7d82beea00 Mon Sep 17 00:00:00 2001 From: Neil Villamizar Date: Fri, 16 Oct 2020 02:44:18 -0400 Subject: [PATCH 1/5] Create fizz_buzz_neil_v.cpp --- C++/fizz_buzz_neil_v.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 C++/fizz_buzz_neil_v.cpp diff --git a/C++/fizz_buzz_neil_v.cpp b/C++/fizz_buzz_neil_v.cpp new file mode 100644 index 0000000..956fcdc --- /dev/null +++ b/C++/fizz_buzz_neil_v.cpp @@ -0,0 +1,40 @@ +#include + +using namespace std; + +void solve_fizz_buzz(int n){ + + if ( n%15 == 0 ){ + cout << "Fizz Buzz"; + return; + } + + if( n%3 == 0){ + cout << "Fizz"; + } + + if( n%5 == 0){ + cout << "Buzz"; + } + + cout << n; + +} + +int main(){ + + int n; + cin >> n; + + for(int i = 1; i <= n; ++i){ + + solve_fizz_buzz(i); + + if(i == n) cout << ".\n"; + else cout << ", "; + + } + + return 0; + +} From c24bd72c9ef195aa896e5dacf151febdb1c2db9d Mon Sep 17 00:00:00 2001 From: Neil Villamizar Date: Fri, 16 Oct 2020 02:49:13 -0400 Subject: [PATCH 2/5] Create fizz_buzz_neil_v.c --- C/fizz_buzz_neil_v.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 C/fizz_buzz_neil_v.c diff --git a/C/fizz_buzz_neil_v.c b/C/fizz_buzz_neil_v.c new file mode 100644 index 0000000..cfbc8af --- /dev/null +++ b/C/fizz_buzz_neil_v.c @@ -0,0 +1,40 @@ +#include + +void solve_fizz_buzz(int n){ + + if ( n%15 == 0 ){ + printf("Fizz Buzz"); + return; + } + + if( n%3 == 0){ + printf("Fizz"); + return; + } + + if( n%5 == 0){ + printf("Buzz"); + return; + } + + printf("%d", n); + +} + +int main(){ + + int n; + scanf("%d", &n); + + for(int i = 1; i <= n; ++i){ + + solve_fizz_buzz(i); + + if(i == n) printf(".\n"); + else printf(", "); + + } + + return 0; + +} From ace9e787269418e27792b4e85db88045ad45ba64 Mon Sep 17 00:00:00 2001 From: Neil Villamizar Date: Fri, 16 Oct 2020 02:49:53 -0400 Subject: [PATCH 3/5] Update fizz_buzz_neil_v.cpp --- C++/fizz_buzz_neil_v.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/C++/fizz_buzz_neil_v.cpp b/C++/fizz_buzz_neil_v.cpp index 956fcdc..601f45b 100644 --- a/C++/fizz_buzz_neil_v.cpp +++ b/C++/fizz_buzz_neil_v.cpp @@ -11,10 +11,12 @@ void solve_fizz_buzz(int n){ if( n%3 == 0){ cout << "Fizz"; + return; } if( n%5 == 0){ cout << "Buzz"; + return; } cout << n; From a4e4c54f79ba210b714002af3050b6d0472f90d1 Mon Sep 17 00:00:00 2001 From: Neil Villamizar Date: Fri, 16 Oct 2020 03:06:27 -0400 Subject: [PATCH 4/5] Create fizz_buzz_neil_v.hs --- Haskell/fizz_buzz_neil_v.hs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Haskell/fizz_buzz_neil_v.hs diff --git a/Haskell/fizz_buzz_neil_v.hs b/Haskell/fizz_buzz_neil_v.hs new file mode 100644 index 0000000..321b9e3 --- /dev/null +++ b/Haskell/fizz_buzz_neil_v.hs @@ -0,0 +1,19 @@ + +solveFizzBuzz :: Int -> String +solveFizzBuzz n + | n `mod` 15 == 0 = "FizzBuzz" + | n `mod` 3 == 0 = "Fizz" + | n `mod` 5 == 0 = "Buzz" + | otherwise = show n + +getEnd :: Int -> Int -> String +getEnd x n + | x == n = "." + | otherwise = "," + +readAInt :: IO Int +readAInt = readLn + +main = do + n <- readAInt + putStrLn $ unwords [ solveFizzBuzz x ++ getEnd x n | x <-[1..n]] From 4d3d1e2ee66336480cb7a89d32e37bdb5a6199c4 Mon Sep 17 00:00:00 2001 From: Neil Villamizar Date: Fri, 16 Oct 2020 03:22:48 -0400 Subject: [PATCH 5/5] Create fizz_buzz_neil_v.py --- Python/fizz_buzz_neil_v.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 Python/fizz_buzz_neil_v.py diff --git a/Python/fizz_buzz_neil_v.py b/Python/fizz_buzz_neil_v.py new file mode 100644 index 0000000..56ead9b --- /dev/null +++ b/Python/fizz_buzz_neil_v.py @@ -0,0 +1,26 @@ + +def solveFizzBuzz(x): + + if(x % 15 == 0): + print ("Fizz Buzz", end='') + return + + if(x % 3 == 0): + print ("Fizz", end='') + return + + if(x % 5 == 0): + print ("Buzz", end='') + return + + print (x, end='') + + +n = int(input()) + +for i in range(1, n+1): + solveFizzBuzz(i) + if(i == n): + print (".") + else: + print(",", end=' ')