Fizz Buzz - CodeEval
Ruby 1.9.3
だった。もっとすっきりと書けそう。
File.open(ARGV[0]).each_line {|line|
l = line.chomp.split(" ")
x, y, n = l[0].to_i, l[1].to_i, l[2].to_i
str = []
(1..n).each{|t|
if (t.modulo(x) == 0 ) && (t.modulo(y) == 0 )
str << "FB"
elsif (t.modulo(x) == 0 ) && (t.modulo(y) != 0 )
str << "F"
elsif (t.modulo(x) != 0 ) && (t.modulo(y) == 0 )
str << "B"
else
str << "#{t}"
end
}
puts str.join(" ")
}