[Question]
  [
Challenge Taken from my university code challenge contest
This is actually Day 0 but yesterdays' challenge was too easy and can be a dupe of another question here.
---
Tetris is a video game that became popular in the 80s. It consists of placing a series of pieces with different shapes that fall on a board, so that they fit in the most compact way possible.
In this problem we will assume a sequence of pieces that fall, each in a certain position and with a certain orientation that can not be changed. The pieces are piled up as they fall and the complete rows are not eliminated (as in the original game). The objective is to determine the final height of each column of the board after all the pieces fall.
There are a total of 7 different pieces, shown in the figure:
[![shapes](https://i.stack.imgur.com/Houek.png)](https://i.stack.imgur.com/Houek.png)
**Challenge**
Given a list of pieces, output the height of all the columns from the board after all pieces falls
A piece consists of three numbers: I, R and P. The first number, I, is the identifier of the piece (a number between 1 and 7, in the same order as in the figure). The second number, R, is the rotation of the piece. It can take the values ‚Äã‚Äã0, 90, 180 or 270 and represents the angle of rotation of the piece in the anti-clockwise direction. The third number, P, indicates the position of the piece. Represents the column on the left occupied by the piece (this can be 1 or 0 Index. Please specify).
**Example and Test case (1 Index)**
* Given `[[1, 0, 1], [4, 0, 1], [5, 90, 4]]`
[![case #1](https://i.stack.imgur.com/GuLzB.png)](https://i.stack.imgur.com/GuLzB.png)
* Output `[3, 3, 1, 3, 2]`
---
* Given `[[6, 270, 4], [1, 180, 5], [1, 90, 6], [7, 0, 4]]`
[![case #2](https://i.stack.imgur.com/V9d8B.png)](https://i.stack.imgur.com/V9d8B.png)
* Output `[0, 0, 0, 9, 9, 8, 3, 3]`
---
* Given `[[3,0,1],[3,180,3]]` Output `[1,1,4,4,4]`
* Given `[[2,180,1],[2,0,3]]` Output `[2,2,4,3,3]`
**Notes**
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'")
* Row/Column can be 1 or 0 Index. Please specify.
* You can redefine input values (maybe you want to call piece 1 as A, etc..). In that case please specify
**Questions**
* Can we use any 4 distinct values instead of an angle in degrees?: *Yes*
* Are we supposed to handle "holes" if a piece doesn't exactly fit over the previous ones?: *Yes*
* Is the height or the width of the board bounded? *No. Neither the width nor the height are bounded*
---
Thanks @Arnauld for the images and the test cases \*.\*
  
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), ~~¬†286 284 270¬†~~ 266 bytes
Pieces and positions are 0-indexed. Angles are in \$[0..3]\$.
```
a=>a.map(([p,r,x])=>(g=y=>y>3?g(+!Y--):b[Y+y]&(m[y]=('0x'+`717433667233ff4717333327661${1e12+0x5e7056a566ffff57efa65n.toString(4)}`[(p*2+r*56+y*99+13)%113])<<x)?m.map(v=>(g=x=>v&&g(x+1,H[x]=v&1?Y:~~H[x],v>>=1))(0,b[++Y]|=v)):g(y+1))(Y=a.length*4),m=[b=[-1]],H=[])&&H
```
[Try it online!](https://tio.run/##XY7NboMwEITvfYtKLbHxgjDGRoli55p7T8iyFJMCTRV@RBACtc2rUwf11NnDaHb3k@bTjvZ27i/dEDTte7GUcrFS2bC2HUK6gx4mg6VClZylmhU7VIg8Z0GAd7nOyGw8VOvZSLSJpg05pTRNGBMijRkry8RF5hSnQtCXL1rQmEQTL9KIC8uFKJ14WpRW8CYc2rehvzQVSvDPSaPOj0nvc0Fmf7sllOFXSpnB@/2ED/XablxbTVKNnlehiVA46snI0aOHbHe/PwKMSkmKMYog14Rk5luOGO8qNJPHNpM2vBZNNXz4CYZa6lzqgBoDR6kN9rzjcm6bW3stwmtboRJpHYEbA5r9eQIUmDEYP/3/5MDcBRwRQ7I6Be5cOHIlll8 "JavaScript (Node.js) ‚Äì Try It Online")
or [try an enhanced version](https://tio.run/##TU/bbtswDH3vV3jAZpORolqWL2hQKU8D8t4nQxBQJZXdFIltOIZhY1s/Y9j37UcyOdiwkg@HhzwED9/saC@H/tgN66Z9cddKXq1Ulp1tB6A72tPJoFRQy1mqWYltDeRTuV7jZq9LMpsQzno2EqJ4ishzwYtUiDwvEiGqKvVU@EiKPOefv3HHExJPmSviLLdZnlc@ssJVNs8aNrRPQ39sakjxx7OGbpWQfpXlZF49PBAu8AvnwuDj44Tb883deHM1STWGYQ0T4XSnJyPHkG/Lzfv7QuiolOSIENO9JqQ03@WIuKlhJku3lJadXFMPr6sU6VnqvdRrbgzdSW0wDHfXwV2GQAY2kCqAna8qsEiDPevd6PqLA2RV23@1h1doFs2hbS7tybFTW4NmjPmuUiqI8f97Cfrl7mQPDu7ZfU2D22IU/P75K9KNQdbZl6fB9gOIBM2HQ2/tsYEoQvQGPt7ZId7dLUZB65j6NFSLv5hSToUx@G@eUeE59bqEpjfkNPOYe/2iu/4B) that also displays the final board.
### Shape encoding
All pieces are stored as exactly 4 nibbles (4x4 bits) with the rows sorted in reverse order and the leftmost pixel mapped to the least significant bit. In other words, the binary representation of the shape is mirrored both vertically and horizontally.
Example:
[![example of shape encoding](https://i.stack.imgur.com/aMY9Z.png)](https://i.stack.imgur.com/aMY9Z.png)
### Hash function and lookup table
Given a piece \$p \in [0..6]\$, a rotation \$r \in [0..3]\$ and a row \$y \in [0..3]\$, we use the following hash function to get the index \$n\$ of the corresponding bitmask from a lookup table:
$$n=(2p+56r+99y+13)\bmod 113$$
Only the first \$82\$ entries are explicitly stored. Everything else is set to \$0\$.
These entries are packed as:
```
`717433667233ff4717333327661${1e12+0x5e7056a566ffff57efa65n.toString(4)}`
```
which expands to the following 82 nibbles:
```
"717433667233ff47173333276611000000000000113213001112221112123333333311133233221211"
```
Using hexadecimal in the final format is only required for the two horizontal representations of the \$I\$ piece, hence the `"ff"` in the above string.
The parameters of the hash function were brute-forced in a way that optimizes leading and trailing zeros. The fact that the string can be compressed some more by using `1e12` for the zeros in the middle and a conversion from base-16 to base-4 for the right part is just a welcome but unexpected side effect. :-)
[**Here is a demonstration**](https://tio.run/##ZVBdToNAEH7nFPOAAUql/C6pVS9BfFITNnRpsLi7WdCUkO2zJ/AcnsGjeBEcaJumOi@zO9/PfJkX@k6bQlWyveZizYYhgzvI0yCNo4iQNIyisozxG2GFKSGB2QcsCF1/l7DUTwhNCCmxkpSVlCTca0XWqopv7NjR@cowCsEbUTOvFhs7f@CSFlu2hlqI7ZuEZqLePHGzz/QTzx0UlELZEkP4K5BwCyk213WgNwBGSB0ghVCM7QQBXCySFSsYMs1e6jko0dK2EnwaKJjB0tffX9O2UTnadgfb7mDbnW0BRhkmmkEILozqhOCjG22W@AgiB64gCKLVkf/abFGx39uWv7OQkD3yZ@cEXqT0d2aP7PPNAuJo@DMLHU8xWdOC2QtvsZmPee7B8n4@P6zR2ZN0nbVUtXY8x7GFZz9u0//uMgHa0MPwCw) of the unpacking process for all pieces and all rotations.
### Commented
```
a => a.map(([p, r, x]) => (     // for each piece p with rotation r and position x:
  g = y =>                      //   g = recursive function taking y
    y > 3 ?                     //   if y is greater than 3:
      g(+!Y--)                  //     reset y to 0, decrement Y and try again
    :                           //   else:
      b[Y + y] & (              //     test if we have a collision of the board with
        m[y] =                  //     the y-th row m[y] of the current piece
          ('0x' + `717...`[     //     which is extracted from a lookup table
            (p * 2 + r * 56 +   //     using the hash function described in the
             y * 99 + 13) % 113 //     previous paragraph
          ]) << x               //     and shifted to the left according to x
      ) ?                       //     if we have a collision:
        m.map(v => (            //       we iterate again on the piece rows stored in m[]
          g = x =>              //         g = recursive function taking x
            v &&                //         if v is not equal to 0:
            g(                  //           do a recursive call:
              x + 1,            //             increment x
              H[x] =            //             update the height at x:
                v & 1 ?         //               if this bit is set:
                  Y             //                 set it to Y
                :               //               else:
                  ~~H[x],       //                 leave it unchanged or force it to 0
                                //                 if it was still undefined
              v >>= 1           //             shift v to the right
            )                   //           end of recursive call
          )(0,                  //         initial call to g with x = 0
               b[++Y] |= v)     //         increment Y and copy the piece row to the board
        )                       //     end of map()
      :                         //   else (no collision):
        g(y + 1)                //     do a recursive call to test the next row
  )(Y = a.length * 4),          //   initial call to g with y = Y = 4 * the number of pieces
                                //   (assuming the worst case: piled vertical I pieces)
  m = [b = [-1]], H = []        //   initialize m[], b[] and H[]
                                //   we set a full line at the bottom of b[]
) && H                          // end of map(); return H[]
```
[Answer]
# [C (clang)](http://clang.llvm.org/), ~~[253](https://tio.run/##hVDRjtsgEHzPV6xSRTLxpjEGV44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dC8OqYhhxMO4xbcTEUUB4KTjOao0k5Da04Ci3uGAkME3f@sDFF0cMiYogJ83z56AVhvcMIQr2/B4@jLZm5X2zuWbkoPtYNRnU6fOi/@cD5CK51H7iDwFh5SdD7p0onjOULo3xAF9v4PQh8h9L8g9N8h2v1PbZbqdrsPPv0C "C (clang) ‚Äì Try It Online")
p.s. Actually the code size is 221 bytes (but 212 chars) because of UNICODE chars coded in UTF-8. But **tio.run** treats it as 212 byte code...
Code size on my computer is 209 chars (218 bytes). But I couldn't replace `\225` by visible char in **tio.run** üòû
## Ungolfed code
```
// a - output array (must be zeroed), b - array of block info, c - number of blocks
// Figure codes: 2->0, 3->1, 6->2, 1->3, 5->4, 7->5, 4->6 (0,1 are L-figures, 2 is is T-figure, 3 is a line 1x4; 4,5 are zigzags; 6 is a cube 2x2)
// Vertical and horizontal positions are zero-indexed, angles = 0..3
t(*a,*b,c)
{
  char*z="VP\225TBUIUVAaUZ@AWVDeTf@EVWhUüòéEQVüòÄRTYTüòâUU";  // UTF-8
//char*z="VP\225TBUIUVAaUZ@AWVDeTf@EVW\1hUüòé\26EQVüòÄRTYTüòâUU";  // 3 bytes longer (use it if you can't copy previous string correctly) :)
  // Blocks
  for(size_t*p,f,n,y,i;c--;b++){
    f=1<<(8-*b)/3;  // number of figure variants
    p=z+*b++*8+*b++%f*2;
    // Get top base line position (y)
    f=n=*p;  // figure width, TBLs and HATs
    for(y=i=0;i<=f%4;
      y=fmax(y,a[*b+i++]+n%4))
      n/=4;
    // Add heights (HATs)
    for(;i--;
      a[*b+i]=y+n%4)
      n/=4;
  }
}  // 215 chars (224 bytes)
```
## Description
Let's found top base line (**TBL**) of each figure and describe it as a number of cells below TBL for each horizontal position. Also let's describe number of cells (height) above TBL (**HAT**).
E.g.:
```
                       ________                                      ________
_[]_____ HAT = 1,0,0    [][][]  HAT = 0,0,0   ___[][]_ HAT = 0,1,1    [][][]  HAT = 0,0,0
 [][][]  TBL = 1,1,1    []      TBL = 2,1,1    [][]    TBL = 1,1,0      []    TBL = 1,2,1
```
Let's describe TBLs and HATs for each figure and each rotation angle:
```
Width  TBLs     HATs
-----  -------  -------
L-figures:
  3    1 1 1    1 0 0    // 0¬∞
  2    1 1      0 2      // 90¬∞
  3    1 1 2    0 0 0    // 180¬∞
  2    3 1      0 0      // 270¬∞
  3    1 1 1    0 0 1    // 0¬∞
  2    1 3      0 0      // 90¬∞
  3    2 1 1    0 0 0    // 180¬∞
  2    1 1      2 0      // 270¬∞
T-figure:
  3    1 1 1    0 1 0    // 0¬∞
  2    1 2      0 1      // 90¬∞
  3    1 2 1    0 0 0    // 180¬∞
  2    2 1      1 0      // 270¬∞
Line:
  4    1 1 1 1  0 0 0 0  // 0¬∞, 180¬∞
  1    4        0        // 90¬∞, 270¬∞
Zigzags:
  3    1 1 0    0 1 1    // 0¬∞, 180¬∞
  2    1 2      1 0      // 90¬∞, 270¬∞
  3    0 1 1    1 1 0    // 0¬∞, 180¬∞
  2    2 1      0 1      // 90¬∞, 270¬∞
Cube:
  2    2 2      0 0      // any angle
```
Now we should encode these numbers as a sequences of 2 bits and put into an array (replacing `4 0` by `3 1` for 90¬∞ angle of "line" to fit in 2 bits ‚Äì result will be the same; and decrease widths by 1).
We'll encode in order: **width** (in 2 LSB), **TBLs**, **HATs** (backward for backward loop).
E.g. `2 2 1 1 0` for 270¬∞ angle of T-figure will be encoded as `1 0 1 2 1` (last *1* is *width-1*): `0b0100011001 = 281`.
**updated 12.02:**
a) I've converted an array to a string and saved 18 chars (you can see previous [239 bytes code](https://tio.run/##hVBdj5swEHzPr1ilioRhaTA2Fci4f4TyYJzz1VLOqS45tQTx149bfKlyfWgrPnZ2Zr3MYHN7NOFxWS5JajAd0LLJnZ4THy5w7Xo9SV6XyGWDvCqwbFDIEiuBTUFvgZzzAnnB6SmxrDnJgioWdHGxco2ITVVSUzcRSz6jw4AjemXzXA1ZRh/VvG2TOk8HthfK6aCvXUpKKrO17Fyvoi896kL5VrudVKN2T@ZXMqJZR32W9VnYScbCXss4rTytfxd7PUYxavO8fPLBHl8OD9CeLwd/@vz962azhn4yPiQMpg3A2pqu6kHDNKsbMXR9JyIFk0Ao6J4Rpi93KBE4gpghnrkkBmH9nSkbiGUrR9YiBZ72FIpKC2d/fTi5xLD9DaWGKcgy/@4F4McznXDJdudhi@TL93HXvLlL38KWuJtR29V/Oj98cF6SldUjxhDUyRsk59UKq5jnHsL@DnGg2f@FsPcQ9l8h7N9DzMurdUfzeF7yn28)) :))
b) More optimization, code is shrinked by 9 chars.  
*This is my last attempt (I think so, lol!)* üòÄ
[Answer]
# Common Lisp, 634 bytes
```
(let((w(make-hash-table))(r 0))(defun z(c)(or(gethash c w)0))(defun x(c v)(setf r(max r c))(setf(gethash c w)v))(defun m(s)(dolist(c s)(apply(lambda(n u p)(let*((i(let*((j'(2 2 2))(k'(3 3))(l'(2 3))(m'(3 2))(o(case n(1(list'(1 1 1 1)'(4)))(2(list j k'(1 1 2)'(3 1)))(3(list j'(1 3)'(2 1 1)k))(4(list'(2 2)))(5(list'(2 2 1)l))(6(list j l'(1 2 1)m))(7(list'(1 2 2)m)))))(setf(cdr(last o))o)))(o(nth(+ u 2)i))(b(nth u i))(s(length o))(d 0)(h 0))(dotimes(i s)(let*((w(nth i b))(g(z(+ i p)))(m(+ g w)))(when(> m d)(setf d m)(setf h(- g(-(apply'max b)w))))))(dotimes(i s)(x(-(+ s p)i 1)(+(nth i o)h)))))c))(dotimes(i r)(print(z (+ i 1))))))
```
## Verbose
```
(defun circular (list)
  (setf (cdr (last list)) list))
(defun get-piece (piece-number)
  (circular (case piece-number
              (1 (list '(1 1 1 1)
                       '(4)))
              (2 (list '(2 2 2)
                       '(3 3)
                       '(1 1 2)
                       '(3 1)))
              (3 (list '(2 2 2)
                       '(1 3)
                       '(2 1 1)
                       '(3 3)))
              (4 (list '(2 2)))
              (5 (list '(2 2 1)
                       '(2 3)))
              (6 (list '(2 2 2)
                       '(2 3)
                       '(1 2 1)
                       '(3 2)))
              (7 (list '(1 2 2)
                       '(3 2))))))
(let ((world (make-hash-table))
      (rightmost-column 0))
  (defun get-world-column (column)
    (or (gethash column world) 0))
  (defun set-world-column (column value)
    (setf rightmost-column (max rightmost-column column))
    (setf (gethash column world) value))
  (defun drop-piece (piece-number rotation position)
    (let* ((piece (get-piece piece-number))
           (top (nth (+ rotation 2) piece))
           (bottom (nth rotation piece))
           (size (length top))
           (max-combined-height 0)
           (contact-height 0))
      (dotimes (i size)
        (let* ((down-distance (nth i bottom))
               (height (get-world-column (+ i position)))
               (combined-height (+ height down-distance)))
          (when (> combined-height max-combined-height)
            (setf max-combined-height combined-height)
            (setf contact-height
                  (- height
                     (- (apply #'max bottom)
                        down-distance))))))
      (dotimes (i size)
        (set-world-column (- (+ size position) i 1)
                          (+ (nth i top) contact-height)))))
  (defun drop-pieces (pieces)
    (dolist (piece pieces)
      (apply #'drop-piece piece)))
  (defun print-world ()
    (loop for i from 1 to rightmost-column
          do (print (get-world-column i)))))
(defun play-tetris (pieces)
  (drop-pieces pieces)
  (print-world))
```
[Test it](https://rextester.com/KTOVE5949)
The pieces are circular-lists of lists of numbers. These sub-lists each represent a side of the shape, the numbers indicating how far they are from the opposite side. They are left to right when that side is on the bottom, right to left when on top, top to bottom when on left, and bottom to top when on right. These design choices eliminate the need to write code for rotation. Unfortunately, the lack of rotation code does not seem to have made up for the lengthy shape representations, or the somewhat complicated logic I used for calculating new column heights.
Rotation is a non-negative integer. 0=0 degrees, 1=90 degrees, 2=180 degrees, 4=270 degrees
[Answer]
# [C# (Visual C# Interactive Compiler)](http://www.mono-project.com/docs/about-mono/releases/5.0.0/#csc), 308 bytes
```
a=>{var o=new int[a.Max(x=>x.Item3+4)];foreach(var(i,r,p)in a){var b="\"4TqzŒ¬™!\0
\0HSš	√ì\0$\n\0!“A“š 
š@";int m=0,n=b[i],t=0,u=n/8+r%(n%8),v=b[u*=2]<<8|b[u-1];for(;t<v/8%8;m=m>n?m:n)n=o[p+t]+v%8-(n=(u=v>>6+3*t++)/2&1)-(n&u);for(;t-->0;)o[p+t]=m-(n=(u=v>>6+3*t)/4&1)-(n&u);}return o;}
```
[Try it online!](https://tio.run/##lZC/TsMwEMaFBAgQE906mYgimzjNX1AgdYAFAYIJJIY0Q6hS8BAHghMqoG/A1o1H4DHCg5VLUgFiAuVsf/bd/b5TBg/a4IFPj3Ix6GEuJJ0tEoTVEYT@kE0j5j8XUYZSJuJHVD1H3fNohEfMH3VPZJzYqkNCb5hmcTS4xVCKOc3oHeECRaRuvWZKX3Eu75/K1/J9vW@s9o328cVc@TbfWmwvf0zgutHqizU418vJUvuwnEAStVbLt4PWguKBKUqYQQW7DnhIJcicCd1Vsw4WHZfQAhL5FrPCXs99AamZ9UDYk71Cdzuul7DEF/vJniCCpcGdKkO16LgaFgznrPD9HdXekqpKdGvTJPC8mZMZQNN8wyNND0t@dRDd@a4fZ7HMM4FSbzz1VnQdBTZFEGa9W@HKVcZlfMZFjC9kxsVN9zTlAisUKXSI4ecG4TM2KKqCUGx/KadhkDEhpAHPqijarcOtHey/OWw3xcCFfosip1HgsA1qp8b@9DLrnNPE3ywsatBqcIvC9wNlNYb/mdYERIUyATlDTT8B "C# (Visual C# Interactive Compiler) ‚Äì Try It Online")
OK - That was madness... I submitted an answer that used run-of-the-mill code-golf techniques. But when I saw what others were submitting, I realized there was a better way.
Each `(shape, rotation)` tuple is encoded into a C# string literal with duplicates removed. The encoding process captures each of these configurations in 2 bytes.
The lowest 3 bits store height and the next 3 store width. Since each of these values is never more than 4, they can be read directly from the 3 bits without any conversion. Here are some examples:
```
  W   H
010 010 (2x2)
010 011 (2x3)
001 100 (1x4)
011 010 (3x2)
100 001 (4x1)
```
Next, each column is stored in 3 bits. The most useful thing for me to store was the number of missing squares from the top and bottom of the column.
```
// missing squares per column
+------ 0 top / 0 bottom
|+----- 0 top / 1 bottom
||+---- 0 top / 1 bottom
|||
HHH (L-Shape)         HH (Jagged-Shape)
H                    HH
                     |||
1 top / 0 bottom ----+||
0 top / 0 bottom -----+|
0 top / 1 bottom ------+
```
There is never more than 2 squares missing from the top or bottom, and there is never more than 1 square missing from both at the same time. Given this set of constraints, I came up with the following encoding:
```
// column encoding of missing squares per column
000: none missing
100: 1 missing on top
101: 2 missing on top
010: 1 missing on bottom
011: 2 missing on bottom
110: 1 missing on top and bottom
```
Since we have to account for at most 3 columns with missing squares above or below, we can encode each `(shape, rotation)` tuple in 15 bits.
```
 C3  C2  C1   W   H
000 000 000 010 010 - 2x2 with no missing squares
000 000 000 100 001 - 4x1 with no missing squares
100 000 100 011 010 - 3x2 with missings square on top of columns 1 and 3
000 110 000 010 011 - 2x3 with missing squares on top and bottom of column 2
```
Lastly, duplicate shapes have been removed. The follow example show how multiple `(shape,rotation)` tuples can produce duplicate outputs for the same shape at different rotations:
```
// Square
HH  (0, 90, 180, 270)
HH
#-------------------------------#
// ZigZag
HH  (0, 180)    H  (90, 270)
 HH            HH
               H
#-------------------------------#
// T
 H  (0)        HHH  (180)
HHH             H
 H  (90)       H    (270)
HH             HH
 H             H
```
All unique outputs are determined and saved to a `byte[]` and converted to a C# string literal. In order to quickly lookup where a shape is based on `I` and `R`, the first 7 bytes of the array consist of an encoded lookup key.
Below is a link to the program that I used to compress the pieces.
[Try it online!](https://tio.run/##pVRdb9pIFH3Gv2IUaVtPIMRmadplPKnavuahUiutVMcPthnCBPBY9hBgC789e@/M2IaWVt1tkMj43HPPnPuB8/oqr@Xz8/U1KSdkKmaykFqqgqgZqedpKWrvKa1IyQuxIbLQcYKfrx6BvyPIAg6Ex3BgPoeBwd2/n/KDQeBo36j8sgYotOz/qxGeV/gPHn6g0Fb3axrB79dxRiM41Tgwz4O5B0EwIYUidZnmMG5AQkRCC5A0U0/CouGEjBytg4PwiJyJpdpY9JjcwqElm2SSFlMXwdBsXeRm87QildKpBoJdQfJXAJv5UAnrTk6g6nKtbdBzHah8dyCS2m4AVU2IWuuOi7CjqXajZRwkwztRPOg54KzJFWk@J0ulSiK1qFJjLZ1OoXKwt0GXqqFiIbkqJVSq52C7LCtVVhJLeEqXa0FmlVoR2dDhUmXlc7FcGnSmjH@y5cFgx7aRcobYtt@n3XBVvE06341p1sZRZscDtouaINuBQBtvNOJdwiV8xc09V9ur0OkczHcl9LqCtwDzDp53J2sdZTstbvGrNg46zKfMMsDUrZrNjuKInIRXanomjFO1k4Z1WcjioV0Gr2mMhKpk9JpJ1w98KcGW1G03xsY@wjUvY2memuRHSH6MxuyxbSaic1676gcbXndLwFpGxuf7zeUbdjKiBYxoxRbR5sWLBWgujgaEYa1KIJBMabjU4Vie@XmY7S69blisjgFI4kUShQxOIHYuCdROk@ZXAMHIbCKcjxJX3Ael2@DteBLQvQ9BOI/MGfFwj0j4NgSkScn2fBVF/k3/z8sFPVkDaHH8mPDMgh8rKNHPHKXmlV@bM5Jx8sN306lvdmT4Qa0LfT0yYewLTN4cZ8Q3okHCuTmECSW2gUDhoZEjYlmLM9xRQjvq6IjaoePGD66a8QMH@v02oJ/TfcgIb@q19dlCUMLURP3sj9GrG0p/FL2GaMc44C/HNuyDKp5EpYef1fu0FjfjTxrgB9eoz@pdVaU7n2Ka5aP19gH7Cg@42f/IshRTsOnKMz6GX2RpSAN/NVCU3zo7q73vq/6YXr4BZcsEH3mq7b0Oam@3N4g6T@0VF/cXFwx/fuZFZXKgQ7JwJqj31evlc0jJgezjicKS9HBmgHDy8j54Sb1er1Hso@R9AJq9driOeHGGaG7/jlmcYRYN8TSS45vrhImKf1fwMr@ThfBdiLLn538B "C# (Visual C# Interactive Compiler) ‚Äì Try It Online")
Less golfed and commented code:
```
// a: input list of (i,r,p) tuples
a=>{
  // create an output array that 4 more than
  // the largest position. this may result
  // in some trailing 0's
  var o=new int[a.Max(x=>x.Item3+4)];
  // iterate over each (i,r,p) tuple
  foreach(var(i,r,p)in a){
    // escaped string
    var b="\"4Tqz¬™!\0\0HS   √ì\0$\n\0!A @";
    // declare several variables that will be used later
    int m=0,n=b[i],t=0,
      // u is the decoded index into b for the current (i,r) pair
      u=n/8+r%(n%8),
      // convert 2 bytes from b into an encoded (shape,rotation) pair
      v=b[u*=2]<<8|b[u-1];
    // iterate over the columns, determining the top of the current
    // piece. The formula here is:
    //   piece_top = max(column_height + shape_height - shape_space_bottom)
    for(;t<v/8%8;m=m>n?m:n)
      n=o[p+t]+v%8-(n=(u=v>>6+3*t++)/2&1)-(n&u);
    // iterate over the columns again, saving the the new height
    // in each column. The formula here is:
    //   new_column_height = piece_top - shape_space_top
    for(;t-->0;)
      o[p+t]=m-(n=(u=v>>6+3*t)/4&1)-(n&u);
  }
  return o;
}
```
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 98 bytes
```
Ôº¶Œ∏¬´‚âî¬ß‚™™¬ß‚™™‚Äù)¬∂‚àß‚Ü∑"e¬´‚Ü®U‚àß0%3ÔºõD‚àß‚Åº~h‚äü‚Åµh/‚ÇÇdŒ¶‚Üó(EÔº¶‚Äù2‚äüŒπ1‚äüŒπŒ∑‚âî‚äüŒπŒ∂Ôº∑‚ÄπÔº¨œÖ‚Å∫Œ∂Ôº¨Œ∑‚äûœÖ‚Å∞‚âî‚åàÔº•Œ∑‚Åª¬ßœÖ‚Å∫Œ∂ŒªÔπ™Ôº©Œ∫¬≥ŒµÔº¶Ôº¨Œ∑¬ß‚âîœÖ‚Å∫Œ∂Œ∫‚Å∫Œµ‚äï√∑Ôº©¬ßŒ∑Œ∫¬≥¬ªÔº©œÖ
```
[Try it online!](https://tio.run/##bVBNT8MwDD2zX2H1lEpByte6IU4TXCYxaRLHqodqDUu0NB1tOqYhfntx6MYAkYPt92w/29mYst00pRuGl6YF8prC@@Rm0XV268kiLH2lj@R572z4gxKGj98JiZZlXCnJs7lgTPJ5xqVSPGNCSsGk4rPoGFdYhShTQiGSs4RCIpKUwrrZE5tikPBf0KT336uMJIVT5N6MdRrIk@46NH4bDOljo@s7cqJwpkyKD9Z9h1kK7IfYqjzauq/R74mhsLIeGy/n9VchF7dYNVXvGvJQdoHsEMs0sjrKff3YdRqM8v8I7S7baQpLv2l1rX3QFVn68GgPttKj/KXTxI7zKJzzMVm31oexpkdmGPI8l5inMC0o5IqCwAtjOKXAzyFmGYWsKIrh9uA@AQ "Charcoal ‚Äì Try It Online") Link is to verbose version of code. Takes input as an array of [P, R, I] values, where I is from 0 to 6, R is from 0 o 3 and P is also 0-indexed. Explanation:
```
Ôº¶Œ∏¬´
```
Loop over the input pieces.
```
‚âî¬ß‚™™¬ß‚™™‚Äù)¬∂‚àß‚Ü∑"e¬´‚Ü®U‚àß0%3ÔºõD‚àß‚Åº~h‚äü‚Åµh/‚ÇÇdŒ¶‚Üó(EÔº¶‚Äù2‚äüŒπ1‚äüŒπŒ∑
```
Extract the description of the current piece and rotation. (See below.)
```
‚âî‚äüŒπŒ∂
```
Extract the position.
```
Ôº∑‚ÄπÔº¨œÖ‚Å∫Œ∂Ôº¨Œ∑‚äûœÖ‚Å∞
```
Ensure that there is enough horizontal room to place the piece.
```
‚âî‚åàÔº•Œ∑‚Åª¬ßœÖ‚Å∫Œ∂ŒªÔπ™Ôº©Œ∫¬≥Œµ
```
Ensure that there is enough vertical room to place the piece.
```
Ôº¶Ôº¨Œ∑¬ß‚âîœÖ‚Å∫Œ∂Œ∫‚Å∫Œµ‚äï√∑Ôº©¬ßŒ∑Œ∫¬≥
```
Calculate the new heights of the affected columns.
```
¬ªÔº©œÖ
```
When all the pieces have been processed, output the final list of column heights on separate lines.
The compressed string represents the original string `00001923001061443168200318613441602332034173203014614341642430137`. Here the `2`s are `I` separators and the `1`s are `R` separators. The pieces therefore decode as follows:
```
P\R  0    1    2    3
0    0000 9
1    300  06   443  68
2    003  86   344  60
4    33
5    034  73
6    030  46   434  64
7    430  37
```
Missing `R` values are automatically filled cyclically by Charcoal. Each digit then maps to two values, overhang and total height, according to the following table:
```
\ O H
0 0 1
3 0 2
4 1 2
6 0 3
7 1 3
8 2 3
9 0 4
```
The overhang and total height relate to the column heights as follows: Given a piece that we want to place at a given position `e`, it may be possible to place the piece even though one of the columns is taller than `e`. The amount of spare space is given by the overhang. The new height of the column after placing the piece is simply the placed position plus the total height.
Example: Suppose we start by placing a `5` piece in column 1. Since there is nothing else yet the piece is therefore placed at position 0 and columns 1 and 3 now have height 1 while column 2 has height 2. We then want to place a `6` piece with `1` rotation in column 0. Here we can actually place this piece at position 0; although column 1 has a height of 1, the piece has an overhang of 1, and so there is enough space to place it. Column 0 ends up with a height of 2 and column 1 ends up with a height of 3.
]