Solved - Probability Calculator - Returning Wrong Results

Edit: I was experiencing an issue in which I the probability calculator test, was returning:
Test 3A : .248
Test 3B : .68

I used a roll() method to improve efficiency, rather than creating a new Hat() every single loop.

My results were not correct, and the reason was i forgot to remove the items from the hat each new roll().

For those arriving at a value of 0.248% probability on Test 3A of the Probability Calculator, I strongly recommend you ensure you are removing elements from the hat.

This problem has been solved

In the future, we can’t say anything about what is happening without seeing your code.

For instance, I have no idea what this means in terms of the code you wrote, but it sounds like you aren’t following the instructions.

I don’t even know what this sentence means - but I also don’t know who in the world can look at 1000 lines of examples and be like “Ah yes, I clearly see something in ALL OF THEM”.

People surely want to plagiarize your failing code and couldn’t just type into the search-console and propably find 5 other topics linking to finished projects… ^^°
Also how exactly do you expect help, without showing off your code?

I created a function called “reset” and saved the hat-content in two seperate arrays - after every roll I called resett and turned the hat-content back to it’s original state.

By the way, you approach will fail for one simple reason: One test checks if after a roll the hat.content has changed.
We could see this, if you’d posted the error message or even your project, instead you are lucky I remember it because many people (including myself) struggled to do that while also allowing multiple-draws.

Edit: I see you found the error yourself. I’m glad but this topic is really confusing O.o

1 Like

Hi JeremyLT,

Thank you for your help.
In the heat of frustration, it can be hard to escape the tunnel vision of wanting a solution.
I have updated the post for future users to be helped by this question, and my future posts will be more concise, and have code snippets as well, as I too would have found this answer useless.

Thank you for your help and efforts.

Andrew.

1 Like

Plagiarism is unlikely. I agree.
Code snippets in the future. Agreed.
Your sarcasm was rude and unnecessary, please leave it out of your posts to future users please. You are not helping contribute to growth in the community by putting others down.

Thank you for taking the time to read it, and I wish you the best in your coding adventures.

I know exactly what you mean by probability calculator, but without seeing your code, we can say nothing to help you repair the errors you made.

This is a moot point however, as you said that you’ve fixed the errors on your own. As such, I’ll go ahead and close this topic.