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.32 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.31 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.30 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.29 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.28 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.27 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.26 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.25 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.24 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.23 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.22 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.21 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.20 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.19 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.18 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.17 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.16 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.15 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.14 tracks/csharp/exercises/bracket-push/Example.cs
trackler-2.1.0.13 tracks/csharp/exercises/bracket-push/Example.cs