Triangle Trilemma

Four points, a square?) and comes originally from a Google Code Jam problem. The problem is stated simply enough

Accept three points as input, determine if they form a triangle, and, if they do, classify it at equilateral (all three sides the same), isoceles (two sides the same, the other different), or scalene (all three sides different), and also classify it as acute (all three angles less than 90 degrees), obtuse (one angle greater than 90 degrees) or right (one angle equal 90 degrees).

But once you start implementing it, that’s when things get more interesting. 😄

read more...


Four points, a square?

Another post from Programming Praxis. This one was originally intended for Friday but they posted it early, so I figured I would go ahead and do the same. The problem is actually deceptively straight forward:

Given four points, do they form a square?

read more...


Happy New Year

Yesterday’s post from Programming Praxis asks us to build a very special sort of expression. Using the numbers 10, 9, 8, 7, 6, 5, 4, 3, 2, and 1 in that order along with the operators of multiplication, division, addition, subtraction, and concatenation, find all of the ways that we can write an expression totaling 2013. Here’s one valid solution:

109 - 8 * 7 + 654 * 3 - 2 / 1 = 2013

read more...


Parallel BF

Getting a bit close to the deadline, but I think I have something that’s pretty interesting. Basically, it’s the same BF interpreter that I wrote about yesterday with four additional commands:

&Spawn a new thread; set the current cell to 0 in the parent and 1 in the child
~Kill the current thread
!Send a ping on the channel specified by the current cell
?Wait for a ping on the channel specified by the current cell

read more...


A Brainf**k Interpreter

The PLT Games website has a competition going where each month there will be some sort of theme for a completely new program. The first theme is a Turing Tarpit–a language that is technically Turing complete and thus can do anything any other Turing complete language can, but is so minimal as to make doing anything worthwhile overly difficult.

  1. Beware of the Turing tar-pit in which everything is possible but nothing of interest is easy. – Alan Perlis, Epigrams on Programming

To that end, I’ve been working on a little something special which I may or may not finish by the end of the month (yes, I know that’s tomorrow). But while I was working on it, I put together a Brainf**k (BF) interpreter which I found pretty interesting to play with.

read more...


Nested Primes

Yesterday’s post from Programming Praxis poses an interesting problem: find the largest prime n such that the result of repeatedly removing each digit of n from left to right is also always prime.

For example, 6317 would be such a number, as not only is it prime, but so are 317, 17, and 7.

read more...