You can use a data structure to store that. I used an unordered_map which made it easier to check the leading clone’s floor’s position against its own.
I’m using python and the elevator_pos / elevator_floor variables are inaccessible and inusable,is this some bug or what? here is the piece of code :
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()]
It is not wrong, but also not in order.
Try saving the elevator location by level, not by how the information arrives.
Trying adding to that section a list, map, or other accessible (dict?) container for the information.
All the elevator data comes before the game starts, but isn’t appended or saved in any particular order.
Think of it as tuples which were randomized (maintaining the elevator location and floor data, but losing the order of the levels) before being read out loud to you.
Hay un salida (print en python) que se está ejecutando en una condición y también por defecto.
Hi
Am i the only one for who there’s no direction given in input from test 2 ?
I can’t even test or validate this exercice. The first test give input correctly and I’m using C# by the way.
That’s really frustrating to not being able to validate an easy test…
Show us the structure of your script, you can hide the part where you compute the next move, just show the inputs/outputs part.
I just tried Test2 in C#, and I got a direction. So yes the problem come from your code. Like @pardouin said, just share your inputs reading.
This is a fine puzzle, I passed it. But my two cents on an issue others have had. You can code this so that the lead clone waits up to two blocks from the generator or elevator and you will pass all tests, even the tall buildings with few rounds. But obviously (as others have pointed out), when you submit, you’ll fail Validator 1 because it requires immediate blocking. As I’ve said elsewhere, I think this fails the spirit of what a validator should be. It should guard against hard coding but not test for anything that isn’t required by the puzzle test cases already. In my opinion, there should be a test case (say, going LEFT instead) that forces the user to understand you’re sometimes going to have to use immediate blocks (which also would force them to deal with the -1 location issue.)
Episode 1 require no graph algorithm or anything else.
Only basic if/else statement is needed, doing more is op.
Imo it should move to “easy” difficulty
You might be right. But I think this a general problem across a lot of puzzles on CG: several of them need to be re-categorized.
Well I only care about the leading clone in this exercice but still can’t pass any test. Have spent some time on it and don’t see what I do different even after reading the suggestions on this forum, so any hint would be welcome.
I save the elevators information (floor and position) in a dictionary like this: elevators[elevator_floor] = elevator_pos.
Once the game starts here are the conditions I thought I needed:
- Check if a clone is actually out, so if clone_floor is negative then I print ‘WAIT’.
- Check the leading clone’s current position compared to the corresponding floor’s elevator position, and then make sure I’m going in the proper direction, because if not then I simply print ‘BLOCK’.
- Else printing ‘WAIT’.
However it doesn’t work at all and can’t get why. I also don’t manage checking the content of my variables as I can only print instructions and since it fails then it doesn’t show me the following prints.
Any hint on what I am missing here?
Thanks!
If you want to print debugging information, you have to do it on stderr. If you don’t know how to do, there’s an example in the base code of each puzzle.
I have tried that to figure out what’s inside my variables, but all I get is either:
- The error message saying I did not print all the input variables if I print this debugging information before any command print. So can’t see anything.
- If I print this debugging information after the command print, then I only see the command print and nothing afterwards.
Are you sure you’re using stderr ? A print on stderr can’t be considered as an output of your program by the referee, so it will wait for a print on stdout anyway…
You mean using this print("Debug messages...", file=sys.stderr, flush=True)
, but by replacing the message by whatever variable I want to check, or doing a string interpolation with the variables I’m interested in?
I’ve tried that way but it doesn’t actually print anything.
Yes that’s what I meant. You have to do it before printing anything on stdout.
If nothing is printed it’s because the instruction is never reached, because your code don’t compile, crash, is blocked in an infinite loop, or because you’ve putted the print in a condition that is never true…
Do you get any error message ?
I don’t always get an error message.
- If I print on stderr before the output print, in the while loop then I can see the variable values => no error message.
- If I print on stderr before the output print, in the for loop of this challenge, I can’t read any input value => no error message.
- If I print on stderr but don’t print any output => error message “Timeout: the program did not provide 1 input lines in due time…”
It seems that here I can’t read the values of elevator_floor, elevator_pos
, and so no matter how I want to store those values (in a list or a dictionary), those variables appear empty later on. Is it linked or nothing to do with all of this?
It’s normal to get a timeout message if you don’t print your output.
Can you show me your code in PM ?
Am I missing something or is the Python version not giving the correct max rounds? Example for test case 2, printing nb_rounds returns 100 but running the test case times out after 8. Getting the same problem with other cases. Thanks