본문 바로가기

algorithm

(20)
[6kyu] Highest Scoring 문제설명Description:Given a string of words, you need to find the highest scoring word.Each letter of a word scores points according to it's position in the alphabet: a = 1, b = 2, c = 3 etc.You need to return the highest scoring word as a string.If two words score the same, return the word that appears earliest in the original string.All letters will be lowercase and all inputs will be valid. 나의풀이f..
[6kyu] Tribonacci sequence 문제설명Description:Well met with Fibonacci bigger brother, AKA Tribonacci.As the name may already reveal, it works basically like a Fibonacci, but summing the last 3 (instead of 2) numbers of the sequence to generate the next. And, worse part of it, regrettably I won't get to hear non-native Italian speakers trying to pronounce it :(So, if we are to start our Tribonacci sequence with [1, 1, 1] as a..
[6kyu] Simple string expansion 문제설명Description:Consider the following expansion:solve("3(ab)") = "ababab" -- "ab" repeats 3 times solve("2(a3(b))" = "abbbabbb" -- "a3(b)" == "abbb" repeats twice. Given a string, return the expansion of that string.Input will consist of only lowercase letters and numbers in valid parenthesis. There will be no letters or numbers after the last closing parenthesis.More examples in test cases.Goo..
[7kyu] Homogenous array 문제설명Description:Challenge:Given a two-dimensional array, return a new array which carries over only those arrays from the original, which were not empty and whose items are all of the same type (i.e. homogenous). For simplicity, the arrays inside the array will only contain characters and integers.Example:Given [[1, 5, 4], ['a', 3, 5], ['b'], [], ['1', 2, 3]], your function should return [[1, 5,..
[6kyu] crashing boxes 문제설명Description:You are stacking some boxes containing gold weights on top of each other. If a box contains more weight than the box below it, it will crash downwards and combine their weights. e.g. If we stack [2] on top of [1], it will crash downwards and become a single box of weight [3][2] [1] --> [3] Given an array of arrays, return the bottom row (i.e. the last array) after all crashings a..
[6kyu] playing with digits 문제설명Description:Some numbers have funny properties. For example:89 --> 8¹ + 9² = 89 * 1695 --> 6² + 9³ + 5⁴= 1390 = 695 * 246288 --> 4³ + 6⁴+ 2⁵ + 8⁶ + 8⁷ = 2360688 = 46288 * 51Given a positive integer n written as abcd... (a, b, c, d... being digits) and a positive integer p we want to find a positive integer k, if it exists, such as the sum of the digits of n taken to the successive powers of ..
[6kyu] multiples of 3 or 5 문제 설명 Description:If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.Finish the solution so that it returns the sum of all the multiples of 3 or 5 below the number passed in.Note: If the number is a multiple of both 3 and 5, only count it once. 나의풀이 function solution(number){ var sum = 0; for(var i = 1; i
[6kyu] TGI Friday !! 문제설명We all love fridays, and even better if it is the last day of the month!In this kata you should write a function that will receive 2 parameters. Both are years, and indicates a range.Your work is to return the number of times a month ends with a Friday.If there is only one year provided, return the number of times a month ends on Friday on that year. Range bounds are inclusive in every case!..