Problem 2262. GJam 2011 Africa Qualifier B: Optimum Profit
This Challenge is derived from GJam 2011 Africa: Investing at the Market. Google Code Jam 2014 Kicks Off its Qualifier round April 11. GJam Registration. The Test Suite, at the bottom, contains a full GJam file input read (fgetl and dlmread), process, and Output example.
Determine the single optimal Buy and Sell time to optimize Profit.
If multiple cases exist then provide set with minimum Buy cost.
Investment buys are made in whole units. If no profit is possible return [0 0 0].
Input: M,x Where M is Investment and x,size(1,12), is Commodity Buy/Sell Price
Output: BSP, [BuyPt SellPt Profit]
Example: M=100; x=[52 50 25 100 61 63 70 51 71 55 10 5];
Output: 3 4 300
Additional GJam solutions can be found at Example GJam Matlab solutions. Select Find Solutions, change Language to Matlab. There were only 50 Qualifier Matlab entrants in 2013 and a mere 2 Matlab users achieved round 2.
Solution Stats
Problem Comments
-
1 Comment
Rafael S.T. Vieira
on 20 Sep 2020
Again a better description for this problem is needed. Found it a at a blog. https://titanwolf.org/Network/Articles/Article?AID=47afa1e5-84c0-4745-b143-9cf7cb8c2030#gsc.tab=0 Basically, we have some money to buy stocks and a vector with the forecast of a stock price for the upcoming months. We must decide when to buy and later sell this stock to obtain the greatest profit (if possible), but this operation can only be done once. In this problem the author also wants the position for buying and selling (smallest buying price if more than one possibility exists).
Solution Comments
Show commentsProblem Recent Solvers14
Suggested Problems
-
2502 Solvers
-
648 Solvers
-
178 Solvers
-
93 Solvers
-
Vectorize the digits of an Integer
321 Solvers
More from this Author308
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!