From dd834665e53e30539e8b00cb215f65243e6ac5de Mon Sep 17 00:00:00 2001 From: starnakin Date: Fri, 1 Dec 2023 12:56:27 +0100 Subject: [PATCH] init day00 python --- .gitignore | 1 + 2023/day01/python/run.sh | 1 + 2023/day01/python/src/main.py | 15 +++++++++++++++ README.md | 0 4 files changed, 17 insertions(+) create mode 100644 .gitignore create mode 100755 2023/day01/python/run.sh create mode 100644 2023/day01/python/src/main.py create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2fa6fd5 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +**/input.txt \ No newline at end of file diff --git a/2023/day01/python/run.sh b/2023/day01/python/run.sh new file mode 100755 index 0000000..cbc5f14 --- /dev/null +++ b/2023/day01/python/run.sh @@ -0,0 +1 @@ +python3 main.py \ No newline at end of file diff --git a/2023/day01/python/src/main.py b/2023/day01/python/src/main.py new file mode 100644 index 0000000..4d9c82c --- /dev/null +++ b/2023/day01/python/src/main.py @@ -0,0 +1,15 @@ +text: str = open("input.txt", "r").read() + +import string + +value: int = 0 + +for line in text.split("\n"): + for index, chars in enumerate([line[::-1], line]): + for char in chars: + if (char in string.digits): + value += int(char) * 10 ** index + print(value) + break; + +print(value) \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29