Last active
January 27, 2022 02:05
-
-
Save theptrk/0ffe3ba20f4b19f6f372c1ce9026b479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These are SP500 prices for practicing sliding window and array problems. | |
# Q: What date was the largest adjusted close price? | |
# Q: What was the longest period of open prices between $3000.00 and $4000.00? | |
# Q: What was the longest period of increasing open prices? | |
# Q: What is the most profitable period to buy at the open and sell at the close? | |
# Q: What is the highest average close price in any 6 month consecutive window of time? | |
headers = ["Date","Open","High","Low","Close","Adj Close"] | |
data = [ | |
["Jan 01, 2022","4,778.14","4,818.62","4,222.62","4,356.45","4,356.45"], | |
["Dec 01, 2021","4,602.82","4,808.93","4,495.12","4,766.18","4,766.18"], | |
["Oct 31, 2021","4,610.62","4,743.83","4,560.00","4,567.00","4,567.00"], | |
["Sep 30, 2021","4,317.16","4,608.08","4,278.94","4,605.38","4,605.38"], | |
["Aug 31, 2021","4,528.80","4,545.85","4,305.91","4,307.54","4,307.54"], | |
["Jul 31, 2021","4,406.86","4,537.36","4,367.73","4,522.68","4,522.68"], | |
["Jun 30, 2021","4,300.73","4,429.97","4,233.13","4,395.26","4,395.26"], | |
["May 31, 2021","4,216.52","4,302.43","4,164.40","4,297.50","4,297.50"], | |
["Apr 30, 2021","4,191.98","4,238.04","4,056.88","4,204.11","4,204.11"], | |
["Mar 31, 2021","3,992.78","4,218.78","3,992.78","4,181.17","4,181.17"], | |
["Mar 01, 2021","3,842.51","3,994.41","3,723.34","3,972.89","3,972.89"], | |
["Feb 01, 2021","3,731.17","3,950.43","3,725.62","3,811.15","3,811.15"], | |
["Jan 01, 2021","3,764.61","3,870.90","3,662.71","3,714.24","3,714.24"], | |
["Dec 01, 2020","3,645.87","3,760.20","3,633.40","3,756.07","3,756.07"], | |
["Oct 31, 2020","3,296.20","3,645.99","3,279.74","3,621.63","3,621.63"], | |
["Sep 30, 2020","3,385.87","3,549.85","3,233.94","3,269.96","3,269.96"], | |
["Aug 31, 2020","3,507.44","3,588.11","3,209.45","3,363.00","3,363.00"], | |
["Jul 31, 2020","3,288.26","3,514.77","3,284.53","3,500.31","3,500.31"], | |
["Jun 30, 2020","3,105.92","3,279.99","3,101.17","3,271.12","3,271.12"], | |
["May 31, 2020","3,038.78","3,233.13","2,965.66","3,100.29","3,100.29"], | |
["Apr 30, 2020","2,869.09","3,068.67","2,766.64","3,044.31","3,044.31"], | |
["Mar 31, 2020","2,498.08","2,954.86","2,447.49","2,912.43","2,912.43"], | |
["Mar 01, 2020","2,974.28","3,136.72","2,191.86","2,584.59","2,584.59"], | |
["Feb 01, 2020","3,235.66","3,393.52","2,855.84","2,954.22","2,954.22"], | |
["Jan 01, 2020","3,244.67","3,337.77","3,214.64","3,225.52","3,225.52"], | |
["Dec 01, 2019","3,143.85","3,247.93","3,070.33","3,230.78","3,230.78"], | |
["Oct 31, 2019","3,050.72","3,154.26","3,050.72","3,140.98","3,140.98"], | |
["Sep 30, 2019","2,983.69","3,050.10","2,855.94","3,037.56","3,037.56"], | |
["Aug 31, 2019","2,909.01","3,021.99","2,891.85","2,976.74","2,976.74"], | |
["Jul 31, 2019","2,980.32","3,013.59","2,822.12","2,926.46","2,926.46"], | |
["Jun 30, 2019","2,971.41","3,027.98","2,952.22","2,980.38","2,980.38"], | |
["May 31, 2019","2,751.53","2,964.15","2,728.81","2,941.76","2,941.76"], | |
["Apr 30, 2019","2,952.33","2,954.13","2,750.52","2,752.06","2,752.06"], | |
["Mar 31, 2019","2,848.63","2,949.52","2,848.63","2,945.83","2,945.83"], | |
["Mar 01, 2019","2,798.22","2,860.31","2,722.27","2,834.40","2,834.40"], | |
["Feb 01, 2019","2,702.32","2,813.49","2,681.83","2,784.49","2,784.49"], | |
["Jan 01, 2019","2,476.96","2,708.95","2,443.96","2,704.10","2,704.10"], | |
["Dec 01, 2018","2,790.50","2,800.18","2,346.58","2,506.85","2,506.85"], | |
["Oct 31, 2018","2,717.58","2,815.15","2,631.09","2,760.17","2,760.17"], | |
["Sep 30, 2018","2,926.29","2,939.86","2,603.54","2,711.74","2,711.74"], | |
["Aug 31, 2018","2,896.96","2,940.91","2,864.12","2,913.98","2,913.98"], | |
["Jul 31, 2018","2,821.17","2,916.50","2,796.34","2,901.52","2,901.52"], | |
["Jun 30, 2018","2,704.95","2,848.03","2,698.95","2,816.29","2,816.29"], | |
["May 31, 2018","2,718.70","2,791.47","2,691.99","2,718.37","2,718.37"], | |
["Apr 30, 2018","2,642.96","2,742.24","2,594.62","2,705.27","2,705.27"], | |
["Mar 31, 2018","2,633.45","2,717.49","2,553.80","2,648.05","2,648.05"], | |
["Mar 01, 2018","2,715.22","2,801.90","2,585.89","2,640.87","2,640.87"], | |
["Feb 01, 2018","2,816.45","2,835.96","2,532.69","2,713.83","2,713.83"], | |
["Jan 01, 2018","2,683.73","2,872.87","2,682.36","2,823.81","2,823.81"], | |
["Dec 01, 2017","2,645.10","2,694.97","2,605.52","2,673.61","2,673.61"], | |
["Oct 31, 2017","2,583.21","2,657.74","2,557.45","2,647.58","2,647.58"], | |
["Sep 30, 2017","2,521.20","2,582.98","2,520.40","2,575.26","2,575.26"], | |
["Aug 31, 2017","2,474.42","2,519.44","2,446.55","2,519.36","2,519.36"], | |
["Jul 31, 2017","2,477.10","2,490.87","2,417.35","2,471.65","2,471.65"], | |
["Jun 30, 2017","2,431.39","2,484.04","2,407.70","2,470.30","2,470.30"], | |
["May 31, 2017","2,415.65","2,453.82","2,405.70","2,423.41","2,423.41"], | |
["Apr 30, 2017","2,388.50","2,418.71","2,352.72","2,411.80","2,411.80"], | |
["Mar 31, 2017","2,362.34","2,398.16","2,328.95","2,384.20","2,384.20"], | |
["Mar 01, 2017","2,380.13","2,400.98","2,322.25","2,362.72","2,362.72"], | |
["Feb 01, 2017","2,285.59","2,371.54","2,271.65","2,363.64","2,363.64"], | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment