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.
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, d, d, &c., convert each to an integer, and find the product.
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 95, meaning that the central for loop of my program ran to a higher ceiling (7 × 9! (~2.5 million) rather than 6 × 95 (~350,000)).
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.