X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=turbot%2Fround.py;h=73f23d75bc32aa3544b8f0b62569c84ccd10af1d;hb=4bca55ecc12eb56357e5a5279fece0adced30430;hp=3e12f5c17eb560c0650b1d8c1c22435a94f2fb1f;hpb=61f3273b217ea1be55adc24c294a4318a98733ef;p=turbot diff --git a/turbot/round.py b/turbot/round.py index 3e12f5c..73f23d7 100644 --- a/turbot/round.py +++ b/turbot/round.py @@ -32,3 +32,33 @@ def round_blocks(round, puzzles, omit_header=False): blocks += puzzle_blocks(puzzle) return blocks + +def round_quoted_puzzles_titles_answers(round, puzzles): + answers = [] + for puzzle in puzzles: + if round: + if 'rounds' not in puzzle: + continue + if round not in puzzle['rounds']: + continue + else: + if 'rounds' in puzzle and len(puzzle['rounds']): + continue + answer = {} + answer['name'] = puzzle['name'] + if puzzle['status'] == 'solved' and 'solution' in puzzle: + answer['solution'] = ", ".join(puzzle['solution']) + else: + answer['solution'] = "" + answers.append(answer) + + if not answers: + return "" + + longest = max(len(ans['name']) for ans in answers) + + format = "%{}s: %s".format(longest) + + return "```" + "\n".join( + [format % (ans['name'], ans['solution']) for ans in answers] + ) + "```"