range34 1228. Kata Example Twist This is an easy twist to the example kata (provided by Codewars when learning how to create your own kata). Add the value "codewars" to the array websites/Websites 1,000 times. Solution: websites = ["codewars" for _ in range(1000)] websites = ["codewars"] * 1000 2022. 12. 28. 1211. Maximum Product Task Given an array of integers , Find the maximum product obtained from multiplying 2 adjacent numbers in the array. Notes Array/list size is at least 2. Array/list numbers could be a mixture of positives, negatives also zeroes . Input >> Output Examples adjacentElementsProduct([1, 2, 3]); ==> return 6 Explanation: The maximum product obtained from multiplying 2 * 3 = 6, and they're adjacent nu.. 2022. 12. 11. 1112. Sum of Multiples Your Job Find the sum of all multiples of n below m Keep in Mind n and m are natural numbers (positive integers) m is excluded from the multiples Examples sumMul(2, 9) ==> 2 + 4 + 6 + 8 = 20 sumMul(3, 13) ==> 3 + 6 + 9 + 12 = 30 sumMul(4, 123) ==> 4 + 8 + 12 + ... = 1860 sumMul(4, -7) ==> "INVALID" Solution: def invalid_value(func): def wrapper(n, m): return (n 2022. 11. 13. 1027. Filling an array (part 1) We want an array, but not just any old array, an array with contents! Write a function that produces an array with the numbers 0 to N-1 in it. For example, the following code will result in an array containing the numbers 0 to 4: arr(5) // => [0,1,2,3,4] Note: The parameter is optional. So you have to give it a default value. Solution: def arr(n: int = 0): return [i for i in range(n)] 2022. 10. 28. 1019. Is it a palindrome? Write a function that checks if a given string (case insensitive) is a palindrome. Solution: def is_palindrome(s): target = s.lower() for i in range(len(target)//2): if target[i] != target[-i-1]: return False return True def is_palindrome(s): s = s.lower() return s == s[::-1] 2022. 10. 19. 1014. Find Multiples of a Number In this simple exercise, you will build a program that takes a value, integer , and returns a list of its multiples up to another value, limit . If limit is a multiple of integer, it should be included as well. There will only ever be positive integers passed into the function, not consisting of 0. The limit will always be higher than the base. For example, if the parameters passed are (2, 6), t.. 2022. 10. 14. 이전 1 2 3 4 5 6 다음