Skip to content

The code calculates the longest possible path of adjacent cells in a given Matrix

License

Notifications You must be signed in to change notification settings

issashu/Longest-path-C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Task given during C training in Code Academy Sofia:

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). You will be provided with 4 individual test cases, which must also be included in your solution.

  1. Individual test case input format:
  • First you should read two whitespace separated 32-bit integers from the provided test case
  • that represents the size (rows and cols) of the matrix.
  • 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.
  1. Your program entry point should accept from one to four additional parameters. Those parameters will indicate the names of the test cases that your program should run. • Example 1: ./myprogram test_1 test_3 • Example 2: ./myprogram test_1 test_2 test_3 test_4 • you can assume that the input from the user will be correct (no validation is required)

  2. You are free to choose a language for implementation between C and Python.

  3. If you provide a C solution: • Your program should not cause memory leaks. • You should also include a Makefile or use CMake tool to generate a Makefile. • Running the GNU make command on your Makefile should produce a binary. • Bonus points: ◦ provide also a GNU make clean command if you are writing the Makefile OR ◦ provide out-of-source build and build clean mechanism if you are using CMake ◦ provide valgrind report on your solution with modes “--leak-check=full --track-origins=yes”

About

The code calculates the longest possible path of adjacent cells in a given Matrix

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published