~
and β
.300
, 44-99
.The structure of the base part of the address consists of the region, municipality, the name and surname of the addressee. The municipality can be divided into districts and post offices. All parts are separated by a comma,.
The names of regions, municipalities and districts are words, the first letter in each word is big, the rest are small. The names of two words are possible, separated by a space or a minus sign. Each word has from three to eight letters AZ.
([-][-]{2,7})
. And the names, respectively, ([-][-]{2,7}(?:[- ][-][-]{2,7}))
.The inhabitants on the hands of 6 fingers, in everyday life duodenalized system. Figures 0β9 are used as is, and 10 and 11 are denoted by~
andβ
.
\d
for numbers β you need to use [0-9~β]
.The post office number in the composition has either 3 digits in a row, or 4, divided into 2 groups of 2 digits with a minus sign. Examples:300
,44-99
.
([0-9~β]{3}|[0-9~β]{2}-[0-9~β]{2})
.Sometimes residents send letters to the municipality of demand. In this case, there is no address: only the municipality and the name of the addressee.
It's funny, but people on the planet are called only six names and nine surnames. Names: Shob, Reb, Mob, Xiang, Ryan, Man. Surnames: Shyo, Ryo, Mo, Xia, Rya, Ma, Xiu, Ryu, Mu. Residents on this planet are not dreamers.
(||||||||) (|||||)
or its shorter analogue ([][]|[]) ([C]|[]||)
. const w = '[-][-]{2,7}'; // word const d = '[0-9~β]'; // digit const name = `(?:${w}(?:[- ]${w})?)`; const number = `(?:${d}{3}|${d}{2}-${d}{2})`; const person = '(?:[][]|[]) (?:|||||)'; // , , (, , )? const re = new RegExp(`^(${name}),\\s*(${name}),\\s*(?:(${name}),\\s*(${number}),\\s*)?(${person})$`); module.exports = function(str) { // if (typeof str !== 'string') return null; const res = str.match(re); // - if (!res) return null; // // , return res.slice(1); };
diff --git a / blitz.html b / blitz.html
index 36b9af8..1e30545 100644
--- a / blitz.html
+++ b / blitz.html
@@ -531.10 +531.6 @@
iframe [src $ = 'ext-analytics.html'] {
height: auto;
}
-.search2__button .suggest2-form__button: nth-child (1) {
- background: # ff0! important;
-}
-
/ * ../../blocks-desktop/input/__control/input__control.styl end * /
/ * ../../node_modules/islands/common.blocks/input/__clear/input__clear.css begin * /
/ * Positioned relative to input__box.
@@ -744.10 +740.6 @@
iframe [src $ = 'ext-analytics.html'] {
background-clip: padding-box;
}
.input_theme_websearch .input__clear {
background-image: url ("/ static / web4 / node_modules / islands / common.blocks / input / _theme / input_theme_websearch.assets / clear.svg");
background-size: 16px;
@@ -857.6 +849.7 @@
iframe [src $ = 'ext-analytics.html'] {
background-color: # f2cf46;
}
.websearch-button__text: before {
+ position: absolute;
top: -6px;
right: -9px;
width: 0;
@@ -866.8 +859.6 @@
iframe [src $ = 'ext-analytics.html'] {
border-style: solid;
border-color: rgba (255,219,76,0);
border-left-color: inherit;
- position: relative;
- z-index: -1000;
}
/ * ../../blocks-deskpad/websearch-button/websearch-button.styl end * /
@@ -1349.6 +1340.7 @@
iframe [src $ = 'ext-analytics.html'] {
font-size: 14px;
line-height: 40px;
position: relative;
+ display: inline-block;
height: auto;
padding: 0;
vertical-align: middle;
div { background: #0C0C0C; border-radius: 10px; position: relative; } div:before { border-radius: 9px 9px 0 0; position: absolute; width: 100%; height: 50%; background: #F8E34B; content: ''; } div:after { content: ''; background: linear-gradient(178deg, #C8C8C8 0px , transparent 7px), #EEEDEF; position: absolute; width: 50%; height: 50%; bottom: 0; border-radius: 0 0 0 9px; }
<div class="game"> <div class="target"> <div class="line"> <div class="symbol nine"></div> <div class="symbol eight"></div> <div class="symbol five"></div> <div class="symbol separator"></div> <div class="symbol four"></div> <div class="symbol one"></div> <div class="symbol two"></div> <div class="symbol separator"></div> </div> <!-- ... --> </div> <!-- ... --> </div>
const digits = document.querySelectorAll('.game .target .symbol:not(.separator)'); const dict = { 'one': 1, 'two': 2, 'three': 3, 'four': 4, 'five': 5, 'six': 6, 'seven': 7, 'eight': 8, 'nine': 9, 'zero': 0, }; const phoneNumber = Array.from(digits).reduce((res, elem) => { for (const className of elem.classList) { if (className in dict) { res.push(dict[className]); break; } } return res; }, []);
<div class="keys"> <div class="key"></div> <div class="key"></div> <!-- β¦ --> </div>
.key:nth-child(3):before { content: '3'; }
const keys = Array.from(document.querySelectorAll('.game .key')).reduce((res, elem) => { const key = window // CSSStyleDeclaration - .getComputedStyle(elem, ':before') // .getPropertyValue('content') // , .replace(/"/g, ''); res[key] = elem; return res; }, {});
phoneNumber.push('call'); const call = () => { const event = new Event('click'); const next = phoneNumber.shift(); keys[next].dispatchEvent(event); if (phoneNumber.length) { setTimeout(call, 100); } } call();
## - % 1%, %username1%, : %username2% - % 2%, %username1%, : %username2%, %username3% - % 3%, %username1% // - % 4%, : %username1%, %username2% // - % 5% // - % 6%, : %username1% - % 1%, %username1% // - % 2% - % 3%, : %username1% ## - %username1% * % 1% // , * % 2% * % 3% * % 1% - %username2% * % 3%
type User = { login: string; tasks: Task[]; spectating: Task[]; };
type Task = { title: string; assignee: User; spectators: User[]; subtasks: Task[]; parent: Task | null; };
/** * @param {User|Task} data - , * (User Task) * @return {string} */ module.exports = function (data) { // return 'β¦'; }
// const User1 = { type: 'user', login: 'fedor', tasks: [], spectating: [] }; const User2 = { type: 'user', login: 'arkady', tasks: [], spectating: [] }; // const Task1 = { type: 'task', title: 'Do something', assignee: null, spectators: [], subtasks: [], parent: null }; const Task2 = { type: 'task', title: 'Something else', assignee: null, spectators: [], subtasks: [], parent: null }; const Task3 = { type: 'task', title: 'Sub task', assignee: null, spectators: [], subtasks: [], parent: null }; // : // Task1.assignee = User1; User1.tasks.push(Task1); // ... β Task1.spectators.push(User2); User2.spectating.push(Task1); // , // Task2.spectators.push(User1); User1.spectating.push(Task2); // Task3.parent = Task2; Task2.subtasks.push(Task3); // , β 3 const lastEdited = Task3;
{ type: 'task', title: 'Sub task', assignee: null, spectators: [], subtasks: [], parent: { type: 'task', title: 'Something else', assignee: null, spectators: [ { type: 'user', login: 'fedor', tasks: [ { type: 'task', title: 'Do something', assignee: [Circular], spectators: [ { type: 'user', login: 'arkady', tasks: [], spectating: [ [Circular] ] } ], subtasks: [], parent: null } ], spectating: [ [Circular] ] } ], subtasks: [ [Circular] ], parent: null } }
## - Do something, fedor, : arkady - Something else, : fedor - Sub task ## - arkady - fedor * Do something
/** * , * @param {{ref: object, visited: ?boolean}} ctx * @param {object} handlers β */ function traverse(ctx, handlers) { // , ctx.ref , β , task.parent if (!ctx.ref) { return; } // , , const visited = ctx.visited || new Set(); if (visited.has(ctx.ref)) { return; } visited.add(ctx.ref); // handlers[ctx.ref.type](ctx.ref, goDeeper); // , function goDeeper(subrefs) { // for (const subref of [].concat(subrefs)) { traverse({ visited, ref: subref }, handlers); } } } // const users = []; const tasks = []; // ref β traverse({ ref }, { user(user, deeper) { users.push(user); deeper(user.tasks); // to task.assignee deeper(user.spectating); // to task.spectators }, task(task, deeper) { tasks.push(task); deeper(task.assignee); // to user.tasks deeper(task.spectators); // to user.spectating deeper(task.parent); // to task.subtasks deeper(task.subtasks); // to task.parent } );
users.sort((u1, u2) => u1.login < u2.login ? -1 : (u1.login > u2.login ? 1 : 0)); tasks.sort((t1, t2) => t1.title < t2.title ? -1 : (t1.title > t2.title ? 1 : 0));
// const taskLine = t => `${ t.title }${ t.assignee ? `, ${t.assignee.login}` : '' }${ t.spectators.length ? `, : ${t.spectators.map(u => u.login).join(', ')}` : '' }`; function renderTasks (parent = null, indent = 0) { return tasks .filter(t => t.parent === parent) .map(t => [ '\n', ' '.repeat(indent), // '- ', taskLine(t), // t.subtasks.length ? printTasks(t, indent + 2) : '' // ].join('')) .join(''); } function renderUsers () { return ${users.map(u => `\n- ${u.login}${ u.tasks.map(t => `\n * ${t.title}`).join('') }`).join('')} } const result = ` ## ${renderTasks()} ## ${renderUsers()} `.trim();
const writeQueue = []; const processQueue = () => { if (writeQueue.length) { const fn = writeQueue.shift(); fn().then(() => { processQueue(); }); } }
const writeQueue = []; let isWriteInProgress = false; const processQueue = () => { if (isWriteInProgress) { return; } if (writeQueue.length) { isWriteInProgress = true; const fn = writeQueue.shift(); fn().then(() => { isWriteInProgress = false; processQueue(); }); } }
app.post("/speeddial/:digit/:phonenumber", (req, res) => { writeQueue.push(makeWriteJob(phone, req, res)); processQueue(); });
const express = require('express'); const { BEEP_CODES } = require('@yandex-blitz/phone'); const writeQueue = []; let isWriteInProgress = false; const processQueue = () => { if (isWriteInProgress) { return; } if (writeQueue.length) { isWriteInProgress = true; const fn = writeQueue.shift(); fn().then(() => { isWriteInProgress = false; processQueue(); }); } } const makeWriteJob = (phone, req, res) => { return () => { return phone.getData() .then(value => { const speeddialDict = JSON.parse(value); speeddialDict[req.params.digit] = Number(req.params.phonenumber); return phone .setData(JSON.stringify(speeddialDict)) .then(() => phone.beep(BEEP_CODES.SUCCESS)) .then(() => { res.sendStatus(200); }) }) .catch(e => { phone.beep(BEEP_CODES.ERROR).then(() => { res.sendStatus(500); }) }) } }; const createApp = ({ phone }) => { const app = express(); // , Β« Β» digit app.get("/speeddial/:digit", (req, res) => { phone.getData().then(value => { const speeddialDict = JSON.parse(value); return phone.connect() .then(async () => { await phone.dial(speeddialDict[req.params.digit]); res.sendStatus(200); }, async() => { await phone.beep(BEEP_CODES.FATAL); res.sendStatus(500); }); }).catch(async (e) => { await phone.beep(BEEP_CODES.ERROR); res.sendStatus(500); }); }); // Β« Β» digit phonenumber app.post("/speeddial/:digit/:phonenumber", (req, res) => { writeQueue.push(makeWriteJob(phone, req, res)); processQueue(); }); return app; }; exports.createApp = createApp;
background: radial-gradient(circle at 5px 5px, #eee, #000);
window.map = ` ##### #o#x# #.#.# #...# ##### `;
<!DOCTYPE html> <html lang=ru/> <head> <style> body { padding: 100px 0 0 100px; } .game-box { perspective: 500px; perspective-origin: center; } .map { transform-style: preserve-3d; } .map__tilt_left { transform: rotateY(-25deg); } .map__tilt_down { transform: rotateX(-25deg); } .map__tilt_up { transform: rotateX(25deg); } .map__tilt_right { transform: rotateY(25deg); } </style> <title></title> </head> <body> <div class="game-box"> <div class="map"> <!-- --> </div> </div> <script> // JavaScript </script> </body> </html>
<table class="map map__tilt_none"> <!-- ... --> <tr> <td class="map__cell map__cell_content_wall"></td> <td class="map__cell map__cell_content_empty"></td> <td class="map__cell map__cell_content_ball"></td> <td class="map__cell map__cell_content_exit"></td> <td class="map__cell map__cell_content_wall"></td> </tr> <!-- ... --> </table>
.map { border: 0; border-spacing: 0; border-collapse: separate; background-color: #ccc; transform-style: preserve-3d; } .map__cell { box-sizing: border-box; border: 1px solid; border-color: #9b9b9b #575757 #575757 #9b9b9b; width: 30px; height: 30px; text-align: center; vertical-align: middle; font-size: 0; line-height: 0; background-color: #707070; } .map__cell_content_ball:after { content: ''; display: inline-block; width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 5px 5px, #eee, #000); } .map__cell_content_wall { border-width: 4px; } .map__cell_content_exit { background-color: #000; border: 5px solid; border-color: #222 #555 #555 #222; }
window.map = ` ####### ##.#### #..o..# ##x.#.# ###...# ####### `;
function convertMap(mapInput) { return mapInput .trim() .split(/\n\s*/) .map(row => row.split('')); }
const CELL_CONTENT = { '#': 'wall', 'o': 'ball', '.': 'empty', 'x': 'exit' }; function buildGameBoxHtml(map) { return ` <div class="game-box"> <table class="map map__tilt_none"> ${map.map(row => ` <tr> ${row.map(cell => ` <td class="map__cell map__cell_content_${CELL_CONTENT[cell]}"></td> `).join('')} </tr> `).join('')} </table> <!-- --> <div class="controls"> <button class="control control_direction_left">β</button> <button class="control control_direction_down">β</button> <button class="control control_direction_up">β</button> <button class="control control_direction_right">β</button> </div> </div> `; }
let gameBox = document.querySelector('.game-box'); let map = gameBox.querySelector('.map'); // gameBox.addEventListener('click', ({ target }) => { // if (!target.classList.contains('control')) { return; }; // - const direction = target.className.match(/\bcontrol_direction_(\w+)/)[1]; // , - map.className = map.className.replace(/\bmap__tilt_\w+/, `map__tilt_${direction}`); // , let ball = map.querySelector('.map__cell_content_ball'); // let nextBall = getNextCell(map, ball, direction); // ball.classList.remove('map__cell_content_ball'); ball.classList.add('map__cell_content_empty'); // , while ( !nextBall.classList.contains('map__cell_content_wall') && !ball.classList.contains('map__cell_content_exit') ) { ball = nextBall; nextBall = getNextCell(map, ball, direction); } // ball.classList.remove('map__cell_content_empty'); ball.classList.add('map__cell_content_ball'); }); const DIRECTIONS = { 'left': [-1, 0], 'up': [0, -1], 'down': [0, 1], 'right': [1, 0] }; // DOM API , function getNextCell(map, cell, direction) { const directionDiff = DIRECTIONS[direction]; return map.rows[cell.parentNode.rowIndex + directionDiff[1]].cells[cell.cellIndex + directionDiff[0]]; }
module.exports = function solveCaptcha(captcha) { // ... }
captcha = ' TRABWARH THSCAHAW WWBSCWAA CACACHCR '
[ 'TRABWARH THSCAHAW' , 'WWBSCWAA CACACHCR' ]
module.exports = function solveCaptcha(captcha) { const n = // const sizes = getAllSizes(); // // board β // β , // , const board = []; // function placeNext(remains) { // ... if (remains === 0) { // ... , , return board; } else { // ... // // , const pos = getEmptyPos(); // for (let i = 0; i < sizes.length; i++) { // , const size = sizes[i]; // // ( // !== 1), null const layer = getLayer(pos, size); // if (layer) { // board.push(layer); // const res = placeNext(remains - 1); // , if (res) return res; // // board.pop(); } } } } // return placeNext(n); }
type PullRequest = { /** * ( ) * N: 1 <= N <= 1000 */ files: string[], /** * VCS */ id: string, /** * Unix-timestamp - */ created: number, }
/** * @param {PullRequest[]} pullRequests PR, * @returns {string[]} */ module.exports = function (pullRequests) { // }
function mergeAllPRs(prs) { /* solution */ } console.assert( mergeAllPRs([ { id: '#1', created: 1536077100, files: ['.gitignore', 'README.md'] }, { id: '#2', created: 1536077700, files: ['index.js', 'package-lock.json', 'package.json'] }, { id: '#3', created: 1536077800, files: ['.pnp.js', 'yarn.lock'] } ]) .join(',') === [ "#1", "#2", "#3" ].join(',') ); console.assert( mergeAllPRs([ { id: '#1', created: 1536074100, files: ['README.md'] }, { id: '#2', created: 1536078700, files: ['README.md'] }, { id: '#3', created: 1536097800, files: ['README.md'] } ]).join(',') === [ "#1" ].join(',') ); console.assert( mergeAllPRs([ { id: '#1', created: 1536077100, files: ['.gitignore', 'README.md'] }, { id: '#2', created: 1536077700, files: ['index.js', 'package-lock.json', 'package.json'] }, { id: '#3', created: 1536077800, files: ['.pnp.js', 'package-lock.json', 'yarn.lock'] }, { id: '#4', created: 1536077900, files: ['index.spec.js', 'index.spec.ts', 'index.ts'] } ]) .join(',') === [ "#1", "#2", "#4" ].join(',') );
function conflicts(a, b) { let i = 0; let j = 0; while (i < a.length && j < b.length) { if (a[i] === b[j]) { return true; } else if (a[i] > b[j]) { j++; } else { i++; } } return false; } function mergeAllPrs (input) { let i = 0; const mergedFiles = []; const mergedPrs = []; while (i < input.length) { const pr = input[i]; if (!conflicts(mergedFiles, pr.files)) { mergedPrs.push(pr); mergedFiles.push(...pr.files); } i++; } return mergedPrs.map(x => x.id); };
console.assert( mergeAllPrs([ { "id": "1", "created": 1538179200, "files": [ "a", "b", "c", "d" ] }, { "id": "2", "created": 1538189200, "files": [ "a", "x" ] }, { "id": "3", "created": 1538199200, "files": [ "b", "g" ] }, { "id": "4", "created": 1538209200, "files": [ "c", "f" ] }, { "id": "5", "created": 1538219200, "files": [ "d", "w" ] } ]) .join(',') === ['2', '3', '4', '5'].join(',') );
[ { "id": "#1", "created": 1536077100, "files": [ ".gitignore", "README.md" ] }, { "id": "#2", "created": 1536077700, "files": [ "index.js", "package-lock.json", "package.json" ] }, { "id": "#3", "created": 1536077800, "files": [ "index.js" ] } ]
const conflictMatrix = new Uint8Array(prs.length ** 2); const prToIndex = new WeakMap(); for (let i = 0; i < prs.length; i++) { const pr1 = prs[i]; prToIndex.set(pr1, i); conflictMatrix[i * prs.length + i] = 0; for (let j = i + 1; j < prs.length; j++) { const pr2 = prs[j]; conflictMatrix[i * prs.length + j] = conflictMatrix[j * prs.length + i] = conflicts(pr1.files, pr2.files); } } /** * PR ( ) */ function doPRsConflict(pr1, pr2) { const i = prToIndex.get(pr1); const j = prToIndex.get(pr2); return conflictMatrix[i * prs.length + j] === 1; }
/** * prsSet, */ function getNonConflictingPRs (prsSet, mergedPrs) { const result = []; const prsToTest = [...prsSet, ...mergedPrs]; prsSet.forEach((pr) => { if (!conflictsWithSomePR(pr, prsToTest)) { result.push(pr); } }); return result; }
const fullSearch = (prsSet, mergedPrs = [], mergedFilesCount = 0) => { hits++; // , // , const safeToMergePRs = getNonConflictingPRs(prsSet, mergedPrs); mergedPrs = mergedPrs.concat(safeToMergePRs); safeToMergePRs.forEach((pr) => { prsSet.delete(pr); mergedFilesCount += pr.files.length; }); const pr = prsSet.values().next().value; // ...
Source: https://habr.com/ru/post/430560/
All Articles