본문 바로가기

STR20

Replace With Alphabet Position Welcome. In this kata you are required to, given a string, replace every letter with its position in the alphabet. If anything in the text isn't a letter, ignore it and don't return it. "a" = 1, "b" = 2, etc. Example alphabet_position("The sunset sets at twelve o' clock.") Should return "20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11" ( as a string ) Solution: from typin.. 2022. 7. 22.
Two to One Description: 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" Solution: 1. Concatenate strin.. 2022. 4. 26.
Square Every Digit Description: Welcome. In this kata, you are asked to square every digit of a number and concatenate them. For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1. Note: The function accepts an integer and returns an integer Solution: 1. Separate the numbers by one digit. 2. Square each of the separated numbers. 3. Return the squared numbers side by si.. 2022. 4. 18.
Dashatize it Description: Given a variable n, If n is an integer, Return a string with dash'-'marks before and after each odd integer, but do not begin or end the string with a dash mark. If n is negative, then the negative sign should be removed. If n is not an integer, return an empty value. Ex: dashatize(274) -> '2-7-4' dashatize(6815) -> '68-1-5' Solution: 1. If 'n' is not a number, 'None' is returned. 2.. 2022. 3. 22.
+1 Array Description: Given an array of integers of any length, return an array that has 1 added to the value represented by the array. the array can't be empty only non-negative, single digit integers are allowed Return nil (or your language's equivalent) for invalid inputs. Examples For example the array [2, 3, 9] equals 239, adding one would return the array [2, 4, 0]. [4, 3, 2, 5] would return [4, 3,.. 2022. 3. 15.
Write Number in Expanded Form 문제 설명 You will be given a number and you will need to return it as a string in Expanded Form. For example: expanded_form(12) # Should return '10 + 2' expanded_form(42) # Should return '40 + 2' expanded_form(70304) # Should return '70000 + 300 + 4' NOTE: All numbers will be whole numbers greater than 0. 해결 방법 1. 숫자를 문자열로 바꾼다. 2. 문자열 중에 '0'이 아닌 수를 찾는다. 3. 찾은 수에 현재 남은 자리수 만큼 '0'을 붙인다. 4. 리스트에 담는다. .. 2022. 2. 18.