diff --git a/2017/09/9.md b/2017/09/9.md index c8f3b1c..08801c4 100644 --- a/2017/09/9.md +++ b/2017/09/9.md @@ -72,8 +72,6 @@ group that immediately contains it. (The outermost group gets a score of Your puzzle answer was `11898`. -The first half of this puzzle is complete! It provides one gold star: \* - ## \-\-- Part Two \-\-- {#part2} Now, you\'re ready to remove the garbage. @@ -93,7 +91,13 @@ nor do any canceled characters or the `!` doing the canceling. *How many non-canceled characters are within the garbage* in your puzzle input? -Answer: +Your puzzle answer was `5601`. -Although it hasn\'t changed, you can still [get your puzzle +Both parts of this puzzle are complete! They provide two gold stars: +\*\* + +At this point, you should [return to your Advent calendar](/2017) and +try another puzzle. + +If you still want to see it, you can [get your puzzle input](9/input). diff --git a/2017/09/solution.py b/2017/09/solution.py index 56d23c8..78d8286 100644 --- a/2017/09/solution.py +++ b/2017/09/solution.py @@ -35,11 +35,12 @@ if part == 1: if part == 2: with open(input_f) as file: for line in file: - print(line.rstrip(), end=' ') + #print(line.rstrip(), end=' ') + length = 0 clean_string = line.rstrip() clean_string = re.sub(r"!.",'',clean_string) - print(clean_string) - clean_string = re.findall(r"<.*?>", clean_string) - for c in clean_string: - clean_string = c.replace('<','',1).replace('>','',1) - print(len(clean_string)) + clean_string = re.findall(r"<(.*?)>", clean_string) + + for i in clean_string: + length += len(i) + print(length)