Thank you for your attention. I have generated a 10x10 integer matrix, by way of a 2 dimensional array, the elements are randomly generated and lie on 1 <= z <= 5. I am in need of an efficient method of setting all adjacent "duplicates" (repeating elements) of length 3 or greater to the integer six (6). The source for the brute method follows for clarity.
Code:
46 for(row=0;row<10;row++)
47 {
48 for(col=0;col<10;col++)
49 {
50 board[row][col]=rand()%4+1; //filling matrix here
51 }}
52 print_board(board, row, col);
53
54 printf("Switch: ROW COLUMN\n ");
55 scanf("%hu %hu", &x1, &y1);
56 printf("With: ROW COLUMN\n");
57 scanf("%hu %hu", &x2, &y2);
58 swap(board, x1, y1,x2, y2); stdrd for loop no good b/c of
59 //below <-this->below
60 if(board[0][0]==board[0][1] && board[0][1]==board[0][2] && board[0][2]==board[0][3])
61 {
62 board[0][0]=6;
63 board[0][1]=6;
64 board[0][2]=6;
65 board[0][3]=6; // brute force would require many
// more to complete
66 }
67
68 print_board(board, row, col);
69
70
I know there must exist a much more elegant approach than listing out all permutations. If you have seen this and recall the technique I would very much appreciate your assistance. C-Monster