brewersfan1976

reflect_string.rb

Sep 15th, 2016
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.96 KB | None | 0 0
  1. def reflectString(inputString)
  2.     string_length = inputString.length
  3.     x = 0
  4.     outputString = ""
  5.    
  6.     while (x < string_length)
  7.           if inputString[x] == 'a' then
  8.              outputString[x] = 'z'
  9.           end
  10.              
  11.           if inputString[x] == 'b' then
  12.              outputString[x] = 'y'
  13.           end
  14.              
  15.           if inputString[x] == 'c' then
  16.              outputString[x] = 'x'
  17.           end
  18.              
  19.           if inputString[x] == 'd' then
  20.              outputString[x] = 'w'
  21.           end
  22.              
  23.           if inputString[x] == 'e' then
  24.              outputString[x] = 'v'
  25.           end
  26.              
  27.           if inputString[x] == 'f' then
  28.              outputString[x] = 'u'
  29.           end
  30.              
  31.           if inputString[x] == 'g' then
  32.              outputString[x] = 't'
  33.           end
  34.              
  35.           if inputString[x] == 'h' then
  36.              outputString[x] = 's'
  37.           end
  38.              
  39.           if inputString[x] == 'i' then
  40.              outputString[x] = 'r'
  41.           end
  42.              
  43.           if inputString[x] == 'j' then
  44.              outputString[x] = 'q'
  45.           end
  46.              
  47.           if inputString[x] == 'k' then
  48.              outputString[x] = 'p'
  49.           end
  50.              
  51.           if inputString[x] == 'l' then
  52.              outputString[x] = 'o'
  53.           end
  54.              
  55.           if inputString[x] == 'm' then
  56.              outputString[x] = 'n'
  57.           end
  58.              
  59.           if inputString[x] == 'n' then
  60.              outputString[x] = 'm'
  61.           end
  62.              
  63.           if inputString[x] == 'o' then
  64.              outputString[x] = 'l'
  65.           end
  66.              
  67.           if inputString[x] == 'p' then
  68.              outputString[x] = 'k'
  69.           end
  70.              
  71.           if inputString[x] == 'q' then
  72.              outputString[x] = 'j'
  73.           end
  74.              
  75.           if inputString[x] == 'r' then
  76.              outputString[x] = 'i'
  77.           end
  78.              
  79.           if inputString[x] == 's' then
  80.              outputString[x] = 'h'
  81.           end
  82.              
  83.           if inputString[x] == 't' then
  84.              outputString[x] = 'g'
  85.           end
  86.              
  87.           if inputString[x] == 'u' then
  88.              outputString[x] = 'f'
  89.           end
  90.              
  91.           if inputString[x] == 'v' then
  92.              outputString[x] = 'e'
  93.           end
  94.              
  95.           if inputString[x] == 'w' then
  96.              outputString[x] = 'd'
  97.           end
  98.              
  99.           if inputString[x] == 'x' then
  100.              outputString[x] = 'c'
  101.           end
  102.              
  103.           if inputString[x] == 'y' then
  104.              outputString[x] = 'b'
  105.           end
  106.              
  107.           if inputString[x] == 'z' then
  108.              outputString[x] = 'a'
  109.           end
  110.              
  111.           x = x + 1
  112.     end
  113.              
  114.     return outputString
  115. end
Advertisement
Add Comment
Please, Sign In to add comment