commit dd834665e53e30539e8b00cb215f65243e6ac5de Author: starnakin Date: Fri Dec 1 12:56:27 2023 +0100 init day00 python 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