Quantcast
Browsing latest articles
Browse All 10 View Live

Generating random numbers

Have you ever wondered how deterministic machines like computers are able to make random choices? A computer program has to tell a computer exactly what to do at every stage; the computer cannot make...

View Article


An introduction to Turing machines

The story of how Alan Turing made important contributions to the allied war effort in World War II as part of a team cracking German codes, only to later end up being prosecuted for homosexual activity...

View Article


Reversing a linked list in place

The other day I finally realized how you reverse a linked list in place. I had attempted to tackle this problem several times before, and had always ended up looking up the answer online, copying and...

View Article

The difference between key-value containers and functions

I was wondering why all of the programming languages I know treat key-value containers (i.e. sequences and associative arrays) differently from functions. From mathematics, I’m used to thinking of...

View Article

Tricks in computer arithmetic

(This post is also available as a PDF, with better typesetting for the mathematical formulas and syntax highlighting for the code listings.) People who do a lot of mental arithmetic often make use of...

View Article


Programming languages as theorem verifiers

(This post is also available as a PDF). One of the most interesting ideas in modern logic is the Curry-Howard correspondence. This is the informal observation that, from a certain perspective,...

View Article

Dualities between depth-first search and breadth-first search

Something which I think is fairly well-known among programmers (I first learned it from reading Higher Order Perl) is that depth-first search and breadth-first search can be implemented in such a way...

View Article

Image may be NSFW.
Clik here to view.

Enumerating the ordered k-partitions of an integer

Given two integers and , where is non-negative, an ordered -partition of is a -tuple of positive integers such that For example, the ordered 3-partitions of 5 are , , , , , and . The problem I'm...

View Article


Implementing Python’s `cmp_to_key` function

Sorting functions in programming languages often take a parameter which allows the user to control how comparison is done when sorting. The most direct way to do this is to have the parameter be a...

View Article


Image may be NSFW.
Clik here to view.

The trajectory of a bouncing ball

You can also view this article at my Github Pages website (the formatting might be better there). Consider an idealized model of a ball bouncing on the ground, where the ball is falling along a line...

View Article
Browsing latest articles
Browse All 10 View Live