public PlayGrid(ISequence <Constraints> columnConstraints, ISequence <Constraints> rowConstraints, IGrid <Square> squares) { if (columnConstraints == null) { throw new ArgumentNullException(nameof(columnConstraints)); } else if (rowConstraints == null) { throw new ArgumentNullException("rowConstraints "); } else if (squares == null) { throw new ArgumentNullException(nameof(squares)); } else if (columnConstraints.Length != squares.Size.Width) { throw new ArgumentException("Number of column constraints should be equal to grid width"); } else if (rowConstraints.Length != squares.Size.Height) { throw new ArgumentException("Number of row constraints should be equal to grid height"); } else { this.Squares = squares.Map(sqr => new Var <Square>(sqr)).Copy(); this.ColumnConstraints = (from i in Squares.ColumnIndices let constraints = columnConstraints[i] let slice = new Slice(Squares.Column(i).Map(var => var.Value)) select new PlayGridConstraints(slice, constraints)).ToSequence(); this.RowConstraints = (from i in Squares.RowIndices let constraints = rowConstraints[i] let slice = new Slice(Squares.Row(i).Map(var => var.Value)) select new PlayGridConstraints(slice, constraints)).ToSequence(); } }