feat: Redo of the AoC repo starting over with 2015 and keeping up with

2025 (completed day 2 so far)
This commit is contained in:
2025-12-02 07:55:08 -06:00
commit c936d7d573
29 changed files with 668 additions and 0 deletions

Binary file not shown.

26
15/4/main.py Normal file
View File

@@ -0,0 +1,26 @@
import hashlib
def search_hashes(secret: str, match_str: str) -> int:
num = 1
while True:
search_string_bytes = (secret + str(num)).encode()
hash_string = hashlib.md5(search_string_bytes).hexdigest()
if hash_string.startswith(match_str):
return num
num += 1
def main():
num = search_hashes('ckczppom', '00000')
print(f'Part1: {num}')
num = search_hashes('ckczppom', '000000')
print(f'Part2: {num}')
if __name__ == "__main__":
main()

11
15/4/test_main.py Normal file
View File

@@ -0,0 +1,11 @@
import pytest
from main import search_hashes
@pytest.mark.parametrize('given, match, expected',
[
('abcdef', '00000', 609043),
('pqrstuv', '00000', 1048970)
])
def test_searching(given, match, expected):
assert search_hashes(given, match) == expected