Post History
JavaScript (Node.js), 541 540 bytes for(_='=>)==!(+==0h,.map(M,R(=1,,e,b &&Nl=[-1,))s(n,=(a a=u,v(i=g(z,u,f=(a,w,cs=Math.max,r?[...r(--a ) (a)]:[],R>&b>&a<w&b<...
Answer
#6: Post edited
# [JavaScript (Node.js)], 541 bytes- <!-- language-all: lang-javascript -->
<pre><code>for(_='=>)+==0h,.map(M,R(=1,,e	,b=[-1,&&=u,v(i))s(n,=(aa=g(z,u,f=(a,w,cs=Math.max,r?[...r(--a)(a)]:[],R>&b>&a<w&b<g=(f,c,d	(v(i(fcd	++f)?a[b][f]:!(e)	),v=fr(w+s).some(f),na(c,uc(f,z!f||!((M1])olNO(o-N||l-O)&(o+N||l+O)(Po,l(Qx=z,y(xN,yOx,y)a[y][x]&g(x,y,o,l)==PQ++,n=s(n,Q,m1,0||(d0,1),n0,k=1]p[!(dp),1]q(jt=z	!(e++,tpt	)a[e][t]&g(t	,q,!q)==(q?m:d)++j,k=s(k,jkcf(r(w,gr(fa[f][g],w,0';G=/[-]/.exec(_);)with(_.split(G))_=join(shift());eval(_)- </code></pre>
[Try it online!][TIO-kkp2nxd9]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kkp2nxd9]: https://tio.run/##bVPLcqpAEC0TQnyVTz4AN9pTtAjbmEmWWSUm2SJlRgTUICAQX8W/ewfDNcm9YQrm9Jzuc2aamiXbsNiKFmHS94OZfTw6QQQT2qN3EpHaCm1RrTnHhrpiIdSlx3oNX6FKdaygXcJpkRp9Ha@7XZF@4AYW0hUhgiCIMfh4SYEV2@yCunDADyw4PMYtNqxKTB9ZMueSO4wu7g1VVSPo91mRFIER88Yw8fXirtmd8pfdbrvT24ZLwSmihbNSsw2ZDzgtq9ialRSl6hTJPTOmpuGYNx2wmwIpEdxQR4pgqzRiosbBygaHoN9sszpY@NG26uDgod1x0rQD8Hitm6Qe1LzaU20kQdB/SlOvPyJdCJQMKiMiwnMhQE8Q4aWyowfcX8Gu9YT71qi6wz0RmbE3jZ3ZdYGHyDMJpc/ii6II6NOsGS@8K7gq6KgJaQqzgoY639C1hu9UN@uhZHRgJoYEebCWYFlJ6KF0xU@jKJi0wmpSyjxs00gyj6SEa@ysuQes71c3MyIqylLgUjG84/Ly/dISHeCnR5f3oOFIjLfGcE0BG1vu3xs@0IFR6EvmQLV3tgUTMiTbRTKHiRqH3iKBB0ImdBksfIjnCycBQob2hnk88Ti0Aj8OPFv1AhfeymVN1k9DkzWOz@O8njEn4rekPNDLX1Vf1ecEPU/RP3E5n/@lfyL9l7UMlb80crt8F@cl/buw9s1X@9/3N5p7fE76N6fym5pEixUQNbJDj1k2DMbR2E/HUTr2By7KvbHfI3n7OT5FZVnObh2T6Z38@XX4DZKZoZmqZ/tuMudBjggB9teC18nyWYoLnVXOKTkr/yDlVNYIf9TTr89IMjz@AQ "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], <del>541</del> 540 bytes
- <!-- language-all: lang-javascript -->
- <pre><code>for(_='=>)==!(+==0h,.map(M,R(=1,,e,b	&&Nl=[-1,))s(n,=(a	a=u,v(i=g(z,u,f=(a,w,cs=Math.max,r?[...r(--a	)	(a)]:[],R>&b>&a<w&b<g=(f	,c,d(v(i(fc	d++f	)?a[b][f]:e)),v=fr(w+s).some(f),na(c,uc(f,z!f||(M1])olNO(oO)|(o--O(Po,l(Qx=z,yxN,yOx,y)a[y][x]&g(x,y,o,l)PQ++,n=s(n,Q,m1,0||(d0,1),n0,k=1]p[dp),1]q(jt=ze++,tpt)a[e][t]&g(t,q,!q)(q?m:d)++j,k=s(k,jkcf(r(w,gr(fa[f][g],w,0';G=/[-]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
- </code></pre>
- [Try it online!][TIO-kkp3kwhs]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kkp3kwhs]: https://tio.run/##bVPLUqtAEK2oKHlUzJstbpKeokNgaxxdutKoW0LFCYE8JJAA5lX8e@4QuTHeK1PQ3XO6z5npYWZsxUIrmC6itueP7P3e8QMY0Ba9l4jUoLR@AzWFVqlWmWBZnbMFlKSn0jW@QZHqWEA7j8Nssyk@i279ihptHS8JEQRBDMHDCwos22Dn9BNXMJVqZ3QMO/zEjMMBXGPZKoT0iUUTTrzB4PzBUFU1gHabZUkWGDFvDRPfzu8rzSF/2d26Obwrjyk4WbRwlK80IKEFp2plq6O8ohSdLHlgxtA0HPO2ZlcEkie4oo4UwFoph0QN/bkNDkGv0mAlsPCzYZXAwV3jxonjGjxd6iYp@dfu9fN1T6qBX7/qkZib9lW7J4jwkvHR5fa1sKE73J5tqs@4rfaKG9wSkRlb09iYzTHwEHkiqb@Ir4oioEeTZrzyruA8o6MmxDGMMhrqfCGXGn5Q3SwtJKM2EhcEub@UYFaI6C5/ZisKRtVFMcon/LZpRAl/lMcl3ixJHZYP89sRERVlJnCaED5wdvFxYYkO8B3jmO@77EiMd8MYmwKW11y71X2kHSPTlsyOam9sCwakS9bTaAIDNVy40wgeCRnQmT/1IJxMnQgI6dor5vLEfdfyvdB3bdX1x/Cey2myfhiarHH/OI7zCXIAfktKAz33XfVdfUzQ0xT9y8@l9l/4p6f/Mpd4uW@OVC5dxXFKPyXWTnS1/3V/g7nGl9FPlE4WndofFWkfTtrDWd7VKJjOgaiBvXCZZUOnH/S9uB/Efa8zRrnV91okPTHuH6KcLCc3lMn0Xv76OvyeyczQTNW1vXE04UHqEQLsrwSvk@UjFSc6shxTUlT@AcqxrBH@qIe/JQFJd/8H "JavaScript (Node.js) – Try It Online"
#5: Post edited
# [JavaScript (Node.js)], <del>534</del> 510 bytes- <!-- language-all: lang-javascript -->
<pre><code>for(_='=>)(f=0h,++,=1,,e=[-1,	,b&&=u,v(i=(aa))s(n,=g(z,u,.map(f=(a,w,cs=Math.max,r?[...r(--a)(a)]:[],O>&b>&a<w&b<g=,c,d(v(i+=c+=dO)?a[b][f]:!(e)),v=fr(w+s).some),na(c,uc,z!f||!((M	1])oMb(lb,o(Nx=z,y(xy+=b,O(x,y)a[y][x]&g(x,y,o)==lN++,n=s(n,N,m1,0||(d0,1),n	0,k=1]p[!(dp),1]q(jt=z!(et+=p,O(t)a[e][t]&g(t,q,!q)==(q?m:d)++j,k=s(k,jkcf(r(w,gr(fa[f][g],w,0';G=/[-]/.exec(_);)with(_.split(G))_=join(shift());eval(_)- </code></pre>
[Try it online!][TIO-kkogd170]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kkogd170]: https://tio.run/##bVLdcrIwEB0tLRQd/3gBvNHNsCLc1qa97FXbB0DGRgTUIiBQ/4Z3t6Hlw/abkmGye/bknN1M1mzHUidZxdkojBbu@exFCczokD4oROmB16VGZ4ltTcMWNbGJboNaIxNvcS4NBiL9wB2slBsKTOqxa0IEQRBTCPGK@nDCD6zrGxZDzeME3GPbaab0mWVLjh4wuX60dF1PYDRiEpGAEfvOsvH1@qEzmPOf3e8H8/u2T7sSOrhodHpQmHU16kgaXTRar12JPDJrbluefdcHtyOQBsEd9ZQE9lo7JXoabdwuwbDTYzVw8KPn1Lp46vW9PO8DPN@aNqlFynNtrkBQn2MkiPDSPNATHm/g0DpqdI6vcMAjEZl1tK2DPfCLVMKIUBqIL5omYEiLgV8EATd1Ew0hz2FRN9DktrcGvlPTrsWK1YeFGBPkyVaBdTOjp8YNb7mVaTTmHlmjsHBtKysssgZusb/lHrB93NwtiKhpa4FrpfCO66v3K0f0gM@IPp@07SmMX4Dl2wK297yB4eSJjq3aSLHHuntwHZiRCdmvsiXM9DQOVhk8ETKj62gVQrpceRkQMnF3LODE8@RNlg3V/FqGavC4WhVeVL4Kf5HKxJQvpy6nK4JZUszvWC73/8u/I/MPrIjki0ZpV3ZRQeZPYeOH7wWT3/QsWW2A6IkbB8xxYTxNpmE@TfJpOPZRHU7DISkvkMdfmayqxftmKn1QnShMo8DVg8iHb8Tjj15llmHrgRv62ZInZUQIsH92XENVK1kuWilWlLKq/iqquWqQ4pucPwE "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], 541 bytes
- <!-- language-all: lang-javascript -->
- <pre><code>for(_='=>)+==0h,.map(M,R(=1,,e	,b=[-1,&&=u,v(i))s(n,=(aa=g(z,u,f=(a,w,cs=Math.max,r?[...r(--a)(a)]:[],R>&b>&a<w&b<g=(f,c,d	(v(i(fcd	++f)?a[b][f]:!(e)	),v=fr(w+s).some(f),na(c,uc(f,z!f||!((M1])olNO(o-N||l-O)&(o+N||l+O)(Po,l(Qx=z,y(xN,yOx,y)a[y][x]&g(x,y,o,l)==PQ++,n=s(n,Q,m1,0||(d0,1),n0,k=1]p[!(dp),1]q(jt=z	!(e++,tpt	)a[e][t]&g(t	,q,!q)==(q?m:d)++j,k=s(k,jkcf(r(w,gr(fa[f][g],w,0';G=/[-]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
- </code></pre>
- [Try it online!][TIO-kkp2nxd9]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kkp2nxd9]: https://tio.run/##bVPLcqpAEC0TQnyVTz4AN9pTtAjbmEmWWSUm2SJlRgTUICAQX8W/ewfDNcm9YQrm9Jzuc2aamiXbsNiKFmHS94OZfTw6QQQT2qN3EpHaCm1RrTnHhrpiIdSlx3oNX6FKdaygXcJpkRp9Ha@7XZF@4AYW0hUhgiCIMfh4SYEV2@yCunDADyw4PMYtNqxKTB9ZMueSO4wu7g1VVSPo91mRFIER88Yw8fXirtmd8pfdbrvT24ZLwSmihbNSsw2ZDzgtq9ialRSl6hTJPTOmpuGYNx2wmwIpEdxQR4pgqzRiosbBygaHoN9sszpY@NG26uDgod1x0rQD8Hitm6Qe1LzaU20kQdB/SlOvPyJdCJQMKiMiwnMhQE8Q4aWyowfcX8Gu9YT71qi6wz0RmbE3jZ3ZdYGHyDMJpc/ii6II6NOsGS@8K7gq6KgJaQqzgoY639C1hu9UN@uhZHRgJoYEebCWYFlJ6KF0xU@jKJi0wmpSyjxs00gyj6SEa@ysuQes71c3MyIqylLgUjG84/Ly/dISHeCnR5f3oOFIjLfGcE0BG1vu3xs@0IFR6EvmQLV3tgUTMiTbRTKHiRqH3iKBB0ImdBksfIjnCycBQob2hnk88Ti0Aj8OPFv1AhfeymVN1k9DkzWOz@O8njEn4rekPNDLX1Vf1ecEPU/RP3E5n/@lfyL9l7UMlb80crt8F@cl/buw9s1X@9/3N5p7fE76N6fym5pEixUQNbJDj1k2DMbR2E/HUTr2By7KvbHfI3n7OT5FZVnObh2T6Z38@XX4DZKZoZmqZ/tuMudBjggB9teC18nyWYoLnVXOKTkr/yDlVNYIf9TTr89IMjz@AQ "JavaScript (Node.js) – Try It Online"
#4: Post edited
# [JavaScript (Node.js)], 534 bytes- <!-- language-all: lang-javascript -->
f=(a,w,h,c=1,s=Math.max,r=(a,b)=>a?[...r(--a,b),b(a)]:[],S=(a,b)=>a>=0&b>=0&a<w&b<h,g=(f,b,c,d,e=0)=>(v(i=>(f+=c,b+=d,e++,S(f,b)?a[b][f]:!(e=0))),e),v=f=>r(w+h,s).some(f),n=0)=>a.map((c,u)=>c.map((f,z)=>!f||!((A=[-1,1]).map(D=>A.map(b=>(F=g(z,u,b,D))&&(K=1,x=z,y=u,v(i=>(x++,y+=b,S(x,y)&&a[y][x]&g(x,y,b,D)==F&&K++)),n=s(n,K)))),m=g(z,u,1,0))||(d=g(z,u,0,1),n=[-1,0,k=1].map(p=>[!(d&&p),1].map(q=>(j=1,t=z,e=u,v(i=>!(e++,t+=p,S(t,e)&&a[e][t]&g(t,e,q,!q)==(q?m:d)&&++j)),k=s(k,j))))&&s(n,k))))&&s(n,c&&f(r(w,g=>r(h,f=>a[f][g])),h,w,0))[Try it online!][TIO-kkog77le]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kkog77le]: https://tio.run/##bZPLbqswEIb3PIWzccZiQvE2rYkqVd1EZ9UlQaohXHIjBMhVvHvOmFBoqwoJ5vLP@GNsr/VJV1G5KupJvl/G93uiQOMZM4yUxEr903Xm7PQFSxMPhfL0zHccp4TJxPgYghbB1A/woxd4yuWheemXMw9fMkwVJBhihEuMlUsSOMGK3omtIgxtRWHbxg8jEjPth4GfBNMRGK0QGAs8qUR5JZztDCvhVPtdDInAvO2lCa8AiPBITvRwEryRM0qaZgTwqvyJRBmINvemvNfWCAngXaVwwyOxvQnBOczpny/qhld1xAfihcCutgqJ7oJX0mj/GviXgKfGbwuVeud8btvCEFWQ41wY7F3XWyL9RdPAsvNdlEZomFzcKBm0NIXy/BEsOS8EdqEDLb8moJqA4i8gmgoR1bYqiKim2RiiOPBrQ0Q@HnB0ICQ4zHbTJWVte00wGwLb4NqAcW4YN4MZcZ4ADZe2iWacIY1a0wb4aUCFGZ0F4r8/f1qWy2T7uMwlu3/6uMm0ib9EnSOtoWqo7gWyk8iHbXXf3@mflvwjZixr6NEt11H0Ifm9sftt3SFmfTp1udqBcMq42OoohqdFucibRdks8qcU2XiRj@lMFttVDWS3nsWY2UHNlMeifV7tt7Gz3afwiCR0UZj23cDZxnlaZ@R0lhCgv5ajHoz1bceP09vW95Iuy34kWcPMtRHi@f4f "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], <del>534</del> 510 bytes
- <!-- language-all: lang-javascript -->
- <pre><code>for(_='=>)(f=0h,++,=1,,e=[-1,	,b&&=u,v(i=(aa))s(n,=g(z,u,.map(f=(a,w,cs=Math.max,r?[...r(--a)(a)]:[],O>&b>&a<w&b<g=,c,d(v(i+=c+=dO)?a[b][f]:!(e)),v=fr(w+s).some),na(c,uc,z!f||!((M	1])oMb(lb,o(Nx=z,y(xy+=b,O(x,y)a[y][x]&g(x,y,o)==lN++,n=s(n,N,m1,0||(d0,1),n	0,k=1]p[!(dp),1]q(jt=z!(et+=p,O(t)a[e][t]&g(t,q,!q)==(q?m:d)++j,k=s(k,jkcf(r(w,gr(fa[f][g],w,0';G=/[-]/.exec(_);)with(_.split(G))_=join(shift());eval(_)
- </code></pre>
- [Try it online!][TIO-kkogd170]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kkogd170]: https://tio.run/##bVLdcrIwEB0tLRQd/3gBvNHNsCLc1qa97FXbB0DGRgTUIiBQ/4Z3t6Hlw/abkmGye/bknN1M1mzHUidZxdkojBbu@exFCczokD4oROmB16VGZ4ltTcMWNbGJboNaIxNvcS4NBiL9wB2slBsKTOqxa0IEQRBTCPGK@nDCD6zrGxZDzeME3GPbaab0mWVLjh4wuX60dF1PYDRiEpGAEfvOsvH1@qEzmPOf3e8H8/u2T7sSOrhodHpQmHU16kgaXTRar12JPDJrbluefdcHtyOQBsEd9ZQE9lo7JXoabdwuwbDTYzVw8KPn1Lp46vW9PO8DPN@aNqlFynNtrkBQn2MkiPDSPNATHm/g0DpqdI6vcMAjEZl1tK2DPfCLVMKIUBqIL5omYEiLgV8EATd1Ew0hz2FRN9DktrcGvlPTrsWK1YeFGBPkyVaBdTOjp8YNb7mVaTTmHlmjsHBtKysssgZusb/lHrB93NwtiKhpa4FrpfCO66v3K0f0gM@IPp@07SmMX4Dl2wK297yB4eSJjq3aSLHHuntwHZiRCdmvsiXM9DQOVhk8ETKj62gVQrpceRkQMnF3LODE8@RNlg3V/FqGavC4WhVeVL4Kf5HKxJQvpy6nK4JZUszvWC73/8u/I/MPrIjki0ZpV3ZRQeZPYeOH7wWT3/QsWW2A6IkbB8xxYTxNpmE@TfJpOPZRHU7DISkvkMdfmayqxftmKn1QnShMo8DVg8iHb8Tjj15llmHrgRv62ZInZUQIsH92XENVK1kuWilWlLKq/iqquWqQ4pucPwE "JavaScript (Node.js) – Try It Online"
#3: Post edited
# [JavaScript (Node.js)], 520 bytes- <!-- language-all: lang-javascript -->
f=(a,w,h,c=1,s=Math.max,r=(a,b)=>a?[...r(--a,b),b(a)]:[],S=(a,b)=>a>=0&b>=0&a<w&b<h,g=(f,b,c,d,e=0)=>(v(i=>(f+=c,b+=d,e++,S(f,b)?a[b][f]:!(e=0))),e),v=f=>r(w+h,s).some(f),n=0)=>a.map((c,u)=>c.map((f,z)=>!f||!([-1,1].map(b=>(F=g(z,u,b,1))&&(K=1,x=z,y=u,v(i=>(x++,y+=b,S(x,y)&&a[y][x]&g(x,y,b,1)==F&&K++)),n=s(n,K))),m=g(z,u,1,0))||(d=g(z,u,0,1),n=[-1,0,k=1].map(p=>[!(d&&p),1].map(q=>(j=1,t=z,e=u,v(i=>!(e++,t+=p,S(t,e)&&a[e][t]&g(t,e,q,!q)==(q?m:d)&&++j)),k=s(k,j))))&&s(n,k))))&&s(n,c&&f(r(w,g=>r(h,f=>a[f][g])),h,w,0))[Try it online!][TIO-kkofkmnl]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kkofkmnl]: https://tio.run/##bZPLboMwEEX3fIWzccfyhMI2rZNdN1FXXTpINe@8CAHyFP@ejgkhalUhwdyZ6/FhDCtzNHVULctmXOzi5HZLFRg8YY6R8rFWn6bJ3a05Y2XzoVBTM9Ou61YwHluNIRgRTHSAX4Nhqjwe2pt5P/HwPcdMQYohRhhjojyywBGWdE@lijCUitJS4pc1iZnRYaDTYDIC6xUCE4FHlappBSeZYy3cerdNIBVYdL0M4ZUAER5IRHeR4pXEKG3bEeixj37Q5UPa80NlcMUD4fhCcA5zes2zuuJFHfBOdSaWi1QhAZ3xQh6jL4E@Bzyzuluo1AfncymFhaihwLkF3fatfSTutoW41x6tIJ8F8XCtephSTfUIYs5L8eDb0@4r4mmIJ3nw0BwIqJGqJKCGpmGBkkA3Fog07nG0JyLYz7aTmKpSrghmTVxrpMi@pUVcP8OI8xRonHQwNNUcabiGRq6zgBbmdPrEf3v7dhyP@d3lMY/i4RryttIV/jP1wneeq56rB4PfW/x77PTPv@Xfkf9PzkbOs0e/XU8xpGzZ@XabarkF4VZJuTFRAq@LalG0i6pdFK8ZspdF8UKfWblZNkBxpxzG7BEZpqYs2hX1bpO4m10G90xK3z4z2gvcTVJkTU6ij4QA89iOejA2tKWmQ8fB0lfZryJrmf0ThHi7/QA "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], 534 bytes
- <!-- language-all: lang-javascript -->
- f=(a,w,h,c=1,s=Math.max,r=(a,b)=>a?[...r(--a,b),b(a)]:[],S=(a,b)=>a>=0&b>=0&a<w&b<h,g=(f,b,c,d,e=0)=>(v(i=>(f+=c,b+=d,e++,S(f,b)?a[b][f]:!(e=0))),e),v=f=>r(w+h,s).some(f),n=0)=>a.map((c,u)=>c.map((f,z)=>!f||!((A=[-1,1]).map(D=>A.map(b=>(F=g(z,u,b,D))&&(K=1,x=z,y=u,v(i=>(x++,y+=b,S(x,y)&&a[y][x]&g(x,y,b,D)==F&&K++)),n=s(n,K)))),m=g(z,u,1,0))||(d=g(z,u,0,1),n=[-1,0,k=1].map(p=>[!(d&&p),1].map(q=>(j=1,t=z,e=u,v(i=>!(e++,t+=p,S(t,e)&&a[e][t]&g(t,e,q,!q)==(q?m:d)&&++j)),k=s(k,j))))&&s(n,k))))&&s(n,c&&f(r(w,g=>r(h,f=>a[f][g])),h,w,0))
- [Try it online!][TIO-kkog77le]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kkog77le]: https://tio.run/##bZPLbqswEIb3PIWzccZiQvE2rYkqVd1EZ9UlQaohXHIjBMhVvHvOmFBoqwoJ5vLP@GNsr/VJV1G5KupJvl/G93uiQOMZM4yUxEr903Xm7PQFSxMPhfL0zHccp4TJxPgYghbB1A/woxd4yuWheemXMw9fMkwVJBhihEuMlUsSOMGK3omtIgxtRWHbxg8jEjPth4GfBNMRGK0QGAs8qUR5JZztDCvhVPtdDInAvO2lCa8AiPBITvRwEryRM0qaZgTwqvyJRBmINvemvNfWCAngXaVwwyOxvQnBOczpny/qhld1xAfihcCutgqJ7oJX0mj/GviXgKfGbwuVeud8btvCEFWQ41wY7F3XWyL9RdPAsvNdlEZomFzcKBm0NIXy/BEsOS8EdqEDLb8moJqA4i8gmgoR1bYqiKim2RiiOPBrQ0Q@HnB0ICQ4zHbTJWVte00wGwLb4NqAcW4YN4MZcZ4ADZe2iWacIY1a0wb4aUCFGZ0F4r8/f1qWy2T7uMwlu3/6uMm0ib9EnSOtoWqo7gWyk8iHbXXf3@mflvwjZixr6NEt11H0Ifm9sftt3SFmfTp1udqBcMq42OoohqdFucibRdks8qcU2XiRj@lMFttVDWS3nsWY2UHNlMeifV7tt7Gz3afwiCR0UZj23cDZxnlaZ@R0lhCgv5ajHoz1bceP09vW95Iuy34kWcPMtRHi@f4f "JavaScript (Node.js) – Try It Online"
#2: Post edited
# [JavaScript (Node.js)], 388 bytes- <!-- language-all: lang-javascript -->
f=(a,w,h,c=1,s=Math.max,r=(a,b)=>a?[...r(--a,b),b(a)]:[],v=f=>r(w+h,s).some(f),n=0)=>a.map((c,u)=>c.map((f,z)=>!f|!(m=(g=(f,b,c,d,e=0)=>(v(i=>(f+=c,b+=d,e++,f<w&b<h?a[b][f]:!(e=0))),e))(z,u,1,0))||(d=g(z,u,0,1),n=[-1,0,k=1].map(p=>[!(d&&p),1].map(q=>(j=1,t=z,e=u,v(i=>!(e++,t+=p,t<w&e<h&&a[e][t]&g(t,e,q,!q)==(q?m:d)&&++j)),k=s(k,j))))&&s(n,k))))&&s(n,c&&f(r(w,g=>r(h,f=>a[f][g])),h,w,0))[Try it online!][TIO-kko906sl]- [JavaScript (Node.js)]: https://nodejs.org
[TIO-kko906sl]: https://tio.run/##bVJbbqswEP1nFebHHYsJhd80TlbQFRikGmIgCa8ASaqIvadjwiXqVWXJnHPm6WGO@qr7tDu0w6pu9ubxyCRovGGBqQyxl596KPxKf2Nn9UTIrd4p3/c7WK0sxwS0iNcqxqvM5LaDm1dgL/y@qQxkAmsZ2BhK0QKkeCGSPkmGdyJuNrpQScglCQmmuEczhcAVDnRnnkwx8STJnofZ5saTTbHTKolVFq9dsM5CoBEC7njBEImOI@xlPvEAQ9uDWpEBTzKMp9qt3CoX9py3AmfpTLWO9OJB3qmBC07VKT0VHTzZ4kCVzabgXCsTqyHmOQxo8IzuWUgJ51213gvOPe9I3ZxkDyckJEjqocbTC6acZ0BjwtxOq0AamqanqDymwIImTw94fHw5TsDC6QQsILycRbeWyfCX00xC5xX1il4cwtklfGJn/v5v/o3CPzSLnC9/6A4VCL8zbalTA@9RF9Vj1I1R/Z4je4vqN1qMtjwMQHhiDmN2@prJLUubum9K45dNDk8lo5VjWgWxX5o6HwoiM6Lfrf@VoxyMLWkp6ZJxcZmt7JeRjczujhAfjx8 "JavaScript (Node.js) – Try It Online"
- # [JavaScript (Node.js)], 520 bytes
- <!-- language-all: lang-javascript -->
- f=(a,w,h,c=1,s=Math.max,r=(a,b)=>a?[...r(--a,b),b(a)]:[],S=(a,b)=>a>=0&b>=0&a<w&b<h,g=(f,b,c,d,e=0)=>(v(i=>(f+=c,b+=d,e++,S(f,b)?a[b][f]:!(e=0))),e),v=f=>r(w+h,s).some(f),n=0)=>a.map((c,u)=>c.map((f,z)=>!f||!([-1,1].map(b=>(F=g(z,u,b,1))&&(K=1,x=z,y=u,v(i=>(x++,y+=b,S(x,y)&&a[y][x]&g(x,y,b,1)==F&&K++)),n=s(n,K))),m=g(z,u,1,0))||(d=g(z,u,0,1),n=[-1,0,k=1].map(p=>[!(d&&p),1].map(q=>(j=1,t=z,e=u,v(i=>!(e++,t+=p,S(t,e)&&a[e][t]&g(t,e,q,!q)==(q?m:d)&&++j)),k=s(k,j))))&&s(n,k))))&&s(n,c&&f(r(w,g=>r(h,f=>a[f][g])),h,w,0))
- [Try it online!][TIO-kkofkmnl]
- [JavaScript (Node.js)]: https://nodejs.org
- [TIO-kkofkmnl]: https://tio.run/##bZPLboMwEEX3fIWzccfyhMI2rZNdN1FXXTpINe@8CAHyFP@ejgkhalUhwdyZ6/FhDCtzNHVULctmXOzi5HZLFRg8YY6R8rFWn6bJ3a05Y2XzoVBTM9Ou61YwHluNIRgRTHSAX4Nhqjwe2pt5P/HwPcdMQYohRhhjojyywBGWdE@lijCUitJS4pc1iZnRYaDTYDIC6xUCE4FHlappBSeZYy3cerdNIBVYdL0M4ZUAER5IRHeR4pXEKG3bEeixj37Q5UPa80NlcMUD4fhCcA5zes2zuuJFHfBOdSaWi1QhAZ3xQh6jL4E@Bzyzuluo1AfncymFhaihwLkF3fatfSTutoW41x6tIJ8F8XCtephSTfUIYs5L8eDb0@4r4mmIJ3nw0BwIqJGqJKCGpmGBkkA3Fog07nG0JyLYz7aTmKpSrghmTVxrpMi@pUVcP8OI8xRonHQwNNUcabiGRq6zgBbmdPrEf3v7dhyP@d3lMY/i4RryttIV/jP1wneeq56rB4PfW/x77PTPv@Xfkf9PzkbOs0e/XU8xpGzZ@XabarkF4VZJuTFRAq@LalG0i6pdFK8ZspdF8UKfWblZNkBxpxzG7BEZpqYs2hX1bpO4m10G90xK3z4z2gvcTVJkTU6ij4QA89iOejA2tKWmQ8fB0lfZryJrmf0ThHi7/QA "JavaScript (Node.js) – Try It Online"
#1: Initial revision
# [JavaScript (Node.js)], 388 bytes <!-- language-all: lang-javascript --> f=(a,w,h,c=1,s=Math.max,r=(a,b)=>a?[...r(--a,b),b(a)]:[],v=f=>r(w+h,s).some(f),n=0)=>a.map((c,u)=>c.map((f,z)=>!f|!(m=(g=(f,b,c,d,e=0)=>(v(i=>(f+=c,b+=d,e++,f<w&b<h?a[b][f]:!(e=0))),e))(z,u,1,0))||(d=g(z,u,0,1),n=[-1,0,k=1].map(p=>[!(d&&p),1].map(q=>(j=1,t=z,e=u,v(i=>!(e++,t+=p,t<w&e<h&&a[e][t]&g(t,e,q,!q)==(q?m:d)&&++j)),k=s(k,j))))&&s(n,k))))&&s(n,c&&f(r(w,g=>r(h,f=>a[f][g])),h,w,0)) [Try it online!][TIO-kko906sl] [JavaScript (Node.js)]: https://nodejs.org [TIO-kko906sl]: https://tio.run/##bVJbbqswEP1nFebHHYsJhd80TlbQFRikGmIgCa8ASaqIvadjwiXqVWXJnHPm6WGO@qr7tDu0w6pu9ubxyCRovGGBqQyxl596KPxKf2Nn9UTIrd4p3/c7WK0sxwS0iNcqxqvM5LaDm1dgL/y@qQxkAmsZ2BhK0QKkeCGSPkmGdyJuNrpQScglCQmmuEczhcAVDnRnnkwx8STJnofZ5saTTbHTKolVFq9dsM5CoBEC7njBEImOI@xlPvEAQ9uDWpEBTzKMp9qt3CoX9py3AmfpTLWO9OJB3qmBC07VKT0VHTzZ4kCVzabgXCsTqyHmOQxo8IzuWUgJ51213gvOPe9I3ZxkDyckJEjqocbTC6acZ0BjwtxOq0AamqanqDymwIImTw94fHw5TsDC6QQsILycRbeWyfCX00xC5xX1il4cwtklfGJn/v5v/o3CPzSLnC9/6A4VCL8zbalTA@9RF9Vj1I1R/Z4je4vqN1qMtjwMQHhiDmN2@prJLUubum9K45dNDk8lo5VjWgWxX5o6HwoiM6Lfrf@VoxyMLWkp6ZJxcZmt7JeRjczujhAfjx8 "JavaScript (Node.js) – Try It Online"