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.
Some of the bugs I faced in my solution happened only when a ship was on a bottom or right border of the desk. At the same time, fixed test don't test this (at least in Java). So I think it would be good to add such a test.
Lasy solution.
That's cheating...
Yeah, should have checked that earlier. Thanks
The problem is not with the section of code that you quoted, the problem is with your
areOpposite
function. You are summing the first letter of each direction to see if they are opposites, but this doesn't really work because two possible direction combinations sum to the same number. Manually check'N' + 'N'
and'W' + 'E'
, and you should see what I mean. In this case, anytime yourareOpposite
function is called forNORTH
andNORTH
, it will returntrue
, which is not what you want.This comment is hidden because it contains spoiler information about the solution
You shouldn't use string concatination so often. In fact s1+s2 in Java just creates a new String with contensts of two others. See StringBuilder class.
This comment is hidden because it contains spoiler information about the solution
Ain't that 1-line solution?
This comment is hidden because it contains spoiler information about the solution