From 88582d2e2b98144192881cc34f9afb7ab8a442bf Mon Sep 17 00:00:00 2001 From: Tristan Date: Fri, 30 Nov 2018 13:28:56 +0000 Subject: [PATCH] 2015 day 3 part 1 --- 2015/3/input.txt | 1 + 2015/3/part1.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 2015/3/input.txt create mode 100644 2015/3/part1.py diff --git a/2015/3/input.txt b/2015/3/input.txt new file mode 100644 index 0000000..e69cd4f --- /dev/null +++ b/2015/3/input.txt @@ -0,0 +1 @@ +^^<<>^^>^^^><^>v^>v><><><^^v>v^v>>>^<>v<^<^>>>>><>^>>^>v^>><<^>v>v<>^v^v^vvv><>^^>v><>^><^^^v>>^v^>v><>v^^><vv^<<>v>>><<<>>^^^vv>>>^><<<>><><^>v<>^>v<^v^><<<<>^<>v>^v>vv<^<<>>>>^^v>vv^^<>^<>^^^^<^^^vv<^^v^^>v>^v^^^^>><v<>^v^><>^^><<^^<^^>vv<>v^<^v^>^^>^<>v^^vv<>>v><<<>vvv<>v<>><^<^v<>^vv>^^v<^<>>vv<^>>^>>vv^v>^v^<>^>>>>vv>^^>v>vv>v><^vv^<^<<^^vv^^v>^>>v><^<>v<><>^^<>v>><>^^>^^>>vvv^><<<<<^<^vv<^<>^^^<<<^>^^^vv<>^<>v<^v>^<<>^v<>>v<<^<^<<<><><>^>>>>^>v^v<>vv<^vvv^^^^vv>^v^^v^<^vv<^vv>v<^>vv<>>^>^><^>v>^v>vvv<>^>^v<><>vv>><^v^<><>>v^v^><^<^>vv>v<^>vvv>v<<<<<^>^vv>^><><>^<v^>^><><>>^>^>><^^^>^^>^^v^^<^v^^>v^^>>><<><><>^^<<^^v^>v>><>^^^><^vvv<^^^^^v><<><><>>^>vv>>^vv^^><v<^^>^<^^<^>>>^v<>v<^^^>vvv^v<<^><>>>>v>>>^^vvv^vvv<^^^^v^v^^<<^>v^v^<<><>><^v><<>><<<>^v>v<>^^vv>>^<>v^^<<^v>>v<>>^v^^>><^>v^<^v^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^^^^^<<^><><^^v^>v>^>><^><<>v^>>^vvv>>^<^<>^^v^vv^^v><>>v<<<>v>^<>v<<>v^>^<<><<>v^>v<><^^>^<^v^^><^>vv>^>vvvv>^^><<>vv^>^v<<^<<^<<>vv>>^>>>>>v^v<^v>v>^^^vv^v<^<>v><>>vv>v><>v>^v<><<<<<>v^vv<<<<^<>^>><>^^vv>^<^<<>vv>>vv><>><^^><^<>^><>v^^^^v^^vv<>v<>v>^vv^>^<>^^^>v^>>>v><<^>>v<^v<>^^v<><<>v<^<^>v<>v^>v>^^<<<^^vv^<><<<>>v>^^<>v>>>><<>v^v<>v>><<<<^<<^>^>v^vv^><^v^^<>^^><>vv>^>vvv<^v^>>^>^>^^<<^>^>^v><>>^<^^v>^>>^^<><>>>^^>^^vvv>v<^^<>v^v^^v^v>><<^^^>>v>^vv>^>^^v<>^^<>v^^<>v^><<>vv<<^vvvv><<v>v^>v^<>v^>^^<>^>^^v<>><<<>^v^^v^v<<<^v^<>^<>v>^^>vv>^^<<<><<^>v<^^<^<<>^>>>>>^v^v<vvv<<>v>v>>^v^v^>><<<<>v^<<>>>^>>^>>< diff --git a/2015/3/part1.py b/2015/3/part1.py new file mode 100644 index 0000000..4dac7f5 --- /dev/null +++ b/2015/3/part1.py @@ -0,0 +1,18 @@ +with open("input.txt", "r") as commands: + x = 0 + y = 0 + history = [] + for command in commands.readlines()[0]: + if command == ">": + x += 1 + elif command == "<": + x -= 1 + elif command == "^": + y += 1 + elif command == "v": + y -= 1 + if not [x, y] in history: + history.append([x, y]) + print(len(history)) + commands.close() +