へたっぴpythonista

ド素人pythonistaとして、日々の学習成果や気づいたことについて書きます。

ProjectEuler

ProjectEuler22をpythonで解く

最近Rosalindばかり解いていて放置気味のEuler。パッと見て解けそうだったので久々に挑戦しました。 Problem22 Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, begin by sorting…

Project Euler56 をpythonで解く

問題 A googol (10^100) is a massive number: one followed by one-hundred zeros; 100^100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.Considering natural …

Project Euler 55をpythonで解く

問題 If we take 47, reverse and add, 47 + 74 = 121, which is palindromic.Not all numbers produce palindromes so quickly. For example,349 + 943 = 1292, 1292 + 2921 = 4213 4213 + 3124 = 7337That is, 349 took three iterations to arrive at a p…

ProjectEuler42 をpythonで解く

最近ご無沙汰だったProjectEuler。なんとなく解けそうだったので挑戦してみました。 Problem42 The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are:1, 3, 6, 10, 15, 21, 28, 36, 45, 55,…

ProjectEuler28をpythonで解く

寝る前に解いたら1時間近くかかってしまいました(笑) Problem28 Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 …

ProjectEuler18 をpythonで

久しぶりにEulerです。 Maximum path sum I By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3That is, 3 + 7 + 4 + 9 = 23.Find the maxi…

projectEuler32をpythonで

Problem32「パンデジタル積」 すべての桁に 1 から n が一度だけ使われている数をn桁の数がパンデジタル (pandigital) であるということにしよう: 例えば5桁の数 15234 は1から5のパンデジタルである.7254 は面白い性質を持っている. 39 × 186 = 7254 と書け…

ProjectEuler11をpythonで解く

ProjectEulerを20番台まで解き進め、そろそろ未解答の問題が目立ってきたので片づけよう。 手始めにProblem11。 Project11 上の 20×20 の格子のうち, 対角線に沿って4つの数字が赤くマークされている.08 02 22 97 38 15 00 40 00 75 04 05 07 78 52 12 50 77…

ProjectEuler21で解く

problem21 d(n) を n の真の約数の和と定義する. (真の約数とは n 以外の約数のことである. ) もし, d(a) = b かつ d(b) = a (a ≠ b のとき) を満たすとき, a と b は友愛数(親和数)であるという.例えば, 220 の約数は 1, 2, 4, 5, 10, 11, 20, 22, 44, 55, …