brewersfan1976

common_points.rb

Mar 6th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.29 KB | None | 0 0
  1. def commonPoints(l1, r1, l2, r2)
  2.     max = [l1, r1, l2, r2].max
  3.     sum = 0
  4.     x = -10
  5.    
  6.     while (x <= max)
  7.           if l1 < x and x < r1 and l2 < x and x < r2 then
  8.              sum = sum + 1
  9.           end
  10.              
  11.           x = x + 1
  12.     end
  13.        
  14.     return sum
  15. end
Advertisement
Add Comment
Please, Sign In to add comment