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 6701013
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:52:59+00:00 2026-05-26T06:52:59+00:00

Is there an efficient algorithm to split up a number into N subsections so

  • 0

Is there an efficient algorithm to split up a number into N subsections so that the sum of the numbers adds up to the original, with a base minimum? For example, if I want to split 50 into 7 subsections, and have a base minimum of 2, I could do 10,5,8,2,3,5,17 (as well as any other number of combinations). I’d like to keep the numbers as integers, and relatively random but I’m not sure how to efficiently generate numbers that sum up to the original and don’t include numbers lower than the given minimum. Any suggestions?

EDIT – Just to copy/paste my comment, the integers don’t have to be unique, but I want to avoid equal sizes for all of them (e.g. 50 split into 10 equal sizes) everytime.

  • 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-26T06:52:59+00:00Added an answer on May 26, 2026 at 6:52 am

    Here’s an algorithm:

    1. Divide N by m where N is your number and m is the number of subsections.
    2. Round the result down to its nearest value and assign that value to all of the subsections.
    3. Add one to each subsection until the values add up to N. At this point if N was 50 and m was 7, you’d have 8, 7, 7, 7, 7, 7, 7
    4. Iterate from 0 to m-1, stepping by 2, and add a random number between -(currentValue-base) and currentValue-base. Add the inverse of that number to its neighboring bucket. If you have an odd number of buckets, then on the last bucket instead of adding the inverse of that number to its neighboring bucket, add it to all of the other buckets in a distributed manner similar to steps 2 and 3 above.

    Performance:
    Step 1 is O(1), Steps 2, 3, and 4 are O(m), so overall it’s O(m).

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

Sidebar

Related Questions

Is there an algorithm that is more time efficient than O(n^2) for detecting cycles
Is there an efficient method of converting an integer into the written numbers, for
Is there an efficient algorithm for merging 2 max-heaps that are stored as arrays?
Is there an efficient algorithm to compute the smallest integer N such that N!
I would like to know if there's an efficient algorithm to find the greatest
Are there any efficient bitwise operations I can do to get the number of
Is there a clever/efficient algorithm for determining the hypotenuse of an angle (i.e. sqrt(a²
I would like to know if there is an efficient algorithm S = F(v,G)
I'd like an efficient algorithm (or library) that I can use in Java to
Is there any efficient algorithm to find the set of edges with the 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.