Yep, that's what I figured out at some point, see two solutions bellow.
This is not correct. Consider the case:
Kata.countSmileys(Vector(":)",":",")")) // actual: 2, expected: 1
You could use normal recursion instead of the tail recursion, that way you wouldn't need the extra argument.
But this works nice anyways ;)
isProbablePrime(i) introduces additional time complexity, probability that a number is prime is 1-pow(0.5, i). Even for small i~30 it is almost 1 so it's pointless to pass such big values here.
This comment is hidden because it contains spoiler information about the solution
You may want to use:
The current code always tests every number from 0 to 999, even if the list has only 5 elements. It also can't find the smallest unused ID if it's bigger than 999.
Hello, could you tell me for how long have you been working with Python? Your solution seems to advance.
Ok, i'll add it soon)
Looks better, thanks.
I'd suggest including a set of random tests as well.
I forked it
Awesome example of helping me understand how/when to use flatMap !!