This is the output of the memo.
This time, I envisioned a program to calculate common shopping points. Code below
qiita.rb
n = gets.to_i
d_1,p_1 = Array.new(n){gets.chomp.split(' ').map{|i| i.to_i}}.transpose
p = 0
c = 0
while n > 0 do
if d_1[c].to_s.include?("3")
p += (p_1[c] * 0.03).floor
elsif d_1[c].to_s.include?("5")
p += (p_1[c] * 0.05).floor
else
p += (p_1[c] * 0.01).floor
end
c = c + 1
n = n - 1
end
puts p
The problem is how to use one point, include ?. As a result, I returned it to a string with to_s and referred to it. Is there a method that directly refers to numbers? When thought.
I couldn't find it as far as I searched, but is there something? .. ..
Recommended Posts