Ad
  • Custom User Avatar

    Thanks for clarification, knowing that I am expected to round only the final results and not the partial results will definitely assist me in debugging. I'll try to handle this myself first, thank you for your assistance!

  • Custom User Avatar

    It varies because I have several solutions.

    Generally speaking I rounded it with several different methods, and at different levels - i.e. in one test I've only rounded the final result, in other tests I've rounded all the multiplied values, in yet another I've rounded only some of them.

    The higher the precision* I've kept, the bigger the gaps were. I've received the "consistently closest values" (i.e. difference of 0.05 not 0.5) by doing the "appropriation" and not even the roudning by using the following imprecise formula: Math.round(value * 1000d) / 1000d;

    I've verified some of the results manually and for the method that I've thought should give the highest precision I've had same results as on Google's and Microsoft's calculators. If I am wrong, please hint me the right method of how is rounding done in Java.

    *"precision" is pretty relative as I am definitely not an expert it this field

  • Custom User Avatar

    I've tried doing this in Java but I fail on random tests.

    I've searched for most precise methods of doing this and avoided common imprecise rounding methods.
    I've analysed the values and calculated the areas by hand and I stand with the results my code produces.

    Could you please take a look at the Java TC's translation?

  • Custom User Avatar

    How do you Google for "~" ? :(

  • Custom User Avatar

    Woah, no lambda, I am amazed. I gotta research the ~- thing.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Interesting Kata. I'll come back to it, and I think to CW alltogether, once I'll solve the challanges on project Euler - often I found myself stuck because my approach to given tasks are too brute-force. In the job I do, its not a problem, but in the jobs I'd want to do, it is.
    Thanks for the direction.

  • Custom User Avatar

    Surprisingly satisfying Kata.
    Also, regarding the random input generators, as of 2nd of July 2017, its pretty specified that you can only use one_two() inside one_two_three()

  • Custom User Avatar

    As for doing the above, indeed I did, as for keeping this simple, well, my sight is far from being perfect, but I'd probably see room for improvements in that matter even if I were semi-blind ;)

  • Custom User Avatar

    @Volie:
    Since the Kata itself is not really about checking if number is a prime or not, but about optimization of the process, it seems reasonable to rank it past the threshold of "able to get it done", and put it in "able to get it done quickly" basket.
    Anyway, CodeWars have tied in my personal ranking of best websites ever, and I thought that Quora is unmatched when it comes to getting rid of your own ignorance. It's not the first time you're responding on my concerns in the discussions, thank you for caring for this environment!

  • Custom User Avatar

    @GiacomoSorbi:
    Thanks for the input, you know, from the perspective of beginner programmer, a program which finds first 1000 prime numbers in 0.5 seconds seems efficient. Now I understand why it is not, and have gone much further in the Kata - to the point that I never get any errors from failed test cases. Unfortunately, there is still room for optimization, as I exceed the 12s threshold on checking whether numbers of size unknown to me are prime. For bilions it works fine. Could I please ask for the biggest possible value available in the Kata test cases, so I could analyse the performance on my local environment?

  • Custom User Avatar

    I have wrote a solution, and it worked. I'm a noob, so I was sure there's a better way for that.
    I then thought "ok, so there's this try/except stuff, which I do not yet understand, and which could make my solution shorter".
    Thanks to this Kata, I have finally found a case in which I knew what I expected the code to do, and this is my first successful usage of try/except mechanism. I learned something new, and I have stripped my solution from 15 lines of code.
    Thanks for the Kata.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    okay, so now I've read all the discussions here, have read the ecolbans comments, know what to do and going further with the Kata seems probable - instead of completely failing the tests, I now have too big discrepency between the number of primes in the list (i.e. 168 where there should be 152).
    Anyway, I think I'll manage, and actually I've learned so much even before completing the Kata.

    The only concern I now have is the difficulty level of this Kata. It's marked as 5, its harder than those of Kyu3 which I have managed to pass, its definitely closer to kyu3 than to kyu5.

  • Loading more items...