Created
July 2, 2015 04:12
-
-
Save tancnle/69aa8dd7e52f24f317e8 to your computer and use it in GitHub Desktop.
Allocate plans to students
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
require 'matrix' | |
cups_per_student_per_row = 2 | |
plants = %w( G C R V ) | |
students = %w( Alice Bob Charlie David Eve Fred Ginny Harriet Ileana Joseph Kincaid Larry ).sort | |
layout = Matrix[ | |
24.times.map{ plants.sample }, | |
24.times.map{ plants.sample } | |
] | |
cols = layout.column_vectors() | |
allocations = Hash[ students.zip(cols.each_slice(cups_per_student_per_row)) ] | |
allocations['Bob'] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment