January 04, 2007

programming challenge one

It's the first week of a new year, and it's the sort of day that one feels like saying: I'm going to do X every week for the rest of the year. Then you realize that you likely don't really. But what the hell, let's give it a shot:

Weekly Programming Challenge

I'm going to gather ideas from a bunch of places, and then write up a challenge. The problems are language neutral, so maybe I'll try some in a few different languages, or different problems in different languages.

There are a few versions of "99 Lisp/Prolog/Whatever Programming Problems" floating around, and I'll take my inspiration for the first few from them.

Challenge One

Goldbach's conjecture states:

Every even integer greater than 2 can be written as the sum of two primes.

Write a function that, given a even integer greater than 2, returns a pair of primes that sums to the given integer.

Example: (in Perl)

my @result = goldbach( 6 );  # result 3, 3
my @result = goldbach( 10 ); # result 3, 7 -or- 5, 5 

Solutions:

First week, so I need to work out the plan. I'll post my solutions after at least 24 hours, but I'll just link to them without notes or solution details on this page. I'll link to anyone else's solution that requests it, you can also link to your solutions/etc. in comments. I'll defer posting comments that contain too much information until at least after the first 24 hours.

I'll always provide my solutions, but I'll stress that I make no suggestion at all that mine are good or completely correct. In particular, I'm planning on trying these problems in a variety of languages, some of which I am likely to suck at. (The only language I can reasonably claim to not suck in is Perl.)

My Solutions:

Other Solutions: