Creating an N by N grid of letters so that no two adjacent letters are the same
<p>I need to print out a N by N grid containing the letters A to F, so that no two adjacent letters are the same. The code below prints out an N by N grid, however I can only get the letters on the left and right to be different. I can't find a way to get the letters above and below to be different as well. I need to solve this problem without the use of arrays. The letters have to be randomized.</p>

<pre><code>public static void main(String[] args) {
    int N = StdIn.readInt();
    for (int column = 0; column &lt; N; column++) {
        int x = 0;

        for (int row = 0; row &lt; N; row++) {

            int c = (int) (Math.random() * 6 + 1);

            while (x == c) {
                c = (int) (Math.random() * 6 + 1);
            }
            if (c == 1) {
                System.out.print("A ");
            }
            if (c == 2) {
                System.out.print("B ");
            }
            if (c == 3) {
                System.out.print("C ");
            }
            if (c == 4) {
                System.out.print("D ");
            }
            if (c == 5) {
                System.out.print("E ");
            }
            if (c == 6) {
                System.out.print("F ");
            }

            x = c;

        }

        System.out.println();

    }
</code></pre>
