-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Week 17 challenge | ||
|
||
You have joined a team which works on a new programming language. The language is intended to be functional lisp-like. | ||
So a lot of parenthesis in the syntax. | ||
|
||
You pick up the task to write utility for the parser, which will simply validate if in given string the parenthesis are valid. | ||
E.g. are they wrapping and closing properly. | ||
|
||
This function should only look at parenthesis and, thus, ignore any other characters that might be in it. | ||
|
||
|
||
Examples: | ||
``` | ||
isValid('fn(1, 2, 3)') // returns true | ||
isValid('!)()()') // return false | ||
isValid('()') // returns true | ||
isValid('())') // returns false | ||
isValid('(()(()))') // returns true | ||
isValid(')(()(()))') // returns false | ||
isValid('((777))(((arg)())(...rest))') // returns true | ||
isValid('((777))((...args)())(9))') // returns false | ||
``` | ||
|
||
|
||
## Upload link | ||
|
||
[https://forms.gle/N4rY73sULh3prw96A] | ||
|
||
|
||
## Results | ||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
const isValid = (code) => { | ||
// your solution here | ||
|
||
return undefined; | ||
}; | ||
|
||
module.exports = isValid; |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const spec = require("./test-cases/spec.json"); | ||
const solutions = fs.readdirSync(path.resolve(__dirname, "solutions")); | ||
|
||
describe.each(solutions)("%s", (filename) => { | ||
const evaluate = require(path.resolve(__dirname, "solutions", filename)); | ||
test.each([ | ||
['n(1, 2, 3)', true], | ||
['!)()()', false], | ||
['()', true], | ||
['())', false], | ||
['(()(()))', true], | ||
[')(()(()))', false], | ||
['((777))(((arg)())(...rest))', true], | ||
['((777))((...args)())(9))', false], | ||
])("%j = %j", (input, result) => { | ||
expect(evaluate(input)).toBe(result); | ||
}); | ||
|
||
test.each(spec.map(({ inputs, result }) => [inputs[0], result]))( | ||
"%j = %j", | ||
(input, result) => { | ||
expect(evaluate(input)).toBe(result); | ||
} | ||
); | ||
}); |
This file contains 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