Ad
  • Default User Avatar

    I corrected my solution and this time the tests did work fine.
    Thanks for your quick fix!

  • Default User Avatar

    Random tests in prolog always fail:
    plunit_dbl_linear:dbl_lin_db/6: "Undefined procedure": dbl_lin/6 (forall bindings = [40])

    in line 49 of your test file there is a call to dbl_lin instead of dbl_lin_db (probably that line wasn't updated when the function was pasted in the test file)

  • Default User Avatar

    You can't, you can fork it and fix it. Take a look at my fork and tell me if you like it

  • Default User Avatar

    In the description you say 3 numbers but the solution you suggest is up to 3 not exactly 3,
    then again you say in range 1 to 10 then you give an example with 12 as a selected number.
    when you search for a non prime number in the is_prime function you can reduce the range in the for loop.
    If the number you are checking is not prime the biggest factor that possibly divides that number is the one that pair with 2 to compose it, right? then your range could be range(2, int // 2) but then, after your first check you find that it is not divisible by 2, so the biggest factor that possibly divides that number is the one that pair with the next prime, 3. so range(2, int // 3) and so on.
    Following the pattern you can actually stop at the square root of the number you are checking range(2, (int)(math.sqrt(n))+1).
    Since the maximum number obtainable is 101010, would you mind cache the 9674 prime numbers? If you have them cached (sorted) then you can binary search the closest prime and find the midmost one.