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

str_diff challenge failing tests when returning expected result #301

Closed
andar1an opened this issue May 11, 2022 · 3 comments
Closed

str_diff challenge failing tests when returning expected result #301

andar1an opened this issue May 11, 2022 · 3 comments

Comments

@andar1an
Copy link

andar1an commented May 11, 2022

My initial attempt to solve this challenge is below:

from collections import Counter

class Solution(object):

    def find_diff(self, str1, str2):
      if str1 is None or str2 is None:
        return TypeError("Strings were not provided")
      c1 = Counter(str1)
      c2 = Counter(str2)
      if len(c1) > len(c2):
        for item in c1.items():
          if item not in c2.items():
            return item[0]
      else:
        for item in c2.items():
          if item not in c1.items():
            return item[0]

If I manually create the class and test the method I get the correct response for the following assertions (they fail in test cell - not sure why yet):

        self.assertEqual(solution.find_diff_xor('ab', 'aab'), 'a')
        self.assertEqual(solution.find_diff_xor('aab', 'ab'), 'a')
        self.assertEqual(solution.find_diff_xor('abcd', 'abcde'), 'e')
        self.assertEqual(solution.find_diff_xor('aaabbcdd', 'abdbacade'), 'e')

A few examples of return values:
image
image

@andar1an
Copy link
Author

I realized assertion was looking for another method, my mistake.

@KrakenDev0001
Copy link

Was this because of the find_diff_xor method? I noticed it never mentioned it in the challenge overview, but it still checked for it. I deleted it because there also wasn't a placeholder in the code block for it, so I'm assuming it was kept in by mistake? I just cloned the repo, so I'm trying to make sure I didn't do the challenge wrong.

@andar1an
Copy link
Author

I honestly don't remember this, sorry.

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

No branches or pull requests

2 participants