join53 1115. Reversed Strings 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(''); } 2022. 11. 15. 1109. Sentence Smash Sentence Smash Write a function that takes an array of words and smashes them together into a sentence and returns the sentence. You can ignore any need to sanitize words or add punctuation, but you should add spaces between each word. Be careful, there shouldn't be a space at the beginning or the end of the sentence! Example ['hello', 'world', 'this', 'is', 'great'] => 'hello world this is grea.. 2022. 11. 9. 1031. Vowel remover Create a function called shortcut to remove the lowercase vowels (a, e, i, o, u ) in a given string. Examples "hello" --> "hll" "codewars" --> "cdwrs" "goodbye" --> "gdby" "HELLO" --> "HELLO" don't worry about uppercase vowels y is not considered a vowel for this kata Solution: def shortcut(s): return ''.join(i for i in s if i not in "aeiou") def shortcut(s): return s.translate(None, 'aeiou') 2022. 10. 31. 1029. Printing Array elements with Comma delimiters nput: Array of elements ["h","o","l","a"] Output: String with comma delimited elements of the array in th same order. "h,o,l,a" solution: def print_array(arr): return ','.join(map(str, arr)) 2022. 10. 29. 1025. Exclusive "or" (xor) Logical Operator Exclusive "or" (xor) Logical Operator Overview In some scripting languages like PHP, there exists a logical operator (e.g. &&, ||, and, or, etc.) called the "Exclusive Or" (hence the name of this Kata). The exclusive or evaluates two booleans. It then returns true if exactly one of the two expressions are true, false otherwise. For example: false xor false == false // since both are false true x.. 2022. 10. 26. 1010. Double Char 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) 2022. 10. 10. 이전 1 2 3 4 5 6 ··· 9 다음