일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- 109. Convert Sorted List to Binary Search Tree
- 운영체제
- LeetCode
- Substring with Concatenation of All Words
- t1
- 프로그래머스
- Python Code
- shiba
- Decorator
- kaggle
- attribute
- Protocol
- 30. Substring with Concatenation of All Words
- 43. Multiply Strings
- Convert Sorted List to Binary Search Tree
- 밴픽
- iterator
- Python Implementation
- data science
- Class
- 315. Count of Smaller Numbers After Self
- 컴퓨터의 구조
- Regular Expression
- 파이썬
- Python
- Generator
- concurrency
- DWG
- 715. Range Module
- 시바견
- Today
- Total
목록분류 전체보기 (407)
Scribbling
1. Pandas Series 1.1. Series import pandas as pd a = [1, 7, 2] myvar = pd.Series(a) print(myvar) 1.2. with index a = [1, 7, 2] myvar = pd.Series(a, index = ["x", "y", "z"]) print(myvar) 1.3. set of (keys, values) calories = {"day1": 420, "day2": 380, "day3": 390} myvar = pd.Series(calories) print(myvar) calories = {"day1": 420, "day2": 380, "day3": 390} myvar = pd.Series(calories, index = ["day1..
0. JavaScript Environment https://jsbin.com/?js,console JS Bin Sample of the bin: jsbin.com 1. Variables let x = 3; const y = 4; console.log(x*y); let num = 3.14; console.log(typeof(x)) 2. Conditionals 2.1. If let season = 'summer'; if (season === 'spring') { console.log('It\'s spring! The trees are budding!'); } else if (season === 'winter'){ console.log('It\'s winter! Everything is covered in ..
Question: There is a stream of two different operations. One is placing a point on a single axis. The other is to check if there's a point in a given range. (see the image below) 1> Brute Force 1-1> For every range check, we can just go over all the points it includes. Time complexity for that would be O(R * N), where R is range and N is the number of range checks. 1-2> Or, we can just go over a..
Monotonic stack or monotonicly increasing/decreasing stack is a stack which keeps its elements in increasing/decreasing order. Monotonic stacks are useful when, - Finding the very previous less element of each element in a vector in O(N) time complexity - Finding the very next less element of each element in a vector in O(N) time complexity (1) Code Example To get the very previous less (or equa..
클래스 메타프로그래밍은 실행 도중에 클래스를 생성하거나 커스터마이징 하는 기술이다. 클래스 데코레이터와 메타클래스는 이를 위한 방법이다. 메타클래스는 강력하지만, 어렵다. 클래스 데커레이터는 사용하기 쉽지만, 상속 계층 구조가 있는 경우에는 사용하기 어렵다. 1. 런타임에 클래스 생성하기 파이썬 표준 라이브러리에는 collections.namedtuple 이라는 클래스 팩토리가 있다. 클래스명과 속성명을 전달하면 이름 및 점 표기법으로 항목을 가져올 수 있다. 유사한 클래스 팩토리를 만들면서 런타임에 클래스 생성하는 방법을 확인해보자. def record(cls_name, field_names): try: field_names = field_names.replace(',', '').split() exce..
디스크립터를 이요하면 여러 속성에 대한 동일한 접근 논리를 재사용 가능하다. 디스크립터는 __get__(), __set__(), __delete__() 메서드로 구성된 프로토콜을 구현하는 클래스다. property 클래스는 디스크립터 프로토콜을 완벽히 구현한다. 아래 글에서 동적 속성을 구현함에 있어 프로퍼티 팩토리를 이용했었다. https://focalpoint.tistory.com/314 Python: Dynamic attributes and properties (동적 속성과 프로퍼티) 파이썬에서는 데이터 속성과 메서드를 통틀어 속성이라고 한다. 메서드는 단지 호출가능한 속성이다. 프로퍼티를 사용하면 클래스인터페이스를 변경하지 않고도 공개 데이터 속성을 접근자 메 focalpoint.tistory.c..
파이썬에서는 데이터 속성과 메서드를 통틀어 속성이라고 한다. 메서드는 단지 호출가능한 속성이다. 프로퍼티를 사용하면 클래스인터페이스를 변경하지 않고도 공개 데이터 속성을 접근자 메서드(getter & setter)로 대체할 수 있다. 파이썬 인터프리터는 obj.attr과 같은 점 표기법으로 표현되는 속성에 대한 접근을 __getattr__()과 __setattr__() 등 특별 메서드를 호출하여 평가한다. 사용자 정의 클래스는 __getattr__() 메서드를 오버라이드하여 '가상 속성'을 구현할 수 있다. 1. 동적 속성을 이용한 데이터 랭글링 다음과 같은 json data를 랭글링 하는 예제를 살펴보자. { "Schedule": { "conferences": [{"serial": 115 }], "ev..
크게 두 단계로 풀 수 있다. 1) 알파벳 조합이 동일한 집합끼리 나눈다. 2) 각 집합 내에서 단어를 연결하고, 소 집합의 갯수를 구한다. This prob can be solved within two steps. 1) Group words by alphabet combinations 2) Connect words in each group and then get the number of small groups Code is quite straightforward, so I guess there's no need to explain more. Time complexity would be (O(N**2*k)), where N is the number of words and k is length of a w..
Thread vs Asyncio 스레드나 코루틴을 통해 콘솔 에니메이션을 구현할 수 있다. 먼저 스레드를 이용하는 코드이다. Console animation can be implemented with either threads or coroutines. First, with thread. import threading import itertools import time import sys class Signal: go = True def spin(msg, signal): write, flush = sys.stdout.write, sys.stdout.flush for char in itertools.cycle('|/-\\'): status = char + ' ' + msg write(status) flus..
img0 = img1 = img2 = 'img' cap0 = cap1 = cap2 = 'cap' dataset = [(img0, cap0), (img1, cap1), (img2, cap2)] list = [(1, 2), (3, 4), (5, 6)] print(*list) for x in zip(*list): print(x) print(*dataset) imgs, caps = zip(*dataset) print(imgs) l1 = 'abc' l2 = '123' l3 = '가나다' for pair in zip(l1, l2, l3): print(pair)