Onboarding - Puzzle discussion


#28

Yup, just me. I'm an idiot...


#29

I have looked at several languages for the beginner game and tried to figure out what needs to be added or changed but none of this makes sense to me. Some kind of stepwise hints or examples of what to do -- AND WHY -- would be really helpful for those of us who are total noobs at programming.


#30

Have you read entirely the statement given on the left-top area?
Same for the comments given on the top of the code?

If yes, what do you mean by "total noobs at programming". If you're implying that you don't know basics for any language, then I can only advice you to find some tutorials on others website for begining.
Codingame isn't a platform that will teach you programming languages, but how to use them on algorithmic problems/artificial intelligences problems.
Maybe we will add later a section like this.

There are some useful clases on udacity and coursera .


#31

im stuck in the loop i cant stop it no condition work !
how come


#32

hello everyone. I am a little puzzled with the console output.

even when the inside for loop ends Standard Output Stream keeps printing "HotDroid" for the next 5 moves instead why?


#33

Because the while loop doesn't end. Then each turn, if you haven't changed anything in the code, your code print "HotDroid".


#34

To add a little more to @cup_of_tea answer, i'll explain explain why

It's because, depending on your language, you have either:

while (1)

OR

while (true)

while loop continue until the condition is true, true means different from 0 so while(1) is always true too


#35

int main()
{

// game loop
while (1) {

    int count; // The number of current enemy ships within range
    cin >> count;
    for (int i = 0; i < count; i++) {

         string closest_enemy="";//closest enemy set to null
         int min_dist;//min dist
        string enemy; // The name of this enemy
        int dist; // The distance to your cannon of this enemy
        cin >> enemy >> dist;
        min_dist=1000;
        if(dist<min_dist)
        {
            min_dist=dist;
            closest_enemy=enemy;
            cout << closest_enemy << endl;// The name of the most threatening enemy (HotDroid is just one example)
        }

        }
    }

#36

the code is working only for the 5 enemy phase and failing for the others.can't understand why??


#37

smbdy pls hlp me


#38

what kind of help do you need smiley_catbtw. I overpowered my cannon. It was enough to shoot the nearest enemy. I made the wole object witch learned the speed of different ship types and count rounds for every ship to hit.


#39

Just started to learn programming/coding, and have done a small amount and only started monday, but am really struggling with this onboard game. Help? PLease??


#40

Have you read the entire topic where everyone has provided the solution like one hundred times? If you did, explain me your problem smile


#41

I have tried reading the problem, but dont get it still, I chose Java as the language, dunno


#42

You should consider reading this whole topic, not just the subject. The onboarding puzzle is the simplest puzzle here. We're here to help you if needed, but prove you have made some research before, you'll learn much more that way.

If you still are having problem, detail what you did, how you did it, or what is the point that you don't understand. Try to check My F.A.Q about it too.


#43

guyz help my code dosent work

while (true) {
var count = parseInt(readline()); // The number of current enemy ships within range
for (var i = 0; i < count; i++) {
var inputs = readline().split(' ');
var enemy = inputs[0]; // The name of this enemy
var dist = parseInt(inputs[1]); // The distance to your cannon of this enemy
var minDist = 1000
var closestEnemy = ''
}

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

if(dist < minDist){
dist = minDist;
closestEnemy = enemy;
print(closestEnemy);

}

}


#44

i cant make it to shoot the closest one


#45

i dont understand the question and how to solve it.can anybody please explain the question ?


#46

I'm not sure how to target the closest enemy, I'm using Python, any help?


#48

Where I should change?
It doesn't work fine.
Output will be "HotDroidHotDroidHotDroidHotDroidBuzz" in training test 01.

// game loop
while (1) {
    char closest_enemy[50] = "\0";
    int min_dist = 1000;
    int count; // The number of current enemy ships within range
    scanf("%d", &count); fgetc(stdin);
    for (int i = 0; i < count; i++) {
        char enemy[50]; // The name of this enemy
        int dist; // The distance to your cannon of this enemy
        scanf("%s%d", enemy, &dist); fgetc(stdin);
        if(dist < closest_enemy){
            min_dist = dist;
            strcat(closest_enemy , enemy);
        }
    }
    printf("%s\n",closest_enemy); 
}