Algorithm101 Shortest Word Description: Simple, given a string of words, return the length of the shortest word(s). String will never be empty and you do not need to account for different data types. Solution: 1. Count the number of letters in each word. 2. Returns the smallest number of characters. def find_short(s): return min(list(map(len, s.split()))) 2022. 4. 23. Vowel Count Description: 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: 1. Check whether the characters in the 'sentence' are included in 'aeiou'. 2. Returns the number of included characters. def get_count(sentence): return sum([i in 'aeiou' for i i.. 2022. 4. 22. String ends with? Description: Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). Examples: solution('abc', 'bc') # returns true solution('abc', 'd') # returns false Solution: 1. Return True if the last digit of 'string' is the same as 'ending'. 2. If 'ending' is an empty string, return True. 3. If not, return False. def solution(strin.. 2022. 4. 21. Remove the minimum Description: The museum of incredible dull things The museum of incredible dull things wants to get rid of some exhibitions. Miriam, the interior architect, comes up with a plan to remove the most boring exhibitions. She gives them a rating, and then removes the one with the lowest rating. However, just as she finished rating all exhibitions, she's off to an important fair, so she asks you to wr.. 2022. 4. 20. Square Every Digit Description: Welcome. In this kata, you are asked to square every digit of a number and concatenate them. For example, if we run 9119 through the function, 811181 will come out, because 92 is 81 and 12 is 1. Note: The function accepts an integer and returns an integer Solution: 1. Separate the numbers by one digit. 2. Square each of the separated numbers. 3. Return the squared numbers side by si.. 2022. 4. 18. Regex validate PIN code Description: ATM machines allow 4 or 6 digit PIN codes and PIN codes cannot contain anything but exactly 4 digits or exactly 6 digits. If the function is passed a valid PIN string, return true, else return false. Examples (Input --> Output) Solution: 1. 인자가 숫자인지 확인한다. 2. 인자의 길이가 4 혹은 6이라면 pin을 반환한다. def validate_pin(pin): return pin.isdigit() and len(pin) in (4, 6) 2022. 4. 16. 이전 1 2 3 4 5 6 7 ··· 17 다음