4 kyu
Candy thieves
Loading description...
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This problem can be reduced to the set cover problem, which is NP-hard, looking at size of tests I can assume that reference solution uses some king of greedy approach, which do not guaranty optimal solution. Example A = [3, 8, 8, 6, 7], B = [2, 2, 3, 5, 6], k = 6. My solution is 3. First thief can take from jars 1 and 4 second from 2, third from 3 and 5
This comment has been hidden.
fixed
Hi,
By reading the description, it looks like you're using the underlying assumption/specification that it's guaranteed that
A[i]-B[i] <= k
(since you don't talk about what to do if too many candies are stolen from one jar). This should be added to the description one way or another (either saying it out loud, or telling all cases will be solvable, or anything else conveying the idea).Or did I misunderstand the rules?
edit: you should add the typical sizes of the inputs too. And a boundary about the expected time complexity.
Cheers
All done
Nwanne, I think some tests are wrong. I'm raising an issue. Close with reason if it's not one.
What am I getting wrong?
my bad, i guess
typo in the line after "notes" -> "theif" 2 times regarding that line, it may be useful (even though it's quite obvious) specifying that a thief can only take all the missing candies from a jar (or none).
anyway i enjoyed the kata, thanks :)
typo fixed
This comment has been hidden.
This comment has been hidden.
thats fixed now ;)
.
Looks quite fun - haven't had time to do it yet. There is one thing that I think you could make clearer in the description:
"Note: More than one thief cannot take candies from a single jar." Mybe try: "Once a theif has removed candy from a jar, no other theif may remove candy from that jar"?
Done!
After making the above change in the description, are you sure the test results are true? Can you please check?
They are, the thief doesnt half-take, he either takes all or he doesnt take at all.
ok thanks...I got it.
I'm afraid I misspelt thief. I said theif but the correct spelling is thief! sorry :( Also, you should add an estimate of the rank to get more people to try it.