Merge pull request #66 from donnemartin/develop

Polish insertion sort challenge and solution
This commit is contained in:
Donne Martin 2016-06-18 22:16:11 -04:00 committed by GitHub
commit 31359896a8
2 changed files with 7 additions and 3 deletions

View File

@ -35,6 +35,8 @@
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"* Is a naiive solution sufficient?\n", "* Is a naiive solution sufficient?\n",
" * Yes\n",
"* Are duplicates allowed?\n",
" * Yes" " * Yes"
] ]
}, },
@ -163,7 +165,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.5.0"
} }
}, },
"nbformat": 4, "nbformat": 4,

View File

@ -34,6 +34,8 @@
"## Constraints\n", "## Constraints\n",
"\n", "\n",
"* Is a naiive solution sufficient?\n", "* Is a naiive solution sufficient?\n",
" * Yes\n",
"* Are duplicates allowed?\n",
" * Yes" " * Yes"
] ]
}, },
@ -89,7 +91,7 @@
" if data is None or len(data) < 2:\n", " if data is None or len(data) < 2:\n",
" return\n", " return\n",
" for r in range(1, len(data)):\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", " if data[l] > data[r]:\n",
" temp = data[r]\n", " temp = data[r]\n",
" data[l+1:r+1] = data[l:r]\n", " data[l+1:r+1] = data[l:r]\n",
@ -200,7 +202,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.4.3" "version": "3.5.0"
} }
}, },
"nbformat": 4, "nbformat": 4,