mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-06 17:38:02 +00:00
Fixed Python2 vs Python3 division compatibility.
This commit is contained in:
@@ -34,7 +34,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Is a naiive solution sufficient (ie not in-place)?\n",
|
"* Is a naiive solution sufficient (ie not in-place)?\n",
|
||||||
" * Yes"
|
" * Yes"
|
||||||
]
|
]
|
||||||
@@ -88,12 +87,14 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
"from __future__ import division\n",
|
||||||
|
"\n",
|
||||||
"def quick_sort(data):\n",
|
"def quick_sort(data):\n",
|
||||||
" if len(data) < 2:\n",
|
" if len(data) < 2:\n",
|
||||||
" return data\n",
|
" return data\n",
|
||||||
" left = []\n",
|
" left = []\n",
|
||||||
" right = []\n",
|
" right = []\n",
|
||||||
" pivot_index = len(data) / 2\n",
|
" pivot_index = int(len(data) / 2)\n",
|
||||||
" pivot_value = data[pivot_index]\n",
|
" pivot_value = data[pivot_index]\n",
|
||||||
" \n",
|
" \n",
|
||||||
" # Build the left and right partitions\n",
|
" # Build the left and right partitions\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user