Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #4

Merged
merged 1 commit into from
Aug 31, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions black_card.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

import sys

with open(sys.argv[1], 'r') as test_cases:
for test in test_cases:
line = test.strip()
persons = line.split(" | ")[0].split(" ")
blackcard = int(line.split(" | ")[1])
while len(persons) != 1:
erase = blackcard % len(persons) - 1
del persons[erase]
print(persons[0])

39 changes: 39 additions & 0 deletions simple_or_trump.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
"""
Card game higher with trump
"""
import sys

with open(sys.argv[1], 'r') as test_cases:
for test in test_cases:
dicti = {
'2':2, '3':3, '4':4, '5':5, '6':6,
'7':7, '8':8, '9':9, '10':10,
'J':11, 'Q':12, 'K':13, 'A':14
}
line = test.strip()
card1 = line.split(" | ")[0].split(" ")[0]
card2 = line.split(" | ")[0].split(" ")[1]
typecard = line.split(" | ")[1]
cardlist = []
cardlist2 = []
if card1[-1] == typecard and card2[-1] != typecard:
cardlist.append(card1)
if card2[-1] == typecard and card1[-1] != typecard:
cardlist.append(card2)
if cardlist == []:
if dicti[card1[0:-1]] == dicti[card2[0:-1]]:
if card1[-1] == typecard:
cardlist2.append(card1)
if card2[-1] == typecard:
cardlist2.append(card2)
if card2[-1] != typecard and card1[-1] != typecard:
cardlist2.append(card1)
cardlist2.append(card2)
else:
if dicti[card1[0:-1]] > dicti[card2[0:-1]]:
cardlist2.append(card1)
else:
cardlist2.append(card2)
print" ".join(cardlist2)
else:
print" ".join(cardlist)