You are the manager of an investment fund targeting the New York Stock Exchange. For your new high-frequency trading program you want to develop a strategy to find the most volatile stock on the market. You decide that this most volatile stock is the stock with the most number of islands in its data stream. Given a data stream formed of a sequence of integers a1, a2, a3, ... , an, an island in the sequence is a contiguous subsequence for which each element is strictly greater than the elements immediately before and after the subsequence (the before and after elements must exist!). In the examples below, each island in the sequence has a bracket below it. The bracket for an island contained within another island is below the bracket of the containing island. A graphical representation has been provided below
The input a set of facts of the form stock(Company,List), where List is a sequence of non-negative number for the stock ticker prices. A sample of the input is given below.
stock(vandelayIndustries, [0, 0, 1, 1, 2, 2, 1, 1, 0, 1, 2, 0]). % 4 ISLANDS stock(kramerica, [0, 1, 2, 4, 3, 1, 3, 4, 5, 2, 1, 0]). % 8 ISLANDS stock(sunshineCarpetCleaners, [0, 1, 2, 4, 4, 1, 0, 2, 4, 1, 0, 0]). % 6 ISLANDS stock(tylerChicken, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]). % 10 ISLANDS stock(wolfieNet, [10, 1, 2, 4, 4, 1, 10, 2, 4, 100]). % 3 ISLANDS |
The output format should be in the form short_position(CompanyName, NumberOfIslands). For example: short_position(tylerChicken, 10).
stock(vandelayIndustries, [0, 0, 1, 1, 2, 2, 1, 1, 0, 1, 2, 0]). stock(kramerica, [0, 1, 2, 4, 3, 1, 3, 4, 5, 2, 1, 0]). stock(sunshineCarpetCleaners, [0, 1, 2, 4, 4, 1, 0, 2, 4, 1, 0, 0]). stock(tylerChicken, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 0]). |
short_position(tylerChicken, 10). |
stock(newsSeeker, [6, 11, 14, 8, 7, 10, 14, 4, 5, 10, 15, 8, 3, 4, 5]). % 10
stock(nycSystems, [9, 13, 15, 16, 1, 19, 4, 6, 4, 7, 14, 10, 4, 14, 11]). % 9 stock(gammaMix, [13, 10, 17, 4, 9, 9, 2, 4, 8, 10, 15, 4, 19, 10, 16]). % 6 stock(systemsInternational, [15, 4, 19, 8, 14, 4, 7, 9, 17, 13, 17, 6, 10, 15, 4]). % 11 stock(streamer, [4, 6, 17, 6, 6, 16, 16, 19, 4, 5, 0, 8, 4, 5, 16]). % 6 |
short_position(systemsInternational, 11). |
stock(mainLightyear, [15, 9, 12, 14, 0, 0, 17, 10, 12, 19, 0, 14, 19, 5, 5]). % 8
stock(flyingBluescreen, [11, 19, 6, 8, 5, 3, 8, 19, 8, 11, 14, 11, 16, 17, 19]). % 4 stock(bluePatrol, [3, 2, 13, 2, 4, 11, 15, 8, 18, 0, 9, 15, 10, 14, 14]). % 7 stock(flyingWorldwide, [15, 17, 16, 13, 12, 7, 14, 14, 13, 9, 5, 9, 15, 5, 7]). % 7 stock(ujamiSystems, [5, 4, 8, 9, 10, 5, 6, 10, 9, 11, 2, 7, 11, 14, 3]). % 11 |
short_position(ujamiSystems, 11). |
stock(selectServices, [19, 12, 4, 19, 4, 18, 12, 11, 7, 10, 16, 16, 4, 18, 7]). % 8
stock(greenServices, [19, 9, 13, 4, 0, 18, 1, 5, 12, 9, 12, 3, 7, 8, 18]). % 6 stock(leonardoServices, [2, 12, 19, 17, 7, 12, 17, 10, 1, 18, 17, 15, 1, 15, 3]). % 11 stock(mainGoServices, [0, 4, 13, 18, 8, 11, 12, 12, 1, 3, 14, 8, 12, 7, 13]). % 9 stock(systemWorks, [7, 0, 6, 5, 1, 4, 9, 16, 11, 18, 9, 16, 12, 15, 13]). % 7 |
short_position(leonardoServices, 11). |
stock(areaServices, [14, 13, 19, 10, 16, 0, 17, 8, 12, 12, 10, 6, 0, 1, 13]). % 7
stock(flashpointInc, [6, 11, 5, 10, 0, 10, 16, 18, 15, 18, 6, 16, 16, 4, 15]). % 9 stock(jayhawk, [8, 19, 5, 1, 14, 16, 10, 11, 18, 15, 0, 2, 1, 6, 13]). % 8 stock(aircushionInc, [1, 3, 16, 16, 11, 3, 13, 3, 17, 0, 11, 15, 1, 5, 0]). % 9 stock(lumoInc, [16, 3, 2, 9, 7, 8, 14, 10, 3, 8, 14, 9, 13, 5, 4]). % 10 |
short_position(lumoInc, 10). |
stock(silverSeaHarvest, [8, 10, 8, 16, 10, 0, 4, 16, 15, 8, 5, 10, 5, 15, 16]). % 7
stock(redInc, [13, 2, 8, 0, 1, 6, 3, 3, 7, 0, 2, 7, 15, 17, 19]). % 5 stock(mumboMix, [6, 1, 16, 10, 0, 1, 12, 7, 0, 4, 8, 16, 5, 19, 7]). % 8 stock(liveTechnologies, [19, 12, 4, 18, 14, 8, 11, 11, 9, 16, 15, 17, 5, 0, 9]). % 9 stock(surveyInc, [7, 1, 7, 7, 5, 11, 0, 3, 16, 9, 7, 13, 7, 18, 15]). % 7 |
short_position(liveTechnologies, 9). |
stock(thinkSystems, [13, 19, 8, 6, 17, 0, 14, 1, 19, 1, 10, 14, 3, 7, 18]). % 6
stock(domaniInc, [0, 18, 19, 18, 19, 19, 9, 14, 15, 10, 19, 17, 0, 8, 12]). % 9 stock(goldIndustries, [6, 9, 1, 11, 18, 14, 18, 12, 19, 15, 19, 4, 16, 9, 2]). % 12 stock(juiceInc, [8, 17, 13, 19, 10, 15, 10, 0, 16, 19, 16, 2, 5, 5, 10]). % 7 stock(flameWorks, [17, 2, 10, 17, 12, 19, 6, 2, 4, 16, 5, 6, 6, 18, 14]). % 7 |
short_position(goldIndustries, 12). |