The post Project Euler 207 Solution appeared first on Dreamshire.
]]>For some positive integers k, there exists an integer partition of the form 4^{t} = 2^{t} + k,
where 4^{t}, 2^{t}, and k are all positive integers and t is a real number.
The first two such partitions are 4^{1} = 2^{1} + 2 and 4^{1.5849625…} = 2^{1.5849625…} + 6.
Partitions where t is also an integer are called perfect.
For any m ≥ 1 let P(m) be the proportion of such partitions that are perfect with k ≤ m.
Thus P(6) = 1/2.
In the following table are listed some values of P(m)
P(5) = 1/1
P(10) = 1/2
P(15) = 2/3
P(20) = 1/2
P(25) = 1/2
P(30) = 2/5
…
P(180) = 1/4
P(185) = 3/13
Find the smallest m for which P(m) < 1/12345
The post Project Euler 207 Solution appeared first on Dreamshire.
]]>The post Project Euler 172 Solution appeared first on Dreamshire.
]]>How many 18-digit numbers n (without leading zeros) are there such that no digit occurs more than three times in n?
The post Project Euler 172 Solution appeared first on Dreamshire.
]]>The post Project Euler 163 Solution appeared first on Dreamshire.
]]>Project Euler 163: Consider an equilateral triangle in which straight lines are drawn from each vertex to the middle of the opposite side, such as in the size 1 triangle in the sketch below.
Sixteen triangles of either different shape or size or orientation or location can now be observed in that triangle. Using size 1 triangles as building blocks, larger triangles can be formed, such as the size 2 triangle in the above sketch. One-hundred and four triangles of either different shape or size or orientation or location can now be observed in that size 2 triangle.
It can be observed that the size 2 triangle contains 4 size 1 triangle building blocks. A size 3 triangle would contain 9 size 1 triangle building blocks and a size n triangle would thus contain n^{2} size 1 triangle building blocks.
If we denote T(n) as the number of triangles present in a triangle of size n, then
T(1) = 16
T(2) = 104
Find T(36).
The post Project Euler 163 Solution appeared first on Dreamshire.
]]>The post Project Euler 190 Solution appeared first on Dreamshire.
]]>Project Euler 190: Let S_{m} = (x_{1}, x_{2}, … , x_{m}) be the m-tuple of positive real numbers with x_{1} + x_{2} + … + x_{m} = m for which P_{m} = x_{1} * x_{2}^{2} * … * x_{m}^{m} is maximised.
For example, it can be verified that [P_{10}] = 4112 ([ ] is the integer part function).
Find Σ[P_{m}] for 2 ≤ m ≤ 15.
The post Project Euler 190 Solution appeared first on Dreamshire.
]]>The post Project Euler 301 Solution appeared first on Dreamshire.
]]>Nim is a game played with heaps of stones, where two players take it in turn to remove any number of stones from any heap until no stones remain.
We’ll consider the three-heap normal-play version of Nim, which works as follows:
– At the start of the game there are three heaps of stones.
– On his turn the player removes any positive number of stones from any single heap.
– The first player unable to move (because no stones remain) loses.
If (n_{1},n_{2},n_{3}) indicates a Nim position consisting of heaps of size n_{1}, n_{2} and n_{3} then there is a simple function X(n_{1},n_{2},n_{3}) — that you may look up or attempt to deduce for yourself — that returns:
For example X(1,2,3) = 0 because, no matter what the current player does, his opponent can respond with a move that leaves two heaps of equal size, at which point every move by the current player can be mirrored by his opponent until no stones remain; so the current player loses. To illustrate:
– current player moves to (1,2,1)
– opponent moves to (1,0,1)
– current player moves to (0,0,1)
– opponent moves to (0,0,0), and so wins.
For how many positive integers n ≤ 2^{30} does X(n,2n,3n) = 0 ?
Classic use of the Fibonacci sequence. Just find the Fibonacci Number F_{L+2}, where L is the 2’s exponent.
fibonacci
is listed in Common Functions and Routines for Project EulerThe post Project Euler 301 Solution appeared first on Dreamshire.
]]>The post Project Euler 317 Solution appeared first on Dreamshire.
]]>A firecracker explodes at a height of 100 m above level ground. It breaks into a large number of very small fragments, which move in every direction; all of them have the same initial velocity of 20 m/s.
We assume that the fragments move without air resistance, in a uniform gravitational field with g=9.81 m/s^{2}.
Find the volume (in m^{3}) of the region through which the fragments move before reaching the ground.
Give your answer rounded to four decimal places.
The post Project Euler 317 Solution appeared first on Dreamshire.
]]>The post Project Euler 318 Solution appeared first on Dreamshire.
]]>Project Euler 318: Consider the real number √2+√3.
When we calculate the even powers of √2+√3
we get:
(√2+√3)^{2} = 9.898979485566356…
(√2+√3)^{4} = 97.98979485566356…
(√2+√3)^{6} = 969.998969071069263…
(√2+√3)^{8} = 9601.99989585502907…
(√2+√3)^{10} = 95049.999989479221…
(√2+√3)^{12} = 940897.9999989371855…
(√2+√3)^{14} = 9313929.99999989263…
(√2+√3)^{16} = 92198401.99999998915…
It looks like that the number of consecutive nines at the beginning of the fractional part of these powers is non-decreasing.
In fact it can be proven that the fractional part of (√2+√3)^{2n} approaches 1 for large n.
Consider all real numbers of the form √p+√q with p and q positive integers and p<q, such that the fractional part
of (√p+√q)^{2n} approaches 1 for large n.
Let C(p,q,n) be the number of consecutive nines at the beginning of the fractional part of
(√p+√q)^{2n}.
Let N(p,q) be the minimal value of n such that C(p,q,n) ≥ 2011.
Find ∑N(p,q) for p+q ≤ 2011.
The post Project Euler 318 Solution appeared first on Dreamshire.
]]>The post Project Euler 327 Solution appeared first on Dreamshire.
]]>A series of three rooms are connected to each other by automatic doors.
Each door is operated by a security card. Once you enter a room the door automatically closes and that security card cannot be used again. A machine at the start will dispense an unlimited number of cards, but each room (including the starting room) contains scanners and if they detect that you are holding more than three security cards or if they detect an unattended security card on the floor, then all the doors will become permanently locked. However, each room contains a box where you may safely store any number of security cards for use at a later stage.
If you simply tried to travel through the rooms one at a time then as you entered room 3 you would have used all three cards and would be trapped in that room forever!
However, if you make use of the storage boxes, then escape is possible. For example, you could enter room 1 using your first card, place one card in the storage box, and use your third card to exit the room back to the start. Then after collecting three more cards from the dispensing machine you could use one to enter room 1 and collect the card you placed in the box a moment ago. You now have three cards again and will be able to travel through the remaining three doors. This method allows you to travel through all three rooms using six security cards in total.
It is possible to travel through six rooms using a total of 123 security cards while carrying a maximum of 3 cards.
Let C be the maximum number of cards which can be carried at any time.
Let R be the number of rooms to travel through.
Let M(C,R) be the minimum number of cards required from the dispensing machine to travel through R rooms carrying up to a maximum of C cards at any time.
For example, M(3,6)=123 and M(4,6)=23.
And, ΣM(C,6)=146 for 3 ≤ C ≤ 4.
You are given that ΣM(C,10)=10382 for 3 ≤ C ≤ 10.
Find ΣM(C,30) for 3 ≤ C ≤ 40.
The post Project Euler 327 Solution appeared first on Dreamshire.
]]>The post Project Euler 371 Solution appeared first on Dreamshire.
]]>Oregon licence plates consist of three letters followed by a three digit number (each digit can be from [0..9]).
While driving to work Seth plays the following game:
Whenever the numbers of two licence plates seen on his trip add to 1000 that’s a win.
E.g. MIC-012 and HAN-988 is a win and RYU-500 and SET-500 too. (as long as he sees them in the same trip).
Find the expected number of plates he needs to see for a win.
Give your answer rounded to 8 decimal places behind the decimal point.
Note: We assume that each licence plate seen is equally likely to have any three digit number on it.
The post Project Euler 371 Solution appeared first on Dreamshire.
]]>The post Project Euler 183 Solution appeared first on Dreamshire.
]]>Let N be a positive integer and let N be split into k equal parts, r = N/k, so that N = r + r + … + r.
Let P be the product of these parts, P = r × r × … × r = r^{k}.
For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then P = 2.2^{5} = 51.53632.
Let M(N) = P_{max} for a given value of N.
It turns out that the maximum for N = 11 is found by splitting eleven into four equal parts which leads to P_{max} = (11/4)^{4}; that is, M(11) = 14641/256 = 57.19140625, which is a terminating decimal.
However, for N = 8 the maximum is achieved by splitting it into three equal parts, so M(8) = 512/27, which is a non-terminating decimal.
Let D(N) = N if M(N) is a non-terminating decimal and D(N) = -N if M(N) is a terminating decimal.
For example, ΣD(N) for 5 ≤ N ≤ 100 is 2438.
Find ΣD(N) for 5 ≤ N ≤ 10000.
The post Project Euler 183 Solution appeared first on Dreamshire.
]]>