[Community Puzzle] Bank Robbers


#21

I solved this puzzle and get green for all testcases, but when I submit it I only get a 50% score? How is this possible?


#23

I think this puzzle has validator issues. The tests are weaker than the validators, so that a wrong code will pass them all and get stuck on the validation, leaving the coder with no clue about what is wrong with their algorithm.

To offset the punishing effect of these validators, I’ll give a few clues about what is expected.

An example that might help understand the problem:

Let’s say we have just 3 robbers (Andy, Bob and Carl) and 10 vaults numbered 1 to 10
All vaults have very simple codes that take one minute to break, except vault 4 that takes 2 minutes and vault 6 that takes 29 minutes.
At first Andy, Bob and Carl work on locks 1 to 3 and take one minute each to crack them.
Then Andy gets to work on lock 4, Bob on lock 5 and Carl on lock 6. Andy will get stuck for 2 minutes, Carl for nearly half an hour. In the mean time, Bob will have time to crack two locks. Then Andy and Bob will get asigned vaults in quick succession until none remains to be cracked. Both will twiddle their thumbs until Carl finally breaks vault 6’s lock.

Each time a lock gets cracked, the thief that is done with it gets reallocated to a new vault (if any remains to be cracked). The rules for reallocation are clearly stated in the problem definition.
Each thief will spend a total time equal to the sum of the time needed to crack each vault that was assigned to him. The final time is simply the max of the times spent by each thief when the last lock is cracked.

Here is some pseudo-code that might help get an idea of the solution.
There are other ways to look at the problem, this is just the simplest to explain I could think of.

Each thief is assigned a cumulated time counter, initially zero.
Each thief begins with no vault assigned to him.

  • while not all vaults are cracked
    • if there are still vaults available (not cracked yet and with no thief working on them)
      • look for an available thief (his cumulated time will be the shortest)
      • reassign the thief to a new vault and increase his cumulated time by that of the new vault
    • count one more cracked vault
  • final time is the longest cumulated time.

In the example:

All thieves initially available
Andy -> vault 1, time 0:01, Bob & Carl available
Bob -> vault 2, time 0:01, Carl available
Carl -> vault 3, time 0:01, Andy, Bob & Carl available
Andy -> vault 4, time 0:03, Bob & Carl available
Bob -> vault 5, time 0:02, Carl available
Carl -> vault 6, time 0:30, Bob available
Bob -> vault 7, time 0:03, Andy & Bob available
Andy -> vault 8 time 0:04, Bob available
Bob -> vault 9, time 0:04, Andy & Bob available
Andy -> vault 10, time 0:05, no more vaults to crack
final time : max (0:05, 0:04, 0:30) = 30 minutes.

#24

feel free to suggest modifications in the IDE tests.


#25

For one thing, out of the 4 tests only the last one exercises the code in any meaningful way.

As it turns out, it’s the first robber who spends the most time and holds the final result.
There are no cases of more than one thief being available at the same time except during initial vault attribution.

All these are potential pitfalls for awkward code. At the very least you should have more than one “big heist” test, and possibly carefully thought out values to make sure vault attribution works as intended.
If anything else fails, swapping the validatoirs with the tests could do the trick.