Project Euler Problem 42

//

Project Euler Problem 42 involved some text parsing -- a nice change of pace. I went on a bit of a binge last night and solved 6 problems, but they were all erpa-derpa-factor-erpa-derpa-sieve, so I didn't bother posting.. as, we'll, they're boring. This one gave me an excuse to write some perverse perl, though, so here goes; I have no shame.

Project Euler Problem 30

//

I hadn't solved a Project Euler problem in quite some time, so I figured I'd sit down and bang one out. Problem 30 was pretty straight forward.

Project Euler Problem 59

//

Project Euler Problem 59 was actually a really nice change of pace. We're given a crypted chunk of data, told that it was produced using an XOR cypher with a three-character key consisting of characters a-z, that the plain-text is english-language, and that we should brute-force it.

Given that the plain-text is english-language, I was going to get fancy and use frequency analysis, but since I didn't have a pen or paper on my couch, I decided that I'd stick with the spirit of the problem and go ahead with a brute-force attack.

It would have taken longer to come up with an 'is this english-language?' heuristic to short-circuit a key than it would to use my brain and vim, so the solution takes awhile to come up with, but it's correct.

... and given that I've seen "Hackers" a thousand times, I probably should have just guessed the key. Oh well; read on for the code.

Oh, and yes, I could have folded the summation of the plain-text into the decryption function, but I forgot that's what the solution was going to be, so I just tacked it on at the end. Don't hate me.

Project Euler Problem 29

//

Tonight's fun is Project Euler Problem 29. This turned out to be a lot easier than I thought. I wrote a quick scratch solution to test for correctness, and it turns out that the throw-away solution runs in < 1sec. What was this one?

Consider all integer combinations of a^(b) for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:

2^(2)=4, 2^(3)=8, 2^(4)=16, 2^(5)=32
3^(2)=9, 3^(3)=27, 3^(4)=81, 3^(5)=243
4^(2)=16, 4^(3)=64, 4^(4)=256, 4^(5)=1024
5^(2)=25, 5^(3)=125, 5^(4)=625, 5^(5)=3125

If they are then placed in numerical order, with any repeats removed, we get the following sequence of 15 distinct terms:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

How many distinct terms are in the sequence generated by a^(b) for 2 ≤ a ≤ 100 and 2 ≤ b ≤ 100?

Project Euler Problem 10

//

I finished my Pizza Rolls, but still felt like ticking a few more off these off the list. Project Euler Problem 10 just asks us to sum all the primes < 2,000,000. Pretty simple stuff. Using the prime sive from a previous problem, we add a little padding, then just sum an array of numbers we found to be primes. Could have while()'d the cache hash for the sum, but the cost of maintaining the array is pretty trivial, I think the resulting code is cleaner, and I'm really tired of these stupid prime number problems.

Solution below.

Project Euler Problem 25

//

So, while waiting for my pizza rolls to finish cooking, I decided that I'd do another Project Euler Problem. Here's a pretty simple solution to Project Euler Problem 25. Pretty straight forward. Just trying to figure out which term in the Fibonacci sequence is the first to contain 1000 digits (the term, not the actual number). Using bigint to handle the large numbers, and casting to a string when we print them out. Runs in 0.684s, which is fast enough for me.

Some Rainy Monday

A track I wrote a few years back -- pretty happy with it, for the most part. Unfortunately the disk with all the actual tracks/samples crashed so I can't finish it up. The ending's filler.

Usual abelton/headphones-as-guitar-mic business.

It look's like you don't have Adobe Flash Player installed. Get it now.

Mautzerblau at Plush 05/18/04

An old industrial set from my 'mautzerblau' days. Figured I'd post it up since I always seem to lose track of it.

Track list below the fold.

It look's like you don't have Adobe Flash Player installed. Get it now.

Project Euler Problem 35

I was apparently being OCD and put some time into the solution for Project Euler Problem 35.

Here we're trying to calculate the number of circular primes < 1,000,000. A circular prime is--well just read the problem statement.

Anyhow, here's a perl solution. It runs in about 5seconds, which isn't too bad, I guess -- could be faster.

Project Euler Problem 22

More sum-a-bunch-of-absurdly-large-numbers fun in Project Euler Problem 22. We're given a 46KB text file full of names, a way of assigning each one a value, and told to give some sums.

Here's a perl solution -- maybe one day I'll get around to writing these in another language.

Syndicate content