본문 바로가기

카테고리 없음

2021-01-10 12시 개발자 글 모음 | "두 개 뽑아서 더하기" 외 7개 이야기

[리팩토링 2판 파이썬 코드로 변경해보기] 1탄 기본 코드 세팅 by 권태형 about Python

  • plays): total_amount = 0 volume_credits = 0 result = f"청구 내역 (고객명: {invoice['customer']})
  • 2f}' for perf in invoice["performances"]: play = plays[perf["playID"]] this_amount = 0 if play["type"] == "tragedy": this_amount = 40000 if perf["audience"] > 30: this_amount += 1000 * (perf["audience"] - 30) elif play["type"] == "comedy": this_amount = 30000 if perf["audience"] > 20: this_amount += 10000 + 500 * (perf["audience"] - 20) this_amount += 300 * perf["audience"] else: raise Exception("알 수 없는 장르") volume_credits += max(perf["audience"] - 30
  • floor(perf["audience"] / 5) result += f' {play["name"]}: {dollar_format


[리팩토링 2판 파이썬 코드로 변경해보기] 2탄 statement() 테스트 코드 추가 by 권태형 about Python

  • TestCase): def test_statement(self): # Given: json 파일로 부터 invoice와 plays를 불러오고
  • load(json_file)[0] with open("plays
  • json") as json_file: plays = json


[리팩토링 2판 파이썬 코드로 변경해보기] 3탄 함수 쪼개기, 변수명 변경 by 권태형 about Python

  • 2f}' for perf in invoice["performances"]: play = plays[perf["playID"]] this_amount = 0 if play["type"] == "tragedy": this_amount = 40000 if perf["audience"] > 30: this_amount += 1000 * (perf["audience"] - 30) elif play["type"] == "comedy": this_amount = 30000 if perf["audience"] > 20: this_amount += 10000 + 500 * (perf["audience"] - 20) this_amount += 300 * perf["audience"] else: raise Exception("알 수 없는 장르") volume_credits += max(perf["audience"] - 30
  • play): if play["type"] == "tragedy": this_amount = 40000 if perf["audience"] > 30: this_amount += 1000 * (perf["audience"] - 30) elif play["type"] == "comedy": this_amount = 30000 if perf["audience"] > 20: this_amount += 10000 + 500 * (perf["audience"] - 20) this_amount += 300 * perf["audience"] else: raise Exception("알 수 없는 장르") return this_amount total_amount = 0 volume_credits = 0 result = f"청구 내역 (고객명: {invoice['customer']})
  • play): result = 0 if play["type"] == "tragedy": result = 40000 if a_performance["audience"] > 30: result += 1000 * (a_performance["audience"] - 30) elif play["type"] == "comedy": result = 30000 if a_performance["audience"] > 20: result += 10000 + 500 * (a_performance["audience"] - 20) result += 300 * a_performance["audience"] else: raise Exception("알 수 없는 장르") return result total_amount = 0 volume_credits = 0 result = f"청구 내역 (고객명: {invoice['customer']})


[BOOK] 나는 LINE 개발자입니다 by 유재욱


    2019 카카오 블라인드 코딩테스트 오픈채팅방 by 사지원

    • 채팅방에 Muzi와 Prodo라는 닉네임을 사용하는 사람이 순서대로 들어오면 채팅방에는 다음과 같이 메시지가 출력된다
    • Prodo 라는 닉네임으로 들어올 경우 기존에 채팅방에 남아있던 Muzi도 Prodo로 다음과 같이 변경된다
    • 채팅방에 두 번째로 들어왔던 Prodo가 Ryan으로 닉네임을 변경하면 채팅방 메시지는 다음과 같이 변경된다


    2019 카카오 블라인드 코딩테스트 실패율 by 사지원

    • 게임을 이용하는 사용자가 현재 멈춰있는 스테이지의 번호가 담긴 배열 stages가 매개변수로 주어질 때
    • 실패율이 높은 스테이지부터 내림차순으로 스테이지의 번호가 담겨있는 배열을 return 하도록 solution 함수를 완성하라
    • 모든 사용자가 마지막 스테이지에 있으므로 4번 스테이지의 실패율은 1이며 나머지 스테이지의 실패율은 0이다


    완주하지 못한 선수 by 사지원 about Algorithm

    • 완주자 명단에는 없기 때문에 완주하지 못했습니다
    • 완주자 명단에는 없기 때문에 완주하지 못했습니다
    • 완주자 명단에는 한 명밖에 없기 때문에 한명은 완주하지 못했습니다


    두 개 뽑아서 더하기 by 사지원 about Algorithm

    • numbers에서 서로 다른 인덱스에 있는 두 개의 수를 뽑아 더해서 만들 수 있는 모든 수를 배열에 오름차순으로 담아 return 하도록 solution 함수를 완성해주세요
    • def solution ( numbers ): sets = set () for base in range ( len ( numbers ) - 1 ): for target in range ( base + 1
    • add ( numbers [ base ] + numbers [ target ]) answer = [] for item in sets : answer