05-2 fertig
This commit is contained in:
21
04/04-1.py
Normal file
21
04/04-1.py
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
input_file = open("input", "r")
|
||||
win_sum = 0
|
||||
for line in input_file:
|
||||
line = line.strip().split(":")
|
||||
zahlen = line[1].split("|")
|
||||
gewinn_zahlen = zahlen[0].split()
|
||||
meine_zahlen = zahlen[1].split()
|
||||
card_win = 0
|
||||
for zahl in meine_zahlen:
|
||||
if zahl in gewinn_zahlen:
|
||||
if card_win == 0:
|
||||
card_win = 1
|
||||
else:
|
||||
card_win *= 2
|
||||
win_sum += card_win
|
||||
|
||||
print(win_sum)
|
||||
input_file.close()
|
||||
Reference in New Issue
Block a user