LESSON PLAN
1. Leetcode - Isomorphic Strings
a. https://leetcode.com/problems/isomorphic-strings/
2. ACSL AGRAM
a. https://imgur.com/a/xXgTEdr
HOMEWORK Complete ACSL AGRAM.
NOTE: There will be no class on Tuesday or Saturday next week (for Fourth of July). Enjoy your break!
translatable = {'K': 13, 'Q': 12, 'J': 11, 'T': 10, 'A': 1}
def translate(string):
if string in translatable:
return translable[string]
else:
return int(string)
def detranslate(i):
if i == 13:
return 'K'
elif i == 12:
return 'Q'
elif i == 11:
return 'J'
elif i == 10:
return 'T'
elif i == 1:
return 'A'
else:
return str(i)
leadCard, *handCard = input().split(', ')
suitOfLeadCard = leadCard[1]
playable = []
for card in handCard:
if suitOfLeadCard == card[1]:
playable.append(card[0])
if len(playable) >= 1:
leadCardValue = translate(leadCard[0])
iplayable = []
for j in playable:
iplayable.append(translate(j))
iplayable.sort()
answer = iplayable[0]
for j in iplayable:
if j <= leadCardValue:
continue
answer = j
break
print(f'{detranslate(answer)}{suitOfLeadCard}')
else:
values = []
for card in hand:
values.append((translate(card[0]), card))
values.sort()
print(values[0][1])