# Python

## Google Treasure Hunt: Last problem

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 2008

Google Treasure Hunt seems to be fairly interesting. There are three puzzles released so far; a fourth one will ensue at 1212448500 (that's `new Date(1212448500 * 1000)`

for you JavaScripters). The first two are dubbed "robot" and "zip" by Google, the former sponsored by the Sydney office, the latter sponsored by the Mountain View headquarters. The latest one, which I call "route" (~~there is no official name for it yet~~ officially named "network"), is sponsored by the San Francisco office.

## A Better main.py for Python-Cocoa Apps

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:

## Synthetic Division Heavylifter

Synthetic Division Heavylifter is a tool available in JavaScript, Python, Ruby, and Common Lisp that performs synthetic division. Synthetic division is a process that is used to speed up the factoring of polynomials. However, it is still a hassle to utilize when the first term or the last term of the polynomial has a large number of factors, since the possible number factor candidates would increase.

## Recent comments

8 years 24 weeks ago

8 years 48 weeks ago

8 years 48 weeks ago

8 years 48 weeks ago

8 years 49 weeks ago

8 years 51 weeks ago

9 years 5 days ago

9 years 1 week ago

9 years 2 weeks ago

9 years 16 weeks ago