배움/알고리즘
-
프로젝트 오일러 8번 문제배움/알고리즘 2019. 1. 26. 18:19
Largest product in a seriesProblem 8The four adjacent digits in the 1000-digit number that have the greatest product are 9 × 9 × 8 × 9 = 5832.73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 6..
-
프로젝트 오일러 7번 문제배움/알고리즘 2019. 1. 26. 17:18
10001st primeProblem 7By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.What is the 10 001st prime number? 문제는 심플하다. 6번째 소수는 13이다. 그렇다면 10001번째 소수는 뭘까? 역시 프로젝트 오일러의 문제는 쉬운듯 하면서도 생각을 한번 더 하게 되는게 매력이다. 일단 가장먼저 생각나는 것은 얼마전에 문제 풀다가 뻘짓하면서 배워둔 에라토스테네스의 체다. https://shiningstone.tistory.com/2 혼자 뻘짓하면서 애를 먹었던 3번 문제에서 공부했었다. 문제와 상관없는 내용이었지만 배운 점은 있다. 바로 문제..
-
프로젝트 오일러 6번배움/알고리즘 2019. 1. 25. 18:49
문제를 먼저 보자. Sum square differenceProblem 6The sum of the squares of the first ten natural numbers is,12 + 22 + ... + 102 = 385The square of the sum of the first ten natural numbers is,(1 + 2 + ... + 10)2 = 552 = 3025Hence the difference between the sum of the squares of the first ten natural numbers and the square of the sum is 3025 − 385 = 2640.Find the difference between the sum of the squares ..
-
프로젝트 오일러 5번배움/알고리즘 2019. 1. 25. 01:38
Smallest multipleProblem 52520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20? 최소 공배수를 구하는 문제다. 두 수의 최소 공배수라면 아주 쉽겠지만 1부터 20까지의 최소 공배수를 구하라는 문제로, for문으로 모두 확인하는 과정은 너무 시간이 오래걸린다. 얼마나 오래걸리나 확인해봤다. import time def isit(num): for a in range(2,20): if..
-
프로젝트 오일러 4번배움/알고리즘 2019. 1. 24. 21:16
4번 Largest palindrome productA palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.Find the largest palindrome made from the product of two 3-digit numbers. palindrome 은 우리말로 회문이다. 풀어말하자면 앞으로 읽으나 뒤로 읽으나 같은 것을 말한다. ex ) 토마토, 12321 3-digit number는 세 자리수. 즉 문제에서는 두 3자리 수의 (계산)결과물 중 가장 큰 회문을 찾으라는 것이 된다. 가장 큰 수를 찾아야하니 당연히 ..
-
파이썬 공부 프로젝트 오일러 (1~3)배움/알고리즘 2019. 1. 23. 21:22
파이썬 스킬을 어떻게 쌓을 수 있을까 고민 하다가 영어도 공부할겸 프로젝트 오일러에서 문제를 풀고 있다. https://projecteuler.net/ 1번은 너무 쉬워서 2번부터 배운 것을 기록하려한다. 프로젝트 오일러는 문제를 맞추고 나면 사람들과 정답을 공유하는 게시판이 있어 다른 사람들의 코딩 스킬을 배우기 좋았다. 2번 문제는 아래와 같다. Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...By considering the term..