Hacker News new | ask | show | jobs
by Zeik 899 days ago
What was the trivial variation? I’d like to give it a try.
1 comments

This was the FizzBuzz python code from chatGPT that prints out differently if value is even and dividable by 3 and 5. Simple task and very nice implementation.

def fizzbuzz_even_surprise(n): return [ (lambda x: 'Surprise' if x % 2 == 0 and x % 3 == 0 and x % 5 == 0 else 'Fizz'(x % 3 == 0) + 'Buzz'(x % 5 == 0) or x)(x) for x in range(1, n+1) ]

print(fizzbuzz_even_surprise(30))