python lambda(2)
-
[TIL] 220409 - python 문자열 자릿수 채우기, 순열/조합/product, lambda함수를 활용한 정렬
2022/04/08 FRI 🎢 ☑️ 프로그래머스 해시 2문제 🔛 국제개발협력개론 에세이 ✔️ 문자열 앞에 0 채우기 (자릿수만큼 표시) : 문자열.zfill(표시할자릿수) ex. str = "39" → str.zfill(4) → "0039" 또는 문자열.rjust(표시할자릿수, 채울문자) - .rjust , .ljust 모두 가능 ex. str = "39" → str.rjust(4, "0") → "0039" ex. str = "39" → str.ljust(4, "a") → "39aa" ✔️ 경우의 수 itertools 라이브러리 - 순열, 조합, product * from itertools import permutation/combination/product * [(),(),...] 리스트 안에 여러 튜..
2022.04.10 -
[해시][정렬] 프로그래머스 - 베스트앨범 문제 - 파이썬 python
https://programmers.co.kr/learn/courses/30/lessons/42579?language=python3 난리가 나버렸다 !!!!! 해시 문제이지만 정렬 문제라고 해도 될 것 같다. 람다 함수를 잘 활용해 정렬하는 것이 중요하다. 참고한 풀이: https://dream-and-passion.tistory.com/5 def solution(genres, plays): answer = [] cnt = len(genres) # = len(plays) gsp = {} for i in range(cnt): if genres[i] not in gsp: gsp[genres[i]] = plays[i] else: gsp[genres[i]] += plays[i] gsp = dict(sorted(..
2022.04.09