From e0d955ec6f925311cc7688732f23d54089ed0497 Mon Sep 17 00:00:00 2001 From: Mark Hoekveen Date: Mon, 11 Nov 2024 09:05:01 +0100 Subject: [PATCH] Move into 2022 folder --- {1 => 2022/1}/input.txt | 0 {1 => 2022/1}/onestar.py | 0 {1 => 2022/1}/twostar.py | 0 {2 => 2022/2}/input.txt | 0 {2 => 2022/2}/onestar.py | 0 {2 => 2022/2}/twostar.py | 0 {3 => 2022/3}/input.txt | 0 {3 => 2022/3}/onestar.py | 6 +++--- {3 => 2022/3}/twostar.py | 0 {4 => 2022/4}/input.txt | 0 {4 => 2022/4}/onestar-1.py | 1 - {4 => 2022/4}/onestar.py | 9 ++------- {4 => 2022/4}/twostar.py | 0 {5 => 2022/5}/input.txt | 0 {5 => 2022/5}/onestar.py | 0 {5 => 2022/5}/twostar.py | 0 {6 => 2022/6}/input.txt | 0 {6 => 2022/6}/onestar.py | 0 {6 => 2022/6}/twostar.py | 0 {7 => 2022/7}/input.txt | 0 {7 => 2022/7}/onestar.py | 0 {7 => 2022/7}/twostar.py | 0 {8 => 2022/8}/input.txt | 0 {8 => 2022/8}/onestar.py | 0 {8 => 2022/8}/twostar.py | 0 {9 => 2022/9}/input.txt | 0 {9 => 2022/9}/onestar.py | 0 {9 => 2022/9}/twostar.py | 0 28 files changed, 5 insertions(+), 11 deletions(-) rename {1 => 2022/1}/input.txt (100%) rename {1 => 2022/1}/onestar.py (100%) rename {1 => 2022/1}/twostar.py (100%) rename {2 => 2022/2}/input.txt (100%) rename {2 => 2022/2}/onestar.py (100%) rename {2 => 2022/2}/twostar.py (100%) rename {3 => 2022/3}/input.txt (100%) rename {3 => 2022/3}/onestar.py (82%) rename {3 => 2022/3}/twostar.py (100%) rename {4 => 2022/4}/input.txt (100%) rename {4 => 2022/4}/onestar-1.py (98%) rename {4 => 2022/4}/onestar.py (55%) rename {4 => 2022/4}/twostar.py (100%) rename {5 => 2022/5}/input.txt (100%) rename {5 => 2022/5}/onestar.py (100%) rename {5 => 2022/5}/twostar.py (100%) rename {6 => 2022/6}/input.txt (100%) rename {6 => 2022/6}/onestar.py (100%) rename {6 => 2022/6}/twostar.py (100%) rename {7 => 2022/7}/input.txt (100%) rename {7 => 2022/7}/onestar.py (100%) rename {7 => 2022/7}/twostar.py (100%) rename {8 => 2022/8}/input.txt (100%) rename {8 => 2022/8}/onestar.py (100%) rename {8 => 2022/8}/twostar.py (100%) rename {9 => 2022/9}/input.txt (100%) rename {9 => 2022/9}/onestar.py (100%) rename {9 => 2022/9}/twostar.py (100%) diff --git a/1/input.txt b/2022/1/input.txt similarity index 100% rename from 1/input.txt rename to 2022/1/input.txt diff --git a/1/onestar.py b/2022/1/onestar.py similarity index 100% rename from 1/onestar.py rename to 2022/1/onestar.py diff --git a/1/twostar.py b/2022/1/twostar.py similarity index 100% rename from 1/twostar.py rename to 2022/1/twostar.py diff --git a/2/input.txt b/2022/2/input.txt similarity index 100% rename from 2/input.txt rename to 2022/2/input.txt diff --git a/2/onestar.py b/2022/2/onestar.py similarity index 100% rename from 2/onestar.py rename to 2022/2/onestar.py diff --git a/2/twostar.py b/2022/2/twostar.py similarity index 100% rename from 2/twostar.py rename to 2022/2/twostar.py diff --git a/3/input.txt b/2022/3/input.txt similarity index 100% rename from 3/input.txt rename to 2022/3/input.txt diff --git a/3/onestar.py b/2022/3/onestar.py similarity index 82% rename from 3/onestar.py rename to 2022/3/onestar.py index 22e0f19..946116b 100644 --- a/3/onestar.py +++ b/2022/3/onestar.py @@ -6,7 +6,7 @@ def priority(item): # lowercase return ord(item)-96 -priorities = [] +totaal = 0 with open("input.txt", "r") as f: for line in f.readlines(): line = line.strip("\n") @@ -15,7 +15,7 @@ with open("input.txt", "r") as f: right = line[h:] for c in left: if c in right: - priorities.append(priority(c)) + totaal += priority(c) print(c) break -print(sum(priorities)) +print(totaal) diff --git a/3/twostar.py b/2022/3/twostar.py similarity index 100% rename from 3/twostar.py rename to 2022/3/twostar.py diff --git a/4/input.txt b/2022/4/input.txt similarity index 100% rename from 4/input.txt rename to 2022/4/input.txt diff --git a/4/onestar-1.py b/2022/4/onestar-1.py similarity index 98% rename from 4/onestar-1.py rename to 2022/4/onestar-1.py index a767e27..6715c24 100644 --- a/4/onestar-1.py +++ b/2022/4/onestar-1.py @@ -1,4 +1,3 @@ -elves = [] count = 0 with open("input.txt", "r") as f: for line in f.readlines(): diff --git a/4/onestar.py b/2022/4/onestar.py similarity index 55% rename from 4/onestar.py rename to 2022/4/onestar.py index d955447..561577e 100644 --- a/4/onestar.py +++ b/2022/4/onestar.py @@ -1,4 +1,3 @@ -elves = [] count = 0 with open("input.txt", "r") as f: for line in f.readlines(): @@ -6,11 +5,7 @@ with open("input.txt", "r") as f: # Some python magic to split out the strings and convert them to integers pair = [x.split("-") for x in line.split(",")] pair = [[int(y) for y in x] for x in pair] - elves.append(pair) - # Elves is now a list of list of lists. - for elf in elves: - if ((elf[0][0] <= elf[1][0] and elf[0][1] >= elf[1][1]) or - (elf[1][0] <= elf[0][0] and elf[1][1] >= elf[0][1])): - print(elf) + if ((pair[0][0] <= pair[1][0] and pair[0][1] >= pair[1][1]) or + (pair[1][0] <= pair[0][0] and pair[1][1] >= pair[0][1])): count += 1 print(count) \ No newline at end of file diff --git a/4/twostar.py b/2022/4/twostar.py similarity index 100% rename from 4/twostar.py rename to 2022/4/twostar.py diff --git a/5/input.txt b/2022/5/input.txt similarity index 100% rename from 5/input.txt rename to 2022/5/input.txt diff --git a/5/onestar.py b/2022/5/onestar.py similarity index 100% rename from 5/onestar.py rename to 2022/5/onestar.py diff --git a/5/twostar.py b/2022/5/twostar.py similarity index 100% rename from 5/twostar.py rename to 2022/5/twostar.py diff --git a/6/input.txt b/2022/6/input.txt similarity index 100% rename from 6/input.txt rename to 2022/6/input.txt diff --git a/6/onestar.py b/2022/6/onestar.py similarity index 100% rename from 6/onestar.py rename to 2022/6/onestar.py diff --git a/6/twostar.py b/2022/6/twostar.py similarity index 100% rename from 6/twostar.py rename to 2022/6/twostar.py diff --git a/7/input.txt b/2022/7/input.txt similarity index 100% rename from 7/input.txt rename to 2022/7/input.txt diff --git a/7/onestar.py b/2022/7/onestar.py similarity index 100% rename from 7/onestar.py rename to 2022/7/onestar.py diff --git a/7/twostar.py b/2022/7/twostar.py similarity index 100% rename from 7/twostar.py rename to 2022/7/twostar.py diff --git a/8/input.txt b/2022/8/input.txt similarity index 100% rename from 8/input.txt rename to 2022/8/input.txt diff --git a/8/onestar.py b/2022/8/onestar.py similarity index 100% rename from 8/onestar.py rename to 2022/8/onestar.py diff --git a/8/twostar.py b/2022/8/twostar.py similarity index 100% rename from 8/twostar.py rename to 2022/8/twostar.py diff --git a/9/input.txt b/2022/9/input.txt similarity index 100% rename from 9/input.txt rename to 2022/9/input.txt diff --git a/9/onestar.py b/2022/9/onestar.py similarity index 100% rename from 9/onestar.py rename to 2022/9/onestar.py diff --git a/9/twostar.py b/2022/9/twostar.py similarity index 100% rename from 9/twostar.py rename to 2022/9/twostar.py