Posts

Showing posts from November, 2019

Iterate Files

Update excel

Dsa Assignment 3

Problem Statement A. (15 marks) Generate a regular lattice. Write a Python program to create a Regular Lattice graph. You are allowed to use the NetworkX package, but only the basic functions — you cannot use any graph generation routines that are built in. A regular lattice is one in which each node is connected to k nearest neighbours on either side – connecting each node to 2k other nodes effectively. Construct a regular lattice graph with 50 nodes and k=3. Plot the graph within the function, as given in the template.  B. (45 marks) Maze. Given a matrix of ‘1’s and ‘0’s that represents a maze, and the indices of the starting and finishing points, generate a NetworkX graph where each node represents a ‘1’ in the input matrix, and print: a) A list of indices in the shortest path solution to the maze (in the order of the path) b) A list of lists of indices in the isolated components of the maze (order doesn’t matter) ● ‘0’s in the input represent walls (cannot be part...

Better code post

Solve a maze of 0s and 1s in python

My 1st exhausting attempt # -*- coding: utf-8 -*- """ Created on Thu Nov  7 01:02:47 2019 @author: chella """ maze=[[1 , 0 , 1 , 1 , 0 , 1], [1 , 1 , 0 , 0 , 0 , 0], [0 , 1 , 0 , 1 , 1 , 1], [0 , 1 , 1 , 1 , 0 , 1], [1 , 0 , 0 , 1 , 1 , 1], [1 , 1 , 0 , 0 , 0 , 1], [0 , 0 , 1 , 1 , 0 , 1]] #This is perfected class vertices:     def __init__(self,node):         self.node=node         self.index=-1         self.edge_list=[]         self.distance = -1              # shortest distance from source node in shortest path search         self.previous = None     def getNeighbors(self):         return self.edge_list             ...