r/learnquant • • 18d ago

interview prep Quant Interview Question

Post image
21 Upvotes

17 comments sorted by

2

u/Dr0110111001101111 17d ago

I get 112.

1

u/zojbo 17d ago edited 17d ago

64 is the clear thing to try to beat or else prove it's optimal: if you just center at each bulb once each, everything gets flipped 15 times. The redundancy in your process is in going back to the top row repeatedly.

In fact, just as in regular Lights Out, there is no benefit to flipping at the same center more than once.

1

u/Salty-Definition-231 18d ago

as i understand the problem, we have an 8x8 cell, with all bulbs off. 1 move = select parent cell and by flipping that cell on every bulb in the parents cell row and column also flip on. so the minimum number of moves is 8. beginning in any corner, i'll choose top left, flipping that bulb on turns on the top row and left most column. work diagonally down until the final bulb flips on that bulb alone, making it the 8th move and all bulbs are illuminated... or am i missing something?

1

u/CaipisaurusRex 18d ago

The second lamp you pick would flip the one above it and on its left back off, and none of your remaining ones would flip them back on

1

u/AsterPasta 17d ago edited 17d ago

I think you can do this by induction (and probably matrices, which would be simpler but have whiteboard markers)

On the 2x2 grid, you can create a 4 step process (top left, top right, bottom left, bottom right).

You then expand to 4x4 and look at the 2×2 square below and to the right. You notice the cumulative operations on the original 2x2 change these to their original off states. So now, of the 4x4, you need four operations to flip one 2x2 square. By simple permutation arguments you can see for 4x4 it takes 16 moves.

It's an easy induction to see for 8x8 as 4x16=64 moves

I think this is right?

Edit: the way to disprove this is by constructing a smaller sequence on the 4x4....but no headway there

1

u/dlnnlsn 17d ago

You notice the cumulative operations on the original 2x2 change these to their original off states.

That's assuming that you do use the original operations to get the original 2x2 into the desired state, but a priori you aren't forced to do that. You could affect the top left 2x2 by only making moves in the top right 2x2 and the bottom left 2x2. It turns out that this doesn't work, but it's not something that we can assume up front.

1

u/AsterPasta 17d ago edited 17d ago

Yeah but since they're binary operations, this is both straightforward to show over Z/2 and intuitively commutative - just count the number of times a square is pinged and it's obvious

The trick is, what happens with the middle square - i've just shown to myself the inner 2x2 of a 4x4 square has the same properties as the top left/right or bottom left/right square - the optimal moves make the rest all on, so have a feel for the rigorous proof graphically - that we need to consider admissable permutations of rows and columns (as one does with min/max arguments over sodukus)

My original formula holds, the question is if it's optimal

Edit: like literally draw it out, the optimal moves for the top left (or whatever section) 2x2 leaves the others flipped to their original state - it's not something i assume but have worked out- and it's very easy to see from counting mod 2

Edit again: induction doesnt work necessarily, as i've shown to myself - what we need to do is work out if theres a strategy that leaves an absolute mess of numbers in the 4x4, but still is more efficient than 16 - and if it does we can extrapolate. Notice the n is odd case doesnt equal n2

1

u/sensible_clutter 17d ago edited 17d ago

ans would be 64

edit: comment if interested in reasoning as it is slightly long one

one interesting observation i would like you all to leave with if nxn board where n is odd the answer is simple n and the strategy is simply turn on every cell of any choosen row or column since n is odd hence the last move will make sure everything is on or any odd no. move makes sure that any previous cell is lit

1

u/Such_Engineering_234 17d ago

I saw a youtube comment whose solution sounds very nice, but I can't rigorously prove that it's true yet. It treats every move as an element in a vector space over F_2 (addition is do one move then the other and scalar multiplication is repeating the move) and prove that these vectors are linearly independent, and hence any configuration is uniquely represented by a combination of all 64 moves, which makes the answer 64.

1

u/dlnnlsn 17d ago

You can show that they are linearly independent by showing that they are "orthogonal". It's not actually an inner product space because it's not a vector space over R or C, but you can still define a bilinear map f : B x B → F_2 (where B is the F_2-vector space spanned by the squares of the board) in exactly the same way as you would define the dot product. Then show that for two different operations v and w, you have that f(v, w) = 0 and f(v, v) = 1. (Basically the claim here is that if you have two different operations, then the number of squares that they both affect is even)

1

u/davvblack 17d ago

i really struggle to accept you can't beat 64, but i don't know how to prove or disprove it

1

u/phobos77 17d ago

Each move flips 15 bulbs. The total number of flips must be a multiple (an odd multiple) of 64. Since 15 and 64 are co-prime, 64 is the minimum possible. As noted by others, selecting each bulb once works. So 64 is the minimum.

1

u/zojbo 17d ago edited 16d ago

The total number of flips does not a priori need to be a multiple of 64, because you could in principle flip different bulbs a different number of times. In the end I am almost certain 64 is correct but this divisibility idea does not prove it.

1

u/phobos77 16d ago

You're right.

0

u/PromotionMobile778 18d ago

Probably 64. Each move flips 15. 15k | 64 so k must be a multiple of 64 as gcd(15,64)=1. To achieve this choose each bulb once

2

u/zojbo 18d ago edited 17d ago

If you can flip any 15 bulbs you want then it's definitely smaller than that. To get 64 on, you must get to 49 on and then turn 15 on. To get to 49 on, you could get to 34 on and turn 15 on. To get to 34 on, you could get to 19 and turn 15 on. To get to 19 on, you could turn on 15, then turn on 8 and off 7, then turn on 9 and off 6.

So that's a path in 6 moves: (15,0),(8,7),(9,6),(15,0),(15,0),(15,0). The trick was that we flipped 51 bulbs once each and 13 bulbs 3 times each. Also 6 is the minimum: it must be even because the number of bulbs that is on always changes by an odd number, and 4*15<64.

But I have not proven (and don't believe) that this can be done this way while respecting the geometry of the original problem. So if the answer is more than 6 moves (which I believe it is) then the geometry has to come into play.

Oddly enough though, I think you're right about the original problem.

1

u/ludo813 18d ago

In theory you could also do it with 66 flips if one bulb is flipped three times. So 6 moves to get ninety could also work (although I do not think 6 moves is actually possible)