Skip to content

Collection of some algorithms implemented in C. Goal is high performance.

Notifications You must be signed in to change notification settings

itssme/DoYouWantToCmyAlgorithms_

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DoYouWantToCmyAlgorithms?

Collection of some algorithms implemented in C.
Goal is high performance.

Implemented Algorithms:

  • Maze Generator (Recursive Backtracking)
  • Maze Solver

Maze generator:

Build

git clone https://github.com/itssme/DoYouWantToCmyAlgorithms_
cd DoYouWantToCmyAlgorithms_/mazeGeneration
mkdir build
cd build
cmake ..
make

Example

Go to the build directory and run:

>> ./generator 10 10

Will create a 10 by 10 field Maze and print:

###########
#...#.....#
###.# ###.#
#.#...#...#
#.#####.###
#.#...#...#
#.#.#.###.#
#...#.#...#
#.###.#.###
#...#.....#
###########

For bigger mazes pipe output into a file:

>> ./generator 10000000 50 > maze.txt  

If the definition BENCH is set at compile time, additional output with the time will be printed.

Look at the output like:

>> tail maze.txt 
#.#.#.#.###.#.#.#.#.#.#.#.#.###.#.#.#############.#
#.#.#.#.#...#.#.#.#...#.#.#.#.....#.............#.#
###.#.#.#.#.#.#.#.#####.#.#.#####.#############.#.#
#...#.#.#.#.#.#.#.....#.#.#.#...#.#.....#...#...#.#
#.#.###.#.###.#.#####.#.#.#.#.#.###.###.#.#.#.###.#
#.#.#...#...#...#...#.#.#.#.#.#.#...#.#...#.#.#...#
#.###.#####.#####.#.###.#.#.#.#.#.###.#####.#.#.#.#
#.................#.....#.#...#...........#.....#.#
###################################################
generated (10000000x50) maze in 6.848794 seconds

Maze solver:

This algorithm will solve a maze generated by the maze generator.

Build

git clone https://github.com/itssme/DoYouWantToCmyAlgorithms_
cd DoYouWantToCmyAlgorithms_/mazeSolver
mkdir build
cd build
cmake ..
make

Example

After generating a maze like ./generator 20 20 > maze.txt with the generator, go to the build directory and run:

>> ./solver 20 20 < maze.txt

to solve the maze. This will use ansi colors to print the maze, so make sure to use a terminal which supports those.

It is also possible to pipe the output to a text file and look at the result late:

>> ./solver 20 20 < maze.txt > solved.txt
>> cat solved.txt

About

Collection of some algorithms implemented in C. Goal is high performance.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published