본문 바로가기

algorithm/codewars

(14)
[6kyu] Compare powers 문제설명 You certainly can tell which is the larger number between 210 and 215.But what about, say, 210 and 310? You know this one too.Things tend to get a bit more complicated with both different bases and exponents: which is larger between 39 and 56?Well, by now you have surely guessed that you have to build a function to compare powers, returning -1 if the first member is larger, 0 if they are eq..
[6kyu] Financing a purchase 문제설명Description:The description is rather long but it tries to explain what a financing plan is.The fixed monthly payment for a fixed rate mortgage is the amount paid by the borrower every month that ensures that the loan is paid off in full with interest at the end of its term.The monthly payment formula is based on the annuity formula. The monthly payment c depends upon:rate - the monthly inte..
[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 ..