Working R-script for executing an optimized pancake flip algorithm.