Meditations on programming, startups, and technology
Currently Browsing: Mathematics

The Art of Computer Programming, Volumes 1-4A Boxed Set

There’s exciting news in Computer Science-land this week, as the 4A volume (on Combinatorial algorithms) of The Art of Computer Programming by Donald Knuth is now complete and is available for preorder on Amazon. To make things even more intriguing, and to really get all of us CS/programming/math enthusiasts salivating, the boxed set is also made available for preorder (it’s slated to ship out next...

Monte Carlo simulation of the Monty Hall Problem in Ruby and Python

Reading Jeff Atwood’s post The Problem of the Unfinished Game, reminded me of a similar problem. The Monty Hall Problem is a well known probability puzzle that has tricked many people. In fact, if you are not familiar with it already, chances are that you’ll get it wrong. And you would be in good company along with many mathematicians and physicists, including the great mathematician, Paul Erdos. This...

How to parse decimal numbers within a string

INPUT: a string containing decimal numbers. OUTPUT: an array containing all the decimal numbers within the given string. You can accomplish this task very quickly with the String#scan method and the right Regular Expression (regex). Given a string s, you can use: numbers = s.scan /[-+]?\d*\.?\d+/ numbers will be an array whose elements are the decimal numbers within the string s. Note how the regex considers the...

Solving mathematical problems with Ruby

A couple of weeks ago I’ve discovered a very interesting and addictive website MathsChallenge.net . They have a section called Project Euler where participants can try to resolve more than 100 mathematical problems. The scoring system is really well done and the discussion forum for each problem is accessible only after having solved the given problem. It’s interesting to see how other people try to...

Copyright © 2005-2011 Antonio Cangiano. All rights reserved.