2024 Sep OPPE 2 - Set 2¶
Check If a Number Divides Two Others
Return True if c divides both a and b. Covers the modulo divisibility test, short-circuit and, and all() for extensibility.
Check String Rotation
Return True if one string is a rotation of another. Covers the classic str2 in str1+str1 trick and why the length check is mandatory.
Find Missing Number in a Range
Find the single missing number from a list of 1 to n. Covers set difference, the sum formula, and why set difference handles duplicates correctly.
SolvedMerge Dictionaries - Sum on Conflicts
Merge two dicts, summing values for shared keys. Covers dict.get(key, 0), shallow copy, key-view union d1.keys() | d2.keys(), and Counter addition.
Most Frequent Numbers
Print all numbers tied for the highest frequency, sorted ascending. Full I/O - covers frequency counting, max(freq.values()), and print(list) for bracket notation.
Employee Data Analysis
Four functions - salary filter, department total, ceiling to 500s, max salary after increment. Covers ceil_to_five_hundreds logic, increment order, and helper function reuse.
Reorder Jumbled Lines
Reorder file lines using new_pos-original_pos instructions on the last line. File I/O → stdout - covers lines[:-1], sorting pairs by new position, and 1-to-0 index conversion.