public static ImmutableArray <Instruction> ParseInstructions(this IInputContent content) { var transformed = content .Transform(str => str.Split(',', StringSplitOptions.RemoveEmptyEntries & StringSplitOptions.TrimEntries)) .Select(str => str.AsMemory()); return(parser.ParseCommands(transformed) .ToImmutableArray()); }
public static IEnumerable <int> CharactersToInt(this IInputContent content) { var span = content.AsSpan(); var result = new int[span.Length]; for (var i = 0; i < result.Length; i++) { if (char.IsDigit(span[i]) is false) { throw new InvalidOperationException($"Character '{span[i]}' is not a digit"); } result[i] = span[i] - '0'; } return(result); }
public static byte[] ParseLengths(this IInputContent content) => content.Transform(static str => str
public static ImmutableArray <Bank> ParseBanks(this IInputContent content) { return(content.Transform(ParseBanksFromContent));
public static int AsInt(this IInputContent content) => int.Parse(content.AsString());
public static ReadOnlySpan <char> AsSpan(this IInputContent content) => content.AsString().AsSpan();