5

Another GeeksForGeeks rant

Wisecrack got me a bit interested in primes (just a passing interest). I looked up their python implementation of "Sieve of Atkin". Wow, is it bad.

First of all, they use PascalCase instead of underscore_natation so that's points off right there.

Their function takes a limit as a parameter (pretty obviously).

Their program breaks if you pass a prime number as a limit. That's right, if you give it a 2, it breaks. Pretty pathetic.

Reading the comments, their Java implementation is wrong too.

For fucks sake guys, if you're going to have an algorithm blog at least write good algorithms.

Comments
  • 2
    When you're reading up GfG you really only care about having an illustrative example of the thing. Code standards, reliability etc. don't matter at all.

    I suspect the fragility is because it was written to solve some competitive programming question and they tell you exactly what kind of input you get - if the input makes it clear that you'll never get a 2 then there's no point programming that case in (bacause time), for example, even though "properly" the algorithm should handle that case.
  • 7
    Points off cos it’s pascal case oh fuck off please
  • 1
    @hatemyjob Python doesn't use fucking Pascal case.
  • 5
    @AlgoRythm to be fair you can use whatever case you want. It still compiles and runs. And if it's consistent across the code - it even looks OK.

    It might look unusual to an eye of someone who's been complying to one set of standards [snake_case]. But it works and as long as it's consistent - it's their adopted code style
  • 3
    @netikras it can't be consistent unless you're only using your code and rewriting the standard libraries.

    Fuck people like this who go against the standard language style.
  • 0
    Their array size is "limit", but they use indices up to and including "limit", so the array should be dimensioned as "limit+1". Noob error.
Add Comment