GithubHelp home page GithubHelp logo

brandondionisio / informed-search-pancake-sorting Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

Implementations of a A* search algorithm and an Uninformed Cost Search (UCS) algorithm to solve the Pancake Sorting Problem -- that is, order a disordered stack of different sized pancakes by flipping all pancakes above a certain depth.

Python 100.00%
a-star pancake-sorting uninformed-search python

informed-search-pancake-sorting's Introduction

Informed-Search-Pancake-Sorting

Implementations of a A* search algorithm and a Uninformed Cost Search (UCS) algorithm to solve the Pancake Sorting Problem -- that is, order a disordered stack of different sized pancakes by flipping all pancakes above a certain depth.

Title

CS 131 HW 02 - The Pancake Problem

Author

Brandon Dionisio

Problem Description

A messy cook has a disordered stack of 10 differently sized pancakes [size from 1 to 10] and a spatula that can be inserted at any point in the stack and used to flip all pancakes above it. The goal is for the cook to have them in the “correct” order for the customer, that is, the large on the bottom up to the smallest on top ([10, 9, 8, 7, 6, 5, 4, 3, 2, 1]).

Acknowledgements

stackoverflow

CS 131 Canvas Slides

CS 131 Piazza

docs.python.org

Running The Program

To run the A* search algorithm, use "python astar.py"

To run the UCS search algorithm, use "python ucs.py"

User Inputs

When running the program, users will be prompted to enter their pancake stack or type 'r'.
Pancake stacks must be consecutive integers with the largest of the integers being the last number.

"42135" is a valid input
"7564348" is a valid input
"5" is a valid input
"32154" is an invalid input
"3 2 1 4" is an invalid input
"4215" is an invalid input

Typing 'r' will initialize the pancake stack as a randomly sorted 10-length pancake stack.

Assumptions

Keeps requesting input until user provides valid input
Plate is on the right of the stack array
A* Search utilizes the total of the forward and backward cost functions UCS utilizes the backward cost only

Forward Cost Function (Heuristic Function)

Number of stack positions for which the pancake at that position is not of adjacent size to the pancake below

Backward Cost Function

Total number of pancakes flipped to get to current position

informed-search-pancake-sorting's People

Contributors

brandondionisio avatar

Watchers

 avatar

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.