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.
good function isPowerOf2
I tried to test the testFn from the "Test Cases". But the function is not working properly!
GOOD:
customers {100, 50, 90, 90, 60}
n 2
return 200
ERROR:
customers {100, 90, 90, 60, 50}
n 2
return 210
log:
100 0
100 90
100 180
160 180
210 180
but true way 100 + 90 =190 vs 90 + 60 + 50 = 200
true algorithm see (for n == 2):
https://www.geeksforgeeks.org/partition-a-set-into-two-subsets-such-that-the-difference-of-subset-sums-is-minimum/
I have tried something similar (but less elegant), however this algorithm does not pass the test with the dataset:
customers {100, 90, 90, 60, 50}
n 2
this algorithm return 210 (100+60+50 = 210 vs 90 + 90 =180)
but true result: 200 (100 + 90 = 190 vs 90 + 60 + 50 = 200)