Created
June 2, 2012 10:09
-
-
Save asflash8/2857651 to your computer and use it in GitHub Desktop.
みなとRuby会議01 ソーシャルコーディング あみだくじ
This file contains hidden or 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
person_num = ARGV.first.to_i | |
person_names = ('A'..'Z').to_a | |
height = 10 | |
person_num.times do |p| | |
print "#{person_names[p]} " | |
end | |
puts | |
height.times do |n| | |
line_display_num = rand(person_num -1) | |
person_num.times do |p| | |
if p == line_display_num | |
print '|---' | |
else | |
print '| ' | |
end | |
end | |
puts | |
end | |
hit_num = rand(person_num) | |
person_num.times do |p| | |
if p == hit_num | |
print "!!! " | |
else | |
print " " | |
end | |
end | |
puts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
みなとRuby会議01 ソーシャルコーディング
お題
あみだくじを作ってください
仕様
・当たりの数は一つ
・横線がランダムに配置されること
・横線の数>0
・横線が複数繋がってはいけない
・人数の指定ができるようにする
これもRubyっぽくないな・・・動いたのでよしとする