private void ApplyOrder(ClothOrder order, ref int[,] cloth) { for (int i = 0; i < order.width; ++i) { for (int j = 0; j < order.height; j++) { cloth[order.x + i, order.y + j] += 1; } } }
private bool OrderOverlaps(ClothOrder order, ref int[,] cloth) { for (int i = 0; i < order.width; ++i) { for (int j = 0; j < order.height; j++) { if (cloth[order.x + i, order.y + j] > 1) { return(true); } } } return(false); }
ClothOrder[] ParseOrders(string[] input) { ClothOrder[] orders = new ClothOrder[input.Length]; char[] splitChars = { '#', '@', ':', ',', 'x' }; for (int i = 0; i < input.Length; ++i) { ClothOrder current = new ClothOrder(); string line = input[i]; string[] elements = line.Split(splitChars, StringSplitOptions.RemoveEmptyEntries); Int32.TryParse(elements[0], out current.orderNumber); Int32.TryParse(elements[1], out current.x); Int32.TryParse(elements[2], out current.y); Int32.TryParse(elements[3], out current.width); Int32.TryParse(elements[4], out current.height); orders[i] = current; } return(orders); }