2017 © Pedro Peláez
 

library peer-value-distributer

Given an array, return a new array with the same keys and values randomly distributed evenly amongst the peers in the specified batch quantity.

image

jpuck/peer-value-distributer

Given an array, return a new array with the same keys and values randomly distributed evenly amongst the peers in the specified batch quantity.

  • Friday, December 8, 2017
  • by jpuck
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Peer Value Distributer

Given an array, return a new array with the same keys and values distributed randomly and evenly amongst the peers in the specified batch quantity., (*1)

Build Status Codecov, (*2)

For example, say you have a group of 15 book authors. You want each author to review 3 of their peers' work. This function will randomly assign each author 3 of its peers to read., (*3)

  • Every book is reviewed exactly 3 times.
  • No one will review any book more than once.
  • No one will review their own book.

The natural maximum distribution count is n-1 so if you specify a count larger than that, it will be ignored and the largest possible count will be used instead., (*4)

e.g. if you distribute those 15 books with a count of 20, it will be ignored and instead every author will be assigned the maximum of 14 peer books to review., (*5)

Registered on packagist for easy installation using composer., (*6)

composer require jpuck/peer-value-distributer

Example

use jpuck\PeerValueDistributer;

$books = [
    'John' => 'The Book of John',
    'Jane' => 'A Work by Jane',
    'Jeff' => 'Readings from Jeff',
    'Jose' => 'Words of Jose',
    'Jena' => 'Writing with Jena',
];

print_r( PeerValueDistributer::distribute($books, $count = 3) );

Output:, (*7)

Array
(
    [Jena] => Array
        (
            [John] => The Book of John
            [Jeff] => Readings from Jeff
            [Jane] => A Work by Jane
        )

    [John] => Array
        (
            [Jeff] => Readings from Jeff
            [Jane] => A Work by Jane
            [Jose] => Words of Jose
        )

    [Jeff] => Array
        (
            [Jane] => A Work by Jane
            [Jose] => Words of Jose
            [Jena] => Writing with Jena
        )

    [Jane] => Array
        (
            [Jose] => Words of Jose
            [Jena] => Writing with Jena
            [John] => The Book of John
        )

    [Jose] => Array
        (
            [Jena] => Writing with Jena
            [John] => The Book of John
            [Jeff] => Readings from Jeff
        )

)

The Versions

08/12 2017

dev-master

9999999-dev

Given an array, return a new array with the same keys and values randomly distributed evenly amongst the peers in the specified batch quantity.

  Sources   Download

GPL-3.0+

The Requires

  • php ^7.0

 

The Development Requires

by Jeff Puckett

28/01 2017

1.0.1

1.0.1.0

Given an array, return a new array with the same keys and values randomly distributed evenly amongst the peers in the specified batch quantity.

  Sources   Download

GPL-3.0+

The Requires

  • php ^7.0

 

The Development Requires

by Jeff Puckett

24/01 2017

1.0.0

1.0.0.0

Given an array, return a new array with the same keys and values randomly distributed evenly amongst the peers in the specified batch quantity.

  Sources   Download

GPL-3.0+

The Requires

  • php ^7.0

 

The Development Requires

by Jeff Puckett