So, I worked a little on similar projects and did not find anything that pushed me in the right direction, but how to solve this project, so I come here to Stack to get some advice. I'm not necessarily looking for a complete solution for this project, since I would like to solve it myself, simply by trying some tips on how to approach it.
What am i trying to do
I am trying to write a program to randomly create seats for eight weeks in a class. It reads a list of 80 names from an excel file and spits out another excel file, in this output file there are 8 sheets, one for each week, each of which has a random 8x10 structure. Is it easy?
There are three additional criteria that I would like to make to make this somewhat more perplexing:
- I would like not a single student to sit next to (in front, behind, or to the side) of the same student for two weeks.
- I would not want any one student to sit in the front or back rows for more than one week.
- These students live in dormitories together, and I would like that during any week there would be no students from the same room sitting next to each other.
This is for an 8-week MBA class, and the whole reason I'm trying to do this is to introduce students to new peers and spark new conversations.
What have i done so far
from openpyxl import Workbook, load_workbook
import random
import itertools
load_wb = raw_input('What is the name of the file containing your students?\n')
num_of_weeks = int(raw_input('How many weeks would you like?\n'))
dest_filename = 'seating_chart.xlsx'
students = []
load_wb = load_workbook(load_wb).active
for cell in load_wb.iter_rows():
students.append(cell[0].value)
def make_grid():
y_list = list(range(1, 11))
x_list = list(range(1, 9))
grid = []
for y in y_list:
for x in x_list:
grid.append((x,y))
return grid
save_wb = Workbook()
grid = make_grid()
for week in range(num_of_weeks):
week +=1
if week == 1:
ws = save_wb.active
else:
ws = save_wb.create_sheet()
ws.title = 'Week '+str(week)
random.shuffle(students)
for x, student in itertools.izip(grid, students):
x,y = x
ws.cell(row=x, column=y, value=student)
save_wb.save(filename=dest_filename)
, , , , , , Python , .
!:)