The 4th edition of Advent Of Code just started! In this short blog post, I would like to share with you some of my thoughts about it and why I participate in this event for the second time in the row.
Groovy has many useful functions built-in, and one of them is
Iterable.combinations() that takes aggregated collections and finds all combinations of items. However, if we take a look its source code, we will find out that it was implemented using very imperative approach (nested for-loops + some if-statement). In this blog post I will show you how to implement the same function using Groovy and tail-recursion algorithm. Enjoy!
Some time ago I was interviewed to one of the Java-based projects and I was asked to solve this pretty interesting puzzle. The question was "how to count frequency of a digit in a factorial of number, let’s say 1000". I tried to solve it using Java 8 Stream API, but I guess you see how bad decision it was. Problems like that can be easily solved with pure functional languages and today we are going to find out how to solve this puzzle with Haskell.