Skip to content

Commit 713368e

Browse files
committed
streamlined color count grader code
1 parent 3a95f07 commit 713368e

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

coloring/grader.py

+1-8
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,14 @@ def grade(input_data, quality_data, submission):
5757

5858
colors = lineTwoParts
5959

60-
colorCount = {}
61-
for c in colors:
62-
if c in colorCount :
63-
colorCount[c] = colorCount[c] + 1
64-
else :
65-
colorCount[c] = 1
66-
6760
colorViolations = ''
6861
for edge in edges:
6962
if(colors[edge[0]] == colors[edge[1]]):
7063
colorViolations = colorViolations+'('+str(edge[0])+','+str(edge[1])+') ';
7164
if(len(colorViolations) > 1):
7265
return {'score':0.0, 'feedback':'the different color constraint was not satisfied on the following edges: '+colorViolations}
7366

74-
value = len(colorCount)
67+
value = len(set(colors))
7568
if value != obj :
7669
feedback = feedback + '\nWarning: submitted objective value is inconsistent with actual value. given: '+str(obj)+' actual value: '+str(value)
7770

0 commit comments

Comments
 (0)