The most impressive part is buried in the comments:
this was a one-day coding challenge for me
Oh, and here’s my effort: