예제 #1
0
        private int CountGold(Luggage l)
        {
            var result = 0;

            foreach (var bag in l.ContainsKind)
            {
                result += bag.Value + (bag.Value * CountGold(bags.FirstOrDefault(x => x.LuggageKind == bag.Key)));
            }
            return(result);
        }
예제 #2
0
        // God this is slow
        private bool FindGold(Luggage x)
        {
            if (x.ContainsKind.ContainsKey("shiny gold"))
            {
                return(true);
            }

            foreach (var kind in x.ContainsKind)
            {
                if (FindGold(bags.FirstOrDefault(y => y.LuggageKind == kind.Key)))
                {
                    return(true);
                }
            }

            return(false);
        }