brewersfan1976

stolen_lunch.rb

Oct 14th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.49 KB | None | 0 0
  1. def stolenLunch(note)
  2.     x = 0
  3.     output = ""
  4.     characters = ('a'..'j').to_a
  5.    
  6.     while (x < note.length)
  7.           if note[x] >= '0' and note[x] <= '9' then
  8.              output = output + characters[note[x].to_i]
  9.           elsif note[x] >= 'a' and note[x] <= 'j' then
  10.                 output = output + (note[x].ord - 'a'.ord).to_s
  11.           else
  12.                 output = output + note[x]
  13.           end
  14.              
  15.           x = x + 1
  16.     end
  17.        
  18.     return output
  19. end
Advertisement
Add Comment
Please, Sign In to add comment