Last active
December 2, 2020 17:12
-
-
Save wulab/f402a9ee4c87fddf65680efb5b06711e to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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