3-1
This commit is contained in:
27
02/02-02.py
Normal file
27
02/02-02.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# parse input
|
||||
input_file = open("input", "r")
|
||||
total_score = 0
|
||||
|
||||
for li in input_file:
|
||||
li = li.strip().split()
|
||||
# Score for loose, draw, win
|
||||
if li[1] == "X":
|
||||
total_score += 0
|
||||
elif li[1] == "Y":
|
||||
total_score += 3
|
||||
elif li[1] == "Z":
|
||||
total_score += 6
|
||||
# Score for Stone, Paper, Scissor
|
||||
if (li[0] == "B" and li[1] == "X") or (li[0] == "A" and li[1] == "Y") or (li[0] == "C" and li[1] == "Z"):
|
||||
total_score += 1
|
||||
elif (li[0] == "C" and li[1] == "X") or (li[0] == "B" and li[1] == "Y") or (li[0] == "A" and li[1] == "Z"):
|
||||
total_score += 2
|
||||
else:
|
||||
total_score += 3
|
||||
print(total_score)
|
||||
input_file.close()
|
||||
|
||||
print("Lösung 2:", total_score)
|
||||
Reference in New Issue
Block a user