Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def which_price?(real, supposed)
- counts = [real, supposed]
- counts.map do |el|
- el.to_s.split('').select{ |el| el.match?(/\d/) }.map(&:to_i)
- end
- if counts[0] == counts[1]
- return 2
- elsif counts.map {|arr| arr[0] - arr[1]}
- .all? {|el| el.positive? || el.negative? }
- return 1
- else
- return 0
- end
- end
- real = '1-4'
- supposed = '4:6'
- puts which_price?(real, supposed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement