Tag Archives: Python

Project Euler. #9. Special Pythagorean triplet

Project Euler (http://projecteuler.net/) 문제9 A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. 피타고라스의 삼각쌍은 세 자연수에 대하여 a < b < c 이고, a2 + b2 = c2 예를 들면, 32 + 42 =… Read More »

Project Euler. #8. Largest product in a series

Project Euler (http://projecteuler.net/) 문제8 Find the greatest product of five consecutive digits in the 1000-digit number. 아래의 1000개의 숫자에서 다섯개의 연속되는 수들의 곱중 가장 큰 수는? 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749 30358907296290491560440772390713810515859307960866 70172427121883998797908792274921901699720888093776 65727333001053367881220235421809751254540594752243 52584907711670556013604839586446706324415722155397 53697817977846174064955149290862569321978468622482 83972241375657056057490261407972968652414535100474 82166370484403199890008895243450658541227588666881 16427171479924442928230863465674813919123162824586 17866458359124566529476545682848912883142607690042 24219022671055626321111109370544217506941658960408 07198403850962455444362981230987879927244284909188 84580156166097919133875499200524063689912560717606 05886116467109405077541002256983155200055935729725 71636269561882670428252483600823257530420752963450 given = """ 73167176531330624919225119674426574742355349194934 96983520312774506326239578318016984801869478851843 85861560789112949495459501737958331952853208805511 12540698747158523863050715693290963295227443043557 66896648950445244523161731856403098711121722383113 62229893423380308135336276614282806444486645238749… Read More »

Project Euler. #7. 10001st prime

Project Euler (http://projecteuler.net/) 문제7 By 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 10001st prime number? 소수를 순서대로 2, 3, 5, 7, 11 그리고 13을 나열하였을 때, 6번째 소수는 13이다. 10001번째 소수는 무엇인가? def isPrime(n): for i in… Read More »

Project Euler. #4. Largest palindrome product

Project Euler (http://projecteuler.net/) 문제4 A 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. 회문 숫자는 양방향 어느쪽에서 읽어도 같다. 두 자리 숫자의 곱으로 이루어지는 숫자 중 가장 큰… Read More »

Project Euler. #3. Largest prime factor

Project Euler (http://projecteuler.net/) 문제3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? 13195의 소인수는 5, 7, 13 그리고 29다. 600851475143의 소인수 중 가장 큰 수는? p=600851475143 def isPrime(n): t=int(n**(1.0/2.0)) while t>1: if n%t==0: return False else: t-=1 return True def isFactor(n):… Read More »

[Python] Twitter API – tweepy 활용하기

다음 코드는 Consumer_key, Consumer_secret, Access_key, Access_secret 의 값을 이용하여 OAuth 인증을 받고 이를 이용하여 'Hello, tweepy API' 라는 글을 본인의 계정으로 트윗하는 샘플코드이다. #-*- coding:cp949 -*- import tweepy CONSUMER_KEY = 'aUPI30zXd2hzUAqP9ow' CONSUMER_SECRET = 'JOzfAHzEBAxOrmY9ERkOuvFJKaupdQ4gADmN2471FRY' ACCESS_KEY = '48014458-kRfCeeMdHm3YDyH1ZYXaYhmywMe6jeN7dksLxv13k' ACCESS_SECRET = '57B6hQaue2FXyY0fR3P1ppHwGnVKte0O1ZnnznA4' auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET) auth.set_access_token(ACCESS_KEY, ACCESS_SECRET) api = tweepy.API(auth) status = api.update_status('Hello, tweepy API') update_status()는… Read More »