Skip to content

Instantly share code, notes, and snippets.

@maripiyoko
Created February 12, 2015 00:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maripiyoko/0cca37fea915be46f879 to your computer and use it in GitHub Desktop.
Save maripiyoko/0cca37fea915be46f879 to your computer and use it in GitHub Desktop.
パタトクカシー問題
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
@maripiyoko
Copy link
Author

ピタゴラスイッチのパタトクカシー問題。
パトカー
タクシー
をパタトクカシーにする。
それを戻すのも。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment