Skip to content

Instantly share code, notes, and snippets.

View alunov-equinix's full-sized avatar

Anton Lunov alunov-equinix

View GitHub Profile
@alunov-equinix
alunov-equinix / get-unique-substr-lengths.test.js
Created September 13, 2020 13:24
Tests for get-unique-substr-lengths.js
getUniqueSubstrLengths(''); // result -> []
getUniqueSubstrLengths('a'); // result -> [1]
getUniqueSubstrLengths('ab'); // result -> [1, 1]
getUniqueSubstrLengths('abc'); // result -> [1, 1, 1]
getUniqueSubstrLengths('abobc'); // result -> [1, 3, 1]
getUniqueSubstrLengths('aazz'); // result -> [2, 2]
getUniqueSubstrLengths('ababdeedhigthtdfgfdgbjxfvsdpkcweqfkoeriovsmxpoozzzzz'); // result -> [47, 5]
getUniqueSubstrLengths('hkjljlkklkjlk'); // result -> [1, 12]
getUniqueSubstrLengths('ababdeeda'); // result -> [9]
getUniqueSubstrLengths('ababdeedhigtht'); // result -> [4, 4, 6]
@alunov-equinix
alunov-equinix / get-unique-substr-lengths.js
Last active September 13, 2020 13:46
JS solution for UniLecs task #140
const getNextState = (str, end) => {
let i,
start = str[0],
substr = '',
count = 1;
for (i = 1; i < str.length; i++) {
if (start === str[i]) {
count++;
if (end < i) {
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title></title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<!-- Галереи и картинки можно добавлять в любом кол-ве(только нужно сохранять названия классов) -->