bisect
import bisect
mylist = [1, 2, 3, 7, 9, 11, 33]
print(bisect.bisect(mylist, 3))
product
import itertools
iterable1 = 'ABCD'
iterable2 = 'xy'
iterable3 = '1234'
itertools.product(iterable1, iterable2, iterable3)
def getMyDivisor(n):
divisorsList = []
for i in range(1, int(n**(1/2)) + 1):
if (n % i == 0):
divisorsList.append(i)
if ( (i**2) != n) :
divisorsList.append(n // i)
divisorsList.sort()
return divisorsList
# 최대공약수
def gcd(a, b):
if b ==0:
return a
if a%b ==0:
return b
else:
return gcd(b, a%b)
def toMinutes(time):
h,m=map(int,time.split(":"))
return h*60+m
# 방법 1 - sum 함수
answer = sum(my_list, [])
# 방법 5 - reduce 함수 이용1
from functools import reduce
list(reduce(lambda x, y: x+y, my_list))
sum(map(lambda x:x[1], nums))
list(map(lambda x:x[0], nums))
lambda x: x*3
이게 어느 문제에서 썼던 거더라..
for i, value in enumerate(melody):
if m==melody[i:i+len(m)]:
print("yes")
mylist = [ [1,2,3], [4,5,6], [7,8,9] ]
new_list = list(map(list, zip(*mylist)))
mydict={x:0 for x in _list}
# from collections import defaultdict
mydict=defaultdict(list)
nums.sort(reverse=True)
nums.sort(key=lamda x: (x[0], -x[1]))