Code4Life : Input collection problem

Hi fellow community.

I’m having a very strange bug that I’ve never seen before, I hope someone will be able to help me with this.

I try to collect the various inputs of this puzzle and store them into Hashmap (as I always does):

However this time, I did notice that every item of the Map is overwritten by the last one added to the Map:

Did some of you have experienced this before ? How did you cope with that ?

Thanks by advance for your help.

You are not clearing the ‘samples’ or at least I don’t see it. That is not the problem though, what bothers me is that you push samples by their ID instead of just ‘i’, and you later on get them by ‘i’, which I think is a mistake.

ps. I think I see what you are trying to do, but it’s not necessary. You can handle the samples as you do robots and molecules. Generally, the IDs shouldn’t be trusted.

1 Like

Thanks for your feedback accorp. You are absolutely right regarding your various points, I did correct them all, however the problem still persists.

For the record, I did use the same methodology (private class and HashMap) to collect inputs on another puzzle yesterday and it worked fine as usual.

Therefore I think it is more an internal problem coming from the platform. Does someone know how can I address this problem to CodinGame people please ?

Thank you.

not a Java expert here but I played a bit with your code and started getting proper results when I got rid of static variables and static inner classes, so I’d look into that.

Sure I assume they are part of the problem. However I don’t understand why as I code all my puzzles using static variables and static inner classes and never experienced this problem before.

Anyway, I will do this one using other techniques, thanks for your feedback.