diff --git a/day03/data/sample.txt b/day03/data/sample.txt index e69de29..a22c6a7 100644 --- a/day03/data/sample.txt +++ b/day03/data/sample.txt @@ -0,0 +1,11 @@ +.##....... +#...#...#.. +.#....#..#. +..#.#...#.# +.#...##..#. +..#.##..... +.#.#.#....# +.#........# +#.##...#... +#...##....# +.#..#...#.# diff --git a/day03/module.py b/day03/module.py new file mode 100644 index 0000000..7c1ca82 --- /dev/null +++ b/day03/module.py @@ -0,0 +1,43 @@ +from aoc.input import get_input +from aoc.partselector import part_one, part_two + +def pw(line): + return line + +inp = get_input(pw) + +if part_one(): + x = 0 + count = 0 + for i in inp: + if i[x%len(i)] == "#": + count +=1 + x +=3 + print(i) + print (count) + + +if part_two(): + x = 0 + total = 1 + for slope in (1, 3, 5, 7): + x = 0 + count = 0 + for i in inp: + if i[x%len(i)] == "#": + count +=1 + x +=slope + total *= count + print(count) + count = 0 + x = 0 + for z, i in enumerate(inp): + if z % 2 == 1: + continue + if i[x%len(i)] == "#": + count +=1 + x +=1 + print(count) + total *= count + print (total) +