First of all I’d say that this is a great book, and totally different from what I’ve read so far in other books. I read A Very Old Man With Enormous Wings a few years ago and had some idea what ‘Magic Realism’ means, so whatever the strange things that happened in this book, be it ghosts, flying carpet, etc, I considered them exactly as the inhabitants of the story considered: normal.
Welcome to day 11 of advent of code where will be helping Santa to create secure passwords. We have already been given how to create new passwords but there is a new security guy who has come up with three new requirements to make the passwords more secure. So let’s start by tackling these three requirements. We are essentially trying to check the password for three conditions and it can easily be done by using pattern matching by regular expressions.
Part 1: The code is pretty simple if we go ahead with using recursion. I started with an iterative solution but quickly realised I am dealing with a list of numbers, going through the numbers one at a time. This is the prerequisite of solving a recursive problem. The Recursive Solution: The condition is that the input string will have at least one number, otherwise it won’t make any sense. Though we are not dealing with erroneous input here.
I have recently started with Paradigms of Artificial Intelligence Programming in order to learn Common-Lisp. I did use it for the AI course that I had in college. The course was mostly a joke, with just a few low-level algorithms being covered (and these too were taught in Prolog), but getting some information about AI I came across Lisp and read through Paul Graham’s excellent book ANSI Common Lisp. Although I didn’t get much chance to use Lisp anywhere else after that, the book and its exercises made me understand recursion at the very basic and grand level.
I have been using magit for some time at a more superficial level. From what I can see, it is remarkable; at least I don’t have to type a lot of git commands. Command line is cool and everything, but typing a command again and again will waste the time and just might start a pain in your hand. Since most of my coding happens in emacs, I am delighted that magit exists and makes common and most repetitive things only a matter of few keystrokes.
I hope what I am writing here makes sense, but I believe – from whatever life experience that I have – that an overly technical brain is somewhat good for the professional life, but is not so good when it comes to understanding the world surrounding us. And the world includes everything from not so living things to most of the living things (e.g. people). Somewhat good for the professional life, because no matter in which profession you are in, the limits of understanding the field is almost impossible, which is a good thing because that means a lot of development might happen in that area, and this is good for everyone.
Part 1: This part took the most time till now. It presents the user with a small DSL which has to be solved because little Bobby Tables cannot solve it. My first thought was to solve it by Algebraic Data Types since the operations and data are essentially recursive and pattern matching would have helped here too. But instead of jumping from one language to another, I decided to go ahead with C# right now.
Events in CSharp Events in C# follow the pub-sub model where the publisher class holds a list of subscribers which let the publisher know that they are waiting for something interesting to happen and the publisher should make them aware if the interesting thing does happen. Event handling in C# requires one to understand delegates: which are boxes which can hold methods of a particular shape and can call them at runtime.
DFS (Depth First Search) helps in finding the connected nodes in a graph. By connected, we mean two nodes which can be reached by following a set of edges. This makes sense in both directed and undirected graph – in directed graph, there’s only one way of moving along the edge, but in the undirected graph we can move both forward and backwards along the edge. In simpler terms, we would want to start at a given node, follow along a path until we reach a deadend, and then move backtrack until we reach a new unvisited node, choose it and start moving along its path.
What is a for comprehension? Just like imperative programming languages, Scala provides a for-loop, but the similarities end there. Primarily it is used for iterating collections, and to extract items out of them. The benefit of for is that its clear and concise. Taking the example of creating a list of all the indices of a matrix, we will do something like this in Scala: 1 2 3 4 5 6 def indices(row: Int, col: Int) = (0 until row).