0
Guys, Lets consider i hava two elements like (1,2), then I need to find the number of ways of arrangement of those two elements.
Such as ( 1,1 ) ( 1, 2 ) ( 2, 1 ) ( 2, 2 ) for this kind of output, can any one of help me to write code for it
5 Respostas
+ 4
if youre asking for number of ways then ..
if you have only 2 elements then you can just use a straight forward method (thera only 4 possibilities)
but if thera n elements array and you want to check all possible combinations .
then it will be like
1elem : n
2elem : n²
3eme : n³
......
so total possibilities n+n²+n³+...+n^n
which is a GP .
= n(1-n^n)/(1-n)
+ 3
you can use itertools, no need to reinvent the wheel.
from itertools import product
x = (1,2)
print(list(product(x, repeat=len(x))))
+ 2
S GOUSE BASHA ,
please show us your try that you have done so far.
+ 1
I don't know exact logic for that, that's why I haven't try it
0
Could you tell me how I can implement this concept in Code