// Arup Guha
// 8/31/2023
// Code for COP 3502 Quiz 1 Version D Questions 3,4

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char** vigeneresquare();

int main() {

    // Call the function.
    char** sqptr = vigeneresquare();

    // Print out the square for testing.
    for (int i=0; i<26; i++)
        printf("%s\n", sqptr[i]);

    // Clean up.
    for (int i=0; i<26; i++)
        free(sqptr[i]);
    free(sqptr);

    return 0;
}

char** vigeneresquare() {

    // We want 26 pointers.
    char** box = calloc(26, sizeof(char*));

    // Go through each row.
    for (int i=0; i<26; i++) {

        // Make room for null char.
        box[i] = calloc(27, sizeof(char));

        // Look how close to the checkerboard code this is =)
        for (int j=0; j<26; j++)
            box[i][j] = (i+j)%26 + 'A';

        // You were requested to do this.
        box[i][26] = '\0';
    }

    // Ta da!
    return box;
}
