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
from itertools import product | |
def change124(n): | |
count = 1 | |
digit = 1 | |
while count != n : | |
for i in product('124', repeat=digit): | |
cur_num = ''.join(i) | |
if count == n : | |
break |
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_bin_match(bin_n, nxt_bin_n): | |
if str(bin_n).count('1') == str(nxt_bin_n).count('1') : | |
return True | |
return False | |
def nextBigNumber(n): | |
bin_n = bin(n) | |
nxt_n = n + 1 | |
nxt_bin_n = bin(nxt_n) | |
while is_bin_match(bin_n, nxt_bin_n) is 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 string | |
def cal_caesar(alp, n): | |
caesar_alp_num = string.ascii_uppercase.index(alp.upper()) + n | |
if caesar_alp_num > 26 : caesar_alp_num -= 26 | |
return caesar_alp_num | |
def caesar(s, n): | |
result_list = [] | |
alp_list = s.split() |
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 cal_matrix(matrix): | |
row = len(matrix) | |
col = len(matrix[0]) | |
return row, col | |
def productMatrix(A, B): | |
row_a, col_a = cal_matrix(A) | |
row_b, col_b = cal_matrix(B) | |
#answer = [[0]*col_b]*row_a | |
answer = [[0]*col_b for x in range(row_a)] |
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 gcdlcm(a, b): | |
min_range = min(a, b)+1 | |
for i in reversed(range(min_range)): | |
if a % i == 0 and b % i == 0: | |
gcd = i | |
break | |
i = a * b | |
while True : |
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
{% extends "layout.html" %} | |
{% block content %} | |
<div class="jumbotron"> | |
<h1>Flask 활용하기</h1> | |
<p class="lead">유튜브의 Eminem 페이지를 크롤링 해서 가져온 정보로 Flask 페이지를 구성합니다.</p> | |
</div> | |
<div class="row"> | |
{% for infos in eminem_info_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
from flask import render_template | |
from youtube_flask_web import app | |
from bs4 import BeautifulSoup | |
import lxml, requests | |
@app.route('/') | |
@app.route('/home') | |
def home(): | |
eminem_info_list = get_eminem_video_link('https://www.youtube.com/user/EminemVEVO/videos') | |
return render_template('index.html', eminem_info_list=eminem_info_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
from bs4 import BeautifulSoup | |
import lxml | |
import requests | |
eminem_video_info = { | |
'title':'', | |
'video_link':'', | |
'img_link':'', | |
'play_time':'', | |
'hits' : '', |
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 get_irrational_num_list(range_to): | |
irrational_num = '' | |
num = 1 | |
while len(irrational_num) < range_to : | |
irrational_num += str(num) | |
num += 1 | |
return irrational_num | |
def get_nth_num(range_to): | |
irrational_num = get_irrational_num_list(range_to) |
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 get_right_triangle_cnt(p): | |
right_triangle_list = set() | |
for a in range(1, round(p/2)): | |
for b in range(1, round(p/2)): | |
c = p - (a + b) | |
if a*a + b*b == c*c : | |
right_triangle_list.add(c) | |
return len(right_triangle_list) | |
def get_max_right_triangle_cnt(range_from, range_to, step): |