본문 바로가기

problem solving

ProjectEuler Problem 1 - Multiples of 3 and 5 If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000.It's easy with Haskell's list comprehension sum [x | x 더보기
Haskell - The 1st Note As I worked as a programmer, I've written a lot and been reading many programs written by other authors. Sometimes I found that I enjoys doing this job - understanding, realizing, creating and solving problems. And when I works with other people as a team to solve, figure out, or whatever, I fill like we are talking each other via our code. Code delivers author's idea, considerations, perspectiv.. 더보기
TCO 2010 Marathon Match Round2 - CellularAutomaton Submission 1 - 35.16 No idea, just return the given configuration. Note. The best submission over all competitor is 46.91. Example scores: 0) 0.2361111111111111 1) 0.0 2) 0.5262974573319401 3) 0.0 4) 0.4849908107004288 5) 0.6650326797385621 6) 0.3459939531368103 7) 0.4034013605442177 8) 0.07321867321867322 9) 0.42770034843205573 Submission 2 - 36.92 SA Select random point and toggle the state of.. 더보기
TCO 2010 Marathon Match Round1 - Planarity Problem Given graph G=(V,E), the problem is to arrange the vertices of the graph so that number of intersecting pairs of edges is minimized. Constraints 10 더보기
Problem 66 - Investigate the Diophantine equation x2 − Dy2 = 1. 링크 Consider quadratic Diophantine equations of the form: x2 – Dy2 = 1 For example, when D=13, the minimal solution in x is 6492 – 131802 = 1. It can be assumed that there are no solutions in positive integers when D is square. By finding minimal solutions in x for D = {2, 3, 5, 6, 7}, we obtain the following: 32 – 222 = 1 22 – 312 = 1 92 – 542 = 1 52 – 622 = 1 82 – 732 = 1 Hence, by considering .. 더보기
Problem 66 - Find the sum of digits in the numerator of the 100th convergent of the continued fraction for e. 링크 The square root of 2 can be written as an infinite continued fraction. 2 = 1 + 1 2 + 1 2 + 1 2 + 1 2 + ... The infinite continued fraction can be written, 2 = [1;(2)], (2) indicates that 2 repeats ad infinitum. In a similar way, 23 = [4;(1,3,1,8)]. It turns out that the sequence of partial values of continued fractions for square roots provide the best rational approximations. Let us consider.. 더보기
Problem 64 - How many continued fractions for N ≤ 10000 have an odd period? 링크 All square roots are periodic when written as continued fractions and can be written in the form: N = a0 + 1 a1 + 1 a2 + 1 a3 + ... For example, let us consider 23: 23 = 4 + 23 — 4 = 4 + 1 = 4 + 1 1 23—4 1 + 23 – 3 7 If we continue we would get the following expansion: 23 = 4 + 1 1 + 1 3 + 1 1 + 1 8 + ... The process can be summarised as follows: a0 = 4, 1 23—4 = 23+4 7 = 1 + 23—3 7 a1 = 1, 7.. 더보기
Problem 63 - How many n-digit positive integers exist which are also an nth power? 링크 The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power. How many n-digit positive integers exist which are also an nth power? python sum(len(str(a**b)) == b for a in range(1, 10) for b in range(1, 22)) 더보기
Problem 62 - Find the smallest cube for which exactly five permutations of its digits are cube. 링크 The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. Find the smallest cube for which exactly five permutations of its digits are cube. python p = {} l = {} seed = 1 while True: n = seed**3 k = "".join(sorted(str(n))) if p.has_ke.. 더보기
Problem 61 - Find the sum of the only set of six 4-digit figurate numbers with a cyclic property. 링크 Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae: Triangle P3,n=n(n+1)/2 1, 3, 6, 10, 15, ... Square P4,n=n2 1, 4, 9, 16, 25, ... Pentagonal P5,n=n(3n1)/2 1, 5, 12, 22, 35, ... Hexagonal P6,n=n(2n1) 1, 6, 15, 28, 45, ... Heptagonal P7,n=n(5n3)/2 1, 7, 18, 34, 55, ... Octagonal P8,n=n(3n2.. 더보기