Skip to content

Commit c376cfd

Browse files
author
Peter van der Wal
committed
fix: don't resubmit puzzles
When a puzzle was already submitted, and a new implementation was tried but that implementation gave the wrong answer, then the puzzle was tried to submit again. This fix prevents that.
1 parent 65c8fbb commit c376cfd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/Service/AnswerService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ public function __construct(
2121
*/
2222
public function isCorrectAnswer(int $year, int $day, int $part, int|string $answer): ?bool
2323
{
24-
if ((string)$answer === $this->getSubmittedAnswer($year, $day, $part)) {
25-
return true;
24+
$submittedAnswer = $this->getSubmittedAnswer($year, $day, $part);
25+
if ($submittedAnswer !== null) {
26+
return (string)$answer === $submittedAnswer;
2627
}
2728
if (in_array($answer, $this->getKnownWrongAnswers($year, $day, $part), true)) {
2829
return false;

0 commit comments

Comments
 (0)