private static InternalRow BuildInternalRow(IReadOnlyList<Room> rooms, Coords coords, int value, bool isInitialValue) { var roomIndex = GetRoomIndexForCoords(rooms, coords); return new InternalRow(coords, value, roomIndex, isInitialValue); }
private static int GetRoomIndexForCoords(IReadOnlyList<Room> rooms, Coords coords) { for (var roomIndex = 0; roomIndex < rooms.Count; roomIndex++) { var room = rooms[roomIndex]; if (room.Cells.Contains(coords)) return roomIndex; } throw new InvalidOperationException($"Failed to find coords {coords} in any room!"); }