본문 바로가기

파이썬9

1912 연속합 with 파이썬 (feat. DP, 동적 프로그래밍) 08.18.2023 1. 문제 시간 제한 메모리 제한 제출 정답 맞힌 사람 정답 비율 1 초 (추가 시간 없음) 128 MB 129671 48065 34077 35.739% 문제 n개의 정수로 이루어진 임의의 수열이 주어진다. 우리는 이 중 연속된 몇 개의 수를 선택해서 구할 수 있는 합 중 가장 큰 합을 구하려고 한다. 단, 수는 한 개 이상 선택해야 한다. 예를 들어서 10, -4, 3, 1, 5, 6, -35, 12, 21, -1 이라는 수열이 주어졌다고 하자. 여기서 정답은 12+21인 33이 정답이 된다. 입력 첫째 줄에 정수 n(1 ≤ n ≤ 100,000)이 주어지고 둘째 줄에는 n개의 정수로 이루어진 수열이 주어진다. 수는 -1,000보다 크거나 같고, 1,000보다 작거나 같은 정수이다... 2023. 8. 18.
TypeError: super(type, obj): obj must be an instance or subtype of type 에러 이유 및 해결방법 1. Error Code Class A: def func(x: int): return x + 1 Class B(A): def use_func(): a = [super().func(i) for i in range(3)] print(a) the original code is different and has been modified since posting it online could cause code leaks of the company I am working for. Yet, I believe this code explains the prob perfect. I got an error in this line: a = [super().func(i) for i in range(3)] 2. The cuase,.. 2023. 7. 13.
켄트백의 TDD 3회차 스터디 18장-24장(~200p) 06.27.2023 1. 전체 코드 공유 (The final code) class TestCase: def __init__(self, name): self.name = name def run(self, result): result.testStarted() self.setUp() try: method = getattr(self, self.name) method() except: result.testFailed() self.tearDown() def setUp(self): pass def tearDown(self): pass class WasRun(TestCase): def __init__(self, name): self.wasRun = None TestCase.__init__(self, name) def .. 2023. 6. 27.
urlopen과 urlretrieve 2023.06.09 1. urlretrieve 1-1. What is urlretreive? urlretrieve함수는 URL을 통해 파일을 다운로드 받을 때 쓰는 함수이다. 필수 인자는 하나이고, 다운로드 받고싶은 파일의 url이다. 리턴값은 카피된 로컬 파일의 이름(경로)와 헤더, 두 개로 구성된 튜플이다. 헤더는 urlOpen.info()를 사용했을 때의 리턴값과 같다. urlretrieve is a function that allows users to download a nextwork object, denoted by a URL, into a local file. The required argument is the url. It returns a tuple that has a filename t.. 2023. 6. 9.
1717 set expression (집합의 표현) with Union-Find in Python3 0. Background To explain why this problem should be solved with union-find not Set in Python. 1. Union-Find 1-1. What is it? A data structure to handle data that is splited in subsets. It is also a sort of disjoint-set. 1-2. How does it work? As the name sounds like, this algorithm is used to get disjoint-set by unioning nodes and finding parents. 1-2-1. Find Find is implemented with a recursive.. 2023. 4. 23.
18258 Queue2(큐2) with Python3 2023.02.24 0. Background Queue 1 problem in baekjoon has been done but queue 2 problem has to be O(1) in time complexity. I could not solve this on my own and would like to write down here what I've found and learnt to resolve it. 1. Issue 1-1. Queue 1 code n = int(input()) queue = [] commands = [input() for _ in range(n)] for command in commands: if "push" in command: queue.append(int(command.s.. 2023. 2. 24.