Don't Panic - Episode 1 - Puzzle discussion

Hey
I can’t pass the first validation test.
Either the clone got destroy either it is blocked on the generator so no other clone can spawn … i don’t get it …
Can someone explain me ?

Edit :
ok, nevermind the problem was this rule :

If there is no leading clone, the line values are: -1 -1 NONE. This can happen only when the clones which are already outside are all blocked and the next clone is not out yet. In this case, you may output action WAIT.

1 Like

I’m using Python3 and having the same issue. There is something that i’m not understanding about how to reference the relevant elevator_pos value. I tried this for getting the direction but it gave an error:
if clone_pos < elevator_pos[elevator_floor.index(clone_floor)]:
elevatorDir = ‘RIGHT’
else:
elevatorDir = ‘LEFT’

Hello, I always have an error with the “U Turn” test after submitting my response. The error is “Timeout: the program did not provide 1 input lines in due time…”, but I’ve already added a output “WAIT” when the only head is blocked. Can someone help? Thanks

Timeout means one of three things.

  1. You took too long to think about the answer (generally this means > 100ms)
  2. Your program crashed. Millions of ways for this to happen.
  3. You didn’t give an answer. Example in pseudocode:

if value < 3 then answer = 1
if value > 3 then answer = 2
value turns out to be 3, no answer is given.

One of those things is probably true in your code.

I solved the problem, thank you.

Thanks for info - helped me to solve :wink:

The animation and the layout were cool. Fun visuals

Anyone an idea what caused it/ how to fix it? Didn’t change anything from the input lines.
Standard Error Stream:

Exception in thread "main" java.util.InputMismatchException

at java.util.Scanner.throwFor on line 864

at java.util.Scanner.next on line 1485

at java.util.Scanner.nextInt on line 2117

at java.util.Scanner.nextInt on line 2076

at Player.main on line 32'

Yes you did :stuck_out_tongue:

Here’s the part you changed:

for (int i = 0; i < nbElevators; i++) {
      int elevatorFloor = in.nextInt(); // floor on which this elevator is found
      int elevatorPos = in.nextInt(); // position of the elevator on its floor
 }

How is it possible to pass test 06 called Few Rounds? It seems impossible to me.

seems you managed to pass it.

The puzzle is bugged as hell. Reading clonePos gives a 0 all the time in C, which makes the puzzle impossible to solve.

EDIT : Alright my bad, I changed the size of the direction array and that totally messed up the scanf.

Why at one point the list can be read and another moment not?

using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/
class Player
{
    static void Main(string[] args)
    {
        List<int> integerList = new List<int>();
        string valeur = "";
        string[] inputs;
        inputs = Console.ReadLine().Split(' ');
        int nbFloors = int.Parse(inputs[0]); // number of floors
        int width = int.Parse(inputs[1]); // width of the area
        int nbRounds = int.Parse(inputs[2]); // maximum number of rounds
        int exitFloor = int.Parse(inputs[3]); // floor on which the exit is found
        int exitPos = int.Parse(inputs[4]); // position of the exit on its floor
        int nbTotalClones = int.Parse(inputs[5]); // number of generated clones
        int nbAdditionalElevators = int.Parse(inputs[6]); // ignore (always zero)
        int nbElevators = int.Parse(inputs[7]); // number of elevators
        for (int i = 0; i < nbElevators; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            int elevatorFloor = int.Parse(inputs[0]); // floor on which this elevator is found
            int elevatorPos = int.Parse(inputs[1]); // position of the elevator on its floor
            integerList.Add(elevatorPos);
        }

        // game loop
        while (true)
        {
            inputs = Console.ReadLine().Split(' ');
            int cloneFloor = int.Parse(inputs[0]); // floor of the leading clone
            int clonePos = int.Parse(inputs[1]); // position of the leading clone on its floor
            string direction = inputs[2]; // direction of the leading clone: LEFT or RIGHT

            // Write an action using Console.WriteLine()
            // To debug: Console.Error.WriteLine("Debug messages...");
            if(cloneFloor == exitFloor)
            {
                if( ( exitPos < clonePos && direction == "RIGHT" ) || ( exitPos > clonePos && direction == "LEFT" ) )
                {
                    valeur = "BLOCK";
                }
                else
                {
                    valeur = "WAIT";
                }
            }
            else
            {
                
                
                if( ( integerList[cloneFloor] < clonePos && direction == "RIGHT" ) || ( integerList[cloneFloor] > clonePos && direction == "LEFT" ) )
                {
                    valeur = "BLOCK";
                }
                else
                {
                    valeur = "WAIT";
                }
            }

            Console.WriteLine(valeur); // action: WAIT or BLOCK
        }
    }
}

you might want to be a bit more explicit if you want someone to help you.

Hi,
I was able to succesfully solve this puzzle in JavaScript but I have a problem while coding the solution in Java. Somehow, the direction is never equal to “RIGHT”. I don’t believe I erased any inital code.

I included below my code and the debug printout for the first level. Does anyone have an idea what I might have done wrong?

Mod note: Don’t post full code, please.

String dir = “RIGHT”;
System.err.println((direction == dir) ? “true” : “false”);
System.err.println(direction);

1 13 100 0 2 0
false
RIGHT
Hello3
0 9 RIGHT WAIT

Try String.equals() rather than the == operator. Java is funny that way.

2 Likes

Darn I’m dumb!! Thank you !

Have you got a response to this problem?

I’m facing the same issue

Hello Friends!
Would you please tell me what went wrong in my code? It work only for some cases but not for other cases. I am suspecting that the input is wrong.

Summary

import java.util.;
import java.io.
;
import java.math.*;

/**

  • Auto-generated code below aims at helping you parse

  • the standard input according to the problem statement.
    **/
    class Player {

    static String what_to_do(String direction, int position, int goal){
    return ( ((direction.equals(“LEFT”)) && (position < goal)) || ((direction.equals(“RIGHT”)) && (position > goal)) ) ? “BLOCK” : “WAIT”;
    // Block if the direction is opposite from the goal and wait otherwise
    }

    public static void main(String args[]) {
    Scanner in = new Scanner(System.in);
    int nbFloors = in.nextInt(); // number of floors
    int width = in.nextInt(); // width of the area
    int nbRounds = in.nextInt(); // maximum number of rounds
    int exitFloor = in.nextInt(); // floor on which the exit is found
    int exitPos = in.nextInt(); // position of the exit on its floor
    int nbTotalClones = in.nextInt(); // number of generated clones
    int nbAdditionalElevators = in.nextInt(); // ignore (always zero)
    int nbElevators = in.nextInt(); // number of elevators
    int[] elevatorFloor = new int[nbElevators];
    int[] elevatorPos = new int[nbElevators];
    int where_to_go = 0;
    int cloneFloor = 0;
    int clonePos = 0;

     for (int i = 0; i < nbElevators; i++) {
         elevatorFloor[i] = in.nextInt(); // floor on which this elevator is found
         elevatorPos[i] = in.nextInt(); // position of the elevator on its floor
     }
    
     // game loop
     while (true) {
         cloneFloor = in.nextInt(); // floor of the leading clone
         clonePos = in.nextInt(); // position of the leading clone on its floor
         String direction = in.next(); // direction of the leading clone: LEFT or RIGHT
         try{
             where_to_go = (cloneFloor == nbElevators) ? (int) exitPos : (int) elevatorPos[cloneFloor] ;
             // just because something went wrong
         }catch (Exception e) {
             where_to_go = (int) exitPos ;
         }
         
         // Write an action using System.out.println()
         // To debug: System.err.println("Debug messages...");
         System.out.println( what_to_do(direction, clonePos, where_to_go) ); // action: WAIT or BLOCK
     }
    

    }