brewersfan1976

alphabetic_shift.rb

Jul 12th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.43 KB | None | 0 0
  1. def alphabeticShift(inputString)
  2.     string_length = inputString.length
  3.     x = 0
  4.     new_string = ""
  5.    
  6.     while (x < string_length)
  7.           if inputString[x] == 'z' then
  8.              new_string = new_string + 'a'
  9.           else
  10.              number = inputString[x].ord + 1
  11.              new_string = new_string + number.chr
  12.           end
  13.              
  14.           x = x + 1
  15.     end
  16.        
  17.     return new_string
  18. end
Advertisement
Add Comment
Please, Sign In to add comment