From 49f937f16f99fb5d21ee3551d2defe65396cb71e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jorge=20Ner=C3=ADn?= Date: Mon, 19 Nov 2018 21:53:06 +0000 Subject: [PATCH] anagram2 function has a minor bug Due to how the checks are made it's not exposed, but it's not following the logic. Walking though the s2 string is supposed to subtract the letters from the dict, if the letter is not on the dict we should set the value to -1 not 1. See the values on the dict at the end of a run of anagram2('dogbb','godbbcc') whithout fixing: d 0 o 0 g 0 b 0 c 0 With the fix: d 0 o 0 g 0 b 0 c -2 Due to the check returning False if len s1 != s2 this bug does not make the whole def fail, but I think it should be fixed with the proper logic. --- .../Anagram Check - SOLUTION.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Array Sequences/Array Sequences Interview Questions/Array Sequence Interview Questions - SOLUTIONS/Anagram Check - SOLUTION.ipynb b/Array Sequences/Array Sequences Interview Questions/Array Sequence Interview Questions - SOLUTIONS/Anagram Check - SOLUTION.ipynb index 91e7d3d2..8d69fa03 100644 --- a/Array Sequences/Array Sequences Interview Questions/Array Sequence Interview Questions - SOLUTIONS/Anagram Check - SOLUTION.ipynb +++ b/Array Sequences/Array Sequences Interview Questions/Array Sequence Interview Questions - SOLUTIONS/Anagram Check - SOLUTION.ipynb @@ -141,7 +141,7 @@ " if letter in count:\n", " count[letter] -= 1\n", " else:\n", - " count[letter] = 1\n", + " count[letter] = -1\n", " \n", " # Check that all counts are 0\n", " for k in count:\n",