I wrote a solution but was advised against posting complete solutions, as it tends to attract those who want only to pass a test without exercising skill. There's some loss of learning by example,...