Exemplo n.º 1
0
            public long GetNumber(int pos)
            {
                if (pos == JoltagesList.Max())
                {
                    return(1);
                }

                if (!JoltagesList.Contains(pos))
                {
                    return(0);
                }

                if (numberAndVisits.ContainsKey(pos))
                {
                    return(numberAndVisits[pos]);
                }

                numberAndVisits.Add(pos, 0);

                for (int i = 1; i <= 3; i++)
                {
                    numberAndVisits[pos] += GetNumber(pos + i);
                }

                return(numberAndVisits[pos]);
            }
Exemplo n.º 2
0
            public long GetCominationsCount()
            {
                long result = 1;

                numberAndVisits = new Dictionary <int, long>();
                JoltagesList.Add(0);

                return(GetNumber(JoltagesList.Min()));
            }
Exemplo n.º 3
0
            public void GenerateStats()
            {
                OneJumps   = 0;
                ThreeJumps = 0;
                int prevJoltage = 0;

                foreach (int joltage in JoltagesList.OrderBy(j => j))
                {
                    switch (joltage - prevJoltage)
                    {
                    case 1:
                        OneJumps++;
                        break;

                    case 3:
                        ThreeJumps++;
                        break;
                    }
                    prevJoltage = joltage;
                }
                ThreeJumps++;
            }