#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <string.h>

int main(int argc, char **argv){
	uint32_t combinations = atoi(argv[1]); //max 255
	char *perms = malloc(combinations);
	uint32_t n1 = 0;
	uint32_t n2 = 0;
	uint32_t n3 = 0;
	uint32_t total_perms = combinations * (combinations-1);
	char end = 0;
	char value = 0;
	char slash = 47;
	//char slash[2];
	
	char *used = malloc(combinations);
	char wrote = 0;
	uint32_t total_wrote = 0;

	printf("array[%u][%u] = {\n", total_perms, combinations);
	//perm_4[12][4] = {
	for(n1=0; n1<combinations; n1++){
		//(void)memset(used, '\0', combinations);
		//used[n1] = 1;
		//printf("\t{%u, ", n1);
		//end = 0;
		for(n2=0; n2<combinations; n2++){
			//(void)memset(used, '\0', combinations);
			if(n1 == n2)
				continue;
			(void)memset(used, '\0', combinations);
			used[n1] = 1;
			used[n2] = 1;
			printf("\t{%u, ", n1);
			//if(used[n2])
			//	continue;
			wrote = 2;
			total_wrote++;
			printf("%u, ", n2);
			//used[n2] = 1;
			for(n3=0; n3<combinations; n3++){
				if(used[n3])
					continue;
				used[n3] = 1;
				wrote++;
				if(wrote == combinations){
					if(total_wrote == total_perms){
						printf("%u}\n};\n", n3);
						break;
					}
					printf("%u},\n", n3);
				}else{
					printf("%u, ", n3);
				}
			}
		}
		if(n1 != combinations-1)
			printf("\t%c%c\n", slash, slash);
	}





	return 0;
}