Is there a numeric version of include?

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

Is there a numeric version of include?
A description of Interface that is often mistaken
Is there a performance difference between Oracle JDK and OpenJDK at the end of 2017?
[Xcode] First of all, this is a convenient shortcut
If there is a state transition, let's create a State class
What is a constructor?
What is a stream
What is a Servlet?
I made a Japanese version of Rails / devise automatic email
Determine that the value is a multiple of 〇 in Ruby
Finally, create a method for whether there is any character