コード例 #1
0
        private static void FirstGem(List <Gems> currList)
        {
            Gems first = new Gems();

            first.number    = 0;
            first.isExluded = false;
            currList.Add(first);
        }
コード例 #2
0
        private static void LastGem(List <Gems> currList)
        {
            Gems last = new Gems();

            last.number    = 0;
            last.isExluded = false;
            currList.Add(last);
        }
コード例 #3
0
        private static void FillGems(int[] numbers, List <Gems> gems)
        {
            Gems first = new Gems();

            first.number    = 0;
            first.isExluded = false;
            gems.Add(first);

            foreach (var gem in numbers)
            {
                Gems currGem = new Gems();

                currGem.number    = gem;
                currGem.isExluded = false;

                gems.Add(currGem);
            }
            Gems last = new Gems();

            first.number    = 0;
            first.isExluded = false;
            gems.Add(last);
        }
コード例 #4
0
        private static List <Gems> Reverse(List <Gems> gems, string[] side, int param)
        {
            var currList = new List <Gems>();

            if (side[1] == "Left" && side.Length == 2)
            {
                FirstGem(currList);

                for (int i = 1; i < gems.Count - 1; i++)
                {
                    Gems currentGem = new Gems();
                    if (gems[i].number + gems[i - 1].number == param)
                    {
                        currentGem.number    = gems[i].number;
                        currentGem.isExluded = false;
                    }
                    else
                    {
                        currentGem.number    = gems[i].number;
                        currentGem.isExluded = gems[i].isExluded;
                    }
                    currList.Add(currentGem);
                }
                LastGem(currList);
                return(currList);
            }
            else if (side[1] == "Right" && side.Length == 2)
            {
                FirstGem(currList);
                for (int i = 1; i < gems.Count - 1; i++)
                {
                    Gems currentGem = new Gems();
                    if (gems[i].number + gems[i + 1].number == param)
                    {
                        currentGem.number    = gems[i].number;
                        currentGem.isExluded = false;
                    }
                    else
                    {
                        currentGem.number    = gems[i].number;
                        currentGem.isExluded = gems[i].isExluded;
                    }
                    currList.Add(currentGem);
                }
                LastGem(currList);
                return(currList);
            }
            else
            {
                FirstGem(currList);
                for (int i = 1; i < gems.Count - 1; i++)
                {
                    var  toLeft     = gems[i - 1].number;
                    var  ToRight    = gems[i + 1].number;
                    var  currGem    = gems[i].number;
                    Gems currentGem = new Gems();
                    if (toLeft + currGem + ToRight == param)
                    {
                        currentGem.number    = gems[i].number;
                        currentGem.isExluded = false;
                    }
                    else
                    {
                        currentGem.number    = gems[i].number;
                        currentGem.isExluded = gems[i].isExluded;
                    }
                    currList.Add(currentGem);
                }
                LastGem(currList);
                return(currList);
            }
        }