Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anagram2 function has a minor bug #12

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jnerin
Copy link

@jnerin jnerin commented Nov 19, 2018

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants