# [Community Puzzle] Card Counting when easily distracted

ok i missed A was worth 1β¦
Sorry everything works !
100% !!!

1 Like

yeah i got it in c sharp ! 100% good puzzle !

1 Like

My favourite Puzzle so far!
even tho my code is quite longβ¦

Ahh, thank you so much. You made my day !!

Hello!
I donβt understand test #6.
3 β2β were played, and 18 cards >= β3β were played.
So it left one chance on 31 cards, so 3%, not 10%.
What have I misunderstood ?
Thanks

Hi,

Aces have a value of 1, so it left 3 chances out of 31 cards.

1 Like

Aaah, forgot this.
All green, thanks

I have used an exemption on Test 9 because I thought it didnβt calculate it correctly, now I think there is either an error with the expected answer or the way binary is rounded in Python 3.
My code scores correctly all other cases (both in testing and evaluating) but it gets Test 9 wrong, tried to manipulate it in the formula, but when I do that all other Tests go wrong. Anyway Test 9 should be 7% but it is 8% so this what I had to do in the code:

serials = list(stream_of_consciousness.split(β.β))
cards = set({βAβ, β2β, β3β, β4β, β5β, β6β, β7β, β8β, β9β, βTβ, βJβ, βQβ, βKβ})
deck = [f"{item}" for item in cards]*4

for i in range(len(serials)):
# Check if the i-th string contains only card names
for char in serials[i]:
if char in cards:
continue
else:
serials[i] = β0β
break
# Turn the value of the cards sequence into sum of points
temp = []
for char in serials[i]:
if char in {βTβ, βJβ, βQβ, βKβ}:
temp.append(10)
elif char==βAβ:
temp.append(1)
else:
temp.append(int(char))
# Remove the card counted from the deck
if char!=β0β:
deck.remove(char)

remaining = []
for i in range(len(deck)):
if deck[i] in {βTβ, βJβ, βQβ, βKβ}:
remaining.append(10)
elif deck[i]==βAβ:
remaining.append(1)
else:
remaining.append(int(deck[i]))

PC = 0
for i in range(len(remaining)):
if remaining[i]>=bust_threshold:
PC+=1

PC = int(100*(1-PC/len(remaining)) + 0.5)

if round(PC)!=7:
print(str(round(PC)) + β%β)
else:
print(β8%β) # because Test 9 is bugged

Please edit your message and format your code using the </> button in the formatting toolbar, otherwise itβs difficult to read it. Thanks.

Hi,

The result for Test 9 is 3/40 so 7.5%, you just need to make sure that when you have a X.5, in order to get the βnearest whole numberβ you are rounding up.

I got distracted reading through the thoughts, then I realized I was trying to program a solution haha - good one

2 Likes

Nice little puzzle, very kind of you setting A fixed to 1 ;D

Just out from interest, does some1 have a βfancierβ solution to set up our knowledge of a Blackjack 52-cards deck? I am doing it like this currently (typescript):

``````const set = ['2', '3', '4', '5', '6', '7', '8', '9', 'A', 'T', 'J', 'Q', 'K'];
const deck = [...set, ...set, ...set, ...set];
``````

Hi. Seems I have problem with filtering card streams and distraction. Used replace ^2-9AKJTQ and removal of uppercase followed by lowercase characters, but still below 50% of successful tests. Any advice?

THX

One of your thoughts might be JACK, because youβre thinking about your friend Jack but that doesnβt mean that youβve seen a jack and ace

Does that help?

well - it helped but caused a lot of thinking . Thank you!