This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#p <= 1000 직각삼각형 | |
#a^2 + b^2 = c^2 | |
#1) p의 값을 기준으로, {a, b, c} 값을 정한다. | |
def get_삼각형의_세변(p): | |
직각삼각형_cnt = 0 | |
for a in range(어디부터, p-2까지): | |
for b in range(어디부터, p-2까지): | |
c = p - (a + b) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#곱하는 수: 9999이하 >> n이 2이상이니까 1, 2를 곱하고 나열해서 9자리를 넘지 않아야 한다. | |
#(9999*2=5자리) | |
#팬디지털 판별! | |
def is_팬디지털(알고싶은_수): | |
팬디지털_list = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] | |
num_list = list(알고싶은_수)#list(re.sub('\D', '', 곱셈식)) | |
if num_list에 팬디지털_list가 다 있으면: | |
return True | |
else: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_pandigital(num_list): | |
pandigital_list = ['1', '2', '3', '4', '5', '6', '7', '8', '9'] | |
return all(num in num_list for num in pandigital_list) | |
def cal_formula(range_from, range_to): | |
pandigital_result = 0 | |
for num in range(range_from, range_to): | |
n = 1 | |
result_str = '' | |
result_str_list = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
import re | |
from itertools import permutations | |
def get_permutation_list(): | |
permu_list = permutations('123456789', 9) | |
return permu_list | |
def get_pandigital_formula(permutation_list): | |
result_set = set() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import e37 | |
import unittest | |
class TestSplitFunction(unittest.TestCase): | |
def test_is_prime(self): | |
r = e37.is_prime(3797) | |
self.assertTrue(r) | |
r = e37.is_prime(24) | |
self.assertFalse(r) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#여전히 함수인 수 찾기(11개) | |
#조건 | |
#1)끝자리나 시작자리가 무조건 3 혹은 7일 것 | |
#2)시작과 끝자리 사이에 들어가는 수는 짝수나 5, 혹은 0이 아닐 것 | |
import primesieve | |
def is_prime(num): | |
if primesieve.generate_n_primes(1, num)[0] == num: | |
pass | |
else : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#2진수 구하는 함수 있으면 좋은데 | |
def get_2진수(10진수): | |
return 2진수 | |
def is_대칭수(num): | |
if num is 대칭수: | |
return True | |
else: | |
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import project_euler_36 | |
import unittest | |
class TestSplitFunction(unittest.TestCase) : | |
def setUp(self): | |
pass | |
def tearDown(self): | |
pass | |
def test_get_binary_num(self) : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
def get_palindrome(range_to): | |
result_sum = 0 | |
for decimal_num in range(range_to): | |
binary_num = bin(decimal_num)[2:] | |
if str(decimal_num)== str(decimal_num)[::-1] and str(binary_num)== str(binary_num)[::-1] : | |
result_sum += decimal_num | |
return result_sum | |
print(get_palindrome(1000000)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#python3 | |
def get_binary_num(decimal_num): | |
binary_num = bin(decimal_num)[2:] | |
return binary_num | |
def is_palindrome(num): | |
str_num = str(num) | |
if str_num == str_num[::-1] : | |
return True | |
else: |