Skip to content

Instantly share code, notes, and snippets.

@amashigeseiji
Created February 15, 2016 12:30
Show Gist options
  • Save amashigeseiji/abc81b8425292eab75ed to your computer and use it in GitHub Desktop.
Save amashigeseiji/abc81b8425292eab75ed to your computer and use it in GitHub Desktop.
class String
def cabmridge
tmp = []
split(' ').each do |word|
tmp2 = []
chars = word.chars
first = chars.shift
last = chars.pop
tmp.push tmp2.push(first).concat(chars.shuffle).push(last).join('')
end
tmp.join(' ')
end
end
p 'この ぶんしょう は いぎりす の ケンブリッジ だいがく の けんきゅう の けっか にんげんは もじ を にんしき する とき その さいしょ と さいご の もじさえ あっていれば じゅんばん は めちゃくちゃ でも ちゃんと よめる という けんきゅう に もとづいて わざと もじの じゅんばん を いれかえて あります'.cabmridge
@amashigeseiji
Copy link
Author

コメントいまさら気づきました!
一時変数やだなとは思ってましたが、なるほどです。

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