반응형

전체 글 125

[python] 9095. 1, 2, 3 더하기

문제 잘못된 풀이 T = int(input()) for i in range(0, T): n = int(input()) dp = [0] * n dp[0] = 1 dp[1] = 2 dp[2] = 4 for j in range(3, n): dp[j] = dp[j-1] + dp[j-2] + dp[j-3] print(dp[n-1]) 해당 문제는 n=1일 때, 1 / n=2일 때, 2 / n=3일 때, 4 / n=4일 때, 7 / n=5일 때, 13 / n=6일 때, 24이다. dp를 n만큼 초기화하여 문제 풀이를 시도했다. 런타임 에러(IndexError)로 문제풀이에 실패했다. 올바른 풀이 T = int(input()) def dfs(n): if n == 1: return 1 elif n == 2: return..

[python] 1065. 한수

문제 올바른 풀이 N = int(input()) def check_hansu(num, check): if num > 99: # 1000보다 작은 자연수 num_str = [int(i) for i in str(num)] if num_str[1]-num_str[0] == num_str[2]-num_str[1]: check = 1 else: check = 1 return check check = 0 cnt = 0 for i in range(1, N+1): cnt += check_hansu(i, check) print(cnt) 해당 문제는 각 자리수의 차가 동일한지를 확인하는 문제이다. 완전 탐색으로 문제를 해결하면 되는데, 1000보다 작거나 같은 자연수만큼 for문을 돌려서 각 자리수의 차를 확인해보면 된다..

[github] failed to push some refs to '~'

에러 발생 상황 앞서 작성했던 글처럼 git push 하는데 에러가 생겨서 인증 토큰을 재발급 받고 등록 후에 다시 git push command를 작성하였다. 이후, 다음과 같은 에러가 발생하였다. Updates were rejected because the remote contains work that you do not have locally. 에러 해결 방법 해당 에러는 같은 repository에 push를 주었다는 것이 원인이라고 한다. 다음과 같이 해결하면 된다고 한다. 다음의 command로 해결할 수 있다.

Error Solution 2023.07.27

[github] support for password authentication was removed

에러 발생 상황 git push origin master command를 작성하였을 때, 다음과 같은 에러가 발생하였다. remote: Support for password authentication was removed on August 13, 2021. remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication. fatal: Authentication failed for ' ~ ' 해당 에러는 인증 토큰의 기간..

Error Solution 2023.07.27

[python] 4673. 셀프 넘버

문제 나의 풀이 not_self_number = list() for i in range(1, 10001): number = [int(num) for num in str(i)] not_self_number.append(sum(number) + i) if i not in not_self_number: print(i) 나는 각 자릿수를 더하는 과정을 string으로 변환하여 for문으로 처리하였다. 그리고 self_number가 아닌 숫자들을 담을 list를 만들어서 생성자를 담아준다. 최종적으로 생성자가 없는 셀프 넘버를 출력한다. 남의 풀이 def self_number(num): self_num = num while num != 0: self_num += num%10 # 오른쪽 끝 숫자를 더함 num //..

[Mac OS] missing xcrun 에러 해결

에러 발견 상황 git config --list command를 작성하였을 때, 다음과 같은 missing xcrun 에러를 발견하였다. xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun 해당 에러는 mac os를 업데이트하면 발생할 수 있다고 한다. 에러 해결 해당 에러는 xcode-select 명령으로 CommandLineTools(command line developer tools)를 설치하여 해결할 수 있다. xcode-select --install 소프트웨어 설치는 약 3-5분 ..

Error Solution 2023.07.27

[python] 1436. 영화감독 숌

문제 잘못된 풀이 N = int(input()) num_list = list() num_list.append(666) for i in range(1, 10001): num = str(i) + str(666) num_list.append(int(num)) num = str(666) + str(i) num_list.append(int(num)) num_list.sort() print(num_list[N-1]) 666을 기준으로 앞 뒤에 숫자를 붙여서 .sort()한다면 문제를 해결할 수 있을 것이라고 생각했다. 올바른 풀이 N = int(input()) cnt = 0 num = 1 while True: if '666' in str(num): cnt+=1 if cnt==N: print(num) break nu..

Contrastive Learning

📍 Contrastive Learning의 목적 embedding space에서 유사한 positive pair는 거리가 가깝게, 그리고 유사하지 않은 negative pair는 거리가 멀게 학습하는 것이다. 유사한지, 유사하지 않은지에 대한 기준이 되는 현재 data point를 anchor(query)라고 한다. anchor와 유사한 sample을 positive point라고 하고, anchor와 유사하지 않은 sample을 negative point이라고 한다. - anchor: 현재 기준이 되는 데이터 샘플 - positive sample: 기준이 되는 데이터 샘플과 같은 class를 가지는 상관관계가 높은 샘플 - negative sample: 기준이 되는 데이터 샘플과 다른 class를 가지..

728x90
반응형