(6.1)
RD007's approach on this challenge. Enjoy!