public Omino Clone() { var clone = new Omino(); clone.Points = this.Points.ToList(); clone.Normalize(); return(clone); }
static IEnumerable <Omino> GetOmino(int N) { Omino init = new Omino(); init.Points.Add(new Point(0, 0)); init.Normalize(); Queue <Omino> queue = new Queue <Omino>(); queue.Enqueue(init); Dictionary <string, Omino> memo = new Dictionary <string, Omino>(); while (queue.Count > 0) { var now = queue.Dequeue(); var id = now.GetId(); if (memo.ContainsKey(id)) { continue; } memo[id] = now; if (now.Points.Count >= N) { continue; } foreach (var p in now.Points) { for (int i = 0; i < 4; i++) { int nr = p.Row + dy[i]; int nc = p.Col + dx[i]; if (!now.Points.Any(q => q.Row == nr && q.Col == nc)) { var next = now.Clone(); next.Points.Add(new Point(nr, nc)); queue.Enqueue(next); } } } } return(memo.Values.Where(v => v.Points.Count == N).ToArray()); }