Posts in project euler

Optimus Prime Optimizes Prime

Optimus Prime

Hi there folks. Optimus Prime here. Few of you know this, but when I’m not out blowing up bad guys with my ion-blaster and swinging my energon-axe, I enjoy solving Project Euler problems over a bowl of oatmeal and a cup of coffee at breakfast. Weird, right? It’s like seeing your teacher walking out on the street, or bumping in to your shrink at the grocery store. Anyway…

I wanted to talk to you about a piece of a Euler problem that I particularly enjoyed optimizing (the problem itself is here). It’s the method I call is_prime?, which, as it’s name suggests, checks to see if a given number is prime. Sure, I could use the built in ruby method Prime.prime?(n), but where would the fun be in that?

written in in optimization, prime numbers, project euler Read on →

Project Euler - Pythagorean Triplets

I’ve been trying to crank through Project Euler questions over the past week or so. They are pretty challenging at first sight, but I’m finding that after looking at them for a few minutes, patterns start revealing themselves and the problem becomes much clearer. Today’s question is the following:

A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,

a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52.

There exists exactly one Pythagorean triplet for which a + b + c = 1000.

Find the product abc

written in in math problems, project euler, pythagorean triplets, ruby Read on →