承接 jpuck/peer-value-distributer 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

jpuck/peer-value-distributer

Composer 安装命令:

composer require 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.

README 文档

README

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.

Build Status Codecov

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.

  • 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.

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.

Registered on packagist for easy installation using composer.

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:

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
        )

)

统计信息

  • 总下载量: 19
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0
  • 更新时间: 2017-01-23

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固