728x90
Problem: py.checkio.org/en/mission/frequency-sorting/
My Solution
python
접기def frequency_sorting(numbers): # eliminating duplication of elements in a list, "numbers" # then, sorting its list in ascending order set_list = sorted(list(set(numbers))) # count the number of each elements in "numbers" count = list(map(lambda x: numbers.count(x), set_list)) sorted_set_list = sorted(set_list, key=(lambda x: count[set_list.index(x)]), reverse=True) sorted_count = sorted(count, reverse = True) dummy_list = [] for ele, counts in list(zip(sorted_set_list, sorted_count)): dummy_list.extend([ele] * counts) return dummy_list
Good Solution that I see
python
접기def checkio(numbers): return sorted(sorted(numbers), key=numbers.count, reverse=True)
728x90
'프로그래밍 문제 > [Python] CheckIO' 카테고리의 다른 글
[CheckIO] Goes Right After (0) | 2021.12.03 |
---|---|
[Check-IO] Absolute Sorting (0) | 2021.11.14 |
[CheckIO] Median (0) | 2021.03.23 |
[CheckIO] Remove All After (0) | 2021.03.22 |
[Check-IO] Lightbulb Intro (0) | 2021.03.17 |
댓글