Easy mode: no modulus or division Hard mode: no looping, only recursion Harder mode: no variables, use only literals, functions and their arguments Even harder mode: only arithmetic allowed is + 1 Ultra hard mode: no branching
### Target ### .PHONY: all all: ; $(info $(fizzbuzz))
Isaiah Jackson
Fuck rules, write something more elegant than this.
def eval(n: Int): Any = n match { case n if n % 5 == 0 && n % 3 == 0 => "fizzbuzz" case n if n % 3 == 0 => "fizz" case n if n % 5 == 0 => "buzz" case _ => n }
def from(n: Int): Stream[Int] = n #:: from(n+1)
(from(1) map eval).take(100).toList
Luke Adams
import fishbuss
Fishbuss.start()
Kayden Torres
You can collapse the "n % 5 and n % 3" into "n % 15"
Levi Diaz
Yes, doable, more coincise and somewhat less expressive, would go for it though
Ethan Martin
it's part of the fizzbuzz joke
Jonathan Cox
select = (i) => (i % 3 == 0 ? "fizz" : "") + (i % 5 == 0 ? "buzz" : "") || i
More coincise, but >arrays >console.log >side effect
Angel Perry
Except for output, what's the side effect?
Tyler Johnson
Was just sperging about output, I lke your implementation
Cooper King
And just remove the last line if you don't want to print every member.
Benjamin Foster
U0 main() { U8 i, fizz, buzz; for (i = 0, fizz = 0, buzz = 0; i < 100; i++, fizz++, buzz++) { Print("%2u ", i); if (fizz == 3) { Print("Fizz"); fizz = 0; } if (buzz == 5) { Print("Buzz"); buzz = 0; } Print("\n"); } }
main;
Charles Gonzalez
I like this one.
That's pretty neat.
Hunter Jackson
>Sup Forumsay retards still doing normie fizzbuzz challenges
Pffft, show me all the prime factors of 1 billion (1000000000) in 30 seconds maximum. Corelets not allowed, sorry Intel pajeets.
Protip: use FORTRAN or C.
Eli Wood
>Ultra hard mode: no branching What?
Anthony Sullivan
No conditions.
Jaxson Myers
2^9 * 5^9 You can do that in your head, c'mon now
Carter Young
>1 gorrilion in 1 sec
Christian James
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
Bentley Miller
You can do fizzbuzz in your head too, retard, it's a game designed for little kids. You can also google the solution to my challenge, that's not the thing I want.
The idea is to show a program figuring it out from scratch, so hurry up.
Juan Turner
But the point is that 10^9 is 2ez, even the following shitty code can do it in a few millis tops. Choose a number with a more interesting prime factorization next time. def slowfactors(n): o = [] p = 2 while n > 1: d, m = divmod(n, p) if m: p += 1 else: n = d o.append(p) return o
Probably doesn't even work but that's how I remember it and I'm on an old tablet and can't test it.
Gavin Kelly
dafuq are u doing
Jonathan Bennett
The speed isn't the point either (the 30 second limit is to stop complete retards).
That code snippet doesn't even do shit at all. My challenge still stands, it's very easy to do, that's why 1 billion was picked so the results are easily confirmable.
Impressive. Should be trivial to make mod recursive too?
Christopher Cox
>Not understanding the use of while instead of for in this situation is better Ladies and gentlemen, a code monkey >Leddit spacing Fuck off back to your safespace, bitchboy.
Carter King
>Does not fulfill requirements >Terrible formatting >Does not conform to code standards >C 0/10
Brody Russell
No modulo No looping (only recursion) No variables (only literals and arguments) Only + 1 Sadly, I have to do a conditional on wrapping on 15 though.
No one is going to do your homework for you, pajeet.
Luis Brooks
return (x < y) ? x : mod(x-y, y);
I still don't see how to do that without branching.
Evan Myers
Well done.
Brandon Collins
>I still don't see how to do that without branching. I _think_ it's not possible.
Michael Jenkins
What language is this?
Landon Morales
JavaScript
Benjamin Hill
t. Code monkey
Matthew Bell
How can something so elegant be shitty JavaScript??????
Carter Moore
user, I didn't ask for all prime numbers up to 1 billion. I asked for prime factors of 1 billion. Good work regardless, as it just werks, except:
bitmap[N];
Come on now. Arrays with variables as sizes? Nu-C please.
>Can't justify his use of while over for >Not even slightly pythonic >Browses Reddit to know how they do spacing over there
I won't go to your safespace until you let me in :)
>Says this in a fizzbuzz thread of all things
Sure thing, Mrs. Kloss.
Jace Kelly
>U0 >U8 That is not c I belive
Connor Scott
Because javascript is great...? Nigger, you are thinking of Java.
Jaxon Ward
>I didn't ask for all prime numbers up to 1 billion. I asked for prime factors of 1 billion. I see, I read wrong. Sorry.
>Come on now. Arrays with variables as sizes? It's not variable, N is defined const. lrn2 C
Ryan Reyes
>pythonic Okay, now I know this is just bait.
Brody Myers
No, I'm thinking of webpajeet.
Kayden Sanchez
Fizzbuzz oneliners, here's python
python -c "[print('Fizz'*(not i%3) + 'Buzz'*(not i%5) or i for i in range(1,101)])"
Jackson Campbell
>Says this in a fizzbuzz thread of all things >Sure thing, Mrs. Kloss. Fair enough, but even schools do more complex shit than fizzbuzz. That question the other poster put up was just straight up homework.
Isaac Phillips
whelp, my brackets got fucked
Non retard version: python -c "print(['Fizz'*(not i%3) + 'Buzz'*(not i%5) or i for i in range(1,101)])"
void dofizzbuzz(fizzbuzz_t &fizzbuzz, int from, int to, int inc, const std::string &what) { if(from >= to) return; fizzbuzz[from] = what; dofizzbuzz(fizzbuzz, from + inc, to, inc, what); }
void dofizzbuzz(fizzbuzz_t &fizzbuzz, int from, int to, int inc) { if(from >= to) return; fizzbuzz[from] = std::to_string(from); dofizzbuzz(fizzbuzz, from + inc, to, inc); }
void print(const fizzbuzz_it &begin, const fizzbuzz_it &end) { if (begin == end) return; std::cout second
Chase Cook
> Does not know JavaScript > code monkey
What?? So writing exclusively in low-level languages like C is being a code monkey?
Chase Ramirez
Not mine but yeah it is. List comprehensions are one of my favorite things about python.
Ayden King
Count all numbers from 1 to 100. If the number is divisible by 3, then say "fizz". If the number is divisible by 5, then say "buzz". Otherwise, say the number.
Christopher Reed
Any compiler still treats it as a variable, I had to change it myself to not "dynamically" set or variably modified as the error shoots out. Switching between C and Python is fucking me up with the pedantics.
>Can't use a language properly by adhering to its philosophy >"M-m-mmust be BAIT!!! Right guys??! I'm not dumb!!! wtf"
(You) just prove why most people using Python are fucking retards.
Finding prime factors is literally easier or just as easy as fizzbuzz, it just takes a long fucking time for a computer to do it for a large number; thus it's useful in encryption. It's only homework if you are in elementary school. I stole the idea from Project Euler lmao.
Caleb Ramirez
Is that Python?
Owen Price
int start = 0; int end = 100;
for (int i = start + 1; i < 101; i += 1) { if (i % 3 == 0) { System.out.print("Fizz"); if (i % 5 == 0) { System.out.print("Buzz"); } } else { if (i % 5 == 0) { System.out.print("Buzz"); } }
if (i % 3 != 0 && i % 5 != 0) { System.out.print(Integer.toString(i)); }
System.out.print("\n"); }
Owen Collins
>reddit spacing
Jace Johnson
>newfag
Lucas Mitchell
>That code snippet doesn't even do shit at all. At best you could say that it's not a complete program, but the function it defines has meaning. >Using while instead of for What iterator, if I may be so bold?
Robert Baker
char v[] = "FizzBuzz%d"; int b[] = {8,8,0,8,4,0,8,8,0,4,8,0,8,8,0};
static int mod(int x, int y) { return (x < y) ? x : mod(x-y, y); }
Twas a quite naive and simple solution, but it gets the job done. FYI, my laptop is a potato. time ./test 2 2 2 2 2 2 2 2 2 5 5 5 5 5 5 5 5 5
real 0m0.107s user 0m0.104s sys 0m0.000s
#include #include #include
using namespace std;
void genPrimes(vector& primes, int maxValue);
int main() { vector primes; int value = 1000000000;
genPrimes(primes, sqrt(value) + 1); for (int p : primes) { while (value % p == 0) { cout
Nicholas Flores
Recursive lazy solution in racket. What is the purpose of not using basic arithmetic for a problem like fizzbuzz? It's number theory, so you need to test at some point if things are divisible or not...
What language is this and how doesn't it contain branching?
Jaxson Jones
(defun is-mult-p (n multiple)
(= (rem n multiple) 0))
(defun fizzbuzz (&optional n)
(let ((n (or n 1)))
(if (> n 100)
nil
(progn
(let ((mult-3 (is-mult-p n 3)) (mult-5 (is-mult-p n 5))) (if mult-3(princ "Fizz"))(if mult-5(princ "Buzz")) (if (not (or mult-3 mult-5))
(princ n))
(princ #\linefeed)
(fizzbuzz (+ n 1)))))))
Ethan Myers
It's APL, here's a shorter version (∊∘(/∘('Fizz' 'Buzz')3∘∣(0=,)5∘∣),⍕(F⍨)3∘∣⍱⍥(=∘0)5∘∣)¨∘⍳
Also I said it's "cheating", because it never expresses branching (= goto = →), but its implementation obviously does, e.g. ¨ (each adverb), / (replicate verb), ⍳ (index vector verb).
Easton Sanchez
for i in range(1, 101): if(i % 3 == 0): print("FIZZ") if(i % 5 == 0): print("BUZZ") if not (i % 3 == 0 or i % 5 == 0): print(i)
Can we try some other fucking challenges other than goddamn fizzbuzz for once? It's already as solved as it can get when it comes to speed.
Jaxson Russell
Nice copy-paste brainlet
Adam Edwards
what if i originally wrote this
Isaiah Kelly
It's amazing how the lack of indentation and double newlines where they don't make sense really makes this code look less elegant than it is.
Cameron Robinson
where's "fizzbuzz" brainlet python?
Andrew Clark
> What's programming
Oliver Watson
Fizzbuzz is unnecessary, you dumb fucking (i % 15) brainlet, learn some software logic. It's an "if" statement after the previous "if", not an "elif". That's why the "if not" is included at the end instead of an "elif". Effectively making 3 if statements instead of what would be 4 or 5. It checks if it's divisible for 3 and 5.
If you cannot even get this wrapped around in your head, then go back to Sup Forums.
I don't know about this modulus, literals, or branching hokus pokus
Anthony Rodriguez
>Ultra hard mode: no branching #include int main() { int n; char* t[] = {"%d\n", "Fizz\n", "Buzz\n", "FizzBuzz\n"}; for (n = 1; n
Juan Morales
Run the code retard
Xavier Peterson
Yes it is. "Fizzbuzz" as a whole is only included because of readability, but that's not the point of these threads now is it?
If you check for (i % 3) AND THEN (i % 5) separately, you will get Fizz and then Buzz (in Python it's on seperate lines due to how print works).
So this: Output: 14 FIZZ BUZZ 16
Will be the same as: Output: 14 FIZZ BUZZ FIZZBUZZ 16
Or: Output: 14 FIZZBUZZ 16
The words are all attributed to the number 15. The program fundamentally just werks. You're so retarded you can't even comprehend a simple 7 line Python program that isn't even complicated.
If you still include (i % 15), kill yourself.
Logan Jackson
>not even requiring an enterprise-grade solution
Sad.
Isaiah Long
I RUNed
James Carter
it's called "fizzbuzz" print the fucking "fizzbuzz" you retarded
Jaxson Hernandez
his thing does print fizzbuzz. did you even read his post or are you actually autistic?
Chase Morris
In python3 pip3 install fzzbzz python3 import fzzbzz fzzbzz(100)