Cooperative Mixin Pipeline & C3 MRO Verification
Difficulty: Hard · Unit 5: OOP, Iterators & Complexity · Featured in: Tough Challenge
Model a text-processing pipeline using cooperative multiple inheritance: Base `Processor` defines `process(text)` returning `text`. Mixins `StripMixin(Processor)`, `LowerMixin(Processor)`, `CollapseSpaceMixin(Processor)`, and `AlnumOnlyMixin(Processor)` each transform `text` and delegate via `super().process(...)` in C3 MRO order. Given a comma-separated list of mixin names and an input string, construct the dynamic subclass `type('Pipeline', (*mixins,), {})` and print both the MRO class names (up to `Processor`) and the transformed output. If C3 linearization fails (`TypeError`), print `MRO_CONFLICT`.
Input & Output Format
Input: Line 1: comma-separated mixin names (e.g. `StripMixin,LowerMixin`). Line 2: raw input text.
Output: Line 1: `MRO: <cls1> -> <cls2> -> ... -> Processor`. Line 2: processed text. Or `MRO_CONFLICT` on invalid hierarchy.
Sample 1
StripMixin,LowerMixin,CollapseSpaceMixin Hello WORLD
MRO: Pipeline -> StripMixin -> LowerMixin -> CollapseSpaceMixin -> Processor hello world
Each mixin passes its transformed text down super().process(text) until Processor returns it.
Free forever — sign in with email at poorvithmp.com to unlock the dry run, verified Python 3 solution, edge-case traps, and downloads.