Last active
March 28, 2021 07:31
-
-
Save nandhasuhendra/7baaf073492867279f63321b4097fe4b to your computer and use it in GitHub Desktop.
UpKoding challange https://www.upkoding.com/proyek/pecahkan-pesan-rahasia-ini-17/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def caesar(string, shift = 1) | |
alpha_num = 'abcdefghijklmnopqrstuvwxyz1234567890'.split('') | |
shifted = Hash[alpha_num.zip(alpha_num.rotate(shift))] | |
string.downcase.chars.map { |chr| shifted.fetch(chr, chr) }.join | |
end | |
50.times do |index| | |
puts caesar('dyvayv9 f6b dr5a a6 b5t6cv9 ayv 0vt9va0 6w ayv b5zcv90v, 69 f6b 1b0a dr5a a6 7b90bv r tr9vv9 z5 ayv ih0a tv5ab9f, sr0zt t647bav9 796x9r44z5x z0 r5 v00v5azr3 02z33 a6 3vr95 - 0av7yv5 yrd2z5x', index) | |
end | |
# key => 18 | |
# message => whether you want to uncover the secrets of the universe, or you just want to pursue a career in the 21st century, basic computer programming is an essential skill to learn - stephen hawking |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment