https://www.codewars.com/kata/5ac6932b2f317b96980000ca
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
Task
Given a list of digits, return the smallest number that could be formed from these digits, using the digits only once (ignore duplicates).
Notes:
- Only positive integers will be passed to the function (> 0 ), no negatives or zeros.
Input >> Output Examples
minValue ({1, 3, 1}) ==> return (13)
Explanation:
(13) is the minimum number could be formed from {1, 3, 1} , Without duplications
minValue({5, 7, 5, 9, 7}) ==> return (579)
Explanation:
(579) is the minimum number could be formed from {5, 7, 5, 9, 7} , Without duplications
minValue({1, 9, 3, 1, 7, 4, 6, 6, 7}) return ==> (134679)
Explanation:
(134679) is the minimum number could be formed from {1, 9, 3, 1, 7, 4, 6, 6, 7} , Without duplications
코드
function minValue(values){
return Number([...new Set(values)].sort((a, b) => a - b).join(''));
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Find the capitals (7 kyu) / JavaScript (0) | 2023.03.25 |
---|---|
[Codewars] Sum The Strings (8 kyu) / JavaScript (0) | 2023.03.24 |
[Codewars] Grasshopper - Terminal game combat function (8 kyu) / JavaScript (0) | 2023.03.22 |
[Codewars] Is the string uppercase? (8 kyu) / JavaScript / Python (0) | 2023.03.21 |
[Codewars] Vowel remover (8 kyu) / JavaScript (0) | 2023.03.20 |
댓글