/// <summary> /// Returns <c>true</c> if both <see cref="WordEntry"/> entries has almost one letter in common /// </summary> public bool GetCommonLetters() { if (Existing.Direction.SameDirection(Candidate.Direction)) { var result = FindCommonLetters(Existing, Candidate); if (result.hasCommon) { ExistingRange = result.left; CandidateRange = result.right; } else { result = FindCommonLetters(Candidate, Existing); if (result.hasCommon) { ExistingRange = result.right; CandidateRange = result.left; } } if (result.hasCommon) { for (int i = ExistingRange.Init; i < ExistingRange.Init + ExistingRange.Length; i++) { CommonLetters.Add(new CommonLetter { Letter = Existing.Name[i], ExistingPos = i, CandidatePos = CandidateRange.Init + i }); } return(true); } return(false); } else { for (int i = 0; i < Existing.Name.Length; i++) { int pos = Candidate.Name.IndexOf(Existing.Name[i]); if (pos >= 0) { CommonLetters.Add(new CommonLetter { Letter = Existing.Name[i], ExistingPos = i, CandidatePos = pos }); } } return(CommonLetters.Count > 0); } }
/// <summary> /// Returns a list of coordinates where both entries intersects /// </summary> /// <returns></returns> public IEnumerable <Point> GetIntersection() { Clear(); CommonLetters.Clear(); ExistingRange = new Range(); CandidateRange = new Range(); for (int i = 0; i < Existing.Name.Length; i++) { for (int j = 0; j < Candidate.Name.Length; j++) { if (Existing.Coordinate(i) == Candidate.Coordinate(j)) { Add(Existing.Coordinate(i)); Logger.LogTrace($" {Existing.Coordinate(i)}"); } } } Logger.LogDebug($"Comparing ({Existing}) with candidate ({Candidate}): {Count} intersection(s) found"); return(this); }