[Community Puzzle] Reverse Minesweeper

Hi, could really use some help (Im using java)
And yes i know it looks like a mess i started debugging and splitting it into separate parts for better debugging…

Problem 1 and 4 are easy, but when i run my code for problem 3 and 4 i get and index out of bounds exception :confused: any ideas why?

And i would also appreciate if someone could give me a little hint on how to tackle the problem of multiple x in one row since my code isnt built for that right now

[Mod edit: Please avoid posting codes on the forum in the future.]

Maybe you have not check the doc

The method throws an IndexOutOfBoundException when :

  • the startIndex is larger than the length of String
  • the startIndex isless than zero
  • startIndex is greater than endIndex
  • endIndex is greater than length of String

for exemple with your code :

If location == 0 then locationL == -1 

and it results as

newStr.substring(0, -1)
1 Like

pls pls im losing my mind, i compared all my outputs to the expected outputs and they are all the same, every single digit. Even my output for case 4 is wrong andf i dont see how. pls have a look:

[Mod edit: Please avoid posting codes on the forum.]

I’ll take a look. But in the future, please avoid posting codes on the forum. Try describing your approach instead.

Edit: Remove .Error in your last Console.Error.WriteLine();.