Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
That's because the tests are bad in almost every language.
Thanks for quick respnose.
Yes, I saw that, but didn't quite understand what is meant. I thought that zeroes are allowed if they don't break other rules.
My solution in the given example returns true, but passes all tests as well.
Hello, I think it is not working correct.
In case below it should return true, but your solution returns false. Am I wrong?
example:
int[][] board =
{
new []{5, 3, 4, 6, 7, 8, 9, 0, 2},
new []{6, 7, 2, 1, 9, 5, 3, 4, 8},
new []{1, 9, 8, 3, 4, 2, 5, 6, 7},
new []{8, 5, 9, 7, 6, 1, 4, 2, 3},
new []{4, 2, 6, 8, 5, 3, 7, 9, 1},
new []{7, 1, 3, 9, 2, 4, 8, 5, 6},
new []{9, 6, 1, 5, 3, 7, 2, 8, 4},
new []{2, 8, 7, 4, 1, 9, 6, 3, 5},
new []{3, 4, 5, 2, 8, 6, 1, 7, 9},
};
I think that it is not working correct.
int[,] field = new int[10, 10]
{{1, 0, 0, 1, 0, 1, 1, 0, 0, 0},
{1, 0, 1, 0, 0, 0, 0, 0, 1, 0},
{1, 0, 1, 0, 1, 1, 1, 0, 1, 0},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 1, 0, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
As piotr-kasprzyk mentions about an error in the first version of this solution, the error has not been fixed here also:
Another test that should fail:
int[,] field = new int[10, 10] {{1, 0, 0, 0, 0, 1, 1, 0, 0, 0}, {1, 0, 1, 0, 0, 0, 0, 0, 1, 0}, {1, 0, 1, 0, 1, 1, 1, 0, 1, 0}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 1, 0, 1, 0, 0, 0}, {0, 0, 0, 0, 1, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 1, 0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}};
Testing horizontal ships after vertical leads to an error of treating 2- and 1-square ships ((5,4)-(6,4) and (5,6)) together as one 3-square ship.
The length variable stops at 2 for the vertical ship, and then we test horizontal ship which is one square away as it was a continuation of the first one.