# Fill the grid from 1 to 100 [closed]

In this challenge you are supposed to fill a grid 10x10 with numbers from 1 to 100 (each number once) following this rules:

• Number 1 must be on the bottom row
• Number 100 must be on the upper row
• Two consecutive numbers must be one next to the other (diagonals doesn't count)
• The grid must be random

It's not necessary at all that all possible outcomes are equiprobable. Still, though, there must be a non-zero chance for every possible grid (that satisfies the first 3 conditions) to occur.

I don't want time to be a problem, but to avoid pure brute force, answers should take less than a minute to run.

Since output shouldn't be the main focus of the challenge I give complete freedom on how to write it, as long as each row in the output corresponds to a row in the grid and numbers are separated by a character (of any kind).

• By "random", do you mean that every grid that satisfies the first 3 conditions has a non-zero chance of being produced? Also, can solutions keep producing random grids until they find one that fits the criteria, or is there a time bound? Apr 6, 2016 at 19:36
• How should output be presented? Does if have to be a string that gives the grid appearance, or can it be a 2x2 array as a functon return value, for example? If the former, 0 (or 00) to 99 would look neater. That one 3-digit number is a pain aesthetically Apr 6, 2016 at 19:45
• As it, this allows the cheap solution of generating a random grid, outputting it if it satisfies the properties, and otherwise outputting a fixed grid that works.
– xnor
Apr 6, 2016 at 20:28
• What would you consider as brute-force here? Why do you think this can be solved (under all the given conditions) in less than one minute? Apr 6, 2016 at 20:52
• @LevelRiverSt It's not cheating at all when it satisfies the rules of the question. I shouldn't have to judge the asker's intent to decide whether a solution method is fair.
– xnor
Apr 6, 2016 at 23:35