A new type of prime numbers are the focus of Problem 37 of Project Euler. This time the type of prime numbers is truncatable primes. I have never heard of this type of primes before, but the problem description gives a good explanation.Find the sum of the only eleven primes that are both truncatable from left to right and right to left.So we know that we are supposed to find 11 of these. I will present you with two similar approaches. The first one is pure brute force where we search through all primes until we hit the ones with the right property. In the other solution we will only generate numbers which are left truncatable and then check if the are right truncatable. However, both solutions are missing one important thing I think. They are missing a clear upper bound. I haven't been able to establish one through any means, so if you can share some insight to that I would be very happy to hear from you.

Continue reading...Wednesday, January 12, 2011

Given problem 22 of Project Euler which reads What is the total of all the name scores in the file?The way I want to solve this problem, is to split it into three parts Read the input file and turn the data into a manageable data structure Sort the data Sum up and provide the answerSo this post will be split into three parts with most focus on the second part, as that is where the meat is. I will swap the sections a bit, such that I treat section 1 and 3 first to set up the framework. At last I will shortly treat two different sorting algorithms plus the .NET API way for sorting.

Continue reading...Wednesday, January 5, 2011

Given problem 20 of Project Euler which reads Find the sum of the digits in the number 100!I exploit the BigInteger class in .NET 4.0 which makes it easy to operate on large integers, and thereby makes it a matter of slicing up the big number.

Continue reading...Saturday, January 1, 2011

Problem 19 of Project Euler is a curious little problem. It asks How many Sundays fell on the first of the month during the twentieth century (1 Jan 1901 to 31 Dec 2000)?I provide a brute force solution exploiting the date/time part of the .NET api to check all 1200 1st of the month.

Continue reading...Saturday, December 18, 2010

Given problem 16 of Project Euler which reads What is the sum of the digits of the number 21000?I exploit the BigInteger class in .NET 4.0 which makes it easy to operate on large integers, and thereby makes it a matter of slicing up the big number.

Continue reading...Tuesday, December 7, 2010

Problem 13 of Project Euler reads: Work out the first ten digits of the sum of the following one-hundred 50-digit numbersWith the development of .NET 4.0 you can make a short cut and the solution becomes rather trivial as I am about to show you.

Continue reading...Wednesday, December 1, 2010

Recently while seeking inspiration, I found a small function in the .net api called StopWatch. It was exactly what I have been looking for. It is placed under System.Diagnostics.Stopwatch Until now I have made my timed my solution algorithms using multiple timestamp variables, but I have come to realise that the StopWatch is exactly what […]

Continue reading...This site uses cookies.

Saturday, April 23, 2011

16 Comments