I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
I'm an Occult Programmer, Anarquista, and a void* made manifest. My passions include tattoos, open source software, build systems, mechanical keyboards, and DIY electronics.
I'm an Occult Programmer, Anarquista, and a void* made manifest. My passions include tattoos, open source software, build systems, mechanical keyboards, and DIY electronics.
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
These actually fail the FizzBuzz challenge because they print numbers that are divisible by 3 and/or 5. The challenge specifically states to print Fizz, Buzz, or FizzBuzz INSTEAD of the number.
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
DECLARE @i INT = 100; ;WITH E1(N) AS (SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1 UNION ALL SELECT 1), -- 1*10^1 or 10 rows E2(N) AS (SELECT 1 FROM E1 a, E1 b), -- 1*10^2 or 100 rows E4(N) AS (SELECT 1 FROM E2 a, E2 b), -- 1*10^4 or 10,000 rows E8(N) AS (SELECT 1 FROM E4 a, E4 b), -- 1*10^8 or 100,000,000 rows cteTally(N) AS (SELECT TOP (@i) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) FROM E8) SELECT CASE WHEN N % 15 = 0 THEN 'fizzbuzz' WHEN N % 5 = 0 THEN 'buzz' WHEN N % 3 = 0 THEN 'fizz' ELSE CONVERT(VARCHAR(10),N) END FROM cteTally
For when you want to define your own custom matcher logic for each word in your custom fizzbuzzer. Still lets you put a single number in for 'divides by' logic.
(defmacrodefine-fizzbuzzer(name&bodypairs)(let((ps(clean-argspairs)))`(defun,name(n)(let((resultnil))(dolist(p',ps)(let((test-passed?(funcall(eval(firstp))n)))(whentest-passed?(push(secondp)result))))(if(nullresult)(write-to-stringn)(apply#'concatenate'string(nreverseresult)))))))(defunclean-args(pairs)(mapcar#'clean-pairpairs))(defunclean-pair(pair)(cond((typep(firstpair)'integer)(list'#'(lambda(n)(dividesn(firstpair)))(secondpair)))((eq(caarpair)'function)pair)(t(error"first element of pair must be either an integer or a function"))))(defunprime?(n)"evaluates to t when n is prime. Highly inefficient"(loopforxfrom2to(roundn2)never(dividesnx)))(defunhas-a-nine-in-it?(n)"does the decimal representation of this number have a 9 in it?"(some#'(lambda(c)(char=c#\9))(write-to-stringn)))(define-fizzbuzzerfizz-buzz(3"Fizz")(5"Buzz"))(define-fizzbuzzerfazz-bazz(#'prime?"Fazz")(#'has-a-nine-in-it?"Bazz"))
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
Here is another example using as a Module and using pattern matching. It looks hilarious :P
defmoduleFizzBuzzdodefrun(num)whennum>=1andnum<=100do:fizzbuzz(num,rem(n,3),rem(n,5))run(num-1)enddefrun(0),do:{:ok,"Done"}defrun(_)do:{:error,"Something went wrong"}defpfizzbuzz(_,0,0),do:IO.puts"Fizzbuzz"defpfizzbuzz(_,0,_),do:IO.puts"Fizz"defpfizzbuzz(_,_,0),do:IO.puts"Buzz"defpfizzbuzz(n,_,_),do:n|>to_string|>IO.putsend# ExampleFizzBuzz.run(55)
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
I know this must be very basic, but it's the first time I'm ever doing this. Here's my implementation using JavaScript, printed into an HTML element :D
Here's a shot at an Erlang version, but I barely know Erlang.
-module(fizzbuzz). -export([start/0]). fizzbuzz(X) when X rem 3 == 0, X rem 5 /= 0 -> fizz; fizzbuzz(X) when X rem 5 == 0, X rem 3 /= 0 -> buzz; fizzbuzz(X) when X rem 3 == 0, X rem 5 == 0 -> fizzbuzz; fizzbuzz(X) -> X. start() -> Result = [fizzbuzz(X) || X <- lists:seq(1,100)], Result.
I teach computer science to undergrads and write for The Renegade Coder. I'm most likely taking care of my daughter, watching the Penguins, or reading manga.
Location
Columbus, Ohio
Education
B.S. in CE from CWRU 2016; M.S. in CSE from OSU 2020; PhD in EED from OSU 2024
Rather than post my own, I’m just going to link you to the fizzbuzz tag on Code Review. I swear I’ve reviewed this one in every language, and that includes LOLCODE.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
CSS
Haha I love that you can do this in CSS.
There's several ways to do it in C++ :)
The Classic
The "GOSH, MOM, IT'S GENERIC"
The "Calculated At Compile Time (stare into madness edition)"
I raise you the compile time calculated fizzbuzz in Nim ;)
C++20 isn't available yet, but we're a bit closer to this approach. :)
Interested in adding this to the collection? 😁
That last one scares me. Haha I’m not sure I’d know where to start reading it.
Thanks for jumping into the challenge with some great additions. 😃
Take that github.com/EnterpriseQualityCoding...
number 3 is the Cthulu of FizzBuzz
These actually fail the FizzBuzz challenge because they print numbers that are divisible by 3 and/or 5. The challenge specifically states to print Fizz, Buzz, or FizzBuzz INSTEAD of the number.
Here's my implementation in Racket
The
print-list
function is a bit redundant, since(map fizzbuzz (range 1 101))
will already print the resulting list to the console.Ah come on @avalander - surely you should've written a FizzBuzz DSL in Racket? 😉
I should, but I don't know enough Racket for that yet 😅
Great stuff! I like racket a lot, but I haven't written any code in it myself. The fact that there are so many dialects of it is pretty cool to me.
Thanks! I've just started learning it myself. I can recommend the book Realm of Racket if you want to give it a shot.
Since nobody has done Javascript yet, here's a crazy implementation.
Consider how easy it is to extend to print
'fazz'
for multiples of 7.I appreciate the commitment to the obscure. Haha these are great.
That's the whole point of the exercise, right? :D
Oh absolutely! Got any code golf solutions?
Hmm... the best I can come up with right now is 85 chars. Nothing really clever, just sacrificed readability for space.
Another fun one, albeit longer, is this.
Sql anybody?
`
Because using a cursor is too mainstream? :)
Here's some fun from the world of Common Lisp
Inoffensive version
Offensive FizzBuzz Builder Macro
For when you want to define your own custom fizzbuzzer. Nice and easy to extend.
Most Offensive Macrogeddon Too Hot for TV Version
For when you want to define your own custom matcher logic for each word in your custom fizzbuzzer. Still lets you put a single number in for 'divides by' logic.
Bring on the parentheses!
Elixir
Here is another example using as a Module and using pattern matching. It looks hilarious :P
Ooh, this would make a nice addition to the repo.
Go ahead.
Didn't see a C# solution, so here's mine (with some linq love):
Is this a Python solution using a massive list comprehension?! I like it.
I know this must be very basic, but it's the first time I'm ever doing this.
Here's my implementation using JavaScript, printed into an HTML element :D
Here's a shot at an Erlang version, but I barely know Erlang.
Here's a solution in Go.
Here's APL.
To understand how it works, read this
Love it! Short and sweet. I haven't gotten around to learning any APL, and the repo shows it.
Yep. I saw there wasn't an APL in the repo
Rather than post my own, I’m just going to link you to the fizzbuzz tag on Code Review. I swear I’ve reviewed this one in every language, and that includes LOLCODE.