Chess

Chess is a board game, with 8×8 tiles and some figures on them. It’s a turn-based game, usually played by two players (or one, for practicing), and the players move these figures according to certain rules. The winner is whoever gets first to the other person’s King (a special figure). If you want to further learn the basics of it, this is a good introductory read.

Simple, right? In this post I’ll explain why I like chess and how I got obsessed with it lately 🙂

Continue reading “Chess”

Re-inventing the Monad wheel

Lately, I spent some time working on one of my Haskell projects: hoare-imp. It is basically an implementation of propositional calculus+first-order logic+number theory (Peano)+Hoare logic, and allows one to reason about computer programs, producing Hoare triples. The source code of this implementation is at around 600 LoC at this moment.

I will explain how I re-implemented a monad, and even used it without knowing about it. And I am sure you have done the same, at some point, too!

Continue reading “Re-inventing the Monad wheel”

Algorithmic puzzle: Continuous Increasing Subsequences

In this blog post, we’ll tackle the following puzzle:

Given an array of integers, count the number of continuous subsequences, such that elements of every subsequence are arranged in strictly increasing order.

The optimal solution to this puzzle is to use the dynamic programming (DP) technique. But, in order to apply this technique, we first need to express the solution through a recurrent formula. So, I will start first by expressing it in Haskell, and then translate the implementation to PHP.

Continue reading “Algorithmic puzzle: Continuous Increasing Subsequences”