5 kyu
Let's Play Darts!
203 of 944FrankK
Loading description...
Games
Algorithms
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.
Haskell setup code shows
BullDS
for the bulls-eye return value when the actual value should beSingleBullDS
Interesting and funny kata to learn and understand some new concepts.
I solved it using python and 7 basic tests pass without a problem, but at "Random coordinates" attempt I get a message "None should equal '11'". Could someone help me understand why this is happening?
This comment has been hidden.
Hello, thx for the kata. It is a very nice challenge. I have passed the test and I am now working on the attempt part, but I can't get through it because some points are so close to the border that numerical precision is an issue. At least I think it is. Are you getting the same issue in Python? or should I try to think about another approach?
I solved it using the math library.
This comment has been hidden.
python?
.
When attempting a solution in Python, the test case remains red: "Random coordinates must return the correct scores" Even as there are no failed test cases.
.
This comment has been hidden.
they actually were running, but without feedback on success
There is typo in swift
Default function name is throw, but should be getScore
Rust translation.
This was a really good Kata, it took about 3 pages of scratch paper to figure out how I wanted to do this!!
:)
This comment has been hidden.
Using python; a small typo in the sample test cases caught my eye. For your 'T2' assertion, the subsequent string misspells 'triple' as 'tripple.'
Great kata, thank you!
Thanks, I changed it!
I'm using Haskell, there are two issues here:
Read the problem more thoroughly! Note that the diameters of each circle were given, and you calculated radii.
Ok! Thanks!
Please, explain how (-133.69, -147.38) is "X" if the coordinates are within the Double ring inner circle (d = 324 mm) which should give a single number.
The largest circle in which hits count on the dart board is 340mm...in diameter. The coordinates are further away from the center than the radius of the double ring outer circle.
if you divide 340 by 2 to get the radius you get 170mm, which is still further from the centre of the circle than either of those 2 coordinates, so how can it be a no score? Edit: As soon as I wrote this I realised what I was misunderstanding- its 170mm at the furthest point from the circle but if you've hit left or right of the exact centre the distance to the top/bottom of the board is going to be less than 170mm
There must be something VERY WRONG with this kata!
With the coordinate (-101.572654585255 , -111.898313933494), the RIGHT answer should be 7, this is my proof:
I think something is VERY WRONG with you... :)
The kata is solved by more than 200 people. Each time with 25000 random coordinate pairs. Nobody had a complaint, nothing went wrong.
It must be a translation made by another user, that does not make this 'kata VERY WRONG'. No, all other languages will tell you 7. Can you please tell me which language you use?
Swift. So it is the Swift version of this kata that is very wrong, perhaps? :)
Hi pegasusroe!
Sorry for my statement about you... Indeed, it is the Swift version and I must have been sleeping when I approved the Swift translation because it lacks the 'randomized test' of 25,000 at random coordinates.
I am not a Swift programmer but I will try to do something about it or eventually remove it. In the meantime the only thing you can do is switch to another language.
FrankK, I have passed sample tests through multiplying my radius by 2. I think the same situation with final tests. Swift language
I tried but I do not get the Swift translation removed. It is just a very bad translation.
Same here. The test case is wrong, and I can't pass using Swift. I spent hours second guessing myself.. What the heck?!
More than 9 months ago I said the same, that there is a problem, so you can't say: "Nobody had a complaint, nothing went wrong." I've already complaint. The answer was the same: "A lot of people solved this Kata, so there can't be any problem...". And now you agree that there is a problem in Swift version of Kata.
The problem still occurs, and moreover: my last working solution (with one error) cannot be processed because of problems with classes and other stuff. So, what's next? Will the Swift translation be corrected or removed?
This comment has been hidden.
Hi... I don't understand. If I follow your link than 227.8 should be 16.
This comment has been hidden.
Hi massacre-nrj,
This kata is solved many times before, there is no error in the kata.
The link is just somebody else's solution to this kata (without acknowledgement), it is more fun to think of your own solution ;)
Cheers, Frank
The thing is that I never knew that there were a solution on this link--I just found typical dartboard with angles in google pics. I have my own solution and the only thing that matters for me is to find out what is wrong with my solution and why 227.8 is 16.
There must be something VERY WRONG with this kata!
With the coordinate (-101.572654585255 , -111.898313933494), the RIGHT answer should be 7, this is my proof: https://ggbm.at/cr6Rg3Nf
This was really fun FrankK!
Off to part 2!
Incomplete description:
...but the example is missing!
Hi Anter, you are right!
I've fixed it.
I'm afraid it's still not right:
I guess
30
doesn't correspond tobelow
(should be either-30
orabove
:-)Yes... That was a sloppy... :D
It is fixed.
I solved this kata, but I can't figure out Random Test. Where can a problem be? Should I use BigDecimal? HELP
All is good!
Whew, that was a tough kata. I spent all day trying to figure out the RandomTest. Hint: Presicion matters.
Excellent Kata Frank! Thanks!
Thanks Soptinator!
I almost feel guilty that you spent so much time... ;)
Hey I looked at your solution, why did you use Math.POW (~~~, 0.5) instead of Math.Sqrt(~~). Does POW take less instruction time?
Hi, no reason and no performance gain.
I think I find it easier to use always the same method for all root calculation, instead of a diffent method for the exception which the square root is.
I pass all the final tests but I fail the RandomizedTest with a IndexOutOfRangeException. I really want to beat this Kata please help.
This comment has been hidden.
yeah sure
This comment has been hidden.
This comment has been hidden.
It's not very elegant, but
(x % y + y) % y
in Java (or any other language with the%
operator that's not Python) would give you the same result asx % y
in Python.This comment has been hidden.
This comment has been hidden.
My bad, sorry. However, wouldn't it make much more sense to specify it as radius?
Hey musesli , so looking at your solution. What's the benefit of using a Diameter() fuction. I thought doing division would cost a lot of processing time. Wouldn't it be better if you hard code your diameters in the if statments to optimize your code? I thought your solution was facinating by the way.
This way, whenever I have to change the value, I won't be making any mistakes easily (e.g. forget the division of the value). I probably should have named it
DiameterToRadius
then a reader would have known what it really does.First of all, it's not code in a critical section. That would make it premature optimization. Never sacrifice good design for what you think is efficiency. A good compiler will inline functions and use constant folding to avoid any overhead when feasable.
As a side note: integer divisions by powers of two are usually implemented with very efficient shifts.
No, because abstraction is way more important, the compiler will very likely take care of it. Only optimize when you find a performance bottleneck (but write code with runtime complexity and cache locality in mind).
Hi Muesli,
Why diameter? Because the figures I looked up on the internet were diameters. I had to make radius of them to solve and I did not want to take that fun away from you... ;)
Much appreciated! It could however help to highlight the word diameters (e.g. with italics). Thanks for this Kata. I published a Haskell translation by the way. :)
Thanks for your translation Muesli!
I 've approved.
Very enjoyable kata! Had fun doing this one, especially since I played a lot of Darts years ago!
Thanks!
The description should be revised to clarify that the sizes of the different circles are based on radius, and NOT diameter. For example, the bull's eye
size
is listed as 6.35mm. But it really should state that theradius
of the bull's eye is 6.35mm.Using the term "size" leads to ambiguity, as it could refer to diameter, circumference, or area. Even a term like "width" generally refers to diameter rather than radius.
Other than that, it's a good, original kata.
Thanks! Good point, I changed the description.
*Ooooch!* Understand, at last ! May be some more explanations on how score is computed (a link to https://en.wikipedia.org/wiki/Darts#Scoring ?) would help non-dart-players like me.
; ))
Thanks for your remark. I've added the link!
(Hehe... I play the game every day, hard to imagine that not everybody is familiar with the rules)