How To Create an Algorithm For Continous Flow of Objects Without Any Gaps Or Overlaps?

72 Views Asked by At

I need to create a mathematical solution or algorithm for the following real life problem:

     F     E     D     C    B    A    Output
T1   _     _     _     _    _    _    _    
T2   _     _     _     _    _    _    _
T3   _     _     _     _    _    _    _
T4   _     _     _     _    _    _    _
T5   _     _     _     _    _    _    _
T6   _     _     _     _    _    _    _
.
.
.

T is a clock ticking at 1 sec intervals and the underlines flow continuously from left to right. Every tick, I need to drop ONE letter on the underlines. Few rules must be followed for dropping the letters: 1) I can't drop/overlap letters on top of each other 2) the output needs to have a continuous (no gaps) flow of letters. Example,

     F     E     D     C    B    A    Output
T1   F     _     _     _    _    _    _    
T2   _     F     _     _    _    _    _
T3   _     E     F     _    _    _    _
T4   _     _     E     F    _    _    _
T5   _     _     D     E    F    _    _
T6   _     _     _     D    E    F    _
T7   _     _     _     C    D    E    F
T8   _     _     D     _    C    D    E (Problem Here! A gap is created!)
T9   _     _     _     D    _    C    D
T10   _     _     _     _    D    _   C
T11   _     _     _     _    _    D   _ (Gap. Not acceptable.)

How do I approach in solving this problem?

EDIT 1: There will always be 6 letter. There is no specific pattern of letters. I just need a continuous output.

EDIT 2: I also need an equal or close to equal effort of letter distribution. Lets say, each letter is dropped 1/6th of the time. An optimum distribution of letters at the output.

EDIT 3: You can drop the same letter twice in a row if you wish, but that won't give me a nice letter distribution.. Also, at every T time, a letter can be dropped.

EDIT 4: The action is: Every T, shift to the right, then drop a letter.

1

There are 1 best solutions below

0
On

I figured out a solution (not sure if this is an optimum solution) by trial and error:

    F   E   D   C   B   A   Output
T1  _   _   D   C   _   _   _
T2  _   E   _   D   C   _   _
T3  F   _   E   _   D   C   _
T4  _   F   _   E   _   D   C       (No Letter Dropped Here)
T5  _   _   F   _   E   A   DC
T6  _   _   _   F   B   E   ADC
T7  _   _   D   C   F   B   EADC        (T1 Event Repeats Here)
T8  _   E   _   D   C   F   BEADC
T9  F   _   E   _   D   C   FBEADC
T10 _   F   _   E   _   D   CFBEADC     (No Letter Dropped Here)
T11 _   _   F   _   E   A   DCFBEADC
T11 _   _   _   F   B   E   ADCFBEADC
T12 _   _   D   C   F   B   EADCFBEADC  (T1 Event Repeats Here
and so on

Now, I need a way to represent this mathematically so I am able to solve similar problem with different number of columns (letters from A to Z for example). Thanks!

Note: with even number of columns, two letters are dropped at the same time (T1, T7, T12) and a single drop is skipped (T4, T10). With Odd number of columns, I don't think these two things occur.