Skip to content

Instantly share code, notes, and snippets.

@FromAtom
Created September 10, 2013 16:30
Show Gist options
  • Save FromAtom/6511976 to your computer and use it in GitHub Desktop.
Save FromAtom/6511976 to your computer and use it in GitHub Desktop.
ゼミ旅行の車割り当てをするコード
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)
@FromAtom
Copy link
Author

なるほどなるほど。
ドライバーは固定で、搭乗者を決めたかったのでmembersになってました。
passengerとかの方が適切でしたね。

ファイルにしたのは入出力の練習したかったからで特に理由はないです!

@Favorwilliams
Copy link

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,

[email protected]

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