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
| function defendable(_attacker, _defender) { | |
| const attacker = new Attacker(_attacker); | |
| const defender = new Defender(_defender); | |
| defender.calcMorale(attacker); | |
| return attacker.getSummaryPower() < defender.getSummaryPower(); | |
| } | |
| class Player { | |
| constructor(units) { | |
| Object.assign(this, units); |
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
| function hasOwnProperty(obj, key) { | |
| return Object.prototype.hasOwnProperty.call(obj, key); | |
| } | |
| function bestPlaces(cityMap) { | |
| const maxX = cityMap[0].length; | |
| const maxY = cityMap.length; | |
| let maxGarbagesCount = 0; | |
| const coordsOfGarbages = cityMap.reduce((acc, line, y) => { |
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 START_STATE = 0; | |
| const BIG_LETTER = 1; | |
| const SMALL_LETTER = 2; | |
| const NUMBER = 4; | |
| const OPENING_BRACKET = 8; | |
| const CLOSING_BRACKET = 16; | |
| const STATES = { | |
| [START_STATE]: [BIG_LETTER, OPENING_BRACKET], | |
| [BIG_LETTER]: [BIG_LETTER, SMALL_LETTER, NUMBER, OPENING_BRACKET, CLOSING_BRACKET], |
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 START_STATE = 0; | |
| const BIG_LETTER = 1; | |
| const SMALL_LETTER = 2; | |
| const NUMBER = 4; | |
| const OPENING_BRACKET = 8; | |
| const CLOSING_BRACKET = 16; | |
| const STATES = { | |
| [START_STATE]: [BIG_LETTER, OPENING_BRACKET], | |
| [BIG_LETTER]: [BIG_LETTER, SMALL_LETTER, NUMBER, OPENING_BRACKET, CLOSING_BRACKET], |
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
| function parseMolecule(formula) { | |
| // do your science here | |
| let result = []; | |
| while ((formula = parseNextChar(formula)) != ''); | |
| function parseNextChar(str) { | |
| const elem = /^[A-Z]{1}[a-z]?/; | |
| const open = /^[({[]/; | |
| const close = /^[)}\]]/; | |
| const digit = /^[0-9]+/; | |
| let match; |
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
| /** COMMENT | |
| var water = 'H2O'; | |
| parseMolecule(water); // return {H: 2, O: 1} | |
| var magnesiumHydroxide = 'Mg2(OH)2'; | |
| parseMolecule(magnesiumHydroxide); // return {Mg: 1, O: 2, H: 2} | |
| var fremySalt = 'K4[ON(SO3)2]2'; | |
| parseMolecule(fremySalt); // return {K: 4, O: 14, N: 2, S: 4} | |
| */ // eslint-valid-jsdoc |
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
| function sum(a, b, c) { | |
| return a + b + c; | |
| } | |
| const curriedSum = curry(sum); | |
| console.log(curriedSum(1, 2, 3)); // 6 | |
| console.log(curriedSum(1, 2)(3)); // 6 | |
| console.log(curriedSum(1)(2)(3)); // 6 | |
| console.log(curriedSum(1)(2, 3)); // 6 |
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
| /** | |
| * Разбор логов | |
| * | |
| * В функцию передаётся текст, содержащий строки вида | |
| * | |
| * 127.0.0.1 [18/Jun/2018:19:53:13 +0000] "POST /api/external/v1/ HTTP/1.1" 200 | |
| * | |
| * Функция должна отдавать список объектов вида | |
| * |
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
| // Купюры - 50 руб, 100 руб, 500 руб, 1000 руб, 5000 руб. | |
| // Есть ограничение на количество каждой из купюр, его нужно держать в актуальном состоянии | |
| // 1250 -> '1x1000 2x100 1x50' | |
| // 6512 -> 'Введена неверная сумма' | |
| /** | |
| * [{ nom: 1000, count: 10 }] | |
| * { 1000: 10 } | |
| * new Map([[1000, 10], [5000, 5]]) |
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
| /** | |
| * @param {Number} hours | |
| * @param {Number} minutes | |
| * @param {Number} interval | |
| * @returns {String} | |
| */ | |
| module.exports = (hours, minutes, interval) => { | |
| const hoursInMinutes = hours * 60; | |
| const summaryMinutes = hoursInMinutes + minutes; | |
| const summaryMinutesWithInterval = summaryMinutes + interval; |