본문 바로가기
  • 머킹이의 머신로그
오늘부터 코딩테스트

[오늘부터 코딩테스트]파이썬으로 프로그래머스 코딩 기초 프로그램 풀기

by 머킹 2023. 11. 16.
728x90

[파이썬] 프로그래머스  Lv0. 커피 심부름, 그림 확대

안녕하세요 머킹입니다.

오늘 드디어 3번째 프로젝트가 끝났습니다.

그리고 드디어 git 에러를 해결했습니다..

 

프로젝트는 끝났지만 문서로 열심히 작성해야해서 끝난게 아닌 것 같기도 하고요.

그리고 이제 블로그에 테크 블로그를 공부하고 제가 모르는 단어들을 정리해보려고 합니다 ㅎㅎ

아마 다음주부터 적을 것 같습니다.


커피 심부름

 

 

def solution(order):
    cold_americano_price = 4500
    hot_americano_price = 4500
    cold_cafelatte_price = 5000
    hot_cafelatte_price = 5000

    total_price = 0

    for item in order:
        if "iceamericano" in item or "americanoice" in item:
            total_price += cold_americano_price
        elif "hotamericano" in item or "americanohot" in item:
            total_price += hot_americano_price
        elif "icecafelatte" in item or "cafelatteice" in item:
            total_price += cold_cafelatte_price
        elif "hotcafelatte" in item or "cafelattehot" in item:
            total_price += hot_cafelatte_price
        elif "americano" in item:
            total_price += cold_americano_price
        elif "cafelatte" in item:
            total_price += cold_cafelatte_price 
        elif "anything" in item:
            total_price += cold_americano_price 

    return total_price

 

엄청난 노가다 코드입니다.

def solution(order):
    answer = 0
    for want in order:
        if 'latte' in want:
            answer += 500
        answer += 4500

    return answer

이게 된다다는게 너무 신기해서 

gpt에게 물어보니 이렇게 답변했습니다.

 

 

 


 

그림 확대

 

 

def solution(picture, k):
    answer = []
    for row in picture:
        expanded_row = ''.join([char * k for char in row])
        answer.extend([expanded_row] * k)
    return answer

 

되게 제가 생각했던 코테다운(?) 코테를 푸니까 재밌네요 ㅎㅎ

이제 Lv1로가면 더 코테다운 문제를 풀겠죠?