I would suggest you to print all the variables which the if-condition contains, right before the if-block. This way you will see better why that condition passes or fails (and hence why the code within that block is executed or not).
On frame 61 the clone goes up a level. It goes into the BLOCK if as it is printing âblock 4â but the program somehow understands a WAIT, as seen in the previous comment. There it the prints you mentioned showing that it does indeed go into the BLOCK section.
As the BLOCK gets ignored, it keeps moving until ~5 frames later when the BLOCK finally gets catched or something and stops.
(1)
Remember that the code is always executed as how it is written. It wonât do more, it wonât do less. So, your program outputs âWAITâ or âBLOCKâ based on how your code is written.
On CodinGame, the game engine receives the output from your code and update the next game turn accordingly. The game engine wonât execute a âWAITâ if you output a âBLOCKâ.
If your debug shows âBLOCKâ but your output shows âWAITâ, that means you have messed up your output somewhere.
(2)
I notice the first anomaly in your replay is during frames 36 to 39. A clone should have been blocked earlier at position 4, instead of at position 3. Then another clone is blocked again at position 4 in frame 39, and still another clone at position 4 again in frame 42.
So, what you have observed in frame 61 seems to have happened earlier in a similar fashion as I just described above.
(3)
As I mentioned in my last comment:
I would suggest you to print all the variables which the if-condition contains, right before the if-block. This way you will see better why that condition passes or fails (and hence why the code within that block is executed or not).
This may be relevant if you cannot spot any bug with regards to point (1).
I am triying to store elevator_floors and elevator_pos values in a dictionary or list with no success. list or dict is created but the values are not appended. Why this very normal logic doesnât work. Is there bug or something in the game?
I am using python 3 and here is the code block that i am trying to run:
elevators = {}
for i in range(nb_elevators):
# elevator_floor: floor on which this elevator is found
# elevator_pos: position of the elevator on its floor
elevator_floor, elevator_pos = [int(j) for j in input().split()]
elevators[elevator_floor] = elevator_pos```
when i try to print the elevators dict after the for loop, it prints an empty dict
import sys
import math
nb_floors, width, nb_rounds, exit_floor, exit_pos, nb_total_clones, nb_additional_elevators, nb_elevators = [int(i) for i in input().split()]
dict_of_elevators={}
for i in range(nb_elevators):
elevator_floor, elevator_pos = [int(j) for j in input().split()]
dict_of_elevators[elevator_floor] = elevator_pos
while True:
inputs = input().split()
clone_floor = int(inputs[0]) # floor of the leading clone
clone_pos = int(inputs[1]) # position of the leading clone on its floor
direction = inputs[2] # direction of the leading clone: LEFT or RIGHT
elevator_floor = 0
if clone_floor < exit_floor:
if clone_pos > dict_of_elevators[elevator_floor]:
if direction == âRIGHTâ:
elevator_floor+=1
print(âBLOCKâ)
else:
print(âWAITâ)
elevator_floor+=1
else:
if exit_pos < clone_pos:
if direction == âLEFTâ:
print(âWAITâ)
else:
print(âBLOCKâ)
#general can someone explain to me why this ainât working??? Iâm bit idealess about things
Please edit your message and format the code properly using the </> button in the formatting toolbar, as currently it is not shown with any indentation. After that we can take a better look.
Hello. I have passed all the tests and validators except the first validator that does not work for my code.
Below is my code:
import sys
import math
# Auto-generated code below aims at helping you parse
# the standard input according to the problem statement.
# nb_floors: number of floors
# width: width of the area
# nb_rounds: maximum number of rounds
# exit_floor: floor on which the exit is found
# exit_pos: position of the exit on its floor
# nb_total_clones: number of generated clones
# nb_additional_elevators: ignore (always zero)
# nb_elevators: number of elevators
nb_floors, width, nb_rounds, exit_floor, exit_pos, nb_total_clones, nb_additional_elevators, nb_elevators = [int(i) for i in input().split()]
elevators = []
for i in range(nb_elevators):
# elevator_floor: floor on which this elevator is found
# elevator_pos: position of the elevator on its floor
elevator_floor, elevator_pos = [int(j) for j in input().split()]
elevators.append((elevator_floor, elevator_pos))
elevators.sort(key=lambda x:x[0])
# game loop
while True:
inputs = input().split()
clone_floor = int(inputs[0]) # floor of the leading clone
clone_pos = int(inputs[1]) # position of the leading clone on its floor
direction = inputs[2] # direction of the leading clone: LEFT or RIGHT
if clone_pos == 0 or clone_pos == width-1:
print("BLOCK")
elif clone_floor!=exit_floor and ((clone_pos-elevators[clone_floor][1] > 0 and direction == "RIGHT") or (clone_pos-elevators[clone_floor][1] < 0 and direction == "LEFT")):
print("BLOCK")
elif clone_floor == exit_floor and clone_floor!=0 and ((clone_pos-exit_pos > 0 and direction == "RIGHT") or (clone_pos-exit_pos < 0 and direction == "LEFT")):
print("BLOCK")
else:
print("WAIT")
Iâm looking for some help.
Edit:
I got a way to solve the problem:
In the first validator, when the first clone is blocked, the following turn has not generated a new clone yet. Therefore we should find sufficient conditions to print(âWAITâ) in this case.
I canât pass test 4 for some reason⌠it always glitch out at the latest floors (using C#).
No matter how many checks I do or how many variables and arrays so to make sure I get the correct position of each floorâs elevator⌠it always behaves weirdly at the latest floorsâŚ