I am a bit stuck here and can't think further.
public struct CandidateDetail
{
public int CellX { get; set; }
public int CellY { get; set; }
public int CellId { get; set; }
}
var dic = new Dictionary<int, List<CandidateDetail>>();
How can I compare each CandidateDetail item against other CandidateDetail items within the same dictionary in the most efficient way?
Example: There are three keys for the dictionary: 5, 6 and 1. Therefore we have three entries. now each of these key entries would have a List associated with. In this case let say each of these three numbers has exactly two CandidateDetails items within the list associated to each key. This means in other words we have two 5, two 6 and two 1 in different or in the same cells. I would like to know:
if[5].1stItem.CellId == [6].1stItem.CellId => we got a hit. That means we have a 5 and a 6 within the same Cell if[5].2ndItem.CellId == [6].2ndItem.CellId => perfect. We found out that the other 5 and 6 are together within a different cell. if[1].1stItem.CellId == ...
Now I need to check the 1 also against the other 5 and 6 to see if the one exists within the previous same two cells or not.
Could a Linq expression help perhaps? I am quite stuck here... I don't know...Maybe I am taking the wrong approach. I am trying to solve the "Hidden pair" of the game Sudoku. :)
http://www.sudokusolver.eu/ExplainSolveMethodD.aspx
Many Thanks, Kave