Ruby 初心者スレッド Part 17
■ このスレッドは過去ログ倉庫に格納されています
0453デフォルトの名無しさん
2008/02/01(金) 13:59:12とりあえず脊髄反射的にバラしてみる
s_splitted = s.split('')
t_splitted = t.split('')
zipped = s_splitted.zip(t_splitted)
zipped.inject(0){|x,y|
y[0] == if y[1] then
x
else
x += if y[0] =~ /[aiueo]/ then
2
else
1
end
end
}
split ttp://www.ruby-lang.org/ja/man/html/String.html#split
zip ttp://www.ruby-lang.org/ja/man/html/Enumerable.html#zip
inject ttp://www.ruby-lang.org/ja/man/html/Enumerable.html#inject
■ このスレッドは過去ログ倉庫に格納されています