Sha256: 490464a30c1a4a1992d7e14b46c70a53eef40d75252c7f5997a0b730263008d2

Contents?: true

Size: 457 Bytes

Versions: 281

Compression:

Stored size: 457 Bytes

Contents

using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

public static class Acronym
{
    public static string Abbreviate(string phrase)
    {
        return Words(phrase).Aggregate("", (abbr, word) => abbr + char.ToUpperInvariant(word[0]));
    }

    private static IEnumerable<string> Words(string phrase)
    {
        return Regex.Matches(phrase, "[A-Z]+[a-z]*|[a-z]+").Cast<Match>().Select(m => m.Value);
    }
}

Version data entries

281 entries across 281 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.179 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.178 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.177 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.176 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.175 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.174 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.173 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.172 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.171 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.170 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.169 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.167 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.166 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.165 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.164 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.163 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.162 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.161 tracks/csharp/exercises/acronym/Example.cs
trackler-2.2.1.160 tracks/csharp/exercises/acronym/Example.cs