From 321ff028879a18514b5c1a962448c3faf897a248 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Sat, 18 Jun 2016 22:15:48 -0400 Subject: [PATCH] Polish insertion sort challenge and solution Update constraints and code. --- .../insertion_sort/insertion_sort_challenge.ipynb | 4 +++- .../insertion_sort/insertion_sort_solution.ipynb | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sorting_searching/insertion_sort/insertion_sort_challenge.ipynb b/sorting_searching/insertion_sort/insertion_sort_challenge.ipynb index dce6097..3233054 100644 --- a/sorting_searching/insertion_sort/insertion_sort_challenge.ipynb +++ b/sorting_searching/insertion_sort/insertion_sort_challenge.ipynb @@ -35,6 +35,8 @@ "## Constraints\n", "\n", "* Is a naiive solution sufficient?\n", + " * Yes\n", + "* Are duplicates allowed?\n", " * Yes" ] }, @@ -163,7 +165,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4, diff --git a/sorting_searching/insertion_sort/insertion_sort_solution.ipynb b/sorting_searching/insertion_sort/insertion_sort_solution.ipynb index b78aebf..4530ae5 100644 --- a/sorting_searching/insertion_sort/insertion_sort_solution.ipynb +++ b/sorting_searching/insertion_sort/insertion_sort_solution.ipynb @@ -34,6 +34,8 @@ "## Constraints\n", "\n", "* Is a naiive solution sufficient?\n", + " * Yes\n", + "* Are duplicates allowed?\n", " * Yes" ] }, @@ -89,7 +91,7 @@ " if data is None or len(data) < 2:\n", " return\n", " for r in range(1, len(data)):\n", - " for l in range(0, r):\n", + " for l in range(r):\n", " if data[l] > data[r]:\n", " temp = data[r]\n", " data[l+1:r+1] = data[l:r]\n", @@ -200,7 +202,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.5.0" } }, "nbformat": 4,