Hello, i have a 2D array which has the dimensions of [9, 9] it is formatted like this:
Berzas,su
la;;sula;
;klevu sa
ldial lap
asula a
aula, a
r suart
zemes vai
kai du
My starting text file which i have formatted into the array above:
Berzas,sula;;sula;;klevu saldial lapasula a aila, ar suart zemes vaikai du
I need to find the amount of times these words appear in the array using recursion:
Sula
Alus
The output should be:
Sula 3
Alus 2
What I have tried:
I've only read the text file and formatted it into a array.
string file = File.ReadAllText(@"C:\Users\Justas\Desktop\L1\Rekursija\Trecias.txt");
string[,] array = new string[n, n];
var list = Enumerable
.Range(0, file.Length / n)
.Select(i => file.Substring(i * n, n))
.ToList();
var res = string.Join(Environment.NewLine, list);
for (int i = 0; i < n; i++)
{
char[] row = list[i].ToCharArray();
for (int j = 0; j < n; j++)
{
array[i, j] = row[j].ToString();
}
}
int rowLength = array.GetLength(0);
int colLength = array.GetLength(1);
I am out of ideas on how to go about this problem. Any help would be greatly appreciated