Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
I tried this code, but it timed out.
def count_primes_less_than(n:int) -> int:
L = 0
for i in range(2, n):
if is_prime(i):
L +=1
return L
def is_prime(num):
if num <= 1:
return False
for i in range(2, int(num**0.5) + 1):
if num % i == 0:
return False
return True
It returns correct on the tests, but when I press the attempt, it times out. Can someone help me optimize the code?
Got it
Are the test cases always going to be primes, or do I have to check for that too?
This comment is hidden because it contains spoiler information about the solution
The part where the function is called without an argument, like you need to do here. Just scroll a little bit and you'll find it.
Uh... Which part?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I honestly have no idea how to do that. I tried a loop, but...
Now you have to work out, how you can make the code work if no argument is passed to it.
And.... now it gives me a TypeError, like last time.
How?
You probably edited the sample tests, backup your code, click Reset, paste it and try again. Not a kata issue, the sample tests are fine in Python.
This comment is hidden because it contains spoiler information about the solution
Loading more items...