From 5338e59a43dd0ef20386d4c17f541ddcb4bba063 Mon Sep 17 00:00:00 2001 From: Donne Martin Date: Mon, 6 Jul 2015 07:06:50 -0400 Subject: [PATCH] Fixed Python2 vs Python3 division compatibility. --- linked_lists/palindrome/palindrome_solution.ipynb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/linked_lists/palindrome/palindrome_solution.ipynb b/linked_lists/palindrome/palindrome_solution.ipynb index 93b53a3..199809b 100644 --- a/linked_lists/palindrome/palindrome_solution.ipynb +++ b/linked_lists/palindrome/palindrome_solution.ipynb @@ -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",