I’m currently doing the Bank robbers puzzle. My success rate at the moment is 75%. The only test I fail on is the “Big Heist” test, where I get 6473750. The right answer is 6515625. I’m simply looping through the array, taking only the Rth (R is the number of robbers) elements and summing them to get the total time.

Is anyone else getting similar results. I pass the all three test cases without any issues. Since the “Big Heist” case is just the “fewer robbers than vaults” but with a larger dataset I don’t see where I’m going wrong.

update:

It’s been a few months since I solved this but I forgot to post why I was failing “Big Heist”. The problem was due to me sorting the times before calculating the duration. The solution I had only worked when the times are sorted, so I scrapped that one.

tl;dr

Do not sort the times. If you do you will get 6473750.

Are u sure the robbers work on the safe in the correct order ? i had a similar problem and it was my logic, i wasn’t looping on the correct thing kinda x) but i had a number that was bigger than the expected one, on your side it’s the other way around … but maybe u’ll think about something !

This problem is not linear. You have to think about what happens, for example, when one robber goes through 3 rounds of unlocking while other robber is still stuck in the first round.

PS. hit me a message if you need an idea codewise.

This problem is not linear. You have to think about what happens, for example, when one robber goes through 3 rounds of unlocking while other robber is still stuck in the first round.

How could that happen, knowing that all robbers will try all combination at same speed on their vaults ?
“He tries all the possible combinations, i.e. he continues to try the untried combinations even after he has found the correct combination.” I really don’t get the idea of this puzzle ^^’

Hi,
I have a problem with Bank Robbers puzzle. All tests pass but not “submision tests”. I would love to know why. I found several solutions where second test didnt passed and finaly I found solution without any way of anything hardcoded but last 2 dont pass now (reminder - in IDE all tests pass).
In last hours I exhausted all ideas of what could possibly go wrong, but it feels like som bug.
I would appeciate some feedback on this. Cheers!

My code:
class Solution {

public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int R = in.nextInt();
int V = in.nextInt();
List<Integer> combs = new ArrayList<>();
for (int i = 0; i < V; i++) {
int C = in.nextInt();
int N = in.nextInt();
combs.add((int)(Math.pow(10,N) * Math.pow(5,C-N)));
}
int count = 0;
while(!combs.isEmpty()) {
count++;
for (int j = 0; j < R; j++) {
if(j<combs.size()) combs.set(j,combs.get(j)-1);
}
for (int k =0; k < combs.size(); k++) {
if(combs.get(k) == 0) combs.remove(k);
}
}
System.out.println(count);
}
}

Hello!
Dosnt sounds right. This slightly different solution (pasting bellow) passes all “submit” tests exept second one so it feels weird, that if its fast enought for big heist, that its slow for second test. More so, my other, even slower solution which is way slower than this one passed all tests. But I hate that accepted solution, its ugly and indeed slow. I dont understand why this slution cant pass.

class Solution {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int R = in.nextInt();
int V = in.nextInt();
List<Integer> combs = new ArrayList<>();
for (int i = 0; i < V; i++) {
int C = in.nextInt();
int N = in.nextInt();
combs.add((int)(Math.pow(10,N) * Math.pow(5,C-N)));
}
int count = 0;
while(!combs.isEmpty()) {
count++;
for (int j = 0; j < R; j++) {
if(j<combs.size()) {
combs.set(j,combs.get(j)-1);
if(combs.get(j)== 0)
combs.remove(j);
}
}
}
if(R>1) count--;
System.out.println(count);
}
}

Well I tested the first code you provided and indeed it timed out. Maybe it was not too slow but anyway it timed out.
The second code you provide do not timeout but is off by one on the second validator.

I don’t know Java but if you use this while loop and remove the “if(R>1) count–;” it works:

Hi, your solution works and I cant really find any difference from mine exept that in yours is used removeIf lambda, yet still your solution passes and mine not. Probably some Java related thing which is beyond my knowledge scope. Because my for cycle and your removeIf should do exactly the same, isnt it?
I dont know, its so hard to do any testing if tests in IDE are different from “submit”. I understand protection from hard-coders, but if there is no hardcode and it passes in IDE, then it shuld be fine… Or at least if submit tests give some feedback.
I have absolutely no idea how to improve in this puzzle with this kind of behavior and testing
Anyway, thank you for checking it out.
Cheers,
Petr

Aha, so one have to go blind and is alowed to see once he gets to where is seeing not relevant anymore, how esoteric
But thank you, good to know.
cheers

anyone had already solved the big heist problem? I can’t seem to understand the said logic:

“Once he finishes one vault, he moves on to the next vault of greater index (robbers work the vaults in increasing order) which nobody has worked on yet”

1 for number of robbers
1 for number of vaults
3 kinds of combination with 1 of it has a combination from 0-9 and the other are from A,E,I,O,U
so getting the total combination will be 10 * 5 * 5 = 250