Best Time to Buy and Sell Stock, three ways

Try:
CALL
1 / 1

Code

The highlighted line runs next. The pill shows the live values in the running call.

Cost

Work done so far, and how the three solutions compare

Prices by day

The vertical bar is the profit of the trade being checked

Keyboard: ← → step, Space play or pause. 1 to 12 prices, whole numbers from 0 to 100. Buying and selling on the same day earns 0, which matches not trading.