public bool CanBeUnlocked(List <Chip> chips)
        {
            if (chips == null || !chips.Any())
            {
                return(false);
            }

            if (!chips.Any(x => x.LeftColor == _beginningMarkerColor))
            {
                return(false);
            }

            if (!chips.Any(x => x.RightColor == _endMarkerColor))
            {
                return(false);
            }

            if (_chipChainBuilder == null)
            {
                return(false);
            }

            List <ChipChain> chains = _chipChainBuilder.GetChains(_beginningMarkerColor, chips);

            FoundUnlockSequence = chains.LastOrDefault(x => x.Last().RightColor == _endMarkerColor);

            return(FoundUnlockSequence != null);
        }
        public List<ChipChain> BuildChains(Chip headChip, List<Chip> remainingChips)
        {
            List<ChipChain> chains = new List<ChipChain>();

            ChipChain possibleChain = new ChipChain() { headChip };
            if (!remainingChips.Any())
            {
                chains.Add(possibleChain);
            }
            else
            {
                List<Chip> nextChips = remainingChips.Where(c => c.LeftColor == possibleChain.Last().RightColor).ToList();
                foreach (Chip nextChip in nextChips)
                {
                    List<Chip> proxyRemainingChips = new List<Chip>(remainingChips);
                    ChipChain proxyPossibleChain = new ChipChain(possibleChain);

                    proxyRemainingChips.Remove(nextChip);
                    proxyPossibleChain.Add(nextChip);

                    if (!proxyRemainingChips.Any())
                    {
                        chains.Add(proxyPossibleChain);
                    }
                    else
                    {
                        BuildChain(chains, proxyRemainingChips, proxyPossibleChain);
                    }
                }
            }

            return chains;
        }
        public bool CanBeUnlocked(List<Chip> chips)
        {
            if (chips == null || !chips.Any())
                return false;

            if (!chips.Any(x => x.LeftColor == _beginningMarkerColor))
                return false;

            if (!chips.Any(x => x.RightColor == _endMarkerColor))
                return false;

            if (_chipChainBuilder == null)
                return false;

            List<ChipChain> chains = _chipChainBuilder.GetChains(_beginningMarkerColor, chips);

            FoundUnlockSequence = chains.LastOrDefault(x => x.Last().RightColor == _endMarkerColor);

            return FoundUnlockSequence != null;
        }
        private void BuildChain(List<ChipChain> chains, List<Chip> remainingChips, ChipChain possibleChain)
        {
            List<Chip> nextChips = remainingChips.Where(c => c.LeftColor == possibleChain.Last().RightColor).ToList();
            foreach (Chip nextChip in nextChips)
            {
                List<Chip> proxyRemainingChips = new List<Chip>(remainingChips);
                ChipChain proxyPossibleChain = new ChipChain(possibleChain);

                proxyRemainingChips.Remove(nextChip);
                proxyPossibleChain.Add(nextChip);

                if (!proxyRemainingChips.Any())
                {
                    chains.Add(proxyPossibleChain);
                }
                else
                {
                    BuildChain(chains, proxyRemainingChips, proxyPossibleChain);
                }
            }
        }