Ejemplo n.º 1
0
        static public void processCase(int currentCaseNumber)
        {
            string caseResult  = "";
            string debugString = "";
            int    count       = 0;
            int    W           = 0;
            int    H           = 0;
            int    D           = 0;

            //Reading case variables
            processLine(new Action <IEnumerator <string> >[]
            {
                (e) => H = int.Parse(e.Current),
                (e) => W = int.Parse(e.Current),
                (e) => D = int.Parse(e.Current)
            });

            string[] stringMap = new string[H];

            for (int i = 0; i < H; i++)
            {
                processLine((s) => stringMap[i] = s);
            }

            MirrorMap map = new MirrorMap(stringMap);

            map.unfoldReflections(D);
            count = map.countReflections(D);

            caseResult = "" + count;
            //Result
            streamWriter.WriteLine("Case #" + currentCaseNumber + ": " + caseResult + debugString);
        }
Ejemplo n.º 2
0
        public MirrorMap(string[] stringMap)
        {
            for (int j = 0; j < stringMap.Length; j++)
            {
                for (int i = 0; i < stringMap[j].Length; i++)
                {
                    switch (stringMap[j][i])
                    {
                    case 'X':
                        players.Add(new Player(i + 0.5d, j + 0.5d));
                        break;

                    case '#':
                        if (j > 0)
                        {
                            planes.Add(new MirrorPlane(i, j, i + 1, j));
                        }
                        if (i > 0)
                        {
                            planes.Add(new MirrorPlane(i, j, i, j + 1));
                        }
                        if (j < stringMap.Length - 1)
                        {
                            planes.Add(new MirrorPlane(i, j + 1, i + 1, j + 1));
                        }
                        if (i < stringMap[j].Length - 1)
                        {
                            planes.Add(new MirrorPlane(i + 1, j, i + 1, j + 1));
                        }
                        break;
                    }
                }
            }
            unfoldMap = new MirrorMap();
        }