content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# Enter your code for "camelCase" here. def to_camel(ident): def a(x): return x def b(x): return x[0].upper() + x[1::] def c(): yield a while True: yield b d = c() return "".join(d.__next__()(x) for x in ident.split("_"))
def to_camel(ident): def a(x): return x def b(x): return x[0].upper() + x[1:] def c(): yield a while True: yield b d = c() return ''.join((d.__next__()(x) for x in ident.split('_')))
# Write a program that asks the user to input any positive integer # and outputs the successive values of the following calculation. # At each step calculate the next value by taking the current value and, # if it is even, divide it by two, but if it is odd, multiply it by three and add one. # Have the program end if the current value is one. # There is an ambiguity in the question, however: # What if the user enters one? # I chose not to end the program immediately in this case. # In order not to end the program immediately if the user # enters one, a 'while (x != 1)': loop will not work. # Instead, a 'while true:' loop can be used, which breaks # once 'x = 1'. I appreciate that 'while true:' is not # generally considered best practice, but the absence of # of a 'do-while' loop in python makes this unavoidable. # Store the user's input as an integer. x = int(input("Enter a positive integer and see what happens: ")) print(x) # As there is no do-while loop built into Python, # Use a 'while-true' loop that ends (with 'break') once the relevant variable equals one. while True: # To calculate the variable's next value, use an if-else block: # to determine if the variable is even, use the modulus operator (x % 2 = 0); # in all other cases the variable is odd. if x % 2 == 0: # use floor division '//' so that an integer rather than a float results. x = x // 2 print(x) else: x = (x * 3) + 1 print(x) if x == 1: break
x = int(input('Enter a positive integer and see what happens: ')) print(x) while True: if x % 2 == 0: x = x // 2 print(x) else: x = x * 3 + 1 print(x) if x == 1: break
class ModelPermissionsMixin(object): """ Defines the permissions methods that most models need, :raises NotImplementedError: if they have not been overridden. """ @classmethod def can_create(cls, user_obj): """ CreateView needs permissions at class (table) level. We'll try it at instance level for a while and see how it goes. """ raise NotImplementedError @classmethod def can_view_list(cls, user_obj): """ ListView needs permissions at class (table) level. We'll try it at instance level for a while and see how it goes. """ raise NotImplementedError def can_update(self, user_obj): """ UpdateView needs permissions at instance (row) level. """ raise NotImplementedError def can_view(self, user_obj): """ DetailView needs permissions at instance (row) level. """ raise NotImplementedError def can_delete(self, user_obj): """ DeleteView needs permissions at instance (row) level. """ raise NotImplementedError
class Modelpermissionsmixin(object): """ Defines the permissions methods that most models need, :raises NotImplementedError: if they have not been overridden. """ @classmethod def can_create(cls, user_obj): """ CreateView needs permissions at class (table) level. We'll try it at instance level for a while and see how it goes. """ raise NotImplementedError @classmethod def can_view_list(cls, user_obj): """ ListView needs permissions at class (table) level. We'll try it at instance level for a while and see how it goes. """ raise NotImplementedError def can_update(self, user_obj): """ UpdateView needs permissions at instance (row) level. """ raise NotImplementedError def can_view(self, user_obj): """ DetailView needs permissions at instance (row) level. """ raise NotImplementedError def can_delete(self, user_obj): """ DeleteView needs permissions at instance (row) level. """ raise NotImplementedError
class BatmanQuotes(object): @staticmethod def get_quote(quotes, hero): index = int(sorted(hero)[0]) return {'B':'Batman: ','R':'Robin: ','J':'Joker: '}[hero[0]] + quotes[index]
class Batmanquotes(object): @staticmethod def get_quote(quotes, hero): index = int(sorted(hero)[0]) return {'B': 'Batman: ', 'R': 'Robin: ', 'J': 'Joker: '}[hero[0]] + quotes[index]
class Node: starting = True ending = False name = "" weight = [1, 20] active = True edge_length = 0 nodes = [] def __init__(self, name, grid, posX, posY, active): self.name = name # Name of the node self.grid = grid # Which grid the node will be placed self.posX = posX # Position X on the grid self.posY = posY # Position Y on the grid self.active = active # Is active pass def add(self, newNode): #To DO self.nodes.append(newNode) print("Added new node") pass def remove(self, node): #To DO self.nodes = [] print("The node has been removed") pass def update(self, index, node): self.nodes.pop(index) self.nodes.insert(index, node) print("The node has been updated") pass
class Node: starting = True ending = False name = '' weight = [1, 20] active = True edge_length = 0 nodes = [] def __init__(self, name, grid, posX, posY, active): self.name = name self.grid = grid self.posX = posX self.posY = posY self.active = active pass def add(self, newNode): self.nodes.append(newNode) print('Added new node') pass def remove(self, node): self.nodes = [] print('The node has been removed') pass def update(self, index, node): self.nodes.pop(index) self.nodes.insert(index, node) print('The node has been updated') pass
#!/usr/bin/env python3 dna = "ATGCAGGGGAAACATGATTCAGGAC" #Make all lowercase lowerDNA = dna.lower() #Replace the complementary ones complA = lowerDNA.replace('a','T') complAT = complA.replace('t','A') complATG = complAT.replace('g','C') complATGC = complATG.replace('c','G') #reverse the complement revDNA = complATGC[::-1] #Print out the answers print("Original Sequence\t5'",dna,"5'") print("Complement\t\t3'",complATGC,"5'") print("Reverse Complement\t5'",revDNA,"3'")
dna = 'ATGCAGGGGAAACATGATTCAGGAC' lower_dna = dna.lower() compl_a = lowerDNA.replace('a', 'T') compl_at = complA.replace('t', 'A') compl_atg = complAT.replace('g', 'C') compl_atgc = complATG.replace('c', 'G') rev_dna = complATGC[::-1] print("Original Sequence\t5'", dna, "5'") print("Complement\t\t3'", complATGC, "5'") print("Reverse Complement\t5'", revDNA, "3'")
# with open("ReadMe.txt",'r') as file: # print(file.read()) # Hello from Python 201 # # Running after adding the second line to the .txt file # with open("ReadMe.txt",'r') as file: # print(file.read()) # Hello from Python 201 # # This is a new line # # Running after adding the second line to the .txt file # with open("ReadMe.txt",'r') as file: # pass # print(file.read()) # Traceback (most recent call last): # # File "ReadingFiles.py", line 15, in <module> # # print(file.read()) # # ValueError: I/O operation on closed file. # Assigning the content to a variable and then reading the file with open("ReadMe.txt",'r') as file: content = file.read() # python has closed the file print("The content is", content) # The content is Hello from Python 201 # This is a new line
with open('ReadMe.txt', 'r') as file: content = file.read() print('The content is', content)
OCTICON_LAW = """ <svg class="octicon octicon-law" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"></path></svg> """
octicon_law = '\n<svg class="octicon octicon-law" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M8.75.75a.75.75 0 00-1.5 0V2h-.984c-.305 0-.604.08-.869.23l-1.288.737A.25.25 0 013.984 3H1.75a.75.75 0 000 1.5h.428L.066 9.192a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.514 3.514 0 00.686.45A4.492 4.492 0 003 11c.88 0 1.556-.22 2.023-.454a3.515 3.515 0 00.686-.45l.045-.04.016-.015.006-.006.002-.002.001-.002L5.25 9.5l.53.53a.75.75 0 00.154-.838L3.822 4.5h.162c.305 0 .604-.08.869-.23l1.289-.737a.25.25 0 01.124-.033h.984V13h-2.5a.75.75 0 000 1.5h6.5a.75.75 0 000-1.5h-2.5V3.5h.984a.25.25 0 01.124.033l1.29.736c.264.152.563.231.868.231h.162l-2.112 4.692a.75.75 0 00.154.838l.53-.53-.53.53v.001l.002.002.002.002.006.006.016.015.045.04a3.517 3.517 0 00.686.45A4.492 4.492 0 0013 11c.88 0 1.556-.22 2.023-.454a3.512 3.512 0 00.686-.45l.045-.04.01-.01.006-.005.006-.006.002-.002.001-.002-.529-.531.53.53a.75.75 0 00.154-.838L13.823 4.5h.427a.75.75 0 000-1.5h-2.234a.25.25 0 01-.124-.033l-1.29-.736A1.75 1.75 0 009.735 2H8.75V.75zM1.695 9.227c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L3 6.327l-1.305 2.9zm10 0c.285.135.718.273 1.305.273s1.02-.138 1.305-.273L13 6.327l-1.305 2.9z"></path></svg>\n'
__all__ = ['__author__', '__license__', '__version__', '__credits__', '__maintainer__'] __author__ = 'Henrik Nyman' __license__ = 'MIT' __version__ = '0.1' __credits__ = ['Henrik Nyman'] __maintainer__ = 'Henrik Nyman'
__all__ = ['__author__', '__license__', '__version__', '__credits__', '__maintainer__'] __author__ = 'Henrik Nyman' __license__ = 'MIT' __version__ = '0.1' __credits__ = ['Henrik Nyman'] __maintainer__ = 'Henrik Nyman'
def projectData(X, U, K): """computes the projection of the normalized inputs X into the reduced dimensional space spanned by the first K columns of U. It returns the projected examples in Z. """ # ====================== YOUR CODE HERE ====================== # Instructions: Compute the projection of the data using only the top K # eigenvectors in U (first K columns). # For the i-th example X(i,:), the projection on to the k-th # eigenvector is given as follows: # x = X(i, :)' # projection_k = x' * U(:, k) # # ============================================================= return Z
def project_data(X, U, K): """computes the projection of the normalized inputs X into the reduced dimensional space spanned by the first K columns of U. It returns the projected examples in Z. """ return Z
def ssort(array): for i in range(len(array)): indxMin = i for j in range(i+1, len(array)): if array[j] < array[indxMin]: indxMin = j tmp = array[indxMin] array[indxMin] = array[i] array[i] = tmp return array
def ssort(array): for i in range(len(array)): indx_min = i for j in range(i + 1, len(array)): if array[j] < array[indxMin]: indx_min = j tmp = array[indxMin] array[indxMin] = array[i] array[i] = tmp return array
depl_user = 'darulez' depl_group = 'docker' # defaults file for ansible-docker-apps-generator assembly_path = 'apps-assembly' apps_path = './apps-universe' stacks_path = './stacks-universe' default_docker_network = 'hoa_network' docker_main_sections = ['docker_from', 'docker_init', 'docker_reqs', 'docker_core', 'docker_post']
depl_user = 'darulez' depl_group = 'docker' assembly_path = 'apps-assembly' apps_path = './apps-universe' stacks_path = './stacks-universe' default_docker_network = 'hoa_network' docker_main_sections = ['docker_from', 'docker_init', 'docker_reqs', 'docker_core', 'docker_post']
class Solution: def widthOfBinaryTree(self, root): """ :type root: TreeNode :rtype: int """ # bfs # corner case if root is None: return 0 queue = list() queue.append((root, 0)) level = 1 while len(queue) > 0: length = len(queue) tmp = list() for _ in range(length): curr, x = queue.pop(0) tmp.append(x) if curr.left: queue.append((curr.left, 2*x)) if curr.right: queue.append((curr.right, 2*x+1)) level = max(level, max(tmp)-min(tmp)+1) return level
class Solution: def width_of_binary_tree(self, root): """ :type root: TreeNode :rtype: int """ if root is None: return 0 queue = list() queue.append((root, 0)) level = 1 while len(queue) > 0: length = len(queue) tmp = list() for _ in range(length): (curr, x) = queue.pop(0) tmp.append(x) if curr.left: queue.append((curr.left, 2 * x)) if curr.right: queue.append((curr.right, 2 * x + 1)) level = max(level, max(tmp) - min(tmp) + 1) return level
class TrieNode(object): __slots__ = ('children', 'isWord') def __init__(self): self.children = {} self.isWord = False class Trie(object): def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def insert(self, word): """ Inserts a word into the trie. :type word: str :rtype: void """ root = self.root for c in word: if c not in root.children: root.children[c] = TrieNode() root = root.children[c] root.isWord = True def search(self, word): """ Returns if the word is in the trie. :type word: str :rtype: bool """ root = self.root for c in word: root = root.children.get(c) if root is None: return False return root.isWord def startsWith(self, prefix): """ Returns if there is any word in the trie that starts with the given prefix. :type prefix: str :rtype: bool """ root = self.root for c in prefix: root = root.children.get(c) if root is None: return False return True
class Trienode(object): __slots__ = ('children', 'isWord') def __init__(self): self.children = {} self.isWord = False class Trie(object): def __init__(self): """ Initialize your data structure here. """ self.root = trie_node() def insert(self, word): """ Inserts a word into the trie. :type word: str :rtype: void """ root = self.root for c in word: if c not in root.children: root.children[c] = trie_node() root = root.children[c] root.isWord = True def search(self, word): """ Returns if the word is in the trie. :type word: str :rtype: bool """ root = self.root for c in word: root = root.children.get(c) if root is None: return False return root.isWord def starts_with(self, prefix): """ Returns if there is any word in the trie that starts with the given prefix. :type prefix: str :rtype: bool """ root = self.root for c in prefix: root = root.children.get(c) if root is None: return False return True
class FastLabelException(Exception): def __init__(self, message, errcode): super(FastLabelException, self).__init__( "<Response [{}]> {}".format(errcode, message) ) self.code = errcode class FastLabelInvalidException(FastLabelException, ValueError): pass
class Fastlabelexception(Exception): def __init__(self, message, errcode): super(FastLabelException, self).__init__('<Response [{}]> {}'.format(errcode, message)) self.code = errcode class Fastlabelinvalidexception(FastLabelException, ValueError): pass
'''ALUMNA: HUAMANI TACOMA ANDY EJERCICIO : PAINT DASH GRIDS-DFS-RECURSIVE''' # DESCRIPCION: IMPLEMENTACION DE DFS-RECURSIVE PARA PINTAR LOS DASH GRIDS DE UNA MATRIZ def dfs_recursive(matrix, startX, startY, simbVisited, simbPared): # TABLERO, POSICION INICIALX, POSICION INICIALY, SIMBOLO VISITADO, SIMBOLO PARED try: if(matrix[startX][startY] != simbPared): # SI EL ELEMENTO NO ES PARED matrix[startX][startY] = simbVisited # SE CAMBIA POR EL SIMBOLO VISITADO else: # SI ES PARED NO SE VISITA print("es pared, no se pude pintar") # SE IMPRIME return matrix # SE RETORNA LA MATRIZ except: # SI LA POSICION ESTA FUERA DE LOS LIMITES print("Fuera del os limites") # SE IMPRIME return matrix # SE RETORNA LA MATRIZ print("Punto Central: (" + str(startX)+","+str(startY)+")") # SE IMPRIME LA POSICION DEL PUNTO CENTRAL dx = [-1,0,1,0] # VECTOR DE MOVIMIENTO EN X dy = [0,1,0,-1] # VECTOR DE MOVIMIENTO EN Y for i in range(4): # SE REALIZA EL RECORRIDO EN TODAS LAS DIRECCIONES nx = dx[i] + startX # SE OBTIENE LA POSICION EN X ny = dy[i] + startY # SE OBTIENE LA POSICION EN Y if((nx >= 0 and nx < len(matrix)) and (ny >= 0 and ny < len(matrix[startX]))): # SI LA POSICION ESTA DENTRO DEL TABLERO if(matrix[nx][ny] != simbVisited and matrix[nx][ny] != simbPared): # SI EL ELEMENTO NO ESTA VISITADO Y NO ES PARED dfs_recursive(matrix, nx, ny, simbVisited, simbPared) # SE LLAMA AL METODO RECURSIVO return matrix # SE RETORNA LA MATRIZ # IMPRIMIR LA MATRIZ def printMatrix(matrix): for i in matrix: for j in i: print(" " , j , end=" ") print() # CASO DE PRUEBA # MATRIZ matrix = [ ["#","#","#","#","#","#"], ["#","-","-","-","-","#"], ["#","-","-","-","-","#"], ["#","-","-","-","-","#"], ["#","-","-","-","#","-"], ["#","#","#","#","-","-"], ] # PRUEBA 01 # MATRIZ INICIAL printMatrix(matrix) # MATRIZ DE VISITADOS printMatrix(dfs_recursive(matrix, 1, 2, "o", "#")) print("\n---------------------------------------------------------") # PRUEBA 02 # MATRIZ INICIAL printMatrix(matrix) # MATRIZ DE VISITADOS printMatrix(dfs_recursive(matrix, 5, 5, "o", "#"))
"""ALUMNA: HUAMANI TACOMA ANDY EJERCICIO : PAINT DASH GRIDS-DFS-RECURSIVE""" def dfs_recursive(matrix, startX, startY, simbVisited, simbPared): try: if matrix[startX][startY] != simbPared: matrix[startX][startY] = simbVisited else: print('es pared, no se pude pintar') return matrix except: print('Fuera del os limites') return matrix print('Punto Central: (' + str(startX) + ',' + str(startY) + ')') dx = [-1, 0, 1, 0] dy = [0, 1, 0, -1] for i in range(4): nx = dx[i] + startX ny = dy[i] + startY if (nx >= 0 and nx < len(matrix)) and (ny >= 0 and ny < len(matrix[startX])): if matrix[nx][ny] != simbVisited and matrix[nx][ny] != simbPared: dfs_recursive(matrix, nx, ny, simbVisited, simbPared) return matrix def print_matrix(matrix): for i in matrix: for j in i: print(' ', j, end=' ') print() matrix = [['#', '#', '#', '#', '#', '#'], ['#', '-', '-', '-', '-', '#'], ['#', '-', '-', '-', '-', '#'], ['#', '-', '-', '-', '-', '#'], ['#', '-', '-', '-', '#', '-'], ['#', '#', '#', '#', '-', '-']] print_matrix(matrix) print_matrix(dfs_recursive(matrix, 1, 2, 'o', '#')) print('\n---------------------------------------------------------') print_matrix(matrix) print_matrix(dfs_recursive(matrix, 5, 5, 'o', '#'))
__all__ = ["PACK_HEADER_MAX"] # max scanned length of packet header PACK_HEADER_MAX = 60
__all__ = ['PACK_HEADER_MAX'] pack_header_max = 60
'''We sort a large sublist of a given list and go on reducing the size of the list until all elements are sorted.''' def shellSort(input_list): mid = len(input_list) // 2 while mid > 0: for i in range(mid, len(input_list)): temp = input_list[i] j = i # Sort the sub list for this gap while j >= mid and input_list[j - mid] > temp: input_list[j] = input_list[j - mid] j = j - mid input_list[j] = temp # Reduce the gap for the next element mid = mid // 2 list = [25, 2, 30, 1, 45, 39, 11, 110, 29] shellSort(list) print(list)
"""We sort a large sublist of a given list and go on reducing the size of the list until all elements are sorted.""" def shell_sort(input_list): mid = len(input_list) // 2 while mid > 0: for i in range(mid, len(input_list)): temp = input_list[i] j = i while j >= mid and input_list[j - mid] > temp: input_list[j] = input_list[j - mid] j = j - mid input_list[j] = temp mid = mid // 2 list = [25, 2, 30, 1, 45, 39, 11, 110, 29] shell_sort(list) print(list)
""" PASSENGERS """ numPassengers = 2341 passenger_arriving = ( (3, 12, 4, 1, 1, 0, 2, 7, 5, 7, 0, 0), # 0 (4, 12, 2, 2, 4, 0, 2, 5, 3, 3, 2, 0), # 1 (3, 2, 3, 2, 2, 0, 6, 7, 5, 5, 2, 0), # 2 (1, 10, 4, 2, 1, 0, 6, 5, 1, 4, 1, 0), # 3 (3, 3, 2, 5, 4, 0, 9, 6, 7, 3, 5, 0), # 4 (5, 7, 4, 2, 3, 0, 5, 7, 4, 5, 0, 0), # 5 (2, 9, 4, 1, 2, 0, 7, 5, 5, 4, 0, 0), # 6 (4, 6, 13, 3, 2, 0, 5, 5, 3, 4, 2, 0), # 7 (1, 2, 7, 4, 3, 0, 2, 6, 4, 6, 3, 0), # 8 (4, 7, 5, 2, 3, 0, 4, 2, 4, 6, 0, 0), # 9 (3, 3, 3, 3, 2, 0, 2, 5, 4, 5, 0, 0), # 10 (2, 2, 4, 3, 2, 0, 4, 2, 6, 0, 4, 0), # 11 (3, 10, 7, 0, 2, 0, 2, 5, 3, 1, 4, 0), # 12 (3, 9, 6, 2, 0, 0, 4, 10, 3, 4, 1, 0), # 13 (5, 6, 6, 3, 1, 0, 5, 6, 3, 4, 0, 0), # 14 (1, 7, 8, 1, 3, 0, 3, 6, 4, 4, 1, 0), # 15 (7, 5, 6, 0, 1, 0, 3, 8, 4, 6, 2, 0), # 16 (0, 4, 5, 3, 4, 0, 4, 6, 6, 3, 3, 0), # 17 (6, 8, 6, 3, 1, 0, 5, 2, 6, 1, 1, 0), # 18 (3, 8, 8, 2, 2, 0, 5, 7, 9, 2, 0, 0), # 19 (3, 5, 6, 4, 2, 0, 8, 8, 4, 3, 2, 0), # 20 (6, 9, 4, 1, 3, 0, 7, 8, 4, 2, 3, 0), # 21 (3, 4, 4, 3, 3, 0, 3, 11, 3, 3, 1, 0), # 22 (3, 8, 3, 2, 0, 0, 4, 4, 4, 4, 2, 0), # 23 (2, 5, 7, 5, 2, 0, 3, 9, 6, 4, 2, 0), # 24 (3, 7, 3, 2, 1, 0, 4, 11, 3, 5, 2, 0), # 25 (0, 12, 5, 0, 2, 0, 3, 6, 4, 2, 2, 0), # 26 (4, 7, 5, 1, 2, 0, 4, 5, 6, 1, 5, 0), # 27 (4, 3, 6, 1, 1, 0, 4, 4, 4, 5, 3, 0), # 28 (1, 8, 6, 3, 3, 0, 4, 5, 5, 6, 1, 0), # 29 (5, 4, 4, 0, 1, 0, 3, 5, 5, 8, 2, 0), # 30 (4, 6, 5, 4, 0, 0, 5, 4, 3, 1, 1, 0), # 31 (4, 10, 4, 2, 0, 0, 3, 2, 7, 6, 1, 0), # 32 (3, 4, 4, 2, 4, 0, 6, 5, 3, 3, 1, 0), # 33 (7, 3, 2, 2, 2, 0, 4, 7, 3, 5, 0, 0), # 34 (5, 8, 6, 3, 3, 0, 7, 7, 3, 4, 0, 0), # 35 (2, 8, 3, 1, 0, 0, 6, 4, 3, 3, 3, 0), # 36 (6, 8, 6, 2, 1, 0, 8, 7, 8, 0, 3, 0), # 37 (0, 6, 4, 5, 0, 0, 2, 7, 3, 2, 2, 0), # 38 (4, 2, 3, 3, 1, 0, 6, 8, 7, 3, 0, 0), # 39 (3, 5, 2, 3, 1, 0, 5, 3, 10, 4, 3, 0), # 40 (6, 5, 7, 2, 0, 0, 6, 4, 1, 4, 4, 0), # 41 (7, 8, 5, 5, 0, 0, 4, 13, 1, 3, 1, 0), # 42 (3, 10, 8, 2, 2, 0, 8, 4, 9, 4, 4, 0), # 43 (4, 6, 7, 4, 0, 0, 8, 7, 4, 0, 0, 0), # 44 (3, 7, 7, 2, 2, 0, 9, 6, 4, 2, 1, 0), # 45 (2, 14, 5, 2, 2, 0, 3, 8, 1, 1, 2, 0), # 46 (8, 4, 2, 1, 2, 0, 8, 6, 2, 3, 0, 0), # 47 (4, 5, 6, 1, 0, 0, 5, 7, 3, 2, 1, 0), # 48 (4, 4, 3, 1, 1, 0, 3, 5, 2, 6, 2, 0), # 49 (1, 9, 5, 6, 0, 0, 7, 5, 5, 1, 2, 0), # 50 (5, 3, 6, 2, 1, 0, 8, 3, 6, 3, 1, 0), # 51 (2, 8, 6, 9, 1, 0, 12, 1, 8, 3, 2, 0), # 52 (4, 8, 7, 3, 0, 0, 8, 8, 5, 4, 0, 0), # 53 (5, 7, 2, 1, 0, 0, 4, 8, 0, 5, 2, 0), # 54 (1, 9, 9, 3, 0, 0, 2, 9, 4, 7, 1, 0), # 55 (2, 8, 6, 3, 4, 0, 3, 11, 5, 4, 3, 0), # 56 (6, 5, 3, 2, 1, 0, 5, 6, 4, 1, 2, 0), # 57 (3, 6, 6, 3, 2, 0, 3, 3, 4, 4, 2, 0), # 58 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), # 59 ) station_arriving_intensity = ( (2.649651558384548, 6.796460700757575, 7.9942360218509, 6.336277173913043, 7.143028846153846, 4.75679347826087), # 0 (2.6745220100478, 6.872041598712823, 8.037415537524994, 6.371564387077295, 7.196566506410256, 4.7551721391908215), # 1 (2.699108477221734, 6.946501402918069, 8.07957012282205, 6.406074879227053, 7.248974358974359, 4.753501207729468), # 2 (2.72339008999122, 7.019759765625, 8.120668982969152, 6.4397792119565205, 7.300204326923078, 4.7517809103260875), # 3 (2.747345978441128, 7.091736339085298, 8.160681323193373, 6.472647946859904, 7.350208333333334, 4.750011473429951), # 4 (2.7709552726563262, 7.162350775550646, 8.199576348721793, 6.504651645531401, 7.39893830128205, 4.748193123490338), # 5 (2.794197102721686, 7.231522727272727, 8.237323264781493, 6.535760869565218, 7.446346153846154, 4.746326086956522), # 6 (2.817050598722076, 7.299171846503226, 8.273891276599542, 6.565946180555556, 7.492383814102565, 4.744410590277778), # 7 (2.8394948907423667, 7.365217785493826, 8.309249589403029, 6.595178140096618, 7.537003205128205, 4.7424468599033816), # 8 (2.8615091088674274, 7.429580196496212, 8.343367408419024, 6.623427309782609, 7.580156249999999, 4.740435122282609), # 9 (2.8830723831821286, 7.492178731762065, 8.376213938874606, 6.65066425120773, 7.621794871794872, 4.738375603864734), # 10 (2.9041638437713395, 7.55293304354307, 8.407758385996857, 6.676859525966184, 7.661870993589743, 4.736268531099034), # 11 (2.92476262071993, 7.611762784090908, 8.437969955012854, 6.7019836956521734, 7.700336538461538, 4.734114130434782), # 12 (2.944847844112769, 7.668587605657268, 8.46681785114967, 6.726007321859903, 7.737143429487181, 4.731912628321256), # 13 (2.9643986440347283, 7.723327160493828, 8.494271279634388, 6.748900966183574, 7.772243589743589, 4.729664251207729), # 14 (2.9833941505706756, 7.775901100852272, 8.520299445694086, 6.770635190217391, 7.8055889423076925, 4.7273692255434785), # 15 (3.001813493805482, 7.826229078984287, 8.544871554555842, 6.791180555555555, 7.8371314102564105, 4.725027777777778), # 16 (3.019635803824017, 7.874230747141554, 8.567956811446729, 6.810507623792271, 7.866822916666667, 4.722640134359904), # 17 (3.03684021071115, 7.919825757575757, 8.589524421593831, 6.82858695652174, 7.894615384615387, 4.72020652173913), # 18 (3.053405844551751, 7.962933762538579, 8.609543590224222, 6.845389115338164, 7.9204607371794875, 4.717727166364734), # 19 (3.0693118354306894, 8.003474414281705, 8.62798352256498, 6.860884661835749, 7.944310897435898, 4.71520229468599), # 20 (3.084537313432836, 8.041367365056816, 8.644813423843189, 6.875044157608696, 7.9661177884615375, 4.712632133152174), # 21 (3.099061408643059, 8.076532267115601, 8.660002499285918, 6.887838164251208, 7.985833333333332, 4.710016908212561), # 22 (3.1128632511462295, 8.108888772709737, 8.673519954120252, 6.899237243357488, 8.003409455128205, 4.707356846316426), # 23 (3.125921971027217, 8.138356534090908, 8.685334993573264, 6.909211956521739, 8.018798076923076, 4.704652173913043), # 24 (3.1382166983708903, 8.164855203510802, 8.695416822872037, 6.917732865338165, 8.03195112179487, 4.701903117451691), # 25 (3.1497265632621207, 8.188304433221099, 8.703734647243644, 6.9247705314009655, 8.042820512820512, 4.699109903381642), # 26 (3.160430695785777, 8.208623875473483, 8.710257671915166, 6.930295516304349, 8.051358173076924, 4.696272758152174), # 27 (3.1703082260267292, 8.22573318251964, 8.714955102113683, 6.934278381642512, 8.057516025641025, 4.69339190821256), # 28 (3.1793382840698468, 8.239552006611252, 8.717796143066266, 6.936689689009662, 8.061245993589743, 4.690467580012077), # 29 (3.1875, 8.25, 8.71875, 6.9375, 8.0625, 4.6875), # 30 (3.1951370284526854, 8.258678799715907, 8.718034948671496, 6.937353656045752, 8.062043661347518, 4.683376259786773), # 31 (3.202609175191816, 8.267242897727273, 8.715910024154589, 6.93691748366013, 8.06068439716312, 4.677024758454107), # 32 (3.2099197969948845, 8.275691228693182, 8.712405570652175, 6.936195772058824, 8.058436835106383, 4.66850768365817), # 33 (3.217072250639386, 8.284022727272728, 8.70755193236715, 6.935192810457517, 8.05531560283688, 4.657887223055139), # 34 (3.224069892902813, 8.292236328124998, 8.701379453502415, 6.933912888071895, 8.051335328014185, 4.645225564301183), # 35 (3.23091608056266, 8.300330965909092, 8.69391847826087, 6.932360294117648, 8.046510638297873, 4.630584895052474), # 36 (3.2376141703964194, 8.308305575284091, 8.68519935084541, 6.9305393178104575, 8.040856161347516, 4.614027402965184), # 37 (3.2441675191815853, 8.31615909090909, 8.675252415458937, 6.9284542483660125, 8.034386524822695, 4.595615275695485), # 38 (3.250579483695652, 8.323890447443182, 8.664108016304347, 6.926109375, 8.027116356382978, 4.57541070089955), # 39 (3.2568534207161126, 8.331498579545455, 8.651796497584542, 6.923508986928105, 8.019060283687942, 4.5534758662335495), # 40 (3.26299268702046, 8.338982421874999, 8.638348203502416, 6.920657373366013, 8.010232934397163, 4.529872959353657), # 41 (3.269000639386189, 8.34634090909091, 8.62379347826087, 6.917558823529411, 8.000648936170213, 4.504664167916042), # 42 (3.2748806345907933, 8.353572975852272, 8.608162666062801, 6.914217626633987, 7.990322916666666, 4.477911679576878), # 43 (3.2806360294117645, 8.360677556818182, 8.591486111111111, 6.910638071895424, 7.979269503546099, 4.449677681992337), # 44 (3.286270180626598, 8.367653586647727, 8.573794157608697, 6.906824448529411, 7.967503324468085, 4.420024362818591), # 45 (3.291786445012788, 8.374500000000001, 8.555117149758455, 6.902781045751634, 7.955039007092199, 4.389013909711811), # 46 (3.297188179347826, 8.381215731534091, 8.535485431763284, 6.898512152777777, 7.941891179078015, 4.356708510328169), # 47 (3.3024787404092075, 8.387799715909091, 8.514929347826087, 6.894022058823529, 7.928074468085106, 4.323170352323839), # 48 (3.307661484974424, 8.39425088778409, 8.493479242149759, 6.889315053104576, 7.91360350177305, 4.288461623354989), # 49 (3.312739769820972, 8.40056818181818, 8.471165458937199, 6.884395424836602, 7.898492907801418, 4.252644511077794), # 50 (3.317716951726343, 8.406750532670454, 8.448018342391304, 6.879267463235294, 7.882757313829787, 4.215781203148426), # 51 (3.322596387468031, 8.412796875, 8.424068236714975, 6.87393545751634, 7.86641134751773, 4.177933887223055), # 52 (3.3273814338235295, 8.41870614346591, 8.39934548611111, 6.868403696895425, 7.849469636524823, 4.139164750957854), # 53 (3.332075447570333, 8.424477272727271, 8.373880434782608, 6.8626764705882355, 7.831946808510638, 4.099535982008995), # 54 (3.336681785485933, 8.430109197443182, 8.347703426932366, 6.856758067810458, 7.813857491134752, 4.05910976803265), # 55 (3.341203804347826, 8.435600852272726, 8.320844806763285, 6.8506527777777775, 7.795216312056738, 4.017948296684991), # 56 (3.345644860933504, 8.440951171875001, 8.29333491847826, 6.844364889705882, 7.77603789893617, 3.9761137556221886), # 57 (3.3500083120204605, 8.44615909090909, 8.265204106280192, 6.837898692810458, 7.756336879432624, 3.9336683325004165), # 58 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 59 ) passenger_arriving_acc = ( (3, 12, 4, 1, 1, 0, 2, 7, 5, 7, 0, 0), # 0 (7, 24, 6, 3, 5, 0, 4, 12, 8, 10, 2, 0), # 1 (10, 26, 9, 5, 7, 0, 10, 19, 13, 15, 4, 0), # 2 (11, 36, 13, 7, 8, 0, 16, 24, 14, 19, 5, 0), # 3 (14, 39, 15, 12, 12, 0, 25, 30, 21, 22, 10, 0), # 4 (19, 46, 19, 14, 15, 0, 30, 37, 25, 27, 10, 0), # 5 (21, 55, 23, 15, 17, 0, 37, 42, 30, 31, 10, 0), # 6 (25, 61, 36, 18, 19, 0, 42, 47, 33, 35, 12, 0), # 7 (26, 63, 43, 22, 22, 0, 44, 53, 37, 41, 15, 0), # 8 (30, 70, 48, 24, 25, 0, 48, 55, 41, 47, 15, 0), # 9 (33, 73, 51, 27, 27, 0, 50, 60, 45, 52, 15, 0), # 10 (35, 75, 55, 30, 29, 0, 54, 62, 51, 52, 19, 0), # 11 (38, 85, 62, 30, 31, 0, 56, 67, 54, 53, 23, 0), # 12 (41, 94, 68, 32, 31, 0, 60, 77, 57, 57, 24, 0), # 13 (46, 100, 74, 35, 32, 0, 65, 83, 60, 61, 24, 0), # 14 (47, 107, 82, 36, 35, 0, 68, 89, 64, 65, 25, 0), # 15 (54, 112, 88, 36, 36, 0, 71, 97, 68, 71, 27, 0), # 16 (54, 116, 93, 39, 40, 0, 75, 103, 74, 74, 30, 0), # 17 (60, 124, 99, 42, 41, 0, 80, 105, 80, 75, 31, 0), # 18 (63, 132, 107, 44, 43, 0, 85, 112, 89, 77, 31, 0), # 19 (66, 137, 113, 48, 45, 0, 93, 120, 93, 80, 33, 0), # 20 (72, 146, 117, 49, 48, 0, 100, 128, 97, 82, 36, 0), # 21 (75, 150, 121, 52, 51, 0, 103, 139, 100, 85, 37, 0), # 22 (78, 158, 124, 54, 51, 0, 107, 143, 104, 89, 39, 0), # 23 (80, 163, 131, 59, 53, 0, 110, 152, 110, 93, 41, 0), # 24 (83, 170, 134, 61, 54, 0, 114, 163, 113, 98, 43, 0), # 25 (83, 182, 139, 61, 56, 0, 117, 169, 117, 100, 45, 0), # 26 (87, 189, 144, 62, 58, 0, 121, 174, 123, 101, 50, 0), # 27 (91, 192, 150, 63, 59, 0, 125, 178, 127, 106, 53, 0), # 28 (92, 200, 156, 66, 62, 0, 129, 183, 132, 112, 54, 0), # 29 (97, 204, 160, 66, 63, 0, 132, 188, 137, 120, 56, 0), # 30 (101, 210, 165, 70, 63, 0, 137, 192, 140, 121, 57, 0), # 31 (105, 220, 169, 72, 63, 0, 140, 194, 147, 127, 58, 0), # 32 (108, 224, 173, 74, 67, 0, 146, 199, 150, 130, 59, 0), # 33 (115, 227, 175, 76, 69, 0, 150, 206, 153, 135, 59, 0), # 34 (120, 235, 181, 79, 72, 0, 157, 213, 156, 139, 59, 0), # 35 (122, 243, 184, 80, 72, 0, 163, 217, 159, 142, 62, 0), # 36 (128, 251, 190, 82, 73, 0, 171, 224, 167, 142, 65, 0), # 37 (128, 257, 194, 87, 73, 0, 173, 231, 170, 144, 67, 0), # 38 (132, 259, 197, 90, 74, 0, 179, 239, 177, 147, 67, 0), # 39 (135, 264, 199, 93, 75, 0, 184, 242, 187, 151, 70, 0), # 40 (141, 269, 206, 95, 75, 0, 190, 246, 188, 155, 74, 0), # 41 (148, 277, 211, 100, 75, 0, 194, 259, 189, 158, 75, 0), # 42 (151, 287, 219, 102, 77, 0, 202, 263, 198, 162, 79, 0), # 43 (155, 293, 226, 106, 77, 0, 210, 270, 202, 162, 79, 0), # 44 (158, 300, 233, 108, 79, 0, 219, 276, 206, 164, 80, 0), # 45 (160, 314, 238, 110, 81, 0, 222, 284, 207, 165, 82, 0), # 46 (168, 318, 240, 111, 83, 0, 230, 290, 209, 168, 82, 0), # 47 (172, 323, 246, 112, 83, 0, 235, 297, 212, 170, 83, 0), # 48 (176, 327, 249, 113, 84, 0, 238, 302, 214, 176, 85, 0), # 49 (177, 336, 254, 119, 84, 0, 245, 307, 219, 177, 87, 0), # 50 (182, 339, 260, 121, 85, 0, 253, 310, 225, 180, 88, 0), # 51 (184, 347, 266, 130, 86, 0, 265, 311, 233, 183, 90, 0), # 52 (188, 355, 273, 133, 86, 0, 273, 319, 238, 187, 90, 0), # 53 (193, 362, 275, 134, 86, 0, 277, 327, 238, 192, 92, 0), # 54 (194, 371, 284, 137, 86, 0, 279, 336, 242, 199, 93, 0), # 55 (196, 379, 290, 140, 90, 0, 282, 347, 247, 203, 96, 0), # 56 (202, 384, 293, 142, 91, 0, 287, 353, 251, 204, 98, 0), # 57 (205, 390, 299, 145, 93, 0, 290, 356, 255, 208, 100, 0), # 58 (205, 390, 299, 145, 93, 0, 290, 356, 255, 208, 100, 0), # 59 ) passenger_arriving_rate = ( (2.649651558384548, 5.43716856060606, 4.79654161311054, 2.534510869565217, 1.428605769230769, 0.0, 4.75679347826087, 5.714423076923076, 3.801766304347826, 3.1976944087403596, 1.359292140151515, 0.0), # 0 (2.6745220100478, 5.497633278970258, 4.822449322514997, 2.5486257548309177, 1.439313301282051, 0.0, 4.7551721391908215, 5.757253205128204, 3.8229386322463768, 3.2149662150099974, 1.3744083197425645, 0.0), # 1 (2.699108477221734, 5.557201122334455, 4.8477420736932295, 2.562429951690821, 1.4497948717948717, 0.0, 4.753501207729468, 5.799179487179487, 3.8436449275362317, 3.23182804912882, 1.3893002805836137, 0.0), # 2 (2.72339008999122, 5.6158078125, 4.872401389781491, 2.575911684782608, 1.4600408653846155, 0.0, 4.7517809103260875, 5.840163461538462, 3.863867527173912, 3.2482675931876606, 1.403951953125, 0.0), # 3 (2.747345978441128, 5.673389071268238, 4.896408793916024, 2.589059178743961, 1.4700416666666667, 0.0, 4.750011473429951, 5.880166666666667, 3.883588768115942, 3.2642725292773487, 1.4183472678170594, 0.0), # 4 (2.7709552726563262, 5.729880620440516, 4.919745809233076, 2.6018606582125603, 1.47978766025641, 0.0, 4.748193123490338, 5.91915064102564, 3.9027909873188404, 3.279830539488717, 1.432470155110129, 0.0), # 5 (2.794197102721686, 5.785218181818181, 4.942393958868895, 2.614304347826087, 1.4892692307692306, 0.0, 4.746326086956522, 5.957076923076922, 3.9214565217391306, 3.294929305912597, 1.4463045454545453, 0.0), # 6 (2.817050598722076, 5.83933747720258, 4.964334765959725, 2.626378472222222, 1.498476762820513, 0.0, 4.744410590277778, 5.993907051282052, 3.939567708333333, 3.309556510639817, 1.459834369300645, 0.0), # 7 (2.8394948907423667, 5.89217422839506, 4.985549753641817, 2.638071256038647, 1.5074006410256409, 0.0, 4.7424468599033816, 6.0296025641025635, 3.9571068840579704, 3.3236998357612113, 1.473043557098765, 0.0), # 8 (2.8615091088674274, 5.943664157196969, 5.006020445051414, 2.649370923913043, 1.5160312499999997, 0.0, 4.740435122282609, 6.064124999999999, 3.9740563858695652, 3.3373469633676094, 1.4859160392992423, 0.0), # 9 (2.8830723831821286, 5.993742985409652, 5.025728363324764, 2.660265700483092, 1.5243589743589743, 0.0, 4.738375603864734, 6.097435897435897, 3.990398550724638, 3.3504855755498424, 1.498435746352413, 0.0), # 10 (2.9041638437713395, 6.042346434834456, 5.044655031598114, 2.6707438103864733, 1.5323741987179484, 0.0, 4.736268531099034, 6.129496794871794, 4.0061157155797105, 3.3631033543987425, 1.510586608708614, 0.0), # 11 (2.92476262071993, 6.089410227272726, 5.062781973007712, 2.680793478260869, 1.5400673076923075, 0.0, 4.734114130434782, 6.16026923076923, 4.021190217391304, 3.375187982005141, 1.5223525568181815, 0.0), # 12 (2.944847844112769, 6.134870084525814, 5.080090710689802, 2.690402928743961, 1.547428685897436, 0.0, 4.731912628321256, 6.189714743589744, 4.035604393115942, 3.386727140459868, 1.5337175211314535, 0.0), # 13 (2.9643986440347283, 6.1786617283950624, 5.096562767780632, 2.699560386473429, 1.5544487179487176, 0.0, 4.729664251207729, 6.217794871794871, 4.049340579710144, 3.397708511853755, 1.5446654320987656, 0.0), # 14 (2.9833941505706756, 6.220720880681816, 5.112179667416451, 2.708254076086956, 1.5611177884615384, 0.0, 4.7273692255434785, 6.2444711538461535, 4.062381114130434, 3.408119778277634, 1.555180220170454, 0.0), # 15 (3.001813493805482, 6.26098326318743, 5.126922932733505, 2.716472222222222, 1.5674262820512819, 0.0, 4.725027777777778, 6.2697051282051275, 4.074708333333333, 3.4179486218223363, 1.5652458157968574, 0.0), # 16 (3.019635803824017, 6.299384597713242, 5.140774086868038, 2.724203049516908, 1.5733645833333332, 0.0, 4.722640134359904, 6.293458333333333, 4.0863045742753625, 3.4271827245786914, 1.5748461494283106, 0.0), # 17 (3.03684021071115, 6.3358606060606055, 5.153714652956299, 2.7314347826086958, 1.578923076923077, 0.0, 4.72020652173913, 6.315692307692308, 4.097152173913043, 3.435809768637532, 1.5839651515151514, 0.0), # 18 (3.053405844551751, 6.370347010030863, 5.165726154134533, 2.738155646135265, 1.5840921474358973, 0.0, 4.717727166364734, 6.336368589743589, 4.107233469202898, 3.4438174360896885, 1.5925867525077158, 0.0), # 19 (3.0693118354306894, 6.402779531425363, 5.1767901135389875, 2.7443538647342995, 1.5888621794871793, 0.0, 4.71520229468599, 6.355448717948717, 4.11653079710145, 3.4511934090259917, 1.6006948828563408, 0.0), # 20 (3.084537313432836, 6.433093892045452, 5.186888054305913, 2.750017663043478, 1.5932235576923073, 0.0, 4.712632133152174, 6.372894230769229, 4.125026494565217, 3.4579253695372754, 1.608273473011363, 0.0), # 21 (3.099061408643059, 6.46122581369248, 5.19600149957155, 2.7551352657004826, 1.5971666666666662, 0.0, 4.710016908212561, 6.388666666666665, 4.132702898550725, 3.464000999714367, 1.61530645342312, 0.0), # 22 (3.1128632511462295, 6.487111018167789, 5.204111972472151, 2.759694897342995, 1.6006818910256408, 0.0, 4.707356846316426, 6.402727564102563, 4.139542346014493, 3.4694079816481005, 1.6217777545419472, 0.0), # 23 (3.125921971027217, 6.5106852272727265, 5.211200996143958, 2.763684782608695, 1.6037596153846152, 0.0, 4.704652173913043, 6.415038461538461, 4.1455271739130435, 3.474133997429305, 1.6276713068181816, 0.0), # 24 (3.1382166983708903, 6.531884162808641, 5.217250093723222, 2.7670931461352657, 1.606390224358974, 0.0, 4.701903117451691, 6.425560897435896, 4.150639719202899, 3.4781667291488145, 1.6329710407021603, 0.0), # 25 (3.1497265632621207, 6.550643546576878, 5.222240788346187, 2.7699082125603858, 1.6085641025641022, 0.0, 4.699109903381642, 6.434256410256409, 4.154862318840579, 3.4814938588974575, 1.6376608866442195, 0.0), # 26 (3.160430695785777, 6.566899100378786, 5.226154603149099, 2.772118206521739, 1.6102716346153847, 0.0, 4.696272758152174, 6.441086538461539, 4.158177309782609, 3.484103068766066, 1.6417247750946966, 0.0), # 27 (3.1703082260267292, 6.580586546015712, 5.228973061268209, 2.7737113526570045, 1.6115032051282048, 0.0, 4.69339190821256, 6.446012820512819, 4.160567028985507, 3.4859820408454727, 1.645146636503928, 0.0), # 28 (3.1793382840698468, 6.591641605289001, 5.230677685839759, 2.7746758756038647, 1.6122491987179486, 0.0, 4.690467580012077, 6.448996794871794, 4.162013813405797, 3.487118457226506, 1.6479104013222503, 0.0), # 29 (3.1875, 6.6, 5.23125, 2.775, 1.6124999999999998, 0.0, 4.6875, 6.449999999999999, 4.1625, 3.4875, 1.65, 0.0), # 30 (3.1951370284526854, 6.606943039772726, 5.230820969202898, 2.7749414624183006, 1.6124087322695035, 0.0, 4.683376259786773, 6.449634929078014, 4.162412193627451, 3.4872139794685983, 1.6517357599431814, 0.0), # 31 (3.202609175191816, 6.613794318181818, 5.229546014492753, 2.7747669934640515, 1.6121368794326238, 0.0, 4.677024758454107, 6.448547517730495, 4.162150490196078, 3.4863640096618354, 1.6534485795454545, 0.0), # 32 (3.2099197969948845, 6.620552982954545, 5.227443342391305, 2.774478308823529, 1.6116873670212764, 0.0, 4.66850768365817, 6.446749468085105, 4.161717463235294, 3.4849622282608697, 1.6551382457386363, 0.0), # 33 (3.217072250639386, 6.627218181818182, 5.224531159420289, 2.7740771241830067, 1.6110631205673758, 0.0, 4.657887223055139, 6.444252482269503, 4.16111568627451, 3.4830207729468596, 1.6568045454545455, 0.0), # 34 (3.224069892902813, 6.633789062499998, 5.220827672101449, 2.773565155228758, 1.6102670656028368, 0.0, 4.645225564301183, 6.441068262411347, 4.160347732843137, 3.480551781400966, 1.6584472656249996, 0.0), # 35 (3.23091608056266, 6.6402647727272734, 5.2163510869565215, 2.7729441176470586, 1.6093021276595745, 0.0, 4.630584895052474, 6.437208510638298, 4.159416176470589, 3.477567391304347, 1.6600661931818184, 0.0), # 36 (3.2376141703964194, 6.6466444602272725, 5.211119610507246, 2.7722157271241827, 1.6081712322695032, 0.0, 4.614027402965184, 6.432684929078013, 4.158323590686274, 3.474079740338164, 1.6616611150568181, 0.0), # 37 (3.2441675191815853, 6.652927272727272, 5.205151449275362, 2.7713816993464047, 1.6068773049645388, 0.0, 4.595615275695485, 6.427509219858155, 4.157072549019607, 3.4701009661835744, 1.663231818181818, 0.0), # 38 (3.250579483695652, 6.659112357954545, 5.198464809782608, 2.7704437499999996, 1.6054232712765955, 0.0, 4.57541070089955, 6.421693085106382, 4.155665625, 3.4656432065217384, 1.6647780894886361, 0.0), # 39 (3.2568534207161126, 6.6651988636363635, 5.191077898550724, 2.7694035947712417, 1.6038120567375882, 0.0, 4.5534758662335495, 6.415248226950353, 4.154105392156863, 3.4607185990338163, 1.6662997159090909, 0.0), # 40 (3.26299268702046, 6.671185937499998, 5.1830089221014495, 2.768262949346405, 1.6020465868794325, 0.0, 4.529872959353657, 6.40818634751773, 4.152394424019608, 3.455339281400966, 1.6677964843749995, 0.0), # 41 (3.269000639386189, 6.677072727272728, 5.174276086956522, 2.767023529411764, 1.6001297872340425, 0.0, 4.504664167916042, 6.40051914893617, 4.150535294117646, 3.4495173913043478, 1.669268181818182, 0.0), # 42 (3.2748806345907933, 6.682858380681817, 5.164897599637681, 2.7656870506535944, 1.5980645833333331, 0.0, 4.477911679576878, 6.3922583333333325, 4.148530575980392, 3.4432650664251203, 1.6707145951704543, 0.0), # 43 (3.2806360294117645, 6.688542045454545, 5.154891666666667, 2.7642552287581696, 1.5958539007092198, 0.0, 4.449677681992337, 6.383415602836879, 4.146382843137254, 3.4365944444444443, 1.6721355113636363, 0.0), # 44 (3.286270180626598, 6.694122869318181, 5.144276494565218, 2.7627297794117642, 1.593500664893617, 0.0, 4.420024362818591, 6.374002659574468, 4.144094669117647, 3.4295176630434785, 1.6735307173295453, 0.0), # 45 (3.291786445012788, 6.6996, 5.133070289855073, 2.761112418300653, 1.5910078014184397, 0.0, 4.389013909711811, 6.364031205673759, 4.14166862745098, 3.4220468599033818, 1.6749, 0.0), # 46 (3.297188179347826, 6.704972585227273, 5.12129125905797, 2.759404861111111, 1.588378235815603, 0.0, 4.356708510328169, 6.353512943262412, 4.139107291666666, 3.4141941727053133, 1.6762431463068181, 0.0), # 47 (3.3024787404092075, 6.710239772727273, 5.108957608695651, 2.757608823529411, 1.5856148936170211, 0.0, 4.323170352323839, 6.3424595744680845, 4.136413235294117, 3.4059717391304343, 1.6775599431818182, 0.0), # 48 (3.307661484974424, 6.715400710227271, 5.096087545289855, 2.75572602124183, 1.5827207003546098, 0.0, 4.288461623354989, 6.330882801418439, 4.133589031862745, 3.3973916968599034, 1.6788501775568176, 0.0), # 49 (3.312739769820972, 6.720454545454543, 5.082699275362319, 2.7537581699346405, 1.5796985815602835, 0.0, 4.252644511077794, 6.318794326241134, 4.130637254901961, 3.388466183574879, 1.6801136363636358, 0.0), # 50 (3.317716951726343, 6.725400426136363, 5.068811005434783, 2.7517069852941174, 1.5765514627659571, 0.0, 4.215781203148426, 6.306205851063829, 4.127560477941176, 3.3792073369565214, 1.6813501065340908, 0.0), # 51 (3.322596387468031, 6.730237499999999, 5.054440942028985, 2.7495741830065357, 1.573282269503546, 0.0, 4.177933887223055, 6.293129078014184, 4.124361274509804, 3.3696272946859898, 1.6825593749999999, 0.0), # 52 (3.3273814338235295, 6.7349649147727275, 5.039607291666666, 2.7473614787581697, 1.5698939273049646, 0.0, 4.139164750957854, 6.279575709219858, 4.121042218137255, 3.359738194444444, 1.6837412286931819, 0.0), # 53 (3.332075447570333, 6.739581818181817, 5.024328260869565, 2.745070588235294, 1.5663893617021276, 0.0, 4.099535982008995, 6.2655574468085105, 4.117605882352941, 3.3495521739130427, 1.6848954545454542, 0.0), # 54 (3.336681785485933, 6.744087357954545, 5.008622056159419, 2.7427032271241827, 1.5627714982269503, 0.0, 4.05910976803265, 6.251085992907801, 4.114054840686275, 3.3390813707729463, 1.6860218394886362, 0.0), # 55 (3.341203804347826, 6.74848068181818, 4.9925068840579705, 2.740261111111111, 1.5590432624113475, 0.0, 4.017948296684991, 6.23617304964539, 4.110391666666667, 3.328337922705314, 1.687120170454545, 0.0), # 56 (3.345644860933504, 6.752760937500001, 4.976000951086956, 2.7377459558823527, 1.5552075797872338, 0.0, 3.9761137556221886, 6.220830319148935, 4.106618933823529, 3.317333967391304, 1.6881902343750002, 0.0), # 57 (3.3500083120204605, 6.756927272727271, 4.959122463768115, 2.7351594771241827, 1.5512673758865245, 0.0, 3.9336683325004165, 6.205069503546098, 4.102739215686275, 3.3060816425120767, 1.6892318181818178, 0.0), # 58 (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0), # 59 ) passenger_allighting_rate = ( (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 0 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 1 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 2 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 3 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 4 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 5 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 6 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 7 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 8 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 9 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 10 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 11 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 12 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 13 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 14 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 15 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 16 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 17 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 18 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 19 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 20 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 21 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 22 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 23 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 24 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 25 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 26 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 27 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 28 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 29 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 30 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 31 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 32 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 33 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 34 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 35 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 36 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 37 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 38 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 39 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 40 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 41 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 42 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 43 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 44 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 45 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 46 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 47 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 48 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 49 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 50 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 51 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 52 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 53 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 54 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 55 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 56 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 57 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 58 (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), # 59 ) """ parameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html """ #initial entropy entropy = 258194110137029475889902652135037600173 #index for seed sequence child child_seed_index = ( 1, # 0 38, # 1 )
""" PASSENGERS """ num_passengers = 2341 passenger_arriving = ((3, 12, 4, 1, 1, 0, 2, 7, 5, 7, 0, 0), (4, 12, 2, 2, 4, 0, 2, 5, 3, 3, 2, 0), (3, 2, 3, 2, 2, 0, 6, 7, 5, 5, 2, 0), (1, 10, 4, 2, 1, 0, 6, 5, 1, 4, 1, 0), (3, 3, 2, 5, 4, 0, 9, 6, 7, 3, 5, 0), (5, 7, 4, 2, 3, 0, 5, 7, 4, 5, 0, 0), (2, 9, 4, 1, 2, 0, 7, 5, 5, 4, 0, 0), (4, 6, 13, 3, 2, 0, 5, 5, 3, 4, 2, 0), (1, 2, 7, 4, 3, 0, 2, 6, 4, 6, 3, 0), (4, 7, 5, 2, 3, 0, 4, 2, 4, 6, 0, 0), (3, 3, 3, 3, 2, 0, 2, 5, 4, 5, 0, 0), (2, 2, 4, 3, 2, 0, 4, 2, 6, 0, 4, 0), (3, 10, 7, 0, 2, 0, 2, 5, 3, 1, 4, 0), (3, 9, 6, 2, 0, 0, 4, 10, 3, 4, 1, 0), (5, 6, 6, 3, 1, 0, 5, 6, 3, 4, 0, 0), (1, 7, 8, 1, 3, 0, 3, 6, 4, 4, 1, 0), (7, 5, 6, 0, 1, 0, 3, 8, 4, 6, 2, 0), (0, 4, 5, 3, 4, 0, 4, 6, 6, 3, 3, 0), (6, 8, 6, 3, 1, 0, 5, 2, 6, 1, 1, 0), (3, 8, 8, 2, 2, 0, 5, 7, 9, 2, 0, 0), (3, 5, 6, 4, 2, 0, 8, 8, 4, 3, 2, 0), (6, 9, 4, 1, 3, 0, 7, 8, 4, 2, 3, 0), (3, 4, 4, 3, 3, 0, 3, 11, 3, 3, 1, 0), (3, 8, 3, 2, 0, 0, 4, 4, 4, 4, 2, 0), (2, 5, 7, 5, 2, 0, 3, 9, 6, 4, 2, 0), (3, 7, 3, 2, 1, 0, 4, 11, 3, 5, 2, 0), (0, 12, 5, 0, 2, 0, 3, 6, 4, 2, 2, 0), (4, 7, 5, 1, 2, 0, 4, 5, 6, 1, 5, 0), (4, 3, 6, 1, 1, 0, 4, 4, 4, 5, 3, 0), (1, 8, 6, 3, 3, 0, 4, 5, 5, 6, 1, 0), (5, 4, 4, 0, 1, 0, 3, 5, 5, 8, 2, 0), (4, 6, 5, 4, 0, 0, 5, 4, 3, 1, 1, 0), (4, 10, 4, 2, 0, 0, 3, 2, 7, 6, 1, 0), (3, 4, 4, 2, 4, 0, 6, 5, 3, 3, 1, 0), (7, 3, 2, 2, 2, 0, 4, 7, 3, 5, 0, 0), (5, 8, 6, 3, 3, 0, 7, 7, 3, 4, 0, 0), (2, 8, 3, 1, 0, 0, 6, 4, 3, 3, 3, 0), (6, 8, 6, 2, 1, 0, 8, 7, 8, 0, 3, 0), (0, 6, 4, 5, 0, 0, 2, 7, 3, 2, 2, 0), (4, 2, 3, 3, 1, 0, 6, 8, 7, 3, 0, 0), (3, 5, 2, 3, 1, 0, 5, 3, 10, 4, 3, 0), (6, 5, 7, 2, 0, 0, 6, 4, 1, 4, 4, 0), (7, 8, 5, 5, 0, 0, 4, 13, 1, 3, 1, 0), (3, 10, 8, 2, 2, 0, 8, 4, 9, 4, 4, 0), (4, 6, 7, 4, 0, 0, 8, 7, 4, 0, 0, 0), (3, 7, 7, 2, 2, 0, 9, 6, 4, 2, 1, 0), (2, 14, 5, 2, 2, 0, 3, 8, 1, 1, 2, 0), (8, 4, 2, 1, 2, 0, 8, 6, 2, 3, 0, 0), (4, 5, 6, 1, 0, 0, 5, 7, 3, 2, 1, 0), (4, 4, 3, 1, 1, 0, 3, 5, 2, 6, 2, 0), (1, 9, 5, 6, 0, 0, 7, 5, 5, 1, 2, 0), (5, 3, 6, 2, 1, 0, 8, 3, 6, 3, 1, 0), (2, 8, 6, 9, 1, 0, 12, 1, 8, 3, 2, 0), (4, 8, 7, 3, 0, 0, 8, 8, 5, 4, 0, 0), (5, 7, 2, 1, 0, 0, 4, 8, 0, 5, 2, 0), (1, 9, 9, 3, 0, 0, 2, 9, 4, 7, 1, 0), (2, 8, 6, 3, 4, 0, 3, 11, 5, 4, 3, 0), (6, 5, 3, 2, 1, 0, 5, 6, 4, 1, 2, 0), (3, 6, 6, 3, 2, 0, 3, 3, 4, 4, 2, 0), (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)) station_arriving_intensity = ((2.649651558384548, 6.796460700757575, 7.9942360218509, 6.336277173913043, 7.143028846153846, 4.75679347826087), (2.6745220100478, 6.872041598712823, 8.037415537524994, 6.371564387077295, 7.196566506410256, 4.7551721391908215), (2.699108477221734, 6.946501402918069, 8.07957012282205, 6.406074879227053, 7.248974358974359, 4.753501207729468), (2.72339008999122, 7.019759765625, 8.120668982969152, 6.4397792119565205, 7.300204326923078, 4.7517809103260875), (2.747345978441128, 7.091736339085298, 8.160681323193373, 6.472647946859904, 7.350208333333334, 4.750011473429951), (2.7709552726563262, 7.162350775550646, 8.199576348721793, 6.504651645531401, 7.39893830128205, 4.748193123490338), (2.794197102721686, 7.231522727272727, 8.237323264781493, 6.535760869565218, 7.446346153846154, 4.746326086956522), (2.817050598722076, 7.299171846503226, 8.273891276599542, 6.565946180555556, 7.492383814102565, 4.744410590277778), (2.8394948907423667, 7.365217785493826, 8.309249589403029, 6.595178140096618, 7.537003205128205, 4.7424468599033816), (2.8615091088674274, 7.429580196496212, 8.343367408419024, 6.623427309782609, 7.580156249999999, 4.740435122282609), (2.8830723831821286, 7.492178731762065, 8.376213938874606, 6.65066425120773, 7.621794871794872, 4.738375603864734), (2.9041638437713395, 7.55293304354307, 8.407758385996857, 6.676859525966184, 7.661870993589743, 4.736268531099034), (2.92476262071993, 7.611762784090908, 8.437969955012854, 6.7019836956521734, 7.700336538461538, 4.734114130434782), (2.944847844112769, 7.668587605657268, 8.46681785114967, 6.726007321859903, 7.737143429487181, 4.731912628321256), (2.9643986440347283, 7.723327160493828, 8.494271279634388, 6.748900966183574, 7.772243589743589, 4.729664251207729), (2.9833941505706756, 7.775901100852272, 8.520299445694086, 6.770635190217391, 7.8055889423076925, 4.7273692255434785), (3.001813493805482, 7.826229078984287, 8.544871554555842, 6.791180555555555, 7.8371314102564105, 4.725027777777778), (3.019635803824017, 7.874230747141554, 8.567956811446729, 6.810507623792271, 7.866822916666667, 4.722640134359904), (3.03684021071115, 7.919825757575757, 8.589524421593831, 6.82858695652174, 7.894615384615387, 4.72020652173913), (3.053405844551751, 7.962933762538579, 8.609543590224222, 6.845389115338164, 7.9204607371794875, 4.717727166364734), (3.0693118354306894, 8.003474414281705, 8.62798352256498, 6.860884661835749, 7.944310897435898, 4.71520229468599), (3.084537313432836, 8.041367365056816, 8.644813423843189, 6.875044157608696, 7.9661177884615375, 4.712632133152174), (3.099061408643059, 8.076532267115601, 8.660002499285918, 6.887838164251208, 7.985833333333332, 4.710016908212561), (3.1128632511462295, 8.108888772709737, 8.673519954120252, 6.899237243357488, 8.003409455128205, 4.707356846316426), (3.125921971027217, 8.138356534090908, 8.685334993573264, 6.909211956521739, 8.018798076923076, 4.704652173913043), (3.1382166983708903, 8.164855203510802, 8.695416822872037, 6.917732865338165, 8.03195112179487, 4.701903117451691), (3.1497265632621207, 8.188304433221099, 8.703734647243644, 6.9247705314009655, 8.042820512820512, 4.699109903381642), (3.160430695785777, 8.208623875473483, 8.710257671915166, 6.930295516304349, 8.051358173076924, 4.696272758152174), (3.1703082260267292, 8.22573318251964, 8.714955102113683, 6.934278381642512, 8.057516025641025, 4.69339190821256), (3.1793382840698468, 8.239552006611252, 8.717796143066266, 6.936689689009662, 8.061245993589743, 4.690467580012077), (3.1875, 8.25, 8.71875, 6.9375, 8.0625, 4.6875), (3.1951370284526854, 8.258678799715907, 8.718034948671496, 6.937353656045752, 8.062043661347518, 4.683376259786773), (3.202609175191816, 8.267242897727273, 8.715910024154589, 6.93691748366013, 8.06068439716312, 4.677024758454107), (3.2099197969948845, 8.275691228693182, 8.712405570652175, 6.936195772058824, 8.058436835106383, 4.66850768365817), (3.217072250639386, 8.284022727272728, 8.70755193236715, 6.935192810457517, 8.05531560283688, 4.657887223055139), (3.224069892902813, 8.292236328124998, 8.701379453502415, 6.933912888071895, 8.051335328014185, 4.645225564301183), (3.23091608056266, 8.300330965909092, 8.69391847826087, 6.932360294117648, 8.046510638297873, 4.630584895052474), (3.2376141703964194, 8.308305575284091, 8.68519935084541, 6.9305393178104575, 8.040856161347516, 4.614027402965184), (3.2441675191815853, 8.31615909090909, 8.675252415458937, 6.9284542483660125, 8.034386524822695, 4.595615275695485), (3.250579483695652, 8.323890447443182, 8.664108016304347, 6.926109375, 8.027116356382978, 4.57541070089955), (3.2568534207161126, 8.331498579545455, 8.651796497584542, 6.923508986928105, 8.019060283687942, 4.5534758662335495), (3.26299268702046, 8.338982421874999, 8.638348203502416, 6.920657373366013, 8.010232934397163, 4.529872959353657), (3.269000639386189, 8.34634090909091, 8.62379347826087, 6.917558823529411, 8.000648936170213, 4.504664167916042), (3.2748806345907933, 8.353572975852272, 8.608162666062801, 6.914217626633987, 7.990322916666666, 4.477911679576878), (3.2806360294117645, 8.360677556818182, 8.591486111111111, 6.910638071895424, 7.979269503546099, 4.449677681992337), (3.286270180626598, 8.367653586647727, 8.573794157608697, 6.906824448529411, 7.967503324468085, 4.420024362818591), (3.291786445012788, 8.374500000000001, 8.555117149758455, 6.902781045751634, 7.955039007092199, 4.389013909711811), (3.297188179347826, 8.381215731534091, 8.535485431763284, 6.898512152777777, 7.941891179078015, 4.356708510328169), (3.3024787404092075, 8.387799715909091, 8.514929347826087, 6.894022058823529, 7.928074468085106, 4.323170352323839), (3.307661484974424, 8.39425088778409, 8.493479242149759, 6.889315053104576, 7.91360350177305, 4.288461623354989), (3.312739769820972, 8.40056818181818, 8.471165458937199, 6.884395424836602, 7.898492907801418, 4.252644511077794), (3.317716951726343, 8.406750532670454, 8.448018342391304, 6.879267463235294, 7.882757313829787, 4.215781203148426), (3.322596387468031, 8.412796875, 8.424068236714975, 6.87393545751634, 7.86641134751773, 4.177933887223055), (3.3273814338235295, 8.41870614346591, 8.39934548611111, 6.868403696895425, 7.849469636524823, 4.139164750957854), (3.332075447570333, 8.424477272727271, 8.373880434782608, 6.8626764705882355, 7.831946808510638, 4.099535982008995), (3.336681785485933, 8.430109197443182, 8.347703426932366, 6.856758067810458, 7.813857491134752, 4.05910976803265), (3.341203804347826, 8.435600852272726, 8.320844806763285, 6.8506527777777775, 7.795216312056738, 4.017948296684991), (3.345644860933504, 8.440951171875001, 8.29333491847826, 6.844364889705882, 7.77603789893617, 3.9761137556221886), (3.3500083120204605, 8.44615909090909, 8.265204106280192, 6.837898692810458, 7.756336879432624, 3.9336683325004165), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) passenger_arriving_acc = ((3, 12, 4, 1, 1, 0, 2, 7, 5, 7, 0, 0), (7, 24, 6, 3, 5, 0, 4, 12, 8, 10, 2, 0), (10, 26, 9, 5, 7, 0, 10, 19, 13, 15, 4, 0), (11, 36, 13, 7, 8, 0, 16, 24, 14, 19, 5, 0), (14, 39, 15, 12, 12, 0, 25, 30, 21, 22, 10, 0), (19, 46, 19, 14, 15, 0, 30, 37, 25, 27, 10, 0), (21, 55, 23, 15, 17, 0, 37, 42, 30, 31, 10, 0), (25, 61, 36, 18, 19, 0, 42, 47, 33, 35, 12, 0), (26, 63, 43, 22, 22, 0, 44, 53, 37, 41, 15, 0), (30, 70, 48, 24, 25, 0, 48, 55, 41, 47, 15, 0), (33, 73, 51, 27, 27, 0, 50, 60, 45, 52, 15, 0), (35, 75, 55, 30, 29, 0, 54, 62, 51, 52, 19, 0), (38, 85, 62, 30, 31, 0, 56, 67, 54, 53, 23, 0), (41, 94, 68, 32, 31, 0, 60, 77, 57, 57, 24, 0), (46, 100, 74, 35, 32, 0, 65, 83, 60, 61, 24, 0), (47, 107, 82, 36, 35, 0, 68, 89, 64, 65, 25, 0), (54, 112, 88, 36, 36, 0, 71, 97, 68, 71, 27, 0), (54, 116, 93, 39, 40, 0, 75, 103, 74, 74, 30, 0), (60, 124, 99, 42, 41, 0, 80, 105, 80, 75, 31, 0), (63, 132, 107, 44, 43, 0, 85, 112, 89, 77, 31, 0), (66, 137, 113, 48, 45, 0, 93, 120, 93, 80, 33, 0), (72, 146, 117, 49, 48, 0, 100, 128, 97, 82, 36, 0), (75, 150, 121, 52, 51, 0, 103, 139, 100, 85, 37, 0), (78, 158, 124, 54, 51, 0, 107, 143, 104, 89, 39, 0), (80, 163, 131, 59, 53, 0, 110, 152, 110, 93, 41, 0), (83, 170, 134, 61, 54, 0, 114, 163, 113, 98, 43, 0), (83, 182, 139, 61, 56, 0, 117, 169, 117, 100, 45, 0), (87, 189, 144, 62, 58, 0, 121, 174, 123, 101, 50, 0), (91, 192, 150, 63, 59, 0, 125, 178, 127, 106, 53, 0), (92, 200, 156, 66, 62, 0, 129, 183, 132, 112, 54, 0), (97, 204, 160, 66, 63, 0, 132, 188, 137, 120, 56, 0), (101, 210, 165, 70, 63, 0, 137, 192, 140, 121, 57, 0), (105, 220, 169, 72, 63, 0, 140, 194, 147, 127, 58, 0), (108, 224, 173, 74, 67, 0, 146, 199, 150, 130, 59, 0), (115, 227, 175, 76, 69, 0, 150, 206, 153, 135, 59, 0), (120, 235, 181, 79, 72, 0, 157, 213, 156, 139, 59, 0), (122, 243, 184, 80, 72, 0, 163, 217, 159, 142, 62, 0), (128, 251, 190, 82, 73, 0, 171, 224, 167, 142, 65, 0), (128, 257, 194, 87, 73, 0, 173, 231, 170, 144, 67, 0), (132, 259, 197, 90, 74, 0, 179, 239, 177, 147, 67, 0), (135, 264, 199, 93, 75, 0, 184, 242, 187, 151, 70, 0), (141, 269, 206, 95, 75, 0, 190, 246, 188, 155, 74, 0), (148, 277, 211, 100, 75, 0, 194, 259, 189, 158, 75, 0), (151, 287, 219, 102, 77, 0, 202, 263, 198, 162, 79, 0), (155, 293, 226, 106, 77, 0, 210, 270, 202, 162, 79, 0), (158, 300, 233, 108, 79, 0, 219, 276, 206, 164, 80, 0), (160, 314, 238, 110, 81, 0, 222, 284, 207, 165, 82, 0), (168, 318, 240, 111, 83, 0, 230, 290, 209, 168, 82, 0), (172, 323, 246, 112, 83, 0, 235, 297, 212, 170, 83, 0), (176, 327, 249, 113, 84, 0, 238, 302, 214, 176, 85, 0), (177, 336, 254, 119, 84, 0, 245, 307, 219, 177, 87, 0), (182, 339, 260, 121, 85, 0, 253, 310, 225, 180, 88, 0), (184, 347, 266, 130, 86, 0, 265, 311, 233, 183, 90, 0), (188, 355, 273, 133, 86, 0, 273, 319, 238, 187, 90, 0), (193, 362, 275, 134, 86, 0, 277, 327, 238, 192, 92, 0), (194, 371, 284, 137, 86, 0, 279, 336, 242, 199, 93, 0), (196, 379, 290, 140, 90, 0, 282, 347, 247, 203, 96, 0), (202, 384, 293, 142, 91, 0, 287, 353, 251, 204, 98, 0), (205, 390, 299, 145, 93, 0, 290, 356, 255, 208, 100, 0), (205, 390, 299, 145, 93, 0, 290, 356, 255, 208, 100, 0)) passenger_arriving_rate = ((2.649651558384548, 5.43716856060606, 4.79654161311054, 2.534510869565217, 1.428605769230769, 0.0, 4.75679347826087, 5.714423076923076, 3.801766304347826, 3.1976944087403596, 1.359292140151515, 0.0), (2.6745220100478, 5.497633278970258, 4.822449322514997, 2.5486257548309177, 1.439313301282051, 0.0, 4.7551721391908215, 5.757253205128204, 3.8229386322463768, 3.2149662150099974, 1.3744083197425645, 0.0), (2.699108477221734, 5.557201122334455, 4.8477420736932295, 2.562429951690821, 1.4497948717948717, 0.0, 4.753501207729468, 5.799179487179487, 3.8436449275362317, 3.23182804912882, 1.3893002805836137, 0.0), (2.72339008999122, 5.6158078125, 4.872401389781491, 2.575911684782608, 1.4600408653846155, 0.0, 4.7517809103260875, 5.840163461538462, 3.863867527173912, 3.2482675931876606, 1.403951953125, 0.0), (2.747345978441128, 5.673389071268238, 4.896408793916024, 2.589059178743961, 1.4700416666666667, 0.0, 4.750011473429951, 5.880166666666667, 3.883588768115942, 3.2642725292773487, 1.4183472678170594, 0.0), (2.7709552726563262, 5.729880620440516, 4.919745809233076, 2.6018606582125603, 1.47978766025641, 0.0, 4.748193123490338, 5.91915064102564, 3.9027909873188404, 3.279830539488717, 1.432470155110129, 0.0), (2.794197102721686, 5.785218181818181, 4.942393958868895, 2.614304347826087, 1.4892692307692306, 0.0, 4.746326086956522, 5.957076923076922, 3.9214565217391306, 3.294929305912597, 1.4463045454545453, 0.0), (2.817050598722076, 5.83933747720258, 4.964334765959725, 2.626378472222222, 1.498476762820513, 0.0, 4.744410590277778, 5.993907051282052, 3.939567708333333, 3.309556510639817, 1.459834369300645, 0.0), (2.8394948907423667, 5.89217422839506, 4.985549753641817, 2.638071256038647, 1.5074006410256409, 0.0, 4.7424468599033816, 6.0296025641025635, 3.9571068840579704, 3.3236998357612113, 1.473043557098765, 0.0), (2.8615091088674274, 5.943664157196969, 5.006020445051414, 2.649370923913043, 1.5160312499999997, 0.0, 4.740435122282609, 6.064124999999999, 3.9740563858695652, 3.3373469633676094, 1.4859160392992423, 0.0), (2.8830723831821286, 5.993742985409652, 5.025728363324764, 2.660265700483092, 1.5243589743589743, 0.0, 4.738375603864734, 6.097435897435897, 3.990398550724638, 3.3504855755498424, 1.498435746352413, 0.0), (2.9041638437713395, 6.042346434834456, 5.044655031598114, 2.6707438103864733, 1.5323741987179484, 0.0, 4.736268531099034, 6.129496794871794, 4.0061157155797105, 3.3631033543987425, 1.510586608708614, 0.0), (2.92476262071993, 6.089410227272726, 5.062781973007712, 2.680793478260869, 1.5400673076923075, 0.0, 4.734114130434782, 6.16026923076923, 4.021190217391304, 3.375187982005141, 1.5223525568181815, 0.0), (2.944847844112769, 6.134870084525814, 5.080090710689802, 2.690402928743961, 1.547428685897436, 0.0, 4.731912628321256, 6.189714743589744, 4.035604393115942, 3.386727140459868, 1.5337175211314535, 0.0), (2.9643986440347283, 6.1786617283950624, 5.096562767780632, 2.699560386473429, 1.5544487179487176, 0.0, 4.729664251207729, 6.217794871794871, 4.049340579710144, 3.397708511853755, 1.5446654320987656, 0.0), (2.9833941505706756, 6.220720880681816, 5.112179667416451, 2.708254076086956, 1.5611177884615384, 0.0, 4.7273692255434785, 6.2444711538461535, 4.062381114130434, 3.408119778277634, 1.555180220170454, 0.0), (3.001813493805482, 6.26098326318743, 5.126922932733505, 2.716472222222222, 1.5674262820512819, 0.0, 4.725027777777778, 6.2697051282051275, 4.074708333333333, 3.4179486218223363, 1.5652458157968574, 0.0), (3.019635803824017, 6.299384597713242, 5.140774086868038, 2.724203049516908, 1.5733645833333332, 0.0, 4.722640134359904, 6.293458333333333, 4.0863045742753625, 3.4271827245786914, 1.5748461494283106, 0.0), (3.03684021071115, 6.3358606060606055, 5.153714652956299, 2.7314347826086958, 1.578923076923077, 0.0, 4.72020652173913, 6.315692307692308, 4.097152173913043, 3.435809768637532, 1.5839651515151514, 0.0), (3.053405844551751, 6.370347010030863, 5.165726154134533, 2.738155646135265, 1.5840921474358973, 0.0, 4.717727166364734, 6.336368589743589, 4.107233469202898, 3.4438174360896885, 1.5925867525077158, 0.0), (3.0693118354306894, 6.402779531425363, 5.1767901135389875, 2.7443538647342995, 1.5888621794871793, 0.0, 4.71520229468599, 6.355448717948717, 4.11653079710145, 3.4511934090259917, 1.6006948828563408, 0.0), (3.084537313432836, 6.433093892045452, 5.186888054305913, 2.750017663043478, 1.5932235576923073, 0.0, 4.712632133152174, 6.372894230769229, 4.125026494565217, 3.4579253695372754, 1.608273473011363, 0.0), (3.099061408643059, 6.46122581369248, 5.19600149957155, 2.7551352657004826, 1.5971666666666662, 0.0, 4.710016908212561, 6.388666666666665, 4.132702898550725, 3.464000999714367, 1.61530645342312, 0.0), (3.1128632511462295, 6.487111018167789, 5.204111972472151, 2.759694897342995, 1.6006818910256408, 0.0, 4.707356846316426, 6.402727564102563, 4.139542346014493, 3.4694079816481005, 1.6217777545419472, 0.0), (3.125921971027217, 6.5106852272727265, 5.211200996143958, 2.763684782608695, 1.6037596153846152, 0.0, 4.704652173913043, 6.415038461538461, 4.1455271739130435, 3.474133997429305, 1.6276713068181816, 0.0), (3.1382166983708903, 6.531884162808641, 5.217250093723222, 2.7670931461352657, 1.606390224358974, 0.0, 4.701903117451691, 6.425560897435896, 4.150639719202899, 3.4781667291488145, 1.6329710407021603, 0.0), (3.1497265632621207, 6.550643546576878, 5.222240788346187, 2.7699082125603858, 1.6085641025641022, 0.0, 4.699109903381642, 6.434256410256409, 4.154862318840579, 3.4814938588974575, 1.6376608866442195, 0.0), (3.160430695785777, 6.566899100378786, 5.226154603149099, 2.772118206521739, 1.6102716346153847, 0.0, 4.696272758152174, 6.441086538461539, 4.158177309782609, 3.484103068766066, 1.6417247750946966, 0.0), (3.1703082260267292, 6.580586546015712, 5.228973061268209, 2.7737113526570045, 1.6115032051282048, 0.0, 4.69339190821256, 6.446012820512819, 4.160567028985507, 3.4859820408454727, 1.645146636503928, 0.0), (3.1793382840698468, 6.591641605289001, 5.230677685839759, 2.7746758756038647, 1.6122491987179486, 0.0, 4.690467580012077, 6.448996794871794, 4.162013813405797, 3.487118457226506, 1.6479104013222503, 0.0), (3.1875, 6.6, 5.23125, 2.775, 1.6124999999999998, 0.0, 4.6875, 6.449999999999999, 4.1625, 3.4875, 1.65, 0.0), (3.1951370284526854, 6.606943039772726, 5.230820969202898, 2.7749414624183006, 1.6124087322695035, 0.0, 4.683376259786773, 6.449634929078014, 4.162412193627451, 3.4872139794685983, 1.6517357599431814, 0.0), (3.202609175191816, 6.613794318181818, 5.229546014492753, 2.7747669934640515, 1.6121368794326238, 0.0, 4.677024758454107, 6.448547517730495, 4.162150490196078, 3.4863640096618354, 1.6534485795454545, 0.0), (3.2099197969948845, 6.620552982954545, 5.227443342391305, 2.774478308823529, 1.6116873670212764, 0.0, 4.66850768365817, 6.446749468085105, 4.161717463235294, 3.4849622282608697, 1.6551382457386363, 0.0), (3.217072250639386, 6.627218181818182, 5.224531159420289, 2.7740771241830067, 1.6110631205673758, 0.0, 4.657887223055139, 6.444252482269503, 4.16111568627451, 3.4830207729468596, 1.6568045454545455, 0.0), (3.224069892902813, 6.633789062499998, 5.220827672101449, 2.773565155228758, 1.6102670656028368, 0.0, 4.645225564301183, 6.441068262411347, 4.160347732843137, 3.480551781400966, 1.6584472656249996, 0.0), (3.23091608056266, 6.6402647727272734, 5.2163510869565215, 2.7729441176470586, 1.6093021276595745, 0.0, 4.630584895052474, 6.437208510638298, 4.159416176470589, 3.477567391304347, 1.6600661931818184, 0.0), (3.2376141703964194, 6.6466444602272725, 5.211119610507246, 2.7722157271241827, 1.6081712322695032, 0.0, 4.614027402965184, 6.432684929078013, 4.158323590686274, 3.474079740338164, 1.6616611150568181, 0.0), (3.2441675191815853, 6.652927272727272, 5.205151449275362, 2.7713816993464047, 1.6068773049645388, 0.0, 4.595615275695485, 6.427509219858155, 4.157072549019607, 3.4701009661835744, 1.663231818181818, 0.0), (3.250579483695652, 6.659112357954545, 5.198464809782608, 2.7704437499999996, 1.6054232712765955, 0.0, 4.57541070089955, 6.421693085106382, 4.155665625, 3.4656432065217384, 1.6647780894886361, 0.0), (3.2568534207161126, 6.6651988636363635, 5.191077898550724, 2.7694035947712417, 1.6038120567375882, 0.0, 4.5534758662335495, 6.415248226950353, 4.154105392156863, 3.4607185990338163, 1.6662997159090909, 0.0), (3.26299268702046, 6.671185937499998, 5.1830089221014495, 2.768262949346405, 1.6020465868794325, 0.0, 4.529872959353657, 6.40818634751773, 4.152394424019608, 3.455339281400966, 1.6677964843749995, 0.0), (3.269000639386189, 6.677072727272728, 5.174276086956522, 2.767023529411764, 1.6001297872340425, 0.0, 4.504664167916042, 6.40051914893617, 4.150535294117646, 3.4495173913043478, 1.669268181818182, 0.0), (3.2748806345907933, 6.682858380681817, 5.164897599637681, 2.7656870506535944, 1.5980645833333331, 0.0, 4.477911679576878, 6.3922583333333325, 4.148530575980392, 3.4432650664251203, 1.6707145951704543, 0.0), (3.2806360294117645, 6.688542045454545, 5.154891666666667, 2.7642552287581696, 1.5958539007092198, 0.0, 4.449677681992337, 6.383415602836879, 4.146382843137254, 3.4365944444444443, 1.6721355113636363, 0.0), (3.286270180626598, 6.694122869318181, 5.144276494565218, 2.7627297794117642, 1.593500664893617, 0.0, 4.420024362818591, 6.374002659574468, 4.144094669117647, 3.4295176630434785, 1.6735307173295453, 0.0), (3.291786445012788, 6.6996, 5.133070289855073, 2.761112418300653, 1.5910078014184397, 0.0, 4.389013909711811, 6.364031205673759, 4.14166862745098, 3.4220468599033818, 1.6749, 0.0), (3.297188179347826, 6.704972585227273, 5.12129125905797, 2.759404861111111, 1.588378235815603, 0.0, 4.356708510328169, 6.353512943262412, 4.139107291666666, 3.4141941727053133, 1.6762431463068181, 0.0), (3.3024787404092075, 6.710239772727273, 5.108957608695651, 2.757608823529411, 1.5856148936170211, 0.0, 4.323170352323839, 6.3424595744680845, 4.136413235294117, 3.4059717391304343, 1.6775599431818182, 0.0), (3.307661484974424, 6.715400710227271, 5.096087545289855, 2.75572602124183, 1.5827207003546098, 0.0, 4.288461623354989, 6.330882801418439, 4.133589031862745, 3.3973916968599034, 1.6788501775568176, 0.0), (3.312739769820972, 6.720454545454543, 5.082699275362319, 2.7537581699346405, 1.5796985815602835, 0.0, 4.252644511077794, 6.318794326241134, 4.130637254901961, 3.388466183574879, 1.6801136363636358, 0.0), (3.317716951726343, 6.725400426136363, 5.068811005434783, 2.7517069852941174, 1.5765514627659571, 0.0, 4.215781203148426, 6.306205851063829, 4.127560477941176, 3.3792073369565214, 1.6813501065340908, 0.0), (3.322596387468031, 6.730237499999999, 5.054440942028985, 2.7495741830065357, 1.573282269503546, 0.0, 4.177933887223055, 6.293129078014184, 4.124361274509804, 3.3696272946859898, 1.6825593749999999, 0.0), (3.3273814338235295, 6.7349649147727275, 5.039607291666666, 2.7473614787581697, 1.5698939273049646, 0.0, 4.139164750957854, 6.279575709219858, 4.121042218137255, 3.359738194444444, 1.6837412286931819, 0.0), (3.332075447570333, 6.739581818181817, 5.024328260869565, 2.745070588235294, 1.5663893617021276, 0.0, 4.099535982008995, 6.2655574468085105, 4.117605882352941, 3.3495521739130427, 1.6848954545454542, 0.0), (3.336681785485933, 6.744087357954545, 5.008622056159419, 2.7427032271241827, 1.5627714982269503, 0.0, 4.05910976803265, 6.251085992907801, 4.114054840686275, 3.3390813707729463, 1.6860218394886362, 0.0), (3.341203804347826, 6.74848068181818, 4.9925068840579705, 2.740261111111111, 1.5590432624113475, 0.0, 4.017948296684991, 6.23617304964539, 4.110391666666667, 3.328337922705314, 1.687120170454545, 0.0), (3.345644860933504, 6.752760937500001, 4.976000951086956, 2.7377459558823527, 1.5552075797872338, 0.0, 3.9761137556221886, 6.220830319148935, 4.106618933823529, 3.317333967391304, 1.6881902343750002, 0.0), (3.3500083120204605, 6.756927272727271, 4.959122463768115, 2.7351594771241827, 1.5512673758865245, 0.0, 3.9336683325004165, 6.205069503546098, 4.102739215686275, 3.3060816425120767, 1.6892318181818178, 0.0), (0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)) passenger_allighting_rate = ((0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1), (0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1, 0, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 0.16666666666666666, 1)) '\nparameters for reproducibiliy. More information: https://numpy.org/doc/stable/reference/random/parallel.html\n' entropy = 258194110137029475889902652135037600173 child_seed_index = (1, 38)
""" Project Euler Problem 12: Highly divisible triangular number """ # What is the value of the first triangle number to have over five hundred divisors? # A simple solution is to not worry about generating primes, and just test odd numbers for divisors # Since we have to test a lot of numbers, it probably is worth generating a list of primes START = 1 number_divisors = 0 i = 0 while number_divisors < 500: i += 1 powers = [] tri_number = (START+i)*(START+i+1)/2 power = 0 while tri_number % 2 == 0: power += 1 tri_number /= 2 if power > 0: powers.append(power) factor = 3 while tri_number > 1: power = 0 while tri_number % factor == 0: power += 1 tri_number /= factor factor += 2 if power > 0: powers.append(power) number_divisors = 1 for p in powers: number_divisors *= p + 1 print((START+i)*(START+i+1)//2)
""" Project Euler Problem 12: Highly divisible triangular number """ start = 1 number_divisors = 0 i = 0 while number_divisors < 500: i += 1 powers = [] tri_number = (START + i) * (START + i + 1) / 2 power = 0 while tri_number % 2 == 0: power += 1 tri_number /= 2 if power > 0: powers.append(power) factor = 3 while tri_number > 1: power = 0 while tri_number % factor == 0: power += 1 tri_number /= factor factor += 2 if power > 0: powers.append(power) number_divisors = 1 for p in powers: number_divisors *= p + 1 print((START + i) * (START + i + 1) // 2)
# """Make a function map that works the same way as the built-in map function:""" def square(n): return n * n def map(square, list1): return [ square(num) for num in list1 ]
"""Make a function map that works the same way as the built-in map function:""" def square(n): return n * n def map(square, list1): return [square(num) for num in list1]
class Solution: def isIsomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ def check(s, t): word_map = {} for i, v in enumerate(s): tmp = word_map.get(t[i]) if tmp is None: word_map[t[i]] = s[i] tmp = s[i] t = t[:i] + tmp + t[i + 1:] return s == t return check(s, t) and check(t, s) s = 'title' t = 'paper' # t = 'title' # s = 'paler' print(Solution().isIsomorphic(s, t))
class Solution: def is_isomorphic(self, s, t): """ :type s: str :type t: str :rtype: bool """ def check(s, t): word_map = {} for (i, v) in enumerate(s): tmp = word_map.get(t[i]) if tmp is None: word_map[t[i]] = s[i] tmp = s[i] t = t[:i] + tmp + t[i + 1:] return s == t return check(s, t) and check(t, s) s = 'title' t = 'paper' print(solution().isIsomorphic(s, t))
# -*- coding: utf-8 -*- # see LICENSE.rst # ---------------------------------------------------------------------------- # # TITLE : data # PROJECT : astronat # # ---------------------------------------------------------------------------- """Data Management. Often data is packaged poorly and it can be difficult to understand how the data should be read. DON`T PANIC. This module provides functions to read the contained data. Routine Listings ---------------- read_constants __all_constants__ """ __author__ = "Nathaniel Starkman" __all__ = [ "read_constants", "__all_constants__", ] ############################################################################### # IMPORTS ############################################################################### # CODE ############################################################################### def read_constants(): """Read SI Constants.""" data = { "G": { "name": "Gravitational constant", "value": 6.6743e-11, "uncertainty": 1.5e-15, "unit": "m3 / (kg s2)", "reference": "CODATA 2018", "source": "CODATA2018", }, "N_A": { "name": "Avogadro's number", "value": 6.02214076e23, "uncertainty": 0.0, "unit": "1 / mol", "reference": "CODATA 2018", "source": "CODATA2018", }, "R": { "name": "Gas constant", "value": 8.31446261815324, "uncertainty": 0.0, "unit": "J / (K mol)", "reference": "CODATA 2018", "source": "CODATA2018", }, "Ryd": { "name": "Rydberg constant", "value": 10973731.56816, "uncertainty": 2.1e-05, "unit": "1 / m", "reference": "CODATA 2018", "source": "CODATA2018", }, "a0": { "name": "Bohr radius", "value": 5.29177210903e-11, "uncertainty": 8e-21, "unit": "m", "reference": "CODATA 2018", "source": "CODATA2018", }, "alpha": { "name": "Fine-structure constant", "value": 0.0072973525693, "uncertainty": 1.1e-12, "unit": "", "reference": "CODATA 2018", "source": "CODATA2018", }, "atm": { "name": "Standard atmosphere", "value": 101325, "uncertainty": 0.0, "unit": "Pa", "reference": "CODATA 2018", "source": "CODATA2018", }, "b_wien": { "name": "Wien wavelength displacement law constant", "value": 0.0028977719551851727, "uncertainty": 0.0, "unit": "K m", "reference": "CODATA 2018", "source": "CODATA2018", }, "c": { "name": "Speed of light in vacuum", "value": 299792458.0, "uncertainty": 0.0, "unit": "m / s", "reference": "CODATA 2018", "source": "CODATA2018", }, "e": { "name": "Electron charge", "value": 1.602176634e-19, "uncertainty": 0.0, "unit": "C", "source": "EMCODATA2018", }, "eps0": { "name": "Vacuum electric permittivity", "value": 8.8541878128e-12, "uncertainty": 1.3e-21, "unit": "F / m", "reference": "CODATA 2018", "source": "EMCODATA2018", }, "g0": { "name": "Standard acceleration of gravity", "value": 9.80665, "uncertainty": 0.0, "unit": "m / s2", "source": "CODATA2018", }, "h": { "name": "Planck constant", "value": 6.62607015e-34, "uncertainty": 0.0, "unit": "J s", "reference": "CODATA 2018", "source": "CODATA2018", }, "hbar": { "name": "Reduced Planck constant", "value": 1.0545718176461565e-34, "uncertainty": 0.0, "unit": "J s", "reference": "CODATA 2018", "source": "CODATA2018", }, "k_B": { "name": "Boltzmann constant", "value": 1.380649e-23, "uncertainty": 0.0, "unit": "J / K", "reference": "CODATA 2018", "source": "CODATA2018", }, "m_e": { "name": "Electron mass", "value": 9.1093837015e-31, "uncertainty": 2.8e-40, "unit": "kg", "reference": "CODATA 2018", "source": "CODATA2018", }, "m_n": { "name": "Neutron mass", "value": 1.67492749804e-27, "uncertainty": 9.5e-37, "unit": "kg", "reference": "CODATA 2018", "source": "CODATA2018", }, "m_p": { "name": "Proton mass", "value": 1.67262192369e-27, "uncertainty": 5.1e-37, "unit": "kg", "reference": "CODATA 2018", "source": "CODATA2018", }, "mu0": { "name": "Vacuum magnetic permeability", "value": 1.25663706212e-06, "uncertainty": 1.9e-16, "unit": "N / A2", "reference": "CODATA 2018", "source": "CODATA2018", }, "muB": { "name": "Bohr magneton", "value": 9.2740100783e-24, "uncertainty": 2.8e-33, "unit": "J / T", "reference": "CODATA 2018", "source": "CODATA2018", }, "sigma_T": { "name": "Thomson scattering cross-section", "value": 6.6524587321e-29, "uncertainty": 6e-38, "unit": "m2", "reference": "CODATA 2018", "source": "CODATA2018", }, "sigma_sb": { "name": "Stefan-Boltzmann constant", "value": 5.6703744191844314e-08, "uncertainty": 0.0, "unit": "W / (K4 m2)", "reference": "CODATA 2018", "source": "CODATA2018", }, "u": { "name": "Atomic mass", "value": 1.6605390666e-27, "uncertainty": 5e-37, "unit": "kg", "reference": "CODATA 2018", "source": "CODATA2018", }, "GM_earth": { "name": "Nominal Earth mass parameter", "value": 398600400000000.0, "uncertainty": 0.0, "unit": "m3 / s2", "source": "IAU2015", }, "GM_jup": { "name": "Nominal Jupiter mass parameter", "value": 1.2668653e17, "uncertainty": 0.0, "unit": "m3 / s2", "source": "IAU2015", }, "GM_sun": { "name": "Nominal solar mass parameter", "value": 1.3271244e20, "uncertainty": 0.0, "unit": "m3 / s2", "source": "IAU2015", }, "L_bol0": { "name": "Luminosity for absolute bolometric magnitude 0", "value": 3.0128e28, "uncertainty": 0.0, "unit": "W", "source": "IAU2015", }, "L_sun": { "name": "Nominal solar luminosity", "value": 3.828e26, "uncertainty": 0.0, "unit": "W", "reference": "IAU 2015 Resolution B 3", "source": "IAU2015", }, "M_earth": { "name": "Earth mass", "value": 5.972167867791379e24, "uncertainty": 1.3422009501651213e20, "unit": "kg", "reference": "IAU 2015 Resolution B 3 + CODATA 2018", "source": "IAU2015", }, "M_jup": { "name": "Jupiter mass", "value": 1.8981245973360505e27, "uncertainty": 4.26589589320839e22, "unit": "kg", "reference": "IAU 2015 Resolution B 3 + CODATA 2018", "source": "IAU2015", }, "M_sun": { "name": "Solar mass", "value": 1.988409870698051e30, "uncertainty": 4.468805426856864e25, "unit": "kg", "reference": "IAU 2015 Resolution B 3 + CODATA 2018", "source": "IAU2015", }, "R_earth": { "name": "Nominal Earth equatorial radius", "value": 6378100.0, "uncertainty": 0.0, "unit": "m", "reference": "IAU 2015 Resolution B 3", "source": "IAU2015", }, "R_jup": { "name": "Nominal Jupiter equatorial radius", "value": 71492000.0, "uncertainty": 0.0, "unit": "m", "reference": "IAU 2015 Resolution B 3", "source": "IAU2015", }, "R_sun": { "name": "Nominal solar radius", "value": 695700000.0, "uncertainty": 0.0, "unit": "m", "reference": "IAU 2015 Resolution B 3", "source": "IAU2015", }, "au": { "name": "Astronomical Unit", "value": 149597870700.0, "uncertainty": 0.0, "unit": "m", "reference": "IAU 2012 Resolution B2", "source": "IAU2015", }, "kpc": { "name": "Kiloparsec", "value": 3.0856775814671917e19, "uncertainty": 0.0, "unit": "m", "reference": "Derived from au", "source": "IAU2015", }, "pc": { "name": "Parsec", "value": 3.0856775814671916e16, "uncertainty": 0.0, "unit": "m", "reference": "Derived from au", "source": "IAU2015", }, } return data # /def # ------------------------------------------------------------------------ __all_constants__ = frozenset(read_constants().keys()) ############################################################################### # END
"""Data Management. Often data is packaged poorly and it can be difficult to understand how the data should be read. DON`T PANIC. This module provides functions to read the contained data. Routine Listings ---------------- read_constants __all_constants__ """ __author__ = 'Nathaniel Starkman' __all__ = ['read_constants', '__all_constants__'] def read_constants(): """Read SI Constants.""" data = {'G': {'name': 'Gravitational constant', 'value': 6.6743e-11, 'uncertainty': 1.5e-15, 'unit': 'm3 / (kg s2)', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'N_A': {'name': "Avogadro's number", 'value': 6.02214076e+23, 'uncertainty': 0.0, 'unit': '1 / mol', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'R': {'name': 'Gas constant', 'value': 8.31446261815324, 'uncertainty': 0.0, 'unit': 'J / (K mol)', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'Ryd': {'name': 'Rydberg constant', 'value': 10973731.56816, 'uncertainty': 2.1e-05, 'unit': '1 / m', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'a0': {'name': 'Bohr radius', 'value': 5.29177210903e-11, 'uncertainty': 8e-21, 'unit': 'm', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'alpha': {'name': 'Fine-structure constant', 'value': 0.0072973525693, 'uncertainty': 1.1e-12, 'unit': '', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'atm': {'name': 'Standard atmosphere', 'value': 101325, 'uncertainty': 0.0, 'unit': 'Pa', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'b_wien': {'name': 'Wien wavelength displacement law constant', 'value': 0.0028977719551851727, 'uncertainty': 0.0, 'unit': 'K m', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'c': {'name': 'Speed of light in vacuum', 'value': 299792458.0, 'uncertainty': 0.0, 'unit': 'm / s', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'e': {'name': 'Electron charge', 'value': 1.602176634e-19, 'uncertainty': 0.0, 'unit': 'C', 'source': 'EMCODATA2018'}, 'eps0': {'name': 'Vacuum electric permittivity', 'value': 8.8541878128e-12, 'uncertainty': 1.3e-21, 'unit': 'F / m', 'reference': 'CODATA 2018', 'source': 'EMCODATA2018'}, 'g0': {'name': 'Standard acceleration of gravity', 'value': 9.80665, 'uncertainty': 0.0, 'unit': 'm / s2', 'source': 'CODATA2018'}, 'h': {'name': 'Planck constant', 'value': 6.62607015e-34, 'uncertainty': 0.0, 'unit': 'J s', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'hbar': {'name': 'Reduced Planck constant', 'value': 1.0545718176461565e-34, 'uncertainty': 0.0, 'unit': 'J s', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'k_B': {'name': 'Boltzmann constant', 'value': 1.380649e-23, 'uncertainty': 0.0, 'unit': 'J / K', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'm_e': {'name': 'Electron mass', 'value': 9.1093837015e-31, 'uncertainty': 2.8e-40, 'unit': 'kg', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'm_n': {'name': 'Neutron mass', 'value': 1.67492749804e-27, 'uncertainty': 9.5e-37, 'unit': 'kg', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'm_p': {'name': 'Proton mass', 'value': 1.67262192369e-27, 'uncertainty': 5.1e-37, 'unit': 'kg', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'mu0': {'name': 'Vacuum magnetic permeability', 'value': 1.25663706212e-06, 'uncertainty': 1.9e-16, 'unit': 'N / A2', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'muB': {'name': 'Bohr magneton', 'value': 9.2740100783e-24, 'uncertainty': 2.8e-33, 'unit': 'J / T', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'sigma_T': {'name': 'Thomson scattering cross-section', 'value': 6.6524587321e-29, 'uncertainty': 6e-38, 'unit': 'm2', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'sigma_sb': {'name': 'Stefan-Boltzmann constant', 'value': 5.6703744191844314e-08, 'uncertainty': 0.0, 'unit': 'W / (K4 m2)', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'u': {'name': 'Atomic mass', 'value': 1.6605390666e-27, 'uncertainty': 5e-37, 'unit': 'kg', 'reference': 'CODATA 2018', 'source': 'CODATA2018'}, 'GM_earth': {'name': 'Nominal Earth mass parameter', 'value': 398600400000000.0, 'uncertainty': 0.0, 'unit': 'm3 / s2', 'source': 'IAU2015'}, 'GM_jup': {'name': 'Nominal Jupiter mass parameter', 'value': 1.2668653e+17, 'uncertainty': 0.0, 'unit': 'm3 / s2', 'source': 'IAU2015'}, 'GM_sun': {'name': 'Nominal solar mass parameter', 'value': 1.3271244e+20, 'uncertainty': 0.0, 'unit': 'm3 / s2', 'source': 'IAU2015'}, 'L_bol0': {'name': 'Luminosity for absolute bolometric magnitude 0', 'value': 3.0128e+28, 'uncertainty': 0.0, 'unit': 'W', 'source': 'IAU2015'}, 'L_sun': {'name': 'Nominal solar luminosity', 'value': 3.828e+26, 'uncertainty': 0.0, 'unit': 'W', 'reference': 'IAU 2015 Resolution B 3', 'source': 'IAU2015'}, 'M_earth': {'name': 'Earth mass', 'value': 5.972167867791379e+24, 'uncertainty': 1.3422009501651213e+20, 'unit': 'kg', 'reference': 'IAU 2015 Resolution B 3 + CODATA 2018', 'source': 'IAU2015'}, 'M_jup': {'name': 'Jupiter mass', 'value': 1.8981245973360505e+27, 'uncertainty': 4.26589589320839e+22, 'unit': 'kg', 'reference': 'IAU 2015 Resolution B 3 + CODATA 2018', 'source': 'IAU2015'}, 'M_sun': {'name': 'Solar mass', 'value': 1.988409870698051e+30, 'uncertainty': 4.468805426856864e+25, 'unit': 'kg', 'reference': 'IAU 2015 Resolution B 3 + CODATA 2018', 'source': 'IAU2015'}, 'R_earth': {'name': 'Nominal Earth equatorial radius', 'value': 6378100.0, 'uncertainty': 0.0, 'unit': 'm', 'reference': 'IAU 2015 Resolution B 3', 'source': 'IAU2015'}, 'R_jup': {'name': 'Nominal Jupiter equatorial radius', 'value': 71492000.0, 'uncertainty': 0.0, 'unit': 'm', 'reference': 'IAU 2015 Resolution B 3', 'source': 'IAU2015'}, 'R_sun': {'name': 'Nominal solar radius', 'value': 695700000.0, 'uncertainty': 0.0, 'unit': 'm', 'reference': 'IAU 2015 Resolution B 3', 'source': 'IAU2015'}, 'au': {'name': 'Astronomical Unit', 'value': 149597870700.0, 'uncertainty': 0.0, 'unit': 'm', 'reference': 'IAU 2012 Resolution B2', 'source': 'IAU2015'}, 'kpc': {'name': 'Kiloparsec', 'value': 3.0856775814671917e+19, 'uncertainty': 0.0, 'unit': 'm', 'reference': 'Derived from au', 'source': 'IAU2015'}, 'pc': {'name': 'Parsec', 'value': 3.0856775814671916e+16, 'uncertainty': 0.0, 'unit': 'm', 'reference': 'Derived from au', 'source': 'IAU2015'}} return data __all_constants__ = frozenset(read_constants().keys())
#Esta es la respuesta del control def sumarLista(lista, largo): if (largo == 0): return 0 else: return lista[largo - 1] + sumarLista(lista, largo - 1) def Desglosar(numero:int,lista=[]): def rev(l): if len(l) == 0: return [] return [l[-1]] + rev(l[:-1]) if numero==0: reversa=rev(lista) return reversa else: lista.append(numero) return Desglosar(numero-1,lista) def combinar(lista, contador = 0, listaaux = []): if contador == len(lista): return [listaaux] x = combinar(lista, contador + 1, listaaux) y = combinar(lista, contador + 1, listaaux + [lista[contador]]) return x + y n=int(input("Ingrese N:")) k=int(input("Ingrese K:")) if n<1 or k<1: print("Debe ser un valor entero positivo") else: desglosar=Desglosar(n) combinar=combinar(desglosar) contador=0 while contador < len(combinar): if sumarLista(combinar[contador], len(combinar[contador])) == k: print(*combinar[contador]) contador = contador + 1
def sumar_lista(lista, largo): if largo == 0: return 0 else: return lista[largo - 1] + sumar_lista(lista, largo - 1) def desglosar(numero: int, lista=[]): def rev(l): if len(l) == 0: return [] return [l[-1]] + rev(l[:-1]) if numero == 0: reversa = rev(lista) return reversa else: lista.append(numero) return desglosar(numero - 1, lista) def combinar(lista, contador=0, listaaux=[]): if contador == len(lista): return [listaaux] x = combinar(lista, contador + 1, listaaux) y = combinar(lista, contador + 1, listaaux + [lista[contador]]) return x + y n = int(input('Ingrese N:')) k = int(input('Ingrese K:')) if n < 1 or k < 1: print('Debe ser un valor entero positivo') else: desglosar = desglosar(n) combinar = combinar(desglosar) contador = 0 while contador < len(combinar): if sumar_lista(combinar[contador], len(combinar[contador])) == k: print(*combinar[contador]) contador = contador + 1
# Utility functions for incrementing counts in dictionaries or appending to a list of values def add_to_dict_num(D, k, v=1): if k in D: D[k] += v else: D[k] = v def add_to_dict_list(D, k, v): if k in D: D[k].append(v) else: D[k] = [v] def report(min_verbosity, *args): if report.verbosity >= min_verbosity: print(f'[{report.context}]', *args)
def add_to_dict_num(D, k, v=1): if k in D: D[k] += v else: D[k] = v def add_to_dict_list(D, k, v): if k in D: D[k].append(v) else: D[k] = [v] def report(min_verbosity, *args): if report.verbosity >= min_verbosity: print(f'[{report.context}]', *args)
''' Created on Mar 19, 2022 @author: mballance ''' class ActivityBlockMetaT(type): def __init__(self, name, bases, dct): pass def __enter__(self): print("ActivityBlockMetaT.__enter__") def __exit__(self, t, v, tb): pass
""" Created on Mar 19, 2022 @author: mballance """ class Activityblockmetat(type): def __init__(self, name, bases, dct): pass def __enter__(self): print('ActivityBlockMetaT.__enter__') def __exit__(self, t, v, tb): pass
# -*- coding:utf-8 -*- class Solution: def LeftRotateString(self, s, n): # write code here if len(s)==0: return s s = list(s) def flip(s,start,end): for i in range(start,(start+end)//2 + 1): s[i],s[end-i+start] = s[end - i+start],s[i] return s n %= len(s) s = flip(s,0,n-1) s = flip(s,n,len(s)-1) s = flip(s,0,len(s)-1) return "".join(s)
class Solution: def left_rotate_string(self, s, n): if len(s) == 0: return s s = list(s) def flip(s, start, end): for i in range(start, (start + end) // 2 + 1): (s[i], s[end - i + start]) = (s[end - i + start], s[i]) return s n %= len(s) s = flip(s, 0, n - 1) s = flip(s, n, len(s) - 1) s = flip(s, 0, len(s) - 1) return ''.join(s)
''' question link- https://leetcode.com/problems/sum-of-all-subset-xor-totals/ Sum of All Subset XOR Totals Question statement: The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1. ''' def subsetXORSum(self, nums): l = len(nums) res = 0 stack = [(0, 0)] while stack: pos, xor = stack.pop() res+=xor for i in range(pos, l): stack.append((i+1, xor^nums[i])) return res
""" question link- https://leetcode.com/problems/sum-of-all-subset-xor-totals/ Sum of All Subset XOR Totals Question statement: The XOR total of an array is defined as the bitwise XOR of all its elements, or 0 if the array is empty. For example, the XOR total of the array [2,5,6] is 2 XOR 5 XOR 6 = 1. """ def subset_xor_sum(self, nums): l = len(nums) res = 0 stack = [(0, 0)] while stack: (pos, xor) = stack.pop() res += xor for i in range(pos, l): stack.append((i + 1, xor ^ nums[i])) return res
class Solution: def uniquePaths(self, m: int, n: int) -> int: ans = [1]*n for i in range(1,m): for j in range(1,n): ans[j] = ans[j-1] + ans[j] return ans[-1] if m and n else 0
class Solution: def unique_paths(self, m: int, n: int) -> int: ans = [1] * n for i in range(1, m): for j in range(1, n): ans[j] = ans[j - 1] + ans[j] return ans[-1] if m and n else 0
''' Write a Python program to compute the sum of all items of a given array of integers where each integer is multiplied by its index. Return 0 if there is no number. Sample Input: [1,2,3,4] [-1,-2,-3,-4] [] Sample Output: 20 -20 0 ''' def sum_index_multiplier(nums): # use enumerate to return count and value #single line of return statement with for return sum(j*i for i, j in enumerate(nums)) print(sum_index_multiplier([1,2,3,4])) print(sum_index_multiplier([-1,-2,-3,-4])) print(sum_index_multiplier([]))
""" Write a Python program to compute the sum of all items of a given array of integers where each integer is multiplied by its index. Return 0 if there is no number. Sample Input: [1,2,3,4] [-1,-2,-3,-4] [] Sample Output: 20 -20 0 """ def sum_index_multiplier(nums): return sum((j * i for (i, j) in enumerate(nums))) print(sum_index_multiplier([1, 2, 3, 4])) print(sum_index_multiplier([-1, -2, -3, -4])) print(sum_index_multiplier([]))
class Node: def __init__(self, data=None): self.data = data self.left = None self.right = None class BinaryTree: def __init__(self, root): self.root = Node(root) def display(self, start, traversal=""): if start != None: traversal += (str(start.data) + " ") traversal = self.display(start.left, traversal) traversal = self.display(start.right, traversal) return traversal def is_bst(self): start = self.root traversal = "" if start.data != None: if start.left.data > start.data: return False if start.right.data < start.data: return False self.display(start.left, traversal) self.display(start.right, traversal) return True def highest_value(self, start, traversal): if start != None: if start.data > traversal: traversal = start.data traversal = self.highest_value(start.left, traversal) traversal = self.highest_value(start.right, traversal) return traversal def lowest_value(self, start, traversal): if start != None: if start.data < traversal: traversal = start.data traversal = self.lowest_value(start.left, traversal) traversal = self.lowest_value(start.right, traversal) return traversal
class Node: def __init__(self, data=None): self.data = data self.left = None self.right = None class Binarytree: def __init__(self, root): self.root = node(root) def display(self, start, traversal=''): if start != None: traversal += str(start.data) + ' ' traversal = self.display(start.left, traversal) traversal = self.display(start.right, traversal) return traversal def is_bst(self): start = self.root traversal = '' if start.data != None: if start.left.data > start.data: return False if start.right.data < start.data: return False self.display(start.left, traversal) self.display(start.right, traversal) return True def highest_value(self, start, traversal): if start != None: if start.data > traversal: traversal = start.data traversal = self.highest_value(start.left, traversal) traversal = self.highest_value(start.right, traversal) return traversal def lowest_value(self, start, traversal): if start != None: if start.data < traversal: traversal = start.data traversal = self.lowest_value(start.left, traversal) traversal = self.lowest_value(start.right, traversal) return traversal
class Solution: def expandFromMiddle(self, s:str, l:int, r:int): while (l >= 0 and r < len(s) and s[l] == s[r]): l -= 1 r += 1 return (r - l - 1) def longestPalindrome(self, s: str) -> str: if len(s) < 1: return 0 start = 0 end = 0 for i in range(len(s)): l1 = self.expandFromMiddle(s, i, i) l2 = self.expandFromMiddle(s, i, i+1) ls = max(l1,l2) if ls > end - start: start = i - ((ls - 1)//2) end = i + (ls//2) return s[start: end+1] if __name__ == "__main__": sol = Solution() s = "babab" s = "cbbd" # s = 'bb' # s = "babc" # s = "aca" # s = "defggbac" # s = 'a' s = "babad" # s = "ccc" s = "abb" # s = "reifadyqgztixemwswtccodfnchcovrmiooffbbijkecuvlvukecutasfxqcqygltrogrdxlrslbnzktlanycgtniprjlospzhhgdrqcwlukbpsrumxguskubokxcmswjnssbkutdhppsdckuckcbwbxpmcmdicfjxaanoxndlfpqwneytatcbyjmimyawevmgirunvmdvxwdjbiqszwhfhjmrpexfwrbzkipxfowcbqjckaotmmgkrbjvhihgwuszdrdiijkgjoljjdubcbowvxslctleblfmdzmvdkqdxtiylabrwaccikkpnpsgcotxoggdydqnuogmxttcycjorzrtwtcchxrbbknfmxnonbhgbjjypqhbftceduxgrnaswtbytrhuiqnxkivevhprcvhggugrmmxolvfzwadlnzdwbtqbaveoongezoymdrhywxcxvggsewsxckucmncbrljskgsgtehortuvbtrsfisyewchxlmxqccoplhlzwutoqoctgfnrzhqctxaqacmirrqdwsbdpqttmyrmxxawgtjzqjgffqwlxqxwxrkgtzqkgdulbxmfcvxcwoswystiyittdjaqvaijwscqobqlhskhvoktksvmguzfankdigqlegrxxqpoitdtykfltohnzrcgmlnhddcfmawiriiiblwrttveedkxzzagdzpwvriuctvtrvdpqzcdnrkgcnpwjlraaaaskgguxzljktqvzzmruqqslutiipladbcxdwxhmvevsjrdkhdpxcyjkidkoznuagshnvccnkyeflpyjzlcbmhbytxnfzcrnmkyknbmtzwtaceajmnuyjblmdlbjdjxctvqcoqkbaszvrqvjgzdqpvmucerumskjrwhywjkwgligkectzboqbanrsvynxscpxqxtqhthdytfvhzjdcxgckvgfbldsfzxqdozxicrwqyprgnadfxsionkzzegmeynye" print(sol.longestPalindrome(s))
class Solution: def expand_from_middle(self, s: str, l: int, r: int): while l >= 0 and r < len(s) and (s[l] == s[r]): l -= 1 r += 1 return r - l - 1 def longest_palindrome(self, s: str) -> str: if len(s) < 1: return 0 start = 0 end = 0 for i in range(len(s)): l1 = self.expandFromMiddle(s, i, i) l2 = self.expandFromMiddle(s, i, i + 1) ls = max(l1, l2) if ls > end - start: start = i - (ls - 1) // 2 end = i + ls // 2 return s[start:end + 1] if __name__ == '__main__': sol = solution() s = 'babab' s = 'cbbd' s = 'babad' s = 'abb' print(sol.longestPalindrome(s))
class Paddle(): def __init__(self, x1, x2 , y1, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 #private method def __setPaddleRight(self): self.x1 = 4 self.x2 = 4 self.y1 = 0 self.y2 = 1 display.set_pixel(self.x1, self.y1, 9) display.set_pixel(self.x2, self.y2, 9) #private method def __setPaddleLeft(self): self.x1 = 0 self.x2 = 0 self.y1 = 4 self.y2 = 3 display.set_pixel(self.x1, self.y1, 9) display.set_pixel(self.x2, self.y2, 9) def startGame(self): self.__setPaddleLeft() self.__setPaddleRight() def moveUp(self): self.y1 -= 1 self.y2 -= 1 if self.y1 or self.y2 == 0: return self.y1, self.y2 def moveDown(self): self.y += 1 self.y += 1 if self.y1 or self.y2 == 0: return self.y1, self.y2 def getCurrentPosition(self): return self.x1, self.y1, self.x2, self.y2 def update(self): display.set_pixel(self.x1, self.y1, 9) display.set_pixel(self.x2, self.y2, 9)
class Paddle: def __init__(self, x1, x2, y1, y2): self.x1 = x1 self.y1 = y1 self.x2 = x2 self.y2 = y2 def __set_paddle_right(self): self.x1 = 4 self.x2 = 4 self.y1 = 0 self.y2 = 1 display.set_pixel(self.x1, self.y1, 9) display.set_pixel(self.x2, self.y2, 9) def __set_paddle_left(self): self.x1 = 0 self.x2 = 0 self.y1 = 4 self.y2 = 3 display.set_pixel(self.x1, self.y1, 9) display.set_pixel(self.x2, self.y2, 9) def start_game(self): self.__setPaddleLeft() self.__setPaddleRight() def move_up(self): self.y1 -= 1 self.y2 -= 1 if self.y1 or self.y2 == 0: return (self.y1, self.y2) def move_down(self): self.y += 1 self.y += 1 if self.y1 or self.y2 == 0: return (self.y1, self.y2) def get_current_position(self): return (self.x1, self.y1, self.x2, self.y2) def update(self): display.set_pixel(self.x1, self.y1, 9) display.set_pixel(self.x2, self.y2, 9)
class Solution(object): def maxProfit(self, prices): """ :type prices: List[int] :rtype: int """ minBuy = 999999 # probably should use sys.maxint maxProfits = 0 for i in xrange(len(prices)): minBuy = min(minBuy, prices[i]) maxProfits = max(maxProfits, prices[i] - minBuy) return maxProfits
class Solution(object): def max_profit(self, prices): """ :type prices: List[int] :rtype: int """ min_buy = 999999 max_profits = 0 for i in xrange(len(prices)): min_buy = min(minBuy, prices[i]) max_profits = max(maxProfits, prices[i] - minBuy) return maxProfits
class Enum(set): def __getattr__(self, name): if name in self: return name raise AttributeError def log(message, log_class, log_level): """Log information to the console. If you are angry about having to use Enums instead of typing the classes and levels in, look up how any logging facility works. Arguments: message -- the relevant information to be logged log_class -- the category of information to be logged. Must be within util.log.LogClass log_level -- the severity of the information being logged. Must be within util.log.LogLevel """ assert log_class in LogClass assert log_level in LogLevel print("%s/%s: %s" % (log_level, log_class, message)) LogClass = Enum(["CV", "GRAPHICS", "GENERAL"]) LogLevel = Enum(["VERBOSE", "INFO", "WARNING", "ERROR"])
class Enum(set): def __getattr__(self, name): if name in self: return name raise AttributeError def log(message, log_class, log_level): """Log information to the console. If you are angry about having to use Enums instead of typing the classes and levels in, look up how any logging facility works. Arguments: message -- the relevant information to be logged log_class -- the category of information to be logged. Must be within util.log.LogClass log_level -- the severity of the information being logged. Must be within util.log.LogLevel """ assert log_class in LogClass assert log_level in LogLevel print('%s/%s: %s' % (log_level, log_class, message)) log_class = enum(['CV', 'GRAPHICS', 'GENERAL']) log_level = enum(['VERBOSE', 'INFO', 'WARNING', 'ERROR'])
class Solution: def findContestMatch(self, n): """ :type n: int :rtype: str """ ans = list(range(1, n + 1)) while len(ans) > 1: ans = ["({},{})".format(ans[i], ans[~i]) for i in range(len(ans) // 2)] return ans[0]
class Solution: def find_contest_match(self, n): """ :type n: int :rtype: str """ ans = list(range(1, n + 1)) while len(ans) > 1: ans = ['({},{})'.format(ans[i], ans[~i]) for i in range(len(ans) // 2)] return ans[0]
N, C, S, *l = map(int, open(0).read().split()) c = 0 S -= 1 ans = 0 for i in l: ans += c == S c = (c+i+N)%N ans += c == S print(ans)
(n, c, s, *l) = map(int, open(0).read().split()) c = 0 s -= 1 ans = 0 for i in l: ans += c == S c = (c + i + N) % N ans += c == S print(ans)
"""Question: https://leetcode.com/problems/palindrome-number/ """ class Solution: def isPalindrome(self, x: int) -> bool: if x < 0: return False copy, reverse = x, 0 while copy: reverse *= 10 reverse += copy % 10 copy = copy // 10 return x == reverse def isPalindrome_using_str(self, x: int) -> bool: return str(x) == str(x)[::-1] if __name__ == '__main__': x = 121 output = Solution().isPalindrome(x) print(f'x: {x}\toutput: {output}') x = -121 output = Solution().isPalindrome(x) print(f'x: {x}\toutput: {output}')
"""Question: https://leetcode.com/problems/palindrome-number/ """ class Solution: def is_palindrome(self, x: int) -> bool: if x < 0: return False (copy, reverse) = (x, 0) while copy: reverse *= 10 reverse += copy % 10 copy = copy // 10 return x == reverse def is_palindrome_using_str(self, x: int) -> bool: return str(x) == str(x)[::-1] if __name__ == '__main__': x = 121 output = solution().isPalindrome(x) print(f'x: {x}\toutput: {output}') x = -121 output = solution().isPalindrome(x) print(f'x: {x}\toutput: {output}')
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @author: Sandip Dutta """ # To implement simple tree algorithms # DFS on Binary Tree, # Problem Stateent : sum of all leaf nodes #number of nodes of tree n = 10 '''we take starting node to be 0th node''' ''' tree is a directed graph here''' tree = [[1, 2],#0 [3, 5],#1 [7, 8],#2 [4],#3 [],#4 [6],#5 [],#6 [],#7 [9],#8 []]#9 #Records if visited or not visited = [False] * n def isLeafNode(neighbour): '''checks if leaf node or not''' #[] evaluates to False # if tree[neighbour] is [], return True return not tree[neighbour] def sum_of_leaf_nodes(): '''sum of leaf nodes calculated''' # Empty tree if tree == None: return 0 # Set 0 as visited visited[0] = True # total of all leaf nodes total = 0 # Traverses the tree for node in range(n): # Get neighbours for neighbour in tree[node]: # If not visited neighbours, then go inside if not visited[neighbour]: # Mark as visited visited[neighbour] = True # if leaf node, add that value to total if isLeafNode(neighbour): total += neighbour # Return the total return total # Print the sum of the root nodesz print("sum is {}".format(sum_of_leaf_nodes())) # ============================================================================= # Make sure to turn visited to all False values as we will be reusing that # array again # ============================================================================= # Recursive version of the above function def sum_of_leaf_nodes_R(node): # Empty tree if tree == None: return 0 total = 0 # Set 0 as visited visited[node] = True # If leaf node, return the value of the node if isLeafNode(node): return node # checks for all neighbours for neighbour in tree[node]: # If unvisited neighbours, visit if not visited[neighbour]: # Add leaf node sum to total total += sum_of_leaf_nodes_R(neighbour) # Return the total return total # Print the sum of the root nodesz print("sum is {}".format(sum_of_leaf_nodes_R(0)))
""" @author: Sandip Dutta """ n = 10 'we take starting node to be 0th node' ' tree is a directed graph here' tree = [[1, 2], [3, 5], [7, 8], [4], [], [6], [], [], [9], []] visited = [False] * n def is_leaf_node(neighbour): """checks if leaf node or not""" return not tree[neighbour] def sum_of_leaf_nodes(): """sum of leaf nodes calculated""" if tree == None: return 0 visited[0] = True total = 0 for node in range(n): for neighbour in tree[node]: if not visited[neighbour]: visited[neighbour] = True if is_leaf_node(neighbour): total += neighbour return total print('sum is {}'.format(sum_of_leaf_nodes())) def sum_of_leaf_nodes_r(node): if tree == None: return 0 total = 0 visited[node] = True if is_leaf_node(node): return node for neighbour in tree[node]: if not visited[neighbour]: total += sum_of_leaf_nodes_r(neighbour) return total print('sum is {}'.format(sum_of_leaf_nodes_r(0)))
def mensagem(cor='', msg='', firula='', tamanho=0): if '\n' in msg: linha = msg.find('\n') else: linha = len(msg) limpa = '\033[m' if tamanho == 0: tamanho = firula * (linha + 4) if firula == '': print(f'{cor} {msg} {limpa}') else: print(f'{cor}{tamanho}{limpa}') print(f'{cor} {msg} \033[m') print(f'{cor}{tamanho}{limpa}')
def mensagem(cor='', msg='', firula='', tamanho=0): if '\n' in msg: linha = msg.find('\n') else: linha = len(msg) limpa = '\x1b[m' if tamanho == 0: tamanho = firula * (linha + 4) if firula == '': print(f'{cor} {msg} {limpa}') else: print(f'{cor}{tamanho}{limpa}') print(f'{cor} {msg} \x1b[m') print(f'{cor}{tamanho}{limpa}')
''' Leetcode Problem number 687. Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root. The length of path between two nodes is represented by the number of edges between them. ''' class Solution: def longestUnivaluePath(self, root: TreeNode) -> int: self.max_path = 0; if(root is None or (root.left is None and root.right is None )): pass else: self.find_max_path(root) return self.max_path def set_max_value(self,new_val)-> None: self.max_path = new_val def find_max_path(self, root: TreeNode) -> int: ''' finds longest path of 1 value and updates the overall maximum value. return : current node's maximum matching value ''' if(root is None or (root.left is None and root.right is None )): return 0 cur_length=0 left_is_same = False left_max_path = 0 right_max_path = 0 if(root.left): left_max_path = self.find_max_path(root.left) if(root.left.val == root.val ): cur_length += 1 + left_max_path; left_is_same = True else: cur_length = 0; if(root.right): right_max_path = self.find_max_path(root.right) if(root.right.val == root.val and left_is_same): self.set_max_value(max(self.max_path, cur_length + 1 + right_max_path)) if(root.right.val == root.val): cur_length = max(1 + right_max_path, cur_length); self.set_max_value(max(self.max_path,cur_length)) return cur_length
""" Leetcode Problem number 687. Given a binary tree, find the length of the longest path where each node in the path has the same value. This path may or may not pass through the root. The length of path between two nodes is represented by the number of edges between them. """ class Solution: def longest_univalue_path(self, root: TreeNode) -> int: self.max_path = 0 if root is None or (root.left is None and root.right is None): pass else: self.find_max_path(root) return self.max_path def set_max_value(self, new_val) -> None: self.max_path = new_val def find_max_path(self, root: TreeNode) -> int: """ finds longest path of 1 value and updates the overall maximum value. return : current node's maximum matching value """ if root is None or (root.left is None and root.right is None): return 0 cur_length = 0 left_is_same = False left_max_path = 0 right_max_path = 0 if root.left: left_max_path = self.find_max_path(root.left) if root.left.val == root.val: cur_length += 1 + left_max_path left_is_same = True else: cur_length = 0 if root.right: right_max_path = self.find_max_path(root.right) if root.right.val == root.val and left_is_same: self.set_max_value(max(self.max_path, cur_length + 1 + right_max_path)) if root.right.val == root.val: cur_length = max(1 + right_max_path, cur_length) self.set_max_value(max(self.max_path, cur_length)) return cur_length
class Except(Exception): def __init__(*args, **kwargs): Exception.__init__(*args, **kwargs) def CheckExceptions(data): raise Except(data)
class Except(Exception): def __init__(*args, **kwargs): Exception.__init__(*args, **kwargs) def check_exceptions(data): raise except(data)
# -*- coding: utf-8 -*- """ Created on Sat Aug 22 19:49:17 2020 @author: matth """ def _linprog_highs_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='highs', callback=None, maxiter=None, disp=False, presolve=True, time_limit=None, dual_feasibility_tolerance=None, primal_feasibility_tolerance=None, ipm_optimality_tolerance=None, simplex_dual_edge_weight_strategy=None, **unknown_options): r""" Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using one of the HiGHS solvers. Linear programming solves problems of the following form: .. math:: \min_x \ & c^T x \\ \mbox{such that} \ & A_{ub} x \leq b_{ub},\\ & A_{eq} x = b_{eq},\\ & l \leq x \leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'highs', which chooses automatically between :ref:`'highs-ds' <optimize.linprog-highs-ds>` and :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. integrality : 1-D array, optional Indicates the type of integrality constraint on each decision variable. ``0`` : Continuous variable; no integrality constraint. ``1`` : Integer variable; decision variable must be an integer within `bounds`. ``2`` : Semi-continuous variable; decision variable must be within `bounds` or take value ``0``. ``3`` : Semi-integer variable; decision variable must be an integer within `bounds` or take value ``0``. By default, all variables are continuous. Options ------- maxiter : int The maximum number of iterations to perform in either phase. For :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, this does not include the number of crossover iterations. Default is the largest possible value for an ``int`` on the platform. disp : bool (default: ``False``) Set to ``True`` if indicators of optimization status are to be printed to the console during optimization. presolve : bool (default: ``True``) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. time_limit : float The maximum time in seconds allotted to solve the problem; default is the largest possible value for a ``double`` on the platform. dual_feasibility_tolerance : double (default: 1e-07) Dual feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. The minimum of this and ``primal_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. primal_feasibility_tolerance : double (default: 1e-07) Primal feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. The minimum of this and ``dual_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. ipm_optimality_tolerance : double (default: ``1e-08``) Optimality tolerance for :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. Minimum allowable value is 1e-12. simplex_dual_edge_weight_strategy : str (default: None) Strategy for simplex dual edge weights. The default, ``None``, automatically selects one of the following. ``'dantzig'`` uses Dantzig's original strategy of choosing the most negative reduced cost. ``'devex'`` uses the strategy described in [15]_. ``steepest`` uses the exact steepest edge strategy as described in [16]_. ``'steepest-devex'`` begins with the exact steepest edge strategy until the computation is too costly or inexact and then switches to the devex method. Curently, ``None`` always selects ``'steepest-devex'``, but this may change as new options become available. unknown_options : dict Optional arguments not used by this particular solver. If ``unknown_options`` is non-empty, a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1D array The (nominally positive) values of the slack, ``b_ub - A_ub @ x``. con : 1D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration or time limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : The HiGHS solver ran into a problem. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed. For the HiGHS simplex method, this includes iterations in all phases. For the HiGHS interior-point method, this does not include crossover iterations. crossover_nit : int The number of primal/dual pushes performed during the crossover routine for the HiGHS interior-point method. This is ``0`` for the HiGHS simplex method. ineqlin : OptimizeResult Solution and sensitivity information corresponding to the inequality constraints, `b_ub`. A dictionary consisting of the fields: residual : np.ndnarray The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. This quantity is also commonly referred to as "slack". marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the inequality constraints, `b_ub`. eqlin : OptimizeResult Solution and sensitivity information corresponding to the equality constraints, `b_eq`. A dictionary consisting of the fields: residual : np.ndarray The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the equality constraints, `b_eq`. lower, upper : OptimizeResult Solution and sensitivity information corresponding to the lower and upper bounds on decision variables, `bounds`. residual : np.ndarray The (nominally positive) values of the quantity ``x - lb`` (lower) or ``ub - x`` (upper). marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the lower and upper `bounds`. Notes ----- Method :ref:`'highs-ds' <optimize.linprog-highs-ds>` is a wrapper of the C++ high performance dual revised simplex implementation (HSOL) [13]_, [14]_. Method :ref:`'highs-ipm' <optimize.linprog-highs-ipm>` is a wrapper of a C++ implementation of an **i**\ nterior-\ **p**\ oint **m**\ ethod [13]_; it features a crossover routine, so it is as accurate as a simplex solver. Method :ref:`'highs' <optimize.linprog-highs>` chooses between the two automatically. For new code involving `linprog`, we recommend explicitly choosing one of these three method values instead of :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy). The result fields `ineqlin`, `eqlin`, `lower`, and `upper` all contain `marginals`, or partial derivatives of the objective function with respect to the right-hand side of each constraint. These partial derivatives are also referred to as "Lagrange multipliers", "dual values", and "shadow prices". The sign convention of `marginals` is opposite that of Lagrange multipliers produced by many nonlinear solvers. References ---------- .. [13] Huangfu, Q., Galabova, I., Feldmeier, M., and Hall, J. A. J. "HiGHS - high performance software for linear optimization." Accessed 4/16/2020 at https://www.maths.ed.ac.uk/hall/HiGHS/#guide .. [14] Huangfu, Q. and Hall, J. A. J. "Parallelizing the dual revised simplex method." Mathematical Programming Computation, 10 (1), 119-142, 2018. DOI: 10.1007/s12532-017-0130-5 .. [15] Harris, Paula MJ. "Pivot selection methods of the Devex LP code." Mathematical programming 5.1 (1973): 1-28. .. [16] Goldfarb, Donald, and John Ker Reid. "A practicable steepest-edge simplex algorithm." Mathematical Programming 12.1 (1977): 361-371. """ pass def _linprog_highs_ds_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='highs-ds', callback=None, maxiter=None, disp=False, presolve=True, time_limit=None, dual_feasibility_tolerance=None, primal_feasibility_tolerance=None, simplex_dual_edge_weight_strategy=None, **unknown_options): r""" Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the HiGHS dual simplex solver. Linear programming solves problems of the following form: .. math:: \min_x \ & c^T x \\ \mbox{such that} \ & A_{ub} x \leq b_{ub},\\ & A_{eq} x = b_{eq},\\ & l \leq x \leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'highs-ds'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. Options ------- maxiter : int The maximum number of iterations to perform in either phase. Default is the largest possible value for an ``int`` on the platform. disp : bool (default: ``False``) Set to ``True`` if indicators of optimization status are to be printed to the console during optimization. presolve : bool (default: ``True``) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. time_limit : float The maximum time in seconds allotted to solve the problem; default is the largest possible value for a ``double`` on the platform. dual_feasibility_tolerance : double (default: 1e-07) Dual feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. primal_feasibility_tolerance : double (default: 1e-07) Primal feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. simplex_dual_edge_weight_strategy : str (default: None) Strategy for simplex dual edge weights. The default, ``None``, automatically selects one of the following. ``'dantzig'`` uses Dantzig's original strategy of choosing the most negative reduced cost. ``'devex'`` uses the strategy described in [15]_. ``steepest`` uses the exact steepest edge strategy as described in [16]_. ``'steepest-devex'`` begins with the exact steepest edge strategy until the computation is too costly or inexact and then switches to the devex method. Curently, ``None`` always selects ``'steepest-devex'``, but this may change as new options become available. unknown_options : dict Optional arguments not used by this particular solver. If ``unknown_options`` is non-empty, a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1D array The (nominally positive) values of the slack, ``b_ub - A_ub @ x``. con : 1D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration or time limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : The HiGHS solver ran into a problem. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed. This includes iterations in all phases. crossover_nit : int This is always ``0`` for the HiGHS simplex method. For the HiGHS interior-point method, this is the number of primal/dual pushes performed during the crossover routine. ineqlin : OptimizeResult Solution and sensitivity information corresponding to the inequality constraints, `b_ub`. A dictionary consisting of the fields: residual : np.ndnarray The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. This quantity is also commonly referred to as "slack". marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the inequality constraints, `b_ub`. eqlin : OptimizeResult Solution and sensitivity information corresponding to the equality constraints, `b_eq`. A dictionary consisting of the fields: residual : np.ndarray The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the equality constraints, `b_eq`. lower, upper : OptimizeResult Solution and sensitivity information corresponding to the lower and upper bounds on decision variables, `bounds`. residual : np.ndarray The (nominally positive) values of the quantity ``x - lb`` (lower) or ``ub - x`` (upper). marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the lower and upper `bounds`. Notes ----- Method :ref:`'highs-ds' <optimize.linprog-highs-ds>` is a wrapper of the C++ high performance dual revised simplex implementation (HSOL) [13]_, [14]_. Method :ref:`'highs-ipm' <optimize.linprog-highs-ipm>` is a wrapper of a C++ implementation of an **i**\ nterior-\ **p**\ oint **m**\ ethod [13]_; it features a crossover routine, so it is as accurate as a simplex solver. Method :ref:`'highs' <optimize.linprog-highs>` chooses between the two automatically. For new code involving `linprog`, we recommend explicitly choosing one of these three method values instead of :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy). The result fields `ineqlin`, `eqlin`, `lower`, and `upper` all contain `marginals`, or partial derivatives of the objective function with respect to the right-hand side of each constraint. These partial derivatives are also referred to as "Lagrange multipliers", "dual values", and "shadow prices". The sign convention of `marginals` is opposite that of Lagrange multipliers produced by many nonlinear solvers. References ---------- .. [13] Huangfu, Q., Galabova, I., Feldmeier, M., and Hall, J. A. J. "HiGHS - high performance software for linear optimization." Accessed 4/16/2020 at https://www.maths.ed.ac.uk/hall/HiGHS/#guide .. [14] Huangfu, Q. and Hall, J. A. J. "Parallelizing the dual revised simplex method." Mathematical Programming Computation, 10 (1), 119-142, 2018. DOI: 10.1007/s12532-017-0130-5 .. [15] Harris, Paula MJ. "Pivot selection methods of the Devex LP code." Mathematical programming 5.1 (1973): 1-28. .. [16] Goldfarb, Donald, and John Ker Reid. "A practicable steepest-edge simplex algorithm." Mathematical Programming 12.1 (1977): 361-371. """ pass def _linprog_highs_ipm_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='highs-ipm', callback=None, maxiter=None, disp=False, presolve=True, time_limit=None, dual_feasibility_tolerance=None, primal_feasibility_tolerance=None, ipm_optimality_tolerance=None, **unknown_options): r""" Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the HiGHS interior point solver. Linear programming solves problems of the following form: .. math:: \min_x \ & c^T x \\ \mbox{such that} \ & A_{ub} x \leq b_{ub},\\ & A_{eq} x = b_{eq},\\ & l \leq x \leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'highs-ipm'. :ref:`'highs-ipm' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. Options ------- maxiter : int The maximum number of iterations to perform in either phase. For :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, this does not include the number of crossover iterations. Default is the largest possible value for an ``int`` on the platform. disp : bool (default: ``False``) Set to ``True`` if indicators of optimization status are to be printed to the console during optimization. presolve : bool (default: ``True``) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. time_limit : float The maximum time in seconds allotted to solve the problem; default is the largest possible value for a ``double`` on the platform. dual_feasibility_tolerance : double (default: 1e-07) The minimum of this and ``primal_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. primal_feasibility_tolerance : double (default: 1e-07) The minimum of this and ``dual_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. ipm_optimality_tolerance : double (default: ``1e-08``) Optimality tolerance for :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. Minimum allowable value is 1e-12. unknown_options : dict Optional arguments not used by this particular solver. If ``unknown_options`` is non-empty, a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1D array The (nominally positive) values of the slack, ``b_ub - A_ub @ x``. con : 1D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration or time limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : The HiGHS solver ran into a problem. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed. For the HiGHS interior-point method, this does not include crossover iterations. crossover_nit : int The number of primal/dual pushes performed during the crossover routine for the HiGHS interior-point method. ineqlin : OptimizeResult Solution and sensitivity information corresponding to the inequality constraints, `b_ub`. A dictionary consisting of the fields: residual : np.ndnarray The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. This quantity is also commonly referred to as "slack". marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the inequality constraints, `b_ub`. eqlin : OptimizeResult Solution and sensitivity information corresponding to the equality constraints, `b_eq`. A dictionary consisting of the fields: residual : np.ndarray The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the equality constraints, `b_eq`. lower, upper : OptimizeResult Solution and sensitivity information corresponding to the lower and upper bounds on decision variables, `bounds`. residual : np.ndarray The (nominally positive) values of the quantity ``x - lb`` (lower) or ``ub - x`` (upper). marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the lower and upper `bounds`. Notes ----- Method :ref:`'highs-ipm' <optimize.linprog-highs-ipm>` is a wrapper of a C++ implementation of an **i**\ nterior-\ **p**\ oint **m**\ ethod [13]_; it features a crossover routine, so it is as accurate as a simplex solver. Method :ref:`'highs-ds' <optimize.linprog-highs-ds>` is a wrapper of the C++ high performance dual revised simplex implementation (HSOL) [13]_, [14]_. Method :ref:`'highs' <optimize.linprog-highs>` chooses between the two automatically. For new code involving `linprog`, we recommend explicitly choosing one of these three method values instead of :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy). The result fields `ineqlin`, `eqlin`, `lower`, and `upper` all contain `marginals`, or partial derivatives of the objective function with respect to the right-hand side of each constraint. These partial derivatives are also referred to as "Lagrange multipliers", "dual values", and "shadow prices". The sign convention of `marginals` is opposite that of Lagrange multipliers produced by many nonlinear solvers. References ---------- .. [13] Huangfu, Q., Galabova, I., Feldmeier, M., and Hall, J. A. J. "HiGHS - high performance software for linear optimization." Accessed 4/16/2020 at https://www.maths.ed.ac.uk/hall/HiGHS/#guide .. [14] Huangfu, Q. and Hall, J. A. J. "Parallelizing the dual revised simplex method." Mathematical Programming Computation, 10 (1), 119-142, 2018. DOI: 10.1007/s12532-017-0130-5 """ pass def _linprog_ip_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='interior-point', callback=None, maxiter=1000, disp=False, presolve=True, tol=1e-8, autoscale=False, rr=True, alpha0=.99995, beta=0.1, sparse=False, lstsq=False, sym_pos=True, cholesky=True, pc=True, ip=False, permc_spec='MMD_AT_PLUS_A', **unknown_options): r""" Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the interior-point method of [4]_. .. deprecated:: 1.9.0 `method='interior-point'` will be removed in SciPy 1.11.0. It is replaced by `method='highs'` because the latter is faster and more robust. Linear programming solves problems of the following form: .. math:: \min_x \ & c^T x \\ \mbox{such that} \ & A_{ub} x \leq b_{ub},\\ & A_{eq} x = b_{eq},\\ & l \leq x \leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'interior-point'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. callback : callable, optional Callback function to be executed once per iteration. Options ------- maxiter : int (default: 1000) The maximum number of iterations of the algorithm. disp : bool (default: False) Set to ``True`` if indicators of optimization status are to be printed to the console each iteration. presolve : bool (default: True) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. tol : float (default: 1e-8) Termination tolerance to be used for all termination criteria; see [4]_ Section 4.5. autoscale : bool (default: False) Set to ``True`` to automatically perform equilibration. Consider using this option if the numerical values in the constraints are separated by several orders of magnitude. rr : bool (default: True) Set to ``False`` to disable automatic redundancy removal. alpha0 : float (default: 0.99995) The maximal step size for Mehrota's predictor-corrector search direction; see :math:`\beta_{3}` of [4]_ Table 8.1. beta : float (default: 0.1) The desired reduction of the path parameter :math:`\mu` (see [6]_) when Mehrota's predictor-corrector is not in use (uncommon). sparse : bool (default: False) Set to ``True`` if the problem is to be treated as sparse after presolve. If either ``A_eq`` or ``A_ub`` is a sparse matrix, this option will automatically be set ``True``, and the problem will be treated as sparse even during presolve. If your constraint matrices contain mostly zeros and the problem is not very small (less than about 100 constraints or variables), consider setting ``True`` or providing ``A_eq`` and ``A_ub`` as sparse matrices. lstsq : bool (default: ``False``) Set to ``True`` if the problem is expected to be very poorly conditioned. This should always be left ``False`` unless severe numerical difficulties are encountered. Leave this at the default unless you receive a warning message suggesting otherwise. sym_pos : bool (default: True) Leave ``True`` if the problem is expected to yield a well conditioned symmetric positive definite normal equation matrix (almost always). Leave this at the default unless you receive a warning message suggesting otherwise. cholesky : bool (default: True) Set to ``True`` if the normal equations are to be solved by explicit Cholesky decomposition followed by explicit forward/backward substitution. This is typically faster for problems that are numerically well-behaved. pc : bool (default: True) Leave ``True`` if the predictor-corrector method of Mehrota is to be used. This is almost always (if not always) beneficial. ip : bool (default: False) Set to ``True`` if the improved initial point suggestion due to [4]_ Section 4.3 is desired. Whether this is beneficial or not depends on the problem. permc_spec : str (default: 'MMD_AT_PLUS_A') (Has effect only with ``sparse = True``, ``lstsq = False``, ``sym_pos = True``, and no SuiteSparse.) A matrix is factorized in each iteration of the algorithm. This option specifies how to permute the columns of the matrix for sparsity preservation. Acceptable values are: - ``NATURAL``: natural ordering. - ``MMD_ATA``: minimum degree ordering on the structure of A^T A. - ``MMD_AT_PLUS_A``: minimum degree ordering on the structure of A^T+A. - ``COLAMD``: approximate minimum degree column ordering. This option can impact the convergence of the interior point algorithm; test different values to determine which performs best for your problem. For more information, refer to ``scipy.sparse.linalg.splu``. unknown_options : dict Optional arguments not used by this particular solver. If `unknown_options` is non-empty a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1-D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1-D array The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. con : 1-D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : Numerical difficulties encountered. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed in all phases. Notes ----- This method implements the algorithm outlined in [4]_ with ideas from [8]_ and a structure inspired by the simpler methods of [6]_. The primal-dual path following method begins with initial 'guesses' of the primal and dual variables of the standard form problem and iteratively attempts to solve the (nonlinear) Karush-Kuhn-Tucker conditions for the problem with a gradually reduced logarithmic barrier term added to the objective. This particular implementation uses a homogeneous self-dual formulation, which provides certificates of infeasibility or unboundedness where applicable. The default initial point for the primal and dual variables is that defined in [4]_ Section 4.4 Equation 8.22. Optionally (by setting initial point option ``ip=True``), an alternate (potentially improved) starting point can be calculated according to the additional recommendations of [4]_ Section 4.4. A search direction is calculated using the predictor-corrector method (single correction) proposed by Mehrota and detailed in [4]_ Section 4.1. (A potential improvement would be to implement the method of multiple corrections described in [4]_ Section 4.2.) In practice, this is accomplished by solving the normal equations, [4]_ Section 5.1 Equations 8.31 and 8.32, derived from the Newton equations [4]_ Section 5 Equations 8.25 (compare to [4]_ Section 4 Equations 8.6-8.8). The advantage of solving the normal equations rather than 8.25 directly is that the matrices involved are symmetric positive definite, so Cholesky decomposition can be used rather than the more expensive LU factorization. With default options, the solver used to perform the factorization depends on third-party software availability and the conditioning of the problem. For dense problems, solvers are tried in the following order: 1. ``scipy.linalg.cho_factor`` 2. ``scipy.linalg.solve`` with option ``sym_pos=True`` 3. ``scipy.linalg.solve`` with option ``sym_pos=False`` 4. ``scipy.linalg.lstsq`` For sparse problems: 1. ``sksparse.cholmod.cholesky`` (if scikit-sparse and SuiteSparse are installed) 2. ``scipy.sparse.linalg.factorized`` (if scikit-umfpack and SuiteSparse are installed) 3. ``scipy.sparse.linalg.splu`` (which uses SuperLU distributed with SciPy) 4. ``scipy.sparse.linalg.lsqr`` If the solver fails for any reason, successively more robust (but slower) solvers are attempted in the order indicated. Attempting, failing, and re-starting factorization can be time consuming, so if the problem is numerically challenging, options can be set to bypass solvers that are failing. Setting ``cholesky=False`` skips to solver 2, ``sym_pos=False`` skips to solver 3, and ``lstsq=True`` skips to solver 4 for both sparse and dense problems. Potential improvements for combatting issues associated with dense columns in otherwise sparse problems are outlined in [4]_ Section 5.3 and [10]_ Section 4.1-4.2; the latter also discusses the alleviation of accuracy issues associated with the substitution approach to free variables. After calculating the search direction, the maximum possible step size that does not activate the non-negativity constraints is calculated, and the smaller of this step size and unity is applied (as in [4]_ Section 4.1.) [4]_ Section 4.3 suggests improvements for choosing the step size. The new point is tested according to the termination conditions of [4]_ Section 4.5. The same tolerance, which can be set using the ``tol`` option, is used for all checks. (A potential improvement would be to expose the different tolerances to be set independently.) If optimality, unboundedness, or infeasibility is detected, the solve procedure terminates; otherwise it repeats. Whereas the top level ``linprog`` module expects a problem of form: Minimize:: c @ x Subject to:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub where ``lb = 0`` and ``ub = None`` unless set in ``bounds``. The problem is automatically converted to the form: Minimize:: c @ x Subject to:: A @ x == b x >= 0 for solution. That is, the original problem contains equality, upper-bound and variable constraints whereas the method specific solver requires equality constraints and variable non-negativity. ``linprog`` converts the original problem to standard form by converting the simple bounds to upper bound constraints, introducing non-negative slack variables for inequality constraints, and expressing unbounded variables as the difference between two non-negative variables. The problem is converted back to the original form before results are reported. References ---------- .. [4] Andersen, Erling D., and Knud D. Andersen. "The MOSEK interior point optimizer for linear programming: an implementation of the homogeneous algorithm." High performance optimization. Springer US, 2000. 197-232. .. [6] Freund, Robert M. "Primal-Dual Interior-Point Methods for Linear Programming based on Newton's Method." Unpublished Course Notes, March 2004. Available 2/25/2017 at https://ocw.mit.edu/courses/sloan-school-of-management/15-084j-nonlinear-programming-spring-2004/lecture-notes/lec14_int_pt_mthd.pdf .. [8] Andersen, Erling D., and Knud D. Andersen. "Presolving in linear programming." Mathematical Programming 71.2 (1995): 221-245. .. [9] Bertsimas, Dimitris, and J. Tsitsiklis. "Introduction to linear programming." Athena Scientific 1 (1997): 997. .. [10] Andersen, Erling D., et al. Implementation of interior point methods for large scale linear programming. HEC/Universite de Geneve, 1996. """ pass def _linprog_rs_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='interior-point', callback=None, x0=None, maxiter=5000, disp=False, presolve=True, tol=1e-12, autoscale=False, rr=True, maxupdate=10, mast=False, pivot="mrc", **unknown_options): r""" Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the revised simplex method. .. deprecated:: 1.9.0 `method='revised simplex'` will be removed in SciPy 1.11.0. It is replaced by `method='highs'` because the latter is faster and more robust. Linear programming solves problems of the following form: .. math:: \min_x \ & c^T x \\ \mbox{such that} \ & A_{ub} x \leq b_{ub},\\ & A_{eq} x = b_{eq},\\ & l \leq x \leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'revised simplex'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. callback : callable, optional Callback function to be executed once per iteration. x0 : 1-D array, optional Guess values of the decision variables, which will be refined by the optimization algorithm. This argument is currently used only by the 'revised simplex' method, and can only be used if `x0` represents a basic feasible solution. Options ------- maxiter : int (default: 5000) The maximum number of iterations to perform in either phase. disp : bool (default: False) Set to ``True`` if indicators of optimization status are to be printed to the console each iteration. presolve : bool (default: True) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. tol : float (default: 1e-12) The tolerance which determines when a solution is "close enough" to zero in Phase 1 to be considered a basic feasible solution or close enough to positive to serve as an optimal solution. autoscale : bool (default: False) Set to ``True`` to automatically perform equilibration. Consider using this option if the numerical values in the constraints are separated by several orders of magnitude. rr : bool (default: True) Set to ``False`` to disable automatic redundancy removal. maxupdate : int (default: 10) The maximum number of updates performed on the LU factorization. After this many updates is reached, the basis matrix is factorized from scratch. mast : bool (default: False) Minimize Amortized Solve Time. If enabled, the average time to solve a linear system using the basis factorization is measured. Typically, the average solve time will decrease with each successive solve after initial factorization, as factorization takes much more time than the solve operation (and updates). Eventually, however, the updated factorization becomes sufficiently complex that the average solve time begins to increase. When this is detected, the basis is refactorized from scratch. Enable this option to maximize speed at the risk of nondeterministic behavior. Ignored if ``maxupdate`` is 0. pivot : "mrc" or "bland" (default: "mrc") Pivot rule: Minimum Reduced Cost ("mrc") or Bland's rule ("bland"). Choose Bland's rule if iteration limit is reached and cycling is suspected. unknown_options : dict Optional arguments not used by this particular solver. If `unknown_options` is non-empty a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1-D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1-D array The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. con : 1-D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : Numerical difficulties encountered. ``5`` : Problem has no constraints; turn presolve on. ``6`` : Invalid guess provided. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed in all phases. Notes ----- Method *revised simplex* uses the revised simplex method as described in [9]_, except that a factorization [11]_ of the basis matrix, rather than its inverse, is efficiently maintained and used to solve the linear systems at each iteration of the algorithm. References ---------- .. [9] Bertsimas, Dimitris, and J. Tsitsiklis. "Introduction to linear programming." Athena Scientific 1 (1997): 997. .. [11] Bartels, Richard H. "A stabilization of the simplex method." Journal in Numerische Mathematik 16.5 (1971): 414-434. """ pass def _linprog_simplex_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='interior-point', callback=None, maxiter=5000, disp=False, presolve=True, tol=1e-12, autoscale=False, rr=True, bland=False, **unknown_options): r""" Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the tableau-based simplex method. .. deprecated:: 1.9.0 `method='simplex'` will be removed in SciPy 1.11.0. It is replaced by `method='highs'` because the latter is faster and more robust. Linear programming solves problems of the following form: .. math:: \min_x \ & c^T x \\ \mbox{such that} \ & A_{ub} x \leq b_{ub},\\ & A_{eq} x = b_{eq},\\ & l \leq x \leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'simplex'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), and :ref:`'revised simplex' <optimize.linprog-revised_simplex>` are also available. callback : callable, optional Callback function to be executed once per iteration. Options ------- maxiter : int (default: 5000) The maximum number of iterations to perform in either phase. disp : bool (default: False) Set to ``True`` if indicators of optimization status are to be printed to the console each iteration. presolve : bool (default: True) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. tol : float (default: 1e-12) The tolerance which determines when a solution is "close enough" to zero in Phase 1 to be considered a basic feasible solution or close enough to positive to serve as an optimal solution. autoscale : bool (default: False) Set to ``True`` to automatically perform equilibration. Consider using this option if the numerical values in the constraints are separated by several orders of magnitude. rr : bool (default: True) Set to ``False`` to disable automatic redundancy removal. bland : bool If True, use Bland's anti-cycling rule [3]_ to choose pivots to prevent cycling. If False, choose pivots which should lead to a converged solution more quickly. The latter method is subject to cycling (non-convergence) in rare instances. unknown_options : dict Optional arguments not used by this particular solver. If `unknown_options` is non-empty a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1-D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1-D array The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. con : 1-D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : Numerical difficulties encountered. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed in all phases. References ---------- .. [1] Dantzig, George B., Linear programming and extensions. Rand Corporation Research Study Princeton Univ. Press, Princeton, NJ, 1963 .. [2] Hillier, S.H. and Lieberman, G.J. (1995), "Introduction to Mathematical Programming", McGraw-Hill, Chapter 4. .. [3] Bland, Robert G. New finite pivoting rules for the simplex method. Mathematics of Operations Research (2), 1977: pp. 103-107. """ pass
""" Created on Sat Aug 22 19:49:17 2020 @author: matth """ def _linprog_highs_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='highs', callback=None, maxiter=None, disp=False, presolve=True, time_limit=None, dual_feasibility_tolerance=None, primal_feasibility_tolerance=None, ipm_optimality_tolerance=None, simplex_dual_edge_weight_strategy=None, **unknown_options): """ Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using one of the HiGHS solvers. Linear programming solves problems of the following form: .. math:: \\min_x \\ & c^T x \\\\ \\mbox{such that} \\ & A_{ub} x \\leq b_{ub},\\\\ & A_{eq} x = b_{eq},\\\\ & l \\leq x \\leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'highs', which chooses automatically between :ref:`'highs-ds' <optimize.linprog-highs-ds>` and :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. integrality : 1-D array, optional Indicates the type of integrality constraint on each decision variable. ``0`` : Continuous variable; no integrality constraint. ``1`` : Integer variable; decision variable must be an integer within `bounds`. ``2`` : Semi-continuous variable; decision variable must be within `bounds` or take value ``0``. ``3`` : Semi-integer variable; decision variable must be an integer within `bounds` or take value ``0``. By default, all variables are continuous. Options ------- maxiter : int The maximum number of iterations to perform in either phase. For :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, this does not include the number of crossover iterations. Default is the largest possible value for an ``int`` on the platform. disp : bool (default: ``False``) Set to ``True`` if indicators of optimization status are to be printed to the console during optimization. presolve : bool (default: ``True``) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. time_limit : float The maximum time in seconds allotted to solve the problem; default is the largest possible value for a ``double`` on the platform. dual_feasibility_tolerance : double (default: 1e-07) Dual feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. The minimum of this and ``primal_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. primal_feasibility_tolerance : double (default: 1e-07) Primal feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. The minimum of this and ``dual_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. ipm_optimality_tolerance : double (default: ``1e-08``) Optimality tolerance for :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. Minimum allowable value is 1e-12. simplex_dual_edge_weight_strategy : str (default: None) Strategy for simplex dual edge weights. The default, ``None``, automatically selects one of the following. ``'dantzig'`` uses Dantzig's original strategy of choosing the most negative reduced cost. ``'devex'`` uses the strategy described in [15]_. ``steepest`` uses the exact steepest edge strategy as described in [16]_. ``'steepest-devex'`` begins with the exact steepest edge strategy until the computation is too costly or inexact and then switches to the devex method. Curently, ``None`` always selects ``'steepest-devex'``, but this may change as new options become available. unknown_options : dict Optional arguments not used by this particular solver. If ``unknown_options`` is non-empty, a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1D array The (nominally positive) values of the slack, ``b_ub - A_ub @ x``. con : 1D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration or time limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : The HiGHS solver ran into a problem. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed. For the HiGHS simplex method, this includes iterations in all phases. For the HiGHS interior-point method, this does not include crossover iterations. crossover_nit : int The number of primal/dual pushes performed during the crossover routine for the HiGHS interior-point method. This is ``0`` for the HiGHS simplex method. ineqlin : OptimizeResult Solution and sensitivity information corresponding to the inequality constraints, `b_ub`. A dictionary consisting of the fields: residual : np.ndnarray The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. This quantity is also commonly referred to as "slack". marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the inequality constraints, `b_ub`. eqlin : OptimizeResult Solution and sensitivity information corresponding to the equality constraints, `b_eq`. A dictionary consisting of the fields: residual : np.ndarray The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the equality constraints, `b_eq`. lower, upper : OptimizeResult Solution and sensitivity information corresponding to the lower and upper bounds on decision variables, `bounds`. residual : np.ndarray The (nominally positive) values of the quantity ``x - lb`` (lower) or ``ub - x`` (upper). marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the lower and upper `bounds`. Notes ----- Method :ref:`'highs-ds' <optimize.linprog-highs-ds>` is a wrapper of the C++ high performance dual revised simplex implementation (HSOL) [13]_, [14]_. Method :ref:`'highs-ipm' <optimize.linprog-highs-ipm>` is a wrapper of a C++ implementation of an **i**\\ nterior-\\ **p**\\ oint **m**\\ ethod [13]_; it features a crossover routine, so it is as accurate as a simplex solver. Method :ref:`'highs' <optimize.linprog-highs>` chooses between the two automatically. For new code involving `linprog`, we recommend explicitly choosing one of these three method values instead of :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy). The result fields `ineqlin`, `eqlin`, `lower`, and `upper` all contain `marginals`, or partial derivatives of the objective function with respect to the right-hand side of each constraint. These partial derivatives are also referred to as "Lagrange multipliers", "dual values", and "shadow prices". The sign convention of `marginals` is opposite that of Lagrange multipliers produced by many nonlinear solvers. References ---------- .. [13] Huangfu, Q., Galabova, I., Feldmeier, M., and Hall, J. A. J. "HiGHS - high performance software for linear optimization." Accessed 4/16/2020 at https://www.maths.ed.ac.uk/hall/HiGHS/#guide .. [14] Huangfu, Q. and Hall, J. A. J. "Parallelizing the dual revised simplex method." Mathematical Programming Computation, 10 (1), 119-142, 2018. DOI: 10.1007/s12532-017-0130-5 .. [15] Harris, Paula MJ. "Pivot selection methods of the Devex LP code." Mathematical programming 5.1 (1973): 1-28. .. [16] Goldfarb, Donald, and John Ker Reid. "A practicable steepest-edge simplex algorithm." Mathematical Programming 12.1 (1977): 361-371. """ pass def _linprog_highs_ds_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='highs-ds', callback=None, maxiter=None, disp=False, presolve=True, time_limit=None, dual_feasibility_tolerance=None, primal_feasibility_tolerance=None, simplex_dual_edge_weight_strategy=None, **unknown_options): """ Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the HiGHS dual simplex solver. Linear programming solves problems of the following form: .. math:: \\min_x \\ & c^T x \\\\ \\mbox{such that} \\ & A_{ub} x \\leq b_{ub},\\\\ & A_{eq} x = b_{eq},\\\\ & l \\leq x \\leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'highs-ds'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. Options ------- maxiter : int The maximum number of iterations to perform in either phase. Default is the largest possible value for an ``int`` on the platform. disp : bool (default: ``False``) Set to ``True`` if indicators of optimization status are to be printed to the console during optimization. presolve : bool (default: ``True``) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. time_limit : float The maximum time in seconds allotted to solve the problem; default is the largest possible value for a ``double`` on the platform. dual_feasibility_tolerance : double (default: 1e-07) Dual feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. primal_feasibility_tolerance : double (default: 1e-07) Primal feasibility tolerance for :ref:`'highs-ds' <optimize.linprog-highs-ds>`. simplex_dual_edge_weight_strategy : str (default: None) Strategy for simplex dual edge weights. The default, ``None``, automatically selects one of the following. ``'dantzig'`` uses Dantzig's original strategy of choosing the most negative reduced cost. ``'devex'`` uses the strategy described in [15]_. ``steepest`` uses the exact steepest edge strategy as described in [16]_. ``'steepest-devex'`` begins with the exact steepest edge strategy until the computation is too costly or inexact and then switches to the devex method. Curently, ``None`` always selects ``'steepest-devex'``, but this may change as new options become available. unknown_options : dict Optional arguments not used by this particular solver. If ``unknown_options`` is non-empty, a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1D array The (nominally positive) values of the slack, ``b_ub - A_ub @ x``. con : 1D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration or time limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : The HiGHS solver ran into a problem. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed. This includes iterations in all phases. crossover_nit : int This is always ``0`` for the HiGHS simplex method. For the HiGHS interior-point method, this is the number of primal/dual pushes performed during the crossover routine. ineqlin : OptimizeResult Solution and sensitivity information corresponding to the inequality constraints, `b_ub`. A dictionary consisting of the fields: residual : np.ndnarray The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. This quantity is also commonly referred to as "slack". marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the inequality constraints, `b_ub`. eqlin : OptimizeResult Solution and sensitivity information corresponding to the equality constraints, `b_eq`. A dictionary consisting of the fields: residual : np.ndarray The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the equality constraints, `b_eq`. lower, upper : OptimizeResult Solution and sensitivity information corresponding to the lower and upper bounds on decision variables, `bounds`. residual : np.ndarray The (nominally positive) values of the quantity ``x - lb`` (lower) or ``ub - x`` (upper). marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the lower and upper `bounds`. Notes ----- Method :ref:`'highs-ds' <optimize.linprog-highs-ds>` is a wrapper of the C++ high performance dual revised simplex implementation (HSOL) [13]_, [14]_. Method :ref:`'highs-ipm' <optimize.linprog-highs-ipm>` is a wrapper of a C++ implementation of an **i**\\ nterior-\\ **p**\\ oint **m**\\ ethod [13]_; it features a crossover routine, so it is as accurate as a simplex solver. Method :ref:`'highs' <optimize.linprog-highs>` chooses between the two automatically. For new code involving `linprog`, we recommend explicitly choosing one of these three method values instead of :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy). The result fields `ineqlin`, `eqlin`, `lower`, and `upper` all contain `marginals`, or partial derivatives of the objective function with respect to the right-hand side of each constraint. These partial derivatives are also referred to as "Lagrange multipliers", "dual values", and "shadow prices". The sign convention of `marginals` is opposite that of Lagrange multipliers produced by many nonlinear solvers. References ---------- .. [13] Huangfu, Q., Galabova, I., Feldmeier, M., and Hall, J. A. J. "HiGHS - high performance software for linear optimization." Accessed 4/16/2020 at https://www.maths.ed.ac.uk/hall/HiGHS/#guide .. [14] Huangfu, Q. and Hall, J. A. J. "Parallelizing the dual revised simplex method." Mathematical Programming Computation, 10 (1), 119-142, 2018. DOI: 10.1007/s12532-017-0130-5 .. [15] Harris, Paula MJ. "Pivot selection methods of the Devex LP code." Mathematical programming 5.1 (1973): 1-28. .. [16] Goldfarb, Donald, and John Ker Reid. "A practicable steepest-edge simplex algorithm." Mathematical Programming 12.1 (1977): 361-371. """ pass def _linprog_highs_ipm_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='highs-ipm', callback=None, maxiter=None, disp=False, presolve=True, time_limit=None, dual_feasibility_tolerance=None, primal_feasibility_tolerance=None, ipm_optimality_tolerance=None, **unknown_options): """ Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the HiGHS interior point solver. Linear programming solves problems of the following form: .. math:: \\min_x \\ & c^T x \\\\ \\mbox{such that} \\ & A_{ub} x \\leq b_{ub},\\\\ & A_{eq} x = b_{eq},\\\\ & l \\leq x \\leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'highs-ipm'. :ref:`'highs-ipm' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. Options ------- maxiter : int The maximum number of iterations to perform in either phase. For :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, this does not include the number of crossover iterations. Default is the largest possible value for an ``int`` on the platform. disp : bool (default: ``False``) Set to ``True`` if indicators of optimization status are to be printed to the console during optimization. presolve : bool (default: ``True``) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. time_limit : float The maximum time in seconds allotted to solve the problem; default is the largest possible value for a ``double`` on the platform. dual_feasibility_tolerance : double (default: 1e-07) The minimum of this and ``primal_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. primal_feasibility_tolerance : double (default: 1e-07) The minimum of this and ``dual_feasibility_tolerance`` is used for the feasibility tolerance of :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. ipm_optimality_tolerance : double (default: ``1e-08``) Optimality tolerance for :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`. Minimum allowable value is 1e-12. unknown_options : dict Optional arguments not used by this particular solver. If ``unknown_options`` is non-empty, a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1D array The (nominally positive) values of the slack, ``b_ub - A_ub @ x``. con : 1D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration or time limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : The HiGHS solver ran into a problem. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed. For the HiGHS interior-point method, this does not include crossover iterations. crossover_nit : int The number of primal/dual pushes performed during the crossover routine for the HiGHS interior-point method. ineqlin : OptimizeResult Solution and sensitivity information corresponding to the inequality constraints, `b_ub`. A dictionary consisting of the fields: residual : np.ndnarray The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. This quantity is also commonly referred to as "slack". marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the inequality constraints, `b_ub`. eqlin : OptimizeResult Solution and sensitivity information corresponding to the equality constraints, `b_eq`. A dictionary consisting of the fields: residual : np.ndarray The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the right-hand side of the equality constraints, `b_eq`. lower, upper : OptimizeResult Solution and sensitivity information corresponding to the lower and upper bounds on decision variables, `bounds`. residual : np.ndarray The (nominally positive) values of the quantity ``x - lb`` (lower) or ``ub - x`` (upper). marginals : np.ndarray The sensitivity (partial derivative) of the objective function with respect to the lower and upper `bounds`. Notes ----- Method :ref:`'highs-ipm' <optimize.linprog-highs-ipm>` is a wrapper of a C++ implementation of an **i**\\ nterior-\\ **p**\\ oint **m**\\ ethod [13]_; it features a crossover routine, so it is as accurate as a simplex solver. Method :ref:`'highs-ds' <optimize.linprog-highs-ds>` is a wrapper of the C++ high performance dual revised simplex implementation (HSOL) [13]_, [14]_. Method :ref:`'highs' <optimize.linprog-highs>` chooses between the two automatically. For new code involving `linprog`, we recommend explicitly choosing one of these three method values instead of :ref:`'interior-point' <optimize.linprog-interior-point>` (default), :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy). The result fields `ineqlin`, `eqlin`, `lower`, and `upper` all contain `marginals`, or partial derivatives of the objective function with respect to the right-hand side of each constraint. These partial derivatives are also referred to as "Lagrange multipliers", "dual values", and "shadow prices". The sign convention of `marginals` is opposite that of Lagrange multipliers produced by many nonlinear solvers. References ---------- .. [13] Huangfu, Q., Galabova, I., Feldmeier, M., and Hall, J. A. J. "HiGHS - high performance software for linear optimization." Accessed 4/16/2020 at https://www.maths.ed.ac.uk/hall/HiGHS/#guide .. [14] Huangfu, Q. and Hall, J. A. J. "Parallelizing the dual revised simplex method." Mathematical Programming Computation, 10 (1), 119-142, 2018. DOI: 10.1007/s12532-017-0130-5 """ pass def _linprog_ip_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='interior-point', callback=None, maxiter=1000, disp=False, presolve=True, tol=1e-08, autoscale=False, rr=True, alpha0=0.99995, beta=0.1, sparse=False, lstsq=False, sym_pos=True, cholesky=True, pc=True, ip=False, permc_spec='MMD_AT_PLUS_A', **unknown_options): """ Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the interior-point method of [4]_. .. deprecated:: 1.9.0 `method='interior-point'` will be removed in SciPy 1.11.0. It is replaced by `method='highs'` because the latter is faster and more robust. Linear programming solves problems of the following form: .. math:: \\min_x \\ & c^T x \\\\ \\mbox{such that} \\ & A_{ub} x \\leq b_{ub},\\\\ & A_{eq} x = b_{eq},\\\\ & l \\leq x \\leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'interior-point'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'revised simplex' <optimize.linprog-revised_simplex>`, and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. callback : callable, optional Callback function to be executed once per iteration. Options ------- maxiter : int (default: 1000) The maximum number of iterations of the algorithm. disp : bool (default: False) Set to ``True`` if indicators of optimization status are to be printed to the console each iteration. presolve : bool (default: True) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. tol : float (default: 1e-8) Termination tolerance to be used for all termination criteria; see [4]_ Section 4.5. autoscale : bool (default: False) Set to ``True`` to automatically perform equilibration. Consider using this option if the numerical values in the constraints are separated by several orders of magnitude. rr : bool (default: True) Set to ``False`` to disable automatic redundancy removal. alpha0 : float (default: 0.99995) The maximal step size for Mehrota's predictor-corrector search direction; see :math:`\\beta_{3}` of [4]_ Table 8.1. beta : float (default: 0.1) The desired reduction of the path parameter :math:`\\mu` (see [6]_) when Mehrota's predictor-corrector is not in use (uncommon). sparse : bool (default: False) Set to ``True`` if the problem is to be treated as sparse after presolve. If either ``A_eq`` or ``A_ub`` is a sparse matrix, this option will automatically be set ``True``, and the problem will be treated as sparse even during presolve. If your constraint matrices contain mostly zeros and the problem is not very small (less than about 100 constraints or variables), consider setting ``True`` or providing ``A_eq`` and ``A_ub`` as sparse matrices. lstsq : bool (default: ``False``) Set to ``True`` if the problem is expected to be very poorly conditioned. This should always be left ``False`` unless severe numerical difficulties are encountered. Leave this at the default unless you receive a warning message suggesting otherwise. sym_pos : bool (default: True) Leave ``True`` if the problem is expected to yield a well conditioned symmetric positive definite normal equation matrix (almost always). Leave this at the default unless you receive a warning message suggesting otherwise. cholesky : bool (default: True) Set to ``True`` if the normal equations are to be solved by explicit Cholesky decomposition followed by explicit forward/backward substitution. This is typically faster for problems that are numerically well-behaved. pc : bool (default: True) Leave ``True`` if the predictor-corrector method of Mehrota is to be used. This is almost always (if not always) beneficial. ip : bool (default: False) Set to ``True`` if the improved initial point suggestion due to [4]_ Section 4.3 is desired. Whether this is beneficial or not depends on the problem. permc_spec : str (default: 'MMD_AT_PLUS_A') (Has effect only with ``sparse = True``, ``lstsq = False``, ``sym_pos = True``, and no SuiteSparse.) A matrix is factorized in each iteration of the algorithm. This option specifies how to permute the columns of the matrix for sparsity preservation. Acceptable values are: - ``NATURAL``: natural ordering. - ``MMD_ATA``: minimum degree ordering on the structure of A^T A. - ``MMD_AT_PLUS_A``: minimum degree ordering on the structure of A^T+A. - ``COLAMD``: approximate minimum degree column ordering. This option can impact the convergence of the interior point algorithm; test different values to determine which performs best for your problem. For more information, refer to ``scipy.sparse.linalg.splu``. unknown_options : dict Optional arguments not used by this particular solver. If `unknown_options` is non-empty a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1-D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1-D array The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. con : 1-D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : Numerical difficulties encountered. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed in all phases. Notes ----- This method implements the algorithm outlined in [4]_ with ideas from [8]_ and a structure inspired by the simpler methods of [6]_. The primal-dual path following method begins with initial 'guesses' of the primal and dual variables of the standard form problem and iteratively attempts to solve the (nonlinear) Karush-Kuhn-Tucker conditions for the problem with a gradually reduced logarithmic barrier term added to the objective. This particular implementation uses a homogeneous self-dual formulation, which provides certificates of infeasibility or unboundedness where applicable. The default initial point for the primal and dual variables is that defined in [4]_ Section 4.4 Equation 8.22. Optionally (by setting initial point option ``ip=True``), an alternate (potentially improved) starting point can be calculated according to the additional recommendations of [4]_ Section 4.4. A search direction is calculated using the predictor-corrector method (single correction) proposed by Mehrota and detailed in [4]_ Section 4.1. (A potential improvement would be to implement the method of multiple corrections described in [4]_ Section 4.2.) In practice, this is accomplished by solving the normal equations, [4]_ Section 5.1 Equations 8.31 and 8.32, derived from the Newton equations [4]_ Section 5 Equations 8.25 (compare to [4]_ Section 4 Equations 8.6-8.8). The advantage of solving the normal equations rather than 8.25 directly is that the matrices involved are symmetric positive definite, so Cholesky decomposition can be used rather than the more expensive LU factorization. With default options, the solver used to perform the factorization depends on third-party software availability and the conditioning of the problem. For dense problems, solvers are tried in the following order: 1. ``scipy.linalg.cho_factor`` 2. ``scipy.linalg.solve`` with option ``sym_pos=True`` 3. ``scipy.linalg.solve`` with option ``sym_pos=False`` 4. ``scipy.linalg.lstsq`` For sparse problems: 1. ``sksparse.cholmod.cholesky`` (if scikit-sparse and SuiteSparse are installed) 2. ``scipy.sparse.linalg.factorized`` (if scikit-umfpack and SuiteSparse are installed) 3. ``scipy.sparse.linalg.splu`` (which uses SuperLU distributed with SciPy) 4. ``scipy.sparse.linalg.lsqr`` If the solver fails for any reason, successively more robust (but slower) solvers are attempted in the order indicated. Attempting, failing, and re-starting factorization can be time consuming, so if the problem is numerically challenging, options can be set to bypass solvers that are failing. Setting ``cholesky=False`` skips to solver 2, ``sym_pos=False`` skips to solver 3, and ``lstsq=True`` skips to solver 4 for both sparse and dense problems. Potential improvements for combatting issues associated with dense columns in otherwise sparse problems are outlined in [4]_ Section 5.3 and [10]_ Section 4.1-4.2; the latter also discusses the alleviation of accuracy issues associated with the substitution approach to free variables. After calculating the search direction, the maximum possible step size that does not activate the non-negativity constraints is calculated, and the smaller of this step size and unity is applied (as in [4]_ Section 4.1.) [4]_ Section 4.3 suggests improvements for choosing the step size. The new point is tested according to the termination conditions of [4]_ Section 4.5. The same tolerance, which can be set using the ``tol`` option, is used for all checks. (A potential improvement would be to expose the different tolerances to be set independently.) If optimality, unboundedness, or infeasibility is detected, the solve procedure terminates; otherwise it repeats. Whereas the top level ``linprog`` module expects a problem of form: Minimize:: c @ x Subject to:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub where ``lb = 0`` and ``ub = None`` unless set in ``bounds``. The problem is automatically converted to the form: Minimize:: c @ x Subject to:: A @ x == b x >= 0 for solution. That is, the original problem contains equality, upper-bound and variable constraints whereas the method specific solver requires equality constraints and variable non-negativity. ``linprog`` converts the original problem to standard form by converting the simple bounds to upper bound constraints, introducing non-negative slack variables for inequality constraints, and expressing unbounded variables as the difference between two non-negative variables. The problem is converted back to the original form before results are reported. References ---------- .. [4] Andersen, Erling D., and Knud D. Andersen. "The MOSEK interior point optimizer for linear programming: an implementation of the homogeneous algorithm." High performance optimization. Springer US, 2000. 197-232. .. [6] Freund, Robert M. "Primal-Dual Interior-Point Methods for Linear Programming based on Newton's Method." Unpublished Course Notes, March 2004. Available 2/25/2017 at https://ocw.mit.edu/courses/sloan-school-of-management/15-084j-nonlinear-programming-spring-2004/lecture-notes/lec14_int_pt_mthd.pdf .. [8] Andersen, Erling D., and Knud D. Andersen. "Presolving in linear programming." Mathematical Programming 71.2 (1995): 221-245. .. [9] Bertsimas, Dimitris, and J. Tsitsiklis. "Introduction to linear programming." Athena Scientific 1 (1997): 997. .. [10] Andersen, Erling D., et al. Implementation of interior point methods for large scale linear programming. HEC/Universite de Geneve, 1996. """ pass def _linprog_rs_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='interior-point', callback=None, x0=None, maxiter=5000, disp=False, presolve=True, tol=1e-12, autoscale=False, rr=True, maxupdate=10, mast=False, pivot='mrc', **unknown_options): """ Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the revised simplex method. .. deprecated:: 1.9.0 `method='revised simplex'` will be removed in SciPy 1.11.0. It is replaced by `method='highs'` because the latter is faster and more robust. Linear programming solves problems of the following form: .. math:: \\min_x \\ & c^T x \\\\ \\mbox{such that} \\ & A_{ub} x \\leq b_{ub},\\\\ & A_{eq} x = b_{eq},\\\\ & l \\leq x \\leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'revised simplex'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), and :ref:`'simplex' <optimize.linprog-simplex>` (legacy) are also available. callback : callable, optional Callback function to be executed once per iteration. x0 : 1-D array, optional Guess values of the decision variables, which will be refined by the optimization algorithm. This argument is currently used only by the 'revised simplex' method, and can only be used if `x0` represents a basic feasible solution. Options ------- maxiter : int (default: 5000) The maximum number of iterations to perform in either phase. disp : bool (default: False) Set to ``True`` if indicators of optimization status are to be printed to the console each iteration. presolve : bool (default: True) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. tol : float (default: 1e-12) The tolerance which determines when a solution is "close enough" to zero in Phase 1 to be considered a basic feasible solution or close enough to positive to serve as an optimal solution. autoscale : bool (default: False) Set to ``True`` to automatically perform equilibration. Consider using this option if the numerical values in the constraints are separated by several orders of magnitude. rr : bool (default: True) Set to ``False`` to disable automatic redundancy removal. maxupdate : int (default: 10) The maximum number of updates performed on the LU factorization. After this many updates is reached, the basis matrix is factorized from scratch. mast : bool (default: False) Minimize Amortized Solve Time. If enabled, the average time to solve a linear system using the basis factorization is measured. Typically, the average solve time will decrease with each successive solve after initial factorization, as factorization takes much more time than the solve operation (and updates). Eventually, however, the updated factorization becomes sufficiently complex that the average solve time begins to increase. When this is detected, the basis is refactorized from scratch. Enable this option to maximize speed at the risk of nondeterministic behavior. Ignored if ``maxupdate`` is 0. pivot : "mrc" or "bland" (default: "mrc") Pivot rule: Minimum Reduced Cost ("mrc") or Bland's rule ("bland"). Choose Bland's rule if iteration limit is reached and cycling is suspected. unknown_options : dict Optional arguments not used by this particular solver. If `unknown_options` is non-empty a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1-D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1-D array The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. con : 1-D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : Numerical difficulties encountered. ``5`` : Problem has no constraints; turn presolve on. ``6`` : Invalid guess provided. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed in all phases. Notes ----- Method *revised simplex* uses the revised simplex method as described in [9]_, except that a factorization [11]_ of the basis matrix, rather than its inverse, is efficiently maintained and used to solve the linear systems at each iteration of the algorithm. References ---------- .. [9] Bertsimas, Dimitris, and J. Tsitsiklis. "Introduction to linear programming." Athena Scientific 1 (1997): 997. .. [11] Bartels, Richard H. "A stabilization of the simplex method." Journal in Numerische Mathematik 16.5 (1971): 414-434. """ pass def _linprog_simplex_doc(c, A_ub=None, b_ub=None, A_eq=None, b_eq=None, bounds=None, method='interior-point', callback=None, maxiter=5000, disp=False, presolve=True, tol=1e-12, autoscale=False, rr=True, bland=False, **unknown_options): """ Linear programming: minimize a linear objective function subject to linear equality and inequality constraints using the tableau-based simplex method. .. deprecated:: 1.9.0 `method='simplex'` will be removed in SciPy 1.11.0. It is replaced by `method='highs'` because the latter is faster and more robust. Linear programming solves problems of the following form: .. math:: \\min_x \\ & c^T x \\\\ \\mbox{such that} \\ & A_{ub} x \\leq b_{ub},\\\\ & A_{eq} x = b_{eq},\\\\ & l \\leq x \\leq u , where :math:`x` is a vector of decision variables; :math:`c`, :math:`b_{ub}`, :math:`b_{eq}`, :math:`l`, and :math:`u` are vectors; and :math:`A_{ub}` and :math:`A_{eq}` are matrices. Alternatively, that's: minimize:: c @ x such that:: A_ub @ x <= b_ub A_eq @ x == b_eq lb <= x <= ub Note that by default ``lb = 0`` and ``ub = None`` unless specified with ``bounds``. Parameters ---------- c : 1-D array The coefficients of the linear objective function to be minimized. A_ub : 2-D array, optional The inequality constraint matrix. Each row of ``A_ub`` specifies the coefficients of a linear inequality constraint on ``x``. b_ub : 1-D array, optional The inequality constraint vector. Each element represents an upper bound on the corresponding value of ``A_ub @ x``. A_eq : 2-D array, optional The equality constraint matrix. Each row of ``A_eq`` specifies the coefficients of a linear equality constraint on ``x``. b_eq : 1-D array, optional The equality constraint vector. Each element of ``A_eq @ x`` must equal the corresponding element of ``b_eq``. bounds : sequence, optional A sequence of ``(min, max)`` pairs for each element in ``x``, defining the minimum and maximum values of that decision variable. Use ``None`` to indicate that there is no bound. By default, bounds are ``(0, None)`` (all decision variables are non-negative). If a single tuple ``(min, max)`` is provided, then ``min`` and ``max`` will serve as bounds for all decision variables. method : str This is the method-specific documentation for 'simplex'. :ref:`'highs' <optimize.linprog-highs>`, :ref:`'highs-ds' <optimize.linprog-highs-ds>`, :ref:`'highs-ipm' <optimize.linprog-highs-ipm>`, :ref:`'interior-point' <optimize.linprog-interior-point>` (default), and :ref:`'revised simplex' <optimize.linprog-revised_simplex>` are also available. callback : callable, optional Callback function to be executed once per iteration. Options ------- maxiter : int (default: 5000) The maximum number of iterations to perform in either phase. disp : bool (default: False) Set to ``True`` if indicators of optimization status are to be printed to the console each iteration. presolve : bool (default: True) Presolve attempts to identify trivial infeasibilities, identify trivial unboundedness, and simplify the problem before sending it to the main solver. It is generally recommended to keep the default setting ``True``; set to ``False`` if presolve is to be disabled. tol : float (default: 1e-12) The tolerance which determines when a solution is "close enough" to zero in Phase 1 to be considered a basic feasible solution or close enough to positive to serve as an optimal solution. autoscale : bool (default: False) Set to ``True`` to automatically perform equilibration. Consider using this option if the numerical values in the constraints are separated by several orders of magnitude. rr : bool (default: True) Set to ``False`` to disable automatic redundancy removal. bland : bool If True, use Bland's anti-cycling rule [3]_ to choose pivots to prevent cycling. If False, choose pivots which should lead to a converged solution more quickly. The latter method is subject to cycling (non-convergence) in rare instances. unknown_options : dict Optional arguments not used by this particular solver. If `unknown_options` is non-empty a warning is issued listing all unused options. Returns ------- res : OptimizeResult A :class:`scipy.optimize.OptimizeResult` consisting of the fields: x : 1-D array The values of the decision variables that minimizes the objective function while satisfying the constraints. fun : float The optimal value of the objective function ``c @ x``. slack : 1-D array The (nominally positive) values of the slack variables, ``b_ub - A_ub @ x``. con : 1-D array The (nominally zero) residuals of the equality constraints, ``b_eq - A_eq @ x``. success : bool ``True`` when the algorithm succeeds in finding an optimal solution. status : int An integer representing the exit status of the algorithm. ``0`` : Optimization terminated successfully. ``1`` : Iteration limit reached. ``2`` : Problem appears to be infeasible. ``3`` : Problem appears to be unbounded. ``4`` : Numerical difficulties encountered. message : str A string descriptor of the exit status of the algorithm. nit : int The total number of iterations performed in all phases. References ---------- .. [1] Dantzig, George B., Linear programming and extensions. Rand Corporation Research Study Princeton Univ. Press, Princeton, NJ, 1963 .. [2] Hillier, S.H. and Lieberman, G.J. (1995), "Introduction to Mathematical Programming", McGraw-Hill, Chapter 4. .. [3] Bland, Robert G. New finite pivoting rules for the simplex method. Mathematics of Operations Research (2), 1977: pp. 103-107. """ pass
"""Devstack environment variables unique to the instructor plugin.""" def plugin_settings(settings): """Settings for the instructor plugin.""" # Set this to the dashboard URL in order to display the link from the # dashboard to the Analytics Dashboard. settings.ANALYTICS_DASHBOARD_URL = None
"""Devstack environment variables unique to the instructor plugin.""" def plugin_settings(settings): """Settings for the instructor plugin.""" settings.ANALYTICS_DASHBOARD_URL = None
__version__ = '0.54' class LandDegradationError(Exception): """Base class for exceptions in this module.""" def __init__(self, msg=None): if msg is None: msg = "An error occurred in the landdegradation module" super(LandDegradationError, self).__init__(msg) class GEEError(LandDegradationError): """Error related to GEE""" def __init__(self, msg="Error with GEE JSON IO"): super(LandDegradationError, self).__init__(msg) class GEEIOError(GEEError): """Error related to GEE""" def __init__(self, msg="Error with GEE JSON IO"): super(GEEError, self).__init__(msg) class GEEImageError(GEEError): """Error related to GEE""" def __init__(self, msg="Error with GEE image handling"): super(GEEError, self).__init__(msg) class GEETaskFailure(GEEError): """Error running task on GEE""" def __init__(self, task): # super(GEEError, self).__init__("Task {} failed".format(task.status().get('id'))) super(GEEError, self).__init__("Task {} failed".format(task)) print(task) self.task = task
__version__ = '0.54' class Landdegradationerror(Exception): """Base class for exceptions in this module.""" def __init__(self, msg=None): if msg is None: msg = 'An error occurred in the landdegradation module' super(LandDegradationError, self).__init__(msg) class Geeerror(LandDegradationError): """Error related to GEE""" def __init__(self, msg='Error with GEE JSON IO'): super(LandDegradationError, self).__init__(msg) class Geeioerror(GEEError): """Error related to GEE""" def __init__(self, msg='Error with GEE JSON IO'): super(GEEError, self).__init__(msg) class Geeimageerror(GEEError): """Error related to GEE""" def __init__(self, msg='Error with GEE image handling'): super(GEEError, self).__init__(msg) class Geetaskfailure(GEEError): """Error running task on GEE""" def __init__(self, task): super(GEEError, self).__init__('Task {} failed'.format(task)) print(task) self.task = task
del_items(0x80145350) SetType(0x80145350, "void _cd_seek(int sec)") del_items(0x801453BC) SetType(0x801453BC, "void init_cdstream(int chunksize, unsigned char *buf, int bufsize)") del_items(0x801453E4) SetType(0x801453E4, "void flush_cdstream()") del_items(0x80145438) SetType(0x80145438, "void reset_cdstream()") del_items(0x80145468) SetType(0x80145468, "void kill_stream_handlers()") del_items(0x80145498) SetType(0x80145498, "void stream_cdready_handler(unsigned char status, unsigned char *result, int idx, int i, int sec, struct CdlLOC subcode[3])") del_items(0x80145684) SetType(0x80145684, "void install_stream_handlers()") del_items(0x801456C0) SetType(0x801456C0, "void cdstream_service()") del_items(0x801457B0) SetType(0x801457B0, "int cdstream_get_chunk(unsigned char **data, struct strheader **h)") del_items(0x801458C8) SetType(0x801458C8, "int cdstream_is_last_chunk()") del_items(0x801458E0) SetType(0x801458E0, "void cdstream_discard_chunk()") del_items(0x80145A00) SetType(0x80145A00, "void close_cdstream()") del_items(0x80145A40) SetType(0x80145A40, "void wait_cdstream()") del_items(0x80145AF8) SetType(0x80145AF8, "int open_cdstream(char *fname, int secoffs, int seclen)") del_items(0x80145BFC) SetType(0x80145BFC, "int set_mdec_img_buffer(unsigned char *p)") del_items(0x80145C30) SetType(0x80145C30, "void start_mdec_decode(unsigned char *data, int x, int y, int w, int h)") del_items(0x80145DB4) SetType(0x80145DB4, "void DCT_out_handler()") del_items(0x80145E50) SetType(0x80145E50, "void init_mdec(unsigned char *vlc_buffer, unsigned char *vlc_table)") del_items(0x80145EC0) SetType(0x80145EC0, "void init_mdec_buffer(char *buf, int size)") del_items(0x80145EDC) SetType(0x80145EDC, "int split_poly_area(struct POLY_FT4 *p, struct POLY_FT4 *bp, int offs, struct RECT *r, int sx, int sy, int correct)") del_items(0x801462CC) SetType(0x801462CC, "void rebuild_mdec_polys(int x, int y)") del_items(0x801464A0) SetType(0x801464A0, "void clear_mdec_frame()") del_items(0x801464AC) SetType(0x801464AC, "void draw_mdec_polys()") del_items(0x801467F8) SetType(0x801467F8, "void invalidate_mdec_frame()") del_items(0x8014680C) SetType(0x8014680C, "int is_frame_decoded()") del_items(0x80146818) SetType(0x80146818, "void init_mdec_polys(int x, int y, int w, int h, int bx1, int by1, int bx2, int by2, int correct)") del_items(0x80146BA8) SetType(0x80146BA8, "void set_mdec_poly_bright(int br)") del_items(0x80146C10) SetType(0x80146C10, "int init_mdec_stream(unsigned char *buftop, int sectors_per_frame, int mdec_frames_per_buffer)") del_items(0x80146C60) SetType(0x80146C60, "void init_mdec_audio(int rate)") del_items(0x80146D68) SetType(0x80146D68, "void kill_mdec_audio()") del_items(0x80146D98) SetType(0x80146D98, "void stop_mdec_audio()") del_items(0x80146DBC) SetType(0x80146DBC, "void play_mdec_audio(unsigned char *data, struct asec *h)") del_items(0x80147054) SetType(0x80147054, "void set_mdec_audio_volume(short vol, struct SpuVoiceAttr voice_attr)") del_items(0x80147120) SetType(0x80147120, "void resync_audio()") del_items(0x80147150) SetType(0x80147150, "void stop_mdec_stream()") del_items(0x801471A4) SetType(0x801471A4, "void dequeue_stream()") del_items(0x80147290) SetType(0x80147290, "void dequeue_animation()") del_items(0x80147440) SetType(0x80147440, "void decode_mdec_stream(int frames_elapsed)") del_items(0x80147620) SetType(0x80147620, "void play_mdec_stream(char *filename, int speed, int start, int end)") del_items(0x801476D4) SetType(0x801476D4, "void clear_mdec_queue()") del_items(0x80147700) SetType(0x80147700, "void StrClearVRAM()") del_items(0x801477C0) SetType(0x801477C0, "short PlayFMVOverLay(char *filename, int w, int h)") del_items(0x80147C84) SetType(0x80147C84, "unsigned short GetDown__C4CPad(struct CPad *this)")
del_items(2148815696) set_type(2148815696, 'void _cd_seek(int sec)') del_items(2148815804) set_type(2148815804, 'void init_cdstream(int chunksize, unsigned char *buf, int bufsize)') del_items(2148815844) set_type(2148815844, 'void flush_cdstream()') del_items(2148815928) set_type(2148815928, 'void reset_cdstream()') del_items(2148815976) set_type(2148815976, 'void kill_stream_handlers()') del_items(2148816024) set_type(2148816024, 'void stream_cdready_handler(unsigned char status, unsigned char *result, int idx, int i, int sec, struct CdlLOC subcode[3])') del_items(2148816516) set_type(2148816516, 'void install_stream_handlers()') del_items(2148816576) set_type(2148816576, 'void cdstream_service()') del_items(2148816816) set_type(2148816816, 'int cdstream_get_chunk(unsigned char **data, struct strheader **h)') del_items(2148817096) set_type(2148817096, 'int cdstream_is_last_chunk()') del_items(2148817120) set_type(2148817120, 'void cdstream_discard_chunk()') del_items(2148817408) set_type(2148817408, 'void close_cdstream()') del_items(2148817472) set_type(2148817472, 'void wait_cdstream()') del_items(2148817656) set_type(2148817656, 'int open_cdstream(char *fname, int secoffs, int seclen)') del_items(2148817916) set_type(2148817916, 'int set_mdec_img_buffer(unsigned char *p)') del_items(2148817968) set_type(2148817968, 'void start_mdec_decode(unsigned char *data, int x, int y, int w, int h)') del_items(2148818356) set_type(2148818356, 'void DCT_out_handler()') del_items(2148818512) set_type(2148818512, 'void init_mdec(unsigned char *vlc_buffer, unsigned char *vlc_table)') del_items(2148818624) set_type(2148818624, 'void init_mdec_buffer(char *buf, int size)') del_items(2148818652) set_type(2148818652, 'int split_poly_area(struct POLY_FT4 *p, struct POLY_FT4 *bp, int offs, struct RECT *r, int sx, int sy, int correct)') del_items(2148819660) set_type(2148819660, 'void rebuild_mdec_polys(int x, int y)') del_items(2148820128) set_type(2148820128, 'void clear_mdec_frame()') del_items(2148820140) set_type(2148820140, 'void draw_mdec_polys()') del_items(2148820984) set_type(2148820984, 'void invalidate_mdec_frame()') del_items(2148821004) set_type(2148821004, 'int is_frame_decoded()') del_items(2148821016) set_type(2148821016, 'void init_mdec_polys(int x, int y, int w, int h, int bx1, int by1, int bx2, int by2, int correct)') del_items(2148821928) set_type(2148821928, 'void set_mdec_poly_bright(int br)') del_items(2148822032) set_type(2148822032, 'int init_mdec_stream(unsigned char *buftop, int sectors_per_frame, int mdec_frames_per_buffer)') del_items(2148822112) set_type(2148822112, 'void init_mdec_audio(int rate)') del_items(2148822376) set_type(2148822376, 'void kill_mdec_audio()') del_items(2148822424) set_type(2148822424, 'void stop_mdec_audio()') del_items(2148822460) set_type(2148822460, 'void play_mdec_audio(unsigned char *data, struct asec *h)') del_items(2148823124) set_type(2148823124, 'void set_mdec_audio_volume(short vol, struct SpuVoiceAttr voice_attr)') del_items(2148823328) set_type(2148823328, 'void resync_audio()') del_items(2148823376) set_type(2148823376, 'void stop_mdec_stream()') del_items(2148823460) set_type(2148823460, 'void dequeue_stream()') del_items(2148823696) set_type(2148823696, 'void dequeue_animation()') del_items(2148824128) set_type(2148824128, 'void decode_mdec_stream(int frames_elapsed)') del_items(2148824608) set_type(2148824608, 'void play_mdec_stream(char *filename, int speed, int start, int end)') del_items(2148824788) set_type(2148824788, 'void clear_mdec_queue()') del_items(2148824832) set_type(2148824832, 'void StrClearVRAM()') del_items(2148825024) set_type(2148825024, 'short PlayFMVOverLay(char *filename, int w, int h)') del_items(2148826244) set_type(2148826244, 'unsigned short GetDown__C4CPad(struct CPad *this)')
# Sets an error rate of %0.025 (1 in 4,000) with a capacity of 5MM items. # See https://hur.st/bloomfilter/?n=5000000&p=0.00025&m=& for more information # 5MM was chosen for being a whole number roughly 2x the size of our most dense sparse plugin output in late July 2020. DEFAULT_ERROR_RATE = 0.00025 DEFAULT_CAPACITY = 5000000 KEY_PREFIX = "fwan_dataset_bf:" # The bloom filters are only useful for per-file-hash Firmware Analysis plugins with sparse output, as those are the # scenarios where we are likely to avoid unnecessary object storage fetches. exclusions = [ "augeas", # firmware-file-level "file_hashes", # too dense "file_tree", # firmware-level "file_type", # too dense "unpack_report", # irrelevant "unpack_failed", # irrelevant "printable_strings", # too dense ] exclusion_prefixes = [ "firmware_cpes", # firmware-level "sbom", # sbom/unified is firmware-level, sbom/apt_file is irrelevant "similarity_hash", # irrelevant ]
default_error_rate = 0.00025 default_capacity = 5000000 key_prefix = 'fwan_dataset_bf:' exclusions = ['augeas', 'file_hashes', 'file_tree', 'file_type', 'unpack_report', 'unpack_failed', 'printable_strings'] exclusion_prefixes = ['firmware_cpes', 'sbom', 'similarity_hash']
fp = open("./packet.csv", "r") vals = fp.readlines() count = 1 pre_val = 0 current = 0 sampling_rate = 31 val_bins = [] for i in range(len(vals)): pre_val = current current = int(vals[i]) if current == pre_val: count = count + 1 else: count = 1 if count == sampling_rate: val_bins.append(pre_val) count = 1 pre_val = 0 current = 0 next_bins = [] for i in range(len(val_bins) // 2): b0 = val_bins[i * 2] b1 = val_bins[i * 2 + 1] if b0 == 1 and b1 == 0: next_bins.append(1) elif b0 == 0 and b1 == 1: next_bins.append(0) val_bins = next_bins[3:] c = 0 for i in range(len(val_bins)): val = int(val_bins[i]) c = (c << 1) | val if i % 8 == 7: print(chr(c), end="") c = 0 print("")
fp = open('./packet.csv', 'r') vals = fp.readlines() count = 1 pre_val = 0 current = 0 sampling_rate = 31 val_bins = [] for i in range(len(vals)): pre_val = current current = int(vals[i]) if current == pre_val: count = count + 1 else: count = 1 if count == sampling_rate: val_bins.append(pre_val) count = 1 pre_val = 0 current = 0 next_bins = [] for i in range(len(val_bins) // 2): b0 = val_bins[i * 2] b1 = val_bins[i * 2 + 1] if b0 == 1 and b1 == 0: next_bins.append(1) elif b0 == 0 and b1 == 1: next_bins.append(0) val_bins = next_bins[3:] c = 0 for i in range(len(val_bins)): val = int(val_bins[i]) c = c << 1 | val if i % 8 == 7: print(chr(c), end='') c = 0 print('')
''' Specifies the username and password required to log into the iNaturalist website. These variables are imported into the 'inaturalist_scraper.py' script ''' username = 'your_iNaturalist_username_here' password = 'your_iNaturalist_password_here'
""" Specifies the username and password required to log into the iNaturalist website. These variables are imported into the 'inaturalist_scraper.py' script """ username = 'your_iNaturalist_username_here' password = 'your_iNaturalist_password_here'
FRONT_LEFT_WHEEL_TOPIC = "/capo_front_left_wheel_controller/command" FRONT_RIGHT_WHEEL_TOPIC = "/capo_front_right_wheel_controller/command" # BACK_RIGHT_WHEEL_TOPIC = "/capo_rear_left_wheel_controller/command", # BACK_LEFT_WHEEL_TOPIC = "/capo_rear_right_wheel_controller/command" HEAD_JOINT_TOPIC = "/capo_head_rotation_controller/command" CAPO_JOINT_STATES = '/joint_states' TOPNAV_FEEDBACK_TOPIC = '/topnav/feedback' TOPNAV_GUIDELINES_TOPIC = 'topnav/guidelines' GAZEBO_MODEL_STATES_TOPIC = "/gazebo/model_states"
front_left_wheel_topic = '/capo_front_left_wheel_controller/command' front_right_wheel_topic = '/capo_front_right_wheel_controller/command' head_joint_topic = '/capo_head_rotation_controller/command' capo_joint_states = '/joint_states' topnav_feedback_topic = '/topnav/feedback' topnav_guidelines_topic = 'topnav/guidelines' gazebo_model_states_topic = '/gazebo/model_states'
class BasicEnvironment: """Object to pass containing data used for solve. Individuals are mapped to this data upon evaluation. Environments also hold additional evaluation data.""" def __init__(self, df, _dict=None): self.df = df self._dict = _dict
class Basicenvironment: """Object to pass containing data used for solve. Individuals are mapped to this data upon evaluation. Environments also hold additional evaluation data.""" def __init__(self, df, _dict=None): self.df = df self._dict = _dict
# -*- coding:utf-8 -*- pizzas = ['fruit', 'buff', 'milk', 'zhishi', 'little'] # for pizza in pizzas: # print(pizza) # print(pizza.title() + ", I like eat !") # print("I like eat pizza!") pizzas_bak = pizzas[:] pizzas.append('chicken') pizzas_bak.append('dog') print(pizzas_bak) print(pizzas)
pizzas = ['fruit', 'buff', 'milk', 'zhishi', 'little'] pizzas_bak = pizzas[:] pizzas.append('chicken') pizzas_bak.append('dog') print(pizzas_bak) print(pizzas)
class Solution: def reformatDate(self, date: str) -> str: pattern = re.compile(r'[0-9]+') dateList=date.split(' ') day=pattern.findall(dateList[0])[0] monthList=["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"] month=monthList.index(dateList[1])+1 year=dateList[2] return year+'-'+str(month).zfill(2)+'-'+str(day).zfill(2)
class Solution: def reformat_date(self, date: str) -> str: pattern = re.compile('[0-9]+') date_list = date.split(' ') day = pattern.findall(dateList[0])[0] month_list = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'] month = monthList.index(dateList[1]) + 1 year = dateList[2] return year + '-' + str(month).zfill(2) + '-' + str(day).zfill(2)
inp = open('input_d24.txt').read().strip().split('\n') graph = dict() n = 0 yn = len(inp) xn = len(inp[0]) poss = '01234567' def find_n(ton): for y in range(len(inp)): for x in range(len(inp[y])): if inp[y][x] == str(ton): return (x,y) def exists(n, found): for ele in list(graph[n]): if ele[0] == int(found): return True return False def find_adj(x,y): res = set() for (a,b) in [(x-1,y), (x+1,y), (x,y-1), (x,y+1)]: if a >= 0 and a < xn and b >= 0 and b < yn: if inp[b][a] != '#': res.add((a,b)) return res for n in range(8): x,y = find_n(n) if n not in graph: graph[n] = set() visited = set() queue = [((x,y), set([(x,y)]))] while queue: (vertex, path) = queue.pop(0) for nex in find_adj(*vertex) - path: if nex in visited: continue visited.add(nex) found = inp[nex[1]][nex[0]] if found in poss: if not exists(n,found): graph[n].add((int(found), len(path))) if int(found) not in graph: graph[int(found)] = set() graph[int(found)].add((n, len(path))) else: p = path.copy() p.add(nex) queue.append((nex, p)) print(graph) print('bruteforcing TSP (fun times)') smallest = 10000 queue = [(0, set([0]), 0)] while queue: (current, visited, count) = queue.pop(0) if count >= smallest: continue for pos in graph[current]: nv = visited.copy() nv.add(pos[0]) nc = count + pos[1] if all([int(p) in nv for p in poss]) and pos[0] == 0 and nc < smallest: smallest = nc print(smallest) elif pos[0] not in visited and nc < smallest: queue.append((pos[0], nv, nc)) print(smallest)
inp = open('input_d24.txt').read().strip().split('\n') graph = dict() n = 0 yn = len(inp) xn = len(inp[0]) poss = '01234567' def find_n(ton): for y in range(len(inp)): for x in range(len(inp[y])): if inp[y][x] == str(ton): return (x, y) def exists(n, found): for ele in list(graph[n]): if ele[0] == int(found): return True return False def find_adj(x, y): res = set() for (a, b) in [(x - 1, y), (x + 1, y), (x, y - 1), (x, y + 1)]: if a >= 0 and a < xn and (b >= 0) and (b < yn): if inp[b][a] != '#': res.add((a, b)) return res for n in range(8): (x, y) = find_n(n) if n not in graph: graph[n] = set() visited = set() queue = [((x, y), set([(x, y)]))] while queue: (vertex, path) = queue.pop(0) for nex in find_adj(*vertex) - path: if nex in visited: continue visited.add(nex) found = inp[nex[1]][nex[0]] if found in poss: if not exists(n, found): graph[n].add((int(found), len(path))) if int(found) not in graph: graph[int(found)] = set() graph[int(found)].add((n, len(path))) else: p = path.copy() p.add(nex) queue.append((nex, p)) print(graph) print('bruteforcing TSP (fun times)') smallest = 10000 queue = [(0, set([0]), 0)] while queue: (current, visited, count) = queue.pop(0) if count >= smallest: continue for pos in graph[current]: nv = visited.copy() nv.add(pos[0]) nc = count + pos[1] if all([int(p) in nv for p in poss]) and pos[0] == 0 and (nc < smallest): smallest = nc print(smallest) elif pos[0] not in visited and nc < smallest: queue.append((pos[0], nv, nc)) print(smallest)
array = [] for i in range (16): # array.append([i,0]) array.append([i,5]) print(array)
array = [] for i in range(16): array.append([i, 5]) print(array)
# # PySNMP MIB module Juniper-PPPOE-PROFILE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-PPPOE-PROFILE-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:03:50 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ValueSizeConstraint, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsIntersection") juniMibs, = mibBuilder.importSymbols("Juniper-MIBs", "juniMibs") JuniEnable, JuniSetMap = mibBuilder.importSymbols("Juniper-TC", "JuniEnable", "JuniSetMap") ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") IpAddress, ModuleIdentity, MibIdentifier, Integer32, Gauge32, iso, Counter32, TimeTicks, Unsigned32, Counter64, NotificationType, ObjectIdentity, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "ModuleIdentity", "MibIdentifier", "Integer32", "Gauge32", "iso", "Counter32", "TimeTicks", "Unsigned32", "Counter64", "NotificationType", "ObjectIdentity", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") juniPppoeProfileMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46)) juniPppoeProfileMIB.setRevisions(('2008-06-18 10:29', '2005-07-13 11:40', '2004-06-10 19:25', '2003-03-11 21:58', '2002-09-16 21:44', '2002-08-15 20:34', '2002-08-15 19:07', '2001-03-21 18:32',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: juniPppoeProfileMIB.setRevisionsDescriptions(('Added juniPppoeProfileMaxSessionOverride object.', 'Added MTU control object.', 'Added Remote Circuit Id Capture object.', 'Added Service Name Table object.', 'Replaced Unisphere names with Juniper names.', 'Added PADI flag and packet trace support.', 'Added duplicate MAC address indicator and AC-NAME tag objects.', 'Initial version of this MIB module.',)) if mibBuilder.loadTexts: juniPppoeProfileMIB.setLastUpdated('200806181029Z') if mibBuilder.loadTexts: juniPppoeProfileMIB.setOrganization('Juniper Networks, Inc.') if mibBuilder.loadTexts: juniPppoeProfileMIB.setContactInfo(' Juniper Networks, Inc. Postal: 10 Technology Park Drive Westford, MA 01886-3146 USA Tel: +1 978 589 5800 Email: mib@Juniper.net') if mibBuilder.loadTexts: juniPppoeProfileMIB.setDescription('The point-to-point protocol over Ethernet (PPPoE) profile MIB for the Juniper enterprise.') juniPppoeProfileObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1)) juniPppoeProfile = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1)) juniPppoeProfileTable = MibTable((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1), ) if mibBuilder.loadTexts: juniPppoeProfileTable.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileTable.setDescription('This table contains profiles for configuring PPPoE interfaces/sessions. Entries in this table are created/deleted as a side-effect of corresponding operations to the juniProfileNameTable in the Juniper-PROFILE-MIB.') juniPppoeProfileEntry = MibTableRow((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1), ).setIndexNames((0, "Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileId")) if mibBuilder.loadTexts: juniPppoeProfileEntry.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileEntry.setDescription('A profile describing configuration of a PPPoE interface and its subinterfaces (sessions).') juniPppoeProfileId = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 1), Unsigned32()) if mibBuilder.loadTexts: juniPppoeProfileId.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileId.setDescription('The integer identifier associated with this profile. A value for this identifier is determined by locating or creating a profile name in the juniProfileNameTable.') juniPppoeProfileSetMap = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 2), JuniSetMap()).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileSetMap.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileSetMap.setDescription("A bitmap representing which objects in this entry have been explicitly configured. See the definition of the JuniSetMap TEXTUAL-CONVENTION for details of use. The INDEX object(s) and this object are excluded from representation (i.e. their bits are never set). When a SET request does not explicitly configure JuniSetMap, bits in JuniSetMap are set as a side-effect of configuring other profile attributes in the same entry. If, however, a SET request explicitly configures JuniSetMap, the explicitly configured value overrides 1) any previous bit settings, and 2) any simultaneous 'side-effect' settings that would otherwise occur. Once set, bits can only be cleared by explicitly configuring JuniSetMap.") juniPppoeProfileMaxNumSessions = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileMaxNumSessions.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileMaxNumSessions.setDescription('The maximum number of PPPoE sessions (subinterfaces) that can be configured on the main PPPoE interface created using this profile. A value of zero indicates no bound is configured.') juniPppoeProfileSubMotm = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 127))).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileSubMotm.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileSubMotm.setDescription('A message to send via a PADM on the sub-interface when this profile is applied to the IP interface above this PPPoE sub- interface. A client may choose to display this message to the user.') juniPppoeProfileSubUrl = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 127))).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileSubUrl.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileSubUrl.setDescription('A URL to be sent via a PADM on the sub-interface when this profile is applied to the IP interface above this PPPoE sub-interface. The string entered here can have several substitutions applied: %D is replaced with the profile name %d is replaced with the domain name %u is replaced with the user name %U is replaced with the user/domain name together %% is replaced with the % character The resulting string must not be greater than 127 octets long. The client may use this URL as the initial web-page for the user.') juniPppoeProfileDupProtect = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 6), JuniEnable().clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileDupProtect.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileDupProtect.setDescription('Flag to control whether duplicate MAC addresses are allowed') juniPppoeProfileAcName = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 7), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileAcName.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileAcName.setDescription('The name to use for the AC-NAME tag that is sent in any PADO that is sent on this interface.') juniPppoeProfilePadiFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 8), JuniEnable().clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfilePadiFlag.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfilePadiFlag.setDescription('The PPPoE major interface parameter PADI flag controls whether to always repsond to a PADI with a PADO regardless of the ability to create the session and allow the session establish phase to resolve it.') juniPppoeProfilePacketTrace = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 9), JuniEnable().clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfilePacketTrace.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfilePacketTrace.setDescription('The PPPoE major interface parameter packet tracing flag controls whether packet tracing is enable or not.') juniPppoeProfileServiceNameTableName = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileServiceNameTableName.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileServiceNameTableName.setDescription('The PPPoE Service name table controls behavior of PADO control packets.') juniPppoeProfilePadrRemoteCircuitIdCapture = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 11), JuniEnable().clone('disable')).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfilePadrRemoteCircuitIdCapture.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfilePadrRemoteCircuitIdCapture.setDescription('The PPPoE major interface parameter PADR remote circuit id capture flag controls whether the remote circuit id string possibly contained in the PADR packet will be saved and used by AAA to replace the NAS-PORT-ID field.') juniPppoeProfileMtu = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(1, 1), ValueRangeConstraint(2, 2), ValueRangeConstraint(66, 65535), )).clone(1494)).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileMtu.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileMtu.setDescription('The initial Maximum Transmit Unit (MTU) that the PPPoE major interface entity will advertise to the remote entity. If the value of this variable is 1 then the local PPPoE entity will use an MTU value determined by its underlying media interface. If the value of this variable is 2 then the local PPPoE entity will use a value determined by the PPPoE Max-Mtu-Tag transmitted from the client in the PADR packet. If no Max-Mtu-Tag is received, the value defaults to a maximum of 1494. The operational MTU is limited by the MTU of the underlying media interface minus the PPPoE frame overhead.') juniPppoeProfileMaxSessionOverride = MibTableColumn((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("override", 1), ("ignore", 2))).clone('ignore')).setMaxAccess("readwrite") if mibBuilder.loadTexts: juniPppoeProfileMaxSessionOverride.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileMaxSessionOverride.setDescription('Configure the action to be taken by PPPoE when RADIUS server returns the PPPoE max-session value: override Override the current PPPoE max-session value with the value returned by RADIUS server Ignore Ignore the max-session value returned by RADIUS server') juniPppoeProfileConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4)) juniPppoeProfileCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1)) juniPppoeProfileGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2)) juniPppoeProfileCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 1)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileCompliance = juniPppoeProfileCompliance.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileCompliance.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE Profile MIB. This statement became obsolete when the duplicate MAC address indicator and AC-NAME tag were added.') juniPppoeCompliance2 = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 2)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup2")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeCompliance2 = juniPppoeCompliance2.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance2.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE profile MIB. This statement became obsolete when PADI flag, AC-name and packet trace objects were added.') juniPppoeCompliance3 = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 3)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup3")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeCompliance3 = juniPppoeCompliance3.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance3.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE profile MIB. This statement became obsolete when the service name table was added.') juniPppoeCompliance4 = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 4)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup4")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeCompliance4 = juniPppoeCompliance4.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance4.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE profile MIB. This statement became obsolete when the remote circuit id capture was added.') juniPppoeCompliance5 = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 5)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup5")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeCompliance5 = juniPppoeCompliance5.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance5.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE MIB. This statement became obsolete when support was added for MTU configuration.') juniPppoeCompliance6 = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 6)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup6")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeCompliance6 = juniPppoeCompliance6.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance6.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE MIB. This statement became obsolete when support was added for juniPppoeProfileMaxSessionOverride.') juniPppoeCompliance7 = ModuleCompliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 7)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileGroup7")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeCompliance7 = juniPppoeCompliance7.setStatus('current') if mibBuilder.loadTexts: juniPppoeCompliance7.setDescription('The compliance statement for entities which implement the Juniper PPPoE Profile MIB.') juniPppoeProfileGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 1)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup = juniPppoeProfileGroup.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup.setDescription('Obsolete collection of objects providing management of profile functionality for PPPoE interfaces in a Juniper product. This group became obsolete when the duplicate MAC address indicator and AC-NAME tag objects were added.') juniPppoeProfileGroup2 = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 2)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileDupProtect"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileAcName")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup2 = juniPppoeProfileGroup2.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup2.setDescription('Obsolete collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product. This group became obsolete when PADI flag, AC-name and packet trace objects were added.') juniPppoeProfileGroup3 = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 3)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileDupProtect"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileAcName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadiFlag"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePacketTrace")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup3 = juniPppoeProfileGroup3.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup3.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juniPppoeProfileGroup4 = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 4)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileDupProtect"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileAcName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadiFlag"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePacketTrace"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileServiceNameTableName")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup4 = juniPppoeProfileGroup4.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup4.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juniPppoeProfileGroup5 = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 5)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileDupProtect"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileAcName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadiFlag"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePacketTrace"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileServiceNameTableName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadrRemoteCircuitIdCapture")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup5 = juniPppoeProfileGroup5.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup5.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juniPppoeProfileGroup6 = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 6)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileDupProtect"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileAcName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadiFlag"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePacketTrace"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileServiceNameTableName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadrRemoteCircuitIdCapture"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMtu")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup6 = juniPppoeProfileGroup6.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup6.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juniPppoeProfileGroup7 = ObjectGroup((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 7)).setObjects(("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSetMap"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxNumSessions"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubMotm"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileSubUrl"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileDupProtect"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileAcName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadiFlag"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePacketTrace"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileServiceNameTableName"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfilePadrRemoteCircuitIdCapture"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMtu"), ("Juniper-PPPOE-PROFILE-MIB", "juniPppoeProfileMaxSessionOverride")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniPppoeProfileGroup7 = juniPppoeProfileGroup7.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileGroup7.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') mibBuilder.exportSymbols("Juniper-PPPOE-PROFILE-MIB", juniPppoeCompliance5=juniPppoeCompliance5, juniPppoeProfileGroup2=juniPppoeProfileGroup2, juniPppoeProfileMtu=juniPppoeProfileMtu, juniPppoeProfile=juniPppoeProfile, juniPppoeProfileSetMap=juniPppoeProfileSetMap, juniPppoeProfilePadiFlag=juniPppoeProfilePadiFlag, juniPppoeProfileTable=juniPppoeProfileTable, juniPppoeProfileDupProtect=juniPppoeProfileDupProtect, juniPppoeCompliance4=juniPppoeCompliance4, juniPppoeProfileGroup=juniPppoeProfileGroup, juniPppoeProfileMIB=juniPppoeProfileMIB, juniPppoeProfileGroup4=juniPppoeProfileGroup4, juniPppoeProfileCompliances=juniPppoeProfileCompliances, juniPppoeProfileAcName=juniPppoeProfileAcName, juniPppoeProfileGroup3=juniPppoeProfileGroup3, juniPppoeProfilePadrRemoteCircuitIdCapture=juniPppoeProfilePadrRemoteCircuitIdCapture, juniPppoeProfileSubMotm=juniPppoeProfileSubMotm, juniPppoeProfilePacketTrace=juniPppoeProfilePacketTrace, juniPppoeProfileEntry=juniPppoeProfileEntry, juniPppoeProfileGroup5=juniPppoeProfileGroup5, juniPppoeProfileMaxSessionOverride=juniPppoeProfileMaxSessionOverride, juniPppoeCompliance2=juniPppoeCompliance2, juniPppoeProfileGroups=juniPppoeProfileGroups, juniPppoeCompliance6=juniPppoeCompliance6, juniPppoeProfileCompliance=juniPppoeProfileCompliance, juniPppoeCompliance3=juniPppoeCompliance3, juniPppoeCompliance7=juniPppoeCompliance7, juniPppoeProfileGroup6=juniPppoeProfileGroup6, juniPppoeProfileMaxNumSessions=juniPppoeProfileMaxNumSessions, juniPppoeProfileId=juniPppoeProfileId, juniPppoeProfileConformance=juniPppoeProfileConformance, PYSNMP_MODULE_ID=juniPppoeProfileMIB, juniPppoeProfileObjects=juniPppoeProfileObjects, juniPppoeProfileServiceNameTableName=juniPppoeProfileServiceNameTableName, juniPppoeProfileSubUrl=juniPppoeProfileSubUrl, juniPppoeProfileGroup7=juniPppoeProfileGroup7)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsIntersection') (juni_mibs,) = mibBuilder.importSymbols('Juniper-MIBs', 'juniMibs') (juni_enable, juni_set_map) = mibBuilder.importSymbols('Juniper-TC', 'JuniEnable', 'JuniSetMap') (object_group, module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ObjectGroup', 'ModuleCompliance', 'NotificationGroup') (ip_address, module_identity, mib_identifier, integer32, gauge32, iso, counter32, time_ticks, unsigned32, counter64, notification_type, object_identity, bits, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'ModuleIdentity', 'MibIdentifier', 'Integer32', 'Gauge32', 'iso', 'Counter32', 'TimeTicks', 'Unsigned32', 'Counter64', 'NotificationType', 'ObjectIdentity', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn') (textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString') juni_pppoe_profile_mib = module_identity((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46)) juniPppoeProfileMIB.setRevisions(('2008-06-18 10:29', '2005-07-13 11:40', '2004-06-10 19:25', '2003-03-11 21:58', '2002-09-16 21:44', '2002-08-15 20:34', '2002-08-15 19:07', '2001-03-21 18:32')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: juniPppoeProfileMIB.setRevisionsDescriptions(('Added juniPppoeProfileMaxSessionOverride object.', 'Added MTU control object.', 'Added Remote Circuit Id Capture object.', 'Added Service Name Table object.', 'Replaced Unisphere names with Juniper names.', 'Added PADI flag and packet trace support.', 'Added duplicate MAC address indicator and AC-NAME tag objects.', 'Initial version of this MIB module.')) if mibBuilder.loadTexts: juniPppoeProfileMIB.setLastUpdated('200806181029Z') if mibBuilder.loadTexts: juniPppoeProfileMIB.setOrganization('Juniper Networks, Inc.') if mibBuilder.loadTexts: juniPppoeProfileMIB.setContactInfo(' Juniper Networks, Inc. Postal: 10 Technology Park Drive Westford, MA 01886-3146 USA Tel: +1 978 589 5800 Email: mib@Juniper.net') if mibBuilder.loadTexts: juniPppoeProfileMIB.setDescription('The point-to-point protocol over Ethernet (PPPoE) profile MIB for the Juniper enterprise.') juni_pppoe_profile_objects = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1)) juni_pppoe_profile = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1)) juni_pppoe_profile_table = mib_table((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1)) if mibBuilder.loadTexts: juniPppoeProfileTable.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileTable.setDescription('This table contains profiles for configuring PPPoE interfaces/sessions. Entries in this table are created/deleted as a side-effect of corresponding operations to the juniProfileNameTable in the Juniper-PROFILE-MIB.') juni_pppoe_profile_entry = mib_table_row((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1)).setIndexNames((0, 'Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileId')) if mibBuilder.loadTexts: juniPppoeProfileEntry.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileEntry.setDescription('A profile describing configuration of a PPPoE interface and its subinterfaces (sessions).') juni_pppoe_profile_id = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 1), unsigned32()) if mibBuilder.loadTexts: juniPppoeProfileId.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileId.setDescription('The integer identifier associated with this profile. A value for this identifier is determined by locating or creating a profile name in the juniProfileNameTable.') juni_pppoe_profile_set_map = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 2), juni_set_map()).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileSetMap.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileSetMap.setDescription("A bitmap representing which objects in this entry have been explicitly configured. See the definition of the JuniSetMap TEXTUAL-CONVENTION for details of use. The INDEX object(s) and this object are excluded from representation (i.e. their bits are never set). When a SET request does not explicitly configure JuniSetMap, bits in JuniSetMap are set as a side-effect of configuring other profile attributes in the same entry. If, however, a SET request explicitly configures JuniSetMap, the explicitly configured value overrides 1) any previous bit settings, and 2) any simultaneous 'side-effect' settings that would otherwise occur. Once set, bits can only be cleared by explicitly configuring JuniSetMap.") juni_pppoe_profile_max_num_sessions = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileMaxNumSessions.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileMaxNumSessions.setDescription('The maximum number of PPPoE sessions (subinterfaces) that can be configured on the main PPPoE interface created using this profile. A value of zero indicates no bound is configured.') juni_pppoe_profile_sub_motm = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 4), display_string().subtype(subtypeSpec=value_size_constraint(0, 127))).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileSubMotm.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileSubMotm.setDescription('A message to send via a PADM on the sub-interface when this profile is applied to the IP interface above this PPPoE sub- interface. A client may choose to display this message to the user.') juni_pppoe_profile_sub_url = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 5), display_string().subtype(subtypeSpec=value_size_constraint(0, 127))).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileSubUrl.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileSubUrl.setDescription('A URL to be sent via a PADM on the sub-interface when this profile is applied to the IP interface above this PPPoE sub-interface. The string entered here can have several substitutions applied: %D is replaced with the profile name %d is replaced with the domain name %u is replaced with the user name %U is replaced with the user/domain name together %% is replaced with the % character The resulting string must not be greater than 127 octets long. The client may use this URL as the initial web-page for the user.') juni_pppoe_profile_dup_protect = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 6), juni_enable().clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileDupProtect.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileDupProtect.setDescription('Flag to control whether duplicate MAC addresses are allowed') juni_pppoe_profile_ac_name = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 7), display_string().subtype(subtypeSpec=value_size_constraint(0, 64))).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileAcName.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileAcName.setDescription('The name to use for the AC-NAME tag that is sent in any PADO that is sent on this interface.') juni_pppoe_profile_padi_flag = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 8), juni_enable().clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfilePadiFlag.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfilePadiFlag.setDescription('The PPPoE major interface parameter PADI flag controls whether to always repsond to a PADI with a PADO regardless of the ability to create the session and allow the session establish phase to resolve it.') juni_pppoe_profile_packet_trace = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 9), juni_enable().clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfilePacketTrace.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfilePacketTrace.setDescription('The PPPoE major interface parameter packet tracing flag controls whether packet tracing is enable or not.') juni_pppoe_profile_service_name_table_name = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 10), display_string().subtype(subtypeSpec=value_size_constraint(0, 31))).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileServiceNameTableName.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileServiceNameTableName.setDescription('The PPPoE Service name table controls behavior of PADO control packets.') juni_pppoe_profile_padr_remote_circuit_id_capture = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 11), juni_enable().clone('disable')).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfilePadrRemoteCircuitIdCapture.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfilePadrRemoteCircuitIdCapture.setDescription('The PPPoE major interface parameter PADR remote circuit id capture flag controls whether the remote circuit id string possibly contained in the PADR packet will be saved and used by AAA to replace the NAS-PORT-ID field.') juni_pppoe_profile_mtu = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 12), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(1, 1), value_range_constraint(2, 2), value_range_constraint(66, 65535))).clone(1494)).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileMtu.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileMtu.setDescription('The initial Maximum Transmit Unit (MTU) that the PPPoE major interface entity will advertise to the remote entity. If the value of this variable is 1 then the local PPPoE entity will use an MTU value determined by its underlying media interface. If the value of this variable is 2 then the local PPPoE entity will use a value determined by the PPPoE Max-Mtu-Tag transmitted from the client in the PADR packet. If no Max-Mtu-Tag is received, the value defaults to a maximum of 1494. The operational MTU is limited by the MTU of the underlying media interface minus the PPPoE frame overhead.') juni_pppoe_profile_max_session_override = mib_table_column((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 1, 1, 1, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('override', 1), ('ignore', 2))).clone('ignore')).setMaxAccess('readwrite') if mibBuilder.loadTexts: juniPppoeProfileMaxSessionOverride.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileMaxSessionOverride.setDescription('Configure the action to be taken by PPPoE when RADIUS server returns the PPPoE max-session value: override Override the current PPPoE max-session value with the value returned by RADIUS server Ignore Ignore the max-session value returned by RADIUS server') juni_pppoe_profile_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4)) juni_pppoe_profile_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1)) juni_pppoe_profile_groups = mib_identifier((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2)) juni_pppoe_profile_compliance = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 1)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_compliance = juniPppoeProfileCompliance.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileCompliance.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE Profile MIB. This statement became obsolete when the duplicate MAC address indicator and AC-NAME tag were added.') juni_pppoe_compliance2 = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 2)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup2')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_compliance2 = juniPppoeCompliance2.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance2.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE profile MIB. This statement became obsolete when PADI flag, AC-name and packet trace objects were added.') juni_pppoe_compliance3 = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 3)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup3')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_compliance3 = juniPppoeCompliance3.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance3.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE profile MIB. This statement became obsolete when the service name table was added.') juni_pppoe_compliance4 = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 4)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup4')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_compliance4 = juniPppoeCompliance4.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance4.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE profile MIB. This statement became obsolete when the remote circuit id capture was added.') juni_pppoe_compliance5 = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 5)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup5')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_compliance5 = juniPppoeCompliance5.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance5.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE MIB. This statement became obsolete when support was added for MTU configuration.') juni_pppoe_compliance6 = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 6)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup6')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_compliance6 = juniPppoeCompliance6.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeCompliance6.setDescription('Obsolete compliance statement for entities which implement the Juniper PPPoE MIB. This statement became obsolete when support was added for juniPppoeProfileMaxSessionOverride.') juni_pppoe_compliance7 = module_compliance((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 1, 7)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileGroup7')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_compliance7 = juniPppoeCompliance7.setStatus('current') if mibBuilder.loadTexts: juniPppoeCompliance7.setDescription('The compliance statement for entities which implement the Juniper PPPoE Profile MIB.') juni_pppoe_profile_group = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 1)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group = juniPppoeProfileGroup.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup.setDescription('Obsolete collection of objects providing management of profile functionality for PPPoE interfaces in a Juniper product. This group became obsolete when the duplicate MAC address indicator and AC-NAME tag objects were added.') juni_pppoe_profile_group2 = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 2)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileDupProtect'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileAcName')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group2 = juniPppoeProfileGroup2.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup2.setDescription('Obsolete collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product. This group became obsolete when PADI flag, AC-name and packet trace objects were added.') juni_pppoe_profile_group3 = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 3)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileDupProtect'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileAcName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadiFlag'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePacketTrace')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group3 = juniPppoeProfileGroup3.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup3.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juni_pppoe_profile_group4 = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 4)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileDupProtect'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileAcName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadiFlag'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePacketTrace'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileServiceNameTableName')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group4 = juniPppoeProfileGroup4.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup4.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juni_pppoe_profile_group5 = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 5)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileDupProtect'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileAcName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadiFlag'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePacketTrace'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileServiceNameTableName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadrRemoteCircuitIdCapture')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group5 = juniPppoeProfileGroup5.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup5.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juni_pppoe_profile_group6 = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 6)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileDupProtect'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileAcName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadiFlag'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePacketTrace'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileServiceNameTableName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadrRemoteCircuitIdCapture'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMtu')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group6 = juniPppoeProfileGroup6.setStatus('obsolete') if mibBuilder.loadTexts: juniPppoeProfileGroup6.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') juni_pppoe_profile_group7 = object_group((1, 3, 6, 1, 4, 1, 4874, 2, 2, 46, 4, 2, 7)).setObjects(('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSetMap'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxNumSessions'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubMotm'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileSubUrl'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileDupProtect'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileAcName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadiFlag'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePacketTrace'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileServiceNameTableName'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfilePadrRemoteCircuitIdCapture'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMtu'), ('Juniper-PPPOE-PROFILE-MIB', 'juniPppoeProfileMaxSessionOverride')) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juni_pppoe_profile_group7 = juniPppoeProfileGroup7.setStatus('current') if mibBuilder.loadTexts: juniPppoeProfileGroup7.setDescription('A collection of objects providing management of profile functionality for PPPOE interfaces in a Juniper product.') mibBuilder.exportSymbols('Juniper-PPPOE-PROFILE-MIB', juniPppoeCompliance5=juniPppoeCompliance5, juniPppoeProfileGroup2=juniPppoeProfileGroup2, juniPppoeProfileMtu=juniPppoeProfileMtu, juniPppoeProfile=juniPppoeProfile, juniPppoeProfileSetMap=juniPppoeProfileSetMap, juniPppoeProfilePadiFlag=juniPppoeProfilePadiFlag, juniPppoeProfileTable=juniPppoeProfileTable, juniPppoeProfileDupProtect=juniPppoeProfileDupProtect, juniPppoeCompliance4=juniPppoeCompliance4, juniPppoeProfileGroup=juniPppoeProfileGroup, juniPppoeProfileMIB=juniPppoeProfileMIB, juniPppoeProfileGroup4=juniPppoeProfileGroup4, juniPppoeProfileCompliances=juniPppoeProfileCompliances, juniPppoeProfileAcName=juniPppoeProfileAcName, juniPppoeProfileGroup3=juniPppoeProfileGroup3, juniPppoeProfilePadrRemoteCircuitIdCapture=juniPppoeProfilePadrRemoteCircuitIdCapture, juniPppoeProfileSubMotm=juniPppoeProfileSubMotm, juniPppoeProfilePacketTrace=juniPppoeProfilePacketTrace, juniPppoeProfileEntry=juniPppoeProfileEntry, juniPppoeProfileGroup5=juniPppoeProfileGroup5, juniPppoeProfileMaxSessionOverride=juniPppoeProfileMaxSessionOverride, juniPppoeCompliance2=juniPppoeCompliance2, juniPppoeProfileGroups=juniPppoeProfileGroups, juniPppoeCompliance6=juniPppoeCompliance6, juniPppoeProfileCompliance=juniPppoeProfileCompliance, juniPppoeCompliance3=juniPppoeCompliance3, juniPppoeCompliance7=juniPppoeCompliance7, juniPppoeProfileGroup6=juniPppoeProfileGroup6, juniPppoeProfileMaxNumSessions=juniPppoeProfileMaxNumSessions, juniPppoeProfileId=juniPppoeProfileId, juniPppoeProfileConformance=juniPppoeProfileConformance, PYSNMP_MODULE_ID=juniPppoeProfileMIB, juniPppoeProfileObjects=juniPppoeProfileObjects, juniPppoeProfileServiceNameTableName=juniPppoeProfileServiceNameTableName, juniPppoeProfileSubUrl=juniPppoeProfileSubUrl, juniPppoeProfileGroup7=juniPppoeProfileGroup7)
class Solution(object): def isValidSudoku(self, board): return (self.is_row_valid(board) and self.is_col_valid(board) and self.is_square_valid(board)) def is_row_valid(self, board): for row in board: if not self.is_unit_valid(row): return False return True def is_col_valid(self, board): # zip turns column into tuple for col in zip(*board): if not self.is_unit_valid(col): return False return True def is_square_valid(self, board): for i in (0, 3, 6): for j in (0, 3, 6): square = [board[x][y] for x in range(i, i + 3) for y in range(j, j + 3)] if not self.is_unit_valid(square): return False return True def is_unit_valid(self, unit): unit = [i for i in unit if i != '.'] return len(set(unit)) == len(unit) test1 = [ ["5","3",".",".","7",".",".",".","."], ["6",".",".","1","9","5",".",".","."], [".","9","8",".",".",".",".","6","."], ["8",".",".",".","6",".",".",".","3"], ["4",".",".","8",".","3",".",".","1"], ["7",".",".",".","2",".",".",".","6"], [".","6",".",".",".",".","2","8","."], [".",".",".","4","1","9",".",".","5"], [".",".",".",".","8",".",".","7","9"] ] test2 = [ ["8","3",".",".","7",".",".",".","."], ["6",".",".","1","9","5",".",".","."], [".","9","8",".",".",".",".","6","."], ["8",".",".",".","6",".",".",".","3"], ["4",".",".","8",".","3",".",".","1"], ["7",".",".",".","2",".",".",".","6"], [".","6",".",".",".",".","2","8","."], [".",".",".","4","1","9",".",".","5"], [".",".",".",".","8",".",".","7","9"] ] solver = Solution() print(solver.isValidSudoku(test1))
class Solution(object): def is_valid_sudoku(self, board): return self.is_row_valid(board) and self.is_col_valid(board) and self.is_square_valid(board) def is_row_valid(self, board): for row in board: if not self.is_unit_valid(row): return False return True def is_col_valid(self, board): for col in zip(*board): if not self.is_unit_valid(col): return False return True def is_square_valid(self, board): for i in (0, 3, 6): for j in (0, 3, 6): square = [board[x][y] for x in range(i, i + 3) for y in range(j, j + 3)] if not self.is_unit_valid(square): return False return True def is_unit_valid(self, unit): unit = [i for i in unit if i != '.'] return len(set(unit)) == len(unit) test1 = [['5', '3', '.', '.', '7', '.', '.', '.', '.'], ['6', '.', '.', '1', '9', '5', '.', '.', '.'], ['.', '9', '8', '.', '.', '.', '.', '6', '.'], ['8', '.', '.', '.', '6', '.', '.', '.', '3'], ['4', '.', '.', '8', '.', '3', '.', '.', '1'], ['7', '.', '.', '.', '2', '.', '.', '.', '6'], ['.', '6', '.', '.', '.', '.', '2', '8', '.'], ['.', '.', '.', '4', '1', '9', '.', '.', '5'], ['.', '.', '.', '.', '8', '.', '.', '7', '9']] test2 = [['8', '3', '.', '.', '7', '.', '.', '.', '.'], ['6', '.', '.', '1', '9', '5', '.', '.', '.'], ['.', '9', '8', '.', '.', '.', '.', '6', '.'], ['8', '.', '.', '.', '6', '.', '.', '.', '3'], ['4', '.', '.', '8', '.', '3', '.', '.', '1'], ['7', '.', '.', '.', '2', '.', '.', '.', '6'], ['.', '6', '.', '.', '.', '.', '2', '8', '.'], ['.', '.', '.', '4', '1', '9', '.', '.', '5'], ['.', '.', '.', '.', '8', '.', '.', '7', '9']] solver = solution() print(solver.isValidSudoku(test1))
n = int(input()) D = [list(map(int,input().split())) for i in range(n)] D.sort(key = lambda t: t[0]) S = 0 for i in D: S += i[1] S = (S+1)//2 S2 = 0 for i in D: S2 += i[1] if S2 >= S: print(i[0]) break
n = int(input()) d = [list(map(int, input().split())) for i in range(n)] D.sort(key=lambda t: t[0]) s = 0 for i in D: s += i[1] s = (S + 1) // 2 s2 = 0 for i in D: s2 += i[1] if S2 >= S: print(i[0]) break
#!/usr/local/bin/python3 # Copyright 2019 NineFx Inc. # Justin Baum # 20 May 2019 # Precis Code-Generator ReasonML # https://github.com/NineFX/smeagol/blob/master/spec/code_gen/precis_cp.txt fp = open('unicodedata.txt', 'r') ranges = [] line = fp.readline() prev = "" start = 0 while line: if len(line) < 2: break linesplit = line.split(";") if ", First" in line: nextline = fp.readline().split(";") start = int(linesplit[0], 16) finish = int(nextline[0], 16) code = linesplit[4] ranges.append((start, finish + 1, code)) else: code = linesplit[4] if code != prev: value = int(linesplit[0], 16) ranges.append((start, value, prev if len(prev) != 0 else "Illegal")) start = value prev = code line = fp.readline() def splitHalf(listy): if len(listy) <= 2: print("switch (point) {") for item in listy: if item[0] == item[1] - 1: print(" | point when (point == " + str(item[0]) + ") => " + str(item[2])) else: print(" | point when (point >= " + str(item[0]) + " && point < " + str(item[1]) +") => " + str(item[2])) print("| _point => raise(PrecisUtils.PrecisError(BidiError))") print("}") return splitValue = listy[len(listy)//2] firstHalf = listy[:len(listy)//2] secondHalf = listy[len(listy)//2:] print("if (point < " +str(splitValue[0]) + ") {") splitHalf(firstHalf) print("} else {") splitHalf(secondHalf) print("}") splitHalf(ranges)
fp = open('unicodedata.txt', 'r') ranges = [] line = fp.readline() prev = '' start = 0 while line: if len(line) < 2: break linesplit = line.split(';') if ', First' in line: nextline = fp.readline().split(';') start = int(linesplit[0], 16) finish = int(nextline[0], 16) code = linesplit[4] ranges.append((start, finish + 1, code)) else: code = linesplit[4] if code != prev: value = int(linesplit[0], 16) ranges.append((start, value, prev if len(prev) != 0 else 'Illegal')) start = value prev = code line = fp.readline() def split_half(listy): if len(listy) <= 2: print('switch (point) {') for item in listy: if item[0] == item[1] - 1: print(' | point when (point == ' + str(item[0]) + ') => ' + str(item[2])) else: print(' | point when (point >= ' + str(item[0]) + ' && point < ' + str(item[1]) + ') => ' + str(item[2])) print('| _point => raise(PrecisUtils.PrecisError(BidiError))') print('}') return split_value = listy[len(listy) // 2] first_half = listy[:len(listy) // 2] second_half = listy[len(listy) // 2:] print('if (point < ' + str(splitValue[0]) + ') {') split_half(firstHalf) print('} else {') split_half(secondHalf) print('}') split_half(ranges)
# Public Attributes class Employee: def __init__(self, ID, salary): # all properties are public self.ID = ID self.salary = salary def displayID(self): print("ID:", self.ID) Steve = Employee(3789, 2500) Steve.displayID() print(Steve.salary)
class Employee: def __init__(self, ID, salary): self.ID = ID self.salary = salary def display_id(self): print('ID:', self.ID) steve = employee(3789, 2500) Steve.displayID() print(Steve.salary)
m: int; n: int; j: int; i: int m = int(input("Quantas linhas vai ter cada matriz? ")) n = int(input("Quantas colunas vai ter cada matriz? ")) A: [[int]] = [[0 for x in range(n)] for x in range(m)] B: [[int]] = [[0 for x in range(n)] for x in range(m)] C: [[int]] = [[0 for x in range(n)] for x in range(m)] print("Digite os valores da matriz A:") for i in range(0, m): for j in range(0, n): A[i][j] = int(input(f"Elemento [{i},{j}]: ")) print("Digite os valores da matriz B:") for i in range(0, m): for j in range(0, n): B[i][j] = int(input(f"Elemento [{i},{j}]: ")) for i in range(0, m): for j in range(0, n): C[i][j] = A[i][j] + B[i][j] print("MATRIZ SOMA:") for i in range(0, m): for j in range(0, n): print(f"{C[i][j]} ", end="") print()
m: int n: int j: int i: int m = int(input('Quantas linhas vai ter cada matriz? ')) n = int(input('Quantas colunas vai ter cada matriz? ')) a: [[int]] = [[0 for x in range(n)] for x in range(m)] b: [[int]] = [[0 for x in range(n)] for x in range(m)] c: [[int]] = [[0 for x in range(n)] for x in range(m)] print('Digite os valores da matriz A:') for i in range(0, m): for j in range(0, n): A[i][j] = int(input(f'Elemento [{i},{j}]: ')) print('Digite os valores da matriz B:') for i in range(0, m): for j in range(0, n): B[i][j] = int(input(f'Elemento [{i},{j}]: ')) for i in range(0, m): for j in range(0, n): C[i][j] = A[i][j] + B[i][j] print('MATRIZ SOMA:') for i in range(0, m): for j in range(0, n): print(f'{C[i][j]} ', end='') print()
# class Tree: # def __init__(self, val, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def solve(self, root): stack = [] stack.append(root) level = -1 min_sum = float('inf') l = 0 while stack: new = [] s = 0 for node in stack: if node.left: new.append(node.left) if node.right: new.append(node.right) s += node.val if s < min_sum: level = l min_sum = s l += 1 stack = new return level
class Solution: def solve(self, root): stack = [] stack.append(root) level = -1 min_sum = float('inf') l = 0 while stack: new = [] s = 0 for node in stack: if node.left: new.append(node.left) if node.right: new.append(node.right) s += node.val if s < min_sum: level = l min_sum = s l += 1 stack = new return level
""" 1. Clarification 2. Possible solutions - Backtracking 3. Coding 4. Tests """ # T=O(sum(feasible solutions' len)), S=O(target) class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: if not candidates or target < 1: return [] ans, tmp = [], [] def backtrack(idx, Sum): if idx >= len(candidates) or Sum >= target: if Sum == target: ans.append(tmp[:]) return tmp.append(candidates[idx]) backtrack(idx, Sum + candidates[idx]) tmp.pop() backtrack(idx + 1, Sum) backtrack(0, 0) return ans
""" 1. Clarification 2. Possible solutions - Backtracking 3. Coding 4. Tests """ class Solution: def combination_sum(self, candidates: List[int], target: int) -> List[List[int]]: if not candidates or target < 1: return [] (ans, tmp) = ([], []) def backtrack(idx, Sum): if idx >= len(candidates) or Sum >= target: if Sum == target: ans.append(tmp[:]) return tmp.append(candidates[idx]) backtrack(idx, Sum + candidates[idx]) tmp.pop() backtrack(idx + 1, Sum) backtrack(0, 0) return ans
def ack ( m, n ): ''' ack: Evaluates Ackermann function with the given arguments m: Positive integer value n: Positive integer value ''' # Guard against error from incorrect input if n < 0 or (not isinstance(n, int)): return "Error: n is either negative or not an integer" if m < 0 or (not isinstance(m, int)): return "Error: m is either negative or not an integer" if m == 0: return n + 1 elif m > 0 and n == 0: return ack(m-1, 1) else: return ack(m-1, ack(m, n-1)) print(ack(3, 4))
def ack(m, n): """ ack: Evaluates Ackermann function with the given arguments m: Positive integer value n: Positive integer value """ if n < 0 or not isinstance(n, int): return 'Error: n is either negative or not an integer' if m < 0 or not isinstance(m, int): return 'Error: m is either negative or not an integer' if m == 0: return n + 1 elif m > 0 and n == 0: return ack(m - 1, 1) else: return ack(m - 1, ack(m, n - 1)) print(ack(3, 4))
# Copyright (c) 2021 Ben Maddison. All rights reserved. # """aspa.as_path Module.""" AS_SEQUENCE = 0x0 AS_SET = 0x1 class AsPathSegment(object): def __init__(self, segment_type, values): if segment_type not in (AS_SEQUENCE, AS_SET): raise ValueError(int) self.type = segment_type self.values = values def __repr__(self): values = map(str, reversed(self.values)) if self.type == AS_SEQUENCE: return f"{'_'.join(values)}" else: return f"[ {' '.join(values)} ]" class AsPath(object): def __init__(self, *segments): for s in segments: if not isinstance(s, AsPathSegment): raise TypeError(f"expected AsPathSegment, got {s}") self.segments = segments def __repr__(self): return f"{'_'.join(map(repr, reversed(self.segments)))}" def flatten(self): return [AsPathElement(orig_segment_type=s.type, value=v) for s in self.segments for v in s.values] class AsPathElement(object): def __init__(self, orig_segment_type, value): self.type = orig_segment_type self.value = value
"""aspa.as_path Module.""" as_sequence = 0 as_set = 1 class Aspathsegment(object): def __init__(self, segment_type, values): if segment_type not in (AS_SEQUENCE, AS_SET): raise value_error(int) self.type = segment_type self.values = values def __repr__(self): values = map(str, reversed(self.values)) if self.type == AS_SEQUENCE: return f"{'_'.join(values)}" else: return f"[ {' '.join(values)} ]" class Aspath(object): def __init__(self, *segments): for s in segments: if not isinstance(s, AsPathSegment): raise type_error(f'expected AsPathSegment, got {s}') self.segments = segments def __repr__(self): return f"{'_'.join(map(repr, reversed(self.segments)))}" def flatten(self): return [as_path_element(orig_segment_type=s.type, value=v) for s in self.segments for v in s.values] class Aspathelement(object): def __init__(self, orig_segment_type, value): self.type = orig_segment_type self.value = value
def love(): lover = 'sure' lover
def love(): lover = 'sure' lover
""" Parses a Markdown file in the Task.md format. :params doc: :returns: a dictionary containing the main fields of the task. """ def remove_obsidian_syntax(string): "Removes Obsidian syntax from a string, namely []'s, [[]]'s and #'s" pass def parse_md(filename): "Parses a markdown file in the Task.md format" # initialize the task object task = {"description": ''} # start reading the input file with open(filename, "r") as read_obj: count = 0 while True: line = read_obj.readline() if not line: break if count == 2: task['title'] = remove_obsidian_syntax(' '.join(line.split()[1:])) if count == 3: task['status'] = remove_obsidian_syntax(line.split()[1]) if count == 4: task['priority'] = remove_obsidian_syntax(line.split()[1]) if count == 5: task['due_date'] = line.split()[2] if count == 6: task['start_date'] = line.split()[2] if count == 7: task['deliverable'] = remove_obsidian_syntax(' '.join(line.split()[1:])) if count >= 9: task['description'] += remove_obsidian_syntax(line) count += 1 print(task) return task if __name__ == "__main__": parse_md("tests/tasks/sampleTask.md")
""" Parses a Markdown file in the Task.md format. :params doc: :returns: a dictionary containing the main fields of the task. """ def remove_obsidian_syntax(string): """Removes Obsidian syntax from a string, namely []'s, [[]]'s and #'s""" pass def parse_md(filename): """Parses a markdown file in the Task.md format""" task = {'description': ''} with open(filename, 'r') as read_obj: count = 0 while True: line = read_obj.readline() if not line: break if count == 2: task['title'] = remove_obsidian_syntax(' '.join(line.split()[1:])) if count == 3: task['status'] = remove_obsidian_syntax(line.split()[1]) if count == 4: task['priority'] = remove_obsidian_syntax(line.split()[1]) if count == 5: task['due_date'] = line.split()[2] if count == 6: task['start_date'] = line.split()[2] if count == 7: task['deliverable'] = remove_obsidian_syntax(' '.join(line.split()[1:])) if count >= 9: task['description'] += remove_obsidian_syntax(line) count += 1 print(task) return task if __name__ == '__main__': parse_md('tests/tasks/sampleTask.md')
# class OtsUtil(object): STEP_THRESHOLD = 408 step = 0 @staticmethod def log(msg): if OtsUtil.step >= OtsUtil.STEP_THRESHOLD: print(msg)
class Otsutil(object): step_threshold = 408 step = 0 @staticmethod def log(msg): if OtsUtil.step >= OtsUtil.STEP_THRESHOLD: print(msg)
#Program to Remove Punctuations From a String string="Wow! What a beautiful nature!" new_string=string.replace("!","") print(new_string)
string = 'Wow! What a beautiful nature!' new_string = string.replace('!', '') print(new_string)
def condensate_to_gas_equivalence(api, stb): "Derivation from real gas equation" Tsc = 519.57 # standard temp in Rankine psc = 14.7 # standard pressure in psi R = 10.732 rho_w = 350.16 # water density in lbm/STB so = 141.5 / (api + 131.5) # so: specific gravity of oil (dimensionless) Mo = 5854 / (api - 8.811) # molecular weight of oil n = (rho_w * so) / Mo V1stb = ((n * R * Tsc) / psc) V = V1stb * stb return(V) def general_equivalence(gamma, M): "Calculate equivalence of 1 STB of water/condensate to scf of gas" # gamma: specific gravity of condensate/water. oil specific gravity use formula: so=141.5/(api+131.5). water specific gravity = 1 # M: molecular weight of condensate/water. oil: Mo = 5854 / (api - 8.811). water: Mw = 18 V1stb = 132849 * (gamma / M) return(V1stb)
def condensate_to_gas_equivalence(api, stb): """Derivation from real gas equation""" tsc = 519.57 psc = 14.7 r = 10.732 rho_w = 350.16 so = 141.5 / (api + 131.5) mo = 5854 / (api - 8.811) n = rho_w * so / Mo v1stb = n * R * Tsc / psc v = V1stb * stb return V def general_equivalence(gamma, M): """Calculate equivalence of 1 STB of water/condensate to scf of gas""" v1stb = 132849 * (gamma / M) return V1stb
def fibonacci(): number = 0 previous_number = 1 while True: if number == 0: yield number number += previous_number if number == 1: yield number number += previous_number if number == 2: yield previous_number if number > 1: yield number cutternt_number = previous_number previous_number = number number = cutternt_number + previous_number generator = fibonacci() for i in range(5): print(next(generator))
def fibonacci(): number = 0 previous_number = 1 while True: if number == 0: yield number number += previous_number if number == 1: yield number number += previous_number if number == 2: yield previous_number if number > 1: yield number cutternt_number = previous_number previous_number = number number = cutternt_number + previous_number generator = fibonacci() for i in range(5): print(next(generator))
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def __repr__(self): return str(self.data) def count_unival_trees(root): if not root: return 0 elif not root.left and not root.right: return 1 elif not root.left and root.data == root.right.data: return 1 + count_unival_trees(root.right) elif not root.right and root.data == root.left.data: return 1 + count_unival_trees(root.left) child_counts = count_unival_trees(root.left) + count_unival_trees(root.right) current_node_count = 0 if root.data == root.left.data and root.data == root.left.data: current_node_count = 1 return current_node_count + child_counts node_a = Node('0') node_b = Node('1') node_c = Node('0') node_d = Node('1') node_e = Node('0') node_f = Node('1') node_g = Node('1') node_a.left = node_b node_a.right = node_c node_c.left = node_d node_c.right = node_e node_d.left = node_f node_d.right = node_g assert count_unival_trees(None) == 0 assert count_unival_trees(node_a) == 5 assert count_unival_trees(node_c) == 4 assert count_unival_trees(node_g) == 1 assert count_unival_trees(node_d) == 3
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def __repr__(self): return str(self.data) def count_unival_trees(root): if not root: return 0 elif not root.left and (not root.right): return 1 elif not root.left and root.data == root.right.data: return 1 + count_unival_trees(root.right) elif not root.right and root.data == root.left.data: return 1 + count_unival_trees(root.left) child_counts = count_unival_trees(root.left) + count_unival_trees(root.right) current_node_count = 0 if root.data == root.left.data and root.data == root.left.data: current_node_count = 1 return current_node_count + child_counts node_a = node('0') node_b = node('1') node_c = node('0') node_d = node('1') node_e = node('0') node_f = node('1') node_g = node('1') node_a.left = node_b node_a.right = node_c node_c.left = node_d node_c.right = node_e node_d.left = node_f node_d.right = node_g assert count_unival_trees(None) == 0 assert count_unival_trees(node_a) == 5 assert count_unival_trees(node_c) == 4 assert count_unival_trees(node_g) == 1 assert count_unival_trees(node_d) == 3
""" A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings. A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings. Given a valid parentheses string S, consider its primitive decomposition: S = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings. Return S after removing the outermost parentheses of every primitive string in the primitive decomposition of S. Example 1: Input: "(()())(())" Output: "()()()" Explanation: The input string is "(()())(())", with primitive decomposition "(()())" + "(())". After removing outer parentheses of each part, this is "()()" + "()" = "()()()". Example 2: Input: "(()())(())(()(()))" Output: "()()()()(())" Explanation: The input string is "(()())(())(()(()))", with primitive decomposition "(()())" + "(())" + "(()(()))". After removing outer parentheses of each part, this is "()()" + "()" + "()(())" = "()()()()(())". Example 3: Input: "()()" Output: "" Explanation: The input string is "()()", with primitive decomposition "()" + "()". After removing outer parentheses of each part, this is "" + "" = "". Note: 1. S.length <= 10000 2. S[i] is "(" or ")" 3. S is a valid parentheses string """ class Solution: def removeOuterParentheses(self, S: str) -> str: res, stack = [], 0 for s in S: if s == '(': if stack > 0: res.append(s) stack += 1 else: stack -= 1 if stack > 0: res.append(s) return ''.join(res)
""" A valid parentheses string is either empty (""), "(" + A + ")", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", "()", "(())()", and "(()(()))" are all valid parentheses strings. A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings. Given a valid parentheses string S, consider its primitive decomposition: S = P_1 + P_2 + ... + P_k, where P_i are primitive valid parentheses strings. Return S after removing the outermost parentheses of every primitive string in the primitive decomposition of S. Example 1: Input: "(()())(())" Output: "()()()" Explanation: The input string is "(()())(())", with primitive decomposition "(()())" + "(())". After removing outer parentheses of each part, this is "()()" + "()" = "()()()". Example 2: Input: "(()())(())(()(()))" Output: "()()()()(())" Explanation: The input string is "(()())(())(()(()))", with primitive decomposition "(()())" + "(())" + "(()(()))". After removing outer parentheses of each part, this is "()()" + "()" + "()(())" = "()()()()(())". Example 3: Input: "()()" Output: "" Explanation: The input string is "()()", with primitive decomposition "()" + "()". After removing outer parentheses of each part, this is "" + "" = "". Note: 1. S.length <= 10000 2. S[i] is "(" or ")" 3. S is a valid parentheses string """ class Solution: def remove_outer_parentheses(self, S: str) -> str: (res, stack) = ([], 0) for s in S: if s == '(': if stack > 0: res.append(s) stack += 1 else: stack -= 1 if stack > 0: res.append(s) return ''.join(res)
# List Operations and Functions # '+' Operator print('-----------+ Operator------------') a = [1,2,3] b = [4,5,6] c = a + b print(c) print('----------* Operator--------------') # '*' Operator a1 = a * 2 print(a1) print('--------len function----------------') print(len(a)) print('--------max function----------------') print(max(a)) print('--------min function----------------') print(min(a)) print('--------sum function----------------') print(sum(a)) print("----------Average--------------") mylist = [] while(True): value = (input("Enter the number: ")) if value == 'done': break value = float(value) mylist.append(value) average = sum(mylist)/len(mylist) print("Average : ", average) # Strings and Lists print("----------Strings to Lists split function--------------") mystring = 'Sagar Sanjeev Potnis' print(mystring) newlist = mystring.split() print(newlist) mystring1 = 'Sagar-Sanjeev-Potnis' print(mystring1) newlist1 = mystring1.split('-') print(newlist1) print("---------- List to String join function--------------") joinstring = " ".join(newlist) print(joinstring) print("----------map function--------------") print("Please Enter list :") maplist = list(map(int, input().split())) print(maplist) print("----------Pitfalls and how to avoid them--------------") pitylist = [5,4,3,2,1] pitylist = sorted(pitylist) print(pitylist) # Sorted function does not modify original list unline sort fucntion!!! so it is better
print('-----------+ Operator------------') a = [1, 2, 3] b = [4, 5, 6] c = a + b print(c) print('----------* Operator--------------') a1 = a * 2 print(a1) print('--------len function----------------') print(len(a)) print('--------max function----------------') print(max(a)) print('--------min function----------------') print(min(a)) print('--------sum function----------------') print(sum(a)) print('----------Average--------------') mylist = [] while True: value = input('Enter the number: ') if value == 'done': break value = float(value) mylist.append(value) average = sum(mylist) / len(mylist) print('Average : ', average) print('----------Strings to Lists split function--------------') mystring = 'Sagar Sanjeev Potnis' print(mystring) newlist = mystring.split() print(newlist) mystring1 = 'Sagar-Sanjeev-Potnis' print(mystring1) newlist1 = mystring1.split('-') print(newlist1) print('---------- List to String join function--------------') joinstring = ' '.join(newlist) print(joinstring) print('----------map function--------------') print('Please Enter list :') maplist = list(map(int, input().split())) print(maplist) print('----------Pitfalls and how to avoid them--------------') pitylist = [5, 4, 3, 2, 1] pitylist = sorted(pitylist) print(pitylist)
{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "9de928d7", "metadata": {}, "outputs": [], "source": [ "import os\n", "import csv\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "id": "8f1478f8", "metadata": {}, "outputs": [], "source": [ "#Set Path\n", "pollCSV = os.path.join('Resources', 'election_data.CSV')\n", "pollCSV = r'C:\\Users\\rzh00\\Documents\\gt-virt-atl-data-pt-09-2021-u-c-master\\02-Homework\\03-Python\\Instructions\\PyPoll\\Resources\\election_data.csv'" ] }, { "cell_type": "code", "execution_count": 3, "id": "0f207e3c", "metadata": {}, "outputs": [], "source": [ "#Varibales\n", "candi = []\n", "vote_count = []\n", "vote_percent = []\n", "\n", "num_vote = 0" ] }, { "cell_type": "code", "execution_count": 7, "id": "08423af7", "metadata": {}, "outputs": [], "source": [ "#Open CSV\n", "with open(pollCSV) as csvfile:\n", " csvreader = csv.reader(csvfile, delimiter = ',')\n", " csvheader = next(csvreader)\n", " for row in csvreader: \n", " num_vote = num_vote + 1 # total votes\n", " candi_name = row[2] # adding candidate name to array\n", " \n", " if candi_name not in candi: #conditional to append any new candidates \n", " candi.append(candi_name)\n", " index = candi.index(row[2])\n", " vote_count.append(1)\n", " else:\n", " index = candi.index(row[2])\n", " vote_count[index] += 1\n", " \n", " for i in vote_count: # find the percentage of the votes recieved\n", " percent = round((i/num_vote) * 100)\n", " percent = '%.3f%%' % percent\n", " vote_percent.append(percent)\n", " \n", " winner = max(vote_count) # determine winner and update the value\n", " index = vote_count.index(winner)\n", " candi_winner = candi[index]" ] }, { "cell_type": "code", "execution_count": 16, "id": "400521a2", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Election Results\n", "--------------------\n", "Total Votes[4436463, 1408401, 985880, 211260]\n", "--------------------\n", "Khan: 63.000% (4436463)\n", "Correy: 20.000% (1408401)\n", "Li: 14.000% (985880)\n", "O'Tooley: 3.000% (211260)\n", "--------------------\n", "Winning Candidate: 4436463\n" ] } ], "source": [ "#Print Results\n", "print('Election Results')\n", "print('-' * 20)\n", "print(f'Total Votes' + str(vote_count))\n", "print('-' * 20)\n", "for i in range(len(candi)):\n", " print(f'{candi[i]}: {str(vote_percent[i])} ({str(vote_count[i])})')\n", "print('-' * 20)\n", "print(f'Winning Candidate: {winner}')" ] }, { "cell_type": "code", "execution_count": 14, "id": "18e81981", "metadata": {}, "outputs": [], "source": [ "result = os.path.join('output', 'result.txt')\n", "result = r'C:\\Users\\rzh00\\Documents\\gt-virt-atl-data-pt-09-2021-u-c-master\\02-Homework\\03-Python\\Instructions\\PyPoll\\result.txt'\n", "\n", "with open(result, 'w') as txt:\n", " txt.write('Election Results')\n", " txt.write('-' * 20)\n", " txt.write(f'Total Votes' + str(vote_count))\n", " txt.write('-' * 20)\n", " for i in range(len(candi)):\n", " txt.write(f'{candi[i]}: {str(vote_percent[i])} ({str(vote_count[i])})')\n", " txt.write('-' * 20)\n", " txt.write(f'Winning Candidate: {winner}')\n", " txt.close()" ] }, { "cell_type": "code", "execution_count": null, "id": "c5893e30", "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.8" } }, "nbformat": 4, "nbformat_minor": 5 }
{'cells': [{'cell_type': 'code', 'execution_count': 1, 'id': '9de928d7', 'metadata': {}, 'outputs': [], 'source': ['import os\n', 'import csv\n', 'import pandas as pd']}, {'cell_type': 'code', 'execution_count': 2, 'id': '8f1478f8', 'metadata': {}, 'outputs': [], 'source': ['#Set Path\n', "pollCSV = os.path.join('Resources', 'election_data.CSV')\n", "pollCSV = r'C:\\Users\\rzh00\\Documents\\gt-virt-atl-data-pt-09-2021-u-c-master\\02-Homework\\03-Python\\Instructions\\PyPoll\\Resources\\election_data.csv'"]}, {'cell_type': 'code', 'execution_count': 3, 'id': '0f207e3c', 'metadata': {}, 'outputs': [], 'source': ['#Varibales\n', 'candi = []\n', 'vote_count = []\n', 'vote_percent = []\n', '\n', 'num_vote = 0']}, {'cell_type': 'code', 'execution_count': 7, 'id': '08423af7', 'metadata': {}, 'outputs': [], 'source': ['#Open CSV\n', 'with open(pollCSV) as csvfile:\n', " csvreader = csv.reader(csvfile, delimiter = ',')\n", ' csvheader = next(csvreader)\n', ' for row in csvreader: \n', ' num_vote = num_vote + 1 # total votes\n', ' candi_name = row[2] # adding candidate name to array\n', ' \n', ' if candi_name not in candi: #conditional to append any new candidates \n', ' candi.append(candi_name)\n', ' index = candi.index(row[2])\n', ' vote_count.append(1)\n', ' else:\n', ' index = candi.index(row[2])\n', ' vote_count[index] += 1\n', ' \n', ' for i in vote_count: # find the percentage of the votes recieved\n', ' percent = round((i/num_vote) * 100)\n', " percent = '%.3f%%' % percent\n", ' vote_percent.append(percent)\n', ' \n', ' winner = max(vote_count) # determine winner and update the value\n', ' index = vote_count.index(winner)\n', ' candi_winner = candi[index]']}, {'cell_type': 'code', 'execution_count': 16, 'id': '400521a2', 'metadata': {}, 'outputs': [{'name': 'stdout', 'output_type': 'stream', 'text': ['Election Results\n', '--------------------\n', 'Total Votes[4436463, 1408401, 985880, 211260]\n', '--------------------\n', 'Khan: 63.000% (4436463)\n', 'Correy: 20.000% (1408401)\n', 'Li: 14.000% (985880)\n', "O'Tooley: 3.000% (211260)\n", '--------------------\n', 'Winning Candidate: 4436463\n']}], 'source': ['#Print Results\n', "print('Election Results')\n", "print('-' * 20)\n", "print(f'Total Votes' + str(vote_count))\n", "print('-' * 20)\n", 'for i in range(len(candi)):\n', " print(f'{candi[i]}: {str(vote_percent[i])} ({str(vote_count[i])})')\n", "print('-' * 20)\n", "print(f'Winning Candidate: {winner}')"]}, {'cell_type': 'code', 'execution_count': 14, 'id': '18e81981', 'metadata': {}, 'outputs': [], 'source': ["result = os.path.join('output', 'result.txt')\n", "result = r'C:\\Users\\rzh00\\Documents\\gt-virt-atl-data-pt-09-2021-u-c-master\\02-Homework\\03-Python\\Instructions\\PyPoll\\result.txt'\n", '\n', "with open(result, 'w') as txt:\n", " txt.write('Election Results')\n", " txt.write('-' * 20)\n", " txt.write(f'Total Votes' + str(vote_count))\n", " txt.write('-' * 20)\n", ' for i in range(len(candi)):\n', " txt.write(f'{candi[i]}: {str(vote_percent[i])} ({str(vote_count[i])})')\n", " txt.write('-' * 20)\n", " txt.write(f'Winning Candidate: {winner}')\n", ' txt.close()']}, {'cell_type': 'code', 'execution_count': null, 'id': 'c5893e30', 'metadata': {}, 'outputs': [], 'source': []}], 'metadata': {'kernelspec': {'display_name': 'Python 3', 'language': 'python', 'name': 'python3'}, 'language_info': {'codemirror_mode': {'name': 'ipython', 'version': 3}, 'file_extension': '.py', 'mimetype': 'text/x-python', 'name': 'python', 'nbconvert_exporter': 'python', 'pygments_lexer': 'ipython3', 'version': '3.8.8'}}, 'nbformat': 4, 'nbformat_minor': 5}
""" A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? ![Sample Grid](http://leetcode.com/wp-content/uploads/2014/12/robot_maze.png) Above is a 3 x 7 grid. How many possible unique paths are there? Note: m and n will be at most 100. """ class Solution(object): def uniquePaths(self, m, n): """ :type m: int :type n: int :rtype: int """ if m == 0 or n == 0: return 0 grid = [[0 for j in range(m)] for i in range(n)] for i in range(n): for j in range(m): if i == 0 or j == 0: grid[i][j] = 1 else: grid[i][j] = grid[i - 1][j] + grid[i][j - 1] return grid[-1][-1]
""" A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? ![Sample Grid](http://leetcode.com/wp-content/uploads/2014/12/robot_maze.png) Above is a 3 x 7 grid. How many possible unique paths are there? Note: m and n will be at most 100. """ class Solution(object): def unique_paths(self, m, n): """ :type m: int :type n: int :rtype: int """ if m == 0 or n == 0: return 0 grid = [[0 for j in range(m)] for i in range(n)] for i in range(n): for j in range(m): if i == 0 or j == 0: grid[i][j] = 1 else: grid[i][j] = grid[i - 1][j] + grid[i][j - 1] return grid[-1][-1]
text = input().split(' ') new_text = '' for word in text: if len(word) > 4: if word[:2] in word[2:]: word = word[2:] new_text += ' ' + word print(new_text[1:])
text = input().split(' ') new_text = '' for word in text: if len(word) > 4: if word[:2] in word[2:]: word = word[2:] new_text += ' ' + word print(new_text[1:])
class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: if len(strs) == 0: return "" resLen = 0 while True: if len(strs[0]) == resLen: return strs[0] curChar = strs[0][resLen] for i in range(1, len(strs)): if len(strs[i]) == resLen or strs[i][resLen] != curChar: return strs[0][: resLen] resLen += 1 return strs[0][: resLen]
class Solution: def longest_common_prefix(self, strs: List[str]) -> str: if len(strs) == 0: return '' res_len = 0 while True: if len(strs[0]) == resLen: return strs[0] cur_char = strs[0][resLen] for i in range(1, len(strs)): if len(strs[i]) == resLen or strs[i][resLen] != curChar: return strs[0][:resLen] res_len += 1 return strs[0][:resLen]
#!python3 # -*- coding:utf-8 -*- ''' this code is a sample of code for learn how to use python test modules. ''' def aaa(): ''' printing tree ! mark. ''' print("!!!") def bbb(): ''' printing tree chars. ''' print("BBB") def ccc(): ''' printing number with loop. ''' for i in range(5): print(i)
""" this code is a sample of code for learn how to use python test modules. """ def aaa(): """ printing tree ! mark. """ print('!!!') def bbb(): """ printing tree chars. """ print('BBB') def ccc(): """ printing number with loop. """ for i in range(5): print(i)
# Project Framework default is 1 (Model/View/Provider) # src is source where is the lib folder located def startmain(src="flutterproject/myapp/lib", pkg="Provider", file="app_widget", home="", project_framework=1, autoconfigfile=True): maindart = open(src + "/main.dart", "w") if project_framework == 1: maindart.write( "import 'package:flutter/material.dart';\n" "import '" + pkg + "/" + file + ".dart';\n\n" "void main() => runApp(AppWidget());") else: print("This project framework is not avaliable yet. :(") maindart.close() if autoconfigfile: configfile(home, src, pkg, file) # Its not recomended use this manually def configfile(home, src, pkg, file): app_widgetdart = open(src+"/"+pkg+"/"+file+".dart", "w") if home == "": app_widgetdart.write("import 'package:flutter/material.dart';\n\n" "class AppWidget extends StatelessWidget {\n" " @override\n" " Widget build(BuildContext context) {\n" " return MaterialApp();\n" " }\n" "}") else: app_widgetdart.write("import 'package:flutter/material.dart';\n" "import '../View/Screens/homepage.dart';\n\n" "class AppWidget extends StatelessWidget {\n" " @override\n" " Widget build(BuildContext context) {\n" " return MaterialApp(\n" " home:" + home + "(),\n" " );\n" " }\n" "}") app_widgetdart.close()
def startmain(src='flutterproject/myapp/lib', pkg='Provider', file='app_widget', home='', project_framework=1, autoconfigfile=True): maindart = open(src + '/main.dart', 'w') if project_framework == 1: maindart.write("import 'package:flutter/material.dart';\nimport '" + pkg + '/' + file + ".dart';\n\nvoid main() => runApp(AppWidget());") else: print('This project framework is not avaliable yet. :(') maindart.close() if autoconfigfile: configfile(home, src, pkg, file) def configfile(home, src, pkg, file): app_widgetdart = open(src + '/' + pkg + '/' + file + '.dart', 'w') if home == '': app_widgetdart.write("import 'package:flutter/material.dart';\n\nclass AppWidget extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp();\n }\n}") else: app_widgetdart.write("import 'package:flutter/material.dart';\nimport '../View/Screens/homepage.dart';\n\nclass AppWidget extends StatelessWidget {\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home:" + home + '(),\n );\n }\n}') app_widgetdart.close()
def max_consecutive_ones(x): # e.g. x= 95 (1101111) """ Steps 1. x & x<<1 --> 1101111 & 1011110 == 1001110 2. x & x<<1 --> 1001110 & 0011100 == 0001100 3. x & x<<1 --> 0001100 & 0011000 == 0001000 4. x & x<<1 --> 0001000 & 0010000 == 0000000 :param x: :return: """ count = 0 while x > 0: x = x & (x << 1) count += 1 return count if __name__ == '__main__': print(max_consecutive_ones(7))
def max_consecutive_ones(x): """ Steps 1. x & x<<1 --> 1101111 & 1011110 == 1001110 2. x & x<<1 --> 1001110 & 0011100 == 0001100 3. x & x<<1 --> 0001100 & 0011000 == 0001000 4. x & x<<1 --> 0001000 & 0010000 == 0000000 :param x: :return: """ count = 0 while x > 0: x = x & x << 1 count += 1 return count if __name__ == '__main__': print(max_consecutive_ones(7))
# Avg week temperature print("Enter temperatures of 7 days:") a = float(input()) b = float(input()) c = float(input()) d = float(input()) e = float(input()) f = float(input()) g = float(input()) print("Average temperature:", (a+b+c+d+e+f+g)/7)
print('Enter temperatures of 7 days:') a = float(input()) b = float(input()) c = float(input()) d = float(input()) e = float(input()) f = float(input()) g = float(input()) print('Average temperature:', (a + b + c + d + e + f + g) / 7)
def digitSum(n,step): res=0 while(n>0): res+=n%10 n=n//10 step+=1 if(res<=9): return (res,step) else: return digitSum(res,step) t=int(input()) for _ in range(t): minstep=[99999999 for i in range(10)] #cache hitratio=[0 for i in range(10)] maxhit=0 n,d=[int(x) for x in input().strip().split()] if(n==1): print("{0} {1}".format(n,0)) continue if(d>9): d=digitSum(d,0)[0] #minimize it to single digit steps=0 if(n>9): n,steps=digitSum(n,steps) minstep[n]=min(minstep[n],steps) minstep[n]=min(minstep[n],steps) hitratio[n]+=1 maxhit=max(maxhit,hitratio[n]) if(n==1): print("{0} {1}".format(n,steps)) continue iteration=1 while(n!=1 and iteration<(10**8)): iteration+=1 #print(minstep) n=n+d steps+=1 if(n<10): minstep[n] = min(minstep[n],steps) hitratio[n]+=1 maxhit=max(maxhit,hitratio[n]) if(n>9): n,steps=digitSum(n,steps) minstep[n] = min(minstep[n],steps) hitratio[n]+=1 maxhit=max(maxhit,hitratio[n]) if(maxhit>100): break tempmin=10 for i in range(2,10): if(minstep[i]!=99999999 and i<tempmin): tempmin=i print("{0} {1}".format(tempmin,minstep[tempmin]))
def digit_sum(n, step): res = 0 while n > 0: res += n % 10 n = n // 10 step += 1 if res <= 9: return (res, step) else: return digit_sum(res, step) t = int(input()) for _ in range(t): minstep = [99999999 for i in range(10)] hitratio = [0 for i in range(10)] maxhit = 0 (n, d) = [int(x) for x in input().strip().split()] if n == 1: print('{0} {1}'.format(n, 0)) continue if d > 9: d = digit_sum(d, 0)[0] steps = 0 if n > 9: (n, steps) = digit_sum(n, steps) minstep[n] = min(minstep[n], steps) minstep[n] = min(minstep[n], steps) hitratio[n] += 1 maxhit = max(maxhit, hitratio[n]) if n == 1: print('{0} {1}'.format(n, steps)) continue iteration = 1 while n != 1 and iteration < 10 ** 8: iteration += 1 n = n + d steps += 1 if n < 10: minstep[n] = min(minstep[n], steps) hitratio[n] += 1 maxhit = max(maxhit, hitratio[n]) if n > 9: (n, steps) = digit_sum(n, steps) minstep[n] = min(minstep[n], steps) hitratio[n] += 1 maxhit = max(maxhit, hitratio[n]) if maxhit > 100: break tempmin = 10 for i in range(2, 10): if minstep[i] != 99999999 and i < tempmin: tempmin = i print('{0} {1}'.format(tempmin, minstep[tempmin]))
###################################################### # # # author # # Parth Lathiya # # https://www.cse.iitb.ac.in/~parthiitb/ # # # ###################################################### at = int(input().strip()) for att in range(at): u = list(map(int, input().strip().split())) u.remove(len(u)-1) print(max(u))
at = int(input().strip()) for att in range(at): u = list(map(int, input().strip().split())) u.remove(len(u) - 1) print(max(u))
# 15/15 num_of_flicks = int(input()) art = [] for _ in range(num_of_flicks): coords = input().split(",") art.append((int(coords[0]), int(coords[1]))) lowest_x = min(art, key=lambda x: x[0])[0] - 1 lowest_y = min(art, key=lambda x: x[1])[1] - 1 highest_x = max(art, key=lambda x: x[0])[0] + 1 highest_y = max(art, key=lambda x: x[1])[1] + 1 print(f"{lowest_x},{lowest_y}") print(f"{highest_x},{highest_y}")
num_of_flicks = int(input()) art = [] for _ in range(num_of_flicks): coords = input().split(',') art.append((int(coords[0]), int(coords[1]))) lowest_x = min(art, key=lambda x: x[0])[0] - 1 lowest_y = min(art, key=lambda x: x[1])[1] - 1 highest_x = max(art, key=lambda x: x[0])[0] + 1 highest_y = max(art, key=lambda x: x[1])[1] + 1 print(f'{lowest_x},{lowest_y}') print(f'{highest_x},{highest_y}')
print("Leap Year Range Calculator: ") year1=int(input("Enter First Year: ")) year2 = int(input("Enter Last Year: ")) while year1<=year2: if year1 % 4 == 0 : print(year1,"is a leap year") year1= year1 + 1
print('Leap Year Range Calculator: ') year1 = int(input('Enter First Year: ')) year2 = int(input('Enter Last Year: ')) while year1 <= year2: if year1 % 4 == 0: print(year1, 'is a leap year') year1 = year1 + 1
I = lambda : int(input()) LI = lambda : [int(x) for x in input().split()] MI = lambda : map(int, input().split()) SI = lambda : input() """ #Leer de archivo for line in sys.stdin: ... """ """ def fastio(): import sys from io import StringIO from atexit import register global input sys.stdin = StringIO(sys.stdin.read()) input = lambda : sys.stdin.readline().rstrip() sys.stdout = StringIO() register(lambda : sys.__stdout__.write(sys.stdout.getvalue())) fastio() """ class PointSystem: def oddsOfWinning(self, pointsToWin, pointsToWinBy, skill): n = 1000 p = [[0 for i in range(n)] for j in range(n)] p[0][0] = 1 for i in range(n-1): for j in range(n-1): if(max(i, j) >= pointsToWin and max(i, j) - min(i, j) >= pointsToWinBy): continue p[i+1][j] += p[i][j] * skill/100.0 p[i][j+1] += p[i][j] * (100-skill)/100.0 ans = 0.0 for i in range(n): for j in range(n): if(i > j and i >= pointsToWin and i - j >= pointsToWinBy): ans += p[i][j] return ans # x = PointSystem() # print(x.oddsOfWinning(2, 1, 40)) # print(x.oddsOfWinning(4, 5, 50)) # print(x.oddsOfWinning(3, 3, 25))
i = lambda : int(input()) li = lambda : [int(x) for x in input().split()] mi = lambda : map(int, input().split()) si = lambda : input() '\n#Leer de archivo\nfor line in sys.stdin:\n ...\n' '\ndef fastio():\n import sys\n from io import StringIO\n from atexit import register\n global input\n sys.stdin = StringIO(sys.stdin.read())\n input = lambda : sys.stdin.readline().rstrip()\n sys.stdout = StringIO()\n register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))\n\nfastio()\n' class Pointsystem: def odds_of_winning(self, pointsToWin, pointsToWinBy, skill): n = 1000 p = [[0 for i in range(n)] for j in range(n)] p[0][0] = 1 for i in range(n - 1): for j in range(n - 1): if max(i, j) >= pointsToWin and max(i, j) - min(i, j) >= pointsToWinBy: continue p[i + 1][j] += p[i][j] * skill / 100.0 p[i][j + 1] += p[i][j] * (100 - skill) / 100.0 ans = 0.0 for i in range(n): for j in range(n): if i > j and i >= pointsToWin and (i - j >= pointsToWinBy): ans += p[i][j] return ans
""" Generator with a finite loop can be used with for """ def count(): n = 1 while n < 1000: yield n n *= 2 gen = count() for number in gen: print(number)
""" Generator with a finite loop can be used with for """ def count(): n = 1 while n < 1000: yield n n *= 2 gen = count() for number in gen: print(number)
""" Constants to be used in the module """ __author__ = 'Santiago Flores Kanter (sfloresk@cisco.com)' QUERY_TARGET_CHILDREN = 'children' QUERY_TARGET_SELF = 'self' QUERY_TARGET_SUBTREE = 'subtree' API_URL = 'api/' MQ_API2_URL = 'mqapi2/'
""" Constants to be used in the module """ __author__ = 'Santiago Flores Kanter (sfloresk@cisco.com)' query_target_children = 'children' query_target_self = 'self' query_target_subtree = 'subtree' api_url = 'api/' mq_api2_url = 'mqapi2/'
#!/usr/bin/env python """ File: pentagon_p_solution-garid.py Find the perimeter of pentagon. """ __author__ = "Ochirgarid Chinzorig (Ochirgarid)" __version__ = "1.0" # Open file on read mode inp = open("../test/test1.txt", "r") # read input lines one by one # and convert them to integer a = int(inp.readline().strip()) b = int(inp.readline().strip()) c = int(inp.readline().strip()) d = int(inp.readline().strip()) e = int(inp.readline().strip()) # must close opened file inp.close() # calculate perimeter p = a + b + c + d + e # print for std out print("Perimeter : {}".format(p))
""" File: pentagon_p_solution-garid.py Find the perimeter of pentagon. """ __author__ = 'Ochirgarid Chinzorig (Ochirgarid)' __version__ = '1.0' inp = open('../test/test1.txt', 'r') a = int(inp.readline().strip()) b = int(inp.readline().strip()) c = int(inp.readline().strip()) d = int(inp.readline().strip()) e = int(inp.readline().strip()) inp.close() p = a + b + c + d + e print('Perimeter : {}'.format(p))
# # PySNMP MIB module MITEL-IPVIRTUAL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MITEL-IPVIRTUAL-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:03:05 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint", "ValueSizeConstraint") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") IpAddress, iso, Unsigned32, Counter64, TimeTicks, Bits, enterprises, ModuleIdentity, Gauge32, ObjectIdentity, Integer32, NotificationType, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "iso", "Unsigned32", "Counter64", "TimeTicks", "Bits", "enterprises", "ModuleIdentity", "Gauge32", "ObjectIdentity", "Integer32", "NotificationType", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32") RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TextualConvention") mitelIpGrpIpVirtualGroup = ModuleIdentity((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4)) mitelIpGrpIpVirtualGroup.setRevisions(('2003-03-24 09:31', '1999-03-01 00:00',)) if mibBuilder.loadTexts: mitelIpGrpIpVirtualGroup.setLastUpdated('200303240931Z') if mibBuilder.loadTexts: mitelIpGrpIpVirtualGroup.setOrganization('MITEL Corporation') mitel = MibIdentifier((1, 3, 6, 1, 4, 1, 1027)) mitelProprietary = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4)) mitelPropIpNetworking = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8)) mitelIpNetRouter = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1)) mitelRouterIpGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1)) mitelIpVGrpPortTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1), ) if mibBuilder.loadTexts: mitelIpVGrpPortTable.setStatus('current') mitelIpVGrpPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1), ).setIndexNames((0, "MITEL-IPVIRTUAL-MIB", "mitelIpVGrpPortTableNetAddr"), (0, "MITEL-IPVIRTUAL-MIB", "mitelIpVGrpPortTableIfIndex")) if mibBuilder.loadTexts: mitelIpVGrpPortEntry.setStatus('current') mitelIpVGrpPortTableNetAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpPortTableNetAddr.setStatus('current') mitelIpVGrpPortTableNetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 2), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelIpVGrpPortTableNetMask.setStatus('current') mitelIpVGrpPortTableIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 11), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpPortTableIfIndex.setStatus('current') mitelIpVGrpPortTableStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 12), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelIpVGrpPortTableStatus.setStatus('current') mitelIpVGrpPortTableCfgMethod = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("static", 1), ("addressless", 2), ("dhcp", 3), ("ipcp", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelIpVGrpPortTableCfgMethod.setStatus('current') mitelIpVGrpRipTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2), ) if mibBuilder.loadTexts: mitelIpVGrpRipTable.setStatus('current') mitelIpVGrpRipEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1), ).setIndexNames((0, "MITEL-IPVIRTUAL-MIB", "mitelIpVGrpTableRipIpAddr")) if mibBuilder.loadTexts: mitelIpVGrpRipEntry.setStatus('current') mitelIpVGrpTableRipIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpTableRipIpAddr.setStatus('current') mitelIpVGrpTableRipRxPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpTableRipRxPkts.setStatus('current') mitelIpVGrpTableRipRxBadPkts = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpTableRipRxBadPkts.setStatus('current') mitelIpVGrpTableRipRxBadRtes = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpTableRipRxBadRtes.setStatus('current') mitelIpVGrpTableRipTxUpdates = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelIpVGrpTableRipTxUpdates.setStatus('current') mibBuilder.exportSymbols("MITEL-IPVIRTUAL-MIB", mitelIpVGrpTableRipRxBadRtes=mitelIpVGrpTableRipRxBadRtes, mitel=mitel, mitelIpVGrpRipTable=mitelIpVGrpRipTable, mitelIpVGrpPortTableNetMask=mitelIpVGrpPortTableNetMask, mitelIpVGrpPortTableStatus=mitelIpVGrpPortTableStatus, mitelIpGrpIpVirtualGroup=mitelIpGrpIpVirtualGroup, mitelIpVGrpPortTable=mitelIpVGrpPortTable, mitelIpVGrpTableRipIpAddr=mitelIpVGrpTableRipIpAddr, mitelIpNetRouter=mitelIpNetRouter, PYSNMP_MODULE_ID=mitelIpGrpIpVirtualGroup, mitelIpVGrpPortEntry=mitelIpVGrpPortEntry, mitelIpVGrpPortTableIfIndex=mitelIpVGrpPortTableIfIndex, mitelProprietary=mitelProprietary, mitelPropIpNetworking=mitelPropIpNetworking, mitelIpVGrpTableRipRxPkts=mitelIpVGrpTableRipRxPkts, mitelIpVGrpRipEntry=mitelIpVGrpRipEntry, mitelIpVGrpTableRipRxBadPkts=mitelIpVGrpTableRipRxBadPkts, mitelRouterIpGroup=mitelRouterIpGroup, mitelIpVGrpPortTableCfgMethod=mitelIpVGrpPortTableCfgMethod, mitelIpVGrpTableRipTxUpdates=mitelIpVGrpTableRipTxUpdates, mitelIpVGrpPortTableNetAddr=mitelIpVGrpPortTableNetAddr)
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ValueSizeConstraint') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (ip_address, iso, unsigned32, counter64, time_ticks, bits, enterprises, module_identity, gauge32, object_identity, integer32, notification_type, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'iso', 'Unsigned32', 'Counter64', 'TimeTicks', 'Bits', 'enterprises', 'ModuleIdentity', 'Gauge32', 'ObjectIdentity', 'Integer32', 'NotificationType', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32') (row_status, display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'DisplayString', 'TextualConvention') mitel_ip_grp_ip_virtual_group = module_identity((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4)) mitelIpGrpIpVirtualGroup.setRevisions(('2003-03-24 09:31', '1999-03-01 00:00')) if mibBuilder.loadTexts: mitelIpGrpIpVirtualGroup.setLastUpdated('200303240931Z') if mibBuilder.loadTexts: mitelIpGrpIpVirtualGroup.setOrganization('MITEL Corporation') mitel = mib_identifier((1, 3, 6, 1, 4, 1, 1027)) mitel_proprietary = mib_identifier((1, 3, 6, 1, 4, 1, 1027, 4)) mitel_prop_ip_networking = mib_identifier((1, 3, 6, 1, 4, 1, 1027, 4, 8)) mitel_ip_net_router = mib_identifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1)) mitel_router_ip_group = mib_identifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1)) mitel_ip_v_grp_port_table = mib_table((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1)) if mibBuilder.loadTexts: mitelIpVGrpPortTable.setStatus('current') mitel_ip_v_grp_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1)).setIndexNames((0, 'MITEL-IPVIRTUAL-MIB', 'mitelIpVGrpPortTableNetAddr'), (0, 'MITEL-IPVIRTUAL-MIB', 'mitelIpVGrpPortTableIfIndex')) if mibBuilder.loadTexts: mitelIpVGrpPortEntry.setStatus('current') mitel_ip_v_grp_port_table_net_addr = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpPortTableNetAddr.setStatus('current') mitel_ip_v_grp_port_table_net_mask = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 2), ip_address()).setMaxAccess('readwrite') if mibBuilder.loadTexts: mitelIpVGrpPortTableNetMask.setStatus('current') mitel_ip_v_grp_port_table_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 11), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpPortTableIfIndex.setStatus('current') mitel_ip_v_grp_port_table_status = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 12), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: mitelIpVGrpPortTableStatus.setStatus('current') mitel_ip_v_grp_port_table_cfg_method = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 1, 1, 15), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('static', 1), ('addressless', 2), ('dhcp', 3), ('ipcp', 4)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: mitelIpVGrpPortTableCfgMethod.setStatus('current') mitel_ip_v_grp_rip_table = mib_table((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2)) if mibBuilder.loadTexts: mitelIpVGrpRipTable.setStatus('current') mitel_ip_v_grp_rip_entry = mib_table_row((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1)).setIndexNames((0, 'MITEL-IPVIRTUAL-MIB', 'mitelIpVGrpTableRipIpAddr')) if mibBuilder.loadTexts: mitelIpVGrpRipEntry.setStatus('current') mitel_ip_v_grp_table_rip_ip_addr = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpTableRipIpAddr.setStatus('current') mitel_ip_v_grp_table_rip_rx_pkts = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 2), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpTableRipRxPkts.setStatus('current') mitel_ip_v_grp_table_rip_rx_bad_pkts = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 3), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpTableRipRxBadPkts.setStatus('current') mitel_ip_v_grp_table_rip_rx_bad_rtes = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 4), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpTableRipRxBadRtes.setStatus('current') mitel_ip_v_grp_table_rip_tx_updates = mib_table_column((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 1, 4, 2, 1, 5), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mitelIpVGrpTableRipTxUpdates.setStatus('current') mibBuilder.exportSymbols('MITEL-IPVIRTUAL-MIB', mitelIpVGrpTableRipRxBadRtes=mitelIpVGrpTableRipRxBadRtes, mitel=mitel, mitelIpVGrpRipTable=mitelIpVGrpRipTable, mitelIpVGrpPortTableNetMask=mitelIpVGrpPortTableNetMask, mitelIpVGrpPortTableStatus=mitelIpVGrpPortTableStatus, mitelIpGrpIpVirtualGroup=mitelIpGrpIpVirtualGroup, mitelIpVGrpPortTable=mitelIpVGrpPortTable, mitelIpVGrpTableRipIpAddr=mitelIpVGrpTableRipIpAddr, mitelIpNetRouter=mitelIpNetRouter, PYSNMP_MODULE_ID=mitelIpGrpIpVirtualGroup, mitelIpVGrpPortEntry=mitelIpVGrpPortEntry, mitelIpVGrpPortTableIfIndex=mitelIpVGrpPortTableIfIndex, mitelProprietary=mitelProprietary, mitelPropIpNetworking=mitelPropIpNetworking, mitelIpVGrpTableRipRxPkts=mitelIpVGrpTableRipRxPkts, mitelIpVGrpRipEntry=mitelIpVGrpRipEntry, mitelIpVGrpTableRipRxBadPkts=mitelIpVGrpTableRipRxBadPkts, mitelRouterIpGroup=mitelRouterIpGroup, mitelIpVGrpPortTableCfgMethod=mitelIpVGrpPortTableCfgMethod, mitelIpVGrpTableRipTxUpdates=mitelIpVGrpTableRipTxUpdates, mitelIpVGrpPortTableNetAddr=mitelIpVGrpPortTableNetAddr)
def Reverse(Dna): tt = { 'A' : 'T', 'T' : 'A', 'G' : 'C', 'C' : 'G', } ans = '' for a in Dna: ans += tt[a] return ans[::-1] def main(infile, outfile): # Read the input, but do something non-trivial instead of count the lines in the file inp = lines = [line.rstrip('\n') for line in infile] print(inp) output = str(Reverse(inp[0])) # For debugging, print something to console print(output) # Write the output. outfile.write(output)
def reverse(Dna): tt = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'} ans = '' for a in Dna: ans += tt[a] return ans[::-1] def main(infile, outfile): inp = lines = [line.rstrip('\n') for line in infile] print(inp) output = str(reverse(inp[0])) print(output) outfile.write(output)
# configuracoes pessoais PERSONAL_NAME = 'YOU' # configuracoes de email EMAIL = 'your gmail account' PASSWORD = 'your gmail PASSWORD' RECEIVER_EMAIL = 'email to forward the contact messages' # configuracoes do Google ReCaptha SECRET_KEY = "Google ReCaptha's Secret key" SITE_KEY = "Google ReCaptha's Site key" APP_SECRET_KEY = '65#9DMN_T' SKILLS = [ { 'name': 'Quick learner', 'strength': '90%' }, { 'name': 'Flask', 'strength': '70%' }, { 'name': 'Javascript', 'strength': '50%' }, { 'name': 'Unit Test', 'strength': '30%' } ] EXPERINCES = [ { 'name': 'Intership', 'company': 'Stark Industries', 'location': 'New York City', 'working_period': 'May 2014 - June 2016', 'job_description': 'Developed tests for Mark IV, also designed some helmets for Mr. Stark.' }, { 'name': 'Developer', 'company': 'Matrix', 'location': 'New York City', 'working_period': 'June 2016 - Currently', 'job_description': 'Created the main training prograns for martial arts.' } ] EDUCATION = [ { 'name': 'Bachelor of Computer Science', 'institution': 'University of Brasil', 'location': 'Brasil', 'graduation_year': '2016' # 'extra_information': None } ] OBJECTIVE = 'Python developer'
personal_name = 'YOU' email = 'your gmail account' password = 'your gmail PASSWORD' receiver_email = 'email to forward the contact messages' secret_key = "Google ReCaptha's Secret key" site_key = "Google ReCaptha's Site key" app_secret_key = '65#9DMN_T' skills = [{'name': 'Quick learner', 'strength': '90%'}, {'name': 'Flask', 'strength': '70%'}, {'name': 'Javascript', 'strength': '50%'}, {'name': 'Unit Test', 'strength': '30%'}] experinces = [{'name': 'Intership', 'company': 'Stark Industries', 'location': 'New York City', 'working_period': 'May 2014 - June 2016', 'job_description': 'Developed tests for Mark IV, also designed some helmets for Mr. Stark.'}, {'name': 'Developer', 'company': 'Matrix', 'location': 'New York City', 'working_period': 'June 2016 - Currently', 'job_description': 'Created the main training prograns for martial arts.'}] education = [{'name': 'Bachelor of Computer Science', 'institution': 'University of Brasil', 'location': 'Brasil', 'graduation_year': '2016'}] objective = 'Python developer'
"""Data set for text records. A Dataset maintains the collection of data instances and metadata associated with the dataset. """ class Dataset(object): """Data set for text records. A Dataset maintains the collection of data instances and metadata associated with the dataset. Parameters ------- id : uuid Unique identifier for a dataset in a TextStudio project. loader : text_studio.DataLoader The DataLoader object responsible for loading the data from an external source and/or writing the data set to an external location. file_path : string The file path points to the location of the data set. Attributes ------- instances : list of dicts Collection of data instances contained in the dataset. loaded : bool True if all data instances in the dataset have been loaded into the dataset. Data instances are not loaded from disk or an external location until needed. Methods ------- load(self, **kwargs): Load the dataset using the Dataset's loader. save(self, **kwargs): Save the dataset using the Dataset's loader. """ def __init__(self, id, loader=None, file_path=""): self.id = id self.loader = loader self.file_path = file_path self.instances = [] self.loaded = False def load(self, **kwargs): """Load the dataset using the Dataset's loader. Load the data set from its stored location, populating the data instances collection. Set the loaded flag to True if the instances were retrieved successfully. Parameters ---------- **kwargs : dictionary Keyword arguments passed to the DataLoader to configure its settings for loading the dataset. """ if self.loader and self.file_path: with open(self.file_path, "r") as file: self.instances = self.loader.load(file, **kwargs) self.loaded = True def save(self, **kwargs): """Save the dataset using the Dataset's loader. Save the data set in its current state to a storage location. Parameters ---------- **kwargs : dictionary Keyword arguments passed to the DataLoader to configure its settings for writing the dataset. """ if self.loader and self.file_path: with open(self.file_path, "w") as file: self.loader.save(self.instances, file, **kwargs)
"""Data set for text records. A Dataset maintains the collection of data instances and metadata associated with the dataset. """ class Dataset(object): """Data set for text records. A Dataset maintains the collection of data instances and metadata associated with the dataset. Parameters ------- id : uuid Unique identifier for a dataset in a TextStudio project. loader : text_studio.DataLoader The DataLoader object responsible for loading the data from an external source and/or writing the data set to an external location. file_path : string The file path points to the location of the data set. Attributes ------- instances : list of dicts Collection of data instances contained in the dataset. loaded : bool True if all data instances in the dataset have been loaded into the dataset. Data instances are not loaded from disk or an external location until needed. Methods ------- load(self, **kwargs): Load the dataset using the Dataset's loader. save(self, **kwargs): Save the dataset using the Dataset's loader. """ def __init__(self, id, loader=None, file_path=''): self.id = id self.loader = loader self.file_path = file_path self.instances = [] self.loaded = False def load(self, **kwargs): """Load the dataset using the Dataset's loader. Load the data set from its stored location, populating the data instances collection. Set the loaded flag to True if the instances were retrieved successfully. Parameters ---------- **kwargs : dictionary Keyword arguments passed to the DataLoader to configure its settings for loading the dataset. """ if self.loader and self.file_path: with open(self.file_path, 'r') as file: self.instances = self.loader.load(file, **kwargs) self.loaded = True def save(self, **kwargs): """Save the dataset using the Dataset's loader. Save the data set in its current state to a storage location. Parameters ---------- **kwargs : dictionary Keyword arguments passed to the DataLoader to configure its settings for writing the dataset. """ if self.loader and self.file_path: with open(self.file_path, 'w') as file: self.loader.save(self.instances, file, **kwargs)
OCTICON_PAPER_AIRPLANE = """ <svg class="octicon octicon-paper-airplane" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.592 2.712L2.38 7.25h4.87a.75.75 0 110 1.5H2.38l-.788 4.538L13.929 8 1.592 2.712zM.989 8L.064 2.68a1.341 1.341 0 011.85-1.462l13.402 5.744a1.13 1.13 0 010 2.076L1.913 14.782a1.341 1.341 0 01-1.85-1.463L.99 8z"></path></svg> """
octicon_paper_airplane = '\n<svg class="octicon octicon-paper-airplane" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" width="16" height="16"><path fill-rule="evenodd" d="M1.592 2.712L2.38 7.25h4.87a.75.75 0 110 1.5H2.38l-.788 4.538L13.929 8 1.592 2.712zM.989 8L.064 2.68a1.341 1.341 0 011.85-1.462l13.402 5.744a1.13 1.13 0 010 2.076L1.913 14.782a1.341 1.341 0 01-1.85-1.463L.99 8z"></path></svg>\n'
def test(): a = 10 fun1 = lambda: a fun1() print(a) a += 1 fun1() print(a) return fun1 fun = test() print(f"Fun: {fun()}")
def test(): a = 10 fun1 = lambda : a fun1() print(a) a += 1 fun1() print(a) return fun1 fun = test() print(f'Fun: {fun()}')
# -*- coding: utf-8 -*- """ neutrino_api This file was automatically generated for NeutrinoAPI by APIMATIC v2.0 ( https://apimatic.io ). """ class Blacklist(object): """Implementation of the 'Blacklist' model. TODO: type model description here. Attributes: is_listed (bool): true if listed, false if not list_host (string): the domain/hostname of the DNSBL list_rating (int): the list rating [1-3] with 1 being the best rating and 3 the lowest rating list_name (string): the name of the DNSBL txt_record (string): the TXT record returned for this listing (if listed) return_code (string): the specific return code for this listing (if listed) response_time (int): the DNSBL server response time in milliseconds """ # Create a mapping from Model property names to API property names _names = { "is_listed":'isListed', "list_host":'listHost', "list_rating":'listRating', "list_name":'listName', "txt_record":'txtRecord', "return_code":'returnCode', "response_time":'responseTime' } def __init__(self, is_listed=None, list_host=None, list_rating=None, list_name=None, txt_record=None, return_code=None, response_time=None): """Constructor for the Blacklist class""" # Initialize members of the class self.is_listed = is_listed self.list_host = list_host self.list_rating = list_rating self.list_name = list_name self.txt_record = txt_record self.return_code = return_code self.response_time = response_time @classmethod def from_dictionary(cls, dictionary): """Creates an instance of this model from a dictionary Args: dictionary (dictionary): A dictionary representation of the object as obtained from the deserialization of the server's response. The keys MUST match property names in the API description. Returns: object: An instance of this structure class. """ if dictionary is None: return None # Extract variables from the dictionary is_listed = dictionary.get('isListed') list_host = dictionary.get('listHost') list_rating = dictionary.get('listRating') list_name = dictionary.get('listName') txt_record = dictionary.get('txtRecord') return_code = dictionary.get('returnCode') response_time = dictionary.get('responseTime') # Return an object of this model return cls(is_listed, list_host, list_rating, list_name, txt_record, return_code, response_time)
""" neutrino_api This file was automatically generated for NeutrinoAPI by APIMATIC v2.0 ( https://apimatic.io ). """ class Blacklist(object): """Implementation of the 'Blacklist' model. TODO: type model description here. Attributes: is_listed (bool): true if listed, false if not list_host (string): the domain/hostname of the DNSBL list_rating (int): the list rating [1-3] with 1 being the best rating and 3 the lowest rating list_name (string): the name of the DNSBL txt_record (string): the TXT record returned for this listing (if listed) return_code (string): the specific return code for this listing (if listed) response_time (int): the DNSBL server response time in milliseconds """ _names = {'is_listed': 'isListed', 'list_host': 'listHost', 'list_rating': 'listRating', 'list_name': 'listName', 'txt_record': 'txtRecord', 'return_code': 'returnCode', 'response_time': 'responseTime'} def __init__(self, is_listed=None, list_host=None, list_rating=None, list_name=None, txt_record=None, return_code=None, response_time=None): """Constructor for the Blacklist class""" self.is_listed = is_listed self.list_host = list_host self.list_rating = list_rating self.list_name = list_name self.txt_record = txt_record self.return_code = return_code self.response_time = response_time @classmethod def from_dictionary(cls, dictionary): """Creates an instance of this model from a dictionary Args: dictionary (dictionary): A dictionary representation of the object as obtained from the deserialization of the server's response. The keys MUST match property names in the API description. Returns: object: An instance of this structure class. """ if dictionary is None: return None is_listed = dictionary.get('isListed') list_host = dictionary.get('listHost') list_rating = dictionary.get('listRating') list_name = dictionary.get('listName') txt_record = dictionary.get('txtRecord') return_code = dictionary.get('returnCode') response_time = dictionary.get('responseTime') return cls(is_listed, list_host, list_rating, list_name, txt_record, return_code, response_time)
class DmpIo(): def __init__(self): # inputs self.event = None self.username = None self.password = None
class Dmpio: def __init__(self): self.event = None self.username = None self.password = None
#!/usr/bin/env python3 """ This prints out my node IPs. nodes-005.py is used to print out..... al;jsdflkajsdf l;ajdsl;faj a;ljsdklfj -------------------------------------------------- """ print('10.10.10.5') print('10.10.10.4') print('10.10.10.3') print('10.10.10.2') print('10.10.10.1')
""" This prints out my node IPs. nodes-005.py is used to print out..... al;jsdflkajsdf l;ajdsl;faj a;ljsdklfj -------------------------------------------------- """ print('10.10.10.5') print('10.10.10.4') print('10.10.10.3') print('10.10.10.2') print('10.10.10.1')
""" Exercise 7: Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string. """ def computegrade(score): if score >= 0.9: return 'A' elif score >= 0.8: return 'B' elif score >= 0.7: return 'C' elif score >= 0.6: return 'D' else: return 'F' try: score = float(input("Enter score: ")) if score > 1 or score < 0: raise ValueError('Bad score') print(computegrade(score)) except: print('Bad score')
""" Exercise 7: Rewrite the grade program from the previous chapter using a function called computegrade that takes a score as its parameter and returns a grade as a string. """ def computegrade(score): if score >= 0.9: return 'A' elif score >= 0.8: return 'B' elif score >= 0.7: return 'C' elif score >= 0.6: return 'D' else: return 'F' try: score = float(input('Enter score: ')) if score > 1 or score < 0: raise value_error('Bad score') print(computegrade(score)) except: print('Bad score')