일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- Python
- DART
- LOWER
- lambda
- SQL
- slice
- range
- js
- FOR
- decorator
- sum
- If
- join
- count
- WECODE
- or
- MAX
- Algorithm
- len
- enumerate
- index
- 파이썬
- Sorted
- 위코드
- STR
- iNT
- and
- split
- map
- list
- Today
- Total
목록STR (20)
코드로 우주평화
Your task is to make a function that can take any non-negative integer as an argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number. Examples: Input: 42145 Output: 54421 Input: 145263 Output: 654321 Input: 123456789 Output: 987654321 Solution: def descending_order(num): return int("".join(sorted([i for i in str(num)], r..
Task Given a list of digits, return the smallest number that could be formed from these digits, using the digits only once (ignore duplicates). Notes: Only positive integers will be passed to the function (> 0 ), no negatives or zeros. Input >> Output Examples minValue ({1, 3, 1}) ==> return (13) Explanation: (13) is the minimum number could be formed from {1, 3, 1} , Without duplications minVal..
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..
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..
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..
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..
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,..
문제 설명 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. 리스트에 담는다. ..
문제 설명 Write a function that accepts an array of 10 integers (between 0 and 9), that returns a string of those numbers in the form of a phone number. Example create_phone_number([1, 2, 3, 4, 5, 6, 7, 8, 9, 0]) # => returns "(123) 456-7890" The returned format must be correct in order to complete this challenge. Don't forget the space after the closing parentheses! 해결 방법 1. n에 담긴 숫자 요소들을 문자로 바꾼다. ..
문제 설명 Given an array of ones and zeroes, convert the equivalent binary value to an integer. Eg: [0, 0, 0, 1] is treated as 0001 which is the binary representation of 1. Examples: Testing: [0, 0, 0, 1] ==> 1 Testing: [0, 0, 1, 0] ==> 2 Testing: [0, 1, 0, 1] ==> 5 Testing: [1, 0, 0, 1] ==> 9 Testing: [0, 0, 1, 0] ==> 2 Testing: [0, 1, 1, 0] ==> 6 Testing: [1, 1, 1, 1] ==> 15 Testing: [1, 0, 1, 1] ..