Skip to main content
1 of 4
ngn
  • 15.3k
  • 2
  • 43
  • 87

K (ngn/k), 84 bytes

p:{$[x;,/i,''(x-i)o'y&i:1+!x&y;,!0]}
l:{x*y%*|(*:)(|!\)/x,y}
{#1_(|/(l/'p/2#x)l')\1}

Try it online!

ngn
  • 15.3k
  • 2
  • 43
  • 87