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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:15:41+00:00 2026-05-23T05:15:41+00:00

All, One of the steps in Swiss pairing algorithm needs to create groups of

  • 0

All,

One of the steps in Swiss pairing algorithm needs to create groups of players having the same score.

E.x.
 P1 - 3
 P2 - 3
 P3 - 2
 P4 - 1
 P5 - 1
 P6 - 1

So this should create 3 groups i.e. 3 arrays consisting Array 1: {P1, P2} ; Array 2: {P3} ; Array 3: {P4, P5, P6}.

This is dynamically changing.

In Java, we could have had an array of arraylist and make it work (One of the solutions I can think of). How can we achieve something like this in PHP?

  • 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-23T05:15:42+00:00Added an answer on May 23, 2026 at 5:15 am

    You can do so as well in PHP with an array:

    $array1 = array($P1, $P2);
    $array2 = array($P3);
    $array3 = array($P4, $P5, $P6);
    

    You might want to stack this into another array as well (grouped by score, probably that’s what you would think of as “arraylist in java”):

    $players = array();
    foreach(array($P1, ..., $P5) as $player) {
        $score = $player->score;
        $players[$score][] = $player;
    }
    var_dump($players);
    

    However if the value changes within any of the players group the data must be updated:

    class Pairing
    {
      private $players;
      public function __construct(array $players) {
        $this->players = $players;
      }
      public function getPairing() {
        $players = array();
        foreach($this->players as $player) {
          $score = $player->score;
          $players[$score][] = $player;
        }
        return $players;
      }
    }
    
    $pairing = new Pairing(array($P1, ..., $P5));
    ...
    var_dump($pairing->getPairing());
    

    Or choose the pattern of choice to deal with the events most efficiently.

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

Sidebar

Related Questions

Having a hard time with this one as I don't think I know all
I have been banging my head on this one all day. The C++ project
I have around 30 scenarios that all bar one require this step to be
Among all the encodings available here http://docs.python.org/library/codecs.html which one is the one I should
Having taken no explicit steps that I'm aware of, Xcode has decided that one
Put them all in one separate folder structure or along with classes which implements
I want two special methods: one that runs for all URLs one that runs
I am trying to code an all in one HTML/PHP contact from with error
I have a handful of projects that all use one project for the data
I have a few SQL Server databases (all in one server), containing their own

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.