Onboarding - Puzzle discussion

Hi. I am new to this website and coding game. I have no idea how to kill the enemy using the java programming in practice session. Any one can help me out with this.
I will be greatfull to them.

Thank you.

Search how to print a string.

Hi guys i am completely new here i am just not getting what to do in this site although it looks good but i just can’t figure out i know i have to code but I am not getting it about input and output can anybody help?

Read again the template code.

You need to read from the standard input and write to the standard output. You only need to write the correct if and modify a bit the print statement.

It’s my first try here. But it frustrates me. My C++ code are below. I think it’s ok even if there are only two enemies. It’s ok in my debug IDE. But I cannot understand the message ‘Your output ‘enemy’ is not one of the remaining ship names.’
Please help.

EDIT: NO FULL CODE :stuck_out_tongue:

This puzzle have been simplified a lot to become a tutorial and it looks like you are using the old template. Now you are only given 2 enemy ships and need to print the name of the one that is the closest.

You should click on the reset button that is on the top right of the text editor.

Hey can someone help me. I have this code and I don’t know what else to do.

NO FULL CODE

Thanks!

Try to explain your problem or what you did, do not copy/paste your full code here.

The problem is that when I run the program Thor does not move at all. I think it has to do with the end of the code, but I don’t know what part is wrong.

Which program?

From what I remember, you wrote something like:
directionToPrintX = E

The way you wrote E is like a variable. Try putting writing ‘E’ or “E” instead, to say you are writing strings.

I did say “no full code” but you can still display some lines.
You can show us the line that you use to print, or how you bind “N” for north direction.

Just few limited part of your code that do not give the solution to thers is fine :wink:

I did what you said with the ‘E’ thing and here is what happened. just a little code.
var directionX();
var directionY();
if{
        thorX > lightX
        directionX = ‘W’
}
here is the error I got

missing ; before statement: var directionX();

Maybe the tutorial should have more instructions like step by step

1 Like

What language is this? Javascript?

I think you are confusing expressions and statements.

A program is a sequence of statements. The statements are seperated by semicolons. Creating a variable is a statement that has to look like this var NAME; or var NAME = EXPRESSION;. An If-Statement has to look like this: if (EXPRESSION) STATEMENT or if (EXPRESSION) STATEMENT else STATEMENT. Statements can be replaced with blocks of statements like {STATEMENT-0 [...] STATEMENT-N}. Expressions are everything that can be evaluated to a value like 2+5 or x<10 or a functioncall like Math.sin(alpha). Functioncalls like NAME() or NAME(ARGUMENT-0, [...] ,ARGUMENT-N) can also be used as statements, because they can have side effects.

So … your first two lines are not valid variable declarations, because of the parentheses. And the test expression in your IF-Statement is missplaced.

So do you mean I should do something like this:

var directionX;
var directionY;
    if(thorX > lightX){
        directionX = ‘W’
    }

Yes, that looks good.

ok I did that to the rest of my directions, and now this is my error:

thorX = directionX;
thorY = directionY;
print directionX;
print directionY;

missing ; before statement: print directionX;

this code work for only one enemy next test don’t know how to implement all those enemys

[quote=“mineboys00, post:149, topic:119, full:true”]
print directionY;[/quote]
You are still struggling with the syntax. print is a function. This line should be a functioncall.

You probably should read a book or tutorial. Codingame doesn’t help you with learning the syntax.

i am a complete noob in terms of programming. i am trying to teach myself some php and am flailing. please tell me whats wrong with this code

NO FULL CODE

this is the error I’m getting
Parse error: syntax error, unexpected ‘echo’ (T_ECHO) in the answer code
at line 28
any help/criticism is great appreciated