Skip to content

Commit

Permalink
day 92: return nil for partitioned DAG
Browse files Browse the repository at this point in the history
  • Loading branch information
vaskoz committed Nov 23, 2018
1 parent d77fa04 commit e162756
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 3 additions & 0 deletions day92/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ func CourseOrder(prereq map[string][]string) []string {
}
}
}
if len(marked) != len(prereq) {
return nil
}
reverse(result)
return result
}
Expand Down
16 changes: 13 additions & 3 deletions day92/problem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@ var testcases = []struct {
expected []string
}{
{map[string][]string{
"CSC300": []string{"CSC100", "CSC200"},
"CSC200": []string{"CSC100"},
"CSC100": []string{},
"CSC300": {"CSC100", "CSC200"},
"CSC200": {"CSC100"},
"CSC100": {},
},
[]string{"CSC100", "CSC200", "CSC300"}},
{map[string][]string{
"CSC300": {"CSC100"},
"CSC100": {"CSC300"},
},
[]string{"CSC100", "CSC300"}},
{map[string][]string{
"CSC300": {"CSC100"},
"CSC400": {"CSC200"},
},
nil},
}

func TestCourseOrder(t *testing.T) {
Expand Down

0 comments on commit e162756

Please sign in to comment.