20 lines
683 B
Python
20 lines
683 B
Python
def printSolution(day, part, solution, test=None, test_case=0, exec_time=None):
|
|
if exec_time is None:
|
|
time_output = ""
|
|
else:
|
|
units = ['s', 'ms', 'μs', 'ns']
|
|
unit = 0
|
|
while exec_time < 1:
|
|
exec_time *= 1000
|
|
unit += 1
|
|
|
|
time_output = " (Average run time: %1.2f%s)" % (exec_time, units[unit])
|
|
|
|
if test is not None:
|
|
print(
|
|
"(TEST case%d/day%d/part%d) -- got '%s' -- expected '%s' -> %s"
|
|
% (test_case, day, part, solution, test, "correct" if test == solution else "WRONG")
|
|
)
|
|
else:
|
|
print("Solution to day %s, part %s: %s%s" % (day, part, solution, time_output))
|