01
This commit is contained in:
28
01/01-01.py
Normal file
28
01/01-01.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
input_file = open("input.txt", "r")
|
||||
|
||||
left = []
|
||||
right = []
|
||||
|
||||
for line in input_file:
|
||||
a, b = line.split()
|
||||
left.append(int(a))
|
||||
right.append(int(b))
|
||||
input_file.close()
|
||||
|
||||
print(left)
|
||||
print(right)
|
||||
|
||||
left.sort()
|
||||
right.sort()
|
||||
|
||||
print(left)
|
||||
print(right)
|
||||
|
||||
list_distance = 0
|
||||
for i in range(len(left)):
|
||||
list_distance += abs(left[i]-right[i])
|
||||
|
||||
print(f'List-Distance: {list_distance}')
|
||||
22
01/01-02.py
Normal file
22
01/01-02.py
Normal file
@@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
input_file = open("input.txt", "r")
|
||||
|
||||
left = []
|
||||
right = []
|
||||
|
||||
for line in input_file:
|
||||
a, b = line.split()
|
||||
left.append(int(a))
|
||||
right.append(int(b))
|
||||
input_file.close()
|
||||
|
||||
print(left)
|
||||
print(right)
|
||||
|
||||
list_similarity = 0
|
||||
for i in range(len(left)):
|
||||
list_similarity += right.count(left[i]) * left[i]
|
||||
|
||||
print(f'List-Similarity: {list_similarity}')
|
||||
1000
01/input.txt
Normal file
1000
01/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user