https://github.com/acvetkov/yandex-task
js task from Yandex
https://github.com/acvetkov/yandex-task
Last synced: 2 months ago
JSON representation
js task from Yandex
- Host: GitHub
- URL: https://github.com/acvetkov/yandex-task
- Owner: acvetkov
- Created: 2014-04-11T10:12:47.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2014-04-30T19:21:00.000Z (about 11 years ago)
- Last Synced: 2025-02-03T10:14:30.721Z (4 months ago)
- Language: JavaScript
- Homepage:
- Size: 207 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Tasks
----------Some javascript tasks from Yandex.
**ArraySelector.getSumCombinations(originalArray, needSum)**
This method find all subsets of original array, where sum of elements equals to needSum
```js
var arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
var results = ArraySelector.getSumCombinations(arr, 10);
/**[
[1, 2, 3, 4],
[2, 3, 5],
[1, 4, 5],
[1, 3, 6],
[4, 6],
[1, 2, 7],
[3, 7],
[2, 8],
[1, 9],
[10]
]*/
```
**Function.prototype.delayCall**
Метод позволяет не вызывать функцию чаще, чем 1 раз в промежуток времени
```js
var block = document.getElementById("black_square");
var handler = function(event) {
console.log("Handler");
};handler = handler.delayCall(1000); // не чаще, чем 1 раз в секунду
block.onclick = handler;```