diff --git a/config.json b/config.json index 7efc9239..b1ec752a 100644 --- a/config.json +++ b/config.json @@ -665,7 +665,7 @@ ] }, { - "slug": "bracket-push", + "slug": "matching-brackets", "uuid": "9d25bf46-52d6-435e-a384-38c25517f8ee", "core": false, "unlocked_by": "hello-world", diff --git a/exercises/bracket-push/README.md b/exercises/matching-brackets/README.md similarity index 75% rename from exercises/bracket-push/README.md rename to exercises/matching-brackets/README.md index 79640e0e..52ab0b1f 100644 --- a/exercises/bracket-push/README.md +++ b/exercises/matching-brackets/README.md @@ -1,7 +1,8 @@ -# Bracket Push +# Matching Brackets -Given a string containing brackets `[]`, braces `{}` and parentheses `()`, -verify that all the pairs are matched and nested correctly. +Given a string containing brackets `[]`, braces `{}`, parentheses `()`, +or any combination thereof, verify that any and all pairs are matched +and nested correctly. The Scala exercises assume an SBT project scheme. The exercise solution source should be placed within the exercise directory/src/main/scala. The exercise diff --git a/exercises/bracket-push/build.sbt b/exercises/matching-brackets/build.sbt similarity index 100% rename from exercises/bracket-push/build.sbt rename to exercises/matching-brackets/build.sbt diff --git a/exercises/bracket-push/example.scala b/exercises/matching-brackets/example.scala similarity index 91% rename from exercises/bracket-push/example.scala rename to exercises/matching-brackets/example.scala index 5f8c5e95..c6f99e44 100644 --- a/exercises/bracket-push/example.scala +++ b/exercises/matching-brackets/example.scala @@ -1,6 +1,6 @@ import scala.util.parsing.combinator.RegexParsers -object BracketPush extends RegexParsers { +object MatchingBrackets extends RegexParsers { lazy val t = "[^\\[\\]\\(\\)\\{\\}]+".r private def paren: Parser[String] = diff --git a/exercises/bracket-push/src/main/scala/.keep b/exercises/matching-brackets/src/main/scala/.keep similarity index 100% rename from exercises/bracket-push/src/main/scala/.keep rename to exercises/matching-brackets/src/main/scala/.keep diff --git a/exercises/bracket-push/src/test/scala/BracketPushTest.scala b/exercises/matching-brackets/src/test/scala/MatchingBracketsTest.scala similarity index 52% rename from exercises/bracket-push/src/test/scala/BracketPushTest.scala rename to exercises/matching-brackets/src/test/scala/MatchingBracketsTest.scala index 2fe54d82..b8014942 100644 --- a/exercises/bracket-push/src/test/scala/BracketPushTest.scala +++ b/exercises/matching-brackets/src/test/scala/MatchingBracketsTest.scala @@ -1,80 +1,80 @@ import org.scalatest.{Matchers, FunSuite} /** @version 1.3.0 */ -class BracketPushTest extends FunSuite with Matchers { +class MatchingBracketsTest extends FunSuite with Matchers { test("paired square brackets") { - BracketPush.isPaired("[]") should be(true) + MatchingBrackets.isPaired("[]") should be(true) } test("empty string") { pending - BracketPush.isPaired("") should be(true) + MatchingBrackets.isPaired("") should be(true) } test("unpaired brackets") { pending - BracketPush.isPaired("[[") should be(false) + MatchingBrackets.isPaired("[[") should be(false) } test("wrong ordered brackets") { pending - BracketPush.isPaired("}{") should be(false) + MatchingBrackets.isPaired("}{") should be(false) } test("wrong closing bracket") { pending - BracketPush.isPaired("{]") should be(false) + MatchingBrackets.isPaired("{]") should be(false) } test("paired with whitespace") { pending - BracketPush.isPaired("{ }") should be(true) + MatchingBrackets.isPaired("{ }") should be(true) } test("partially paired brackets") { pending - BracketPush.isPaired("{[])") should be(false) + MatchingBrackets.isPaired("{[])") should be(false) } test("simple nested brackets") { pending - BracketPush.isPaired("{[]}") should be(true) + MatchingBrackets.isPaired("{[]}") should be(true) } test("several paired brackets") { pending - BracketPush.isPaired("{}[]") should be(true) + MatchingBrackets.isPaired("{}[]") should be(true) } test("paired and nested brackets") { pending - BracketPush.isPaired("([{}({}[])])") should be(true) + MatchingBrackets.isPaired("([{}({}[])])") should be(true) } test("unopened closing brackets") { pending - BracketPush.isPaired("{[)][]}") should be(false) + MatchingBrackets.isPaired("{[)][]}") should be(false) } test("unpaired and nested brackets") { pending - BracketPush.isPaired("([{])") should be(false) + MatchingBrackets.isPaired("([{])") should be(false) } test("paired and wrong nested brackets") { pending - BracketPush.isPaired("[({]})") should be(false) + MatchingBrackets.isPaired("[({]})") should be(false) } test("math expression") { pending - BracketPush.isPaired("(((185 + 223.85) * 15) - 543)/2") should be(true) + MatchingBrackets.isPaired("(((185 + 223.85) * 15) - 543)/2") should be(true) } test("complex latex expression") { pending - BracketPush.isPaired( + MatchingBrackets.isPaired( """\left(\begin{array}{cc} \frac{1}{3} & x\ \mathrm{e}^{x} &... x^2 \end{array}\right)""") should be( true) } diff --git a/testgen/src/main/scala/BracketPushTestGenerator.scala b/testgen/src/main/scala/MatchingBracketsTestGenerator.scala similarity index 72% rename from testgen/src/main/scala/BracketPushTestGenerator.scala rename to testgen/src/main/scala/MatchingBracketsTestGenerator.scala index 4d5093a6..deacf542 100644 --- a/testgen/src/main/scala/BracketPushTestGenerator.scala +++ b/testgen/src/main/scala/MatchingBracketsTestGenerator.scala @@ -3,9 +3,9 @@ import java.io.File import testgen.TestSuiteBuilder._ import testgen._ -object BracketPushTestGenerator { +object MatchingBracketsTestGenerator { def main(args: Array[String]): Unit = { - val file = new File("src/main/resources/bracket-push.json") + val file = new File("src/main/resources/matching-brackets.json") val code = TestSuiteBuilder.build(file, fromLabeledTestFromInput("value")) println(s"-------------")