public async Task <IEnumerable <ElfsFabricClaim> > GetElfsFabricClaims() { var elfsClaimsStrings = await _adventClient.GetInputStringListAsync("2018/day/3/input"); var elfsClaims = new List <ElfsFabricClaim>(); foreach (var claimString in elfsClaimsStrings) { var claim = ElfsFabricClaim.Parse(claimString); elfsClaims.Add(claim); } return(elfsClaims); }
public static ElfsFabricClaim Parse(string elfClaimString) { var splitString = elfClaimString.Split(' '); var id = splitString[0].Remove(0, 1); var offsets = splitString[2].Split(',', ':'); var measurements = splitString[3].Split('x'); var claim = new ElfsFabricClaim { Id = int.Parse(id), OffsetLeft = int.Parse(offsets[0]), OffsetTop = int.Parse(offsets[1]), Width = int.Parse(measurements[0]), Height = int.Parse(measurements[1]) }; return(claim); }