The last and fourth problem from Google Treasure Hunt deals with consecutive prime numbers. Its basic form is:
Find the smallest number that can be expressed as
the sum of m consecutive prime numbers,
the sum of n consecutive prime numbers,
the sum of o consecutive prime numbers,
the sum of p consecutive prime numbers,
and is itself a prime number.
For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).
In the case of m, n, o, and p, there are four conditions, although there can be more. The example of 41 has only two conditions, for instance.
Again, my solution was written in Python and is designed to scale to a variable amount of conditions, as seen in the
primes.py I wrote:
Google Treasure Hunt seems to be fairly interesting. There are three puzzles released so far; a fourth one will ensue at 1212448500 (that's
there is no official name for it yet ), is sponsored by the San Francisco office.
Although Apple describes both Python and Ruby as "first-class citizens" under a Leopard development environment, I feel that Apple meant it more programmatically than documentationally. Sure, both PyObjC and RubyCocoa are mature bridges, but both lack documentation from Apple (you have to rely on the community for gotchas) and RubyCocoa seems to receive more attention than PyObjC when it comes to tutorials for starters.
Moreover, the starting templates for Cocoa-Python apps and Cocoa-Ruby apps are not created equal. For example, while Apple encourages the scripts to be put into Resources, only a Cocoa-Ruby bootstrap file generated by Xcode (called main.rb) would automatically
require them. A Cocoa-Python bootstrap file generated by Xcode (called main.py) would not
import them, and this problem would manifest itself when you first attempt to do bindings in Interface Builder.
First, observe a generated main.rb: