Created
November 17, 2014 02:48
-
-
Save fuadsaud/bd0d4de93dd3ce7bf577 to your computer and use it in GitHub Desktop.
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 characters
PLAINTEXT = ARGV[0].gsub(/[^A-Za-z]/, '') | |
KEY = ARGV[1] | |
p KEY | |
.chars | |
.cycle | |
.take(PLAINTEXT.size) | |
.zip(PLAINTEXT.chars) | |
.reduce(Hash.new { [] }) { |acc, (key, char)| acc.merge(key => acc[key] + [char]) } | |
.to_a | |
.sort | |
.flat_map(&:last) | |
.join |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment