using System; using System.Collections.Generic; using System.IO; using System.Linq; namespace Common { public class Wiring { public List> Inputs { get; private set; } public List> Outputs { get; private set; } public Wiring(string text) { var parts = text.Split(" | "); Inputs = ParseSegments(parts[0]); Outputs = ParseSegments(parts[1]); } private static List> ParseSegments(string text) { var char_sets = new List>(); foreach (var str in text.Split(" ")) { var char_set = new HashSet(); foreach (var chr in str.ToCharArray()) { char_set.Add(chr); } char_sets.Add(char_set); } return char_sets; } } public class SegmentDisplay { public List Wirings { get; private set; } public SegmentDisplay(string path) { Wirings = new List(); var lines = File.ReadAllLines(path); foreach (var line in lines) { Wirings.Add(new Wiring(line)); } } } }