DEV Community

Discussion on: What's the Wackiest Coding Hack You've Ever Seen?

Collapse
 
ibrahimraimi profile image
Ibrahim Raimi

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.

Collapse
 
darthbob88 profile image
Raymond Price

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.