initial commit, day 10
This commit is contained in:
24
01a.py
Executable file
24
01a.py
Executable file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
with open('01a.txt') as f:
|
||||
text = f.read().strip()
|
||||
|
||||
lines = text.split('\n')
|
||||
|
||||
a = [0] * len(lines)
|
||||
b = a[:]
|
||||
|
||||
for i in range(len(lines)):
|
||||
spl = lines[i].split(' ', maxsplit=1)
|
||||
a[i] = int(spl[0].strip())
|
||||
b[i] = int(spl[1].strip())
|
||||
|
||||
a.sort()
|
||||
b.sort()
|
||||
|
||||
total = 0
|
||||
|
||||
for x, y in zip(a, b):
|
||||
total += abs(x - y)
|
||||
|
||||
print(total)
|
||||
Reference in New Issue
Block a user