Creating a randomized class schedule

scraffat

New Member
Joined
Aug 27, 2021
Messages
2
Office Version
  1. 365
Platform
  1. Windows
Here's a brain teaser (that I can't come up with a solution for:

I have 60 children that each need to take 4 classes in a day.

There are 4 time slots for the classes, and 15 slots in each class. I don't want the same students in each class, would like to randomize it a bit.

Any ideas??
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
Hi Scraffat,

The obvious solution would be to use one of the RAND functions but the challenge is that if you make a change with causes it to recalculate then a new set of random numbers is generated and so your results change. You could generate random numbers then copy&paste as values to fix them but I wanted to avoid a manual task and you'd still have to handle duplicate results.

I'm just showing a part of each table for brevity but I did test using 60 names. Is this what you wanted?

Children Tab
You didn't say how you wanted the results shown so I've assumed a new schedule each day (so I'm using the date to modify calculation results) and I've assumed if you have children with the same name then you employ some kind of unique identifier yourself. This takes the ASCII table position of the 1st, 3rd and last character of their names multiplied then divides by the day, month (multiplied by 37) and year. I then pick the 3rd, 4th and 5th digit of that generated number as the "pseudo random" number. NOTE: There is no special significance to this calculation, it was just made up at 'random'.

Timetable Tab
This shows the 4 classes and 15 seats for each in the 60 rows. The dates are copied from the Children tab into row 1 and for each cell where you want a name it indexes into the list of 60 names using the unique calculated rank of the "pseudo random" number.

The unique rank ensures no name is repeated each day.

Scraffat.xlsx
ABCDEF
1Name28-Aug-2129-Aug-2130-Aug-2131-Aug-21
2Christine61351189
3Christina3278462
4Christy9784922
5Flora44199674
6Kayleigh28966739
7Mila95684320
8Adrian3765127
9Lucas52239671
Children
Cell Formulas
RangeFormula
D1:F1D1=C1+1
C2:F9C2=VALUE(MID((CODE($B2)*CODE(MID($B2&" ",3,1))*CODE(RIGHT($B2,1)))/(DAY(C$1)*37)+(MONTH(C$1)*37)+YEAR(C$1),3,3))


Cell Formulas
RangeFormula
C1:F1C1=Children!C1
C2:F9C2=INDEX(Children!$B$2:$B$61,RANK(Children!C2,Children!C$2:C$61,1)+COUNTIF(Children!C$2:C2,Children!C2)-1)
 
Upvote 0
Hi Scraffat,

The obvious solution would be to use one of the RAND functions but the challenge is that if you make a change with causes it to recalculate then a new set of random numbers is generated and so your results change. You could generate random numbers then copy&paste as values to fix them but I wanted to avoid a manual task and you'd still have to handle duplicate results.

I'm just showing a part of each table for brevity but I did test using 60 names. Is this what you wanted?

Children Tab
You didn't say how you wanted the results shown so I've assumed a new schedule each day (so I'm using the date to modify calculation results) and I've assumed if you have children with the same name then you employ some kind of unique identifier yourself. This takes the ASCII table position of the 1st, 3rd and last character of their names multiplied then divides by the day, month (multiplied by 37) and year. I then pick the 3rd, 4th and 5th digit of that generated number as the "pseudo random" number. NOTE: There is no special significance to this calculation, it was just made up at 'random'.

Timetable Tab
This shows the 4 classes and 15 seats for each in the 60 rows. The dates are copied from the Children tab into row 1 and for each cell where you want a name it indexes into the list of 60 names using the unique calculated rank of the "pseudo random" number.

The unique rank ensures no name is repeated each day.

Scraffat.xlsx
ABCDEF
1Name28-Aug-2129-Aug-2130-Aug-2131-Aug-21
2Christine61351189
3Christina3278462
4Christy9784922
5Flora44199674
6Kayleigh28966739
7Mila95684320
8Adrian3765127
9Lucas52239671
Children
Cell Formulas
RangeFormula
D1:F1D1=C1+1
C2:F9C2=VALUE(MID((CODE($B2)*CODE(MID($B2&" ",3,1))*CODE(RIGHT($B2,1)))/(DAY(C$1)*37)+(MONTH(C$1)*37)+YEAR(C$1),3,3))


Cell Formulas
RangeFormula
C1:F1C1=Children!C1
C2:F9C2=INDEX(Children!$B$2:$B$61,RANK(Children!C2,Children!C$2:C$61,1)+COUNTIF(Children!C$2:C2,Children!C2)-1)
You're a wizard!!! THANK YOU!
 
Upvote 0

Forum statistics

Threads
1,215,237
Messages
6,123,800
Members
449,127
Latest member
Cyko

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top