Post History
JavaScript (Node.js), 892 bytes (not fully working) I=>{N=a=>Math.min(...a);X=a=>Math.max(...a) C=[];s=[t=[],[]];S="splice";p="push" c=I[P="map"](a=>a[P](p=>p-N(a))) d=X(c[1])-X(...
Answer
#4: Post edited
# [JavaScript (Node.js)](https://nodejs.org/), 894 bytes- ```js
- I=>{N=a=>Math.min(...a);X=a=>Math.max(...a)
C=[];s=[t=[],[]];S="splice";i=0;p="push"- c=I[P="map"](a=>a[P](p=>p-N(a)))
- d=X(c[1])-X(c[r=0])
d>0?r=1:d||c[1][P]((a,b)=>a==1&&C[p](c[0][b]))if(''+c[0].filter((a,b)=>C.indexOf(a)>=0&&c[1][b]!=1))r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b]))if(''+c[1].filter((a,b)=>C.indexOf(a)>=0&&c[0][b]!=1)&&X(c[0])==2)return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b)- if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c
- m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``])
- u=(''+s[0]).split`,`[P](a=>X(s[0])-a)
- v=(''+s[1]).split`,`[P](a=>+a)
- w=[]
- if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3
- while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0]
- m*=X([+t[J]``,+w[J]``]);return m}
- ```
[Attempt This Online!](https://ato.pxeger.com/run?1=zVbNcts2ED7kxmOPPaGyRwIskibkpHHEWfngkzOtkqkv7jCcEUWBEjoSqZKQRI0iv0gvPrQvlafpAqT-7HQm00ursQXu37ff7gKg_vgzzUbi6cur75JFGiuZpaQQ8yiPlHj4lRaT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OGZCbZx1BIRjnFdYOHF06Ryx0On6lY47z89fG5ZDfuL2xDKkT9KqCk9i3VexJhuu6yhPHdy_xOp6WTzT8Wc86hj5q8LWJ7ww9omwq3Gk2pmZQ5m42jzYx1wEet8H5xjy2-bZ7vmmRFp7juYgUfXw0lykGc68Or7YNc05MdTTDv-35Bvf14ReLjmJsO2CuPnKDT-kAX4PWf0Hr_f2HvluoXKZj_dNh_JLlN9LUT9D7WrxbZLmijPnVEXl6qta_AQ) (Add input in the footer)- I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_
**Definitely** can still be optimized, there's no way 895 characters is the limit.- <details>
<summary><h3>How does it work? <s>(Assuming it works)</s></h3>- </summary>
- Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique).
- After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method.
- Ah! Here's the better method.
- * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down.
- * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers.
- * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay!
- For a better picture, let's label the coordinates of the 10th-13th tetrominoes:
- ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png)
- We get
- ```
- [[0,0], [1,0], [3,0], [2,1]],
- [[0,0], [2,0], [1,1], [3,1]],
- [[0,0], [3,0], [1,1], [2,1]],
- [[0,0], [1,0], [2,1], [3,1]].
- ```
- _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_
- Now, mushing the X- and Y-coordinates would look like this:
- ```
- X: [0,1,3,2] Y: [0,0,0,1]
- X: [0,2,1,3] Y: [0,0,1,1]
- X: [0,3,1,2] Y: [0,0,1,1]
- X: [0,1,2,3] Y: [0,0,1,1]
- ```
- _(Also note that order **really, really** matters here)_
- Anyway, when we flip the tetrominoes upside-down:
- ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png)
- The coordinates become
- ```
- [[2,0], [0,1], [1,1], [3,1]],
- [[1,0], [3,0], [0,1], [2,1]],
- [[1,0], [2,0], [0,1], [3,1]],
- [[2,0], [3,0], [0,1], [1,1]].
- ```
- What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them!
- _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_
- Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging.
- The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_
- Anyway, this means we can get the flipped version of any tetromino. Progress!
- What to do next?
- * From those flipped tetrominoes, get their mushed together X- and Y-coordinates.
- * Compare them to the original tetromino. Use the one with the greatest value.
- _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_
- ### Rotating
- So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate?
- My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't.
- For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well!
- However, how about the square-ish ones where its width is the same as its height?
- Let's take a look at this guy, the 16th tetromino:
- ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png)
- Let's call it Yancy. ~~Why not?~~
- ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_.
- Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :)
- However, take Yancy's cousin Yandy _(who's quite odd)_:
- ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png)
- Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?**
- Well... after some pondering, here's what I figured out:
- * We can think of rotation as a diagonal mirror, something like this:
- ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png)
- _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_
- * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa.
- * The only thing left to do is to rearrange them, and **we're done!**
- Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems.
- Oh wait...
- Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂
- After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself.
- _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_
- </details>
- # [JavaScript (Node.js)](https://nodejs.org/), 892 bytes (not fully working)
- ```js
- I=>{N=a=>Math.min(...a);X=a=>Math.max(...a)
- C=[];s=[t=[],[]];S="splice";p="push"
- c=I[P="map"](a=>a[P](p=>p-N(a)))
- d=X(c[1])-X(c[r=0])
- d>0?r=1:d||c[1][P]((a,b)=>a-1||C[p](c[i=0][b]))
- if(''+c[0].filter((a,b)=>C[O="indexOf"](a)>=0&&c[1][b]!=1)){r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b]))
- if(''+c[1].filter((a,b)=>C[O](a)>=0&&c[0][b]!=1)&&X(c[0])==2)
- return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b)}
- if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c
- m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``])
- u=(''+s[0]).split`,`[P](a=>X(s[0])-a)
- v=(''+s[1]).split`,`[P](a=>+a)
- w=[]
- if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3
- while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0]
- m*=X([+t[J]``,+w[J]``]);return m}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=zVjLbuO6GV6cHbso0Cdg7UEsjmWPqLtiMLOY1Ry0mYPOZgodAVZkOVbhyD6W7DhIfF6km1m0L3WeprzJJikXKLppgySSPv73C39Kf_9HvVmU33_74Q_LfV201aaGTbnNd3lbfvur1azybYleAYTrsoVHSGCa2fBFXgsGOPTKAGdGqZabHbQY6bqqS7hZQi5g2mzXVWuNfq5HiAuDknXG789MxSrfMSbGLOkgrJbQ4guEEDgajs4LEB6n232zsoojmp2xF4m9nLGTvBbH8VhgAilexDN72pXtflfD9Eidy2bgBMA5GsVms1tUdd5WyxcjHmyp-T-JBbdF-J4WR2ZH9t9EgIvhAfjwAS7hc97AdlXCczQ-U4pFuYB5C5fVrmlt-LyqihVcbMqmHrXwsTqUcF9Xv-xLuM4fynUzhX8qly2sWrgqdyXM65fn_AXeIrAkFbl7fSJ_ztuVfU-wXZOc3D1Nn6ramk6nObKPEsiPApjR6FgFi0pFPV-T2irQrCAFpdhaR3J3nKzR7ECfd-ViX5SWldsPiNzl4wf0wZ_dvydHKz3YR8o1OWTovVUQMsK2Y7s2Hn10bzECJxmGexqAR_LPfbucxL_98PaZGnrPjGG2XgycfbtgnY3gE0mzWUPSll7tNMtmX8mA5bwoB7MtGbAMDUBBPqc_kQG1e5BZVEae_pRZW3K3ndxbOUIILMg3q0hxhibsuiNORrE75-OO4NvF2xtbYiydhxP89vYp3WaUtqK06UNGZVRLazQaF6mTTZfVui13Hfmn9AsZVPWiPH5ZMv3ojjg3N1zmQ_ZHgmlhUj0288Rm7KomQvDNjVSFDUX4iiJFvNOJv7lhTlGXCHER6Cqv59LHC8tHfOvcKo_OrYuuZPnETNkhWpLrsvMdvVKMs1YZIfdCMSoUVa9NiicPmWienJIh6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gfhc_0-nXnS4GDYT7sb6RiXF_csTLT0CnGeo6VSHoRwzxbP8EScAOmcVtl8JUOix7B3nmz8KVRiKXgi41yDvStnDWmDHBZGZ_jqYUmUgY_7QfJdPsfUUxufz3oV0_k8NEykw7l3LuQj2jDPj640n2-2CgcTjV3IDLRThjxqyr1W20AwH9rQTFrgqQin880dCbOhbfZfEBqNFfQPgDiIgVk6QdInk6P7SvJCbEwy4Uvo9scODr1rbRN2s1DXGFwZepiNdPP8iMPIECBIY90sAeqHcmFW5FzJupjxRsl0U94g9bQMC5n65izZg57t0cWhbMY-EbF3ss26nK43jxZ_M-OfYvitDfkXBvp-PX_3ym_H-HT77nUER_TNfVvmrfXrr_zbCWXGjmQX74looi1JbkR_T-9e6Yvs5QMl40LoNEdT9o49_7meI2rY_8KsH79-uZ827a6qH9mXwse-lf-hmeyO3F3jnzabXWshNBPvxN-_i-u_AA) (Add input in the footer)
- I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_
- **Definitely** can still be optimized, there's no way 892 bytes is the limit.
- <details>
- <summary><h3>How does it work? <s>(Assuming it works, which it doesn't fully yet)</s></h3>
- </summary>
- Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique).
- After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method.
- Ah! Here's the better method.
- * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down.
- * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers.
- * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay!
- For a better picture, let's label the coordinates of the 10th-13th tetrominoes:
- ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png)
- We get
- ```
- [[0,0], [1,0], [3,0], [2,1]],
- [[0,0], [2,0], [1,1], [3,1]],
- [[0,0], [3,0], [1,1], [2,1]],
- [[0,0], [1,0], [2,1], [3,1]].
- ```
- _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_
- Now, mushing the X- and Y-coordinates would look like this:
- ```
- X: [0,1,3,2] Y: [0,0,0,1]
- X: [0,2,1,3] Y: [0,0,1,1]
- X: [0,3,1,2] Y: [0,0,1,1]
- X: [0,1,2,3] Y: [0,0,1,1]
- ```
- _(Also note that order **really, really** matters here)_
- Anyway, when we flip the tetrominoes upside-down:
- ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png)
- The coordinates become
- ```
- [[2,0], [0,1], [1,1], [3,1]],
- [[1,0], [3,0], [0,1], [2,1]],
- [[1,0], [2,0], [0,1], [3,1]],
- [[2,0], [3,0], [0,1], [1,1]].
- ```
- What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them!
- _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_
- Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging.
- The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_
- Anyway, this means we can get the flipped version of any tetromino. Progress!
- What to do next?
- * From those flipped tetrominoes, get their mushed together X- and Y-coordinates.
- * Compare them to the original tetromino. Use the one with the greatest value.
- _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_
- ### Rotating
- So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate?
- My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't.
- For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well!
- However, how about the square-ish ones where its width is the same as its height?
- Let's take a look at this guy, the 16th tetromino:
- ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png)
- Let's call it Yancy. ~~Why not?~~
- ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_.
- Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :)
- However, take Yancy's cousin Yandy _(who's quite odd)_:
- ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png)
- Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?**
- Well... after some pondering, here's what I figured out:
- * We can think of rotation as a diagonal mirror, something like this:
- ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png)
- _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_
- * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa.
- * The only thing left to do is to rearrange them, and **we're done!**
- Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems.
- Oh wait...
- Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂
- After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself.
- _**Update: I tested every possible transformation, and there were errors in tetrominoes 4-9, 11, 13, 21, and 22. Sigh.**_
- _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_
- </details>
#3: Post edited
- # [JavaScript (Node.js)](https://nodejs.org/), 894 bytes
- ```js
- I=>{N=a=>Math.min(...a);X=a=>Math.max(...a)
- C=[];s=[t=[],[]];S="splice";i=0;p="push"
- c=I[P="map"](a=>a[P](p=>p-N(a)))
- d=X(c[1])-X(c[r=0])
- d>0?r=1:d||c[1][P]((a,b)=>a==1&&C[p](c[0][b]))
- if(''+c[0].filter((a,b)=>C.indexOf(a)>=0&&c[1][b]!=1))
- r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b]))
- if(''+c[1].filter((a,b)=>C.indexOf(a)>=0&&c[0][b]!=1)&&X(c[0])==2)
- return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b)
- if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c
- m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``])
- u=(''+s[0]).split`,`[P](a=>X(s[0])-a)
- v=(''+s[1]).split`,`[P](a=>+a)
- w=[]
- if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3
- while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0]
- m*=X([+t[J]``,+w[J]``]);return m}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=zVbNcts2ED7kxmOPPaGyRwIskibkpHHEWfngkzOtkqkv7jCcEUWBEjoSqZKQRI0iv0gvPrQvlafpAqT-7HQm00ursQXu37ff7gKg_vgzzUbi6cur75JFGiuZpaQQ8yiPlHj4lRaTaC7YxiJkKhQpCZAgtMm6XmOt8HDVCs9HryTLCdWuU5kKkiXEALjFfCoVbX1KW8yAkTrUN8_7oHgS5TpIB9d-hMiEUGMAANI6a-0NhJTufFFMaFwyf69b17r1Xret17hstytdpYnXlaylXKhFnpKgxOJC39pa1r4bcZblI5lGSibrZ_3QpuJ_0gvDpao9iEvNI_w3HTAwpgGXlyQhq6ggaiLIvht36DESIxIpksi8UDZZTWQ8IaNMFGlLkbFcCrJI5e8LQabRUEwLl_wkEkWkIhORCxKl61W0Jl1mJSCht5nBz5Ga2H3gdgoR9GbuTKbUdd2I2WWtiMpK4WN3aKy7IrHyKaQ0Zn4MMXrMaQm90pkyf4lyLkaLWFAa2UMGvag9ZJev_f4FlDRY2iVGOcuQXdAYoMVtz-7YvHXT6XJmbes29LEBY_hroRLn-surxzsk2tdkNNcDQf_hoNtxtG4hCP0CAoWrHYShfw8NPfNYNHwJnj-Hhp5Sw4rhLvgIDeTeCCniRMHHkM6hN3f6NGKMWSN4oHHAQ-boNQcvRF3Pu8mBd0efP2uTDtlVCcCbzdtgHqKzFwbDECFkQluttpbdRE6VyHfet65MR6L8kGCqHnjNpkEbhj8AxzDMYOs6bIP0Dzn4sxz8G3J4uxzN5oOhyQA6mK_efM8qcvjNIeSGd73ukeh1O-wrg9Z0coabcip2pbMN6kykDAH6VV4WH2XaFAF3hmF1fCJ0Y1j5MAzuQyptzrbMluBwX7bbW8QsMB7TFxBbMxxRwPFz8UALMyr9HfwCjVwsRV4IHC0L3kPjt0ymjXAwsNuVg1GjjCNdAK1BWXU5DOyB5oZbQoOi2sFttay9-EuvNppXOC1d-qwioKEPTTBRugnGpptQs2VKj7KoWsPsogaMdoUf1S3hytoDLgzasoZaMrbSOAsDstgF28v9k4SlOxXpWE186Ti6hwobqEBntmYXuoltZUjb7VXdF7_eFLPt7hh-H2dpoYgShTK37sA6ww_h1sAm-hlvtA4uOxHlK4vsRH3fvdbaI-83aD62_6jdifk_iXuL-tpilNpMro18dqx6Z_AOGZCbZx1BIRjnFdYOHF06Ryx0On6lY47z89fG5ZDfuL2xDKkT9KqCk9i3VexJhuu6yhPHdy_xOp6WTzT8Wc86hj5q8LWJ7ww9omwq3Gk2pmZQ5m42jzYx1wEet8H5xjy2-bZ7vmmRFp7juYgUfXw0lykGc68Or7YNc05MdTTDv-35Bvf14ReLjmJsO2CuPnKDT-kAX4PWf0Hr_f2HvluoXKZj_dNh_JLlN9LUT9D7WrxbZLmijPnVEXl6qta_AQ) (Add input in the footer)
- I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_
- **Definitely** can still be optimized, there's no way 895 characters is the limit.
- <details>
<summary><h3>How does it work? <s>(Assuming this works)</s></h3>- </summary>
- Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique).
- After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method.
- Ah! Here's the better method.
- * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down.
- * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers.
- * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay!
- For a better picture, let's label the coordinates of the 10th-13th tetrominoes:
- ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png)
- We get
- ```
- [[0,0], [1,0], [3,0], [2,1]],
- [[0,0], [2,0], [1,1], [3,1]],
- [[0,0], [3,0], [1,1], [2,1]],
- [[0,0], [1,0], [2,1], [3,1]].
- ```
- _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_
- Now, mushing the X- and Y-coordinates would look like this:
- ```
- X: [0,1,3,2] Y: [0,0,0,1]
- X: [0,2,1,3] Y: [0,0,1,1]
- X: [0,3,1,2] Y: [0,0,1,1]
- X: [0,1,2,3] Y: [0,0,1,1]
- ```
- _(Also note that order **really, really** matters here)_
- Anyway, when we flip the tetrominoes upside-down:
- ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png)
- The coordinates become
- ```
- [[2,0], [0,1], [1,1], [3,1]],
- [[1,0], [3,0], [0,1], [2,1]],
- [[1,0], [2,0], [0,1], [3,1]],
- [[2,0], [3,0], [0,1], [1,1]].
- ```
- What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them!
- _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_
- Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging.
- The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_
- Anyway, this means we can get the flipped version of any tetromino. Progress!
- What to do next?
- * From those flipped tetrominoes, get their mushed together X- and Y-coordinates.
- * Compare them to the original tetromino. Use the one with the greatest value.
- _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_
- ### Rotating
- So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate?
- My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't.
- For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well!
- However, how about the square-ish ones where its width is the same as its height?
- Let's take a look at this guy, the 16th tetromino:
- ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png)
- Let's call it Yancy. ~~Why not?~~
- ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_.
- Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :)
- However, take Yancy's cousin Yandy _(who's quite odd)_:
- ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png)
- Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?**
- Well... after some pondering, here's what I figured out:
- * We can think of rotation as a diagonal mirror, something like this:
- ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png)
- _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_
- * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa.
- * The only thing left to do is to rearrange them, and **we're done!**
- Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems.
- Oh wait...
- Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂
- After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself.
- _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_
- </details>
- # [JavaScript (Node.js)](https://nodejs.org/), 894 bytes
- ```js
- I=>{N=a=>Math.min(...a);X=a=>Math.max(...a)
- C=[];s=[t=[],[]];S="splice";i=0;p="push"
- c=I[P="map"](a=>a[P](p=>p-N(a)))
- d=X(c[1])-X(c[r=0])
- d>0?r=1:d||c[1][P]((a,b)=>a==1&&C[p](c[0][b]))
- if(''+c[0].filter((a,b)=>C.indexOf(a)>=0&&c[1][b]!=1))
- r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b]))
- if(''+c[1].filter((a,b)=>C.indexOf(a)>=0&&c[0][b]!=1)&&X(c[0])==2)
- return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b)
- if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c
- m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``])
- u=(''+s[0]).split`,`[P](a=>X(s[0])-a)
- v=(''+s[1]).split`,`[P](a=>+a)
- w=[]
- if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3
- while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0]
- m*=X([+t[J]``,+w[J]``]);return m}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=zVbNcts2ED7kxmOPPaGyRwIskibkpHHEWfngkzOtkqkv7jCcEUWBEjoSqZKQRI0iv0gvPrQvlafpAqT-7HQm00ursQXu37ff7gKg_vgzzUbi6cur75JFGiuZpaQQ8yiPlHj4lRaTaC7YxiJkKhQpCZAgtMm6XmOt8HDVCs9HryTLCdWuU5kKkiXEALjFfCoVbX1KW8yAkTrUN8_7oHgS5TpIB9d-hMiEUGMAANI6a-0NhJTufFFMaFwyf69b17r1Xret17hstytdpYnXlaylXKhFnpKgxOJC39pa1r4bcZblI5lGSibrZ_3QpuJ_0gvDpao9iEvNI_w3HTAw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-kAX4PWf0Hr_f2HvluoXKZj_dNh_JLlN9LUT9D7WrxbZLmijPnVEXl6qta_AQ) (Add input in the footer)
- I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_
- **Definitely** can still be optimized, there's no way 895 characters is the limit.
- <details>
- <summary><h3>How does it work? <s>(Assuming it works)</s></h3>
- </summary>
- Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique).
- After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method.
- Ah! Here's the better method.
- * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down.
- * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers.
- * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay!
- For a better picture, let's label the coordinates of the 10th-13th tetrominoes:
- ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png)
- We get
- ```
- [[0,0], [1,0], [3,0], [2,1]],
- [[0,0], [2,0], [1,1], [3,1]],
- [[0,0], [3,0], [1,1], [2,1]],
- [[0,0], [1,0], [2,1], [3,1]].
- ```
- _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_
- Now, mushing the X- and Y-coordinates would look like this:
- ```
- X: [0,1,3,2] Y: [0,0,0,1]
- X: [0,2,1,3] Y: [0,0,1,1]
- X: [0,3,1,2] Y: [0,0,1,1]
- X: [0,1,2,3] Y: [0,0,1,1]
- ```
- _(Also note that order **really, really** matters here)_
- Anyway, when we flip the tetrominoes upside-down:
- ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png)
- The coordinates become
- ```
- [[2,0], [0,1], [1,1], [3,1]],
- [[1,0], [3,0], [0,1], [2,1]],
- [[1,0], [2,0], [0,1], [3,1]],
- [[2,0], [3,0], [0,1], [1,1]].
- ```
- What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them!
- _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_
- Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging.
- The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_
- Anyway, this means we can get the flipped version of any tetromino. Progress!
- What to do next?
- * From those flipped tetrominoes, get their mushed together X- and Y-coordinates.
- * Compare them to the original tetromino. Use the one with the greatest value.
- _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_
- ### Rotating
- So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate?
- My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't.
- For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well!
- However, how about the square-ish ones where its width is the same as its height?
- Let's take a look at this guy, the 16th tetromino:
- ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png)
- Let's call it Yancy. ~~Why not?~~
- ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_.
- Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :)
- However, take Yancy's cousin Yandy _(who's quite odd)_:
- ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png)
- Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?**
- Well... after some pondering, here's what I figured out:
- * We can think of rotation as a diagonal mirror, something like this:
- ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png)
- _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_
- * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa.
- * The only thing left to do is to rearrange them, and **we're done!**
- Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems.
- Oh wait...
- Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂
- After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself.
- _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_
- </details>
#2: Post edited
- # [JavaScript (Node.js)](https://nodejs.org/), 894 bytes
- ```js
- I=>{N=a=>Math.min(...a);X=a=>Math.max(...a)
- C=[];s=[t=[],[]];S="splice";i=0;p="push"
- c=I[P="map"](a=>a[P](p=>p-N(a)))
- d=X(c[1])-X(c[r=0])
- d>0?r=1:d||c[1][P]((a,b)=>a==1&&C[p](c[0][b]))
- if(''+c[0].filter((a,b)=>C.indexOf(a)>=0&&c[1][b]!=1))
- r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b]))
- if(''+c[1].filter((a,b)=>C.indexOf(a)>=0&&c[0][b]!=1)&&X(c[0])==2)
- return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b)
- if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c
- m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``])
- u=(''+s[0]).split`,`[P](a=>X(s[0])-a)
- v=(''+s[1]).split`,`[P](a=>+a)
- w=[]
- if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3
- while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0]
- m*=X([+t[J]``,+w[J]``]);return m}
- ```
[Attempt This Online!](https://ato.pxeger.com/run?1=zVbNcts2ED7kxmOPPaGyRwIskibkpHHEWf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7VXdF7_eFLPt7hh-H2dpoYgShTK37sA6ww_h1sAm-hlvtA4uOxHlK4vsRH3fvdbaI-83aD62_6jdifk_iXuL-tpilNpMro18dqx6Z_AOGZCbZx1BIRjnFdYOHF06Ryx0On6lY47z89fG5ZDfuL2xDKkT9KqCk9i3VexJhuu6yhPHdy_xOp6WTzT8Wc86hj5q8LWJ7ww9omwq3Gk2pmZQ5m42jzYx1wEet8H5xjy2-bZ7vmmRFp7juYgUfXw0lykGc68Or7YNc05MdTTDv-35Bvf14ReLjmJsO2CuPnKDT-kAX4PWf0Hr_f2HvluoXKZj_dNh_JLlN9LUT9D7WrxbZLmijPnVEXl6qta_AQ) (add input in the footer)- I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_
- **Definitely** can still be optimized, there's no way 895 characters is the limit.
- <details>
- <summary><h3>How does it work? <s>(Assuming this works)</s></h3>
- </summary>
- Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique).
- After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method.
- Ah! Here's the better method.
- * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down.
- * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers.
- * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay!
- For a better picture, let's label the coordinates of the 10th-13th tetrominoes:
- ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png)
- We get
- ```
- [[0,0], [1,0], [3,0], [2,1]],
- [[0,0], [2,0], [1,1], [3,1]],
- [[0,0], [3,0], [1,1], [2,1]],
- [[0,0], [1,0], [2,1], [3,1]].
- ```
- _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_
- Now, mushing the X- and Y-coordinates would look like this:
- ```
- X: [0,1,3,2] Y: [0,0,0,1]
X: [0,2,1,1] Y: [0,0,1,1]- X: [0,3,1,2] Y: [0,0,1,1]
- X: [0,1,2,3] Y: [0,0,1,1]
- ```
- _(Also note that order **really, really** matters here)_
- Anyway, when we flip the tetrominoes upside-down:
- ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png)
- The coordinates become
- ```
- [[2,0], [0,1], [1,1], [3,1]],
- [[1,0], [3,0], [0,1], [2,1]],
- [[1,0], [2,0], [0,1], [3,1]],
- [[2,0], [3,0], [0,1], [1,1]].
- ```
- What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them!
- _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_
- Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging.
- The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_
- Anyway, this means we can get the flipped version of any tetromino. Progress!
- What to do next?
- * From those flipped tetrominoes, get their mushed together X- and Y-coordinates.
- * Compare them to the original tetromino. Use the one with the greatest value.
- _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_
- ### Rotating
- So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate?
- My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't.
- For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well!
- However, how about the square-ish ones where its width is the same as its height?
- Let's take a look at this guy, the 16th tetromino:
- ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png)
- Let's call it Yancy. ~~Why not?~~
- ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_.
- Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :)
- However, take Yancy's cousin Yandy _(who's quite odd)_:
- ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png)
- Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?**
- Well... after some pondering, here's what I figured out:
- * We can think of rotation as a diagonal mirror, something like this:
- ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png)
- _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_
- * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa.
- * The only thing left to do is to rearrange them, and **we're done!**
- Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems.
- Oh wait...
- Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂
- After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself.
- _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_
- </details>
- # [JavaScript (Node.js)](https://nodejs.org/), 894 bytes
- ```js
- I=>{N=a=>Math.min(...a);X=a=>Math.max(...a)
- C=[];s=[t=[],[]];S="splice";i=0;p="push"
- c=I[P="map"](a=>a[P](p=>p-N(a)))
- d=X(c[1])-X(c[r=0])
- d>0?r=1:d||c[1][P]((a,b)=>a==1&&C[p](c[0][b]))
- if(''+c[0].filter((a,b)=>C.indexOf(a)>=0&&c[1][b]!=1))
- r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b]))
- if(''+c[1].filter((a,b)=>C.indexOf(a)>=0&&c[0][b]!=1)&&X(c[0])==2)
- return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b)
- if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c
- m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``])
- u=(''+s[0]).split`,`[P](a=>X(s[0])-a)
- v=(''+s[1]).split`,`[P](a=>+a)
- w=[]
- if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3
- while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0]
- m*=X([+t[J]``,+w[J]``]);return m}
- ```
- [Attempt This Online!](https://ato.pxeger.com/run?1=zVbNcts2ED7kxmOPPaGyRwIskibkpHHEWfngkzOtkqkv7jCcEUWBEjoSqZKQRI0iv0gvPrQvlafpAqT-7HQm00ursQXu37ff7gKg_vgzzUbi6cur75JFGiuZpaQQ8yiPlHj4lRaTaC7YxiJkKhQpCZAgtMm6XmOt8HDVCs9HryTLCdWuU5kKkiXEALjFfCoVbX1KW8yAkTrUN8_7oHgS5TpIB9d-hMiEUGMAANI6a-0NhJTufFFMaFwyf69b17r1Xret17hstytdpYnXlaylXKhFnpKgxOJC39pa1r4bcZblI5lGSibrZ_3QpuJ_0gvDpao9iEvNI_w3HTAwpgGXlyQhq6ggaiLIvht36DESIxIpksi8UDZZTWQ8IaNMFGlLkbFcCrJI5e8LQabRUEwLl_wkEkWkIhORCxKl61W0Jl1mJSCht5nBz5Ga2H3gdgoR9GbuTKbUdd2I2WWtiMpK4WN3aKy7IrHyKaQ0Zn4MMXrMaQm90pkyf4lyLkaLWFAa2UMGvag9ZJev_f4FlDRY2iVGOcuQXdAYoMVtz-7YvHXT6XJmbes29LEBY_hroRLn-surxzsk2tdkNNcDQf_hoNtxtG4hCP0CAoWrHYShfw8NPfNYNHwJnj-Hhp5Sw4rhLvgIDeTeCCniRMHHkM6hN3f6NGKMWSN4oHHAQ-boNQcvRF3Pu8mBd0efP2uTDtlVCcCbzdtgHqKzFwbDECFkQluttpbdRE6VyHfet65MR6L8kGCqHnjNpkEbhj8AxzDMYOs6bIP0Dzn4sxz8G3J4uxzN5oOhyQA6mK_efM8qcvjNIeSGd73ukeh1O-wrg9Z0coabcip2pbMN6kykDAH6VV4WH2XaFAF3hmF1fCJ0Y1j5MAzuQyptzrbMluBwX7bbW8QsMB7TFxBbMxxRwPFz8UALMyr9HfwCjVwsRV4IHC0L3kPjt0ymjXAwsNuVg1GjjCNdAK1BWXU5DOyB5oZbQoOi2sFttay9-EuvNppXOC1d-qwioKEPTTBRugnGpptQs2VKj7KoWsPsogaMdoUf1S3hytoDLgzasoZaMrbSOAsDstgF28v9k4SlOxXpWE186Ti6hwobqEBntmYXuoltZUjb7VXdF7_eFLPt7hh-H2dpoYgShTK37sA6ww_h1sAm-hlvtA4uOxHlK4vsRH3fvdbaI-83aD62_6jdifk_iXuL-tpilNpMro18dqx6Z_AOGZCbZx1BIRjnFdYOHF06Ryx0On6lY47z89fG5ZDfuL2xDKkT9KqCk9i3VexJhuu6yhPHdy_xOp6WTzT8Wc86hj5q8LWJ7ww9omwq3Gk2pmZQ5m42jzYx1wEet8H5xjy2-bZ7vmmRFp7juYgUfXw0lykGc68Or7YNc05MdTTDv-35Bvf14ReLjmJsO2CuPnKDT-kAX4PWf0Hr_f2HvluoXKZj_dNh_JLlN9LUT9D7WrxbZLmijPnVEXl6qta_AQ) (Add input in the footer)
- I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_
- **Definitely** can still be optimized, there's no way 895 characters is the limit.
- <details>
- <summary><h3>How does it work? <s>(Assuming this works)</s></h3>
- </summary>
- Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique).
- After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method.
- Ah! Here's the better method.
- * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down.
- * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers.
- * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay!
- For a better picture, let's label the coordinates of the 10th-13th tetrominoes:
- ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png)
- We get
- ```
- [[0,0], [1,0], [3,0], [2,1]],
- [[0,0], [2,0], [1,1], [3,1]],
- [[0,0], [3,0], [1,1], [2,1]],
- [[0,0], [1,0], [2,1], [3,1]].
- ```
- _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_
- Now, mushing the X- and Y-coordinates would look like this:
- ```
- X: [0,1,3,2] Y: [0,0,0,1]
- X: [0,2,1,3] Y: [0,0,1,1]
- X: [0,3,1,2] Y: [0,0,1,1]
- X: [0,1,2,3] Y: [0,0,1,1]
- ```
- _(Also note that order **really, really** matters here)_
- Anyway, when we flip the tetrominoes upside-down:
- ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png)
- The coordinates become
- ```
- [[2,0], [0,1], [1,1], [3,1]],
- [[1,0], [3,0], [0,1], [2,1]],
- [[1,0], [2,0], [0,1], [3,1]],
- [[2,0], [3,0], [0,1], [1,1]].
- ```
- What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them!
- _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_
- Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging.
- The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_
- Anyway, this means we can get the flipped version of any tetromino. Progress!
- What to do next?
- * From those flipped tetrominoes, get their mushed together X- and Y-coordinates.
- * Compare them to the original tetromino. Use the one with the greatest value.
- _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_
- ### Rotating
- So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate?
- My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't.
- For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well!
- However, how about the square-ish ones where its width is the same as its height?
- Let's take a look at this guy, the 16th tetromino:
- ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png)
- Let's call it Yancy. ~~Why not?~~
- ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_.
- Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :)
- However, take Yancy's cousin Yandy _(who's quite odd)_:
- ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png)
- Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?**
- Well... after some pondering, here's what I figured out:
- * We can think of rotation as a diagonal mirror, something like this:
- ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png)
- _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_
- * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa.
- * The only thing left to do is to rearrange them, and **we're done!**
- Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems.
- Oh wait...
- Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂
- After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself.
- _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_
- </details>
#1: Initial revision
# [JavaScript (Node.js)](https://nodejs.org/), 894 bytes ```js I=>{N=a=>Math.min(...a);X=a=>Math.max(...a) C=[];s=[t=[],[]];S="splice";i=0;p="push" c=I[P="map"](a=>a[P](p=>p-N(a))) d=X(c[1])-X(c[r=0]) d>0?r=1:d||c[1][P]((a,b)=>a==1&&C[p](c[0][b])) if(''+c[0].filter((a,b)=>C.indexOf(a)>=0&&c[1][b]!=1)) r=1,C=[],c[0][P]((a,b)=>a==1&&C[p](c[1][b])) if(''+c[1].filter((a,b)=>C.indexOf(a)>=0&&c[0][b]!=1)&&X(c[0])==2) return c[1][P]((a,b)=>a-1?c[0][b]!=1?1:0:c[0][b]!=1?0:2).reduce((a,b)=>a+b) if(r)while(''+c[0]){if(c[0][i]==N(c[0]))c[P]((a,b)=>{s[1-b].push(a[i]),c[b][S](i,1)}),i=-1;i++}''+s[0]?0:s=c m=X([1111*X(s[1])-s[1][R="reverse"]()[J="join"]``,+s[1][R]()[J]``]) u=(''+s[0]).split`,`[P](a=>X(s[0])-a) v=(''+s[1]).split`,`[P](a=>+a) w=[] if(m-s[1][J]``)while(''+s[1]){if(s[1][i]==X(s[1]))t[p](s[0][i]),s[P](a=>a[S](i,1)),i=-1;i++}i=3 while(''+u){if(v[i]==X(v))w[p](u[i]),u[S](i,1),v[S](i,1),i=v.length;i--}''+t?0:t=s[0] m*=X([+t[J]``,+w[J]``]);return m} ``` [Attempt This Online!](https://ato.pxeger.com/run?1=zVbNcts2ED7kxmOPPaGyRwIskibkpHHEWfngkzOtkqkv7jCcEUWBEjoSqZKQRI0iv0gvPrQvlafpAqT-7HQm00ursQXu37ff7gKg_vgzzUbi6cur75JFGiuZpaQQ8yiPlHj4lRaTaC7YxiJkKhQpCZAgtMm6XmOt8HDVCs9HryTLCdWuU5kKkiXEALjFfCoVbX1KW8yAkTrUN8_7oHgS5TpIB9d-hMiEUGMAANI6a-0NhJTufFFMaFwyf69b17r1Xret17hstytdpYnXlaylXKhFnpKgxOJC39pa1r4bcZblI5lGSibrZ_3QpuJ_0gvDpao9iEvNI_w3HTAwpgGXlyQhq6ggaiLIvht36DESIxIpksi8UDZZTWQ8IaNMFGlLkbFcCrJI5e8LQabRUEwLl_wkEkWkIhORCxKl61W0Jl1mJSCht5nBz5Ga2H3gdgoR9GbuTKbUdd2I2WWtiMpK4WN3aKy7IrHyKaQ0Zn4MMXrMaQm90pkyf4lyLkaLWFAa2UMGvag9ZJev_f4FlDRY2iVGOcuQXdAYoMVtz-7YvHXT6XJmbes29LEBY_hroRLn-surxzsk2tdkNNcDQf_hoNtxtG4hCP0CAoWrHYShfw8NPfNYNHwJnj-Hhp5Sw4rhLvgIDeTeCCniRMHHkM6hN3f6NGKMWSN4oHHAQ-boNQcvRF3Pu8mBd0efP2uTDtlVCcCbzdtgHqKzFwbDECFkQluttpbdRE6VyHfet65MR6L8kGCqHnjNpkEbhj8AxzDMYOs6bIP0Dzn4sxz8G3J4uxzN5oOhyQA6mK_efM8qcvjNIeSGd73ukeh1O-wrg9Z0coabcip2pbMN6kykDAH6VV4WH2XaFAF3hmF1fCJ0Y1j5MAzuQyptzrbMluBwX7bbW8QsMB7TFxBbMxxRwPFz8UALMyr9HfwCjVwsRV4IHC0L3kPjt0ymjXAwsNuVg1GjjCNdAK1BWXU5DOyB5oZbQoOi2sFttay9-EuvNppXOC1d-qwioKEPTTBRugnGpptQs2VKj7KoWsPsogaMdoUf1S3hytoDLgzasoZaMrbSOAsDstgF28v9k4SlOxXpWE186Ti6hwobqEBntmYXuoltZUjb7VXdF7_eFLPt7hh-H2dpoYgShTK37sA6ww_h1sAm-hlvtA4uOxHlK4vsRH3fvdbaI-83aD62_6jdifk_iXuL-tpilNpMro18dqx6Z_AOGZCbZx1BIRjnFdYOHF06Ryx0On6lY47z89fG5ZDfuL2xDKkT9KqCk9i3VexJhuu6yhPHdy_xOp6WTzT8Wc86hj5q8LWJ7ww9omwq3Gk2pmZQ5m42jzYx1wEet8H5xjy2-bZ7vmmRFp7juYgUfXw0lykGc68Or7YNc05MdTTDv-35Bvf14ReLjmJsO2CuPnKDT-kAX4PWf0Hr_f2HvluoXKZj_dNh_JLlN9LUT9D7WrxbZLmijPnVEXl6qta_AQ) (add input in the footer) I can confirm that solving something hard, even if it took 6 million years, is **very** rewarding :) _(Though the code's REALLY long)_ **Definitely** can still be optimized, there's no way 895 characters is the limit. <details> <summary><h3>How does it work? <s>(Assuming this works)</s></h3> </summary> Since symmetry is important, my first thought involved finding the _average_ X- and Y-coordinates of the squares. It works, but sadly the labels occur more than once (meaning they're not unique). After days of brainstorming on how to make them unique ~~which almost drove me insane~~, I came to the conclusion we need a better method. Ah! Here's the better method. * Let's say the top left grid is `[0,0]`, the X-axis goes left to right, and the Y-axis up to down. * We separate the X- and Y-coordinates, and mush them each together to form 2 numbers. * To ensure uniqueness, we then multiply those numbers and assign it as the label. Yeay! For a better picture, let's label the coordinates of the 10th-13th tetrominoes: ![Tetrominoes 10-13](https://i.postimg.cc/1mT2Vkc1/Label-a-hinged-tetromino.png) We get ``` [[0,0], [1,0], [3,0], [2,1]], [[0,0], [2,0], [1,1], [3,1]], [[0,0], [3,0], [1,1], [2,1]], [[0,0], [1,0], [2,1], [3,1]]. ``` _(Note that the order of the coordinates is just like reading text in most languages (top to bottom, left to right))_ Now, mushing the X- and Y-coordinates would look like this: ``` X: [0,1,3,2] Y: [0,0,0,1] X: [0,2,1,1] Y: [0,0,1,1] X: [0,3,1,2] Y: [0,0,1,1] X: [0,1,2,3] Y: [0,0,1,1] ``` _(Also note that order **really, really** matters here)_ Anyway, when we flip the tetrominoes upside-down: ![Flipped tetrominoes 10-13](https://i.postimg.cc/QXjJSfx9/Label-a-hinged-tetromino-but-flipped.png) The coordinates become ``` [[2,0], [0,1], [1,1], [3,1]], [[1,0], [3,0], [0,1], [2,1]], [[1,0], [2,0], [0,1], [3,1]], [[2,0], [3,0], [0,1], [1,1]]. ``` What did we achieve? As it turns out, we can flip a tetromino by flipping its Y-coordinates and then rearranging them! _(In this example, we flip the Y-coordinates from_ `0` _to_ `1` _and vice versa. The idea is pretty similar for other tetrominoes.)_ Also, notice that the Y-coordinates are **always** in ascending order, which is what we'll need to do when rearranging. The same is true when flipping the tetrominoes horizontally: flip the X-coordinates, and rearrange. _(Feel free to check this by hand)_ Anyway, this means we can get the flipped version of any tetromino. Progress! What to do next? * From those flipped tetrominoes, get their mushed together X- and Y-coordinates. * Compare them to the original tetromino. Use the one with the greatest value. _(That means if we have_ `[0,1,3,2]` _and_ `[2,0,1,3]`, _we pick the latter because_ `132 < 2013`_. So, we get the same result even if we flip the tetrominoes around!)_ ### Rotating So far we've solved mirroring (or flipping), but what about the ~~pesky~~ rotation? How do we rotate, and how do we know when to rotate? My idea is that **if a tetromino has two squares side-by-side** or **is more tall than wide**, we rotate. Otherwise, we don't. For not square-ish tetrominoes like 10-13 (the ones I showed you before), this works well! However, how about the square-ish ones where its width is the same as its height? Let's take a look at this guy, the 16th tetromino: ![Yancy](https://i.postimg.cc/66sr4KqZ/Yancy.png) Let's call it Yancy. ~~Why not?~~ ...anyway, Yancy is a square-ish 3x3 tetromino, and these are quite annoying _(no offense, Yancy)_. Yancy here does _not_ have two squares side-by-side. This means we shouldn't rotate it, and it's fine just the way it is :) However, take Yancy's cousin Yandy _(who's quite odd)_: ![Yandy](https://i.postimg.cc/jt5zF2xc/Yandy.png) Since Yandy has two squares side-by-side, we need to rotate it. The question is **how?** Well... after some pondering, here's what I figured out: * We can think of rotation as a diagonal mirror, something like this: ![Yandy mirror](https://i.postimg.cc/tRCnVSvy/Yandy-mirror.png) _(Note that even if the result is flipped, that's still the same tetromino which means it doesn't matter!)_ * When we mirror something _(like in the image)_, its X-coordinates become its Y-coordinates and vice versa. * The only thing left to do is to rearrange them, and **we're done!** Now, only a bunch of tetrominoes will always have two blocks side-by-side even when rotated, and they're _all_ symmetric so they definitely won't cause any problems. Oh wait... Actually, **they do.** Thankfully enough, there's an unelegant "hardcoded" way to give them unique labels _(see line 6-8 in my code)_ and I don't have to spend another 6 million years trying to fix that 🙂 After all this, though, I can only hope my effort isn't ruined by a tetromino which I haven't tested on and somehow breaks the code. Feel free to test the code yourself. _Also, the code's **really** golfed that not even I can immediately understand it. That's why I didn't bother trying to break down the code :)_ </details>