mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-10 03:18:02 +00:00
Polish find loop start challenge and solution
Change slow and fast nodes equality check from their data value to an object check.
This commit is contained in:
@@ -186,21 +186,21 @@
|
|||||||
],
|
],
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"kernelspec": {
|
"kernelspec": {
|
||||||
"display_name": "Python 2",
|
"display_name": "Python 3",
|
||||||
"language": "python",
|
"language": "python",
|
||||||
"name": "python2"
|
"name": "python3"
|
||||||
},
|
},
|
||||||
"language_info": {
|
"language_info": {
|
||||||
"codemirror_mode": {
|
"codemirror_mode": {
|
||||||
"name": "ipython",
|
"name": "ipython",
|
||||||
"version": 2
|
"version": 3
|
||||||
},
|
},
|
||||||
"file_extension": ".py",
|
"file_extension": ".py",
|
||||||
"mimetype": "text/x-python",
|
"mimetype": "text/x-python",
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython2",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "2.7.10"
|
"version": "3.5.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|||||||
@@ -111,10 +111,10 @@
|
|||||||
" fast = fast.next.next\n",
|
" fast = fast.next.next\n",
|
||||||
" if fast is None:\n",
|
" if fast is None:\n",
|
||||||
" return None\n",
|
" return None\n",
|
||||||
" if slow.data == fast.data:\n",
|
" if slow == fast:\n",
|
||||||
" break\n",
|
" break\n",
|
||||||
" slow = self.head\n",
|
" slow = self.head\n",
|
||||||
" while slow.data != fast.data:\n",
|
" while slow != fast:\n",
|
||||||
" slow = slow.next\n",
|
" slow = slow.next\n",
|
||||||
" fast = fast.next\n",
|
" fast = fast.next\n",
|
||||||
" if fast is None:\n",
|
" if fast is None:\n",
|
||||||
@@ -238,7 +238,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,
|
||||||
|
|||||||
Reference in New Issue
Block a user