Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
The idea is: at any point where you are adding up the total value of your current hand of cards, it is up to you to decide whether or not it is more mathematically advantageous to count an
ace
as1
or11
.From the description:
not a kata issue
This is a shitkata I've given up on, and I don't think it should be approved at all anymore. Anyway, I'll still answer your question.
It's a mathematical concept, so I'm just repeating something you'd find on the internet.
Let's say we have an event that can yield multiple outcomes with different values associated with each. The expected value is the sum of the probability of an outcome's value multiplied with it's probability for all outcomes of the event.
I'll not go too much into it; there are way more sources online that can explain it better than I can.
For this problem, the even has only two outcomes: heads or tails. If you get heads, you win the prize; if you get tails, you gain nothing.
So the expected value is just the probability of getting heads times the prize value. It gets a bit unintuitive with negative values for the prize, but the idea remains.
This comment is hidden because it contains spoiler information about the solution
Added that test to C, Ruby and Javascript.
This comment is hidden because it contains spoiler information about the solution
Not now, I'm at work. I've added this test to Python:
The algorithm used skipped values iterating over a list and mutating it in the process.
Will you please change the other 15 language versions as well? Because nobody else can because you're not telling what change you made, or why.
Added a test for Python that rendered your solution invalid. But there should be more tests like that, ideally, with random numbers to avoid hardcoding.
Because of some list functions not working on strings (pop, remove for example) I have a bit of a blindspot as to whether I should transform to lists or not and tend to do it without thinking, especially when it's a low level kata (since I usually go through a few of these whenever I get stuck in something more complex, meaning I sometimes do unnecessary stuff like this :) )