Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
18
Task/General-FizzBuzz/Ruby/general-fizzbuzz.rb
Normal file
18
Task/General-FizzBuzz/Ruby/general-fizzbuzz.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
def general_fizzbuzz(text)
|
||||
num, *nword = text.split
|
||||
num = num.to_i
|
||||
dict = nword.each_slice(2).map{|n,word| [n.to_i,word]}
|
||||
(1..num).each do |i|
|
||||
str = dict.map{|n,word| word if i%n==0}.join
|
||||
puts str.empty? ? i : str
|
||||
end
|
||||
end
|
||||
|
||||
text = <<EOS
|
||||
20
|
||||
3 Fizz
|
||||
5 Buzz
|
||||
7 Baxx
|
||||
EOS
|
||||
|
||||
general_fizzbuzz(text)
|
||||
Loading…
Add table
Add a link
Reference in a new issue