Posts

Showing posts from February, 2022

8-puzzle solving

 Game Trees Snigle Player Path Finding Problems 1.Rubik Cube 2.Sliding Puzzle 3.Travellig sales man Problem Two Player games 1.Chess 2.Checkers 3.Othello Constraint Satisfaction Problem 1.Eight Queens 2.Sudoku Solutions for 8-puzzle solving in python is  from source, github 8-puzzle Explanation from  Goeduhub More https://www.linkedin.com/pulse/solving-8-puzzle-using-algorithm-python-ajinkya-sonawane

Find how many iterations taken to get 6 on a 6-face die

  #rolling a 6-face dice #calculate how many iterations needed to get 6 import random n=1 iterations=0 while n>0:     n=random.randint(1,6)     if n==6:         print("Total iterations# ",iterations)         break#exit loop     iterations+=1

Find length of list using while loop without len() in python

  #Python 3.7.5 L=[10,10,2] i=0 while L[i:]:    i+=1 print("Length is ",i) #Likewise length of string  S="NAME" i=0 while S[i:]:     i+=1 print("len is ",i)

Maths vs Stats computations

 If total time taken to calculate perfect numbers from 1 to 10000 is 12 seconds(on i5 2nd gen 12gb ram) then find out total time taken for perfect numbers from 1 to 20000? sol: 24 seconds is wrong  Because as the number becoming large, computation calculation increases there by delay in time So time is 54 seconds(in my system) #Find  all perfect number 1 -100 import time as t start=t.time() z=1 while z<=20000:     n=z     i=1     sum=0     while i<n:         if n%i==0:             sum=sum+i         i=i+1     if sum==n:         print(n, end="\t")     z=z+1 end=t.time() print("Total time #",end-start, " seconds")