Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'jcode' # Usun jesli uzywasz Ruby 1.9
- def zadany_element(x,y)
- count = 0
- x.each{|z|
- return count if y == z
- count += 1
- }
- return 0 # 0 zamiast false, by zapobiec bledom
- end
- $alfabet = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
- def przesun(x,y)
- result = ''
- x = x.upcase
- x.each_char{|z|
- result << $alfabet[(zadany_element($alfabet,z)+y)%26]
- }
- return result
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement