Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 |
Tags
- pvalue
- 데이터분석가
- SQL
- 데이터가공
- 표본
- 그로스마케터
- DAU
- INSERTINTO
- 데이터분석
- warehouser
- 데이터
- engagement
- 통계
- WAU
- 이전행
- Python
- categorical
- ABTest
- onehot
- 특정컬럼
- dataanalysis
- 전처리
- data
- GTM
- 리텐션
- dataanalyst
- 그룹
- 코테
- sql로데이터
- row추가
Archives
- Today
- Total
Meiren
[5일 벼락치기] 프로그래머스 햄버거 만들기(lv.1) 본문
파이썬 안쓰다가 4개월만에 하려니까 기본 문법부터 다 틀린다. 정신체리
그리고 시간초과해서 .... 노답
1. 문제

2. 틀린 내 코드
def solution(ingredient):
answer = 0
ingrd = ''.join(str(e) for e in ingredient)
while '1231' in ingrd:
answer += 1
ingrd = ingrd.replace('1231','', 1)
return answer
3. 통과한 내 코드
구글링함... pop쓰는 걸 습관화 해야 할 듯
4. 다른 통과 코드들
def solution(ingredient):
answer = 0
s = []
for i in ingredient:
s.append(i)
if s[-4:] == [1, 2, 3, 1]:
answer += 1
for j in range(4):
s.pop()
return answer
- list.pop()
맨 마지막 인자 삭제 - 특정 수만큼 반복하고자 할 때,
for i in range(n): - stack, slicing, 역순
list[-n:] == [a, s, d, f]
5. 자잘한 내 실수들
list to str
- 리스트의 인자가 문자열이 아닌 숫자인 경우, 인자들을 문자로 바꾼 뒤 join 해야한다
''.join(str(e) for e in ingredient)
- 이를 다시 리스트로 정의해줘야 적용된다.
''.join(str(e) for e in ingredient)
ingredient = ''.join(str(e) for e in ingredient)
replace
- 해당되는 문자 중 첫번째 문자만 교체하고 싶을 때, replace( , , 1)
ingredicnt = ingredient('1231', '', 1)