From 1d613e69f834cf1caf996a054db2326a496d481b Mon Sep 17 00:00:00 2001 From: derailed-dash Date: Sat, 13 Jan 2024 20:41:32 +0000 Subject: [PATCH] Docs improvement --- src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb b/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb index f679c5a..4f45afe 100644 --- a/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb +++ b/src/AoC_2023/Dazbo's_Advent_of_Code_2023.ipynb @@ -4893,13 +4893,18 @@ " # We can subst char for itself (no change), or for ?\n", " if self.record[char_idx] in (char, \"?\"): \n", " if char == \".\": \n", - " # we're extending the operational section or ending the damaged group\n", + " # we're either extending the operational section or ending the damaged group\n", " if curr_group_len == 0: # we're not in a group, so we must be extending\n", " count += self.get_arrangements_count(char_idx+1, curr_group_idx, 0)\n", - " elif (curr_group_idx < len(self.damaged_groups) \n", - " and curr_group_len == self.damaged_groups[curr_group_idx]):\n", + " elif (curr_group_idx < len(self.damaged_groups) and \n", + " curr_group_len == self.damaged_groups[curr_group_idx]):\n", " # we're adding a . after a #, so the group is now complete; move on to next group\n", " count += self.get_arrangements_count(char_idx+1, curr_group_idx+1, 0)\n", + " else:\n", + " # either: curr_group_len is too long\n", + " # or: we're adding . before completing a group\n", + " # Both are invalid \n", + " pass\n", " else: # we're adding a #; extend the current group (which might be empty at this point)\n", " count += self.get_arrangements_count(char_idx+1, curr_group_idx, curr_group_len+1)\n", " \n", @@ -4966,13 +4971,13 @@ "source": [ "%%time\n", "sample_inputs = []\n", - "sample_inputs.append(\"\"\"???.### 1,1,3\n", + "sample_inputs.append(\"\"\"\\\n", + "???.### 1,1,3\n", ".??..??...?##. 1,1,3\n", "?#?#?#?#?#?#?#? 1,3,1,6\n", "????.#...#... 4,1,1\n", "????.######..#####. 1,6,5\n", - "?###???????? 3,2,1\n", - "\"\"\")\n", + "?###???????? 3,2,1\"\"\")\n", "sample_answers = [21]\n", "\n", "for curr_input, curr_ans in zip(sample_inputs, sample_answers):\n",