31
-vim-
6y

> be me
> has some free time
> decides to practice rust skills
> logs on codewars
> finds challenge involving prime numbers
> passes 30 min skimming the Internet to implement the Sieve Of Atkin algorithm
> tries example tests
> passes
> submits answer

> “memory allocation of 18446744073709547402 bytes. failederror: process didn’t exit successfully”

> 18446744073709547402 bytes ~= 18 million petabytes

So yeah, I think it’s broken

Comments
  • 12
    Oh fuck! I just realised, 2^64 is 1.8e19 and the number I get is 1.8e18

    That can’t be good
  • 6
    Wondering if they actually allocated first 17 million petabytes...
  • 4
    In cloud it could have happened.
  • 2
    maybe unsigned long long wrapped around? 🤔
  • 2
    @Electrux oh, that could explain it!

    Maybe there’s an edge case with the sieve of atkin, probably if it’s the limit is like 0 or negative
  • 0
    @-vim- maybe, i dunno 😅😅
    i just guessed that
  • 1
    @hack

    allocator fails obv.

    but still though.
  • 0
    Yea. I remember those challenges. Sieves don't scale well. I've done it too. There's some optimizations you can do to make it faster but good old factorization is the way to go when dealing with such massive numbers.
  • 0
    @Wisecrack maybe they have wrongly configured scaleable architecture that extends automatically? If thats the case someone gonna get bankrupt this month.
Add Comment