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.
Pure genius!
Well played!
Correction:
String.join
does use theStringBuilder
library, becauseStringJoiner
usesStringBuilder
under the hood. This means thatString.join
,StringJoiner
, andStringBuilder
are all O(n) optimal ways to concatenate strings, whereas the string concatenation operator+
is O(n^2).It should be mentioned that no matter how many times a ship was damaged we only get 0.5 point for each ship. And it's also unclear how to calculate
points
, for those having problems with figuring out points:points = numberOfDamagedShips * 0.5 + numberOfSunkShips - notTouchedShips
.Indeed take a look at the formula for points:
points = numberOfDamagedShips * 0.5 + numberOfSunkShips - notTouchedShips
Assuming instructions are stored in 2D array
x
andy
point to a single instruction,v
should be an integer and you are responsible to change the single instruction tov
character counterpart. In java it would look like that:arr[y][x] = (char) v
.In case of "get" your task is to store on the stack
v
integer counterpart:stack.push( (int) arr[y][x])
Had a trouble too. Turns out I haven't assumed at the beginning that the default dierction is to the right.
In Java tests there's a problem with every even
n
except2
. It's beacause of one1
in the wrong place. To bypass this bug just add the below code before return statement:Aaand for me ..........