This file contains hidden or 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 rejectOnTime = (func, time) => Promise | |
.race([ | |
func, | |
new Promise((res, rej) => { | |
setTimeout(() => rej('Не успел'), time) | |
}) | |
]) | |
const foo = (time) => new Promise ((res, rej) => { | |
setTimeout(() => res('Успел'), time) |
This file contains hidden or 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
class Query { | |
body: string; | |
constructor () { | |
this.body = '<type>' | |
}; | |
pipe (...args) { | |
this.body = args.reduce((acc, arg) => { | |
return acc.replace(arg.tag, arg.body) | |
}, this.body); | |
return this; |
This file contains hidden or 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 fs = require('fs'); | |
const buildStepCounter = (step = 1) => () => step++ | |
list = [9,10,14,15,17,19,24,24,26,28,29,31,33,33,42,42,47,47,58,59,61] | |
node = 47 | |
let result = '' | |
const linearSearch = (node, list) => { | |
let resultIndex; |
This file contains hidden or 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
''' | |
example of graph in input.json | |
{ | |
"start": "1", | |
"end": "12", | |
"nodes": { | |
"1": ["2", "3"], | |
"2": ["4", "7"], | |
"3": ["5", "11"], |
This file contains hidden or 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
def entry (str, substr): | |
if len(str) < len(substr): | |
return False | |
else: | |
if str[:len(substr)] != substr: | |
return entry(str[1:], substr) | |
else: | |
return True |
This file contains hidden or 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
### special for iVan | |
def reformat(line): | |
expression = [] | |
element = '&' | |
line.replace(' ', '') | |
for item in line: | |
if item in '0123456789': | |
if element == '&': | |
element = int(item) |
This file contains hidden or 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
/* | |
Задача №3152. Четные индексы | |
let mas = [1, 2, 3, 4, 5, 6]; | |
for (item in mas) { // итерация по ключу | |
if (item % 2 == 0) {console.log(mas[item])} | |
}*/ | |
/* | |
Задача №3153. Четные элементы | |
let mas = [1, 2, 2, 3, 4, 5, 3, 2]; |
This file contains hidden or 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
'use strict' | |
const readline = require('readline') | |
const rl = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout | |
}) | |
function get_random_arbitrary(min, max) { |