코딩테스트/프로그래머스

[Python] [COS Pro 샘플문제] [2급]

박소민 2022. 8. 25. 20:59
문제 다운 링크) https://www.ybmit.com/cos_pro/cos_pro_r_test.jsp

 

문제 1
def solution(shirt_size):
  size=["XS","S","M","L","XL","XXL"]
  dic={}
  for s in size: 
    dic[s]=0

  for shirt in shirt_size:
    dic[shirt]+=1

  return list(dic.values())
shirt_size=["XS", "S", "L", "L", "XL", "S"]
#결과
[1, 2, 0, 2, 1, 0]

 

문제 2
def solution(price, grade):
  if grade=="S":
    price=0.95*price
  elif grade=="G":
    price=0.9*price
  elif grade=="V":
    price=0.85*price

  return int(price)
price=2500
grade="V"
price2=96900
grade2="S"

#결과
2125
92055

 

문제 3
def solution(start_month, start_day, end_month, end_day):
  answer=0
  month=[0,31,28,31,30,31,30,31,31,30,31,30,31]
  
  for _ in range(start_month+1,end_month):
    answer+=month[i]
  answer+=month[start_month]-start_day
  answer+=end_day

  return answer
#start= 1/2 , end= 2/2
start_month, start_day, end_month, end_day= 1,2,2,2

#결과
31