Skip to content

Instantly share code, notes, and snippets.

@wulab
Last active December 2, 2020 17:12
Show Gist options
  • Save wulab/f402a9ee4c87fddf65680efb5b06711e to your computer and use it in GitHub Desktop.
Save wulab/f402a9ee4c87fddf65680efb5b06711e to your computer and use it in GitHub Desktop.
const lessonList = [...]
const timeslotRange = [...]
const roomRange = [...]
const timeTable = new TimeTable()
const timeLimit = 5000
const startTime = new Date()
let currentTime = startTime
let bestScore = 0
while (currentTime - startTime < timeLimit) {
for (const lesson of lessonList) {
const timeslot = pickOne(timeslotRange)
const room = pickOne(room)
lesson.set(timeslot, room)
timeTable.add(lesson)
}
const score = timeTable.calculateScore()
if (score > bestScore) {
bestScore = score
}
currentTime = new Date()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment