Day 98: Coaching and 4Clojure 53
Continued coaching one of my regular students
Took Poppy (one of my cats) to the vets for a checkup. Apart from a some plaque build Poppy is fine. More toothpaste and teeth cleaning for Poppy.
Cycled into Wagamama Southbank for another coaching session, getting my teeth stuck into 4Clojure challenge #53, a tricky one eventually solved with partition and partition-by.
4Clojure solution
4Clojure #53¶
Ouch, exercise 53 was quite a tricky problem and very easy to get caught up in imperative thinking.
Trying to do this using loop/recur and reduce approach became very complex and we didnt get that working in the end.
I started a more functional approach along the right lines with partitioning up the data set so each combination of pairs could be compared to see if the second value was higher than the first.
After some experiementing I realised partition-by could use a function that grouped the pairs until the pairs stopped increasing.
This approach to partitioning put the data in to a shape that made it easier to process.
Redundant data was removed and then the remaining partiions sorted by size, using count to find the largest continuous sequence.
Then the resulting partitions needed to be flattened to get the right shape of data as a result.
4Clojure Challenge 53 - Partition and Filter
Design Journal - 4Clojure #53
Thank you.