How to divide x number of players into 2 teams randomly multiple times, differently every time?

前端 未结 2 1000
天命终不由人
天命终不由人 2021-01-14 04:42

I have a mathematical problem in my JavaScript code. I need to divide a given number of players into 2 teams randomly so that each time – if players want to play again – the

2条回答
  •  伪装坚强ぢ
    2021-01-14 05:12

    For the even cases, just pick numbers you haven't used randomly and make teams.

    For the odd cases, pick a number randomly to sit out. Then the remaining numbers are like an even case.

提交回复
热议问题