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

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

Hello, I read “you are playing Blackjack at a casino table that uses only one standard deck of 52 cards”, but for the second test, I count 54 cards, it’s an error in the description or I should recount? Can you give me that number because I think I didn’t get the way of counting cards :no_mouth:

Can you list the 54 cards you have counted?

Thank you for your quick answer.
This is the list I see (sadly I cannot upload images because I’m new on the forum):

  1. Did I turn the iron off?
  2. Did I turn the iron off?
  3. A
  4. T
  5. 3
  6. A
  7. 7
  8. J
  9. A
  10. J
  11. Oceans11
  12. 9
  13. 5
  14. A
  15. mob boss
  16. IRS
  17. hungry
  18. Cute dealer
  19. 2
  20. 4
  21. 5
  22. T
  23. 8
  24. 4
  25. Q
  26. Show Girls!!
  27. Q
  28. Q
  29. Q
  30. 2
  31. 4
  32. 8
  33. 6
  34. 8
  35. QUEEN
  36. K
  37. 8
  38. 3
  39. 7
  40. 6
  41. 9
  42. 5
  43. Is that Penn or Teller?
  44. 3
  45. 6
  46. 2
  47. 4
  48. 3
  49. 6
  50. K
  51. J
  52. 7
  53. K
  54. J

No worries, now I see how you’re counting. You should only count A23456789TJQK as cards, and all other streams of consciousness should not be treated as cards. In your list, every item which consists of more than one character should be ignored, e.g. #1, #35.

Ohhh I understand!!! I thought that the next card would always be the 52 pickaxe, but no.
So in the first test 49 cards have been drawn and 44 in the second?