Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6145673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:49:48+00:00 2026-05-23T18:49:48+00:00

Can you help me out with a distribution algorithm? Here’s the deal. I have

  • 0

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)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T18:49:48+00:00Added an answer on May 23, 2026 at 6:49 pm

    This is the Serpentine System.

    The following table will tell you which pens to give to each person:

    person        Pen 1          Pen 2             Pen 3         Pen 4
      1       PERSONS*0+1    PERSONS*2-0       PERSONS*2+1   PERSONS*4-0
      2       PERSONS*0+2    PERSONS*2-1       PERSONS*2+2   PERSONS*4-1
      3       PERSONS*0+3    PERSONS*2-2       PERSONS*2+3   PERSONS*4-2
      4       PERSONS*0+4    PERSONS*2-3       PERSONS*2+4   PERSONS*4-3
      :
      :
      N       PERSONS*0+N    PERSONS*2-(N-1)   PERSONS*2+N   PERSONS*4-(N-1)
                      ^              ^                 ^             ^
                      |              |                 |             |
                      +--- start at 0 and increase 2 every 2 pens ---+---> 4, 6, 6, 8
    

    And so on in both directions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

maybe you can help me out here. I have an issue with my codeigniter
Hopefully somebody can help me out here. I'm working within an embedded ActionScript2 and
I am hoping someone can help me out with a quick question I have
Have a bit of a weird one and hopefully someone can help out. The
Hopefully someone can help out here; I am trying to write a function which
I hope somebody can help work out to do this. Basically, I have a
Anyone that can help me out will be very much appreciated. I seem to
Perhaps someone can help me out with this one: I'm using a basic search
Alright, I am hoping someone can help me out. I apologize up front that
I am new in Symbian UIQ. So anyone can help me out about following

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.