add 2025 day 2 part 1

This commit is contained in:
2025-12-02 10:17:42 +01:00
parent b921ef683b
commit 4b062f4b69
6 changed files with 72 additions and 0 deletions

View File

@@ -0,0 +1 @@
3.10

0
2025/day-02/README.md Normal file
View File

1
2025/day-02/input.txt Executable file
View File

@@ -0,0 +1 @@
24-46,124420-259708,584447-720297,51051-105889,6868562486-6868811237,55-116,895924-1049139,307156-347325,372342678-372437056,1791-5048,3172595555-3172666604,866800081-866923262,5446793-5524858,6077-10442,419-818,57540345-57638189,2143479-2274980,683602048-683810921,966-1697,56537997-56591017,1084127-1135835,1-14,2318887654-2318959425,1919154462-1919225485,351261-558210,769193-807148,4355566991-4355749498,809094-894510,11116-39985,9898980197-9898998927,99828221-99856128,9706624-9874989,119-335

41
2025/day-02/part-one.py Normal file
View File

@@ -0,0 +1,41 @@
import logging
import sys
def main():
# Logger setup
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
stream_handler = logging.StreamHandler()
logger.addHandler(stream_handler)
output = 0
logger.debug("Init output with value: " + str(output))
with open("input.txt", "r") as input:
for line in input:
line = line.strip()
ranges = line.split(",")
for id_range in ranges:
ids = id_range.split("-")
print(ids)
for x in range(int(ids[0]), int(ids[1]) + 1):
# print("Testing " + str(x))
if len(str(x)) % 2 != 0:
continue
middle = int(len(str(x))/2)
if(str(x)[middle:] == str(x)[:middle]):
print(str(x))
output += x
logger.info("Output: " + str(output))
# x = 1111
# if len(str(x)) % 2 != 0:
# print("NOO")
# middle = int(len(str(x))/2)
# if(str(x)[middle:] == str(x)[:middle]):
# print(str(x))
#print(x[(len(x)/2):])
#print(x[:(len(x)/2)])
if __name__ == "__main__":
main()

View File

@@ -0,0 +1,9 @@
[project]
name = "day-02"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"logging>=0.4.9.6",
]

20
2025/day-02/uv.lock generated Normal file
View File

@@ -0,0 +1,20 @@
version = 1
revision = 2
requires-python = ">=3.10"
[[package]]
name = "day-02"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "logging" },
]
[package.metadata]
requires-dist = [{ name = "logging", specifier = ">=0.4.9.6" }]
[[package]]
name = "logging"
version = "0.4.9.6"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/93/4b/979db9e44be09f71e85c9c8cfc42f258adfb7d93ce01deed2788b2948919/logging-0.4.9.6.tar.gz", hash = "sha256:26f6b50773f085042d301085bd1bf5d9f3735704db9f37c1ce6d8b85c38f2417", size = 96029, upload-time = "2013-06-04T23:43:22.086Z" }