8 kyu
Thinkful - Number Drills: Blue and red marbles
6,232 of 13,539Grae-Drake
Loading description...
Probability
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Scala translation
Approved
in thinkful number drills:blue red marbles it dosnt work on rust
good kata!
Desc modify suggestion:
"First two numbers are the initial red and blue marbles.
Last two numbers are how many marbles have been pulled.
You need to find the probability of pulling blue on the next pull."
(These math ones should be 7 kyu, not 8. I think 8 should be reserved for fundimentals)
very useful comment thanks
The description could be simplified with no loss to the problem, for instance: "You get a point if you guessed correctly. The trick is" has no bearing on solving the problem itself, and so I wouldn't miss it if it was gone.
This comment has been hidden.
Expected: 3.0d +/- 9.9999999999999995E-08d But was: 0.59999999999999998d
The first test which should expect 0.6. Looks like it's testing for a quadratic since it's got 2 solutions (3 + 9.9999999999999995E-08 and 3 - 9.9999999999999995E-08).
Wassup?
Actual and expected are flipped, and what you see is because they're compared with a Delta value to not fail because floating point differences, it's not related to a quadratic.
Fixed, check your code, probability can never be more than 1.
Works :) Although, I failed the second test this time around because "You've decided to write a function, guessBlue() to help automatically calculate whether you should guess "blue" or "red"." this line from the description implies we're supposed to return the marble with the highest probability, and not just probability of blue (even though that's what the method name implies). Thanks for the kata :)
Well, yes, but the last line also says this:
guessBlue() should return the probability of drawing a blue marble
then you use that result to guess one color or the other I guess.It's interesting how I don't need to round anything...
This kata is broken. Please, check it.
Broken how? Check what? Please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
My solution is correct. The earlier solutions are also correct. My solution does not work, as well as all solutions provided earlier. The tests do not pass.
Which language are you questioning? As of writing this Kata is available in 8 languages so hard to help unless know which one?
c#
This comment has been hidden.
Earlier solutions still pass in C#.
Okej, I checked everything again. My serious mistake. Sorry for the confusion. Everything works.
No problem
C and C++ translations available. Please review.
This comment has been hidden.
Fixed.
This comment has been hidden.
Hi,
I'll check that second point across languages and make an update of the description.
Hi, In Java (0.0 / 0.0) produce NaN. For example: double zeroDouble = 0; int zeroInt = 0; System.out.println(zeroDouble / zeroDouble); System.out.println(zeroDouble / zeroInt);
And what would you expect for 5, 5, 5, 5 anyway? 0 blue out of 0 total is NaN.
description updated
(crasy thing of the day: in 4 years practicing Java, I believe it's the first time I cross path with
Double.NaN
XD )Hi, Unnamed! In case of guessBlue(5, 5, 5, 5) I'll expect 0. The probability of drawn a blue marble from an empty bag is zero, but not NaN!
Then what's the probabilities of:
These probabilities are obviously also zero.
If probability is a quantitative assessment of the possibility of a certain event (for example, getting an object out of a bag), then since there is no opportunity to get something from an empty bag, then the corresponding probabilities are equal to zero, isn’t it?
If there's no sample space, anything else doesn't make sense, there are no probabilities at all.
Interesting. If you just calculate the result and return it, it is zero in Java. I guess this is because the input parameters are int and the output is double. If you add or subtract them into a double you can devide the resulting double values. I wonder who also needed some minutes to understand this.
Not an issue.
This comment has been hidden.
Can you say more? What part did you find ambiguous?
lol maths
This comment has been hidden.
lovely task
No random tests in Rust.
"expected: NaN"?
Fixed.
Test Passed: Value == 0.7777777777777778 Expected: 0.35714285714285715, instead got: 0.3571428571428571
???
Should be okay now.
The Test Framework for Groovy (prolly not this exercise itself) starts to have issues with precision if I purposely cast any part of the opperations as float or double in the puzzle. Looking at other solutions, it is prolly using a Decimal number/data type in the background and relying on that being a thing... which is the sort of thing that evokes existential dread for me (expecting an expected behaviour in a language... THE HUBRIS! xD).
Prolly not an issue with how the puzzle handles the Groovy stuff (I've noticed Groovy is in Beta... so I'm going to assume it is the test case stuff)... but definitely something to note. Even if it is more a note, and not an error/warning with the Groovy tests.
not sure why this was marked solved, just did this in groovy and had the same issue. Setting as a float, which is a requirement in the instructions, causes it to fail. Perhaps an explanation of why it was marked resolved would be nice ie a groovy bug, but, its 5 years old, not sure its a groovy bug? ¯_(ツ)_/¯
Haskell : https://www.codewars.com/kumite/5bb1843a2d15ec9d04000037?sel=5bb1843a2d15ec9d04000037
Groovy translation kumited. Please review and approve. Thanks, suic
Rust Translation
Please review.
This comment has been hidden.
How do you terminate a decimal in python? Thanks.
I am getting:
0.6666666666666666 should equal 0.6
P.S I have already tried to convert one of the numbers to a float but it did not work.
This comment has been hidden.
Because your dividend and divisor both are wrong.
Hi:
The random test is expecting decimal 16 instead of 1. Which decimal is expected in general?
Hi @kane0019, I'm not sure what your question is.
Hi there: I am using Python
Random tests Test Passed 0.6 should equal 0.6052631578947368
as you can see the random tests is looking for float decimal point which others test is expecting 1 fixed point base on my understanding. According to your test sample I think 1 fix decimal point should be the expected anwser, is it ?
No rounding is required,
0.6
is the exact answer for that sample test.OK. No problems. Thanks for the clarification.
Hi, two suggestions:
Regards,
suic
P. S.: Please consider the approval of this translation. Thanks, suic
Thanks, added the test cases.
I actually excluded those edge cases from the random tests (there'll always be at least one of each color in the bag) to keep the complexity of the kata down.