Upgrade to Pro — share decks privately, control downloads, hide ads and more …

one_liner_fizzbuzz

maimu
December 07, 2023

 one_liner_fizzbuzz

maimu

December 07, 2023
Tweet

More Decks by maimu

Other Decks in Programming

Transcript

  1. 条件分岐を追加! seq 100 | awk '{ if ($1 % 15

    == 0) print "FizzBuzz"; else if ($1 % 3 == 0) print "Fizz"; else if ($1 % 5 == 0) print "Buzz"; else print $1; }'
  2. Rubyワンライナーでもやってみた seq 100 | ruby -ne 'if $_.to_i%15==0; puts "FizzBuzz"

    elsif $_.to_i%5==0; puts "Buzz" elsif $_.to_i%3==0; puts "Fizz" else puts $_ end'