Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Magic with 5 cards by tokiojapan55
RANKS = tuple('A 2 3 4 5 6 7 8 9 10 J Q K'.split())
SUITS = tuple('♣♦♥♠')
def bot(*cards, n=1):
first_tell = []
delta_tell = []
hide = []
turn = n - 1
ar = [(SUITS.index(card.split(' ')[1]), RANKS.index(card.split(' ')[0])) for card in cards]
ar = sorted(ar, key=lambda a:(a[1],a[0]))
summary = [0] * 4
for s,n in ar:
summary[s] += 1
max_suit = summary.index(max(summary))
max_suit_cards = sorted([(s, n) for s,n in ar if s==max_suit], key=lambda c: c[1])
msc = max_suit_cards
max_suit_cards_delta = [(n, ((msc[(n+1)%len(msc)][1]-msc[n][1]) % len(RANKS))) for n in range(len(msc))]
sorted_delta = sorted(max_suit_cards_delta, key=lambda c: c[1])
delta = sorted_delta[0][1]
first_tell.append(msc[sorted_delta[0][0]])
del ar[ar.index(first_tell[0])]
s = first_tell[0][0]
n = (first_tell[0][1] + delta) % len(RANKS)
hide.append((s,n))
del ar[ar.index(hide[0])]
if delta >= 5:
delta_tell.append(ar[0])
del ar[ar.index(delta_tell[-1])]
elif delta >= 3:
delta_tell.append(ar[1])
del ar[ar.index(delta_tell[-1])]
else:
delta_tell.append(ar[2])
del ar[ar.index(delta_tell[-1])]
if delta % 2:
delta_tell.extend(ar)
else:
delta_tell.extend(ar[::-1])
tell = delta_tell[:(turn%4)] + first_tell + delta_tell[(turn%4):]
result = [RANKS[n] + ' ' + SUITS[s] for s,n in tell]
print(result)
return result
def magician(*cards, n=1):
turn = n - 1
ar = [(SUITS.index(card.split(' ')[1]), RANKS.index(card.split(' ')[0])) for card in cards]
ar = [ar[turn%4]] + ar[:(turn%4)] + ar[(turn%4+1):]
print(ar)
delta = 2
if ar[2][1] < ar[3][1] or (ar[2][1] == ar[3][1] and ar[2][0] < ar[3][0]):
delta = 1
sorted_ar = sorted(ar[1:], key=lambda a:(a[1],a[0]))
if ar[1] == sorted_ar[0]:
delta += 4
elif ar[1] == sorted_ar[1]:
delta += 2
else:
delta += 0
print("delta", delta)
suit = ar[0][0]
rank = (ar[0][1] + delta) % len(RANKS)
result = RANKS[rank] + ' ' + SUITS[suit]
print(result)
return result
June 8, 2020
Comments: