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
Needs an edge case such as
solution(10, 2, 5)
.This comment is hidden because it contains spoiler information about the solution
This is amazingly simple, but I'm not sure I understand how it can work.
This comment is hidden because it contains spoiler information about the solution
There should be a test with maximum numbers like
solution(10000000,19,23,25,27,28,29)
.Meanwhile, your solution can't even handle
solution(0,19,23,25,27,28,29)
.An
O(n * len(factors))
solution: https://www.codewars.com/kata/reviews/5e2837f1bb3beb00011a0b1f/groups/5e28612383dbcd0001385f8dIs is supposed to pass?
updated description
If performance is required, then the input range should be specified.
My prime-factorization based solution became faster at n = 10000
Averages of 250 testcases
Random numbers up to 10^1: Prime factors: 0.000 s, naive = 0.000 s
Random numbers up to 10^2: Prime factors: 0.001 s, naive = 0.001 s
Random numbers up to 10^3: Prime factors: 0.007 s, naive = 0.004 s
Random numbers up to 10^4: Prime factors: 0.044 s, naive = 0.044 s
Random numbers up to 10^5: Prime factors: 0.289 s, naive = 0.456 s
Random numbers up to 10^6: Prime factors: 3.563 s, naive = 5.182 s
Random numbers up to 10^7: Prime factors: 26.995 s, naive = 56.739 s
Your code fails for 143 = 13 * 11, or other numbers which have prime factors other than 2,3,5 and 7
Updated ✔️
Could you include the constraint that leading zeroes are not allowed to the description?