Skip to content

Instantly share code, notes, and snippets.

View denchistyakov's full-sized avatar

Denis Chistyakov denchistyakov

View GitHub Profile
case "$1" in
start)
echo "Starting TeamCity Agent '$teamcity_agent_name'..."
d_start $teamcity_agent_name
;;
stop)
echo "Stopping TeamCity Agent '$teamcity_agent_name'..."
d_stop $teamcity_agent_name
;;
restart|force-reload)
#! /bin/sh
### BEGIN INIT INFO
# Provides: autostart.script
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop:
# Short-Description: Install and start init-teamcity-agent-instance
# Description: Run init-teamcity-agent-instance install if this
# need and init-teamcity-agent-instance start.
/**
* @param {array} input Игровое поле для крестиков-ноликов 3×3
* @return {number}
*/
function ticTacToe(input) {
let result = -1;
let map = {
// Сумма каждой строки
0: 0,
1: 0,
/**
* @param {string} morseCode Строка закодированная азбукой морзе
* @param {object} dict Словарь: ключа символ в азбуке Морзе, значение символ ASCII
* @return {string}
*/
function decodeMorse(morseCode, dict) {
let result = [];
const words = morseCode.split(' ');
for (let i = 0; i < words.length; i++) {
const word = words[i];
/**
* @param {number[]} input Массив целых чисел
* @return {number[]}
*/
function countPositivesSumNegatives(input) {
if (!Array.isArray(input) || (Array.isArray(input) && input.length === 0)) {
return [];
}
let result = [0, 0];
/**
* @param {number} count
* @param {string[]} forms
* @return {string}
*/
function plural(count, forms) {
// В большинстве случаев возвращаем третью форму
let idx = 2;
let numbersInCount = count.toString().split('');
let lastNumber = Number(numbersInCount[numbersInCount.length - 1]);
/**
* @param {string} varName Исходное имя переменной в змеинном_регистре
* @return {string} Имя переменной преобразованное к нижнемуВерблюжемуРегистру
*/
function convertCase(varName) {
let underscores = '';
if (varName[0] === '_') {
for (let i = 0; i < varName.length; i++) {
const char = varName[i];
if (char !== '_') {
function next_combination(a, n) {
let k = a.length;
for (let i = k - 1; i>= 0; --i) {
if (a[i] < n - k + i + 1) {
++a[i];
for (let j = i + 1; j < k; ++j) {
a[j] = a[j - 1] + 1;
}
return true;
}
function chooseBestSum(t, k, ls) {
let acc = [];
generate(k, ls.length, [], ls, acc, 0, 0);
const maxTravel = acc
.map(chunk => chunk.reduce((acc, item) => acc += item))
.filter(sum => sum <= t)
.reduce((acc, sum) => {
if (sum > acc) {
acc = sum;
}
class SnakesLadders {
constructor() {
this.board = [
0,
0, 36, 0, 0, 0, 0, 7, 23, 0, 0,
0, 0, 0, 0, 11, -10, 0, 0, 0, 0,
21, 0, 0, 0, 0, 0, 0, 56, 0, 0,
0, 0, 0, 0, 0, 8, 0, 0, 0, 0,
0, 0, 0, 0, 0, -21, 0, 0, -38, 0,
16, 0, 0, 0, 0, 0, 0, 0, 0, 0,