@@ -95,7 +95,7 @@ def verify_answer(problem):
95
95
96
96
# Calculate the wall time and format the output
97
97
wall_time = wall_end - wall_start
98
- time_info = ' (time elapsed: {0}) ' .format (format_time (wall_time ))
98
+ time_info = 'Time elapsed: {0}' .format (format_time (wall_time ))
99
99
100
100
# Python 3 returns bytes; use a valid encoding like ASCII as the output
101
101
# will fall in that range
@@ -116,20 +116,22 @@ def verify_answer(problem):
116
116
try :
117
117
if output [- 1 ] == '\n ' :
118
118
output = output [:- 1 ]
119
-
120
- # If there is still a newline, the output is multilined. Print the
121
- # first line of the output on a separate line from the "checking
122
- # against solution" message.
123
- if '\n ' in output :
124
- output = '\n ' + output
125
-
126
119
except IndexError :
127
120
output = "[no output]"
128
121
129
- is_correct = output .strip () == solution
130
- click .secho (
131
- output , bold = True , nl = False , fg = ('green' if is_correct else 'red' )
132
- )
122
+ # If there is still a newline, the output is multilined. Print the
123
+ # first line of the output on a separate line from the "checking
124
+ # against solution" message. Additionally, a multi-line output is
125
+ # not going to be correct, so skip the solution check.
126
+ if '\n ' in output :
127
+ # Multi-line output
128
+ is_correct = False
129
+ click .secho ('\n ' + output , bold = True , fg = 'red' )
130
+ else :
131
+ is_correct = output .strip () == solution
132
+ fg_colour = 'green' if is_correct else 'red'
133
+ click .secho (output , bold = True , fg = fg_colour )
134
+
133
135
click .secho (time_info , fg = 'cyan' )
134
136
return is_correct
135
137
0 commit comments