brewersfan1976

is_tandem_repeat.rb

Sep 25th, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.57 KB | None | 0 0
  1. def isTandemRepeat(inputString)
  2.     if inputString.length % 2 != 0 then
  3.        return false
  4.     end
  5.        
  6.     x = 0
  7.     string_1 = ""
  8.     string_2 = ""
  9.        
  10.     while (x < inputString.length / 2)
  11.           string_1[x] = inputString[x]
  12.           x = x + 1
  13.     end
  14.        
  15.     x = inputString.length / 2
  16.     y = 0
  17.        
  18.     while (x < inputString.length)
  19.           string_2[y] = inputString[x]
  20.           x = x + 1
  21.           y = y + 1
  22.     end
  23.        
  24.     if string_1 == string_2 then
  25.        return true
  26.     else
  27.        return false
  28.     end
  29. end
Advertisement
Add Comment
Please, Sign In to add comment