Showing posts with label projecteuler. Show all posts
Showing posts with label projecteuler. Show all posts

Project Euler > Problem 195 > Inscribed circles of triangles with one angle of 60 degrees (Java Solution)

Problem:

Let's call an integer sided triangle with exactly one angle of 60 degrees a 60-degree triangle.
Let r be the radius of the inscribed circle of such a 60-degree triangle.

There are 1234 60-degree triangles for which r [≤] 100.
Let T(n) be the number of 60-degree triangles for which r [≤] n, so
T(100) = 1234, T(1000) = 22767, and T(10000) = 359912.

Find T(1053779).


Solution:

1533776805

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 194 > Coloured Configurations (Java Solution)

Problem:

Consider graphs built with the units A: and B: , where the units are glued along the vertical edges as in the graph .

A configuration of type (a,b,c) is a graph thus built of a units A and b units B, where the graph's vertices are coloured using up to c colours, so that no two adjacent vertices have the same colour.
The compound graph above is an example of a configuration of type (2,2,6), in fact of type (2,2,c) for all c [≥] 4.

Let N(a,b,c) be the number of configurations of type (a,b,c).
For example, N(1,0,3) = 24, N(0,2,4) = 92928 and N(2,2,3) = 20736.

Find the last 8 digits of N(25,75,1984).


Solution:

5482660

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 193 > Squarefree Numbers (Java Solution)

Problem:

A positive integer n is called squarefree, if no square of a prime divides n, thus 1, 2, 3, 5, 6, 7, 10, 11 are squarefree, but not 4, 8, 9, 12.

How many squarefree numbers are there below 250?


Solution:

16695334890

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 192 > Best Approximations (Java Solution)

Problem:

Let x be a real number.
A best approximation to x for the denominator bound d is a rational number r/s in reduced form, with s [≤] d, such that any rational number which is closer to x than r/s has a denominator larger than d:

|p/q-x| [<] |r/s-x| [⇒] q [>] d

For example, the best approximation to [√]13 for the denominator bound 20 is 18/5 and the best approximation to [√]13 for the denominator bound 30 is 101/28.

Find the sum of all denominators of the best approximations to [√]n for the denominator bound 1012, where n is not a perfect square and 1 [<] n [≤] 100000.


Solution:

162

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 191 > Prize Strings (Java Solution)

Problem:

A particular school offers cash rewards to children with good attendance and punctuality. If they are absent for three consecutive days or late on more than one occasion then they forfeit their prize.

During an n-day period a trinary string is formed for each child consisting of L's (late), O's (on time), and A's (absent).

Although there are eighty-one trinary strings for a 4-day period that can be formed, exactly forty-three strings would lead to a prize:

OOOO OOOA OOOL OOAO OOAA OOAL OOLO OOLA OAOO OAOA
OAOL OAAO OAAL OALO OALA OLOO OLOA OLAO OLAA AOOO
AOOA AOOL AOAO AOAA AOAL AOLO AOLA AAOO AAOA AAOL
AALO AALA ALOO ALOA ALAO ALAA LOOO LOOA LOAO LOAA
LAOO LAOA LAAO

How many "prize" strings exist over a 30-day period?


Solution:

7652413

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 190 > Maximising a weighted product (Java Solution)

Problem:

Let Sm = (x1, x2, ... , xm) be the m-tuple of positive real numbers with x1 + x2 + ... + xm = m for which Pm = x1 * x22 * ... * xmm is maximised.

For example, it can be verified that [P10] = 4112 ([ ] is the integer part function).

Find Σ[Pm] for 2 [≤] m [≤] 15.


Solution:

210

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 189 > Tri-colouring a triangular grid (Java Solution)

Problem:

Consider the following configuration of 64 triangles:

We wish to colour the interior of each triangle with one of three colours: red, green or blue, so that no two neighbouring triangles have the same colour. Such a colouring shall be called valid. Here, two triangles are said to be neighbouring if they share an edge.
Note: if they only share a vertex, then they are not neighbours.

For example, here is a valid colouring of the above grid:

A colouring C' which is obtained from a colouring C by rotation or reflection is considered distinct from C unless the two are identical.

How many distinct valid colourings are there for the above configuration?


Solution:

840

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 188 > The hyperexponentiation of a number (Java Solution)

Problem:

The hyperexponentiation or tetration of a number a by a positive integer b, denoted by a↑↑b or ba, is recursively defined by:

a↑↑1 = a,
a↑↑(k+1) = a(a↑↑k).

Thus we have e.g. 3↑↑2 = 33 = 27, hence 3↑↑3 = 327 = 7625597484987 and 3↑↑4 is roughly 103.6383346400240996*10^12.

Find the last 8 digits of 1777↑↑1855.


Solution:

932718654

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 187 > Semiprimes (Java Solution)

Problem:

A composite is a number containing at least two prime factors. For example, 15 = 3 [×] 5; 9 = 3 [×] 3; 12 = 2 [×] 2 [×] 3.

There are ten composites below thirty containing precisely two, not necessarily distinct, prime factors: 4, 6, 9, 10, 14, 15, 21, 22, 25, 26.

How many composite integers, n [<] 108, have precisely two, not necessarily distinct, prime factors?


Solution:

748317

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 186 > Connectedness of a network. (Java Solution)

Problem:

Here are the records from a busy telephone system with one million users:

RecNr Caller Called
1 200007 100053
2 600183 500439
3 600863 701497
... ... ...

The telephone number of the caller and the called number in record n are Caller(n) = S2n-1 and Called(n) = S2n where S1,2,3,... come from the "Lagged Fibonacci Generator":

For 1 [≤] k [≤] 55, Sk = [100003 - 200003k + 300007k3] (modulo 1000000)
For 56 [≤] k, Sk = [Sk-24 + Sk-55] (modulo 1000000)

If Caller(n) = Called(n) then the user is assumed to have misdialled and the call fails; otherwise the call is successful.

From the start of the records, we say that any pair of users X and Y are friends if X calls Y or vice-versa. Similarly, X is a friend of a friend of Z if X is a friend of Y and Y is a friend of Z; and so on for longer chains.

The Prime Minister's phone number is 524287. After how many successful calls, not counting misdials, will 99% of the users (including the PM) be a friend, or a friend of a friend etc., of the Prime Minister?


Solution:

872187

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 185 > Number Mind (Java Solution)

Problem:

The game Number Mind is a variant of the well known game Master Mind.

Instead of coloured pegs, you have to guess a secret sequence of digits. After each guess you're only told in how many places you've guessed the correct digit. So, if the sequence was 1234 and you guessed 2036, you'd be told that you have one correct digit; however, you would NOT be told that you also have another digit in the wrong place.

For instance, given the following guesses for a 5-digit secret sequence,

90342 ;2 correct
70794 ;0 correct
39458 ;2 correct
34109 ;1 correct
51545 ;2 correct
12531 ;1 correct

The correct sequence 39542 is unique.

Based on the following guesses,

5616185650518293 ;2 correct
3847439647293047 ;1 correct
5855462940810587 ;3 correct
9742855507068353 ;3 correct
4296849643607543 ;3 correct
3174248439465858 ;1 correct
4513559094146117 ;2 correct
7890971548908067 ;3 correct
8157356344118483 ;1 correct
2615250744386899 ;2 correct
8690095851526254 ;3 correct
6375711915077050 ;1 correct
6913859173121360 ;1 correct
6442889055042768 ;2 correct
2321386104303845 ;0 correct
2326509471271448 ;2 correct
5251583379644322 ;2 correct
1748270476758276 ;3 correct
4895722652190306 ;1 correct
3041631117224635 ;3 correct
1841236454324589 ;3 correct
2659862637316867 ;2 correct

Find the unique 16-digit secret sequence.


Solution:

55

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 184 > Triangles containing the origin. (Java Solution)

Problem:

Consider the set Ir of points (x,y) with integer co-ordinates in the interior of the circle with radius r, centered at the origin, i.e. x2 + y2 [<] r2.

For a radius of 2, I2 contains the nine points (0,0), (1,0), (1,1), (0,1), (-1,1), (-1,0), (-1,-1), (0,-1) and (1,-1). There are eight triangles having all three vertices in I2 which contain the origin in the interior. Two of them are shown below, the others are obtained from these by rotation.

For a radius of 3, there are 360 triangles containing the origin in the interior and having all vertices in I3 and for I5 the number is 10600.

How many triangles are there containing the origin in the interior and having all three vertices in I105?


Solution:

40730

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 183 > Maximum product of parts (Java Solution)

Problem:

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 = rk.

For example, if 11 is split into five equal parts, 11 = 2.2 + 2.2 + 2.2 + 2.2 + 2.2, then P = 2.25 = 51.53632.

Let M(N) = Pmax 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 Pmax = (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.


Solution:

100

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 182 > RSA encryption (Java Solution)

Problem:

The RSA encryption is based on the following procedure:

Generate two distinct primes p and q.
Compute n=pq and φ=(p-1)(q-1).
Find an integer e, 1[<]e[<]φ, such that gcd(e,φ)=1.

A message in this system is a number in the interval [0,n-1].
A text to be encrypted is then somehow converted to messages (numbers in the interval [0,n-1]).
To encrypt the text, for each message, m, c=me mod n is calculated.

To decrypt the text, the following procedure is needed: calculate d such that ed=1 mod φ, then for each encrypted message, c, calculate m=cd mod n.

There exist values of e and m such that me mod n=m.
We call messages m for which me mod n=m unconcealed messages.

An issue when choosing e is that there should not be too many unconcealed messages.
For instance, let p=19 and q=37.
Then n=19*37=703 and φ=18*36=648.
If we choose e=181, then, although gcd(181,648)=1 it turns out that all possible messages
m (0[≤]m[≤]n-1) are unconcealed when calculating me mod n.
For any valid choice of e there exist some unconcealed messages.
It's important that the number of unconcealed messages is at a minimum.

Choose p=1009 and q=3643.
Find the sum of all values of e, 1[<]e[<]φ(1009,3643) and gcd(e,φ)=1, so that the number of unconcealed messages for this value of e is at a minimum.


Solution:

45228

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 181 > Investigating in how many ways objects of two different colours can be grouped. (Java Solution)

Problem:

Having three black objects B and one white object W they can be grouped in 7 ways like this:

(BBBW) (B,BBW) (B,B,BW) (B,B,B,W) (B,BB,W) (BBB,W) (BB,BW)

In how many ways can sixty black objects B and forty white objects W be thus grouped?


Solution:

73682

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 180 > Rational zeros of a function of three variables. (Java Solution)

Problem:

For any integer n, consider the three functions

f1,n(x,y,z) = xn+1 + yn+1 [−] zn+1
f2,n(x,y,z) = (xy + yz + zx)*(xn-1 + yn-1 [−] zn-1)
f3,n(x,y,z) = xyz*(xn-2 + yn-2 [−] zn-2)

and their combination

fn(x,y,z) = f1,n(x,y,z) + f2,n(x,y,z) [−] f3,n(x,y,z)

We call (x,y,z) a golden triple of order k if x, y, and z are all rational numbers of the form a / b with
0 [<] a [<] b [≤] k and there is (at least) one integer n, so that fn(x,y,z) = 0.

Let s(x,y,z) = x + y + z.
Let t = u / v be the sum of all distinct s(x,y,z) for all golden triples (x,y,z) of order 35.
All the s(x,y,z) and t must be in reduced form.

Find u + v.


Solution:

443839

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 179 > Consecutive positive divisors (Java Solution)

Problem:

Find the number of integers 1 [<] n [<] 107, for which n and n + 1 have the same number of positive divisors. For example, 14 has the positive divisors 1, 2, 7, 14 while 15 has 1, 3, 5, 15.


Solution:

9183

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 178 > Step Numbers (Java Solution)

Problem:

Consider the number 45656.
It can be seen that each pair of consecutive digits of 45656 has a difference of one.
A number for which every pair of consecutive digits has a difference of one is called a step number.
A pandigital number contains every decimal digit from 0 to 9 at least once.
How many pandigital step numbers less than 1040 are there?


Solution:

669171001

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 177 > Integer angled Quadrilaterals. (Java Solution)

Problem:

Let ABCD be a convex quadrilateral, with diagonals AC and BD. At each vertex the diagonal makes an angle with each of the two sides, creating eight corner angles.

For example, at vertex A, the two angles are CAD, CAB.

We call such a quadrilateral for which all eight corner angles have integer values when measured in degrees an "integer angled quadrilateral". An example of an integer angled quadrilateral is a square, where all eight corner angles are 45°. Another example is given by DAC = 20°, BAC = 60°, ABD = 50°, CBD = 30°, BCA = 40°, DCA = 30°, CDB = 80°, ADB = 50°.

What is the total number of non-similar integer angled quadrilaterals?

Note: In your calculations you may assume that a calculated angle is integral if it is within a tolerance of 10-9 of an integer value.


Solution:

-59231

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Project Euler > Problem 176 > Right-angled triangles that share a cathetus. (Java Solution)

Problem:

The four right-angled triangles with sides (9,12,15), (12,16,20), (5,12,13) and (12,35,37) all have one of the shorter sides (catheti) equal to 12. It can be shown that no other integer sided right-angled triangle exists with one of the catheti equal to 12.

Find the smallest integer that can be the length of a cathetus of exactly 47547 different integer sided right-angled triangles.


Solution:

983

Code:
The solution may include methods that will be found here: Library.java .

public interface EulerSolution{

public String run();

}
We don't have code for that problem yet! If you solved that out using Java, feel free to contribute it to our website, using our "Upload" form.
Read More

Follow Me

If you like our content, feel free to follow me to stay updated.

Subscribe

Enter your email address:

We hate spam as much as you do.

Upload Material

Got an exam, project, tutorial video, exercise, solutions, unsolved problem, question, solution manual? We are open to any coding material. Why not upload?

Upload

Copyright © 2012 - 2014 Java Problems  --  About  --  Attribution  --  Privacy Policy  --  Terms of Use  --  Contact