Ad
  • Custom User Avatar
  • Custom User Avatar

    Well played!

  • Custom User Avatar

    Correction: String.join does use the StringBuilder library, because StringJoiner uses StringBuilder under the hood. This means that String.join, StringJoiner, and StringBuilder are all O(n) optimal ways to concatenate strings, whereas the string concatenation operator + is O(n^2).

  • Custom User Avatar

    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.

  • Custom User Avatar

    Indeed take a look at the formula for points: points = numberOfDamagedShips * 0.5 + numberOfSunkShips - notTouchedShips

  • Custom User Avatar

    Assuming instructions are stored in 2D array x and y point to a single instruction, v should be an integer and you are responsible to change the single instruction to v 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])

  • Custom User Avatar

    Had a trouble too. Turns out I haven't assumed at the beginning that the default dierction is to the right.

  • Custom User Avatar

    In Java tests there's a problem with every even n except 2. It's beacause of one 1 in the wrong place. To bypass this bug just add the below code before return statement:

    if(size % 2 == 0 && size > 2)
      arr[size / 2][size / 2 - 1] = 1;
    
  • Custom User Avatar

    Aaand for me ..........