The FizzBuzz code challenge, where developers are asked to write a program that prints the numbers from 1 to 100. But for multiples of three, the program should print Fizz instead of the number, and for multiples of five, it should print Buzz. For numbers that are multiples of both three and five, the program should print FizzBuzz. This challenge has led to some creative solutions, including one developer who wrote the entire program in one line of code using a ternary operator.
I saw one that worked by finding the right seed for an RNG, then for int ii from 0 to 100 { print [ "Fizz", "Buzz", "FizzBuzz", ii ][rand.nextInt() % 4] }
Another one, that I want to do myself, used a genetic algorithm to evolve an array containing the correct sequence of strings.
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.
The
FizzBuzzcode challenge, where developers are asked to write a program that prints the numbers from 1 to 100. But for multiples of three, the program should printFizzinstead of the number, and for multiples of five, it should printBuzz. For numbers that are multiples of both three and five, the program should printFizzBuzz. This challenge has led to some creative solutions, including one developer who wrote the entire program in one line of code using a ternary operator.I saw one that worked by finding the right seed for an RNG, then
for int ii from 0 to 100 { print [ "Fizz", "Buzz", "FizzBuzz", ii ][rand.nextInt() % 4] }Another one, that I want to do myself, used a genetic algorithm to evolve an array containing the correct sequence of strings.