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.
Incorrect solutions can pass if you try the tests a few times. My solution failed a few test cases; I inserted a print statement to display the inputs, ran it again, and it passed!
F___! Fixed.
Did the other.
Added message showing the array length.
Thanks for the review.
Changed.
I added another zero to the large random tests. This causes the following to time out.
for (int i = 0; i < array.length-1; i++) {
sum = 0;
for (int j = i; j < array.length; j++) {
sum+=array[j];
if (sum > maxSum) maxSum = sum;
}
}
In the description? Or in some other way?
Loop through the tree, comparing each node to the sum of its children. When you find a mismatch, you have to figure out which is the wrong value. This can be done by considering different cases. For example, is either of the children not equal to the sum of its children?
Question: In the example ([-2, -1, 1, 2]) ➞ [-2, -1, 1, 2], why don't the -1 and 1 meet and destroy each other?
Duplicate?
My first attempt failed two of the fixed tests:
'\n.'
and'..\n\n..'
. But it passed all the random tests. So I just had to hardcode those two cases. The random tests should include examples like those. In that case solutions like mine would have to be correctly fixed.Fun problem, although a little easy for 5kyu.
One suggestion: It would be nice if an example showing multiple lines was included in either the description or the sample tests.
Java Translation
One question is what the initial solution should be. Java has a few ways of rounding. I put 3 in the code (2 of them commented out). The third one behaves most similarly to the Python version.
When I try to change the C# version to 12.0 and then re-publish, I get the message "Default Version is not a supported version". Any ideas?
Mark
Very imaginative problem! Interestingly, as long as the array doesn't contain zeros, a similiar idea works if
f
gives products rather than sums.Thanks!
Hi metatable,
It looks good, except that in the random tests the number of streets and drivers is the same. The number of drivers should be an independent random number.
Regards,
brodiemark
It might be worth adding to the description a reference to "Difference of Squares".
Thanks!
Loading more items...