Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
]
},
{
"slug": "bracket-push",
"slug": "matching-brackets",
"uuid": "a2070019-e56d-4d48-994b-300411598707",
"core": true,
"unlocked_by": null,
Expand Down Expand Up @@ -926,7 +926,7 @@
"slug": "linked-list",
"uuid": "49b557ad-0bf0-451b-9a12-6dd9eb0291a2",
"core": false,
"unlocked_by": "bracket-push",
"unlocked_by": "matching-brackets",
"difficulty": 5,
"topics": [
"classes",
Expand Down Expand Up @@ -971,7 +971,7 @@
"slug": "dot-dsl",
"uuid": "d128ec4b-190f-4726-b3e7-870be09531aa",
"core": false,
"unlocked_by": "bracket-push",
"unlocked_by": "matching-brackets",
"difficulty": 5,
"topics": [
"classes",
Expand Down Expand Up @@ -1199,7 +1199,7 @@
"slug": "diamond",
"uuid": "2f3faeb7-7cc3-42ed-9525-cd9c73922a8d",
"core": false,
"unlocked_by": "bracket-push",
"unlocked_by": "matching-brackets",
"difficulty": 8,
"topics": [
"algorithms",
Expand Down
2 changes: 1 addition & 1 deletion exercises/Exercises.sln
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BookStore", "book-store\Boo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Bowling", "bowling\Bowling.csproj", "{CE0CA302-A594-422D-A215-E78F2F3AF0CE}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BracketPush", "bracket-push\BracketPush.csproj", "{A9584773-6FD0-42CB-B94E-A61125C5C1E7}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MatchingBrackets", "matching-brackets\MatchingBrackets.csproj", "{A9584773-6FD0-42CB-B94E-A61125C5C1E7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Change", "change\Change.csproj", "{31595C04-4C0E-4A72-90A1-054EE5C47BFC}"
EndProject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ root = true
[*]
indent_style = space

[BracketPush.cs]
[MatchingBrackets.cs]
indent_size = 4

###############################
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Linq;

public static class BracketPush
public static class MatchingBrackets
{
public static bool IsPaired(string input)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

public static class BracketPush
public static class MatchingBrackets
{
public static bool IsPaired(string input)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,124 @@

using Xunit;

public class BracketPushTest
public class MatchingBracketsTest
{
[Fact]
public void Paired_square_brackets()
{
var value = "[]";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Empty_string()
{
var value = "";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Unpaired_brackets()
{
var value = "[[";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Wrong_ordered_brackets()
{
var value = "}{";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Wrong_closing_bracket()
{
var value = "{]";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Paired_with_whitespace()
{
var value = "{ }";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Partially_paired_brackets()
{
var value = "{[])";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Simple_nested_brackets()
{
var value = "{[]}";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Several_paired_brackets()
{
var value = "{}[]";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Paired_and_nested_brackets()
{
var value = "([{}({}[])])";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Unopened_closing_brackets()
{
var value = "{[)][]}";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Unpaired_and_nested_brackets()
{
var value = "([{])";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Paired_and_wrong_nested_brackets()
{
var value = "[({]})";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Paired_and_incomplete_brackets()
{
var value = "{}[";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Too_many_closing_brackets()
{
var value = "[]]";
Assert.False(BracketPush.IsPaired(value));
Assert.False(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Math_expression()
{
var value = "(((185 + 223.85) * 15) - 543)/2";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}

[Fact(Skip = "Remove to run test")]
public void Complex_latex_expression()
{
var value = "\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)";
Assert.True(BracketPush.IsPaired(value));
Assert.True(MatchingBrackets.IsPaired(value));
}
}
}
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 All @@ -10,8 +10,8 @@ To run the tests, run the command `dotnet test` from within the exercise directo

Initially, only the first test will be enabled. This is to encourage you to solve the exercise one step at a time.
Once you get the first test passing, remove the `Skip` property from the next test and work on getting that test passing.
Once none of the tests are skipped and they are all passing, you can submit your solution
using `exercism submit BracketPush.cs`
Once none of the tests are skipped and they are all passing, you can submit your solution
using `exercism submit MatchingBrackets.cs`

## Further information

Expand Down