You can use http://pastebin.com/ to share code, because your Google Doc is not publicly available.
If itās Python3, you missed the āfile=sys.stderrā part
# To debug: print("Debug messages...", file=sys.stderr)
Like :
print("Debug messages...", width, height, file=sys.stderr)
Thank you! That helped!
Hi all, I got all test cases passed, but once I submit the code, it fails on the āsingleā test case and I do not know how to debug it. Anybody has the same problem? Result is 88% and not 100%ā¦ Any help?
Hello, just stupid questionā¦is there a difference between evaluation from top to bottom in columns and from left to right in rows? Because I wrote this in rows and it fails theirs stupid evaluationā¦dont want to rewwire it.
Changed implementation and now it works
Hi, complete noob here and need some help. This is Javascript and my code doesnāt seem to save the x1, x2, y1, y2 results. I declared the variables outside the for loops. This is not a complete code since Iāve just started. Any ideas what I am doing wrong.
/**
* Don't let the machines win. You are humanity's last hope...
**/
var width = parseInt(readline()); // the number of cells on the X axis
var height = parseInt(readline()); // the number of cells on the Y axis
var x1 = '';
var y1 = '';
var x2 = '';
var y2 = '';
var x3 = '';
var y3 = '';
for (var i = 0; i < height; i++)
{
for (var j=0; j < width; j++ )
{
var line = readline(); // width characters, each either 0 or .
if (line === 0)
{
x1 = j;
y1 = i;
j++;
if (line === 0)
{
x2 = j;
y2 = i;
j--;
} else
{
x2 = -1;
y2 = -1;
j--;
}
}
}
print (x1 + " " + y1 + " " + x2 + " " + y2 + " " + '0 0');
}
// Write an action using print()
// To debug: printErr('Debug messages...');
//printErr('Debug messages...', + x1);
// Three coordinates: a node, its right neighbor, its bottom neighbor
[SOLVED] (there was a space missing)
Iām getting the following error in swift. Any guess of what causes this? Looks like a bug in codingame.
Game information:
invalid input. Expected āx1 y1 x2 y2 x3 y3ā but found ā0 0 -1 -1-1 -1ā
Several thingsā¦
- The 0 in if (line === 0) should be in quotes. The number 0 and a string that represents the number 0 are not equal.
- That same line, as written, is comparing the whole string to 0 rather than looking at the individual characters in it, which is what I think you wanted to do.
- The else block will never be called. Iāll elaborate if you want but hopefully you can figure out why by following the flow of the program.
Bonus advice: Since the data is given to you in rows, readline() should be called once for each row, not each character.
I cant even get started with this one
i have used this code in an attempt to output the full grid to the console (and show i can reading it correctly)
for ($i = 0; $i < $height; $i++)
{
error_log($line);
}
But all that does is repeat the first line of the grid for as many times as there are rows.
IE
if we have the following grid
X X X
X
X
it would output
0 0 0
0 0 0
0 0 0
when the output should be
0 0 0
0 . .
0 . .
How can i read each line in the grid?
Check the console, your output does not follow the right form.
by the look of it, Iād say itās an index issue. Donāt hesitate to use debug prints (printErr in JS I think) to understand when your program fails to enter a loop
Got the same problem
I didnāt want to use the 2D Array way so i created a Object and just do the calc in the main.
admin edit: please dont just post your code. Either ask a specific question or give hints for others
Pro tip: Keep looking for neighbors to the south and west until you reach the edge of the map. In my first attempt I failed to look for neighbors more than one cell away. Seeing the test case made it clear that I was supposed to keep searching in a given direction. This was frustrating at first but it added a nice complexity element once I knew what was expected.
I think I must be missing something with the input, my code passes all the test cases on my local machine but fails on the site. Can anyone help me?
As I understand it I get the width and height as an integer, then a string with all of the rows from top to bottom, so a grid like this:
00
0.
should have input like this:
2
2
00
0.
and thatās how I modeled the tests.
But I fail the horizontal case which looks like this:
000
on the site, but I pass it on my machine with the inputs
3
1
000
I tried printing out the third input as I get it and I get 0.0.0
Am I just misunderstanding what the inputs are supposed to look like?
Iāve put my code here, apologies for it being a bit messy, I only started learning python yesterday:
https://pastebin.com/207r2Nys
I feel like Iām missing something. Any solution Iāve tried in C++ results in a timeout. It almost seems like just taking in the inputās alone takes up the majority of the available time before an output is required.
Solutions so far have been recursive and non-recursive and even then if I donāt just output immediately I get the infamous āTimeout: the program did not provide 1 input lines in due timeā¦ā error.
In fact Iāve even tried just outputting right after the default setup and receive this error. If I just run it from default setup I get the timeout and no output of the 0 0 1 0 0 1. It doesnāt seem to allow at all for a C++ solution.
I just test it with the default C++ template and I get
Game information:
Timeout: Only 1 node has been computed.
This is different that what youāre saying. Your problem comes from not printing a '\n'
most likely
int main()
{
int width; // the number of cells on the X axis
cin >> width; cin.ignore();
int height; // the number of cells on the Y axis
cin >> height; cin.ignore();
int array[height][width];
for (int i = 0; i < height; i++) {
for(int x = 0; x < width; x++){
cin >> array[i][x]; cin.ignore();
}
}
cout << "0 0 1 0 0 1" << endl;
}
Game information:
Timeout: the program did not provide 1 input lines in due timeā¦
Itās funny, yesterday the above was default. Today it doesnāt setup the array at all. The only thing missing from the above code that was setup was the debug message section I deleted.