Sha256: a4ce6f5655b7756a9020d4cd941f314446e3d917bb1fae991e20c4e5bfb80e68

Contents?: true

Size: 1.35 KB

Versions: 231

Compression:

Stored size: 1.35 KB

Contents

using System.Linq;

public static class House
{
    private static readonly string[] Subjects =
    {
        "house that Jack built",
        "malt",
        "rat",
        "cat",
        "dog",
        "cow with the crumpled horn",
        "maiden all forlorn",
        "man all tattered and torn",
        "priest all shaven and shorn",
        "rooster that crowed in the morn",
        "farmer sowing his corn",
        "horse and the hound and the horn"
    };

    private static readonly string[] Verbs =
    {
        "lay in",
        "ate",
        "killed",
        "worried",
        "tossed",
        "milked",
        "kissed",
        "married",
        "woke",
        "kept",
        "belonged to",
        ""
    };

    public static string Rhyme()
    {
        var numberOfBlocks = Subjects.Length;
        return string.Join("\n\n", Enumerable.Range(1, numberOfBlocks).Select(Block));
    }

    private static string Block(int number)
    {
        return string.Join("\n", Enumerable.Range(1, number).Reverse().Select(index => Line(number, index)));
    }

    private static string Line(int number, int index)
    {
        var subject = Subjects[index - 1];
        var verb = Verbs[index - 1];
        var ending = index == 1 ? "." : "";

        return index == number ? $"This is the {subject}{ending}" : $"that {verb} the {subject}{ending}";
    }
}

Version data entries

231 entries across 231 versions & 1 rubygems

Version Path
trackler-2.2.1.13 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.12 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.11 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.10 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.9 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.8 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.7 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.6 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.5 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.4 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.3 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.2 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.1 tracks/csharp/exercises/house/Example.cs
trackler-2.2.1.0 tracks/csharp/exercises/house/Example.cs
trackler-2.2.0.6 tracks/csharp/exercises/house/Example.cs
trackler-2.2.0.5 tracks/csharp/exercises/house/Example.cs
trackler-2.2.0.4 tracks/csharp/exercises/house/Example.cs
trackler-2.2.0.3 tracks/csharp/exercises/house/Example.cs
trackler-2.2.0.2 tracks/csharp/exercises/house/Example.cs
trackler-2.2.0.1 tracks/csharp/exercises/house/Example.cs