brewersfan1976

decipher.rb

Oct 14th, 2016
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.60 KB | None | 0 0
  1. def decipher(cipher)
  2.     x = 0
  3.     output = ""
  4.     string = ""
  5.     while (x < cipher.length)
  6.           if cipher[x] != '9' then
  7.              string = string + cipher[x]
  8.              string = string + cipher[x + 1]
  9.              string = string + cipher[x + 2]
  10.              output = output + (string.to_i).chr
  11.              x = x + 3
  12.           else
  13.              string = string + cipher[x]
  14.              string = string + cipher[x + 1]
  15.              output = output + (string.to_i).chr
  16.              x = x + 2
  17.           end
  18.              
  19.           string = ""
  20.     end
  21.        
  22.     return output
  23. end
Advertisement
Add Comment
Please, Sign In to add comment