[Community Puzzle] Shoot Enemy Aircraft

That was fun. :slight_smile:

Thank you :slight_smile:

could someone explain to me how planes behave when they exit the screen. Since level 2 is impossible in 1 pass since all 3 planes stack over each other and you cant shoot 3 missiles at once

do they come back from the same side they came or do they turn around

…>… …>. …> …< …<… …<…

Actually this case never appears, you can shoot each plane before it reaches the other side.

Hi, my solution passes all the test cases, but when I submit I fail the “Hold the line case”. I’m not sure how it differs from the corresponding test case, but it seems to be an edge case for my solution and I can’t figure out why.

2 Likes

In the validator the launcher is on the right of the grid (instead of the left in the test case).
You can try this custom test case :

2
>.>..
____^

Output : SHOOT WAIT SHOOT

3 Likes

Thanks, it seems the problem occurs when the gun is in the rightmost position.

Hi,

Your puzzle seems cool but I have an issue to print the value “WAIT” (it works with “SHOOT”).
I tried with different languages (Dart and after Javascript) and I have the same issue.

For example with this code (it’s the default one with the line console.log('SHOOT') commented) :

/**
 * Auto-generated code below aims at helping you parse
 * the standard input according to the problem statement.
 **/

const n = parseInt(readline());
for (let i = 0; i < n; i++) {
    const line = readline();
}

// Write an answer using console.log()
// To debug: console.error('Debug messages...');

//console.log('SHOOT');
console.log('WAIT');

I have the result "Failed. Found: nothing, Expected: “WAIT” ".

Do you have any idea of the problem ? Thanks !

Hi, you have to output several lines, until you shoot every aircraft. Your first line is WAIT but your 2nd line is nothing because you don’t output a second line.

Hello,

I have a little problem with my PHP output, everything is fine, I get the correct firing instructions, but there is a formatting error.

Sortie console
Sortie standard :

array (
  0 => '....................',
  1 => '.>..................',
  2 => '...................<',
  3 => '....................',
  4 => '....................',
  5 => '_________^__________',
)
WAIT
WAIT
WAIT
SHOOT
WAIT
WAIT
SHOOT

Échec
Trouvé :

SHOOTEnd of line (\n)

Attendu :

Rien


I use the proposed output function:

    {
        echo("SHOOT\n");
    } else {
        echo("WAIT\n");
    }

Thanks for your help :wink:

Maybe you printed an unexpected ‘\n’ (empty line after the last SHOOT)

Thanks, it was simply that :wink:

this had me thinking like 2 whole days, aint no way this is easyyy
but it was fun tho

1 Like

It was fun.
I handled shift down of aircrafts when they aren’t targetable before they reach altitude boundaries .

It’s badly that this kind of scenario wasn’t checked by validators/test.
Because this usecase need more work on implementations.

This puzzle was supposed to be a CoC so I didn’t made it too difficult. Every aircraft can be shot. Maybe I should have added unreachable aircraft … I didn’t think about it when I made this puzzle as an easy one.

Description is certainly lacking, it should clearly describe all possible (and impossible) conditions.
For example, what happens if planes collide?
Is it always possible to shoot all planes?
Does the missile gets destroyed when it hits the plane, or does it travel further?
I know certain things might be obvious, but all assumptions on input data should be unambiguous

Yes it was obvious for me, and nobody asked me to add these informations when the puzzle wasn’t approved yet.
The statement has been updated, thanks for your feedback.

I really enjoyed that, thanks!

1 Like

Yes, very good one, thank you :slight_smile:

is there any other test case? having the same problem as the above comment