Onboarding - Puzzle discussion

what is the code for the test case “one enemy” in c to understand next what to do…

Read the template, try some test cases, print some debug messages…

Hello everyone,

I am programming in JavaScript and have basic knowledge about the syntax.

However, I am confused as this code:

 // game loop
while (true) {
    var enemy1 = readline();
    var dist1 = parseInt(readline());
    var enemy2 = readline();
    var dist2 = parseInt(readline());

    // Write an action using print()
    // To debug: printErr('Debug messages...');

if(dist1 < dist2){
    print(enemy1);   
} else{
  print(enemy2); 
}


    print('HotDroid');
    
}

only seems to work for test case 1. In case 2, however, it seems to be too slow to detect the Sectoid in step 7/8 which is already in close distance.

  1. Can I refer to any of distance of the ships other than enemy1 and enemy2?

  2. Which JavaScript language elements are available/not available?

I am very thankful for any hints :slight_smile:

hint: what is print('HotDroid'); doing in your code? read above for the solution

@nicolas_patrois kudos for being so patient with all the people here that don’t listen/read.

Thank you very much for your help!

I was not intending to bother anyone with my question, I just did not find an answer related to JavaScript. If I overlooked it, sorry for that :wink:

Generally, I am not the person posting without at least trying to understand previous comments. Nevertheless, I am just a human being and thus error-prone :-p

It’s a part of my everyday work.

Sorry I didn’t mean to offend you, it was mostly directed to those who say:

Help! I don’t have patience to read, I haven’t code anything yet but i’d be glad if someone can hold my hand.

If you explain what is your problem precisely and what you have accomplish and stuff, that’s the right way to post here :smiley: Basically follow the guidelines of posting on stackoverflow, those who don’t post any relevant work in their question get stoned there too.

Not really, you’re not a moderator :slight_smile: but I love it, people like you keep this community alive, keep up the good work

Add this in the code

if(dist1<dist2){
System.out.println(enemy1);
}else
System.out.println(enemy2);
}

Add this to code

 if(dist1<dist2){
                   System.out.println(enemy1);
                }else
                System.out.println(enemy2);
            }

My every day work, the one I that gives me money. :wink:

1 Like

EDIT MOD: No, please formulate your question in order to explain what you did, not just your code copy paste, no full code is allowed so that other people don’t copy it

I wrote this code…can you help me where is the fault?

No & for ints.

sorry i dont understand your reply…

No & for ints in scanf.

How can i test my new code in code of rings again

they said you should wait until they reissue code of rings puzzle

How can you delete your account?

i am new to this codingame forum . plzz help me , i dont knw what to do in the first game that is " one enemy " …

Please read again this thread, the explanations and the template code. :wink:

is it helpful for a newbie in any language…