Skip to content

Instantly share code, notes, and snippets.

@tenten0213
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenten0213/f1b2ea04b066a9d8b4df to your computer and use it in GitHub Desktop.
Save tenten0213/f1b2ea04b066a9d8b4df to your computer and use it in GitHub Desktop.
ジョン・ボン・ジョヴィ 元ネタ: https://twitter.com/yagiyyyy/status/473405016540053504
def gen_bonjovi
bonjovi = %w(ボ ン ジョ ヴィ)]
random_jovis = []
count = 0
while(random_jovis.last(8).join != "ジョン・ボン・ジョヴィ") do
count += 1
random_jovis.push("・") if count % 2 == 0
random_jovis.push(bonjovi.sample)
end
puts random_jovis.join
puts "\n\n #{count} Bon Jovis"
puts "
_人人人人人人人人人人人人人人_
> You Give Love a Bad Name <
 ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄
"
end
gen_bonjovi
def gen_bonjovi
bonjovi = %w(ボ ン ジョ ヴィ)
expect = %w(ジョ ン ・ ボ ン ・ ジョ ヴィ)
random_jovis = []
count = 0
while(random_jovis != expect) do
count += 1
random_jovis.push("・") if count % 2 == 0
random_jovis.push(bonjovi.sample)
print random_jovis.shift(random_jovis.size - expect.size).join if random_jovis.size > expect.size
end
print random_jovis.join
puts "\n\n #{count} Bon Jovis"
puts "
_人人人人人人人人人人人人人人_
> You Give Love a Bad Name <
 ̄Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y ̄
"
end
gen_bonjovi
@tenten0213
Copy link
Author

配列の要素を極力少ない状態に保つバージョンも追加。
上のやつだと文字列の結合と出力に時間がかかるし、メモリも食いそう。

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