[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 !!

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 ?


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

1 Like

Aaah, forgot this.
All green, thanks :slight_smile:

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:
serials[i] = β€œ0”
# Turn the value of the cards sequence into sum of points
temp = []
for char in serials[i]:
if char in {β€œT”, β€œJ”, β€œQ”, β€œK”}:
elif char==β€œA”:
# Remove the card counted from the deck
if char!=β€œ0”:

remaining = []
for i in range(len(deck)):
if deck[i] in {β€œT”, β€œJ”, β€œQ”, β€œK”}:
elif deck[i]==β€œA”:

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

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

if round(PC)!=7:
print(str(round(PC)) + β€œ%”)
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.


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 :slight_smile:


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?


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 :hot_face:. Thank you!