Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @superzero4,validated by @_yel_p,@Alombaros and @Ali-Kanbar.
If you have any issues, feel free to ping them.
Coding Games and Programming Challenges to Code Better
Send your feedback or ask for help here!
Created by @superzero4,validated by @_yel_p,@Alombaros and @Ali-Kanbar.
If you have any issues, feel free to ping them.
I pass all 5 first tests. But not test 6 and 7. I fail Validator 5 and 7 and pass all others.
I think Test 6 is false, because when the value_to_reach is 366$ and you have 82 6$ coins and some that have more value, you need to take at least 61*6$=366$ to get enough. But if you take 121 coins, like the test wants, then you guaranteed take too much.
Test 6: " Standard Output Stream:
nu=82 va=6
nu=2 va=8
nu=7 va=9
nu=71 va=23
nu=94 va=90
N=5; sum_All= 10664, reach=366
61
Found:
61
Expected:
121"
The problem does not ask you for merely the minimum coins you need; it asks you for the minimum coins you need to grab without knowing what you have grabbed until you have taken the coins out.
It is possible that the coins you have taken at the beginning are all $2 instead of $6, so you won’t have enough coins if you’ve taken out 61 $2 coins.
But in this case, there are no coins with a value below 6$. So 121 coins is guaranteed not the bare minimum of coins you need to take, but way too much coins. I always assume that you take the coins with the least value out, if there are any left.
Thx! The problem was my input, because i tried to unite the 2 for loops for input, and made it harder that way, because same values appeared twice sometimes, and i wrote 2 functions only to handle this.
Hello, I pass all test cases and all validators but Validator 6 when submitting. After trying to find any bug, I searched for the submission to find the Validator 6 input data and answer, and tried it as a custom test case, but I got the right answer. Maybe there is an issue with the length of some input lines (3800+ characters in Validator 6)?
I think you mean Validator 7 instead of Validator 6? I’ve deleted the trailing blank lines in the input for that validator and its corresponding test. Please see if that helps.
Yes sorry I meant Validator 7.
That fixed it, thank you for your quick response!
I don’t get why tests 6 & 7 fail. I assume we have more of the lowest value coins and even like that I estimate too much coins apparently.
366 [94, 90, 82, 71, 23] [2, 6, 7, 8, 9]
With my logic I would say we need at least 124 coins :
But apparently 121 is enough
You’ve sorted the coin values and now their order does not match the order of the number of coins (e.g. you have 90 $2 coins instead of 94).
I also tried letting them in order and I got more fails
Your approach (using sorting) is correct, but you have to make sure to use the correct number of coins during the calculations.
I’m dumb I fixed my error ^^ thank you !