Code Signal_练习题_Circle of Numbers】的更多相关文章

Consider integer numbers from 0 to n - 1 written down along the circle in such a way that the distance between any two neighboring numbers is equal (note that 0 and n - 1are neighboring, too). Given n and firstNumber, find the number which is written…
Ticket numbers usually consist of an even number of digits. A ticket number is considered lucky if the sum of the first half of the digits is equal to the sum of the second half. Given a ticket number n, determine if it's lucky or not. Example For n…
Let's define digit degree of some positive integer as the number of times we need to replace this number with the sum of its digits until we get to a one digit number. Given an integer, find its digit degree. Example For n = 5, the output should bedi…
You found two items in a treasure chest! The first item weighs weight1 and is worth value1, and the second item weighs weight2 and is worth value2. What is the total maximum value of the items you can take with you, assuming that your max weight capa…
Each day a plant is growing by upSpeed meters. Each night that plant's height decreases by downSpeed meters due to the lack of sun heat. Initially, plant is 0 meters tall. We plant the seed at the beginning of a day. We want to know when the height o…
Given array of integers, find the maximal possible sum of some of its k consecutive elements. Example For inputArray = [2, 3, 5, 1, 6] and k = 2, the output should bearrayMaxConsecutiveSum(inputArray, k) = 8.All possible sums of 2 consecutive element…
Given a string, find the number of different characters in it. Example For s = "cabca", the output should bedifferentSymbolsNaive(s) = 3. There are 3 different characters a, b and c. 我的解答: def differentSymbolsNaive(s): return len(set(s)) 一模一样 膜拜…
Find the leftmost digit that occurs in a given string. Example For inputString = "var_1__Int", the output should befirstDigit(inputString) = '1'; For inputString = "q2q-q", the output should befirstDigit(inputString) = '2'; For inputSt…
Given array of integers, remove each kth element from it. Example For inputArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] and k = 3, the output should beextractEachKth(inputArray, k) = [1, 2, 4, 5, 7, 8, 10]. 我的解答: def extractEachKth(inputArray, k): return…
Given an array of equal-length strings, check if it is possible to rearrange the strings in such a way that after the rearrangement the strings at consecutive positions would differ by exactly one character. Example For inputArray = ["aba", &quo…