{
"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,