Your question is Reverse Words and Check Anagrams. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
For a text-processing utility used in Alten Calsoft Labs tooling, implement one function that performs two independent string operations. First, reverse the order of words in a sentence. Second, determine whether two strings are anagrams.
A word is any maximal sequence of non-whitespace characters. Preserve each word's characters exactly, collapse consecutive whitespace between output words, and return an empty string for input containing only whitespace. For the anagram check, comparison is case-insensitive and ignores every character that is not an ASCII letter or digit.
Implement analyze_strings(s1, s2). It receives two strings and returns a dictionary with:
reversed: the words of s1 in reverse order, joined by one space.anagram: a Boolean indicating whether normalized s1 and s2 contain the same letters and digits with the same frequencies.The word reversal and anagram check must be computed independently. Do not use sorting for the primary solution.
def analyze_strings(s1, s2):