Posts

Showing posts from June, 2018

Artificial Intelligence Programs For Programming in Python

Traveling Salesman Problem ( TSP )] Artificial Intelligence Programs For Master Leval Programming in Python from iter tools import permutations def distance(point1, point2): >>> distance([3,4],[0,0]) 5.0 >>> distance([3,6],[10,6]) 7.0 return ((point1[0] - point2[0])**2 + (point1[1] - point2[1])**2) ** 0.5 def total_distance(points): all the points are in the given order. >>> total_distance([[1,2],[4,6]]) 5.0 >>> total_distance([[3,6],[7,6],[12,6]]) 9.0 return sum([distance(point, points[index + 1]) for index, point in enumerate(points[:-1])]) def travelling_salesman(points, start=None): Time complexity is O(N!), so never use on long lists. >>> travelling_salesman([[0,0],[10,0],[6,0]]) ([0, 0], [6, 0], [10, 0]) >>> travelling_salesman([[0,0],[6,0],[2,3],[3,7],[0.5,9],[3,5],[9,1]]) ([0, 0], [6, 0], [9, 1], [2, 3], [3, 5], [3, 7], [0.5, 9]) """ if the start is None: start = points[0] return min([perm for perm ...

Simple Basic Commands For MongoDB

Image
Simple Basic Commands For MongoDB      1.    Create a database named “mydb”       >   Use mydb      2.    Show all databases       >   Show dbs           3.      Show currently selected database. >   DB      4.      Create a collection named “emp”. >   db.createCollection(“emp”)      5.      Show all collections of the selected database. >   Show collections 6.   Insert following documents in emp collection: >  db.emp.insert( [ { empno : 1,ename : "Sachin",sal : 60000,desige : "Manager",dept : "Purchase" }, { empno : 2,ename : "Kohali",sal : 50000,desige : "Manager",dept : "Sales" }]) Find() 1.      List all documents. > db.emp.find() 2.  ...

Java Programs learn with the All examples With Execute

Java Program List Solution :  03. Write a menu driven program to find given number is :     i)      Pelindrome or not     ii)     Odd or Even     iii)    Armstrong or not      iv)     Prime or not. import java.util.Scanner; class choose { public static void main(String Args[]) { int a,n,f; System.out.println("Menu"); System.out.println("\n1. Polindrome \n2. Even or Odd \n3. Armstrong or not \n4. Prime or not\n5. Exit"); System.out.print("\nEnter the Choosen No. : "); Scanner ob=new Scanner(System.in); a=ob.nextInt(); switch(a) { case 1: System.out.print("\n\nEnter the 3digit no. : "); n=ob.nextInt(); int r,sum=0,temp;    temp=n;    while(n>0){     r=n%10;  //getting remainder    sum=(sum*10)+r;     n=n/10;  ...