Skip to content

Commit 301997c

Browse files
ricemeryErikSchierboom
authored andcommitted
Rename bracket-push exercise to matching-brackets. (#609)
* Rename bracket-push exercise to matching-brackets. Refs #607 * Remove unneeded build.properties. Refs #607 * Put pending annotations back in test cases. Refs #607
1 parent 5a2c43e commit 301997c

File tree

7 files changed

+24
-23
lines changed

7 files changed

+24
-23
lines changed

config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -665,7 +665,7 @@
665665
]
666666
},
667667
{
668-
"slug": "bracket-push",
668+
"slug": "matching-brackets",
669669
"uuid": "9d25bf46-52d6-435e-a384-38c25517f8ee",
670670
"core": false,
671671
"unlocked_by": "hello-world",

exercises/bracket-push/README.md renamed to exercises/matching-brackets/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
# Bracket Push
1+
# Matching Brackets
22

3-
Given a string containing brackets `[]`, braces `{}` and parentheses `()`,
4-
verify that all the pairs are matched and nested correctly.
3+
Given a string containing brackets `[]`, braces `{}`, parentheses `()`,
4+
or any combination thereof, verify that any and all pairs are matched
5+
and nested correctly.
56

67
The Scala exercises assume an SBT project scheme. The exercise solution source
78
should be placed within the exercise directory/src/main/scala. The exercise

exercises/bracket-push/example.scala renamed to exercises/matching-brackets/example.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import scala.util.parsing.combinator.RegexParsers
22

3-
object BracketPush extends RegexParsers {
3+
object MatchingBrackets extends RegexParsers {
44
lazy val t = "[^\\[\\]\\(\\)\\{\\}]+".r
55

66
private def paren: Parser[String] =

exercises/bracket-push/src/test/scala/BracketPushTest.scala renamed to exercises/matching-brackets/src/test/scala/MatchingBracketsTest.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,80 @@
11
import org.scalatest.{Matchers, FunSuite}
22

33
/** @version 1.3.0 */
4-
class BracketPushTest extends FunSuite with Matchers {
4+
class MatchingBracketsTest extends FunSuite with Matchers {
55

66
test("paired square brackets") {
7-
BracketPush.isPaired("[]") should be(true)
7+
MatchingBrackets.isPaired("[]") should be(true)
88
}
99

1010
test("empty string") {
1111
pending
12-
BracketPush.isPaired("") should be(true)
12+
MatchingBrackets.isPaired("") should be(true)
1313
}
1414

1515
test("unpaired brackets") {
1616
pending
17-
BracketPush.isPaired("[[") should be(false)
17+
MatchingBrackets.isPaired("[[") should be(false)
1818
}
1919

2020
test("wrong ordered brackets") {
2121
pending
22-
BracketPush.isPaired("}{") should be(false)
22+
MatchingBrackets.isPaired("}{") should be(false)
2323
}
2424

2525
test("wrong closing bracket") {
2626
pending
27-
BracketPush.isPaired("{]") should be(false)
27+
MatchingBrackets.isPaired("{]") should be(false)
2828
}
2929

3030
test("paired with whitespace") {
3131
pending
32-
BracketPush.isPaired("{ }") should be(true)
32+
MatchingBrackets.isPaired("{ }") should be(true)
3333
}
3434

3535
test("partially paired brackets") {
3636
pending
37-
BracketPush.isPaired("{[])") should be(false)
37+
MatchingBrackets.isPaired("{[])") should be(false)
3838
}
3939

4040
test("simple nested brackets") {
4141
pending
42-
BracketPush.isPaired("{[]}") should be(true)
42+
MatchingBrackets.isPaired("{[]}") should be(true)
4343
}
4444

4545
test("several paired brackets") {
4646
pending
47-
BracketPush.isPaired("{}[]") should be(true)
47+
MatchingBrackets.isPaired("{}[]") should be(true)
4848
}
4949

5050
test("paired and nested brackets") {
5151
pending
52-
BracketPush.isPaired("([{}({}[])])") should be(true)
52+
MatchingBrackets.isPaired("([{}({}[])])") should be(true)
5353
}
5454

5555
test("unopened closing brackets") {
5656
pending
57-
BracketPush.isPaired("{[)][]}") should be(false)
57+
MatchingBrackets.isPaired("{[)][]}") should be(false)
5858
}
5959

6060
test("unpaired and nested brackets") {
6161
pending
62-
BracketPush.isPaired("([{])") should be(false)
62+
MatchingBrackets.isPaired("([{])") should be(false)
6363
}
6464

6565
test("paired and wrong nested brackets") {
6666
pending
67-
BracketPush.isPaired("[({]})") should be(false)
67+
MatchingBrackets.isPaired("[({]})") should be(false)
6868
}
6969

7070
test("math expression") {
7171
pending
72-
BracketPush.isPaired("(((185 + 223.85) * 15) - 543)/2") should be(true)
72+
MatchingBrackets.isPaired("(((185 + 223.85) * 15) - 543)/2") should be(true)
7373
}
7474

7575
test("complex latex expression") {
7676
pending
77-
BracketPush.isPaired(
77+
MatchingBrackets.isPaired(
7878
"""\left(\begin{array}{cc} \frac{1}{3} & x\ \mathrm{e}^{x} &... x^2 \end{array}\right)""") should be(
7979
true)
8080
}

testgen/src/main/scala/BracketPushTestGenerator.scala renamed to testgen/src/main/scala/MatchingBracketsTestGenerator.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import java.io.File
33
import testgen.TestSuiteBuilder._
44
import testgen._
55

6-
object BracketPushTestGenerator {
6+
object MatchingBracketsTestGenerator {
77
def main(args: Array[String]): Unit = {
8-
val file = new File("src/main/resources/bracket-push.json")
8+
val file = new File("src/main/resources/matching-brackets.json")
99

1010
val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("value"))
1111
println(s"-------------")

0 commit comments

Comments
 (0)