본문 바로가기

lambda17

1108. JavaScript Array Filter In Python, there is a built-in filter function that operates similarly to JS's filter. For more information on how to use this function, visit https://docs.python.org/3/library/functions.html#filter The solution would work like the following: get_even_numbers([2,4,5,6]) => [2,4,6] Solution: def get_even_numbers(arr, condition = lambda x: x % 2 == 0): return [i for i in arr if condition(i)] def g.. 2022. 11. 9.
1106. Grasshopper - Messi Goals Messi's Goal Total Use variables to find the sum of the goals Messi scored in 3 competitions Information Messi goal scoring statistics: Competition Goals La Liga 43 Champions League 10 Copa del Rey 5 Task Create these three variables and store the appropriate values using the table above: la_liga_goals champions_league_goals copa_del_rey_goals Create a fourth variable named total_goals that stor.. 2022. 11. 7.
1104. Sum Mixed Array Given an array of integers as strings and numbers, return the sum of the array values as if all were numbers. Return your answer as a number. sum_mix = lambda x: sum(map(int, x)) 2022. 11. 4.
1012. All Star Code Challenge #18 This Kata is intended as a small challenge for my students All Star Code Challenge #18 Create a function that accepts 2 string arguments and returns an integer of the count of occurrences the 2nd argument is found in the first one. If no occurrences can be found, a count of 0 should be returned. ("Hello", "o") ==> 1 ("Hello", "l") ==> 2 ("", "z") ==> 0 Notes: The first argument can be an empty s.. 2022. 10. 12.
1011. Square(n) Sum Complete the square sum function so that it squares each number passed into it and then sums the results together. For example, for [1, 2, 2] it should return 9 because 1^2 + 2^2 + 2^2 = 9. Solution: def square_sum(numbers): square = lambda x:(x**2+x**2)//2 return sum(square(number) for number in numbers) 2022. 10. 11.
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.