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
body { | |
/* ширина контейнера меняется при растяжении окна браузера */ | |
width: 300px; | |
} | |
.wrapper { | |
outline: 1px solid red; | |
} | |
.wrapper:after { | |
content: ''; |
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 {array<string>} arr | |
* @returns {array<string>} | |
*/ | |
function sortAnagrams(arr) { | |
return arr.sort((s1, s2) => { | |
return s1.split('').sort().join('') === s2.split('').sort().join(''); |
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 {array<string>} arr | |
* @returns {array<string>} | |
*/ | |
function sortAnagrams(arr) { |
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
/** | |
* На вход принимает лабиринт: двумерный массив | |
* булевых значений, каждая ячейка указывает на | |
* возможность перемещения туда робота. | |
* Возвращает массив ячеек (row, col), по которым | |
* робот может перемещаться для достижения цели. | |
* Алгоритм рекурсивный, сложность O(2^(N + M)), N, M - размеры сетки. | |
* | |
* @param {array<array><boolean>} maze | |
* @returns {array<array><number>} |
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
/** | |
* Используется мемоизация так, | |
* что время работы уменьшается до O(N x M), | |
* т.к. каждая ячейка посещается не более одного раза. | |
* | |
* @param {array<array><boolean>} maze | |
* @returns {array<array><number>} | |
*/ | |
const getPath = (function() { | |
function getPath(maze, row, col, path, cache) { |
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
body { | |
height: 200px; | |
} | |
.aside { | |
outline: 1px solid red; | |
display: flex; | |
height: 100%; | |
width: 300px; | |
flex-direction: column; |
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 | |
* // 1 | |
* jpath('.foo.bar', { foo: { bar: 1 } }); | |
* | |
* // null | |
* jpath('.foo.bar.baz', { foo: 2 }) | |
*/ | |
const jpath = (function() { | |
function recursiveSearch(fields, source) { |
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
/** | |
* Находит индекс указанного элемента x в массиве arr. | |
* Если такого элемента нет, вернет -1. | |
* Работает за O(log n). | |
* В худшем случае деградирует до O(n), при большом количестве одинаковых элементов. | |
* @param {array<number>} arr | |
* @param {number} x | |
* @returns {number} | |
*/ | |
const search = (function() { |
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
.my-fancy-input { | |
font-size: 20px; | |
font-family: monospace; | |
letter-spacing: 10px; | |
} |
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
.my-fancy-input { | |
position: relative; | |
width: 160px; | |
height: 20px; | |
border: 1px solid black; | |
} | |
.my-fancy-input input { | |
position: absolute; | |
background: transparent; | |
box-sizing: border-box; |