I couldn’t figure out how to send PMs…
However, the WAIT output is placed right at the end of the while loop, to always trigger when all other conditions is false.
Hi guys,
everything good until TestCase 05 there i got an NonType Error.
Is it a GameBug or do i need to address the Issue.
It’s probably not a game bug and you probably need to address the issue in your code. You may post the full error message here for further advice.
That envelope button doesn’t appear for me (the other 3 show up just fine)
Here ist the code i submitted.
For some reason i got no value for cloneTarget.
I try to find the issue so i read out the values and types of the every variable needed for the targeting function def target().
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()]
elevatorFloors = []
elevatorPositions = []
cloneTarget = 1
for i in range(nb_elevators):
elevator_floor, elevator_pos = [int(j) for j in input().split()]
print(elevator_floor, elevator_pos, type(elevator_floor), type(elevator_pos),file=sys.stderr )
elevatorFloors.append(int(elevator_floor))
elevatorPositions.append(int(elevator_pos))
def target():
if clone_floor == exit_floor:
cloneTarget = exit_pos
return int(cloneTarget)
elif clone_floor == elevatorFloors.index(clone_floor):
cloneTarget = elevatorPositions[elevatorFloors.index(clone_floor)]
return int(cloneTarget)
# 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
try:
target()
cloneTarget = target()
print('CloneTargetType', type(cloneTarget), file=sys.stderr, flush=True)
except:
print('WAIT')
try:
if direction == "RIGHT":
cloneTarget += 1
if clone_pos < cloneTarget :
print('WAIT')
elif clone_pos > cloneTarget:
print('BLOCK')
if direction == "LEFT":
cloneTarget -= 1
if clone_pos < cloneTarget :
print('BLOCK')
elif clone_pos > cloneTarget :
print('WAIT')
if direction == 'None':
print('WAIT')
except:
print('WAIT')
Actually I asked for the error message, not the full code
You get None when none of the conditions in your target function is satisfied.
my newbie behaviour couldn’t help my self otherwise.
Do you have any idea why this is the case. I don’t see the difference between the first 4 and the following TestCases that could cause this kind of problem.
Because clone_floor may not be the same as elevatorFloors.index(clone_floor). The elevators are not necessarily given in order of the floors.
elevatorFloors.index(clone_floor) is just to find the index of elevatorFloors so i can get the right elevatorPosition.
Yes, but why are you checking
clone_floor == elevatorFloors.index(clone_floor)
in your function then?
It is just a double check it should cause this issue.
Did you try this Code in your IDE?
I tried your code. I think we should continue this discussion in PM rather than in the forum.
I am currently learning to program in C++ and this task has put me at a dead end.I don’t understand where my mistake is with the elevator positions.
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
int nb_floors; // number of floors
int width; // width of the area
int nb_rounds; // maximum number of rounds
int exit_floor; // floor on which the exit is found
int exit_pos; // position of the exit on its floor
int nb_total_clones; // number of generated clones
int nb_additional_elevators; // ignore (always zero)
int nb_elevators; // number of elevators
int elevators [nb_elevators + 10]; /*
[mod edit: don’t put fully working code on the forum]
I dont know why, but if you put a more logical
“int elevators [nb_elevators - 1];” or “int elevators [nb_elevators];”,
then there is a problem with storing the coordinates of the elevators (second screenshot)
Screenshot #1 on 7 task: int elevators [nb_elevators + 10] (https://snipboard.io/t2QXiT.jpg)
Screenshot #2 on 7 task: int elevators [nb_elevators - 1] (https://snipboard.io/IkKtDN.jpg)
My guess is that the code trying to access out-of-range indexes causes unexpected behaviour. Note that cloneFloor may be -1 (when there is no leading clone), and also it may be the exit floor (and as there is no elevator, it is not counted in nb_elevators). I’ll guess your array cannot properly handle the index of -1, nor the index of the exit floor if the size of your array is not big enough.
Thanks for the answer! I will definitely check when I’m at the PC. I can also say the following: nb_l + 4 does not work, but nb_l + 5 already works as it should. But with indexes, I’ll see how it affects
It’s difficult to tell as I can’t see what values ef
and ep
contain. I would suggest you to add a few more stderr prints to see which condition is satisfied (and hence whether BLOCK or WAIT is chosen) for each turn, to help you investigate further.
Hello,
I passed all tests in the IDE but during the final submission the test 1 and the test 7 are not validated. Can I PM my code to someone to have a check ? (code is in javascript).
You may PM me your code, but I would also suggest you to investigate a bit more first by watching the replays of the validators, if you haven’t done so yet. The replays can be found by clicking MY REPORT, and then DETAILS.
I’m newbee on this forum. I don’t see the envelop to PM as you showed before. May be a restriction for new users ? (upload image is also resstricted for new users)
The Details don’t bring me new points of comprehension with respect to the IDE test which work perfectly.