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.70 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.69 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.68 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.67 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.66 tracks/csharp/generators/Exercises/FlattenArray.cs
trackler-2.2.1.65 tracks/csharp/generators/Exercises/FlattenArray.cs