Last active
February 20, 2020 12:25
-
-
Save Levi-Lesches/90b42240a92110d88d5db02c88402e50 to your computer and use it in GitHub Desktop.
Simple stock market code
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
class Range { | |
final num buy, sell; | |
const Range(this.buy, this.sell); | |
} | |
Range maxProfit(List<double> points) { | |
// We want to find a range by examining a list of local minima and maxima | |
// We can assign a new list (think about what type it would hold) of those minima and maxima | |
// To find that list, we go through the list of points, two at a time, watching | |
// for changes in whether the points are increasing or decreasing. | |
// | |
// To find the best points to buy and sell, we can check every combination | |
// (in chronological order) of the local minima and maxima to maximize | |
// value. | |
double previousValue, nextValue; | |
for (final MapEntry<int, double> entry in points.asMap().entries) { | |
final int index = entry.key; | |
final double value = entry.value; | |
if (index != points.length - 1) { | |
// Assign nextValue here | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0 V L V ~(i <==> g)