Ad
  • Default User Avatar

    why use a different iteration method for the first list ?

  • Custom User Avatar

    Yeah, the code failed for most of the cases cuz i made it exclude non-unique prime factors (my understanding of k-primes definition). Now, it works perfectly, but for one last random test lol.

    Thanks for the fast response th.

  • Default User Avatar

    I am aware that 40 ppl has passed it

    I am very sorry, the C tests are not broken. Not only 40 ppl passed this test but it is common to all languages so 868 ppl passed it. I tried many C solutions and all were fine. I am afraid something is wrong in your code. I also tried your solution with other tests taken from "ATTEMPT" and you fail every one. Cheers.

  • Custom User Avatar

    Tests for C are broken! Please take a look into it! I get this: Expected 2, got 3.

    NOTE:
    I had the same issue in sample tests what drove me crazy. At the end, I found that the problem is in the first test there were 3 consecutive primes and not 2. Check it yourself:
    int a[] = {10081, 10071, 10077, 10065, 10060, 10070, 10086, 10083, 10078, 10076, 10089, 10085, 10063, 10074, 10068, 10073, 10072, 10075};

    I am aware that 40 ppl has passed it, but the fact that there is an issue in the sample tests made me frustrated. I debugged the code it passed all sampe tests (after correting the aforementioned one).

  • Custom User Avatar

    Try to add the case when n = 2 ie arr = {1, 4} => 5 and arr {-10, 2}. My code had that bug (since I had to convert it from recursion into iter) and it passed the tests.

  • Custom User Avatar

    careful, tests didn't caught a bug in it (2nd if cond).

  • 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

    Well, he used letters as indexes in his array (since computers sees only numbers: A is 65 in ASCII).
    Before that he covers up all possiblly encoded symbols in range of 256 bits (thus, table[0..255])
    => similar to count sort algorithm

    i.e. the following string "ABA" will have these values in the table[] after the first loop (counting loop):
    1st round: table[65] = 1
    2nd round: table[66] = 1
    3rd round: table[65] = 2 => which will be checked within the verifying second loop by <if (table[toupper(word[i])] == 1)>