Henu
개발냥발
Henu
전체 방문자
오늘
어제
  • 분류 전체보기 (411)
    • DevOps (52)
      • Kubernetes (19)
      • Docker (14)
      • AWS (3)
      • Nginx (4)
      • Linux (4)
      • ArgoCD (1)
      • CN (2)
      • NATS (0)
      • Git (5)
    • Back-End (30)
      • Django (18)
      • Spring (5)
      • JPA (1)
      • MSA (5)
    • CS (87)
      • SystemSoftware (20)
      • OS (25)
      • Computer Architecture (16)
      • Network (23)
      • Database (2)
    • Lang (21)
      • Java (9)
      • Python (4)
      • C# (8)
    • Life (12)
    • 블록체인 (2)
    • Algorithm (204)
      • BOJ (160)
      • 프로그래머스 (19)
      • LeetCode (4)
      • SWEA (1)
      • 알고리즘 문제 해결 전략 (8)
      • DS, algorithms (7)
      • Checkio (5)
    • IT (2)

블로그 메뉴

  • GitHub
  • 글쓰기
  • 관리자

공지사항

  • Free!

인기 글

태그

  • 프로그래머스
  • BFS
  • 백트래킹
  • boj
  • django
  • Kubernetes
  • 다이나믹 프로그래밍
  • DFS
  • docker
  • Network

최근 댓글

최근 글

티스토리

hELLO · Designed By 정상우.
Henu

개발냥발

Algorithm/Checkio

[Checkio] HOME. Bigger Price

2020. 6. 9. 17:05

Your mission here is to find the TOP most expensive goods. The amount we are looking for will be given as a first argument and the whole data as the second one

Input: int and list of dicts. Each dicts has two keys "name" and "price"

Output: the same as the second Input argument.

 

- 입력받은 수 만큼 비싼 상품부터 출력

 

1
2
3
4
5
def bigger_price(limit: int, data: list) -> list:
 
    data = sorted(data, key = lambda x : x["price"], reverse=True)
    
    return data[0:limit]
Colored by Color Scripter
cs

data 리스트 속의 요소들이 딕셔너리로 주어진다

-> 딕셔너리의 "price"키의 value에 대해 내림차순 정렬한다

-> 입력받은 수 만큼 요소를 앞에서부터 리턴한다

 

20개쯤 풀어봤는데 checkio 기본문제들이 다 이렇게 간단하게 풀리지만 그만큼 기본 문법을 잘 알고 있냐고 묻는것 같아서 좋다

'Algorithm > Checkio' 카테고리의 다른 글

[Checkio] Scientific Expedition. Sum by Type  (0) 2020.06.17
[Checkio] Electronic station. Surjection Strings  (0) 2020.06.11
[Checkio] Electronic station. Digits Multiplication  (0) 2020.06.09
[Checkio] HOME. Sort Array by Element Frequency  (0) 2020.06.08
    'Algorithm/Checkio' 카테고리의 다른 글
    • [Checkio] Scientific Expedition. Sum by Type
    • [Checkio] Electronic station. Surjection Strings
    • [Checkio] Electronic station. Digits Multiplication
    • [Checkio] HOME. Sort Array by Element Frequency

    티스토리툴바