A deep dive into flattening an iterator of iterators and a segue into set theory and some of its theorems based on the solutions to this problem, inspired by a coding interview question.


Generating All Balanced Parentheses: A Deep Dive Into An Interview Question
A deep dive into the generation of balanced parentheses, inspired by a coding interview question.

A Review of Basic Algorithms and Data Structures in Python  Part 1: Graph Algorithms
A quick review of basic graph algorithms and related data structures, with minimal implementations and unit tests provided in Python.

The Infinite In Haskell and Python
Exploring the use of coroutines and lazy evaluation to generate infinite structures in Haskell and Python.
Tags: 
Understanding Recurrence Relations Using Automata, Python Code, And Javascript Visualizations
Recurrence relations are very often taught in first or secondyear computer science and discrete mathematics courses. This post takes a somewhat different and more visual approach to understanding linear recurrences and solving them by drawing the link between linear recurrences, automata, and matrices, using the problem of generating all dominotilings of a board as the springboard. Code in Python and visualizations in JavaScript are used to demonstrate the ideas.

Understanding SAT by Implementing a Simple SAT Solver in Python
SAT is often described as the "mother of all NPcomplete problems." This post goes over what SAT is and why it is considered to be so important. A simple SAT solver is implemented using Python in the process.
Tags: 
So How Do You Actually Calculate The Fibonacci Numbers?
You have seen it as an example a million times. But do you know how to do it efficiently?
Tags: 
Combinatorial Generation Using Coroutines With Examples in Python
Approaching combinatorial generation algorithms using coroutines, with examples in Python. Inspired by Knuth's work in his volume 4 of The Art of Computer Programming, as well as his "Deconstructing Coroutines" paper, cowritten with Frank Ruskey.

Multilinear Representation of Boolean Functions
Algorithm to compute the multilinear representation of a boolean function given its truth table.
Tags: 
Understanding TwoStep Verification With An Example Using Python and Google Authenticator
An introduction to twostep authentication, HOTP and TOTP algorithms, with an example in Python on Heroku using Flask and pyotp and the Google Authenticator app for clientside.
Tags: 
Line Intersecting Maximal Number of Circles (Circle "Stabbing" Problem)
Developing an algorithm to find a line that intersects a maximal number of circles, given a set of circles. Based on an ACM ICPC regional competition problem.

Expected Running Time of Two Randomized Sort Algorithms (ACM ICPC 2013 PACNW Regional)
Computing the expected running time of two randomized sort algorithms for a given input array. This problem appeared in ACM ICPC 2013 PACNW regional competition.

Pattern Matching in Fibonacci Words (ACM ICPC World Finals 2012)
A discussion of calculating the number of occurrences of a given pattern in Fibonacci words, with a Java solution. Problem from the 2012 ACM ICPC world finals.

Fibonacci Primitive Roots of Primes (Project Euler)
A problem on finding primes with Fibonacci primitive roots, from Project Euler and my Python solution.

Common Substring Permutation
Short post on a simple problem on common subsequence permutations with a neat oneline Python solution.
Tags: 
Visualizing the Convex Hull Using Raphaël
Visualizing a simple incremental convex hull algorithm using HTML5, JavaScript and Raphaël, and what I learned from doing so.

Basics of Cryptography Part I: RSA Encryption and Decryption
An introduction to RSA cryptography, with accompanying Python code implementing the basic algorithms used. A quick review of the number theory and group theory involved is given as well.

A Study of Python's More Advanced Features Part I: Iterators, Generators, itertools
A study of Python's iterators, generators and the itertools package, with ample (mostly) mathematical examples.
Tags: 
Interview Question: Fairness from Unfairness and Randomness Extraction
Interview question to use an unfair coin to simulate a fair one. The question is the same as extracting randomness from an unfair Bernoulli process. A Python implementation is given.

Interview Question: Grouping Words Into Anagrams
Simple Python solution to interview question to group words into anagrams.