title: Path finding algorithm excercise and working with .txt files
body: <p>This is a homework which was given to me and I have been struggling with writing the solution.</p>
  <p>Write a program that finds the longest adjacent sequence of colors in a matrix(2D grid). Colors are represented by ‘R’, ‘G’, ‘B’ characters (respectively Red, Green and Blue).<br />
  You will be provided with 4 individual test cases, which must also be included in your solution.<br />
  An example of your solution root directory should look like this:</p>
  <blockquote>
  <p>solutionRootDir<br />
  | - (my solution files and folders)<br />
  | - tests/<br />
  | - test_1<br />
  | - test_2<br />
  | - test_3<br />
  | - test_4</p>
  </blockquote>
  <ol>
  <li>Individual test case input format:</li>
  </ol>
  <ul>
  <li>First you should read two whitespace separated 32-bit integers from the provided test case</li>
  <li>that represents the size (rows and cols) of the matrix.</li>
  <li>Next you should read rows number of newline separated lines of 8-bit characters.
  Your program should find and print the longest adjacent sequence (diagonals are not counted as adjacent fields),
  and print to the standard output the number.
  NOTE: in case of several sequences with the same length – simply print their equal length.</li>
  </ul>
  <blockquote>
  <p>test_1<br />
  Provided input:<br />
  3 3<br />
  R R B<br />
  G G R<br />
  R B G<br />
  Expected Output:<br />
  2</p>
  </blockquote>
  <blockquote>
  <p>test_2<br />
  Provided input:<br />
  4 4<br />
  R R R G<br />
  G B R G<br />
  R G G G<br />
  G G B B<br />
  Expected Output:<br />
  7</p>
  </blockquote>
  <blockquote>
  <p>test_3<br />
  Provided input:<br />
  6 6<br />
  R R B B B B<br />
  B R B B G B<br />
  B G G B R B<br />
  B B R B G B<br />
  R B R B R B<br />
  R B B B G B<br />
  Expected Output:
  22</p>
  </blockquote>
  <blockquote>
  <p>test_4<br />
  Provided input:<br />
  1000 1000<br />
  1000 rows of 1000 R’s<br />
  Expected Output:<br />
  1000000</p>
  </blockquote>
  <ol start="2">
  <li>Your program entry point should accepted from one to four additional parameters.
  Those parameters will indicate the names of the test cases that your program should run.</li>
  </ol>
  <p>• Example 1: ./myprogram test_1 test_3</p>
  <p>• Example 2: ./myprogram test_1 test_2 test_3 test_4</p>
  <p>• you can assume that the input from the user will be correct (no validation is required)</p>
  <pre class="lang-py prettyprint-override"><code>import numpy as np
  
  a = int(input(&quot;Enter rows: &quot;))
  b = int(input(&quot;Enter columns: &quot;))
  rgb = [&quot;R&quot;, &quot;G&quot;, &quot;B&quot;]
  T = [[0 for col in range(b)] for row in range(a)]
  
  for row in range(a):
      for col in range(b):
          T[row][col] = np.random.choice(rgb)
  
  for r in T:
      for c in r:
          print(c, end=&quot; &quot;)
      print()
  
  def solution(t):
      rows: int = len(t)
      cols: int = len(t[0])
      longest = np.empty((rows, cols))
      longest_sean = 1
  
      for i in range(rows - 1, -1, -1):
          for j in range(cols - 1, -1, -1):
              target = t[i][j]
  
              current = 1
  
              for ii in range(i, rows):
                  for jj in range(j, cols):
                      length = 1
                      if target == t[ii][jj]:
                          length += longest[ii][jj]
                      current = max(current, length)
  
              longest[i][j] = current
              longest_sean = max(current, longest_sean)
  
      return longest_sean
  
  print(solution(T))
  </code></pre>