FOR78 0209. Sort Out The Men From Boys Scenario Now that the competition gets tough it will Sort out the men from the boys . Men are the Even numbers and Boys are the odd!alt!alt Task Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from the boys!alt!alt Notes Return an array/list where Even numbers come first then odds Since , Men are stronger than Boys , Then Even numbers in ascen.. 2023. 2. 9. 0125. Counting sheep... Consider an array/list of sheep where some sheep may be missing from their place. We need a function that counts the number of sheep present in the array (true means present). For example, [True, True, True, False, True, True, True, True , True, False, True, False, True, False, False, True , True, True, True, True , False, False, True, True] The correct answer would be 17. Hint: Don't forget to .. 2023. 1. 25. 0113. Build a square I will give you an integer. Give me back a shape that is as long and wide as the integer. The integer will be a whole number between 1 and 50. Example n = 3, so I expect a 3x3 square back just like below as a string: +++ +++ +++ Solution: def generate_shape(n: int) -> str: return "\n".join("+" * n for i in range(n)) 2023. 1. 13. 0110. altERnaTIng cAsE <=> ALTerNAtiNG CaSe altERnaTIng cAsE ALTerNAtiNG CaSe Define String.prototype.toAlternatingCase (or a similar function/method such as to_alternating_case/toAlternatingCase/ToAlternatingCase in your selected language; see the initial solution for details) such that each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. For example: "hello world".toAlternatingCase() === "HELLO WORLD" "HE.. 2023. 1. 11. 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. 1229. Parts of a list Write a function partlist that gives all the ways to divide a list (an array) of at least two elements into two non-empty parts. Each two non empty parts will be in a pair (or an array for languages without tuples or a structin C - C: see Examples test Cases - ) Each part will be in a string Elements of a pair must be in the same order as in the original array. Examples of returns in different l.. 2022. 12. 30. 이전 1 2 3 4 ··· 13 다음