示例#1
0
        private static bool CanMakeAllSquares(TwoDiceRoll roll)
        {
            Die d1 = roll.Die1;
            Die d2 = roll.Die2;
            bool[] found = new bool[100];
            foreach (int d1s in d1.Sides)
            {
                foreach (int d2s in d2.Sides)
                {
                    int d1ss = d1s == 9 ? 6 : d1s;
                    int d2ss = d2s == 9 ? 6 : d2s;
                    int roll1 = 10*d1ss + d2ss;
                    int roll2 = 10*d2ss + d1ss;
                    found[roll1] = true;
                    found[roll2] = true;
                }
            }

            foreach (int need in needed)
            {
                if(found[need]==false) return false;
            }

            return true;
        }
示例#2
0
        public static void Solve()
        {
            Console.WriteLine("Problem 090");

            GetDiePossibilities();

            int countDistinct = 0;
            List<TwoDiceRoll> distinctRolls = new List<TwoDiceRoll>();

            foreach(Die d1 in diePossibilies)
            {
                foreach (Die d2 in diePossibilies)
                {
                    TwoDiceRoll roll = new TwoDiceRoll(d1, d2);
                    if(CanMakeAllSquares(roll))
                    {
                        if (!distinctRolls.Contains(roll))
                        {
                            Console.WriteLine("d1: {0}  d2: {1}", d1, d2);
                            countDistinct++;
                            //if (d1.Contains6or9) countDistinct++;
                            //if (d2.Contains6or9) countDistinct++;
                            //if (d1.Contains6or9 && d2.Contains6or9) countDistinct++;
                            distinctRolls.Add(roll);
                        }
                    }
                }
            }
            Console.WriteLine("distinct: {0}", countDistinct);
        }