Hyebin‘s blog
article thumbnail
[Codewars/JS] Convert string to camel case
Algorithm/Codewars 2022. 1. 30. 18:43

Detail Digital root is the recursive sum of all the digits in a number. Digital root - Wikipedia The digital root (also repeated digital sum) of a natural number in a given radix is the (single digit) value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The pro en.wikipedia.org Given n, take the sum of th..

[Codewars/JS] Convert string to camel case
Algorithm/Codewars 2022. 1. 30. 17:05

Detail Complete the method/function so that it converts dash/underscore delimited words into camel casing. The first word within the output should be capitalized only if the original word was capitalized (known as Upper Camel Case, also often referred to as Pascal case). Examples "the-stealth-warrior" gets converted to "theStealthWarrior" "The_Stealth_Warrior" gets converted to "TheStealthWarrio..

[Codewars/JS] Disemvowel Trolls
Algorithm/Codewars 2022. 1. 21. 00:58

Detail Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example, the string "This website is for losers LOL!" would become "Ths wbst s fr lsrs LL!". Note: for this kata y isn..

[Codewars/JS] Find the odd int
Algorithm/Codewars 2022. 1. 20. 18:18

Given an array of integers, find the one that appears an odd number of times. There will always be only one integer that appears an odd number of times. Examples [7] should return 7, because it occurs 1 time (which is odd). [0] should return 0, because it occurs 1 time (which is odd). [1,1,2] should return 2, because it occurs 1 time (which is odd). [0,1,0,1,0] should return 0, because it occurs..

article thumbnail
[Codewars/JS] Vowel Count
Algorithm/Codewars 2022. 1. 18. 18:29

Detail Return the number (count) of vowels in the given string. We will consider a, e, i, o, u as vowels for this Kata (but not y). The input string will only consist of lower case letters and/or spaces. function getCount(str) { var vowelsCount = 0; str = str .split("") .filter( (a) => a.match("a") || a.match("e") || a.match("i") || a.match("o") || a.match("u") ); vowelsCount = str.length; retur..

[Codewars/JS] Moving Zeros To The End
Algorithm/Codewars 2022. 1. 14. 15:40

Detail Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements. moveZeros([false,1,0,1,2,0,1,3,"a"]) // returns[false,1,1,2,1,3,"a",0,0] var moveZeros = function (arr) { // 0 카운터 세기 let arrLength = arr.length; let count = 0; for (let i = 0; i v !== 0), ...arr.filter(v => v === 0)] } 이 방법은 애플코딩에서 배웠던 방법이라 다시보니 반가웠다! 이 방법을 자주 활용해서 내 ..

[Codewars/JS] RGB To Hex Conversion
Algorithm/Codewars 2022. 1. 13. 17:44

The rgb function is incomplete. Complete it so that passing in RGB decimal values will result in a hexadecimal representation being returned. Valid decimal values for RGB are 0 - 255. Any values that fall out of that range must be rounded to the closest valid value. Note: Your answer should always be 6 characters long, the shorthand with 3 will not work here. The following are examples of expect..

[Codewars/JS] Two to One
Algorithm/Codewars 2022. 1. 13. 16:53

Details Take 2 strings s1 and s2 including only letters from ato z. Return a new sorted string, the longest possible, containing distinct letters - each taken only once - coming from s1 or s2. Examples: a = "xyaabbbccccdefww" b = "xxxxyyyyabklmopq" longest(a, b) -> "abcdefklmopqwxy" a = "abcdefghijklmnopqrstuvwxyz" longest(a, a) -> "abcdefghijklmnopqrstuvwxyz" function longest(s1, s2) { const st..

검색 태그