Giter Club home page Giter Club logo

grimly's Introduction

grimly

Grimly is 42 Starfleet second project!!! In this project, you have to find the shortest path to solve a maze

How to test it

  1. Make (to compile it & make a executive file called grimly)
  2. ./grimly resources/01.map resources/02.map resources/03.map ... or ./grimly and write on the stdin or cat name_of_map | ./grimly

How it works

The algorithm uses BFS (Breadth-First Search)

Initially the algorithm reads the input and checks for errors. Errors in the maze considered are: All lines must respect the sizes given in the first line (LINExCOL).

■ There can only be one entrance. ∗ There must be at least one exit. ■ There must be a solution to the labyrinth. ■ The labyrinth will not be more than a billion square. ■ At the end of each line, there is a new line. ■ The characters present in the card must be only those shown on the first line.

The program starts from the entrance, and finds all adjacent "empty" spot, assigns a character in the spot as the realative direction of current spot (UP, DOWN, RIGHT, LEFT). Later, put it in the Queue. With the while loop, repeat this assignment until 1. there is no spot left or 2. find an exit. In the first case, there will be empty queue, and you program fail to find the exit, so return an error. In the second case, it will print_path from the exit_spot to entrance.

Note

  1. first time implementing queue data structure
  2. first time implementing doubly linked list
  3. first time using BFS Algorithm

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.