일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- enumerate
- range
- sum
- If
- SQL
- FOR
- split
- slice
- or
- 파이썬
- 위코드
- Algorithm
- list
- len
- WECODE
- count
- js
- map
- iNT
- MAX
- index
- Python
- join
- Sorted
- lambda
- and
- LOWER
- DART
- STR
- decorator
- Today
- Total
목록split (21)
코드로 우주평화
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..
Each number should be formatted that it is rounded to two decimal places. You don't need to check whether the input is a valid number because only valid numbers are used in the tests. Example: 5.5589 is rounded 5.56 3.3424 is rounded 3.34 Solution: def two_decimal_places(n: float) -> float: l, r = str(n).split(".") r = str(round(int("1"+r[:5]), -3)) return float(".".join([l, r[1:3]])) def two_de..
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])
Return the number (count) of vowels in the given string. We will consider a, e, i, o, u as vowels for this Kata (but not y). The input string will only consist of lower case letters and/or spaces. Solution: int getCount(String inputStr){ List arr = []; for (String s in inputStr.toLowerCase().split('')) { if (["a","e","i","o","u"].contains(s)) { arr.add(s); } } return arr.length; } import "dart:c..
Take 2 strings s1 and s2 including only letters from a to 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: String longest(String a, String ..
Complete the solution so that it reverses the string passed into it. 'world' => 'dlrow' 'word' => 'drow' Solution: String solution(str) { return str.split('').reversed.join(''); }
What if we need the length of the words separated by a space to be added at the end of that same word and have it returned as an array? Example(Input --> Output) "apple ban" --> ["apple 5", "ban 3"] "you will win" -->["you 3", "will 4", "win 3"] Your task is to write a function that takes a String and returns an Array/list with the length of each word added to each element . Note: String will ha..
Complete the function/method so that it returns the url with anything after the anchor (#) removed. Examples "www.codewars.com#about" --> "www.codewars.com" "www.codewars.com?page=1" -->"www.codewars.com?page=1" Solution: def remove_url_anchor(url): i = url.find("#") return [url, url[:i]][i!=-1] Order Solution: def remove_url_anchor(url): return url.split('#')[0] def remove_url_anchor(url): retu..
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..
Some people just have a first name; some people have first and last names and some people have first, middle and last names. You task is to initialize the middle names (if there is any). Examples 'Jack Ryan' => 'Jack Ryan' 'Lois Mary Lane' => 'Lois M. Lane' 'Dimitri' => 'Dimitri' 'Alice Betty Catherine Davis' => 'Alice B. C. Davis' Solution: 1. If there are 3 or more elements of name, only the f..