#!/usr/bin/env python3 """ https://adventofcode.com/2015/day/1 """ import aoc PUZZLE = aoc.Puzzle(day=1, year=2015) def find_floor(): """Solve part A""" floor = 0 floor += PUZZLE.input.count('(') floor -= PUZZLE.input.count(')') return floor def find_basement(): """Solve part B""" floor, position = 0, 0 for staircase in PUZZLE.input: position += 1 floor += 1 if staircase == '(' else -1 if floor == -1: return position return None if __name__ == "__main__": PUZZLE.report_a(find_floor()) PUZZLE.report_b(find_basement())
#!/usr/bin/env python3 """ https://adventofcode.com/2020/day/3 """ import aoc PUZZLE = aoc.Puzzle(day=3, year=2020) def count_trees(*slopes): """Count tress matching slope""" answer = 1 for right, down in [map(int, (x, y)) for x, y in slopes]: col, trees = 0, 0 rows = PUZZLE.input.splitlines() for row in rows[down::down]: col += right if row[col % len(row)] == '#': trees += 1 answer = answer * trees return answer if __name__ == "__main__": PUZZLE.report_a(count_trees('31')) PUZZLE.report_b(count_trees('11', '31', '51', '71', '12'))
#!/usr/bin/env python3 # -*- coding: UTF-8 -*- """ https://adventofcode.com/YEAR/day/DAY """ import aoc PUZZLE = aoc.Puzzle(day=DAY, year=YEAR) def solve(): """Solve puzzle""" # print(PUZZLE.input) return None if __name__ == "__main__": PUZZLE.report_a(solve()) PUZZLE.report_b(solve())