Skip to content

Instantly share code, notes, and snippets.

@JessyCatterwaul
Created October 7, 2015 15:18
Show Gist options
  • Save JessyCatterwaul/2822c29c3b4ba7b8157b to your computer and use it in GitHub Desktop.
Save JessyCatterwaul/2822c29c3b4ba7b8157b to your computer and use it in GitHub Desktop.
Simple wins this round. forEach doesn't help with anything except obfuscation.
for 🔢 in 1...100{print([3:"Fi",5:"Bu"].reduce(nil){🔢%$1.0==0 ?$1.1+"zz"+($0 ?? ""):$0} ?? 🔢)} //93
for 🔢 in 1...100{print(🔢%15==0 ?"FizzBuzz":🔢%3==0 ?"Fizz":🔢%5==0 ?"Buzz":"\(🔢)")} //81
(1...100).forEach{print($0%15==0 ?"FizzBuzz":$0%3==0 ?"Fizz":$0%5==0 ?"Buzz":"\($0)")} //86
@johnhoover75
Copy link

Do you think with some effort you could get it under 50?

@JessyCatterwaul
Copy link
Author

No! Can you? I think the smallest number I've seen was 59, but I haven't seen anyone else do it in Swift.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment