In traditional Tetris, there are 7 distinct tetromino bricks, each denoted by a letter similar to its shape.
#
# # #
# ## # # ### ## ##
# ## ## ## # ## ##
I O L J T Z S
Consider the arrangements of these bricks that can make a solid W×H rectangle, for some positive integers W and H. For example, using 2 I's, 1 L, 1 J, 2 T's, and 1 S, a 7×4 rectangle can be made:
IIIITTT
LIIIITJ
LTTTSSJ
LLTSSJJ
The same bricks can be rearranged (by moving and rotating but not flipping) into a different 7×4 pattern:
IJJTLLI
IJTTTLI
IJSSTLI
ISSTTTI
Now consider using a rectangular block of code in place of the first arrangement. For example this 7×4 bit of Python 3, which prints Tetris
to stdout:
p=print
x='Tet'
y='ris'
p(x+y)#
According to the first Tetris arrangement its 7 "bricks" are...
x '
int y ' ='r is
p=pr t p( ='Te )# x +y
In the other arrangement (one of many possible) they are unintelligible as code:
r#)x(x=
p'r'=y'
='istpT
p+ytnie
But, given the bricks separately, it might be possible to piece them back together properly. This is the basis of the challenge.
Challenge
This is a cops-and-robbers challenge. There are two competing roles, the Jumblers and the Rebuilders.
The Jumblers submit answers with blocks of code that have been broken down into Tetris bricks.
The Rebuilders attempt to rebuild these blocks in the separate question dedicated for them: Jumblers vs Rebuilders: Coding with Tetris Bricks - Area for Rebuilder Answers.
Jumblers
Using only printable ASCII (hex codes 20 to 7E) write a W×H rectangular program. When run, it must output the sole word Tetris
to stdout (or closest alternative). Do not post this code in your answer; don't give W or H either. Break it up into some arrangement of Tetris bricks like the example above and post these in your answer. (Your code may contain spaces but since they are hard to distinguish, it's best to use some other character in place of spaces and tell people what you used.)
The harder it is to rebuild your program the better. There may be many ways to rearrange your code-bricks into a rectangle, possibly with different dimensions. What the code does when run in these different arrangements doesn't matter as long as at least one arrangement prints Tetris
to stdout.
The only other restriction is that W * H be less than 1025.
Jumblers should specify their programming language (and version).
Rebuilders
Your goal is to take a Jumbler's code-bricks and put them back into their original order, so Tetris
is printed when the code is run. If the working arrangement you find isn't the one the Jumbler had in mind that's too bad for them.
Remember that only translation and rotation are allowed in rearrangements, not mirroring.
Scoring
Each time a submission is rebuilt it is considered "cracked" and is no longer in the running. The first Rebuilder to rebuild a submission gets the credit for it. If an answer goes uncracked for 72 hours the Jumbler should reveal the solution and will be henceforth immune from being cracked. A Jumbler must do this to win, since otherwise it will be unclear if there even was a solution.
The winning Jumbler is the uncracked answer with the smallest area (W * H = 4 * num of bricks). In case of ties the highest voted answer wins. The accepted answer for this question will be the winning Jumbler.
The winning Rebuilder is the user who cracks the most submissions. In case of ties it goes to whomever cracked the most cumulative area.
Notes
- You may not rebuild your own submissions. (But otherwise you may take on both roles.)
- Rebuilders may not attempt to crack the same answer more than once.
Scoreboard
Sorted from oldest submission to newest.
+--------------+-------------+------------------+---------+----------+----------------+-------------------------------------------+-------------------------------------------+
| Jumbler | Language | Area | Immune? | Rebuilt? | Rebuilder | Link | Solution Link |
+--------------+-------------+------------------+---------+----------+----------------+-------------------------------------------+-------------------------------------------+
| xnor | Python 3 | 212 | no | yes | foobar | https://codegolf.stackexchange.com/a/40142 | https://codegolf.stackexchange.com/a/40203 |
| xnor | Python 3 | 340 | no | yes | feersum | https://codegolf.stackexchange.com/a/40146 | https://codegolf.stackexchange.com/a/40189 |
| es1024 | C | 80 | no | yes | user23013 | https://codegolf.stackexchange.com/a/40155 | https://codegolf.stackexchange.com/a/40210 |
| Ethiraric | Brainfuck | 108 | yes | | | https://codegolf.stackexchange.com/a/40156 | |
| Qwertiy | JavaScript | 420 | yes | | | https://codegolf.stackexchange.com/a/40161 | |
| user23013 | Befunge | 360 | yes | | | https://codegolf.stackexchange.com/a/40163 | |
| user23013 | CJam | 80 | yes | | | https://codegolf.stackexchange.com/a/40171 | |
| Geobits | Java | 360 | yes | | | https://codegolf.stackexchange.com/a/40180 | |
| Dennis | CJam | 60 | yes | | | https://codegolf.stackexchange.com/a/40184 | |
| xnor | Python 3 | 160 | yes | | | https://codegolf.stackexchange.com/a/40192 | |
| COTO | C | 72 | yes | | | https://codegolf.stackexchange.com/a/40198 | |
| es1024 | C | 780 | yes | | | https://codegolf.stackexchange.com/a/40202 | |
| Gerli | Mathematica | 72 | no | yes | Martin Büttner | https://codegolf.stackexchange.com/a/40230 | https://codegolf.stackexchange.com/a/40242 |
| Hydrothermal | JavaScript | 80 | yes | | | https://codegolf.stackexchange.com/a/40235 | |
| Sam Yonnou | GolfScript | 48 (frontrunner) | yes | | | https://codegolf.stackexchange.com/a/40239 | |
| feersum | Matlab | 48 | | | | https://codegolf.stackexchange.com/a/40310 | |
| Beta Decay | Python 3 | 484 | | | | https://codegolf.stackexchange.com/a/40312 | |
| potato | Python 3 | 176 | | | | https://codegolf.stackexchange.com/a/40341 | |
+--------------+-------------+------------------+---------+----------+----------------+-------------------------------------------+-------------------------------------------+
(Thanks to http://www.sensefulsolutions.com/2010/10/format-text-as-table.html for table formatting.)
User COTO made an excellent tool for playing with code-bricks. I've turned it into a convenient snippet:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><script>function parseSpec(s){function first(){var e,t;t=S.findIndex(function(t){return(e=t.findIndex(function(e){return/\S/.test(e)}))!=-1});return t==-1?null:[e,t]}function at(e){var t=e[0],n=e[1];return n>=0&&n<S.length&&t>=0&&t<S[n].length?S[n][t]:" "}function wipe(e){var t=e[0],n=e[1];if(n>=0&&n<S.length&&t>=0&&t<S[n].length)S[n][t]=" "}var P,S=s.split("\n").map(function(e){return e.split("")});var oPats=$(".proto-tet [pat]").get().map(function(e){return{sPat:eval("["+$(e).attr("pat")+"]"),e:e,block:function(e){return[at(e)].concat(this.sPat.map(function(t){return at([e[0]+t[0],e[1]+t[1]])}))},wipe:function(e){this.sPat.forEach(function(e){return wipe([P[0]+e[0],P[1]+e[1]])})},match:function(e){return!/\s/.test(this.block(e).join(""))}}});window.oPats=oPats;while(P=first()){var oPat=oPats.find(function(e){return e.match(P)});if(!oPat){orphan(at(P));wipe(P);continue}createPiece(oPat.e,oPat.block(P));wipe(P);oPat.wipe(P)}}function createPiece(e,t){function r(e){var t=$(this).position();G.isIgnoreClick=false;G.eDrag=this;G.iOffsets=[e.clientX-t.left,e.clientY-t.top]}function i(){if(G.isIgnoreClick)return;var e=$(this);s($(".proto-tet ."+e.attr("rr")),function(e,t){return n[t-1]},e.css("left"),e.css("top"));e.remove()}function s(e,t,n,s){e.clone().html(e.html().replace(/@(\d)(\d)/g,t)).appendTo("body").on("mousedown",r).click(i).css({left:n,top:s})}var n=[];s($(e),function(e,r,i){return n[r-1]=t[i-1]},18+G.iSpawn%8*18*4+"px",18+~~(G.iSpawn/8)*18*4+"px");G.iSpawn++}function init(){$(document).on("mouseup",function(){return G.eDrag=null}).on("mousemove",function(e){if(G.eDrag){var t=$(G.eDrag),n=Math.round((e.clientX-G.iOffsets[0])/18)*18,r=Math.round((e.clientY-G.iOffsets[1])/18)*18,i=t.position();if(n!=i.left||r!=i.top)G.isIgnoreClick=true;t.css({left:n+"px",top:r+"px"})}})}function orphan(e){error("Spec character not a part of any block: '"+e+"'")}function error(e){$(".error").css("display","block").append("<div>"+e+"</div>")}function go(){$(init);$(function(){parseSpec($("#spec").val())});$("#spec").remove();$("#info").remove();$("#go").remove()}var G={eDrag:null,isIgnoreClick:true,iSpawn:0};Array.prototype.findIndex=function(e){for(var t=0;t<this.length;t++){if(e(this[t]))return t}return-1};Array.prototype.find=function(e){var t=this.findIndex(e);if(t==-1)return;else return this[t]}</script><style>.proto-tet, .spec{display: none;}.tet-I{color: darkgreen;}.tet-J{color: orangered;}.tet-L{color: navy;}.tet-T{color: darkred;}.tet-O{color: darkcyan;}.tet-S{color: darkviolet;}.tet-Z{color: darkorange;}body > .tet{position: absolute;cursor: move;-webkit-touch-callout: none;-webkit-user-select: none;-khtml-user-select: none;-moz-user-select: none;-ms-user-select: none;user-select: none;border-collapse: collapse;}.tet td{width: 18px;height: 18px;font: bold 14px "Courier New",monospace;text-align: center;vertical-align: middle;padding: 0;}.error{z-index: 1024;position: absolute;display: none;color: red;font-weight: bold;background-color: white;}textarea{font-family: "Courier New", Courier, monospace;}</style><div id='info'>Put code-bricks here and hit OK. Re-run the snippet to restart.<br>(You may need to replace spaces in code-bricks with some other character first.)</div><textarea id='spec' rows='16' cols='80'>ABCD a b Oo c oo d E h F efg hg GFE GH f H e I IJK J l L LK kji kl j i t OP p QR rs MN on ST q m W z XY zxw yx Y Z y w WXZ</textarea><br><button id='go' type='button' onclick='go()'>OK</button><div class="proto-tet"><table class="tet tet-I tet-I0" rr="tet-I1" pat="[1,0],[2,0],[3,0]"><tr><td>@11</td><td>@22</td><td>@33</td><td>@44</td></tr></table><table class="tet tet-I tet-I1" rr="tet-I2" pat="[0,1],[0,2],[0,3]"><tr><td>@11</td></tr><tr><td>@22</td></tr><tr><td>@33</td></tr><tr><td>@44</td></tr></table><table class="tet tet-I tet-I2" rr="tet-I3" ><tr><td>@40</td><td>@30</td><td>@20</td><td>@10</td></tr></table><table class="tet tet-I tet-I3" rr="tet-I0"><tr><td>@40</td></tr><tr><td>@30</td></tr><tr><td>@20</td></tr><tr><td>@10</td></tr></table><table class="tet tet-J tet-J0" rr="tet-J1" pat="[0,1],[-1,2],[0,2]"><tr><td></td><td>@11</td></tr><tr><td></td><td>@22</td></tr><tr><td>@33</td><td>@44</td></tr></table><table class="tet tet-J tet-J1" rr="tet-J2" pat="[0,1],[1,1],[2,1]"><tr><td>@31</td><td></td><td></td></tr><tr><td>@42</td><td>@23</td><td>@14</td></tr></table><table class="tet tet-J tet-J2" rr="tet-J3" pat="[1,0],[0,1],[0,2]"><tr><td>@41</td><td>@32</td></tr><tr><td>@23</td><td></td></tr><tr><td>@14</td><td></td></tr></table><table class="tet tet-J tet-J3" rr="tet-J0" pat="[1,0],[2,0],[2,1]"><tr><td>@11</td><td>@22</td><td>@43</td></tr><tr><td></td><td></td><td>@34</td></tr></table><table class="tet tet-O tet-O0" rr="tet-O1" pat="[1,0],[0,1],[1,1]"><tr><td>@11</td><td>@22</td></tr><tr><td>@33</td><td>@44</td></tr></table><table class="tet tet-O tet-O1" rr="tet-O2"><tr><td>@30</td><td>@10</td></tr><tr><td>@40</td><td>@20</td></tr></table><table class="tet tet-O tet-O2" rr="tet-O3"><tr><td>@40</td><td>@30</td></tr><tr><td>@20</td><td>@10</td></tr></table><table class="tet tet-O tet-O3" rr="tet-O0"><tr><td>@20</td><td>@40</td></tr><tr><td>@10</td><td>@30</td></tr></table><table class="tet tet-L tet-L0" rr="tet-L1" pat="[0,1],[0,2],[1,2]"><tr><td>@11</td><td></td></tr><tr><td>@22</td><td></td></tr><tr><td>@33</td><td>@44</td></tr></table><table class="tet tet-L tet-L1" rr="tet-L2" pat="[1,0],[2,0],[0,1]"><tr><td>@31</td><td>@22</td><td>@13</td></tr><tr><td>@44</td><td></td><td></td></tr></table><table class="tet tet-L tet-L2" rr="tet-L3" pat="[1,0],[1,1],[1,2]"><tr><td>@41</td><td>@32</td></tr><tr><td></td><td>@23</td></tr><tr><td></td><td>@14</td></tr></table><table class="tet tet-L tet-L3" rr="tet-L0" pat="[-2,1],[-1,1],[0,1]"><tr><td></td><td></td><td>@41</td></tr><tr><td>@12</td><td>@23</td><td>@34</td></tr></table><table class="tet tet-S tet-S0" rr="tet-S1" pat="[1,0],[-1,1],[0,1]"><tr><td></td><td>@21</td><td>@12</td></tr><tr><td>@43</td><td>@34</td><td></td></tr></table><table class="tet tet-S tet-S1" rr="tet-S2" pat="[0,1],[1,1],[1,2]"><tr><td>@41</td><td></td></tr><tr><td>@32</td><td>@23</td></tr><tr><td></td><td>@14</td></tr></table><table class="tet tet-S tet-S2" rr="tet-S3"><tr><td></td><td>@30</td><td>@40</td></tr><tr><td>@10</td><td>@20</td><td></td></tr></table><table class="tet tet-S tet-S3" rr="tet-S0"><tr><td>@10</td><td></td></tr><tr><td>@20</td><td>@30</td></tr><tr><td></td><td>@40</td></tr></table><table class="tet tet-Z tet-Z0" rr="tet-Z1" pat="[1,0],[1,1],[2,1]"><tr><td>@11</td><td>@22</td><td></td></tr><tr><td></td><td>@33</td><td>@44</td></tr></table><table class="tet tet-Z tet-Z1" rr="tet-Z2" pat="[-1,1],[0,1],[-1,2]"><tr><td></td><td>@11</td></tr><tr><td>@32</td><td>@23</td></tr><tr><td>@44</td><td></td></tr></table><table class="tet tet-Z tet-Z2" rr="tet-Z3"><tr><td>@40</td><td>@30</td><td></td></tr><tr><td></td><td>@20</td><td>@10</td></tr></table><table class="tet tet-Z tet-Z3" rr="tet-Z0"><tr><td></td><td>@40</td></tr><tr><td>@20</td><td>@30</td></tr><tr><td>@10</td><td></td></tr></table><table class="tet tet-T tet-T0" rr="tet-T1" pat="[1,0],[2,0],[1,1]"><tr><td>@11</td><td>@22</td><td>@33</td></tr><tr><td></td><td>@44</td><td></td></tr></table><table class="tet tet-T tet-T1" rr="tet-T2" pat="[-1,1],[0,1],[0,2]"><tr><td></td><td>@11</td></tr><tr><td>@42</td><td>@23</td></tr><tr><td></td><td>@34</td></tr></table><table class="tet tet-T tet-T2" rr="tet-T3" pat="[-1,1],[0,1],[1,1]"><tr><td></td><td>@41</td><td></td></tr><tr><td>@32</td><td>@23</td><td>@14</td></tr></table><table class="tet tet-T tet-T3" rr="tet-T0" pat="[0,1],[1,1],[0,2]"><tr><td>@31</td><td></td></tr><tr><td>@22</td><td>@43</td></tr><tr><td>@14</td><td></td></tr></table></div><div class="error"></div>