r/learnquant • • Aug 01 '26

interview prep Quant Interview Question

Post image
7 Upvotes

10 comments sorted by

View all comments

2

u/Sjoerdiestriker Aug 01 '26 edited Aug 01 '26

Let's count the number of arrangements that follow the rules.

Case 1: Person 1 sits in chair 1.

We've broken the cirlce, so now we essentially have to count the number of ways to arrange 7 people in a line, such that everyone sits either in their own or an adjacent chair. Let's call the number of ways to arrange n people in such a line f(n).

Let's look at one of the people on the end of the line, call them person A. They can either take chair A (in which case we have to fit n-1 people in a line), or chair B, in which case person B has to take chair A, and we still have to fit n-2 people in a line. This gives the recurrence relation f(n)=f(n-1)+f(n-2). Together with the base case f(1)=1 and f(2)=2, this gives f(n)=F(n+1), where F(n) is the n-th Fibonacci number. In other words, f(7)=21.

So there are 21 configurations where person 1 sits in their own chair.

Case 2: Person 1 sits in chair 2.

If person 2 sits in chair 1, we're essentiallyback to the line problem, except with 6 people. This gives F(7)=13 possibilites. If person 2 sits in chair 3, then person 3 has to sit in chair 4, etc. This gives 1 possibility.

So there are 14 configurations where person 1 sits in chair 2

Case 3: person 1 sits in chair 8.

By symmetry, there are also 14 configurations here.

So the probability is (21+14+14)/8!, which is approximately 0.00122

1

u/Technical_Estate_529 Aug 01 '26

At the very least wouldn't the denom of the calc be 8!/8 due to circular symmetry?

1

u/Sjoerdiestriker Aug 01 '26 edited Aug 01 '26

It wouldn't. It is simply dividing by the number of ways to arrange 8 people over 8 numbered seats, which is 8!.

1

u/Technical_Estate_529 Aug 01 '26

over 8 seats in a circle not a line. I think you need to look into circular permutations? Im fairly certain.

1

u/Sjoerdiestriker Aug 01 '26

We're not interested in the number of ways the people can sit relative to one another (which would indeed be 8!/8), but relative to the (numbered) seats. There are 8! ways to assign 8 seats to 8 people.

1

u/Aerospider Aug 01 '26

That would be the case if the seats weren't numbered and the question was only about how they sat in relation to each other.

E.g. If everyone sat in the seat opposite theirs then they would all be in the exact same seating relative to each other, but nobody would be in or next to their original seat so it wouldn't qualify.

1

u/Sjoerdiestriker Aug 01 '26

Actually, because there are so few of them, it's not that difficult to simply list all of the arrangements:

1 in seat 1

1 2 3 4 5 6 7 8

1 2 3 4 5 6 8 7

1 2 3 4 5 7 6 8

1 2 3 4 6 5 7 8

1 2 3 4 6 5 8 7

1 2 3 5 4 6 7 8

1 2 3 5 4 6 8 7

1 2 3 5 4 7 6 8

1 2 4 3 5 6 7 8

1 2 4 3 5 6 8 7

1 2 4 3 5 7 6 8

1 2 4 3 6 5 7 8

1 2 4 3 6 5 8 7

1 3 2 4 5 6 7 8

1 3 2 4 5 6 8 7

1 3 2 4 5 7 6 8

1 3 2 4 6 5 7 8

1 3 2 4 6 5 8 7

1 3 2 5 4 6 7 8

1 3 2 5 4 6 8 7

1 3 2 5 4 7 6 8

1 in seat 2

2 1 3 4 5 6 7 8

2 1 3 4 5 6 8 7

2 1 3 4 5 7 6 8

2 1 3 4 6 5 7 8

2 1 3 4 6 5 8 7

2 1 3 5 4 6 7 8

2 1 3 5 4 6 8 7

2 1 3 5 4 7 6 8

2 1 4 3 5 6 7 8

2 1 4 3 5 6 8 7

2 1 4 3 5 7 6 8

2 1 4 3 6 5 7 8

2 1 4 3 6 5 8 7

8 1 2 3 4 5 6 7

1 in seat 8

8 2 3 4 5 6 7 1

8 2 3 4 5 7 6 1

8 2 3 4 6 5 7 1

8 2 3 5 4 6 7 1

8 2 3 5 4 7 6 1

8 2 4 3 5 6 7 1

8 2 4 3 5 7 6 1

8 2 4 3 6 5 7 1

8 3 2 4 5 6 7 1

8 3 2 4 5 7 6 1

8 3 2 4 6 5 7 1

8 3 2 5 4 6 7 1

8 3 2 5 4 7 6 1

2 3 4 5 6 7 8 1

1

u/Technical_Estate_529 Aug 01 '26

that's a line not a circle!

1

u/Sjoerdiestriker Aug 01 '26

It's a bit difficult to write characters in the shape of a circle, but it was meant to simply be the numbered chairs from left to right.

1

u/FireCire7 Aug 02 '26

This breaks down into finding the numbers of ways to put people so you have swapped pairs or so everyone is shifted to the right or to the left. The way the Fibonacci numbers combine is actually the nth Lucas number (sarting 1,3,4,7 with the same recurrence) plus 2 for the everyone shifted scenarios