Hello! Either this is a bug, or I need to learn more about python.
I have a set of code that runs great, got me to silver league, but I wanted to keep optimizing. What I found was that when I made a seemingly innocuous change to my code from:
Ok, good to know. Thanks for the response. Could you help me understand why this would create an infinite loop? The change I made was not in the loop you mentioned. As far as I can tell, the change in calculatePriorityScores would only change the values in the returned dictionary, it wouldn’t affect deleting from that dictionary later. Help a fellow?
Your change does impact the loop, since you changed the priorityScores.
You have Heath = -1 for undiagnosed sample,
Let’s have priorityScores = [20,-1,20],
First 2 rounds, you will delete maxPriorityScore=20; then priorityScores = [-1]
Then you will never fullfiled the if priorityScores[k] > maxPriorityScore: as 0 > -1, and thus never delete the last item, len(priorityScores.keys()) > 0, will loop forever.
is this thread with last posting from February the “official” bug thread? I see more recent bug threads but they are closed.
My problem: When I have 2 samples diagnosed, it seems to me that the “system” executes a "CONNECT " at the diagnosis station so that one sample is stored in the cloud which is not triggered by my robot’s code.
But actually I don’t print CONNECT 1 twice: In my code I have a System.err.printlin() with the name of the method which is logged whenever I print a CONNECT x. I see this method name everyhwere where I expect a CONNECT x, but I see the a CONNECT x in the logging where this System.err.println() is not logged - this is why I think that the wrong CONNECT x is not from my code (however this may happen ?)
Now I get your point: I repeat the CONNECT in the while loop for the 2nd sample, which is wrong, because this 2nd CONNECT must wait for the next turn. I have corrected this, now it works perfect.
Looking at the referee code on GitHub, there is still one sample in the list that breaks symmetry, as noted a long time ago by Counterbalance in the original bug thread: Code4Life - Bugs
The offending sample is samplePool.get(1).add(new Sample(new int[] { 0, 2, 3, 0, 3 }, 20, MoleculeType.B));, which should be 10, not 20, to complete the symmetry. Symmetry would be nice!
Nope, it does not seem to change anything for me. See this last game: https://www.codingame.com/share-replay/403431275
I did try to change my code to remove some operations that may have been previously CPU-intense, but it does not change.
I have transcoded my program to Python3 and did not face the issue.