mirror of
https://github.com/donnemartin/interactive-coding-challenges
synced 2026-01-08 02:18:03 +00:00
Fixed Python2 vs Python3 division compatibility.
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"## Constraints\n",
|
"## Constraints\n",
|
||||||
"\n",
|
"\n",
|
||||||
|
|
||||||
"* Is a single character or number a palindrome?\n",
|
"* Is a single character or number a palindrome?\n",
|
||||||
" * No\n",
|
" * No\n",
|
||||||
"* Can we assume we already have a linked list class that can be used for this problem?\n",
|
"* Can we assume we already have a linked list class that can be used for this problem?\n",
|
||||||
@@ -100,6 +99,9 @@
|
|||||||
},
|
},
|
||||||
"outputs": [],
|
"outputs": [],
|
||||||
"source": [
|
"source": [
|
||||||
|
"from __future__ import division\n",
|
||||||
|
"\n",
|
||||||
|
"\n",
|
||||||
"class MyLinkedList(LinkedList):\n",
|
"class MyLinkedList(LinkedList):\n",
|
||||||
" \n",
|
" \n",
|
||||||
" def is_palindrome(self):\n",
|
" def is_palindrome(self):\n",
|
||||||
@@ -117,7 +119,7 @@
|
|||||||
" \n",
|
" \n",
|
||||||
" # Compare the reversed list with the original list\n",
|
" # Compare the reversed list with the original list\n",
|
||||||
" # Only need to compare the first half \n",
|
" # Only need to compare the first half \n",
|
||||||
" iterations_to_compare_half = length / 2\n",
|
" iterations_to_compare_half = length // 2\n",
|
||||||
" curr = self.head\n",
|
" curr = self.head\n",
|
||||||
" curr_reversed = reversed_list.head\n",
|
" curr_reversed = reversed_list.head\n",
|
||||||
" for _ in range(0, iterations_to_compare_half):\n",
|
" for _ in range(0, iterations_to_compare_half):\n",
|
||||||
|
|||||||
Reference in New Issue
Block a user