일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- split
- 파이썬
- range
- STR
- 위코드
- Algorithm
- slice
- and
- len
- Python
- lambda
- MAX
- FOR
- SQL
- index
- LOWER
- Sorted
- sum
- iNT
- decorator
- list
- js
- map
- If
- WECODE
- or
- join
- count
- DART
- enumerate
- Today
- Total
목록FOR (78)
코드로 우주평화
Jamie is a programmer, and James' girlfriend. She likes diamonds, and wants a diamond string from James. Since James doesn't know how to make this happen, he needs your help. Task You need to return a string that looks like a diamond shape when printed on the screen, using asterisk (*) characters. Trailing spaces should be removed, and every line must be terminated with a newline character (\n)...
The maximum sum subarray problem consists in finding the maximum sum of a contiguous subsequence in an array or list of integers: max_sequence([-2, 1, -3, 4, -1, 2, 1, -5, 4]) # should be 6: [4, -1, 2, 1] Easy case is when the list is made up of only positive numbers and the maximum sum is the sum of the whole array. If the list is made up of only negative numbers, return 0 instead. Empty list i..
In this kata you will create a function that takes a list of non-negative integers and strings and returns a new list with the strings filtered out. Example filter_list([1,2,'a','b']) == [1,2] filter_list([1,'a','b',0,15]) == [1,0,15] filter_list([1,2,'aasf','1','123',123]) == [1,2,123] Solution: def filter_list(l): return [i for i in l if isinstance(i, int)]
There is an array with some numbers. All numbers are equal except for one. Try to find it! find_uniq([ 1, 1, 1, 2, 1, 1 ]) == 2 find_uniq([ 0, 0, 0.55, 0, 0 ]) == 0.55 It’s guaranteed that array contains at least 3 numbers. The tests contain some very huge arrays, so think about performance. Solution: def find_uniq(arr): n = arr[0] == arr[-1] and arr[0] or arr[1] return [i for i in arr if n != i..
In this Kata, you will be given a string that may have mixed uppercase and lowercase letters and your task is to convert that string to either lowercase only or uppercase only based on: make as few changes as possible. if the string contains equal number of uppercase and lowercase letters, convert the string to lowercase. For example: solve("coDe") = "code". Lowercase characters > uppercase. Cha..
Take an integer n (n >= 0) and a digit d (0
In a factory a printer prints labels for boxes. For one kind of boxes the printer has to use colors which, for the sake of simplicity, are named with letters from a to m. The colors used by the printer are recorded in a control string. For example a "good" control string would be aaabbbbhaijjjm meaning that the printer used three times color a, four times color b, one time color h then one time ..
Build Tower Build a pyramid-shaped tower given a positive integer number of floors. A tower block is represented with "*" character. For example, a tower with 3 floors looks like this: [ " * ", " *** ", "*****" ] And a tower with 6 floors looks like this: [ " * ", " *** ", " ***** ", " ******* ", " ********* ", "***********" ] Solution: def tower_builder(n_floors): nums = [i>0 and i*2+1 or 1 for..
The first input array is the key to the correct answers to an exam, like ["a", "a", "b", "d"]. The second one contains a student's submitted answers. The two arrays are not empty and are the same length. Return the score for this array of answers, giving +4 for each correct answer, -1 for each incorrect answer, and +0 for each blank answer, represented as an empty string (in C the space characte..
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..