content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def find_tree(row, index): if index > len(row): row = row * ((index // len(row)) + 1) if row[index] == '#': return 1 return 0 if __name__ == '__main__': with open('input.txt') as f: data = [r.strip() for r in f.readlines()] indices = range(0, len(data) * 3, 3) tree_count = 0 for row, i in zip(data, indices): tree_count += find_tree(row, i) print(f'Total trees: {tree_count}')
def find_tree(row, index): if index > len(row): row = row * (index // len(row) + 1) if row[index] == '#': return 1 return 0 if __name__ == '__main__': with open('input.txt') as f: data = [r.strip() for r in f.readlines()] indices = range(0, len(data) * 3, 3) tree_count = 0 for (row, i) in zip(data, indices): tree_count += find_tree(row, i) print(f'Total trees: {tree_count}')
class BufferToLines(object): def __init__(self): self._acc_buff = "" self._last_line = "" self._in_middle_of_line = False def add(self, buff): self._acc_buff += buff.decode() self._in_middle_of_line = False if self._acc_buff[-1] == '\n' else True def lines(self): lines = self._acc_buff.split('\n') up_to_index = len(lines) - 2 if self._in_middle_of_line else len(lines) - 1 self._acc_buff = lines[-1] if self._in_middle_of_line else "" for iii in range(up_to_index): yield lines[iii]
class Buffertolines(object): def __init__(self): self._acc_buff = '' self._last_line = '' self._in_middle_of_line = False def add(self, buff): self._acc_buff += buff.decode() self._in_middle_of_line = False if self._acc_buff[-1] == '\n' else True def lines(self): lines = self._acc_buff.split('\n') up_to_index = len(lines) - 2 if self._in_middle_of_line else len(lines) - 1 self._acc_buff = lines[-1] if self._in_middle_of_line else '' for iii in range(up_to_index): yield lines[iii]
"""Contains name, version, and description.""" NAME = "saltant-py" VERSION = "0.4.0" DESCRIPTION = "saltant SDK for Python"
"""Contains name, version, and description.""" name = 'saltant-py' version = '0.4.0' description = 'saltant SDK for Python'
""" Tema: Funciones decoradoras. Curso: Curso de python, video 74. Plataforma: Youtube. Profesor: Juan diaz - Pildoras informaticas. Alumno: @edinsonrequena. """ def funcion_decoradora(funcion_como_parametro): def funcion_interior(*args, **kwargs): print('Codigo que se ejecutara antes de llamar a la funcion a decorar') funcion_como_parametro(*args, **kwargs) print('Codigo que se ejecutara despues de llamar a la funcion a decorar') return funcion_interior @funcion_decoradora def suma(num1, num2, num3): print(num1+num2+num3) def resta(num1, num2): print(num1-num2) @funcion_decoradora def division(num1, num2): print(num1/num2) @funcion_decoradora def potencia(base, exponente): print(pow(base,exponente)) if __name__ == '__main__': suma(5,10,16) resta(8,6) potencia(base=5, exponente=10) division(5,7)
""" Tema: Funciones decoradoras. Curso: Curso de python, video 74. Plataforma: Youtube. Profesor: Juan diaz - Pildoras informaticas. Alumno: @edinsonrequena. """ def funcion_decoradora(funcion_como_parametro): def funcion_interior(*args, **kwargs): print('Codigo que se ejecutara antes de llamar a la funcion a decorar') funcion_como_parametro(*args, **kwargs) print('Codigo que se ejecutara despues de llamar a la funcion a decorar') return funcion_interior @funcion_decoradora def suma(num1, num2, num3): print(num1 + num2 + num3) def resta(num1, num2): print(num1 - num2) @funcion_decoradora def division(num1, num2): print(num1 / num2) @funcion_decoradora def potencia(base, exponente): print(pow(base, exponente)) if __name__ == '__main__': suma(5, 10, 16) resta(8, 6) potencia(base=5, exponente=10) division(5, 7)
GET_ACTION_LIST = 'get_action_list' EXECUTE_ACTION = 'execute_action' GET_FIELD_OPTIONS = 'get_field_options' GET_ELEMENT_STATUS = 'get_element_status' message_handlers = {} def add_handler(message_name, func): message_handlers[message_name] = func def get_handler(message_name): return message_handlers.get(message_name)
get_action_list = 'get_action_list' execute_action = 'execute_action' get_field_options = 'get_field_options' get_element_status = 'get_element_status' message_handlers = {} def add_handler(message_name, func): message_handlers[message_name] = func def get_handler(message_name): return message_handlers.get(message_name)
""" Parameters for etl & mondrian """ Patient = { "resourceType" : "Patient", "QI": {"resourceType" : 0, "birthDate" : 1, "address" : 1, "gender" : 0, "ord_latitude" : 1, "ord_logitude" : 1, "version" : 0}, "CATEGORICAL": { "resourceType" : 1, "birthDate" : 0, "address" : 1, "gender" : 1, "ord_latitude" : 0, "ord_logitude" : 0, "version" : 1}, "k":10 } # Observation = { # "resourceType" : "Observation", # "QI": {"resourceType":0}, # "CATEGORICAL": { "resourceType" : 1} # } # DiagnosticReport = { # "resourceType" : "DiagnosticReport", # "QI" : {"resourceType":0}, # "CATEGORICAL": { "resourceType" : 1} # } # Location = { # "resourceType" : "Location", # "QI" : {"resourceType":0}, # "CATEGORICAL": { "resourceType" : 1} # } # Encounter = { # "resourceType" : "Encounter", # "QI" : {"resourceType":0}, # "CATEGORICAL": { "resourceType" : 1} # }
""" Parameters for etl & mondrian """ patient = {'resourceType': 'Patient', 'QI': {'resourceType': 0, 'birthDate': 1, 'address': 1, 'gender': 0, 'ord_latitude': 1, 'ord_logitude': 1, 'version': 0}, 'CATEGORICAL': {'resourceType': 1, 'birthDate': 0, 'address': 1, 'gender': 1, 'ord_latitude': 0, 'ord_logitude': 0, 'version': 1}, 'k': 10}
# Write a program that asks the number of kilometers a car has driven and the number of days it has been hired. # Calculate the price to pay, knowing that the car costs US$ 60 per day and US$ 0.15 per km driven. k = float(input('Enter how many kilometers the car has traveled: ')) d = float(input('Enter how many days the car has been rented: ')) t = (k * 0.15) + (d * 60) print('The total rental of the car is {}US${:.2f}{}'.format('\033[1;31;40m', t, '\033[m'))
k = float(input('Enter how many kilometers the car has traveled: ')) d = float(input('Enter how many days the car has been rented: ')) t = k * 0.15 + d * 60 print('The total rental of the car is {}US${:.2f}{}'.format('\x1b[1;31;40m', t, '\x1b[m'))
#!/usr/bin/env python ## ============================================================================= jsonStr = """[{"DT":"\/Date(1495333623000-0700)\/", "ST":"\/Date(1495337144000)\/", "Trend":8, "Value":245, "WT":"\/Date(1495326471000)\/"}, {"DT":"\/Date(1519423410000-0700)\/", "ST":"\/Date(1519423939000)\/", "Trend":8, "Value":245, "WT":"\/Date(1519423410000)\/"} ]"""
json_str = '[{"DT":"\\/Date(1495333623000-0700)\\/",\n "ST":"\\/Date(1495337144000)\\/",\n "Trend":8,\n "Value":245,\n "WT":"\\/Date(1495326471000)\\/"},\n\n {"DT":"\\/Date(1519423410000-0700)\\/",\n "ST":"\\/Date(1519423939000)\\/",\n "Trend":8,\n "Value":245,\n "WT":"\\/Date(1519423410000)\\/"} ]'
class BaseMemory(object): def __init__(self, max_num=20000, key_num=2000, sampling_policy='random', updating_policy='random', ): super(BaseMemory, self).__init__() self.max_num = max_num self.key_num = key_num self.sampling_policy = sampling_policy self.updating_policy = updating_policy self.feat = None def reset(self): self.feat = None def init_memory(self, feat): self.feat = feat def sample(self): raise NotImplementedError def update(self, new_feat): raise NotImplementedError def __len__(self): if self.feat is None: return 0 return len(self.feat)
class Basememory(object): def __init__(self, max_num=20000, key_num=2000, sampling_policy='random', updating_policy='random'): super(BaseMemory, self).__init__() self.max_num = max_num self.key_num = key_num self.sampling_policy = sampling_policy self.updating_policy = updating_policy self.feat = None def reset(self): self.feat = None def init_memory(self, feat): self.feat = feat def sample(self): raise NotImplementedError def update(self, new_feat): raise NotImplementedError def __len__(self): if self.feat is None: return 0 return len(self.feat)
commands = input().split(" ") my_list = [] team_a_count = 11 team_b_count = 11 condition = False for i in commands: if i not in my_list: my_list.append(i) if "A" in i: team_a_count -= 1 if "B" in i: team_b_count -= 1 if team_a_count < 7 or team_b_count < 7: condition = True break print(f'Team A - {team_a_count}; Team B - {team_b_count}') if condition: print ("Game was terminated")
commands = input().split(' ') my_list = [] team_a_count = 11 team_b_count = 11 condition = False for i in commands: if i not in my_list: my_list.append(i) if 'A' in i: team_a_count -= 1 if 'B' in i: team_b_count -= 1 if team_a_count < 7 or team_b_count < 7: condition = True break print(f'Team A - {team_a_count}; Team B - {team_b_count}') if condition: print('Game was terminated')
""" Utilities. """ def init_params(model, scip_limits, scip_params): """ :param model: scip.Model(), model instantiation :param scip_limits: dict, specifying SCIP parameter limits :param scip_params: dict, specifying SCIP parameter setting :return: - Initialize SCIP parameters for the model. """ model.setIntParam('display/verblevel', 0) # limits model.setLongintParam('limits/nodes', scip_limits['node_limit']) model.setRealParam('limits/time', scip_limits['time_limit']) # enable presolve and cuts (as in default) model.setIntParam('presolving/maxrounds', -1) # 0: off, -1: unlimited model.setIntParam('separating/maxrounds', -1) # 0 to disable local separation model.setIntParam('separating/maxroundsroot', -1) # 0 to disable root separation # disable reoptimization (as in default) model.setBoolParam('reoptimization/enable', False) # cutoff value is eventually set in env.run_episode # other parameters to be disabled in 'sandbox' setting model.setBoolParam('conflict/usesb', scip_params['conflict_usesb']) model.setBoolParam('branching/fullstrong/probingbounds', scip_params['probing_bounds']) model.setBoolParam('branching/relpscost/probingbounds', scip_params['probing_bounds']) model.setBoolParam('branching/checksol', scip_params['checksol']) model.setLongintParam('branching/fullstrong/reevalage', scip_params['reevalage']) # primal heuristics (54 total, 14 of which are disabled in default setting as well) if not scip_params['heuristics']: model.setIntParam('heuristics/actconsdiving/freq', -1) # disabled at default model.setIntParam('heuristics/bound/freq', -1) # disabled at default model.setIntParam('heuristics/clique/freq', -1) model.setIntParam('heuristics/coefdiving/freq', -1) model.setIntParam('heuristics/completesol/freq', -1) model.setIntParam('heuristics/conflictdiving/freq', -1) # disabled at default model.setIntParam('heuristics/crossover/freq', -1) model.setIntParam('heuristics/dins/freq', -1) # disabled at default model.setIntParam('heuristics/distributiondiving/freq', -1) model.setIntParam('heuristics/dualval/freq', -1) # disabled at default model.setIntParam('heuristics/farkasdiving/freq', -1) model.setIntParam('heuristics/feaspump/freq', -1) model.setIntParam('heuristics/fixandinfer/freq', -1) # disabled at default model.setIntParam('heuristics/fracdiving/freq', -1) model.setIntParam('heuristics/gins/freq', -1) model.setIntParam('heuristics/guideddiving/freq', -1) model.setIntParam('heuristics/zeroobj/freq', -1) # disabled at default model.setIntParam('heuristics/indicator/freq', -1) model.setIntParam('heuristics/intdiving/freq', -1) # disabled at default model.setIntParam('heuristics/intshifting/freq', -1) model.setIntParam('heuristics/linesearchdiving/freq', -1) model.setIntParam('heuristics/localbranching/freq', -1) # disabled at default model.setIntParam('heuristics/locks/freq', -1) model.setIntParam('heuristics/lpface/freq', -1) model.setIntParam('heuristics/alns/freq', -1) model.setIntParam('heuristics/nlpdiving/freq', -1) model.setIntParam('heuristics/mutation/freq', -1) # disabled at default model.setIntParam('heuristics/multistart/freq', -1) model.setIntParam('heuristics/mpec/freq', -1) model.setIntParam('heuristics/objpscostdiving/freq', -1) model.setIntParam('heuristics/octane/freq', -1) # disabled at default model.setIntParam('heuristics/ofins/freq', -1) model.setIntParam('heuristics/oneopt/freq', -1) model.setIntParam('heuristics/proximity/freq', -1) # disabled at default model.setIntParam('heuristics/pscostdiving/freq', -1) model.setIntParam('heuristics/randrounding/freq', -1) model.setIntParam('heuristics/rens/freq', -1) model.setIntParam('heuristics/reoptsols/freq', -1) model.setIntParam('heuristics/repair/freq', -1) # disabled at default model.setIntParam('heuristics/rins/freq', -1) model.setIntParam('heuristics/rootsoldiving/freq', -1) model.setIntParam('heuristics/rounding/freq', -1) model.setIntParam('heuristics/shiftandpropagate/freq', -1) model.setIntParam('heuristics/shifting/freq', -1) model.setIntParam('heuristics/simplerounding/freq', -1) model.setIntParam('heuristics/subnlp/freq', -1) model.setIntParam('heuristics/trivial/freq', -1) model.setIntParam('heuristics/trivialnegation/freq', -1) model.setIntParam('heuristics/trysol/freq', -1) model.setIntParam('heuristics/twoopt/freq', -1) # disabled at default model.setIntParam('heuristics/undercover/freq', -1) model.setIntParam('heuristics/vbounds/freq', -1) model.setIntParam('heuristics/veclendiving/freq', -1) model.setIntParam('heuristics/zirounding/freq', -1)
""" Utilities. """ def init_params(model, scip_limits, scip_params): """ :param model: scip.Model(), model instantiation :param scip_limits: dict, specifying SCIP parameter limits :param scip_params: dict, specifying SCIP parameter setting :return: - Initialize SCIP parameters for the model. """ model.setIntParam('display/verblevel', 0) model.setLongintParam('limits/nodes', scip_limits['node_limit']) model.setRealParam('limits/time', scip_limits['time_limit']) model.setIntParam('presolving/maxrounds', -1) model.setIntParam('separating/maxrounds', -1) model.setIntParam('separating/maxroundsroot', -1) model.setBoolParam('reoptimization/enable', False) model.setBoolParam('conflict/usesb', scip_params['conflict_usesb']) model.setBoolParam('branching/fullstrong/probingbounds', scip_params['probing_bounds']) model.setBoolParam('branching/relpscost/probingbounds', scip_params['probing_bounds']) model.setBoolParam('branching/checksol', scip_params['checksol']) model.setLongintParam('branching/fullstrong/reevalage', scip_params['reevalage']) if not scip_params['heuristics']: model.setIntParam('heuristics/actconsdiving/freq', -1) model.setIntParam('heuristics/bound/freq', -1) model.setIntParam('heuristics/clique/freq', -1) model.setIntParam('heuristics/coefdiving/freq', -1) model.setIntParam('heuristics/completesol/freq', -1) model.setIntParam('heuristics/conflictdiving/freq', -1) model.setIntParam('heuristics/crossover/freq', -1) model.setIntParam('heuristics/dins/freq', -1) model.setIntParam('heuristics/distributiondiving/freq', -1) model.setIntParam('heuristics/dualval/freq', -1) model.setIntParam('heuristics/farkasdiving/freq', -1) model.setIntParam('heuristics/feaspump/freq', -1) model.setIntParam('heuristics/fixandinfer/freq', -1) model.setIntParam('heuristics/fracdiving/freq', -1) model.setIntParam('heuristics/gins/freq', -1) model.setIntParam('heuristics/guideddiving/freq', -1) model.setIntParam('heuristics/zeroobj/freq', -1) model.setIntParam('heuristics/indicator/freq', -1) model.setIntParam('heuristics/intdiving/freq', -1) model.setIntParam('heuristics/intshifting/freq', -1) model.setIntParam('heuristics/linesearchdiving/freq', -1) model.setIntParam('heuristics/localbranching/freq', -1) model.setIntParam('heuristics/locks/freq', -1) model.setIntParam('heuristics/lpface/freq', -1) model.setIntParam('heuristics/alns/freq', -1) model.setIntParam('heuristics/nlpdiving/freq', -1) model.setIntParam('heuristics/mutation/freq', -1) model.setIntParam('heuristics/multistart/freq', -1) model.setIntParam('heuristics/mpec/freq', -1) model.setIntParam('heuristics/objpscostdiving/freq', -1) model.setIntParam('heuristics/octane/freq', -1) model.setIntParam('heuristics/ofins/freq', -1) model.setIntParam('heuristics/oneopt/freq', -1) model.setIntParam('heuristics/proximity/freq', -1) model.setIntParam('heuristics/pscostdiving/freq', -1) model.setIntParam('heuristics/randrounding/freq', -1) model.setIntParam('heuristics/rens/freq', -1) model.setIntParam('heuristics/reoptsols/freq', -1) model.setIntParam('heuristics/repair/freq', -1) model.setIntParam('heuristics/rins/freq', -1) model.setIntParam('heuristics/rootsoldiving/freq', -1) model.setIntParam('heuristics/rounding/freq', -1) model.setIntParam('heuristics/shiftandpropagate/freq', -1) model.setIntParam('heuristics/shifting/freq', -1) model.setIntParam('heuristics/simplerounding/freq', -1) model.setIntParam('heuristics/subnlp/freq', -1) model.setIntParam('heuristics/trivial/freq', -1) model.setIntParam('heuristics/trivialnegation/freq', -1) model.setIntParam('heuristics/trysol/freq', -1) model.setIntParam('heuristics/twoopt/freq', -1) model.setIntParam('heuristics/undercover/freq', -1) model.setIntParam('heuristics/vbounds/freq', -1) model.setIntParam('heuristics/veclendiving/freq', -1) model.setIntParam('heuristics/zirounding/freq', -1)
class ActivePlan(object): def __init__(self, join_observer_list, on_next, on_completed): self.join_observer_list = join_observer_list self.on_next = on_next self.on_completed = on_completed self.join_observers = {} for join_observer in self.join_observer_list: self.join_observers[join_observer] = join_observer def dequeue(self): for join_observer in self.join_observers.values(): join_observer.queue.pop(0) def match(self): has_values = True for join_observer in self.join_observer_list: if not len(join_observer.queue): has_values = False break if has_values: first_values = [] is_completed = False for join_observer in self.join_observer_list: first_values.append(join_observer.queue[0]) if join_observer.queue[0].kind == 'C': is_completed = True if is_completed: self.on_completed() else: self.dequeue() values = [] for value in first_values: values.append(value.value) self.on_next(*values)
class Activeplan(object): def __init__(self, join_observer_list, on_next, on_completed): self.join_observer_list = join_observer_list self.on_next = on_next self.on_completed = on_completed self.join_observers = {} for join_observer in self.join_observer_list: self.join_observers[join_observer] = join_observer def dequeue(self): for join_observer in self.join_observers.values(): join_observer.queue.pop(0) def match(self): has_values = True for join_observer in self.join_observer_list: if not len(join_observer.queue): has_values = False break if has_values: first_values = [] is_completed = False for join_observer in self.join_observer_list: first_values.append(join_observer.queue[0]) if join_observer.queue[0].kind == 'C': is_completed = True if is_completed: self.on_completed() else: self.dequeue() values = [] for value in first_values: values.append(value.value) self.on_next(*values)
""" Datos de entrada Temperatura = t = float Datos de salida Deporte = d = str """ # Entradas t=float(input(" Digite temperatura ")) # Caja Negra deporte= '' if(t>85 and t< 120): deporte= "Natacion " elif(t>70 and t<= 85 ): deporte= "Tenis " elif(t>32 and t<= 70 ): deporte = "Golf " elif(t>10 and t<= 32 ): deporte = "Esqui " elif(t>=0 and t<= 10 ): deporte = "Marcha " else: deporte= "No hay ningun deporte a practicar" # Datos de Salida print(f"El deporte apropiado para practicar es : {deporte} ")
""" Datos de entrada Temperatura = t = float Datos de salida Deporte = d = str """ t = float(input(' Digite temperatura ')) deporte = '' if t > 85 and t < 120: deporte = 'Natacion ' elif t > 70 and t <= 85: deporte = 'Tenis ' elif t > 32 and t <= 70: deporte = 'Golf ' elif t > 10 and t <= 32: deporte = 'Esqui ' elif t >= 0 and t <= 10: deporte = 'Marcha ' else: deporte = 'No hay ningun deporte a practicar' print(f'El deporte apropiado para practicar es : {deporte} ')
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Title : Lists Subdomain : Basic Data Types Author : Vincent Celis Created : 19 July 2018 https://www.hackerrank.com/challenges/python-lists/problem """ methods = { 'insert': lambda *args: args[0].insert(int(args[1]), int(args[2])), 'print': lambda *args: print(args[0]), 'remove': lambda *args: args[0].remove(int(args[1])), 'append': lambda *args: args[0].append(int(args[1])), 'sort': lambda *args: args[0].sort(), 'pop': lambda *args: args[0].pop(), 'reverse': lambda *args: args[0].reverse() } if __name__ == '__main__': N = int(input()) commands = [[e for e in input().split()] for _ in range(N)] result = [] for command in commands: method = methods[command[0]] method(result, *command[1:])
""" Title : Lists Subdomain : Basic Data Types Author : Vincent Celis Created : 19 July 2018 https://www.hackerrank.com/challenges/python-lists/problem """ methods = {'insert': lambda *args: args[0].insert(int(args[1]), int(args[2])), 'print': lambda *args: print(args[0]), 'remove': lambda *args: args[0].remove(int(args[1])), 'append': lambda *args: args[0].append(int(args[1])), 'sort': lambda *args: args[0].sort(), 'pop': lambda *args: args[0].pop(), 'reverse': lambda *args: args[0].reverse()} if __name__ == '__main__': n = int(input()) commands = [[e for e in input().split()] for _ in range(N)] result = [] for command in commands: method = methods[command[0]] method(result, *command[1:])
COINS = ( (25, 'Quarters'), (10, 'Dimes'), (5, 'Nickels'), (1, 'Pennies') ) def loose_change(cents): change = {'Pennies': 0, 'Nickels': 0, 'Dimes': 0, 'Quarters': 0} cents = int(cents) if cents <= 0: return change for coin_value, coin_name in COINS: q, r = divmod(cents, coin_value) change[coin_name] = q cents = r return change
coins = ((25, 'Quarters'), (10, 'Dimes'), (5, 'Nickels'), (1, 'Pennies')) def loose_change(cents): change = {'Pennies': 0, 'Nickels': 0, 'Dimes': 0, 'Quarters': 0} cents = int(cents) if cents <= 0: return change for (coin_value, coin_name) in COINS: (q, r) = divmod(cents, coin_value) change[coin_name] = q cents = r return change
""" time: n^3 space: n """ class Solution: def wordBreak(self, s: str, wordDict: List[str]) -> bool: dp = [True] + [False] * len(s) for i in range(1, len(s)+1): for w in wordDict: if s[:i].endswith(w): dp[i] |= dp[i-len(w)] return dp[-1] """ time: n^2 space: n """ class Solution: def wordBreak1(self, s: str, wordDict: List[str]) -> bool: q = [0] visited = set() while q: i = q.pop() visited.add(i) for w in wordDict: wend = i+len(w) if s[i:wend] == w: if wend == len(s): return True else: if wend not in visited: q.append(wend) return False
""" time: n^3 space: n """ class Solution: def word_break(self, s: str, wordDict: List[str]) -> bool: dp = [True] + [False] * len(s) for i in range(1, len(s) + 1): for w in wordDict: if s[:i].endswith(w): dp[i] |= dp[i - len(w)] return dp[-1] '\ntime: n^2\nspace: n\n' class Solution: def word_break1(self, s: str, wordDict: List[str]) -> bool: q = [0] visited = set() while q: i = q.pop() visited.add(i) for w in wordDict: wend = i + len(w) if s[i:wend] == w: if wend == len(s): return True elif wend not in visited: q.append(wend) return False
class Alert: def __init__(self, name): self.name = name self.enabled = False def load(self, values): for k, v in values.items(): if str(k).startswith('_') or k == 'name' or k not in vars(self): continue # !cover setattr(self, k, v) # self.__dict__.update(**values) def get_save_obj(self): ret = {} for k, v in vars(self).items(): if not k.startswith('_') and k != 'name': ret[k] = v return ret def alert(self, upd): print(upd) return False def formatted_name(self, name=None): """ Returns this object's name, stripped of invalid characters. If provided, it formats that name instead. """ name = name if name else self.name return (''.join(s for s in name.lower() if s.isalnum() or s == ' ')).title()
class Alert: def __init__(self, name): self.name = name self.enabled = False def load(self, values): for (k, v) in values.items(): if str(k).startswith('_') or k == 'name' or k not in vars(self): continue setattr(self, k, v) def get_save_obj(self): ret = {} for (k, v) in vars(self).items(): if not k.startswith('_') and k != 'name': ret[k] = v return ret def alert(self, upd): print(upd) return False def formatted_name(self, name=None): """ Returns this object's name, stripped of invalid characters. If provided, it formats that name instead. """ name = name if name else self.name return ''.join((s for s in name.lower() if s.isalnum() or s == ' ')).title()
'''input 97 89 20000 25899 10 5 8 10 97 89 8634 17266 97 89 8633 8633 100 100 101 200 1 1 1 1 1 1 20000 20000 100 100 20000 20000 12 8 25 48 2 3 8 12 2 2 2 2 ''' # -*- coding: utf-8 -*- # AtCoder Beginner Contest # Problem A if __name__ == '__main__': a = int(input()) b = int(input()) n = int(input()) # See: # https://beta.atcoder.jp/contests/abc032/submissions/2264731 for i in range(n, 30000 + 1): if i % a == 0 and i % b == 0: print(i) exit()
"""input 97 89 20000 25899 10 5 8 10 97 89 8634 17266 97 89 8633 8633 100 100 101 200 1 1 1 1 1 1 20000 20000 100 100 20000 20000 12 8 25 48 2 3 8 12 2 2 2 2 """ if __name__ == '__main__': a = int(input()) b = int(input()) n = int(input()) for i in range(n, 30000 + 1): if i % a == 0 and i % b == 0: print(i) exit()
def count_largest_group(n: int) -> int: hash_ = {} for i in range(1, n + 1): num = i count = 0 while num >= 10: count += num % 10 num //= 10 count += num if count in hash_: hash_[count] += 1 else: hash_[count] = 1 max_val = max(hash_.values()) ans = 0 for e in hash_.values(): if e == max_val: ans += 1 return ans if __name__ == '__main__': print(count_largest_group(15))
def count_largest_group(n: int) -> int: hash_ = {} for i in range(1, n + 1): num = i count = 0 while num >= 10: count += num % 10 num //= 10 count += num if count in hash_: hash_[count] += 1 else: hash_[count] = 1 max_val = max(hash_.values()) ans = 0 for e in hash_.values(): if e == max_val: ans += 1 return ans if __name__ == '__main__': print(count_largest_group(15))
code=r"""function whos_f() %Static variables %persistent l %cellFile counter %persistent m %cellFunc counter %persistent cellFile %persistent cellFunc %initialize counter k %if isempty(l) % l = 1; % m = 1; %end %Get info about caller, filename ST = dbstack(); if (length(ST) >= 2) file = strcat(ST(2).file, '.txt'); else file = 'command_window.txt'; end if (length(ST) > 2) func = ['#function_name: ', ST(2).name]; elseif (length(ST) == 2) func = ['#function_name: ' , ST(2).name, ', main']; else func = '#command window:'; end %should only run this function once for every function in file %if(~any(ismember(file, cellFile)) || ~any(ismember(func, cellFunc))) %Calls whos on caller workspace, then processes and prints the data cmdstr = 'whos;'; my_vars = evalin('caller', cmdstr) ; %numer of workspace variables Nvars = size(my_vars, 1); %fprintf('#name, size, class, complex, integer\n') str = sprintf('%s\n%s', func, '#name, size, class, complex, integer'); for j = 1:Nvars %Test if all values are integer in variable, variable comes from caller workspace name = my_vars(j).name; cmd = ['all(' name ' == double(uint64(' name ')));']; %got error with struct, so I test if it works try integer = evalin('caller', cmd); catch integer = -1; end if (integer ~= -1) %Have to call all one more time for matrixes, two for cubes while (length(integer) > 1) integer = all(integer); end %Print the fields in the struct %fprintf('%s,%dx%d, %s, %d, %d\n', ... % name, my_vars(j).size, my_vars(j).class, ... % my_vars(j).complex, integer) temp = sprintf('\n%s, %dx%d, %s, %d, %d', ... name, my_vars(j).size, my_vars(j).class, ... my_vars(j).complex, integer); str = [str, temp]; end end %check if written to file, if not, new file, else append %if (~ismember(file, cellFile)) % cellFile{l} = file; % l = l + 1; % fp = fopen(file, 'w'); %else fp = fopen(file, 'a'); fprintf(fp, '\n'); %end %add function to static cellarray cellFunc %cellFunc{m} = func; %m = m + 1; %write whos to file fprintf(fp, '%s\n', str); fclose(fp); %end end """
code = "function whos_f()\n %Static variables\n %persistent l %cellFile counter\n %persistent m %cellFunc counter\n %persistent cellFile\n %persistent cellFunc\n\n %initialize counter k\n %if isempty(l)\n % l = 1;\n % m = 1;\n %end\n\n %Get info about caller, filename\n ST = dbstack();\n if (length(ST) >= 2)\n file = strcat(ST(2).file, '.txt');\n else\n file = 'command_window.txt';\n end\n \n if (length(ST) > 2)\n func = ['#function_name: ', ST(2).name];\n elseif (length(ST) == 2)\n func = ['#function_name: ' , ST(2).name, ', main'];\n else\n func = '#command window:';\n end\n \n %should only run this function once for every function in file\n %if(~any(ismember(file, cellFile)) || ~any(ismember(func, cellFunc)))\n %Calls whos on caller workspace, then processes and prints the data\n cmdstr = 'whos;';\n my_vars = evalin('caller', cmdstr) ; \n\n %numer of workspace variables\n Nvars = size(my_vars, 1);\n\n %fprintf('#name, size, class, complex, integer\\n')\n str = sprintf('%s\\n%s', func, '#name, size, class, complex, integer');\n for j = 1:Nvars\n %Test if all values are integer in variable, variable comes from caller workspace\n name = my_vars(j).name;\n cmd = ['all(' name ' == double(uint64(' name ')));'];\n \n %got error with struct, so I test if it works\n try\n integer = evalin('caller', cmd);\n catch\n integer = -1;\n end\n \n if (integer ~= -1)\n %Have to call all one more time for matrixes, two for cubes\n while (length(integer) > 1)\n integer = all(integer); \n end\n\n %Print the fields in the struct\n %fprintf('%s,%dx%d, %s, %d, %d\\n', ...\n % name, my_vars(j).size, my_vars(j).class, ...\n % my_vars(j).complex, integer)\n temp = sprintf('\\n%s, %dx%d, %s, %d, %d', ...\n name, my_vars(j).size, my_vars(j).class, ...\n my_vars(j).complex, integer);\n str = [str, temp];\n end\n end\n\n %check if written to file, if not, new file, else append\n %if (~ismember(file, cellFile))\n % cellFile{l} = file;\n % l = l + 1;\n % fp = fopen(file, 'w');\n %else\n fp = fopen(file, 'a');\n fprintf(fp, '\\n');\n %end\n\n %add function to static cellarray cellFunc\n %cellFunc{m} = func; \n %m = m + 1;\n \n %write whos to file\n fprintf(fp, '%s\\n', str);\n fclose(fp);\n %end\nend\n"
# -*- coding: utf-8 -*- """ pylite ~~~~~~~~~ :copyright: (c) 2014 by Dariush Abbasi. :license: MIT, see LICENSE for more details. """ __version__ = "0.1.0"
""" pylite ~~~~~~~~~ :copyright: (c) 2014 by Dariush Abbasi. :license: MIT, see LICENSE for more details. """ __version__ = '0.1.0'
"""Answer to Question 3 goes here. Author: Dylan Blanchard, Sloan Anderson, and Stephen Johnson Class: CSI-480-01 Assignment: PA 5 -- Supervised Learning Due Date: Nov 30, 2018 11:59 PM Certification of Authenticity: I certify that this is entirely my own work, except where I have given fully-documented references to the work of others. I understand the definition and consequences of plagiarism and acknowledge that the assessor of this assignment may, for the purpose of assessing this assignment: - Reproduce this assignment and provide a copy to another member of academic - staff; and/or Communicate a copy of this assignment to a plagiarism checking - service (which may then retain a copy of this assignment on its database for - the purpose of future plagiarism checking) Champlain College CSI-480, Fall 2018 The following code was adapted by Joshua Auerbach (jauerbach@champlain.edu) from the UC Berkeley Pacman Projects (see license and attribution below). ---------------------- Licensing Information: You are free to use or extend these projects for educational purposes provided that (1) you do not distribute or publish solutions, (2) you retain this notice, and (3) you provide clear attribution to UC Berkeley, including a link to http://ai.berkeley.edu. Attribution Information: The Pacman AI projects were developed at UC Berkeley. The core projects and autograders were primarily created by John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu). Student side autograding was added by Brad Miller, Nick Hay, and Pieter Abbeel (pabbeel@cs.berkeley.edu). """ def q3(): """Answer question 3.""" # *** YOUR CODE HERE *** return "a"
"""Answer to Question 3 goes here. Author: Dylan Blanchard, Sloan Anderson, and Stephen Johnson Class: CSI-480-01 Assignment: PA 5 -- Supervised Learning Due Date: Nov 30, 2018 11:59 PM Certification of Authenticity: I certify that this is entirely my own work, except where I have given fully-documented references to the work of others. I understand the definition and consequences of plagiarism and acknowledge that the assessor of this assignment may, for the purpose of assessing this assignment: - Reproduce this assignment and provide a copy to another member of academic - staff; and/or Communicate a copy of this assignment to a plagiarism checking - service (which may then retain a copy of this assignment on its database for - the purpose of future plagiarism checking) Champlain College CSI-480, Fall 2018 The following code was adapted by Joshua Auerbach (jauerbach@champlain.edu) from the UC Berkeley Pacman Projects (see license and attribution below). ---------------------- Licensing Information: You are free to use or extend these projects for educational purposes provided that (1) you do not distribute or publish solutions, (2) you retain this notice, and (3) you provide clear attribution to UC Berkeley, including a link to http://ai.berkeley.edu. Attribution Information: The Pacman AI projects were developed at UC Berkeley. The core projects and autograders were primarily created by John DeNero (denero@cs.berkeley.edu) and Dan Klein (klein@cs.berkeley.edu). Student side autograding was added by Brad Miller, Nick Hay, and Pieter Abbeel (pabbeel@cs.berkeley.edu). """ def q3(): """Answer question 3.""" return 'a'
"""Card Games - Exercism Python Exercises""" def get_rounds(number): """ :param number: int - current round number. :return: list - current round and the two that follow. """ return [number, number + 1, number + 2] def concatenate_rounds(rounds_1, rounds_2): """ :param rounds_1: list - first rounds played. :param rounds_2: list - second set of rounds played. :return: list - all rounds played. """ rounds = rounds_1[:] for go_round in rounds_2: rounds.append(go_round) return rounds def list_contains_round(rounds, number): """ :param rounds: list - rounds played. :param number: int - round number. :return: bool - was the round played? """ if number in rounds: return True return False def card_average(hand): """ :param hand: list - cards in hand. :return: float - average value of the cards in the hand. """ total = 0 for card in hand: total += card return total / len(hand) def approx_average_is_average(hand): """ :param hand: list - cards in hand. :return: bool - if approximate average equals to the `true average`. """ end_average = (hand[0] + hand[-1]) / 2 mid_index = len(hand) // 2 mid_average = float(hand[mid_index]) hand_sum = 0 for card in hand: hand_sum += card true_average = hand_sum / len(hand) return end_average == true_average or mid_average == true_average def average_even_is_average_odd(hand): """ :param hand: list - cards in hand. :return: bool - are even and odd averages equal? """ even_count = 0 even_average = 0 even_sum = 0 for i in range(0, len(hand), 2): even_count += 1 even_sum += hand[i] even_average = even_sum / even_count odd_count = 0 odd_average = 0 odd_sum = 0 for i in range(1, len(hand), 2): odd_count += 1 odd_sum += hand[i] odd_average = odd_sum / odd_count return even_average == odd_average def maybe_double_last(hand): """ :param hand: list - cards in hand. :return: list - hand with Jacks (if present) value doubled. """ if hand[-1] == 11: new_hand = hand[:] new_hand[-1] = 22 return new_hand return hand
"""Card Games - Exercism Python Exercises""" def get_rounds(number): """ :param number: int - current round number. :return: list - current round and the two that follow. """ return [number, number + 1, number + 2] def concatenate_rounds(rounds_1, rounds_2): """ :param rounds_1: list - first rounds played. :param rounds_2: list - second set of rounds played. :return: list - all rounds played. """ rounds = rounds_1[:] for go_round in rounds_2: rounds.append(go_round) return rounds def list_contains_round(rounds, number): """ :param rounds: list - rounds played. :param number: int - round number. :return: bool - was the round played? """ if number in rounds: return True return False def card_average(hand): """ :param hand: list - cards in hand. :return: float - average value of the cards in the hand. """ total = 0 for card in hand: total += card return total / len(hand) def approx_average_is_average(hand): """ :param hand: list - cards in hand. :return: bool - if approximate average equals to the `true average`. """ end_average = (hand[0] + hand[-1]) / 2 mid_index = len(hand) // 2 mid_average = float(hand[mid_index]) hand_sum = 0 for card in hand: hand_sum += card true_average = hand_sum / len(hand) return end_average == true_average or mid_average == true_average def average_even_is_average_odd(hand): """ :param hand: list - cards in hand. :return: bool - are even and odd averages equal? """ even_count = 0 even_average = 0 even_sum = 0 for i in range(0, len(hand), 2): even_count += 1 even_sum += hand[i] even_average = even_sum / even_count odd_count = 0 odd_average = 0 odd_sum = 0 for i in range(1, len(hand), 2): odd_count += 1 odd_sum += hand[i] odd_average = odd_sum / odd_count return even_average == odd_average def maybe_double_last(hand): """ :param hand: list - cards in hand. :return: list - hand with Jacks (if present) value doubled. """ if hand[-1] == 11: new_hand = hand[:] new_hand[-1] = 22 return new_hand return hand
#Accept a list of words and return length of longest word. def long_word(word_list): word_len=[] for word in word_list: word_len.append((len(word),word)) word_len.sort() return word_len[-1][0], word_len[-1][1] word=long_word(["hai","everyone","bye"]) print("\nThe longest word is: ",word[1]) print("\nand the length of '",word[1],"' is: ",word[0])
def long_word(word_list): word_len = [] for word in word_list: word_len.append((len(word), word)) word_len.sort() return (word_len[-1][0], word_len[-1][1]) word = long_word(['hai', 'everyone', 'bye']) print('\nThe longest word is: ', word[1]) print("\nand the length of '", word[1], "' is: ", word[0])
# 5-5 Problems print(all([1, 2, abs(-3)-3])) print(chr(ord('a')) == 'a') x = [1, -2, 3, -5, 8, -3] print(list(filter(lambda val: val > 0, x))) x = hex(234) print(int(x, 16)) x = [1, 2, 3, 4] print(list(map(lambda a: a * 3, x))) x = [-8, 2, 7, 5, -3, 5, 0, 1] print(max(x) + min(x)) x = 17 / 3 print(round(x, 4))
print(all([1, 2, abs(-3) - 3])) print(chr(ord('a')) == 'a') x = [1, -2, 3, -5, 8, -3] print(list(filter(lambda val: val > 0, x))) x = hex(234) print(int(x, 16)) x = [1, 2, 3, 4] print(list(map(lambda a: a * 3, x))) x = [-8, 2, 7, 5, -3, 5, 0, 1] print(max(x) + min(x)) x = 17 / 3 print(round(x, 4))
"""https://code.google.com/codejam/contest/10284486/dashboard#s=p1&a=1""" def main(): T = int(input()) for i in range(1, T + 1): N, K, P = (int(s) for s in input().split()) A = [] B = [] C = [] for _ in range(K): a, b, c = (int(s) for s in input().split()) A.append(a) B.append(b) C.append(c) print("Case #{}: {}".format(i, solve(N, P, A, B, C))) def solve(N: int, P: int, A: list, B: list, C: list) -> str: res = [None for _ in range(N)] fill = list(bin(P - 1)[2:]) fill = ["0", ] * (N - len(fill) - len(A)) + fill for a, c in zip(A, C): res[a - 1] = str(c) for i in range(len(res) - 1, -1, -1): if res[i] is not None: continue if not fill: break res[i] = fill[-1] fill.pop() return "".join(res) if __name__ == '__main__': main()
"""https://code.google.com/codejam/contest/10284486/dashboard#s=p1&a=1""" def main(): t = int(input()) for i in range(1, T + 1): (n, k, p) = (int(s) for s in input().split()) a = [] b = [] c = [] for _ in range(K): (a, b, c) = (int(s) for s in input().split()) A.append(a) B.append(b) C.append(c) print('Case #{}: {}'.format(i, solve(N, P, A, B, C))) def solve(N: int, P: int, A: list, B: list, C: list) -> str: res = [None for _ in range(N)] fill = list(bin(P - 1)[2:]) fill = ['0'] * (N - len(fill) - len(A)) + fill for (a, c) in zip(A, C): res[a - 1] = str(c) for i in range(len(res) - 1, -1, -1): if res[i] is not None: continue if not fill: break res[i] = fill[-1] fill.pop() return ''.join(res) if __name__ == '__main__': main()
def get_max_profits(stock_prices): if len(stock_prices) < 2: raise ValueError("Getting a profit requires at least two prices") min_price = stock_prices[0] max_profit = stock_prices[1] - stock_prices[0] for current_time in range(1, len(stock_prices)): print(current_time, "currenttime") current_price = stock_prices[current_time] potential_profit = current_price - min_price max_profit = max(max_profit, potential_profit) min_price = min(min_price, current_price) return max_profit stock_prices = [10, 7, 5, 8, 11, 9] print("max profit is:", get_max_profits(stock_prices))
def get_max_profits(stock_prices): if len(stock_prices) < 2: raise value_error('Getting a profit requires at least two prices') min_price = stock_prices[0] max_profit = stock_prices[1] - stock_prices[0] for current_time in range(1, len(stock_prices)): print(current_time, 'currenttime') current_price = stock_prices[current_time] potential_profit = current_price - min_price max_profit = max(max_profit, potential_profit) min_price = min(min_price, current_price) return max_profit stock_prices = [10, 7, 5, 8, 11, 9] print('max profit is:', get_max_profits(stock_prices))
""" Leetcode #1185 """ class Solution: # if we know that 1/1/1971 was Friday def dayOfTheWeek(self, day: int, month: int, year: int) -> str: isLeapYear = lambda x: 1 if x % 400 == 0 or (x % 4 == 0 and x % 100 != 0) else 0 months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] numDays = -1 # start from 1971-01-01, remove that day for i in range(1971, year): numDays += 365 + isLeapYear(i) numDays += sum(months[:month-1]) + day + isLeapYear(year) # Adding 5 because 1/1/1971 was Friday return days[(5+numDays)%7] # without knowing 1/1/1971 was friday # but we know what today is def dayOfTheWeek_2(self, day: int, month: int, year: int) -> str: # today of 6th june day is saturday # so starting days from Saturday days = ["Saturday", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday"] months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def isLeapYear(year): return 1 if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 else 0 def getDay(day, month, year): numDays = 0 # get num days till last year for y in range(year-1, 1970, -1): numDays += 365 + isLeapYear(y) numDays += sum(months[:month-1]) numDays += day if month > 2: numDays += isLeapYear(year) return numDays k = getDay(6, 6, 2020) # today is saturday d = getDay(day, month, year) return days[(d-k)%7] if __name__ == "__main__": solution = Solution() assert solution.dayOfTheWeek(31, 8, 2019) == "Saturday" assert solution.dayOfTheWeek(18, 7, 1999) == "Sunday" assert solution.dayOfTheWeek_2(31, 8, 2019) == "Saturday" assert solution.dayOfTheWeek_2(18, 7, 1999) == "Sunday"
""" Leetcode #1185 """ class Solution: def day_of_the_week(self, day: int, month: int, year: int) -> str: is_leap_year = lambda x: 1 if x % 400 == 0 or (x % 4 == 0 and x % 100 != 0) else 0 months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'] num_days = -1 for i in range(1971, year): num_days += 365 + is_leap_year(i) num_days += sum(months[:month - 1]) + day + is_leap_year(year) return days[(5 + numDays) % 7] def day_of_the_week_2(self, day: int, month: int, year: int) -> str: days = ['Saturday', 'Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def is_leap_year(year): return 1 if year % 4 == 0 and year % 100 != 0 or year % 400 == 0 else 0 def get_day(day, month, year): num_days = 0 for y in range(year - 1, 1970, -1): num_days += 365 + is_leap_year(y) num_days += sum(months[:month - 1]) num_days += day if month > 2: num_days += is_leap_year(year) return numDays k = get_day(6, 6, 2020) d = get_day(day, month, year) return days[(d - k) % 7] if __name__ == '__main__': solution = solution() assert solution.dayOfTheWeek(31, 8, 2019) == 'Saturday' assert solution.dayOfTheWeek(18, 7, 1999) == 'Sunday' assert solution.dayOfTheWeek_2(31, 8, 2019) == 'Saturday' assert solution.dayOfTheWeek_2(18, 7, 1999) == 'Sunday'
# https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher PLAINTEXT = 'ATTACKATDAWN' KEY = 'LEMON' def vigenere_cipher_func(key, message): message = message.lower() key = key.lower() cipher_message = '' key_value = 0 for char in message: if ord(char) >= 97 and ord(char) < 134: mi = ord(char) - 97 ki = ord(key[key_value % len(key)]) ci = (mi + ki - 97) % 26 + 97 cipher_message += chr(ci) key_value += 1 else: cipher_message += char return cipher_message.upper() def vigenere_decipher_func(key, message): message = message.lower() key = key.lower() plain_messages = '' key_value = 0 for char in message: if ord(char) >= 97 and ord(char) < 134: ci = ord(char) - 97 ki = ord(key[key_value % len(key)]) - 97 mi = (ci - ki) % 26 + 97 plain_messages += chr(mi) key_value += 1 else: plain_messages += char return plain_messages.upper() crypto_text = vigenere_cipher_func(KEY, PLAINTEXT) decrypto_text = vigenere_decipher_func(KEY, crypto_text) # tests print(PLAINTEXT, ' + ', KEY, ' >> ', crypto_text) print(crypto_text, ' - ', KEY, ' >> ', decrypto_text)
plaintext = 'ATTACKATDAWN' key = 'LEMON' def vigenere_cipher_func(key, message): message = message.lower() key = key.lower() cipher_message = '' key_value = 0 for char in message: if ord(char) >= 97 and ord(char) < 134: mi = ord(char) - 97 ki = ord(key[key_value % len(key)]) ci = (mi + ki - 97) % 26 + 97 cipher_message += chr(ci) key_value += 1 else: cipher_message += char return cipher_message.upper() def vigenere_decipher_func(key, message): message = message.lower() key = key.lower() plain_messages = '' key_value = 0 for char in message: if ord(char) >= 97 and ord(char) < 134: ci = ord(char) - 97 ki = ord(key[key_value % len(key)]) - 97 mi = (ci - ki) % 26 + 97 plain_messages += chr(mi) key_value += 1 else: plain_messages += char return plain_messages.upper() crypto_text = vigenere_cipher_func(KEY, PLAINTEXT) decrypto_text = vigenere_decipher_func(KEY, crypto_text) print(PLAINTEXT, ' + ', KEY, ' >> ', crypto_text) print(crypto_text, ' - ', KEY, ' >> ', decrypto_text)
# # PySNMP MIB module SVRNTCLU-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SVRNTCLU-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:04:39 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") SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") Counter64, IpAddress, NotificationType, Bits, Gauge32, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, Counter32, TimeTicks, ModuleIdentity, Unsigned32, Integer32, enterprises, mgmt, iso, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "IpAddress", "NotificationType", "Bits", "Gauge32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "Counter32", "TimeTicks", "ModuleIdentity", "Unsigned32", "Integer32", "enterprises", "mgmt", "iso", "ObjectIdentity") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") dec = MibIdentifier((1, 3, 6, 1, 4, 1, 36)) ema = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2)) class ObjectType(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7)) namedValues = NamedValues(("objectUnknown", 1), ("objectOther", 2), ("share", 3), ("disk", 4), ("application", 5), ("ipAddress", 6), ("fileShare", 7)) class PolicyType(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6)) namedValues = NamedValues(("policyUnknown", 1), ("policyOther", 2), ("inOrder", 3), ("random", 4), ("leastLoad", 5), ("roundRobin", 6)) class Boolean(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2)) namedValues = NamedValues(("true", 1), ("false", 2)) class DateAndTime(DisplayString): pass class FailoverReason(Integer32): subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5)) namedValues = NamedValues(("reasonUnknown", 1), ("reasonOther", 2), ("reconfiguration", 3), ("failure", 4), ("failback", 5)) mib_extensions_1 = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18)).setLabel("mib-extensions-1") svrSystem = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22)) svrCluster = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4)) svrNTClu = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2)) svrNTCluObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1)) svrNTCluMibInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1)) svrNTCluClusterInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2)) ntcExMgtMibMajorRev = MibScalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExMgtMibMajorRev.setStatus('mandatory') ntcExMgtMibMinorRev = MibScalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExMgtMibMinorRev.setStatus('mandatory') ntcExAlias = MibScalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 1), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExAlias.setStatus('mandatory') ntcExGroupTable = MibTable((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7), ) if mibBuilder.loadTexts: ntcExGroupTable.setStatus('mandatory') ntcExGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1), ).setIndexNames((0, "SVRNTCLU-MIB", "ntcExGroupIndex")) if mibBuilder.loadTexts: ntcExGroupEntry.setStatus('mandatory') ntcExGroupIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupIndex.setStatus('mandatory') ntcExGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupName.setStatus('mandatory') ntcExGroupComment = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 3), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupComment.setStatus('mandatory') ntcExGroupOnLine = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupOnLine.setStatus('mandatory') ntcExGroupFailedOver = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 5), Boolean()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupFailedOver.setStatus('mandatory') ntcExGroupPolicy = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 6), PolicyType()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupPolicy.setStatus('mandatory') ntcExGroupReevaluate = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 7), Boolean()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupReevaluate.setStatus('mandatory') ntcExGroupMembers = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 8), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupMembers.setStatus('mandatory') ntcExGroupObjects = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 9), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExGroupObjects.setStatus('mandatory') ntcExObjectTable = MibTable((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8), ) if mibBuilder.loadTexts: ntcExObjectTable.setStatus('mandatory') ntcExObjectEntry = MibTableRow((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1), ).setIndexNames((0, "SVRNTCLU-MIB", "ntcExObjectIndex")) if mibBuilder.loadTexts: ntcExObjectEntry.setStatus('mandatory') ntcExObjectIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExObjectIndex.setStatus('mandatory') ntcExObjectName = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 2), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExObjectName.setStatus('mandatory') ntcExObjectComment = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 3), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExObjectComment.setStatus('mandatory') ntcExObjectType = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 4), ObjectType()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExObjectType.setStatus('mandatory') ntcExObjectDrives = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 5), DisplayString()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExObjectDrives.setStatus('mandatory') ntcExObjectIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 6), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ntcExObjectIpAddress.setStatus('mandatory') mibBuilder.exportSymbols("SVRNTCLU-MIB", ntcExGroupName=ntcExGroupName, PolicyType=PolicyType, ntcExGroupComment=ntcExGroupComment, ntcExGroupMembers=ntcExGroupMembers, ntcExObjectEntry=ntcExObjectEntry, ntcExMgtMibMinorRev=ntcExMgtMibMinorRev, mib_extensions_1=mib_extensions_1, ntcExObjectDrives=ntcExObjectDrives, svrNTCluClusterInfo=svrNTCluClusterInfo, ntcExGroupTable=ntcExGroupTable, ntcExGroupOnLine=ntcExGroupOnLine, ntcExObjectIpAddress=ntcExObjectIpAddress, ntcExGroupFailedOver=ntcExGroupFailedOver, FailoverReason=FailoverReason, ntcExObjectComment=ntcExObjectComment, ema=ema, svrSystem=svrSystem, ntcExObjectType=ntcExObjectType, ntcExGroupIndex=ntcExGroupIndex, Boolean=Boolean, svrNTCluObjects=svrNTCluObjects, svrNTClu=svrNTClu, ntcExMgtMibMajorRev=ntcExMgtMibMajorRev, svrNTCluMibInfo=svrNTCluMibInfo, ntcExObjectIndex=ntcExObjectIndex, ntcExGroupReevaluate=ntcExGroupReevaluate, ntcExGroupEntry=ntcExGroupEntry, dec=dec, DateAndTime=DateAndTime, ntcExAlias=ntcExAlias, ntcExGroupPolicy=ntcExGroupPolicy, ntcExObjectTable=ntcExObjectTable, ObjectType=ObjectType, svrCluster=svrCluster, ntcExGroupObjects=ntcExGroupObjects, ntcExObjectName=ntcExObjectName)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_union, value_range_constraint, value_size_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (counter64, ip_address, notification_type, bits, gauge32, mib_scalar, mib_table, mib_table_row, mib_table_column, mib_identifier, counter32, time_ticks, module_identity, unsigned32, integer32, enterprises, mgmt, iso, object_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter64', 'IpAddress', 'NotificationType', 'Bits', 'Gauge32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'MibIdentifier', 'Counter32', 'TimeTicks', 'ModuleIdentity', 'Unsigned32', 'Integer32', 'enterprises', 'mgmt', 'iso', 'ObjectIdentity') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') dec = mib_identifier((1, 3, 6, 1, 4, 1, 36)) ema = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2)) class Objecttype(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7)) named_values = named_values(('objectUnknown', 1), ('objectOther', 2), ('share', 3), ('disk', 4), ('application', 5), ('ipAddress', 6), ('fileShare', 7)) class Policytype(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6)) named_values = named_values(('policyUnknown', 1), ('policyOther', 2), ('inOrder', 3), ('random', 4), ('leastLoad', 5), ('roundRobin', 6)) class Boolean(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2)) named_values = named_values(('true', 1), ('false', 2)) class Dateandtime(DisplayString): pass class Failoverreason(Integer32): subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5)) named_values = named_values(('reasonUnknown', 1), ('reasonOther', 2), ('reconfiguration', 3), ('failure', 4), ('failback', 5)) mib_extensions_1 = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18)).setLabel('mib-extensions-1') svr_system = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22)) svr_cluster = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4)) svr_nt_clu = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2)) svr_nt_clu_objects = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1)) svr_nt_clu_mib_info = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1)) svr_nt_clu_cluster_info = mib_identifier((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2)) ntc_ex_mgt_mib_major_rev = mib_scalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExMgtMibMajorRev.setStatus('mandatory') ntc_ex_mgt_mib_minor_rev = mib_scalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExMgtMibMinorRev.setStatus('mandatory') ntc_ex_alias = mib_scalar((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 1), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExAlias.setStatus('mandatory') ntc_ex_group_table = mib_table((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7)) if mibBuilder.loadTexts: ntcExGroupTable.setStatus('mandatory') ntc_ex_group_entry = mib_table_row((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1)).setIndexNames((0, 'SVRNTCLU-MIB', 'ntcExGroupIndex')) if mibBuilder.loadTexts: ntcExGroupEntry.setStatus('mandatory') ntc_ex_group_index = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupIndex.setStatus('mandatory') ntc_ex_group_name = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupName.setStatus('mandatory') ntc_ex_group_comment = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 3), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupComment.setStatus('mandatory') ntc_ex_group_on_line = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 4), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupOnLine.setStatus('mandatory') ntc_ex_group_failed_over = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 5), boolean()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupFailedOver.setStatus('mandatory') ntc_ex_group_policy = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 6), policy_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupPolicy.setStatus('mandatory') ntc_ex_group_reevaluate = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 7), boolean()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupReevaluate.setStatus('mandatory') ntc_ex_group_members = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 8), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupMembers.setStatus('mandatory') ntc_ex_group_objects = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 7, 1, 9), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExGroupObjects.setStatus('mandatory') ntc_ex_object_table = mib_table((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8)) if mibBuilder.loadTexts: ntcExObjectTable.setStatus('mandatory') ntc_ex_object_entry = mib_table_row((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1)).setIndexNames((0, 'SVRNTCLU-MIB', 'ntcExObjectIndex')) if mibBuilder.loadTexts: ntcExObjectEntry.setStatus('mandatory') ntc_ex_object_index = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExObjectIndex.setStatus('mandatory') ntc_ex_object_name = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 2), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExObjectName.setStatus('mandatory') ntc_ex_object_comment = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 3), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExObjectComment.setStatus('mandatory') ntc_ex_object_type = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 4), object_type()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExObjectType.setStatus('mandatory') ntc_ex_object_drives = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 5), display_string()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExObjectDrives.setStatus('mandatory') ntc_ex_object_ip_address = mib_table_column((1, 3, 6, 1, 4, 1, 36, 2, 18, 22, 4, 2, 1, 2, 8, 1, 6), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ntcExObjectIpAddress.setStatus('mandatory') mibBuilder.exportSymbols('SVRNTCLU-MIB', ntcExGroupName=ntcExGroupName, PolicyType=PolicyType, ntcExGroupComment=ntcExGroupComment, ntcExGroupMembers=ntcExGroupMembers, ntcExObjectEntry=ntcExObjectEntry, ntcExMgtMibMinorRev=ntcExMgtMibMinorRev, mib_extensions_1=mib_extensions_1, ntcExObjectDrives=ntcExObjectDrives, svrNTCluClusterInfo=svrNTCluClusterInfo, ntcExGroupTable=ntcExGroupTable, ntcExGroupOnLine=ntcExGroupOnLine, ntcExObjectIpAddress=ntcExObjectIpAddress, ntcExGroupFailedOver=ntcExGroupFailedOver, FailoverReason=FailoverReason, ntcExObjectComment=ntcExObjectComment, ema=ema, svrSystem=svrSystem, ntcExObjectType=ntcExObjectType, ntcExGroupIndex=ntcExGroupIndex, Boolean=Boolean, svrNTCluObjects=svrNTCluObjects, svrNTClu=svrNTClu, ntcExMgtMibMajorRev=ntcExMgtMibMajorRev, svrNTCluMibInfo=svrNTCluMibInfo, ntcExObjectIndex=ntcExObjectIndex, ntcExGroupReevaluate=ntcExGroupReevaluate, ntcExGroupEntry=ntcExGroupEntry, dec=dec, DateAndTime=DateAndTime, ntcExAlias=ntcExAlias, ntcExGroupPolicy=ntcExGroupPolicy, ntcExObjectTable=ntcExObjectTable, ObjectType=ObjectType, svrCluster=svrCluster, ntcExGroupObjects=ntcExGroupObjects, ntcExObjectName=ntcExObjectName)
""" Placeholder test file. We'll add a bunch of tests here in later versions. """ def test_add(): """Placeholder test.""" pass
""" Placeholder test file. We'll add a bunch of tests here in later versions. """ def test_add(): """Placeholder test.""" pass
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Nov 30 22:35:24 2021 @author: aboisvert """ #%% Part 1 """ As the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine. For example, suppose you had the following report: 199 200 208 210 200 207 240 269 260 263 This report indicates that, scanning outward from the submarine, the sonar sweep found depths of 199, 200, 208, 210, and so on. The first order of business is to figure out how quickly the depth increases, just so you know what you're dealing with - you never know if the keys will get carried into deeper water by an ocean current or a fish or something. To do this, count the number of times a depth measurement increases from the previous measurement. (There is no measurement before the first measurement.) """ a = ''' 190 168 166 163 170 160 171 166 161 167 175 178 193 189 188 191 193 192 193 180 177 178 176 177 196 203 211 209 210 209 225 219 229 214 202 205 208 207 208 204 208 206 205 208 209 219 236 241 243 239 251 278 279 284 283 287 244 245 257 253 272 276 287 288 304 306 313 312 284 293 288 289 290 283 298 309 300 298 297 291 292 304 301 303 306 280 286 266 270 272 274 269 270 271 270 266 274 275 278 280 283 284 283 267 282 283 285 286 302 307 309 311 309 315 314 317 319 318 314 313 330 333 335 365 370 361 362 367 358 361 359 358 349 352 367 355 359 360 355 357 359 368 375 383 385 399 410 413 414 418 417 418 419 420 421 422 434 439 438 440 441 443 445 444 446 450 452 463 466 476 464 467 470 474 460 473 475 476 482 481 489 495 505 503 508 493 508 509 508 513 538 536 521 526 523 536 537 558 557 563 557 560 561 560 575 578 582 583 587 574 576 581 580 579 581 599 601 602 606 607 606 605 606 607 611 607 606 605 603 597 598 593 584 585 587 619 614 616 596 627 628 630 631 634 633 631 632 641 637 647 643 651 625 593 601 602 599 592 593 597 601 592 612 611 612 616 620 622 627 626 629 632 642 654 655 657 658 661 662 653 655 658 665 674 664 694 689 692 693 681 686 687 698 701 706 687 689 706 710 716 723 733 735 734 733 727 729 744 750 736 739 745 743 742 743 741 739 742 748 755 752 762 768 767 760 758 756 765 779 796 797 798 796 797 775 779 780 781 784 794 799 793 797 795 793 802 800 809 814 826 830 820 804 805 809 816 817 845 850 861 857 858 863 868 873 880 891 865 876 890 925 927 926 932 941 942 943 942 943 942 947 938 940 943 949 953 954 966 970 967 963 961 964 966 973 983 975 974 980 977 988 989 991 989 990 1000 1001 1006 996 998 997 996 979 981 1014 1018 1023 996 995 1006 1000 994 996 999 1001 999 1000 1002 1001 1003 1005 1006 1014 1037 1039 1040 1066 1059 1081 1085 1072 1069 1070 1069 1080 1079 1106 1105 1118 1127 1150 1151 1147 1133 1134 1135 1136 1137 1138 1140 1138 1149 1150 1149 1143 1136 1137 1140 1141 1140 1141 1142 1155 1182 1173 1167 1163 1172 1186 1180 1176 1179 1178 1189 1201 1205 1201 1200 1209 1207 1218 1226 1232 1234 1233 1225 1228 1229 1219 1221 1220 1199 1201 1204 1212 1224 1208 1209 1210 1220 1219 1215 1231 1240 1246 1249 1281 1247 1251 1255 1263 1260 1292 1293 1305 1311 1316 1319 1323 1307 1326 1319 1316 1327 1328 1333 1342 1337 1338 1335 1353 1368 1371 1386 1382 1381 1378 1374 1391 1396 1397 1399 1388 1380 1406 1396 1398 1397 1401 1402 1401 1369 1372 1373 1370 1371 1362 1375 1378 1389 1400 1402 1404 1420 1425 1429 1425 1406 1412 1425 1421 1401 1402 1399 1400 1412 1387 1386 1390 1392 1396 1402 1404 1405 1406 1379 1384 1419 1420 1422 1427 1423 1426 1421 1420 1428 1424 1428 1436 1432 1439 1444 1457 1458 1460 1464 1459 1460 1493 1489 1510 1503 1505 1506 1492 1515 1517 1506 1488 1485 1488 1471 1473 1496 1499 1497 1501 1475 1465 1460 1458 1462 1467 1466 1483 1471 1476 1471 1493 1492 1494 1503 1504 1505 1506 1507 1510 1492 1493 1500 1498 1528 1533 1538 1539 1575 1576 1557 1555 1557 1579 1589 1594 1599 1600 1598 1609 1619 1618 1617 1629 1613 1619 1620 1631 1627 1628 1630 1631 1616 1631 1651 1657 1658 1637 1642 1641 1651 1652 1647 1649 1658 1649 1629 1631 1632 1619 1617 1620 1634 1632 1633 1636 1634 1641 1639 1642 1647 1640 1609 1611 1607 1597 1601 1606 1635 1637 1647 1640 1650 1654 1656 1636 1626 1624 1625 1615 1620 1621 1618 1614 1615 1616 1622 1623 1625 1627 1626 1627 1632 1644 1659 1668 1671 1672 1673 1676 1684 1709 1735 1734 1731 1738 1740 1748 1751 1741 1740 1739 1741 1739 1750 1762 1766 1765 1764 1775 1774 1775 1776 1777 1778 1757 1755 1756 1757 1756 1776 1780 1781 1790 1792 1791 1803 1810 1801 1800 1831 1834 1818 1823 1806 1801 1812 1814 1837 1842 1843 1842 1841 1836 1828 1835 1846 1845 1855 1854 1858 1856 1865 1866 1865 1850 1859 1872 1868 1866 1867 1862 1869 1870 1882 1896 1901 1903 1917 1939 1942 1945 1955 1956 1954 1974 1944 1943 1942 1956 1961 1957 1953 1954 1955 1958 1961 1948 1947 1959 1960 1961 1969 1996 1992 1993 1988 1994 2021 2020 2003 1999 1995 2006 2002 1994 1995 1998 1995 1988 1992 1997 2003 2006 2007 2010 2006 2015 2000 1998 1993 2003 2004 2006 2005 2008 2019 2020 2030 2031 2036 2037 2038 2037 2036 2038 2031 2043 2044 2047 2050 2049 2027 2053 2057 2058 2034 2038 2033 2034 2038 2045 2031 2037 2053 2061 2058 2062 2063 2051 2046 2045 2042 2043 2042 2037 2053 2047 2059 2058 2057 2058 2069 2070 2073 2086 2098 2116 2110 2108 2109 2111 2112 2114 2116 2102 2108 2110 2111 2115 2114 2123 2124 2121 2144 2167 2170 2167 2135 2141 2145 2152 2166 2159 2160 2133 2132 2133 2100 2104 2101 2102 2109 2108 2109 2112 2114 2113 2114 2123 2121 2122 2116 2115 2126 2133 2135 2136 2137 2138 2137 2140 2156 2148 2144 2143 2142 2145 2161 2160 2162 2154 2155 2136 2134 2132 2138 2140 2143 2135 2136 2143 2130 2127 2158 2161 2167 2169 2186 2191 2185 2193 2192 2205 2199 2198 2199 2201 2200 2201 2225 2234 2232 2241 2230 2227 2218 2228 2241 2242 2243 2258 2251 2242 2226 2218 2223 2222 2225 2247 2246 2243 2245 2238 2239 2237 2255 2257 2258 2251 2267 2268 2269 2283 2264 2266 2264 2265 2293 2310 2327 2334 2354 2353 2358 2354 2359 2353 2362 2363 2364 2362 2366 2362 2356 2355 2351 2385 2386 2387 2389 2391 2400 2411 2373 2343 2332 2331 2335 2346 2343 2357 2365 2366 2373 2374 2368 2363 2362 2366 2365 2369 2340 2341 2337 2357 2358 2353 2355 2374 2373 2379 2382 2390 2388 2387 2388 2387 2388 2389 2399 2400 2398 2406 2409 2414 2416 2425 2434 2424 2418 2420 2413 2418 2419 2427 2428 2429 2428 2431 2430 2418 2430 2434 2442 2443 2410 2409 2416 2400 2398 2402 2403 2405 2440 2433 2439 2435 2414 2431 2440 2443 2442 2445 2449 2448 2444 2443 2450 2432 2431 2436 2460 2467 2471 2470 2473 2477 2486 2487 2482 2487 2488 2490 2493 2465 2463 2471 2467 2466 2473 2469 2471 2483 2484 2496 2494 2497 2493 2521 2522 2500 2504 2512 2521 2522 2529 2524 2521 2528 2529 2544 2521 2532 2525 2530 2524 2523 2505 2498 2499 2494 2487 2484 2487 2488 2491 2498 2497 2486 2478 2484 2488 2489 2491 2489 2493 2496 2499 2496 2495 2498 2499 2498 2497 2503 2500 2534 2535 2546 2588 2616 2642 2641 2640 2654 2663 2659 2663 2664 2674 2678 2680 2683 2692 2698 2703 2704 2707 2704 2735 2710 2728 2730 2739 2734 2741 2738 2760 2744 2745 2746 2747 2750 2744 2746 2759 2761 2762 2763 2764 2785 2795 2818 2820 2824 2828 2831 2833 2837 2838 2840 2839 2847 2844 2835 2834 2829 2835 2837 2805 2832 2833 2832 2833 2822 2823 2826 2835 2823 2825 2828 2829 2828 2850 2851 2853 2862 2864 2877 2871 2874 2886 2921 2895 2899 2887 2898 2897 2899 2922 2929 2935 2937 2938 2935 2939 2944 2945 2981 2982 2986 3002 3003 3010 3009 3020 3021 3029 3028 3019 3020 3021 2996 2993 2999 3009 3013 2996 2988 2990 3032 3031 3023 3037 3027 2994 2988 2991 3023 3025 3029 3033 3043 3052 3053 3052 3054 3055 3045 3044 3053 3056 3077 3078 3079 3073 3099 3093 3097 3100 3064 3076 3082 3095 3091 3095 3101 3102 3099 3100 3095 3097 3093 3102 3105 3143 3160 3157 3156 3158 3150 3151 3150 3157 3184 3179 3181 3173 3179 3184 3187 3197 3198 3199 3208 3214 3221 3205 3209 3210 3214 3215 3214 3216 3234 3237 3246 3254 3255 3278 3277 3278 3281 3299 3298 3306 3305 3304 3315 3323 3330 3331 3323 3326 3329 3330 3336 3326 3324 3320 3318 3317 3319 3318 3320 3321 3322 3331 3322 3315 3326 3325 3317 3316 3312 3323 3322 3329 3328 3323 3324 3332 3331 3329 3294 3293 3290 3283 3278 3281 3290 3291 3265 3268 3271 3255 3248 3249 3250 3253 3254 3276 3277 3274 3279 3281 3295 3290 3306 3309 3300 3306 3317 3316 3325 3322 3343 3346 3355 3356 3370 3371 3372 3373 3377 3378 3390 3397 3399 3433 3454 3468 3474 3472 3475 3473 3471 3489 3490 3495 3510 3505 3514 3516 3528 3529 3545 3544 3549 3547 3555 3556 3555 3546 3555 3556 3566 3553 3552 3578 3565 3566 3558 3544 3540 3539 3534 3535 3522 3523 3512 3508 3548 3559 3566 3561 3581 3584 3616 3624 3623 3626 3625 3624 3630 3627 3631 3618 3632 3631 3641 3648 3645 3649 3653 3663 3672 3677 3678 3686 3688 3687 3694 3684 3688 3690 3699 3703 3706 3707 3711 3718 3715 3716 3717 3718 3724 3723 3733 3737 3738 3739 3738 3741 3769 3770 3767 3770 3769 3768 3771 3743 3744 3749 3752 3755 3756 3755 3750 3751 3750 3745 3755 3757 3756 3758 3759 3769 3768 3776 3766 3774 3776 3775 3780 3801 3776 3775 3776 3789 3794 3793 3790 3773 3769 3770 3781 3782 3781 3782 3755 3762 3763 3768 3765 3780 3789 3790 3792 3795 3796 3797 3796 3789 3788 3791 3786 3785 3784 3764 3767 3771 3774 3782 3794 3811 3802 3808 3819 3806 3826 3818 3808 3809 3824 3844 3833 3834 3825 3830 3835 3839 3841 3828 3826 3835 3841 3849 3858 3851 3846 3850 3853 3863 3862 3866 3867 3873 3871 3859 3892 3887 3905 3914 3915 3909 3910 3926 3925 3933 3930 3933 3930 3920 3919 3923 3924 3920 3922 3935 3938 3940 3935 3947 3948 3952 3953 3962 3985 3984 3987 4005 4006 4007 4027 4031 4043 4042 4037 4038 4034 4037 4044 4054 4063 4081 4078 4090 4114 4125 4122 4130 4137 4142 4140 4139 4140 4139 4143 4158 4155 4151 4154 4153 4152 4148 4144 4145 4157 4145 4143 4144 4142 4143 4144 4150 4152 4153 4176 4165 4168 4175 4178 4184 4183 4182 4164 4163 4164 4177 4192 4190 4197 4216 4217 4214 4192 4193 4189 4191 4171 4172 4177 4194 4189 4187 4192 4198 4200 4210 4222 4243 4252 4253 4258 4264 4260 4261 4259 4272 4290 4318 4320 4334 4335 4336 4352 4356 4380 4400 4396 4389 4390 4393 4392 4397 4399 4397 4395 4400 4394 4403 4400 4416 4417 4424 4431 4437 4424 4422 4421 4422 4410 4417 4420 4421 4428 4439 4449 4448 4437 4414 4429 4440 4417 4418 4422 4401 4393 4402 4400 4414 4419 4392 4395 4406 4428 4429 4442 4413 4437 4447 4444 4430 4429 4438 4434 4433 4436 4422 4423 4422 4413 4415 4403 4416 4420 4386 4379 4371 4378 4381 4404 4417 4416 4418 4412 4416 4407 4400 4408 4412 4423 4421 4412 4409 4426 4424 4429 4420 4398 4404 4403 4409 4410 4418 4417 4426 4428 4447 4459 4461 4465 4478 4479 4450 4452 4454 4445 4447 4459 4482'''.strip().split('\n') a = list(map(int, a)) prev_val = 99999999 ctr = 0 for val in a: if val > prev_val: ctr += 1 prev_val = val print(ctr) #%% Part 2 """ Considering every single measurement isn't as useful as you expected: there's just too much noise in the data. Instead, consider sums of a three-measurement sliding window. Again considering the above example: 199 A 200 A B 208 A B C 210 B C D 200 E C D 207 E F D 240 E F G 269 F G H 260 G H 263 H Start by comparing the first and second three-measurement windows. The measurements in the first window are marked A (199, 200, 208); their sum is 199 + 200 + 208 = 607. The second window is marked B (200, 208, 210); its sum is 618. The sum of measurements in the second window is larger than the sum of the first, so this first comparison increased. Your goal now is to count the number of times the sum of measurements in this sliding window increases from the previous sum. So, compare A with B, then compare B with C, then C with D, and so on. Stop when there aren't enough measurements left to create a new three-measurement sum. """ prev_vals = [0, 0, 0] ctr = 0 for i, val in enumerate(a): new_vals = [prev_vals[1], prev_vals[2], val] if 0 not in prev_vals: s1 = sum(prev_vals) s2 = sum(new_vals) if s2 > s1: ctr += 1 prev_vals = new_vals print(ctr)
""" Created on Tue Nov 30 22:35:24 2021 @author: aboisvert """ "\nAs the submarine drops below the surface of the ocean, it automatically performs a sonar sweep of the nearby sea floor. On a small screen, the sonar sweep report (your puzzle input) appears: each line is a measurement of the sea floor depth as the sweep looks further and further away from the submarine.\n\nFor example, suppose you had the following report:\n\n199\n200\n208\n210\n200\n207\n240\n269\n260\n263\n\nThis report indicates that, scanning outward from the submarine, the sonar sweep found depths of 199, 200, 208, 210, and so on.\n\nThe first order of business is to figure out how quickly the depth increases, just so you know what you're dealing with - you never know if the keys will get carried into deeper water by an ocean current or a fish or something.\n\nTo do this, count the number of times a depth measurement increases from the previous measurement. (There is no measurement before the first measurement.)\n" a = '\n190\n168\n166\n163\n170\n160\n171\n166\n161\n167\n175\n178\n193\n189\n188\n191\n193\n192\n193\n180\n177\n178\n176\n177\n196\n203\n211\n209\n210\n209\n225\n219\n229\n214\n202\n205\n208\n207\n208\n204\n208\n206\n205\n208\n209\n219\n236\n241\n243\n239\n251\n278\n279\n284\n283\n287\n244\n245\n257\n253\n272\n276\n287\n288\n304\n306\n313\n312\n284\n293\n288\n289\n290\n283\n298\n309\n300\n298\n297\n291\n292\n304\n301\n303\n306\n280\n286\n266\n270\n272\n274\n269\n270\n271\n270\n266\n274\n275\n278\n280\n283\n284\n283\n267\n282\n283\n285\n286\n302\n307\n309\n311\n309\n315\n314\n317\n319\n318\n314\n313\n330\n333\n335\n365\n370\n361\n362\n367\n358\n361\n359\n358\n349\n352\n367\n355\n359\n360\n355\n357\n359\n368\n375\n383\n385\n399\n410\n413\n414\n418\n417\n418\n419\n420\n421\n422\n434\n439\n438\n440\n441\n443\n445\n444\n446\n450\n452\n463\n466\n476\n464\n467\n470\n474\n460\n473\n475\n476\n482\n481\n489\n495\n505\n503\n508\n493\n508\n509\n508\n513\n538\n536\n521\n526\n523\n536\n537\n558\n557\n563\n557\n560\n561\n560\n575\n578\n582\n583\n587\n574\n576\n581\n580\n579\n581\n599\n601\n602\n606\n607\n606\n605\n606\n607\n611\n607\n606\n605\n603\n597\n598\n593\n584\n585\n587\n619\n614\n616\n596\n627\n628\n630\n631\n634\n633\n631\n632\n641\n637\n647\n643\n651\n625\n593\n601\n602\n599\n592\n593\n597\n601\n592\n612\n611\n612\n616\n620\n622\n627\n626\n629\n632\n642\n654\n655\n657\n658\n661\n662\n653\n655\n658\n665\n674\n664\n694\n689\n692\n693\n681\n686\n687\n698\n701\n706\n687\n689\n706\n710\n716\n723\n733\n735\n734\n733\n727\n729\n744\n750\n736\n739\n745\n743\n742\n743\n741\n739\n742\n748\n755\n752\n762\n768\n767\n760\n758\n756\n765\n779\n796\n797\n798\n796\n797\n775\n779\n780\n781\n784\n794\n799\n793\n797\n795\n793\n802\n800\n809\n814\n826\n830\n820\n804\n805\n809\n816\n817\n845\n850\n861\n857\n858\n863\n868\n873\n880\n891\n865\n876\n890\n925\n927\n926\n932\n941\n942\n943\n942\n943\n942\n947\n938\n940\n943\n949\n953\n954\n966\n970\n967\n963\n961\n964\n966\n973\n983\n975\n974\n980\n977\n988\n989\n991\n989\n990\n1000\n1001\n1006\n996\n998\n997\n996\n979\n981\n1014\n1018\n1023\n996\n995\n1006\n1000\n994\n996\n999\n1001\n999\n1000\n1002\n1001\n1003\n1005\n1006\n1014\n1037\n1039\n1040\n1066\n1059\n1081\n1085\n1072\n1069\n1070\n1069\n1080\n1079\n1106\n1105\n1118\n1127\n1150\n1151\n1147\n1133\n1134\n1135\n1136\n1137\n1138\n1140\n1138\n1149\n1150\n1149\n1143\n1136\n1137\n1140\n1141\n1140\n1141\n1142\n1155\n1182\n1173\n1167\n1163\n1172\n1186\n1180\n1176\n1179\n1178\n1189\n1201\n1205\n1201\n1200\n1209\n1207\n1218\n1226\n1232\n1234\n1233\n1225\n1228\n1229\n1219\n1221\n1220\n1199\n1201\n1204\n1212\n1224\n1208\n1209\n1210\n1220\n1219\n1215\n1231\n1240\n1246\n1249\n1281\n1247\n1251\n1255\n1263\n1260\n1292\n1293\n1305\n1311\n1316\n1319\n1323\n1307\n1326\n1319\n1316\n1327\n1328\n1333\n1342\n1337\n1338\n1335\n1353\n1368\n1371\n1386\n1382\n1381\n1378\n1374\n1391\n1396\n1397\n1399\n1388\n1380\n1406\n1396\n1398\n1397\n1401\n1402\n1401\n1369\n1372\n1373\n1370\n1371\n1362\n1375\n1378\n1389\n1400\n1402\n1404\n1420\n1425\n1429\n1425\n1406\n1412\n1425\n1421\n1401\n1402\n1399\n1400\n1412\n1387\n1386\n1390\n1392\n1396\n1402\n1404\n1405\n1406\n1379\n1384\n1419\n1420\n1422\n1427\n1423\n1426\n1421\n1420\n1428\n1424\n1428\n1436\n1432\n1439\n1444\n1457\n1458\n1460\n1464\n1459\n1460\n1493\n1489\n1510\n1503\n1505\n1506\n1492\n1515\n1517\n1506\n1488\n1485\n1488\n1471\n1473\n1496\n1499\n1497\n1501\n1475\n1465\n1460\n1458\n1462\n1467\n1466\n1483\n1471\n1476\n1471\n1493\n1492\n1494\n1503\n1504\n1505\n1506\n1507\n1510\n1492\n1493\n1500\n1498\n1528\n1533\n1538\n1539\n1575\n1576\n1557\n1555\n1557\n1579\n1589\n1594\n1599\n1600\n1598\n1609\n1619\n1618\n1617\n1629\n1613\n1619\n1620\n1631\n1627\n1628\n1630\n1631\n1616\n1631\n1651\n1657\n1658\n1637\n1642\n1641\n1651\n1652\n1647\n1649\n1658\n1649\n1629\n1631\n1632\n1619\n1617\n1620\n1634\n1632\n1633\n1636\n1634\n1641\n1639\n1642\n1647\n1640\n1609\n1611\n1607\n1597\n1601\n1606\n1635\n1637\n1647\n1640\n1650\n1654\n1656\n1636\n1626\n1624\n1625\n1615\n1620\n1621\n1618\n1614\n1615\n1616\n1622\n1623\n1625\n1627\n1626\n1627\n1632\n1644\n1659\n1668\n1671\n1672\n1673\n1676\n1684\n1709\n1735\n1734\n1731\n1738\n1740\n1748\n1751\n1741\n1740\n1739\n1741\n1739\n1750\n1762\n1766\n1765\n1764\n1775\n1774\n1775\n1776\n1777\n1778\n1757\n1755\n1756\n1757\n1756\n1776\n1780\n1781\n1790\n1792\n1791\n1803\n1810\n1801\n1800\n1831\n1834\n1818\n1823\n1806\n1801\n1812\n1814\n1837\n1842\n1843\n1842\n1841\n1836\n1828\n1835\n1846\n1845\n1855\n1854\n1858\n1856\n1865\n1866\n1865\n1850\n1859\n1872\n1868\n1866\n1867\n1862\n1869\n1870\n1882\n1896\n1901\n1903\n1917\n1939\n1942\n1945\n1955\n1956\n1954\n1974\n1944\n1943\n1942\n1956\n1961\n1957\n1953\n1954\n1955\n1958\n1961\n1948\n1947\n1959\n1960\n1961\n1969\n1996\n1992\n1993\n1988\n1994\n2021\n2020\n2003\n1999\n1995\n2006\n2002\n1994\n1995\n1998\n1995\n1988\n1992\n1997\n2003\n2006\n2007\n2010\n2006\n2015\n2000\n1998\n1993\n2003\n2004\n2006\n2005\n2008\n2019\n2020\n2030\n2031\n2036\n2037\n2038\n2037\n2036\n2038\n2031\n2043\n2044\n2047\n2050\n2049\n2027\n2053\n2057\n2058\n2034\n2038\n2033\n2034\n2038\n2045\n2031\n2037\n2053\n2061\n2058\n2062\n2063\n2051\n2046\n2045\n2042\n2043\n2042\n2037\n2053\n2047\n2059\n2058\n2057\n2058\n2069\n2070\n2073\n2086\n2098\n2116\n2110\n2108\n2109\n2111\n2112\n2114\n2116\n2102\n2108\n2110\n2111\n2115\n2114\n2123\n2124\n2121\n2144\n2167\n2170\n2167\n2135\n2141\n2145\n2152\n2166\n2159\n2160\n2133\n2132\n2133\n2100\n2104\n2101\n2102\n2109\n2108\n2109\n2112\n2114\n2113\n2114\n2123\n2121\n2122\n2116\n2115\n2126\n2133\n2135\n2136\n2137\n2138\n2137\n2140\n2156\n2148\n2144\n2143\n2142\n2145\n2161\n2160\n2162\n2154\n2155\n2136\n2134\n2132\n2138\n2140\n2143\n2135\n2136\n2143\n2130\n2127\n2158\n2161\n2167\n2169\n2186\n2191\n2185\n2193\n2192\n2205\n2199\n2198\n2199\n2201\n2200\n2201\n2225\n2234\n2232\n2241\n2230\n2227\n2218\n2228\n2241\n2242\n2243\n2258\n2251\n2242\n2226\n2218\n2223\n2222\n2225\n2247\n2246\n2243\n2245\n2238\n2239\n2237\n2255\n2257\n2258\n2251\n2267\n2268\n2269\n2283\n2264\n2266\n2264\n2265\n2293\n2310\n2327\n2334\n2354\n2353\n2358\n2354\n2359\n2353\n2362\n2363\n2364\n2362\n2366\n2362\n2356\n2355\n2351\n2385\n2386\n2387\n2389\n2391\n2400\n2411\n2373\n2343\n2332\n2331\n2335\n2346\n2343\n2357\n2365\n2366\n2373\n2374\n2368\n2363\n2362\n2366\n2365\n2369\n2340\n2341\n2337\n2357\n2358\n2353\n2355\n2374\n2373\n2379\n2382\n2390\n2388\n2387\n2388\n2387\n2388\n2389\n2399\n2400\n2398\n2406\n2409\n2414\n2416\n2425\n2434\n2424\n2418\n2420\n2413\n2418\n2419\n2427\n2428\n2429\n2428\n2431\n2430\n2418\n2430\n2434\n2442\n2443\n2410\n2409\n2416\n2400\n2398\n2402\n2403\n2405\n2440\n2433\n2439\n2435\n2414\n2431\n2440\n2443\n2442\n2445\n2449\n2448\n2444\n2443\n2450\n2432\n2431\n2436\n2460\n2467\n2471\n2470\n2473\n2477\n2486\n2487\n2482\n2487\n2488\n2490\n2493\n2465\n2463\n2471\n2467\n2466\n2473\n2469\n2471\n2483\n2484\n2496\n2494\n2497\n2493\n2521\n2522\n2500\n2504\n2512\n2521\n2522\n2529\n2524\n2521\n2528\n2529\n2544\n2521\n2532\n2525\n2530\n2524\n2523\n2505\n2498\n2499\n2494\n2487\n2484\n2487\n2488\n2491\n2498\n2497\n2486\n2478\n2484\n2488\n2489\n2491\n2489\n2493\n2496\n2499\n2496\n2495\n2498\n2499\n2498\n2497\n2503\n2500\n2534\n2535\n2546\n2588\n2616\n2642\n2641\n2640\n2654\n2663\n2659\n2663\n2664\n2674\n2678\n2680\n2683\n2692\n2698\n2703\n2704\n2707\n2704\n2735\n2710\n2728\n2730\n2739\n2734\n2741\n2738\n2760\n2744\n2745\n2746\n2747\n2750\n2744\n2746\n2759\n2761\n2762\n2763\n2764\n2785\n2795\n2818\n2820\n2824\n2828\n2831\n2833\n2837\n2838\n2840\n2839\n2847\n2844\n2835\n2834\n2829\n2835\n2837\n2805\n2832\n2833\n2832\n2833\n2822\n2823\n2826\n2835\n2823\n2825\n2828\n2829\n2828\n2850\n2851\n2853\n2862\n2864\n2877\n2871\n2874\n2886\n2921\n2895\n2899\n2887\n2898\n2897\n2899\n2922\n2929\n2935\n2937\n2938\n2935\n2939\n2944\n2945\n2981\n2982\n2986\n3002\n3003\n3010\n3009\n3020\n3021\n3029\n3028\n3019\n3020\n3021\n2996\n2993\n2999\n3009\n3013\n2996\n2988\n2990\n3032\n3031\n3023\n3037\n3027\n2994\n2988\n2991\n3023\n3025\n3029\n3033\n3043\n3052\n3053\n3052\n3054\n3055\n3045\n3044\n3053\n3056\n3077\n3078\n3079\n3073\n3099\n3093\n3097\n3100\n3064\n3076\n3082\n3095\n3091\n3095\n3101\n3102\n3099\n3100\n3095\n3097\n3093\n3102\n3105\n3143\n3160\n3157\n3156\n3158\n3150\n3151\n3150\n3157\n3184\n3179\n3181\n3173\n3179\n3184\n3187\n3197\n3198\n3199\n3208\n3214\n3221\n3205\n3209\n3210\n3214\n3215\n3214\n3216\n3234\n3237\n3246\n3254\n3255\n3278\n3277\n3278\n3281\n3299\n3298\n3306\n3305\n3304\n3315\n3323\n3330\n3331\n3323\n3326\n3329\n3330\n3336\n3326\n3324\n3320\n3318\n3317\n3319\n3318\n3320\n3321\n3322\n3331\n3322\n3315\n3326\n3325\n3317\n3316\n3312\n3323\n3322\n3329\n3328\n3323\n3324\n3332\n3331\n3329\n3294\n3293\n3290\n3283\n3278\n3281\n3290\n3291\n3265\n3268\n3271\n3255\n3248\n3249\n3250\n3253\n3254\n3276\n3277\n3274\n3279\n3281\n3295\n3290\n3306\n3309\n3300\n3306\n3317\n3316\n3325\n3322\n3343\n3346\n3355\n3356\n3370\n3371\n3372\n3373\n3377\n3378\n3390\n3397\n3399\n3433\n3454\n3468\n3474\n3472\n3475\n3473\n3471\n3489\n3490\n3495\n3510\n3505\n3514\n3516\n3528\n3529\n3545\n3544\n3549\n3547\n3555\n3556\n3555\n3546\n3555\n3556\n3566\n3553\n3552\n3578\n3565\n3566\n3558\n3544\n3540\n3539\n3534\n3535\n3522\n3523\n3512\n3508\n3548\n3559\n3566\n3561\n3581\n3584\n3616\n3624\n3623\n3626\n3625\n3624\n3630\n3627\n3631\n3618\n3632\n3631\n3641\n3648\n3645\n3649\n3653\n3663\n3672\n3677\n3678\n3686\n3688\n3687\n3694\n3684\n3688\n3690\n3699\n3703\n3706\n3707\n3711\n3718\n3715\n3716\n3717\n3718\n3724\n3723\n3733\n3737\n3738\n3739\n3738\n3741\n3769\n3770\n3767\n3770\n3769\n3768\n3771\n3743\n3744\n3749\n3752\n3755\n3756\n3755\n3750\n3751\n3750\n3745\n3755\n3757\n3756\n3758\n3759\n3769\n3768\n3776\n3766\n3774\n3776\n3775\n3780\n3801\n3776\n3775\n3776\n3789\n3794\n3793\n3790\n3773\n3769\n3770\n3781\n3782\n3781\n3782\n3755\n3762\n3763\n3768\n3765\n3780\n3789\n3790\n3792\n3795\n3796\n3797\n3796\n3789\n3788\n3791\n3786\n3785\n3784\n3764\n3767\n3771\n3774\n3782\n3794\n3811\n3802\n3808\n3819\n3806\n3826\n3818\n3808\n3809\n3824\n3844\n3833\n3834\n3825\n3830\n3835\n3839\n3841\n3828\n3826\n3835\n3841\n3849\n3858\n3851\n3846\n3850\n3853\n3863\n3862\n3866\n3867\n3873\n3871\n3859\n3892\n3887\n3905\n3914\n3915\n3909\n3910\n3926\n3925\n3933\n3930\n3933\n3930\n3920\n3919\n3923\n3924\n3920\n3922\n3935\n3938\n3940\n3935\n3947\n3948\n3952\n3953\n3962\n3985\n3984\n3987\n4005\n4006\n4007\n4027\n4031\n4043\n4042\n4037\n4038\n4034\n4037\n4044\n4054\n4063\n4081\n4078\n4090\n4114\n4125\n4122\n4130\n4137\n4142\n4140\n4139\n4140\n4139\n4143\n4158\n4155\n4151\n4154\n4153\n4152\n4148\n4144\n4145\n4157\n4145\n4143\n4144\n4142\n4143\n4144\n4150\n4152\n4153\n4176\n4165\n4168\n4175\n4178\n4184\n4183\n4182\n4164\n4163\n4164\n4177\n4192\n4190\n4197\n4216\n4217\n4214\n4192\n4193\n4189\n4191\n4171\n4172\n4177\n4194\n4189\n4187\n4192\n4198\n4200\n4210\n4222\n4243\n4252\n4253\n4258\n4264\n4260\n4261\n4259\n4272\n4290\n4318\n4320\n4334\n4335\n4336\n4352\n4356\n4380\n4400\n4396\n4389\n4390\n4393\n4392\n4397\n4399\n4397\n4395\n4400\n4394\n4403\n4400\n4416\n4417\n4424\n4431\n4437\n4424\n4422\n4421\n4422\n4410\n4417\n4420\n4421\n4428\n4439\n4449\n4448\n4437\n4414\n4429\n4440\n4417\n4418\n4422\n4401\n4393\n4402\n4400\n4414\n4419\n4392\n4395\n4406\n4428\n4429\n4442\n4413\n4437\n4447\n4444\n4430\n4429\n4438\n4434\n4433\n4436\n4422\n4423\n4422\n4413\n4415\n4403\n4416\n4420\n4386\n4379\n4371\n4378\n4381\n4404\n4417\n4416\n4418\n4412\n4416\n4407\n4400\n4408\n4412\n4423\n4421\n4412\n4409\n4426\n4424\n4429\n4420\n4398\n4404\n4403\n4409\n4410\n4418\n4417\n4426\n4428\n4447\n4459\n4461\n4465\n4478\n4479\n4450\n4452\n4454\n4445\n4447\n4459\n4482'.strip().split('\n') a = list(map(int, a)) prev_val = 99999999 ctr = 0 for val in a: if val > prev_val: ctr += 1 prev_val = val print(ctr) "\nConsidering every single measurement isn't as useful as you expected: there's just too much noise in the data.\n\nInstead, consider sums of a three-measurement sliding window. Again considering the above example:\n\n199 A \n200 A B \n208 A B C \n210 B C D\n200 E C D\n207 E F D\n240 E F G \n269 F G H\n260 G H\n263 H\nStart by comparing the first and second three-measurement windows. The measurements in the first window are marked A (199, 200, 208); their sum is 199 + 200 + 208 = 607. The second window is marked B (200, 208, 210); its sum is 618. The sum of measurements in the second window is larger than the sum of the first, so this first comparison increased.\n\nYour goal now is to count the number of times the sum of measurements in this sliding window increases from the previous sum. So, compare A with B, then compare B with C, then C with D, and so on. Stop when there aren't enough measurements left to create a new three-measurement sum.\n" prev_vals = [0, 0, 0] ctr = 0 for (i, val) in enumerate(a): new_vals = [prev_vals[1], prev_vals[2], val] if 0 not in prev_vals: s1 = sum(prev_vals) s2 = sum(new_vals) if s2 > s1: ctr += 1 prev_vals = new_vals print(ctr)
def iteritems(dictonary): pass class StringIO(object): pass
def iteritems(dictonary): pass class Stringio(object): pass
def dfs(node, parent, visited, tin, low, adj:list, timer,res): visited[node] = 1 timer += 1 tin[node] = low[node] = timer for it in adj[node]: if(it == parent): continue if(visited[it] == 0): dfs(it, node, visited, tin, low, adj, timer,res) low[node] = min(low[node], low[it]) if(low[it] > tin[node]): ## check bridge condition if exist.. res.append([it ,node]) else: low[node] = min(low[node], tin[it]) def printBridges(adj, n): visited = [0]*(n) ## array for dfs tin = [-1]*(n) ## store time of insertion of every node.. low = [-1]*(n) ## store lowest time of insertion.. timer = 0 res = [] for i in range(n): if(visited[i] == 0): dfs(i, -1, visited, tin, low, adj, timer,res) return res ## Driver Code...!!!! if __name__ == "__main__": V = int(input()) adj = [[] for i in range(V)] for i in range(V): u,v = list(map(int,input().split())) adj[u].append(v) adj[v].append(u) print(printBridges(adj, V)) """ 5 0 1 0 2 1 2 1 3 3 4 """
def dfs(node, parent, visited, tin, low, adj: list, timer, res): visited[node] = 1 timer += 1 tin[node] = low[node] = timer for it in adj[node]: if it == parent: continue if visited[it] == 0: dfs(it, node, visited, tin, low, adj, timer, res) low[node] = min(low[node], low[it]) if low[it] > tin[node]: res.append([it, node]) else: low[node] = min(low[node], tin[it]) def print_bridges(adj, n): visited = [0] * n tin = [-1] * n low = [-1] * n timer = 0 res = [] for i in range(n): if visited[i] == 0: dfs(i, -1, visited, tin, low, adj, timer, res) return res if __name__ == '__main__': v = int(input()) adj = [[] for i in range(V)] for i in range(V): (u, v) = list(map(int, input().split())) adj[u].append(v) adj[v].append(u) print(print_bridges(adj, V)) '\n5\n0 1\n0 2\n1 2\n1 3\n3 4\n'
r= int(input()) pi= 3.14159 sphere= (4/3)* pi* pow(r,3) print("VOLUME = %.3f" %sphere)
r = int(input()) pi = 3.14159 sphere = 4 / 3 * pi * pow(r, 3) print('VOLUME = %.3f' % sphere)
class CoreConstraintConstants: core_constraint_slots = ( "table", "constraint_name", "constraint_definition", "UNIQUE", "PRIMARY_KEY", "FOREIGN_KEY", "REFERENCES", "CHECK", "DEFAULT", "FOR" ) core_constraint_default_values = { "table": None, "constraint_name": None, "constraint_definition": "", "UNIQUE": (), "PRIMARY_KEY": (), "FOREIGN_KEY": None, "REFERENCES": None, "CHECK": (), "DEFAULT": None, "FOR": None }
class Coreconstraintconstants: core_constraint_slots = ('table', 'constraint_name', 'constraint_definition', 'UNIQUE', 'PRIMARY_KEY', 'FOREIGN_KEY', 'REFERENCES', 'CHECK', 'DEFAULT', 'FOR') core_constraint_default_values = {'table': None, 'constraint_name': None, 'constraint_definition': '', 'UNIQUE': (), 'PRIMARY_KEY': (), 'FOREIGN_KEY': None, 'REFERENCES': None, 'CHECK': (), 'DEFAULT': None, 'FOR': None}
# -*- coding: utf-8 -*- COMMIT_AUTHOR_NAME = 'Mimiron' COMMIT_AUTHOR_EMAIL = ''
commit_author_name = 'Mimiron' commit_author_email = ''
class LookupBindingPropertiesAttribute(Attribute,_Attribute): """ Specifies the properties that support lookup-based binding. This class cannot be inherited. LookupBindingPropertiesAttribute() LookupBindingPropertiesAttribute(dataSource: str,displayMember: str,valueMember: str,lookupMember: str) """ def Equals(self,obj): """ Equals(self: LookupBindingPropertiesAttribute,obj: object) -> bool Determines whether the specified System.Object is equal to the current System.ComponentModel.LookupBindingPropertiesAttribute instance. obj: The System.Object to compare with the current System.ComponentModel.LookupBindingPropertiesAttribute instance Returns: true if the object is equal to the current instance; otherwise,false, indicating they are not equal. """ pass def GetHashCode(self): """ GetHashCode(self: LookupBindingPropertiesAttribute) -> int Returns the hash code for this instance. Returns: A hash code for the current System.ComponentModel.LookupBindingPropertiesAttribute. """ pass def __eq__(self,*args): """ x.__eq__(y) <==> x==y """ pass def __init__(self,*args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self,dataSource=None,displayMember=None,valueMember=None,lookupMember=None): """ __new__(cls: type) __new__(cls: type,dataSource: str,displayMember: str,valueMember: str,lookupMember: str) """ pass def __ne__(self,*args): pass DataSource=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the name of the data source property for the component to which the System.ComponentModel.LookupBindingPropertiesAttribute is bound. Get: DataSource(self: LookupBindingPropertiesAttribute) -> str """ DisplayMember=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the name of the display member property for the component to which the System.ComponentModel.LookupBindingPropertiesAttribute is bound. Get: DisplayMember(self: LookupBindingPropertiesAttribute) -> str """ LookupMember=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the name of the lookup member for the component to which this attribute is bound. Get: LookupMember(self: LookupBindingPropertiesAttribute) -> str """ ValueMember=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the name of the value member property for the component to which the System.ComponentModel.LookupBindingPropertiesAttribute is bound. Get: ValueMember(self: LookupBindingPropertiesAttribute) -> str """ Default=None
class Lookupbindingpropertiesattribute(Attribute, _Attribute): """ Specifies the properties that support lookup-based binding. This class cannot be inherited. LookupBindingPropertiesAttribute() LookupBindingPropertiesAttribute(dataSource: str,displayMember: str,valueMember: str,lookupMember: str) """ def equals(self, obj): """ Equals(self: LookupBindingPropertiesAttribute,obj: object) -> bool Determines whether the specified System.Object is equal to the current System.ComponentModel.LookupBindingPropertiesAttribute instance. obj: The System.Object to compare with the current System.ComponentModel.LookupBindingPropertiesAttribute instance Returns: true if the object is equal to the current instance; otherwise,false, indicating they are not equal. """ pass def get_hash_code(self): """ GetHashCode(self: LookupBindingPropertiesAttribute) -> int Returns the hash code for this instance. Returns: A hash code for the current System.ComponentModel.LookupBindingPropertiesAttribute. """ pass def __eq__(self, *args): """ x.__eq__(y) <==> x==y """ pass def __init__(self, *args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self, dataSource=None, displayMember=None, valueMember=None, lookupMember=None): """ __new__(cls: type) __new__(cls: type,dataSource: str,displayMember: str,valueMember: str,lookupMember: str) """ pass def __ne__(self, *args): pass data_source = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the name of the data source property for the component to which the System.ComponentModel.LookupBindingPropertiesAttribute is bound.\n\n\n\nGet: DataSource(self: LookupBindingPropertiesAttribute) -> str\n\n\n\n' display_member = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the name of the display member property for the component to which the System.ComponentModel.LookupBindingPropertiesAttribute is bound.\n\n\n\nGet: DisplayMember(self: LookupBindingPropertiesAttribute) -> str\n\n\n\n' lookup_member = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the name of the lookup member for the component to which this attribute is bound.\n\n\n\nGet: LookupMember(self: LookupBindingPropertiesAttribute) -> str\n\n\n\n' value_member = property(lambda self: object(), lambda self, v: None, lambda self: None) 'Gets the name of the value member property for the component to which the System.ComponentModel.LookupBindingPropertiesAttribute is bound.\n\n\n\nGet: ValueMember(self: LookupBindingPropertiesAttribute) -> str\n\n\n\n' default = None
# # PySNMP MIB module IP-FORWARD-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/IP-FORWARD-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:17:45 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52) # ( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") ( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ( ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ConstraintsUnion, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ConstraintsUnion") ( IANAipRouteProtocol, ) = mibBuilder.importSymbols("IANA-RTPROTO-MIB", "IANAipRouteProtocol") ( InterfaceIndexOrZero, ) = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero") ( InetAutonomousSystemNumber, InetAddressPrefixLength, InetAddressType, InetAddress, ) = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAutonomousSystemNumber", "InetAddressPrefixLength", "InetAddressType", "InetAddress") ( ip, ) = mibBuilder.importSymbols("IP-MIB", "ip") ( ModuleCompliance, ObjectGroup, NotificationGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "ObjectGroup", "NotificationGroup") ( Unsigned32, ModuleIdentity, Gauge32, Counter64, MibIdentifier, iso, Counter32, NotificationType, ObjectIdentity, Bits, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Integer32, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "ModuleIdentity", "Gauge32", "Counter64", "MibIdentifier", "iso", "Counter32", "NotificationType", "ObjectIdentity", "Bits", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Integer32") ( RowStatus, TextualConvention, DisplayString, ) = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "TextualConvention", "DisplayString") ipForward = ModuleIdentity((1, 3, 6, 1, 2, 1, 4, 24)).setRevisions(("2006-02-01 00:00", "1996-09-19 00:00", "1992-07-02 21:56",)) if mibBuilder.loadTexts: ipForward.setLastUpdated('200602010000Z') if mibBuilder.loadTexts: ipForward.setOrganization('IETF IPv6 Working Group\n http://www.ietf.org/html.charters/ipv6-charter.html') if mibBuilder.loadTexts: ipForward.setContactInfo('Editor:\n Brian Haberman\n Johns Hopkins University - Applied Physics Laboratory\n Mailstop 17-S442\n 11100 Johns Hopkins Road\n Laurel MD, 20723-6099 USA\n\n Phone: +1-443-778-1319\n Email: brian@innovationslab.net\n\n Send comments to <ipv6@ietf.org>') if mibBuilder.loadTexts: ipForward.setDescription('The MIB module for the management of CIDR multipath IP\n Routes.\n\n Copyright (C) The Internet Society (2006). This version\n of this MIB module is a part of RFC 4292; see the RFC\n itself for full legal notices.') inetCidrRouteNumber = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 6), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: inetCidrRouteNumber.setDescription('The number of current inetCidrRouteTable entries that\n are not invalid.') inetCidrRouteDiscards = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 8), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: inetCidrRouteDiscards.setDescription('The number of valid route entries discarded from the\n inetCidrRouteTable. Discarded route entries do not\n appear in the inetCidrRouteTable. One possible reason\n for discarding an entry would be to free-up buffer space\n for other route table entries.') inetCidrRouteTable = MibTable((1, 3, 6, 1, 2, 1, 4, 24, 7), ) if mibBuilder.loadTexts: inetCidrRouteTable.setDescription("This entity's IP Routing table.") inetCidrRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 24, 7, 1), ).setIndexNames((0, "IP-FORWARD-MIB", "inetCidrRouteDestType"), (0, "IP-FORWARD-MIB", "inetCidrRouteDest"), (0, "IP-FORWARD-MIB", "inetCidrRoutePfxLen"), (0, "IP-FORWARD-MIB", "inetCidrRoutePolicy"), (0, "IP-FORWARD-MIB", "inetCidrRouteNextHopType"), (0, "IP-FORWARD-MIB", "inetCidrRouteNextHop")) if mibBuilder.loadTexts: inetCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy (as reflected in the\n inetCidrRoutePolicy object).\n\n Dynamically created rows will survive an agent reboot.\n\n Implementers need to be aware that if the total number\n of elements (octets or sub-identifiers) in\n inetCidrRouteDest, inetCidrRoutePolicy, and\n inetCidrRouteNextHop exceeds 111, then OIDs of column\n instances in this table will have more than 128 sub-\n identifiers and cannot be accessed using SNMPv1,\n SNMPv2c, or SNMPv3.') inetCidrRouteDestType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 1), InetAddressType()) if mibBuilder.loadTexts: inetCidrRouteDestType.setDescription('The type of the inetCidrRouteDest address, as defined\n in the InetAddress MIB.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.') inetCidrRouteDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 2), InetAddress()) if mibBuilder.loadTexts: inetCidrRouteDest.setDescription('The destination IP address of this route.\n\n The type of this address is determined by the value of\n the inetCidrRouteDestType object.\n\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.') inetCidrRoutePfxLen = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 3), InetAddressPrefixLength()) if mibBuilder.loadTexts: inetCidrRoutePfxLen.setDescription('Indicates the number of leading one bits that form the\n mask to be logical-ANDed with the destination address\n before being compared to the value in the\n inetCidrRouteDest field.\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.') inetCidrRoutePolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 4), ObjectIdentifier()) if mibBuilder.loadTexts: inetCidrRoutePolicy.setDescription('This object is an opaque object without any defined\n semantics. Its purpose is to serve as an additional\n index that may delineate between multiple entries to\n the same destination. The value { 0 0 } shall be used\n as the default value for this object.') inetCidrRouteNextHopType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 5), InetAddressType()) if mibBuilder.loadTexts: inetCidrRouteNextHopType.setDescription('The type of the inetCidrRouteNextHop address, as\n defined in the InetAddress MIB.\n\n Value should be set to unknown(0) for non-remote\n routes.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.') inetCidrRouteNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 6), InetAddress()) if mibBuilder.loadTexts: inetCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route. For non-remote routes, a zero length string.\n The type of this address is determined by the value of\n the inetCidrRouteNextHopType object.') inetCidrRouteIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 7), InterfaceIndexOrZero()).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached. A value of 0 is valid and represents the\n scenario where no interface is specified.') inetCidrRouteType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5,))).clone(namedValues=NamedValues(("other", 1), ("reject", 2), ("local", 3), ("remote", 4), ("blackhole", 5),))).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject(2) refers to a route that, if matched, discards\n the message as unreachable and returns a notification\n (e.g., ICMP error) to the message sender. This is used\n in some protocols as a means of correctly aggregating\n routes.\n\n blackhole(5) refers to a route that, if matched,\n discards the message silently.') inetCidrRouteProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 9), IANAipRouteProtocol()).setMaxAccess("readonly") if mibBuilder.loadTexts: inetCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.') inetCidrRouteAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 10), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: inetCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of 'too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.") inetCidrRouteNextHopAS = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 11), InetAutonomousSystemNumber()).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.") inetCidrRouteMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 12), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inetCidrRouteMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 13), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inetCidrRouteMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 14), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inetCidrRouteMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 15), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inetCidrRouteMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 16), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inetCidrRouteStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 17), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: inetCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.\n\n A row entry cannot be modified when the status is\n marked as active(1).') ipForwardConformance = MibIdentifier((1, 3, 6, 1, 2, 1, 4, 24, 5)) ipForwardGroups = MibIdentifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 1)) ipForwardCompliances = MibIdentifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 2)) ipForwardFullCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 3)).setObjects(*(("IP-FORWARD-MIB", "inetForwardCidrRouteGroup"),)) if mibBuilder.loadTexts: ipForwardFullCompliance.setDescription('When this MIB is implemented for read-create, the\n implementation can claim full compliance.\n\n There are a number of INDEX objects that cannot be\n represented in the form of OBJECT clauses in SMIv2,\n but for which there are compliance requirements,\n expressed in OBJECT clause form in this description:\n\n -- OBJECT inetCidrRouteDestType\n -- SYNTAX InetAddressType (ipv4(1), ipv6(2),\n -- ipv4z(3), ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteDest\n -- SYNTAX InetAddress (SIZE (4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHopType\n -- SYNTAX InetAddressType (unknown(0), ipv4(1),\n -- ipv6(2), ipv4z(3)\n -- ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHop\n -- SYNTAX InetAddress (SIZE (0 | 4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n ') ipForwardReadOnlyCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 4)).setObjects(*(("IP-FORWARD-MIB", "inetForwardCidrRouteGroup"),)) if mibBuilder.loadTexts: ipForwardReadOnlyCompliance.setDescription('When this MIB is implemented without support for read-\n create (i.e., in read-only mode), the implementation can\n claim read-only compliance.') inetForwardCidrRouteGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 4)).setObjects(*(("IP-FORWARD-MIB", "inetCidrRouteDiscards"), ("IP-FORWARD-MIB", "inetCidrRouteIfIndex"), ("IP-FORWARD-MIB", "inetCidrRouteType"), ("IP-FORWARD-MIB", "inetCidrRouteProto"), ("IP-FORWARD-MIB", "inetCidrRouteAge"), ("IP-FORWARD-MIB", "inetCidrRouteNextHopAS"), ("IP-FORWARD-MIB", "inetCidrRouteMetric1"), ("IP-FORWARD-MIB", "inetCidrRouteMetric2"), ("IP-FORWARD-MIB", "inetCidrRouteMetric3"), ("IP-FORWARD-MIB", "inetCidrRouteMetric4"), ("IP-FORWARD-MIB", "inetCidrRouteMetric5"), ("IP-FORWARD-MIB", "inetCidrRouteStatus"), ("IP-FORWARD-MIB", "inetCidrRouteNumber"),)) if mibBuilder.loadTexts: inetForwardCidrRouteGroup.setDescription('The IP version-independent CIDR Route Table.') ipCidrRouteNumber = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 3), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteNumber.setDescription('The number of current ipCidrRouteTable entries that are\n not invalid. This object is deprecated in favor of\n inetCidrRouteNumber and the inetCidrRouteTable.') ipCidrRouteTable = MibTable((1, 3, 6, 1, 2, 1, 4, 24, 4), ) if mibBuilder.loadTexts: ipCidrRouteTable.setDescription("This entity's IP Routing table. This table has been\n deprecated in favor of the IP version neutral\n inetCidrRouteTable.") ipCidrRouteEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 24, 4, 1), ).setIndexNames((0, "IP-FORWARD-MIB", "ipCidrRouteDest"), (0, "IP-FORWARD-MIB", "ipCidrRouteMask"), (0, "IP-FORWARD-MIB", "ipCidrRouteTos"), (0, "IP-FORWARD-MIB", "ipCidrRouteNextHop")) if mibBuilder.loadTexts: ipCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy.') ipCidrRouteDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteDest.setDescription('The destination IP address of this route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteMask object is\n not equal to x.') ipCidrRouteMask = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipCidrRouteDest field. For those systems that\n do not support arbitrary subnet masks, an agent\n constructs the value of the ipCidrRouteMask by\n reference to the IP Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteDest object is\n not equal to ipCidrRouteDest.') ipCidrRouteTos = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteTos.setDescription('The policy specifier is the IP TOS Field. The encoding\n of IP TOS is as specified by the following convention.\n Zero indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30') ipCidrRouteNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 4), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route; Otherwise, 0.0.0.0.') ipCidrRouteIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 5), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.') ipCidrRouteType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4,))).clone(namedValues=NamedValues(("other", 1), ("reject", 2), ("local", 3), ("remote", 4),))).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject (2) refers to a route that, if matched,\n discards the message as unreachable. This is used in\n some protocols as a means of correctly aggregating\n routes.') ipCidrRouteProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,))).clone(namedValues=NamedValues(("other", 1), ("local", 2), ("netmgmt", 3), ("icmp", 4), ("egp", 5), ("ggp", 6), ("hello", 7), ("rip", 8), ("isIs", 9), ("esIs", 10), ("ciscoIgrp", 11), ("bbnSpfIgp", 12), ("ospf", 13), ("bgp", 14), ("idpr", 15), ("ciscoEigrp", 16),))).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.') ipCidrRouteAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.") ipCidrRouteInfo = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 9), ObjectIdentifier()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipCidrRouteProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.") ipCidrRouteNextHopAS = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 10), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.") ipCidrRouteMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 11), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ipCidrRouteMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 12), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ipCidrRouteMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 13), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ipCidrRouteMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 14), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ipCidrRouteMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 15), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ipCidrRouteStatus = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 16), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.') ipForwardCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 1)).setObjects(*(("IP-FORWARD-MIB", "ipForwardCidrRouteGroup"),)) if mibBuilder.loadTexts: ipForwardCompliance.setDescription('The compliance statement for SNMPv2 entities that\n implement the ipForward MIB.\n\n This compliance statement has been deprecated and\n replaced with ipForwardFullCompliance and\n ipForwardReadOnlyCompliance.') ipForwardCidrRouteGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 3)).setObjects(*(("IP-FORWARD-MIB", "ipCidrRouteNumber"), ("IP-FORWARD-MIB", "ipCidrRouteDest"), ("IP-FORWARD-MIB", "ipCidrRouteMask"), ("IP-FORWARD-MIB", "ipCidrRouteTos"), ("IP-FORWARD-MIB", "ipCidrRouteNextHop"), ("IP-FORWARD-MIB", "ipCidrRouteIfIndex"), ("IP-FORWARD-MIB", "ipCidrRouteType"), ("IP-FORWARD-MIB", "ipCidrRouteProto"), ("IP-FORWARD-MIB", "ipCidrRouteAge"), ("IP-FORWARD-MIB", "ipCidrRouteInfo"), ("IP-FORWARD-MIB", "ipCidrRouteNextHopAS"), ("IP-FORWARD-MIB", "ipCidrRouteMetric1"), ("IP-FORWARD-MIB", "ipCidrRouteMetric2"), ("IP-FORWARD-MIB", "ipCidrRouteMetric3"), ("IP-FORWARD-MIB", "ipCidrRouteMetric4"), ("IP-FORWARD-MIB", "ipCidrRouteMetric5"), ("IP-FORWARD-MIB", "ipCidrRouteStatus"),)) if mibBuilder.loadTexts: ipForwardCidrRouteGroup.setDescription('The CIDR Route Table.\n\n This group has been deprecated and replaced with\n inetForwardCidrRouteGroup.') ipForwardNumber = MibScalar((1, 3, 6, 1, 2, 1, 4, 24, 1), Gauge32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipForwardNumber.setDescription('The number of current ipForwardTable entries that are\n not invalid.') ipForwardTable = MibTable((1, 3, 6, 1, 2, 1, 4, 24, 2), ) if mibBuilder.loadTexts: ipForwardTable.setDescription("This entity's IP Routing table.") ipForwardEntry = MibTableRow((1, 3, 6, 1, 2, 1, 4, 24, 2, 1), ).setIndexNames((0, "IP-FORWARD-MIB", "ipForwardDest"), (0, "IP-FORWARD-MIB", "ipForwardProto"), (0, "IP-FORWARD-MIB", "ipForwardPolicy"), (0, "IP-FORWARD-MIB", "ipForwardNextHop")) if mibBuilder.loadTexts: ipForwardEntry.setDescription('A particular route to a particular destination, under a\n particular policy.') ipForwardDest = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipForwardDest.setDescription('The destination IP address of this route. An entry\n with a value of 0.0.0.0 is considered a default route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardMask object is\n not equal to x.') ipForwardMask = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 2), IpAddress().clone(hexValue="00000000")).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipForwardDest field. For those systems that do\n not support arbitrary subnet masks, an agent constructs\n the value of the ipForwardMask by reference to the IP\n Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardDest object is\n not equal to ipForwardDest.') ipForwardPolicy = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0,2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: ipForwardPolicy.setDescription("The general set of conditions that would cause\n the selection of one multipath route (set of\n next hops for a given destination) is referred\n to as 'policy'.\n\n Unless the mechanism indicated by ipForwardProto\n specifies otherwise, the policy specifier is\n the IP TOS Field. The encoding of IP TOS is as\n specified by the following convention. Zero\n indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30\n\n Protocols defining 'policy' otherwise must either\n define a set of values that are valid for\n this object or must implement an integer-instanced\n policy table for which this object's\n value acts as an index.") ipForwardNextHop = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 4), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipForwardNextHop.setDescription('On remote routes, the address of the next system en\n route; otherwise, 0.0.0.0.') ipForwardIfIndex = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 5), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.') ipForwardType = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4,))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("local", 3), ("remote", 4),)).clone('invalid')).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Setting this object to the value invalid(2) has the\n effect of invalidating the corresponding entry in the\n ipForwardTable object. That is, it effectively\n disassociates the destination identified with said\n entry from the route identified with said entry. It is\n an implementation-specific matter as to whether the\n agent removes an invalidated entry from the table.\n Accordingly, management stations must be prepared to\n receive tabular information from agents that\n corresponds to entries not currently in use. Proper\n interpretation of such entries requires examination of\n the relevant ipForwardType object.') ipForwardProto = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,))).clone(namedValues=NamedValues(("other", 1), ("local", 2), ("netmgmt", 3), ("icmp", 4), ("egp", 5), ("ggp", 6), ("hello", 7), ("rip", 8), ("is-is", 9), ("es-is", 10), ("ciscoIgrp", 11), ("bbnSpfIgp", 12), ("ospf", 13), ("bgp", 14), ("idpr", 15),))).setMaxAccess("readonly") if mibBuilder.loadTexts: ipForwardProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.') ipForwardAge = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: ipForwardAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied except through\n knowledge of the routing protocol by which the route\n was learned.") ipForwardInfo = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 9), ObjectIdentifier()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipForwardProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.") ipForwardNextHopAS = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 10), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardNextHopAS.setDescription('The Autonomous System Number of the Next Hop. When\n this is unknown or not relevant to the protocol\n indicated by ipForwardProto, zero.') ipForwardMetric1 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 11), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ipForwardMetric2 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 12), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ipForwardMetric3 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 13), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ipForwardMetric4 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 14), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ipForwardMetric5 = MibTableColumn((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 15), Integer32().clone(-1)).setMaxAccess("readcreate") if mibBuilder.loadTexts: ipForwardMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ipForwardOldCompliance = ModuleCompliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 2)).setObjects(*(("IP-FORWARD-MIB", "ipForwardMultiPathGroup"),)) if mibBuilder.loadTexts: ipForwardOldCompliance.setDescription('The compliance statement for SNMP entities that\n implement the ipForward MIB.') ipForwardMultiPathGroup = ObjectGroup((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 2)).setObjects(*(("IP-FORWARD-MIB", "ipForwardNumber"), ("IP-FORWARD-MIB", "ipForwardDest"), ("IP-FORWARD-MIB", "ipForwardMask"), ("IP-FORWARD-MIB", "ipForwardPolicy"), ("IP-FORWARD-MIB", "ipForwardNextHop"), ("IP-FORWARD-MIB", "ipForwardIfIndex"), ("IP-FORWARD-MIB", "ipForwardType"), ("IP-FORWARD-MIB", "ipForwardProto"), ("IP-FORWARD-MIB", "ipForwardAge"), ("IP-FORWARD-MIB", "ipForwardInfo"), ("IP-FORWARD-MIB", "ipForwardNextHopAS"), ("IP-FORWARD-MIB", "ipForwardMetric1"), ("IP-FORWARD-MIB", "ipForwardMetric2"), ("IP-FORWARD-MIB", "ipForwardMetric3"), ("IP-FORWARD-MIB", "ipForwardMetric4"), ("IP-FORWARD-MIB", "ipForwardMetric5"),)) if mibBuilder.loadTexts: ipForwardMultiPathGroup.setDescription('IP Multipath Route Table.') mibBuilder.exportSymbols("IP-FORWARD-MIB", inetCidrRouteAge=inetCidrRouteAge, ipForwardFullCompliance=ipForwardFullCompliance, inetCidrRouteDest=inetCidrRouteDest, ipCidrRouteInfo=ipCidrRouteInfo, ipForwardNextHop=ipForwardNextHop, ipForwardConformance=ipForwardConformance, PYSNMP_MODULE_ID=ipForward, inetCidrRouteMetric5=inetCidrRouteMetric5, inetCidrRouteEntry=inetCidrRouteEntry, inetCidrRouteIfIndex=inetCidrRouteIfIndex, ipForwardNextHopAS=ipForwardNextHopAS, ipCidrRouteIfIndex=ipCidrRouteIfIndex, inetCidrRouteMetric2=inetCidrRouteMetric2, ipForwardInfo=ipForwardInfo, ipForwardDest=ipForwardDest, inetCidrRouteMetric1=inetCidrRouteMetric1, ipForwardEntry=ipForwardEntry, inetCidrRouteNextHop=inetCidrRouteNextHop, ipCidrRouteNextHopAS=ipCidrRouteNextHopAS, ipCidrRouteNumber=ipCidrRouteNumber, ipForwardMask=ipForwardMask, ipForwardPolicy=ipForwardPolicy, ipCidrRouteProto=ipCidrRouteProto, ipCidrRouteMetric2=ipCidrRouteMetric2, ipForward=ipForward, ipCidrRouteMetric4=ipCidrRouteMetric4, inetForwardCidrRouteGroup=inetForwardCidrRouteGroup, ipForwardMetric3=ipForwardMetric3, ipForwardCompliances=ipForwardCompliances, ipForwardReadOnlyCompliance=ipForwardReadOnlyCompliance, ipCidrRouteMask=ipCidrRouteMask, ipForwardIfIndex=ipForwardIfIndex, ipForwardCompliance=ipForwardCompliance, ipCidrRouteMetric3=ipCidrRouteMetric3, ipForwardProto=ipForwardProto, ipForwardMetric4=ipForwardMetric4, inetCidrRouteDiscards=inetCidrRouteDiscards, ipCidrRouteNextHop=ipCidrRouteNextHop, ipForwardTable=ipForwardTable, ipCidrRouteAge=ipCidrRouteAge, inetCidrRouteNextHopAS=inetCidrRouteNextHopAS, inetCidrRouteTable=inetCidrRouteTable, inetCidrRoutePolicy=inetCidrRoutePolicy, ipCidrRouteType=ipCidrRouteType, ipForwardOldCompliance=ipForwardOldCompliance, ipForwardGroups=ipForwardGroups, ipForwardMetric1=ipForwardMetric1, ipForwardNumber=ipForwardNumber, inetCidrRouteProto=inetCidrRouteProto, ipForwardMetric2=ipForwardMetric2, ipForwardAge=ipForwardAge, inetCidrRouteMetric3=inetCidrRouteMetric3, inetCidrRoutePfxLen=inetCidrRoutePfxLen, ipCidrRouteEntry=ipCidrRouteEntry, ipCidrRouteMetric5=ipCidrRouteMetric5, ipForwardType=ipForwardType, ipCidrRouteTable=ipCidrRouteTable, ipForwardMultiPathGroup=ipForwardMultiPathGroup, inetCidrRouteStatus=inetCidrRouteStatus, ipCidrRouteDest=ipCidrRouteDest, ipForwardMetric5=ipForwardMetric5, ipCidrRouteTos=ipCidrRouteTos, inetCidrRouteType=inetCidrRouteType, inetCidrRouteNumber=inetCidrRouteNumber, ipCidrRouteStatus=ipCidrRouteStatus, ipForwardCidrRouteGroup=ipForwardCidrRouteGroup, ipCidrRouteMetric1=ipCidrRouteMetric1, inetCidrRouteMetric4=inetCidrRouteMetric4, inetCidrRouteNextHopType=inetCidrRouteNextHopType, inetCidrRouteDestType=inetCidrRouteDestType)
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'SingleValueConstraint', 'ConstraintsUnion') (ian_aip_route_protocol,) = mibBuilder.importSymbols('IANA-RTPROTO-MIB', 'IANAipRouteProtocol') (interface_index_or_zero,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero') (inet_autonomous_system_number, inet_address_prefix_length, inet_address_type, inet_address) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAutonomousSystemNumber', 'InetAddressPrefixLength', 'InetAddressType', 'InetAddress') (ip,) = mibBuilder.importSymbols('IP-MIB', 'ip') (module_compliance, object_group, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'ObjectGroup', 'NotificationGroup') (unsigned32, module_identity, gauge32, counter64, mib_identifier, iso, counter32, notification_type, object_identity, bits, ip_address, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'Unsigned32', 'ModuleIdentity', 'Gauge32', 'Counter64', 'MibIdentifier', 'iso', 'Counter32', 'NotificationType', 'ObjectIdentity', 'Bits', 'IpAddress', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks', 'Integer32') (row_status, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'TextualConvention', 'DisplayString') ip_forward = module_identity((1, 3, 6, 1, 2, 1, 4, 24)).setRevisions(('2006-02-01 00:00', '1996-09-19 00:00', '1992-07-02 21:56')) if mibBuilder.loadTexts: ipForward.setLastUpdated('200602010000Z') if mibBuilder.loadTexts: ipForward.setOrganization('IETF IPv6 Working Group\n http://www.ietf.org/html.charters/ipv6-charter.html') if mibBuilder.loadTexts: ipForward.setContactInfo('Editor:\n Brian Haberman\n Johns Hopkins University - Applied Physics Laboratory\n Mailstop 17-S442\n 11100 Johns Hopkins Road\n Laurel MD, 20723-6099 USA\n\n Phone: +1-443-778-1319\n Email: brian@innovationslab.net\n\n Send comments to <ipv6@ietf.org>') if mibBuilder.loadTexts: ipForward.setDescription('The MIB module for the management of CIDR multipath IP\n Routes.\n\n Copyright (C) The Internet Society (2006). This version\n of this MIB module is a part of RFC 4292; see the RFC\n itself for full legal notices.') inet_cidr_route_number = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 6), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: inetCidrRouteNumber.setDescription('The number of current inetCidrRouteTable entries that\n are not invalid.') inet_cidr_route_discards = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 8), counter32()).setMaxAccess('readonly') if mibBuilder.loadTexts: inetCidrRouteDiscards.setDescription('The number of valid route entries discarded from the\n inetCidrRouteTable. Discarded route entries do not\n appear in the inetCidrRouteTable. One possible reason\n for discarding an entry would be to free-up buffer space\n for other route table entries.') inet_cidr_route_table = mib_table((1, 3, 6, 1, 2, 1, 4, 24, 7)) if mibBuilder.loadTexts: inetCidrRouteTable.setDescription("This entity's IP Routing table.") inet_cidr_route_entry = mib_table_row((1, 3, 6, 1, 2, 1, 4, 24, 7, 1)).setIndexNames((0, 'IP-FORWARD-MIB', 'inetCidrRouteDestType'), (0, 'IP-FORWARD-MIB', 'inetCidrRouteDest'), (0, 'IP-FORWARD-MIB', 'inetCidrRoutePfxLen'), (0, 'IP-FORWARD-MIB', 'inetCidrRoutePolicy'), (0, 'IP-FORWARD-MIB', 'inetCidrRouteNextHopType'), (0, 'IP-FORWARD-MIB', 'inetCidrRouteNextHop')) if mibBuilder.loadTexts: inetCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy (as reflected in the\n inetCidrRoutePolicy object).\n\n Dynamically created rows will survive an agent reboot.\n\n Implementers need to be aware that if the total number\n of elements (octets or sub-identifiers) in\n inetCidrRouteDest, inetCidrRoutePolicy, and\n inetCidrRouteNextHop exceeds 111, then OIDs of column\n instances in this table will have more than 128 sub-\n identifiers and cannot be accessed using SNMPv1,\n SNMPv2c, or SNMPv3.') inet_cidr_route_dest_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 1), inet_address_type()) if mibBuilder.loadTexts: inetCidrRouteDestType.setDescription('The type of the inetCidrRouteDest address, as defined\n in the InetAddress MIB.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.') inet_cidr_route_dest = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 2), inet_address()) if mibBuilder.loadTexts: inetCidrRouteDest.setDescription('The destination IP address of this route.\n\n The type of this address is determined by the value of\n the inetCidrRouteDestType object.\n\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.') inet_cidr_route_pfx_len = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 3), inet_address_prefix_length()) if mibBuilder.loadTexts: inetCidrRoutePfxLen.setDescription('Indicates the number of leading one bits that form the\n mask to be logical-ANDed with the destination address\n before being compared to the value in the\n inetCidrRouteDest field.\n The values for the index objects inetCidrRouteDest and\n inetCidrRoutePfxLen must be consistent. When the value\n of inetCidrRouteDest (excluding the zone index, if one\n is present) is x, then the bitwise logical-AND\n of x with the value of the mask formed from the\n corresponding index object inetCidrRoutePfxLen MUST be\n equal to x. If not, then the index pair is not\n consistent and an inconsistentName error must be\n returned on SET or CREATE requests.') inet_cidr_route_policy = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 4), object_identifier()) if mibBuilder.loadTexts: inetCidrRoutePolicy.setDescription('This object is an opaque object without any defined\n semantics. Its purpose is to serve as an additional\n index that may delineate between multiple entries to\n the same destination. The value { 0 0 } shall be used\n as the default value for this object.') inet_cidr_route_next_hop_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 5), inet_address_type()) if mibBuilder.loadTexts: inetCidrRouteNextHopType.setDescription('The type of the inetCidrRouteNextHop address, as\n defined in the InetAddress MIB.\n\n Value should be set to unknown(0) for non-remote\n routes.\n\n Only those address types that may appear in an actual\n routing table are allowed as values of this object.') inet_cidr_route_next_hop = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 6), inet_address()) if mibBuilder.loadTexts: inetCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route. For non-remote routes, a zero length string.\n The type of this address is determined by the value of\n the inetCidrRouteNextHopType object.') inet_cidr_route_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 7), interface_index_or_zero()).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached. A value of 0 is valid and represents the\n scenario where no interface is specified.') inet_cidr_route_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('reject', 2), ('local', 3), ('remote', 4), ('blackhole', 5)))).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject(2) refers to a route that, if matched, discards\n the message as unreachable and returns a notification\n (e.g., ICMP error) to the message sender. This is used\n in some protocols as a means of correctly aggregating\n routes.\n\n blackhole(5) refers to a route that, if matched,\n discards the message silently.') inet_cidr_route_proto = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 9), ian_aip_route_protocol()).setMaxAccess('readonly') if mibBuilder.loadTexts: inetCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.') inet_cidr_route_age = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 10), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: inetCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of 'too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.") inet_cidr_route_next_hop_as = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 11), inet_autonomous_system_number()).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.") inet_cidr_route_metric1 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 12), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inet_cidr_route_metric2 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 13), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inet_cidr_route_metric3 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 14), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inet_cidr_route_metric4 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 15), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inet_cidr_route_metric5 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 16), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's inetCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") inet_cidr_route_status = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 7, 1, 17), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: inetCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.\n\n A row entry cannot be modified when the status is\n marked as active(1).') ip_forward_conformance = mib_identifier((1, 3, 6, 1, 2, 1, 4, 24, 5)) ip_forward_groups = mib_identifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 1)) ip_forward_compliances = mib_identifier((1, 3, 6, 1, 2, 1, 4, 24, 5, 2)) ip_forward_full_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 3)).setObjects(*(('IP-FORWARD-MIB', 'inetForwardCidrRouteGroup'),)) if mibBuilder.loadTexts: ipForwardFullCompliance.setDescription('When this MIB is implemented for read-create, the\n implementation can claim full compliance.\n\n There are a number of INDEX objects that cannot be\n represented in the form of OBJECT clauses in SMIv2,\n but for which there are compliance requirements,\n expressed in OBJECT clause form in this description:\n\n -- OBJECT inetCidrRouteDestType\n -- SYNTAX InetAddressType (ipv4(1), ipv6(2),\n -- ipv4z(3), ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteDest\n -- SYNTAX InetAddress (SIZE (4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHopType\n -- SYNTAX InetAddressType (unknown(0), ipv4(1),\n -- ipv6(2), ipv4z(3)\n -- ipv6z(4))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global ipv4 and ipv6 addresses.\n --\n -- OBJECT inetCidrRouteNextHop\n -- SYNTAX InetAddress (SIZE (0 | 4 | 8 | 16 | 20))\n -- DESCRIPTION\n -- This MIB requires support for global and\n -- non-global IPv4 and IPv6 addresses.\n ') ip_forward_read_only_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 4)).setObjects(*(('IP-FORWARD-MIB', 'inetForwardCidrRouteGroup'),)) if mibBuilder.loadTexts: ipForwardReadOnlyCompliance.setDescription('When this MIB is implemented without support for read-\n create (i.e., in read-only mode), the implementation can\n claim read-only compliance.') inet_forward_cidr_route_group = object_group((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 4)).setObjects(*(('IP-FORWARD-MIB', 'inetCidrRouteDiscards'), ('IP-FORWARD-MIB', 'inetCidrRouteIfIndex'), ('IP-FORWARD-MIB', 'inetCidrRouteType'), ('IP-FORWARD-MIB', 'inetCidrRouteProto'), ('IP-FORWARD-MIB', 'inetCidrRouteAge'), ('IP-FORWARD-MIB', 'inetCidrRouteNextHopAS'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric1'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric2'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric3'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric4'), ('IP-FORWARD-MIB', 'inetCidrRouteMetric5'), ('IP-FORWARD-MIB', 'inetCidrRouteStatus'), ('IP-FORWARD-MIB', 'inetCidrRouteNumber'))) if mibBuilder.loadTexts: inetForwardCidrRouteGroup.setDescription('The IP version-independent CIDR Route Table.') ip_cidr_route_number = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 3), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteNumber.setDescription('The number of current ipCidrRouteTable entries that are\n not invalid. This object is deprecated in favor of\n inetCidrRouteNumber and the inetCidrRouteTable.') ip_cidr_route_table = mib_table((1, 3, 6, 1, 2, 1, 4, 24, 4)) if mibBuilder.loadTexts: ipCidrRouteTable.setDescription("This entity's IP Routing table. This table has been\n deprecated in favor of the IP version neutral\n inetCidrRouteTable.") ip_cidr_route_entry = mib_table_row((1, 3, 6, 1, 2, 1, 4, 24, 4, 1)).setIndexNames((0, 'IP-FORWARD-MIB', 'ipCidrRouteDest'), (0, 'IP-FORWARD-MIB', 'ipCidrRouteMask'), (0, 'IP-FORWARD-MIB', 'ipCidrRouteTos'), (0, 'IP-FORWARD-MIB', 'ipCidrRouteNextHop')) if mibBuilder.loadTexts: ipCidrRouteEntry.setDescription('A particular route to a particular destination, under a\n particular policy.') ip_cidr_route_dest = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteDest.setDescription('The destination IP address of this route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteMask object is\n not equal to x.') ip_cidr_route_mask = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 2), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipCidrRouteDest field. For those systems that\n do not support arbitrary subnet masks, an agent\n constructs the value of the ipCidrRouteMask by\n reference to the IP Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipCidrRouteDest object is\n not equal to ipCidrRouteDest.') ip_cidr_route_tos = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteTos.setDescription('The policy specifier is the IP TOS Field. The encoding\n of IP TOS is as specified by the following convention.\n Zero indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30') ip_cidr_route_next_hop = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 4), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteNextHop.setDescription('On remote routes, the address of the next system en\n route; Otherwise, 0.0.0.0.') ip_cidr_route_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 5), integer32()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.') ip_cidr_route_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('reject', 2), ('local', 3), ('remote', 4)))).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Routes that do not result in traffic forwarding or\n rejection should not be displayed, even if the\n implementation keeps them stored internally.\n\n reject (2) refers to a route that, if matched,\n discards the message as unreachable. This is used in\n some protocols as a means of correctly aggregating\n routes.') ip_cidr_route_proto = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16))).clone(namedValues=named_values(('other', 1), ('local', 2), ('netmgmt', 3), ('icmp', 4), ('egp', 5), ('ggp', 6), ('hello', 7), ('rip', 8), ('isIs', 9), ('esIs', 10), ('ciscoIgrp', 11), ('bbnSpfIgp', 12), ('ospf', 13), ('bgp', 14), ('idpr', 15), ('ciscoEigrp', 16)))).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.') ip_cidr_route_age = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 8), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipCidrRouteAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied, except through\n knowledge of the routing protocol by which the route\n was learned.") ip_cidr_route_info = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 9), object_identifier()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipCidrRouteProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.") ip_cidr_route_next_hop_as = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 10), integer32()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteNextHopAS.setDescription("The Autonomous System Number of the Next Hop. The\n semantics of this object are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. When this object is unknown or not relevant, its\n value should be set to zero.") ip_cidr_route_metric1 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 11), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ip_cidr_route_metric2 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 12), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ip_cidr_route_metric3 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 13), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ip_cidr_route_metric4 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 14), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ip_cidr_route_metric5 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 15), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipCidrRouteProto\n value. If this metric is not used, its value should be\n set to -1.") ip_cidr_route_status = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 4, 1, 16), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipCidrRouteStatus.setDescription('The row status variable, used according to row\n installation and removal conventions.') ip_forward_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 1)).setObjects(*(('IP-FORWARD-MIB', 'ipForwardCidrRouteGroup'),)) if mibBuilder.loadTexts: ipForwardCompliance.setDescription('The compliance statement for SNMPv2 entities that\n implement the ipForward MIB.\n\n This compliance statement has been deprecated and\n replaced with ipForwardFullCompliance and\n ipForwardReadOnlyCompliance.') ip_forward_cidr_route_group = object_group((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 3)).setObjects(*(('IP-FORWARD-MIB', 'ipCidrRouteNumber'), ('IP-FORWARD-MIB', 'ipCidrRouteDest'), ('IP-FORWARD-MIB', 'ipCidrRouteMask'), ('IP-FORWARD-MIB', 'ipCidrRouteTos'), ('IP-FORWARD-MIB', 'ipCidrRouteNextHop'), ('IP-FORWARD-MIB', 'ipCidrRouteIfIndex'), ('IP-FORWARD-MIB', 'ipCidrRouteType'), ('IP-FORWARD-MIB', 'ipCidrRouteProto'), ('IP-FORWARD-MIB', 'ipCidrRouteAge'), ('IP-FORWARD-MIB', 'ipCidrRouteInfo'), ('IP-FORWARD-MIB', 'ipCidrRouteNextHopAS'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric1'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric2'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric3'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric4'), ('IP-FORWARD-MIB', 'ipCidrRouteMetric5'), ('IP-FORWARD-MIB', 'ipCidrRouteStatus'))) if mibBuilder.loadTexts: ipForwardCidrRouteGroup.setDescription('The CIDR Route Table.\n\n This group has been deprecated and replaced with\n inetForwardCidrRouteGroup.') ip_forward_number = mib_scalar((1, 3, 6, 1, 2, 1, 4, 24, 1), gauge32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipForwardNumber.setDescription('The number of current ipForwardTable entries that are\n not invalid.') ip_forward_table = mib_table((1, 3, 6, 1, 2, 1, 4, 24, 2)) if mibBuilder.loadTexts: ipForwardTable.setDescription("This entity's IP Routing table.") ip_forward_entry = mib_table_row((1, 3, 6, 1, 2, 1, 4, 24, 2, 1)).setIndexNames((0, 'IP-FORWARD-MIB', 'ipForwardDest'), (0, 'IP-FORWARD-MIB', 'ipForwardProto'), (0, 'IP-FORWARD-MIB', 'ipForwardPolicy'), (0, 'IP-FORWARD-MIB', 'ipForwardNextHop')) if mibBuilder.loadTexts: ipForwardEntry.setDescription('A particular route to a particular destination, under a\n particular policy.') ip_forward_dest = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 1), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipForwardDest.setDescription('The destination IP address of this route. An entry\n with a value of 0.0.0.0 is considered a default route.\n\n This object may not take a Multicast (Class D) address\n value.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardMask object is\n not equal to x.') ip_forward_mask = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 2), ip_address().clone(hexValue='00000000')).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardMask.setDescription('Indicate the mask to be logical-ANDed with the\n destination address before being compared to the value\n in the ipForwardDest field. For those systems that do\n not support arbitrary subnet masks, an agent constructs\n the value of the ipForwardMask by reference to the IP\n Address Class.\n\n Any assignment (implicit or otherwise) of an instance\n of this object to a value x must be rejected if the\n bitwise logical-AND of x with the value of the\n corresponding instance of the ipForwardDest object is\n not equal to ipForwardDest.') ip_forward_policy = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly') if mibBuilder.loadTexts: ipForwardPolicy.setDescription("The general set of conditions that would cause\n the selection of one multipath route (set of\n next hops for a given destination) is referred\n to as 'policy'.\n\n Unless the mechanism indicated by ipForwardProto\n specifies otherwise, the policy specifier is\n the IP TOS Field. The encoding of IP TOS is as\n specified by the following convention. Zero\n indicates the default path if no more specific\n policy applies.\n\n +-----+-----+-----+-----+-----+-----+-----+-----+\n | | | |\n | PRECEDENCE | TYPE OF SERVICE | 0 |\n | | | |\n +-----+-----+-----+-----+-----+-----+-----+-----+\n\n IP TOS IP TOS\n Field Policy Field Policy\n Contents Code Contents Code\n 0 0 0 0 ==> 0 0 0 0 1 ==> 2\n 0 0 1 0 ==> 4 0 0 1 1 ==> 6\n 0 1 0 0 ==> 8 0 1 0 1 ==> 10\n 0 1 1 0 ==> 12 0 1 1 1 ==> 14\n 1 0 0 0 ==> 16 1 0 0 1 ==> 18\n 1 0 1 0 ==> 20 1 0 1 1 ==> 22\n 1 1 0 0 ==> 24 1 1 0 1 ==> 26\n 1 1 1 0 ==> 28 1 1 1 1 ==> 30\n\n Protocols defining 'policy' otherwise must either\n define a set of values that are valid for\n this object or must implement an integer-instanced\n policy table for which this object's\n value acts as an index.") ip_forward_next_hop = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 4), ip_address()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipForwardNextHop.setDescription('On remote routes, the address of the next system en\n route; otherwise, 0.0.0.0.') ip_forward_if_index = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 5), integer32()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardIfIndex.setDescription('The ifIndex value that identifies the local interface\n through which the next hop of this route should be\n reached.') ip_forward_type = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('local', 3), ('remote', 4))).clone('invalid')).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardType.setDescription('The type of route. Note that local(3) refers to a\n route for which the next hop is the final destination;\n remote(4) refers to a route for which the next hop is\n not the final destination.\n\n Setting this object to the value invalid(2) has the\n effect of invalidating the corresponding entry in the\n ipForwardTable object. That is, it effectively\n disassociates the destination identified with said\n entry from the route identified with said entry. It is\n an implementation-specific matter as to whether the\n agent removes an invalidated entry from the table.\n Accordingly, management stations must be prepared to\n receive tabular information from agents that\n corresponds to entries not currently in use. Proper\n interpretation of such entries requires examination of\n the relevant ipForwardType object.') ip_forward_proto = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15))).clone(namedValues=named_values(('other', 1), ('local', 2), ('netmgmt', 3), ('icmp', 4), ('egp', 5), ('ggp', 6), ('hello', 7), ('rip', 8), ('is-is', 9), ('es-is', 10), ('ciscoIgrp', 11), ('bbnSpfIgp', 12), ('ospf', 13), ('bgp', 14), ('idpr', 15)))).setMaxAccess('readonly') if mibBuilder.loadTexts: ipForwardProto.setDescription('The routing mechanism via which this route was learned.\n Inclusion of values for gateway routing protocols is\n not intended to imply that hosts should support those\n protocols.') ip_forward_age = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 8), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: ipForwardAge.setDescription("The number of seconds since this route was last updated\n or otherwise determined to be correct. Note that no\n semantics of `too old' can be implied except through\n knowledge of the routing protocol by which the route\n was learned.") ip_forward_info = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 9), object_identifier()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardInfo.setDescription("A reference to MIB definitions specific to the\n particular routing protocol that is responsible for\n this route, as determined by the value specified in the\n route's ipForwardProto value. If this information is\n not present, its value should be set to the OBJECT\n IDENTIFIER { 0 0 }, which is a syntactically valid\n object identifier, and any implementation conforming to\n ASN.1 and the Basic Encoding Rules must be able to\n generate and recognize this value.") ip_forward_next_hop_as = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 10), integer32()).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardNextHopAS.setDescription('The Autonomous System Number of the Next Hop. When\n this is unknown or not relevant to the protocol\n indicated by ipForwardProto, zero.') ip_forward_metric1 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 11), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardMetric1.setDescription("The primary routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ip_forward_metric2 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 12), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardMetric2.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ip_forward_metric3 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 13), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardMetric3.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ip_forward_metric4 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 14), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardMetric4.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ip_forward_metric5 = mib_table_column((1, 3, 6, 1, 2, 1, 4, 24, 2, 1, 15), integer32().clone(-1)).setMaxAccess('readcreate') if mibBuilder.loadTexts: ipForwardMetric5.setDescription("An alternate routing metric for this route. The\n semantics of this metric are determined by the routing-\n protocol specified in the route's ipForwardProto value.\n If this metric is not used, its value should be set to\n -1.") ip_forward_old_compliance = module_compliance((1, 3, 6, 1, 2, 1, 4, 24, 5, 2, 2)).setObjects(*(('IP-FORWARD-MIB', 'ipForwardMultiPathGroup'),)) if mibBuilder.loadTexts: ipForwardOldCompliance.setDescription('The compliance statement for SNMP entities that\n implement the ipForward MIB.') ip_forward_multi_path_group = object_group((1, 3, 6, 1, 2, 1, 4, 24, 5, 1, 2)).setObjects(*(('IP-FORWARD-MIB', 'ipForwardNumber'), ('IP-FORWARD-MIB', 'ipForwardDest'), ('IP-FORWARD-MIB', 'ipForwardMask'), ('IP-FORWARD-MIB', 'ipForwardPolicy'), ('IP-FORWARD-MIB', 'ipForwardNextHop'), ('IP-FORWARD-MIB', 'ipForwardIfIndex'), ('IP-FORWARD-MIB', 'ipForwardType'), ('IP-FORWARD-MIB', 'ipForwardProto'), ('IP-FORWARD-MIB', 'ipForwardAge'), ('IP-FORWARD-MIB', 'ipForwardInfo'), ('IP-FORWARD-MIB', 'ipForwardNextHopAS'), ('IP-FORWARD-MIB', 'ipForwardMetric1'), ('IP-FORWARD-MIB', 'ipForwardMetric2'), ('IP-FORWARD-MIB', 'ipForwardMetric3'), ('IP-FORWARD-MIB', 'ipForwardMetric4'), ('IP-FORWARD-MIB', 'ipForwardMetric5'))) if mibBuilder.loadTexts: ipForwardMultiPathGroup.setDescription('IP Multipath Route Table.') mibBuilder.exportSymbols('IP-FORWARD-MIB', inetCidrRouteAge=inetCidrRouteAge, ipForwardFullCompliance=ipForwardFullCompliance, inetCidrRouteDest=inetCidrRouteDest, ipCidrRouteInfo=ipCidrRouteInfo, ipForwardNextHop=ipForwardNextHop, ipForwardConformance=ipForwardConformance, PYSNMP_MODULE_ID=ipForward, inetCidrRouteMetric5=inetCidrRouteMetric5, inetCidrRouteEntry=inetCidrRouteEntry, inetCidrRouteIfIndex=inetCidrRouteIfIndex, ipForwardNextHopAS=ipForwardNextHopAS, ipCidrRouteIfIndex=ipCidrRouteIfIndex, inetCidrRouteMetric2=inetCidrRouteMetric2, ipForwardInfo=ipForwardInfo, ipForwardDest=ipForwardDest, inetCidrRouteMetric1=inetCidrRouteMetric1, ipForwardEntry=ipForwardEntry, inetCidrRouteNextHop=inetCidrRouteNextHop, ipCidrRouteNextHopAS=ipCidrRouteNextHopAS, ipCidrRouteNumber=ipCidrRouteNumber, ipForwardMask=ipForwardMask, ipForwardPolicy=ipForwardPolicy, ipCidrRouteProto=ipCidrRouteProto, ipCidrRouteMetric2=ipCidrRouteMetric2, ipForward=ipForward, ipCidrRouteMetric4=ipCidrRouteMetric4, inetForwardCidrRouteGroup=inetForwardCidrRouteGroup, ipForwardMetric3=ipForwardMetric3, ipForwardCompliances=ipForwardCompliances, ipForwardReadOnlyCompliance=ipForwardReadOnlyCompliance, ipCidrRouteMask=ipCidrRouteMask, ipForwardIfIndex=ipForwardIfIndex, ipForwardCompliance=ipForwardCompliance, ipCidrRouteMetric3=ipCidrRouteMetric3, ipForwardProto=ipForwardProto, ipForwardMetric4=ipForwardMetric4, inetCidrRouteDiscards=inetCidrRouteDiscards, ipCidrRouteNextHop=ipCidrRouteNextHop, ipForwardTable=ipForwardTable, ipCidrRouteAge=ipCidrRouteAge, inetCidrRouteNextHopAS=inetCidrRouteNextHopAS, inetCidrRouteTable=inetCidrRouteTable, inetCidrRoutePolicy=inetCidrRoutePolicy, ipCidrRouteType=ipCidrRouteType, ipForwardOldCompliance=ipForwardOldCompliance, ipForwardGroups=ipForwardGroups, ipForwardMetric1=ipForwardMetric1, ipForwardNumber=ipForwardNumber, inetCidrRouteProto=inetCidrRouteProto, ipForwardMetric2=ipForwardMetric2, ipForwardAge=ipForwardAge, inetCidrRouteMetric3=inetCidrRouteMetric3, inetCidrRoutePfxLen=inetCidrRoutePfxLen, ipCidrRouteEntry=ipCidrRouteEntry, ipCidrRouteMetric5=ipCidrRouteMetric5, ipForwardType=ipForwardType, ipCidrRouteTable=ipCidrRouteTable, ipForwardMultiPathGroup=ipForwardMultiPathGroup, inetCidrRouteStatus=inetCidrRouteStatus, ipCidrRouteDest=ipCidrRouteDest, ipForwardMetric5=ipForwardMetric5, ipCidrRouteTos=ipCidrRouteTos, inetCidrRouteType=inetCidrRouteType, inetCidrRouteNumber=inetCidrRouteNumber, ipCidrRouteStatus=ipCidrRouteStatus, ipForwardCidrRouteGroup=ipForwardCidrRouteGroup, ipCidrRouteMetric1=ipCidrRouteMetric1, inetCidrRouteMetric4=inetCidrRouteMetric4, inetCidrRouteNextHopType=inetCidrRouteNextHopType, inetCidrRouteDestType=inetCidrRouteDestType)
class InvalidSignatureError(Exception): """ User signature is not valid.""" class BadRequestError(Exception): """ Indicates a malformed request or missing parameters."""
class Invalidsignatureerror(Exception): """ User signature is not valid.""" class Badrequesterror(Exception): """ Indicates a malformed request or missing parameters."""
# Declare any variables (as constants) that are or could be used anywhere in the application # TODO: Determine what a good fingerprint length is FINGERPRINT_LENGTH = 40
fingerprint_length = 40
def multi(a,b): return a*b if __name__ == '__main__': print(multi(2,3))
def multi(a, b): return a * b if __name__ == '__main__': print(multi(2, 3))
class LayerShape: def __init__(self, *dims): self.dims = dims if len(dims) == 1: self.channels = dims[0] elif len(dims) == 2: self.channels = dims[0] self.height = dims[1] elif len(dims) == 3: self.channels = dims[0] self.height = dims[1] self.width = dims[2] elif len(dims) == 4: self.frames = dims[0] self.channels = dims[1] self.height = dims[2] self.width = dims[3] def squeeze_dims(self): filter(lambda x: x == 1, self.dims) def size(self): if len(self.dims) == 1: return self.channels if len(self.dims) == 2: return self.channels * self.height if len(self.dims) == 3: return self.channels * self.height * self.width return self.channels * self.height * self.width * self.frames def __repr__(self): return "LayerShape(" + ", ".join([str(x) for x in self.dims]) + ")" def __str__(self): return self.__repr__()
class Layershape: def __init__(self, *dims): self.dims = dims if len(dims) == 1: self.channels = dims[0] elif len(dims) == 2: self.channels = dims[0] self.height = dims[1] elif len(dims) == 3: self.channels = dims[0] self.height = dims[1] self.width = dims[2] elif len(dims) == 4: self.frames = dims[0] self.channels = dims[1] self.height = dims[2] self.width = dims[3] def squeeze_dims(self): filter(lambda x: x == 1, self.dims) def size(self): if len(self.dims) == 1: return self.channels if len(self.dims) == 2: return self.channels * self.height if len(self.dims) == 3: return self.channels * self.height * self.width return self.channels * self.height * self.width * self.frames def __repr__(self): return 'LayerShape(' + ', '.join([str(x) for x in self.dims]) + ')' def __str__(self): return self.__repr__()
# Time: O(Log n) We performed a Binary Search # Space: O(1) class Solution: def findMin(self, nums): if len(nums) == 1: return nums[0] left = 0 right = len(nums) - 1 if nums[0] < nums[right]: return nums[0] while left <= right: mid = (right + left) // 2 mid_val = nums[mid] right_of_mid_val = nums[mid + 1] left_of_mid_val = nums[mid - 1] if mid_val > right_of_mid_val: return right_of_mid_val if left_of_mid_val > mid_val: return mid_val if mid_val > nums[0]: left = mid + 1 else: right = mid - 1 solution = Solution() print(solution.findMin([3, 4, 5, 1, 2]))
class Solution: def find_min(self, nums): if len(nums) == 1: return nums[0] left = 0 right = len(nums) - 1 if nums[0] < nums[right]: return nums[0] while left <= right: mid = (right + left) // 2 mid_val = nums[mid] right_of_mid_val = nums[mid + 1] left_of_mid_val = nums[mid - 1] if mid_val > right_of_mid_val: return right_of_mid_val if left_of_mid_val > mid_val: return mid_val if mid_val > nums[0]: left = mid + 1 else: right = mid - 1 solution = solution() print(solution.findMin([3, 4, 5, 1, 2]))
def foo_task(): print('Foo task is running...') print('Foo task completed.') return True def sum_task(arg_1: int, arg_2: int): print('Sum task is running...') result = arg_1 + arg_2 print('Sum task completed.') return result
def foo_task(): print('Foo task is running...') print('Foo task completed.') return True def sum_task(arg_1: int, arg_2: int): print('Sum task is running...') result = arg_1 + arg_2 print('Sum task completed.') return result
#!/usr/bin/env python3 # Tax calculator # This program currently # only works with the hungarian tax def calcTax(cost, country='hungary'): countries = {'hungary' : 27} if country in countries.keys(): tax = (cost / 100) * countries[country] else: return "Country can't be found" return tax def main(): # Wrapper function tax = calcTax(int(input('What was the cost of your purchase? ')), input('Which country are you in? ')) if type(tax) == str: print(tax) else: print('The tax on your purchase was:', tax) if __name__ == '__main__': main()
def calc_tax(cost, country='hungary'): countries = {'hungary': 27} if country in countries.keys(): tax = cost / 100 * countries[country] else: return "Country can't be found" return tax def main(): tax = calc_tax(int(input('What was the cost of your purchase? ')), input('Which country are you in? ')) if type(tax) == str: print(tax) else: print('The tax on your purchase was:', tax) if __name__ == '__main__': main()
""" Write code to add, search and remove items from an unsorted linked list. """ class LinkedList: def __init__(self): self.length = 0 self.head = None def add(self, cargo): _next = self.head self.head = Node(cargo, _next) self.length += 1 def search(self, value): node = self.head while node: if node.cargo == value: return node node = node.next return None def delete(self, k): node = self.head # The node to delete is the head, change it. if node.cargo == k: self.head = node.next del node self.length -= 1 return # The node to delete is not the head, update the chain. while node.next: if node.next.cargo == k: node.next = node.next.next del node.next self.length -= 1 return node = node.next def print_forward(self): print('[', end='') if self.head: self.head.print_forward() print(']') class Node: def __init__(self, cargo=None, _next=None): self.cargo = cargo self.next = _next def print_forward(self): print(self, end=',' if self.next else '') if self.next: self.next.print_forward() def __str__(self): return str(self.cargo) linked_list = LinkedList() linked_list.add(1) linked_list.add(2) linked_list.add(3) print('-' * 40) print(f'Head = {linked_list.head.cargo}') print(f'Length = {linked_list.length}') linked_list.print_forward() print('-' * 40) linked_list.delete(3) print(f'Head = {linked_list.head.cargo}') print(f'Length = {linked_list.length}') linked_list.print_forward()
""" Write code to add, search and remove items from an unsorted linked list. """ class Linkedlist: def __init__(self): self.length = 0 self.head = None def add(self, cargo): _next = self.head self.head = node(cargo, _next) self.length += 1 def search(self, value): node = self.head while node: if node.cargo == value: return node node = node.next return None def delete(self, k): node = self.head if node.cargo == k: self.head = node.next del node self.length -= 1 return while node.next: if node.next.cargo == k: node.next = node.next.next del node.next self.length -= 1 return node = node.next def print_forward(self): print('[', end='') if self.head: self.head.print_forward() print(']') class Node: def __init__(self, cargo=None, _next=None): self.cargo = cargo self.next = _next def print_forward(self): print(self, end=',' if self.next else '') if self.next: self.next.print_forward() def __str__(self): return str(self.cargo) linked_list = linked_list() linked_list.add(1) linked_list.add(2) linked_list.add(3) print('-' * 40) print(f'Head = {linked_list.head.cargo}') print(f'Length = {linked_list.length}') linked_list.print_forward() print('-' * 40) linked_list.delete(3) print(f'Head = {linked_list.head.cargo}') print(f'Length = {linked_list.length}') linked_list.print_forward()
def boarding_pass_row(seq): assert len(seq) == 7 # FBFBBFF seqb = seq.replace('F', '0').replace('B', '1') return int(seqb, 2) def boarding_pass_col(seq): assert len(seq) == 3 seqb = seq.replace('R', '1').replace('L', '0') return int(seqb, 2) def row_id(seq): row, col = boarding_pass_row(seq[:7]), boarding_pass_col(seq[7:]) return 8 * row + col if __name__ == '__main__': print(row_id('FBFBBFFRLR')) print(row_id('BFFFBBFRRR')) print(row_id('FFFBBBFRRR')) print(row_id('BBFFBBFRLL')) ids = open('input5.txt').read().splitlines() all_ids = [row_id(i) for i in ids] print('p1:', max(all_ids)) """ >>> d = np.diff(np.sort(all_ids)) >>> np.where(d != 1) (array([652], dtype=int64),) >>> np.sort(all_ids)[652] 698 >>> np.sort(all_ids)[651:654] array([697, 698, 700]) """ print('p2:', 699)
def boarding_pass_row(seq): assert len(seq) == 7 seqb = seq.replace('F', '0').replace('B', '1') return int(seqb, 2) def boarding_pass_col(seq): assert len(seq) == 3 seqb = seq.replace('R', '1').replace('L', '0') return int(seqb, 2) def row_id(seq): (row, col) = (boarding_pass_row(seq[:7]), boarding_pass_col(seq[7:])) return 8 * row + col if __name__ == '__main__': print(row_id('FBFBBFFRLR')) print(row_id('BFFFBBFRRR')) print(row_id('FFFBBBFRRR')) print(row_id('BBFFBBFRLL')) ids = open('input5.txt').read().splitlines() all_ids = [row_id(i) for i in ids] print('p1:', max(all_ids)) '\n\t>>> d = np.diff(np.sort(all_ids))\n\t>>> np.where(d != 1)\n\t(array([652], dtype=int64),)\n\t>>> np.sort(all_ids)[652]\n\t698\n\t>>> np.sort(all_ids)[651:654]\n\tarray([697, 698, 700])\n\n\t' print('p2:', 699)
''' Details about this Python package. ''' __version__ = '1.1.0' __title__ = 'example-python' __author__ = 'Mahathir Almashor' __author_email__ = 'mahathir.almashor@data61.csiro.au' __description__ = 'Example Python repository for Cyber Security Cooperative Research Centre' __url__ = 'https://github.com/ma-al/example-python'
""" Details about this Python package. """ __version__ = '1.1.0' __title__ = 'example-python' __author__ = 'Mahathir Almashor' __author_email__ = 'mahathir.almashor@data61.csiro.au' __description__ = 'Example Python repository for Cyber Security Cooperative Research Centre' __url__ = 'https://github.com/ma-al/example-python'
# Create query to get call counts by complaint_type query = """ SELECT complaint_type, COUNT(*) FROM hpd311calls GROUP BY complaint_type; """ # Create data frame of call counts by issue calls_by_issue = pd.read_sql(query, engine) # Graph the number of calls for each housing issue calls_by_issue.plot.barh(x="complaint_type") plt.show()
query = '\nSELECT complaint_type, \n COUNT(*)\n FROM hpd311calls\n GROUP BY complaint_type;\n' calls_by_issue = pd.read_sql(query, engine) calls_by_issue.plot.barh(x='complaint_type') plt.show()
with open("day13.in") as f: lines = f.read().splitlines() dots = set() for i, line in enumerate(lines): if line == "": break x, y = line.split(",") dots.add((int(x), int(y))) # folds for line in lines[i+1:]: _, _, fold = line.split(" ") axis, num = fold.split("=") num = int(num) new_dots = set() if axis == "x": # vertical line at |num|. for (xpos, ypos) in dots: if xpos > num: newxpos = num - (xpos - num) new_dots.add((newxpos, ypos)) else: new_dots.add((xpos, ypos)) elif axis == "y": # horizontal line at |num| for (xpos, ypos) in dots: if ypos > num: newypos = num - (ypos - num) new_dots.add((xpos, newypos)) else: new_dots.add((xpos, ypos)) dots = new_dots print(len(new_dots)) max_x = 0 max_y = 0 for (x, y) in dots: max_x = max(max_x, x) max_y = max(max_y, y) print(max_x, max_y) for j in range(max_y + 1): print("".join(["#" if (i, j) in dots else " " for i in range(max_x + 1)]))
with open('day13.in') as f: lines = f.read().splitlines() dots = set() for (i, line) in enumerate(lines): if line == '': break (x, y) = line.split(',') dots.add((int(x), int(y))) for line in lines[i + 1:]: (_, _, fold) = line.split(' ') (axis, num) = fold.split('=') num = int(num) new_dots = set() if axis == 'x': for (xpos, ypos) in dots: if xpos > num: newxpos = num - (xpos - num) new_dots.add((newxpos, ypos)) else: new_dots.add((xpos, ypos)) elif axis == 'y': for (xpos, ypos) in dots: if ypos > num: newypos = num - (ypos - num) new_dots.add((xpos, newypos)) else: new_dots.add((xpos, ypos)) dots = new_dots print(len(new_dots)) max_x = 0 max_y = 0 for (x, y) in dots: max_x = max(max_x, x) max_y = max(max_y, y) print(max_x, max_y) for j in range(max_y + 1): print(''.join(['#' if (i, j) in dots else ' ' for i in range(max_x + 1)]))
# Copyright (c) 2019-present, Facebook, Inc. # All rights reserved. # # This source code is licensed under the license found in the # LICENSE file in the root directory of this source tree. # def f_gold ( num ) : series = [ 1 , 3 , 2 , - 1 , - 3 , - 2 ] ; series_index = 0 ; result = 0 ; for i in range ( ( len ( num ) - 1 ) , - 1 , - 1 ) : digit = ord ( num [ i ] ) - 48 ; result += digit * series [ series_index ] ; series_index = ( series_index + 1 ) % 6 ; result %= 7 ; if ( result < 0 ) : result = ( result + 7 ) % 7 ; return result ; #TOFILL if __name__ == '__main__': param = [ ('K',), ('850076',), ('00111',), ('X',), ('1',), ('10010001100',), (' pgPeLz',), ('53212456821275',), ('101',), ('V',) ] n_success = 0 for i, parameters_set in enumerate(param): if f_filled(*parameters_set) == f_gold(*parameters_set): n_success+=1 print("#Results: %i, %i" % (n_success, len(param)))
def f_gold(num): series = [1, 3, 2, -1, -3, -2] series_index = 0 result = 0 for i in range(len(num) - 1, -1, -1): digit = ord(num[i]) - 48 result += digit * series[series_index] series_index = (series_index + 1) % 6 result %= 7 if result < 0: result = (result + 7) % 7 return result if __name__ == '__main__': param = [('K',), ('850076',), ('00111',), ('X',), ('1',), ('10010001100',), (' pgPeLz',), ('53212456821275',), ('101',), ('V',)] n_success = 0 for (i, parameters_set) in enumerate(param): if f_filled(*parameters_set) == f_gold(*parameters_set): n_success += 1 print('#Results: %i, %i' % (n_success, len(param)))
VALUE_INITIALIZED = 0 def test_owner_address(box, accounts): # verify that accounts[0] is contract owner assert accounts[0].address == box.owner() def test_value_after_contract_creation(box, accounts): # verify initialized value of box assert VALUE_INITIALIZED == box.retrieve()
value_initialized = 0 def test_owner_address(box, accounts): assert accounts[0].address == box.owner() def test_value_after_contract_creation(box, accounts): assert VALUE_INITIALIZED == box.retrieve()
"""Module that implements mocking Vega type coercing functions.""" type_coercing_functions = ['toBoolean', 'toDate', 'toNumber', 'toString'] error_message = ' is a mocking function that is not supposed to be called directly' def toBoolean(value): """Coerce the input value to a string. None values and empty strings are mapped to None.""" raise RuntimeError('toBoolean' + error_message) def toDate(value): """Coerce the input value to a Date instance. None values and empty strings are mapped to None. If an optional parser function is provided, it is used to perform date parsing, otherwise Date.parse is used. Be aware that Date.parse has different implementations across browsers! """ raise RuntimeError('toDate' + error_message) def toNumber(value): """Coerce the input value to a number. None values and empty strings are mapped to None.""" raise RuntimeError('toNumber' + error_message) def toString(value): """Coerce the input value to a string. None values and empty strings are mapped to None.""" raise RuntimeError('toString' + error_message)
"""Module that implements mocking Vega type coercing functions.""" type_coercing_functions = ['toBoolean', 'toDate', 'toNumber', 'toString'] error_message = ' is a mocking function that is not supposed to be called directly' def to_boolean(value): """Coerce the input value to a string. None values and empty strings are mapped to None.""" raise runtime_error('toBoolean' + error_message) def to_date(value): """Coerce the input value to a Date instance. None values and empty strings are mapped to None. If an optional parser function is provided, it is used to perform date parsing, otherwise Date.parse is used. Be aware that Date.parse has different implementations across browsers! """ raise runtime_error('toDate' + error_message) def to_number(value): """Coerce the input value to a number. None values and empty strings are mapped to None.""" raise runtime_error('toNumber' + error_message) def to_string(value): """Coerce the input value to a string. None values and empty strings are mapped to None.""" raise runtime_error('toString' + error_message)
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def preorder(self, root): """ :type root: Node :rtype: List[int] """ result = [] self.dfs_rec(root, result) return result def dfs_rec(self, root, result): if not root: return result.append(root.val) for child in root.children: self.dfs_rec(child,result)
""" # Definition for a Node. class Node(object): def __init__(self, val, children): self.val = val self.children = children """ class Solution(object): def preorder(self, root): """ :type root: Node :rtype: List[int] """ result = [] self.dfs_rec(root, result) return result def dfs_rec(self, root, result): if not root: return result.append(root.val) for child in root.children: self.dfs_rec(child, result)
# This file creates custom rules to make tests can easily run under # certain environment(like inside a docker). # # For example: # # run_under_test( # name = "test_under_docker", # under = "//tools/docker:zookeper", # command = "//sometest", # data = [ # ], # args = [ # "--gtest_filter=abc", # ] # ) # # This is almost equivalent to # bazel run --script_path "name" --run_under "under" "command" # # under: any build target that produces an executable binary, this is # the top level command to run, and it should take another executable # as command line flag to run as subprocess. # # command: any build target that produces an executable binary. # # data: list of files that need to be accessed when running the # "under" and the "command". def _run_under_impl(ctx): bin_dir = ctx.configuration.bin_dir build_directory = str(bin_dir)[:-len('[derived]')] + '/' under = ctx.executable.under under_args = ctx.attr.under_args command = ctx.executable.command exe = ctx.outputs.executable ctx.file_action(output=exe, content='''#!/bin/bash cd %s.runfiles && \\ exec %s %s \\ %s "$@" ''' % (build_directory + exe.short_path, build_directory + under.short_path, " ".join(under_args), build_directory + command.short_path)) # The $@ above will pass ctx.attr.args along to the command runfiles = [command, under] + ctx.files.data return struct( runfiles=ctx.runfiles( files=runfiles, collect_data=True, collect_default=True) ) run_under_attr = { "command": attr.label(mandatory=True, allow_files=True, cfg='target', executable=True), "under": attr.label(mandatory=True, allow_files=True, cfg='target', executable=True), # Arguments for the "under" command to setup the environment. "under_args": attr.string_list(), "data": attr.label_list(allow_files=True, cfg='data'), # bazel automatically implements "args": attr.string_list() # and passes them on invocation } run_under_binary = rule( _run_under_impl, attrs = run_under_attr, executable=True) run_under_test = rule( _run_under_impl, test = True, attrs = run_under_attr, executable=True)
def _run_under_impl(ctx): bin_dir = ctx.configuration.bin_dir build_directory = str(bin_dir)[:-len('[derived]')] + '/' under = ctx.executable.under under_args = ctx.attr.under_args command = ctx.executable.command exe = ctx.outputs.executable ctx.file_action(output=exe, content='#!/bin/bash\ncd %s.runfiles && \\\nexec %s %s \\\n%s "$@"\n' % (build_directory + exe.short_path, build_directory + under.short_path, ' '.join(under_args), build_directory + command.short_path)) runfiles = [command, under] + ctx.files.data return struct(runfiles=ctx.runfiles(files=runfiles, collect_data=True, collect_default=True)) run_under_attr = {'command': attr.label(mandatory=True, allow_files=True, cfg='target', executable=True), 'under': attr.label(mandatory=True, allow_files=True, cfg='target', executable=True), 'under_args': attr.string_list(), 'data': attr.label_list(allow_files=True, cfg='data')} run_under_binary = rule(_run_under_impl, attrs=run_under_attr, executable=True) run_under_test = rule(_run_under_impl, test=True, attrs=run_under_attr, executable=True)
# x = n^2 + an + b; |a| < 1000 and |b| < 1000 # b has to be odd, positive and prime as we are testing consecutive values for n # a has to be negative otherwise the difference between consecutive x's will be huge! def is_prime(num) : if (num <= 1) : return False if (num <= 3) : return True if (num % 2 == 0 or num % 3 == 0) : return False i = 5 while(i * i <= num) : if (num % i == 0 or num % (i + 2) == 0) : return False i = i + 6 return True def max_prod(max_val_a , max_val_b): max_n = 0 max_b = 0 max_a = 0 for i in range(-max_val_a, -1): for j in range(1, max_val_b, 2): n = 0 while is_prime(n**2 + i*n + j): n += 1 if n > max_n: max_a = i max_b = j max_n = n return max_a * max_b if __name__ == '__main__': print(max_prod(1000, 1000))
def is_prime(num): if num <= 1: return False if num <= 3: return True if num % 2 == 0 or num % 3 == 0: return False i = 5 while i * i <= num: if num % i == 0 or num % (i + 2) == 0: return False i = i + 6 return True def max_prod(max_val_a, max_val_b): max_n = 0 max_b = 0 max_a = 0 for i in range(-max_val_a, -1): for j in range(1, max_val_b, 2): n = 0 while is_prime(n ** 2 + i * n + j): n += 1 if n > max_n: max_a = i max_b = j max_n = n return max_a * max_b if __name__ == '__main__': print(max_prod(1000, 1000))
linz = '---' * 30 # This is the Procedual way of creating a GUI '''import tkinter def main(): #creates the main window main_window = tkinter.Tk() # Enters the Tkinter main loop tkinter.mainloop() # Calls the main function main() print(linz)''' linz = '---' * 30 # This is the Module way of creating a GUI """import tkinter class MYHGUI: def init(self): self.main_window = tkinter.Tk() tkinter.mainloop() my_gui = MYHGUI()""" print(linz) # ---------------------------------------------------
linz = '---' * 30 'import tkinter\ndef main():\n #creates the main window\n main_window = tkinter.Tk()\n\n # Enters the Tkinter main loop\n tkinter.mainloop()\n\n# Calls the main function\nmain()\nprint(linz)' linz = '---' * 30 'import tkinter\n\nclass MYHGUI:\n def init(self):\n self.main_window = tkinter.Tk()\n tkinter.mainloop()\n\nmy_gui = MYHGUI()' print(linz)
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) nlist = [[i,j,k] for i in range(0, x+1) for j in range(0, y+1) for k in range(0, z+1) if (i+j+k) > n or (i+j+k)< n] print(nlist)
if __name__ == '__main__': x = int(input()) y = int(input()) z = int(input()) n = int(input()) nlist = [[i, j, k] for i in range(0, x + 1) for j in range(0, y + 1) for k in range(0, z + 1) if i + j + k > n or i + j + k < n] print(nlist)
""" Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print 'ab123#'.isalnum() False str.isalpha() This method checks if all the characters of a string are alphabetical (a-z and A-Z). >>> print 'abcD'.isalpha() True >>> print 'abcd1'.isalpha() False str.isdigit() This method checks if all the characters of a string are digits (0-9). >>> print '1234'.isdigit() True >>> print '123edsd'.isdigit() False str.islower() This method checks if all the characters of a string are lowercase characters (a-z). >>> print 'abcd123#'.islower() True >>> print 'Abcd123#'.islower() False str.isupper() This method checks if all the characters of a string are uppercase characters (A-Z). >>> print 'ABCD123#'.isupper() True >>> print 'Abcd123#'.isupper() False Task You are given a string . Your task is to find out if the string contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters. Input Format A single line containing a string . Constraints Output Format In the first line, print True if has any alphanumeric characters. Otherwise, print False. In the second line, print True if has any alphabetical characters. Otherwise, print False. In the third line, print True if has any digits. Otherwise, print False. In the fourth line, print True if has any lowercase characters. Otherwise, print False. In the fifth line, print True if has any uppercase characters. Otherwise, print False. Sample Input qA2 Sample Output True True True True True """ if __name__ == '__main__': s = input() string_validator = {"any_alphanumeric": False, "any_alphabetical": False, "any_digits": False, "any_lower_case": False, "any_uppercase": False} for char in s: if ord(char) in range(65, 65 + 25): string_validator['any_uppercase'] = True string_validator['any_alphanumeric'] = True string_validator['any_alphabetical'] = True if ord(char) in range(97, 97 + 25): string_validator['any_lower_case'] = True string_validator['any_alphanumeric'] = True string_validator['any_alphabetical'] = True if ord(char) in range(48, 58): string_validator['any_digits'] = True string_validator['any_alphanumeric'] = True print(string_validator['any_alphanumeric']) print(string_validator['any_alphabetical']) print(string_validator['any_digits']) print(string_validator['any_lower_case']) print(string_validator['any_uppercase']) # # In the first line, print True if has any alphanumeric characters. Otherwise, print False. # # In the second line, print True if has any alphabetical characters. Otherwise, print False. # # In the third line, print True if has any digits. Otherwise, print False. # # In the fourth line, print True if has any lowercase characters. Otherwise, print False. # # In the fifth line, print True if has any uppercase characters. Otherwise, print False. # if s.isalnum(): # print(True) # else: # print(False) # if s.isalnum() and not s.isdigit(): # print(True) # else: # print(False) # if s.isdigit() or (not s.isalpha() and not s.isdigit()): # print(True) # else: # print(False) # if (not s.isupper() and not s.islower()) and not s.isdigit() and not s.isspace(): # # mixedcase # print(True) # elif s.islower(): # print(True) # else: # print(False) # if (not s.isupper() and not s.islower()) and not s.isdigit() and not s.isspace(): # # mixedcase # print(True) # elif s.isupper(): # print(True) # else: # print(False)
""" Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc. str.isalnum() This method checks if all the characters of a string are alphanumeric (a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print 'ab123#'.isalnum() False str.isalpha() This method checks if all the characters of a string are alphabetical (a-z and A-Z). >>> print 'abcD'.isalpha() True >>> print 'abcd1'.isalpha() False str.isdigit() This method checks if all the characters of a string are digits (0-9). >>> print '1234'.isdigit() True >>> print '123edsd'.isdigit() False str.islower() This method checks if all the characters of a string are lowercase characters (a-z). >>> print 'abcd123#'.islower() True >>> print 'Abcd123#'.islower() False str.isupper() This method checks if all the characters of a string are uppercase characters (A-Z). >>> print 'ABCD123#'.isupper() True >>> print 'Abcd123#'.isupper() False Task You are given a string . Your task is to find out if the string contains: alphanumeric characters, alphabetical characters, digits, lowercase and uppercase characters. Input Format A single line containing a string . Constraints Output Format In the first line, print True if has any alphanumeric characters. Otherwise, print False. In the second line, print True if has any alphabetical characters. Otherwise, print False. In the third line, print True if has any digits. Otherwise, print False. In the fourth line, print True if has any lowercase characters. Otherwise, print False. In the fifth line, print True if has any uppercase characters. Otherwise, print False. Sample Input qA2 Sample Output True True True True True """ if __name__ == '__main__': s = input() string_validator = {'any_alphanumeric': False, 'any_alphabetical': False, 'any_digits': False, 'any_lower_case': False, 'any_uppercase': False} for char in s: if ord(char) in range(65, 65 + 25): string_validator['any_uppercase'] = True string_validator['any_alphanumeric'] = True string_validator['any_alphabetical'] = True if ord(char) in range(97, 97 + 25): string_validator['any_lower_case'] = True string_validator['any_alphanumeric'] = True string_validator['any_alphabetical'] = True if ord(char) in range(48, 58): string_validator['any_digits'] = True string_validator['any_alphanumeric'] = True print(string_validator['any_alphanumeric']) print(string_validator['any_alphabetical']) print(string_validator['any_digits']) print(string_validator['any_lower_case']) print(string_validator['any_uppercase'])
# :coding: utf-8 # :copyright: Copyright (c) 2021 strack class StrackError(RuntimeError): """ Custom error class. """ def __init__(self, arg): self.args = arg
class Strackerror(RuntimeError): """ Custom error class. """ def __init__(self, arg): self.args = arg
##Collect data: ''' #SMI: 2021/10/30 SAF: 308214 Standard Beamline 12-ID proposal: (CFN, 307961) create proposal: proposal_id( '2021_3', '307961_Dinca' ) #create the proposal id and folder %run -i /home/xf12id/.ipython/profile_collection/startup/users/30-user-Dinca2021C2B.py RE( shopen() ) # to open the beam and feedback RE( shclose()) # Energy: 16.1 keV, 0.77009 A # SAXS distance 5000 ##for the run >=5 # 5 m, beam stop: 1.9 # 5m, 1M, x=-5, Y = -40 # the correspond beam center is [ 454, 682 ] # beamstop_save() FOR MIT CELL, Cables: Cell A: #3, red to red #2 orange to blue Cell B: #9 black to black #4 brown to brown ''' username = 'Dinca' #####First Run sample_dict = { 1: 'Cell01_NaCl_Electrolyte' , 2: 'Cell03_AlCl3_Electrolyte' , } #####Second Run sample_dict = { 1: 'Cell05_MgCl2_Electrolyte' , 2: 'Cell06_AlCl3_Electrolyte' , } #####Third Run sample_dict = { 1: 'Cell04_NH4Cl_Electrolyte' , 2: 'Cell07_NaCl_Electrolyte_PH1' , } pxy_dict = { 1: ( 35800, 800 ), 2: (-23400, 1200), } PZ = -1500 # Plan # measure at RT without apply V, # -0.7 V, measure # keep 30 min, measure ############# ## For sample 1 # Without V, # Manually measure one by one # measure_pos_noV() # apply V = -0.7 # measure_pos_V() user_name = 'Dinca' pos = 1 def _measure( sample ): if abs(waxs.arc.user_readback.value-20 ) < 2: RE( measure_wsaxs( t = 1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample= sample ) ) RE( measure_waxs( t = 1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample= sample ) ) else: RE( measure_waxs( t = 1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample= sample ) ) RE( measure_wsaxs( t = 1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample= sample ) ) def measure_pos_noV( pos ): mov_sam( pos ) samplei = RE.md['sample'] _measure( samplei ) def measure_pos_V( pos , N = 20, wait_time= 5 * 60, start_time= 2 ): mov_sam( pos ) t0 = time.time() for i in range(N): dt = (time.time() - t0)/60 + start_time samplei = RE.md['sample'] + 'ApplyN0p7_t_%.1fmin'%dt print( i, samplei ) _measure( samplei ) print( 'Sleep for 5 min...') time.sleep( wait_time ) def _measure_one_potential( V ='' ): mov_sam ( 2 ) RE.md['sample'] += V print( RE.md['sample']) RE( measure_waxs() ) time.sleep(3) RE(measure_saxs(1, move_y= False ) ) ################################################## ############ Some convinent functions################# ######################################################### def movx( dx ): RE( bps.mvr(piezo.x, dx) ) def movy( dy ): RE( bps.mvr(piezo.y, dy) ) def get_posxy( ): return round( piezo.x.user_readback.value, 2 ),round( piezo.y.user_readback.value , 2 ) def move_waxs( waxs_angle=8.0): RE( bps.mv(waxs, waxs_angle) ) def move_waxs_off( waxs_angle=8.0 ): RE( bps.mv(waxs, waxs_angle) ) def move_waxs_on( waxs_angle=0.0 ): RE( bps.mv(waxs, waxs_angle) ) def mov_sam( pos ): px,py = pxy_dict[ pos ] RE( bps.mv(piezo.x, px) ) RE( bps.mv(piezo.y, py) ) sample = sample_dict[pos] print('Move to pos=%s for sample:%s...'%(pos, sample )) RE.md['sample'] = sample def check_saxs_sample_loc( sleep = 5 ): ks = list( sample_dict.keys() ) for k in ks: mov_sam( k ) time.sleep( sleep ) def measure_saxs( t = 1, att='None', dx=0, dy=0, user_name=username, sample= None ): if sample is None: sample = RE.md['sample'] dets = [ pil1M ] if dy: yield from bps.mvr(piezo.y, dy ) if dx: yield from bps.mvr(piezo.x, dx ) name_fmt = '{sample}_x{x:05.2f}_y{y:05.2f}_z{z_pos:05.2f}_det{saxs_z:05.2f}m_expt{t}s_sid{scan_id:08d}' sample_name = name_fmt.format( sample = sample, x=np.round(piezo.x.position,2), y=np.round(piezo.y.position,2), z_pos=piezo.z.position, saxs_z=np.round(pil1m_pos.z.position,2), t=t, scan_id=RE.md['scan_id']) det_exposure_time( t, t) #sample_name='test' sample_id(user_name=user_name, sample_name=sample_name ) print(f'\n\t=== Sample: {sample_name} ===\n') print('Collect data here....') yield from bp.count(dets, num=1) sample_id(user_name='test', sample_name='test') def measure_waxs( t = 1, waxs_angle=0, att='None', dx=0, dy=0, user_name=username, sample= None ): if sample is None: sample = RE.md['sample'] yield from bps.mv(waxs, waxs_angle) dets = [ pil900KW, pil300KW ] #att_in( att ) if dx: yield from bps.mvr(piezo.x, dx ) if dy: yield from bps.mvr(piezo.y, dy ) name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}' sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position, waxs_angle=waxs_angle, expt= t, scan_id=RE.md['scan_id']) det_exposure_time( t, t) sample_id(user_name=user_name, sample_name=sample_name ) print(f'\n\t=== Sample: {sample_name} ===\n') print('Collect data here....') yield from bp.count(dets, num=1) #att_out( att ) #sample_id(user_name='test', sample_name='test') def measure_wsaxs( t = 1, waxs_angle=20, att='None', dx=0, dy=0, user_name=username, sample= None ): if sample is None: sample = RE.md['sample'] yield from bps.mv(waxs, waxs_angle) dets = [ pil900KW, pil300KW , pil1M ] if dx: yield from bps.mvr(piezo.x, dx ) if dy: yield from bps.mvr(piezo.y, dy ) name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_det{saxs_z}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}' sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position, saxs_z=np.round(pil1m_pos.z.position,2), waxs_angle=waxs_angle, expt= t, scan_id=RE.md['scan_id']) det_exposure_time( t, t) sample_id(user_name=user_name, sample_name=sample_name ) print(f'\n\t=== Sample: {sample_name} ===\n') print('Collect data here....') yield from bp.count(dets, num=1) #att_out( att ) #sample_id(user_name='test', sample_name='test')
""" #SMI: 2021/10/30 SAF: 308214 Standard Beamline 12-ID proposal: (CFN, 307961) create proposal: proposal_id( '2021_3', '307961_Dinca' ) #create the proposal id and folder %run -i /home/xf12id/.ipython/profile_collection/startup/users/30-user-Dinca2021C2B.py RE( shopen() ) # to open the beam and feedback RE( shclose()) # Energy: 16.1 keV, 0.77009 A # SAXS distance 5000 ##for the run >=5 # 5 m, beam stop: 1.9 # 5m, 1M, x=-5, Y = -40 # the correspond beam center is [ 454, 682 ] # beamstop_save() FOR MIT CELL, Cables: Cell A: #3, red to red #2 orange to blue Cell B: #9 black to black #4 brown to brown """ username = 'Dinca' sample_dict = {1: 'Cell01_NaCl_Electrolyte', 2: 'Cell03_AlCl3_Electrolyte'} sample_dict = {1: 'Cell05_MgCl2_Electrolyte', 2: 'Cell06_AlCl3_Electrolyte'} sample_dict = {1: 'Cell04_NH4Cl_Electrolyte', 2: 'Cell07_NaCl_Electrolyte_PH1'} pxy_dict = {1: (35800, 800), 2: (-23400, 1200)} pz = -1500 user_name = 'Dinca' pos = 1 def _measure(sample): if abs(waxs.arc.user_readback.value - 20) < 2: re(measure_wsaxs(t=1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample=sample)) re(measure_waxs(t=1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample=sample)) else: re(measure_waxs(t=1, waxs_angle=0, att='None', dy=0, user_name=user_name, sample=sample)) re(measure_wsaxs(t=1, waxs_angle=20, att='None', dy=0, user_name=user_name, sample=sample)) def measure_pos_no_v(pos): mov_sam(pos) samplei = RE.md['sample'] _measure(samplei) def measure_pos_v(pos, N=20, wait_time=5 * 60, start_time=2): mov_sam(pos) t0 = time.time() for i in range(N): dt = (time.time() - t0) / 60 + start_time samplei = RE.md['sample'] + 'ApplyN0p7_t_%.1fmin' % dt print(i, samplei) _measure(samplei) print('Sleep for 5 min...') time.sleep(wait_time) def _measure_one_potential(V=''): mov_sam(2) RE.md['sample'] += V print(RE.md['sample']) re(measure_waxs()) time.sleep(3) re(measure_saxs(1, move_y=False)) def movx(dx): re(bps.mvr(piezo.x, dx)) def movy(dy): re(bps.mvr(piezo.y, dy)) def get_posxy(): return (round(piezo.x.user_readback.value, 2), round(piezo.y.user_readback.value, 2)) def move_waxs(waxs_angle=8.0): re(bps.mv(waxs, waxs_angle)) def move_waxs_off(waxs_angle=8.0): re(bps.mv(waxs, waxs_angle)) def move_waxs_on(waxs_angle=0.0): re(bps.mv(waxs, waxs_angle)) def mov_sam(pos): (px, py) = pxy_dict[pos] re(bps.mv(piezo.x, px)) re(bps.mv(piezo.y, py)) sample = sample_dict[pos] print('Move to pos=%s for sample:%s...' % (pos, sample)) RE.md['sample'] = sample def check_saxs_sample_loc(sleep=5): ks = list(sample_dict.keys()) for k in ks: mov_sam(k) time.sleep(sleep) def measure_saxs(t=1, att='None', dx=0, dy=0, user_name=username, sample=None): if sample is None: sample = RE.md['sample'] dets = [pil1M] if dy: yield from bps.mvr(piezo.y, dy) if dx: yield from bps.mvr(piezo.x, dx) name_fmt = '{sample}_x{x:05.2f}_y{y:05.2f}_z{z_pos:05.2f}_det{saxs_z:05.2f}m_expt{t}s_sid{scan_id:08d}' sample_name = name_fmt.format(sample=sample, x=np.round(piezo.x.position, 2), y=np.round(piezo.y.position, 2), z_pos=piezo.z.position, saxs_z=np.round(pil1m_pos.z.position, 2), t=t, scan_id=RE.md['scan_id']) det_exposure_time(t, t) sample_id(user_name=user_name, sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') print('Collect data here....') yield from bp.count(dets, num=1) sample_id(user_name='test', sample_name='test') def measure_waxs(t=1, waxs_angle=0, att='None', dx=0, dy=0, user_name=username, sample=None): if sample is None: sample = RE.md['sample'] yield from bps.mv(waxs, waxs_angle) dets = [pil900KW, pil300KW] if dx: yield from bps.mvr(piezo.x, dx) if dy: yield from bps.mvr(piezo.y, dy) name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}' sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position, waxs_angle=waxs_angle, expt=t, scan_id=RE.md['scan_id']) det_exposure_time(t, t) sample_id(user_name=user_name, sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') print('Collect data here....') yield from bp.count(dets, num=1) def measure_wsaxs(t=1, waxs_angle=20, att='None', dx=0, dy=0, user_name=username, sample=None): if sample is None: sample = RE.md['sample'] yield from bps.mv(waxs, waxs_angle) dets = [pil900KW, pil300KW, pil1M] if dx: yield from bps.mvr(piezo.x, dx) if dy: yield from bps.mvr(piezo.y, dy) name_fmt = '{sample}_x{x_pos:05.2f}_y{y_pos:05.2f}_z{z_pos:05.2f}_det{saxs_z}_waxs{waxs_angle:05.2f}_expt{expt}s_sid{scan_id:08d}' sample_name = name_fmt.format(sample=sample, x_pos=piezo.x.position, y_pos=piezo.y.position, z_pos=piezo.z.position, saxs_z=np.round(pil1m_pos.z.position, 2), waxs_angle=waxs_angle, expt=t, scan_id=RE.md['scan_id']) det_exposure_time(t, t) sample_id(user_name=user_name, sample_name=sample_name) print(f'\n\t=== Sample: {sample_name} ===\n') print('Collect data here....') yield from bp.count(dets, num=1)
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSymmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root: return False def dfs(leftNode,rightNode): if leftNode == None and rightNode == None: return True elif leftNode == None or rightNode == None or leftNode.val != rightNode.val: return False else: return dfs(leftNode.left,rightNode.right) and dfs(leftNode.right,rightNode.left) return dfs(root.left,root.right)
class Solution(object): def is_symmetric(self, root): """ :type root: TreeNode :rtype: bool """ if not root: return False def dfs(leftNode, rightNode): if leftNode == None and rightNode == None: return True elif leftNode == None or rightNode == None or leftNode.val != rightNode.val: return False else: return dfs(leftNode.left, rightNode.right) and dfs(leftNode.right, rightNode.left) return dfs(root.left, root.right)
class Arithmetic: def __init__(self): self.value1 = 0 self.value2 = 0 def Accept(self, no1, no2): self.value1 = no1 self.value2 = no2 def Addition(self): result = self.value1 + self.value2 print("Addition is = ", result) def Subtraction(self): result = self.value1 - self.value2 print("Subtraction is = ", result) def Multiplication(self): result = self.value1 * self.value2 print("Multiplication is = ", result) def Division(self): result = self.value1 / self.value2 print("Division is = ", result) def main(): a = int(input("Enter value1 : ")) b = int(input("Enter value2 = ")) obj = Arithmetic() obj.Accept(a, b) obj.Addition() obj.Subtraction() obj.Multiplication() obj.Division() if __name__ == '__main__': main()
class Arithmetic: def __init__(self): self.value1 = 0 self.value2 = 0 def accept(self, no1, no2): self.value1 = no1 self.value2 = no2 def addition(self): result = self.value1 + self.value2 print('Addition is = ', result) def subtraction(self): result = self.value1 - self.value2 print('Subtraction is = ', result) def multiplication(self): result = self.value1 * self.value2 print('Multiplication is = ', result) def division(self): result = self.value1 / self.value2 print('Division is = ', result) def main(): a = int(input('Enter value1 : ')) b = int(input('Enter value2 = ')) obj = arithmetic() obj.Accept(a, b) obj.Addition() obj.Subtraction() obj.Multiplication() obj.Division() if __name__ == '__main__': main()
input = """####.#.##.###.#.#.##.#..###.#..#.#.#..##....#.###...##..###.##.#.#.#.##...##..#..#....#.#.##..#...## .##...##.##.######.#.#.##...#.#.#.#.#...#.##.#..#.#.####...#....#....###.#.#.#####....#.#.##.#.#.##. ###.##..#..#####.......#.########...#.####.###....###.###...#...####.######.#..#####.#.###....####.. ....#..#..#....###.##.#.....##...#.###.#.#.#..#.#..##...#....#.##.###.#...######......#..#.#..####.# ..###.####..#.#.#..##.#.#....#......#.##.##..##.#.....##.###.#..###...###.#.##..#.#..###....####.#.# #.#...#......####.#..##.####.#.#.#...##..###.##.#...#..#..###....#.#....#..##..#....##.....##.#...#. ....##.#.#.#.##..##...##..##..#....#....###...####.###...##.#...#..#....##.....#..#.#####.###.###.## #...##..#.#..#....#..########.##....##..##.###..#.#..#..#.##.##.#..##..######....####..#####.#.###.. .####...######.#..#.##.#.#..####...####.##.#.#......#...##....##..#...###..#.####......###......#.## .####.###..#..#####.##...###......#...###..#..##..#.#....##.##.#.##.###..#..#..###.#..#.#....####.## #..#..##.##.##.###.#.##.##.#.#.#....#....#.####.#.##...#####...###.#####.#.#.#....####..###..###..## #.##....#...########..##...#.#.##.......#.#..##...####...#.####.####..##...##.#....###.#.####...#.## #.#...##..#.##.##..##....#.....##.##.....#...###...#..#...####.##.####..#...##..##.##.##.##..##...## .#..###...#.#.....#######..##.###....##..#.##.#......###.##....#......###...#.##....#.....##......## ..##....#.###...###..####.##..#..##.##......##.#.....#...#..#..##...###..#.####...#...#..##.#..##..# ...#.#.#...#.#..#.##....##..#...#.##..#......#.#.....#####.##.#...#######.#.#..#.####..###.....###.# .#....#.#.##..####.#####..#.#######..#.##.###...##.##....##..###..#.##.###.......#....#..######.#### #..#.##.##..#..#..##.####.#.#.#.#..#.##...#..######....#.##.#..##.##.######.###.###.###...#.....#.#. .#.......#...#.####.##...#####..##..#.#....##..#.#.#.####.#.##....#..##.##..#.###.....#.##.##.#.##.# #..##..##...#....#.##.#...#.#....#......####...##..#...##.##.#..#########..#..#.##.##..#.#.#######.. #.......#####..###..######.#..##.#.#####..##...###...#.####.##...###..#.#.#####....#...#.##...#.#..# .##..#...#####.##.##......#...#.#.#.###.#.#.#...##.#..#....###.....#..#.#.###......#####.###.#..##.# .....###.#.#.#..##...#...###..#...#.#.##..###.##.#####.##..#.#.#.#.#####....#.#.#####...##.#..#.#.#. ###...##.#..#.####..##.#..##.#.#.#...#.#..#..##..##..#.#.#.#.##...##..#..#.....#....#####.#.#.####.# ....##....#.#.....#...###.#...##..##.##..#..###..##.###..#####..#...#####.##.#..#.#.#.###...####.### ##.##.##.#...#..#...........##.##.###.#...###.####.#..#..#...#..#..####.#.###########..#.###.###.#.# ##.##..##.####..###...##...#....###.###.#..##..#..#.###.#..####.#..##.#.#...#..#.#.##.##...#...#.... ..##...#.#.##....##...#.#.#......##.##.#.#.####.####....####.#.###.##.#.#..####..#..######..#..#.#.. ####.#.##.......##.###....##.#..####.#.#######..#...###..##.##..#...#...####........#.#..##...#....# #..#.#.....#..#.###..#.#...###..##...#.#..#.#.##..#...##.##.##.#.#.#..#.####.########....########..# #...#..##.##..#.#.#.##.##.##.#..#..#.##....#....###.#.###.#.#..#....#...##..#.....####...##.#..#...# .###...##...####....###.##.#..####...##.#.##.#..##..##....#....##.#...#..#..##..##..##.#...#...###.. .#..##.#..##..####..#.#.##..###.#...#....##.###...#.###....#.#.#........#..#.#.#..##..#####..#..#.#. .#.##.....#..#...#.##.....#.##..#..#....#..#..#....#.##..##...#.##.##..##..#.#.#.##..####.##..#.#..# ...###.#.....#...#.##.#.###.#...##..#.###..#..#..#.#..#...###.#.##.##.##.#.##.#####.#..#.#..#.#...## #.#.#.#.##.#.....##..#.###......##.#.##..#...#.########.##.###..#..#..##..##.#..##..###.#.###...#.#. ..##...##...#...###.#..##..#..#..#.#.##..##......##..##.....##.....####..#.##......#..####...###..## ##.......#..##....###...###......#.##.##....######..###.##...##.#...#...#.....#.###.#.#..#.##..#..#. #.#..#..#.#####.##.##.###..#...###.....#..##..####...#.#.###....#..#.#.###.####..#.#........##.#.... ..###.#...##.#.####.#.##.##.....##...#.##.#.###.#.#..##.#..##..#..##.##....#.#####.##..#######.....# ###.###..##.#..##...#####..##.####....#.##......##......#.#....##.####.#.#.#.###...#..####..#.###### #..###...#.#.......#..####.####...#....###.###...#.##..##..#..##.##.......####.##...#.#.#.##.#.#..#. ..#...#..###.##..#.#.#.##..#..#.#.......###..###..#####.#.#.#.#.#..#.#.#.#..###....#.####..###...#.. ...######.###....#..####.####......#...#.###.#....#...####.##........##...##.#..##.###.#..#..##..### .#..###.####.###.#.#..#..#..#.##.#.#.###.##..####.#####..##....##.#.##...###.####.#.#######.#..#..#. .#..##.#..##..#...##...#..#..##.#.#....##.##...###.#.#...##..##..#.###.#.#.#.#...#....#.#..#.#.###.# .###..#.#..####.#########...####....####.#.##...##.##..#.##.#........#.....###.###.######.##.....### ..##.##..##..#.####.#..#####.#....##.##.#####.....#.#......##...#####..####....###..#.#...#..####..# .#..##..##.##.##.##.#.###.###.#..#..#...###.#.##..##...##...###...##.###..#.#.#####.#.#.##....#.##.. ...#.#....##.#.....###.##...#..##....#...###....#..#.###...##.#...###.#....#...##..###.#.....##....# .#######..#...##.#.###.##.#.###...##......#.###.#...#.###.#.#.#..#..#####..#########...##..##...#..# .#..#.##...#.#..#.##..#.#.#.##.....####.#..#.###..##.#.#.#...#....#.#..##.######...#.#..##.##...#..# #.#######.#####..#####.##.##.#.#.##.###..#....####.#..##.##.######..###...#.#..#.####.##.##....####. ...##..#...##..#..#.....#.##...#.....##.#####.###.########.######..#...###..#.##.#.#.##..#.#.##..##. #..#..#.#....###.#...##..####.#.##..#.####.###..##.#...#.###.#..#.##..#######.#...#..#.#..##.#....## ..#.##.#.####..##.###.###..#.##.#.####..##....##.###.#..##.#.###.###.##.##.#####..#.#...########.... .#.#.###..###...#...#..##.##......#..#...#.#.#.######.#.#...##..##........#....###..##...#..##.##... ##..#....##.###...##.#.##.##.##..#....#.#.#..#..####.##..#...#...#..#..#####.###...#..###..#...#.#.. ##.#.#.##.###.....######.#.....#...#.##....###.#.##.#.#.##..##.######.#####....#.#####...##.#..###.# ######.#...####..###..##..#..##...#.#....##.#...##...#.....#...##....#.##..###..###...###..#..###### .....##.........#####.#.##..#..#.#.#.#.##...#....#.....###.########...#..####..#...#...##..#.##.##.# #..###...#.##.##.#.#..####.#.....##..###....##..#...#.#...##.##..###..####...#.####..##..#..##..#... #.####.#..##.#..#.....#..#.#..###...######.#.........####....###..#.#.#.##.#..#...#..####.....##..#. ..##....#.###.......##.#...#.####..##....##.#..#....#######...####.##..#####.#.#.#.#.##..##..#.#.#.. #.#.#.###..#..#.#..#.#.###....#...#####.###...........#.#....#####...#..####....#...###.#..#..####.. .......#.####.##...#..#.##..###..#..#.#.#.#.###....#....#.#.#..#.#..##.#####.#.....#.##.#.###.###.## ..###...#..#...####.#..##..##.#.#..#...#.#..#....###.#..####..######...####.#.##..#.#..###...##.#### ..#.###..#.#...##...#.#....#..#...#.#..##.######.######.#.##.....#..##.#..###..#..#.##.###...#..#.## ####..##.####.....#...#.#.###..#...####.###.#.#.#.......##...#....#..#....#.#......###...#####.#.##. #..##..#..#.####...#####.#.###.##.#.##.....#.#..#.##........######.#.#.###....##.##..##..########.## #.#....###.##....#######.#...#.#.#.#..##.#.##...#.###...#.#.#..#.#..####.#.#..#..#.##.####....#..##. ####.##....#.......###..#..##.#.#.##..#...#...##.###....##..###.#.#...#..#.....##.###.##...###....## ..##.#..#....######..#.##.#.#...##..####.#####...##.#..###.##...#..####..###.##..##.##.#####.#..#.#. .#.##..#..##.#.###.###....#.#..#....#...###.##.#.#.####.....#....#...#.....#....#.#.###.#..#.##..### ..###.#.#.##...##.##.##.#...#####.#..##.#....##..####...###..#....#.##...#........#####.#.###.#..#.. ....#..##..##....#.#....#.#..##...##.#...##.###.#.#..###..##.##.##..#.#.#..#.#.##.......#.##.###..#. .#..##.##.####.##....##.##.....###..##.#.##...#..###....###.###....#.#....#....#.##.#.##.#.##.....## #.#..#.##.###.#.######.....###.#..#...#.#.....##.###.#...#.#..###.#.....##.###.#.###.####..#####.#.. #.#.##......#.##.#.#..##....#..###.#.###...##...###.#..#.##...#..#.##..##.#...######.##.....#####.## #.#..#####....###.###...#.......#....###.##...#..#.##..#...#####..#..#.##......###...#...###..#.#..# #.##..##.##.#..#.##.##..#.###.##.........###.#.#..#.#.....#.#...#.#.##.#.##.#...#...####.#.......##. .#...####.##..#..##....####..######...#.#..##.##.....#####.#...#..#.####.#######...#.#####..#.###... .#..######.#.##..##...##.....###.#..##..#...####..###...###.###..#..######.#....########..#####...#. #..##.......#####...###..#.#.##.#..###.#...##.#..#.##.###...###...##.#..##..########..#.#..##..#.### .#.#..#...#.#..#..##...#.#.##...###..#..#....###.#....#.##....###.###..##..#.#.####..####.#######.## ...##..##.##.###.##.###...##.#.#.....##.####..#..##.#..#.####...##..#..#.##...##...###.##.#.......## .#.....#.##..#.#.....#.##.##..###..#....###...#.#....##########.##.###.#...#.####..####.#..#.#..###. .##.#.#.##..#..###.###.##.#########.#.#.#.#.##.###..##..#.##.####......#####...#..####.#.##..#####.# ..#....###...##....#.###..##..#..####.##..####.#..####.###.#....####.....#.###..##...##..####...##.# .###.....###.##.##..###.###.....##..#.######.#.#..##..#.##.#..#.#.#....#...#.#.#...#...##....#..##.# ..##....#..#####....#..####.#.#...##.#....##..##.###.###....###......#...#.#####.......#...#.....### ###.#..#.#.##..#..#...#.#....###.##.#.###.#...#.##.#..#.#.......#.#.#.###.####.###....#..##..#####.. .#..#######.#..###.#.##.#####.#####...##..#.####.#.#.##..###...#..##.##..#.#.###..#....#..#...###.#. ..#####..#.##.....###..##.#...#.#.#..#######.#..#...#.##.##.#.#....####...###..##...#....####.#..#.# .####..#.#.##.###.#.##.....#..##.#.....###.....#..##...#....###.###..#......###.#.#.#.##.#.##..#...# ##.#..##.#..##...#.#....##..######..#.....#..#...#####....##......####.##..#...##..#.##.#.#######..# ##..####.#...##...#.#####.#.#..#....#.#..##.####.#..######.#..#..#.......#####..#..#..###.##...##.## #.####......#.###...#..####.#..##.##..#.#...##.###.#...#####..####.#..#.#.....#.##...###...#.#....## ###.#.#.##.######......#.#.#.#.#........#..#..###.#.#.#..#.........#..#....#.#..#..#..###.##......## ##.#########...#...###..#.###.....#.#.##.........###....#.####.#...###.#..##..#.###..#..##......#.##""" target = 100 class Light: def __init__(self, x, y, state): self.x = x self.y = y self.state = state self.next_state = None def calculate_next_state(self, grid): on_around = 0 for dy in range(-1, 2): if self.y + dy < 0: continue for dx in range(-1, 2): if dx == 0 and dy == 0: continue if self.x + dx < 0: continue try: on_around += grid[self.y + dy][self.x + dx].state except IndexError: pass if self.state == 1: self.next_state = 1 if on_around == 2 or on_around == 3 else 0 else: self.next_state = 1 if on_around == 3 else 0 def apply_next_state(self): if self.next_state is None: print("Invalid next state") exit(1) self.state = self.next_state self.next_state = None grid = [] for y, line in enumerate(input.splitlines()): grid.append([ Light(x, y, 1 if l == "#" else 0) for x, l in enumerate(line) ]) def update_grid(grid): for y in range(len(grid)): for x in range(len(grid[0])): grid[y][x].calculate_next_state(grid) for y in range(len(grid)): for x in range(len(grid[0])): grid[y][x].apply_next_state() def pretty_print_grid(grid): for row in grid: print("".join([ "#" if l.state else "." for l in row ])) for i in range(target): update_grid(grid) # pretty_print_grid(grid) print(sum([l.state for row in grid for l in row]))
input = '####.#.##.###.#.#.##.#..###.#..#.#.#..##....#.###...##..###.##.#.#.#.##...##..#..#....#.#.##..#...##\n.##...##.##.######.#.#.##...#.#.#.#.#...#.##.#..#.#.####...#....#....###.#.#.#####....#.#.##.#.#.##.\n###.##..#..#####.......#.########...#.####.###....###.###...#...####.######.#..#####.#.###....####..\n....#..#..#....###.##.#.....##...#.###.#.#.#..#.#..##...#....#.##.###.#...######......#..#.#..####.#\n..###.####..#.#.#..##.#.#....#......#.##.##..##.#.....##.###.#..###...###.#.##..#.#..###....####.#.#\n#.#...#......####.#..##.####.#.#.#...##..###.##.#...#..#..###....#.#....#..##..#....##.....##.#...#.\n....##.#.#.#.##..##...##..##..#....#....###...####.###...##.#...#..#....##.....#..#.#####.###.###.##\n#...##..#.#..#....#..########.##....##..##.###..#.#..#..#.##.##.#..##..######....####..#####.#.###..\n.####...######.#..#.##.#.#..####...####.##.#.#......#...##....##..#...###..#.####......###......#.##\n.####.###..#..#####.##...###......#...###..#..##..#.#....##.##.#.##.###..#..#..###.#..#.#....####.##\n#..#..##.##.##.###.#.##.##.#.#.#....#....#.####.#.##...#####...###.#####.#.#.#....####..###..###..##\n#.##....#...########..##...#.#.##.......#.#..##...####...#.####.####..##...##.#....###.#.####...#.##\n#.#...##..#.##.##..##....#.....##.##.....#...###...#..#...####.##.####..#...##..##.##.##.##..##...##\n.#..###...#.#.....#######..##.###....##..#.##.#......###.##....#......###...#.##....#.....##......##\n..##....#.###...###..####.##..#..##.##......##.#.....#...#..#..##...###..#.####...#...#..##.#..##..#\n...#.#.#...#.#..#.##....##..#...#.##..#......#.#.....#####.##.#...#######.#.#..#.####..###.....###.#\n.#....#.#.##..####.#####..#.#######..#.##.###...##.##....##..###..#.##.###.......#....#..######.####\n#..#.##.##..#..#..##.####.#.#.#.#..#.##...#..######....#.##.#..##.##.######.###.###.###...#.....#.#.\n.#.......#...#.####.##...#####..##..#.#....##..#.#.#.####.#.##....#..##.##..#.###.....#.##.##.#.##.#\n#..##..##...#....#.##.#...#.#....#......####...##..#...##.##.#..#########..#..#.##.##..#.#.#######..\n#.......#####..###..######.#..##.#.#####..##...###...#.####.##...###..#.#.#####....#...#.##...#.#..#\n.##..#...#####.##.##......#...#.#.#.###.#.#.#...##.#..#....###.....#..#.#.###......#####.###.#..##.#\n.....###.#.#.#..##...#...###..#...#.#.##..###.##.#####.##..#.#.#.#.#####....#.#.#####...##.#..#.#.#.\n###...##.#..#.####..##.#..##.#.#.#...#.#..#..##..##..#.#.#.#.##...##..#..#.....#....#####.#.#.####.#\n....##....#.#.....#...###.#...##..##.##..#..###..##.###..#####..#...#####.##.#..#.#.#.###...####.###\n##.##.##.#...#..#...........##.##.###.#...###.####.#..#..#...#..#..####.#.###########..#.###.###.#.#\n##.##..##.####..###...##...#....###.###.#..##..#..#.###.#..####.#..##.#.#...#..#.#.##.##...#...#....\n..##...#.#.##....##...#.#.#......##.##.#.#.####.####....####.#.###.##.#.#..####..#..######..#..#.#..\n####.#.##.......##.###....##.#..####.#.#######..#...###..##.##..#...#...####........#.#..##...#....#\n#..#.#.....#..#.###..#.#...###..##...#.#..#.#.##..#...##.##.##.#.#.#..#.####.########....########..#\n#...#..##.##..#.#.#.##.##.##.#..#..#.##....#....###.#.###.#.#..#....#...##..#.....####...##.#..#...#\n.###...##...####....###.##.#..####...##.#.##.#..##..##....#....##.#...#..#..##..##..##.#...#...###..\n.#..##.#..##..####..#.#.##..###.#...#....##.###...#.###....#.#.#........#..#.#.#..##..#####..#..#.#.\n.#.##.....#..#...#.##.....#.##..#..#....#..#..#....#.##..##...#.##.##..##..#.#.#.##..####.##..#.#..#\n...###.#.....#...#.##.#.###.#...##..#.###..#..#..#.#..#...###.#.##.##.##.#.##.#####.#..#.#..#.#...##\n#.#.#.#.##.#.....##..#.###......##.#.##..#...#.########.##.###..#..#..##..##.#..##..###.#.###...#.#.\n..##...##...#...###.#..##..#..#..#.#.##..##......##..##.....##.....####..#.##......#..####...###..##\n##.......#..##....###...###......#.##.##....######..###.##...##.#...#...#.....#.###.#.#..#.##..#..#.\n#.#..#..#.#####.##.##.###..#...###.....#..##..####...#.#.###....#..#.#.###.####..#.#........##.#....\n..###.#...##.#.####.#.##.##.....##...#.##.#.###.#.#..##.#..##..#..##.##....#.#####.##..#######.....#\n###.###..##.#..##...#####..##.####....#.##......##......#.#....##.####.#.#.#.###...#..####..#.######\n#..###...#.#.......#..####.####...#....###.###...#.##..##..#..##.##.......####.##...#.#.#.##.#.#..#.\n..#...#..###.##..#.#.#.##..#..#.#.......###..###..#####.#.#.#.#.#..#.#.#.#..###....#.####..###...#..\n...######.###....#..####.####......#...#.###.#....#...####.##........##...##.#..##.###.#..#..##..###\n.#..###.####.###.#.#..#..#..#.##.#.#.###.##..####.#####..##....##.#.##...###.####.#.#######.#..#..#.\n.#..##.#..##..#...##...#..#..##.#.#....##.##...###.#.#...##..##..#.###.#.#.#.#...#....#.#..#.#.###.#\n.###..#.#..####.#########...####....####.#.##...##.##..#.##.#........#.....###.###.######.##.....###\n..##.##..##..#.####.#..#####.#....##.##.#####.....#.#......##...#####..####....###..#.#...#..####..#\n.#..##..##.##.##.##.#.###.###.#..#..#...###.#.##..##...##...###...##.###..#.#.#####.#.#.##....#.##..\n...#.#....##.#.....###.##...#..##....#...###....#..#.###...##.#...###.#....#...##..###.#.....##....#\n.#######..#...##.#.###.##.#.###...##......#.###.#...#.###.#.#.#..#..#####..#########...##..##...#..#\n.#..#.##...#.#..#.##..#.#.#.##.....####.#..#.###..##.#.#.#...#....#.#..##.######...#.#..##.##...#..#\n#.#######.#####..#####.##.##.#.#.##.###..#....####.#..##.##.######..###...#.#..#.####.##.##....####.\n...##..#...##..#..#.....#.##...#.....##.#####.###.########.######..#...###..#.##.#.#.##..#.#.##..##.\n#..#..#.#....###.#...##..####.#.##..#.####.###..##.#...#.###.#..#.##..#######.#...#..#.#..##.#....##\n..#.##.#.####..##.###.###..#.##.#.####..##....##.###.#..##.#.###.###.##.##.#####..#.#...########....\n.#.#.###..###...#...#..##.##......#..#...#.#.#.######.#.#...##..##........#....###..##...#..##.##...\n##..#....##.###...##.#.##.##.##..#....#.#.#..#..####.##..#...#...#..#..#####.###...#..###..#...#.#..\n##.#.#.##.###.....######.#.....#...#.##....###.#.##.#.#.##..##.######.#####....#.#####...##.#..###.#\n######.#...####..###..##..#..##...#.#....##.#...##...#.....#...##....#.##..###..###...###..#..######\n.....##.........#####.#.##..#..#.#.#.#.##...#....#.....###.########...#..####..#...#...##..#.##.##.#\n#..###...#.##.##.#.#..####.#.....##..###....##..#...#.#...##.##..###..####...#.####..##..#..##..#...\n#.####.#..##.#..#.....#..#.#..###...######.#.........####....###..#.#.#.##.#..#...#..####.....##..#.\n..##....#.###.......##.#...#.####..##....##.#..#....#######...####.##..#####.#.#.#.#.##..##..#.#.#..\n#.#.#.###..#..#.#..#.#.###....#...#####.###...........#.#....#####...#..####....#...###.#..#..####..\n.......#.####.##...#..#.##..###..#..#.#.#.#.###....#....#.#.#..#.#..##.#####.#.....#.##.#.###.###.##\n..###...#..#...####.#..##..##.#.#..#...#.#..#....###.#..####..######...####.#.##..#.#..###...##.####\n..#.###..#.#...##...#.#....#..#...#.#..##.######.######.#.##.....#..##.#..###..#..#.##.###...#..#.##\n####..##.####.....#...#.#.###..#...####.###.#.#.#.......##...#....#..#....#.#......###...#####.#.##.\n#..##..#..#.####...#####.#.###.##.#.##.....#.#..#.##........######.#.#.###....##.##..##..########.##\n#.#....###.##....#######.#...#.#.#.#..##.#.##...#.###...#.#.#..#.#..####.#.#..#..#.##.####....#..##.\n####.##....#.......###..#..##.#.#.##..#...#...##.###....##..###.#.#...#..#.....##.###.##...###....##\n..##.#..#....######..#.##.#.#...##..####.#####...##.#..###.##...#..####..###.##..##.##.#####.#..#.#.\n.#.##..#..##.#.###.###....#.#..#....#...###.##.#.#.####.....#....#...#.....#....#.#.###.#..#.##..###\n..###.#.#.##...##.##.##.#...#####.#..##.#....##..####...###..#....#.##...#........#####.#.###.#..#..\n....#..##..##....#.#....#.#..##...##.#...##.###.#.#..###..##.##.##..#.#.#..#.#.##.......#.##.###..#.\n.#..##.##.####.##....##.##.....###..##.#.##...#..###....###.###....#.#....#....#.##.#.##.#.##.....##\n#.#..#.##.###.#.######.....###.#..#...#.#.....##.###.#...#.#..###.#.....##.###.#.###.####..#####.#..\n#.#.##......#.##.#.#..##....#..###.#.###...##...###.#..#.##...#..#.##..##.#...######.##.....#####.##\n#.#..#####....###.###...#.......#....###.##...#..#.##..#...#####..#..#.##......###...#...###..#.#..#\n#.##..##.##.#..#.##.##..#.###.##.........###.#.#..#.#.....#.#...#.#.##.#.##.#...#...####.#.......##.\n.#...####.##..#..##....####..######...#.#..##.##.....#####.#...#..#.####.#######...#.#####..#.###...\n.#..######.#.##..##...##.....###.#..##..#...####..###...###.###..#..######.#....########..#####...#.\n#..##.......#####...###..#.#.##.#..###.#...##.#..#.##.###...###...##.#..##..########..#.#..##..#.###\n.#.#..#...#.#..#..##...#.#.##...###..#..#....###.#....#.##....###.###..##..#.#.####..####.#######.##\n...##..##.##.###.##.###...##.#.#.....##.####..#..##.#..#.####...##..#..#.##...##...###.##.#.......##\n.#.....#.##..#.#.....#.##.##..###..#....###...#.#....##########.##.###.#...#.####..####.#..#.#..###.\n.##.#.#.##..#..###.###.##.#########.#.#.#.#.##.###..##..#.##.####......#####...#..####.#.##..#####.#\n..#....###...##....#.###..##..#..####.##..####.#..####.###.#....####.....#.###..##...##..####...##.#\n.###.....###.##.##..###.###.....##..#.######.#.#..##..#.##.#..#.#.#....#...#.#.#...#...##....#..##.#\n..##....#..#####....#..####.#.#...##.#....##..##.###.###....###......#...#.#####.......#...#.....###\n###.#..#.#.##..#..#...#.#....###.##.#.###.#...#.##.#..#.#.......#.#.#.###.####.###....#..##..#####..\n.#..#######.#..###.#.##.#####.#####...##..#.####.#.#.##..###...#..##.##..#.#.###..#....#..#...###.#.\n..#####..#.##.....###..##.#...#.#.#..#######.#..#...#.##.##.#.#....####...###..##...#....####.#..#.#\n.####..#.#.##.###.#.##.....#..##.#.....###.....#..##...#....###.###..#......###.#.#.#.##.#.##..#...#\n##.#..##.#..##...#.#....##..######..#.....#..#...#####....##......####.##..#...##..#.##.#.#######..#\n##..####.#...##...#.#####.#.#..#....#.#..##.####.#..######.#..#..#.......#####..#..#..###.##...##.##\n#.####......#.###...#..####.#..##.##..#.#...##.###.#...#####..####.#..#.#.....#.##...###...#.#....##\n###.#.#.##.######......#.#.#.#.#........#..#..###.#.#.#..#.........#..#....#.#..#..#..###.##......##\n##.#########...#...###..#.###.....#.#.##.........###....#.####.#...###.#..##..#.###..#..##......#.##' target = 100 class Light: def __init__(self, x, y, state): self.x = x self.y = y self.state = state self.next_state = None def calculate_next_state(self, grid): on_around = 0 for dy in range(-1, 2): if self.y + dy < 0: continue for dx in range(-1, 2): if dx == 0 and dy == 0: continue if self.x + dx < 0: continue try: on_around += grid[self.y + dy][self.x + dx].state except IndexError: pass if self.state == 1: self.next_state = 1 if on_around == 2 or on_around == 3 else 0 else: self.next_state = 1 if on_around == 3 else 0 def apply_next_state(self): if self.next_state is None: print('Invalid next state') exit(1) self.state = self.next_state self.next_state = None grid = [] for (y, line) in enumerate(input.splitlines()): grid.append([light(x, y, 1 if l == '#' else 0) for (x, l) in enumerate(line)]) def update_grid(grid): for y in range(len(grid)): for x in range(len(grid[0])): grid[y][x].calculate_next_state(grid) for y in range(len(grid)): for x in range(len(grid[0])): grid[y][x].apply_next_state() def pretty_print_grid(grid): for row in grid: print(''.join(['#' if l.state else '.' for l in row])) for i in range(target): update_grid(grid) print(sum([l.state for row in grid for l in row]))
class Config(object) : #DETECTRON_URL = 'http://localhost/predictions' DETECTRON_URL = 'https://master-ainized-detectron2-gkswjdzz.endpoint.ainize.ai/predictions' #STANFORDNLP_URL = 'http://localhost:81/analyze' STANFORDNLP_URL = 'https://master-ainized-stanfordnlp-gkswjdzz.endpoint.ainize.ai/analyze'
class Config(object): detectron_url = 'https://master-ainized-detectron2-gkswjdzz.endpoint.ainize.ai/predictions' stanfordnlp_url = 'https://master-ainized-stanfordnlp-gkswjdzz.endpoint.ainize.ai/analyze'
""" From Kapil Sharma's lecture 11 Jun 2020 Given the head of a sll and a node, return its index (position). Assume that indexing starts at 0. Return -1 if index is not found. """ class Node: def __init__(self, data): self.data = data self.next = None def find_index(head, node): # Edge cases if head == None or node == None: return -1 if head == node: return 0 position = 0 curr = head # Iterate thru sll until node is found or reach tail while curr is not None and curr != node: curr = curr.next position += 1 # If node is not found if curr == None: return -1 # If node is found return position node1 = Node(1) node2 = Node(2) node3 = Node(3) node1.next = node2 node2.next = node3 node4 = Node(4) def print_ll(head): ll_list = [] curr = head while curr is not None: ll_list.append(curr.data) curr = curr.next print(ll_list) return ll_list try: print_ll(node1) print(find_index(node1, node1)) # 0 print(find_index(node1, node2)) # 1 print(find_index(node1, node3)) # 2 print(find_index(node1, node4)) # -1 print(find_index(node1, node5)) # Exception except Exception: print("node does not exist")
""" From Kapil Sharma's lecture 11 Jun 2020 Given the head of a sll and a node, return its index (position). Assume that indexing starts at 0. Return -1 if index is not found. """ class Node: def __init__(self, data): self.data = data self.next = None def find_index(head, node): if head == None or node == None: return -1 if head == node: return 0 position = 0 curr = head while curr is not None and curr != node: curr = curr.next position += 1 if curr == None: return -1 return position node1 = node(1) node2 = node(2) node3 = node(3) node1.next = node2 node2.next = node3 node4 = node(4) def print_ll(head): ll_list = [] curr = head while curr is not None: ll_list.append(curr.data) curr = curr.next print(ll_list) return ll_list try: print_ll(node1) print(find_index(node1, node1)) print(find_index(node1, node2)) print(find_index(node1, node3)) print(find_index(node1, node4)) print(find_index(node1, node5)) except Exception: print('node does not exist')
# -*- coding: utf-8 -*- # AtCoder Beginner Contest def main(): n, a, b = list(map(int, input().split())) position = 0 for i in range(n): s, d = list(map(str, input().split())) if int(d) < a: d = a elif int(d) > b: d = b else: d = d if s == 'West': d = -1 * int(d) else: d = int(d) position += d if position == 0: print(str(0)) elif position > 0: print('East ' + str(position)) else: print('West ' + str(abs(position))) if __name__ == '__main__': main()
def main(): (n, a, b) = list(map(int, input().split())) position = 0 for i in range(n): (s, d) = list(map(str, input().split())) if int(d) < a: d = a elif int(d) > b: d = b else: d = d if s == 'West': d = -1 * int(d) else: d = int(d) position += d if position == 0: print(str(0)) elif position > 0: print('East ' + str(position)) else: print('West ' + str(abs(position))) if __name__ == '__main__': main()
""" Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2: Input: nums = [3,2,4], target = 6 Output: [1,2] Example 3: Input: nums = [3,3], target = 6 Output: [0,1] Constraints: 2 <= nums.length <= 104 -109 <= nums[i] <= 109 -109 <= target <= 109 Only one valid answer exists. Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity? Author: Eda AYDIN """ class Solution: def twoSum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ length = len(nums) for i in range(length): diff = target - nums[i] if diff in nums[i+1:]: index = nums[i + 1:].index(diff)+i+1 return [i, index] if __name__ == '__main__': solution = Solution() print(solution.twoSum([2,7,11,15],9))
""" Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target. You may assume that each input would have exactly one solution, and you may not use the same element twice. You can return the answer in any order. Example 1: Input: nums = [2,7,11,15], target = 9 Output: [0,1] Output: Because nums[0] + nums[1] == 9, we return [0, 1]. Example 2: Input: nums = [3,2,4], target = 6 Output: [1,2] Example 3: Input: nums = [3,3], target = 6 Output: [0,1] Constraints: 2 <= nums.length <= 104 -109 <= nums[i] <= 109 -109 <= target <= 109 Only one valid answer exists. Follow-up: Can you come up with an algorithm that is less than O(n2) time complexity? Author: Eda AYDIN """ class Solution: def two_sum(self, nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ length = len(nums) for i in range(length): diff = target - nums[i] if diff in nums[i + 1:]: index = nums[i + 1:].index(diff) + i + 1 return [i, index] if __name__ == '__main__': solution = solution() print(solution.twoSum([2, 7, 11, 15], 9))
class CFG: # Disease: _TARGET_R0 = 1.4 # before Test and Trace and Isolation DAYS_BEFORE_INFECTIOUS = 4 # t0 DAYS_INFECTIOUS_TO_SYMPTOMS = 2 # t1 DAYS_OF_SYMPTOMS = 5 # t2 PROB_SYMPTOMATIC = 0.6 # pS probability that an infected person develops actionable symptoms # Person: PROB_ISOLATE_IF_SYMPTOMS = 0.75 # pIsolSimpt PROB_ISOLATE_IF_TRACED = 0.3 # PROB_ISOLATE_IF_TESTPOS = 0.3 # PROB_GET_TEST_IF_TRACED = 0.75 # PROB_APPLY_FOR_TEST_IF_SYMPTOMS = 0.75 # pA DURATION_OF_ISOLATION = 10 #tIsol # Society: PROB_INFECT_IF_TOGETHER_ON_A_DAY = 0.025 # this is a moving target - because depends on hand-washing, masks ... PROB_NON_C19_SYMPTOMS_PER_DAY = 0.01 # like b - probability someone unnecessarily requests a test on a given day PROB_TEST_IF_REQUESTED = 1 # pG # set to 1 ... however, see the next parameter ... with capacity idea DAILY_TEST_CAPACITY_PER_HEAD = 0.0075 # being very generous here ... this is probably more like 0.005 TEST_DAYS_ELAPSED = 1 # like pR # time to get result to the index in an ideal world with no backlog # DAYS_GETTING_TO_CONTACTS = 1 # tricky to implement, leaving for now PROB_TRACING_GIVEN_CONTACT = 0.8 * 0.75 # pT # Simulator SIMULATOR_PERIODS_PER_DAY = 1 MEAN_NETWORK_SIZE = 1 +_TARGET_R0 / (DAYS_INFECTIOUS_TO_SYMPTOMS + DAYS_OF_SYMPTOMS) / PROB_INFECT_IF_TOGETHER_ON_A_DAY # the above formula, and the _TARGET_R0 concept, assumes that all people have identical network size _PROPORTION_OF_INFECTED_WHO_GET_TESTED = PROB_SYMPTOMATIC * \ PROB_APPLY_FOR_TEST_IF_SYMPTOMS * \ PROB_TEST_IF_REQUESTED # should be 0.205 def set_config(obj, conf): obj.cfg = CFG() if conf is not None: extra_params = (conf.keys() - set(dir(obj.cfg))) if len(extra_params) > 0: raise AttributeError(f"unrecognised parameter overrides: {extra_params}") obj.cfg.__dict__.update(conf or {}) def print_baseline_config(): cfg = CFG() for param in dir(cfg): if not param.startswith("__"): print(param, getattr(cfg, param))
class Cfg: _target_r0 = 1.4 days_before_infectious = 4 days_infectious_to_symptoms = 2 days_of_symptoms = 5 prob_symptomatic = 0.6 prob_isolate_if_symptoms = 0.75 prob_isolate_if_traced = 0.3 prob_isolate_if_testpos = 0.3 prob_get_test_if_traced = 0.75 prob_apply_for_test_if_symptoms = 0.75 duration_of_isolation = 10 prob_infect_if_together_on_a_day = 0.025 prob_non_c19_symptoms_per_day = 0.01 prob_test_if_requested = 1 daily_test_capacity_per_head = 0.0075 test_days_elapsed = 1 prob_tracing_given_contact = 0.8 * 0.75 simulator_periods_per_day = 1 mean_network_size = 1 + _TARGET_R0 / (DAYS_INFECTIOUS_TO_SYMPTOMS + DAYS_OF_SYMPTOMS) / PROB_INFECT_IF_TOGETHER_ON_A_DAY _proportion_of_infected_who_get_tested = PROB_SYMPTOMATIC * PROB_APPLY_FOR_TEST_IF_SYMPTOMS * PROB_TEST_IF_REQUESTED def set_config(obj, conf): obj.cfg = cfg() if conf is not None: extra_params = conf.keys() - set(dir(obj.cfg)) if len(extra_params) > 0: raise attribute_error(f'unrecognised parameter overrides: {extra_params}') obj.cfg.__dict__.update(conf or {}) def print_baseline_config(): cfg = cfg() for param in dir(cfg): if not param.startswith('__'): print(param, getattr(cfg, param))
getMappingUsageMetrics = [ { "names": [ "TotalBandwidth", "TotalHits", "HitRatio" ], "totals": [ "0.0", "0", "0.0" ], "type": "TOTALS" } ]
get_mapping_usage_metrics = [{'names': ['TotalBandwidth', 'TotalHits', 'HitRatio'], 'totals': ['0.0', '0', '0.0'], 'type': 'TOTALS'}]
class Solution: def reverse(self, x: int) -> int: l = 0 val = 0 flag = 1 if x == 0: return x else: if x>0: val = x l = len(str(val)) else: val = -1*x l = len(str(val)) flag = 0 count = 10 ** (l-1) output = 0 while count>=1: output = output + int(val%10*count) val=int(val//10) count/=10 return (0,(-1*output,output) [flag==1]) [output<2**31 and (output>-1*(2**31))]
class Solution: def reverse(self, x: int) -> int: l = 0 val = 0 flag = 1 if x == 0: return x else: if x > 0: val = x l = len(str(val)) else: val = -1 * x l = len(str(val)) flag = 0 count = 10 ** (l - 1) output = 0 while count >= 1: output = output + int(val % 10 * count) val = int(val // 10) count /= 10 return (0, (-1 * output, output)[flag == 1])[output < 2 ** 31 and output > -1 * 2 ** 31]
class Solution: def oddCells(self, n: int, m: int, indices: list) -> int: row_operation = [False] * n col_operation = [False] * m for index in indices: row_id, col_id = index row_operation[row_id] = not row_operation[row_id] col_operation[col_id] = not col_operation[col_id] row_operated_num = 0 col_operated_num = 0 for op in row_operation: if op: row_operated_num += 1 for op in col_operation: if op: col_operated_num += 1 return (row_operated_num * m + col_operated_num * n - 2 * row_operated_num * col_operated_num)
class Solution: def odd_cells(self, n: int, m: int, indices: list) -> int: row_operation = [False] * n col_operation = [False] * m for index in indices: (row_id, col_id) = index row_operation[row_id] = not row_operation[row_id] col_operation[col_id] = not col_operation[col_id] row_operated_num = 0 col_operated_num = 0 for op in row_operation: if op: row_operated_num += 1 for op in col_operation: if op: col_operated_num += 1 return row_operated_num * m + col_operated_num * n - 2 * row_operated_num * col_operated_num
""" http://stackoverflow.com/questions/312443/#312464 """ def chunks(l, n): for i in range(0, len(l), n): yield l[i : i + n]
""" http://stackoverflow.com/questions/312443/#312464 """ def chunks(l, n): for i in range(0, len(l), n): yield l[i:i + n]
# FindControlUnderMouse() returns an existing control, not a new one, # so create this one by hand. f = Function(ExistingControlHandle, 'FindControlUnderMouse', (Point, 'inWhere', InMode), (WindowRef, 'inWindow', InMode), (SInt16, 'outPart', OutMode), ) functions.append(f) f = Function(ControlHandle, 'as_Control', (Handle, 'h', InMode)) functions.append(f) f = Method(Handle, 'as_Resource', (ControlHandle, 'ctl', InMode)) methods.append(f) f = Method(void, 'GetControlRect', (ControlHandle, 'ctl', InMode), (Rect, 'rect', OutMode)) methods.append(f) DisposeControl_body = """ if (!PyArg_ParseTuple(_args, "")) return NULL; if ( _self->ob_itself ) { SetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */ DisposeControl(_self->ob_itself); _self->ob_itself = NULL; } Py_INCREF(Py_None); _res = Py_None; return _res; """ f = ManualGenerator("DisposeControl", DisposeControl_body) f.docstring = lambda : "() -> None" methods.append(f) # All CreateXxxXxxControl() functions return a new object in an output # parameter; these should however be managed by us (we're creating them # after all), so set the type to ControlRef. for f in functions: if f.name.startswith("Create"): v = f.argumentList[-1] if v.type == ExistingControlHandle: v.type = ControlRef
f = function(ExistingControlHandle, 'FindControlUnderMouse', (Point, 'inWhere', InMode), (WindowRef, 'inWindow', InMode), (SInt16, 'outPart', OutMode)) functions.append(f) f = function(ControlHandle, 'as_Control', (Handle, 'h', InMode)) functions.append(f) f = method(Handle, 'as_Resource', (ControlHandle, 'ctl', InMode)) methods.append(f) f = method(void, 'GetControlRect', (ControlHandle, 'ctl', InMode), (Rect, 'rect', OutMode)) methods.append(f) dispose_control_body = '\n\tif (!PyArg_ParseTuple(_args, ""))\n\t\treturn NULL;\n\tif ( _self->ob_itself ) {\n\t\tSetControlReference(_self->ob_itself, (long)0); /* Make it forget about us */\n\t\tDisposeControl(_self->ob_itself);\n\t\t_self->ob_itself = NULL;\n\t}\n\tPy_INCREF(Py_None);\n\t_res = Py_None;\n\treturn _res;\n' f = manual_generator('DisposeControl', DisposeControl_body) f.docstring = lambda : '() -> None' methods.append(f) for f in functions: if f.name.startswith('Create'): v = f.argumentList[-1] if v.type == ExistingControlHandle: v.type = ControlRef
print("Premier programme") nom = input("Donnez votre nom : ") print("Bonjour %s, comment vas-tu? " % nom)
print('Premier programme') nom = input('Donnez votre nom : ') print('Bonjour %s, comment vas-tu? ' % nom)
def read_data(filename="data/input1.data"): with open(filename) as f: return f.read() def rot(l, i): offset = len(l) // 2 pos = (i+offset) % len(l) return l[pos] if l[pos] == l[i] else 0 if __name__ == "__main__": captcha = [int(x) for x in read_data()] captcha.append(captcha[0]) print(sum([captcha[i] for i in range(1, len(captcha)) if captcha[i-1] == captcha[i]])) captcha = [int(x) for x in read_data()] total = 0 for i in range(len(captcha)): total += rot(captcha, i) print(total)
def read_data(filename='data/input1.data'): with open(filename) as f: return f.read() def rot(l, i): offset = len(l) // 2 pos = (i + offset) % len(l) return l[pos] if l[pos] == l[i] else 0 if __name__ == '__main__': captcha = [int(x) for x in read_data()] captcha.append(captcha[0]) print(sum([captcha[i] for i in range(1, len(captcha)) if captcha[i - 1] == captcha[i]])) captcha = [int(x) for x in read_data()] total = 0 for i in range(len(captcha)): total += rot(captcha, i) print(total)
""" appthwack.tests ~~~~~~~~~~~~~~~ Package which contains tests for the AppThwack client. """ __author__ = 'Andrew Hawker <andrew@appthwack.com>'
""" appthwack.tests ~~~~~~~~~~~~~~~ Package which contains tests for the AppThwack client. """ __author__ = 'Andrew Hawker <andrew@appthwack.com>'
#################### version 1 ################################################# a = list(range(10)) # print(a, id(a)) res_1 = list(a) # print(res_1, id(res_1)) for i in a: if i in (3, 5): print(">>>", i, id(i)) res_1 = list(filter(lambda x: x != i, res_1)) # print(type(res_1), id(res_1)) print(list(res_1)) #################### version 2 ################################################# b = list(range(10)) # print(b, id(b)) res_2 = list(b) # print(res_2, id(res_2)) for i in b: if i in {3, 5}: print(">>>", i, id(i)) res_2 = filter(lambda x: x != i, res_2) for w in res_2: pass # print(type(res_2), id(res_2)) res_2 = list(res_2) print(list(res_2)) #################### version 3 ################################################# c = list(range(10)) # print(c, id(c)) res_3 = list(c) # print(res_3, id(res_3)) for i in c: if i in (3, 5): print(">>>", i, id(i)) res_3 = filter(lambda x: x != i, res_3) # print(type(res_3), id(res_3)) print(list(res_3))
a = list(range(10)) res_1 = list(a) for i in a: if i in (3, 5): print('>>>', i, id(i)) res_1 = list(filter(lambda x: x != i, res_1)) print(list(res_1)) b = list(range(10)) res_2 = list(b) for i in b: if i in {3, 5}: print('>>>', i, id(i)) res_2 = filter(lambda x: x != i, res_2) for w in res_2: pass res_2 = list(res_2) print(list(res_2)) c = list(range(10)) res_3 = list(c) for i in c: if i in (3, 5): print('>>>', i, id(i)) res_3 = filter(lambda x: x != i, res_3) print(list(res_3))
"""Given an integer, write a function to determine if it is a power of two.""" class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ if n == 1: return True num = 1 while num < n: num *= 2 if n / num == 1: return True return False if __name__ == '__main__': solution = Solution() print(solution.isPowerOfTwo(4))
"""Given an integer, write a function to determine if it is a power of two.""" class Solution(object): def is_power_of_two(self, n): """ :type n: int :rtype: bool """ if n == 1: return True num = 1 while num < n: num *= 2 if n / num == 1: return True return False if __name__ == '__main__': solution = solution() print(solution.isPowerOfTwo(4))
def add_native_methods(clazz): def initPbuffer__long__long__boolean__int__int__(a0, a1, a2, a3, a4, a5): raise NotImplementedError() clazz.initPbuffer__long__long__boolean__int__int__ = initPbuffer__long__long__boolean__int__int__
def add_native_methods(clazz): def init_pbuffer__long__long__boolean__int__int__(a0, a1, a2, a3, a4, a5): raise not_implemented_error() clazz.initPbuffer__long__long__boolean__int__int__ = initPbuffer__long__long__boolean__int__int__
class CompressString(object): def compress(self, string): if string is None or not string: return string result = '' prev_char = string[0] count = 0 for char in string: if char == prev_char: count += 1 else: result += self._calc_partial_result(prev_char, count) prev_char = char count = 1 result += self._calc_partial_result(prev_char, count) return result if len(result) < len(string) else string def _calc_partial_result(self, prev_char, count): return prev_char + (str(count) if count > 1 else '')
class Compressstring(object): def compress(self, string): if string is None or not string: return string result = '' prev_char = string[0] count = 0 for char in string: if char == prev_char: count += 1 else: result += self._calc_partial_result(prev_char, count) prev_char = char count = 1 result += self._calc_partial_result(prev_char, count) return result if len(result) < len(string) else string def _calc_partial_result(self, prev_char, count): return prev_char + (str(count) if count > 1 else '')
class Solution: def findErrorNums(self, nums): """ :type nums: List[int] :rtype: List[int] """ record = [0] * (len(nums) + 1) for num in nums: record[num] += 1 dup, miss = 0, 0 for idx, val in enumerate(record): if val == 2: dup = idx if val == 0: miss = idx return [dup, miss]
class Solution: def find_error_nums(self, nums): """ :type nums: List[int] :rtype: List[int] """ record = [0] * (len(nums) + 1) for num in nums: record[num] += 1 (dup, miss) = (0, 0) for (idx, val) in enumerate(record): if val == 2: dup = idx if val == 0: miss = idx return [dup, miss]
def solution(a): answer = 0 left_min = 1000000001 left_zero = [] reverse_a = a[::-1] right_zero = [] right_min = 1000000001 for i in range(len(a)): left_min = min(a[i], left_min) if left_min == a[i]: left_zero.append(1) else: left_zero.append(0) for i in range(len(a)): right_min = min(reverse_a[i], right_min) if right_min == reverse_a[i]: right_zero.append(1) else: right_zero.append(0) right_zero = right_zero[::-1] for i in range(len(right_zero)): if left_zero[i] or right_zero[i]: answer += 1 return answer temp = [-16, 27, 65, -2, 58, -92, -71, -68, -61, -33] print(solution(temp))
def solution(a): answer = 0 left_min = 1000000001 left_zero = [] reverse_a = a[::-1] right_zero = [] right_min = 1000000001 for i in range(len(a)): left_min = min(a[i], left_min) if left_min == a[i]: left_zero.append(1) else: left_zero.append(0) for i in range(len(a)): right_min = min(reverse_a[i], right_min) if right_min == reverse_a[i]: right_zero.append(1) else: right_zero.append(0) right_zero = right_zero[::-1] for i in range(len(right_zero)): if left_zero[i] or right_zero[i]: answer += 1 return answer temp = [-16, 27, 65, -2, 58, -92, -71, -68, -61, -33] print(solution(temp))
data = ( ((-0.195090, 0.980785), (0.000000, 1.000000)), ((-0.382683, 0.923880), (-0.195090, 0.980785)), ((-0.555570, 0.831470), (-0.382683, 0.923880)), ((-0.707107, 0.707107), (-0.555570, 0.831470)), ((-0.831470, 0.555570), (-0.707107, 0.707107)), ((-0.923880, 0.382683), (-0.831470, 0.555570)), ((-0.980785, 0.195090), (-0.923880, 0.382683)), ((-0.651678, 0.500014), (0.831491, 0.344416)), ((0.831491, 0.344416), (-0.817293, 0.175582)), ((-0.882707, 0.175581), (0.768508, 0.344415)), ((0.768508, 0.344415), (-0.748323, 0.500013)), ((-0.748323, 0.500013), (0.563604, 0.636396)), ((0.563604, 0.636396), (-0.500013, 0.748323)), ((-0.500013, 0.748323), (0.255585, 0.831492)), ((0.923879, 0.382684), (0.980785, 0.195091)), ((0.831469, 0.555571), (0.923879, 0.382684)), ((0.707106, 0.707108), (0.831469, 0.555571)), ((0.555569, 0.831470), (0.707106, 0.707108)), ((0.382682, 0.923880), (0.555569, 0.831470)), ((0.195089, 0.980786), (0.382682, 0.923880)), ((0.000000, 1.000000), (0.195089, 0.980786)), ((0.255585, 0.831492), (-0.175581, 0.882707)), ((-0.175581, 0.882707), (-0.000000, 0.900000)), ((-0.399988, 0.748323), (0.636395, 0.636397)), ((0.344414, 0.831492), (-0.399988, 0.748323)), ((-0.124420, 0.882707), (0.344414, 0.831492)), ((-0.195090, -0.980785), (0.000000, -1.000000)), ((-0.382683, -0.923880), (-0.195090, -0.980785)), ((-0.555570, -0.831470), (-0.382683, -0.923880)), ((-0.707107, -0.707107), (-0.555570, -0.831470)), ((-0.831470, -0.555570), (-0.707107, -0.707107)), ((-0.923880, -0.382683), (-0.831470, -0.555570)), ((-0.980785, -0.195090), (-0.923880, -0.382683)), ((-1.000000, -0.000000), (-0.980785, -0.195090)), ((-0.651678, -0.500014), (0.831491, -0.344416)), ((0.831491, -0.344416), (-0.817293, -0.175582)), ((-0.817293, -0.175582), (0.900000, -0.000001)), ((0.800000, -0.000000), (-0.882707, -0.175581)), ((-0.882707, -0.175581), (0.768508, -0.344415)), ((0.768508, -0.344415), (-0.748323, -0.500013)), ((-0.748323, -0.500013), (0.563604, -0.636396)), ((0.563604, -0.636396), (-0.500013, -0.748323)), ((-0.500013, -0.748323), (0.255585, -0.831492)), ((0.980785, -0.195091), (1.000000, -0.000001)), ((0.923879, -0.382684), (0.980785, -0.195091)), ((0.831469, -0.555571), (0.923879, -0.382684)), ((0.707106, -0.707108), (0.831469, -0.555571)), ((0.555569, -0.831470), (0.707106, -0.707108)), ((0.382682, -0.923880), (0.555569, -0.831470)), ((0.195089, -0.980786), (0.382682, -0.923880)), ((0.000000, -1.000000), (0.195089, -0.980786)), ((0.255585, -0.831492), (-0.175581, -0.882707)), ((-0.175581, -0.882707), (-0.000000, -0.900000)), ((-0.399988, -0.748323), (0.636395, -0.636397)), ((0.344414, -0.831492), (-0.399988, -0.748323)), ((-0.124420, -0.882707), (0.344414, -0.831492)), ((-1.000000, -0.000000), (-0.980785, 0.195090)), ((-0.000000, 0.900000), (-0.124420, 0.882707)), ((0.636395, 0.636397), (-0.651678, 0.500014)), ((-0.817293, 0.175582), (0.900000, -0.000001)), ((0.800000, -0.000000), (-0.882707, 0.175581)), ((0.980785, 0.195091), (1.000000, -0.000001)), ((-0.000000, -0.900000), (-0.124420, -0.882707)), ((0.636395, -0.636397), (-0.651678, -0.500014)), )
data = (((-0.19509, 0.980785), (0.0, 1.0)), ((-0.382683, 0.92388), (-0.19509, 0.980785)), ((-0.55557, 0.83147), (-0.382683, 0.92388)), ((-0.707107, 0.707107), (-0.55557, 0.83147)), ((-0.83147, 0.55557), (-0.707107, 0.707107)), ((-0.92388, 0.382683), (-0.83147, 0.55557)), ((-0.980785, 0.19509), (-0.92388, 0.382683)), ((-0.651678, 0.500014), (0.831491, 0.344416)), ((0.831491, 0.344416), (-0.817293, 0.175582)), ((-0.882707, 0.175581), (0.768508, 0.344415)), ((0.768508, 0.344415), (-0.748323, 0.500013)), ((-0.748323, 0.500013), (0.563604, 0.636396)), ((0.563604, 0.636396), (-0.500013, 0.748323)), ((-0.500013, 0.748323), (0.255585, 0.831492)), ((0.923879, 0.382684), (0.980785, 0.195091)), ((0.831469, 0.555571), (0.923879, 0.382684)), ((0.707106, 0.707108), (0.831469, 0.555571)), ((0.555569, 0.83147), (0.707106, 0.707108)), ((0.382682, 0.92388), (0.555569, 0.83147)), ((0.195089, 0.980786), (0.382682, 0.92388)), ((0.0, 1.0), (0.195089, 0.980786)), ((0.255585, 0.831492), (-0.175581, 0.882707)), ((-0.175581, 0.882707), (-0.0, 0.9)), ((-0.399988, 0.748323), (0.636395, 0.636397)), ((0.344414, 0.831492), (-0.399988, 0.748323)), ((-0.12442, 0.882707), (0.344414, 0.831492)), ((-0.19509, -0.980785), (0.0, -1.0)), ((-0.382683, -0.92388), (-0.19509, -0.980785)), ((-0.55557, -0.83147), (-0.382683, -0.92388)), ((-0.707107, -0.707107), (-0.55557, -0.83147)), ((-0.83147, -0.55557), (-0.707107, -0.707107)), ((-0.92388, -0.382683), (-0.83147, -0.55557)), ((-0.980785, -0.19509), (-0.92388, -0.382683)), ((-1.0, -0.0), (-0.980785, -0.19509)), ((-0.651678, -0.500014), (0.831491, -0.344416)), ((0.831491, -0.344416), (-0.817293, -0.175582)), ((-0.817293, -0.175582), (0.9, -1e-06)), ((0.8, -0.0), (-0.882707, -0.175581)), ((-0.882707, -0.175581), (0.768508, -0.344415)), ((0.768508, -0.344415), (-0.748323, -0.500013)), ((-0.748323, -0.500013), (0.563604, -0.636396)), ((0.563604, -0.636396), (-0.500013, -0.748323)), ((-0.500013, -0.748323), (0.255585, -0.831492)), ((0.980785, -0.195091), (1.0, -1e-06)), ((0.923879, -0.382684), (0.980785, -0.195091)), ((0.831469, -0.555571), (0.923879, -0.382684)), ((0.707106, -0.707108), (0.831469, -0.555571)), ((0.555569, -0.83147), (0.707106, -0.707108)), ((0.382682, -0.92388), (0.555569, -0.83147)), ((0.195089, -0.980786), (0.382682, -0.92388)), ((0.0, -1.0), (0.195089, -0.980786)), ((0.255585, -0.831492), (-0.175581, -0.882707)), ((-0.175581, -0.882707), (-0.0, -0.9)), ((-0.399988, -0.748323), (0.636395, -0.636397)), ((0.344414, -0.831492), (-0.399988, -0.748323)), ((-0.12442, -0.882707), (0.344414, -0.831492)), ((-1.0, -0.0), (-0.980785, 0.19509)), ((-0.0, 0.9), (-0.12442, 0.882707)), ((0.636395, 0.636397), (-0.651678, 0.500014)), ((-0.817293, 0.175582), (0.9, -1e-06)), ((0.8, -0.0), (-0.882707, 0.175581)), ((0.980785, 0.195091), (1.0, -1e-06)), ((-0.0, -0.9), (-0.12442, -0.882707)), ((0.636395, -0.636397), (-0.651678, -0.500014)))
sum = float(input()) counter_of_coins = 0 sum = int(sum*100) counter_of_coins += sum // 200 sum = sum % 200 counter_of_coins += sum // 100 sum = sum % 100 counter_of_coins += sum // 50 sum = sum % 50 counter_of_coins += sum // 20 sum = sum % 20 counter_of_coins += sum // 10 sum = sum % 10 counter_of_coins += sum // 5 sum = sum % 5 counter_of_coins += sum // 2 sum = sum % 2 if sum == 1: counter_of_coins += 1 print(int(counter_of_coins))
sum = float(input()) counter_of_coins = 0 sum = int(sum * 100) counter_of_coins += sum // 200 sum = sum % 200 counter_of_coins += sum // 100 sum = sum % 100 counter_of_coins += sum // 50 sum = sum % 50 counter_of_coins += sum // 20 sum = sum % 20 counter_of_coins += sum // 10 sum = sum % 10 counter_of_coins += sum // 5 sum = sum % 5 counter_of_coins += sum // 2 sum = sum % 2 if sum == 1: counter_of_coins += 1 print(int(counter_of_coins))
def validate_string(s): is_alpha_numeric = False is_alpha = False is_digits = False is_lowercase = False is_uppercase = False for letter in s: if letter.isalnum(): is_alpha_numeric = True if letter.isalpha(): is_alpha = True if letter.isdigit(): is_digits = True if letter.islower(): is_lowercase = True if letter.isupper(): is_uppercase = True print(f'{is_alpha_numeric}\n{is_alpha}\n{is_digits}\n{is_lowercase}\n{is_uppercase}') if __name__ == '__main__': s = input() validate_string(s)
def validate_string(s): is_alpha_numeric = False is_alpha = False is_digits = False is_lowercase = False is_uppercase = False for letter in s: if letter.isalnum(): is_alpha_numeric = True if letter.isalpha(): is_alpha = True if letter.isdigit(): is_digits = True if letter.islower(): is_lowercase = True if letter.isupper(): is_uppercase = True print(f'{is_alpha_numeric}\n{is_alpha}\n{is_digits}\n{is_lowercase}\n{is_uppercase}') if __name__ == '__main__': s = input() validate_string(s)
""" Exceptions ========== """ class AuditEventException(BaseException): pass
""" Exceptions ========== """ class Auditeventexception(BaseException): pass
class TestScheduleJobFileData: test_job_connection = { "Name": "TestIntegrationConnection", "ConnectorTypeName": "POSTGRESQL", "Host": "localhost", "Port": 5432, "Sid": "", "DatabaseName": "test_pdi_integration", "User": "postgres", "Password": "123456" } test_file_connection = { "Name": "TestIntegrationConnectionFile", "ConnectorTypeName": "CSV", "Host": "", "Port": 0, "User": "", "Password": "" } test_data_operation = { "Name": "TEST_JOB_FILE_DATA_OPERATION", "Contacts": [ {"Email": "ahmetcagriakca@gmail.com"} ], "Integrations": [ { "Limit": 100, "ProcessCount": 1, "Integration": { "Code": "TEST_CSV_TO_DB_INTEGRATION", "SourceConnections": { "ConnectionName": "TestIntegrationConnectionFile", "File": { "Folder": "", "FileName": "test.csv", "Csv": { "HasHeader": True, "Header": "Id;Name", "Separator": ";", } }, "Columns": "Id,Name", }, "TargetConnections": { "ConnectionName": "TestIntegrationConnection", "Database": { "Schema": "test", "TableName": "test_integration_target", "Query": "" }, "Columns": "Id,Name", }, "IsTargetTruncate": True, "IsDelta": True, "Comments": "Test data_integration record", } }, { "Limit": 100, "ProcessCount": 1, "Integration": { "Code": "TEST_DB_TO_CSV_NONE_HEADER_INTEGRATION", "SourceConnections": { "ConnectionName": "TestIntegrationConnection", "Database": { "Schema": "test", "TableName": "test_integration_target", "Query": "" }, "Columns": "Id,Name", }, "TargetConnections": { "ConnectionName": "TestIntegrationConnectionFile", "File": { "Folder": "", "FileName": "test_new_none_header.csv", "Csv": { "HasHeader": False, "Header": "", "Separator": ",", } }, "Columns": "Id,Name", }, "IsTargetTruncate": True, "IsDelta": True, "Comments": "Test data_integration record", } }, { "Limit": 100, "ProcessCount": 1, "Integration": { "Code": "TEST_CSV_TO_CSV_INTEGRATION_WITHOUT_HEADER", "SourceConnections": { "ConnectionName": "TestIntegrationConnectionFile", "File": { "Folder": "", "FileName": "test_new_none_header.csv", "Csv": { "HasHeader": False, "Header": "Id,Name", "Separator": ",", } }, "Columns": "Name,Id", }, "TargetConnections": { "ConnectionName": "TestIntegrationConnectionFile", "File": { "Folder": "", "FileName": "test_new_change_column_order.csv", "Csv": { "HasHeader": True, "Header": "Name;Id", "Separator": ";", } }, "Columns": "Name,Id", }, "IsTargetTruncate": True, "IsDelta": True, "Comments": "Test data_integration record", } }, { "Limit": 100, "ProcessCount": 1, "Integration": { "Code": "TEST_CSV_TO_CSV_INTEGRATION", "SourceConnections": { "ConnectionName": "TestIntegrationConnectionFile", "File": { "Folder": "", "FileName": "test_new_none_header.csv", "Csv": { "HasHeader": False, "Header": "Id,Name", "Separator": ",", } }, "Columns": "Id", }, "TargetConnections": { "ConnectionName": "TestIntegrationConnectionFile", "File": { "Folder": "", "FileName": "test_new_only_id.csv", "Csv": { "HasHeader": True, "Header": "Id", "Separator": ";", } }, "Columns": "Id", }, "IsTargetTruncate": True, "IsDelta": True, "Comments": "Test data_integration record", } }, ] }
class Testschedulejobfiledata: test_job_connection = {'Name': 'TestIntegrationConnection', 'ConnectorTypeName': 'POSTGRESQL', 'Host': 'localhost', 'Port': 5432, 'Sid': '', 'DatabaseName': 'test_pdi_integration', 'User': 'postgres', 'Password': '123456'} test_file_connection = {'Name': 'TestIntegrationConnectionFile', 'ConnectorTypeName': 'CSV', 'Host': '', 'Port': 0, 'User': '', 'Password': ''} test_data_operation = {'Name': 'TEST_JOB_FILE_DATA_OPERATION', 'Contacts': [{'Email': 'ahmetcagriakca@gmail.com'}], 'Integrations': [{'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_CSV_TO_DB_INTEGRATION', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test.csv', 'Csv': {'HasHeader': True, 'Header': 'Id;Name', 'Separator': ';'}}, 'Columns': 'Id,Name'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnection', 'Database': {'Schema': 'test', 'TableName': 'test_integration_target', 'Query': ''}, 'Columns': 'Id,Name'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}, {'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_DB_TO_CSV_NONE_HEADER_INTEGRATION', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnection', 'Database': {'Schema': 'test', 'TableName': 'test_integration_target', 'Query': ''}, 'Columns': 'Id,Name'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_none_header.csv', 'Csv': {'HasHeader': False, 'Header': '', 'Separator': ','}}, 'Columns': 'Id,Name'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}, {'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_CSV_TO_CSV_INTEGRATION_WITHOUT_HEADER', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_none_header.csv', 'Csv': {'HasHeader': False, 'Header': 'Id,Name', 'Separator': ','}}, 'Columns': 'Name,Id'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_change_column_order.csv', 'Csv': {'HasHeader': True, 'Header': 'Name;Id', 'Separator': ';'}}, 'Columns': 'Name,Id'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}, {'Limit': 100, 'ProcessCount': 1, 'Integration': {'Code': 'TEST_CSV_TO_CSV_INTEGRATION', 'SourceConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_none_header.csv', 'Csv': {'HasHeader': False, 'Header': 'Id,Name', 'Separator': ','}}, 'Columns': 'Id'}, 'TargetConnections': {'ConnectionName': 'TestIntegrationConnectionFile', 'File': {'Folder': '', 'FileName': 'test_new_only_id.csv', 'Csv': {'HasHeader': True, 'Header': 'Id', 'Separator': ';'}}, 'Columns': 'Id'}, 'IsTargetTruncate': True, 'IsDelta': True, 'Comments': 'Test data_integration record'}}]}
# -*- coding: utf-8 -*- """ Label mapping. Created on Tue May 15 22:00:00 2018 Author: Prasun Roy | CVPRU-ISICAL (http://www.isical.ac.in/~cvpr) GitHub: https://github.com/prasunroy/air-writing """ # English numerals map2ascii_en_numbers = { 0: 48, 1: 49, 2: 50, 3: 51, 4: 52, 5: 53, 6: 54, 7: 55, 8: 56, 9: 57 } # Bengali numerals map2unicode_bn_numbers = { 0: '\u09e6', 1: '\u09e7', 2: '\u09e8', 3: '\u09e9', 4: '\u09ea', 5: '\u09eb', 6: '\u09ec', 7: '\u09ed', 8: '\u09ee', 9: '\u09ef' } # Devanagari numerals map2unicode_dv_numbers = { 0: '\u0966', 1: '\u0967', 2: '\u0968', 3: '\u0969', 4: '\u096a', 5: '\u096b', 6: '\u096c', 7: '\u096d', 8: '\u096e', 9: '\u096f' }
""" Label mapping. Created on Tue May 15 22:00:00 2018 Author: Prasun Roy | CVPRU-ISICAL (http://www.isical.ac.in/~cvpr) GitHub: https://github.com/prasunroy/air-writing """ map2ascii_en_numbers = {0: 48, 1: 49, 2: 50, 3: 51, 4: 52, 5: 53, 6: 54, 7: 55, 8: 56, 9: 57} map2unicode_bn_numbers = {0: '০', 1: '১', 2: '২', 3: '৩', 4: '৪', 5: '৫', 6: '৬', 7: '৭', 8: '৮', 9: '৯'} map2unicode_dv_numbers = {0: '०', 1: '१', 2: '२', 3: '३', 4: '४', 5: '५', 6: '६', 7: '७', 8: '८', 9: '९'}
def func(a, b=5, c=10): print('a equals {}, b equals {}, and c equals {}'.format(a, b, c)) func(3, 7) func(25, c=24) func(c=50, a=100)
def func(a, b=5, c=10): print('a equals {}, b equals {}, and c equals {}'.format(a, b, c)) func(3, 7) func(25, c=24) func(c=50, a=100)
# encoding: utf-8 # module termios # from /usr/lib/python3.5/lib-dynload/termios.cpython-35m-x86_64-linux-gnu.so # by generator 1.145 """ This module provides an interface to the Posix calls for tty I/O control. For a complete description of these calls, see the Posix or Unix manual pages. It is only available for those Unix versions that support Posix termios style tty I/O control. All functions in this module take a file descriptor fd as their first argument. This can be an integer file descriptor, such as returned by sys.stdin.fileno(), or a file object, such as sys.stdin itself. """ # no imports # Variables with simple values B0 = 0 B1000000 = 4104 B110 = 3 B115200 = 4098 B1152000 = 4105 B1200 = 9 B134 = 4 B150 = 5 B1500000 = 4106 B1800 = 10 B19200 = 14 B200 = 6 B2000000 = 4107 B230400 = 4099 B2400 = 11 B2500000 = 4108 B300 = 7 B3000000 = 4109 B3500000 = 4110 B38400 = 15 B4000000 = 4111 B460800 = 4100 B4800 = 12 B50 = 1 B500000 = 4101 B57600 = 4097 B576000 = 4102 B600 = 8 B75 = 2 B921600 = 4103 B9600 = 13 BRKINT = 2 BS0 = 0 BS1 = 8192 BSDLY = 8192 CBAUD = 4111 CBAUDEX = 4096 CDSUSP = 25 CEOF = 4 CEOL = 0 CEOT = 4 CERASE = 127 CFLUSH = 15 CIBAUD = 269418496 CINTR = 3 CKILL = 21 CLNEXT = 22 CLOCAL = 2048 CQUIT = 28 CR0 = 0 CR1 = 512 CR2 = 1024 CR3 = 1536 CRDLY = 1536 CREAD = 128 CRPRNT = 18 CRTSCTS = 2147483648 CS5 = 0 CS6 = 16 CS7 = 32 CS8 = 48 CSIZE = 48 CSTART = 17 CSTOP = 19 CSTOPB = 64 CSUSP = 26 CWERASE = 23 ECHO = 8 ECHOCTL = 512 ECHOE = 16 ECHOK = 32 ECHOKE = 2048 ECHONL = 64 ECHOPRT = 1024 EXTA = 14 EXTB = 15 FF0 = 0 FF1 = 32768 FFDLY = 32768 FIOASYNC = 21586 FIOCLEX = 21585 FIONBIO = 21537 FIONCLEX = 21584 FIONREAD = 21531 FLUSHO = 4096 HUPCL = 1024 ICANON = 2 ICRNL = 256 IEXTEN = 32768 IGNBRK = 1 IGNCR = 128 IGNPAR = 4 IMAXBEL = 8192 INLCR = 64 INPCK = 16 IOCSIZE_MASK = 1073676288 IOCSIZE_SHIFT = 16 ISIG = 1 ISTRIP = 32 IUCLC = 512 IXANY = 2048 IXOFF = 4096 IXON = 1024 NCC = 8 NCCS = 32 NL0 = 0 NL1 = 256 NLDLY = 256 NOFLSH = 128 N_MOUSE = 2 N_PPP = 3 N_SLIP = 1 N_STRIP = 4 N_TTY = 0 OCRNL = 8 OFDEL = 128 OFILL = 64 OLCUC = 2 ONLCR = 4 ONLRET = 32 ONOCR = 16 OPOST = 1 PARENB = 256 PARMRK = 8 PARODD = 512 PENDIN = 16384 TAB0 = 0 TAB1 = 2048 TAB2 = 4096 TAB3 = 6144 TABDLY = 6144 TCFLSH = 21515 TCGETA = 21509 TCGETS = 21505 TCIFLUSH = 0 TCIOFF = 2 TCIOFLUSH = 2 TCION = 3 TCOFLUSH = 1 TCOOFF = 0 TCOON = 1 TCSADRAIN = 1 TCSAFLUSH = 2 TCSANOW = 0 TCSBRK = 21513 TCSBRKP = 21541 TCSETA = 21510 TCSETAF = 21512 TCSETAW = 21511 TCSETS = 21506 TCSETSF = 21508 TCSETSW = 21507 TCXONC = 21514 TIOCCONS = 21533 TIOCEXCL = 21516 TIOCGETD = 21540 TIOCGICOUNT = 21597 TIOCGLCKTRMIOS = 21590 TIOCGPGRP = 21519 TIOCGSERIAL = 21534 TIOCGSOFTCAR = 21529 TIOCGWINSZ = 21523 TIOCINQ = 21531 TIOCLINUX = 21532 TIOCMBIC = 21527 TIOCMBIS = 21526 TIOCMGET = 21525 TIOCMIWAIT = 21596 TIOCMSET = 21528 TIOCM_CAR = 64 TIOCM_CD = 64 TIOCM_CTS = 32 TIOCM_DSR = 256 TIOCM_DTR = 2 TIOCM_LE = 1 TIOCM_RI = 128 TIOCM_RNG = 128 TIOCM_RTS = 4 TIOCM_SR = 16 TIOCM_ST = 8 TIOCNOTTY = 21538 TIOCNXCL = 21517 TIOCOUTQ = 21521 TIOCPKT = 21536 TIOCPKT_DATA = 0 TIOCPKT_DOSTOP = 32 TIOCPKT_FLUSHREAD = 1 TIOCPKT_FLUSHWRITE = 2 TIOCPKT_NOSTOP = 16 TIOCPKT_START = 8 TIOCPKT_STOP = 4 TIOCSCTTY = 21518 TIOCSERCONFIG = 21587 TIOCSERGETLSR = 21593 TIOCSERGETMULTI = 21594 TIOCSERGSTRUCT = 21592 TIOCSERGWILD = 21588 TIOCSERSETMULTI = 21595 TIOCSERSWILD = 21589 TIOCSER_TEMT = 1 TIOCSETD = 21539 TIOCSLCKTRMIOS = 21591 TIOCSPGRP = 21520 TIOCSSERIAL = 21535 TIOCSSOFTCAR = 21530 TIOCSTI = 21522 TIOCSWINSZ = 21524 TOSTOP = 256 VDISCARD = 13 VEOF = 4 VEOL = 11 VEOL2 = 16 VERASE = 2 VINTR = 0 VKILL = 3 VLNEXT = 15 VMIN = 6 VQUIT = 1 VREPRINT = 12 VSTART = 8 VSTOP = 9 VSUSP = 10 VSWTC = 7 VSWTCH = 7 VT0 = 0 VT1 = 16384 VTDLY = 16384 VTIME = 5 VWERASE = 14 XCASE = 4 XTABS = 6144 # functions def tcdrain(fd): # real signature unknown; restored from __doc__ """ tcdrain(fd) -> None Wait until all output written to file descriptor fd has been transmitted. """ pass def tcflow(fd, action): # real signature unknown; restored from __doc__ """ tcflow(fd, action) -> None Suspend or resume input or output on file descriptor fd. The action argument can be termios.TCOOFF to suspend output, termios.TCOON to restart output, termios.TCIOFF to suspend input, or termios.TCION to restart input. """ pass def tcflush(fd, queue): # real signature unknown; restored from __doc__ """ tcflush(fd, queue) -> None Discard queued data on file descriptor fd. The queue selector specifies which queue: termios.TCIFLUSH for the input queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for both queues. """ pass def tcgetattr(fd): # real signature unknown; restored from __doc__ """ tcgetattr(fd) -> list_of_attrs Get the tty attributes for file descriptor fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list of the tty special characters (each a string of length 1, except the items with indices VMIN and VTIME, which are integers when these fields are defined). The interpretation of the flags and the speeds as well as the indexing in the cc array must be done using the symbolic constants defined in this module. """ pass def tcsendbreak(fd, duration): # real signature unknown; restored from __doc__ """ tcsendbreak(fd, duration) -> None Send a break on file descriptor fd. A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration has a system dependent meaning. """ pass def tcsetattr(fd, when, attributes): # real signature unknown; restored from __doc__ """ tcsetattr(fd, when, attributes) -> None Set the tty attributes for file descriptor fd. The attributes to be set are taken from the attributes argument, which is a list like the one returned by tcgetattr(). The when argument determines when the attributes are changed: termios.TCSANOW to change immediately, termios.TCSADRAIN to change after transmitting all queued output, or termios.TCSAFLUSH to change after transmitting all queued output and discarding all queued input. """ pass # classes class error(Exception): # no doc def __init__(self, *args, **kwargs): # real signature unknown pass __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) # default """list of weak references to the object (if defined)""" # variables with complex values __loader__ = None # (!) real value is '' __spec__ = None # (!) real value is ''
""" This module provides an interface to the Posix calls for tty I/O control. For a complete description of these calls, see the Posix or Unix manual pages. It is only available for those Unix versions that support Posix termios style tty I/O control. All functions in this module take a file descriptor fd as their first argument. This can be an integer file descriptor, such as returned by sys.stdin.fileno(), or a file object, such as sys.stdin itself. """ b0 = 0 b1000000 = 4104 b110 = 3 b115200 = 4098 b1152000 = 4105 b1200 = 9 b134 = 4 b150 = 5 b1500000 = 4106 b1800 = 10 b19200 = 14 b200 = 6 b2000000 = 4107 b230400 = 4099 b2400 = 11 b2500000 = 4108 b300 = 7 b3000000 = 4109 b3500000 = 4110 b38400 = 15 b4000000 = 4111 b460800 = 4100 b4800 = 12 b50 = 1 b500000 = 4101 b57600 = 4097 b576000 = 4102 b600 = 8 b75 = 2 b921600 = 4103 b9600 = 13 brkint = 2 bs0 = 0 bs1 = 8192 bsdly = 8192 cbaud = 4111 cbaudex = 4096 cdsusp = 25 ceof = 4 ceol = 0 ceot = 4 cerase = 127 cflush = 15 cibaud = 269418496 cintr = 3 ckill = 21 clnext = 22 clocal = 2048 cquit = 28 cr0 = 0 cr1 = 512 cr2 = 1024 cr3 = 1536 crdly = 1536 cread = 128 crprnt = 18 crtscts = 2147483648 cs5 = 0 cs6 = 16 cs7 = 32 cs8 = 48 csize = 48 cstart = 17 cstop = 19 cstopb = 64 csusp = 26 cwerase = 23 echo = 8 echoctl = 512 echoe = 16 echok = 32 echoke = 2048 echonl = 64 echoprt = 1024 exta = 14 extb = 15 ff0 = 0 ff1 = 32768 ffdly = 32768 fioasync = 21586 fioclex = 21585 fionbio = 21537 fionclex = 21584 fionread = 21531 flusho = 4096 hupcl = 1024 icanon = 2 icrnl = 256 iexten = 32768 ignbrk = 1 igncr = 128 ignpar = 4 imaxbel = 8192 inlcr = 64 inpck = 16 iocsize_mask = 1073676288 iocsize_shift = 16 isig = 1 istrip = 32 iuclc = 512 ixany = 2048 ixoff = 4096 ixon = 1024 ncc = 8 nccs = 32 nl0 = 0 nl1 = 256 nldly = 256 noflsh = 128 n_mouse = 2 n_ppp = 3 n_slip = 1 n_strip = 4 n_tty = 0 ocrnl = 8 ofdel = 128 ofill = 64 olcuc = 2 onlcr = 4 onlret = 32 onocr = 16 opost = 1 parenb = 256 parmrk = 8 parodd = 512 pendin = 16384 tab0 = 0 tab1 = 2048 tab2 = 4096 tab3 = 6144 tabdly = 6144 tcflsh = 21515 tcgeta = 21509 tcgets = 21505 tciflush = 0 tcioff = 2 tcioflush = 2 tcion = 3 tcoflush = 1 tcooff = 0 tcoon = 1 tcsadrain = 1 tcsaflush = 2 tcsanow = 0 tcsbrk = 21513 tcsbrkp = 21541 tcseta = 21510 tcsetaf = 21512 tcsetaw = 21511 tcsets = 21506 tcsetsf = 21508 tcsetsw = 21507 tcxonc = 21514 tioccons = 21533 tiocexcl = 21516 tiocgetd = 21540 tiocgicount = 21597 tiocglcktrmios = 21590 tiocgpgrp = 21519 tiocgserial = 21534 tiocgsoftcar = 21529 tiocgwinsz = 21523 tiocinq = 21531 tioclinux = 21532 tiocmbic = 21527 tiocmbis = 21526 tiocmget = 21525 tiocmiwait = 21596 tiocmset = 21528 tiocm_car = 64 tiocm_cd = 64 tiocm_cts = 32 tiocm_dsr = 256 tiocm_dtr = 2 tiocm_le = 1 tiocm_ri = 128 tiocm_rng = 128 tiocm_rts = 4 tiocm_sr = 16 tiocm_st = 8 tiocnotty = 21538 tiocnxcl = 21517 tiocoutq = 21521 tiocpkt = 21536 tiocpkt_data = 0 tiocpkt_dostop = 32 tiocpkt_flushread = 1 tiocpkt_flushwrite = 2 tiocpkt_nostop = 16 tiocpkt_start = 8 tiocpkt_stop = 4 tiocsctty = 21518 tiocserconfig = 21587 tiocsergetlsr = 21593 tiocsergetmulti = 21594 tiocsergstruct = 21592 tiocsergwild = 21588 tiocsersetmulti = 21595 tiocserswild = 21589 tiocser_temt = 1 tiocsetd = 21539 tiocslcktrmios = 21591 tiocspgrp = 21520 tiocsserial = 21535 tiocssoftcar = 21530 tiocsti = 21522 tiocswinsz = 21524 tostop = 256 vdiscard = 13 veof = 4 veol = 11 veol2 = 16 verase = 2 vintr = 0 vkill = 3 vlnext = 15 vmin = 6 vquit = 1 vreprint = 12 vstart = 8 vstop = 9 vsusp = 10 vswtc = 7 vswtch = 7 vt0 = 0 vt1 = 16384 vtdly = 16384 vtime = 5 vwerase = 14 xcase = 4 xtabs = 6144 def tcdrain(fd): """ tcdrain(fd) -> None Wait until all output written to file descriptor fd has been transmitted. """ pass def tcflow(fd, action): """ tcflow(fd, action) -> None Suspend or resume input or output on file descriptor fd. The action argument can be termios.TCOOFF to suspend output, termios.TCOON to restart output, termios.TCIOFF to suspend input, or termios.TCION to restart input. """ pass def tcflush(fd, queue): """ tcflush(fd, queue) -> None Discard queued data on file descriptor fd. The queue selector specifies which queue: termios.TCIFLUSH for the input queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for both queues. """ pass def tcgetattr(fd): """ tcgetattr(fd) -> list_of_attrs Get the tty attributes for file descriptor fd, as follows: [iflag, oflag, cflag, lflag, ispeed, ospeed, cc] where cc is a list of the tty special characters (each a string of length 1, except the items with indices VMIN and VTIME, which are integers when these fields are defined). The interpretation of the flags and the speeds as well as the indexing in the cc array must be done using the symbolic constants defined in this module. """ pass def tcsendbreak(fd, duration): """ tcsendbreak(fd, duration) -> None Send a break on file descriptor fd. A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration has a system dependent meaning. """ pass def tcsetattr(fd, when, attributes): """ tcsetattr(fd, when, attributes) -> None Set the tty attributes for file descriptor fd. The attributes to be set are taken from the attributes argument, which is a list like the one returned by tcgetattr(). The when argument determines when the attributes are changed: termios.TCSANOW to change immediately, termios.TCSADRAIN to change after transmitting all queued output, or termios.TCSAFLUSH to change after transmitting all queued output and discarding all queued input. """ pass class Error(Exception): def __init__(self, *args, **kwargs): pass __weakref__ = property(lambda self: object(), lambda self, v: None, lambda self: None) 'list of weak references to the object (if defined)' __loader__ = None __spec__ = None
def isPrime(number): if number > 1: for i in range(2, number): if (number % i) == 0: return False else: return True else: return False inputFile = open('test.txt') lines = inputFile.readlines() inputFile.close() pyramid = [] for i in lines: print(i) for line in lines: pyramid.append(line.split()) for i in range(0,len(pyramid)): for j in range(0,len(pyramid[i])): pyramid[i][j] = int(pyramid[i][j]) for i in range(len(pyramid)-2, -1, -1): for j in range(0, len(pyramid[i])): if isPrime(pyramid[i][j]) == False: pyramid[i][j] += max(pyramid[i+1][j], pyramid[i+1][j+1]) print('\nThe maximum sum of the numbers is',max(pyramid)[0])
def is_prime(number): if number > 1: for i in range(2, number): if number % i == 0: return False else: return True else: return False input_file = open('test.txt') lines = inputFile.readlines() inputFile.close() pyramid = [] for i in lines: print(i) for line in lines: pyramid.append(line.split()) for i in range(0, len(pyramid)): for j in range(0, len(pyramid[i])): pyramid[i][j] = int(pyramid[i][j]) for i in range(len(pyramid) - 2, -1, -1): for j in range(0, len(pyramid[i])): if is_prime(pyramid[i][j]) == False: pyramid[i][j] += max(pyramid[i + 1][j], pyramid[i + 1][j + 1]) print('\nThe maximum sum of the numbers is', max(pyramid)[0])
def verify(output): scopes = False fail = False for line in output.split('\n'): if scopes: if line.startswith(' '): name,size = [x.strip() for x in line.split('-')] if size != '0': print("unfreed memory in scope",name,":",size) fail = True continue if line.startswith('Unfreed memory'): scopes = True if not fail: raise Exception('expected unfreed memory, but didn\'t fined it')
def verify(output): scopes = False fail = False for line in output.split('\n'): if scopes: if line.startswith(' '): (name, size) = [x.strip() for x in line.split('-')] if size != '0': print('unfreed memory in scope', name, ':', size) fail = True continue if line.startswith('Unfreed memory'): scopes = True if not fail: raise exception("expected unfreed memory, but didn't fined it")
#!/usr/bin/env python # coding: utf-8 def write_tweet_tfile(file_to_populate, text): file_handler = open(file_to_populate,"a+") file_handler.writelines(text) file_handler.close() def strip_token(myword, chars_token): return myword.strip(chars_token)
def write_tweet_tfile(file_to_populate, text): file_handler = open(file_to_populate, 'a+') file_handler.writelines(text) file_handler.close() def strip_token(myword, chars_token): return myword.strip(chars_token)
class Person: def __init__(self, name, email): self.name = name self.email = email self.all_my_emails = [] def send_email(self, to_user, message): print(f"send from {self.name} with email {self.email}") print(f"sending to {to_user} message {message}") return True def say_hello(self, message): print(f"I am {self.name}") andy = Person("andy", "akmiles@icloud.com") print(andy.name) print(andy.email) fred = Person("fred", "Fred@yahoo.com") print(fred.name) andy.send_email("harry", "blah blah blah") andy.say_hello("khkjhkj")
class Person: def __init__(self, name, email): self.name = name self.email = email self.all_my_emails = [] def send_email(self, to_user, message): print(f'send from {self.name} with email {self.email}') print(f'sending to {to_user} message {message}') return True def say_hello(self, message): print(f'I am {self.name}') andy = person('andy', 'akmiles@icloud.com') print(andy.name) print(andy.email) fred = person('fred', 'Fred@yahoo.com') print(fred.name) andy.send_email('harry', 'blah blah blah') andy.say_hello('khkjhkj')
################################### # SIMPLETICKET CONFIGURATION FILE # ################################### ############################################### # Flask Development Environment Configuration # ############################################### # This is not used when using the WSGI mod for apache. # interface ip and port number to launch the ticket system on. # setting 0.0.0.0 as the interface ip exposes the flask host on all available interfaces. INTERFACE_IP = "0.0.0.0" INTERFACE_PORT = "80" ###################################### # General SimpleTicket Configuration # ###################################### # Require login for opening the home page? # This will automatically redirect to login if not logged in already. REQUIRE_LOGIN = True # Language file that is used for the web interface. # The language file has .json as a file format and is located in the lang directory at the simpleticket install path root. LANGUAGE = "en_EN" # Site Name (Displayed in header, title, about page...) SITE_NAME = "SimpleTicket Development Instance" # Needed for sessions. Change this to logout all users. SECRET_KEY = 'm-_2hz7kJL-oOHtwKkI5ew' # create-admin-user file path CREATE_ADMIN_FILE = "_CREATE_ADMIN_ALLOWED" # Custom Properties go here. # Reference the manual for more information on custom config properties. TIMEFORMAT = "%H:%M:%S, %d.%m.%Y"
interface_ip = '0.0.0.0' interface_port = '80' require_login = True language = 'en_EN' site_name = 'SimpleTicket Development Instance' secret_key = 'm-_2hz7kJL-oOHtwKkI5ew' create_admin_file = '_CREATE_ADMIN_ALLOWED' timeformat = '%H:%M:%S, %d.%m.%Y'
N = int(input()) while True: S = [[] for k in range(N)] S_len = [0 for k in range(N)] bigger_len = 0 for k in range(N): S[k] = input().split() S_len[k] = sum([len(w) for w in S[k]]) + len(S[k]) - 1 if S_len[k] > bigger_len: bigger_len = S_len[k] for k in range(N): print(' ' * (bigger_len - S_len[k]) + ' '.join(S[k])) N = int(input()) if N == 0: break print()
n = int(input()) while True: s = [[] for k in range(N)] s_len = [0 for k in range(N)] bigger_len = 0 for k in range(N): S[k] = input().split() S_len[k] = sum([len(w) for w in S[k]]) + len(S[k]) - 1 if S_len[k] > bigger_len: bigger_len = S_len[k] for k in range(N): print(' ' * (bigger_len - S_len[k]) + ' '.join(S[k])) n = int(input()) if N == 0: break print()
def Final_Product(Check_list): Prod = 1 for ele in Check_list: Prod *= ele return Prod def Product_Matrix(Test_list): Semi_Result = Final_Product( [element for ele in Test_list for element in ele]) return Semi_Result Test_list = [[1, 4, 5], [7, 3], [4], [46, 7, 3]] print(Product_Matrix(Test_list))
def final__product(Check_list): prod = 1 for ele in Check_list: prod *= ele return Prod def product__matrix(Test_list): semi__result = final__product([element for ele in Test_list for element in ele]) return Semi_Result test_list = [[1, 4, 5], [7, 3], [4], [46, 7, 3]] print(product__matrix(Test_list))
"""Utility functions""" class BraceMessage(object): """Helper class that can be used to construct log messages with the new {}-string formatting syntax. NOTE: When using this helper class, one pays no signigicant performance penalty since the actual formatting only happens when (and if) the logged message is actually outputted to a log by a handler. Example usage: from genesis.utils.formatters import BraceMessage as __ logger.error(__("Message with {0} {name}", 2, name="placeholders")) Source: https://docs.python.org/3/howto/logging-cookbook.html#use-of-alternative-formatting-styles """ def __init__(self, fmt, *args, **kwargs): self.fmt = fmt self.args = args self.kwargs = kwargs def __str__(self): return self.fmt.format(*self.args, **self.kwargs)
"""Utility functions""" class Bracemessage(object): """Helper class that can be used to construct log messages with the new {}-string formatting syntax. NOTE: When using this helper class, one pays no signigicant performance penalty since the actual formatting only happens when (and if) the logged message is actually outputted to a log by a handler. Example usage: from genesis.utils.formatters import BraceMessage as __ logger.error(__("Message with {0} {name}", 2, name="placeholders")) Source: https://docs.python.org/3/howto/logging-cookbook.html#use-of-alternative-formatting-styles """ def __init__(self, fmt, *args, **kwargs): self.fmt = fmt self.args = args self.kwargs = kwargs def __str__(self): return self.fmt.format(*self.args, **self.kwargs)