[Community Puzzle] Robbery optimisation

Started with the trivial implementation of scanning all options. As JBM noted (above) It solved the puzzle if number of houses where under 20. 50 was a timeout

So introduced dynamic programming (memoization). Now all is solved, and I’m happy.

Then looked at the top solution - and saw a simple O(n) approach and had a big silly smile all over my face. This is one of the reasons I love CG so much :slight_smile:

2 Likes

Good day every one, i pass all the validator test but some how fail the 75 houses test in the submission. Seems rather odd since i pass the 75 houses test in the validation. Anyone got any idea for edge cases i should check ?

Thx
LarsUrban

The “20 Houses” Validator is the same as the “20 Houses” Test except that the input 12 is replaced by a number greater than 100. Try creating some custom cases to test your code.

Hi, I’m having the same problem here. Solution should be good.

Hi codingamers! I pass all the validator test but I fail the 75 houses test in the submission. Since those tests should only prevent hard coded solutions I assume there is a mistake in the test case? Thanks for your help!

The tests also prevent wrong solutions. Maybe there is a mistake in your code given that hundreds of players have solved the puzzle?

Ok, then my bad, should have stated the question differently: I want an admin or something similar to really check the case.
And yes you are right, hundreds of coding gamers already solved the exercise BUT i could also read in the comments that test cases changed over the years and that solution once valid would now fail the test. These things happen.
I coded some hours with with pen and paper, got the algorithm in linear time, typed it in in about 20 minutes and all test cases run through (except those with negative values). I fixed that after a couple of minutes. Thats why now I have the feeling IT COULD BE that the test case has its issues.
I also agree with additional tests as validators, but they shouldnt have the same name. If they have the same name the logic should be the same but with different values (to prevent hard coding).
Thank you.

I wrote 5DN1L and he presented a testcase which his solution passes and mine didnt (now it does :slightly_smiling_face: ) So thank you very much 5DN1L !
I would suggest to add a small test case in which there are just two houses, this would have done the trick for my false solution.
Long story short: the test cases were alright, my solution was false.

1 Like

Good job! :tada:

Below is the test case @DaMiche mentioned. It may be useful to future players too.

10
920
847
293
570
37
827
881
205
370
31

The answer should be 2741.

hello everyone,
can anyone pls tell how to resolve this error at line 3

screenshot(attached):

The statement says:

Input
Line 1: An integer N for the number of houses in the street.
Next N lines: The value housevalue of the nth house content.

And your code doesn’t reflect the sequence of the input mentioned above.

K thanks :+1:

This was indeed what I needed. I was in the exact same situation as @DaMiche, and this extra test case helped me to find my mistake. Is it possible to add this to the test cases of the puzzle?

Cases come in pairs, so if I add that case as a test, I would have to come up with another new case as a validator :sweat_smile: For the time being, I would prefer leaving the puzzle unmodified.