first commit
This commit is contained in:
32
02/solve02.py
Executable file
32
02/solve02.py
Executable file
@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
def read_input():
|
||||
with open('input.txt', 'r') as f:
|
||||
for line in f:
|
||||
yield line.strip()
|
||||
|
||||
def compare(a, b):
|
||||
if len(a) != len(b):
|
||||
return None
|
||||
|
||||
change = None
|
||||
for i in range(len(a)):
|
||||
if a[i] != b[i]:
|
||||
if change is None:
|
||||
change = i
|
||||
else:
|
||||
return None
|
||||
return a[:change]+a[change+1:]
|
||||
|
||||
boxes = []
|
||||
result = None
|
||||
for box in read_input():
|
||||
for b in boxes:
|
||||
result = compare(box, b)
|
||||
if result:
|
||||
break
|
||||
if result:
|
||||
break
|
||||
boxes.append(box)
|
||||
|
||||
print(result)
|
||||
Reference in New Issue
Block a user