5.3 KiB
5.3 KiB
title | id | challengeType | videoUrl | localeTitle |
---|---|---|---|---|
Balanced brackets | 594dc6c729e5700999302b45 | 5 | Сбалансированные кронштейны |
Description
Определите, сбалансирована ли сгенерированная строка скобок; то есть, состоит ли он целиком из пар открывающих / закрывающих скобок (в этом порядке), ни одно из которых не выполняется.
Примеры:(пусто) true
[]
true
][
false
[][]
true
][][
false
[]][[]
false
[[[[]]]]
true
Instructions
Tests
tests:
- text: <code>isBalanced</code> - это функция.
testString: 'assert(typeof isBalanced === "function", "<code>isBalanced</code> is a function.");'
- text: '<code>isBalanced("[]")</code> должен возвращать true.'
testString: 'assert(isBalanced(testCases[0]), "<code>isBalanced("[]")</code> should return true.");'
- text: '<code>isBalanced("]][[[][][][]][")</code> должен возвращать значение false.'
testString: 'assert(!isBalanced(testCases[1]), "<code>isBalanced("]][[[][][][]][")</code> should return false.");'
- text: '<code>isBalanced("[][[[[][][[[]]]]]]")</code> должен возвращать true.'
testString: 'assert(isBalanced(testCases[2]), "<code>isBalanced("[][[[[][][[[]]]]]]")</code> should return true.");'
- text: '<code>isBalanced("][")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[3]), "<code>isBalanced("][")</code> should return true.");'
- text: '<code>isBalanced("[[[]]]][[]")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[4]), "<code>isBalanced("[[[]]]][[]")</code> should return true.");'
- text: '<code>isBalanced("][[]")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[5]), "<code>isBalanced("][[]")</code> should return true.");'
- text: '<code>isBalanced("][[][]][[[]]")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[6]), "<code>isBalanced("][[][]][[[]]")</code> should return true.");'
- text: '<code>isBalanced("[[][]]][")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[7]), "<code>isBalanced("[[][]]][")</code> should return true.");'
- text: '<code>isBalanced("[[[]]][[]]]][][[")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[8]), "<code>isBalanced("[[[]]][[]]]][][[")</code> should return true.");'
- text: '<code>isBalanced("[]][[]]][[[[][]]")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[9]), "<code>isBalanced("[]][[]]][[[[][]]")</code> should return true.");'
- text: '<code>isBalanced("][]][[][")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[10]), "<code>isBalanced("][]][[][")</code> should return true.");'
- text: '<code>isBalanced("[[]][[][]]")</code> должен возвращать true.'
testString: 'assert(isBalanced(testCases[11]), "<code>isBalanced("[[]][[][]]")</code> should return true.");'
- text: '<code>isBalanced("[[]]")</code> должен возвращать true.'
testString: 'assert(isBalanced(testCases[12]), "<code>isBalanced("[[]]")</code> should return true.");'
- text: '<code>isBalanced("]][]][[]][[[")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[13]), "<code>isBalanced("]][]][[]][[[")</code> should return true.");'
- text: '<code>isBalanced("][]][][[")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[14]), "<code>isBalanced("][]][][[")</code> should return true.");'
- text: '<code>isBalanced("][][")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[15]), "<code>isBalanced("][][")</code> should return true.");'
- text: '<code>isBalanced("[[]]][][][[]][")</code> должен возвращать true.'
testString: 'assert(!isBalanced(testCases[16]), "<code>isBalanced("[[]]][][][[]][")</code> should return true.");'
- text: <code>isBalanced("")</code> должен возвращать true.
testString: 'assert(isBalanced(testCases[17]), "<code>isBalanced("")</code> should return true.");'
Challenge Seed
function isBalanced (str) {
// Good luck!
return true;
}
After Test
console.info('after the test');
Solution
// solution required