I assume we have to draw exactly 111 squares and the lines are finite.
My answer:
We have to draw a 1x111 grid, so the count is 111+2 = 114 lines. --> Changed my answer to 19 lines.
How I find that:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("***********");
printGrids(111);
Console.WriteLine("***********");
printGrids(112);
Console.WriteLine("***********");
Console.ReadLine();
}
private static void printGrids(int target)
{
Console.WriteLine(string.Format("Target: {0}", target));
for (int minDiff = 0; minDiff <= target; minDiff++)
{
bool found = false;
for (int x = 1; x <= target; x++)
for (int y = x; y <= target; y++)
{
int val = calc(x, y);
int diff = Math.Abs(val - target);
if (diff == minDiff)
{
Console.WriteLine(string.Format("{0}x{1}: {2}", x, y, val));
found = true;
}
}
if (found)
break;
}
}
private static int calc(int x, int y)
{
int sum = 0;
for (int val = 0; val < Math.Min(x, y); val++)
sum += (x - val) * (y - val);
return sum;
}
}
Prints:
***********
Target: 110
1x110: 110
2x37: 110
3x19: 110
4x12: 110
***********
Target: 111
1x111: 111
***********
Target: 112
1x112: 112
6x7: 112
***********
So if 112 is acceptable, using a 6x7 grid (15 lines) would be OK. But if we want exactly 111 squares, 1x111 grid (114 lines) is the only answer.
Edit:
4x12 (18 lines) - is the best answer for 110. We can add 1 more square to that with 1 line so the answer is 19 lines. (There might be less, I'll check it out when I find time.)
