Skip to content

Instantly share code, notes, and snippets.

@slapec
Created January 5, 2021 07:23
Show Gist options
  • Save slapec/4ef089873e742109482e663df4538c93 to your computer and use it in GitHub Desktop.
Save slapec/4ef089873e742109482e663df4538c93 to your computer and use it in GitHub Desktop.
import collections
def scramble(word, chars):
word_char_count = collections.Counter(word)
chars_char_count = collections.Counter(chars)
chars_char_count.subtract(word_char_count)
return all(chars_char_count[word_char] >= 0 for word_char in word_char_count.keys())
print(scramble('door', 'abcdeooor'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment