Git Product home page Git Product logo

random's Introduction

一、简介

大多数情况,部门出去玩,是大家取在一起放松心情,还有一个很重要的点是 :相互之间有更深入的了解。所以我们会分组,玩游戏,blahbla...

分组最重要的就是随机。作为一群程序员,当然不是靠某个人来分, 而是通过我们的管家 —— 程序。之前出去玩的时候写过一个随机分组 的程序,重新整理一下,发出来。我们面试的时候, 最经常了的一道题就是从里面分离出来的 —— 如何随机分组。

二、程序

查看 random.js 的源文件,可直接运行于浏览器或者 Node 环境。

三、测试

可以直接访问 /random 来查看 DEMO,或者在 CLI 环境中运行:

$node test.js <team> <size>

# Usage: 默认 size 为组的数量,可以强制为每组的人数
#   -分成多少组: node test <team> <size>
#   区分性别,多少人为一组: node test <team> <size> true
#   不区别性别,多少人为一组:node test <team> <size> false true

random's People

Contributors

sofish avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

random's Issues

a few concerns

1、当输入非数字时,没有message提示
if(!size) return;

2、如果team里female较少(一般情况),不能正确分组了
return females.map(function(group, i) {
return group.concat(males[i] || []);
});
//这是要求每个group里都必须有妹子吗?
//26个member,4个妹子,想分6组

random

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.