diff --git a/2025/03/part1.py b/2025/03/part1.py new file mode 100644 index 0000000..b72adc6 --- /dev/null +++ b/2025/03/part1.py @@ -0,0 +1,17 @@ +import os + +#if (os.path.isfile("./input")): +# input = open("./input", "r").read() +#else: +input = "987654321111111\n811111111111119\n234234234234278\n818181911112111\n" + +r = 0 +for bat in input.split('\n'): + if (bat == ""): + break + for i in reversed(range(12)): + print(bat) + r += int(max(bat[:-i + 1])) * 10**i + bat = bat[bat.find(max(bat[:-i + 1])) + 1:] # i dont remember the code i did on this one, it's just weird code for part2 that doesnt work, sorryyyyyyyyyyyyyyyyyyyy + +print(r) diff --git a/2025/03/part2.py b/2025/03/part2.py new file mode 100644 index 0000000..a40e4aa --- /dev/null +++ b/2025/03/part2.py @@ -0,0 +1,17 @@ +import os + +if (os.path.isfile("./input")): + input = open("./input", "r").read() +else: + input = "987654321111111\n811111111111119\n234234234234278\n818181911112111\n" + +r = 0 +for bat in input.split('\n'): + if (bat == ""): + break + for i in reversed(range(12)): + m = max(bat[:(len(bat) if i == 0 else -i)]) + r += int(m) * 10**i + bat = bat[bat.index(str(m)) + 1:] + +print(r) diff --git a/2025/04/part1.py b/2025/04/part1.py new file mode 100644 index 0000000..564216f --- /dev/null +++ b/2025/04/part1.py @@ -0,0 +1,42 @@ +import os + +if (os.path.isfile("./input")): + input = open("./input", "r").read() +else: + input = "..@@.@@@@.\n@@@.@.@.@@\n@@@@@.@.@@\n@.@@@@..@.\n@@.@@@@.@@\n.@@@@@@@.@\n.@.@.@.@@@\n@.@@@.@@@@\n.@@@@@@@@.\n@.@.@@@.@." + +map = input.split('\n') +if (map[-1] == ""): + map.pop() + +for i in range(len(map)): + map[i] = "." + map[i] + "." + +map.append("." * len(map[0])) +map.insert(0, "." * len(map[0])) + +r = 0 +for y in range(len(map)): + for x in range(len(map[y])): + if map[y][x] == "@": + c = 0 + if (map[y+1][x+1] == "@"): + c += 1 + if (map[y+1][x] == "@"): + c += 1 + if (map[y+1][x-1] == "@"): + c += 1 + if (map[y][x+1] == "@"): + c += 1 + if (map[y][x-1] == "@"): + c += 1 + if (map[y-1][x+1] == "@"): + c += 1 + if (map[y-1][x] == "@"): + c += 1 + if (map[y-1][x-1] == "@"): + c += 1 + if (c < 4): + r += 1 + +print(r) diff --git a/2025/04/part2.py b/2025/04/part2.py new file mode 100644 index 0000000..4dcb4d1 --- /dev/null +++ b/2025/04/part2.py @@ -0,0 +1,48 @@ +import os + +if (os.path.isfile("./input")): + input = open("./input", "r").read() +else: + input = "..@@.@@@@.\n@@@.@.@.@@\n@@@@@.@.@@\n@.@@@@..@.\n@@.@@@@.@@\n.@@@@@@@.@\n.@.@.@.@@@\n@.@@@.@@@@\n.@@@@@@@@.\n@.@.@@@.@." + +map = input.split('\n') +if (map[-1] == ""): + map.pop() + +for i in range(len(map)): + map[i] = list("." + map[i] + ".") + +map.append(list("." * len(map[0]))) +map.insert(0, list("." * len(map[0]))) + +r = 0 +lastr = -1 +while (r != lastr): + lastr = r; + nmap = map; + for y in range(len(map)): + for x in range(len(map[y])): + if map[y][x] == "@": + c = 0 + if (map[y+1][x+1] == "@"): + c += 1 + if (map[y+1][x] == "@"): + c += 1 + if (map[y+1][x-1] == "@"): + c += 1 + if (map[y][x+1] == "@"): + c += 1 + if (map[y][x-1] == "@"): + c += 1 + if (map[y-1][x+1] == "@"): + c += 1 + if (map[y-1][x] == "@"): + c += 1 + if (map[y-1][x-1] == "@"): + c += 1 + if (c < 4): + r += 1 + nmap[y][x] = "." + map = nmap; + +print(r)