题目: Complete the function which takes two arguments and returns all numbers which are divisible by the given divisor. First argument is an array of numbers and the second is the divisor. Example divisible_by([1, 2, 3, 4, 5, 6], 2) == [2, 4, 6] 解题方法:…
题目: When you sign up for an account somewhere, some websites do not actually store your password in their databases. Instead, they will transform your password into something else using a cryptographic hashing algorithm. After the password is transfo…
题目: Create a method that takes an array/list as an input, and outputs the index at which the sole odd number is located. This method should work with arrays with negative numbers. If there are no odd numbers in the array, then the method should outpu…
题目: 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. 解题方法:(再想想可能就出来了) def square_sum(numbers): return sum(map…
题目: 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   Task Given an array/list [] of n integers , Separate The even numbers from the odds , or Separate the men from t…
题目: Create a function that accepts dimensions, of Rows x Columns, as parameters in order to create a multiplication table sized according to the given dimensions. **The return value of the function must be an array, and the numbers must be Fixnums, N…
原题: A perfect power is a classification of positive integers: In mathematics, a perfect power is a positive integer that can be expressed as an integer power of another positive integer. More formally, n is a perfect power if there exist natural numb…
原题: This time we want to write calculations using functions and get the results. Let's have a look at some examples: seven(times(five())) # must return 35 four(plus(nine())) # must return 13 eight(minus(three())) # must return 5 six(divided_by(two())…
题目: Summation Write a program that finds the summation of every number from 1 to num. The number will always be a positive integer greater than 0. For example: summation(2) -> 3 1 + 2 summation(8) -> 36 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 解题方法: 很简单的题目: de…
题目: Consider an array 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…