Serpentine algorithm
Can you help me out with a distribution algorithm?

Here's the deal. I have Number of pens = (Number of students * Pens per student)
So, if I have 18 students and every student has 3 pens, then we have 54 pens in total.
Every pen has an order number on it like: Pen1, Pen2, Pen3. We have to evenly distribute number of pens to every student by serpentine like this:  
**(Assuming 18 students)**  


**if 1 pen per user:**  
person 1: pen 1  
person 2: pen 2  
person 3: pen 3  
...  
person 18: pen 18  
  
**2 units:**  

person 1: pen  1 and pen  36  
person 2: pen  2 and pen  35  
person 3: pen  3 and pen  34  
...  
person 18: pen 18 and pen 19  
**3 units:** 

1st person: unit 1, unit 36, unit 37  
2nd person: unit 2, unit 35, unit 38  
3rd person: unit 3, unit 34, unit 39  
...     
person 18: unit 18, unit19, unit54  
**4 units per student:**  

person 1: unit 1, unit 36, unit 37, and unit 72  
person 2: unit 2, unit 35, unit 38, and unit 71   
person 3: unit 3, unit 34, unit 39, and unit 70    
...  
person 18: unit18, unit19,unit 54, unit 55  

So, input is Number of students + pens per student. And I need to output a distribution (array)


Serpentine algorithm
===

Can you help me out with a distribution algorithm?

Here's the deal. I have Number of pens = (Number of students * Pens per student)
So, if I have 18 students and every student has 3 pens, then we have 54 pens in total.
Every pen has an order number on it like: Pen1, Pen2, Pen3. We have to evenly distribute number of pens to every student by serpentine like this:  
**(Assuming 18 students)**  


**if 1 pen per user:**  
person 1: pen 1  
person 2: pen 2  
person 3: pen 3  
...  
person 18: pen 18  
  
**2 units:**  

person 1: pen  1 and pen  36  
person 2: pen  2 and pen  35  
person 3: pen  3 and pen  34  
...  
person 18: pen 18 and pen 19  
**3 units:** 

1st person: unit 1, unit 36, unit 37  
2nd person: unit 2, unit 35, unit 38  
3rd person: unit 3, unit 34, unit 39  
...     
person 18: unit 18, unit19, unit54  
**4 units per student:**  

person 1: unit 1, unit 36, unit 37, and unit 72  
person 2: unit 2, unit 35, unit 38, and unit 71   
person 3: unit 3, unit 34, unit 39, and unit 70    
...  
person 18: unit18, unit19,unit 54, unit 55  

So, input is Number of students + pens per student. And I need to output a distribution (array)

