calculate number of sits in a valid row (combinatorial question)

26 Views Asked by At

I am trying to solve some basic question in computer science although the problem is that I can't figure out how to calculate the combinatorial equation to solve my problem.

Consider a row with with $x$ chairs. in first place (from left to right) should always be a person, next should be maximum 4 empty spaces and then another person and so on. It is possible for the row to have only one place which will be occupied or a place and two, three or four empty spaces and so on. Example for valid rows:

p - - - - p - - - - p - -
p - - - - p - 
p - -
p

Example of invalid rows:

- p - - -
p - - - - -
p - p 
p - - p
p - - - p

How can I build an equation to calculate the number of occupied chairs?

EDIT: the following table:

total    not-empty chairs
1        1
2        1
3        1
4        1
5        1
6        2
7        2
8        2
9        2
10       2
11       3
12       3
1

There are 1 best solutions below

2
On

It is $\lceil \frac{x}{5} \rceil$ - this means $\frac{x}{5}$ rounded up to the closest integer.