Created
September 10, 2013 16:30
-
-
Save FromAtom/6511976 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
def assignCar(members, first_car_capacity) | |
members.shuffle! | |
puts "---First car members---" | |
puts members.first(first_car_capacity) | |
puts "---Second car members---" | |
puts members.last(members.length-first_car_capacity) | |
end | |
# snorkel member's car assign | |
snorkel_buf = File.read("snorkel_members.txt", :encoding => Encoding::UTF_8) | |
snorkel_members = snorkel_buf.rstrip.split(/\r?\n/).map {|line| line.chomp } | |
assignCar(snorkel_members,6) | |
# glassboat member's car assign | |
glassboat_buf = File.read("glassboat_members.txt", :encoding => Encoding::UTF_8) | |
glassboat_members = glassboat_buf.rstrip.split(/\r?\n/).map {|line| line.chomp } | |
assignCar(glassboat_members,6) |
My Pleasure to write you,
My name is Favor Williams,
My email address is
( [email protected])
Am interested to know
more about you,
Contact me for my
photo and other
important issue via,
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なるほどなるほど。
ドライバーは固定で、搭乗者を決めたかったのでmembersになってました。
passengerとかの方が適切でしたね。
ファイルにしたのは入出力の練習したかったからで特に理由はないです!