/pancake-sort

Pancake sorting is the colloquial term for the mathematical problem of sorting a disordered stack of pancakes in order of size when a spatula can be inserted at any point in the stack and used to flip all pancakes above it. A pancake number is the minimum number of flips required for a given number of pancakes.

Primary LanguageHTMLMIT LicenseMIT

Pancake Sort

Pancake sorting is the colloquial term for the mathematical problem of sorting a disordered stack of pancakes in order of size when a spatula can be inserted at any point in the stack and used to flip all pancakes above it. A pancake number is the minimum number of flips required for a given number of pancakes.

Demo

image

image

Features

  • Sorts a list of numbers
  • Responsive
  • Easy to use

Functions

  • pancakeSortFn(arr, n) - Sorts the list
  • findMax(arr, n) - Finds the maximum element in the list
  • flip(arr, i) - Flips the list