Last active
August 2, 2025 18:34
-
-
Save matugm/db363c7131e6af27716c to your computer and use it in GitHub Desktop.
Revisions
-
matugm revised this gist
Sep 6, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ def caesar_cipher(string, shift = 1) encrypter = non_caps.merge(caps) string.chars.map { |c| encrypter.fetch(c, c) } end p caesar_cipher("testingzZ1Z").join -
matugm revised this gist
Jul 21, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ def caesar_cipher(string, shift = 1) alphabet = Array('a'..'z') non_caps = Hash[alphabet.zip(alphabet.rotate(shift))] -
matugm revised this gist
Jul 21, 2015 . 1 changed file with 14 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ def caesar_cipher(string, shift = 1) alphabet = Array('a'..'z') non_caps = Hash[alphabet.zip(alphabet.rotate(shift))] alphabet = Array('A'..'Z') caps = Hash[alphabet.zip(alphabet.rotate(shift))] encrypter = non_caps.merge(caps) string.chars.map { |c| encrypter.fetch(c, '?') } end p caesar_cipher("testingzZ1Z").join -
matugm revised this gist
Jun 3, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ def caesar_cipher(string, shift = 1) alphabet = Array('a'..'z') encrypter = Hash[alphabet.zip(alphabet.rotate(shift))] string.chars.map { |c| encrypter.fetch(c, " ") } end p caesar_cipher("testing").join -
matugm revised this gist
Jun 3, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ def caesar_cipher(string, shift = 1) alphabet = Array('a'..'z') encrypter = Hash[alphabet.zip(alphabet.rotate(shift))] string.chars.map { |c| encrypter[c] } end p caesar_cipher("testing").join -
matugm revised this gist
Jun 3, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ def caesar_cipher(string, shift = 1) alphabet = Array('a'..'z') @encrypter = Hash[alphabet.zip(alphabet.rotate(shift))] string.chars.map { |c| @encrypter[c] } end p caesar_cipher("testing").join -
matugm revised this gist
Mar 6, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ def caesar_cipher(string) alphabet = Array('a'..'z') @encrypter = Hash[alphabet.zip(alphabet.rotate(1))] -
matugm revised this gist
Mar 6, 2015 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ def caesar_cipher(string) alphabet = Array('a'..'z') @encrypter = Hash[alphabet.zip(alphabet.rotate(1))] string.chars.map { |c| @encrypter[c] } end p caesar_cipher("testing") -
matugm created this gist
Mar 6, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ ALPHABET_SIZE = 26 def caesar_cipher(string) shiftyArray = [] charLine = string.chars.map(&:ord) shift = 1 ALPHABET_SIZE.times do |shift| shiftyArray << charLine.map do |c| ((c + shift) < 123 ? (c + shift) : (c + shift) - 26).chr end.join end shiftyArray end puts caesar_cipher("testing")