Sha256: 86839472b4322f5f3fba8eeee7582b9c8e02f50493d3044fc52922c4b300d799
Contents?: true
Size: 1.46 KB
Versions: 28
Compression:
Stored size: 1.46 KB
Contents
using System; using System.Collections.Generic; using Generators.Input; using Generators.Output; using Newtonsoft.Json.Linq; namespace Generators.Exercises { public class Minesweeper : GeneratorExercise { protected override void UpdateCanonicalData(CanonicalData canonicalData) { foreach (var canonicalDataCase in canonicalData.Cases) { canonicalDataCase.UseVariablesForInput = true; canonicalDataCase.UseVariableForExpected = true; canonicalDataCase.Input["minefield"] = ToMultiLineString(canonicalDataCase.Input["minefield"]); canonicalDataCase.Expected = ToMultiLineString(canonicalDataCase.Expected); } } private UnescapedValue ToMultiLineString(JArray input) { return new UnescapedValue("new string[0]"); } private UnescapedValue ToMultiLineString(IEnumerable<string> input) { const string template = @"new string[] { {% if input.size > 0 %}{% for item in {{input}} %}{% if forloop.length == 1 %}""{{item}}""{% break %}{% endif %}""{{item}}""{% if forloop.last == false %},{% else %}{{string.Empty}}{% endif %} {% endfor %}{% endif %} }"; return new UnescapedValue(TemplateRenderer.RenderInline(template, new { input })); } protected override HashSet<string> AddAdditionalNamespaces() => new HashSet<string> { typeof(Array).Namespace }; } }
Version data entries
28 entries across 28 versions & 1 rubygems