[SOLVED] Hunger games


#1

Hello all,

I have a problem with the easy puzzle “Hunger games” in PHP :
I want to return an empty line, for make a return like this between each tributes :
Name: Bowser
Killed: None
Killer: Mario

Name: Mario
Killed: Bowser
Killer: Winner
But with an “echo(“Killer: Mario\n”);echo("\n");”, I have this error :
Find: Killer: WinnerEnd of line (\n)
Waiting : Killer: WinnerNothing
If you have an idea of how to do?

Thanks


#2

Hello Roro, please add link to the puzzle you seek help.

Nevertheless, this puzzle does not accept end of line for the last line of your output.
So you need to change your code to deal with this.


#4

Here is the puzzle : https://www.codingame.com/ide/puzzle/hunger-games
I tried a lot of things, but nothing works, that’s why I post here :slight_smile:


#5

Pretty clear for me. It’s says that the output ends with “end of line” while it should ends with “nothing”.
Have you tried to replace your echo("\n") with nothing (e.g. remove it :wink:)


#6

Yes, I understand what you say, but the problem is this : I need to put one clear line between the two blocs of tributes.
But I can’t put a double “\n”, it make an error :confused:

EDIT: problem solved


#8

For example you could use this inside the for cycle of tributes:
if (i<tributes-1)
{
Console.WriteLine();
}


#9

Hi,
I have the same problem in JAVA.
If I put System.out.println(); or System.out.println(…"\n") for the last line, I get the error message WinnerEnd of line (\n) instead of WinnerNothing.
And if I put no extra line, I get an error message too (found “Na…” instead of Nothing).
Did you find a solution (even in PHP, it might help me).
Thanx,


#10

As I understand, the problem is that you are displaying new line to the very end of the list. It is expected that there is no empty line after last “Killer: …” line;
so we do like that:
if(i < tributes-1)
{
display empty line;
}
Did you understand?