Пример #1
0
        public string RunB()
        {
            int total = 0;

            Utils.Load <string>("./2020/Day02.input", (s, l) =>
            {
                StringView stv = new StringView(s);
                stv.Split(out int min, "-", out int max, " ", out char letter, ": ", out string pw);
                if (pw[min - 1] == letter ^ pw[max - 1] == letter)
                {
                    total++;
                }

                return(false);
            });
Пример #2
0
        public StringView Substring(int start, int length = Int32.MaxValue)
        {
            StringView stv = new StringView(_base);

            stv._start  = _start + start;
            stv._length = length;
            if (stv._start >= _base.Length)
            {
                stv._start = _base.Length - 1;
            }
            if (stv._length > _base.Length)
            {
                stv._length = _base.Length - stv._start;
            }

            return(stv);
        }