본문 바로가기

list16

0121. esreveR Write a function reverse which reverses a list (or in clojure's case, any list-like data structure) (the dedicated builtin(s) functionalities are deactivated) Solution: def reverse(lst): result = list() for _ in range(len(lst)): result.append(lst.pop()) return result 2023. 1. 21.
0102. Enumerable Magic #25 - Take the First N Elements Create a function that accepts a list/array and a number n, and returns a list/array of the first n elements from the list/array. Solution: def take(arr, n): result = [] arrs = [arr[i-1:i] for i in range(1, n+1)] for arr in arrs: result += arr return result 2023. 1. 3.
1230. The Wide-Mouthed frog! 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.. 2022. 12. 30.
Factorial In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example: 5! = 5 * 4 * 3 * 2 * 1 = 120. By convention the value of 0! is 1. Write a function to calculate factorial for a given input. If input is below 0 or above 12 throw an exception of type ArgumentOutOfRangeException (C#) or IllegalArgumentException (.. 2022. 8. 7.
Categorize New Member The Western Suburbs Croquet Club has two categories of membership, Senior and Open. They would like your help with an application form that will tell prospective members which category they will be placed. To be a senior, a member must be at least 55 years old and have a handicap greater than 7. In this croquet club, handicaps range from -2 to +26; the better the player the lower the handicap. I.. 2022. 5. 3.
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.