A presentation to try to dissuade my colleagues from using MongoDB as an authoritative data store in a geo-distributed service

My employer, like many web companies over the past few years, has been undergoing a slow but steady transition from a single, monolithic code base to a service oriented architecture. Our reasons are pretty standard – the team is growing, everyone wants to be able to develop without worrying about stepping on other developers’ toes – but we have one obstacle that makes our situation unique: our primary data store is a single MongoDB database that contains six years of production data, and all services are expected to affect the public-facing website by directly modifying said database.

It’s been a while since I tried my hand at Project Euler, and in the meantime, I seem to have forgotten a good deal about C# syntax. I wrote the solution to problem 89 in python, as it seemed easier to get my sea legs back in that language.

Problem 43 asks for a lot, at least it terms of the sheer number of conditions it imposes on potential answers: The number, 1406357289, is a 0 to 9 pandigital number because it is made up of each of the digits 0 to 9 in some order, but it also has a rather interesting sub-string divisibility property. Let d1 be the 1st digit, d2 be the 2nd digit, and so on.

Woohoo! I’ve gotten through all Euler problems solved by more than 20,000 people — not an official milestone, but one that feels important nonetheless. The last of these, the tersely-worded problem 52, concerned multiples/permutations: It can be seen that the number, 125874, and its double, 251748, contain exactly the same digits, but in a different order. Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits.

A circular prime, according to Project Euler, is a prime whose cyclical permutations are themselves prime:

The number, 197, is called a circular prime because all rotations of the digits: 197, 971, and 719, are themselves prime.

There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.

Problem 40 asks for information that should be easily obtainable by a couple of for loops and a heap of processing power: An irrational decimal fraction is created by concatenating the positive integers: 0.123456789101112131415161718192021… It can be seen that the 12th digit of the fractional part is 1. If d n represents the nth digit of the fractional part, find the value of the following expression. d1 × d10 × d100 × d1000 × d10000 × d100000 × d1000000 The simple way to do this would be to construct a million-character string and then pull d[0], d[9], d[99], &c., convert each to an integer, and find the product.

Problem 29 looks like it should take forever to solve by brute force.

Problem 34 is a slightly modified version of problem 30, so I solved the former with a slightly modified version of the code I used to solve the latter. It took *slightly* longer to run, as 9! is greater than 9^{5}, meaning that the central `for`

loop of my program ran to a higher ceiling (7 × 9! (~2.5 million) rather than 6 × 9^{5} (~350,000)).

I was a bit stumped at first by problem 30, which reads,

Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:

1634 = 1

^{4}+ 6^{4}+ 3^{4}+ 4^{4}

8208 = 8^{4}+ 2^{4}+ 0^{4}+ 8^{4}

9474 = 9^{4}+ 4^{4}+ 7^{4}+ 4^{4}(As 1 = 1

^{4}is not a sum it is not included.)The sum of these numbers is 1634 + 8208 + 9474 = 19316.

Find the sum of all the numbers that can be written as the sum of fifth powers of their digits.

Since getting to level 1, I’ve been doing Euler problems in order of difficulty instead of in the order they’re presented on the site. The next one up was problem 36

Problem 28 is the last problem I’ll be tackling today and the first trick question I’ve encountered on Project Euler. Take note of both the diction and the example given:

Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows:

2122 23 2425

2078910

19 612 11

1854312

1716 15 1413

Problem 48, the next challenge in Project Euler when they’re sorted by ascending difficulty, seemed a bit familiar. It asks you to come up with a very large number and then report back the last few digits thereof. It reads: The series, 11 + 22 + 33 + … + 1010 = 10405071317. Find the last ten digits of the series, 11 + 22 + 33 + … + 10001000. .NET makes this kind of problem extremely easy, as all one has to do is use BigIntegers to add all members of the series together.