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

  • Home
  • SEARCH
  • 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 7493773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T17:10:27+00:00 2026-05-29T17:10:27+00:00

I have the following problem: I have M numbers arranged into a line. I

  • 0

I have the following problem: I have M numbers arranged into a line. I need to divide the line into N groups such that the sums of the numbers of each group are closest to the mean of these sums by some metric. The actual metric is not important: we can choose to minimize sum of absolute differences, or variance, etc., depending on which leads to the simplest solution.

A similar problem is partitioning of sets, which is NP Hard. However, here we have additional constraint: groups must pack successive numbers, so there might be a solution that doesn’t involve brute-force search. The numbers are large.

EDIT

Example:

Numbers: 1 2 3 4 5 6 7 8 9 10, need to divide into 3 groups

Let’s say we want to minimize sum of absolute differences (SAD).

Groups: (1) 1 2 3 4 5 6 (sum = 21); (2) 7 8 (sum = 15); (3) 9 10 (sum = 19)

Mean = (21+15+19)/3 = 18.33, SAD = 21-18.33 + 18.33-15 + 19-18.33 = 6.67 <- That’s what we want to minimize.

  • 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-29T17:10:29+00:00Added an answer on May 29, 2026 at 5:10 pm

    Once you know what the sum should be, then you can make groups that are close to this sum. If your metrics are nice then you should be able to use binary search to find what the actual sum is. When you are aiming for a particular sum you could go through the list adding numbers to a group until the groups sum goes over the sum size. Then either take or don’t take this last integer. go through the entire list doing this and see what groups sum deviated the most from the sum. Then go back through the list trying combinations of group sizes that fall within the deviation.. it should be fast enough. Otherwise use dynamic programming.

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

Sidebar

Related Questions

I have the following problem: There is an array that consists of 6 numbers,
I have the following regexp that matches underscores, letters, numbers, and spaces. My problem
I have the following predicate that works fine with numbers such as 555 and
I have the following code and an input file that has all numbers such
Hi i have following Problem. I write a Mediawiki Extension where i need some
I have the following code for handling phone numbers such as country code for
I am having the following problem. I have the numbers 1/2/3/4/5/6 and I want
im having a problem with some code that i have. I have the following
I have wrote following code for a simple problem in Python - def Peu1(numbers):
I have the following method that I wrote for Project Euler - Problem 36

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.