일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- count
- range
- slice
- DART
- LOWER
- STR
- lambda
- decorator
- or
- js
- Python
- map
- len
- and
- FOR
- 위코드
- iNT
- split
- 파이썬
- SQL
- WECODE
- If
- enumerate
- Algorithm
- join
- list
- MAX
- Sorted
- index
- sum
- Today
- Total
목록slice (32)
코드로 우주평화
Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are the Even numbers and Boys are the odd!alt!alt Task Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from the boys!alt!alt Notes Return an array/list where Even numbers come first then odds Since , Men are stronger than Boys , Then Even numbers in ascen..
Complete the function that takes two numbers as input, num and nth and return the nth digit of num (counting from right to left). Note If num is negative, ignore its sign and treat it as a positive value If nth is not positive, return -1 Keep in mind that 42 = 00042. This means that findDigit(42, 5) would return 0 Examples(num, nth --> output) 5673, 4 --> 5 129, 2 --> 2 -2825, 3 --> 8 -456, 4 --..
Write a function to get the first element(s) of a sequence. Passing a parameter n (default=1) will return the first n element(s) of the sequence. If n == 0 return an empty sequence [] Examples arr = ['a', 'b', 'c', 'd', 'e'] first(arr) # --> ['a'] first(arr, 2) # --> ['a', 'b'] first(arr, 3) # --> ['a', 'b', 'c'] first(arr, 0) # --> [] Solution: def first(seq: list[str], n:int = 1) -> list[str]:..
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(..
Write a function that returns a string in which firstname is swapped with last name. Example(Input --> Output) "john McClane" --> "McClane john" Solution: def name_shuffler(str_): return " ".join(str_.split(" ")[::-1])
It's pretty straightforward. Your goal is to create a function that removes the first and last characters of a string. You're given one parameter, the original string. You don't have to worry with strings with less than two characters. Solution: def remove_char(s: str, limit: int = 1): return s[limit:-limit]
Write a function to split a string and convert it into an array of words. Examples (Input ==> Output): "Robin Singh" ==> ["Robin", "Singh"] "I love arrays they are my favorite" ==> ["I", "love", "arrays", "they", "are", "my", "favorite"] Solution: from typing import List def string_to_array(s: str) -> List[str]: return split(s) def split(s: str, c: str = " ") -> List[str]: list, ci = [], 0 for i..
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]
Palindrome strings A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward or forward. This includes capital letters, punctuation, and word dividers. Implement a function that checks if something is a palindrome. If the input is a number, convert it to string first. Examples(Input ==> Output) "anna" ==> true "walter" ==> false 12321 ==> true 123456 =..