# Fitting 7 Segments Digits on Smallest Rectangular Grid

On the 2 x 1 grid all 7- segment digits above can be formed one at a time as seen on clocks, calculators and other digital devices.
If we are allowed to flip or rotate and overlap segments, how should these digits be configured inside the 3 x 4 grid, so we can see all of them at the same time?

Here's my solution, with the following features:

1. Distinct 2 and 5
2. Distinct 6 and 9
3. Rotations only (Mirror images of numbers don't look all that nice)
4. No upside-down digits (max. rotation 90 degrees)

This was way more difficult than expected. There may be other non-mirror solutions apart from this one and its symmetries, but if there are, they are few and far between.

• Nice animations!
– JS1
Commented Jun 11, 2018 at 8:45
• there the no flipped digit solution!
– TSLF
Commented Jun 11, 2018 at 13:57
• @JS1 Thanks! I made a new version now that I had time; all done with GIMP's copy-paste, rectangle select, and a paintbucket full of 36% transparent black paint :-)
– Bass
Commented Jun 11, 2018 at 15:49

Explanation:

0: middle row, first two columns
1: top row, first two columns
2 and 5: top two rows, third column
3: bottom two rows, second column
4: top row, last two columns
6 and 9: bottom two rows, third column
7: bottom row, first two columns
8: bottom row, last two columns
Note the last column of the middle row isn't even used.

• full overlapping of 2 & 5 or 6 & 9 conceals the digits beneath thus we cant see
– TSLF
Commented Jun 11, 2018 at 4:45

After finding and writing up the solution to this slightly related problem I decided to impose similar constraints for this problem, formulate it as a SAT instance and solve:

• No flipping
• The digits can only lie in one of two orthogonal orientations; this implies that 6 and 9 cannot be represented by the same segments

The on/off states of the grid segments are the 31 base variables. For each combination of digit and possible location for a digit (there are 17 with my self-imposed constraints) a position variable representing whether that digit appears at that position is introduced, along with the eight clauses needed to enforce it. Finally ten clauses are introduced, one for each digit, representing the need for at least one corresponding position variable to be true. The code I wrote to generate the DIMACS file can be found here.

The end result of this was

no solution for the width-4 height-3 case and exactly one solution for the width-3 height-4 case:

Edit:

With no holds barred (flipping, 2/5 and 6/9 occupying the same space allowed) and a 3×3 grid there is also a unique solution:

• Note that my 308 solution also has only the 4,9,7,1 horizontal.
– TSLF
Commented Sep 25, 2021 at 1:14
• @TSLF But your 9 and your 7 point in opposite directions there. See my edit, which shows an even tighter solution. Commented Sep 25, 2021 at 7:27

Solution for 4 x 3 grid

5 -4 6

3 0 8

2 - 9

-7 - 1

• The “no upside-downies” bit was just me trying to show off; my upvote is for the brilliant alternative “no-mirrored-digits” solution to the original question you had before you rotated it 90 degrees :-)
– Bass
Commented Jun 11, 2018 at 19:21
• Oh, oops, it’s the OP’s self-answer. Sorry :-)
– Bass
Commented Jun 11, 2018 at 19:25