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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:20:07+00:00 2026-05-10T20:20:07+00:00

I have a list of email address which I want to distribute evenly by

  • 0

I have a list of email address which I want to distribute evenly by domain.

For example:

let the list be,

a@a.com b@a.com c@a.com a@b.com b@b.com c@c.com 

The output should be

a@a.com a@b.com c@c.com b@a.com b@b.com c@a.com 

The source list is not sorted by domain as in example, but can be sorted by domain, if that can help. What would be an efficient (single/two pass?) algorithm of doing this?

raj

  • 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. 2026-05-10T20:20:07+00:00Added an answer on May 10, 2026 at 8:20 pm

    Here is my solution to this problem. Given an input like

    [['A', 13], ['B', 5], ['C', 3], ['D', 1]]  

    The output is

    AABABAACABAACABAACABAD 

    Ruby source of the program is:

    require 'pp'  def shuffle (total, num)   ret_arr = Array.new   intervel = total/num.to_f   0.upto(num-1) do |i|     val = i * intervel     ret_arr << val.floor   end   return ret_arr end  freq_table = [['A', 13], ['B', 5], ['C', 3], ['D', 1]]  pp freq_table total = 0 freq_table.collect {|i| total += i[1] } final_array = Array.new(total,0) print  final_array.to_s + '\n\n' placed = 0  freq_table.each do |i|   placements =  shuffle(total - placed, i[1])   placements.each do |j|     free_index = -1     0.upto final_array.size do |k|       free_index += 1 if (final_array[k] == 0 || final_array[k] == i[0])       if j == free_index         final_array[k] = i[0]         break       end     end   end   print 'Placing #{i[1]} #{i[0]}s over #{total - placed} positions\n'   pp placements   print  final_array.to_s + '\n\n'   placed += i[1] end 

    The idea is to take the alphabet with highest frequency and distribute it first across an array whose size is the total number of all elements. Next distribute the alphabet with second highest frequency and distribute it across the free spaces and so on.

    If you have questions let me know and I am happy to answer.

    raj

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

Sidebar

Ask A Question

Stats

  • Questions 66k
  • Answers 66k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Edit the svn config file and add an entry for… May 11, 2026 at 11:32 am
  • added an answer You could wrap your function so it doesn't do the… May 11, 2026 at 11:32 am
  • added an answer I've had this happen before. I believe the issue was… May 11, 2026 at 11:32 am

Related Questions

I have a list of email address which I want to distribute evenly by
I have a list of integers, List<Integer> and I'd like to convert all the
I have a List of Foo. Foo has a string property named Bar. I'd
I have a list of 2-item tuples and I'd like to convert them to
I have a list of more than 15 thousand latitude and longitude coordinates. Given
I have a list of objects I wish to sort based on a field
I have a list of bean objects passed into my JSP page, and one
i have a list of products that are being displayed in particular order. store
I have a list of timesheet entries that show a start and stop time.
I have a list of structs and I want to change one element. For

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.