<filename>algorithm/string/making_anagrams/solution.py<gh_stars>1-10
#!/usr/bin/env python3
"""
Strings: Making Anagrams

:author: <NAME>
:hackerrank: https://hackerrank.com/delaanthonio
:problem: https://www.hackerrank.com/challenges/ctci-making-anagrams
"""

from collections import defaultdict


def make_anagram(a: str, b: str) -> int:
    counts = defaultdict(int)
    for char in a:
        counts[char] += 1
    for char in b:
        counts[char] -= 1
    return sum(abs(x) for x in counts.values())


def main():
    a = input()
    b = input()
    result = make_anagram(a, b)
    print(result)


if __name__ == '__main__':
    main()

<filename>algorithm/string/making_anagrams/solution.py<gh_stars>1-10
#!/usr/bin/env python3
"""
Strings: Making Anagrams

:author: <NAME>
:hackerrank: https://hackerrank.com/delaanthonio
:problem: https://www.hackerrank.com/challenges/ctci-making-anagrams
"""

from collections import defaultdict


def make_anagram(a: str, b: str) -> int:
    counts = defaultdict(int)
    for char in a:
        counts[char] += 1
    for char in b:
        counts[char] -= 1
    return sum(abs(x) for x in counts.values())


def main():
    a = input()
    b = input()
    result = make_anagram(a, b)
    print(result)


if __name__ == '__main__':
    main()

#!/usr/bin/env python3 Strings: Making Anagrams  :author: <NAME> :hackerrank: https://hackerrank.com/delaanthonio :problem: https://www.hackerrank.com/challenges/ctci-making-anagrams