I suck in Java but I was able to solve it.
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.
Learn to program while solving puzzles.
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?
Got it figured out, nvm
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
you dont process all the conditions in your program, in some of them you donāt have output
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?
enemy1 and dist1 are inputs given by CodinGame each round.
cin (http://www.cplusplus.com/reference/iostream/cin/) is used to read these input.
im noob. the only attacks or shots i use is with
Print(āā¦ā)
can u help me with extra commands or something for in JavaScript??
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.
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);
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ā¦
tell me how to do it!!!
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.
You can help me? I m a beginnen. Sorry.
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?
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?
It looks like you are missing a newline to flush the stream.
Hey @ShadiMirza,
Rock should be the first one you kill. Arenāt you killing the farthest one, instead of the closest one?