일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- iNT
- STR
- LOWER
- SQL
- js
- sum
- map
- index
- 파이썬
- or
- join
- If
- lambda
- Algorithm
- enumerate
- Sorted
- range
- and
- MAX
- slice
- count
- decorator
- Python
- 위코드
- split
- len
- DART
- WECODE
- list
- Today
- Total
목록index (17)
코드로 우주평화
Define a function that removes duplicates from an array of numbers and returns it as a result. The order of the sequence has to stay the same. Solution: def distinct(seq: list[int]) -> list[int]: result = [] for i in seq: if i not in result: result.append(i) return result def distinct(seq: list[int]) -> list[int]: return sorted(set(seq), key=seq.index) def distinct(seq: list[int]) -> list[int]: ..
You're re-designing a blog and the blog's posts have the following format for showing the date and time a post was made: Weekday Month Day, time e.g., Friday May 2, 7pm You're running out of screen real estate, and on some pages you want to display a shorter format, Weekday Month Day that omits the time. Write a function, shortenToDate, that takes the Website date/time in its original string for..
Write a method that takes one argument as name and then greets that name, capitalized and ends with an exclamation point. Example: "riley" --> "Hello Riley!" "JACK" --> "Hello Jack!" Solution: var greet = function(name) { modifiedName = name.charAt(0).toUpperCase() + name.slice(1).toLowerCase() return `Hello ${modifiedName}!` }; var greet = function(name) { return 'Hello ' + name[0].toUpperCase(..
The wide-mouth frog is particularly interested in the eating habits of other creatures. He just can't stop asking the creatures he encounters what they like to eat. But, then he meets the alligator who just LOVES to eat wide-mouthed frogs! When he meets the alligator, it then makes a tiny mouth. Your goal in this kata is to create complete the mouth_size method this method takes one argument ani..
Basic regex tasks. Write a function that takes in a numeric code of any length. The function should check if the code begins with 1, 2, or 3 and return true if so. Return false otherwise. You can assume the input will always be a number. Solution: def validate_code(code: int) -> bool: return int(str(code)[0])
You ask a small girl,"How old are you?" She always says, "x years old", where x is a random number between 0 and 9. Write a program that returns the girl's age (0-9) as an integer. Assume the test input string is always a valid string. For example, the test input may be "1 year old" or "5 years old". The first character in the string is always a number. Solution: def get_age(age): def get_int(ag..
Write a function that checks if a given string (case insensitive) is a palindrome. Solution: def is_palindrome(s): target = s.lower() for i in range(len(target)//2): if target[i] != target[-i-1]: return False return True def is_palindrome(s): s = s.lower() return s == s[::-1]
Wolves have been reintroduced to Great Britain. You are a sheep farmer, and are now plagued by wolves which pretend to be sheep. Fortunately, you are good at spotting them. Warn the sheep in front of the wolf that it is about to be eaten. Remember that you are standing at the front of the queue which is at the end of the array: [sheep, sheep, sheep, sheep, sheep, wolf, sheep, sheep] (YOU ARE HER..
This kata is from check py.checkio.org You are given an array with positive numbers and a non-negative number N. You should find the N-th power of the element in the array with the index N. If N is outside of the array, then return -1. Don't forget that the first element has the index 0. Let's look at a few examples: array = [1, 2, 3, 4] and N = 2, then the result is 3^2 == 9; array = [1, 2, 3] ..
Given a string of words, you need to find the highest scoring word. Each letter of a word scores points according to its position in the alphabet: a = 1, b = 2, c = 3 etc. You need to return the highest scoring word as a string. If two words score the same, return the word that appears earliest in the original string. All letters will be lowercase and all inputs will be valid. Solution: def high..