function fizzbuzz(n) mdl = [modulo3(i) = if i%3 == 0 "Fizz" end modulo5(i) = if i%5 == 0 "Buzz" end modulo7(i) = if i%7 == 0 "Woof" end] for i = 1:n msg = "" for m = 1:length(mdl) if mdl[m](i) != nothing msg *= mdl[m](i) end end if msg == "" msg *= "$i" end println(msg) end end
Hudson Davis
Import fizzBuzz from "fizzbuzz" Console.log(fizzBuzz())
Jack White
when are they gonna make a programming language for non-autists and women like "if you press the 'G' key, make the character jump" is way easier than this [(string)-,,':;()] shit
Michael Smith
they make "coding" programs for children. Shit like scratch, where it's just blocks that snap into each other.
More like /prog/ overflow from when they closed the text boards that just won't go away.
Kevin Nguyen
#include using namespace std;
void fizzbuzz(int);
int main() { fizzbuzz(100); return 0; }
void fizzbuzz(int MAXNUM){ for (int i = 1; i
Dylan Gonzalez
very nice >+ follows best practices >+ looks clean >- no comments though
Connor Stewart
easily readable, honestly the best solution that you would want to see in production. your bracket spacing isn't consistent (you put a space after main() but not after fizzbuzz() or for()) but that's minor.
No comments. For something this simple you obviously don't really need it, but if someone doesn't know what fizzbuzz is, you'll want a comment describing what it is.
as a side note, if you're concerned purely about performance, you're doing modulo at least three times. there is a way that's longer and not as "clean" looking, but it only does modulo twice. you'll also want to avoid the iostream library and do a print call only once if possible. print calls are very, very slow.
Parker Young
>you'll also want to avoid the iostream library and do a print call how can I print to the console without the iostream library? Isn't it required for cout?
Robert Roberts
class FizzBuzzNumberFactory:
def __init__(self, n): if n % 15 == 0: self.FizzBuzzTypeNumber = FizzBuzzNumber(n) elif n % 5 == 0: self.FizzBuzzTypeNumber = BuzzNumber(n) elif n % 3 == 0: self.FizzBuzzTypeNumber = FizzNumber(n) else: self.FizzBuzzTypeNumber = NumberNumber(n)
def FizzBuzzin(n): fizzBuzzingList = [] for i in range(1, n+1): fizzBuzzingList.append(FizzBuzzNumberFactory(i)) fizzBuzzingList = list(map(str, fizzBuzzingList)) for i in fizzBuzzingList: print(i)
Owen Perez
it is required for cout. i have never done very much c++, but i was always told to avoid it and use the ones from instead, like printf() and fprintf()
Brayden Adams
Posted this in /dpt/ a couple days ago. People seemed to enjoy it.
and i guess fizz could going to get casted to an int lol oh well lol
Sebastian Brooks
function fizzBuzz(num) { switch(num % 15) { case 0: return 'FizzBuzz';
case 5: case 10: return 'Buzz';
case 3: case 6: case 9: case 12: return 'Fizz'; }
return num; }
for(let i = 1; i < 101; i++) { console.log(fizzBuzz(i)); }
Andrew Myers
func fizzBuzz(_ n: Int) -> String { var ret = String() if (n % 3 == 0) { ret += "Fizz" } if (n % 5 == 0) { ret += "Buzz" } if (ret.isEmpty) { ret = String(n) } return ret }
(1...100).forEach { print(fizzBuzz($0)) }
Camden Anderson
Fuck you
Caleb James
if then buzz fizz buzz
Adam Edwards
for i in {1..100}; do [ $(( i % 3 )) -eq 0 ] && o=fizz || { [ $(( i % 5 )) -eq 0 ] && o=${o}buzz } || { [ -z $o ] && o=$i } echo $o o= done
the character is a human controlled object the character can be described as "A small smug creature who trusts in the banking system." the character has the ability "moving" when moving the character navigates laterally between areas adjacent to the character's current position the character has the ability "jumping" when jumping the character is raised upwards by 1 unit for 1 turn
// This is where the magic happens func fizzbuzz(_ range: ClosedRange = 0...100) { for i in range { let factory: Factory if i.canBeFizzBuzzed() { factory = FizzBuzzFactory() } else if i.canBeFizzed() { factory = FizzFactory() } else if i.canBeBuzzed() { factory = BuzzFactory() } else { factory = IntFactory(intValue: i) } print(factory.makeString()) } }
you should push each result into an array and then print the result at the end for better performance
John Clark
nice
t.
James Lewis
>its a butthurt pajeet tries to make Swift look like a shitlang episode
for i in 1...100 { switch (i % 3 == 0, i % 5 == 0) { case (false, false): print(i) case (true, false): print("fizz") case (false, true): print("buzz") case (true, true): print("fizzbuzz") } }
Easton Edwards
>Why you faggots look for retarded ass complicated solutions. >Fizzbuzz
I have two fizzbuzzes I wrote last week on my phone when I had read about it here. The first one is the fizzbuzz ever so be nice. for i in range(1, 101): if i % 3 == 0: if i % 5 == 0: print("fizzbuzz") else: print("fizz") elif i % 5 == 0: print("buzz") else: print(i)
I wrote the second smaller and to have numbers printed for each line, which I like. for i in range(1, 101): s = str(i) + " " if i % 3 == 0: s += "fizz" if i % 5 == 0: s += "buzz" print(s)
Michael Cruz
>you'll also want to avoid the iostream library >i have never done very much c++, but i was always told ___ kek
Anthony Anderson
If (key_pressed('G')) player.jump()
Most game engines make it that intuitive. You shouldn't be programming if you can't read that..
subset Fizz of Int where * %% 3; subset Buzz of Int where * %% 5; subset FizzBuzz of Int where Fizz & Buzz;
for 1..100 -> $n { first $n ~~ *, FizzBuzz, Fizz, Buzz, :p andthen .value.^name.say orelse $n.say }
Dominic Wood
I'm just learning C++ for work. Is it common practice to use the using name space instead of just doing std::cout?
Noah Cook
do not do using namespace std;
you're polluting your namespace
Josiah Powell
From what I've read on Jow Forums it's better not to use using namespace std because, for example, if you want to create your own sort() function, it could potentially cause headaches. The other thing I've read is that you should never put using namespace std in a header because all the files that include it will be affected.
Charles Moore
4
Austin Wilson
if( !(i%3))
:^)
Jace Gray
a={}; for i=1, 100 do a[i] = i end
for i=3, 100, 3 do a[i] = "fizz" end
for i=5, 100, 5 do a[i] = "buzz" end
for i=15, 100, 15 do a[i] = "fizzbuzz" end
for i=1, 100 do print(a[i]) end
Ryder Moore
I like you
Liam Reed
lmao having different prints for "fizzbuzz" and "fizz"
perl -e 'say "Fizz"x!($_%3)."Buzz"x!($_%5)||$_ for 1..100'
Aiden Young
holy waste of time, non-autists and women would kill themselves before being able to complete a single page of this """"""""""""""code""""""""""""""
Parker Adams
What part is human controlled? What defines creature? Does the human control the arms? Are the arms a separate object? What about inventory? Is that separate? How do you determine when the character is moving laterally? Or when areas are adjacent? What determines a unit or a turn?
Connor Miller
Ive only been studying for a month, but I really don't think this is the best way to do it.
Joshua Thompson
>using namespace >cout >4 fucking conditionals #include int main (void) { for (int i = 0; i < 100; i++) { printf("%d\r", i); if (!(i%3)) printf("Fizz"); if (!(i%5)) printf("Buzz"); printf("\n"); } }
library ieee; use ieee.std_logic_1164.all; library std; use std.textio.all;
entity fizzbuzz is end fizzbuzz;
architecture structural of fizzbuzz is begin process begin for i in 1 to 100 loop if i mod 3 = 0 and i mod 5 = 0 then write (output, "FIZZBUZZ" & LF); elsif i mod 3 = 0 then write (output, "FIZZ" & LF); elsif i mod 5 = 0 then write (output, "BUZZ" & LF); else write (output, integer'image(i) & LF); end if; end loop; wait; end process; end architecture;
#!/bin/bash/python3 i = 0 while True: i += 1 if (i % 3 == 0): print ("Fizz") if (i % 5 == 0): print ("Buzz") if (i % 15 == 0): print ("FizzBuzz") else: print (i)