Mistake in test case Question #230
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 45/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- typescript
- Domain
- content
Research direction
Open question 230 from the linked DevFAQ page and compare the stated valid test case with the issue’s bracket analysis and TypeScript reproduction. Update the question so the example with the unmatched closing bracket is represented correctly, then verify that the displayed test cases and expected results are consistent.
Written by the indexing model from the issue text.
Description
There is a mistake in this question.

It is written that "{dklf(df(kl))d]{}" is a valid test case while it is not due to the not opened "[".
Please update the question.
The code I used to test the cases:
const sum = (arr: number[]): number => arr.reduce((acc, el) => acc+el, 0);
type OpeningBracket = "(" | "[" | "{";
type BracketStackMap = Record<OpeningBracket, number>;
const checkBrackets = (str: string) => {
const brackets = ["(",")", "[","]", "{","}"]; // "()[]{}".split("");
const filtered = str.split("").filter(character => brackets.includes(character));
const bracketsStack = new Map<BracketStackMap>([["(", 0], ["[", 0], ["{", 0]]);
for(let i=0; i<filtered.length; i++){
// could be simplified with closed/opening bracket key/value mapping
const key = filtered[i] === ")" ? "("
: filtered[i] === "]" ? "["
: filtered[i] === "}" ? "{"
: filtered[i];
const currentVal = bracketsStack.get(key);
// console.log({i, str: filtered[i], key})
switch(filtered[i]){
case "(":
case "[":
case "{":
bracketsStack.set(filtered[i], currentVal + 1);
break;
case ")":
case "]":
case "}":
bracketsStack.set(key, currentVal - 1);
break;
default: throw new Error(`Unhandled bracket: ${filtered[i]}`);
}
if(bracketsStack.get(key) < 0){
// console.log("negative", bracketsStack.get(key))
return false;
};
}
return (sum([...bracketsStack.values()]) === 0);
};
const tests = {
"{ac[bb]}": true,
"{dklf(df(kl))d]{}": true, //fails, should pass according to task description
"{[[[]]]}": true,
"{3234[fd": false,
"{df][d}": false
};
Object.entries(tests).forEach(([test, expected]) => {
const result = (checkBrackets(test) === expected) ? "✅" : "❌";
console.log(`${result} "${test}" `);
});
// results
"✅ '{ac[bb]}' "
"❌ '{dklf(df(kl))d]{}' "
"✅ '{[[[]]]}' "
"✅ '{3234[fd' "
"✅ '{df][d}' "
- Dominant language
- TypeScript
- Stars
- 40
- Forks
- 10
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from typeofweb-org/devfaq
-
Dodanie możliwości sortowania pytań po dacie aktualizacji / edycjiMay be free again @grzegorzpokorski claimed this 1343 days ago, and no pull request is open. Open
typeofweb-org/devfaq#506 · 1 assignee ·
-
Użyj vercel/og-image do generowania obrazków na social mediaMay be free again @xStrixU claimed this 1343 days ago, and no pull request is open. Open
typeofweb-org/devfaq#504 · 1 assignee ·
-
Edycja własnych pytańMay be free again @xStrixU claimed this 1357 days ago, and no pull request is open. Open
typeofweb-org/devfaq#481 · 1 assignee ·
-
Przycisk do edycji pytania dla adminówMay be free again @grzegorzpokorski claimed this 1345 days ago, and no pull request is open. Open
typeofweb-org/devfaq#479 · 1 assignee ·
-
Admin panel dla odpowiedziMay be free again @grzegorzpokorski claimed this 1341 days ago, and no pull request is open. Open
typeofweb-org/devfaq#478 · 1 assignee ·
All issues in typeofweb-org/devfaq
Similar issues
-
check:passed streams:add
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Fission-AI/OpenSpec#1986 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
nestjs/docs.nestjs.com#3554 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
publicodes/publicodes#868 ·
-
namespace operations
Difficulty 1/5 Under an hour Newbie friendliness 78/100
EclipseFdn/open-vsx.org#13488 ·
Maintainers usually reply within 2 days