전체보기
-
파이썬: 람다 표현식Python/이것저것 파이썬 2023. 10. 7. 07:12
1씩 증가하는 카운터 import tkinter counter = 0 def add(): global counter counter += 1 label.config(text=str(counter)) root = tkinter.Tk() label = tkinter.Label(root, text=str(counter)) label.pack() button = tkinter.Button(root, text='증가', width=15, command=add) button.pack() root.mainloop() 여기에 5씩 증가하는 버튼을 추가한다면? import tkinter counter = 0 def add1(): global counter counter += 1 label.config(text=str(co..
-
[python] emf 2 pngPython/이것저것 파이썬 2023. 8. 2. 10:04
PPT를 만들기 위해 PDF에 있는 사진을 천여장 옮기게 되었다. 열심히 복붙했고 --; 그런데 완성된 파일이 너무 큰 게 아닌가 ㅠ,.ㅠ pptx 파일 확장자를 zip으로 바꾼 뒤 압축을 풀면 안에 파일을 구경할 수 있다. 이미지 파일이 신기하게도 EMF라는 특이한 확장자로 되어 있더란~!! 꿀뷰에서도 지원되지 않는 특이한 포맷... (어도비의 벡터이미지 포맷인가보다.) 혹시나 파이썬의 PIL로 읽을 수 있을까 해서 돌려보니... 헉 잘 읽힌다... 이거슨~! https://www.adobe.com/kr/creativecloud/file-types/image/vector/emf-file.html EMF 파일의 정의와 여는 방법 | Adobe 벡터 이미지 포맷인 EMF(Enhanced Metafile)에..
-
-
프로그래머스 / 두 원 사이의 정수코딩 테스트/Level 2 2023. 4. 15. 15:54
https://school.programmers.co.kr/learn/courses/30/lessons/181187 파이썬 def solution(r1, r2): answer = 0 pow_r1, pow_r2 = r1 ** 2, r2 ** 2 for y in range(1, r2 + 1): temp1 = pow_r1 - y ** 2 if temp1 >= 0: temp2 = temp1 ** 0.5 x1 = int(temp2) - (1 if temp2 == int(temp2) else 0) else: x1 = -1 answer += int((pow_r2 - y ** 2) ** 0.5) - x1 return answer * 4
-
프로그래머스 / 연속된 부분 수열의 합코딩 테스트/Level 2 2023. 4. 11. 23:29
https://school.programmers.co.kr/learn/courses/30/lessons/178870 파이썬 이렇게 쉽게는 넘어가지 않겠지.. def solution(sequence, k): answer = [] for i in range(len(sequence)): for j in range(i + 1, len(sequence) + 1): s = sum(sequence[i:j]) if s == k: answer.append([i, j - 1]) elif s > k: break return sorted(answer, key=lambda x: x[1] - x[0])[0] 소티드를 이용해서 간결하게.. def solution(sequence, k): answer = [] left = right..
-
프로그래머스 / 달리기 경주코딩 테스트/Level 1 2023. 4. 10. 18:21
https://school.programmers.co.kr/learn/courses/30/lessons/178871 파이썬 def solution(players, callings): players_map = {each: index for index, each in enumerate(players)} for player in callings: index = players_map[player] players_map[player] -= 1 players_map[players[index - 1]] += 1 players[index - 1], players[index] = players[index], players[index - 1] return players 계속 find 명령을 쓰면 시간이 너무 오래 걸린다...
-
프로그래머스 / 과제 진행하기코딩 테스트/Level 2 2023. 4. 1. 13:22
https://school.programmers.co.kr/learn/courses/30/lessons/176962 파이썬 def solution(plans): timeline = [] plans2 = map(lambda x: (x[0], int(x[1][0]) * 60 + int(x[1][1]), x[2]), map(lambda x: (x[0], x[1].split(':'), int(x[2])), plans)) for name, start, playtime in sorted(plans2, key=lambda x: x[1]): for index, each in enumerate(timeline): if each[1] > start: timeline[index][1] += playtime timeline...