Skip to content

Commit

Permalink
bracket-push: rename to matching-brackets (#253)
Browse files Browse the repository at this point in the history
This rename was proposed in:
exercism/problem-specifications#1501

The rationale for the name is:

* to name the exercise by its story, not by what it potentially teaches
* to avoid unnecessarily biasing the solution space
  • Loading branch information
topstack1226 committed Apr 16, 2019
1 parent ee9d4fd commit 62d2ea2
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 77 deletions.
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
Expand Up @@ -1152,7 +1152,7 @@
]
},
{
"slug": "bracket-push",
"slug": "matching-brackets",
"uuid": "b455f96b-329d-4dec-ac31-599b02c0b2e5",
"core": false,
"unlocked_by": null,
Expand Down
73 changes: 0 additions & 73 deletions exercises/bracket-push/bracket-push.test.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Bracket Push
# Matching Brackets

Given a string containing brackets `[]`, braces `{}`, parentheses `()`,
or any combination thereof, verify that any and all pairs are matched
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class BracketPush {
class MatchingBrackets {
bracketPairs: Map<string, string>
expression: string

Expand Down Expand Up @@ -47,4 +47,4 @@ class BracketPush {
}
}

export default BracketPush
export default MatchingBrackets
73 changes: 73 additions & 0 deletions exercises/matching-brackets/matching-brackets.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import MatchingBrackets from './matching-brackets'

describe('Matching Brackets', () => {
it('paired square brackets', () => {
const matchingBrackets = new MatchingBrackets('[]')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('empty string', () => {
const matchingBrackets = new MatchingBrackets('')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('unpaired brackets', () => {
const matchingBrackets = new MatchingBrackets('[[')
expect(matchingBrackets.isPaired()).toBeFalsy()
})

xit('wrong ordered brackets', () => {
const matchingBrackets = new MatchingBrackets('}{')
expect(matchingBrackets.isPaired()).toBeFalsy()
})

xit('wrong closing bracket', () => {
const matchingBrackets = new MatchingBrackets('{]')
expect(matchingBrackets.isPaired()).toBeFalsy()
})

xit('paired with whitespace', () => {
const matchingBrackets = new MatchingBrackets('{ }')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('simple nested brackets', () => {
const matchingBrackets = new MatchingBrackets('{[]}')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('several paired brackets', () => {
const matchingBrackets = new MatchingBrackets('{}[]')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('paired and nested brackets', () => {
const matchingBrackets = new MatchingBrackets('([{}({}[])])')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('unopened closing brackets', () => {
const matchingBrackets = new MatchingBrackets('{[)][]}')
expect(matchingBrackets.isPaired()).toBeFalsy()
})

xit('unpaired and nested brackets', () => {
const matchingBrackets = new MatchingBrackets('([{])')
expect(matchingBrackets.isPaired()).toBeFalsy()
})

xit('paired and wrong nested brackets', () => {
const matchingBrackets = new MatchingBrackets('[({]})')
expect(matchingBrackets.isPaired()).toBeFalsy()
})

xit('math expression', () => {
const matchingBrackets = new MatchingBrackets('(((185 + 223.85) * 15) - 543)/2')
expect(matchingBrackets.isPaired()).toBeTruthy()
})

xit('complex latex expression', () => {
const matchingBrackets = new MatchingBrackets('\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)')
expect(matchingBrackets.isPaired()).toBeTruthy()
})
})
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 62d2ea2

Please sign in to comment.