Posts

Showing posts with the label MongoDB Exercise

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 ...

MongoDB Exercises Practice Solution Exercise First

Image
MongoDB Exercises Practice Solution Exercise  Practice This All Examples Exercise 3 => Create database EMP and Make Collection With name "EMPL" and Follow Queries  =>Created Database > use emp switched to DB emp =>Create Collection > db.createCollection("empl") =>Insert Records Into EMPL Collection > db.empl.insert([ {no:1,name:"ST",salary:2000,role:"OB"}, {no:2,name:"MSD",salary:1500,role:"WK"}, {no:3,name:"YS",salary:1000,role:"ALR"}, {no:4,name:"RD",salary:1000,role:"MOB"}, {no:5,name:"RS",salary:500,role:"OB"}, {no:6,name:"BK",salary:500,role:"MOB"}, {no:7,name:"VK",salary:300,role:"BW"}, {no:8,name:"JB",salary:400,role:"BW"}, {no:9,name:"HP",salary:400,role:"ALR"}, {no:10,name:"VS",salary:300,role:"OB"...