Skip to content

ffavela/knight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Solves the knight's tour (see
https://en.wikipedia.org/wiki/Knight%27s_tour). Given a starting point
it looks for different solutions.

This is an old piece of code that I wrote while learning C (The "K&R"
was my bible at the time). And difficult to grasp concepts (at least to
me), such as pointers and recursivity, where used in the program.

To those unfamiliar with git, simply do a:

$ git clone https://github.com/ffavela/knight

In the terminal and you have just downloaded the code. You now do a:

$ cd knight/

To switch to the directory.

To compile simply do:

$ make

To run, starting from square 3,7:

$ ./knight 3 7
...
...
...[SAMPLE OUPUT]
  2 39 10 37  8  5 20 17
 11 36  1  4 21 18  7 44
 40  3 38  9  6 45 16 19
 35 12 41 54 15 22 43 46
 64 27 14 31 42 55 50 23
 13 34 61 26 53 58 47 56
 28 63 32 59 30 49 24 51
 33 60 29 62 25 52 57 48
124
...
...
...

To stop it just do a control C "CTRL-C".

If no arguments are given, the tour starts from square 1,1.

You can change the rectangle dimensions by modifying the headers.h file.
For example, if you want to make a 5x5 board, you alter the COLS and
rows variables de following way:

#define COLS 	5
#define ROWS	5

About

Simple program that solves the knight's tour.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published