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.
If you are brute-forcing your way to the solution, it is very likely that you are timing out.
@LucaREz This is much better. I like your explanation more than mine.
You can't, you can fork it and fix it. Take a look at my fork and tell me if you like it
How do I even delete this thing??
A bit confusing. I'll just delete it and think of aother one. Thanks for the input.
In the description you say 3 numbers but the solution you suggest is up to 3 not exactly 3,
then again you say in range 1 to 10 then you give an example with 12 as a selected number.
when you search for a non prime number in the is_prime function you can reduce the range in the for loop.
If the number you are checking is not prime the biggest factor that possibly divides that number is the one that pair with 2 to compose it, right? then your range could be
range(2, int // 2)
but then, after your first check you find that it is not divisible by 2, so the biggest factor that possibly divides that number is the one that pair with the next prime, 3. sorange(2, int // 3)
and so on.Following the pattern you can actually stop at the square root of the number you are checking
range(2, (int)(math.sqrt(n))+1)
.Since the maximum number obtainable is 101010, would you mind cache the 9674 prime numbers? If you have them cached (sorted) then you can binary search the closest prime and find the midmost one.
This comment is hidden because it contains spoiler information about the solution
I misread is as well until I took another look and saw that it's asking for the NEXT biggest number. Facepalm.
Which language? What is wrong? Look at the top of the ppage to see how many people passed the kata.
Something wrong with these tests. Good problem but the testing process is very flawed. I'm going to have to skip this one.