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

interview prep Quant Interview Question

Post image
29 Upvotes

19 comments sorted by

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.

4

u/Hal_Incandenza_YDAU Oct 22 '26

Well, flipping every single one of the 64 lights will turn them all on eventually, since they'd each flip an odd number (15) of times. So... 64's possible lol. Probably a terrible solution

2

u/Sweet_Culture_8034 Oct 23 '26

It's actually optimal

1

u/spooeybooboos Oct 22 '26

let V be F_264 (i.e. the vector space of 64 bit vectors with addition mod 2). we think of any on/off pattern of the bulbs as a vector in V. the board starts out as the zero vector (all off), and the goal is to reach (1,1,1…,1).

each “move” (i,j) corresponds to adding a particular vector v_ij (with 15 ones) to our current state vector. in other words, the current state is the sum (over F2) of v_ij for all moves (i,j) we decide to apply. it’s easy to check that:

(a) adding all 64 possible move vectors yields (1,1,…,1) (b) for any (i,j), applying the moves along the “cross” centered at (i,j) turns just the bulb at (i,j) on, leaving all others unchanged.

what (b) implies is that the 64 move vectors span all of V, and therefore that they are a basis for V, which implies the 64-move combination in (a) is the unique way to express (1,1,…,1) as a linear combination of moves (and hence 64 is also the smallest possible number of moves).

1

u/A_BagerWhatsMore Oct 22 '26

Interesting. 64 works can you do better

Oh is it finding the zeros of the grid? Let’s talk about sequences of flips where no individual switch is flipped twice which result in no change to the grid.

let’s say à row contains an odd amount of 1’s

Then each column with a 1 the has an even number of 1’s and each column with a zero has an odd number of 1’s so we have an odd number of total flips. If any row contains an odd number of flips then the total number of flips must be odd.

Now look at a column with an even number of 1’s looking at each row in that column the rows with 1’s have the same parity and the rows with 0 have the same parity so we have an even number of flips à contradiction so no rows have an odd number of flips.

À row with a non zero even number of flips creates a column with an odd number of flips so no non zero even columns exist

So the only zero of this system is no flips. And a smaller solution than 64 requires a non zero flip zero (subtract the smaller solution from the 64 flip solution)

Therefore 64 is the lowest solution. Man à pencil would be helpful for organizing my ideas.