[TIL_Carrotww] 61 - 22/11/29

μœ ν˜•μ„Β·2022λ…„ 11μ›” 30일
0

TIL

λͺ©λ‘ 보기
72/138
post-thumbnail

πŸ“Carrotww의 μ½”λ”© 기둝μž₯

🧲 python algorithm

πŸ” programmers H-Index

def solution(citations):
    citations.sort()
    for num, val in enumerate(citations):
        if val >= len(citations) - num:
            return len(citations) - num
    return 0

문제만 잘 μ΄ν•΄ν•˜λ©΄ ν’€ 수 μžˆλŠ” λ¬Έμ œμ΄λ‹€.
무슨 μ†Œλ¦¬μΈκ°€... ν–ˆμ—ˆμ°Œλ§Œ ν•˜λ‚˜ν•˜λ‚˜ 보면 μ‰¬μš΄ λ¬Έμ œμ΄λ‹€.
사싀 이미 ν’€μ—ˆλ˜ λ¬Έμ œμ΄μ§€λ§Œ campμ—μ„œ μ§„ν–‰ν•˜λŠ” μ•Œκ³ λ¦¬μ¦˜ λ°˜μ—μ„œ λ‚˜μ˜¨ λ¬Έμ œμ—¬μ„œ λ‹€μ‹œ ν’€μ–΄λ³΄μ•˜λ‹€.

🧲 python algorithm

πŸ” programmers μ˜¬λ°”λ₯Έ κ΄„ν˜Έ μŠ€νƒ/큐

def solution(ss):
    result = []
    for s in ss:
        if s == '(':
            result.append(s)
        else:
            if result == []:
                return False
            result.pop()
    return result == []

이 λ¬Έμ œλ„ ν’€μ—ˆλ˜ λ¬Έμ œμ΄μ§€λ§Œ μ•Œκ³ λ¦¬μ¦˜ μˆ˜μ—…μ— μžˆμ–΄μ„œ λ‹€μ‹œ ν’€μ–΄λ³΄μ•˜λ‹€.

🧲 javascript 이미지 객체둜 λ°”κΎΈκΈ°

πŸ” url 이미지 객체둜 λ³€ν™˜

async function convertURLtoFile(url) {
    const response = await fetch(url);
    const data = await response.blob();
    const ext = url.split(".").pop(); // url ꡬ쑰에 맞게 μˆ˜μ •ν•  것
    const filename = url.split("/").pop(); // url ꡬ쑰에 맞게 μˆ˜μ •ν•  것
    const metadata = { type: `image/${ext}` };
    return new File([data], filename, metadata);
  };
window.onload = async() => {
    const test_image = 'http://127.0.0.1:8000/media/filter/8b74b3ca29944b7bb6e3c7d25663aaba.jpg'

    const result1 = convertURLtoFile(test_image);

    let temp = undefined


    await result1.then(response => {
      temp = response
      // console.log(response)
    })

    console.log(temp)
}

promise 데이터λ₯Ό λ³΄λŠ” 것이 μ–΄λ €μ› μ§€λ§Œ λ°˜λ‚˜μ ˆ λ™μ•ˆ κ³ μƒν•˜λ©΄μ„œ 비동기 ν•¨μˆ˜λ₯Ό 거쳐온 데이터λ₯Ό λ³΄λŠ” 방법을 잘 μ΄ν•΄ν–ˆλ‹€...!
였늘 끝!

profile
Carrot_hyeong

0개의 λŒ“κΈ€