Sha256: 5e9aab10982b6f704acc2842d6154e3ba835fa887ceef1ada6e27d463c4f1ba9

Contents?: true

Size: 1.15 KB

Versions: 28

Compression:

Stored size: 1.15 KB

Contents

using System;
using System.Collections.Generic;
using System.Linq;
using Generators.Input;

namespace Generators.Exercises
{
    public class Alphametics : GeneratorExercise
    {
        protected override void UpdateCanonicalData(CanonicalData canonicalData)
        {
            foreach (var canonicalDataCase in canonicalData.Cases)
            {
                canonicalDataCase.UseVariableForExpected = true;
                canonicalDataCase.UseVariableForTested = true;

                if (canonicalDataCase.Expected == null)
                    canonicalDataCase.ExceptionThrown = typeof(ArgumentException);
                else
                    canonicalDataCase.Expected = ConvertExpected(canonicalDataCase);
            }
        }

        private static dynamic ConvertExpected(CanonicalDataCase canonicalDataCase)
        {
            Dictionary<string, object> expected = canonicalDataCase.Expected;
            return expected.ToDictionary(kv => kv.Key[0], kv => int.Parse(kv.Value.ToString()));
        }

        protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string> { typeof(Dictionary<char, int>).Namespace };
    }
}

Version data entries

28 entries across 28 versions & 1 rubygems

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