Thanks for your answer, I’ll check with that in mind
Hey guys,
Im getting the first two test case right but im not getting where im going wrong with the last two:
[Mod edit: Please avoid sharing codes on the forum.]
Your code is not formatted properly, so it is difficult to check. Anyway, I think you may consider whether your code has taken into account the following from the puzzle statement:
Once he finishes one vault, he moves on to the next available vault.
Meaning: they do not divide their work evenly in terms of the number of vaults. Not sure if that was the assumption you made when you calculated the variable work_divided.
All the robbers work at the same time… You have to output the total time the heist takes.
Meaning: you do not have to sum up the times spent by individual robbers. You are requested to output how long the entire heist takes.
Hello,
Isn’t the goal : “You have to output the total time the heist takes.” incorrect ? Wouldn’t it be “You have to output the maximum total time the heist might take.” because one can open a vault on average at number of permutations / 2 ?
Thanks
Not sure what you mean, but the robbers don’t split their work evenly, so I guess averages aren’t relevant.
HI everyone,
It seems that, like many, I get trouble to pass this puzzle (supposed to by a short refreshing one when i started it …).
After failing without takink account of the index rule, I wrote it again stucking to the summary :
[Mod edit: Please avoid sharing codes on the forum.]
And what should happen happened, all tests cases passed but failing validation.
Do you have any clue ?
Best regards,
This line is never reached:
$robberVault[$i] = $oversizedCombination;
because $i is always less than $V in all test cases. And even if there is a test case where the number of robbers is greater than the number of vaults, the “redundant” robbers will have no vault to work on and hence will not affect the answer anyway.
And I think your code fails with this custom case:
2
2
4 0
4 0
The answer should be 625.
Thanks for your test case !
The weakness in the original code was in the loop iteration in the case where all vaults has been cracked before we reach the end of the loop, which happen every time you cracked at least 2 vault in the same iteration (if it’s not the last one, explaining why the third test case success).
Dirty fix : Add a control to set the second to add to 0 if the minimum of the table is equal to the oversized combination. It made the job.
Better fix : Switch to while loop that stop when a counter (increased each time the vault was cracked) reach the total number of vault.
Best fix I guess : Not implementing it that way
For every one who stack with this puzzle on the last “Big Heist” test case,
try not to focus on amount of vaults… sorting vaults by it’s complexity is actually a dead-end. Instead focus on amount of robbers you were given.
@MahmudalKashgari said "Do not sort the times. " and @OlivZed said “Finally, re-re-re-reread the statement and got it ! “index” is the key”. Those 2 things made me realize that I read the specification through the fingers. Index is the key. Much thanks.
Just curious why was problem not stated as to minimize the time that robbers will spend to open all vaults?
Because there is nothing to minimize. The statement explains how the robbers proceed (solve vaults in order - one robber per vault - once one vault is finished go to next available vault in the list), and we must compute how long the heist will take. They will always spend exactly the same amount of second for a given input, not 1 second more, not 1 less.
I am literally asking: WHY DID THE AUTHOR DECIDE NOT TO MAKE THE PUZZLE CONDITION SO AS TO MINIMIZE TIME!
And you answer me that there is nothing to minimize in the puzzle according to the condition.
Oh I didn’t understand your question this way, my bad. Thank you for calmly bringing that up to my attention.
My answer becomes: How could you minimize time without knowing the passwords beforehand ? You only know the code is a combination of letters and digits, there is no optimized way to brute-force it. (I mean, except if the password if the boss’ birthday…) Whether you try to solve in lexicographical order or the other way around or use a random password generator, there will always be a “worst case scenario” that will take the time we already compute on this puzzle.
Start from the hardest, when someone ended guessing pick next hardest from the remains
Oh… now I get it, apologies. Then my answer becomes: I guess the robbers are as smart as me.
Thank you! The ‘mindset change’ of increasing the time of each robber helped me solve it.
Hi, I have all the tests passing but the submit tests #3 and #4 fails, I checked my logic it seems correct, does any one have an idea on how to fix this ? Thanks in advance.
If you want, you may send me your code via private message, and I’ll take a look.
In view of the inadequate test coverage and that quite a number of people struggling with the puzzle (as seen from the previous messages), I’ve added the following cases:
-
Test/Validator 4: More robbers than vaults, to cover the scenario
R>V. -
Test/Validator 5: Vaults with same stats, to cover the scenario where some vaults have the same stats (i.e. two vaults share the same
CandN). -
Test 6: Medium Heist, to cover the scenario where
Vis between 10 and 15. -
Validator 7: Big Heist, to replace the original validator, which has been “downgraded” and renamed Medium Heist.