일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- FOR
- lambda
- len
- slice
- and
- STR
- Sorted
- sum
- count
- or
- enumerate
- range
- split
- MAX
- 위코드
- iNT
- If
- WECODE
- list
- js
- Python
- join
- 파이썬
- index
- SQL
- map
- Algorithm
- LOWER
- decorator
- DART
- Today
- Total
목록lambda (17)
코드로 우주평화
Complete the square sum function so that it squares each number passed into it and then sums the results together. For example, for [1, 2, 2] it should return 9 because 1^2 + 2^2 + 2^2 = 9. Solution: def square_sum(numbers): square = lambda x:(x**2+x**2)//2 return sum(square(number) for number in numbers)
Given a string, you have to return a string in which each character (case-sensitive) is repeated once. Examples (Input -> Output): * "String" -> "SSttrriinngg" * "Hello World" -> "HHeelllloo WWoorrlldd" * "1234!_ " -> "11223344!!__ " Good Luck! Solution: def double_char(s: str) -> str: return "".join((lambda x: x+x)(i) for i in s)
Given a month as an integer from 1 to 12, return to which quarter of the year it belongs as an integer number. For example: month 2 (February), is part of the first quarter; month 6 (June), is part of the second quarter; and month 11 (November), is part of the fourth quarter. Solution: def quarter_of(month): return (lambda x: x%3==0 and x//3 or x//3+1)(month) Other Solution: from math import cei..
Description: Write a function that takes an array of strings as an argument and returns a sorted array containing the same strings, ordered from shortest to longest. For example, if this array were passed as an argument: ["Telescopes", "Glasses", "Eyes", "Monocles"] Your function would return the following array: ["Eyes", "Glasses", "Monocles", "Telescopes"] All of the strings in the array passe..
Description: Given an array of integers, return a new array with each value doubled. For example: [1, 2, 3] --> [2, 4, 6] Solution: 1. Get the elements out of the array. 2. Multiply the element by 2 and put it back into the array. 3. Return an array. def maps(a): return list(map(lambda x: x * 2, a)) The lambda function is an anonymous function and is suitable for simple calculations.
Description: Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you'll have to capitalize each word, check out how contractions are expected to be in the example bel..
문제 설명 문자열로 구성된 리스트 strings와, 정수 n이 주어졌을 때, 각 문자열의 인덱스 n번째 글자를 기준으로 오름차순 정렬하려 합니다. 예를 들어 strings가 ["sun", "bed", "car"]이고 n이 1이면 각 단어의 인덱스 1의 문자 "u", "e", "a"로 strings를 정렬합니다. 제한 사항 strings는 길이 1 이상, 50이하인 배열입니다. strings의 원소는 소문자 알파벳으로 이루어져 있습니다. strings의 원소는 길이 1 이상, 100이하인 문자열입니다. 모든 strings의 원소의 길이는 n보다 큽니다. 인덱스 1의 문자가 같은 문자열이 여럿 일 경우, 사전순으로 앞선 문자열이 앞쪽에 위치합니다. 입출력 예 1 "sun", "bed", "car"의 1번째 ..