Settings

Theme

The Simple Proof of the Tetris Lamp

jackm.co.uk

404 points by jpeggg 11 years ago · 89 comments

Reader

jones1618 11 years ago

Terrific reasoning! That same "checkerboard coloring" strategy is used a lot for figuring out tiling problems.

It is too bad the lamp wasn't made of pentominoes (the 12 Tetris-like pieces with 5 squares vs. your tetrominoes with 4 squares.). See http://en.wikipedia.org/wiki/Pentomino. There are 2339 ways to form these into a perfect 6x10 rectangle (more if you include rotations and reflections).

FYI: The creator of Tetris actually got the idea for his game pieces from Solomon W. Golomb's book "Polyominoes" that introduced all kinds of variations on tiling puzzles and proofs. Chapter one starts using checkerboard reasoning right off the bat. So, you are in good company.

megamark16 11 years ago

I came here looking for a link to someplace where I can buy this lamp. Since no one has posted such a link yet, here it is:

http://www.thinkgeek.com/product/f034/

(I realize we all have access to Google, but if I save 100 people 10 seconds, then I just saved 1000 seconds!)

mjs 11 years ago

Similar to:

https://en.wikipedia.org/wiki/Mutilated_chessboard_problem

  • gus_massa 11 years ago

    Yes. Every time you get a problem with a rectangle table, you must paint it like a chessboard. If that is not enough to find the solution, you must try to think.

    A small technical detail, dew to professional deformation. The article says that the numbers of squares of each color must be the same, but that only happens if the total number is even, like in this case 13+15=28. If the total number of squares is odd, then you get one extra square of one of the colors.

    • j2kun 11 years ago

      You must paint it, but it is sometimes better to choose a pattern specific to the problem you're trying to solve.

      E.g. http://jeremykun.com/2011/06/26/tiling-a-chessboard/

    • pja 11 years ago

      Minor derail - I know I mistype 'their' as 'they're' and likewise for other similar homonym pairs all the time, but due -> dew is a particularly nice example of the genre :)

      • theoh 11 years ago

        "making do" -> "making due" seems to be relatively common among US English speakers, too. In British pronunciation dew also sounds the same as due but both differ from the US "do"...

  • carussell 11 years ago

    The problem and its proof are mentioned in EWD 1036: On the cruelty of really teaching computing science. < http://www.cs.utexas.edu/users/EWD/transcriptions/EWD10xx/EW... >

    • webnrrd2k 11 years ago

      That is a really great paper! It should be required reading for all computer science types.

pmelendez 11 years ago

>"Maybe now I can shift my irritation from the lamp itself to whoever designed it to possess such a property. "

I wouldn't be mad at the designer. That person designed a lamp and proposed an impossible puzzle that at first glance looked plausible.

It is the best way to troll people... ever!

davecap1 11 years ago

That's exactly how they get you to buy TWO lamps! :)

  • rndn 11 years ago

    Is that really obvious? I think the checkerboard pattern only says something about the neighborhoods of the pieces and the amounts of tiles of each color used, not whether there exists is a rectangle configuration.

    • ecesena 11 years ago

      Here's an example. The trick I used was creating the extra block and the hole on the same side (so, not like the pic). With the pieces numbered as in the post:

          2233ffff
          72233ddd
          7744eaad
          7114eaag
          5114eegg
          555bbccg
          6666bbcc
      
      Note that, as in the post, I'm not "respecting" Tetris in 2d: pieces 2 and 3 have been "3d rotated" and are "looking in the same direction".
    • rmetzler 11 years ago

      If you buy 2 lamps, you've got 2 of all the 7 pieces. Piece 7 (the T-shaped piece) is doubled and you can switch the pattern for the second set. You'll have 15x color A and 13x color B in the first set and 13x color A and 15x color B in the second set. I'm pretty sure this would enable you to create a rectangular lamp.

      • JoshTriplett 11 years ago

        The proof in the article is a proof by contradiction. Having equal numbers of each colored square is a necessary but not sufficient condition to form a rectangle.

      • nemetroid 11 years ago

        Having the same number of both colours is not sufficient. 14 Z pieces will give you 28 of each color, but you can't make a rectangular lamp (of any size) from only Z pieces.

        • evanb 11 years ago

          That's true, but here's a construction:

              OOZZ
              OOSZZ
              LLSS
              ILTS
              ILTT
              IJT 
              IJJJ
          
          That's built out of one full set of OZSLJTI. If you take two of those, one rotated by 180˚, you get a rectangle.
        • eterm 11 years ago

          Not in 2D, but you can in 3D!

          edit: Actually I'm not sure my previous statement was true. You can make it more pleasing such as this though: http://nterm.co.uk/content/images/tetris.png

          • penguat 11 years ago

            <nitpick>rectangle specifies 2d</nitpick> I believe you could form a hollow cuboid, but I don't think you could complete a solid cuboid.

        • dkersten 11 years ago

          So the obvious next question is: how many sets do you need to create a perfect rectangle?

lern_too_spel 11 years ago

Your friend read Martin Gardner's aha! Insight, which has exactly this proof in it and is a popular book for young mathematical puzzle enthusiasts.

jimmaswell 11 years ago

Here's one nice-looking configuration I found. You seem to be implicitly assuming you can only have a depth of one unit but that's possibly an unnecessary limitation. I'm working on seeing if some kind of perfect cuboid can be made.

https://3dwarehouse.sketchup.com/model.html?id=u2d94f70c-682... (there's a webgl viewer)

  • osense 11 years ago

    I'm not sure, but i think the lamp wouldn't work anymore - it seems like the front and back metal strips might have different polarity.

pharke 11 years ago

A few things:

1) Why limit yourself to 4x7? The 1988 NES version of Tetris is 10 units wide.

2) There isn't any malicious design, you simply get 1 of each shape (one of the L pieces in the author's photo is reflected, should be turned the other way).

3) In Tetris, a full row is removed immediately so having a complete rectangular shape that occupies the full available width is unrealistic.

Pedantry aside, you'd have to ask Alexey Pajitnov if there was any devilry involved in choosing the shapes since the makers of the lamp have faithfully included a full set. Also, I personally prefer the aesthetic of a lamp arranged in such a way as to leave a hole in each row rather than a plain wall of coloured squares.

  • vinceguidry 11 years ago

    > Pedantry aside, you'd have to ask Alexey Pajitnov if there was any devilry involved in choosing the shapes since the makers of the lamp have faithfully included a full set.

    No devilry, there's just only so many ways you can connect four squares together to make a shape.

    http://en.wikipedia.org/wiki/Tetromino

  • AlexMax 11 years ago

    > 1) Why limit yourself to 4x7? The 1988 NES version of Tetris is 10 units wide.

    Presumably, the objective is to arrange the tetriminos into a pleasing rectangle shape. Unfortunately, the factors of 28 are 1, 2, 4, 7, 14 and 28, so 4x7 is the closest you can get to a square, and 2x14 has a similar problem of having the same number of 'white' squares as 'black' squares. The closest one can get is 5x6 with two holes removed.

    • maaku 11 years ago

      Why? A full row in tetris is removed. To someone who knows the game, leaving a hole in each row would be more pleasing. Aesthetically I'd also find it more interesting, but that's an aside.

      • po 11 years ago

        If you must, pretend it's half scale and it's a 4x7 rectangle in a 5 block wide well. The author is waiting for a long piece.

  • prezjordan 11 years ago

    This is not an exercise in "valid" tetris configurations, per se. It's a matter of arranging these blocks to make a clean square - plain and simple. The "malicious design" is tongue-in-cheek.

    Every engineer who has this lamp on their desk has thought of this.

  • eps 11 years ago

    Btw, the Tetris field is always exactly 10x20.

jimmaswell 11 years ago

You could rotate some pieces such that they're partially jutting out of the back of the lamp, which might make it possible.

rndn 11 years ago

Isn't the lamp simply designed to contain all of the seven types of Tetris pieces?

PhasmaFelis 11 years ago

> Maybe now I can shift my irritation from the lamp itself to whoever designed it to possess such a property.

There's no "design" involved in the choice of pieces: there are seven different ways to connect four squares in an orthogonal grid, "tetrominoes", assuming you allow for pieces to be rotated but not reflected. Tetris uses all seven, and so does the lamp. (Although the lamp's design apparently allows pieces to be reflected, i.e. rotated outside of the grid, so the S and Z pieces can be considered the same, as can L and J.)

jakethedog 11 years ago

You can make a rectangle as long as you don't use all of the pieces (maybe that is part of the puzzle?). For example, from http://www.amazon.co.uk/Lychee-Tetris-Constructible-Three-di..., remove the purple piece, shift the red piece to the left one space and flip it, then place the blue piece vertically on the right hand side.

  • peeters 11 years ago

    The argument in the article was that it's the purple piece (the "T") that is the problem (or least that makes the proof trivial). Can you make a rectangle with a subset that includes the T?

    • throwaway183839 11 years ago

      Theorem: No.

      Proof: Any rectangle made of Tetris pieces must have an even number of squares (in fact, a multiple of 4) and hence the same number of black/white squares. Every Tetris piece except the T has the same number of black/white squares, hence the T cannot be used in any arrangement of a subset of Tetris pieces into a rectangle.

    • kazagistar 11 years ago

      No.

      Every even x even rectangle has equal dark and light squares.

      Every even x odd rectangle has equal dark and light squares.

      Every odd x odd rectangle has one more odd then even, or one more even then odd. (1x1 square is obvious, any odd x odd rectangle can be reduced to 1x1 square by removing only odd x even rectangle.)

      Since the T piece creates a odd-even difference of 2, any number of other tetris pieces (including repeats) that only contains a single T piece can never form a rectangle with no holes.

analyticsjam 11 years ago

I recently read a similar case in Simon Singh's book Fermat's Enigma http://www.amazon.com/reader/0385493622?_encoding=UTF8&query... about the 14-15 puzzle. It was similarly unsolvable and provable the same way.

Interestingly, his account is rather different than that on wikipedia http://en.wikipedia.org/wiki/15_puzzle Singh claims that Sam Lloyd created the puzzle, secretly proved it was impossible, and offered rewards to anyone who could solve it.

a3_nm 11 years ago

A similar trick can be used to solve the following problem: considering a rectangular grid, is it possible to find a cycle that goes from adjacent squares to adjacent squares and visits each square exactly once?

Answer (ROT13): Vg qrcraqf ba gur cnevgl bs gur ahzore bs fdhnerf, juvpu qrcraqf ba jurgure gur qvzrafvbaf bs gur tevq fvqrf ner obgu bqq be abg. Vs gur ahzore bs fdhnerf vf bqq, gurer nera'g nf znal juvgr fdhnerf nf oynpx fdhnerf, naq n plpyr zhfg tb sebz juvgr gb oynpx naq sebz oynpx gb juvgr, fb ab plpyr rkvfgf. Vs vg vf rira, lbh pna rnfvyl pbzr hc jvgu n trareny fpurzr gb pbafgehpg n plpyr.

archagon 11 years ago

Speaking of Tetris proofs, I've had the following problem on the back-burner for a while: is there a way to check whether an arbitrary contiguous space comprised of squares can be filled in by tetrominoes? I don't have a math background so reasoning about it is difficult. Here's the question on StackOverflow: http://stackoverflow.com/questions/20083552/tetromino-space-...

  • jones1618 11 years ago

    A lot depends on your specific rules of the game. Does "filled by tetrominoes" mean you have to use every tetromino at least once? If not, then you can always fill your contiguous square space with 2x2 tetrominoes. Also, whatever your rules, it is generally a lot easier to prove it is possible (or not) to fill a space than find an actual solution.

    • archagon 11 years ago

      The main rule I'm trying to follow is "as random a tiling as possible". So unless absolutely necessary, no picking certain pieces just because it's easier.

      The max area I'm having to tile is fairly small (maybe 100x100 at most) so an actual solution could be fairly easily brute-forced in the last step of the process. I just want to avoid having to backtrack as much as possible since it increases the cost substantially.

  • praptak 11 years ago

    I vaguely remember someone having proved Tetris NP-hard but I think the problem wasn't filling a fixed shape but rather maximizing the number of erased lines given a board and an upcoming sequence of pieces.

    All this from memory, so it might be totally wrong.

jpegggOP 11 years ago

Author here - slightly overwhelmed by the response, but thanks for everyone's feedback! I never thought so many people would be as interested as I am in the lamp...

ezl 11 years ago

you should turn that link into an affiliate link. i would love to know how many (other) people also bought that tetris lamp after reading the article.

kcanini 11 years ago

What's more annoying is that it has two identical L pieces, instead of having one that is a mirror-image of the other, as they appear in Tetris.

  • bjackman 11 years ago

    Well it looks like you can rotate them (I mean in the 3rd dimension not present in actual Tetris)

  • sadawi 11 years ago

    Looks like the pieces are reversible, so the two L's and two S's are actually L, J, S, and Z.

  • Luc 11 years ago

    There's also two S pieces instead of an S and a Z. Irritating indeed. There must be order!

DominikR 11 years ago

Interesting concept. However, is it really a proof? If I removed piece #7 I'd have 24 boxes (12 white, 12 black) with which I could theoretically build a 6x4 rectangle, but I don't see how this would be actually possible with those pieces.

Maybe it only proves the negative, but not that there must be a solution.

Edit: there seems to be a solution for a 4x6 rectangle.

  • jpegggOP 11 years ago

    Exactly that - it's a proof that in this case a solution can't be found. Having a collection of pieces that doesn't violate the assumption in the article isn't a sufficient requirement for a solution to exist.

qb45 11 years ago

This is to prevent customers from accidentally assembling the lamp in an unspectacular way.

staffordrj 11 years ago

Very relevant to the video game Sigils of Elohim http://store.steampowered.com/app/321480/

h_a 11 years ago

Reminds me of Knuth's Dancing Links algorithm: http://arxiv.org/pdf/cs/0011047.pdf

robinhouston 11 years ago

If you remove the T piece, is it possible to assemble the other six into a rectangle? I suspect not, but the checkerboard proof does not suffice for this.

  • pjtr 11 years ago

        rr  Z []      S  LL
        r  ZZ []      SS  L
        r  Z     IIII  S  L
    
        rr  Z [] S  LL
        r  ZZ [] SS  L
        r  Z IIII S  L
    
        rrZ[]SLL
        rZZ[]SSL
        rZIIIISL
    • robinhouston 11 years ago

      Interesting! I just came here to say that I’ve found a 4x6 packing. I love the fact you can also do 3x8!

          ZZLL
          IZZL
          IOOL
          IOOJ
          ISSJ
          SSJJ
    • Dove 11 years ago

      I would think rotating this sideways and placing the troublesome T on top would give a pleasingly neat and symmetrical shape, if not a rectangular one.

izzydata 11 years ago

Maybe now you will have to buy a second one in order to make a perfectly rectangle then get rid of the excess pieces. Genius design.

bbcbasic 11 years ago

Wow so weird to see the tetris lamp on HN. One of my 2 year-old's favourite toys!

otikik 11 years ago

So if you ignore piece number 7, can you form a rectangle with the remaining pieces?

paxcoder 11 years ago

I would be interested in learning who that friend was, and how he got to the proof.

Spoygg 11 years ago

Nerdgasm :)

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection