From c20b3d31e9ba68c9a11867365b0c5710f803bd10 Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 24 Jan 2023 02:50:23 +0100 Subject: [PATCH] 2022 - Day 9 part 1 --- 2022/9/9.py | 82 ++ 2022/9/input.txt | 2000 ++++++++++++++++++++++++++++++++++++++ 2022/9/input_example.txt | 8 + 3 files changed, 2090 insertions(+) create mode 100644 2022/9/9.py create mode 100644 2022/9/input.txt create mode 100644 2022/9/input_example.txt diff --git a/2022/9/9.py b/2022/9/9.py new file mode 100644 index 0000000..36756b4 --- /dev/null +++ b/2022/9/9.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python +# 2022 - Advent Of Code 9 + +import math + +# file = 'input_example.txt' +file = 'input.txt' + + +visited_pos = [[0, 0]] +head_pos = [0, 0] +tail_pos = [0, 0] + + +def parse_file(input_file): + moves = [] + with open(input_file, encoding="utf-8") as f: + for line in f.readlines(): + d, u = line.strip().split(' ') + moves.append((d, int(u))) + return moves + + +def col_round(x): + frac = x - int(x) + if frac < 0.5: + return math.floor(x) + return math.ceil(x) + + +def move_tail(h, t): + vx = h[0] - t[0] + vy = h[1] - t[1] + + vlen = round(math.sqrt(vx * vx + vy * vy)) + head_tail_dist = vlen + + # print(f'head_tail_dist: {head_tail_dist}') + if head_tail_dist > 1: + # print('move tail!') + + nx = col_round(vx / vlen) + ny = col_round(vy / vlen) + print(f'x:{vx}/{nx} y: {vy}/{ny} len: {vlen}') + + t[0] += nx + t[1] += ny + print(f'head_pos: {h}') + print(f'new tail_pos: {t}') + v_list = [t[0], t[1]] + if v_list not in visited_pos: + visited_pos.append(v_list) + # visited_pos.append(v_list) + + +head_moves = parse_file(file) +print(head_moves) + +for m in head_moves: + if m[0] == 'R': + print(f'right: {m[1]}') + for _ in range(0, m[1]): + head_pos[0] += 1 + move_tail(head_pos, tail_pos) + if m[0] == 'L': + print(f'left: {m[1]}') + for _ in range(0, m[1]): + head_pos[0] -= 1 + move_tail(head_pos, tail_pos) + if m[0] == 'U': + print(f'up: {m[1]}') + for _ in range(0, m[1]): + head_pos[1] += 1 + move_tail(head_pos, tail_pos) + if m[0] == 'D': + print(f'down: {m[1]}') + for _ in range(0, m[1]): + head_pos[1] -= 1 + move_tail(head_pos, tail_pos) + +print(visited_pos) +print(len(visited_pos)) diff --git a/2022/9/input.txt b/2022/9/input.txt new file mode 100644 index 0000000..6eead55 --- /dev/null +++ b/2022/9/input.txt @@ -0,0 +1,2000 @@ +R 1 +D 1 +L 1 +D 1 +L 2 +U 2 +D 2 +R 1 +D 1 +L 2 +R 1 +L 2 +R 2 +L 1 +R 2 +D 1 +R 1 +D 2 +U 1 +R 1 +D 2 +R 2 +L 1 +D 1 +R 2 +D 2 +R 1 +L 2 +D 1 +L 2 +D 2 +R 2 +D 2 +L 1 +D 1 +L 1 +D 1 +R 2 +L 2 +R 2 +D 2 +R 2 +D 2 +R 2 +L 2 +R 2 +U 1 +R 1 +D 2 +R 1 +L 1 +U 1 +L 2 +U 1 +D 1 +R 1 +U 1 +R 2 +D 2 +U 2 +D 2 +R 1 +L 1 +U 2 +L 2 +D 2 +L 1 +R 2 +D 1 +R 1 +L 2 +U 2 +R 1 +D 1 +U 2 +L 1 +U 2 +L 1 +R 2 +D 2 +R 1 +D 2 +R 1 +D 1 +R 1 +D 1 +L 2 +D 2 +R 2 +D 2 +R 1 +D 1 +R 2 +L 1 +U 2 +R 2 +D 1 +L 2 +U 1 +D 2 +L 2 +D 2 +L 2 +D 1 +R 1 +L 1 +U 2 +L 2 +D 1 +L 2 +U 1 +L 3 +D 1 +R 1 +U 3 +L 2 +U 1 +D 3 +L 1 +D 2 +R 1 +L 3 +D 2 +L 2 +D 1 +L 1 +R 2 +L 3 +D 2 +L 1 +U 3 +L 1 +R 3 +U 1 +R 3 +U 3 +D 1 +L 2 +U 2 +D 2 +U 3 +D 3 +L 1 +U 3 +D 3 +L 3 +R 1 +D 1 +U 2 +R 1 +U 3 +L 3 +D 2 +L 3 +D 1 +R 2 +U 1 +D 2 +L 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+L 2 +R 7 +L 11 +R 1 +L 16 +U 2 +L 1 +R 18 +U 5 +L 9 +U 4 +D 8 +U 4 +L 18 +D 17 +L 14 +D 2 +R 1 +U 13 +L 9 +R 14 +D 14 +U 12 +D 14 +L 2 +U 10 +D 11 +R 10 +L 9 +U 7 +D 12 +L 4 +D 2 +R 17 +D 1 +U 15 +R 14 +D 16 +L 1 +R 11 +U 9 +R 8 +U 6 +D 7 +U 7 +L 2 +D 10 +U 9 +D 9 +L 11 +D 11 +L 14 +U 16 +D 11 +L 17 +R 5 +L 13 +U 16 +R 16 +U 18 +D 1 +R 1 +U 13 +R 6 +L 7 +U 11 +D 12 +L 8 +U 17 +D 11 +U 8 +L 14 +U 17 +L 4 +U 18 +D 18 +R 8 +D 13 +L 10 +U 3 +R 9 +L 14 +R 7 +U 14 +R 14 +L 9 +U 5 +R 4 +D 13 +U 10 +D 1 +R 10 +D 4 +R 3 +U 14 +D 10 +U 12 +L 11 +U 9 +L 16 +R 5 +L 14 +D 4 +U 11 +L 2 +R 10 +U 8 +D 9 +L 2 +R 16 +L 1 +R 12 +U 7 +D 11 +U 18 +D 4 +R 8 +U 18 +D 5 +R 15 +U 16 +L 2 +D 15 +U 5 +D 10 +U 18 +L 7 +U 4 +R 2 +U 17 +L 2 +R 3 +D 2 +L 2 +U 3 +R 10 +L 8 +U 4 +L 18 +U 6 +D 11 +R 13 +D 9 +U 10 +L 16 +R 15 +L 4 +D 1 +L 5 +D 7 +U 18 +L 5 +R 7 +L 15 +U 4 +L 6 +U 19 +D 19 +L 2 +R 2 +L 19 +D 9 +L 14 +U 18 +D 12 +R 19 +U 15 +L 16 +U 9 +L 11 +R 5 +L 14 +R 16 +U 19 +D 7 +U 8 +R 6 +U 14 +R 17 +D 9 +L 5 +U 3 +D 9 +U 8 +L 4 +U 12 +D 12 +R 13 +U 3 +R 18 +U 5 +L 12 +U 4 +L 1 +D 14 +R 5 +L 19 +U 17 +R 18 +D 11 +L 4 +U 18 +L 9 diff --git a/2022/9/input_example.txt b/2022/9/input_example.txt new file mode 100644 index 0000000..9874df2 --- /dev/null +++ b/2022/9/input_example.txt @@ -0,0 +1,8 @@ +R 4 +U 4 +L 3 +D 1 +R 4 +D 1 +L 5 +R 2