Skip to main content
1 of 7
Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382

#MATL, 28 bytes

2:i:"`@ymy@wTF_)Zdqa+}@h]]G) 

The code is slow, but gives the correct result.

Try it online!

Luis Mendo
  • 106.7k
  • 10
  • 139
  • 382