add: 2022

This commit is contained in:
2024-08-29 17:12:29 +02:00
parent 5ab804addc
commit df47044ce4
9 changed files with 2658 additions and 0 deletions

19
2022/day04/part1.py Normal file
View File

@ -0,0 +1,19 @@
f = open("file");
s = f.read();
f.close();
menfou = 0;
for pair in s.splitlines():
elfs = pair.split(",");
values = elfs[0].split("-")
start1 = int(values[0]);
end1 = int(values[1]);
values = elfs[1].split("-")
start2 = int(values[0]);
end2 = int(values[1]);
if (start2 <= start1 <= end2 and end1 <= end2):
print (start2, start1, end1, end2)
menfou += 1;
elif (start1 <= start2 <= end1 and end2 <= end1):
print (start1, start2, end2, end1)
menfou += 1;
print(menfou);

19
2022/day04/part2.py Normal file
View File

@ -0,0 +1,19 @@
f = open("file");
s = f.read();
f.close();
menfou = 0;
for pair in s.splitlines():
elfs = pair.split(",");
values = elfs[0].split("-")
start1 = int(values[0]);
end1 = int(values[1]);
values = elfs[1].split("-")
start2 = int(values[0]);
end2 = int(values[1]);
verif = 0;
for i in range(start1, end1 + 1):
for y in range(start2, end2 + 1):
if (y == i):
verif = 1;
menfou += verif;
print(menfou);