Finding the smallest grid of squares

4

Inspiration from Puzzling.SE.

Suppose we have an m × n grid such that each element is a base 10 digit. We can read the numbers from such a grid so that we fix a starting element, go to one of the eight nearest coordinates and maintain that direction for zero to five steps. This allows you to read a one to five digit number from a grid if you concatenate the digits.

Your task is to write a program finding the smallest m × n grid from which the squares of the numbers 1 to 100 (inclusive) can be read.

For example, if the grid is:

00182
36495

then the squares of 1-10 can be read from it, but, for example, 121 is missing. In this rectangle m × n = 2 × 5 = 10.

The winner is the code which generates the smallest grid.

guest

Posted 2015-12-12T16:32:55.327

Reputation: 49

Question was closed 2015-12-13T01:21:53.567

2Please write it up as a separate problem here, instead of just posting a link. – Timwi – 2015-12-12T16:33:50.000

2

Welcome to Programming Puzzles and Code Golf! As it currently stands, this question is not a valid challenge as outlined in the help center. Please edit your question to those specifications and next time, please Use The Sandbox before posting.

– cat – 2015-12-12T16:41:20.733

The criterion for the grid is still very unclear. please add more examples and test cases. – cat – 2015-12-12T17:09:47.530

I can try to clarify. What part of the puzzle is unclear? – guest – 2015-12-12T17:13:22.650

in the end of the first paragraph, it says " you don't have to go to that direction any number of steps so you can also read the numbers 1, 4, and 9." Can you edit the post to explain in a more understandable way what you mean? – cat – 2015-12-12T17:15:14.510

It means that you can read one to five digit numbers and you can't read for example 121 in the 2x1 grid 1 2. – guest – 2015-12-12T17:18:49.960

2There are at least two things which are unclear: 1. The definition of which numbers are contained in the grid; 2. The tie-breaker to distinguish between brute-force programs which are guaranteed to generate the smallest grid (although they might not actually do so in any reasonable time). – Peter Taylor – 2015-12-12T19:19:22.840

I meant that you read digits and then catenate it to form 1 to 5 digit numbers. Brute force programs are okay but you just have to output the grid. – guest – 2015-12-12T19:46:50.987

1How can you read the digits? In a straight line? Orthogonally? Diagonally? Forwards? Backwards? Snaking? – xnor – 2015-12-12T22:35:25.683

By straight line. What else could the "maintain that direction mean"? – guest – 2015-12-13T09:08:31.370

Why this it unclear what I'm asking. I think "The winner is the code which generates the smallest grid." is very clear criterion. – guest – 2015-12-13T09:34:45.617

1I think I could probably rewrite the question to clarify the definition of the numbers in the grid, but that wouldn't fix the problem of the winning condition. "The one which generates the smallest grid" is perfectly clear, but also almost entirely useless, because the most likely case is that every single answer submitted would be optimal, so they would all be "winners". – Peter Taylor – 2015-12-14T11:56:24.013

No answers