[Community Puzzle] Card Counting when easily distracted

Coding Games and Programming Challenges to Code Better

Send your feedback or ask for help here!

Created by @Lisa-Has-Ideas,validated by @cedricdd,@5922 and @_CG_XorMode.
If you have any issues, feel free to ping them.

1 Like

Another hit from Lisa-Has-Ideas. Reminds me of the movie ā€œRain Manā€ :smiley:

1 Like

Thanks. Iā€™m so glad people enjoy my puzzles. I love creating them.

2 Likes

I loved this puzzle. It was educational and really fitting to its diffictulty. Its difficulty is visible at a glance and its description is clear.
Solving it in C++ was a challenge, but that was entirely my choice))

If I had any ideas or criticisms, Iā€™d ask you to reduce the number of tests. I donā€™t see why you would need this many.
As for ideas, I expected thoughts to be more unique in those different test cases. I even thought that you could collaborate with someone and make an ARG where your answers would be part of a clue for something else. Since puzzle is easy enough, itā€™s rather accessible for anyone with a passing interest in programming.

And judging by other answers, I need to check out other puzzles of yours!

2 Likes

Ha, yes, there are a lot of tests. What I did was I created a program to generate (randomly) all the test cases, and since I had done that, I wanted to ā€œget my moneyā€™s worthā€ out of it.:slight_smile:
True it is probably excessive, but from feedback on prior puzzles I created, people seem to really like lots of test cases. (I know I personally get a little ā€œdopamine hitā€ every time I see something go green.)

I tried to put humor in the inputs for those interested enough to look (probably not many will, but its sort of like an Easter egg I guessā€¦ anyways that was my thought.).

I LOVE that idea about ā€œyour answers would be part of a clue for something else.ā€ā€¦ I will keep that idea in mind and see how that might germinate into something. Thank you for that inspiration.

Yes, please do play all my other puzzles :slight_smile:

1 Like

Hi, is streamofconciousness a list type with one number (or word) for each cases or is it just kind of a big box with anything inside

in fact I just donā€™t understand why it doesnā€™t work, this is my code:
import sys

import math

Auto-generated code below aims at helping you parse

the standard input according to the problem statement.

stream_of_consciousness = input()

bust_threshold = int(input())

T=J=Q=K=10

A=1

card=[2,3,4,5,6,7,8,9,T,J,Q,K,A]

percentage = [4/52,4/52,4/52,4/52,4/52,4/52,4/52,4/52,4/52,16/52]

percentageChance=0

res=[]

for i in stream_of_consciousness:

if i in card :

    res.append(i)

for i in res:

percentage[i]-=1/52

for i in range (len(percentage)):

if i <= bust_threshold :

    percentageChance+=percentage[i]

percentageChance*=100

percentageChance=round(percentageChance)

Write an answer using print

To debug: print(ā€œDebug messagesā€¦ā€, file=sys.stderr, flush=True)

print(str(percentageChance)+"%")

Hey thanks for playing my puzzle. You can see in the test cases what stream of consciousness looks like.

It is one long string.

Remember that just because something is in the stream of consciousness doesnā€™t mean itā€™s a card.

For example if one chunk in the stream of consciousness is ā€œ2-for-1 buffetā€, that doesnā€™t mean that you have seen a ā€œ2ā€ card.

so double check on your logic

Hi @Lisa-Has-Ideas, sorry to annoy you,

I will describe what my program do with ā€œTest 1ā€ :

1 : I split stream_of_consciousness by ā€˜.ā€™
2 : I remove invalid elements : ā€˜some distractionā€™ and ā€˜another distractionā€™
3 : So, there are 45 valids cards already played : 2223334445555678678678678TTTTJJJJQQQQKKKKAAAA
4 : Only 2 remainings cards : 2,3 are < 4 :bustThreshold

So my result is 2/7 : 29% and not 67%

I donā€™t understand in which step Iā€™m wrong. Can you help me ^^ ?

Hi Stat ā€“
You are not annoying ā€¦ I learn from peopleā€™s questions. So thank you for the question.

Look back at the ā€œTest 1ā€ input. There are four 9s (in other words ā€œ9999ā€) that you have ignored. Donā€™t ignore those :slight_smile:

1 Like

Thanks a lot for your fast response,

it was just a stupid mistake of my part : write to fast ā€˜9,ā€™ instead of ā€˜9ā€™ in my list with all card values. Didnā€™t think the error would be from here x)

I just finished it now. Thanks for this great puzzle.

1 Like

HI could you explain the rules
for test1
it remains 2,3,4 in the deck.
so what is mean 2nd string 4 ? what the % of getting 4 ? 33%
also what is mean bustThreshold with simple words. google translate cant translate bust

1 Like

Hi Alex ā€“ Thanks for playing my puzzle.

The puzzle states: (The bustThreshold is what would make your hand ā€œgo-bustā€/lose by going over 21. It isnā€™t anything you need to calculate; it is provided.)
See image from Wikipedia, especially the part I highlighted

In Blackjack, you do not want the cards in your hand to go over a value of 21. If you do, you lose. So in the puzzle I provide the value you do not want. For example, your hand has a value of 18, so you know that you do NOT want a 4 or higher, because that will make it total of 22 or more and will make you ā€œgo bustā€ (aka lose)

In other words: In the puzzle I could have said ā€œyour hand is 18, what is the chance of getting a card that doesnā€™t makes you bust (i.e., makes your hand-total not exceed 21)?ā€ But I kept it simple and just provided the bust-threshold for you.

Does that help?

2 Likes

thank you for answer
so I understood bust is like burn down/out my score aka looseā€¦ okā€¦ I know rules of blackjackā€¦ but I cant understand till the end what I should calculate

so from mentioned above task >> it remains 2,3,4 in the deck.
and the 2nd string (4) means if I get 4 I looseā€¦ okā€¦ itā€™s mean that I have 18ā€¦ okā€¦
but how from that I should get 67% ? do you mean we should calculate % for all cards that will not busted us (all cards that give us <= 21 )?

yes, exactly :slight_smile:

thank you sir

1 Like

finally I did :slight_smile:
your A=1 made me to think little bit :slight_smile:

1 Like

Is test #23 broken ?

bust : 2
A2.TAT

thats clearly 3 cards on a possibility of 47 (52-5)
3/47 = 6.38% but the test says its supposed to be 4%
even if its rounded up from 3.51 to 4.49 I dont understand how it could be 4% for a 2 on next draw

thank you !

Howā€™ve you got 3 cards? There are 4 aces, everything else is bust and 2 of the aces have already been dealt.

2 Likes

Hi. Thanks for playing my puzzle. I think RoboStac responded well to your concern. Two aces have been played. Therefore 2 aces remain. Hopefully that gets you going. :slight_smile:

1 Like