Skip to content

Instantly share code, notes, and snippets.

@asflash8
Created June 2, 2012 10:09
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asflash8/2857651 to your computer and use it in GitHub Desktop.
Save asflash8/2857651 to your computer and use it in GitHub Desktop.
みなとRuby会議01 ソーシャルコーディング あみだくじ
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
@asflash8
Copy link
Author

asflash8 commented Jun 2, 2012

みなとRuby会議01 ソーシャルコーディング
お題
 あみだくじを作ってください

仕様
 ・当たりの数は一つ
 ・横線がランダムに配置されること
 ・横線の数>0
 ・横線が複数繋がってはいけない
 ・人数の指定ができるようにする

これもRubyっぽくないな・・・動いたのでよしとする

@muddydixon
Copy link

面白いからjsで参戦してみた
https://gist.github.com/2859068

@asflash8
Copy link
Author

asflash8 commented Jun 4, 2012

おおお、うれしい!

横線は行でひとつはたしかに少ないですね…

コードを読んで勉強します!

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