This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function quickSort(numbers, target, partial) { | |
var sum, remaining; | |
var partial = partial || []; | |
// sum partial | |
sum = partial.reduce(function (a, b) { | |
return a + b; | |
}, 0); | |
// check if the sum partial equals the target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. | |
# Find the sum of all the multiples of 3 or 5 below 1000. | |
class Multiples: | |
def __init__(self, num, min, max): | |
self.__num = num | |
self.__min = self.round_step(min) | |
self.__max = max |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: | |
# | |
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... | |
# | |
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find the sum of the even-valued terms. | |
# Find the sum of the even-valued terms < four million in the Fibonacci sequence | |
class Fibonacci_numbers: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const input = [[1, 2, [3]], 4]; | |
// ––––– Option 1 ––––– | |
function baseFlatten(array, depth, result) { | |
result || (result = []); | |
if (array == null) { | |
return result; | |
} |