Esempio n. 1
0
        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());
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 public static byte[] ParseLengths(this IInputContent content)
 => content.Transform(static str => str
Esempio n. 4
0
 public static ImmutableArray <Bank> ParseBanks(this IInputContent content)
 {
     return(content.Transform(ParseBanksFromContent));
Esempio n. 5
0
 public static int AsInt(this IInputContent content)
 => int.Parse(content.AsString());
Esempio n. 6
0
 public static ReadOnlySpan <char> AsSpan(this IInputContent content)
 => content.AsString().AsSpan();