Skip to main content
OCR
Source Link
200_success
  • 145.6k
  • 22
  • 191
  • 481

Problem:

CharGrid

Problem

CharGrid

The CharGridCharGrid class encapsulates a 2-d char array with a couple couple operations.

int countPlus()

Look for a '+' pattern in the grid made with repetitions of a character. A '+' is made of single character in the middle and four "arms" extending out up, down, left, and right. The arms start with the middle char and extend until the first different character or grid edge. To count as a '+', all the arms should have two or more chars and should all be the same length. For example, the grid below contains exactly 2 +'s: the p-plus in the top left and the x-plus in the top right. The y in the bottom right doesn't work because the top, right, and left arms would be length 2, but the bottom arm would be length 3.

  p      
  p    x 
ppppp xxx
  p  y x 
  p yyy  
zzzzzyzzz
  xx y

Plusses may be formed using any character such as digits or punctuation marks, they do not have to be letters. Just treat all chars the same and your code should work fine.

enter image description here

import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;

public class CharGridTest {

    // 
    // CountPlus Tests
    // 
    @Test
    public void testCountPlus1() {
        char[][] grid1 = new char[][]{
            {'x'}
        };
        char[][] grid2 = new char[][]{
            {'a'},
            {'b'}
        };
        char[][] grid3 = new char[][]{
            {'a'},
            {'b'},
            {'c'}
        };
        char[][] grid4 = new char[][]{
            {'a'},
            {'b'},
            {'c'},
            {'d'}
        };
        char[][] grid5 = new char[][]{
            {'a', 'b', 'c'}
        };
        char[][] grid6 = new char[][]{
            {'a', 'b', 'c', 'd'}
        };

        CharGrid cg1 = new CharGrid(grid1);
        CharGrid cg2 = new CharGrid(grid2);
        CharGrid cg3 = new CharGrid(grid3);
        CharGrid cg4 = new CharGrid(grid4);
        CharGrid cg5 = new CharGrid(grid5);
        CharGrid cg6 = new CharGrid(grid6);

        assertEquals(0, cg1.countPlus());
        assertEquals(0, cg2.countPlus());
        assertEquals(0, cg3.countPlus());
        assertEquals(0, cg4.countPlus());
        assertEquals(0, cg5.countPlus());
        assertEquals(0, cg6.countPlus());
    }

    @Test
    public void testCountPlus2() {
        char[][] grid1 = new char[][]{
            {'x', 'y'},};
        char[][] grid2 = new char[][]{
            {'x', 'y'},
            {'a', 'b'},};
        char[][] grid3 = new char[][]{
            {'a', 'b'},
            {'c', 'd'},
            {'e', 'f'},};
        char[][] grid4 = new char[][]{
            {'a', 'b'},
            {'c', 'd'},
            {'e', 'f'},
            {'g', 'h'},};
        char[][] grid5 = new char[][]{
            {'a', 'b', 'c'},
            {'d', 'e', 'f'}
        };
        char[][] grid6 = new char[][]{
            {'a', 'b', 'c', 'd'},
            {'a', 'b', 'c', 'd'},};

        CharGrid cg1 = new CharGrid(grid1);
        CharGrid cg2 = new CharGrid(grid2);
        CharGrid cg3 = new CharGrid(grid3);
        CharGrid cg4 = new CharGrid(grid4);
        CharGrid cg5 = new CharGrid(grid5);
        CharGrid cg6 = new CharGrid(grid6);

        assertEquals(0, cg1.countPlus());
        assertEquals(0, cg2.countPlus());
        assertEquals(0, cg3.countPlus());
        assertEquals(0, cg4.countPlus());
        assertEquals(0, cg5.countPlus());
        assertEquals(0, cg6.countPlus());
    }

    @Test
    public void testCountPlus3() {
        char[][] grid1 = new char[][]{
            {' ', 'x', ' '},
            {'x', 'x', 'x'},
            {' ', 'x', ' '}
        };

        CharGrid cg1 = new CharGrid(grid1);

        assertEquals(1, cg1.countPlus());

    }

    @Test
    public void testCountPlus32() {
        char[][] grid2 = new char[][]{
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x'},
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '}
        };
        CharGrid cg2 = new CharGrid(grid2);
        assertEquals(1, cg2.countPlus());
    }

    @Test
    public void testCountPlus33() {
        char[][] grid3 = new char[][]{
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x'},
            {'x', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '}
        };
        CharGrid cg3 = new CharGrid(grid3);
        assertEquals(0, cg3.countPlus());
    }

    @Test
    public void testCountPlus34() {
        char[][] grid4 = new char[][]{
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', 'x', 'x', 'x', 'x', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '}
        };
        CharGrid cg4 = new CharGrid(grid4);
        assertEquals(0, cg4.countPlus());
    }

    @Test
    public void testCountPlus35() {
        char[][] grid5 = new char[][]{
            {' ', ' ', ' ', ' ', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', 'x', 'x', 'x', 'x', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', ' ', ' ', ' ', ' '}
        };
        CharGrid cg5 = new CharGrid(grid5);
        assertEquals(1, cg5.countPlus());
    }

    @Test
    public void testCountPlus36() {
        char[][] grid6 = new char[][]{
            {' ', 't', ' ', 'x', ' ', ' ', ' '},
            {'t', 't', 't', 'x', ' ', ' ', ' '},
            {' ', 't', ' ', 'x', ' ', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x', 'x', 'x'},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '}
        };
        CharGrid cg6 = new CharGrid(grid6);
        assertEquals(2, cg6.countPlus());
    }

    @Test
    public void testCountPlus37() {
        char[][] grid7 = new char[][]{
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', ' ', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', 'x', ' '},
            {'p', 'p', 'p', 'p', 'p', 'y', 'x', 'x', 'x'},
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', 'x', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', ' ', ' '},
            {'z', 'z', 'z', 'z', 'z', 'y', 'z', 'z', 'z'},
            {' ', ' ', 'x', 'x', ' ', ' ', ' ', ' ', ' '},};
        CharGrid cg7 = new CharGrid(grid7);
        assertEquals(2, cg7.countPlus());
    }

    @Test
    public void testCountPlus38() {
        char[][] grid8 = new char[][]{
            {' ', ' ', 'p', ' ', ' ', 'q', ' ', ' ', ' '},
            {' ', ' ', 'p', ' ', 'q', 'q', 'q', 'x', ' '},
            {'p', 'p', 'p', 'p', 'p', 'q', 'x', 'x', 'x'},
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', 'x', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', ' ', ' '},
            {'z', 'z', 'z', 'z', 'z', 'y', 'z', 'z', 'z'},
            {' ', ' ', 'x', 'x', ' ', 'y', ' ', ' ', ' '},};
        CharGrid cg8 = new CharGrid(grid8);
        assertEquals(3, cg8.countPlus());
    }


}

        

Problem:

CharGrid

The CharGrid class encapsulates a 2-d char array with a couple operations.

enter image description here

import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;

public class CharGridTest {

    // 
    // CountPlus Tests
    // 
    @Test
    public void testCountPlus1() {
        char[][] grid1 = new char[][]{
            {'x'}
        };
        char[][] grid2 = new char[][]{
            {'a'},
            {'b'}
        };
        char[][] grid3 = new char[][]{
            {'a'},
            {'b'},
            {'c'}
        };
        char[][] grid4 = new char[][]{
            {'a'},
            {'b'},
            {'c'},
            {'d'}
        };
        char[][] grid5 = new char[][]{
            {'a', 'b', 'c'}
        };
        char[][] grid6 = new char[][]{
            {'a', 'b', 'c', 'd'}
        };

        CharGrid cg1 = new CharGrid(grid1);
        CharGrid cg2 = new CharGrid(grid2);
        CharGrid cg3 = new CharGrid(grid3);
        CharGrid cg4 = new CharGrid(grid4);
        CharGrid cg5 = new CharGrid(grid5);
        CharGrid cg6 = new CharGrid(grid6);

        assertEquals(0, cg1.countPlus());
        assertEquals(0, cg2.countPlus());
        assertEquals(0, cg3.countPlus());
        assertEquals(0, cg4.countPlus());
        assertEquals(0, cg5.countPlus());
        assertEquals(0, cg6.countPlus());
    }

    @Test
    public void testCountPlus2() {
        char[][] grid1 = new char[][]{
            {'x', 'y'},};
        char[][] grid2 = new char[][]{
            {'x', 'y'},
            {'a', 'b'},};
        char[][] grid3 = new char[][]{
            {'a', 'b'},
            {'c', 'd'},
            {'e', 'f'},};
        char[][] grid4 = new char[][]{
            {'a', 'b'},
            {'c', 'd'},
            {'e', 'f'},
            {'g', 'h'},};
        char[][] grid5 = new char[][]{
            {'a', 'b', 'c'},
            {'d', 'e', 'f'}
        };
        char[][] grid6 = new char[][]{
            {'a', 'b', 'c', 'd'},
            {'a', 'b', 'c', 'd'},};

        CharGrid cg1 = new CharGrid(grid1);
        CharGrid cg2 = new CharGrid(grid2);
        CharGrid cg3 = new CharGrid(grid3);
        CharGrid cg4 = new CharGrid(grid4);
        CharGrid cg5 = new CharGrid(grid5);
        CharGrid cg6 = new CharGrid(grid6);

        assertEquals(0, cg1.countPlus());
        assertEquals(0, cg2.countPlus());
        assertEquals(0, cg3.countPlus());
        assertEquals(0, cg4.countPlus());
        assertEquals(0, cg5.countPlus());
        assertEquals(0, cg6.countPlus());
    }

    @Test
    public void testCountPlus3() {
        char[][] grid1 = new char[][]{
            {' ', 'x', ' '},
            {'x', 'x', 'x'},
            {' ', 'x', ' '}
        };

        CharGrid cg1 = new CharGrid(grid1);

        assertEquals(1, cg1.countPlus());

    }

    @Test
    public void testCountPlus32() {
        char[][] grid2 = new char[][]{
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x'},
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '}
        };
        CharGrid cg2 = new CharGrid(grid2);
        assertEquals(1, cg2.countPlus());
    }

    @Test
    public void testCountPlus33() {
        char[][] grid3 = new char[][]{
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x'},
            {'x', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '}
        };
        CharGrid cg3 = new CharGrid(grid3);
        assertEquals(0, cg3.countPlus());
    }

    @Test
    public void testCountPlus34() {
        char[][] grid4 = new char[][]{
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', 'x', 'x', 'x', 'x', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '}
        };
        CharGrid cg4 = new CharGrid(grid4);
        assertEquals(0, cg4.countPlus());
    }

    @Test
    public void testCountPlus35() {
        char[][] grid5 = new char[][]{
            {' ', ' ', ' ', ' ', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', 'x', 'x', 'x', 'x', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', ' ', ' ', ' ', ' '}
        };
        CharGrid cg5 = new CharGrid(grid5);
        assertEquals(1, cg5.countPlus());
    }

    @Test
    public void testCountPlus36() {
        char[][] grid6 = new char[][]{
            {' ', 't', ' ', 'x', ' ', ' ', ' '},
            {'t', 't', 't', 'x', ' ', ' ', ' '},
            {' ', 't', ' ', 'x', ' ', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x', 'x', 'x'},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '}
        };
        CharGrid cg6 = new CharGrid(grid6);
        assertEquals(2, cg6.countPlus());
    }

    @Test
    public void testCountPlus37() {
        char[][] grid7 = new char[][]{
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', ' ', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', 'x', ' '},
            {'p', 'p', 'p', 'p', 'p', 'y', 'x', 'x', 'x'},
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', 'x', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', ' ', ' '},
            {'z', 'z', 'z', 'z', 'z', 'y', 'z', 'z', 'z'},
            {' ', ' ', 'x', 'x', ' ', ' ', ' ', ' ', ' '},};
        CharGrid cg7 = new CharGrid(grid7);
        assertEquals(2, cg7.countPlus());
    }

    @Test
    public void testCountPlus38() {
        char[][] grid8 = new char[][]{
            {' ', ' ', 'p', ' ', ' ', 'q', ' ', ' ', ' '},
            {' ', ' ', 'p', ' ', 'q', 'q', 'q', 'x', ' '},
            {'p', 'p', 'p', 'p', 'p', 'q', 'x', 'x', 'x'},
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', 'x', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', ' ', ' '},
            {'z', 'z', 'z', 'z', 'z', 'y', 'z', 'z', 'z'},
            {' ', ' ', 'x', 'x', ' ', 'y', ' ', ' ', ' '},};
        CharGrid cg8 = new CharGrid(grid8);
        assertEquals(3, cg8.countPlus());
    }


}

        

Problem

CharGrid

The CharGrid class encapsulates a 2-d char array with a couple operations.

int countPlus()

Look for a '+' pattern in the grid made with repetitions of a character. A '+' is made of single character in the middle and four "arms" extending out up, down, left, and right. The arms start with the middle char and extend until the first different character or grid edge. To count as a '+', all the arms should have two or more chars and should all be the same length. For example, the grid below contains exactly 2 +'s: the p-plus in the top left and the x-plus in the top right. The y in the bottom right doesn't work because the top, right, and left arms would be length 2, but the bottom arm would be length 3.

  p      
  p    x 
ppppp xxx
  p  y x 
  p yyy  
zzzzzyzzz
  xx y

Plusses may be formed using any character such as digits or punctuation marks, they do not have to be letters. Just treat all chars the same and your code should work fine.

import static org.junit.Assert.*;
import org.junit.Before;
import org.junit.Test;

public class CharGridTest {

    // 
    // CountPlus Tests
    // 
    @Test
    public void testCountPlus1() {
        char[][] grid1 = new char[][]{
            {'x'}
        };
        char[][] grid2 = new char[][]{
            {'a'},
            {'b'}
        };
        char[][] grid3 = new char[][]{
            {'a'},
            {'b'},
            {'c'}
        };
        char[][] grid4 = new char[][]{
            {'a'},
            {'b'},
            {'c'},
            {'d'}
        };
        char[][] grid5 = new char[][]{
            {'a', 'b', 'c'}
        };
        char[][] grid6 = new char[][]{
            {'a', 'b', 'c', 'd'}
        };

        CharGrid cg1 = new CharGrid(grid1);
        CharGrid cg2 = new CharGrid(grid2);
        CharGrid cg3 = new CharGrid(grid3);
        CharGrid cg4 = new CharGrid(grid4);
        CharGrid cg5 = new CharGrid(grid5);
        CharGrid cg6 = new CharGrid(grid6);

        assertEquals(0, cg1.countPlus());
        assertEquals(0, cg2.countPlus());
        assertEquals(0, cg3.countPlus());
        assertEquals(0, cg4.countPlus());
        assertEquals(0, cg5.countPlus());
        assertEquals(0, cg6.countPlus());
    }

    @Test
    public void testCountPlus2() {
        char[][] grid1 = new char[][]{
            {'x', 'y'},};
        char[][] grid2 = new char[][]{
            {'x', 'y'},
            {'a', 'b'},};
        char[][] grid3 = new char[][]{
            {'a', 'b'},
            {'c', 'd'},
            {'e', 'f'},};
        char[][] grid4 = new char[][]{
            {'a', 'b'},
            {'c', 'd'},
            {'e', 'f'},
            {'g', 'h'},};
        char[][] grid5 = new char[][]{
            {'a', 'b', 'c'},
            {'d', 'e', 'f'}
        };
        char[][] grid6 = new char[][]{
            {'a', 'b', 'c', 'd'},
            {'a', 'b', 'c', 'd'},};

        CharGrid cg1 = new CharGrid(grid1);
        CharGrid cg2 = new CharGrid(grid2);
        CharGrid cg3 = new CharGrid(grid3);
        CharGrid cg4 = new CharGrid(grid4);
        CharGrid cg5 = new CharGrid(grid5);
        CharGrid cg6 = new CharGrid(grid6);

        assertEquals(0, cg1.countPlus());
        assertEquals(0, cg2.countPlus());
        assertEquals(0, cg3.countPlus());
        assertEquals(0, cg4.countPlus());
        assertEquals(0, cg5.countPlus());
        assertEquals(0, cg6.countPlus());
    }

    @Test
    public void testCountPlus3() {
        char[][] grid1 = new char[][]{
            {' ', 'x', ' '},
            {'x', 'x', 'x'},
            {' ', 'x', ' '}
        };

        CharGrid cg1 = new CharGrid(grid1);

        assertEquals(1, cg1.countPlus());

    }

    @Test
    public void testCountPlus32() {
        char[][] grid2 = new char[][]{
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x'},
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '}
        };
        CharGrid cg2 = new CharGrid(grid2);
        assertEquals(1, cg2.countPlus());
    }

    @Test
    public void testCountPlus33() {
        char[][] grid3 = new char[][]{
            {' ', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x'},
            {'x', ' ', 'x', ' ', ' '},
            {' ', ' ', 'x', ' ', ' '}
        };
        CharGrid cg3 = new CharGrid(grid3);
        assertEquals(0, cg3.countPlus());
    }

    @Test
    public void testCountPlus34() {
        char[][] grid4 = new char[][]{
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', 'x', 'x', 'x', 'x', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '}
        };
        CharGrid cg4 = new CharGrid(grid4);
        assertEquals(0, cg4.countPlus());
    }

    @Test
    public void testCountPlus35() {
        char[][] grid5 = new char[][]{
            {' ', ' ', ' ', ' ', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', 'x', 'x', 'x', 'x', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', ' ', ' ', ' ', ' '}
        };
        CharGrid cg5 = new CharGrid(grid5);
        assertEquals(1, cg5.countPlus());
    }

    @Test
    public void testCountPlus36() {
        char[][] grid6 = new char[][]{
            {' ', 't', ' ', 'x', ' ', ' ', ' '},
            {'t', 't', 't', 'x', ' ', ' ', ' '},
            {' ', 't', ' ', 'x', ' ', ' ', ' '},
            {'x', 'x', 'x', 'x', 'x', 'x', 'x'},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '},
            {' ', ' ', ' ', 'x', ' ', 'x', ' '},
            {' ', ' ', ' ', 'x', ' ', ' ', ' '}
        };
        CharGrid cg6 = new CharGrid(grid6);
        assertEquals(2, cg6.countPlus());
    }

    @Test
    public void testCountPlus37() {
        char[][] grid7 = new char[][]{
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', ' ', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', 'x', ' '},
            {'p', 'p', 'p', 'p', 'p', 'y', 'x', 'x', 'x'},
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', 'x', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', ' ', ' '},
            {'z', 'z', 'z', 'z', 'z', 'y', 'z', 'z', 'z'},
            {' ', ' ', 'x', 'x', ' ', ' ', ' ', ' ', ' '},};
        CharGrid cg7 = new CharGrid(grid7);
        assertEquals(2, cg7.countPlus());
    }

    @Test
    public void testCountPlus38() {
        char[][] grid8 = new char[][]{
            {' ', ' ', 'p', ' ', ' ', 'q', ' ', ' ', ' '},
            {' ', ' ', 'p', ' ', 'q', 'q', 'q', 'x', ' '},
            {'p', 'p', 'p', 'p', 'p', 'q', 'x', 'x', 'x'},
            {' ', ' ', 'p', ' ', ' ', 'y', ' ', 'x', ' '},
            {' ', ' ', 'p', ' ', 'y', 'y', 'y', ' ', ' '},
            {'z', 'z', 'z', 'z', 'z', 'y', 'z', 'z', 'z'},
            {' ', ' ', 'x', 'x', ' ', 'y', ' ', ' ', ' '},};
        CharGrid cg8 = new CharGrid(grid8);
        assertEquals(3, cg8.countPlus());
    }


}
edited title
Link
mdfst13
  • 22.4k
  • 6
  • 34
  • 70

find Find number of plus in a 2d array

Tweeted twitter.com/StackCodeReview/status/739479103670194176
added 4 characters in body
Source Link
Thor
  • 627
  • 1
  • 9
  • 14

I know as a matter of fact that there are many areas upon which my code could be improved. However, rather than asking other people to correct my code, I would much prefer to be given hints or general principles as to how my code could be improvedI would much prefer to be given hints or general principles as to how my code could be improved. I think this way, me, and everyone that read this post could get more out of this exercise this way.

I know as a matter of fact that there are many areas upon which my code could be improved. However, rather than asking other people to correct my code, I would much prefer to be given hints or general principles as to how my code could be improved. I think this way, me, and everyone that read this post could get more out of this exercise this way.

I know as a matter of fact that there are many areas upon which my code could be improved. However, rather than asking other people to correct my code, I would much prefer to be given hints or general principles as to how my code could be improved. I think this way, me, and everyone that read this post could get more out of this exercise this way.

Source Link
Thor
  • 627
  • 1
  • 9
  • 14
Loading