X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=monotone-substrings%2Fsingle_substring_itertools.ipynb;h=1e0f20d00e3e8969b72f5a9056481f3801797e2a;hb=041a6ab60fde9a9c7c52e0aad9548e434c68f9a9;hp=80c2d2ac016fa2a4acaa5e97bbf8be379f41ede2;hpb=4be776e6aef6b347a2ee84820f5e658e517cf43a;p=ou-summer-of-code-2017.git diff --git a/monotone-substrings/single_substring_itertools.ipynb b/monotone-substrings/single_substring_itertools.ipynb index 80c2d2a..1e0f20d 100644 --- a/monotone-substrings/single_substring_itertools.ipynb +++ b/monotone-substrings/single_substring_itertools.ipynb @@ -1,5 +1,33 @@ { "cells": [ + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Monotone substrings\n", + "\n", + "Given a list of numbers, find the length of longest increasing or decreasing substring in the list.\n", + "\n", + "For instance, the sequence\n", + " 10, 1, 2, 3, 4, 5, 5, 5, 6, 4, 3, 5, 6\n", + "contains these increasing or decreasing substrings:\n", + "* 10, 1\n", + "* 1, 2, 3, 4, 5\n", + "* 5, 6\n", + "* 6, 4, 3\n", + "* 3, 5, 6\n", + "\n", + "As an extension, allow the substring to contain runs of identical numbers, each of which is included in the length of the longest substring.\n", + "\n", + "If identical numbers are allowed, the above sequence contains substrings:\n", + "* 10, 1\n", + "* 1, 2, 3, 4, 5, 5, 5, 6\n", + "* 6, 4, 3\n", + "* 3, 5, 6\n", + "\n", + "The list is given as a single line of comma-separated integers. " + ] + }, { "cell_type": "code", "execution_count": 1,