content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
array([[ -8.71756106, -1.36180276], [ -8.58324975, -1.6198254 ], [ -8.44660752, -1.87329902], [ -8.30694854, -2.12042891], [ -8.16366778, -2.35941504], [ -8.01626074, -2.58846783], [ -7.8643173 , -2.80576865], [ -7.70752251, -3.0094502 ], [ -7.5458139 , -3.19806094], [ -7.37912158, -3.3697834 ], [ -7.20747945, -3.5226388 ], [ -7.03113284, -3.65485777], [ -6.85017635, -3.76269362], [ -6.66523309, -3.84275185], [ -6.47736681, -3.89099441], [ -6.28828709, -3.90157094], [ -6.10156897, -3.86340302], [ -5.91871331, -3.79305295], [ -5.74014533, -3.69605418], [ -5.56572991, -3.57762694], [ -5.39517681, -3.44210881], [ -5.22781241, -3.29456196], [ -5.06232383, -3.14085048], [ -4.89257735, -2.98799629], [ -4.71966422, -2.83672204], [ -4.54372346, -2.68713228], [ -4.36476778, -2.53940585], [ -4.18276114, -2.39377984], [ -3.99760462, -2.25058361], [ -3.80926438, -2.11016077], [ -3.61765447, -1.97299377], [ -3.4227503 , -1.83963827], [ -3.22466935, -1.71063201], [ -3.02363515, -1.5864963 ], [ -2.8199305 , -1.46774788], [ -2.61386232, -1.3549046 ], [ -2.40573771, -1.24848664], [ -2.19584837, -1.14901525], [ -1.98446111, -1.05701006], [ -1.77181225, -0.97298507], [ -1.55810414, -0.89744287], [ -1.34350217, -0.83086662], [ -1.12813134, -0.77370943], [ -0.91207182, -0.72638078], [ -0.69535387, -0.68923045], [ -0.47795283, -0.66253066], [ -0.25978553, -0.64645761], [ -0.04070946, -0.64107399], [ 0.17947379, -0.64631382], [ 0.40100956, -0.661971 ], [ 0.62417469, -0.68769217], [ 0.84925505, -0.72297438], [ 1.0765168 , -0.7671692 ], [ 1.30617386, -0.81949558], [ 1.53834874, -0.87904872], [ 1.77300538, -0.94474994], [ 2.01004375, -1.0156523 ], [ 2.24941382, -1.09111049], [ 2.49090963, -1.17034172], [ 2.76505053, -1.25699281], [ 3.0392737 , -1.33956764], [ 3.31357819, -1.4173004 ], [ 3.58794949, -1.48951235], [ 3.86235753, -1.55528368], [ 4.13674424, -1.61362995], [ 4.41101533, -1.66379521], [ 4.68503054, -1.70493339], [ 4.95859183, -1.73617318], [ 5.23143608, -1.75675047], [ 5.50323138, -1.76605581], [ 5.77357759, -1.7636462 ], [ 6.04201219, -1.74925505], [ 6.30802249, -1.72280316], [ 6.57106704, -1.6844134 ], [ 6.83061188, -1.63443731], [ 7.0861612 , -1.57343982], [ 7.33719115, -1.50196243], [ 7.58299863, -1.42023179], [ 7.8226528 , -1.32820378], [ 8.0545371 , -1.22514719], [ 8.27658784, -1.11037577], [ 8.48611424, -0.9831958 ], [ 8.67910996, -0.84268891], [ 8.85098102, -0.68873567], [ 8.99611087, -0.52182284], [ 9.10907438, -0.34357458], [ 9.18417432, -0.15630253], [ 9.21305752, 0.03692533], [ 9.1840698 , 0.23008171], [ 9.11910658, 0.4192829 ], [ 9.02164578, 0.60281683], [ 8.8945003 , 0.77935859], [ 8.73948257, 0.94759291], [ 8.5591441 , 1.10658568], [ 8.35621373, 1.25571578], [ 8.13392856, 1.39493299], [ 7.89600098, 1.5249387 ], [ 7.64494533, 1.64617321], [ 7.38361784, 1.75967206], [ 7.11449512, 1.86661923], [ 6.83961129, 1.96821002], [ 6.56059338, 2.06558415], [ 6.27873646, 2.15980551], [ 5.99507103, 2.25185709], [ 5.71041846, 2.34264296], [ 5.42539621, 2.43296897], [ 5.14049084, 2.52356403], [ 4.85570433, 2.61443171], [ 4.57103584, 2.70556915], [ 4.28648169, 2.79696731], [ 4.00217813, 2.88852238], [ 3.72231814, 2.97718081], [ 3.44870505, 3.06108881], [ 3.18310961, 3.13857246], [ 2.92666246, 3.20839957], [ 2.68000575, 3.26968441], [ 2.44342382, 3.32179983], [ 2.21693264, 3.36431422], [ 2.00034546, 3.39694375], [ 1.79331822, 3.41952112], [ 1.59535102, 3.4320146 ], [ 1.40578511, 3.43455695], [ 1.22408879, 3.42711031], [ 1.04965328, 3.40969902], [ 0.88172434, 3.38251449], [ 0.71940866, 3.34591804], [ 0.5619256 , 3.29981197], [ 0.40770804, 3.24544617], [ 0.25548391, 3.18343735], [ 0.10399591, 3.11449499], [ -0.04775527, 3.03962421], [ -0.20018042, 2.96056489], [ -0.35331487, 2.8785744 ], [ -0.52508461, 2.78543704], [ -0.69712913, 2.70164087], [ -0.86954503, 2.63519574], [ -1.04209219, 2.59240169], [ -1.21405958, 2.57909091], [ -1.38377538, 2.60407937], [ -1.55062259, 2.65787841], [ -1.71439338, 2.73536957], [ -1.87529031, 2.83169338], [ -2.03395581, 2.94135403], [ -2.19140835, 3.05794591], [ -2.33805266, 3.16255329], [ -2.48451156, 3.25896796], [ -2.63059232, 3.3426935 ], [ -2.77602606, 3.41054738], [ -2.92043777, 3.46019213], [ -3.06330851, 3.48968652], [ -3.20374051, 3.4957004 ], [ -3.34029351, 3.47415945], [ -3.47007084, 3.41768448], [ -3.59300929, 3.33351807], [ -3.70923634, 3.22566695], [ -3.81889624, 3.09672268], [ -3.92268025, 2.95011367], [ -4.02185397, 2.79022243], [ -4.1178521 , 2.62159416], [ -4.2161323 , 2.46452926], [ -4.31781117, 2.31796144], [ -4.42318035, 2.1831457 ], [ -4.5322453 , 2.06073257], [ -4.64501631, 1.95155647], [ -4.76140997, 1.85631353], [ -4.88126733, 1.77560052], [ -5.00435734, 1.70987926], [ -5.13042301, 1.65962035], [ -5.25938944, 1.62667518], [ -5.39072417, 1.61040595], [ -5.52382922, 1.60897593], [ -5.65849722, 1.62377451], [ -5.79444211, 1.65715234], [ -5.93107153, 1.71528106], [ -6.06746368, 1.79081424], [ -6.20317769, 1.88240466], [ -6.33788905, 1.98864946], [ -6.47136342, 2.10834012], [ -6.60346438, 2.24020588], [ -6.73412053, 2.3831744 ], [ -6.86333984, 2.53617923], [ -6.99113472, 2.69858842], [ -7.12064178, 2.87523527], [ -7.25444618, 3.04299389], [ -7.39243765, 3.20138631], [ -7.53467379, 3.34977808], [ -7.68110851, 3.48788772], [ -7.83182097, 3.61515988], [ -7.98682564, 3.73117341], [ -8.14612629, 3.83548086], [ -8.30966415, 3.92772849], [ -8.47726222, 4.00781042], [ -8.64863214, 4.07585135], [ -8.82344578, 4.13196495], [ -9.0013035 , 4.17638389], [ -9.18202552, 4.20814242], [ -9.36528871, 4.22605346], [ -9.55064213, 4.22773377], [ -9.73708983, 4.20936143], [ -9.92226831, 4.16594795], [-10.10086343, 4.09095817], [-10.26193798, 3.97820376], [-10.38552981, 3.82399663], [-10.47199275, 3.64300549], [-10.52918735, 3.44482848], [-10.5584774 , 3.23235077], [-10.56124879, 3.00791184], [-10.53904816, 2.77357185], [-10.49439476, 2.53143451], [-10.42938497, 2.2831314 ], [-10.34681037, 2.03021889], [-10.24958903, 1.77398657], [-10.14059192, 1.51544409], [-10.02259337, 1.25535648], [ -9.89818344, 0.99427857], [ -9.76968504, 0.73258465], [ -9.63916162, 0.47047985], [ -9.50822 , 0.20830133], [ -9.37711487, -0.05380021], [ -9.24579077, -0.31579848], [ -9.11420368, -0.5776724 ], [ -8.98238041, -0.83943435], [ -8.85033536, -1.10109084], [ -8.71756106, -1.36180276]])
array([[-8.71756106, -1.36180276], [-8.58324975, -1.6198254], [-8.44660752, -1.87329902], [-8.30694854, -2.12042891], [-8.16366778, -2.35941504], [-8.01626074, -2.58846783], [-7.8643173, -2.80576865], [-7.70752251, -3.0094502], [-7.5458139, -3.19806094], [-7.37912158, -3.3697834], [-7.20747945, -3.5226388], [-7.03113284, -3.65485777], [-6.85017635, -3.76269362], [-6.66523309, -3.84275185], [-6.47736681, -3.89099441], [-6.28828709, -3.90157094], [-6.10156897, -3.86340302], [-5.91871331, -3.79305295], [-5.74014533, -3.69605418], [-5.56572991, -3.57762694], [-5.39517681, -3.44210881], [-5.22781241, -3.29456196], [-5.06232383, -3.14085048], [-4.89257735, -2.98799629], [-4.71966422, -2.83672204], [-4.54372346, -2.68713228], [-4.36476778, -2.53940585], [-4.18276114, -2.39377984], [-3.99760462, -2.25058361], [-3.80926438, -2.11016077], [-3.61765447, -1.97299377], [-3.4227503, -1.83963827], [-3.22466935, -1.71063201], [-3.02363515, -1.5864963], [-2.8199305, -1.46774788], [-2.61386232, -1.3549046], [-2.40573771, -1.24848664], [-2.19584837, -1.14901525], [-1.98446111, -1.05701006], [-1.77181225, -0.97298507], [-1.55810414, -0.89744287], [-1.34350217, -0.83086662], [-1.12813134, -0.77370943], [-0.91207182, -0.72638078], [-0.69535387, -0.68923045], [-0.47795283, -0.66253066], [-0.25978553, -0.64645761], [-0.04070946, -0.64107399], [0.17947379, -0.64631382], [0.40100956, -0.661971], [0.62417469, -0.68769217], [0.84925505, -0.72297438], [1.0765168, -0.7671692], [1.30617386, -0.81949558], [1.53834874, -0.87904872], [1.77300538, -0.94474994], [2.01004375, -1.0156523], [2.24941382, -1.09111049], [2.49090963, -1.17034172], [2.76505053, -1.25699281], [3.0392737, -1.33956764], [3.31357819, -1.4173004], [3.58794949, -1.48951235], [3.86235753, -1.55528368], [4.13674424, -1.61362995], [4.41101533, -1.66379521], [4.68503054, -1.70493339], [4.95859183, -1.73617318], [5.23143608, -1.75675047], [5.50323138, -1.76605581], [5.77357759, -1.7636462], [6.04201219, -1.74925505], [6.30802249, -1.72280316], [6.57106704, -1.6844134], [6.83061188, -1.63443731], [7.0861612, -1.57343982], [7.33719115, -1.50196243], [7.58299863, -1.42023179], [7.8226528, -1.32820378], [8.0545371, -1.22514719], [8.27658784, -1.11037577], [8.48611424, -0.9831958], [8.67910996, -0.84268891], [8.85098102, -0.68873567], [8.99611087, -0.52182284], [9.10907438, -0.34357458], [9.18417432, -0.15630253], [9.21305752, 0.03692533], [9.1840698, 0.23008171], [9.11910658, 0.4192829], [9.02164578, 0.60281683], [8.8945003, 0.77935859], [8.73948257, 0.94759291], [8.5591441, 1.10658568], [8.35621373, 1.25571578], [8.13392856, 1.39493299], [7.89600098, 1.5249387], [7.64494533, 1.64617321], [7.38361784, 1.75967206], [7.11449512, 1.86661923], [6.83961129, 1.96821002], [6.56059338, 2.06558415], [6.27873646, 2.15980551], [5.99507103, 2.25185709], [5.71041846, 2.34264296], [5.42539621, 2.43296897], [5.14049084, 2.52356403], [4.85570433, 2.61443171], [4.57103584, 2.70556915], [4.28648169, 2.79696731], [4.00217813, 2.88852238], [3.72231814, 2.97718081], [3.44870505, 3.06108881], [3.18310961, 3.13857246], [2.92666246, 3.20839957], [2.68000575, 3.26968441], [2.44342382, 3.32179983], [2.21693264, 3.36431422], [2.00034546, 3.39694375], [1.79331822, 3.41952112], [1.59535102, 3.4320146], [1.40578511, 3.43455695], [1.22408879, 3.42711031], [1.04965328, 3.40969902], [0.88172434, 3.38251449], [0.71940866, 3.34591804], [0.5619256, 3.29981197], [0.40770804, 3.24544617], [0.25548391, 3.18343735], [0.10399591, 3.11449499], [-0.04775527, 3.03962421], [-0.20018042, 2.96056489], [-0.35331487, 2.8785744], [-0.52508461, 2.78543704], [-0.69712913, 2.70164087], [-0.86954503, 2.63519574], [-1.04209219, 2.59240169], [-1.21405958, 2.57909091], [-1.38377538, 2.60407937], [-1.55062259, 2.65787841], [-1.71439338, 2.73536957], [-1.87529031, 2.83169338], [-2.03395581, 2.94135403], [-2.19140835, 3.05794591], [-2.33805266, 3.16255329], [-2.48451156, 3.25896796], [-2.63059232, 3.3426935], [-2.77602606, 3.41054738], [-2.92043777, 3.46019213], [-3.06330851, 3.48968652], [-3.20374051, 3.4957004], [-3.34029351, 3.47415945], [-3.47007084, 3.41768448], [-3.59300929, 3.33351807], [-3.70923634, 3.22566695], [-3.81889624, 3.09672268], [-3.92268025, 2.95011367], [-4.02185397, 2.79022243], [-4.1178521, 2.62159416], [-4.2161323, 2.46452926], [-4.31781117, 2.31796144], [-4.42318035, 2.1831457], [-4.5322453, 2.06073257], [-4.64501631, 1.95155647], [-4.76140997, 1.85631353], [-4.88126733, 1.77560052], [-5.00435734, 1.70987926], [-5.13042301, 1.65962035], [-5.25938944, 1.62667518], [-5.39072417, 1.61040595], [-5.52382922, 1.60897593], [-5.65849722, 1.62377451], [-5.79444211, 1.65715234], [-5.93107153, 1.71528106], [-6.06746368, 1.79081424], [-6.20317769, 1.88240466], [-6.33788905, 1.98864946], [-6.47136342, 2.10834012], [-6.60346438, 2.24020588], [-6.73412053, 2.3831744], [-6.86333984, 2.53617923], [-6.99113472, 2.69858842], [-7.12064178, 2.87523527], [-7.25444618, 3.04299389], [-7.39243765, 3.20138631], [-7.53467379, 3.34977808], [-7.68110851, 3.48788772], [-7.83182097, 3.61515988], [-7.98682564, 3.73117341], [-8.14612629, 3.83548086], [-8.30966415, 3.92772849], [-8.47726222, 4.00781042], [-8.64863214, 4.07585135], [-8.82344578, 4.13196495], [-9.0013035, 4.17638389], [-9.18202552, 4.20814242], [-9.36528871, 4.22605346], [-9.55064213, 4.22773377], [-9.73708983, 4.20936143], [-9.92226831, 4.16594795], [-10.10086343, 4.09095817], [-10.26193798, 3.97820376], [-10.38552981, 3.82399663], [-10.47199275, 3.64300549], [-10.52918735, 3.44482848], [-10.5584774, 3.23235077], [-10.56124879, 3.00791184], [-10.53904816, 2.77357185], [-10.49439476, 2.53143451], [-10.42938497, 2.2831314], [-10.34681037, 2.03021889], [-10.24958903, 1.77398657], [-10.14059192, 1.51544409], [-10.02259337, 1.25535648], [-9.89818344, 0.99427857], [-9.76968504, 0.73258465], [-9.63916162, 0.47047985], [-9.50822, 0.20830133], [-9.37711487, -0.05380021], [-9.24579077, -0.31579848], [-9.11420368, -0.5776724], [-8.98238041, -0.83943435], [-8.85033536, -1.10109084], [-8.71756106, -1.36180276]])
class Solution: """ @param numbersbers : Give an array numbersbers of n integer @return : Find all unique triplets in the array which gives the sum of zero. """ def threeSum(self, numbers): if not numbers or len(numbers) < 3: return set() numbers.sort() triplets = [] seen = set() for idx, val in enumerate(numbers): lo, hi = idx+1, len(numbers)-1 while lo < hi: sol = (val, numbers[lo], numbers[hi]) sums = sum(sol) if sums == 0 and sol not in seen: triplets.append(sol) seen.add(sol) elif sums < 0: lo += 1 else: hi -= 1 return triplets
class Solution: """ @param numbersbers : Give an array numbersbers of n integer @return : Find all unique triplets in the array which gives the sum of zero. """ def three_sum(self, numbers): if not numbers or len(numbers) < 3: return set() numbers.sort() triplets = [] seen = set() for (idx, val) in enumerate(numbers): (lo, hi) = (idx + 1, len(numbers) - 1) while lo < hi: sol = (val, numbers[lo], numbers[hi]) sums = sum(sol) if sums == 0 and sol not in seen: triplets.append(sol) seen.add(sol) elif sums < 0: lo += 1 else: hi -= 1 return triplets
"""Module containing scheduling algorithms. Each scheduling algorithm receives a specific set of inputs. They output partial mappings when requested using the query method. Implemented scheduling methods: OpenMPStatic, LPT. Methods with interfaces but no implementation: OpenMPDynamic, OpenMPGuided, RecursiveBipartition. """ class Scheduler: """ Basic scheduler class. Attributes ---------- name : string Algorithm's name num_resources : int Number of identical resources """ def __init__(self, num_resources, name='scheduler'): self.name = name self.num_resources = num_resources def __repr__(self): return self.name def query(self, resource_id): """ Provides the next tasks to a given resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- empty list """ return [] class OpenMPStatic(Scheduler): """ Static scheduler based on the algorithm used for OpenMP. Notes ----- This scheduler requires an additional parameters defining the chunk size. Its initialization method pre-computes the schedule. """ def __init__(self, tasks, num_resources, chunk_size=0): Scheduler.__init__(self, num_resources, name='Static') self.chunk_size = chunk_size # Pre-computes the schedule schedule = [list() for i in range(num_resources)] num_tasks = len(tasks) # Two styles # if chunk size == 0, does a compact mapping if chunk_size == 0: # Size of partitions partition_size = num_tasks // num_resources # Number of resources that will have +1 tasks leftover = num_tasks % num_resources # Starting task identifier task = 0 # Iterates over the resources mapping groups of tasks to them for resource in range(num_resources): # Sets the actual size of the group of tasks to map # to this resource based on the existence of any leftover if leftover > 0: group_size = partition_size + 1 leftover -= 1 else: # No more resources with +1 tasks group_size = partition_size for i in range(group_size): schedule[resource].append(task) task += 1 # next task to map else: # does a round-robin mapping by chunks resource = 0 chunk_counter = 0 for task in range(num_tasks): schedule[resource].append(task) chunk_counter += 1 # if the chunk is full, starts a new one in the next resource if chunk_counter == chunk_size: chunk_counter = 0 resource = (resource + 1) % num_resources # Stores the pre-computed schedule self.schedule = schedule def query(self, resource_id): """ Provides a list of tasks to a resource once. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int Pre-computed list of task identifiers, or an empty list """ tasks = self.schedule[resource_id] if tasks: # if they have not been scheduled before # empties the list self.schedule[resource_id] = [] return tasks class LPT(Scheduler): """ Largest Processing Time first scheduler. Notes ----- Its initialization creates an internal list of tasks ordered by load. """ def __init__(self, tasks, num_resources): Scheduler.__init__(self, num_resources, name='LPT') num_tasks = len(tasks) # Orders tasks by non-increasing load tasks_by_priority = [(tasks[i], i) for i in range(num_tasks)] tasks_by_priority.sort(reverse=True) self.tasks = tasks_by_priority def query(self, resource_id): """ Provides a list of one task to a resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int List with one task identifier """ if self.tasks: load, task_id = self.tasks.pop(0) return [task_id] else: # nothing to return return [] class OpenMPDynamic(Scheduler): """ Dynamic scheduler based on the algorithm used for OpenMP. Notes ----- This scheduler requires an additional parameters defining the chunk size. """ def __init__(self, tasks, num_resources, chunk_size=1): Scheduler.__init__(self, num_resources, name='Dynamic') self.chunk_size = chunk_size # TODO def query(self, resource_id): """ Provides a list of tasks to a resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int List of task identifiers based on the chunk size, or an empty list """ # TODO class OpenMPGuided(Scheduler): """ Guided scheduler based on the algorithm used for OpenMP. Notes ----- This scheduler requires an additional parameters defining the chunk size. The chunk size gives the minimum size of the list of tasks to return. The size of the list to return is based on the number of remaining tasks to schedule divided by the number of resources in the system. """ def __init__(self, tasks, num_resources, chunk_size=1): Scheduler.__init__(self, num_resources, name='Guided') self.chunk_size = chunk_size # TODO def query(self, resource_id): """ Provides a list of tasks to a resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int List of task identifiers based on the chunk size, or an empty list """ # TODO class RecursiveBipartition(Scheduler): """ Recursive bipartition scheduler for use when the number of resources is a power of two. Notes ----- Its initialization method pre-computes the schedule. The bipartition should split a sequence of tasks in the place where the load is the most balanced between the two parts. A variation of the algorithm that works with numbers that are not power of two would just have to define different proportions when partitioning For instance, for 5 resources, the algorithm would first split the load at the 2/5-3/5 point and follow recursively from there. """ def __init__(self, tasks, num_resources): Scheduler.__init__(self, num_resources, name='RB') # TODO def query(self, resource_id): """ Provides a list of tasks to a resource once. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int Pre-computed list of task identifiers, or an empty list """ tasks = self.schedule[resource_id] if tasks: # if they have not been scheduled before # empties the list self.schedule[resource_id] = [] return tasks
"""Module containing scheduling algorithms. Each scheduling algorithm receives a specific set of inputs. They output partial mappings when requested using the query method. Implemented scheduling methods: OpenMPStatic, LPT. Methods with interfaces but no implementation: OpenMPDynamic, OpenMPGuided, RecursiveBipartition. """ class Scheduler: """ Basic scheduler class. Attributes ---------- name : string Algorithm's name num_resources : int Number of identical resources """ def __init__(self, num_resources, name='scheduler'): self.name = name self.num_resources = num_resources def __repr__(self): return self.name def query(self, resource_id): """ Provides the next tasks to a given resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- empty list """ return [] class Openmpstatic(Scheduler): """ Static scheduler based on the algorithm used for OpenMP. Notes ----- This scheduler requires an additional parameters defining the chunk size. Its initialization method pre-computes the schedule. """ def __init__(self, tasks, num_resources, chunk_size=0): Scheduler.__init__(self, num_resources, name='Static') self.chunk_size = chunk_size schedule = [list() for i in range(num_resources)] num_tasks = len(tasks) if chunk_size == 0: partition_size = num_tasks // num_resources leftover = num_tasks % num_resources task = 0 for resource in range(num_resources): if leftover > 0: group_size = partition_size + 1 leftover -= 1 else: group_size = partition_size for i in range(group_size): schedule[resource].append(task) task += 1 else: resource = 0 chunk_counter = 0 for task in range(num_tasks): schedule[resource].append(task) chunk_counter += 1 if chunk_counter == chunk_size: chunk_counter = 0 resource = (resource + 1) % num_resources self.schedule = schedule def query(self, resource_id): """ Provides a list of tasks to a resource once. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int Pre-computed list of task identifiers, or an empty list """ tasks = self.schedule[resource_id] if tasks: self.schedule[resource_id] = [] return tasks class Lpt(Scheduler): """ Largest Processing Time first scheduler. Notes ----- Its initialization creates an internal list of tasks ordered by load. """ def __init__(self, tasks, num_resources): Scheduler.__init__(self, num_resources, name='LPT') num_tasks = len(tasks) tasks_by_priority = [(tasks[i], i) for i in range(num_tasks)] tasks_by_priority.sort(reverse=True) self.tasks = tasks_by_priority def query(self, resource_id): """ Provides a list of one task to a resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int List with one task identifier """ if self.tasks: (load, task_id) = self.tasks.pop(0) return [task_id] else: return [] class Openmpdynamic(Scheduler): """ Dynamic scheduler based on the algorithm used for OpenMP. Notes ----- This scheduler requires an additional parameters defining the chunk size. """ def __init__(self, tasks, num_resources, chunk_size=1): Scheduler.__init__(self, num_resources, name='Dynamic') self.chunk_size = chunk_size def query(self, resource_id): """ Provides a list of tasks to a resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int List of task identifiers based on the chunk size, or an empty list """ class Openmpguided(Scheduler): """ Guided scheduler based on the algorithm used for OpenMP. Notes ----- This scheduler requires an additional parameters defining the chunk size. The chunk size gives the minimum size of the list of tasks to return. The size of the list to return is based on the number of remaining tasks to schedule divided by the number of resources in the system. """ def __init__(self, tasks, num_resources, chunk_size=1): Scheduler.__init__(self, num_resources, name='Guided') self.chunk_size = chunk_size def query(self, resource_id): """ Provides a list of tasks to a resource. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int List of task identifiers based on the chunk size, or an empty list """ class Recursivebipartition(Scheduler): """ Recursive bipartition scheduler for use when the number of resources is a power of two. Notes ----- Its initialization method pre-computes the schedule. The bipartition should split a sequence of tasks in the place where the load is the most balanced between the two parts. A variation of the algorithm that works with numbers that are not power of two would just have to define different proportions when partitioning For instance, for 5 resources, the algorithm would first split the load at the 2/5-3/5 point and follow recursively from there. """ def __init__(self, tasks, num_resources): Scheduler.__init__(self, num_resources, name='RB') def query(self, resource_id): """ Provides a list of tasks to a resource once. Parameters ---------- resource_id : int Identifier of the resource Returns ------- list of int Pre-computed list of task identifiers, or an empty list """ tasks = self.schedule[resource_id] if tasks: self.schedule[resource_id] = [] return tasks
NAME = 'comic.py' ORIGINAL_AUTHORS = [ 'Miguel Boekhold' ] ABOUT = ''' Returns a random comic from xkcd ''' COMMANDS = ''' >>> .comic returns a url of a random comic ''' WEBSITE = ''
name = 'comic.py' original_authors = ['Miguel Boekhold'] about = '\nReturns a random comic from xkcd\n' commands = '\n>>> .comic\nreturns a url of a random comic\n' website = ''
def printMyName(myName): print('My name is' + myName) print('Who are you ?') myName = input() printMyName(myName)
def print_my_name(myName): print('My name is' + myName) print('Who are you ?') my_name = input() print_my_name(myName)
def get_version_from_win32_pe(file): # http://windowssdk.msdn.microsoft.com/en-us/library/ms646997.aspx sig = struct.pack("32s", u"VS_VERSION_INFO".encode("utf-16-le")) # This pulls the whole file into memory, so not very feasible for # large binaries. try: filedata = open(file).read() except IOError: return "Unknown" offset = filedata.find(sig) if offset == -1: return "Unknown" filedata = filedata[offset + 32 : offset + 32 + (13*4)] version_struct = struct.unpack("13I", filedata) ver_ms, ver_ls = version_struct[4], version_struct[5] return "%d.%d.%d.%d" % (ver_ls & 0x0000ffff, (ver_ms & 0xffff0000) >> 16, ver_ms & 0x0000ffff, (ver_ls & 0xffff0000) >> 16)
def get_version_from_win32_pe(file): sig = struct.pack('32s', u'VS_VERSION_INFO'.encode('utf-16-le')) try: filedata = open(file).read() except IOError: return 'Unknown' offset = filedata.find(sig) if offset == -1: return 'Unknown' filedata = filedata[offset + 32:offset + 32 + 13 * 4] version_struct = struct.unpack('13I', filedata) (ver_ms, ver_ls) = (version_struct[4], version_struct[5]) return '%d.%d.%d.%d' % (ver_ls & 65535, (ver_ms & 4294901760) >> 16, ver_ms & 65535, (ver_ls & 4294901760) >> 16)
class NodeConfig: def __init__(self, node_name: str, ws_url: str) -> None: self.node_name = node_name self.ws_url = ws_url
class Nodeconfig: def __init__(self, node_name: str, ws_url: str) -> None: self.node_name = node_name self.ws_url = ws_url
#always put a repr in place to explicitly differentiate str from repr class Car: def __init__(self, color, mileage): self.color = color self.mileage = mileage def __repr__(self): return '{self.__class__.__name__}({self.color}, {self.mileage})'.format(self=self) def __str__(self): return 'a {self.color} car'.format(self=self)
class Car: def __init__(self, color, mileage): self.color = color self.mileage = mileage def __repr__(self): return '{self.__class__.__name__}({self.color}, {self.mileage})'.format(self=self) def __str__(self): return 'a {self.color} car'.format(self=self)
BROKER_URL = "mongodb://arbor/celery" CELERY_RESULT_BACKEND = "mongodb" CELERY_MONGODB_BACKEND_SETTINGS = { "host": "arbor", "database": "celery" }
broker_url = 'mongodb://arbor/celery' celery_result_backend = 'mongodb' celery_mongodb_backend_settings = {'host': 'arbor', 'database': 'celery'}
# -*- coding: utf-8 -*- """ Created on Sat Mar 13 21:31:02 2021 @author: eliphat """ class BaseConstraint: def cause_vars(self): raise NotImplementedError() def effect_vars(self): raise NotImplementedError() def fix(self, ts): raise NotImplementedError() def is_resolved(self): # is_resolved will be called after fix raise NotImplementedError()
""" Created on Sat Mar 13 21:31:02 2021 @author: eliphat """ class Baseconstraint: def cause_vars(self): raise not_implemented_error() def effect_vars(self): raise not_implemented_error() def fix(self, ts): raise not_implemented_error() def is_resolved(self): raise not_implemented_error()
def fun(): a=89 str="adar" return[a,str]; print(fun())
def fun(): a = 89 str = 'adar' return [a, str] print(fun())
"""The version number is based on semantic versioning. References - https://semver.org/ - https://www.python.org/dev/peps/pep-0440/ This file is autogenerated, do not modify by hand. """ __version__ = "0.0.0" COMMIT = "ed3301fdf82f5608a53a19a4aa0961c14c323421" MAJOR = 0 MINOR = 0 PATCH = 0
"""The version number is based on semantic versioning. References - https://semver.org/ - https://www.python.org/dev/peps/pep-0440/ This file is autogenerated, do not modify by hand. """ __version__ = '0.0.0' commit = 'ed3301fdf82f5608a53a19a4aa0961c14c323421' major = 0 minor = 0 patch = 0
# input N, X, Y = map(int, input().split()) As = [*map(int, input().split())] Bs = [*map(int, input().split())] # compute # output print(sum(i not in As and i not in Bs for i in range(1, N+1)))
(n, x, y) = map(int, input().split()) as = [*map(int, input().split())] bs = [*map(int, input().split())] print(sum((i not in As and i not in Bs for i in range(1, N + 1))))
names = ["duanzijie","zhaokeer","lijiaxi","zhuzi","wangwenbo","gongyijun"] print(names) print(names[0]) print(names[1]) print(names[2]) print(names[3]) print(names[4]) print(names[5]) hi = "hi" + " " + name[1] print(hi)
names = ['duanzijie', 'zhaokeer', 'lijiaxi', 'zhuzi', 'wangwenbo', 'gongyijun'] print(names) print(names[0]) print(names[1]) print(names[2]) print(names[3]) print(names[4]) print(names[5]) hi = 'hi' + ' ' + name[1] print(hi)
""" User defined here are allowed to use privileged bot commands """ regulars = [ 965146, #Shree 4946380, #Mithrandir 5067311, #Andras Deak 397817, #Stephen Kennedy 6707985, #geisterfurz007 ]
""" User defined here are allowed to use privileged bot commands """ regulars = [965146, 4946380, 5067311, 397817, 6707985]
n = int(input()) s = input() c=0 for i in range(n-1): if s[i]==s[i+1]: c +=1 print(c)
n = int(input()) s = input() c = 0 for i in range(n - 1): if s[i] == s[i + 1]: c += 1 print(c)
# practice of anna class TestClass: def __init__(self, name): # __init__ is the rule first creator made so every time we have to foloow self.name = name if __name__ == '__main__': obj1 = TestClass() print(obj1) obj2 = TestClass() print(obj2)
class Testclass: def __init__(self, name): self.name = name if __name__ == '__main__': obj1 = test_class() print(obj1) obj2 = test_class() print(obj2)
class SpiderpigError(Exception): pass class ValidationError(SpiderpigError): pass class NotInitialized(SpiderpigError): pass class CyclicExecution(SpiderpigError): pass class TooManyDependencies(SpiderpigError): pass
class Spiderpigerror(Exception): pass class Validationerror(SpiderpigError): pass class Notinitialized(SpiderpigError): pass class Cyclicexecution(SpiderpigError): pass class Toomanydependencies(SpiderpigError): pass
## bisenetv2 cfg = dict( model_type='bisenetv2', num_aux_heads=4, lr_start = 5e-2, weight_decay=5e-4, warmup_iters = 1000, max_iter = 150000, im_root='./datasets/coco', train_im_anns='./datasets/coco/train.txt', val_im_anns='./datasets/coco/val.txt', scales=[0.5, 1.5], cropsize=[512, 512], ims_per_gpu=8, use_fp16=True, use_sync_bn=False, respth='./res', )
cfg = dict(model_type='bisenetv2', num_aux_heads=4, lr_start=0.05, weight_decay=0.0005, warmup_iters=1000, max_iter=150000, im_root='./datasets/coco', train_im_anns='./datasets/coco/train.txt', val_im_anns='./datasets/coco/val.txt', scales=[0.5, 1.5], cropsize=[512, 512], ims_per_gpu=8, use_fp16=True, use_sync_bn=False, respth='./res')
class PorterStemmer: def __init__(self): self.vowels = ('a', 'e', 'i', 'o', 'u') def is_consonant(self, s: str, i: int): return not self.is_vowel(s, i) def is_vowel(self, s: str, i: int): if s[i].lower() in self.vowels: return True elif s[i].lower() == 'y': if self.is_consonant(s, i-1): return True else: return False def find_m(self, s): i = 0 m = 0 while i < len(s): if self.is_vowel(s, i) and self.is_consonant(s, i+1): m += 1 i += 2 else: i += 1 return m def contains_vowel(self, s): for v in self.vowels: if v in s: return True for i in range(len(s)): if s[i] == 'y': if self.is_vowel(s, i): return True return False def step1a(self, s): if s[-4:] == 'sses': s = s[:-4] + 'ss' elif s[-3:] == "ies": s = s[:-3] + "i" elif s[-2:] == "ss": pass elif s[-1] == "s": s = s[:-1] return s def step1b(self, s): if s[-3:] == 'eed': m = self.find_m(s[:-3]) if m > 0: s = s[:-1] elif s[-2:] == 'ed': if self.contains_vowel(s[:-2]): s = s[:-2] elif s[-3:] == 'ing': if self.contains_vowel(s[:-3]): s = s[:-3] return s def step2(self, s): if s[-7:] == 'ational': m = self.find_m(s[:-7]) if m > 0: s = s[:-5]+"e" elif s[-6:] == 'tional': m = self.find_m(s[:-6]) if m > 0: s = s[:-2] elif s[-4:] == 'enci': m = self.find_m(s[:-4]) if m > 0: s = s[:-1]+"e" elif s[-4:] == 'anci': m = self.find_m(s[:-4]) if m > 0: s = s[:-1]+"e" elif s[-4:] == 'izer': m = self.find_m(s[:-4]) if m > 0: s = s[:-1] elif s[-4:] == 'abli': m = self.find_m(s[:-4]) if m > 0: s = s[:-1]+"e" elif s[-4:] == 'alli': m = self.find_m(s[:-1]) if m > 0: s = s[:-2] elif s[-5:] == 'entli': m = self.find_m(s[:-5]) if m > 0: s = s[:-2] elif s[-3:] == 'eli': m = self.find_m(s[:-3]) if m > 0: s = s[:-2] elif s[-5:] == 'ousli': m = self.find_m(s[:-5]) if m > 0: s = s[:-2] elif s[-7:] == 'ization': m = self.find_m(s[:-7]) if m > 0: s = s[:-5]+"e" elif s[-5:] == 'ation': m = self.find_m(s[:-5]) if m > 0: s = s[:-3]+"e" elif s[-4:] == 'ator': m = self.find_m(s[:-4]) if m > 0: s = s[:-2]+"e" elif s[-5:] == 'alism': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-7:] == 'iveness': m = self.find_m(s[:-7]) if m > 0: s = s[:-4] elif s[-7:] == 'fulness': m = self.find_m(s[:-7]) if m > 0: s = s[:-4] elif s[-7:] == 'ousness': m = self.find_m(s[:-7]) if m > 0: s = s[:-4] elif s[-5:] == 'aliti': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-5:] == 'iviti': m = self.find_m(s[:-5]) if m > 0: s = s[:-3]+"e" elif s[-6:] == 'bliti': m = self.find_m(s[:-6]) if m > 0: s = s[:-3]+"e" return s def step3(self, s): if s[-5:] == 'icate': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-5:] == 'ative': m = self.find_m(s[:-5]) if m > 0: s = s[:-5] elif s[-5:] == 'alize': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-5:] == 'iciti': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-4:] == 'ical': m = self.find_m(s[:-4]) if m > 0: s = s[:-2] elif s[-3:] == 'ful': m = self.find_m(s[:-3]) if m > 0: s = s[:-3] elif s[-4:] == 'ness': m = self.find_m(s[:-4]) if m > 0: s = s[:-4] def step4(self, s): if s[-2:] == 'al': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-4:] == 'ance': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-4:] == 'ence': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-2:] == 'er': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-2:] == 'ic': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-4:] == 'able': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-4:] == 'ible': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-4:] == 'ant': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-5:] == 'ement': m = self.find_m(s[:-5]) if m > 1: s = s[:-5] elif s[-4:] == 'ment': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-3:] == 'ent': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ion': m = self.find_m(s[:-3]) if m > 1 and (s[-4]== "s" or s[-4]=="t"): s = s[:-3] elif s[-2:] == 'ou': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-3:] == 'ism': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ate': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'iti': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ous': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ive': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ize': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] def __call__(self, s: str): s = self.step1a(s) s = self.step1b(s) return s
class Porterstemmer: def __init__(self): self.vowels = ('a', 'e', 'i', 'o', 'u') def is_consonant(self, s: str, i: int): return not self.is_vowel(s, i) def is_vowel(self, s: str, i: int): if s[i].lower() in self.vowels: return True elif s[i].lower() == 'y': if self.is_consonant(s, i - 1): return True else: return False def find_m(self, s): i = 0 m = 0 while i < len(s): if self.is_vowel(s, i) and self.is_consonant(s, i + 1): m += 1 i += 2 else: i += 1 return m def contains_vowel(self, s): for v in self.vowels: if v in s: return True for i in range(len(s)): if s[i] == 'y': if self.is_vowel(s, i): return True return False def step1a(self, s): if s[-4:] == 'sses': s = s[:-4] + 'ss' elif s[-3:] == 'ies': s = s[:-3] + 'i' elif s[-2:] == 'ss': pass elif s[-1] == 's': s = s[:-1] return s def step1b(self, s): if s[-3:] == 'eed': m = self.find_m(s[:-3]) if m > 0: s = s[:-1] elif s[-2:] == 'ed': if self.contains_vowel(s[:-2]): s = s[:-2] elif s[-3:] == 'ing': if self.contains_vowel(s[:-3]): s = s[:-3] return s def step2(self, s): if s[-7:] == 'ational': m = self.find_m(s[:-7]) if m > 0: s = s[:-5] + 'e' elif s[-6:] == 'tional': m = self.find_m(s[:-6]) if m > 0: s = s[:-2] elif s[-4:] == 'enci': m = self.find_m(s[:-4]) if m > 0: s = s[:-1] + 'e' elif s[-4:] == 'anci': m = self.find_m(s[:-4]) if m > 0: s = s[:-1] + 'e' elif s[-4:] == 'izer': m = self.find_m(s[:-4]) if m > 0: s = s[:-1] elif s[-4:] == 'abli': m = self.find_m(s[:-4]) if m > 0: s = s[:-1] + 'e' elif s[-4:] == 'alli': m = self.find_m(s[:-1]) if m > 0: s = s[:-2] elif s[-5:] == 'entli': m = self.find_m(s[:-5]) if m > 0: s = s[:-2] elif s[-3:] == 'eli': m = self.find_m(s[:-3]) if m > 0: s = s[:-2] elif s[-5:] == 'ousli': m = self.find_m(s[:-5]) if m > 0: s = s[:-2] elif s[-7:] == 'ization': m = self.find_m(s[:-7]) if m > 0: s = s[:-5] + 'e' elif s[-5:] == 'ation': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] + 'e' elif s[-4:] == 'ator': m = self.find_m(s[:-4]) if m > 0: s = s[:-2] + 'e' elif s[-5:] == 'alism': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-7:] == 'iveness': m = self.find_m(s[:-7]) if m > 0: s = s[:-4] elif s[-7:] == 'fulness': m = self.find_m(s[:-7]) if m > 0: s = s[:-4] elif s[-7:] == 'ousness': m = self.find_m(s[:-7]) if m > 0: s = s[:-4] elif s[-5:] == 'aliti': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-5:] == 'iviti': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] + 'e' elif s[-6:] == 'bliti': m = self.find_m(s[:-6]) if m > 0: s = s[:-3] + 'e' return s def step3(self, s): if s[-5:] == 'icate': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-5:] == 'ative': m = self.find_m(s[:-5]) if m > 0: s = s[:-5] elif s[-5:] == 'alize': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-5:] == 'iciti': m = self.find_m(s[:-5]) if m > 0: s = s[:-3] elif s[-4:] == 'ical': m = self.find_m(s[:-4]) if m > 0: s = s[:-2] elif s[-3:] == 'ful': m = self.find_m(s[:-3]) if m > 0: s = s[:-3] elif s[-4:] == 'ness': m = self.find_m(s[:-4]) if m > 0: s = s[:-4] def step4(self, s): if s[-2:] == 'al': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-4:] == 'ance': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-4:] == 'ence': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-2:] == 'er': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-2:] == 'ic': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-4:] == 'able': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-4:] == 'ible': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-4:] == 'ant': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-5:] == 'ement': m = self.find_m(s[:-5]) if m > 1: s = s[:-5] elif s[-4:] == 'ment': m = self.find_m(s[:-4]) if m > 1: s = s[:-4] elif s[-3:] == 'ent': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ion': m = self.find_m(s[:-3]) if m > 1 and (s[-4] == 's' or s[-4] == 't'): s = s[:-3] elif s[-2:] == 'ou': m = self.find_m(s[:-2]) if m > 1: s = s[:-2] elif s[-3:] == 'ism': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ate': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'iti': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ous': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ive': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] elif s[-3:] == 'ize': m = self.find_m(s[:-3]) if m > 1: s = s[:-3] def __call__(self, s: str): s = self.step1a(s) s = self.step1b(s) return s
def bubble_sort(L): swap = False while not swap: swap = True for j in range(1, len(L)): if L[j-1] > L[j]: swap = False temp = L[j] L[j] = L[j-1] L[j-1] = temp
def bubble_sort(L): swap = False while not swap: swap = True for j in range(1, len(L)): if L[j - 1] > L[j]: swap = False temp = L[j] L[j] = L[j - 1] L[j - 1] = temp
# # PySNMP MIB module CRESCENDO-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CRESCENDO-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:12:29 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, ValueRangeConstraint, SingleValueConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ValueSizeConstraint") MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("RFC1212", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn") DisplayString, = mibBuilder.importSymbols("RFC1213", "DisplayString") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") enterprises, Unsigned32, iso, MibIdentifier, Integer32, NotificationType, Counter32, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, Bits, ObjectIdentity, IpAddress, ModuleIdentity, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "enterprises", "Unsigned32", "iso", "MibIdentifier", "Integer32", "NotificationType", "Counter32", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "Bits", "ObjectIdentity", "IpAddress", "ModuleIdentity", "Gauge32") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") crescendo = MibIdentifier((1, 3, 6, 1, 4, 1, 203)) crescendoProducts = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1)) concentrator = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1)) conc = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 1)) chassis = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 2)) module = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 3)) port = MibIdentifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 4)) concMgmtType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("snmp", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: concMgmtType.setStatus('mandatory') concIpAddr = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 2), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: concIpAddr.setStatus('mandatory') concNetMask = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 3), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: concNetMask.setStatus('mandatory') concBroadcast = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 4), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: concBroadcast.setStatus('mandatory') concTrapReceiverTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5), ) if mibBuilder.loadTexts: concTrapReceiverTable.setStatus('mandatory') concTrapReceiverEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1), ).setIndexNames((0, "CRESCENDO-MIB", "concTrapReceiverAddr")) if mibBuilder.loadTexts: concTrapReceiverEntry.setStatus('mandatory') concTrapReceiverType = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: concTrapReceiverType.setStatus('mandatory') concTrapReceiverAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 2), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: concTrapReceiverAddr.setStatus('mandatory') concTrapReceiverComm = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite") if mibBuilder.loadTexts: concTrapReceiverComm.setStatus('mandatory') concCommunityTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6), ) if mibBuilder.loadTexts: concCommunityTable.setStatus('mandatory') concCommunityEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1), ).setIndexNames((0, "CRESCENDO-MIB", "concCommunityAccess")) if mibBuilder.loadTexts: concCommunityEntry.setStatus('mandatory') concCommunityAccess = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("readOnly", 2), ("readWrite", 3), ("readWriteAll", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: concCommunityAccess.setStatus('mandatory') concCommunityString = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite") if mibBuilder.loadTexts: concCommunityString.setStatus('mandatory') concAttachType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("dualAttach", 2), ("singleAttach", 3), ("nullAttach", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: concAttachType.setStatus('mandatory') concTraffic = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 100))).setMaxAccess("readonly") if mibBuilder.loadTexts: concTraffic.setStatus('mandatory') concReset = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("reset", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: concReset.setStatus('mandatory') concBaudRate = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 10), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: concBaudRate.setStatus('mandatory') chassisType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("cxxxx", 2), ("c1000", 3), ("c1001", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisType.setStatus('mandatory') chassisBkplType = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("other", 1), ("fddi", 2), ("fddiEthernet", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisBkplType.setStatus('mandatory') chassisPs1Type = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("none", 2), ("w50", 3), ("w200", 4), ("w600", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisPs1Type.setStatus('mandatory') chassisPs1Status = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisPs1Status.setStatus('mandatory') chassisPs1TestResult = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisPs1TestResult.setStatus('mandatory') chassisPs2Type = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("none", 2), ("w50", 3), ("w200", 4), ("w600", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisPs2Type.setStatus('mandatory') chassisPs2Status = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisPs2Status.setStatus('mandatory') chassisPs2TestResult = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisPs2TestResult.setStatus('mandatory') chassisFanStatus = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisFanStatus.setStatus('mandatory') chassisFanTestResult = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 10), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisFanTestResult.setStatus('mandatory') chassisMinorAlarm = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 11), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisMinorAlarm.setStatus('mandatory') chassisMajorAlarm = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisMajorAlarm.setStatus('mandatory') chassisTempAlarm = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisTempAlarm.setStatus('mandatory') chassisNumSlots = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 14), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisNumSlots.setStatus('mandatory') chassisSlotConfig = MibScalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 15), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: chassisSlotConfig.setStatus('mandatory') moduleTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1), ) if mibBuilder.loadTexts: moduleTable.setStatus('mandatory') moduleEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1), ).setIndexNames((0, "CRESCENDO-MIB", "moduleIndex")) if mibBuilder.loadTexts: moduleEntry.setStatus('mandatory') moduleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleIndex.setStatus('mandatory') moduleType = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("empty", 2), ("c1000", 3), ("c1001", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleType.setStatus('mandatory') moduleSerialNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleSerialNumber.setStatus('mandatory') moduleHwHiVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleHwHiVersion.setStatus('mandatory') moduleHwLoVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleHwLoVersion.setStatus('mandatory') moduleFwHiVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleFwHiVersion.setStatus('mandatory') moduleFwLoVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 7), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleFwLoVersion.setStatus('mandatory') moduleSwHiVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleSwHiVersion.setStatus('mandatory') moduleSwLoVersion = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 9), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleSwLoVersion.setStatus('mandatory') moduleStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleStatus.setStatus('mandatory') moduleTestResult = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 11), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleTestResult.setStatus('mandatory') moduleReset = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("other", 1), ("reset", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: moduleReset.setStatus('mandatory') moduleName = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 13), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite") if mibBuilder.loadTexts: moduleName.setStatus('mandatory') moduleNumPorts = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 14), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: moduleNumPorts.setStatus('mandatory') modulePortStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 15), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readonly") if mibBuilder.loadTexts: modulePortStatus.setStatus('mandatory') portTable = MibTable((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1), ) if mibBuilder.loadTexts: portTable.setStatus('mandatory') portEntry = MibTableRow((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1), ).setIndexNames((0, "CRESCENDO-MIB", "portModuleIndex"), (0, "CRESCENDO-MIB", "portIndex")) if mibBuilder.loadTexts: portEntry.setStatus('mandatory') portModuleIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: portModuleIndex.setStatus('mandatory') portIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: portIndex.setStatus('mandatory') portFddiIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: portFddiIndex.setStatus('mandatory') portName = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 4), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 20))).setMaxAccess("readwrite") if mibBuilder.loadTexts: portName.setStatus('mandatory') portType = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("cddi", 2), ("fiber", 3), ("multiMedia", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: portType.setStatus('mandatory') portStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("other", 1), ("ok", 2), ("minorFault", 3), ("majorFault", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: portStatus.setStatus('mandatory') mibBuilder.exportSymbols("CRESCENDO-MIB", moduleNumPorts=moduleNumPorts, chassisMinorAlarm=chassisMinorAlarm, concTrapReceiverType=concTrapReceiverType, crescendoProducts=crescendoProducts, chassisType=chassisType, chassisPs1TestResult=chassisPs1TestResult, chassisMajorAlarm=chassisMajorAlarm, chassisSlotConfig=chassisSlotConfig, modulePortStatus=modulePortStatus, chassisPs1Status=chassisPs1Status, moduleHwHiVersion=moduleHwHiVersion, concCommunityEntry=concCommunityEntry, chassisFanTestResult=chassisFanTestResult, chassisPs2TestResult=chassisPs2TestResult, chassisFanStatus=chassisFanStatus, concIpAddr=concIpAddr, chassisPs2Status=chassisPs2Status, moduleReset=moduleReset, chassisPs2Type=chassisPs2Type, concTrapReceiverComm=concTrapReceiverComm, concNetMask=concNetMask, moduleStatus=moduleStatus, chassisPs1Type=chassisPs1Type, chassisNumSlots=chassisNumSlots, concBroadcast=concBroadcast, concTrapReceiverTable=concTrapReceiverTable, concMgmtType=concMgmtType, moduleHwLoVersion=moduleHwLoVersion, moduleSwLoVersion=moduleSwLoVersion, moduleTestResult=moduleTestResult, moduleIndex=moduleIndex, moduleType=moduleType, crescendo=crescendo, module=module, concTrapReceiverEntry=concTrapReceiverEntry, concCommunityString=concCommunityString, moduleTable=moduleTable, portType=portType, concBaudRate=concBaudRate, chassisTempAlarm=chassisTempAlarm, portEntry=portEntry, moduleFwLoVersion=moduleFwLoVersion, moduleSwHiVersion=moduleSwHiVersion, moduleSerialNumber=moduleSerialNumber, concAttachType=concAttachType, portIndex=portIndex, moduleFwHiVersion=moduleFwHiVersion, moduleName=moduleName, chassis=chassis, portName=portName, port=port, concCommunityAccess=concCommunityAccess, concentrator=concentrator, portStatus=portStatus, concTrapReceiverAddr=concTrapReceiverAddr, conc=conc, concCommunityTable=concCommunityTable, concTraffic=concTraffic, moduleEntry=moduleEntry, portTable=portTable, portFddiIndex=portFddiIndex, chassisBkplType=chassisBkplType, concReset=concReset, portModuleIndex=portModuleIndex)
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, single_value_constraint, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueSizeConstraint') (mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('RFC1212', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn') (display_string,) = mibBuilder.importSymbols('RFC1213', 'DisplayString') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (enterprises, unsigned32, iso, mib_identifier, integer32, notification_type, counter32, counter64, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks, bits, object_identity, ip_address, module_identity, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'enterprises', 'Unsigned32', 'iso', 'MibIdentifier', 'Integer32', 'NotificationType', 'Counter32', 'Counter64', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks', 'Bits', 'ObjectIdentity', 'IpAddress', 'ModuleIdentity', 'Gauge32') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') crescendo = mib_identifier((1, 3, 6, 1, 4, 1, 203)) crescendo_products = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1)) concentrator = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1)) conc = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 1)) chassis = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 2)) module = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 3)) port = mib_identifier((1, 3, 6, 1, 4, 1, 203, 1, 1, 4)) conc_mgmt_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('snmp', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: concMgmtType.setStatus('mandatory') conc_ip_addr = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 2), ip_address()).setMaxAccess('readwrite') if mibBuilder.loadTexts: concIpAddr.setStatus('mandatory') conc_net_mask = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 3), ip_address()).setMaxAccess('readwrite') if mibBuilder.loadTexts: concNetMask.setStatus('mandatory') conc_broadcast = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 4), ip_address()).setMaxAccess('readwrite') if mibBuilder.loadTexts: concBroadcast.setStatus('mandatory') conc_trap_receiver_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5)) if mibBuilder.loadTexts: concTrapReceiverTable.setStatus('mandatory') conc_trap_receiver_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'concTrapReceiverAddr')) if mibBuilder.loadTexts: concTrapReceiverEntry.setStatus('mandatory') conc_trap_receiver_type = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('invalid', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: concTrapReceiverType.setStatus('mandatory') conc_trap_receiver_addr = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 2), ip_address()).setMaxAccess('readwrite') if mibBuilder.loadTexts: concTrapReceiverAddr.setStatus('mandatory') conc_trap_receiver_comm = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 5, 1, 3), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite') if mibBuilder.loadTexts: concTrapReceiverComm.setStatus('mandatory') conc_community_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6)) if mibBuilder.loadTexts: concCommunityTable.setStatus('mandatory') conc_community_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'concCommunityAccess')) if mibBuilder.loadTexts: concCommunityEntry.setStatus('mandatory') conc_community_access = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('readOnly', 2), ('readWrite', 3), ('readWriteAll', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: concCommunityAccess.setStatus('mandatory') conc_community_string = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 6, 1, 2), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite') if mibBuilder.loadTexts: concCommunityString.setStatus('mandatory') conc_attach_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('dualAttach', 2), ('singleAttach', 3), ('nullAttach', 4)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: concAttachType.setStatus('mandatory') conc_traffic = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(0, 100))).setMaxAccess('readonly') if mibBuilder.loadTexts: concTraffic.setStatus('mandatory') conc_reset = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('reset', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: concReset.setStatus('mandatory') conc_baud_rate = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 1, 10), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: concBaudRate.setStatus('mandatory') chassis_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('cxxxx', 2), ('c1000', 3), ('c1001', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisType.setStatus('mandatory') chassis_bkpl_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('other', 1), ('fddi', 2), ('fddiEthernet', 3)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisBkplType.setStatus('mandatory') chassis_ps1_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('none', 2), ('w50', 3), ('w200', 4), ('w600', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisPs1Type.setStatus('mandatory') chassis_ps1_status = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisPs1Status.setStatus('mandatory') chassis_ps1_test_result = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 5), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisPs1TestResult.setStatus('mandatory') chassis_ps2_type = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('none', 2), ('w50', 3), ('w200', 4), ('w600', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisPs2Type.setStatus('mandatory') chassis_ps2_status = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisPs2Status.setStatus('mandatory') chassis_ps2_test_result = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 8), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisPs2TestResult.setStatus('mandatory') chassis_fan_status = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisFanStatus.setStatus('mandatory') chassis_fan_test_result = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 10), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisFanTestResult.setStatus('mandatory') chassis_minor_alarm = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 11), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisMinorAlarm.setStatus('mandatory') chassis_major_alarm = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisMajorAlarm.setStatus('mandatory') chassis_temp_alarm = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisTempAlarm.setStatus('mandatory') chassis_num_slots = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 14), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisNumSlots.setStatus('mandatory') chassis_slot_config = mib_scalar((1, 3, 6, 1, 4, 1, 203, 1, 1, 2, 15), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: chassisSlotConfig.setStatus('mandatory') module_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1)) if mibBuilder.loadTexts: moduleTable.setStatus('mandatory') module_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'moduleIndex')) if mibBuilder.loadTexts: moduleEntry.setStatus('mandatory') module_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleIndex.setStatus('mandatory') module_type = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('empty', 2), ('c1000', 3), ('c1001', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleType.setStatus('mandatory') module_serial_number = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 3), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleSerialNumber.setStatus('mandatory') module_hw_hi_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 4), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleHwHiVersion.setStatus('mandatory') module_hw_lo_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 5), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleHwLoVersion.setStatus('mandatory') module_fw_hi_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 6), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleFwHiVersion.setStatus('mandatory') module_fw_lo_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 7), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleFwLoVersion.setStatus('mandatory') module_sw_hi_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 8), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleSwHiVersion.setStatus('mandatory') module_sw_lo_version = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 9), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleSwLoVersion.setStatus('mandatory') module_status = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleStatus.setStatus('mandatory') module_test_result = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 11), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleTestResult.setStatus('mandatory') module_reset = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('other', 1), ('reset', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: moduleReset.setStatus('mandatory') module_name = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 13), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite') if mibBuilder.loadTexts: moduleName.setStatus('mandatory') module_num_ports = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 14), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: moduleNumPorts.setStatus('mandatory') module_port_status = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 3, 1, 1, 15), octet_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readonly') if mibBuilder.loadTexts: modulePortStatus.setStatus('mandatory') port_table = mib_table((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1)) if mibBuilder.loadTexts: portTable.setStatus('mandatory') port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1)).setIndexNames((0, 'CRESCENDO-MIB', 'portModuleIndex'), (0, 'CRESCENDO-MIB', 'portIndex')) if mibBuilder.loadTexts: portEntry.setStatus('mandatory') port_module_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 1), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: portModuleIndex.setStatus('mandatory') port_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: portIndex.setStatus('mandatory') port_fddi_index = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 3), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: portFddiIndex.setStatus('mandatory') port_name = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 4), display_string().subtype(subtypeSpec=value_size_constraint(0, 20))).setMaxAccess('readwrite') if mibBuilder.loadTexts: portName.setStatus('mandatory') port_type = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('cddi', 2), ('fiber', 3), ('multiMedia', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: portType.setStatus('mandatory') port_status = mib_table_column((1, 3, 6, 1, 4, 1, 203, 1, 1, 4, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('other', 1), ('ok', 2), ('minorFault', 3), ('majorFault', 4)))).setMaxAccess('readonly') if mibBuilder.loadTexts: portStatus.setStatus('mandatory') mibBuilder.exportSymbols('CRESCENDO-MIB', moduleNumPorts=moduleNumPorts, chassisMinorAlarm=chassisMinorAlarm, concTrapReceiverType=concTrapReceiverType, crescendoProducts=crescendoProducts, chassisType=chassisType, chassisPs1TestResult=chassisPs1TestResult, chassisMajorAlarm=chassisMajorAlarm, chassisSlotConfig=chassisSlotConfig, modulePortStatus=modulePortStatus, chassisPs1Status=chassisPs1Status, moduleHwHiVersion=moduleHwHiVersion, concCommunityEntry=concCommunityEntry, chassisFanTestResult=chassisFanTestResult, chassisPs2TestResult=chassisPs2TestResult, chassisFanStatus=chassisFanStatus, concIpAddr=concIpAddr, chassisPs2Status=chassisPs2Status, moduleReset=moduleReset, chassisPs2Type=chassisPs2Type, concTrapReceiverComm=concTrapReceiverComm, concNetMask=concNetMask, moduleStatus=moduleStatus, chassisPs1Type=chassisPs1Type, chassisNumSlots=chassisNumSlots, concBroadcast=concBroadcast, concTrapReceiverTable=concTrapReceiverTable, concMgmtType=concMgmtType, moduleHwLoVersion=moduleHwLoVersion, moduleSwLoVersion=moduleSwLoVersion, moduleTestResult=moduleTestResult, moduleIndex=moduleIndex, moduleType=moduleType, crescendo=crescendo, module=module, concTrapReceiverEntry=concTrapReceiverEntry, concCommunityString=concCommunityString, moduleTable=moduleTable, portType=portType, concBaudRate=concBaudRate, chassisTempAlarm=chassisTempAlarm, portEntry=portEntry, moduleFwLoVersion=moduleFwLoVersion, moduleSwHiVersion=moduleSwHiVersion, moduleSerialNumber=moduleSerialNumber, concAttachType=concAttachType, portIndex=portIndex, moduleFwHiVersion=moduleFwHiVersion, moduleName=moduleName, chassis=chassis, portName=portName, port=port, concCommunityAccess=concCommunityAccess, concentrator=concentrator, portStatus=portStatus, concTrapReceiverAddr=concTrapReceiverAddr, conc=conc, concCommunityTable=concCommunityTable, concTraffic=concTraffic, moduleEntry=moduleEntry, portTable=portTable, portFddiIndex=portFddiIndex, chassisBkplType=chassisBkplType, concReset=concReset, portModuleIndex=portModuleIndex)
la_liga_goals = 43 champions_league_goals = 10 copa_del_rey_goals = 5 total_goals = la_liga_goals + champions_league_goals + copa_del_rey_goals
la_liga_goals = 43 champions_league_goals = 10 copa_del_rey_goals = 5 total_goals = la_liga_goals + champions_league_goals + copa_del_rey_goals
""" Too Long Print and remove all elements with length greater than 4 in a given list of strings. """ the_list = ["dragon", "cab", "science", "dove", "lime", "river", "pop"] to_remove = [] for x in the_list: # iterates through every element in the list if len(x) > 4: # if the element length is greater than 4 print(x) # prints the element to_remove.append(x) # appends element to remove list for y in to_remove: # iterates through every element meant to be removed the_list.remove(y) # removes element from list
""" Too Long Print and remove all elements with length greater than 4 in a given list of strings. """ the_list = ['dragon', 'cab', 'science', 'dove', 'lime', 'river', 'pop'] to_remove = [] for x in the_list: if len(x) > 4: print(x) to_remove.append(x) for y in to_remove: the_list.remove(y)
class NoUserIdOrSessionKeyError(Exception): pass class NoProductToDelete(Exception): pass class NoCart(Exception): pass class BadConfigError(Exception): pass
class Nouseridorsessionkeyerror(Exception): pass class Noproducttodelete(Exception): pass class Nocart(Exception): pass class Badconfigerror(Exception): pass
"""WizCoin By Al Sweigart test@gmail.com A basic Python project.""" __version__ = '0.1.0'
"""WizCoin By Al Sweigart test@gmail.com A basic Python project.""" __version__ = '0.1.0'
def main(): *t, n = map(int, input().split()) t=list(t) for i in range(2, n): t.append(t[i-2] + t[i-1]*t[i-1]) print(t[-1]) if __name__ == '__main__': main()
def main(): (*t, n) = map(int, input().split()) t = list(t) for i in range(2, n): t.append(t[i - 2] + t[i - 1] * t[i - 1]) print(t[-1]) if __name__ == '__main__': main()
''' Created on Oct 2, 2012 @author: vadim Todo: need to learn string algorithms. ''' f = open('data/keylog.txt') mx = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] while True: line = f.readline() if not line: break line = line[:-1] mx[int(line[0])][int(line[1])] += 1 mx[int(line[1])][int(line[2])] += 1 for l in mx: print(l) f.close() if __name__ == '__main__': pass
""" Created on Oct 2, 2012 @author: vadim Todo: need to learn string algorithms. """ f = open('data/keylog.txt') mx = [[0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]] while True: line = f.readline() if not line: break line = line[:-1] mx[int(line[0])][int(line[1])] += 1 mx[int(line[1])][int(line[2])] += 1 for l in mx: print(l) f.close() if __name__ == '__main__': pass
""" CSCI 204, Stack lab """ """ Tongyu Yang CSCI204 Lab06 """ class MyStack: """ Implement this Stack ADT using a Python list to hold elements. Do NOT use the len() feature of lists. """ CAPACITY = 10 def __init__( self ): """ Initialize an empty stack. """ self._capacity = MyStack.CAPACITY self._size = 0 self._array = [None] * self._capacity def isEmpty( self ): """ Is the stack empty? Returns True if the stack is empty; False otherwise. """ if self._size == 0: return True else: return False def push( self, item ): """ Push the item onto the top of the stack. """ if self._size == 0: self._array[0] = item else: if self._size == self._capacity: new_array = [None] * (2 * self._capacity) self._capacity *= 2 else: new_array = [None] * self._capacity new_array[0] = item for index in range(self._capacity - 1): new_array[index + 1] = self._array[index] self._array = new_array self._size += 1 def pop( self ): """ Pop the top item off the stack and return it. """ if self._size == 0: return None else: popped_item = self._array[0] for index in range(self._capacity - 1): self._array[index] = self._array[index + 1] self._size -= 1 return popped_item def peek( self ): """ Return the top item on the stack (does not change the stack). """ return self._array[0] def __repr__ (self): return str(self._array) # stack=MyStack() # print(stack.isEmpty()) # stack.push(1) # print(stack) # stack.push(2) # stack.push(3) # print(stack) # stack.pop() # print(stack) # stack.pop() # print(stack) # stack.pop() # print(stack) # print(stack.peek())
""" CSCI 204, Stack lab """ ' Tongyu Yang CSCI204 Lab06 ' class Mystack: """ Implement this Stack ADT using a Python list to hold elements. Do NOT use the len() feature of lists. """ capacity = 10 def __init__(self): """ Initialize an empty stack. """ self._capacity = MyStack.CAPACITY self._size = 0 self._array = [None] * self._capacity def is_empty(self): """ Is the stack empty? Returns True if the stack is empty; False otherwise. """ if self._size == 0: return True else: return False def push(self, item): """ Push the item onto the top of the stack. """ if self._size == 0: self._array[0] = item else: if self._size == self._capacity: new_array = [None] * (2 * self._capacity) self._capacity *= 2 else: new_array = [None] * self._capacity new_array[0] = item for index in range(self._capacity - 1): new_array[index + 1] = self._array[index] self._array = new_array self._size += 1 def pop(self): """ Pop the top item off the stack and return it. """ if self._size == 0: return None else: popped_item = self._array[0] for index in range(self._capacity - 1): self._array[index] = self._array[index + 1] self._size -= 1 return popped_item def peek(self): """ Return the top item on the stack (does not change the stack). """ return self._array[0] def __repr__(self): return str(self._array)
# # Copyright (c) 2019 Opticks Team. All Rights Reserved. # # This file is part of Opticks # (see https://bitbucket.org/simoncblyth/opticks). # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # class MXD(object): def __init__(self, ab, key, cut, erc, shortname): """ :param ab: :param key: property name which returns a dict with numerical values :param cut: warn/error/fatal maximum permissable deviations, exceeding error level yields non-zero RC :param erc: integer return code if any of the values exceeds the cut RC passed from python to C++ via system calls are truncated beyond 0xff see: SSysTest """ self.ab = ab self.key = key self.cut = cut self.erc = erc self.shortname = shortname mxd = property(lambda self:getattr(self.ab, self.key)) def _get_mx(self): mxd = self.mxd return max(mxd.values()) if len(mxd) > 0 else 999. mx = property(_get_mx) def _get_rc(self): return self.erc if self.mx > self.cut[1] else 0 rc = property(_get_rc) def __repr__(self): mxd = self.mxd pres_ = lambda d:" ".join(map(lambda kv:"%10s : %8.3g " % (kv[0], kv[1]),d.items())) return "\n".join(["%s .rc %d .mx %7.3f .cut %7.3f/%7.3f/%7.3f %s " % ( self.shortname, self.rc, self.mx, self.cut[0], self.cut[1], self.cut[2], pres_(mxd) )]) class RC(object): def __init__(self, ab ): self.ab = ab self.c2p = MXD(ab, "c2p", ab.ok.c2max, 77, "ab.rc.c2p") self.rdv = MXD(ab, "rmxs", ab.ok.rdvmax, 88, "ab.rc.rdv") self.pdv = MXD(ab, "pmxs", ab.ok.pdvmax, 99, "ab.rc.pdv") def _get_rcs(self): return map(lambda _:_.rc, [self.c2p, self.rdv, self.pdv]) rcs = property(_get_rcs) def _get_rc(self): return max(self.rcs+[0]) rc = property(_get_rc) def __repr__(self): return "\n".join([ "ab.rc .rc %3d %r " % (self.rc, self.rcs) , repr(self.c2p), repr(self.rdv), repr(self.pdv), "." ])
class Mxd(object): def __init__(self, ab, key, cut, erc, shortname): """ :param ab: :param key: property name which returns a dict with numerical values :param cut: warn/error/fatal maximum permissable deviations, exceeding error level yields non-zero RC :param erc: integer return code if any of the values exceeds the cut RC passed from python to C++ via system calls are truncated beyond 0xff see: SSysTest """ self.ab = ab self.key = key self.cut = cut self.erc = erc self.shortname = shortname mxd = property(lambda self: getattr(self.ab, self.key)) def _get_mx(self): mxd = self.mxd return max(mxd.values()) if len(mxd) > 0 else 999.0 mx = property(_get_mx) def _get_rc(self): return self.erc if self.mx > self.cut[1] else 0 rc = property(_get_rc) def __repr__(self): mxd = self.mxd pres_ = lambda d: ' '.join(map(lambda kv: '%10s : %8.3g ' % (kv[0], kv[1]), d.items())) return '\n'.join(['%s .rc %d .mx %7.3f .cut %7.3f/%7.3f/%7.3f %s ' % (self.shortname, self.rc, self.mx, self.cut[0], self.cut[1], self.cut[2], pres_(mxd))]) class Rc(object): def __init__(self, ab): self.ab = ab self.c2p = mxd(ab, 'c2p', ab.ok.c2max, 77, 'ab.rc.c2p') self.rdv = mxd(ab, 'rmxs', ab.ok.rdvmax, 88, 'ab.rc.rdv') self.pdv = mxd(ab, 'pmxs', ab.ok.pdvmax, 99, 'ab.rc.pdv') def _get_rcs(self): return map(lambda _: _.rc, [self.c2p, self.rdv, self.pdv]) rcs = property(_get_rcs) def _get_rc(self): return max(self.rcs + [0]) rc = property(_get_rc) def __repr__(self): return '\n'.join(['ab.rc .rc %3d %r ' % (self.rc, self.rcs), repr(self.c2p), repr(self.rdv), repr(self.pdv), '.'])
# Swap assign variables print("Enter 3 no.s:") a = float(input("a: ")) b = float(input("b: ")) c = float(input("c: ")) a, b = a+b, b+c print("Variables are: ") print("a:", a) print("b:", b) print("c:", c)
print('Enter 3 no.s:') a = float(input('a: ')) b = float(input('b: ')) c = float(input('c: ')) (a, b) = (a + b, b + c) print('Variables are: ') print('a:', a) print('b:', b) print('c:', c)
class A: def __setitem__(self, e, f): print(e + f) a = A() a[2] = 8
class A: def __setitem__(self, e, f): print(e + f) a = a() a[2] = 8
""" for i in range(1,101,2): if(i%7==0): continue print(i) """ c=0 while c<=100: if(c%2!=0 and c%7!=0): print(c) c=c+1
""" for i in range(1,101,2): if(i%7==0): continue print(i) """ c = 0 while c <= 100: if c % 2 != 0 and c % 7 != 0: print(c) c = c + 1
cpp_config = [ 'query-lib/official/cpp/codeql-suites/cpp-security-and-quality.qls', 'query-lib/official/cpp/codeql-suites/cpp-security-extended.qls', ] js_config = [] # exported lang_configs = { 'cpp' : cpp_config, 'javascript' : js_config } need_compile = ['cpp', 'java']
cpp_config = ['query-lib/official/cpp/codeql-suites/cpp-security-and-quality.qls', 'query-lib/official/cpp/codeql-suites/cpp-security-extended.qls'] js_config = [] lang_configs = {'cpp': cpp_config, 'javascript': js_config} need_compile = ['cpp', 'java']
# Push (temp, idx) in a stack. Pop element when a bigger elem is seen and update arr[idx] with (new_idx-idx). # class Solution: # def dailyTemperatures(self, T: List[int]) -> List[int]: # S = [] # res = [0]*len(T) # for i in range(len(T)-1, -1, -1): # while S and T[S[-1]] <= T[i]: # S.pop() # if S: # res[i] = S[-1] - i # S.append(i) # return res class Solution: # Time: O(n) # Space: O(n) def dailyTemperatures(self, T: List[int]) -> List[int]: res = [0]*len(T) stack = [] for i, t1 in enumerate(T): while stack and t1 > stack[-1][1]: j, t2 = stack.pop() res[j] = i - j stack.append((i, t1)) return res
class Solution: def daily_temperatures(self, T: List[int]) -> List[int]: res = [0] * len(T) stack = [] for (i, t1) in enumerate(T): while stack and t1 > stack[-1][1]: (j, t2) = stack.pop() res[j] = i - j stack.append((i, t1)) return res
class OrderBook: """ Implements data structure to append messages one at a time """ def __init__(self): # bids, asks self.book = (dict(), dict()) def bestBid(self): if not self.book[0].keys(): return (float('nan'), float('nan')) price = max(self.book[0].keys()) return (price, self.book[0][price]) def bestAsk(self): if not self.book[1].keys(): return (float('nan'), float('nan')) price = min(self.book[1].keys()) return (price, self.book[1][price]) def update(self, message): buySell = 'Buy' in message.Flags addDel = 'Add' in message.Flags price = message.Price amount = message.Amount amountRest = message.AmountRest if addDel: if not price in self.book[1-buySell]: self.book[1-buySell][price] = 0 self.book[1-buySell][price] += amount else: self.book[1-buySell][price] -= amount if self.book[1-buySell][price] < 0: raise RuntimeError('Negative ammount is generated in order book') if self.book[1-buySell][price] == 0: del self.book[1-buySell][price] def updateBulk(self, messages): for name, message in messages.iterrows(): self.update(message)
class Orderbook: """ Implements data structure to append messages one at a time """ def __init__(self): self.book = (dict(), dict()) def best_bid(self): if not self.book[0].keys(): return (float('nan'), float('nan')) price = max(self.book[0].keys()) return (price, self.book[0][price]) def best_ask(self): if not self.book[1].keys(): return (float('nan'), float('nan')) price = min(self.book[1].keys()) return (price, self.book[1][price]) def update(self, message): buy_sell = 'Buy' in message.Flags add_del = 'Add' in message.Flags price = message.Price amount = message.Amount amount_rest = message.AmountRest if addDel: if not price in self.book[1 - buySell]: self.book[1 - buySell][price] = 0 self.book[1 - buySell][price] += amount else: self.book[1 - buySell][price] -= amount if self.book[1 - buySell][price] < 0: raise runtime_error('Negative ammount is generated in order book') if self.book[1 - buySell][price] == 0: del self.book[1 - buySell][price] def update_bulk(self, messages): for (name, message) in messages.iterrows(): self.update(message)
class BaseType: def __init__(self, db_type: str, python_type: type): self.db_type = db_type self.python_type = python_type Float = BaseType("REAL", float) Int = BaseType("INTEGER", int) String = BaseType("TEXT", str) TypeMap = { float: Float, int: Int, str: String }
class Basetype: def __init__(self, db_type: str, python_type: type): self.db_type = db_type self.python_type = python_type float = base_type('REAL', float) int = base_type('INTEGER', int) string = base_type('TEXT', str) type_map = {float: Float, int: Int, str: String}
album_info = { 'Arrival - ABBA': { 'image': 'arrival.jpg', 'spotify_link_a': '1M4anG49aEs4YimBdj96Oy', }, }
album_info = {'Arrival - ABBA': {'image': 'arrival.jpg', 'spotify_link_a': '1M4anG49aEs4YimBdj96Oy'}}
print('Hello, world.') print('Hello, Python!') print(2 + 3) print('2' * 3) print(f'2 + 3 = {2 + 3}') print('1', '2', '3', sep=' + ', end=' ') print('=', 1 + 2 + 3, end='') print('!')
print('Hello, world.') print('Hello, Python!') print(2 + 3) print('2' * 3) print(f'2 + 3 = {2 + 3}') print('1', '2', '3', sep=' + ', end=' ') print('=', 1 + 2 + 3, end='') print('!')
#!/usr/bin/env python #coding: utf-8 class Solution: # @param A, a list of integers # @return an integer def firstMissingPositive(self, A): if not A: return 1 la = len(A) i = 0 while i < la: if i + 1 == A[i]: i += 1 continue if A[i] <= 0: i += 1 continue j = A[i] while j > 0 and j <= la and j != A[j-1] and j != i: t = A[j-1] A[j-1] = j j = t if j > 0 and j <= la and j != A[j-1]: A[j-1] = j i += 1 i = 1 while i <= la: if A[i-1] != i: return i i += 1 return A[la-1] + 1 if __name__ == '__main__': s = Solution() assert 3 == s.firstMissingPositive([1,2,0]) assert 2 == s.firstMissingPositive([3,4,-1,1]) assert 2 == s.firstMissingPositive([1,1]) assert 3 == s.firstMissingPositive([1,1,2,2]) assert 2 == s.firstMissingPositive([1,1,3,3]) assert 1 == s.firstMissingPositive([]) assert 1 == s.firstMissingPositive([2]) assert 3 == s.firstMissingPositive([2,1])
class Solution: def first_missing_positive(self, A): if not A: return 1 la = len(A) i = 0 while i < la: if i + 1 == A[i]: i += 1 continue if A[i] <= 0: i += 1 continue j = A[i] while j > 0 and j <= la and (j != A[j - 1]) and (j != i): t = A[j - 1] A[j - 1] = j j = t if j > 0 and j <= la and (j != A[j - 1]): A[j - 1] = j i += 1 i = 1 while i <= la: if A[i - 1] != i: return i i += 1 return A[la - 1] + 1 if __name__ == '__main__': s = solution() assert 3 == s.firstMissingPositive([1, 2, 0]) assert 2 == s.firstMissingPositive([3, 4, -1, 1]) assert 2 == s.firstMissingPositive([1, 1]) assert 3 == s.firstMissingPositive([1, 1, 2, 2]) assert 2 == s.firstMissingPositive([1, 1, 3, 3]) assert 1 == s.firstMissingPositive([]) assert 1 == s.firstMissingPositive([2]) assert 3 == s.firstMissingPositive([2, 1])
def xor(a, b): return (a or b) and not (a and b) def collapse_polymer(polymer): pos = 0 while pos + 1 < len(polymer): first = polymer[pos] second = polymer[pos + 1] if first.lower() == second.lower() and xor(first.isupper(), second.isupper()): if pos + 2 >= len(polymer): polymer = polymer[0:pos] else: polymer = polymer[0:pos] + polymer[pos + 2:] pos = max(0, pos - 1) else : pos += 1 return polymer def find_shortest_poly_by_removing_one_type(polymer): alphabet = "abcdefghijklmnopqrstuvwxyz" ans = polymer for letter in alphabet: tst = polymer.replace(letter.lower(), '') tst = tst.replace(letter.upper(), '') tmp = collapse_polymer(tst) if len(tmp) < len(ans): ans = tmp return ans
def xor(a, b): return (a or b) and (not (a and b)) def collapse_polymer(polymer): pos = 0 while pos + 1 < len(polymer): first = polymer[pos] second = polymer[pos + 1] if first.lower() == second.lower() and xor(first.isupper(), second.isupper()): if pos + 2 >= len(polymer): polymer = polymer[0:pos] else: polymer = polymer[0:pos] + polymer[pos + 2:] pos = max(0, pos - 1) else: pos += 1 return polymer def find_shortest_poly_by_removing_one_type(polymer): alphabet = 'abcdefghijklmnopqrstuvwxyz' ans = polymer for letter in alphabet: tst = polymer.replace(letter.lower(), '') tst = tst.replace(letter.upper(), '') tmp = collapse_polymer(tst) if len(tmp) < len(ans): ans = tmp return ans
class Aula: def __init__(self, id, numero, titulo): self._id = id self._numero = numero self._titulo = titulo def get_id(self): return self._id def get_numero(self): return self._numero def get_titulo(self): return self._titulo
class Aula: def __init__(self, id, numero, titulo): self._id = id self._numero = numero self._titulo = titulo def get_id(self): return self._id def get_numero(self): return self._numero def get_titulo(self): return self._titulo
class Queue(object): def __init__(self): self.q = [] def push(self, value): self.q.insert(0, value) def pop(self): return self.q.pop() def is_empty(self): return self.q == [] def size(self): return len(self.q) # Example q = Queue() q.push(1) q.push(2) q.push(3) print(q.q) # [3, 2, 1] q.pop() print(q.q) # [3, 2]
class Queue(object): def __init__(self): self.q = [] def push(self, value): self.q.insert(0, value) def pop(self): return self.q.pop() def is_empty(self): return self.q == [] def size(self): return len(self.q) q = queue() q.push(1) q.push(2) q.push(3) print(q.q) q.pop() print(q.q)
file = open("day 04/Toon - Python/input", "r") lines = file.readlines() numbers = [int(x) for x in lines[0][:-1].split(',')] boards = [[int(x) for x in line[:-1].split(' ') if x != '' ] for line in lines[2:]] boards = [boards[i*6:i*6+5] for i in range(100)] def contains_bingo(board): return -5 in [sum(line) for line in board] or -5 in [sum(line) for line in [list(i) for i in zip(*board)]] found = False for number in numbers: for i in range(len(boards)): boards[i] = [[-1 if x == number else x for x in line] for line in boards[i]] if contains_bingo(boards[i]): result = boards[i] result_number = number found = True if found: break def sum_board(board): return sum([sum([0 if x == -1 else x for x in line]) for line in board]) print("part 1: %s" % (sum_board(result) * number)) boards = [[int(x) for x in line[:-1].split(' ') if x != '' ] for line in lines[2:]] boards = [boards[i*6:i*6+5] for i in range(100)] def find_last(boards, numbers): good_boards = [] bad_boards = [] for i in range(len(boards)): boards[i] = [[-1 if x == numbers[0] else x for x in line] for line in boards[i]] if not contains_bingo(boards[i]): good_boards += [boards[i]] else: bad_boards += [boards[i]] if len(good_boards) == 0: return sum_board(bad_boards[0]) * numbers[0] return find_last(good_boards, numbers[1:]) print("part 2: %s" % find_last(boards, numbers))
file = open('day 04/Toon - Python/input', 'r') lines = file.readlines() numbers = [int(x) for x in lines[0][:-1].split(',')] boards = [[int(x) for x in line[:-1].split(' ') if x != ''] for line in lines[2:]] boards = [boards[i * 6:i * 6 + 5] for i in range(100)] def contains_bingo(board): return -5 in [sum(line) for line in board] or -5 in [sum(line) for line in [list(i) for i in zip(*board)]] found = False for number in numbers: for i in range(len(boards)): boards[i] = [[-1 if x == number else x for x in line] for line in boards[i]] if contains_bingo(boards[i]): result = boards[i] result_number = number found = True if found: break def sum_board(board): return sum([sum([0 if x == -1 else x for x in line]) for line in board]) print('part 1: %s' % (sum_board(result) * number)) boards = [[int(x) for x in line[:-1].split(' ') if x != ''] for line in lines[2:]] boards = [boards[i * 6:i * 6 + 5] for i in range(100)] def find_last(boards, numbers): good_boards = [] bad_boards = [] for i in range(len(boards)): boards[i] = [[-1 if x == numbers[0] else x for x in line] for line in boards[i]] if not contains_bingo(boards[i]): good_boards += [boards[i]] else: bad_boards += [boards[i]] if len(good_boards) == 0: return sum_board(bad_boards[0]) * numbers[0] return find_last(good_boards, numbers[1:]) print('part 2: %s' % find_last(boards, numbers))
listOriginPath = [ { "header": "test.example.com", "httpPort": 80, "mappingUniqueId": "993419389425697", "origin": "10.10.10.1", "originType": "HOST_SERVER", "path": "/example", "status": "RUNNING" }, { "header": "test.example.com", "httpPort": 80, "mappingUniqueId": "993419389425697", "origin": "10.10.10.1", "originType": "HOST_SERVER", "path": "/example1", "status": "RUNNING" } ] createOriginPath = [ { "header": "test.example.com", "httpPort": 80, "mappingUniqueId": "993419389425697", "origin": "10.10.10.1", "originType": "HOST_SERVER", "path": "/example", "status": "RUNNING", "bucketName": "test-bucket", 'fileExtension': 'jpg', "performanceConfiguration": "General web delivery" } ] deleteOriginPath = "Origin with path /example/videos/* has been deleted"
list_origin_path = [{'header': 'test.example.com', 'httpPort': 80, 'mappingUniqueId': '993419389425697', 'origin': '10.10.10.1', 'originType': 'HOST_SERVER', 'path': '/example', 'status': 'RUNNING'}, {'header': 'test.example.com', 'httpPort': 80, 'mappingUniqueId': '993419389425697', 'origin': '10.10.10.1', 'originType': 'HOST_SERVER', 'path': '/example1', 'status': 'RUNNING'}] create_origin_path = [{'header': 'test.example.com', 'httpPort': 80, 'mappingUniqueId': '993419389425697', 'origin': '10.10.10.1', 'originType': 'HOST_SERVER', 'path': '/example', 'status': 'RUNNING', 'bucketName': 'test-bucket', 'fileExtension': 'jpg', 'performanceConfiguration': 'General web delivery'}] delete_origin_path = 'Origin with path /example/videos/* has been deleted'
@jit(nopython=True) def pressure_poisson(p, b, l2_target): J, I = b.shape iter_diff = l2_target + 1 n = 0 while iter_diff > l2_target and n <= 500: pn = p.copy() for i in range(1, I - 1): for j in range(1, J - 1): p[j, i] = (.25 * (pn[j, i + 1] + pn[j, i - 1] + pn[j + 1, i] + pn[j - 1, i]) - b[j, i]) for j in range(J): p[j, 0] = p[j, 1] p[j, -1] = p[j, -2] for i in range(I): p[0, i] = p[1, i] p[-1, i] = 0 if n % 10 == 0: iter_diff = numpy.sqrt(numpy.sum((p - pn)**2)/numpy.sum(pn**2)) n += 1 return p
@jit(nopython=True) def pressure_poisson(p, b, l2_target): (j, i) = b.shape iter_diff = l2_target + 1 n = 0 while iter_diff > l2_target and n <= 500: pn = p.copy() for i in range(1, I - 1): for j in range(1, J - 1): p[j, i] = 0.25 * (pn[j, i + 1] + pn[j, i - 1] + pn[j + 1, i] + pn[j - 1, i]) - b[j, i] for j in range(J): p[j, 0] = p[j, 1] p[j, -1] = p[j, -2] for i in range(I): p[0, i] = p[1, i] p[-1, i] = 0 if n % 10 == 0: iter_diff = numpy.sqrt(numpy.sum((p - pn) ** 2) / numpy.sum(pn ** 2)) n += 1 return p
a = [int(x) for x in input().split()] time = None # a[0] initial hour # a[1] initial min # a[2] final hour # a[3] final min start = 60 * a[0] + a[1] finish = 60 * a[2] + a[3] if finish <= start: finish += 1440 # 24 * 60 time = finish - start print(f"O JOGO DUROU {int(time / 60)} HORA(S) E {int(time % 60)} MINUTO(S)")
a = [int(x) for x in input().split()] time = None start = 60 * a[0] + a[1] finish = 60 * a[2] + a[3] if finish <= start: finish += 1440 time = finish - start print(f'O JOGO DUROU {int(time / 60)} HORA(S) E {int(time % 60)} MINUTO(S)')
def Compute_kmeans_inertia(resultsDict, FSWRITE = False, gpu_available = False): # Measure inertia of kmeans model for a variety of values of cluster number n km_list = list() data = resultsDict['PCA_fit_transform'] #data = resultsDict['NP_images_STD'] N_clusters = len(resultsDict['imagesFilenameList']) if gpu_available: print('Running Compute_kmeans_inertia on GPU: ') with gpu_context(): for clust in range(1,N_clusters): km = KMeans(n_clusters=clust, init='random', random_state=42) km = km.fit(data) km_list.append({'clusters': clust, 'inertia': km.inertia_, 'model': km}) # It is possible to specify to make the computations on CPU else: print('Running Compute_kmeans_inertia on local CPU: ') for clust in range(1,N_clusters): km = KMeans(n_clusters=clust, init='random', random_state=42) km = km.fit(data) km_list.append({'clusters': clust, 'inertia': km.inertia_, 'model': km}) resultsDict['km'] = km resultsDict['km_list'] = km_list if FSWRITE == True: write_results(resultsDict) return resultsDict
def compute_kmeans_inertia(resultsDict, FSWRITE=False, gpu_available=False): km_list = list() data = resultsDict['PCA_fit_transform'] n_clusters = len(resultsDict['imagesFilenameList']) if gpu_available: print('Running Compute_kmeans_inertia on GPU: ') with gpu_context(): for clust in range(1, N_clusters): km = k_means(n_clusters=clust, init='random', random_state=42) km = km.fit(data) km_list.append({'clusters': clust, 'inertia': km.inertia_, 'model': km}) else: print('Running Compute_kmeans_inertia on local CPU: ') for clust in range(1, N_clusters): km = k_means(n_clusters=clust, init='random', random_state=42) km = km.fit(data) km_list.append({'clusters': clust, 'inertia': km.inertia_, 'model': km}) resultsDict['km'] = km resultsDict['km_list'] = km_list if FSWRITE == True: write_results(resultsDict) return resultsDict
n_students = int(input()) skills = list(input().split(" ")) skills = [int(skill) for skill in skills] skills = sorted(skills) n_problems = 0 ptr1 = n_students - 1 ptr2 = n_students - 2 while ptr2 >= 0: if (skills[ptr1] == skills[ptr2]): ptr1 -= 2 ptr2 -= 2 else: n_problems += 1 skills[ptr2] += 1 print(n_problems)
n_students = int(input()) skills = list(input().split(' ')) skills = [int(skill) for skill in skills] skills = sorted(skills) n_problems = 0 ptr1 = n_students - 1 ptr2 = n_students - 2 while ptr2 >= 0: if skills[ptr1] == skills[ptr2]: ptr1 -= 2 ptr2 -= 2 else: n_problems += 1 skills[ptr2] += 1 print(n_problems)
""" 0011. Container With Most Water Medium Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container. Example 1: Input: height = [1,8,6,2,5,4,8,3,7] Output: 49 Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49. Example 2: Input: height = [1,1] Output: 1 Example 3: Input: height = [4,3,2,1,4] Output: 16 Example 4: Input: height = [1,2,1] Output: 2 Constraints: 2 <= height.length <= 3 * 104 0 <= height[i] <= 3 * 104 """ class Solution: def maxArea(self, height: List[int]) -> int: i, j, res = 0, len(height) - 1, 0 while i < j: if height[i] < height[j]: res = max(res, height[i] * (j - i)) i += 1 else: res = max(res, height[j] * (j - i)) j -= 1 return res
""" 0011. Container With Most Water Medium Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. Notice that you may not slant the container. Example 1: Input: height = [1,8,6,2,5,4,8,3,7] Output: 49 Explanation: The above vertical lines are represented by array [1,8,6,2,5,4,8,3,7]. In this case, the max area of water (blue section) the container can contain is 49. Example 2: Input: height = [1,1] Output: 1 Example 3: Input: height = [4,3,2,1,4] Output: 16 Example 4: Input: height = [1,2,1] Output: 2 Constraints: 2 <= height.length <= 3 * 104 0 <= height[i] <= 3 * 104 """ class Solution: def max_area(self, height: List[int]) -> int: (i, j, res) = (0, len(height) - 1, 0) while i < j: if height[i] < height[j]: res = max(res, height[i] * (j - i)) i += 1 else: res = max(res, height[j] * (j - i)) j -= 1 return res
teste = [0, 2, 3, 4, 5] print(teste) teste.insert(0, teste[3]) print(teste) teste.pop(4) print(teste)
teste = [0, 2, 3, 4, 5] print(teste) teste.insert(0, teste[3]) print(teste) teste.pop(4) print(teste)
# -*- coding: utf-8 -*- """Top-level package for ePages Client.""" __author__ = """Pekka Piispanen, Tero Kotti""" __email__ = 'pekka@vilkas.fi, tero@vilkas.fi' __version__ = '0.2.0'
"""Top-level package for ePages Client.""" __author__ = 'Pekka Piispanen, Tero Kotti' __email__ = 'pekka@vilkas.fi, tero@vilkas.fi' __version__ = '0.2.0'
arr = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 9] arr.sort() my_dict = {i:arr.count(i) for i in arr} # sorting the dictionary based on value my_dict = {k: v for k, v in sorted(my_dict.items(), key=lambda item: item[1])} print(len(my_dict)) print(my_dict) list = list(my_dict.keys()) print(list[-1])
arr = [1, 2, 3, 4, 4, 4, 5, 6, 6, 7, 8, 9] arr.sort() my_dict = {i: arr.count(i) for i in arr} my_dict = {k: v for (k, v) in sorted(my_dict.items(), key=lambda item: item[1])} print(len(my_dict)) print(my_dict) list = list(my_dict.keys()) print(list[-1])
# Model parameters model_hidden_size = 768 model_embedding_size = 256 model_num_layers = 1 # Training parameters n_steps = 2e4 learning_rate_init = 1e-3 speakers_per_batch = 16 utterances_per_speaker = 32 ## Tensor-train parameters for last linear layer. compression = 'tt' n_cores = 2 rank = 2 # Evaluation and Test parameters val_speakers_per_batch = 40 val_utterances_per_speaker = 32 test_speakers_per_batch = 40 test_utterances_per_speaker = 32 # seed = None
model_hidden_size = 768 model_embedding_size = 256 model_num_layers = 1 n_steps = 20000.0 learning_rate_init = 0.001 speakers_per_batch = 16 utterances_per_speaker = 32 compression = 'tt' n_cores = 2 rank = 2 val_speakers_per_batch = 40 val_utterances_per_speaker = 32 test_speakers_per_batch = 40 test_utterances_per_speaker = 32
"""******************************************************* This module has functions converting energies ***************************************************** """ #print __doc__ def convert_energy(Energy, Input_unit, Output_unit):#converts distance modulus to distance in parsec """Description: ocnverts energy from Input_unit to Output_unit. Input :- Energy to be converted - Input unit. Can be: 'erg' - ergs 'J' - Jouls 'Hz' - Frequency [1/s] 'A','Ang'- Wavelength [Ang] 'cm' - Wavelength [cm] 'nm' - Wavelength [nm] 'm' - Wavelength [m] 'eV' - Electron volts [h nu/q] 'keV' - kilo Electron volts [h nu/q] 'MeV' - Mega Electron volts [h nu/q] 'GeV' - Giga Electron volts [h nu/q] 'T' - Temperature [K] 'me' - Electron mass [E/m_e] 'mp' - Proton mass [E/m_p] 'cal' - calorie (4.184 J) 'Btu' - (1.055x10^3 J) 'kWh' - kilowatt-hour (3.6x10^6 J) 'TNT' - one ton of TNT (4.2x10^9 J) 'gr' - Energy equivalent of 1 gram of matter (9x10^13 J) - requested output unit. One of the above. Output :- Energy in output system Tested : ? By : Maayane T. Soumagnac Nov 2016 URL : Example: Reliable: """ Erg2Erg = 1. Erg2J = 1e-7# 1erg=10**-7J #Erg2Hz = 1.5092e26#? #Erg2A = 1.9864e-8 #? Erg2eV = 6.2415e11 #Erg2T = 7.2430e15#? Erg2me = 1.2214e6 Erg2mp = 665.214577 Erg2cal = Erg2J/4.184 Erg2Btu = Erg2J/1.055e3 Erg2kWh = Erg2J/3.6e6 Erg2TNT = Erg2J/4.2e9 #Erg2gr = get_constant('c', 'cgs'). ^ -2 relation='inv' if Input_unit.lower()=='erg': ConvFactor = Erg2Erg elif Input_unit.lower()=='j': ConvFactor=Erg2J #elif Input_unit.lower()=='hz': # ConvFactor=Erg2Hz #elif Input_unit.lower() in ('a','ang'): # relation='inv' # ConvFactor=Erg2A ''' elif Input_unit.lower()=='cm': relation='inv' ConvFactor=Erg2A*1e-8 elif Input_unit.lower()=='nm': relation='inv' ConvFactor=Erg2A*1e-4 #elif Input_unit.lower()=='m': # relation='inv' # ConvFactor=Erg2A*1e-10 elif Input_unit.lower()=='ev': ConvFactor = Erg2eV elif Input_unit.lower()=='kev': ConvFactor = Erg2eV*1e-3 elif Input_unit.lower()=='mev': ConvFactor = Erg2eV*1e-6 elif Input_unit.lower()=='gev': ConvFactor = Erg2eV* 1e-9 #elif Input_unit.lower()=='t': # ConvFactor = Erg2T elif Input_unit.lower()=='me': ConvFactor = Erg2me elif Input_unit.lower()=='mp': ConvFactor = Erg2mp elif Input_unit.lower()=='cal': ConvFactor = Erg2cal elif Input_unit.lower()=='btu': ConvFactor = Erg2Btu elif Input_unit.lower()=='kwh': ConvFactor = Erg2kWh elif Input_unit.lower()=='tnt': ConvFactor = Erg2TNT #elif Input_unit =='gr': # ConvFactor = Erg2gr else: print 'error: unknown InUnit option' ''' if relation=='lin': ErgE=Energy*ConvFactor elif relation=='inv': ErgE=Energy/ConvFactor else: print('unknown relation') relation = 'lin' if Output_unit.lower()=='erg': ConvFactor = Erg2Erg elif Output_unit.lower()== 'j': ConvFactor = Erg2J #elif Output_unit.lower()== 'hz': # ConvFactor = Erg2Hz #elif Output_unit.lower()== {'a','ang'}: # relation = 'inv' # ConvFactor = Erg2A #elif Output_unit.lower()== 'nm': # relation = 'inv' # ConvFactor = Erg2A*1e-4 #elif Output_unit.lower()== 'cm': # relation = 'inv' # ConvFactor = Erg2A*1e-8 #elif Output_unit.lower()== 'm': # relation = 'inv' # ConvFactor = Erg2A*1e-10 ''' elif Output_unit.lower()== 'ev': ConvFactor = Erg2eV elif Output_unit.lower()== 'kev': ConvFactor = Erg2eV*1e-3 elif Output_unit.lower()== 'mev': ConvFactor = Erg2eV*1e-6 elif Output_unit.lower()== 'gev': ConvFactor = Erg2eV*1e-9 #elif Output_unit.lower()== 't': # ConvFactor = Erg2T elif Output_unit.lower()== 'me': ConvFactor = Erg2me elif Output_unit.lower()== 'mp': ConvFactor = Erg2mp elif Output_unit.lower()== 'cal': ConvFactor = Erg2cal elif Output_unit.lower()== 'btu': ConvFactor = Erg2Btu elif Output_unit.lower()== 'kwh': ConvFactor = Erg2kWh elif Output_unit.lower()== 'tnt': ConvFactor = Erg2TNT #elif Output_unit.lower()== 'gr': # ConvFactor = Erg2gr else: print 'Unknown InUnit Option' ''' if relation == 'lin': new_energy = ErgE * ConvFactor elif relation == 'inv': new_energy= ErgE/ConvFactor else: print('unknown relation') return new_energy
"""******************************************************* This module has functions converting energies ***************************************************** """ def convert_energy(Energy, Input_unit, Output_unit): """Description: ocnverts energy from Input_unit to Output_unit. Input :- Energy to be converted - Input unit. Can be: 'erg' - ergs 'J' - Jouls 'Hz' - Frequency [1/s] 'A','Ang'- Wavelength [Ang] 'cm' - Wavelength [cm] 'nm' - Wavelength [nm] 'm' - Wavelength [m] 'eV' - Electron volts [h nu/q] 'keV' - kilo Electron volts [h nu/q] 'MeV' - Mega Electron volts [h nu/q] 'GeV' - Giga Electron volts [h nu/q] 'T' - Temperature [K] 'me' - Electron mass [E/m_e] 'mp' - Proton mass [E/m_p] 'cal' - calorie (4.184 J) 'Btu' - (1.055x10^3 J) 'kWh' - kilowatt-hour (3.6x10^6 J) 'TNT' - one ton of TNT (4.2x10^9 J) 'gr' - Energy equivalent of 1 gram of matter (9x10^13 J) - requested output unit. One of the above. Output :- Energy in output system Tested : ? By : Maayane T. Soumagnac Nov 2016 URL : Example: Reliable: """ erg2_erg = 1.0 erg2_j = 1e-07 erg2e_v = 624150000000.0 erg2me = 1221400.0 erg2mp = 665.214577 erg2cal = Erg2J / 4.184 erg2_btu = Erg2J / 1055.0 erg2k_wh = Erg2J / 3600000.0 erg2_tnt = Erg2J / 4200000000.0 relation = 'inv' if Input_unit.lower() == 'erg': conv_factor = Erg2Erg elif Input_unit.lower() == 'j': conv_factor = Erg2J "\n elif Input_unit.lower()=='cm':\n relation='inv'\n ConvFactor=Erg2A*1e-8\n elif Input_unit.lower()=='nm':\n relation='inv'\n ConvFactor=Erg2A*1e-4\n #elif Input_unit.lower()=='m':\n # relation='inv'\n # ConvFactor=Erg2A*1e-10\n elif Input_unit.lower()=='ev':\n ConvFactor = Erg2eV\n elif Input_unit.lower()=='kev':\n ConvFactor = Erg2eV*1e-3\n elif Input_unit.lower()=='mev':\n ConvFactor = Erg2eV*1e-6\n elif Input_unit.lower()=='gev':\n ConvFactor = Erg2eV* 1e-9\n #elif Input_unit.lower()=='t':\n # ConvFactor = Erg2T\n elif Input_unit.lower()=='me':\n ConvFactor = Erg2me\n elif Input_unit.lower()=='mp':\n ConvFactor = Erg2mp\n elif Input_unit.lower()=='cal':\n ConvFactor = Erg2cal\n elif Input_unit.lower()=='btu':\n ConvFactor = Erg2Btu\n elif Input_unit.lower()=='kwh':\n ConvFactor = Erg2kWh\n elif Input_unit.lower()=='tnt':\n ConvFactor = Erg2TNT\n #elif Input_unit =='gr':\n # ConvFactor = Erg2gr\n else: print 'error: unknown InUnit option'\n " if relation == 'lin': erg_e = Energy * ConvFactor elif relation == 'inv': erg_e = Energy / ConvFactor else: print('unknown relation') relation = 'lin' if Output_unit.lower() == 'erg': conv_factor = Erg2Erg elif Output_unit.lower() == 'j': conv_factor = Erg2J "\n elif Output_unit.lower()== 'ev':\n ConvFactor = Erg2eV\n elif Output_unit.lower()== 'kev':\n ConvFactor = Erg2eV*1e-3\n elif Output_unit.lower()== 'mev':\n ConvFactor = Erg2eV*1e-6\n elif Output_unit.lower()== 'gev':\n ConvFactor = Erg2eV*1e-9\n #elif Output_unit.lower()== 't':\n # ConvFactor = Erg2T\n elif Output_unit.lower()== 'me':\n ConvFactor = Erg2me\n elif Output_unit.lower()== 'mp':\n ConvFactor = Erg2mp\n elif Output_unit.lower()== 'cal':\n ConvFactor = Erg2cal\n elif Output_unit.lower()== 'btu':\n ConvFactor = Erg2Btu\n elif Output_unit.lower()== 'kwh':\n ConvFactor = Erg2kWh\n elif Output_unit.lower()== 'tnt':\n ConvFactor = Erg2TNT\n #elif Output_unit.lower()== 'gr':\n # ConvFactor = Erg2gr\n else: print 'Unknown InUnit Option'\n" if relation == 'lin': new_energy = ErgE * ConvFactor elif relation == 'inv': new_energy = ErgE / ConvFactor else: print('unknown relation') return new_energy
BRIGHTID_NODE = 'http://node.brightid.org/brightid/v5' VERIFICATIONS_URL = BRIGHTID_NODE + '/verifications/idchain/' OPERATION_URL = BRIGHTID_NODE + '/operations/' CONTEXT = 'idchain' RPC_URL = 'wss://idchain.one/ws/' RELAYER_ADDRESS = '0x0df7eDDd60D613362ca2b44659F56fEbafFA9bFB' DISTRIBUTION_ADDRESS = '0x6E39d7540c2ad4C18Eb29501183AFA79156e79aa' DISTRIBUTION_ABI = '[{"inputs": [{"internalType": "address payable", "name": "beneficiary", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "claim", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "addr", "type": "address"}], "name": "setBrightid", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_claimable", "type": "uint256"}], "name": "setClaimable", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"stateMutability": "payable", "type": "receive"}, {"inputs": [], "name": "brightid", "outputs": [{"internalType": "contract BrightID", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "claimable", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "claimed", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}]' BRIGHTID_ADDRESS = '0x72a70314C3adD56127413F78402392744af4EF64' BRIGHTID_ABI = '[{"anonymous": false, "inputs": [{"indexed": false, "internalType": "contract IERC20", "name": "supervisorToken", "type": "address"}, {"indexed": false, "internalType": "contract IERC20", "name": "proposerToken", "type": "address"}], "name": "MembershipTokensSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}, {"internalType": "uint8", "name": "v", "type": "uint8"}, {"internalType": "bytes32", "name": "r", "type": "bytes32"}, {"internalType": "bytes32", "name": "s", "type": "bytes32"}], "name": "propose", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Proposed", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "contract IERC20", "name": "_supervisorToken", "type": "address"}, {"internalType": "contract IERC20", "name": "_proposerToken", "type": "address"}], "name": "setMembershipTokens", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_waiting", "type": "uint256"}, {"internalType": "uint256", "name": "_timeout", "type": "uint256"}], "name": "setTiming", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "start", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [], "name": "Started", "type": "event"}, {"inputs": [], "name": "stop", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "stopper", "type": "address"}], "name": "Stopped", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "waiting", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "timeout", "type": "uint256"}], "name": "TimingSet", "type": "event"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Verified", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}], "name": "verify", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "history", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "isRevoked", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], "name": "proposals", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "proposerToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "stopped", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "supervisorToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "timeout", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "verifications", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "waiting", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}]' NOT_FOUND = 2 NOT_SPONSORED = 4 CHAINID = '0x4a' GAS = 500000 GAS_PRICE = 10000000000 WAITING_TIME_AFTER_PROPOSING = 15 LINK_CHECK_NUM = 18 LINK_CHECK_PERIOD = 10 SPONSOR_CHECK_NUM = 6 SPONSOR_CHECK_PERIOD = 10 HOST = 'localhost' PORT = 5000 SPONSORSHIP_PRIVATEKEY = '' RELAYER_PRIVATE = ''
brightid_node = 'http://node.brightid.org/brightid/v5' verifications_url = BRIGHTID_NODE + '/verifications/idchain/' operation_url = BRIGHTID_NODE + '/operations/' context = 'idchain' rpc_url = 'wss://idchain.one/ws/' relayer_address = '0x0df7eDDd60D613362ca2b44659F56fEbafFA9bFB' distribution_address = '0x6E39d7540c2ad4C18Eb29501183AFA79156e79aa' distribution_abi = '[{"inputs": [{"internalType": "address payable", "name": "beneficiary", "type": "address"}, {"internalType": "uint256", "name": "amount", "type": "uint256"}], "name": "claim", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "addr", "type": "address"}], "name": "setBrightid", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_claimable", "type": "uint256"}], "name": "setClaimable", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"stateMutability": "payable", "type": "receive"}, {"inputs": [], "name": "brightid", "outputs": [{"internalType": "contract BrightID", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "claimable", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "claimed", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}]' brightid_address = '0x72a70314C3adD56127413F78402392744af4EF64' brightid_abi = '[{"anonymous": false, "inputs": [{"indexed": false, "internalType": "contract IERC20", "name": "supervisorToken", "type": "address"}, {"indexed": false, "internalType": "contract IERC20", "name": "proposerToken", "type": "address"}], "name": "MembershipTokensSet", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "previousOwner", "type": "address"}, {"indexed": true, "internalType": "address", "name": "newOwner", "type": "address"}], "name": "OwnershipTransferred", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}, {"internalType": "uint8", "name": "v", "type": "uint8"}, {"internalType": "bytes32", "name": "r", "type": "bytes32"}, {"internalType": "bytes32", "name": "s", "type": "bytes32"}], "name": "propose", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Proposed", "type": "event"}, {"inputs": [], "name": "renounceOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "contract IERC20", "name": "_supervisorToken", "type": "address"}, {"internalType": "contract IERC20", "name": "_proposerToken", "type": "address"}], "name": "setMembershipTokens", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "uint256", "name": "_waiting", "type": "uint256"}, {"internalType": "uint256", "name": "_timeout", "type": "uint256"}], "name": "setTiming", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [], "name": "start", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [], "name": "Started", "type": "event"}, {"inputs": [], "name": "stop", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "address", "name": "stopper", "type": "address"}], "name": "Stopped", "type": "event"}, {"anonymous": false, "inputs": [{"indexed": false, "internalType": "uint256", "name": "waiting", "type": "uint256"}, {"indexed": false, "internalType": "uint256", "name": "timeout", "type": "uint256"}], "name": "TimingSet", "type": "event"}, {"inputs": [{"internalType": "address", "name": "newOwner", "type": "address"}], "name": "transferOwnership", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"anonymous": false, "inputs": [{"indexed": true, "internalType": "address", "name": "addr", "type": "address"}], "name": "Verified", "type": "event"}, {"inputs": [{"internalType": "bytes32", "name": "context", "type": "bytes32"}, {"internalType": "address[]", "name": "addrs", "type": "address[]"}], "name": "verify", "outputs": [], "stateMutability": "nonpayable", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "history", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "isRevoked", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "owner", "outputs": [{"internalType": "address", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "bytes32", "name": "", "type": "bytes32"}], "name": "proposals", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "proposerToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "stopped", "outputs": [{"internalType": "bool", "name": "", "type": "bool"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "supervisorToken", "outputs": [{"internalType": "contract IERC20", "name": "", "type": "address"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "timeout", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [{"internalType": "address", "name": "", "type": "address"}], "name": "verifications", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}, {"inputs": [], "name": "waiting", "outputs": [{"internalType": "uint256", "name": "", "type": "uint256"}], "stateMutability": "view", "type": "function"}]' not_found = 2 not_sponsored = 4 chainid = '0x4a' gas = 500000 gas_price = 10000000000 waiting_time_after_proposing = 15 link_check_num = 18 link_check_period = 10 sponsor_check_num = 6 sponsor_check_period = 10 host = 'localhost' port = 5000 sponsorship_privatekey = '' relayer_private = ''
# Time: O(n log n); Space: O(n) def target_indices(nums, target): nums.sort() ans = [] for i, n in enumerate(nums): if n == target: ans.append(i) return ans # Time: O(n + k); Space(n + k) def target_indices2(nums, target): count = [0] * (max(nums) + 1) for n in nums: count[n] += 1 sorted_nums = [] for i, n in enumerate(count): if n != 0: sorted_nums.extend([i] * n) ans = [] for i, n in enumerate(sorted_nums): if n == target: ans.append(i) return ans # Time: O(n); Space: O(n) def target_indices3(nums, target): less, equal = 0, 0 for num in nums: if num < target: less += 1 if num == target: equal += 1 return list(range(less, less + equal)) # Test cases: print(target_indices2([1, 2, 5, 2, 3], 2)) print(target_indices2([1, 2, 5, 2, 3], 3)) print(target_indices2([1, 2, 5, 2, 3], 5))
def target_indices(nums, target): nums.sort() ans = [] for (i, n) in enumerate(nums): if n == target: ans.append(i) return ans def target_indices2(nums, target): count = [0] * (max(nums) + 1) for n in nums: count[n] += 1 sorted_nums = [] for (i, n) in enumerate(count): if n != 0: sorted_nums.extend([i] * n) ans = [] for (i, n) in enumerate(sorted_nums): if n == target: ans.append(i) return ans def target_indices3(nums, target): (less, equal) = (0, 0) for num in nums: if num < target: less += 1 if num == target: equal += 1 return list(range(less, less + equal)) print(target_indices2([1, 2, 5, 2, 3], 2)) print(target_indices2([1, 2, 5, 2, 3], 3)) print(target_indices2([1, 2, 5, 2, 3], 5))
class Browser(object): def __init__(self): form = {} def open(self, url): pass def set_handle_robots(self, status): pass def set_cookiejar(self, cj): pass def forms(self): forms = [{'session[username_or_email]':'', 'session[password]':''}] return forms def close(self): pass class submit(object): def __init__(self): pass def get_data(self): return '<code>0123456</code>'
class Browser(object): def __init__(self): form = {} def open(self, url): pass def set_handle_robots(self, status): pass def set_cookiejar(self, cj): pass def forms(self): forms = [{'session[username_or_email]': '', 'session[password]': ''}] return forms def close(self): pass class Submit(object): def __init__(self): pass def get_data(self): return '<code>0123456</code>'
class Dataset(): def __init__(self, data,feature=None): self.len = data.shape[0] if (feature is not None): self.data = data[:,:feature] self.label = data[:,feature:] else: feature = data.shape[1] self.data = data[:,:feature] self.label = None def __getitem__(self, index): if (self.label is None): return self.data[index] return self.data[index],self.label[index] def __len__(self): return self.len
class Dataset: def __init__(self, data, feature=None): self.len = data.shape[0] if feature is not None: self.data = data[:, :feature] self.label = data[:, feature:] else: feature = data.shape[1] self.data = data[:, :feature] self.label = None def __getitem__(self, index): if self.label is None: return self.data[index] return (self.data[index], self.label[index]) def __len__(self): return self.len
class UnbundledTradeIndicatorEnum: UNBUNDLED_TRADE_NONE = 0 FIRST_SUB_TRADE_OF_UNBUNDLED_TRADE = 1 LAST_SUB_TRADE_OF_UNBUNDLED_TRADE = 2
class Unbundledtradeindicatorenum: unbundled_trade_none = 0 first_sub_trade_of_unbundled_trade = 1 last_sub_trade_of_unbundled_trade = 2
# -*- coding: UTF-8 -* def input_data2(): return None
def input_data2(): return None
def longest_possible_word_length(): return 189819 class iterlines(object): def __init__(self, filehandle): self._filehandle = filehandle def __iter__(self): self._filehandle.seek(0) return self def __next__(self): line = self._filehandle.readline() if line == '': raise StopIteration return line.strip('\n') def generate_wordlist_from_file(filename, pred): with open(filename, 'r') as f: for word in iterlines(f): if pred(word.replace('\n', '')): yield word def generate_wordlist_from_dict(pred): for word in generate_wordlist_from_file('/usr/share/dict/words', pred): yield word def generate_wordlist(pred, wordlist=None, filename=None): if wordlist is not None: return [word for word in wordlist if pred(word)] if filename is not None: return [word for word in generate_wordlist_from_file(filename, pred)] return [word for word in generate_wordlist_from_dict(pred)] def words_by_ending(ending, wordlist=None): def endswith(word): return word.endswith(ending) return generate_wordlist(endswith, wordlist) def words_by_start(start, wordlist=None): def startswith(word): return word.startswith(start) return generate_wordlist(startswith, wordlist) def words_by_length(length, wordlist=None): def is_correct_length(word): return len(word) == length def is_correct_length_tuple(word): return len(word) >= length[0] and len(word) <= length[1] if isinstance(length, tuple): return generate_wordlist(is_correct_length_tuple, wordlist) return generate_wordlist(is_correct_length, wordlist) def words_by_maxlength(maxlength, wordlist=None): return words_by_length((1, maxlength), wordlist) def words_by_minlength(minlength, wordlist=None): return words_by_length((minlength, longest_possible_word_length()), wordlist) def len_hist(wordlist, should_print=False): def extend_to_length(arr, newlen): oldlen = len(arr) if newlen > oldlen: arr.extend([0] * (newlen - oldlen)) assert(len(arr) == newlen) hist = [] for word in wordlist: oldlen = len(hist) wordlen = len(word) if wordlen >= oldlen: extend_to_length(hist, wordlen + 1) assert(len(hist) == wordlen + 1) hist[wordlen] += 1 if should_print: print_len_hist(hist) return hist def print_len_hist(h): print('Word length histogram:') total = 0 for idx in range(len(h)): if h[idx] > 0: print('\t' + str(h[idx]) + ' words of length ' + str(idx)) total += h[idx] print(str(total) + ' words total') def remove_duplicates(wordlist): unique_words = set() for word in wordlist: unique_words.add(word) wordlist = list(unique_words) return wordlist def words_from_file(filename): return generate_wordlist(lambda w: True, None, filename) def remove_vowels(wordlist, include_y=False): wordmap = dict() vowels = 'aeiouy' if include_y else 'aeiou' for word in wordlist: trimmed = ''.join([c for c in word if c.lower() not in vowels]) wordmap[trimmed] = word return wordmap
def longest_possible_word_length(): return 189819 class Iterlines(object): def __init__(self, filehandle): self._filehandle = filehandle def __iter__(self): self._filehandle.seek(0) return self def __next__(self): line = self._filehandle.readline() if line == '': raise StopIteration return line.strip('\n') def generate_wordlist_from_file(filename, pred): with open(filename, 'r') as f: for word in iterlines(f): if pred(word.replace('\n', '')): yield word def generate_wordlist_from_dict(pred): for word in generate_wordlist_from_file('/usr/share/dict/words', pred): yield word def generate_wordlist(pred, wordlist=None, filename=None): if wordlist is not None: return [word for word in wordlist if pred(word)] if filename is not None: return [word for word in generate_wordlist_from_file(filename, pred)] return [word for word in generate_wordlist_from_dict(pred)] def words_by_ending(ending, wordlist=None): def endswith(word): return word.endswith(ending) return generate_wordlist(endswith, wordlist) def words_by_start(start, wordlist=None): def startswith(word): return word.startswith(start) return generate_wordlist(startswith, wordlist) def words_by_length(length, wordlist=None): def is_correct_length(word): return len(word) == length def is_correct_length_tuple(word): return len(word) >= length[0] and len(word) <= length[1] if isinstance(length, tuple): return generate_wordlist(is_correct_length_tuple, wordlist) return generate_wordlist(is_correct_length, wordlist) def words_by_maxlength(maxlength, wordlist=None): return words_by_length((1, maxlength), wordlist) def words_by_minlength(minlength, wordlist=None): return words_by_length((minlength, longest_possible_word_length()), wordlist) def len_hist(wordlist, should_print=False): def extend_to_length(arr, newlen): oldlen = len(arr) if newlen > oldlen: arr.extend([0] * (newlen - oldlen)) assert len(arr) == newlen hist = [] for word in wordlist: oldlen = len(hist) wordlen = len(word) if wordlen >= oldlen: extend_to_length(hist, wordlen + 1) assert len(hist) == wordlen + 1 hist[wordlen] += 1 if should_print: print_len_hist(hist) return hist def print_len_hist(h): print('Word length histogram:') total = 0 for idx in range(len(h)): if h[idx] > 0: print('\t' + str(h[idx]) + ' words of length ' + str(idx)) total += h[idx] print(str(total) + ' words total') def remove_duplicates(wordlist): unique_words = set() for word in wordlist: unique_words.add(word) wordlist = list(unique_words) return wordlist def words_from_file(filename): return generate_wordlist(lambda w: True, None, filename) def remove_vowels(wordlist, include_y=False): wordmap = dict() vowels = 'aeiouy' if include_y else 'aeiou' for word in wordlist: trimmed = ''.join([c for c in word if c.lower() not in vowels]) wordmap[trimmed] = word return wordmap
""" Two ways for checking model architectures: 1. Use torchsummary. 2. Define your model classes as a BaseModel (instead of a nn.Module), which specifies a __str__() function. """ # from __future__ import print_function # import torch # import torchsummary # device = torch.device("cuda" if torch.cuda.is_available() else "cpu") # model_test = ResNet_UNet() # model_test.to(device) # #torchsummary.summary(model_test, (3, 256, 256)) # print(model_test)
""" Two ways for checking model architectures: 1. Use torchsummary. 2. Define your model classes as a BaseModel (instead of a nn.Module), which specifies a __str__() function. """
class DependencyResolutionError(RuntimeError): """Raised when task dependencies cannot be resolved. This may be raised by :meth:`.Queue.submit` (if it is possible to detect at that time), or by :meth:`.Task.result` later. """ class PatternMissingError(RuntimeError): """Raised by :meth:`.Task.result` when the :ref:`pattern <patterns>` can't be identified.""" class DependencyFailedError(RuntimeError): """Raises by :meth:`.Task.result` when a dependency of the task failed."""
class Dependencyresolutionerror(RuntimeError): """Raised when task dependencies cannot be resolved. This may be raised by :meth:`.Queue.submit` (if it is possible to detect at that time), or by :meth:`.Task.result` later. """ class Patternmissingerror(RuntimeError): """Raised by :meth:`.Task.result` when the :ref:`pattern <patterns>` can't be identified.""" class Dependencyfailederror(RuntimeError): """Raises by :meth:`.Task.result` when a dependency of the task failed."""
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def __repr__(self): if type(self.data) != 'str': return str(self.data) return self.data def _height(root): if root is None: return 0 return max(_height(root.left), _height(root.right)) + 1 def is_balanced_binary_tree(root): ''' Binary tree where difference between the left and the right subtree for any node is not more than one ''' if root is None: return True lh = _height(root.left) rh = _height(root.right) if ((abs(lh - rh) <= 1) and is_balanced_binary_tree(root.left) and is_balanced_binary_tree(root.right)): return True return False def _count_nodes(root): if root is None: return 0 return (1 + _count_nodes(root.left) + _count_nodes(root.right)) def is_complete_binary_tree(root, index, number_of_nodes): ''' Binary tree in which all levels are filled except possibly the lowest level which is filled from left to right ''' if root is None: return True if index >= number_of_nodes: return False return (is_complete_binary_tree(root.left, 2*index+1, number_of_nodes) and is_complete_binary_tree(root.right, 2*index+2, number_of_nodes)) def _calculate_left_depth(root): left_depth = 0 while(root is not None): left_depth += 1 root = root.left return left_depth def is_perfect_binary_tree(root, left_depth, level=0): ''' Binary tree in which every internal node has exactly 2 child nodes and and all leaf nodes are at the same level is a perfect binary tree ''' if root is None: return True if (root.left is None and root.right is None): return (left_depth == level + 1) if (root.left is None or root.right is None): return False return (is_perfect_binary_tree(root.left, left_depth, level+1) and is_perfect_binary_tree(root.right, left_depth, level+1)) def is_full_binary_tree(root): ''' Binary tree with parent node and all internal nodes having either 2 children nodes or no children nodes are called full binary tree. ''' if root is None: return True if root.left is None and root.right is None: return True if root.left is not None and root.right is not None: return is_full_binary_tree(root.left) and is_full_binary_tree(root.right) return False def build_tree_one(): root = Node(1) root.right = Node(3) root.left = Node(2) root.left.left = Node(4) root.left.right = Node(5) root.left.right.left = Node(6) root.left.right.right = Node(7) return root def build_tree_two(): root = Node(1) root.left = Node(12) root.right = Node(9) root.left.left = Node(5) root.left.right = Node(6) return root def build_tree_three(): root = Node(1) root.left = Node(2) root.right = Node(3) root.left.left = Node(4) root.left.right = Node(5) root.right.left = Node(13) root.right.right = Node(9) return root if __name__ == '__main__': tree_one = build_tree_one() if is_full_binary_tree(tree_one): print('Tree One is full binary tree') else: print('Tree One is not full binary tree') if is_perfect_binary_tree(tree_one, _calculate_left_depth(tree_one)): print('Tree One is perfect binary tree') else: print('Tree One is not perfect binary tree') if is_complete_binary_tree(tree_one, 0, _count_nodes(tree_one)): print('Tree One is a complete binary tree') else: print('Tree One is not a complete binary tree') if is_balanced_binary_tree(tree_one): print('Tree One is balanced binary tree') else: print('Tree One is not a balanced binary tree') tree_two = build_tree_two() if is_full_binary_tree(tree_two): print('\nTree Two is full binary tree') else: print('\nTree Two is not full binary tree') if is_perfect_binary_tree(tree_two, _calculate_left_depth(tree_two)): print('Tree Two is perfect binary tree') else: print('Tree Two is not perfect binary tree') if is_complete_binary_tree(tree_two, 0, _count_nodes(tree_two)): print('Tree Two is a complete binary tree') else: print('Tree Two is not a complete binary tree') if is_balanced_binary_tree(tree_two): print('Tree Two is balanced binary tree') else: print('Tree Two is not a balanced binary tree') tree_three = build_tree_three() if is_full_binary_tree(tree_three): print('\nTree Three is full binary tree') else: print('\nTree Three is not full binary tree') if is_perfect_binary_tree(tree_three, _calculate_left_depth(tree_three)): print('Tree Three is perfect binary tree') else: print('Tree Three is not perfect binary tree') if is_complete_binary_tree(tree_three, 0, _count_nodes(tree_three)): print('Tree Three is a complete binary tree') else: print('Tree Three is not a complete binary tree') if is_balanced_binary_tree(tree_three): print('Tree Three is balanced binary tree') else: print('Tree Three is not a balanced binary tree')
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def __repr__(self): if type(self.data) != 'str': return str(self.data) return self.data def _height(root): if root is None: return 0 return max(_height(root.left), _height(root.right)) + 1 def is_balanced_binary_tree(root): """ Binary tree where difference between the left and the right subtree for any node is not more than one """ if root is None: return True lh = _height(root.left) rh = _height(root.right) if abs(lh - rh) <= 1 and is_balanced_binary_tree(root.left) and is_balanced_binary_tree(root.right): return True return False def _count_nodes(root): if root is None: return 0 return 1 + _count_nodes(root.left) + _count_nodes(root.right) def is_complete_binary_tree(root, index, number_of_nodes): """ Binary tree in which all levels are filled except possibly the lowest level which is filled from left to right """ if root is None: return True if index >= number_of_nodes: return False return is_complete_binary_tree(root.left, 2 * index + 1, number_of_nodes) and is_complete_binary_tree(root.right, 2 * index + 2, number_of_nodes) def _calculate_left_depth(root): left_depth = 0 while root is not None: left_depth += 1 root = root.left return left_depth def is_perfect_binary_tree(root, left_depth, level=0): """ Binary tree in which every internal node has exactly 2 child nodes and and all leaf nodes are at the same level is a perfect binary tree """ if root is None: return True if root.left is None and root.right is None: return left_depth == level + 1 if root.left is None or root.right is None: return False return is_perfect_binary_tree(root.left, left_depth, level + 1) and is_perfect_binary_tree(root.right, left_depth, level + 1) def is_full_binary_tree(root): """ Binary tree with parent node and all internal nodes having either 2 children nodes or no children nodes are called full binary tree. """ if root is None: return True if root.left is None and root.right is None: return True if root.left is not None and root.right is not None: return is_full_binary_tree(root.left) and is_full_binary_tree(root.right) return False def build_tree_one(): root = node(1) root.right = node(3) root.left = node(2) root.left.left = node(4) root.left.right = node(5) root.left.right.left = node(6) root.left.right.right = node(7) return root def build_tree_two(): root = node(1) root.left = node(12) root.right = node(9) root.left.left = node(5) root.left.right = node(6) return root def build_tree_three(): root = node(1) root.left = node(2) root.right = node(3) root.left.left = node(4) root.left.right = node(5) root.right.left = node(13) root.right.right = node(9) return root if __name__ == '__main__': tree_one = build_tree_one() if is_full_binary_tree(tree_one): print('Tree One is full binary tree') else: print('Tree One is not full binary tree') if is_perfect_binary_tree(tree_one, _calculate_left_depth(tree_one)): print('Tree One is perfect binary tree') else: print('Tree One is not perfect binary tree') if is_complete_binary_tree(tree_one, 0, _count_nodes(tree_one)): print('Tree One is a complete binary tree') else: print('Tree One is not a complete binary tree') if is_balanced_binary_tree(tree_one): print('Tree One is balanced binary tree') else: print('Tree One is not a balanced binary tree') tree_two = build_tree_two() if is_full_binary_tree(tree_two): print('\nTree Two is full binary tree') else: print('\nTree Two is not full binary tree') if is_perfect_binary_tree(tree_two, _calculate_left_depth(tree_two)): print('Tree Two is perfect binary tree') else: print('Tree Two is not perfect binary tree') if is_complete_binary_tree(tree_two, 0, _count_nodes(tree_two)): print('Tree Two is a complete binary tree') else: print('Tree Two is not a complete binary tree') if is_balanced_binary_tree(tree_two): print('Tree Two is balanced binary tree') else: print('Tree Two is not a balanced binary tree') tree_three = build_tree_three() if is_full_binary_tree(tree_three): print('\nTree Three is full binary tree') else: print('\nTree Three is not full binary tree') if is_perfect_binary_tree(tree_three, _calculate_left_depth(tree_three)): print('Tree Three is perfect binary tree') else: print('Tree Three is not perfect binary tree') if is_complete_binary_tree(tree_three, 0, _count_nodes(tree_three)): print('Tree Three is a complete binary tree') else: print('Tree Three is not a complete binary tree') if is_balanced_binary_tree(tree_three): print('Tree Three is balanced binary tree') else: print('Tree Three is not a balanced binary tree')
def most_frequent(arr): ret = None counter = {} max_count = -1 for n in arr: counter.setdefault(n, 0) counter[n] += 1 if counter[n] > max_count: max_count = counter[n] ret = n return ret
def most_frequent(arr): ret = None counter = {} max_count = -1 for n in arr: counter.setdefault(n, 0) counter[n] += 1 if counter[n] > max_count: max_count = counter[n] ret = n return ret
# Created by MechAviv # Kinesis Introduction # Map ID :: 331003200 # Subway :: Subway Car #3 JAY = 1531001 GIRL = 1531067 sm.spawnNpc(GIRL, 699, 47) sm.showNpcSpecialActionByTemplateId(GIRL, "summon") sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.setSpineObjectEffectPlay(True, "subway_bg", "outside", True, False) sm.setSpineObjectEffectPlay(True, "subway_main", "outside", True, False) sm.unlockForIntro() sm.playSound("Sound/Field.img/flowervioleta/wink") sm.cameraSwitchNormal("go_next", 1000) sm.addPopUpSay(JAY, 2000, "#face10#Watch out, there are more on the way!", "")
jay = 1531001 girl = 1531067 sm.spawnNpc(GIRL, 699, 47) sm.showNpcSpecialActionByTemplateId(GIRL, 'summon') sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700303, 250, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700304, 300, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.spawnMob(2700305, 350, 57, False) sm.setSpineObjectEffectPlay(True, 'subway_bg', 'outside', True, False) sm.setSpineObjectEffectPlay(True, 'subway_main', 'outside', True, False) sm.unlockForIntro() sm.playSound('Sound/Field.img/flowervioleta/wink') sm.cameraSwitchNormal('go_next', 1000) sm.addPopUpSay(JAY, 2000, '#face10#Watch out, there are more on the way!', '')
# https://www.hackerrank.com/challenges/30-review-loop/ T = int(input()) S = list() for i in range(T): S.append(str(input())) for i in range(len(S)): print(S[i][0] + S[i][2::2] + ' ' + S[i][1::2])
t = int(input()) s = list() for i in range(T): S.append(str(input())) for i in range(len(S)): print(S[i][0] + S[i][2::2] + ' ' + S[i][1::2])
# # PySNMP MIB module A3COM0420-SWITCH-EXTENSIONS (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM0420-SWITCH-EXTENSIONS # Produced by pysmi-0.3.4 at Mon Apr 29 16:54:17 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) # brasica2, = mibBuilder.importSymbols("A3COM0004-GENERIC", "brasica2") OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueRangeConstraint") ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") NotificationType, Bits, MibIdentifier, TimeTicks, Integer32, ObjectIdentity, Counter64, Unsigned32, iso, Gauge32, ModuleIdentity, IpAddress, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "NotificationType", "Bits", "MibIdentifier", "TimeTicks", "Integer32", "ObjectIdentity", "Counter64", "Unsigned32", "iso", "Gauge32", "ModuleIdentity", "IpAddress", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn") TextualConvention, MacAddress, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "MacAddress", "DisplayString") stackConfigGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 1)) prConStackFwdingMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("fastForward", 1), ("fragmentFree", 2), ("storeAndForward", 3), ("intelligent", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackFwdingMode.setStatus('mandatory') prConStackPaceMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notApplicable", 1), ("normalEthernet", 2), ("lowLatency", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackPaceMode.setStatus('mandatory') prConStackVLANConfigMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notApplicable", 1), ("portMode", 2), ("autoSelect", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackVLANConfigMode.setStatus('mandatory') prConStackRAPStudyPort = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 4), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackRAPStudyPort.setStatus('mandatory') prConStackRAPCopyPort = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 5), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackRAPCopyPort.setStatus('mandatory') prConStackRAPEnable = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("off", 1), ("on", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackRAPEnable.setStatus('mandatory') prConStackBridgeMode = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("single", 1), ("multiple", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackBridgeMode.setStatus('mandatory') prConStackIpTos = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("notApplicable", 1), ("enable", 2), ("disable", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackIpTos.setStatus('mandatory') prConStackPktRateControl = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=NamedValues(("notApplicable", 1), ("disable", 2), ("limitUnknownDAs", 3), ("limitMcasts", 4), ("limitMcastsAndUnknownDAs", 5), ("limitBcasts", 6), ("limitBcastsAndUnknownDAs", 7), ("limitBcastsAndMcasts", 8), ("limitBcastsMcastsAndUnknownDAs", 9)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackPktRateControl.setStatus('mandatory') prConStackPktRateLimit = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 262143))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackPktRateLimit.setStatus('mandatory') prConStackStpProtocolVersion = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 12), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 2))).clone(namedValues=NamedValues(("stpVersion0", 0), ("rstpVersion2", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackStpProtocolVersion.setStatus('mandatory') prConStackStpPathCostDefault = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("stp8021d1998", 1), ("stp8021t2000", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConStackStpPathCostDefault.setStatus('mandatory') prConStackLacpOperInfo = MibScalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("notOperational", 1), ("operational", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: prConStackLacpOperInfo.setStatus('mandatory') switchConfigGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 2)) prConfigPortTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1), ) if mibBuilder.loadTexts: prConfigPortTable.setStatus('mandatory') prConfigPortEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: prConfigPortEntry.setStatus('mandatory') prConPortVLANConfigMode = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("notApplicable", 1), ("useDefault", 2), ("portMode", 3), ("autoSelect", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConPortVLANConfigMode.setStatus('mandatory') prConPortIFM = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("notApplicable", 1), ("off", 2), ("maxJams6", 3), ("maxJams7", 4), ("maxJams8", 5), ("maxJams9", 6), ("maxJams10", 7), ("maxJams11", 8), ("maxJams12", 9), ("maxJams13", 10)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConPortIFM.setStatus('mandatory') prConPortLacp = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConPortLacp.setStatus('mandatory') prConPortStpAdminPathCost = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 200000000))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConPortStpAdminPathCost.setStatus('mandatory') prConPortCascadeMode = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: prConPortCascadeMode.setStatus('mandatory') prConPortFdbTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2), ) if mibBuilder.loadTexts: prConPortFdbTable.setStatus('mandatory') prConPortFdbEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1), ).setIndexNames((0, "A3COM0420-SWITCH-EXTENSIONS", "prConPortFdbPort"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConPortFdbId"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConPortFdbAddress")) if mibBuilder.loadTexts: prConPortFdbEntry.setStatus('mandatory') prConPortFdbPort = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))) if mibBuilder.loadTexts: prConPortFdbPort.setStatus('mandatory') prConPortFdbId = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 2), Integer32()) if mibBuilder.loadTexts: prConPortFdbId.setStatus('mandatory') prConPortFdbAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 3), MacAddress()) if mibBuilder.loadTexts: prConPortFdbAddress.setStatus('mandatory') prConPortFdbStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("learned", 3), ("self", 4), ("mgmt", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: prConPortFdbStatus.setStatus('mandatory') prConTrunkMulticastTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3), ) if mibBuilder.loadTexts: prConTrunkMulticastTable.setStatus('mandatory') prConTrunkMulticastEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1), ).setIndexNames((0, "A3COM0420-SWITCH-EXTENSIONS", "prConTrunkMulticastFdbId"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConTrunkMulticastAddress")) if mibBuilder.loadTexts: prConTrunkMulticastEntry.setStatus('mandatory') prConTrunkMulticastFdbId = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 1), Integer32()) if mibBuilder.loadTexts: prConTrunkMulticastFdbId.setStatus('mandatory') prConTrunkMulticastAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 2), MacAddress()) if mibBuilder.loadTexts: prConTrunkMulticastAddress.setStatus('mandatory') prConTrunkMulticastPortlist = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 3), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConTrunkMulticastPortlist.setStatus('mandatory') prConTrunkMulticastStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("permanent", 3), ("deleteOnReset", 4), ("deleteOnTimeout", 5)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConTrunkMulticastStatus.setStatus('mandatory') prConTrunkMulticastType = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("other", 1), ("invalid", 2), ("learned", 3), ("self", 4), ("mgmt", 5)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: prConTrunkMulticastType.setStatus('mandatory') prConTrunkMulticastRobp = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("true", 1), ("false", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: prConTrunkMulticastRobp.setStatus('mandatory') prConIfIndexTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4), ) if mibBuilder.loadTexts: prConIfIndexTable.setStatus('mandatory') prConIfIndexEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1), ).setIndexNames((0, "A3COM0420-SWITCH-EXTENSIONS", "prConIfIndexGroupIndex"), (0, "A3COM0420-SWITCH-EXTENSIONS", "prConIfIndexPortIndex")) if mibBuilder.loadTexts: prConIfIndexEntry.setStatus('mandatory') prConIfIndexGroupIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1024))) if mibBuilder.loadTexts: prConIfIndexGroupIndex.setStatus('mandatory') prConIfIndexPortIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 1024))) if mibBuilder.loadTexts: prConIfIndexPortIndex.setStatus('mandatory') prConIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: prConIfIndex.setStatus('mandatory') prConIfIndexBridgePort = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: prConIfIndexBridgePort.setStatus('mandatory') prConfigAggTable = MibTable((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5), ) if mibBuilder.loadTexts: prConfigAggTable.setStatus('mandatory') prConfigAggEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1), ).setIndexNames((0, "IF-MIB", "ifIndex")) if mibBuilder.loadTexts: prConfigAggEntry.setStatus('mandatory') prConfigAggStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("unused", 1), ("autoInUse", 2), ("autoAgeing", 3), ("autoReusable", 4), ("manual", 5)))).setMaxAccess("readonly") if mibBuilder.loadTexts: prConfigAggStatus.setStatus('mandatory') mibBuilder.exportSymbols("A3COM0420-SWITCH-EXTENSIONS", prConIfIndexGroupIndex=prConIfIndexGroupIndex, prConIfIndexTable=prConIfIndexTable, prConfigAggEntry=prConfigAggEntry, prConfigAggStatus=prConfigAggStatus, prConTrunkMulticastStatus=prConTrunkMulticastStatus, switchConfigGroup=switchConfigGroup, prConPortIFM=prConPortIFM, stackConfigGroup=stackConfigGroup, prConPortFdbStatus=prConPortFdbStatus, prConTrunkMulticastAddress=prConTrunkMulticastAddress, prConIfIndexEntry=prConIfIndexEntry, prConStackIpTos=prConStackIpTos, prConStackStpPathCostDefault=prConStackStpPathCostDefault, prConPortFdbId=prConPortFdbId, prConPortVLANConfigMode=prConPortVLANConfigMode, prConTrunkMulticastTable=prConTrunkMulticastTable, prConIfIndexBridgePort=prConIfIndexBridgePort, prConPortFdbPort=prConPortFdbPort, prConPortCascadeMode=prConPortCascadeMode, prConStackBridgeMode=prConStackBridgeMode, prConPortFdbTable=prConPortFdbTable, prConTrunkMulticastRobp=prConTrunkMulticastRobp, prConStackRAPEnable=prConStackRAPEnable, prConPortLacp=prConPortLacp, prConTrunkMulticastType=prConTrunkMulticastType, prConfigAggTable=prConfigAggTable, prConStackPktRateLimit=prConStackPktRateLimit, prConIfIndexPortIndex=prConIfIndexPortIndex, prConTrunkMulticastFdbId=prConTrunkMulticastFdbId, prConStackFwdingMode=prConStackFwdingMode, prConStackStpProtocolVersion=prConStackStpProtocolVersion, prConPortFdbEntry=prConPortFdbEntry, prConPortFdbAddress=prConPortFdbAddress, prConPortStpAdminPathCost=prConPortStpAdminPathCost, prConIfIndex=prConIfIndex, prConStackRAPCopyPort=prConStackRAPCopyPort, prConTrunkMulticastEntry=prConTrunkMulticastEntry, prConTrunkMulticastPortlist=prConTrunkMulticastPortlist, prConStackRAPStudyPort=prConStackRAPStudyPort, prConfigPortEntry=prConfigPortEntry, prConStackPktRateControl=prConStackPktRateControl, prConfigPortTable=prConfigPortTable, prConStackPaceMode=prConStackPaceMode, prConStackVLANConfigMode=prConStackVLANConfigMode, prConStackLacpOperInfo=prConStackLacpOperInfo)
(brasica2,) = mibBuilder.importSymbols('A3COM0004-GENERIC', 'brasica2') (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, single_value_constraint, constraints_union, constraints_intersection, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueRangeConstraint') (if_index,) = mibBuilder.importSymbols('IF-MIB', 'ifIndex') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (notification_type, bits, mib_identifier, time_ticks, integer32, object_identity, counter64, unsigned32, iso, gauge32, module_identity, ip_address, counter32, mib_scalar, mib_table, mib_table_row, mib_table_column) = mibBuilder.importSymbols('SNMPv2-SMI', 'NotificationType', 'Bits', 'MibIdentifier', 'TimeTicks', 'Integer32', 'ObjectIdentity', 'Counter64', 'Unsigned32', 'iso', 'Gauge32', 'ModuleIdentity', 'IpAddress', 'Counter32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn') (textual_convention, mac_address, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'MacAddress', 'DisplayString') stack_config_group = mib_identifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 1)) pr_con_stack_fwding_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('fastForward', 1), ('fragmentFree', 2), ('storeAndForward', 3), ('intelligent', 4)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackFwdingMode.setStatus('mandatory') pr_con_stack_pace_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('notApplicable', 1), ('normalEthernet', 2), ('lowLatency', 3)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackPaceMode.setStatus('mandatory') pr_con_stack_vlan_config_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 3), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('notApplicable', 1), ('portMode', 2), ('autoSelect', 3)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackVLANConfigMode.setStatus('mandatory') pr_con_stack_rap_study_port = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 4), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackRAPStudyPort.setStatus('mandatory') pr_con_stack_rap_copy_port = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 5), integer32()).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackRAPCopyPort.setStatus('mandatory') pr_con_stack_rap_enable = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('off', 1), ('on', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackRAPEnable.setStatus('mandatory') pr_con_stack_bridge_mode = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 7), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('single', 1), ('multiple', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackBridgeMode.setStatus('mandatory') pr_con_stack_ip_tos = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 9), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('notApplicable', 1), ('enable', 2), ('disable', 3)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackIpTos.setStatus('mandatory') pr_con_stack_pkt_rate_control = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9))).clone(namedValues=named_values(('notApplicable', 1), ('disable', 2), ('limitUnknownDAs', 3), ('limitMcasts', 4), ('limitMcastsAndUnknownDAs', 5), ('limitBcasts', 6), ('limitBcastsAndUnknownDAs', 7), ('limitBcastsAndMcasts', 8), ('limitBcastsMcastsAndUnknownDAs', 9)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackPktRateControl.setStatus('mandatory') pr_con_stack_pkt_rate_limit = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 11), integer32().subtype(subtypeSpec=value_range_constraint(0, 262143))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackPktRateLimit.setStatus('mandatory') pr_con_stack_stp_protocol_version = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 12), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(0, 2))).clone(namedValues=named_values(('stpVersion0', 0), ('rstpVersion2', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackStpProtocolVersion.setStatus('mandatory') pr_con_stack_stp_path_cost_default = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('stp8021d1998', 1), ('stp8021t2000', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConStackStpPathCostDefault.setStatus('mandatory') pr_con_stack_lacp_oper_info = mib_scalar((1, 3, 6, 1, 4, 1, 43, 10, 34, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('notOperational', 1), ('operational', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: prConStackLacpOperInfo.setStatus('mandatory') switch_config_group = mib_identifier((1, 3, 6, 1, 4, 1, 43, 10, 34, 2)) pr_config_port_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1)) if mibBuilder.loadTexts: prConfigPortTable.setStatus('mandatory') pr_config_port_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex')) if mibBuilder.loadTexts: prConfigPortEntry.setStatus('mandatory') pr_con_port_vlan_config_mode = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4))).clone(namedValues=named_values(('notApplicable', 1), ('useDefault', 2), ('portMode', 3), ('autoSelect', 4)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConPortVLANConfigMode.setStatus('mandatory') pr_con_port_ifm = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 13), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('notApplicable', 1), ('off', 2), ('maxJams6', 3), ('maxJams7', 4), ('maxJams8', 5), ('maxJams9', 6), ('maxJams10', 7), ('maxJams11', 8), ('maxJams12', 9), ('maxJams13', 10)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConPortIFM.setStatus('mandatory') pr_con_port_lacp = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 14), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enable', 1), ('disable', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConPortLacp.setStatus('mandatory') pr_con_port_stp_admin_path_cost = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 15), integer32().subtype(subtypeSpec=value_range_constraint(0, 200000000))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConPortStpAdminPathCost.setStatus('mandatory') pr_con_port_cascade_mode = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 1, 1, 16), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: prConPortCascadeMode.setStatus('mandatory') pr_con_port_fdb_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2)) if mibBuilder.loadTexts: prConPortFdbTable.setStatus('mandatory') pr_con_port_fdb_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1)).setIndexNames((0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConPortFdbPort'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConPortFdbId'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConPortFdbAddress')) if mibBuilder.loadTexts: prConPortFdbEntry.setStatus('mandatory') pr_con_port_fdb_port = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))) if mibBuilder.loadTexts: prConPortFdbPort.setStatus('mandatory') pr_con_port_fdb_id = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 2), integer32()) if mibBuilder.loadTexts: prConPortFdbId.setStatus('mandatory') pr_con_port_fdb_address = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 3), mac_address()) if mibBuilder.loadTexts: prConPortFdbAddress.setStatus('mandatory') pr_con_port_fdb_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 2, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('learned', 3), ('self', 4), ('mgmt', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: prConPortFdbStatus.setStatus('mandatory') pr_con_trunk_multicast_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3)) if mibBuilder.loadTexts: prConTrunkMulticastTable.setStatus('mandatory') pr_con_trunk_multicast_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1)).setIndexNames((0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConTrunkMulticastFdbId'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConTrunkMulticastAddress')) if mibBuilder.loadTexts: prConTrunkMulticastEntry.setStatus('mandatory') pr_con_trunk_multicast_fdb_id = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 1), integer32()) if mibBuilder.loadTexts: prConTrunkMulticastFdbId.setStatus('mandatory') pr_con_trunk_multicast_address = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 2), mac_address()) if mibBuilder.loadTexts: prConTrunkMulticastAddress.setStatus('mandatory') pr_con_trunk_multicast_portlist = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 3), octet_string()).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConTrunkMulticastPortlist.setStatus('mandatory') pr_con_trunk_multicast_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 4), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('permanent', 3), ('deleteOnReset', 4), ('deleteOnTimeout', 5)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConTrunkMulticastStatus.setStatus('mandatory') pr_con_trunk_multicast_type = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 5), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('other', 1), ('invalid', 2), ('learned', 3), ('self', 4), ('mgmt', 5)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: prConTrunkMulticastType.setStatus('mandatory') pr_con_trunk_multicast_robp = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 3, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('true', 1), ('false', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: prConTrunkMulticastRobp.setStatus('mandatory') pr_con_if_index_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4)) if mibBuilder.loadTexts: prConIfIndexTable.setStatus('mandatory') pr_con_if_index_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1)).setIndexNames((0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConIfIndexGroupIndex'), (0, 'A3COM0420-SWITCH-EXTENSIONS', 'prConIfIndexPortIndex')) if mibBuilder.loadTexts: prConIfIndexEntry.setStatus('mandatory') pr_con_if_index_group_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 1024))) if mibBuilder.loadTexts: prConIfIndexGroupIndex.setStatus('mandatory') pr_con_if_index_port_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(1, 1024))) if mibBuilder.loadTexts: prConIfIndexPortIndex.setStatus('mandatory') pr_con_if_index = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 3), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: prConIfIndex.setStatus('mandatory') pr_con_if_index_bridge_port = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 4, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(1, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: prConIfIndexBridgePort.setStatus('mandatory') pr_config_agg_table = mib_table((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5)) if mibBuilder.loadTexts: prConfigAggTable.setStatus('mandatory') pr_config_agg_entry = mib_table_row((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1)).setIndexNames((0, 'IF-MIB', 'ifIndex')) if mibBuilder.loadTexts: prConfigAggEntry.setStatus('mandatory') pr_config_agg_status = mib_table_column((1, 3, 6, 1, 4, 1, 43, 10, 34, 2, 5, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5))).clone(namedValues=named_values(('unused', 1), ('autoInUse', 2), ('autoAgeing', 3), ('autoReusable', 4), ('manual', 5)))).setMaxAccess('readonly') if mibBuilder.loadTexts: prConfigAggStatus.setStatus('mandatory') mibBuilder.exportSymbols('A3COM0420-SWITCH-EXTENSIONS', prConIfIndexGroupIndex=prConIfIndexGroupIndex, prConIfIndexTable=prConIfIndexTable, prConfigAggEntry=prConfigAggEntry, prConfigAggStatus=prConfigAggStatus, prConTrunkMulticastStatus=prConTrunkMulticastStatus, switchConfigGroup=switchConfigGroup, prConPortIFM=prConPortIFM, stackConfigGroup=stackConfigGroup, prConPortFdbStatus=prConPortFdbStatus, prConTrunkMulticastAddress=prConTrunkMulticastAddress, prConIfIndexEntry=prConIfIndexEntry, prConStackIpTos=prConStackIpTos, prConStackStpPathCostDefault=prConStackStpPathCostDefault, prConPortFdbId=prConPortFdbId, prConPortVLANConfigMode=prConPortVLANConfigMode, prConTrunkMulticastTable=prConTrunkMulticastTable, prConIfIndexBridgePort=prConIfIndexBridgePort, prConPortFdbPort=prConPortFdbPort, prConPortCascadeMode=prConPortCascadeMode, prConStackBridgeMode=prConStackBridgeMode, prConPortFdbTable=prConPortFdbTable, prConTrunkMulticastRobp=prConTrunkMulticastRobp, prConStackRAPEnable=prConStackRAPEnable, prConPortLacp=prConPortLacp, prConTrunkMulticastType=prConTrunkMulticastType, prConfigAggTable=prConfigAggTable, prConStackPktRateLimit=prConStackPktRateLimit, prConIfIndexPortIndex=prConIfIndexPortIndex, prConTrunkMulticastFdbId=prConTrunkMulticastFdbId, prConStackFwdingMode=prConStackFwdingMode, prConStackStpProtocolVersion=prConStackStpProtocolVersion, prConPortFdbEntry=prConPortFdbEntry, prConPortFdbAddress=prConPortFdbAddress, prConPortStpAdminPathCost=prConPortStpAdminPathCost, prConIfIndex=prConIfIndex, prConStackRAPCopyPort=prConStackRAPCopyPort, prConTrunkMulticastEntry=prConTrunkMulticastEntry, prConTrunkMulticastPortlist=prConTrunkMulticastPortlist, prConStackRAPStudyPort=prConStackRAPStudyPort, prConfigPortEntry=prConfigPortEntry, prConStackPktRateControl=prConStackPktRateControl, prConfigPortTable=prConfigPortTable, prConStackPaceMode=prConStackPaceMode, prConStackVLANConfigMode=prConStackVLANConfigMode, prConStackLacpOperInfo=prConStackLacpOperInfo)
L = int(input()) R = int(input()) xor = L ^ R max_xor = 1 while xor: xor >>= 1 max_xor <<= 1 print (max_xor-1)
l = int(input()) r = int(input()) xor = L ^ R max_xor = 1 while xor: xor >>= 1 max_xor <<= 1 print(max_xor - 1)
# microbit-module: shared_config@0.1.0 RADIO_CHANNEL = 17 MSG_DEYLAY = 50
radio_channel = 17 msg_deylay = 50
# Invert a binary tree. # Input: # 4 # / \ # 2 7 # / \ / \ # 1 3 6 9 # # Output: # 4 # / \ # 7 2 # / \ / \ # 9 6 3 1 class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None class Solution: def invertTree(self, node: TreeNode) -> TreeNode: if not node: return None node.left, node.right = self.invertTree(node.right), self.invertTree(node.left) return node
class Treenode: def __init__(self, val): self.val = val self.left = None self.right = None class Solution: def invert_tree(self, node: TreeNode) -> TreeNode: if not node: return None (node.left, node.right) = (self.invertTree(node.right), self.invertTree(node.left)) return node
def roundUp(number:float)->int: split = [int(i) for i in str(number).split(".")] if split[1] >0: return split[0]+1 return split[0] ## Program Start ## n, k = [int(i) for i in input().strip().split(" ")][-2:] scores = sorted([int(i) for i in input().strip().split(" ")]) min_days = roundUp(n/k) output = 0 for i in range(0, min_days): output += scores[len(scores) -1 -i] print(output)
def round_up(number: float) -> int: split = [int(i) for i in str(number).split('.')] if split[1] > 0: return split[0] + 1 return split[0] (n, k) = [int(i) for i in input().strip().split(' ')][-2:] scores = sorted([int(i) for i in input().strip().split(' ')]) min_days = round_up(n / k) output = 0 for i in range(0, min_days): output += scores[len(scores) - 1 - i] print(output)
class StackOfPlates(object): def __init__(self): self.stack = [] self.capacity = 10 def push(self, item): if self.stack and self.stack[-1].length() < 10: self.stack[-1].push(item) else: new_stack = Stack() new_stack.push(item) self.stack.append(new_stack) def pop(self): self.stack[-1].pop() if self.stack[-1].length == 0: del stack[-1] def popAt(self, index): self.stack[index].pop() class Stack(object): def __init__(self): self.items = [] def get_items(self): return self.items def length(self): return len(self.items) def push(self, item): self.items.append(item) def pop(self): self.items.pop() stack = StackOfPlates() stack.push(1) stack.push(10) stack.push(11) stack.push(12) stack.push(13) stack.push(14) stack.push(15) stack.push(16) stack.push(17) stack.push(18) stack.push(19) stack.push(20) stack.push(2) stack.push(3) stack.push(4) stack.push(5) print(stack.stack[0].items) print(stack.stack[1].items) stack.pop() stack.popAt(0) print(stack.stack[0].items) print(stack.stack[1].items)
class Stackofplates(object): def __init__(self): self.stack = [] self.capacity = 10 def push(self, item): if self.stack and self.stack[-1].length() < 10: self.stack[-1].push(item) else: new_stack = stack() new_stack.push(item) self.stack.append(new_stack) def pop(self): self.stack[-1].pop() if self.stack[-1].length == 0: del stack[-1] def pop_at(self, index): self.stack[index].pop() class Stack(object): def __init__(self): self.items = [] def get_items(self): return self.items def length(self): return len(self.items) def push(self, item): self.items.append(item) def pop(self): self.items.pop() stack = stack_of_plates() stack.push(1) stack.push(10) stack.push(11) stack.push(12) stack.push(13) stack.push(14) stack.push(15) stack.push(16) stack.push(17) stack.push(18) stack.push(19) stack.push(20) stack.push(2) stack.push(3) stack.push(4) stack.push(5) print(stack.stack[0].items) print(stack.stack[1].items) stack.pop() stack.popAt(0) print(stack.stack[0].items) print(stack.stack[1].items)
""" This module will be transformed... into something far greater. """ a = "Hello" msg = f"{a} World" msg2 = f"Finally, {a} World" print(msg)
""" This module will be transformed... into something far greater. """ a = 'Hello' msg = f'{a} World' msg2 = f'Finally, {a} World' print(msg)
def skipVowels(word): novowels = '' for ch in word: if ch.lower() in 'aeiou': continue novowels += ch novowels+=ch return novowels print(skipVowels('hello')) print(skipVowels('awaited'))
def skip_vowels(word): novowels = '' for ch in word: if ch.lower() in 'aeiou': continue novowels += ch novowels += ch return novowels print(skip_vowels('hello')) print(skip_vowels('awaited'))
# -*- coding: utf-8 -*- """ ----------Phenix Labs---------- Created on Sat Jan 23 22:41:46 2021 @author: Gyan Krishna Topic: HCF andf LCM of tow numbers """ a = int(input("enter first number ")) b = int(input("enter second number ")) hcf = 1 small = min(a,b) for i in range(1,small+1): if(a%i == 0 and b%i == 0): hcf = i lcm = (a * b)/hcf print("lcm = ",lcm) print("hcf = ",hcf)
""" ----------Phenix Labs---------- Created on Sat Jan 23 22:41:46 2021 @author: Gyan Krishna Topic: HCF andf LCM of tow numbers """ a = int(input('enter first number ')) b = int(input('enter second number ')) hcf = 1 small = min(a, b) for i in range(1, small + 1): if a % i == 0 and b % i == 0: hcf = i lcm = a * b / hcf print('lcm = ', lcm) print('hcf = ', hcf)
class orf(object): """ Class that represents and Open Reading Frame Attributes: start (int): Start codon coordinate of the ORF in the parent sequence stop (int): Stop codon coordinate of the ORF in the parent sequence length (int): Number of aminoacids in the ORF translation (str): Translation of the ORF seq (str): ORF sequence """ def __init__(self, start, stop, length, translation=None, sequence=None): if(type(start) is not int): raise Exception("ORF start is not an int") if(type(stop) is not int): raise Exception("ORF stop is not an int") if(start<0 or stop<0): raise Exception("ORF start and stop coordinates must be >=0") if(type(length) is not int): raise Exception("ORF length is not an int") if(length<1): raise Exception("ORF length is less than 1") if(type(length) is not int): raise Exception("ORF length is not an int") if(translation and type(translation) is not str): raise Exception("ORF translation is not a string") if(sequence and type(sequence) is not str): raise Exception("ORF sequence is not a string") assert (stop-start) % 3 == 0 assert (stop-start) // 3 == length self.start = start self.stop = stop self.length = length self.translation = translation self.sequence = sequence
class Orf(object): """ Class that represents and Open Reading Frame Attributes: start (int): Start codon coordinate of the ORF in the parent sequence stop (int): Stop codon coordinate of the ORF in the parent sequence length (int): Number of aminoacids in the ORF translation (str): Translation of the ORF seq (str): ORF sequence """ def __init__(self, start, stop, length, translation=None, sequence=None): if type(start) is not int: raise exception('ORF start is not an int') if type(stop) is not int: raise exception('ORF stop is not an int') if start < 0 or stop < 0: raise exception('ORF start and stop coordinates must be >=0') if type(length) is not int: raise exception('ORF length is not an int') if length < 1: raise exception('ORF length is less than 1') if type(length) is not int: raise exception('ORF length is not an int') if translation and type(translation) is not str: raise exception('ORF translation is not a string') if sequence and type(sequence) is not str: raise exception('ORF sequence is not a string') assert (stop - start) % 3 == 0 assert (stop - start) // 3 == length self.start = start self.stop = stop self.length = length self.translation = translation self.sequence = sequence
""" Test cases for 7.py found in the LeetCode folder. Answer by @VGZELDA """ # function to be tested def reverse(x): x=int(x) if(x>=0): x=str(x) x=x[::-1] x=int(x) if(x<-1*(2**31))or(x>=2**31): return 0 else: return x else: x=x*(-1) x=str(x) x=x[::-1] x=int(x) x=-1*x if(x<-1*(2147483648))or(x>=2147483648): return 0 else: return x # function to test reverse def test_reverse(): assert reverse(123) == 321, "Should be 321" assert reverse(120) == 21, "Should be 21" test_reverse() print("Everything passed")
""" Test cases for 7.py found in the LeetCode folder. Answer by @VGZELDA """ def reverse(x): x = int(x) if x >= 0: x = str(x) x = x[::-1] x = int(x) if x < -1 * 2 ** 31 or x >= 2 ** 31: return 0 else: return x else: x = x * -1 x = str(x) x = x[::-1] x = int(x) x = -1 * x if x < -1 * 2147483648 or x >= 2147483648: return 0 else: return x def test_reverse(): assert reverse(123) == 321, 'Should be 321' assert reverse(120) == 21, 'Should be 21' test_reverse() print('Everything passed')
DosTags = { # System 33: "SYS_Input", 34: "SYS_Output", 35: "SYS_Asynch", 36: "SYS_UserShell", 37: "SYS_CustomShell", # CreateNewProc 1001: "NP_SegList", 1002: "NP_FreeSegList", 1003: "NP_Entry", 1004: "NP_Input", 1005: "NP_Output", 1006: "NP_CloseInput", 1007: "NP_CloseOutput", 1008: "NP_Error", 1009: "NP_CloseError", 1010: "NP_CurrentDir", 1011: "NP_StackSize", 1012: "NP_Name", 1013: "NP_Priority", 1014: "NP_ConsoleTask", 1015: "NP_WindowPtr", 1016: "NP_HomeDir", 1017: "NP_CopyVars", 1018: "NP_Cli", 1019: "NP_Path", 1020: "NP_CommandName", 1021: "NP_Arguments", 1022: "NP_NotifyOnDeath", 1023: "NP_Synchronous", 1024: "NP_ExitCode", 1025: "NP_ExitData", # AllocDosObject 2001: "ADO_FH_Mode", 2002: "ADO_DirLen", 2003: "ADR_CommNameLen", 2004: "ADR_CommFileLen", 2005: "ADR_PromptLen", }
dos_tags = {33: 'SYS_Input', 34: 'SYS_Output', 35: 'SYS_Asynch', 36: 'SYS_UserShell', 37: 'SYS_CustomShell', 1001: 'NP_SegList', 1002: 'NP_FreeSegList', 1003: 'NP_Entry', 1004: 'NP_Input', 1005: 'NP_Output', 1006: 'NP_CloseInput', 1007: 'NP_CloseOutput', 1008: 'NP_Error', 1009: 'NP_CloseError', 1010: 'NP_CurrentDir', 1011: 'NP_StackSize', 1012: 'NP_Name', 1013: 'NP_Priority', 1014: 'NP_ConsoleTask', 1015: 'NP_WindowPtr', 1016: 'NP_HomeDir', 1017: 'NP_CopyVars', 1018: 'NP_Cli', 1019: 'NP_Path', 1020: 'NP_CommandName', 1021: 'NP_Arguments', 1022: 'NP_NotifyOnDeath', 1023: 'NP_Synchronous', 1024: 'NP_ExitCode', 1025: 'NP_ExitData', 2001: 'ADO_FH_Mode', 2002: 'ADO_DirLen', 2003: 'ADR_CommNameLen', 2004: 'ADR_CommFileLen', 2005: 'ADR_PromptLen'}
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def findBottomLeftValue(self, root: TreeNode) -> int: current = [root] while True: children = [] for node in current: if node.left: children.append(node.left) if node.right: children.append(node.right) if not children: return current[0].val else: current = children
class Solution: def find_bottom_left_value(self, root: TreeNode) -> int: current = [root] while True: children = [] for node in current: if node.left: children.append(node.left) if node.right: children.append(node.right) if not children: return current[0].val else: current = children
# # PySNMP MIB module CXMLPPP-IP-NCP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXMLPPP-IP-NCP-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:33:10 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) # ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint", "ValueRangeConstraint") cxMLPPP, SapIndex = mibBuilder.importSymbols("CXProduct-SMI", "cxMLPPP", "SapIndex") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") Integer32, Unsigned32, MibIdentifier, Gauge32, ObjectIdentity, IpAddress, TimeTicks, Counter64, ModuleIdentity, Bits, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, iso = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "Unsigned32", "MibIdentifier", "Gauge32", "ObjectIdentity", "IpAddress", "TimeTicks", "Counter64", "ModuleIdentity", "Bits", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "iso") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") mlpppIpNsTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52), ) if mibBuilder.loadTexts: mlpppIpNsTable.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsTable.setDescription('A table containing status parameters about each MLPPP module layer PPP IP Network Control Protocol.') mlpppIpNsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1), ).setIndexNames((0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNsLSapNumber"), (0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNsNumber")) if mibBuilder.loadTexts: mlpppIpNsEntry.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsEntry.setDescription('Status parameters for a specific PPP IP Network Control Protocol.') mlpppIpNsLSapNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 1), SapIndex()).setMaxAccess("readonly") if mibBuilder.loadTexts: mlpppIpNsLSapNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsLSapNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1-10 Default Value: none') mlpppIpNsNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mlpppIpNsNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1 Default Value: none') mlpppIpNsLocalToRemoteComp = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 40), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("vj-tcp", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mlpppIpNsLocalToRemoteComp.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsLocalToRemoteComp.setDescription("Identifies whether the local end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the remote. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default Value: None") mlpppIpNsRemoteToLocalComp = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 41), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("vj-tcp", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mlpppIpNsRemoteToLocalComp.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsRemoteToLocalComp.setDescription("Identifies whether the remote end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the local end. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default value: None") mlpppIpNcTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53), ) if mibBuilder.loadTexts: mlpppIpNcTable.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcTable.setDescription("A table containing configuration parameters about each MLPPP module layer's PPP IP Network Control Protocol.") mlpppIpNcEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1), ).setIndexNames((0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNcUSapNumber"), (0, "CXMLPPP-IP-NCP-MIB", "mlpppIpNcNumber")) if mibBuilder.loadTexts: mlpppIpNcEntry.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcEntry.setDescription('The configuration parameters for a specific PPP IP Network Control Protocol.') mlpppIpNcUSapNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 1), SapIndex()).setMaxAccess("readonly") if mibBuilder.loadTexts: mlpppIpNcUSapNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcUSapNumber.setDescription('Indicates the row containing objects for monitoring a SAP that is associated with one of the MLPPP links . Range of Values: 1-10 Default Value: none') mlpppIpNcNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mlpppIpNcNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcNumber.setDescription('Indicates the row containing objects for monitoring a SAP associated with one of the MLPPP links. Range of Values: 1 Default Value: none') mlpppIpNcComp = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("vj-tcp", 2))).clone('none')).setMaxAccess("readwrite") if mibBuilder.loadTexts: mlpppIpNcComp.setReference('Section 4.0, Van Jacobson TCP/IP Header Compression of RFC1332.') if mibBuilder.loadTexts: mlpppIpNcComp.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcComp.setDescription('Determines whether the local end of PPP link wants to use TCP/IP header compression (vj-tcp) to send packets over the link. If header compression is desired, the local will negotiate for its implementation with the remote end of the link. The result of the negotiation is displayed in mlpppIpNsLocalToRemoteComp (the local) and mlpppIpNsRemoteToLocalComp (remote). If compression is not desired, there will be no attempt to negotiate with the other end of the link. Options: none (1) vj-tcp (2): header compression Default Value: none Configuration Changed: administrative') mibBuilder.exportSymbols("CXMLPPP-IP-NCP-MIB", mlpppIpNsRemoteToLocalComp=mlpppIpNsRemoteToLocalComp, mlpppIpNcNumber=mlpppIpNcNumber, mlpppIpNsTable=mlpppIpNsTable, mlpppIpNcEntry=mlpppIpNcEntry, mlpppIpNsNumber=mlpppIpNsNumber, mlpppIpNsLocalToRemoteComp=mlpppIpNsLocalToRemoteComp, mlpppIpNcTable=mlpppIpNcTable, mlpppIpNsLSapNumber=mlpppIpNsLSapNumber, mlpppIpNcUSapNumber=mlpppIpNcUSapNumber, mlpppIpNsEntry=mlpppIpNsEntry, mlpppIpNcComp=mlpppIpNcComp)
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_intersection, constraints_union, value_size_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'ValueSizeConstraint', 'ValueRangeConstraint') (cx_mlppp, sap_index) = mibBuilder.importSymbols('CXProduct-SMI', 'cxMLPPP', 'SapIndex') (module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup') (integer32, unsigned32, mib_identifier, gauge32, object_identity, ip_address, time_ticks, counter64, module_identity, bits, notification_type, mib_scalar, mib_table, mib_table_row, mib_table_column, counter32, iso) = mibBuilder.importSymbols('SNMPv2-SMI', 'Integer32', 'Unsigned32', 'MibIdentifier', 'Gauge32', 'ObjectIdentity', 'IpAddress', 'TimeTicks', 'Counter64', 'ModuleIdentity', 'Bits', 'NotificationType', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter32', 'iso') (display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention') mlppp_ip_ns_table = mib_table((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52)) if mibBuilder.loadTexts: mlpppIpNsTable.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsTable.setDescription('A table containing status parameters about each MLPPP module layer PPP IP Network Control Protocol.') mlppp_ip_ns_entry = mib_table_row((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1)).setIndexNames((0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNsLSapNumber'), (0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNsNumber')) if mibBuilder.loadTexts: mlpppIpNsEntry.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsEntry.setDescription('Status parameters for a specific PPP IP Network Control Protocol.') mlppp_ip_ns_l_sap_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 1), sap_index()).setMaxAccess('readonly') if mibBuilder.loadTexts: mlpppIpNsLSapNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsLSapNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1-10 Default Value: none') mlppp_ip_ns_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mlpppIpNsNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsNumber.setDescription('Indicates the row that contains objects for monitoring a SAP that is associated with one of the PPP links. Range of Values: 1 Default Value: none') mlppp_ip_ns_local_to_remote_comp = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 40), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('vj-tcp', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: mlpppIpNsLocalToRemoteComp.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsLocalToRemoteComp.setDescription("Identifies whether the local end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the remote. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default Value: None") mlppp_ip_ns_remote_to_local_comp = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 52, 1, 41), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('vj-tcp', 2)))).setMaxAccess('readonly') if mibBuilder.loadTexts: mlpppIpNsRemoteToLocalComp.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNsRemoteToLocalComp.setDescription("Identifies whether the remote end of the IP-PPP link is using TCP/IP header compression (vj-tcp) to send packets to the local end. The value of this object is determined when the PPP configuration is negotiated. The local port's preference for header compression is determined using mlpppIpNcComp of mlpppIpNcTable. Options: none (1) vj-tcp (2): header compression Default value: None") mlppp_ip_nc_table = mib_table((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53)) if mibBuilder.loadTexts: mlpppIpNcTable.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcTable.setDescription("A table containing configuration parameters about each MLPPP module layer's PPP IP Network Control Protocol.") mlppp_ip_nc_entry = mib_table_row((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1)).setIndexNames((0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNcUSapNumber'), (0, 'CXMLPPP-IP-NCP-MIB', 'mlpppIpNcNumber')) if mibBuilder.loadTexts: mlpppIpNcEntry.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcEntry.setDescription('The configuration parameters for a specific PPP IP Network Control Protocol.') mlppp_ip_nc_u_sap_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 1), sap_index()).setMaxAccess('readonly') if mibBuilder.loadTexts: mlpppIpNcUSapNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcUSapNumber.setDescription('Indicates the row containing objects for monitoring a SAP that is associated with one of the MLPPP links . Range of Values: 1-10 Default Value: none') mlppp_ip_nc_number = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 2), integer32()).setMaxAccess('readonly') if mibBuilder.loadTexts: mlpppIpNcNumber.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcNumber.setDescription('Indicates the row containing objects for monitoring a SAP associated with one of the MLPPP links. Range of Values: 1 Default Value: none') mlppp_ip_nc_comp = mib_table_column((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 49, 53, 1, 10), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('vj-tcp', 2))).clone('none')).setMaxAccess('readwrite') if mibBuilder.loadTexts: mlpppIpNcComp.setReference('Section 4.0, Van Jacobson TCP/IP Header Compression of RFC1332.') if mibBuilder.loadTexts: mlpppIpNcComp.setStatus('mandatory') if mibBuilder.loadTexts: mlpppIpNcComp.setDescription('Determines whether the local end of PPP link wants to use TCP/IP header compression (vj-tcp) to send packets over the link. If header compression is desired, the local will negotiate for its implementation with the remote end of the link. The result of the negotiation is displayed in mlpppIpNsLocalToRemoteComp (the local) and mlpppIpNsRemoteToLocalComp (remote). If compression is not desired, there will be no attempt to negotiate with the other end of the link. Options: none (1) vj-tcp (2): header compression Default Value: none Configuration Changed: administrative') mibBuilder.exportSymbols('CXMLPPP-IP-NCP-MIB', mlpppIpNsRemoteToLocalComp=mlpppIpNsRemoteToLocalComp, mlpppIpNcNumber=mlpppIpNcNumber, mlpppIpNsTable=mlpppIpNsTable, mlpppIpNcEntry=mlpppIpNcEntry, mlpppIpNsNumber=mlpppIpNsNumber, mlpppIpNsLocalToRemoteComp=mlpppIpNsLocalToRemoteComp, mlpppIpNcTable=mlpppIpNcTable, mlpppIpNsLSapNumber=mlpppIpNsLSapNumber, mlpppIpNcUSapNumber=mlpppIpNcUSapNumber, mlpppIpNsEntry=mlpppIpNsEntry, mlpppIpNcComp=mlpppIpNcComp)
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: Level order in a list of lists of integers """ def levelOrder(self, root): # write your code here if root is None: return [] res, q_lvl = [], [root] while q_lvl != []: pre, tmp = [], [] for node in q_lvl: pre.append(node.val) l, r = node.left, node.right if l: tmp.append(l) if r: tmp.append(r) res.append(pre) q_lvl = tmp return res
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of binary tree. @return: Level order in a list of lists of integers """ def level_order(self, root): if root is None: return [] (res, q_lvl) = ([], [root]) while q_lvl != []: (pre, tmp) = ([], []) for node in q_lvl: pre.append(node.val) (l, r) = (node.left, node.right) if l: tmp.append(l) if r: tmp.append(r) res.append(pre) q_lvl = tmp return res
def B(): n = int(input()) a = [int(x) for x in input().split()] d = {i:[] for i in range(1,n+1)} d[0]= [0,0] for i in range(2*n): d[a[i]].append(i) ans = 0 for i in range(n): a , b = d[i] , d[i+1] ans+= min(abs(b[0]-a[0])+abs(b[1]-a[1]) , abs(b[0]-a[1])+abs(b[1]-a[0])) print(ans) B()
def b(): n = int(input()) a = [int(x) for x in input().split()] d = {i: [] for i in range(1, n + 1)} d[0] = [0, 0] for i in range(2 * n): d[a[i]].append(i) ans = 0 for i in range(n): (a, b) = (d[i], d[i + 1]) ans += min(abs(b[0] - a[0]) + abs(b[1] - a[1]), abs(b[0] - a[1]) + abs(b[1] - a[0])) print(ans) b()
# Given a linked list, return the node where the cycle begins. If there is no cycle, return null. # To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is no cycle in the linked list. # Note: Do not modify the linked list. # Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None # NOTE: This solution has O(n) space complexity. Jose Portilla and leetcode solutions use two pointers # to solve this in O(1) space. In interview setting, if I give this answer, they may ask to optimize it, # during which leetcode soln. could be useful. class Solution(object): def detectCycle(self, head): """ :type head: ListNode :rtype: ListNode """ seen = set() cur = head while cur: if cur in seen: return cur seen.add(cur) cur = cur.next return None
class Solution(object): def detect_cycle(self, head): """ :type head: ListNode :rtype: ListNode """ seen = set() cur = head while cur: if cur in seen: return cur seen.add(cur) cur = cur.next return None
line_items = [{ "invNumber": 100, "lineNumber": 1, "partNumber": "TU100", "description": "TacUmbrella", "price": 9.99 }, { "invNumber": 100, "lineNumber": 2, "partNumber": "TLB9000", "description": "TacLunchbox 9000", "price": 19.99 }, { "invNumber": 101, "lineNumber": 1, "partNumber": "TPJ5", "description": "TacPajamas", "price": 99.99 }] def main(event, context): print(f'event: {event}') source = event['source'] return list(filter(lambda line_item: line_item['invNumber'] == source['invNumber'], line_items)) # Test # e = {"source": {"invNumber": 100}} # print(main(e, None))
line_items = [{'invNumber': 100, 'lineNumber': 1, 'partNumber': 'TU100', 'description': 'TacUmbrella', 'price': 9.99}, {'invNumber': 100, 'lineNumber': 2, 'partNumber': 'TLB9000', 'description': 'TacLunchbox 9000', 'price': 19.99}, {'invNumber': 101, 'lineNumber': 1, 'partNumber': 'TPJ5', 'description': 'TacPajamas', 'price': 99.99}] def main(event, context): print(f'event: {event}') source = event['source'] return list(filter(lambda line_item: line_item['invNumber'] == source['invNumber'], line_items))
class ResizeError(Exception): pass def codelengths_from_frequencies(freqs): freqs = sorted(freqs.items(), key=lambda item: (item[1], -item[0]), reverse=True) nodes = [Node(char=key, weight=value) for (key, value) in freqs] while len(nodes) > 1: right, left = nodes.pop(), nodes.pop() node = Node(weight=right.weight + left.weight) node.add([left, right]) if not nodes: nodes.append(node) else: pos = 0 while pos < len(nodes) and nodes[pos].weight > node.weight: pos += 1 nodes.insert(pos, node) top = nodes[0] tree = Tree(top) tree.reduce(15) codes = tree.codes() code_items = list(codes.items()) code_items.sort(key=lambda item:(len(item[1]), item[0])) return [(car, len(value)) for car, value in code_items] def normalized(codelengths): car, codelength = codelengths[0] value = 0 codes = {car: "0" * codelength} for (newcar, nbits) in codelengths[1:]: value += 1 bvalue = str(bin(value))[2:] bvalue = "0" * (codelength - len(bvalue)) + bvalue if nbits > codelength: codelength = nbits bvalue += "0" * (codelength - len(bvalue)) value = int(bvalue, 2) assert len(bvalue) == nbits codes[newcar] = bvalue return codes class Tree: def __init__(self, root): self.root = root self.nb_levels = 0 def length(self): self.root.level = 0 node = self.root nb_levels = 0 def set_level(node): nonlocal nb_levels for child in node.children: child.level = node.level + 1 nb_levels = max(nb_levels, child.level) if not child.is_leaf: set_level(child) set_level(self.root) return nb_levels def reduce_tree(self): """Change the tree to reduce the number of levels. Uses the algorithm described in http://compressions.sourceforge.net/Huffman.html#3 """ currentlen = self.length() deepest = self.nodes_at(currentlen) deepest_leaves = [node for node in deepest if node.is_leaf] rightmost_leaf = deepest_leaves[-1] sibling = rightmost_leaf.parent.children[0] # replace rightmost_leaf's parent by rightmost_leaf parent = rightmost_leaf.parent grand_parent = parent.parent rank = grand_parent.children.index(parent) children = grand_parent.children children[rank] = rightmost_leaf grand_parent.add(children) # find first upper level with leaves up_level = rightmost_leaf.level - 2 while up_level > 0: nodes = self.nodes_at(up_level) leaf_nodes = [node for node in nodes if node.is_leaf] if leaf_nodes: leftmost_leaf = leaf_nodes[0] # replace by node with leaves = [sibling, leftmost_leaf] parent = leftmost_leaf.parent rank = parent.children.index(leftmost_leaf) new_node = Node() new_node.level = leftmost_leaf.level children = [sibling, leftmost_leaf] new_node.add(children) parent.children[rank] = new_node new_node.parent = parent break else: up_level -= 1 if up_level == 0: raise ResizeError def nodes_at(self, level, top=None): """Return list of all the nodes below top at specified level.""" res = [] if top is None: top = self.root if top.level == level: res = [top] elif not top.is_leaf: for child in top.children: res += self.nodes_at(level, child) return res def reduce(self, maxlevels): """Reduce number of levels to maxlevels, if possible.""" while self.length() > maxlevels: self.reduce_tree() def codes(self, node=None, code=''): """Returns a dictionary mapping leaf characters to the Huffman code of the node, as a string of 0's and 1's.""" if node is None: self.dic = {} node = self.root if node.is_leaf: self.dic[node.char] = code else: for i, child in enumerate(node.children): self.codes(child, code + str(i)) return self.dic class Node: def __init__(self, char=None, weight=0, level=0): self.char = char self.is_leaf = char is not None self.level = level self.weight = weight self.height = 0 def add(self, children): self.children = children for child in self.children: child.parent = self child.level = self.level + 1 self.height = max(self.height, children[0].height + 1, children[1].height + 1) node = self while hasattr(node, "parent"): node.parent.height = max(node.parent.height, node.height + 1) node = node.parent def __repr__(self): if self.is_leaf: return f'{chr(self.char)!r}' else: return f'{self.children}' class Compresser: def __init__(self, text): if not isinstance(text, (bytes, bytearray, memoryview)): raise TypeError("a bytes-like object is required, not '" + type(text).__name__ + "'") self.text = text freqs = {} for car in self.text: freqs[car] = freqs.get(car, 0) + 1 self.codelengths = codelengths_from_frequencies(freqs) self.codes = normalized(self.codelengths) self.max_codelength = max(len(v) for v in self.codes.values()) def compressed_bytes(self): compressed = self.compressed_str() + self.codes[256] out = bytearray() pos = 0 while pos < len(compressed): bits = compressed[pos:pos + 8] byte = int(bits, 2) if len(bits) < 8: byte <<= (8 - len(bits)) out.append(byte) pos += 8 return out def compressed_str(self): return ''.join(self.codes[car] for car in self.text) class Decompresser: def __init__(self, compressed, codelengths): self.compressed = compressed codes = normalized(codelengths) self.codes = {value : key for key, value in codes.items()} self.root = Node() self.make_tree(self.root) def make_tree(self, node): if node is self.root: node.code = '' children = [] for bit in '01': next_code = node.code + bit if next_code in self.codes: child = Node(char=self.codes[next_code]) else: child = Node() child.code = next_code children.append(child) node.add(children) for child in children: if not child.is_leaf: self.make_tree(child) def decompress(self): source = self.compressed if isinstance(source, (bytes, bytearray)): return self.decompress_bytes() pos = 0 node = self.root res = bytearray() while pos < len(source): code = int(source[pos]) child = node.children[code] if child.is_leaf: res.append(child) node = self.root else: node = child pos += 1 return bytes(res) def decompress_bytes(self): source = self.compressed pos = 0 node = self.root res = bytearray() while pos < len(source): byte = source[pos] mask = 128 while mask > 0: code = bool(byte & mask) child = node.children[code] if child.is_leaf: if child.char == 256: break # end of block res.append(child.char) node = self.root else: node = child mask >>= 1 pos += 1 return res def compress(text, klass=bytes): compr = Compresser(text) result = {"codelengths": compr.codelengths} if klass is bytes: result["data"] = compr.compressed_bytes() elif klass is str: result["data"] = compr.compressed_str() else: raise TypeError("second argument of compress must be bytes or " "str, not '{}'".format(klass)) return result def decompress(data, codelengths): decomp = Decompresser(data, codelengths) return decomp.decompress()
class Resizeerror(Exception): pass def codelengths_from_frequencies(freqs): freqs = sorted(freqs.items(), key=lambda item: (item[1], -item[0]), reverse=True) nodes = [node(char=key, weight=value) for (key, value) in freqs] while len(nodes) > 1: (right, left) = (nodes.pop(), nodes.pop()) node = node(weight=right.weight + left.weight) node.add([left, right]) if not nodes: nodes.append(node) else: pos = 0 while pos < len(nodes) and nodes[pos].weight > node.weight: pos += 1 nodes.insert(pos, node) top = nodes[0] tree = tree(top) tree.reduce(15) codes = tree.codes() code_items = list(codes.items()) code_items.sort(key=lambda item: (len(item[1]), item[0])) return [(car, len(value)) for (car, value) in code_items] def normalized(codelengths): (car, codelength) = codelengths[0] value = 0 codes = {car: '0' * codelength} for (newcar, nbits) in codelengths[1:]: value += 1 bvalue = str(bin(value))[2:] bvalue = '0' * (codelength - len(bvalue)) + bvalue if nbits > codelength: codelength = nbits bvalue += '0' * (codelength - len(bvalue)) value = int(bvalue, 2) assert len(bvalue) == nbits codes[newcar] = bvalue return codes class Tree: def __init__(self, root): self.root = root self.nb_levels = 0 def length(self): self.root.level = 0 node = self.root nb_levels = 0 def set_level(node): nonlocal nb_levels for child in node.children: child.level = node.level + 1 nb_levels = max(nb_levels, child.level) if not child.is_leaf: set_level(child) set_level(self.root) return nb_levels def reduce_tree(self): """Change the tree to reduce the number of levels. Uses the algorithm described in http://compressions.sourceforge.net/Huffman.html#3 """ currentlen = self.length() deepest = self.nodes_at(currentlen) deepest_leaves = [node for node in deepest if node.is_leaf] rightmost_leaf = deepest_leaves[-1] sibling = rightmost_leaf.parent.children[0] parent = rightmost_leaf.parent grand_parent = parent.parent rank = grand_parent.children.index(parent) children = grand_parent.children children[rank] = rightmost_leaf grand_parent.add(children) up_level = rightmost_leaf.level - 2 while up_level > 0: nodes = self.nodes_at(up_level) leaf_nodes = [node for node in nodes if node.is_leaf] if leaf_nodes: leftmost_leaf = leaf_nodes[0] parent = leftmost_leaf.parent rank = parent.children.index(leftmost_leaf) new_node = node() new_node.level = leftmost_leaf.level children = [sibling, leftmost_leaf] new_node.add(children) parent.children[rank] = new_node new_node.parent = parent break else: up_level -= 1 if up_level == 0: raise ResizeError def nodes_at(self, level, top=None): """Return list of all the nodes below top at specified level.""" res = [] if top is None: top = self.root if top.level == level: res = [top] elif not top.is_leaf: for child in top.children: res += self.nodes_at(level, child) return res def reduce(self, maxlevels): """Reduce number of levels to maxlevels, if possible.""" while self.length() > maxlevels: self.reduce_tree() def codes(self, node=None, code=''): """Returns a dictionary mapping leaf characters to the Huffman code of the node, as a string of 0's and 1's.""" if node is None: self.dic = {} node = self.root if node.is_leaf: self.dic[node.char] = code else: for (i, child) in enumerate(node.children): self.codes(child, code + str(i)) return self.dic class Node: def __init__(self, char=None, weight=0, level=0): self.char = char self.is_leaf = char is not None self.level = level self.weight = weight self.height = 0 def add(self, children): self.children = children for child in self.children: child.parent = self child.level = self.level + 1 self.height = max(self.height, children[0].height + 1, children[1].height + 1) node = self while hasattr(node, 'parent'): node.parent.height = max(node.parent.height, node.height + 1) node = node.parent def __repr__(self): if self.is_leaf: return f'{chr(self.char)!r}' else: return f'{self.children}' class Compresser: def __init__(self, text): if not isinstance(text, (bytes, bytearray, memoryview)): raise type_error("a bytes-like object is required, not '" + type(text).__name__ + "'") self.text = text freqs = {} for car in self.text: freqs[car] = freqs.get(car, 0) + 1 self.codelengths = codelengths_from_frequencies(freqs) self.codes = normalized(self.codelengths) self.max_codelength = max((len(v) for v in self.codes.values())) def compressed_bytes(self): compressed = self.compressed_str() + self.codes[256] out = bytearray() pos = 0 while pos < len(compressed): bits = compressed[pos:pos + 8] byte = int(bits, 2) if len(bits) < 8: byte <<= 8 - len(bits) out.append(byte) pos += 8 return out def compressed_str(self): return ''.join((self.codes[car] for car in self.text)) class Decompresser: def __init__(self, compressed, codelengths): self.compressed = compressed codes = normalized(codelengths) self.codes = {value: key for (key, value) in codes.items()} self.root = node() self.make_tree(self.root) def make_tree(self, node): if node is self.root: node.code = '' children = [] for bit in '01': next_code = node.code + bit if next_code in self.codes: child = node(char=self.codes[next_code]) else: child = node() child.code = next_code children.append(child) node.add(children) for child in children: if not child.is_leaf: self.make_tree(child) def decompress(self): source = self.compressed if isinstance(source, (bytes, bytearray)): return self.decompress_bytes() pos = 0 node = self.root res = bytearray() while pos < len(source): code = int(source[pos]) child = node.children[code] if child.is_leaf: res.append(child) node = self.root else: node = child pos += 1 return bytes(res) def decompress_bytes(self): source = self.compressed pos = 0 node = self.root res = bytearray() while pos < len(source): byte = source[pos] mask = 128 while mask > 0: code = bool(byte & mask) child = node.children[code] if child.is_leaf: if child.char == 256: break res.append(child.char) node = self.root else: node = child mask >>= 1 pos += 1 return res def compress(text, klass=bytes): compr = compresser(text) result = {'codelengths': compr.codelengths} if klass is bytes: result['data'] = compr.compressed_bytes() elif klass is str: result['data'] = compr.compressed_str() else: raise type_error("second argument of compress must be bytes or str, not '{}'".format(klass)) return result def decompress(data, codelengths): decomp = decompresser(data, codelengths) return decomp.decompress()
class ContentTransformer: def transform(content): raise NotImplementedError() @classmethod def from_siteinfo(cls, siteinfo, *args, **kwargs): raise NotImplementedError()
class Contenttransformer: def transform(content): raise not_implemented_error() @classmethod def from_siteinfo(cls, siteinfo, *args, **kwargs): raise not_implemented_error()
ports_assignment = { "rs1_rs2" : 6004, "rs1_receive_bgp_messages" : 6000 , "rs1_send_mpc_output" : 6001 , "worker_port" : 7760, "rs2_receive_bgp_messages" : 6002, "rs2_send_mpc_output" : 6003, "rs1-preference-channel" : 6005, "rs2-preference-channel" : 6006} #process_assignement = {"rs1" : '192.168.102.2',"rs2" : '192.168.102.8'} process_assignement = {"rs1" : 'localhost',"rs2" : 'localhost'}
ports_assignment = {'rs1_rs2': 6004, 'rs1_receive_bgp_messages': 6000, 'rs1_send_mpc_output': 6001, 'worker_port': 7760, 'rs2_receive_bgp_messages': 6002, 'rs2_send_mpc_output': 6003, 'rs1-preference-channel': 6005, 'rs2-preference-channel': 6006} process_assignement = {'rs1': 'localhost', 'rs2': 'localhost'}
# DAN KABAGAMBE # TUMUSIIME FRANCIS # NAKUYA SHAKIRAH HADIJJAH total = 0 count = 0 smallest = None largest = None # Finding the largest and smallest while True: a = input('Enter a number:') try: a = int(a) count = count + 1 total = total + a if smallest is None: smallest = a else: if a < smallest: smallest = a if largest is None: largest = a else: if a > largest: largest = a except: if a == 'done': print(total) print(count) print('smallest:' , smallest) print("largest:", largest) break else: print('Invalid input') continue
total = 0 count = 0 smallest = None largest = None while True: a = input('Enter a number:') try: a = int(a) count = count + 1 total = total + a if smallest is None: smallest = a elif a < smallest: smallest = a if largest is None: largest = a elif a > largest: largest = a except: if a == 'done': print(total) print(count) print('smallest:', smallest) print('largest:', largest) break else: print('Invalid input') continue
DASHBOARD = 'mydashboard' DISABLED = False ADD_INSTALLED_APPS = [ 'openstack_dashboard.dashboards.mydashboard', ]
dashboard = 'mydashboard' disabled = False add_installed_apps = ['openstack_dashboard.dashboards.mydashboard']
def test13(a, b): """Test for Docstring""" a.b[1] ziffern = "0123456789" ziffern[a:b]
def test13(a, b): """Test for Docstring""" a.b[1] ziffern = '0123456789' ziffern[a:b]
"""" Entradas Valor_c--> float--> C Salidas Descuento --> float -->desc """ C=float(input("Digite el valor de la compra: ")) desc=(C*0.15) #cajanegra toaltal=(C-desc) #Salida print("El total a pagar es: "+str(toaltal))
"""" Entradas Valor_c--> float--> C Salidas Descuento --> float -->desc """ c = float(input('Digite el valor de la compra: ')) desc = C * 0.15 toaltal = C - desc print('El total a pagar es: ' + str(toaltal))
class Status: CANCELED = "CANCELED" DECOMPRESSING = "DECOMPRESSING" DELETED = "DELETED" FAILED = "FAILED" FREE = "FREE" INITIAL_LOAD = "INITIAL_LOAD" INVALID_FILE = "INVALID_FILE" LOST = "LOST" STAGE = "STAGE" PROCESSING = "PROCESSING" RUNNING = "RUNNING" SUCCEEDED = "SUCCEEDED" STOPPED = "STOPPED" TIMEOUT = "TIMEOUT" WAITING = "WAITING"
class Status: canceled = 'CANCELED' decompressing = 'DECOMPRESSING' deleted = 'DELETED' failed = 'FAILED' free = 'FREE' initial_load = 'INITIAL_LOAD' invalid_file = 'INVALID_FILE' lost = 'LOST' stage = 'STAGE' processing = 'PROCESSING' running = 'RUNNING' succeeded = 'SUCCEEDED' stopped = 'STOPPED' timeout = 'TIMEOUT' waiting = 'WAITING'
# -*- coding: utf-8 -*- def test_del_first_contact(app): app.session.login(username = "admin", password = "secret") app.contact.delete_first_contact() app.session.logout()
def test_del_first_contact(app): app.session.login(username='admin', password='secret') app.contact.delete_first_contact() app.session.logout()
class Person: def __init__(self, params): self.name = params.get('name') self.birth_date = params.get('birth_date') def params_str(self): return "{{name: '{}', birth_date: '{}'}}".format(self.name, self.birth_date)
class Person: def __init__(self, params): self.name = params.get('name') self.birth_date = params.get('birth_date') def params_str(self): return "{{name: '{}', birth_date: '{}'}}".format(self.name, self.birth_date)
def add_native_methods(clazz): def getAll____(a0): raise NotImplementedError() def getByName0__java_lang_String__(a0, a1): raise NotImplementedError() def getByIndex0__int__(a0, a1): raise NotImplementedError() def getByInetAddress0__java_net_InetAddress__(a0, a1): raise NotImplementedError() def isUp0__java_lang_String__int__(a0, a1, a2): raise NotImplementedError() def isLoopback0__java_lang_String__int__(a0, a1, a2): raise NotImplementedError() def supportsMulticast0__java_lang_String__int__(a0, a1, a2): raise NotImplementedError() def isP2P0__java_lang_String__int__(a0, a1, a2): raise NotImplementedError() def getMacAddr0__byte____java_lang_String__int__(a0, a1, a2, a3): raise NotImplementedError() def getMTU0__java_lang_String__int__(a0, a1, a2): raise NotImplementedError() def init____(a0): raise NotImplementedError() clazz.getAll____ = staticmethod(getAll____) clazz.getByName0__java_lang_String__ = staticmethod(getByName0__java_lang_String__) clazz.getByIndex0__int__ = staticmethod(getByIndex0__int__) clazz.getByInetAddress0__java_net_InetAddress__ = staticmethod(getByInetAddress0__java_net_InetAddress__) clazz.isUp0__java_lang_String__int__ = staticmethod(isUp0__java_lang_String__int__) clazz.isLoopback0__java_lang_String__int__ = staticmethod(isLoopback0__java_lang_String__int__) clazz.supportsMulticast0__java_lang_String__int__ = staticmethod(supportsMulticast0__java_lang_String__int__) clazz.isP2P0__java_lang_String__int__ = staticmethod(isP2P0__java_lang_String__int__) clazz.getMacAddr0__byte____java_lang_String__int__ = staticmethod(getMacAddr0__byte____java_lang_String__int__) clazz.getMTU0__java_lang_String__int__ = staticmethod(getMTU0__java_lang_String__int__) clazz.init____ = staticmethod(init____)
def add_native_methods(clazz): def get_all____(a0): raise not_implemented_error() def get_by_name0__java_lang__string__(a0, a1): raise not_implemented_error() def get_by_index0__int__(a0, a1): raise not_implemented_error() def get_by_inet_address0__java_net__inet_address__(a0, a1): raise not_implemented_error() def is_up0__java_lang__string__int__(a0, a1, a2): raise not_implemented_error() def is_loopback0__java_lang__string__int__(a0, a1, a2): raise not_implemented_error() def supports_multicast0__java_lang__string__int__(a0, a1, a2): raise not_implemented_error() def is_p2_p0__java_lang__string__int__(a0, a1, a2): raise not_implemented_error() def get_mac_addr0__byte____java_lang__string__int__(a0, a1, a2, a3): raise not_implemented_error() def get_mtu0__java_lang__string__int__(a0, a1, a2): raise not_implemented_error() def init____(a0): raise not_implemented_error() clazz.getAll____ = staticmethod(getAll____) clazz.getByName0__java_lang_String__ = staticmethod(getByName0__java_lang_String__) clazz.getByIndex0__int__ = staticmethod(getByIndex0__int__) clazz.getByInetAddress0__java_net_InetAddress__ = staticmethod(getByInetAddress0__java_net_InetAddress__) clazz.isUp0__java_lang_String__int__ = staticmethod(isUp0__java_lang_String__int__) clazz.isLoopback0__java_lang_String__int__ = staticmethod(isLoopback0__java_lang_String__int__) clazz.supportsMulticast0__java_lang_String__int__ = staticmethod(supportsMulticast0__java_lang_String__int__) clazz.isP2P0__java_lang_String__int__ = staticmethod(isP2P0__java_lang_String__int__) clazz.getMacAddr0__byte____java_lang_String__int__ = staticmethod(getMacAddr0__byte____java_lang_String__int__) clazz.getMTU0__java_lang_String__int__ = staticmethod(getMTU0__java_lang_String__int__) clazz.init____ = staticmethod(init____)
''' Description: Exercise 3 (for loop) Version: 1.0.0.20210117 Author: Arvin Zhao Date: 2021-01-17 17:46:34 Last Editors: Arvin Zhao LastEditTime: 2021-01-18 10:40:04 ''' direction = input('Which direction do you want to count? (up/down)').strip().lower() if direction == 'up': top = int(input('Enter the top number: ')) for count in range(top): print(count + 1) elif direction == 'down': bottom = int(input('Enter a number below 20: ')) for count in range(20, bottom - 1, -1): print(count) else: print('I don\'t understand.')
""" Description: Exercise 3 (for loop) Version: 1.0.0.20210117 Author: Arvin Zhao Date: 2021-01-17 17:46:34 Last Editors: Arvin Zhao LastEditTime: 2021-01-18 10:40:04 """ direction = input('Which direction do you want to count? (up/down)').strip().lower() if direction == 'up': top = int(input('Enter the top number: ')) for count in range(top): print(count + 1) elif direction == 'down': bottom = int(input('Enter a number below 20: ')) for count in range(20, bottom - 1, -1): print(count) else: print("I don't understand.")
#!/usr/bin/env python # -*- coding: utf-8 -*- def colorText(txt='', fgColor='', fgLine='', bgColor='', ): txtColor = '' if (fgLine != ''): txtColor += '\033[4m' if (fgColor == 'black'): txtColor += '\033[30m' elif (fgColor == 'red'): txtColor += '\033[31m' elif (fgColor == 'green'): txtColor += '\033[32m' elif (fgColor == 'yellow'): txtColor += '\033[33m' elif (fgColor == 'blue'): txtColor += '\033[34m' elif (fgColor == 'magenta'): txtColor += '\033[35m' elif (fgColor == 'cyan'): txtColor += '\033[36m' elif (fgColor == 'white'): txtColor += '\033[37m' if (bgColor == 'black'): txtColor += '\033[40m' elif (bgColor == 'red'): txtColor += '\033[41m' elif (bgColor == 'green'): txtColor += '\033[42m' elif (bgColor == 'yellow'): txtColor += '\033[43m' elif (bgColor == 'blue'): txtColor += '\033[44m' elif (bgColor == 'magenta'): txtColor += '\033[45m' elif (bgColor == 'cyan'): txtColor += '\033[46m' elif (bgColor == 'white'): txtColor += '\033[47m' resetColor = '' if (txtColor != ''): resetColor = '\033[0m' return txtColor + str(txt) + resetColor if __name__ == '__main__': fgColor='white' bgColor='black' txt = colorText('white', fgColor=fgColor, bgColor=bgColor, ) print(txt) fgColor='red' bgColor='green' txt = colorText('red/green', fgColor=fgColor, bgColor=bgColor, ) print(txt) fgColor='cyan' bgColor='' txt = colorText('cyan/line', fgColor=fgColor, fgLine='yes', bgColor=bgColor, ) print(txt) fgColor='' bgColor='' txt = colorText('normal', fgColor=fgColor, bgColor=bgColor, ) print(txt)
def color_text(txt='', fgColor='', fgLine='', bgColor=''): txt_color = '' if fgLine != '': txt_color += '\x1b[4m' if fgColor == 'black': txt_color += '\x1b[30m' elif fgColor == 'red': txt_color += '\x1b[31m' elif fgColor == 'green': txt_color += '\x1b[32m' elif fgColor == 'yellow': txt_color += '\x1b[33m' elif fgColor == 'blue': txt_color += '\x1b[34m' elif fgColor == 'magenta': txt_color += '\x1b[35m' elif fgColor == 'cyan': txt_color += '\x1b[36m' elif fgColor == 'white': txt_color += '\x1b[37m' if bgColor == 'black': txt_color += '\x1b[40m' elif bgColor == 'red': txt_color += '\x1b[41m' elif bgColor == 'green': txt_color += '\x1b[42m' elif bgColor == 'yellow': txt_color += '\x1b[43m' elif bgColor == 'blue': txt_color += '\x1b[44m' elif bgColor == 'magenta': txt_color += '\x1b[45m' elif bgColor == 'cyan': txt_color += '\x1b[46m' elif bgColor == 'white': txt_color += '\x1b[47m' reset_color = '' if txtColor != '': reset_color = '\x1b[0m' return txtColor + str(txt) + resetColor if __name__ == '__main__': fg_color = 'white' bg_color = 'black' txt = color_text('white', fgColor=fgColor, bgColor=bgColor) print(txt) fg_color = 'red' bg_color = 'green' txt = color_text('red/green', fgColor=fgColor, bgColor=bgColor) print(txt) fg_color = 'cyan' bg_color = '' txt = color_text('cyan/line', fgColor=fgColor, fgLine='yes', bgColor=bgColor) print(txt) fg_color = '' bg_color = '' txt = color_text('normal', fgColor=fgColor, bgColor=bgColor) print(txt)
type_dict = { "[INFO]": "info", "[WARNING]": "warning", "[ERROR]": "error", "[DEBUG]": "debug", "START": "start", "REPORT": "report", "END": "end", "DEBUG": "debug", } style_dict = { "error": "bold red", "start": "green", "report": "dim yellow", "debug": "bold blue", "warning": "yellow", "info": "yellow", "end": "cyan", } OTHER_TYPE = "debug"
type_dict = {'[INFO]': 'info', '[WARNING]': 'warning', '[ERROR]': 'error', '[DEBUG]': 'debug', 'START': 'start', 'REPORT': 'report', 'END': 'end', 'DEBUG': 'debug'} style_dict = {'error': 'bold red', 'start': 'green', 'report': 'dim yellow', 'debug': 'bold blue', 'warning': 'yellow', 'info': 'yellow', 'end': 'cyan'} other_type = 'debug'