After reading the “coconut” problem over on my friend’s blog, I thought it would be fun to solve it with a silly brute force approach. First, go read his post and then come back here. let take n = let m = n – 1 // give one to the monkey if m…

# Year: 2009

## Towers of Hanoi

A friend of mine is starting a pretty fun looking math blog. His first post is on Towers of Hanoi. I’m sure he’ll tackle it with some slick mathematics, but my usual M.O. is to convert everything to code. I remember this “Hello Recursive World” from SICP in Scheme; looks better in F#: let rec hanoi…

## TinyRPN Calculator

It’s fun dorking around with the HP 41CX emulator on the iPhone. It’s a near-perfect rendition. I forgot how much I loved RPN calculators. The 48GX looks even more interesting with Reverse Polish Lisp but I haven’t figured out how to use it yet. The 41CX, on the other hand, is an old friend. 🙂…

## Favorite Talks

Talks Alan Kay’s TED talk about teaching children

## Favorite Posts

Tangible Functional Programming Conal Elliot talk: https://www.youtube.com/watch?v=faJ8N0giqzwTangible Values: http://haskell.org/haskellwiki/TV

## Favorite Quotes

“Beware of bugs in the above code; I have only proved it correct, not tried it.” – Donald Knuth “Language and program evolve together. Like the borders between two warring states, the boundary between language and program is drawn and redrawn, until eventually it comes to rest along the mountains and rivers, the natural frontiers…

## Babbage’s Difference Engine

## Project Euler Problem #7

Find the 10001st prime let naturals = Seq.unfold (fun i -> Some(i, i + 1))let primes = naturals 2 |> Seq.filter (fun n -> seq { 2..int (sqrt (float n)) } |> Seq.forall (fun x -> n % x <> 0))Seq.nth 10000 primes

## Project Euler Problem #6

Difference between sum of the squares and the square of the sum of 1 – 100: (fun ns -> let sqr x = x * x (sqr (List.sum ns)) – (List.map sqr ns |> List.sum) ) [1..100]

## Project Euler Problem #5

Smallest number divisible by each of 1 to 20: First cut (takes almost an hour to execute!): let isFactor n d = n % d = 0 {1..Int32.MaxValue} |> Seq.find (fun n -> [1..20] |> List.forall (isFactor n)) Second cut (takes a millisecond!): let rec gcd a b = if b =…