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 binary_search_iter(seq, target): | |
high , low=len(seq),0 | |
while low < high: | |
mid = (high+low)//2 | |
if target ==seq[mid]: | |
return mid | |
elif target<seq[mid]: | |
high=mid | |
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 binary_search_rec(seq, target, low,high): | |
if low > high: | |
return None | |
mid = (low+high)//2 | |
if target == seq[mid]: | |
return mid | |
elif target<seq[mid]: | |
return binary_search_rec(seq, target, low,mid-1) | |
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
from typing import Any, Sequence | |
def bin_search(a : Sequence, key : Any)-> int: | |
'''์ํ์ค a์์ key์ ์ผ์นํ๋ ์์๋ฅผ ์ด์ง ๊ฒ์''' | |
pl =0 | |
pr= len(a)-1 | |
while True: | |
pc=(pl+pr)//2 # ์ค์ ์ฐ๋์์ ์ธ๋ฑ์ค | |
if a[pc]==key: |
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 json | |
with open('C:\\Users\\gnvid\\PycharmProjects\\telegramBot\\stock_list.json', 'r', encoding='UTF8') as f: | |
json_data = json.load(f) |
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 requests | |
from bs4 import BeautifulSoup | |
url = "https://finance.naver.com/item/main.nhn?code=034220" | |
result = requests.get(url) | |
bs_obj = BeautifulSoup(result.content,"html.parser") | |
no_today = bs_obj.find("p", {"class": "no_today"}) # ํ๊ทธ p, ์์ฑ๊ฐ no_today ์ฐพ๊ธฐ | |
blind = no_today.find("span") # ํ๊ทธ span, ์์ฑ๊ฐ blind ์ฐพ๊ธฐ | |
now_price = blind.text |
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
document.getElementById("save").addEventListener("click", function () | |
{ | |
var user = document.getElementById("user").value ; | |
//localStorage["user"] = user ; | |
localStorage.setItem("user", user) ; | |
alert("gmail id saved") ; | |
console.log("gmail id saved") | |
} , 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
# ์ํ๋ ๊ฐ์๋งํผ ๊ฐ์ ์ ๋ ฅ๋ฐ์ ๋ง์ง๋ง n๊ฐ๋ฅผ ์ ์ฅ | |
n = int(input('์ ์๋ฅผ ๋ช๊ฐ ์ ์ฅํ ๊น์?')) | |
a= [None]*n # ์ ๋ ฅ๋ฐ์ ๊ฐ์ ์ ์ฅํ๋ ๋ฐฐ์ด | |
cnt = 0 # ์ ์๋ฅผ ์ ๋ ฅ๋ฐ์ ๊ฐ์ | |
while True: | |
a[cnt%n]=int(input((f'{cnt+1}๋ฒ์งธ์ ์๋ฅผ ์ ๋ ฅํ์ธ์'))) | |
cnt+=1 | |
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
class Solution(object): | |
def reorderLogFiles(self, logs): | |
""" | |
:type logs: List[str] | |
:rtype: List[str] | |
""" | |
digit_log=[] | |
let_temp=[] | |
let=[] |
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 cv2 | |
import numpy as np | |
import glob | |
# ์์ ์ฝ๊ธฐ ๋ฐ ํ์ | |
img = cv2.imread('pistol.jpg') | |
cv2.imshow('query', img) | |
# ๋น๊ตํ ์์๋ค์ด ์๋ ๊ฒฝ๋ก | |
search_dir ="101_ObjectCategories" |
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
pattern = r"ca" | |
text = "caabsacasca" | |
# ๋งค์นญ๋ ๊ฐ์ ์ดํฐ๋ ์ดํฐ๋ก ๋ชจ๋ ๋ฐํ | |
iterator = re.finditer(pattern ,text) | |
for match in iterator: | |
print match.group() # 1ๅ็ฎ: ca 2ๅ็ฎ: ca | |
print match.start() # 1ๅ็ฎ: 0 2ๅ็ฎ: 6 | |
print match.end() # 1ๅ็ฎ: 2 2ๅ็ฎ: 8 | |
print match.span() # 1ๅ็ฎ: (0, 2) 2ๅ็ฎ: (6, 8) | |