Send your feedback or ask for help here!
Very nice puzzle.
It took me a bit to figure out the elegant solution as I started with a direction that proved way too complicated for the problem at hand.
Kudos to the creator of the puzzle. Nicely done !
I don’t know why i have problem with 2 last test cases especially “Many real friends” case where only positive joy. my result is 25259954
All test cases pass, but validation fails at no. 6. Any idea?
I do not understand the first test case :
4 10 5
output : 7
If I bring 2 friends, travel cost would be of (2 * 5 + 10) / 3 = 6.66… , so I can bring the one that brings me 10 joy and the ones with 4 joy and I would get with 2 friends 14 joy ?
Where am I wrong ?
You’re wrong because “they won’t accept money from others”.
Each friend has to pay its additional cost and then the base cost is divided between each in equal parts.
So for you and too travelers, they have to pay 5+3.33 …only those with 9$ can pay and you get 7.
I think you missed the following sentence
“Your friends have their pride: they won’t accept money from others, hence every traveler - including yourself - has to pay the same price”
So each of your friends have to pay 5+10/nbTravellers
If you bring 2 friends you will be 3 travellers (2friends+you), so everybody will need to pay 5+10/3=8.333
If you bring 3 friends, the cost per friend will be 5+10/4=7.5
If you bring 4 friends, the cost per friend will be 5+10/5=7
Considering the different budgets of the friends, you can only bring the 2 friends with a budget of 9. Thus the 7 joy
got it than you
It’s my solution, passes all test cases but fails on validations at “Only base cost”.
I have the same problem, I tried also to take the date and do it in exel. I gave 25259954 as result.
I have the same problem
I understand it. But what could be that reason why test works and validator doesn’t?
@DarvasKristof Well, the reason simply could be that you’ve been lucky on the test. Consider the two following inputs to help debugging (and once it’s done, please erase your code from here ^^).
5 87 0 15 -13 16 7 77 17 38 -15 26 16 ================== Correct answer: 18
5 95 0 29 5 29 -13 5 -16 20 -3 31 17 ================= Correct answer: 9
Thank you, it’s erased
Thanks, I found the solution!!
(Don’t you want to add an extra testcase for my mistake?)
This puzzle is not defined unambiguously. Took me a while to figure out how the ambiguity situations are taken/ment from author’s point of view.
If you like me that we understand wrong of requirement of this puzzle. I’m taking all friend into invite list and consider they are going event if they don’t have enough money so the cost for each person is wrong. Addition is couting yourself as 1.
- Like first test case you count costEachperson = 10/4+ 5= 7.5 --> wrong
is will be 10/3 +4 = 8.3
- it’s 2 friend with budget 9 and including you.