## 12337 - Bob's Beautiful Balls

Moderator: Board moderators

cutenemo
New poster
Posts: 7
Joined: Fri Dec 13, 2013 9:52 pm
Location: California

### 12337 - Bob's Beautiful Balls

I keep getting WA for this problem. I'm transforming the string into a matrix (spiral) and then comparing checking if each column has only one color.

I tried these cases myself
Sample Input
7
BGWBBGGGBBWGBBGWBB
GBBWBBWBBB
BBBBBBBBBBBBBBB
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGWW
GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
GGGGGGGGGGGG
BGWBBGGGBBWGBBGWBBB
BBBBWWBBBB
Output for Sample Input
Case 1: 9
Case 2: -1
Case 3: 8
Case 4: -1
Case 5: 20
Case 6: 7
Case 7: -1
Case 8: 7
Can anyone help with more test cases that I can check?

Thank you

mjimaz
New poster
Posts: 6
Joined: Thu Jan 09, 2014 1:03 am

### Re: 12337 - Bob's Beautiful Balls

Your input testcases should be 8, I'm guessing that's a typo.

Try these:

Input:

4
BBBB
BB
BGGB
WWBWW

Output:

Case 1: 4
Case 2: -1
Case 3: 4
Case 4: -1

Keep in mind, If there is more than one N & M solution, the lowest sum is the answer.
Also if N = 6 and M = 3 does give you -1, maybe N = 3 and M = 6 works. So try the 2nd if the first doesn't give a beautiful grid.

Thanks for the cases, helped me a lot ;D

cutenemo
New poster
Posts: 7
Joined: Fri Dec 13, 2013 9:52 pm
Location: California

### Re: 12337 - Bob's Beautiful Balls

Thanks though

mjimaz
New poster
Posts: 6
Joined: Thu Jan 09, 2014 1:03 am

### Re: 12337 - Bob's Beautiful Balls

Try this:

Input:

1
GGGGGGGGGGGGGGGGGGGGGGGG

Output:

Case 1: 10

cutenemo
New poster
Posts: 7
Joined: Fri Dec 13, 2013 9:52 pm
Location: California

### Re: 12337 - Bob's Beautiful Balls

Solved it finally!!

I was failing on this case!

BGWWWWWGBBBBGGG