3-1
This commit is contained in:
32
03/03-01.py
Normal file
32
03/03-01.py
Normal file
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
data = []
|
||||
|
||||
# parse input
|
||||
input_file = open("input", "r")
|
||||
for line in input_file:
|
||||
line = line.strip()
|
||||
part1 = line[:len(line)//2]
|
||||
part2 = line[len(line)//2:]
|
||||
# print(part1, part2)
|
||||
for i in range(len(part1)):
|
||||
if part1[i] in part2:
|
||||
# print(part1[i])
|
||||
data.append(part1[i])
|
||||
break
|
||||
input_file.close()
|
||||
|
||||
print(data)
|
||||
solution = 0
|
||||
for b in data:
|
||||
if 96 < ord(b) < 123:
|
||||
print(ord(b)-96)
|
||||
solution += ord(b)-96
|
||||
elif 64 < ord(b) < 91:
|
||||
print(ord(b)-64+26)
|
||||
solution += ord(b)-64+26
|
||||
else:
|
||||
print("Fehler")
|
||||
|
||||
print("Lösung 1:", solution)
|
||||
Reference in New Issue
Block a user