Beta
Pi approximation fractions
Loading description...
Mathematics
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.
Thanks for this kata.
I think the test has a serious deficiency: it does not check if the solution contains the smallest possible numbers, although this condition is stated in the problem description. Please modify the test or the description.
This comment has been hidden.
|n/d - π| < eps
For eps==0.1, why would 16/5 be wrong?16/5 = 3.2
->|3.2 - 3.14159| = 0.058 < 0.1
I've fixed the test to check just for precision, not exact num/den pairs. You should be ablt to publish your solution now.
This comment has been hidden.
As the current tests goes, there is a serious lack of resolving power and lots of fractions between the input ranges are not tested at all (just look at my solution and ZED's solution).
The random tests does not cover every value of the entire range, so some solutions that fails at some particular values will still pass the tests, given some amount of submits.
If you don't want duplicates, you can always use a set to hold the values until the size is of a certain size, and then shuffle the result. Asymptotic complexity is just
O(n*log(n))
.Also, 50 tests are not enough, at least 500 or something is recommended for good coverage of the input range.
Ok, I can change the number of tests to 500 if you insist. But I thought that the purpose of random tests is to check whether the solutions works in general, rather than test all possible inputs. If I need to test all inputs I can just make a single
for
loop with every precision possible, that would be more explicit and cpu saving than generating random numbers. Also, I think that hardcoding every possible fraction shouldn't be considered as a solution, but I don't know how to handle this and make codewarriors to think about the algo. I can increase precision, but that'll just make them to generate some more hardcoded values. Some advices about how to avoid that would be appreciated. Please, leave your feedback or thought about this issue and I'll go straight to fixing that.This comment has been hidden.
Calculating all possible ranges seems like an overdo comparing to the 110 iterations. I've changed the random tests to simple check of all possible precision, and it doesn't seem to cause any trouble with perfomance.
you should revise your random tests, they are random... but not random at all at the same time... x)
Can you give some details about what's wrong? Maybe you can show an example. If the random tests are that bad I can remove them and add 20+ static tests, that's not a big deal.
just print the expected values. ;)
Sorry, haven't noticed that. Now it's fixed :). Also reduced the number of random tests in half, since the choice interval is rather small and some random precisions duplicate themself.
I believe I already saw that task on CW... Did you search for duplicates?
You mean this one? Well, this task is quite different
No, I was thinking about more recents kata related to these fractions problems (a lot of those have been published in the last few weeks/months, iirc). But I'm not sure there were some similar enough to make this one a duplicate.
Let me think... was there many fractions problems...? Oh, do you mean those JomiP katas?
possibly, yes... But I feel like I saw some others. I might be wrong though (memory is not really my best asset... x/ )
I've searched for duplicates before writing theis Kata, and I've looks through all
Possible duplicates
that CW gave me. But if there is some duplicate that I've missed, please, send it to me. Then I will rewrite this kata to differ from the duplicate. :(well ok. Let's resolve this. If there are, other users will notify you with a faithful info.