FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
learning-python/group_maker.py at master · rrees/learning-python · GitHub
rrees
/
learning-python
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
9
Code
Issues
0
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
learning-python
/
group_maker.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
25 lines (19 loc) · 581 Bytes
Breadcrumbs
learning-python
/
group_maker.py
Copy path
File metadata and controls
25 lines (19 loc) · 581 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import
random
import
itertools
import
pprint
# Issues to fix with this program
# Groups should be of the largest equal size
# Any people left over should be spread across the groups
# I.e. no-one left in a small group or just by themselves
people
=
[
]
def
chunker
(
itr
,
size
):
item
=
list
(
itertools
.
islice
(
itr
,
size
))
while
item
:
yield
item
item
=
list
(
itertools
.
islice
(
itr
,
size
))
if
__name__
==
'__main__'
:
no_of_groups
=
3
# needs to be calculated
random
.
shuffle
(
people
)
groups
=
[
g
for
g
in
chunker
(
iter
(
people
),
len
(
people
)
/
no_of_groups
)]
pprint
.
pprint
(
groups
)
Back
|
FazBrowse Home
|
New Git URL