generated from public/aoc_template
Compare commits
2 Commits
939b55360d
...
543684569b
| Author | SHA1 | Date | |
|---|---|---|---|
| 543684569b | |||
| 2cb9a83234 |
BIN
.aoc_tiles/tiles/2024/06.png
Normal file
BIN
.aoc_tiles/tiles/2024/06.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
BIN
.aoc_tiles/tiles/2024/07.png
Normal file
BIN
.aoc_tiles/tiles/2024/07.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.1 KiB |
BIN
.aoc_tiles/tiles/2024/08.png
Normal file
BIN
.aoc_tiles/tiles/2024/08.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
.aoc_tiles/tiles/2024/09.png
Normal file
BIN
.aoc_tiles/tiles/2024/09.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
14
README.md
14
README.md
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
<!-- AOC TILES BEGIN -->
|
<!-- AOC TILES BEGIN -->
|
||||||
<h1 align="center">
|
<h1 align="center">
|
||||||
2024 - 10 ⭐ - Python
|
2024 - 18 ⭐ - Python
|
||||||
</h1>
|
</h1>
|
||||||
<a href="day01.py">
|
<a href="day01.py">
|
||||||
<img src=".aoc_tiles/tiles/2024/01.png" width="161px">
|
<img src=".aoc_tiles/tiles/2024/01.png" width="161px">
|
||||||
@ -19,4 +19,16 @@
|
|||||||
<a href="day05.py">
|
<a href="day05.py">
|
||||||
<img src=".aoc_tiles/tiles/2024/05.png" width="161px">
|
<img src=".aoc_tiles/tiles/2024/05.png" width="161px">
|
||||||
</a>
|
</a>
|
||||||
|
<a href="day06.py">
|
||||||
|
<img src=".aoc_tiles/tiles/2024/06.png" width="161px">
|
||||||
|
</a>
|
||||||
|
<a href="day07.py">
|
||||||
|
<img src=".aoc_tiles/tiles/2024/07.png" width="161px">
|
||||||
|
</a>
|
||||||
|
<a href="day08.py">
|
||||||
|
<img src=".aoc_tiles/tiles/2024/08.png" width="161px">
|
||||||
|
</a>
|
||||||
|
<a href="day09.py">
|
||||||
|
<img src=".aoc_tiles/tiles/2024/09.png" width="161px">
|
||||||
|
</a>
|
||||||
<!-- AOC TILES END -->
|
<!-- AOC TILES END -->
|
||||||
6
day01.py
6
day01.py
@ -17,7 +17,7 @@ class Day(AOCDay):
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|
||||||
def parse_input(self) -> (list, list):
|
def parse_input(self) -> tuple[list, list]:
|
||||||
lefts, rights = [], []
|
lefts, rights = [], []
|
||||||
for line in self.getInput():
|
for line in self.getInput():
|
||||||
left, right = map(int, line.split())
|
left, right = map(int, line.split())
|
||||||
@ -32,8 +32,8 @@ class Day(AOCDay):
|
|||||||
|
|
||||||
def part2(self) -> Any:
|
def part2(self) -> Any:
|
||||||
lefts, rights = self.parse_input()
|
lefts, rights = self.parse_input()
|
||||||
rights = Counter(rights)
|
counted = Counter(rights)
|
||||||
return sum(num * rights[num] for num in lefts)
|
return sum(num * counted[num] for num in lefts)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
9
day09.py
9
day09.py
@ -21,7 +21,6 @@ def get_checksum(head: Block) -> int:
|
|||||||
index = head
|
index = head
|
||||||
count = 0
|
count = 0
|
||||||
while index is not None:
|
while index is not None:
|
||||||
print((str(index.file_id) + "|") * index.file_length, end="")
|
|
||||||
if index.file_id > 0:
|
if index.file_id > 0:
|
||||||
for _ in range(index.file_length):
|
for _ in range(index.file_length):
|
||||||
checksum += index.file_id * count
|
checksum += index.file_id * count
|
||||||
@ -30,7 +29,6 @@ def get_checksum(head: Block) -> int:
|
|||||||
count += index.file_length
|
count += index.file_length
|
||||||
index = index.right
|
index = index.right
|
||||||
|
|
||||||
print()
|
|
||||||
return checksum
|
return checksum
|
||||||
|
|
||||||
|
|
||||||
@ -42,7 +40,7 @@ class Day(AOCDay):
|
|||||||
],
|
],
|
||||||
[
|
[
|
||||||
(2858, "input9_test"),
|
(2858, "input9_test"),
|
||||||
(None, "input9"),
|
(6373055193464, "input9"),
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -102,6 +100,9 @@ class Day(AOCDay):
|
|||||||
|
|
||||||
index = tail
|
index = tail
|
||||||
while index is not None:
|
while index is not None:
|
||||||
|
while index.file_id == -1:
|
||||||
|
index = index.left
|
||||||
|
|
||||||
search = head
|
search = head
|
||||||
while search != index:
|
while search != index:
|
||||||
if search.file_id == -1 and search.file_length >= index.file_length:
|
if search.file_id == -1 and search.file_length >= index.file_length:
|
||||||
@ -120,8 +121,8 @@ class Day(AOCDay):
|
|||||||
search.right.left = new_space
|
search.right.left = new_space
|
||||||
search.right = new_space
|
search.right = new_space
|
||||||
|
|
||||||
index = new_free_space
|
|
||||||
break
|
break
|
||||||
|
|
||||||
search = search.right
|
search = search.right
|
||||||
|
|
||||||
index = index.left
|
index = index.left
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user