Advertisement
Guest User

Untitled

a guest
Jul 7th, 2020
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.42 KB | None | 0 0
  1.  
  2. def which_price?(real, supposed)
  3.   counts = [real, supposed]
  4.  
  5.   counts.map do |el|
  6.     el.to_s.split('').select{ |el| el.match?(/\d/) }.map(&:to_i)
  7.   end
  8.    
  9.   if counts[0] == counts[1]
  10.     return 2
  11.   elsif counts.map {|arr| arr[0] - arr[1]}
  12.     .all? {|el| el.positive? || el.negative? }
  13.     return 1
  14.   else
  15.     return 0
  16.   end
  17. end
  18.  
  19. real = '1-4'
  20. supposed = '4:6'
  21.  
  22. puts which_price?(real, supposed)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement