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.
brackets denote choosing between a number of characters in regex. in this case, picking one of "a", "e", "i", "o", "u", "A", "E", "I", "O", or "U".
As long as there exist one valid combination, then the grid is valid.
Brilliant solution. Definitely an up vote.
Not a suggestion. And your solution is
O(n^2)
.Except that if you read the kata description:
You'll see there is no ship of size 5 and in the example ReagentX used there is no 4 cells ship. If you can fit all those ships, without overlapping, then the board is valid. Overlap is forbidden too:
The guy has a point here, how are we supposed to know the difference between an overlap or a if its just laying side by side, for instance:
0001000
0001000
0111110
0001000
0001000
Above You could assume that two (size 5) ships are overlapping or it can be assumed that one(size 5) ship and two(size 2) ships are independent, Because there is no definition of a ship boundary!!
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
That's out. What you have done does not guarantee the equality of two words. Try the case where variable word is 'aabc' and one of variable words is 'abbc'.
'I assume you mean that this should test whether a board can be valid'
Yes, that is what you're supposed to do.
pffff... just learn to read, then?
Please explain to me how the following board is valid:
You can't, becasue it isn't, ans you can't possibly know that it is without information not given by the problem. "Is the board valid" is not a question you can answer because, as I said in my original comment, just becasue there exists a configuration that can be valid that does not imply that the configuration is valid. Since the problem is to determine if a valid solution exists for a given board the task is not "return true if it has a valid disposition of ships" but rather "return true if it can have a valid disposition of ships" which is a different question entirely.
depends... seems to me you downvoted me 5 times in a row while I was answering to your question/trouble. Does that feel friendly to you?
that's exactly what I told you before, you didn't correctly understood the task. Somewhat:
-> yes (seems you edited that part while I was answering before). But all the same, that's exactly what you're asked for: the question is "is the board valid", not "where each one of the ships is placed?".
Not sure why youre so hostile. Please explain to me how you know the board I mentioned in my comment is not the following:
Loading more items...