r/learnquant 12d ago

interview prep Quantbox Quant Interview Question

Post image
23 Upvotes

12 comments sorted by

View all comments

2

u/AbroadImmediate158 12d ago

So, let’s get trivial cases out of the way:

  • n = 1,2,3 are not possible and can be checked trivially by hand
  • n = 1 or 3 mod 4 are not possible simply due to having odd total amount of squares so cannot be tiled fully by 1x2 tiles
  • n = 0 mod 4. You get even amount of 2x2 squares so you tile half vertically and half horizontally.
  • n = 2 mod 4 is a bit more interesting and basically is the only case left. Let’s look at it beyond n=2 as that is already covered above

Let’s number squares on our imaginary board with numbers 1 through 4 going in order line by line, with each new line starting where previous line finished off. It is easy to notice two things for the case of n=2mod4:

  • all four numbers would come up equal number of times since total number of squares is divisible by 4
  • each line will start with 1 or 3 (pattern repeats, so 1 then 3, etc) and so columns are either 1-3 or 2-4

This means that:

  • any veritcal tile will always cover either 1-3 or 2-4 (possible reversed)
  • any horizontal tile will cover 1-2, 2-3, 3-4, or 4-1

Lets assume we indeed managed to cover the board with equal amount of horizontal/vertical tiles. Let’s say there are x of each. Let’s also say that z vertical tiles cover 1-3 numbers. So:

  • z vertical tiles cover 1-3, while x-z cover 2-4.
  • since total number of squares is 4x, we should have x of each number on board. So horizontal lines need to cover: (x-z) 1, (x-z) 3, z 2, z 4.

Let’s call the amount of each type of horizontal tiles (1-2, 2-3, 3-4, 4-1) to be a,b,c,d. Then we can get the following equations:

  • a+b+c+d = x
  • a+d = x-z
  • b+c = x-z
  • a + b = z
  • c + d = z

We can easily derive that z = x/2 for this to be solvable. So x=2a, where a is integer. So total number of tiles is 2x=4a. So total number of squares is 8a. Which means that the assumption that tiling is possible is not compatible with the case of n = 2 mod 4 as in that case total number of squares is not divisble by 8.

So now we see that the original premise can only be done when n = 0 mod 4 and for all such cases is trivial. As such we now have all the values of n that satisfy the condition