Skip to content

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.

Notifications You must be signed in to change notification settings

brandondionisio/Informed-Search-Pancake-Sorting

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages