This commit is contained in:
2023-12-01 13:22:00 +01:00
commit 800ace7a75
7 changed files with 1129 additions and 0 deletions

10
AoC/2022/7/1.py Executable file
View File

@ -0,0 +1,10 @@
#!/bin/python
"""
Description:
"""
if __name__ == "__main__":
main()

1000
AoC/2023/trebuchet/input.in Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv) {
char c;
int sum = 0;
int first = -1, last = -1;
while ((c = getchar()) != EOF) {
if (c == '\n') {
sum += last != -1 ? first*10 + last : first*10 + first;
first = -1;
last = -1;
} else {
if (c <= '9' && c >= '0') {
if (first == -1) {
first = c - '0';
} else {
last = c - '0';
}
}
}
}
printf("%d\n", sum);
return 0;
}

View File

@ -0,0 +1,32 @@
def findFirstAndLastInt(inp):
first = 0
last = 0
for i in inp:
if i.isdigit():
if first == 0:
first = i
else:
last = i
if last == 0:
last = first
return int(first), int(last)
def main():
inputs = []
with open("input.in", "r") as f:
for line in f:
inputs.append(line.strip())
s = 0
for inp in inputs:
first, last = findFirstAndLastInt(inp)
s += first*10 + last
print(s)
if __name__ == "__main__":
main()