Sha256: f59a6a29549530e3140661f626b836b10369754853148598a28b7a2140a815db

Contents?: true

Size: 1.09 KB

Versions: 86

Compression:

Stored size: 1.09 KB

Contents

using Generators.Input;
using Generators.Output;

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

                string stringInput = canonicalDataCase.Properties["input"].ToString();

                // We skip reformatting of pure int arrays.
                if(stringInput.Contains("System.Int32"))
                    continue;

                string properInput = ToProperObjArray(stringInput);

                canonicalDataCase.Properties["input"] = new UnescapedValue(properInput);
            }
        }

        private string ToProperObjArray(string input) 
        {
            string res = input.Replace("System.Int32", "");
            res = res.Replace("]", "}");
            res = res.Replace("[", "new object[] {");
            return res;
        }
    }
}

Version data entries

86 entries across 86 versions & 1 rubygems

Version Path
trackler-2.2.1.151 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.150 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.149 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.148 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.147 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.146 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.145 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.144 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.143 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.142 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.141 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.140 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.139 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.138 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.137 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.136 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.135 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.134 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.133 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.132 tracks/csharp/generators/Exercises/FlattenArray.cs