Exemplo n.º 1
0
        private void Split(FriendsPresents pr, int n, int m)
        {
            FriendsPresents f1 = pr.Give(n, m);
            FriendsPresents f2 = f1.Clone();

            Share(f1, n - 1, 0);
            Share(f2, n - 1, 1);
        }
Exemplo n.º 2
0
 static public FriendsPresents Min(FriendsPresents first, FriendsPresents second)
 {
     if (Math.Abs(first.valueDifference) < Math.Abs(second.valueDifference))
     {
         return(first);
     }
     return(second);
 }
Exemplo n.º 3
0
        private void Share(FriendsPresents pr, int n, int m)
        {
            if (n == 0)
            {
                pr.Give(n, m);
                posibilities.Add(pr);
                return;
            }

            Split(pr, n, m);
        }
Exemplo n.º 4
0
        private FriendsPresents FindMinDiff(List <FriendsPresents> list)
        {
            FriendsPresents min = list[0];


            foreach (FriendsPresents p in posibilities)
            {
                min = FriendsPresents.Min(min, p);
            }

            return(min);
        }