Posts

Showing posts from June, 2022

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

GPSC Reasoning SSC Reasoning Quiz

GPSC Reasoning SSC Reasoning Quiz NO Question OP1 OP2 OP3 OP4 Right 1 Look at this series: 73, 10, 83, 11, 9, 12, ... What number should come next? 7 10 12 13 2 2 Look at this series: 74, 10, 8, 11, 94, 12, ... What number should come next? 8 88 888 8888 23 3 Paragraph Question n/a n/a n/a n/a n/a 4 how ____ you? n/a n/a n/a n/a Fine 5 Look at this series: 7, 10, 8, 11, 9, 12, ... What number should come next? 8 88 888 8888 n/a 6 Simple Question n/a n/a n/a n/a Simple Answer 7 i___rfom mumbai A