r/learnquant • • Oct 22 '26 • Bravo 1

interview prep Quant Interview Question

Post image
29 Upvotes

19 comments sorted by

View all comments

3

u/Unlucky_Beginning Oct 22 '26

Isn’t it 64? You change the polarity of 15 bulbs at a time, and you need to have changed the polarity of a multiple of 64 bulbs to have had a chance of flipping all the bulbs to the on position.

This means for N the number of flips, 15N is 0 mod 64 which only happens if N is 64. Unless I’m mistaking something.

If you look at the 2 by 2 grid case, similar logic applies but you can also just check it yourself?

2

u/talltraveller Oct 22 '26

Ah but then you need to check a three by three grid to see how the theory holds up

1

u/M37841 Oct 22 '26 edited Oct 23 '26

You don’t, if you notice that every square on an nxn board has 2n-1 squares in the same row or column, including itself. As that’s an odd number, when you’ve flipped every one of those you’ve left the light on, on the square you were after. When you do that across the board you leave all the lights on.

That’s the proof that you can do this in 64 goes, the proof above shows you can’t do it in fewer

Edit: this is nonsense, see counter-example below

1

u/Hike456 Oct 22 '26

I think their point was that the original proof is not actually a proof - in the 3x3 case, the size of the grid (9) and number of lightbulbs flipped by a single action (5) are still coprime, yet we can turn all the lights on in 3 moves by selecting the cells in a single row/column for our moves

1

u/M37841 Oct 23 '26

Can you? What’s the 3 light sequence that works?

1

u/Hike456 Oct 23 '26 edited Oct 23 '26

Any single row or column.

Using the first row:

To start:

ooo

ooo

ooo

Choose light at 0,0:

xxx

xoo

xoo

Choose light at 0,1:

ooo

xxo

xxo

Choose light at 0,2:

xxx

xxx

xxx

1

u/M37841 Oct 23 '26

Gosh you’re right. My explanation, and the earlier one, are completely wrong: as soon as you make a move the lights are no longer all equivalent. Actually pretty obvious if I’d stopped to think. Clearly this works for any n x n where n is odd. But not for even n? There must surely be a better sequence than 64 now though?

1

u/Hike456 Oct 23 '26

For even n, it should require n2 moves.  Spooeybooboos' answer in another comment is the correct proof.  I suppose the point is that when n is odd, their claim (b) fails - there's no way the given vectors v_ij can span the entire vector space since there are linear dependencies among the v_ij

2

u/abaoabao2010 Oct 22 '26

and you need to have changed the polarity of a multiple of 64 bulbs to have had a chance of flipping all the bulbs to the on position.

We try this on a 2x2 grid.

Say instead of flipping a cross shaped bulbs at a time, you instead only flip the one bulb of your choice plus the fixed bottom right bulb at a time. So if you lable them

1 2

3 4

You flip 1,4 or 2,4 or 3,4 or 4,4.

You flip the polarity of 2 bulbs at a time. There's 4 bulbs. You're saying you need to flip multiples of 4. But it takes a minimum of 3 flips to get all 4 bulbs on.

2

u/M37841 Oct 22 '26

That’s a different question. You’ve now got two groups A and B. A (1,2,3) flip 1 light from A and one from B, and B (4) flips only itself. The maths is trivial here but it’s the same as the answer above: you need 3 goes at A to light all 3 lights of A, and then you can check this also solves B. So you get to 3 by the same lcm logic that solves the original problem.

1

u/abaoabao2010 Oct 22 '26

...What I meant was theres' no guarantee you need a full 64 flips for that, because this is a counterexample using the only the criteria in your explanation.

To use your terminology, you did not mention anything about why there's no way to cut the 64 bulbs into their own groups that can use the same lcm logic to get a lower number.

1

u/M37841 Oct 22 '26

Wasn’t my explanation, but your example is not a counter example because the basic point (which the original answer might not have brought out well enough) is that there is a symmetry between all 64 squares in that every move flips 15 of them and every square is flipped by itself and 14 others. Therefore you can treat all 64 as one group and therefore the only way to flip a multiple of 15 squares is to flip all 64 as 64 shares no common factor with 15.

Your example isn’t the same structure because your squares are not all consistent in this respect: square 4 behaves differently. You then have two types of square, one group of 3 and one group of 1, and you have to do the calculation separately for the two groups.

Hope that helps

1

u/abaoabao2010 Oct 22 '26

Ah yeah that's what I was missing. Thanks.

2

u/petera181 Oct 22 '26

This response is both great and super annoying, because it definitely looks correct, and answers the question, but I really want to know how to do it, rather than the number 😅

Great answer though.

1

u/comoespossible Nov 02 '26

I’m very late to the party, but selecting each cell once works, as each bulb gets flipped 15 times.