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.
Unpublishing due to being a dup (despite this being earlier), as well as old unresolved issues and a long since unactive author.
Won't call it a duplicate of a later kata ( Jun 28, 2014 vs. Jan 7, 2018 ), but this kata has been overtaken by the much better executed Packing your backpack.
Needs more testcases than ONE FIXED TEST.
DP or memoisation is not even necessary, and generally wrong solutions can pass the
teststest.So, another dp problem? ;-)
Needs more test cases, other than that it's a great kata, thank you :)
Hey, just a small feedback:
i think you can simple calculate the quotient of (score / debt), sort by that as first criteria, sort by debt as second criteria and use the result as stack, of which you pick items as long as you are below the max debt. At least thats what i did :)
This comment is hidden because it contains spoiler information about the solution
Nice kata.
It would be nice with a few more test cases. Especially to sort out some corner cases, such as when no debts can be paid.
I would also advice you to use
Test.assertEquals
instead ofTest.expect
. It makes it easier for the developer to see in what way his result differs from the expected one.Thanks!
Good point @greghmerrill - I've updated the description as per your suggestion. Thanks!
Cool. No problem.
Agreed and updated. Thanks again!
Ah, I see. Now I've passed. Thanks.
Maybe even clearer would be "His goal is to reach the highest possible sum of scores." As it is, it could be read as "highest sum of scores for the number of debts paid," which would come up with the same problem.
Thanks for your help!
From your solution, I can see that my problem statement was poor. I have changed "His goal is to reach the highest possible sum of scores for debts paid, thereby reducing the risk of war with as many houses as possible." to simply "His goal is to reach the highest possible sum of scores for debts paid."
With this in mind, try changing your objective function, and I think you will find the rest of your solution holds good.
Passed the example test fixture, but getting the
Test Failed: Bolton,Frey,Swyft,Tarth,Tully is not optimal. Looks like the Lannisters are going to war ...
message on the first real test. Though I see the reason to hide it, I feel like it would be really helpful to know what the expected result is.I've tried many ways of balancing total score with number of houses, but cannot figure it out. Maybe I'm thinking about this the wrong way?
(My code so far to follow.)
Loading more items...