Ad
  • Default User Avatar
    • added more sample tests
    • added tester function for better error feedback
    • increased random tests from 5 to 100
    • provided a wider range of random tests from 0 <= n <= 100 to ... ?
    • made reference solution static
    • added missing headers for random testing
    • added srand() to seed actual randomization!
    • streamlined testing format
    • added larger tests to fixed tests
    • made fixed / random tester static
    • updated language verion from C11 to Clang 8/C18
  • Default User Avatar

    Hello!

    I don't know if solving it in this way has a name. Maybe constraint satisfaction?

    I think it is one natural way of approaching optimization for the problem: constrain the next subset to be explored based on the current subset.

  • Default User Avatar

    I'm interested in this O(f()^2 * logf()) approach that you mentioned. I'd like to learn this optimization. Could you point me to any online reference?

    EDIT: I found your submission. Is this a popular approach? I can't find similar applications online. Would appreciate some references.

  • Default User Avatar

    I like this solution because it does the minimum amount of programmer work.

    This solution is worse than O(n^3) because of the nested for loops, making this an extremely costly solution in time. Storing each set of kPrimes and iterating over it would be a simple optimization. It can further be reduced by restricted the set a based on b and c (taking it to something less than O(f()^2 * logf()), where f() is based on # of primes below s). There are further improvements and maybe someone would have more insight into the time complexity.

  • Custom User Avatar

    Rejected as there are an insufficient amount of fixed assertions and no random assertions in the Submit tests.