Skip to main content

how many possibilities of arrangement in python code.



def first():
    print('hello')
def poss(m):
    k=0    for j in range(len(m)):
        for i in range(len(m)-1):
            k+=1            x=m[i]
            m[i]=m[i+1]
            m[i+1]=x
            print(k,">",m)
            i+=1        j+=1



###input

m=[1,2,3,5]
poss(m)

##result


1 > [2, 1, 3, 5]
2 > [2, 3, 1, 5]
3 > [2, 3, 5, 1]
4 > [3, 2, 5, 1]
5 > [3, 5, 2, 1]
6 > [3, 5, 1, 2]
7 > [5, 3, 1, 2]
8 > [5, 1, 3, 2]
9 > [5, 1, 2, 3]
10 > [1, 5, 2, 3]
11 > [1, 2, 5, 3]
12 > [1, 2, 3, 5]



Comments

Popular posts from this blog

Use of formula loop plot of graph y=sin(x)/x and y=sin(x^2)/x in LabVIEW

1. Formula loop Using formula loop compute y for the following two functions: 𝑦1 = sin(x)/x and 𝑦2 = sin(x2)/x where x varies from 0 to 10 in step of 0.05. Plot 𝑦1 & 𝑦2 vs. x in a single XY graph. Use For Loop and Formula loop for this problem.

Separate negative and positive value from the array using structure function in LabVIEW

Great Architecture clips

Picture credit by Simran (my little sister) Lots of thanks 😊