コード例 #1
0
        int[] ParseLayers(string filename)
        {
            var intermediate = new List <Tuple <int, int> >();

            FileIterator.ForEachLine <string>(filename, line =>
            {
                var spec = line.Split(new char[] { ':', ' ' }, StringSplitOptions.RemoveEmptyEntries);
                if (spec.Length != 2)
                {
                    Oh.ForFucksSake();
                }

                var range = int.Parse(spec[0]);
                var depth = int.Parse(spec[1]);
                intermediate.Add(new Tuple <int, int>(range, depth));
            });

            var r = new int[intermediate.Last().Item1 + 1];

            foreach (var t in intermediate)
            {
                r[t.Item1] = t.Item2;
            }

            return(r);
        }
コード例 #2
0
        static string Reduce(int[] input)
        {
            if (input.Length != 256)
            {
                Oh.ForFucksSake();
            }
            var reduced = new byte[16];

            for (var i = 0; i < 16; i++)
            {
                for (var j = 0; j < 16; j++)
                {
                    reduced[i] ^= (byte)input[(i * 16) + j];
                }
            }

            return(BitConverter.ToString(reduced).Replace("-", "").ToLower());
        }