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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:42:30+00:00 2026-05-13T14:42:30+00:00

I want to be able to create a program that will take a list

  • 0

I want to be able to create a program that will take a list of names from a .txt file (Doesnt have to be a txt, maybe excell, whatever is easiest) and generate those names into groups or “teams”.

I have 30 “users” that have to be sorted into “Teams”. I want to be able to do this fairly, so I want to random :P.

I haven’t yet decided the amount of persons per team, but I will soon.

3 Teams of 10
5 teams of 6

Thanks for the responce.

  • 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-13T14:42:31+00:00Added an answer on May 13, 2026 at 2:42 pm

    Since this isn’t homework and it looked like a fun little project… (This is one huge spoiler)

    Console app built for .Net 4.0 with VS 2010 Beta 2

    class Program
    {
        static void Main()
        {
            /* Assuming one team per line */
            Team[] teams = File.ReadAllLines("teams.txt")
                                .Select(t => new Team(t))
                                .ToArray();
    
            /* Guid.NewGuid() is creates a sufficiently random order */
            /* Assuming one player per line */
            string[] players = File.ReadAllLines("players.txt")
                                    .OrderBy(s => Guid.NewGuid())
                                    .ToArray();
    
            /* 
             * No use randomizing anymore...
             * Just assign (PlayerCount / TeamCount) players to each team 
             */
            for (int i = 0; i < teams.Length; i++)
            {
                var p = players.Skip(i * players.Length / teams.Length)
                                .Take(players.Length / teams.Length);
    
                teams[i % teams.Length].Players.AddRange(p);
            }
    
            foreach (Team t in teams)
            {
                System.Diagnostics.Debug.WriteLine(t);
            }
        }
    }
    
    class Team
    {
        public string Name { get; set; }
        public List<string> Players { get; set; }
    
        public Team(string name)
        {
            Name = name;
            Players = new List<string>();
        }
    
        public override string ToString()
        {
            /* Team name plus the players sorted alphabetically */
            /*//.Net 4.0
            return string.Format("{0}  \n{1}",
                Name,
                string.Join("  \n",
                            Players.Select(p => string.Concat("\t", p))
                                   .OrderBy(s => s)));
            */
    
            //.Net 3.5 & 4.0
            return string.Format("{0}  \n{1}",
                Name,
                string.Join("  \n",
                            Players.Select(p => string.Concat("\t", p))
                                   .OrderBy(s => s).ToArray()));
        }
    }
    

    Example output:

    Colts  
        Chuck  
        Cory  
        Jim  
        Sam  
        Ulysses
    Saints  
        Al  
        Brett  
        Hank  
        Ned  
        Quinn
    Vikings  
        Dave  
        Don  
        Ernie  
        Frank  
        Gus
    Jets  
        Bob  
        Eric  
        Isaac  
        Walt  
        Yancy
    Chargers  
        Abe  
        Mark  
        Oscar  
        Xavier  
        Zach
    Cardinals  
        Fred  
        Kyle  
        Pete  
        Ralph  
        Tom
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

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

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer On a long shot the link below explains a situation… May 13, 2026 at 8:48 pm
  • Editorial Team
    Editorial Team added an answer When you type this: if (txtAge.Text = "49") This basically… May 13, 2026 at 8:48 pm
  • Editorial Team
    Editorial Team added an answer I have used MailMessage before and it has never caused… May 13, 2026 at 8:48 pm

Related Questions

I have a program that will analyzes source code. It can recursively go through
I am writing a program that generates a single large table of information. The
OK so that title sucks a little but I could not think of anything
So I've got a program that needs to be multilingual. The only difference between
This question can be broken up into a couple of parts: What is the

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.