3/2/2023 0 Comments Letter soup maker free![]() ''.join(s.split()) removes all whitespace from a string s, see this question.lower() puts the message in lowercase, so that 'Hello World' and hello world are equivalent, see the documentation > validate_soup('Hello World', 'abcloollhedwrdef') > validate_soup('Hello World', 'loollhedwr') > validate_soup('Hello World', 'loolhedwr') > validate_soup('Hello World', 'loollhedw') Return all(n > validate_soup('Hello World', 'loollhed') Soup_count = collections.Counter(soup_preprocessed) Msg_count = collections.Counter(msg_preprocessed) Soup_preprocessed = ''.join(soup.lower().split()) ![]() Msg_preprocessed = ''.join(msg.lower().split()) Here is a solution using collections.Counter, which is a subclass of dict. However, knowing how to use the modules of the standard library is a pretty useful skill. I assume your teacher expects you to write an algorithm for scratch on your own. Please use Big-O notation to explain how long it takes your function to run in terms of the length of your message (m) and the number of letters in your bowl of soup (s).īelow is the code I have tried but it is not working as per the task:- def sol(alpha): The function should return True or False accordingly. The function should determine if you can write your message with the letters found in your bowl of soup.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |