Skip to content

Instantly share code, notes, and snippets.

@tancnle
Created July 2, 2015 04:12
Show Gist options
  • Save tancnle/69aa8dd7e52f24f317e8 to your computer and use it in GitHub Desktop.
Save tancnle/69aa8dd7e52f24f317e8 to your computer and use it in GitHub Desktop.
Allocate plans to students
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