# Instructionless: Sieve of Eratosthenes

This is an instructionless puzzle: work out the rules and then solve the main puzzle. An example and its unique solution have been given to you, as well as two failed solutions with errors marked.

Thanks to the person who formatted this puzzle for me!

• are the crossed grids the only errors in the puzzle? – Omega Krypton Sep 1 '19 at 11:13
• Well, the significance of the numbers and how to fill in all the question marks is clear enough. The green path and blue dots, not so much. (I assume the blue dots are also an important part of the puzzle?) – Rand al'Thor Sep 1 '19 at 15:31
• @OmegaKrypton Yes, the crossed out squares are the only errors for that particular attempted solution. – boboquack Sep 1 '19 at 23:22
• @Randal'Thor Yes, the blue dots are important. The numbers and question marks are only the clues to solve the puzzle, the green line and blue dots are the solution to the puzzle. – boboquack Sep 1 '19 at 23:24
• @boboquack - Whilst I had the rules (partially) wrong, I really liked this puzzle - very neatly constructed. Thematically built grid, unique grid logic, clean and unambiguous rules once found. Nice work! – Alconja Sep 4 '19 at 0:57

Solution:

Rules:

- Draw a single closed loop which visits every cell exactly once
- Add a number of "stops" on the path between cells
- A number in a cell indicates the distance (along the path) to the closest "stop" in (at least) one of the directions

NG Example 1:

- 2: Closest stops are 1 and 7 cells away, neither is 2 cells away
- 2: Closest stops are 1 and 4 cells away, neither is 2 cells away

NG Example 2:

- 2: Closest stops are 3 and 5 cells away, neither is 2 cells away
- 5: Closest stops are 1 and 7 cells away, neither is 5 cells away
- 2: Cell is not visited by the path
- _: Cell is not visited by the path

Deductions:

From each cell with a number, there exists one direction of the path which has the closest stop at the given distance. We ignore the other direction for now. When going along this direction, every number we visit has to either agree with the number of cells until the next stop or be greater than the steps we have already taken (while agreeing with every other number pointing backwards). Especially for bigger numbers, this limits the possibilities a lot, for example exploring from a 7 and visiting a numbered cell next, limits us to the following chains:
?->7->2->3/5->[ ]->5/3->2->7
[ ]->7->3->5->5->3->2/7->[ ]
3->7->5->5->7->3->2->[ ]
5->7->7->5->[ ]->3->2->[ ]
Most importantly, 3->2->2, 5->2->2 or 7->2->2 are impossible.
Important: It is possible for the path to go through these numbered cells (see bottom right corner), but we know the search direction will be the other way around. While solving we mostly care about the path along the search direction.

Solving path:

The $$7$$ in the first row has only one possible path, cells with only two neighbours can be filled in as well. Paths $$2$$->$$2$$->$$3$$/$$5$$ always need a stop after the last $$2$$.

The $$3$$ in the top right corner can only go up two cells which lets us fill in the rest of the path in that area.

The $$7$$ in the bottom right has only one path left as well.

Both $$5$$ in the top left have to be connected, otherwise they would both have to go to the left which quickly leads to a contradiction.

The $$7$$ in the bottom left corner is now left with a single possible path. After that, the remaining path can be filled in.

Questionmarks (thanks @Rand al'Thor):

The whole grid represents the Sieve of Eratosthenes for the numbers 1 to 100, every cell is marked with the prime number that removed the cell. Question marks are the cells where the clue for the puzzle and the sieve disagree. For solving the puzzle, cells with a question mark behave exactly the same as an empty cell.

• Can you explain the rules you derived to make this, please? Would help us to understand what we're looking at here... Thanks! – Stiv Sep 2 '19 at 18:04
• Congratulations! As Stiv said, if you could add the rules you used to derive this solutions that would be great - once that's up you'll get the checkmark. Also, if you have time/wouldn't mind, a short outline of the logic used to get this solution would also be good. – boboquack Sep 2 '19 at 23:21
• yes, answer is incomplete until you define the rules... – Sayed Mohd Ali Sep 3 '19 at 6:15
• I just wanted to wait for confirmation before describing the rules and the outline of the solving path. I will add it soonish. – w l Sep 3 '19 at 6:52

Here are the rules I came up with:

1. You must draw a green line in a loop that travels through every cell without intersecting itself.
2. The green line must be divided into line segments using blue dots to indicate the segment endpoints.
3. Each number on the line segment must be that many squares away from an endpoint, including itself. For example, a 2 must be one square away from an endpoint. A 3 must be two squares away from an endpoint.
4. Question marks may take on the values 1, 2, 3, 5, 7.

With these rules, I basically ended up with the same answer as @w l, so he should get credit for solving the puzzle first. I'll give a lengthy explanation of the logic though:

(a) Start with the top 7. It can't go anywhere but connect to the seven below because any other path runs into low numbers that prevent it from reaching seven squares. (b) After that, look at the 3 and notice that it can only go to the right. (c) Next look at the other 3 and see that it can only go up.

Next:

(a) Notice that the 2 is trapped so it must connect upwards and to the right. (b) The rest of the corner can only connect in one way. (c) I added some blue dots that are known.

Next:

(a) Looking at the 5, the only direction it can go is left. (b) This causes the 2 to its right to connect downwards. (c) Then, none of the three numbers in the same column as the 5 can connect to the right because there would be nowhere to go. So that makes the column to its right connect vertically.

Next:

(a) Looking at the 3, it must connect to the left. (b) This causes the 5 above to connect further to the left. (c) Now, looking at the other 5, it has nowhere to go other than to connect in a large 8 length segment.

Next:

(a) The 2 is trapped in a corner so it must connect to the two above it. (b) The 3 to its left has nowhere to go but left. (c) Both 2's are cornered so they must connect to their left.

Next:

(a) If the marked square connected downward, then three ends would have to connect, leaving a dead end. So the marked square must connect upward. (b) The 7 has nowhere to go except in the marked direction. All other ways cause dead ends to appear. (c) The marked 2 is cornered, so it must connect to its two neighbors. I added some more blue dots as well.

Next:

(a) The three marked squares are corners and are forced to connect to their neighbors. (b) The 7 in the bottom left corner has only one way to go now. (c) The two marked squares are forced to connect a certain way.

Next:

(a) The 5 must connect to its right as there is no other way to go now. (b) The 3 must connect left and up, given the known connections nearby. (c) The marked square is a corner, which leads to the bottom left area being connected in a certain way.

Next:

(a) The marked 2 must connect to the right. It must connect with the 7 otherwise it would form a small loop. (b) The bottom right corner is easy to fill in at this point and this completes the solution.

• Nice explanation! – boboquack Sep 3 '19 at 21:59

This answer complements the existing ones by @wl and @JS1, who found the actual solution of the puzzle. I just want to explain one aspect which seemed obvious to me but which isn't mentioned in the previous answers: how to fill in the squares of the grid, i.e. how the numbers are chosen (they're not random!), what the question marks should be, and the difference between a question mark and a blank square.

Two observations make it clear what we should be looking for:

• the fact that the numbers appearing in the grid are the first few primes (2,3,5,7);

• the title containing "Sieve of Eratosthenes".

In fact, there's a very natural pattern to the numbers:

each $$n\times n$$ grid is first filled with all the numbers from $$1$$ to $$n^2$$, in order, left to right and top to bottom. Then each number is replaced by its lowest prime factor, or blanked out if that prime is bigger than 7.

Or to put it even more naturally, following the title:

first write $$2$$ in every even-numbered square, then write $$3$$ in every still-blank multiple-of-3 square, then write $$5$$ in every still-blank multiple-of-5 square, then write $$7$$ in every still-blank multiple-of-7 square. (We don't need to go to $$11$$, because the smallest number which is a multiple of $$11$$ but not any smaller prime is $$121>100$$.)

For the $$4\times4$$ grid in the example, this gives:

 1 2 3 4 2 3 2
 5 6 7 8 5 2 7 2
 9 10 11 12 3 2 2
13 14 15 16 2 3 2

which shows how the question marks would be filled in.

For the $$10\times10$$ grid, we do the same again using

the numbers from $$1$$ to $$100$$. Again all the question marks can be filled in in a natural way, and the blank squares (corresponding to prime numbers) remain blank.

• Seems so obvious once you see it. This basically makes the question marks clues which are at odds with the sieve. – w l Sep 3 '19 at 11:41
• Good observation! This puzzle was made for a competition where the only clues could be numbers with the digits 2, 3, 5 or 7, so I thought this would make a fitting thematic submission. – boboquack Sep 3 '19 at 22:01