/* grid_maker.c : makes random grids of English Worddle */

#include <stdio.h>
#include <stdlib.h>
#include <sys/times.h>

const char * dices[] = {
	"ednosw",
	"aaciot",
	"acelrs",
	"ehinps",
	"eefhiy",
	"elpstu",
	"acdemp",
	"gilruw",
	"egkluy",
	"ahmors",
	"abilty",
	"adenvz",
	"bfiorx",
	"dknotu",
	"abjmoq",
	"abjmoq"
};

#define SIZE 4
#define FACES 6

#define RAND(m) ((int) ((double)(m)*rand()/(RAND_MAX+1.0)))

int main(int argc, char ** argv)
{
	int i,j;
	int d[SIZE*SIZE];
	srand((unsigned int)times(NULL));
	
	for (i=0; i < SIZE*SIZE; i++)
		d[i] = dices[i][RAND(FACES)];
	for (i=0; i < SIZE*SIZE; i++)
	{
		char tmp = d[i];
		int r = i + RAND(SIZE*SIZE-i);
		d[i] = d[r];
		d[r] = tmp;
	}
	for (i=0; i < SIZE; i++)
	{
		for (j=0; j < SIZE; j++) printf("%c ", d[j * SIZE + i]);
		printf("\n");
	}
	return 0;
}
