Onboarding - Puzzle discussion


#172

NO idea how to do first test thing on Java


#173

I suck in Java but I was able to solve it.


#174

I originally came to this site because it was marketed as a way to LEARN to program, which I have been interested in for a while, but upon getting here and attempting to do the tutorial and then reading this forum I see that this is not the case. I thought the idea of this site was great when I heard it but it seems that it is completely useless unless you already know how to program.


#175

Learn to program while solving puzzles.


#176

Ok, so. I have the program outputting the name of enemy1, if the distance is less than that of enemy2, and outputting the name of enemy 2 otherwise. after the first couple shots, it just stops. Any thoughts?


#177

Got it figured out, nvm :slight_smile:


#178

I’m getting this message when I try to run test case :“Timeout: your program did not provide an input in due time”. I’m not sure what it means, and how to handle it. Please help


#179

you dont process all the conditions in your program, in some of them you don’t have output


#180

I finished the tutorial without trouble once I stopped overcomplicating things and just followed the directions, but I’m just learning C++ and I want to know why it works. Could somebody explain how:
string enemy1; // name of enemy 1 cin >> enemy1; cin.ignore(); int dist1; // distance to enemy 1 cin >> dist1; cin.ignore();

was able to identify the enemy in the game information?


#181

enemy1 and dist1 are inputs given by CodinGame each round.

cin (http://www.cplusplus.com/reference/iostream/cin/) is used to read these input.


#182

im noob. the only attacks or shots i use is with
Print(’…’)
can u help me with extra commands or something for in JavaScript??


#183

You need to know what an “If statement” is, and how to compare two numbers.

That’s probably the first chapter of every tutorial/manual/book in every programming language.


#184

try just a succession of scanf and printf of pointer and it will works for test 1

exemple
char *enemy1
char *enemy2
int dist1;
int dist2;

scanf("%s", &enemy2);
scanf("%d", &dist[0]);
printf("%s\n", &enemy2);
scanf("%s", &enemy1);
scanf("%d", &dist[0]);
printf("%s\n", &enemy1);


#185

I’m on the first puzzle and writing an “if” statement is pretty easy but the ship does not react. Do I need to compile my code somehow on the IDE and then run the game? Or does the syntax have to be specific?

if ( dist1 < dist2 ) {
cout<<"Enemy = "<<enemy1<<endl;
}
else etc…


#186

tell me how to do it!!!


#187

From what I can see, your output seems wrong. You have to output only the value of either enemy1 or enemy2. Followed by a newline.


#188

You can help me? I m a beginnen. Sorry.:wink:


#189

Hi,
I’m trying the first puzzle in C++, but it seems I cannot get anything printed to the console. (I’m on Firefox)
I tried just printing things:
cerr << “Debug messages…”;
cerr << “name 1:”+enemy1;
cerr << “name 2:”+enemy2;
but even this doesn’t print anywhere. It should print in the console output, right?
Am I missing something? Do I need to save or compile the code?


#190

Hey, I’m working on “Imminent Danger” in Javascript. I used the provided skeleton code and formatted it. The test runs, however, and “Rock” always gets through and kills me, even though the ship is killing other ships the entire time. Is it because “Rock” is only a single ship, and the code compares two ships?


#191

It looks like you are missing a newline to flush the stream.