I'm really new and bad at programming in C as I just started learning. Please be patient with me. I am currently trying to solve this puzzle: https://www.codingame.com/ide/puzzle/hidden-word. In the website, you can click on the three lines with three dots symbol on a box labeled "test cases" to view the test cases, then click on each test case to see the grid of letters and numbers in the left box, and then the expected output in the right box.
I know what I have to do which is to search through the grid of letters horizontally, vertically, diagonally, and the reverse of them, remove the numbers, don't print the repeated letters and combine the rest of the letters, print it out as the expected output.
I know how to write some of the other parts except for the one most important part, which is described in the title. I don't know how to check the letters horizontally, vertically, diagonally, and the reverse of them as the test cases have different numbers of column and rows. I figured I should use array but I am really bad at writing array codes.
Again, I am new and not a native English speaker so most of the stuff I just referenced on the internet and modified them. I probably shouldn't manually put the input in an array myself as the code is already written in the background (I don't know how to call it) and I don't know how to do this better.
Here is my current code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#define MAX_STR_LEN 41
int main()
{
int n;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
char aWord[41];
scanf("%s", aWord);
}
int h;
int w;
scanf("%d%d", &h, &w);
for (int i = 0; i < h; i++) {
char line[41];
scanf("%s", line);
}
int i;
int F[7][3] = {
{'2', '', ''},
{'B', 'A', 'C'},
{'B', 'O', 'B'},
{'3', '', '3'},
{'B', 'A', 'C'},
{'B', 'O', 'B'},
{'R', 'E', 'D'}
};
for (i = 0; i < n; i++) {
int string;
scanf("%d", &F);
// remove numbers
// don't print repeated elements
// combine the rest of the elements
strcpy(string, F);
// print the combined elements
}
return 0;
}
As you can see, I have attempted but failed miserably. Can someone guide me through it? You don't really have to help me write the code, you could just tell me where and what to learn to write this type of code or teach me how to write them please. Thanks in advance.
question from:
https://stackoverflow.com/questions/65874095/how-to-read-array-in-different-directions