Skip to content
Comparison between BFS and DFS in solving several real-world puzzle problems.
Branch: master
Clone or download

Latest commit

Fetching latest commit…
Cannot retrieve the latest commit at this time.


Type Name Latest commit message Commit time
Failed to load latest commit information.


Comparison between BFS and DFS in solving several real-world puzzle problems.

Getting Started


  • Python 3.x
  • Terminal (in Unix) OR PowerShell (in Windows)

Download source code

# Change to HOME directory
$ cd ~

# Clone this repo and 'cd' into it
$ git clone
$ cd BFS-DFS-puzzle-solving/

Solving Sudoku

Sudoku         Sudoku solution
Image source:

$ python3

Solving Peg solitaire

Peg solitaire
Image source:

$ python3

Solving MN puzzle (15-puzzle)

Image source:

$ python3

Solving Word ladder

Word ladder         Word ladder solution
Image source:

$ python3


Name GitHub Email
Chenjie Ni jellycsc

Thoughts and future improvements

  • BFS and DFS are both uninformed search algorithms. BFS is capable of finding shortest path solution but it's not memory efficient. In contrast, DFS uses a lot less memory, but it's not guaranteed to find a solution if the depth of the search tree is infinite.
  • A* with clever heuristic will save your life.
  • Pacman in Stanford CS221

Contributing to this project

  1. Fork it GitHub forks
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -m 'Add some feature')
  4. Push to your feature branch (git push origin my-new-feature)
  5. Create a new Pull Request

Details are described here.

Bug Reporting GitHub issues

Please click issue button above↑ to report any issues related to this project
OR you can shoot an email to


This project is licensed under the MIT License - see LICENSE file for more details.

You can’t perform that action at this time.