Fizz Buzz

Pages: 123
Here is my calculator's horrible solution.

1
2
3
4
5
6
7
result{}1:=List{}1;
result{}{{x}}:=result{}(x-1)\cup List{}( f{}x);
f{}{{x}}:if IsInteger{}(x/3)IsInteger{}(x/5):=FizzBuzz;
f{}{{x}}:if IsInteger{}(x/3):=Fizz;
f{}{{x}}:if IsInteger{}(x/5):=Buzz;
f{}{{x}}:=x;
result{}100


http://vector-partition.jacobs-university.de/vpf/cgi-bin/calculator?textInput=result%7B%7D1%3A%3DList%7B%7D1%3B%0D%0Aresult%7B%7D%7B%7Bx%7D%7D%3A%3Dresult%7B%7D%28x-1%29%5Ccup+List%7B%7D%28+f%7B%7Dx%29%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3Aif+IsInteger%7B%7D%28x%2F3%29IsInteger%7B%7D%28x%2F5%29%3A%3DFizzBuzz%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3Aif+IsInteger%7B%7D%28x%2F3%29%3A%3DFizz%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3Aif+IsInteger%7B%7D%28x%2F5%29%3A%3DBuzz%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3A%3Dx%3B%0D%0Aresult%7B%7D100

At least, I didn't have to make up new syntax to make it work

Haha, but I can quantify the fizzbuzziness of my code very quickly:

1
2
3
4
5
6
7
result{}1:=1;
result{}{{x}}:=result{}(x-1)+( f{}x);
f{}{{x}}:if IsInteger{}(x/3)IsInteger{}(x/5):=FizzBuzz;
f{}{{x}}:if IsInteger{}(x/3):=Fizz;
f{}{{x}}:if IsInteger{}(x/5):=Buzz;
f{}{{x}}:=x;
result{}100


http://vector-partition.jacobs-university.de/vpf/cgi-bin/calculator?textInput=result%7B%7D1%3A%3D1%3B%0D%0Aresult%7B%7D%7B%7Bx%7D%7D%3A%3Dresult%7B%7D%28x-1%29%2B%28+f%7B%7Dx%29%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3Aif+IsInteger%7B%7D%28x%2F3%29IsInteger%7B%7D%28x%2F5%29%3A%3DFizzBuzz%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3Aif+IsInteger%7B%7D%28x%2F3%29%3A%3DFizz%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3Aif+IsInteger%7B%7D%28x%2F5%29%3A%3DBuzz%3B%0D%0Af%7B%7D%7B%7Bx%7D%7D%3A%3Dx%3B%0D%0Aresult%7B%7D100
Last edited on
Topic archived. No new replies allowed.
Pages: 123