brewersfan1976

higher_version.rb

Oct 14th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.55 KB | None | 0 0
  1. def higherVersion(ver1, ver2)
  2.     array1 = Array.new
  3.     array2 = Array.new
  4.     array1 = ver1.split('.')
  5.     array2 = ver2.split('.')
  6.     x = 0
  7.    
  8.     while (x < array1.length)
  9.           if array1[x].to_i > array2[x].to_i and x == 0 then
  10.              return true
  11.           end
  12.              
  13.           if x > 0 then
  14.              if array1[x - 1].to_i == array2[x - 1].to_i and array1[x].to_i > array2[x].to_i then
  15.                  return true
  16.              end
  17.           end
  18.              
  19.           x = x + 1
  20.     end
  21.    
  22.     return false
  23. end
Advertisement
Add Comment
Please, Sign In to add comment