day03
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
.##.......
|
||||
#...#...#..
|
||||
.#....#..#.
|
||||
..#.#...#.#
|
||||
.#...##..#.
|
||||
..#.##.....
|
||||
.#.#.#....#
|
||||
.#........#
|
||||
#.##...#...
|
||||
#...##....#
|
||||
.#..#...#.#
|
||||
|
||||
43
day03/module.py
Normal file
43
day03/module.py
Normal file
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user