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

Make a Translator using python?

CODE : pip install translate create a new script file eg. english in the same directory. from translate import Translator translator=Translator( to_lang = "hi" ) with open ( './english.txt' , 'r' ) as file2: text=file2.read() translation=translator.translate(text) print(translation) or another way  jj= str ( input ( 'enter th english' )) from translate import Translator translator=Translator( to_lang = "hi" ) with open ( './english.txt' , 'w' ) as file2: file2.write( f'-- { jj } ' ) with open ( './english.txt' , 'r' ) as file2: text = file2.read() translation=translator.translate(text) print (translation) DEMO:

Image Identify using machine learning in Python.

#pip install imageai #pip install Tensorflow #pip install keras from  imageai.Prediction  import  ImagePrediction import  os from  keras.models  import  load_model Givenimage= "picc.jpg" execution_path=os.getcwd() #print(execution_path) prediction = ImagePrediction() prediction.setModelTypeAsSqueezeNet() prediction.setModelPath(os.path.join(execution_path,  "squeezenet_weights_tf_dim_ordering_tf_kernels.h5" )) prediction.loadModel() predictions, probabilities = prediction.predictImage(os.path.join(execution_path, Givenimage), result_count= 3  ) for  eachPrediction, eachProbability  in   zip (predictions, probabilities):      print (eachPrediction ,  " : "  , eachProbability)   Result: WARNING:tensorflow:11 out of the last 11 calls to <function Model.make_predict_function.<locals>.predict_function at 0x7f941e211598> tr...

Projectile motion using LabVIEW

A projectile is projected with a velocity of V (in m/s) and at an angle  (in degree) to the horizontal. Build a VI to compute (i) Maximum height reached (in meters), (ii) Time of flight (in seconds) and (iii) Range of the projectile (in meters).