Beta

Pi approximation fractions

Description
Loading description...
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • zhamar Avatar

    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.

  • TSingh1699 Avatar

    This comment has been hidden.

  • Mercy Madmask Avatar

    |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

    • polluxCast0r Avatar

      I've fixed the test to check just for precision, not exact num/den pairs. You should be ablt to publish your solution now.

  • dch216 Avatar

    This comment has been hidden.

  • Voile Avatar

    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).

  • Voile Avatar

    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.

    • polluxCast0r Avatar

      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.

    • Voile Avatar

      This comment has been hidden.

    • polluxCast0r Avatar

      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.

  • Blind4Basics Avatar

    you should revise your random tests, they are random... but not random at all at the same time... x)

    • polluxCast0r Avatar

      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.

    • Blind4Basics Avatar

      just print the expected values. ;)

    • polluxCast0r Avatar

      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.

      Issue marked resolved by polluxCast0r 7 years ago
  • Blind4Basics Avatar

    I believe I already saw that task on CW... Did you search for duplicates?

    • ZED.CWT Avatar

      You mean this one? Well, this task is quite different

    • Blind4Basics Avatar

      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.

    • ZED.CWT Avatar

      Let me think... was there many fractions problems...? Oh, do you mean those JomiP katas?

    • Blind4Basics Avatar

      possibly, yes... But I feel like I saw some others. I might be wrong though (memory is not really my best asset... x/ )

    • polluxCast0r Avatar

      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. :(

    • Blind4Basics Avatar

      well ok. Let's resolve this. If there are, other users will notify you with a faithful info.

      Question marked resolved by Blind4Basics 7 years ago