all 30 comments

sorted by: hot top controversial new old
[+] 27 points 9 months ago (2 children)
  • [–] 21 points 9 months ago* (1 child)

    You could simplify it even further by removing the int x parameter of the function...

  • source
  • hideshow 1 child comment
  • load more comments (1 reply)
    [–] 39 points 9 months ago (3 children)

    95.121% of the time it works everytime.

  • source
  • hideshow 3 child comments
  • [+] 10 points 8 months ago (2 children)
  • [–] 17 points 8 months ago

    Just put "Precondition: x must not be prime" in the function doc and it'll be 100% accurate. Not my fault if you use it wrong.

  • source
  • [–] 15 points 9 months ago

    It approaches 100% accuracy

  • source
  • [–] 13 points 8 months ago (1 child)

    We could probably improve on that significantly without losing speed.

    return $x < 8
    

    That should yield one additional correct answer, while also confusing anyone who thinks it just returns false.

    And if we just hard coded and checked the first 20 or so primes before always returning false, we would probably get noticeable improvement (depending on the total range).

  • source
  • hideshow 1 child comment
  • [–] 1 point 8 months ago

    I've seen so many game jam entries where the code is like this. Delicately balanced and using so many assumptions to just get the thing out the door.

    It's funny when they decide to make a full game out of it and realize that it's gonna take them 6 months just to undo the tech debt of the original "demo"

  • source
  • parent
  • [–] 10 points 8 months ago

    This is how AI accuracy is also measured.

  • source
  • [–] 8 points 9 months ago

    I've had managers who follow that exact algorithm.

  • source
  • [–] 5 points 9 months ago (3 children)

    I'm confused, shouldn't this be printing false no matter what the input is?

  • source
  • hideshow 3 child comments
  • [–] 6 points 8 months ago

    The output is not the output of the algorithm, it's the output of the unit test.

    95% of numbers up to that point at not prime. Testing the algorithm that only says "not prime" is therefore correct 95% of the time. The joke is that, similar to AI, the algorithm is being presented as a useful tool because it's correct often but not always.

  • source
  • parent
  • [–] 6 points 8 months ago (1 child)

    The test suite probably looks something like this:

    int tests_passed=0;
    int tests_failed=0;
    for(int i=0;i<100000;i++){
        printf("test no. %d: ", i);
        if(is_prime(i)==actually_is_prime(i)){
            printf("passed\n");
            tests_passed++;
        }else{
            printf("failed\n");
            tests_failed++;
        }
    }
    //...
    
  • source
  • parent
  • hideshow 1 child comment
  • [–] 6 points 9 months ago (1 child)

    Is this not at all stochastic, or do I just not know what stochastic means?

  • source
  • hideshow 1 child comment
  • [–] 5 points 8 months ago*

    I said something similar about an election fraud detection system with 99.999% accuracy.

    https://lemmy.world/comment/22178379

  • source
  • [–] 5 points 9 months ago* (last edited 8 months ago) (1 child)

    This but AI

    But they are like 60-80%

  • source
  • hideshow 1 child comment
  • [–] 4 points 9 months ago (2 children)

    But when the input is all prime numbers then the accuracy is 0.

  • source
  • hideshow 2 child comments
  • [–] 4 points 8 months ago (1 child)
  • [–] 4 points 9 months ago

    But cryptography...

  • source
  • [–] 2 points 8 months ago

    The test suite probably looks something like this:

    int tests_passed=0;
    int tests_failed=0;
    for(int i=0;i<100000;i++){
        printf("test no. %d: ", i);
        if(is_prime(i)==actually_is_prime(i)){
            printf("passed\n");
            tests_passed++;
        }else{
            printf("failed\n");
            tests_failed++;
        }
    }
    //...
    
  • source