def verify(num, filename=None, exit=True):
p = Problem(num)<EOL>filename = filename or p.filename()<EOL>if not os.path.isfile(filename):<EOL><INDENT>if p.glob:<EOL><INDENT>filename = str(p.file)<EOL><DEDENT>else:<EOL><INDENT>click.secho('<STR_LIT>' % p.num, fg='<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>solution = p.solution<EOL>click.echo('<STR_LIT>'.format(filename), nl=False)<EOL>cmd = (sys.executable or '<STR_LIT>', filename)<EOL>start = clock()<EOL>proc = subprocess.Popen(cmd, stdout=subprocess.PIPE)<EOL>stdout = proc.communicate()[<NUM_LIT:0>]<EOL>end = clock()<EOL>time_info = format_time(start, end)<EOL>if proc.poll() != <NUM_LIT:0>:<EOL><INDENT>click.secho('<STR_LIT>'.format(filename), fg='<STR_LIT>')<EOL>click.secho(time_info, fg='<STR_LIT>')<EOL>return sys.exit(<NUM_LIT:1>) if exit else None<EOL><DEDENT>if isinstance(stdout, bytes):<EOL><INDENT>output = stdout.decode('<STR_LIT:ascii>')<EOL><DEDENT>output_lines = output.splitlines() if output else ['<STR_LIT>']<EOL>if len(output_lines) > <NUM_LIT:1>:<EOL><INDENT>is_correct = False<EOL>click.echo()  <EOL>click.secho('<STR_LIT:\n>'.join(output_lines), bold=True, fg='<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>is_correct = output_lines[<NUM_LIT:0>] == solution<EOL>fg_colour = '<STR_LIT>' if is_correct else '<STR_LIT>'<EOL>click.secho(output_lines[<NUM_LIT:0>], bold=True, fg=fg_colour)<EOL><DEDENT>click.secho(time_info, fg='<STR_LIT>')<EOL>if is_correct:<EOL><INDENT>p.file.change_suffix('<STR_LIT>')<EOL><DEDENT>return sys.exit(<NUM_LIT:1>) if exit and not is_correct else is_correct<EOL>
Verifies the solution to a problem.