Created
February 12, 2015 00:57
-
-
Save maripiyoko/0cca37fea915be46f879 to your computer and use it in GitHub Desktop.
パタトクカシー問題
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 patatokukashi(words) | |
line1 = [] | |
line2 = [] | |
words.chars.each_slice(2) do |a,b| | |
line1.push(a) | |
line2.push(b) | |
end | |
line1.join("") + line2.join("") | |
end | |
def reverse_patatokukashi(words) | |
mid = words.size / 2 | |
lines = words.scan(/.{1,#{mid}}/) | |
lines[0].chars.zip(lines[1].chars).join("") | |
end | |
words = "This is a pen" | |
parsed_words = words.gsub(" ", "").upcase | |
chipherd_words = patatokukashi(parsed_words) | |
puts chipherd_words | |
original_words = reverse_patatokukashi(chipherd_words) | |
puts original_words |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ピタゴラスイッチのパタトクカシー問題。
パトカー
タクシー
をパタトクカシーにする。
それを戻すのも。