Skip to content

Commit

Permalink
accellerated validation algorithm by \infty%
Browse files Browse the repository at this point in the history
  • Loading branch information
denniwang committed Jan 22, 2025
1 parent d09803a commit 210c402
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/common/src/major2-validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ function validateCourseRequirement(
return Err(CourseError(r));
}

const max_combo = 1000;
const max_combo = 5;
function validateRangeRequirement(
r: ICourseRange2,
tracker: CourseValidationTracker
Expand All @@ -451,6 +451,7 @@ function validateRangeRequirement(
const solutionsSoFar: Array<Solution> = [];

// produce all combinations of the courses
// This is inefficient, added a hard limit (max_combo = 5) to prevent infinite loops / too many combinations
for (const course of courses) {
const solutionsSoFarWithCourse: Array<Solution> = [];
const cs = courseToString(course);
Expand Down Expand Up @@ -480,6 +481,8 @@ function validateRangeRequirement(
// Update the solutions so far
solutionsSoFar.push(...solutionsSoFarWithCourse);

// If we have too many combinations, return an error
// Error should make validation icon gray
if (solutionsSoFar.length > max_combo) {
return Err({
type: MajorValidationErrorType.Course,
Expand Down

0 comments on commit 210c402

Please sign in to comment.