While there a solution is clever, it’s not terribly maintainable and likely didn’t fit the bill.
Beyond that, things like soft skills matter for senior roles. The author can write, there’s no denying that, but we don’t know how well they can explain the why of their solution. It’s very likely the interviewers wanted more traditional functions that were unit-testable.