Skip to content

Latest commit

 

History

History

stock_picker

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Project: Stock Picker

From The Odin Project

Implement a method #stock_picker that takes in an array of stock prices, one for each hypothetical day. It should return a pair of days representing the best day to buy and the best day to sell. Days start at 0.

Usage

Use the following command to run the application

  • from the root folder:
ruby stock_picker/stock_picker.rb 

OR

  • from inside the stock_picker folder
ruby stock_picker.rb

Examples

For the following stocks: 17, 3, 6, 9, 15, 8, 6, 1, 10
Pick [1, 4] - for a profit of $15 - $3 = $12

For the following stocks: 32, 76, 22, 55, 22, 2, 34, 1
Pick [0, 1] - for a profit of $76 - $32 = $44

For the following stocks: 33, 23, 1, 2, 7, 8, 24, 2, 4
Pick [2, 6] - for a profit of $24 - $1 = $23