reset password
Author Message
jgarc629
Posts: 76
Posted 17:24 Apr 26, 2017 |

I'm having a problem getting the X marks to get added one at a time per line. My first line is the array of just "-" but my second line gets "X" added at random locations in random amounts and my array is usually full of X markers by like the 4th line and continues to print arrays filled with X markers after that until it reaches the input n. Can anyone help me?

kknaur
Posts: 540
Posted 19:08 Apr 26, 2017 |

In my implementation, I have a method whose job is to take the array and add one more person taking into consideration that the person wants to sit in the middle of the longest section of seats available.  I just call this method as many times as necessary until the array is filled in the correct order.  If you are adding more than one person at a time see where you add and see if there is a way to limit it.  Basically you want to add a person, print the row, add the next person, print the row and so on.

jgarc629
Posts: 76
Posted 19:40 Apr 26, 2017 |

Oh okay I was confused with the order the seats are filled, I thought it was random.