A Ruby answer for http://codegolf.stackexchange.com/questions/19925/counting-triangles