brewersfan1976

stolen_lunch.rb

Jan 13th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.64 KB | None | 0 0
  1. def stolenLunch(note)
  2.     x = 0
  3.     string = ""
  4.     array_1 = ['a','b','c','d','e','f','g','h','i','j']
  5.     array_2 = [0,1,2,3,4,5,6,7,8,9]
  6.    
  7.     while (x < note.length)
  8.           string = string + note[x]
  9.           x = x + 1
  10.     end
  11.    
  12.     x = 0
  13.    
  14.    while (x < string.length)
  15.          if string[x] >= '0' and string[x] <= '9' then
  16.             string[x] = array_1[string[x].to_i]
  17.          elsif
  18.             string[x] >= 'a' and string[x] <= 'j' then
  19.             index = array_1.index(string[x])
  20.             string[x] = array_2[index].to_s
  21.          end
  22.        
  23.          x = x + 1
  24.    end
  25.              
  26.    return string
  27. end
Advertisement
Add Comment
Please, Sign In to add comment