I've tried using python's itertools to implement how to divide 10 students into teams of 5 each, but it doesn't work.
You can answer with print (len (L)/2). However, I tried to implement it by putting conditions in the comprehension, but it doesn't work though it may be a problem of my mathematical knowledge.
Corresponding source code
What I tried Supplementary information (FW/tool version, etc.)
import itertools L = [x for x in itertools.combinations ('ABCDEFGHIJ', r = 5)] print (len (L))
Answer # 1
You want the number of streets, right?
import math n = len ('ABCDEFGHIJ') count = math.factorial (n) // math.factorial (n -5) // math.factorial (5) print (count) # 252
Answer # 2
You also have the option of using the scipy library
from scipy.special import comb print (comb (N = 10, k = 5, exact = True)) # 252
Answer # 3
Even if you don't use comprehension forcibly
len (list (itertools.combinations ('ABCDEFGHIJ', r = 5))) // 2
Isn't it okay?
- python - about the implementation of fibonacci sequence
- i have a question about basic python problems
- python - about downloading youtube videos by youtube-dl
- python - about hamiltonian neural networks
- python - about write loop to csv
- about python argument and data definition
- python 3x - about downloading anaconda
- python - about the optimum angle of rotation matrix
- python - what i don't understand about yolo9000 (v2)
- about processing to exclude the character string group specified from list in python
- python - about "" "of" "" select === = "" "
- about batch change of file name using python
- about the python speedtest code
- please tell me about the role of python tag = "mychr"
- about python def issues
- about the operation of python's speedtest module (library)
- python, about the fire spread step of forest fire simulation
- python 3x - please teach about the exchange of information with qthead
- python - about x-axis adjustment in matplotlib
- python - you may need to restart the kernel to use updated packages error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- i want to call a child component method from a parent in vuejs
- python 3x - typeerror: 'method' object is not subscriptable
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file