Hyebin‘s blog
[Codewars/JS] Count the number of Duplicates
Algorithm/Codewars 2022. 1. 12. 17:09

Count the number of Duplicates Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric digits. Example "abcde" -> 0 # no characters repeats more than once "aabbcde" -> 2 # 'a' and 'b' "aabBcde..

[codewars/JS] Sort the odd
Algorithm/Codewars 2022. 1. 12. 15:05

Task You will be given an array of numbers. You have to sort the odd numbers in ascending order while leaving the even numbers at their original positions. Examples [7, 1] => [1, 7] [5, 8, 6, 3, 4] => [3, 8, 6, 5, 4] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] => [1, 8, 3, 6, 5, 4, 7, 2, 9, 0] function sortArray(array) { const result = array.filter((a)=> a%2 !== 0) result.sort(function(a,b){ return a-b }); c..

[codewars/JS] Growth of a Population
Algorithm/Codewars 2022. 1. 12. 01:39

Instructions In a small town the population is p0 = 1000 at the beginning of a year. The population regularly increases by 2 percent per year and moreover 50 new inhabitants per year come to live in the town. How many years does the town need to see its population greater or equal to p = 1200 inhabitants? At the end of the first year there will be: 1000 + 1000 * 0.02 + 50 => 1070 inhabitants At ..

[codewars/JS] Sum of two lowest positive integers
Algorithm/Codewars 2022. 1. 11. 22:21

Description: Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed. For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7. [10, 343445353, 3453445, 3453545353453] should return 3453455. function sumTwoSmallestNumbers(numbers) { const sortArray = numb..

검색 태그