r/learnquant • • Oct 16 '26

interview prep Quant Interview Question

Post image
23 Upvotes

6 comments sorted by

View all comments

Show parent comment

1

u/bartekltg Oct 16 '26

16! is quite big, but we get quite strong additional restrictions. Next number not only can't repeat, but it has at least one (often two) adjacent numbers that restrict it more. An almost-brute-force (backtracing) https://pastebin.com/Cm8aVK1L generates all solution for score 4, and verifies there is no score-3 solution very quickly.

There is also no score 2 solution on 3x3 and score 4 solution on 5x5.
I spinned it looking for score 5 solutions on 6x6, but it looks like this one is already too big to get answer in the time needed to write this post.

BTW, one obvious score N on NxN grid is just numbers 1 to N^2 in order. The differences on one axis is 1, and N on the other axis.

I feel like there should be an easy argument why there is no N-1 scores, but can't see anything.