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.
same problem...
/e
solved it!
thanks for test cases :)
Since 2 days I'm getting "Submission timed out." all the time...
don't like this... My Test shows me the array from 0 to 3000 and no problems with timeout... How far do I need to be able to go here?
Edit:
This returns an empty array []. If I reduce the range from (700,1000) to (700,999) I get all prime numbers... So when I try to submit, I pass many tests but at some point there comes a range that my algorithm doesn't solve... why's that? Please try not to spoil too much in the answers. I want to be able to see them. Btw: How can I indent my code?
function isPrime(number) {
if (number < 2) return false;
if (number == 2 || number == 3 ) return true;
for (var i=2; i<Math.ceil(Math.sqrt(number))+1; i++) {
if (number%i==0) return false;
}
return true;
}
function getPrimes(start, finish) {
var a = [start, finish];
a = a.sort();
for (var i=a[0],res=[]; i<a[1]+1; i++) {
if (isPrime(i)) {
res.push(i);
}
}
return res;
}
Test.assertSimilar(getPrimes(700,1000),[...]);
I get the same error message "Test Failed: maximumSum with n>values.length not working as expected" but I pass the test you offered (Test.assertEquals(minimumSum(new Array(5, 4, 3, 2, -11), 8), maximumSum(new Array(5, 4, 3, 2, -11), 8));) ... No idea what to do.
Yes, I believe the given information is enough to google the rest. I learned a lot by researching how to add a function to a protoype.
neither do I... What exactly can the input be? More than just numbers?
yes, that's the reason.
What if e.g. n>1, m=0? Function should return zero, but returns n-1.