Sha256: b1fe735da22a2df6c9f601ea705c00a354ec27fd695cf2a12a648c6e596d2ea3

Contents?: true

Size: 523 Bytes

Versions: 208

Compression:

Stored size: 523 Bytes

Contents

using System.Linq;

public static class BracketPush
{
    public static bool Matched(string input)
    {
        var brackets = new string(input.Where(c => "[]{}()".Contains(c)).ToArray());
        var previousLength = brackets.Length;

        while (brackets.Length > 0)
        {
            brackets = brackets.Replace("[]", "").Replace("{}", "").Replace("()", "");

            if (brackets.Length == previousLength)
            {
                return false;
            }
        }

        return true;
    }
}

Version data entries

208 entries across 208 versions & 1 rubygems

Version Path
trackler-2.1.0.53 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.52 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.51 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.50 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.49 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.48 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.47 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.46 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.45 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.44 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.43 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.42 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.41 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.40 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.39 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.38 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.37 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.36 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.34 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.33 tracks/csharp/exercises/bracket-push/Example.cs