일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 완전탐색
- 프로그래머스
- 파이썬
- 데이터분석
- CodingTest
- lambda
- itertools
- counter
- collections
- join
- mysql
- Stack
- 연습문제
- lv4
- 코테
- Level2
- python
- coding test
- 조합
- programmers
- BFS
- 코딩테스트
- time complexity
- 코딩
- import re
- Queue
- 시간복잡도
- level4
- coding
- sql
- Today
- Total
목록import functools (1)
ror_coding
[Python] reduce (functools)
from functools import reduce (누적 함수 적용)partial (함수의 일부 인수 고정해서 새로운 함수 생성)lru_cache (함수의 실행 결과 캐싱하여 동일한 입력에 대해 빠르게 반환) reducefrom functools import reducefrom math import gcd# 리스트의 모든 값 곱하기nums = [1, 2, 3, 4]= reduce(lambda x, y: x * y, nums) # 24= reduce(gcd, nums) # 모든 원소의 최대공약수 구함. partialfrom functools import partial# 기본 인자를 고정한 함수 생성def power(base, exp): return base ** expsquare = partial(..
Algorithm/Python
2025. 1. 16. 16:33