Created
June 2, 2010 04:35
-
-
Save ybenjo/421930 to your computer and use it in GitHub Desktop.
This file contains 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
team_mem = Hash.new{|h,k|h[k] = [ ]} | |
id_team = Hash.new{ } | |
id = [ ] | |
id_name = Hash.new{ } | |
tmp_team = "" | |
print "team? : " | |
tmp_team = gets.chomp! | |
loop do | |
print "add?" | |
break if gets.chomp.size > 6 | |
print "id? : " | |
tmp_id = gets.chomp! | |
id.push tmp_id | |
id_team[tmp_id] = tmp_team | |
team_mem[tmp_team].push tmp_id | |
print "name? : " | |
id_name[tmp_id] = gets.chomp | |
end | |
id_score = Hash.new{|h,k|h[k] = [ ]} | |
team_mem.each_pair do |key,mem_list| | |
print "team : #{key}, " | |
mem_list.each do |id| | |
print "id : #{id}, " | |
puts "name : #{id_name[id]}." | |
mem_list.reject{|x| x == id}.each do |oth_id| | |
puts "--------------------------" | |
print "#{id_name[oth_id]}'s score? : " | |
tmp_tmp = gets.chomp.to_f | |
print "#{id_name[oth_id]}'s score? : " | |
tmp_tmp += gets.chomp.to_f | |
id_score[oth_id].push tmp_tmp | |
end | |
puts "------------------------------------------------------------------------" | |
end | |
end | |
f = open("re_#{tmp_team}.txt","w") | |
id_score.each do |key,value| | |
score = value.inject(0.0){|s,v|s+=(v-10)}/value.size | |
piyo = score < 0 ? 20 + score : 20 | |
f.puts "#{key},#{piyo}" | |
end | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment