This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def get_col_name(col): | |
| abc = " ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
| col_name = "" | |
| while col > 0: | |
| letter_index = col % 26 | |
| if letter_index == 0: | |
| letter_index = 26 | |
| col -= 26 | |
| col //= 26 | |
| col_name = abc[letter_index] + col_name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Vertex: | |
| def __init__(self, name, value=1, connections={}): | |
| self.name = name | |
| self.value = value | |
| self.connections = connections | |
| def __repr__(self): | |
| return "%s(%d)" % (self.name, self.value) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| graph = {'A': set(['B', 'C']), | |
| 'B': set(['A', 'D', 'E']), | |
| 'C': set(['A', 'F']), | |
| 'D': set(['B']), | |
| 'E': set(['B', 'F']), | |
| 'F': set(['C', 'E'])} | |
| def dfs_paths(graph, start, goal): | |
| stack = [(start, [start])] | |
| while stack: |
NewerOlder