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