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.
Need a test with two different elements, but the sum of these elements must be equal.
For example,
Several solutions in Ruby:
Test cases changed. But, I haven't add the testcase like
a, b = [1,4,1], [1,3,2]
, just increased the testcase which expectedfalse
and two arrays have the same elements but different order(of course, their sums are equal ;-))Please add test with unequal arrays, where a.sum == b.sum (Ruby).
a, b = [1,4,1], [1,3,2]
read the description again, please.
EDIT
and, don't use sort in your code.
This comment is hidden because it contains spoiler information about the solution
A similar type of "dialog" )
https://youtu.be/hSQfhZqqQCo?t=3m55s
Got it! Thanks and appreciate it !
So, to solve this kata, you should find the pattern of the result sequence(when n=1...1000), Or use dynamic programming to solve it.
Finally, howmanytimes ==
463415834
.It means that your code run 463415834 times if you calculate the result for
n=800
Add some codes to your code, and run it, you'll see why your code timeout
(reply the comment to see the code)
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution