본문 바로가기

Python345

Sum of two lowest positive integers Description: Create a function that returns the sum of the two lowest positive numbers given an array of minimum 4 positive integers. No floats or non-positive integers will be passed. For example, when an array is passed like [19, 5, 42, 2, 77], the output should be 7. [10, 343445353, 3453445, 3453545353453] should return 3453455. Solution: 1. Find the two smallest numbers. 2. Returns the sum o.. 2022. 4. 19.
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.
Sort Numbers Description: Finish the solution so that it sorts the passed in array of numbers. If the function passes in an empty array or null/nil value then it should return an empty array. For example: solution([1,2,3,10,5]) # should return [1,2,3,5,10] solution(None) # should return [] Solution: 1. If the 'nums' array is empty, an empty array is returned. 2. If the 'nums' array is not empty, the elements.. 2022. 4. 17.
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.
Get the mean of an array Description: It's the academic year's end, fateful moment of your school report. The averages must be calculated. All the students come to you and entreat you to calculate their average for them. Easy ! You just need to write a script. Return the average of the given array rounded down to its nearest integer. The array will never be empty. Solution: 1. Find the average. 2. Rounds down to an inte.. 2022. 4. 15.
Sum of Odd Cubed Numbers Description: Find the sum of the odd numbers within an array, after cubing the initial integers. The function should return undefined/None/nil/NULL if any of the values aren't numbers. Note: Booleans should not be considered as numbers. Solution: 1. If the element in the array is not of type 'int', None is returned. 2. If the cube of the remaining elements is odd, the values ​​are added. 3. Retu.. 2022. 4. 14.