content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
''' Reversed Queue Write a function that takes a queue as an input and returns a reversed version of it. ''' # Solution class LinkedListNode: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.num_elements = 0 self.head = None def push(self, data): new_node = LinkedListNode(data) if self.head is None: self.head = new_node else: new_node.next = self.head self.head = new_node self.num_elements += 1 def pop(self): if self.is_empty(): return None temp = self.head.data self.head = self.head.next self.num_elements -= 1 return temp def top(self): if self.head is None: return None return self.head.data def size(self): return self.num_elements def is_empty(self): return self.num_elements == 0 class Queue: def __init__(self): self.head = None self.tail = None self.num_elements = 0 def enqueue(self, data): new_node = LinkedListNode(data) if self.head is None: self.head = new_node self.tail = new_node else: self.tail.next = new_node self.tail = new_node self.num_elements += 1 def dequeue(self): if self.is_empty(): return None temp = self.head.data self.head = self.head.next self.num_elements -= 1 return temp def front(self): if self.head is None: return None return self.head.data def size(self): return self.num_elements def is_empty(self): return self.num_elements == 0 def reverse_queue(queue): stack = Stack() while not queue.is_empty(): stack.push(queue.dequeue()) while not stack.is_empty(): queue.enqueue(stack.pop()) def test_function(test_case): queue = Queue() for num in test_case: queue.enqueue(num) reverse_queue(queue) index = len(test_case) - 1 while not queue.is_empty(): removed = queue.dequeue() if removed != test_case[index]: print("Fail") return else: index -= 1 print("Pass") test_case_1 = [1, 2, 3, 4] test_function(test_case_1) test_case_2 = [1] test_function(test_case_2) # or just use 2 queues and dequeue the first and enqueue it in the other one # https://youtu.be/l_tnEtFCXnc
""" Reversed Queue Write a function that takes a queue as an input and returns a reversed version of it. """ class Linkedlistnode: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.num_elements = 0 self.head = None def push(self, data): new_node = linked_list_node(data) if self.head is None: self.head = new_node else: new_node.next = self.head self.head = new_node self.num_elements += 1 def pop(self): if self.is_empty(): return None temp = self.head.data self.head = self.head.next self.num_elements -= 1 return temp def top(self): if self.head is None: return None return self.head.data def size(self): return self.num_elements def is_empty(self): return self.num_elements == 0 class Queue: def __init__(self): self.head = None self.tail = None self.num_elements = 0 def enqueue(self, data): new_node = linked_list_node(data) if self.head is None: self.head = new_node self.tail = new_node else: self.tail.next = new_node self.tail = new_node self.num_elements += 1 def dequeue(self): if self.is_empty(): return None temp = self.head.data self.head = self.head.next self.num_elements -= 1 return temp def front(self): if self.head is None: return None return self.head.data def size(self): return self.num_elements def is_empty(self): return self.num_elements == 0 def reverse_queue(queue): stack = stack() while not queue.is_empty(): stack.push(queue.dequeue()) while not stack.is_empty(): queue.enqueue(stack.pop()) def test_function(test_case): queue = queue() for num in test_case: queue.enqueue(num) reverse_queue(queue) index = len(test_case) - 1 while not queue.is_empty(): removed = queue.dequeue() if removed != test_case[index]: print('Fail') return else: index -= 1 print('Pass') test_case_1 = [1, 2, 3, 4] test_function(test_case_1) test_case_2 = [1] test_function(test_case_2)
class Solution: def maximalSquare(self, matrix): if not matrix: return 0 row = [0] * len(matrix[0]) res = 0 for i in xrange(len(matrix)): top_left = 0 for j in xrange(len(matrix[i])): if matrix[i][j] == "0": top_left = row[j] row[j] = 0 else: val = min(row[j], row[j - 1] if j > 0 else 0, top_left) + 1 top_left = row[j] row[j] = val res = max(res, row[j]) return res ** 2
class Solution: def maximal_square(self, matrix): if not matrix: return 0 row = [0] * len(matrix[0]) res = 0 for i in xrange(len(matrix)): top_left = 0 for j in xrange(len(matrix[i])): if matrix[i][j] == '0': top_left = row[j] row[j] = 0 else: val = min(row[j], row[j - 1] if j > 0 else 0, top_left) + 1 top_left = row[j] row[j] = val res = max(res, row[j]) return res ** 2
class Ring: """Parent class/interface for all rings to inherit from""" def __init__(self, name, element_type, is_commutative=False): self.name = name self.element_type = element_type self.is_commutative = is_commutative # Stuff we need to implement in child classes def one(self): raise NotImplementedError def zero(self): raise NotImplementedError def __eq__(self, other): raise NotImplementedError # Stuff that just works def coerce(self, x): # passthrough if they are the same type already if type(x) is type(self): return x raise NotImplementedError def __contains__(self, other): return type(other) is self.element_type def __repr__(self): return self.name class RingElement: """Parent class for elements in some ring""" def __init__(self, ring): self.ring = ring # Stuff to implement def __add__(self, other): raise NotImplementedError def __mul__(self, other): raise NotImplementedError def __rmul__(self, other): # multiplication isn't necessarily commutative # only need to implement it if it isn't if self.ring.is_commutative: return self.__mul__(other) raise NotImplementedError def __neg__(self): raise NotImplementedError def __eq__(self, other): raise NotImplementedError def __lt__(self, other): # This is optional if you want the ring to be ordered raise NotImplementedError(f'Ordering not implemented for Ring {self.ring}') # Stuff that just works def __le__(self, other): return self.__eq__(other) or self.__lt__(other) def __gt__(self, other): return not self.__le__(other) def __ge__(self, other): return self.__eq__(other) or self.__gt__(other) def __pow__(self, power): try: a = int(power) except ValueError as err: raise ValueError('Powers of ring elements must be integers.') from err if a < 0: raise ValueError('Power of ring element must be nonnegative.') if a == 0: return self.ring.one() else: # compute recursively return self.__mul__(self.__pow__(a-1)) def __radd__(self, other): # addition is always commutative return self.__add__(other) def __sub__(self, other): # a - b is a + (-b) if type(other) is not type(self): raise TypeError( f'Subtraction not defined for types {type(self)} and {type(other)}' ) return self.__add__(other.__neg__()) def __repr__(self): return f'Element of {self.ring}'
class Ring: """Parent class/interface for all rings to inherit from""" def __init__(self, name, element_type, is_commutative=False): self.name = name self.element_type = element_type self.is_commutative = is_commutative def one(self): raise NotImplementedError def zero(self): raise NotImplementedError def __eq__(self, other): raise NotImplementedError def coerce(self, x): if type(x) is type(self): return x raise NotImplementedError def __contains__(self, other): return type(other) is self.element_type def __repr__(self): return self.name class Ringelement: """Parent class for elements in some ring""" def __init__(self, ring): self.ring = ring def __add__(self, other): raise NotImplementedError def __mul__(self, other): raise NotImplementedError def __rmul__(self, other): if self.ring.is_commutative: return self.__mul__(other) raise NotImplementedError def __neg__(self): raise NotImplementedError def __eq__(self, other): raise NotImplementedError def __lt__(self, other): raise not_implemented_error(f'Ordering not implemented for Ring {self.ring}') def __le__(self, other): return self.__eq__(other) or self.__lt__(other) def __gt__(self, other): return not self.__le__(other) def __ge__(self, other): return self.__eq__(other) or self.__gt__(other) def __pow__(self, power): try: a = int(power) except ValueError as err: raise value_error('Powers of ring elements must be integers.') from err if a < 0: raise value_error('Power of ring element must be nonnegative.') if a == 0: return self.ring.one() else: return self.__mul__(self.__pow__(a - 1)) def __radd__(self, other): return self.__add__(other) def __sub__(self, other): if type(other) is not type(self): raise type_error(f'Subtraction not defined for types {type(self)} and {type(other)}') return self.__add__(other.__neg__()) def __repr__(self): return f'Element of {self.ring}'
optimizer = dict(type='Adam', lr=0.001) optimizer_config = dict(grad_clip=None) lr_config = dict(policy='poly', power=0.9) total_epochs = 5000 checkpoint_config = dict(interval=10) log_config = dict(interval=5, hooks=[dict(type='TextLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] model = dict( type='PANet', backbone=dict( type='mmdet.ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='SyncBN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet18'), norm_eval=True, style='caffe'), neck=dict(type='FPEM_FFM', in_channels=[64, 128, 256, 512]), bbox_head=dict( type='PANHead', text_repr_type='poly', in_channels=[128, 128, 128, 128], out_channels=6, loss=dict(type='PANLoss')), train_cfg=None, test_cfg=None) dataset_type = 'IcdarDataset' data_root = 'data' img_norm_cfg = dict( mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [ dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict( type='LoadTextAnnotations', with_bbox=True, with_mask=True, poly2mask=False), dict(type='ColorJitter', brightness=0.12549019607843137, saturation=0.5), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict( type='ScaleAspectJitter', img_scale=[(3000, 640)], ratio_range=(0.7, 1.3), aspect_ratio_range=(0.9, 1.1), multiscale_mode='value', keep_ratio=False), dict(type='PANetTargets', shrink_ratio=(1.0, 0.7)), dict(type='RandomFlip', flip_ratio=0.5, direction='horizontal'), dict(type='RandomRotateTextDet'), dict( type='RandomCropInstances', target_size=(640, 640), instance_key='gt_kernels'), dict(type='Pad', size_divisor=32), dict( type='CustomFormatBundle', keys=['gt_kernels', 'gt_mask'], visualize=dict(flag=False, boundary_key='gt_kernels')), dict(type='Collect', keys=['img', 'gt_kernels', 'gt_mask']) ] test_pipeline = [ dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict( type='MultiScaleFlipAug', img_scale=(3000, 640), flip=False, transforms=[ dict(type='Resize', img_scale=(3000, 640), keep_ratio=True), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']) ]) ] data = dict( samples_per_gpu=2, workers_per_gpu=2, val_dataloader=dict(samples_per_gpu=1), test_dataloader=dict(samples_per_gpu=1), train=dict( type='IcdarDataset', ann_file='data/instances_training.json', img_prefix='data/imgs', pipeline=[ dict( type='LoadImageFromFile', color_type='color_ignore_orientation'), dict( type='LoadTextAnnotations', with_bbox=True, with_mask=True, poly2mask=False), dict( type='ColorJitter', brightness=0.12549019607843137, saturation=0.5), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict( type='ScaleAspectJitter', img_scale=[(3000, 640)], ratio_range=(0.7, 1.3), aspect_ratio_range=(0.9, 1.1), multiscale_mode='value', keep_ratio=False), dict(type='PANetTargets', shrink_ratio=(1.0, 0.7)), dict(type='RandomFlip', flip_ratio=0.5, direction='horizontal'), dict(type='RandomRotateTextDet'), dict( type='RandomCropInstances', target_size=(640, 640), instance_key='gt_kernels'), dict(type='Pad', size_divisor=32), dict( type='CustomFormatBundle', keys=['gt_kernels', 'gt_mask'], visualize=dict(flag=False, boundary_key='gt_kernels')), dict(type='Collect', keys=['img', 'gt_kernels', 'gt_mask']) ]), val=dict( type='IcdarDataset', ann_file='data/instances_test.json', img_prefix='data/imgs', pipeline=[ dict( type='LoadImageFromFile', color_type='color_ignore_orientation'), dict( type='MultiScaleFlipAug', img_scale=(3000, 640), flip=False, transforms=[ dict( type='Resize', img_scale=(3000, 640), keep_ratio=True), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']) ]) ]), test=dict( type='IcdarDataset', ann_file='data/instances_test.json', img_prefix='data/imgs', pipeline=[ dict( type='LoadImageFromFile', color_type='color_ignore_orientation'), dict( type='MultiScaleFlipAug', img_scale=(3000, 640), flip=False, transforms=[ dict( type='Resize', img_scale=(3000, 640), keep_ratio=True), dict( type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img']) ]) ])) evaluation = dict(interval=10, metric='hmean-iou') work_dir = 'panet' gpu_ids = range(0, 1)
optimizer = dict(type='Adam', lr=0.001) optimizer_config = dict(grad_clip=None) lr_config = dict(policy='poly', power=0.9) total_epochs = 5000 checkpoint_config = dict(interval=10) log_config = dict(interval=5, hooks=[dict(type='TextLoggerHook')]) dist_params = dict(backend='nccl') log_level = 'INFO' load_from = None resume_from = None workflow = [('train', 1)] model = dict(type='PANet', backbone=dict(type='mmdet.ResNet', depth=18, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=-1, norm_cfg=dict(type='SyncBN', requires_grad=True), init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet18'), norm_eval=True, style='caffe'), neck=dict(type='FPEM_FFM', in_channels=[64, 128, 256, 512]), bbox_head=dict(type='PANHead', text_repr_type='poly', in_channels=[128, 128, 128, 128], out_channels=6, loss=dict(type='PANLoss')), train_cfg=None, test_cfg=None) dataset_type = 'IcdarDataset' data_root = 'data' img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True) train_pipeline = [dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict(type='LoadTextAnnotations', with_bbox=True, with_mask=True, poly2mask=False), dict(type='ColorJitter', brightness=0.12549019607843137, saturation=0.5), dict(type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ScaleAspectJitter', img_scale=[(3000, 640)], ratio_range=(0.7, 1.3), aspect_ratio_range=(0.9, 1.1), multiscale_mode='value', keep_ratio=False), dict(type='PANetTargets', shrink_ratio=(1.0, 0.7)), dict(type='RandomFlip', flip_ratio=0.5, direction='horizontal'), dict(type='RandomRotateTextDet'), dict(type='RandomCropInstances', target_size=(640, 640), instance_key='gt_kernels'), dict(type='Pad', size_divisor=32), dict(type='CustomFormatBundle', keys=['gt_kernels', 'gt_mask'], visualize=dict(flag=False, boundary_key='gt_kernels')), dict(type='Collect', keys=['img', 'gt_kernels', 'gt_mask'])] test_pipeline = [dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict(type='MultiScaleFlipAug', img_scale=(3000, 640), flip=False, transforms=[dict(type='Resize', img_scale=(3000, 640), keep_ratio=True), dict(type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img'])])] data = dict(samples_per_gpu=2, workers_per_gpu=2, val_dataloader=dict(samples_per_gpu=1), test_dataloader=dict(samples_per_gpu=1), train=dict(type='IcdarDataset', ann_file='data/instances_training.json', img_prefix='data/imgs', pipeline=[dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict(type='LoadTextAnnotations', with_bbox=True, with_mask=True, poly2mask=False), dict(type='ColorJitter', brightness=0.12549019607843137, saturation=0.5), dict(type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='ScaleAspectJitter', img_scale=[(3000, 640)], ratio_range=(0.7, 1.3), aspect_ratio_range=(0.9, 1.1), multiscale_mode='value', keep_ratio=False), dict(type='PANetTargets', shrink_ratio=(1.0, 0.7)), dict(type='RandomFlip', flip_ratio=0.5, direction='horizontal'), dict(type='RandomRotateTextDet'), dict(type='RandomCropInstances', target_size=(640, 640), instance_key='gt_kernels'), dict(type='Pad', size_divisor=32), dict(type='CustomFormatBundle', keys=['gt_kernels', 'gt_mask'], visualize=dict(flag=False, boundary_key='gt_kernels')), dict(type='Collect', keys=['img', 'gt_kernels', 'gt_mask'])]), val=dict(type='IcdarDataset', ann_file='data/instances_test.json', img_prefix='data/imgs', pipeline=[dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict(type='MultiScaleFlipAug', img_scale=(3000, 640), flip=False, transforms=[dict(type='Resize', img_scale=(3000, 640), keep_ratio=True), dict(type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img'])])]), test=dict(type='IcdarDataset', ann_file='data/instances_test.json', img_prefix='data/imgs', pipeline=[dict(type='LoadImageFromFile', color_type='color_ignore_orientation'), dict(type='MultiScaleFlipAug', img_scale=(3000, 640), flip=False, transforms=[dict(type='Resize', img_scale=(3000, 640), keep_ratio=True), dict(type='Normalize', mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True), dict(type='Pad', size_divisor=32), dict(type='ImageToTensor', keys=['img']), dict(type='Collect', keys=['img'])])])) evaluation = dict(interval=10, metric='hmean-iou') work_dir = 'panet' gpu_ids = range(0, 1)
# Copyright (c) Twisted Matrix Laboratories. # See LICENSE for details. """ Command-journalling persistence framework inspired by Prevayler. This package is deprecated since Twisted 11.0. Maintainer: Itamar Shtull-Trauring """
""" Command-journalling persistence framework inspired by Prevayler. This package is deprecated since Twisted 11.0. Maintainer: Itamar Shtull-Trauring """
# Simple game in python print('Hi, welcome to the Tim quiz!') print('Try to get as many questions correct as possible...') totalQuestions = 4 score = 0 ans = input('1. What is the name of my youtube channel? ') if ans.lower() == 'tech with tim': print('Correct!') score += 1 else: print('Incorrect') ans = input('2. What is my age? ') if ans == "17": print('Correct!') score += 1 else: print('Incorrect') ans = input('3. What is my favourite sport? ') if ans.lower() == "soccer": print('Correct!') score += 1 else: print('Incorrect') ans = input('4. What is my favourite food? ') if ans.lower() == "pizza": print('Correct!') score += 1 else: print('Incorrect') print("Thank you for playing, you got " + str(score) + ' questions correct!' ) percent = (score/totalQuestions) * 100 print("Mark: " + str(int(percent)) + '%') if percent >= 50: print('Nice! You passed!') else: print('Better luck next time')
print('Hi, welcome to the Tim quiz!') print('Try to get as many questions correct as possible...') total_questions = 4 score = 0 ans = input('1. What is the name of my youtube channel? ') if ans.lower() == 'tech with tim': print('Correct!') score += 1 else: print('Incorrect') ans = input('2. What is my age? ') if ans == '17': print('Correct!') score += 1 else: print('Incorrect') ans = input('3. What is my favourite sport? ') if ans.lower() == 'soccer': print('Correct!') score += 1 else: print('Incorrect') ans = input('4. What is my favourite food? ') if ans.lower() == 'pizza': print('Correct!') score += 1 else: print('Incorrect') print('Thank you for playing, you got ' + str(score) + ' questions correct!') percent = score / totalQuestions * 100 print('Mark: ' + str(int(percent)) + '%') if percent >= 50: print('Nice! You passed!') else: print('Better luck next time')
# add this file to your .gitignore file of the project LOCAL_SETTINGS = dict( media_root='/Users/user/projects/project/media', path='/Users/user/projects/project', virtualenv_path='/Users/user/virtualenvs/project', )
local_settings = dict(media_root='/Users/user/projects/project/media', path='/Users/user/projects/project', virtualenv_path='/Users/user/virtualenvs/project')
# Copyright (c) 2022 {{cookiecutter.author_name}} # # This software is released under the MIT License. # https://opensource.org/licenses/MIT """Version information for {{cookiecutter.project_name}}. This file is imported by ``{{cookiecutter.package_name}}.__init__``, and parsed by ``setup.py``. """ # Note, that dev versions must have an extra dot compared to alpha/beta/rc # versions in the version string. Examples: # # Correct: "1.0.0.dev0" and "1.0.0a1" # Incorrect: "1.0.0dev0" and "1.0.0.a1" # # See PEP 0440 for details - https://www.python.org/dev/peps/pep-0440 __version__ = '1.0.0.dev1'
"""Version information for {{cookiecutter.project_name}}. This file is imported by ``{{cookiecutter.package_name}}.__init__``, and parsed by ``setup.py``. """ __version__ = '1.0.0.dev1'
def tw(f,t,st): for x in range(t): f.write("\t") nl = True if st[-1] == "#": nl = False st = st[:-1] f.write(st) if nl: f.write("\n") def write_property_lua(f, tab, name, value, pref = ""): tw(f, tab, '%s{ name = "%s",' % (pref, name)) tab = tab + 1 if (type(value)==str): tw(f, tab, 'value = "%s",' % value) tw(f, t, 'type = "string",') elif (type(value)==bool): if (value): tw(f, tab, 'value = true,') else: tw(f, tab, 'value = false,') tw(f, t, 'type = "bool",') elif (type(value)==int): tw(f, t, 'type = "int",') tw(f, tab, 'value = %d,' % value) elif (type(value)==float): tw(f, t, 'type = "real",') tw(f, tab, 'value = %f,' % value) elif (type(value)==dict): tw(f, t, 'type = "dictionary",') for x in value: write_property_lua(f,tab,x,value[x]) elif (isinstance(value,ObjectTree)): if (not value._resource): print("ERROR: Not a resource!!") tw(f, tab-1, "},") return tw(f, tab, 'type = "resource",') tw(f, tab, 'resource_type = "%s",' % value._type) if (value._res_path!=""): tw(f, tab, 'path = "%s",' % value._res_path) else: tw(f, tab, "value = {") tab = tab + 1 tw(f, tab, 'type = "%s",' % value._type) for x in value._properties: write_property_lua(f,tab,x[0],x[1]) tab = tab - 1 tw(f, tab, "},") elif (isinstance(value,Color)): tw(f, tab, 'type = "color",') tw(f, tab, 'value = { %.20f, %.20f, %.20f, %.20f },' % (value.r, value.g, value.b, value.a)) elif (isinstance(value,Vector3)): tw(f, tab, 'type = "vector3",') tw(f, tab, 'value = { %.20f, %.20f, %.20f },' % (value.x, value.y, value.z)) elif (isinstance(value,Quat)): tw(f, tab, 'type = "quaternion",') tw(f, tab, 'value = { %.20f, %.20f, %.20f, %.20f },' % (value.x, value.y, value.z, value.w)) elif (isinstance(value,Matrix4x3)): # wtf, blender matrix? tw(f, tab, 'type = "transform",') tw(f, tab, 'value = { #') for i in range(3): for j in range(3): f.write("%.20f, " % value.m[j][i]) for i in range(3): f.write("%.20f, " % value.m[i][3]) f.write("},\n") elif (type(value)==list): if (len(value)==0): tw(f, tab-1, "},") return first=value[0] if (type(first)==int): tw(f, tab, 'type = "int_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write("%d, " % value[i]) f.write("},\n") elif (type(first)==float): tw(f, tab, 'type = "real_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write("%.20f, " % value[i]) f.write("},\n") elif (type(first)==str): tw(f, tab, 'type = "string_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write('"%s", ' % value[i]) f.write("},\n") elif (isinstance(first,Vector3)): tw(f, tab, 'type = "vector3_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write("{ %.20f, %.20f, %.20f }, " % (value[i].x, value[i].y, value[i].z)) f.write("},\n") elif (isinstance(first,Color)): tw(f, tab, 'type = "color_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write("{ %.20f, %.20f, %.20f, %.20f }, " % (value[i].r, value[i].g, value[i].b, value[i].a)) f.write("},\n") elif (type(first)==dict): tw(f, tab, 'type = "dict_array",') tw(f, tab, 'value = {') for i in range(len(value)): write_property_lua(f,tab+1,str(i+1),value[i]) tw(f, tab, '},') tw(f, tab-1, "},") def write_node_lua(f,tab,tree,path): tw(f, tab, '{ type = "%s",') if not tree._resource: tw(f, tab+1, 'meta = {') write_property_lua(f, tab+3, "name", tree._name) if path != "": write_property_lua(f, tab+3, "path", path) tw(f, tab+1, '},') tw(f, tab+1, "properties = {,") for x in tree._properties: write_property_lua(f,tab+2,x[0],x[1]) tw(f, tab+1, "},") tw(f, tab, '},') if (path==""): path="." else: if (path=="."): path=tree._name else: path=path+"/"+tree._name #path="." for x in tree._children: write_node_lua(f,tab,x,path) def write(tree,fname): f=open(fname,"wb") f.write("return = {\n") f.write('\tmagic = "SCENE",\n') tab = 1 write_node_lua(f,tab,tree,"") f.write("}\n\n")
def tw(f, t, st): for x in range(t): f.write('\t') nl = True if st[-1] == '#': nl = False st = st[:-1] f.write(st) if nl: f.write('\n') def write_property_lua(f, tab, name, value, pref=''): tw(f, tab, '%s{ name = "%s",' % (pref, name)) tab = tab + 1 if type(value) == str: tw(f, tab, 'value = "%s",' % value) tw(f, t, 'type = "string",') elif type(value) == bool: if value: tw(f, tab, 'value = true,') else: tw(f, tab, 'value = false,') tw(f, t, 'type = "bool",') elif type(value) == int: tw(f, t, 'type = "int",') tw(f, tab, 'value = %d,' % value) elif type(value) == float: tw(f, t, 'type = "real",') tw(f, tab, 'value = %f,' % value) elif type(value) == dict: tw(f, t, 'type = "dictionary",') for x in value: write_property_lua(f, tab, x, value[x]) elif isinstance(value, ObjectTree): if not value._resource: print('ERROR: Not a resource!!') tw(f, tab - 1, '},') return tw(f, tab, 'type = "resource",') tw(f, tab, 'resource_type = "%s",' % value._type) if value._res_path != '': tw(f, tab, 'path = "%s",' % value._res_path) else: tw(f, tab, 'value = {') tab = tab + 1 tw(f, tab, 'type = "%s",' % value._type) for x in value._properties: write_property_lua(f, tab, x[0], x[1]) tab = tab - 1 tw(f, tab, '},') elif isinstance(value, Color): tw(f, tab, 'type = "color",') tw(f, tab, 'value = { %.20f, %.20f, %.20f, %.20f },' % (value.r, value.g, value.b, value.a)) elif isinstance(value, Vector3): tw(f, tab, 'type = "vector3",') tw(f, tab, 'value = { %.20f, %.20f, %.20f },' % (value.x, value.y, value.z)) elif isinstance(value, Quat): tw(f, tab, 'type = "quaternion",') tw(f, tab, 'value = { %.20f, %.20f, %.20f, %.20f },' % (value.x, value.y, value.z, value.w)) elif isinstance(value, Matrix4x3): tw(f, tab, 'type = "transform",') tw(f, tab, 'value = { #') for i in range(3): for j in range(3): f.write('%.20f, ' % value.m[j][i]) for i in range(3): f.write('%.20f, ' % value.m[i][3]) f.write('},\n') elif type(value) == list: if len(value) == 0: tw(f, tab - 1, '},') return first = value[0] if type(first) == int: tw(f, tab, 'type = "int_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write('%d, ' % value[i]) f.write('},\n') elif type(first) == float: tw(f, tab, 'type = "real_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write('%.20f, ' % value[i]) f.write('},\n') elif type(first) == str: tw(f, tab, 'type = "string_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write('"%s", ' % value[i]) f.write('},\n') elif isinstance(first, Vector3): tw(f, tab, 'type = "vector3_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write('{ %.20f, %.20f, %.20f }, ' % (value[i].x, value[i].y, value[i].z)) f.write('},\n') elif isinstance(first, Color): tw(f, tab, 'type = "color_array",') tw(f, tab, 'value = #') for i in range(len(value)): f.write('{ %.20f, %.20f, %.20f, %.20f }, ' % (value[i].r, value[i].g, value[i].b, value[i].a)) f.write('},\n') elif type(first) == dict: tw(f, tab, 'type = "dict_array",') tw(f, tab, 'value = {') for i in range(len(value)): write_property_lua(f, tab + 1, str(i + 1), value[i]) tw(f, tab, '},') tw(f, tab - 1, '},') def write_node_lua(f, tab, tree, path): tw(f, tab, '{ type = "%s",') if not tree._resource: tw(f, tab + 1, 'meta = {') write_property_lua(f, tab + 3, 'name', tree._name) if path != '': write_property_lua(f, tab + 3, 'path', path) tw(f, tab + 1, '},') tw(f, tab + 1, 'properties = {,') for x in tree._properties: write_property_lua(f, tab + 2, x[0], x[1]) tw(f, tab + 1, '},') tw(f, tab, '},') if path == '': path = '.' elif path == '.': path = tree._name else: path = path + '/' + tree._name for x in tree._children: write_node_lua(f, tab, x, path) def write(tree, fname): f = open(fname, 'wb') f.write('return = {\n') f.write('\tmagic = "SCENE",\n') tab = 1 write_node_lua(f, tab, tree, '') f.write('}\n\n')
fileout = open("requests.sh", "w") for i in range(1,57): if i >= 10: s = "0" + str(i) else: s = "00" + str(i) fileout.write("curl -s -H 'Content-Type: application/json' -H " + '"Authorization: Bearer `gcloud auth print-access-token`"' + " https://speech.googleapis.com/v1/speech:recognize -d" + ''' "{'config': {'encoding':'FLAC','sampleRateHertz': 44100,'languageCode': 'en-US','enableWordTimeOffsets': false},'audio': {'uri':'gs://bamboo-foundation-6245/SPLIT-'''+s+'''.flac'}}" > TEMP/OUT-'''+s+".txt\n") fileout.close();
fileout = open('requests.sh', 'w') for i in range(1, 57): if i >= 10: s = '0' + str(i) else: s = '00' + str(i) fileout.write("curl -s -H 'Content-Type: application/json' -H " + '"Authorization: Bearer `gcloud auth print-access-token`"' + ' https://speech.googleapis.com/v1/speech:recognize -d' + ' "{\'config\': {\'encoding\':\'FLAC\',\'sampleRateHertz\': 44100,\'languageCode\': \'en-US\',\'enableWordTimeOffsets\': false},\'audio\': {\'uri\':\'gs://bamboo-foundation-6245/SPLIT-' + s + '.flac\'}}" > TEMP/OUT-' + s + '.txt\n') fileout.close()
def define_env(env): "Definition of the module" @env.macro def feedback(title, section, slug): email_address = f"{section}+{slug}@technotes.jakoubek.net" md = "\n\n## Feedback / Kontakt\n\n" md += f"Wenn Sie Fragen oder Anregungen zum Artikel *{title}* haben, senden Sie mir bitte eine E-Mail an: [{email_address}](mailto:{email_address}?subject=[Technotes] {title})" return md # def on_post_page_macros(env): # env.raw_markdown += "{{ feedback(page.meta.title, page.meta.section, page.meta.slug) }}" # env.raw_markdown += '\n\n## Feedback / Kontakt\n\n' # env.raw_markdown += 'Wenn Sie Fragen oder Anregungen zum Artikel *' + \ # env.page.title + '* haben ...' # env.raw_markdown += env.page.abs_url
def define_env(env): """Definition of the module""" @env.macro def feedback(title, section, slug): email_address = f'{section}+{slug}@technotes.jakoubek.net' md = '\n\n## Feedback / Kontakt\n\n' md += f'Wenn Sie Fragen oder Anregungen zum Artikel *{title}* haben, senden Sie mir bitte eine E-Mail an: [{email_address}](mailto:{email_address}?subject=[Technotes] {title})' return md
class Solution: # # Greedy (Accepted), O(n) time, O(1) space # def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: # plots = len(flowerbed) # flowerbed.append(0) # prev = planted = 0 # for i in range(plots): # if flowerbed[i] == 0: # if prev == 0 and flowerbed[i+1] == 0: # planted += 1 # flowerbed[i] = 1 # prev = flowerbed[i] # return planted >= n # Greedy (Top Voted), O(n) time, O(1) space def canPlaceFlowers(self, A: List[int], N: int) -> bool: for i, x in enumerate(A): if (not x and (i == 0 or A[i-1] == 0) and (i == len(A)-1 or A[i+1] == 0)): N -= 1 A[i] = 1 return N <= 0
class Solution: def can_place_flowers(self, A: List[int], N: int) -> bool: for (i, x) in enumerate(A): if not x and (i == 0 or A[i - 1] == 0) and (i == len(A) - 1 or A[i + 1] == 0): n -= 1 A[i] = 1 return N <= 0
# PyZ3950_parsetab.py # This file is automatically generated. Do not edit. _lr_method = 'SLR' _lr_signature = '\xfc\xb2\xa8\xb7\xd9\xe7\xad\xba"\xb2Ss\'\xcd\x08\x16' _lr_action_items = {'QUOTEDVALUE':([18,12,14,0,26,],[1,1,1,1,1,]),'LOGOP':([3,5,20,4,6,27,19,24,25,13,22,1,],[-5,-8,-4,-14,14,14,14,-9,-6,-13,-7,-12,]),'SET':([12,14,0,26,],[10,10,10,10,]),'WORD':([12,14,0,5,18,13,24,4,16,15,1,26,],[4,4,4,13,4,-13,13,-14,22,21,-12,4,]),'$':([2,5,3,7,28,25,13,1,4,6,22,20,24,],[-1,-8,-5,0,-3,-6,-13,-12,-14,-2,-7,-4,-9,]),'SLASH':([21,],[26,]),'ATTRSET':([0,],[8,]),'QUAL':([26,17,14,0,12,],[9,23,9,9,9,]),'COMMA':([23,9,11,],[-11,-10,17,]),'LPAREN':([26,14,0,8,12,],[12,12,12,15,12,]),'RPAREN':([19,3,22,1,25,27,5,13,20,4,24,],[25,-5,-7,-12,-6,28,-8,-13,-4,-14,-9,]),'RELOP':([9,11,23,10,],[-10,18,-11,16,]),} _lr_action = { } for _k, _v in _lr_action_items.items(): for _x,_y in zip(_v[0],_v[1]): _lr_action[(_x,_k)] = _y del _lr_action_items _lr_goto_items = {'cclfind_or_attrset':([0,],[2,]),'elements':([12,14,26,0,],[3,20,3,3,]),'val':([12,18,14,26,0,],[5,24,5,5,5,]),'top':([0,],[7,]),'cclfind':([12,0,26,],[19,6,27,]),'quallist':([26,12,14,0,],[11,11,11,11,]),} _lr_goto = { } for _k, _v in _lr_goto_items.items(): for _x,_y in zip(_v[0],_v[1]): _lr_goto[(_x,_k)] = _y del _lr_goto_items _lr_productions = [ ("S'",1,None,None,None), ('top',1,'p_top','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',170), ('cclfind_or_attrset',1,'p_cclfind_or_attrset_1','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',174), ('cclfind_or_attrset',6,'p_cclfind_or_attrset_2','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',178), ('cclfind',3,'p_ccl_find_1','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',182), ('cclfind',1,'p_ccl_find_2','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',186), ('elements',3,'p_elements_1','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',190), ('elements',3,'p_elements_2','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',212), ('elements',1,'p_elements_3','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',218), ('elements',3,'p_elements_4','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',222), ('quallist',1,'p_quallist_1','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',229), ('quallist',3,'p_quallist_2','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',233), ('val',1,'p_val_1','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',237), ('val',2,'p_val_2','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',241), ('val',1,'p_val_3','/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py',245), ]
_lr_method = 'SLR' _lr_signature = 'ü²¨·Ùç\xadº"²Ss\'Í\x08\x16' _lr_action_items = {'QUOTEDVALUE': ([18, 12, 14, 0, 26], [1, 1, 1, 1, 1]), 'LOGOP': ([3, 5, 20, 4, 6, 27, 19, 24, 25, 13, 22, 1], [-5, -8, -4, -14, 14, 14, 14, -9, -6, -13, -7, -12]), 'SET': ([12, 14, 0, 26], [10, 10, 10, 10]), 'WORD': ([12, 14, 0, 5, 18, 13, 24, 4, 16, 15, 1, 26], [4, 4, 4, 13, 4, -13, 13, -14, 22, 21, -12, 4]), '$': ([2, 5, 3, 7, 28, 25, 13, 1, 4, 6, 22, 20, 24], [-1, -8, -5, 0, -3, -6, -13, -12, -14, -2, -7, -4, -9]), 'SLASH': ([21], [26]), 'ATTRSET': ([0], [8]), 'QUAL': ([26, 17, 14, 0, 12], [9, 23, 9, 9, 9]), 'COMMA': ([23, 9, 11], [-11, -10, 17]), 'LPAREN': ([26, 14, 0, 8, 12], [12, 12, 12, 15, 12]), 'RPAREN': ([19, 3, 22, 1, 25, 27, 5, 13, 20, 4, 24], [25, -5, -7, -12, -6, 28, -8, -13, -4, -14, -9]), 'RELOP': ([9, 11, 23, 10], [-10, 18, -11, 16])} _lr_action = {} for (_k, _v) in _lr_action_items.items(): for (_x, _y) in zip(_v[0], _v[1]): _lr_action[_x, _k] = _y del _lr_action_items _lr_goto_items = {'cclfind_or_attrset': ([0], [2]), 'elements': ([12, 14, 26, 0], [3, 20, 3, 3]), 'val': ([12, 18, 14, 26, 0], [5, 24, 5, 5, 5]), 'top': ([0], [7]), 'cclfind': ([12, 0, 26], [19, 6, 27]), 'quallist': ([26, 12, 14, 0], [11, 11, 11, 11])} _lr_goto = {} for (_k, _v) in _lr_goto_items.items(): for (_x, _y) in zip(_v[0], _v[1]): _lr_goto[_x, _k] = _y del _lr_goto_items _lr_productions = [("S'", 1, None, None, None), ('top', 1, 'p_top', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 170), ('cclfind_or_attrset', 1, 'p_cclfind_or_attrset_1', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 174), ('cclfind_or_attrset', 6, 'p_cclfind_or_attrset_2', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 178), ('cclfind', 3, 'p_ccl_find_1', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 182), ('cclfind', 1, 'p_ccl_find_2', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 186), ('elements', 3, 'p_elements_1', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 190), ('elements', 3, 'p_elements_2', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 212), ('elements', 1, 'p_elements_3', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 218), ('elements', 3, 'p_elements_4', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 222), ('quallist', 1, 'p_quallist_1', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 229), ('quallist', 3, 'p_quallist_2', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 233), ('val', 1, 'p_val_1', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 237), ('val', 2, 'p_val_2', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 241), ('val', 1, 'p_val_3', '/Users/cjkarr/Desktop/python-z3950-importer/PyZ3950/ccl.py', 245)]
# # PySNMP MIB module RSPAN-MGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RSPAN-MGMT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:50:21 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint") dlink_common_mgmt, = mibBuilder.importSymbols("DLINK-ID-REC-MIB", "dlink-common-mgmt") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") MibIdentifier, iso, Counter64, Bits, ModuleIdentity, ObjectIdentity, IpAddress, NotificationType, Unsigned32, Gauge32, Integer32, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "iso", "Counter64", "Bits", "ModuleIdentity", "ObjectIdentity", "IpAddress", "NotificationType", "Unsigned32", "Gauge32", "Integer32", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks") TextualConvention, DisplayString, RowStatus = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString", "RowStatus") class VlanId(Integer32): subtypeSpec = Integer32.subtypeSpec + ValueRangeConstraint(1, 4094) class PortList(OctetString): subtypeSpec = OctetString.subtypeSpec + ValueSizeConstraint(0, 127) swRSPANMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 171, 12, 68)) if mibBuilder.loadTexts: swRSPANMIB.setLastUpdated('200807290000Z') if mibBuilder.loadTexts: swRSPANMIB.setOrganization('D-Link Crop.') swRSPANCtrl = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 12, 68, 1)) swRSPANInfo = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 12, 68, 2)) swRSPANMgmt = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 12, 68, 3)) swRSPANState = MibScalar((1, 3, 6, 1, 4, 1, 171, 12, 68, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: swRSPANState.setStatus('current') swRSPANMaxSupportedEntry = MibScalar((1, 3, 6, 1, 4, 1, 171, 12, 68, 2, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: swRSPANMaxSupportedEntry.setStatus('current') swRSPANCurrentNumEntries = MibScalar((1, 3, 6, 1, 4, 1, 171, 12, 68, 2, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: swRSPANCurrentNumEntries.setStatus('current') swRSPANTable = MibTable((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1), ) if mibBuilder.loadTexts: swRSPANTable.setStatus('current') swRSPANEntry = MibTableRow((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1), ).setIndexNames((0, "RSPAN-MGMT-MIB", "swRSPANVLANID")) if mibBuilder.loadTexts: swRSPANEntry.setStatus('current') swRSPANVLANID = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 1), VlanId()).setMaxAccess("readonly") if mibBuilder.loadTexts: swRSPANVLANID.setStatus('current') swRSPANSourceIngress = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 2), PortList()).setMaxAccess("readcreate") if mibBuilder.loadTexts: swRSPANSourceIngress.setStatus('current') swRSPANSourceEgress = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 3), PortList()).setMaxAccess("readcreate") if mibBuilder.loadTexts: swRSPANSourceEgress.setStatus('current') swRSPANRedirct = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 4), PortList()).setMaxAccess("readcreate") if mibBuilder.loadTexts: swRSPANRedirct.setStatus('current') swRSPANRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 5), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: swRSPANRowStatus.setStatus('current') mibBuilder.exportSymbols("RSPAN-MGMT-MIB", swRSPANTable=swRSPANTable, PortList=PortList, swRSPANInfo=swRSPANInfo, swRSPANSourceIngress=swRSPANSourceIngress, swRSPANSourceEgress=swRSPANSourceEgress, swRSPANRedirct=swRSPANRedirct, swRSPANMIB=swRSPANMIB, swRSPANEntry=swRSPANEntry, VlanId=VlanId, swRSPANMaxSupportedEntry=swRSPANMaxSupportedEntry, swRSPANState=swRSPANState, swRSPANRowStatus=swRSPANRowStatus, swRSPANVLANID=swRSPANVLANID, swRSPANCurrentNumEntries=swRSPANCurrentNumEntries, swRSPANCtrl=swRSPANCtrl, PYSNMP_MODULE_ID=swRSPANMIB, swRSPANMgmt=swRSPANMgmt)
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_intersection, constraints_union, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'SingleValueConstraint') (dlink_common_mgmt,) = mibBuilder.importSymbols('DLINK-ID-REC-MIB', 'dlink-common-mgmt') (notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance') (mib_identifier, iso, counter64, bits, module_identity, object_identity, ip_address, notification_type, unsigned32, gauge32, integer32, counter32, mib_scalar, mib_table, mib_table_row, mib_table_column, time_ticks) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'iso', 'Counter64', 'Bits', 'ModuleIdentity', 'ObjectIdentity', 'IpAddress', 'NotificationType', 'Unsigned32', 'Gauge32', 'Integer32', 'Counter32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'TimeTicks') (textual_convention, display_string, row_status) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString', 'RowStatus') class Vlanid(Integer32): subtype_spec = Integer32.subtypeSpec + value_range_constraint(1, 4094) class Portlist(OctetString): subtype_spec = OctetString.subtypeSpec + value_size_constraint(0, 127) sw_rspanmib = module_identity((1, 3, 6, 1, 4, 1, 171, 12, 68)) if mibBuilder.loadTexts: swRSPANMIB.setLastUpdated('200807290000Z') if mibBuilder.loadTexts: swRSPANMIB.setOrganization('D-Link Crop.') sw_rspan_ctrl = mib_identifier((1, 3, 6, 1, 4, 1, 171, 12, 68, 1)) sw_rspan_info = mib_identifier((1, 3, 6, 1, 4, 1, 171, 12, 68, 2)) sw_rspan_mgmt = mib_identifier((1, 3, 6, 1, 4, 1, 171, 12, 68, 3)) sw_rspan_state = mib_scalar((1, 3, 6, 1, 4, 1, 171, 12, 68, 1, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('enabled', 1), ('disabled', 2)))).setMaxAccess('readwrite') if mibBuilder.loadTexts: swRSPANState.setStatus('current') sw_rspan_max_supported_entry = mib_scalar((1, 3, 6, 1, 4, 1, 171, 12, 68, 2, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: swRSPANMaxSupportedEntry.setStatus('current') sw_rspan_current_num_entries = mib_scalar((1, 3, 6, 1, 4, 1, 171, 12, 68, 2, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 65535))).setMaxAccess('readonly') if mibBuilder.loadTexts: swRSPANCurrentNumEntries.setStatus('current') sw_rspan_table = mib_table((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1)) if mibBuilder.loadTexts: swRSPANTable.setStatus('current') sw_rspan_entry = mib_table_row((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1)).setIndexNames((0, 'RSPAN-MGMT-MIB', 'swRSPANVLANID')) if mibBuilder.loadTexts: swRSPANEntry.setStatus('current') sw_rspanvlanid = mib_table_column((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 1), vlan_id()).setMaxAccess('readonly') if mibBuilder.loadTexts: swRSPANVLANID.setStatus('current') sw_rspan_source_ingress = mib_table_column((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 2), port_list()).setMaxAccess('readcreate') if mibBuilder.loadTexts: swRSPANSourceIngress.setStatus('current') sw_rspan_source_egress = mib_table_column((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 3), port_list()).setMaxAccess('readcreate') if mibBuilder.loadTexts: swRSPANSourceEgress.setStatus('current') sw_rspan_redirct = mib_table_column((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 4), port_list()).setMaxAccess('readcreate') if mibBuilder.loadTexts: swRSPANRedirct.setStatus('current') sw_rspan_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 171, 12, 68, 3, 1, 1, 5), row_status()).setMaxAccess('readcreate') if mibBuilder.loadTexts: swRSPANRowStatus.setStatus('current') mibBuilder.exportSymbols('RSPAN-MGMT-MIB', swRSPANTable=swRSPANTable, PortList=PortList, swRSPANInfo=swRSPANInfo, swRSPANSourceIngress=swRSPANSourceIngress, swRSPANSourceEgress=swRSPANSourceEgress, swRSPANRedirct=swRSPANRedirct, swRSPANMIB=swRSPANMIB, swRSPANEntry=swRSPANEntry, VlanId=VlanId, swRSPANMaxSupportedEntry=swRSPANMaxSupportedEntry, swRSPANState=swRSPANState, swRSPANRowStatus=swRSPANRowStatus, swRSPANVLANID=swRSPANVLANID, swRSPANCurrentNumEntries=swRSPANCurrentNumEntries, swRSPANCtrl=swRSPANCtrl, PYSNMP_MODULE_ID=swRSPANMIB, swRSPANMgmt=swRSPANMgmt)
class Node: def __init__(self, declaration_list): self.declaration_list = declaration_list def visit(self): context = {"type": "program"} return self.declaration_list.visit(context)
class Node: def __init__(self, declaration_list): self.declaration_list = declaration_list def visit(self): context = {'type': 'program'} return self.declaration_list.visit(context)
""" Problem Description The program takes a list from the user and finds the cumulative sum of a list where the ith element is the sum of the first i+1 elements from the original list. Problem Solution 1. Declare an empty list and initialise to an empty list. 2. Consider a for loop to accept values for the list. 3. Take the number of elements in the list and store it in a variable. 4. Accept the values into the list using another for loop and insert into the list. 5. Using list comprehension and list slicing, find the cumulative sum of elements in the list. 6. Print the original list and the new list. 7. Exit. """ a=[] n=int(input("Enter the number of elements in list: ")) for i in range(n): data=int(input(f"Enter elements at position {i}: ")) a.append(data) print("elements in the list: ",end=" ") for i in range(n): print(a[i],end=" ") print() b=[sum(a[0:i+1]) for i in range(0,n)] print(f"The new list is: {b}")
""" Problem Description The program takes a list from the user and finds the cumulative sum of a list where the ith element is the sum of the first i+1 elements from the original list. Problem Solution 1. Declare an empty list and initialise to an empty list. 2. Consider a for loop to accept values for the list. 3. Take the number of elements in the list and store it in a variable. 4. Accept the values into the list using another for loop and insert into the list. 5. Using list comprehension and list slicing, find the cumulative sum of elements in the list. 6. Print the original list and the new list. 7. Exit. """ a = [] n = int(input('Enter the number of elements in list: ')) for i in range(n): data = int(input(f'Enter elements at position {i}: ')) a.append(data) print('elements in the list: ', end=' ') for i in range(n): print(a[i], end=' ') print() b = [sum(a[0:i + 1]) for i in range(0, n)] print(f'The new list is: {b}')
"""Application deployment configuration parameters.""" PROTOCOL = 'http' HOSTNAME = 'localhost' PORT = 6040
"""Application deployment configuration parameters.""" protocol = 'http' hostname = 'localhost' port = 6040
# -*- coding: utf-8 -*- """ Created on Tue Jun 22 11:20:42 2021 @author: Keisha """ class Bird: def intro(self): print("There are man y types of birds.") def flight(self): print("Most of the birds can fly ut some caqnnot.") class sparrow(Bird): def flight(self): print("Sparrows can fly.") class ostrich(Bird): def flight(self): print("Ostriches cannot fly.") obj_bird = Bird() obj_spr = sparrow() obj_ost = ostrich() obj_bird.intro() obj_bird.flight() obj_spr.intro() obj_spr.flight() obj_ost.intro() obj_ost.flight()
""" Created on Tue Jun 22 11:20:42 2021 @author: Keisha """ class Bird: def intro(self): print('There are man y types of birds.') def flight(self): print('Most of the birds can fly ut some caqnnot.') class Sparrow(Bird): def flight(self): print('Sparrows can fly.') class Ostrich(Bird): def flight(self): print('Ostriches cannot fly.') obj_bird = bird() obj_spr = sparrow() obj_ost = ostrich() obj_bird.intro() obj_bird.flight() obj_spr.intro() obj_spr.flight() obj_ost.intro() obj_ost.flight()
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def _diameterBTree(self,root): if not root: return 0 l = self._diameterBTree(root.left) r = self._diameterBTree(root.right) self.ans = max(self.ans,1+l+r) return 1+max(l,r) def diameterOfBinaryTree(self, root: TreeNode) -> int: if not root: return 0 self.ans = 0 self._diameterBTree(root) return self.ans-1
class Treenode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def _diameter_b_tree(self, root): if not root: return 0 l = self._diameterBTree(root.left) r = self._diameterBTree(root.right) self.ans = max(self.ans, 1 + l + r) return 1 + max(l, r) def diameter_of_binary_tree(self, root: TreeNode) -> int: if not root: return 0 self.ans = 0 self._diameterBTree(root) return self.ans - 1
class Modification: def __init__(self): self.AAs=[] self.mass=0.0 self.NL={} self.DI={} self.factor=1 self.name="" self.ID=-1 def setAAs(self, newAAlist): self.AAs=newAAlist return True def getAAs(self): return self.AAs def setMass(self, newMass): self.mass=newMass return True def getMass(self): return self.mass def setNL(self, newNLdict): self.NL=newNLdict return True def getNL(self): return self.NL def setDI(self, newDIdict): self.DI=newDIdict return True def getDI(self): return self.DI def setName(self, newName): self.name=newName return True def getName(self): return self.name def setID(self, newID): self.ID=str(newID) return True def getID(self): return self.ID def create(self,nameString,modString,NLstring):#,DIstring): self.name=nameString for each in modString.split()[0]: # This will be each AA... self.AAs.append(each) self.mass=modString.split()[1] for each in NLstring.split()[0]: if each != "-": self.NL[each]=float(NLstring.split()[1]) #for each in DIstring.split()[0]: # if each != "-": # self.DI[each]=float(DIstring.split()[1]) def __str__(self): return self.ID+"_"+self.name+"_"+str(self.mass)
class Modification: def __init__(self): self.AAs = [] self.mass = 0.0 self.NL = {} self.DI = {} self.factor = 1 self.name = '' self.ID = -1 def set_a_as(self, newAAlist): self.AAs = newAAlist return True def get_a_as(self): return self.AAs def set_mass(self, newMass): self.mass = newMass return True def get_mass(self): return self.mass def set_nl(self, newNLdict): self.NL = newNLdict return True def get_nl(self): return self.NL def set_di(self, newDIdict): self.DI = newDIdict return True def get_di(self): return self.DI def set_name(self, newName): self.name = newName return True def get_name(self): return self.name def set_id(self, newID): self.ID = str(newID) return True def get_id(self): return self.ID def create(self, nameString, modString, NLstring): self.name = nameString for each in modString.split()[0]: self.AAs.append(each) self.mass = modString.split()[1] for each in NLstring.split()[0]: if each != '-': self.NL[each] = float(NLstring.split()[1]) def __str__(self): return self.ID + '_' + self.name + '_' + str(self.mass)
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def append(self,newdata): new_node=Node(newdata) if self.head is None: self.head=new_node return temp=self.head while(temp.next): temp=temp.next temp.next=new_node def first_node_of_loop(self,node): # finding the position where fast=slow slow=self.head fast = self.head while(True): slow = slow.next fast = fast.next.next if slow==fast: break #starting from head move fast & cur_node until they are equal cur_node=self.head while(cur_node!=fast): fast=fast.next cur_node=cur_node.next return cur_node arr = list(map(int,input().split())) l = LinkedList() for i in range(lenn(arr)): l.append(arr[i]) print(l.first_node_of_loop(l.head))
class Node: def __init__(self, data): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def append(self, newdata): new_node = node(newdata) if self.head is None: self.head = new_node return temp = self.head while temp.next: temp = temp.next temp.next = new_node def first_node_of_loop(self, node): slow = self.head fast = self.head while True: slow = slow.next fast = fast.next.next if slow == fast: break cur_node = self.head while cur_node != fast: fast = fast.next cur_node = cur_node.next return cur_node arr = list(map(int, input().split())) l = linked_list() for i in range(lenn(arr)): l.append(arr[i]) print(l.first_node_of_loop(l.head))
""" AS PYTHON DOESN'T HAVE CONSTANT DECLARATION, THE NEXT METHODS RETURN THE VALUES WHO NEED CONSTANT BEHAVIOR. """ def VGL_SHAPE_NCHANNELS(): return 0 def VGL_SHAPE_WIDTH(): return 1 def VGL_SHAPE_HEIGHT(): return 2 def VGL_SHAPE_LENGTH(): return 3 def VGL_MAX_DIM(): return 10 def VGL_ARR_SHAPE_SIZE(): return VGL_MAX_DIM()+1 def VGL_ARR_CLSTREL_SIZE(): return 256 def VGL_STREL_CUBE(): return 1 def VGL_STREL_CROSS(): return 2 def VGL_STREL_GAUSS(): return 3 def VGL_STREL_MEAN(): return 4 def VGL_IMAGE_3D_IMAGE(): return 0 def VGL_IMAGE_2D_IMAGE(): return 1
""" AS PYTHON DOESN'T HAVE CONSTANT DECLARATION, THE NEXT METHODS RETURN THE VALUES WHO NEED CONSTANT BEHAVIOR. """ def vgl_shape_nchannels(): return 0 def vgl_shape_width(): return 1 def vgl_shape_height(): return 2 def vgl_shape_length(): return 3 def vgl_max_dim(): return 10 def vgl_arr_shape_size(): return vgl_max_dim() + 1 def vgl_arr_clstrel_size(): return 256 def vgl_strel_cube(): return 1 def vgl_strel_cross(): return 2 def vgl_strel_gauss(): return 3 def vgl_strel_mean(): return 4 def vgl_image_3_d_image(): return 0 def vgl_image_2_d_image(): return 1
def simplest_numbers_generator(): """Simplest Number Generator, yielding only two values - 1 and 2. Disclaimer: Use it just to trace how next and yield operators works. This example is not useful in real world! """ num = 1 print("Yielding", num) yield num num +=1 print("Yielding", num) yield 2 num +=1 print("Yielding", num) print("Sory, there is nothing to yield...") def test_simplest_numbers_generator(test): """To test the simplest_numbers_generator, use: test_simplest_numbers_generator("for") -- to see the generator behaviour on for loop test_simplest_numbers_generator("next") -- to see the generator behaviour on next() call """ print_header("Testing simplest_numbers_generator on {}".format(test), "#", 50) # create num_gen generator num_gen = simplest_numbers_generator() # print( num_gen.__dir__() ) if test == "for": for i in num_gen: print(i) elif test == "next": # ask the num_gen for 2 values: print( next(num_gen) ) print( next(num_gen) ) # ask num_gen for more values that it can yield print( next(num_gen) ) def print_header(msg, symbol, width): """Summary Args: msg (String): the text to be printed symbol (String): the border symbol width (Int): the width of printing area """ print("\n") print(symbol*width) print(symbol+msg.center(width-2)+symbol) print(symbol*width) test_simplest_numbers_generator("for") test_simplest_numbers_generator("next")
def simplest_numbers_generator(): """Simplest Number Generator, yielding only two values - 1 and 2. Disclaimer: Use it just to trace how next and yield operators works. This example is not useful in real world! """ num = 1 print('Yielding', num) yield num num += 1 print('Yielding', num) yield 2 num += 1 print('Yielding', num) print('Sory, there is nothing to yield...') def test_simplest_numbers_generator(test): """To test the simplest_numbers_generator, use: test_simplest_numbers_generator("for") -- to see the generator behaviour on for loop test_simplest_numbers_generator("next") -- to see the generator behaviour on next() call """ print_header('Testing simplest_numbers_generator on {}'.format(test), '#', 50) num_gen = simplest_numbers_generator() if test == 'for': for i in num_gen: print(i) elif test == 'next': print(next(num_gen)) print(next(num_gen)) print(next(num_gen)) def print_header(msg, symbol, width): """Summary Args: msg (String): the text to be printed symbol (String): the border symbol width (Int): the width of printing area """ print('\n') print(symbol * width) print(symbol + msg.center(width - 2) + symbol) print(symbol * width) test_simplest_numbers_generator('for') test_simplest_numbers_generator('next')
""" --- What is wrong with this family? --- Simple You have a list of family relationships between father and son. Every element on this list has two elements. The first is the father's name, the second is a son's name. All names in the family are unique. Check if the family tree is correct. There are no strangers in the family tree. All connections in the family are natural. Input: list of lists. Every element has two strings. List has at least one element Output: bool. Is family tree correct. Precondition: 1 <= len(tree) < 100 """ def my_solution(tree): ancestor = tree[0][0] dict_tree = {} for father, son in tree: if dict_tree.get(father, None): dict_tree[father].append(son) else: dict_tree[father] = [son, ] fathers = dict_tree.keys() sons = [i for s in dict_tree.values() for i in s] if len(fathers) == 1: return True if set(fathers) - {ancestor, } - set(sons): return False if len(set(sons)) < len(sons): return False for k, v in dict_tree.items(): for f in v: if k in dict_tree.get(f, []): return False return True def tom_tom_solution(tree): fathers, sons = zip(*tree) fathers_set, sons_set = set(fathers), set(sons) return (all(father != son for father, son in tree) and len(fathers_set - sons_set) == 1 and len(sons) == len(sons_set))
""" --- What is wrong with this family? --- Simple You have a list of family relationships between father and son. Every element on this list has two elements. The first is the father's name, the second is a son's name. All names in the family are unique. Check if the family tree is correct. There are no strangers in the family tree. All connections in the family are natural. Input: list of lists. Every element has two strings. List has at least one element Output: bool. Is family tree correct. Precondition: 1 <= len(tree) < 100 """ def my_solution(tree): ancestor = tree[0][0] dict_tree = {} for (father, son) in tree: if dict_tree.get(father, None): dict_tree[father].append(son) else: dict_tree[father] = [son] fathers = dict_tree.keys() sons = [i for s in dict_tree.values() for i in s] if len(fathers) == 1: return True if set(fathers) - {ancestor} - set(sons): return False if len(set(sons)) < len(sons): return False for (k, v) in dict_tree.items(): for f in v: if k in dict_tree.get(f, []): return False return True def tom_tom_solution(tree): (fathers, sons) = zip(*tree) (fathers_set, sons_set) = (set(fathers), set(sons)) return all((father != son for (father, son) in tree)) and len(fathers_set - sons_set) == 1 and (len(sons) == len(sons_set))
"""CSP (Constraint Satisfaction Problems) problems and solvers. (Chapter 6).""" # CLASS FROM https://github.com/aimacode/aima-python/ slightly modified for performance (see tag @modified) # the proof about performance can be found in the files original_results.txt and modified_results.txt # @modified: removed unused imports class CSP: """This class describes finite-domain Constraint Satisfaction Problems. A CSP is specified by the following inputs: variables A list of variables; each is atomic (e.g. int or string). domains A dict of {var:[possible_value, ...]} entries. neighbors A dict of {var:[var,...]} that for each variable lists the other variables that participate in constraints. constraints A function f(A, a, B, b) that returns true if neighbors A, B satisfy the constraint when they have values A=a, B=b In the textbook and in most mathematical definitions, the constraints are specified as explicit pairs of allowable values, but the formulation here is easier to express and more compact for most cases. (For example, the n-Queens problem can be represented in O(n) space using this notation, instead of O(N^4) for the explicit representation.) In terms of describing the CSP as a problem, that's all there is. However, the class also supports data structures and methods that help you solve CSPs by calling a search function on the CSP. Methods and slots are as follows, where the argument 'a' represents an assignment, which is a dict of {var:val} entries: assign(var, val, a) Assign a[var] = val; do other bookkeeping unassign(var, a) Do del a[var], plus other bookkeeping nconflicts(var, val, a) Return the number of other variables that conflict with var=val curr_domains[var] Slot: remaining consistent values for var Used by constraint propagation routines. The following methods are used only by graph_search and tree_search: actions(state) Return a list of actions result(state, action) Return a successor of state goal_test(state) Return true if all constraints satisfied The following are just for debugging purposes: nassigns Slot: tracks the number of assignments made display(a) Print a human-readable representation """ # added a variable to save the number of backtracks # in my opinion it is better to show the backtracks instead of the assignments def __init__(self, variables, domains, neighbors, constraints): """Construct a CSP problem. If variables is empty, it becomes domains.keys().""" variables = variables or list(domains.keys()) self.variables = variables self.domains = domains self.neighbors = neighbors self.constraints = constraints self.initial = () self.curr_domains = None self.nassigns = 0 self.n_bt = 0 def assign(self, var, val, assignment): """Add {var: val} to assignment; Discard the old value if any.""" assignment[var] = val self.nassigns += 1 def unassign(self, var, assignment): """Remove {var: val} from assignment. DO NOT call this if you are changing a variable to a new value; just call assign for that.""" if var in assignment: del assignment[var] # @Modified: the original used a recursive function, in my opinion this one looks better # and is easier to understand def nconflicts(self, var, val, assignment): """Return the number of conflicts var=val has with other variables.""" count = 0 for var2 in self.neighbors.get(var): val2 = None if assignment.__contains__(var2): val2 = assignment[var2] if val2 is not None and self.constraints(var, val, var2, val2) is False: count += 1 return count def display(self, assignment): """Show a human-readable representation of the CSP.""" # Subclasses can print in a prettier way, or display with a GUI print('CSP:', self, 'with assignment:', assignment) def goal_test(self, state): """The goal is to assign all variables, with all constraints satisfied.""" assignment = dict(state) return (len(assignment) == len(self.variables) and all(self.nconflicts(variables, assignment[variables], assignment) == 0 for variables in self.variables)) # These are for constraint propagation def support_pruning(self): """Make sure we can prune values from domains. (We want to pay for this only if we use it.)""" if self.curr_domains is None: self.curr_domains = {v: list(self.domains[v]) for v in self.variables} def suppose(self, var, value): """Start accumulating inferences from assuming var=value.""" self.support_pruning() removals = [(var, a) for a in self.curr_domains[var] if a != value] self.curr_domains[var] = [value] return removals def prune(self, var, value, removals): """Rule out var=value.""" self.curr_domains[var].remove(value) if removals is not None: removals.append((var, value)) def choices(self, var): """Return all values for var that aren't currently ruled out.""" return (self.curr_domains or self.domains)[var] def restore(self, removals): """Undo a supposition and all inferences from it.""" for B, b in removals: self.curr_domains[B].append(b) # ______________a________________________________________________________________ # Constraint Propagation with AC-3 def AC3(csp, queue=None, removals=None): """[Figure 6.3]""" if queue is None: queue = [(Xi, Xk) for Xi in csp.variables for Xk in csp.neighbors[Xi]] csp.support_pruning() while queue: (Xi, Xj) = queue.pop() if revise(csp, Xi, Xj, removals): if not csp.curr_domains[Xi]: return False for Xk in csp.neighbors[Xi]: if Xk != Xi: queue.append((Xk, Xi)) return True def revise(csp, Xi, Xj, removals): """Return true if we remove a value.""" revised = False for x in csp.curr_domains[Xi][:]: # If Xi=x conflicts with Xj=y for every possible y, eliminate Xi=x if all(not csp.constraints(Xi, x, Xj, y) for y in csp.curr_domains[Xj]): csp.prune(Xi, x, removals) revised = True return revised # ______________________________________________________________________________ # CSP Backtracking Search # Variable ordering # @Modified: we just want the first one that haven't been assigned so returning fast is good def first_unassigned_variable(assignment, csp): """The default variable order.""" for var in csp.variables: if var not in assignment: return var # @Modified: the original used a function from util files and was harder to understand, # it also apparently used 2 for loops: one to find the minimum and # other one to create a list (and a lambda function) def mrv(assignment, csp): """Minimum-remaining-values heuristic.""" vars_to_check = [] size = [] for v in csp.variables: if v not in assignment.keys(): vars_to_check.append(v) size.append(num_legal_values(csp, v, assignment)) return vars_to_check[size.index(min(size))] # @Modified: the original used a function count and a list, in my opinion it is faster to # just count with a loop 'for' without calling external functions def num_legal_values(csp, var, assignment): if csp.curr_domains: return len(csp.curr_domains[var]) else: count = 0 for val in csp.domains[var]: if csp.nconflicts(var, val, assignment) == 0: count += 1 return count # Value ordering def unordered_domain_values(var, assignment, csp): """The default value order.""" return csp.choices(var) def lcv(var, assignment, csp): """Least-constraining-values heuristic.""" return sorted(csp.choices(var), key=lambda val: csp.nconflicts(var, val, assignment)) # Inference def no_inference(csp, var, value, assignment, removals): return True def forward_checking(csp, var, value, assignment, removals): """Prune neighbor values inconsistent with var=value.""" for B in csp.neighbors[var]: if B not in assignment: for b in csp.curr_domains[B][:]: if not csp.constraints(var, value, B, b): csp.prune(B, b, removals) if not csp.curr_domains[B]: return False return True def mac(csp, var, value, assignment, removals): """Maintain arc consistency.""" return AC3(csp, [(X, var) for X in csp.neighbors[var]], removals) # The search, proper # @Modified: we should notice that with MRV it works good since the partial initial state # leaves some variables with unitary domain so we will start to assign these variables. # Added csp.n_bt+=1 def backtracking_search(csp, select_unassigned_variable, order_domain_values, inference): """[Figure 6.5]""" def backtrack(assignment): if len(assignment) == len(csp.variables): return assignment var = select_unassigned_variable(assignment, csp) for value in order_domain_values(var, assignment, csp): if 0 == csp.nconflicts(var, value, assignment): csp.assign(var, value, assignment) removals = csp.suppose(var, value) if inference(csp, var, value, assignment, removals): result = backtrack(assignment) if result is not None: return result else: csp.n_bt += 1 csp.restore(removals) csp.unassign(var, assignment) return None result = backtrack({}) assert result is None or csp.goal_test(result) return result def different_values_constraint(A, a, B, b): """A constraint saying two neighboring variables must differ in value.""" return a != b
"""CSP (Constraint Satisfaction Problems) problems and solvers. (Chapter 6).""" class Csp: """This class describes finite-domain Constraint Satisfaction Problems. A CSP is specified by the following inputs: variables A list of variables; each is atomic (e.g. int or string). domains A dict of {var:[possible_value, ...]} entries. neighbors A dict of {var:[var,...]} that for each variable lists the other variables that participate in constraints. constraints A function f(A, a, B, b) that returns true if neighbors A, B satisfy the constraint when they have values A=a, B=b In the textbook and in most mathematical definitions, the constraints are specified as explicit pairs of allowable values, but the formulation here is easier to express and more compact for most cases. (For example, the n-Queens problem can be represented in O(n) space using this notation, instead of O(N^4) for the explicit representation.) In terms of describing the CSP as a problem, that's all there is. However, the class also supports data structures and methods that help you solve CSPs by calling a search function on the CSP. Methods and slots are as follows, where the argument 'a' represents an assignment, which is a dict of {var:val} entries: assign(var, val, a) Assign a[var] = val; do other bookkeeping unassign(var, a) Do del a[var], plus other bookkeeping nconflicts(var, val, a) Return the number of other variables that conflict with var=val curr_domains[var] Slot: remaining consistent values for var Used by constraint propagation routines. The following methods are used only by graph_search and tree_search: actions(state) Return a list of actions result(state, action) Return a successor of state goal_test(state) Return true if all constraints satisfied The following are just for debugging purposes: nassigns Slot: tracks the number of assignments made display(a) Print a human-readable representation """ def __init__(self, variables, domains, neighbors, constraints): """Construct a CSP problem. If variables is empty, it becomes domains.keys().""" variables = variables or list(domains.keys()) self.variables = variables self.domains = domains self.neighbors = neighbors self.constraints = constraints self.initial = () self.curr_domains = None self.nassigns = 0 self.n_bt = 0 def assign(self, var, val, assignment): """Add {var: val} to assignment; Discard the old value if any.""" assignment[var] = val self.nassigns += 1 def unassign(self, var, assignment): """Remove {var: val} from assignment. DO NOT call this if you are changing a variable to a new value; just call assign for that.""" if var in assignment: del assignment[var] def nconflicts(self, var, val, assignment): """Return the number of conflicts var=val has with other variables.""" count = 0 for var2 in self.neighbors.get(var): val2 = None if assignment.__contains__(var2): val2 = assignment[var2] if val2 is not None and self.constraints(var, val, var2, val2) is False: count += 1 return count def display(self, assignment): """Show a human-readable representation of the CSP.""" print('CSP:', self, 'with assignment:', assignment) def goal_test(self, state): """The goal is to assign all variables, with all constraints satisfied.""" assignment = dict(state) return len(assignment) == len(self.variables) and all((self.nconflicts(variables, assignment[variables], assignment) == 0 for variables in self.variables)) def support_pruning(self): """Make sure we can prune values from domains. (We want to pay for this only if we use it.)""" if self.curr_domains is None: self.curr_domains = {v: list(self.domains[v]) for v in self.variables} def suppose(self, var, value): """Start accumulating inferences from assuming var=value.""" self.support_pruning() removals = [(var, a) for a in self.curr_domains[var] if a != value] self.curr_domains[var] = [value] return removals def prune(self, var, value, removals): """Rule out var=value.""" self.curr_domains[var].remove(value) if removals is not None: removals.append((var, value)) def choices(self, var): """Return all values for var that aren't currently ruled out.""" return (self.curr_domains or self.domains)[var] def restore(self, removals): """Undo a supposition and all inferences from it.""" for (b, b) in removals: self.curr_domains[B].append(b) def ac3(csp, queue=None, removals=None): """[Figure 6.3]""" if queue is None: queue = [(Xi, Xk) for xi in csp.variables for xk in csp.neighbors[Xi]] csp.support_pruning() while queue: (xi, xj) = queue.pop() if revise(csp, Xi, Xj, removals): if not csp.curr_domains[Xi]: return False for xk in csp.neighbors[Xi]: if Xk != Xi: queue.append((Xk, Xi)) return True def revise(csp, Xi, Xj, removals): """Return true if we remove a value.""" revised = False for x in csp.curr_domains[Xi][:]: if all((not csp.constraints(Xi, x, Xj, y) for y in csp.curr_domains[Xj])): csp.prune(Xi, x, removals) revised = True return revised def first_unassigned_variable(assignment, csp): """The default variable order.""" for var in csp.variables: if var not in assignment: return var def mrv(assignment, csp): """Minimum-remaining-values heuristic.""" vars_to_check = [] size = [] for v in csp.variables: if v not in assignment.keys(): vars_to_check.append(v) size.append(num_legal_values(csp, v, assignment)) return vars_to_check[size.index(min(size))] def num_legal_values(csp, var, assignment): if csp.curr_domains: return len(csp.curr_domains[var]) else: count = 0 for val in csp.domains[var]: if csp.nconflicts(var, val, assignment) == 0: count += 1 return count def unordered_domain_values(var, assignment, csp): """The default value order.""" return csp.choices(var) def lcv(var, assignment, csp): """Least-constraining-values heuristic.""" return sorted(csp.choices(var), key=lambda val: csp.nconflicts(var, val, assignment)) def no_inference(csp, var, value, assignment, removals): return True def forward_checking(csp, var, value, assignment, removals): """Prune neighbor values inconsistent with var=value.""" for b in csp.neighbors[var]: if B not in assignment: for b in csp.curr_domains[B][:]: if not csp.constraints(var, value, B, b): csp.prune(B, b, removals) if not csp.curr_domains[B]: return False return True def mac(csp, var, value, assignment, removals): """Maintain arc consistency.""" return ac3(csp, [(X, var) for x in csp.neighbors[var]], removals) def backtracking_search(csp, select_unassigned_variable, order_domain_values, inference): """[Figure 6.5]""" def backtrack(assignment): if len(assignment) == len(csp.variables): return assignment var = select_unassigned_variable(assignment, csp) for value in order_domain_values(var, assignment, csp): if 0 == csp.nconflicts(var, value, assignment): csp.assign(var, value, assignment) removals = csp.suppose(var, value) if inference(csp, var, value, assignment, removals): result = backtrack(assignment) if result is not None: return result else: csp.n_bt += 1 csp.restore(removals) csp.unassign(var, assignment) return None result = backtrack({}) assert result is None or csp.goal_test(result) return result def different_values_constraint(A, a, B, b): """A constraint saying two neighboring variables must differ in value.""" return a != b
class Error(Exception): message = None def __str__(self): return repr(self.message) class GSLZeroDivision(Error): message = "GSL encountered zero division" class GSLFailure(Error): message = "GSL failed" class GSLMemoryFailure(Error): message = "GSL failed to allocate necessary memory" class EFSMTruncationIndexExceeded(Error): message = "Index of truncation exceeds permissible range" class EFSMCompilationError(Error): message = "Import error, perhaps you forgot to run 'make'?" class EFSMConvergenceParam(Error): message = "Could not estimate convergence parameter" class EFSMMaximumIterationExceeded(Error): message = "Exceeded maximum number of iterations allowed" class EFSMFailure(Error): message = "EFSM failed" gsl_error_mapping = { -1: GSLFailure, 8: GSLMemoryFailure, 12: GSLZeroDivision }
class Error(Exception): message = None def __str__(self): return repr(self.message) class Gslzerodivision(Error): message = 'GSL encountered zero division' class Gslfailure(Error): message = 'GSL failed' class Gslmemoryfailure(Error): message = 'GSL failed to allocate necessary memory' class Efsmtruncationindexexceeded(Error): message = 'Index of truncation exceeds permissible range' class Efsmcompilationerror(Error): message = "Import error, perhaps you forgot to run 'make'?" class Efsmconvergenceparam(Error): message = 'Could not estimate convergence parameter' class Efsmmaximumiterationexceeded(Error): message = 'Exceeded maximum number of iterations allowed' class Efsmfailure(Error): message = 'EFSM failed' gsl_error_mapping = {-1: GSLFailure, 8: GSLMemoryFailure, 12: GSLZeroDivision}
""" Tema: Recursividad y Factoriales. Curso: Pensamiento computacional. Plataforma: Platzi. Profesor: David Aroesti. Alumno: @edinsonrequena. """ def factorial(n): """Calcula el factorial de n n int > 0 returns n! """ print(n) if n == 1: return 1 return n * factorial(n - 1) def main(): a = int(input("Escribe un entero: ")) print(factorial(a)) if '__main__' == __name__: main()
""" Tema: Recursividad y Factoriales. Curso: Pensamiento computacional. Plataforma: Platzi. Profesor: David Aroesti. Alumno: @edinsonrequena. """ def factorial(n): """Calcula el factorial de n n int > 0 returns n! """ print(n) if n == 1: return 1 return n * factorial(n - 1) def main(): a = int(input('Escribe un entero: ')) print(factorial(a)) if '__main__' == __name__: main()
# coding=utf-8 class TestTeamcityMessages: def testPass(self): pass def testAssertEqual(self): assert (True == True) def testAssertEqualFails(self): assert 1 == 2 def testAssertFalse(self): assert False def testException(self): raise Exception("some exception")
class Testteamcitymessages: def test_pass(self): pass def test_assert_equal(self): assert True == True def test_assert_equal_fails(self): assert 1 == 2 def test_assert_false(self): assert False def test_exception(self): raise exception('some exception')
volatile = False log_norm = False # Maximal sequence length in training data max_seq_len = 50 ''' Embedding layer ''' # Size of word embedding of source word and target word src_wemb_size = 512 trg_wemb_size = 512 ''' Encoder layer ''' # Size of hidden units in encoder enc_hid_size = 512 ''' Attention layer ''' # Size of alignment vector align_size = 512 ''' Decoder layer ''' # Size of hidden units in decoder dec_hid_size = 512 # Size of the output vector out_size = 512 drop_rate = 0.5 # Directory to save model, test output and validation output dir_model = 'wmodel' dir_valid = 'wvalid' dir_tests = 'wtests' # Validation data val_shuffle = True #val_tst_dir = '/home/wen/3.corpus/allnist_stanfordseg_jiujiu/' #val_tst_dir = '/home5/wen/2.data/allnist_stanseg/' #val_tst_dir = '/home5/wen/2.data/segment_allnist_stanseg/' #val_tst_dir = '/home5/wen/2.data/segment_allnist_stanseg_low/' #val_tst_dir = '/home5/wen/2.data/mt/nist_data_stanseg/' val_tst_dir = '/home/wen/3.corpus/mt/nist_data_stanseg/' #val_tst_dir = '/home/wen/3.corpus/segment_allnist_stanseg/' #val_tst_dir = '/home/wen/3.corpus/wmt2017/de-en/' #val_tst_dir = './data/' #val_prefix = 'wmt17.dev' val_prefix = 'nist02' #val_prefix = 'devset1_2.lc' #val_prefix = 'newstest2014.tc' val_src_suffix = 'src' val_ref_suffix = 'ref.plain_' #val_src_suffix = 'zh' #val_ref_suffix = 'en' #val_src_suffix = 'en' #val_ref_suffix = 'de' ref_cnt = 4 #tests_prefix = ['nist02', 'nist03', 'nist04', 'nist05', 'nist06', 'nist08', 'wmt17.tst'] tests_prefix = ['nist03', 'nist04', 'nist05', 'nist06', 'nist08'] #tests_prefix = ['data2', 'data3', 'test'] #tests_prefix = ['devset3.lc', '900'] #tests_prefix = ['devset3.lc'] #tests_prefix = ['newstest2015.tc', 'newstest2016.tc', 'newstest2017.tc'] #tests_prefix = None # Training data train_shuffle = True batch_size = 80 sort_k_batches = 20 # Data path dir_data = 'data/' train_src = dir_data + 'train.src' train_trg = dir_data + 'train.trg' # Dictionary src_vocab_from = train_src trg_vocab_from = train_trg src_dict_size = 30000 trg_dict_size = 30000 src_dict = dir_data + 'src.dict.tcf' trg_dict = dir_data + 'trg.dict.tcf' inputs_data = dir_data + 'inputs.pt' # Training max_epochs = 30 epoch_shuffle = False epoch_shuffle_minibatch = 1 small = False display_freq = 10 if small else 1000 sampling_freq = 100 if small else 5000 sample_size = 5 if_fixed_sampling = False epoch_eval = False final_test = False eval_valid_from = 20 if small else 50000 eval_valid_freq = 50 if small else 20000 save_one_model = True start_epoch = 1 model_prefix = dir_model + '/model' best_model = dir_valid + '/best.model.pt' if dir_valid else 'best.model.pt' # pretrained model #pre_train = None pre_train = best_model fix_pre_params = True # decoder hype-parameters search_mode = 1 with_batch = 1 ori_search = 0 beam_size = 10 vocab_norm = 1 len_norm = 1 with_mv = 0 merge_way = 'Y' avg_att = 0 m_threshold = 100. ngram = 3 length_norm = 0. cover_penalty = 0. # optimizer ''' Starting learning rate. If adagrad/adadelta/adam is used, then this is the global learning rate. Recommended settings: sgd = 1, adagrad = 0.1, adadelta = 1, adam = 0.001 ''' opt_mode = 'adadelta' learning_rate = 1.0 #opt_mode = 'adam' #learning_rate = 1e-3 #opt_mode = 'sgd' #learning_rate = 1. max_grad_norm = 1.0 # Start decaying every epoch after and including this epoch start_decay_from = None learning_rate_decay = 0.5 last_valid_bleu = 0. snip_size = 10 file_tran_dir = 'wexp-gpu-nist03' laynorm = False segments = False seg_val_tst_dir = 'orule_1.7' # model enc_rnn_type = 'sru' # rnn, gru, lstm, sru enc_layer_cnt = 4 dec_rnn_type = 'sru' # rnn, gru, lstm, sru dec_layer_cnt = 4 with_bpe = False with_postproc = True copy_trg_emb = False # 0: groundhog, 1: rnnsearch, 2: ia, 3: ran, 4: rn, 5: sru, 6: cyknet model = 4 # convolutional layer #filter_window_size = [1, 3, 5] # windows size filter_window_size = [1] # windows size #filter_feats_size = [32, 64, 96] filter_feats_size = [96] mlp_size = 256 # generate BTG tree when decoding dynamic_cyk_decoding = False print_att = True # Scheduled Sampling of Samy bengio's paper ss_type = 1 # 1: linear decay, 2: exponential decay, 3: inverse sigmoid decay ss_eps_begin = 1 # set None for no scheduled sampling ss_eps_end = 1 #ss_decay_rate = 0.005 ss_decay_rate = (ss_eps_begin - ss_eps_end) / 10. ss_k = 0.98 # k < 1 for exponential decay, k >= 1 for inverse sigmoid decay # free parameter for self-normalization # 0 is equivalent to the standard neural network objective function. self_norm_alpha = None nonlocal_mode = 'dot' # gaussian, dot, embeddedGaussian #dec_gpu_id = [1] #dec_gpu_id = None gpu_id = [0] #gpu_id = None
volatile = False log_norm = False max_seq_len = 50 '\nEmbedding layer\n' src_wemb_size = 512 trg_wemb_size = 512 '\nEncoder layer\n' enc_hid_size = 512 '\nAttention layer\n' align_size = 512 '\nDecoder layer\n' dec_hid_size = 512 out_size = 512 drop_rate = 0.5 dir_model = 'wmodel' dir_valid = 'wvalid' dir_tests = 'wtests' val_shuffle = True val_tst_dir = '/home/wen/3.corpus/mt/nist_data_stanseg/' val_prefix = 'nist02' val_src_suffix = 'src' val_ref_suffix = 'ref.plain_' ref_cnt = 4 tests_prefix = ['nist03', 'nist04', 'nist05', 'nist06', 'nist08'] train_shuffle = True batch_size = 80 sort_k_batches = 20 dir_data = 'data/' train_src = dir_data + 'train.src' train_trg = dir_data + 'train.trg' src_vocab_from = train_src trg_vocab_from = train_trg src_dict_size = 30000 trg_dict_size = 30000 src_dict = dir_data + 'src.dict.tcf' trg_dict = dir_data + 'trg.dict.tcf' inputs_data = dir_data + 'inputs.pt' max_epochs = 30 epoch_shuffle = False epoch_shuffle_minibatch = 1 small = False display_freq = 10 if small else 1000 sampling_freq = 100 if small else 5000 sample_size = 5 if_fixed_sampling = False epoch_eval = False final_test = False eval_valid_from = 20 if small else 50000 eval_valid_freq = 50 if small else 20000 save_one_model = True start_epoch = 1 model_prefix = dir_model + '/model' best_model = dir_valid + '/best.model.pt' if dir_valid else 'best.model.pt' pre_train = best_model fix_pre_params = True search_mode = 1 with_batch = 1 ori_search = 0 beam_size = 10 vocab_norm = 1 len_norm = 1 with_mv = 0 merge_way = 'Y' avg_att = 0 m_threshold = 100.0 ngram = 3 length_norm = 0.0 cover_penalty = 0.0 '\nStarting learning rate. If adagrad/adadelta/adam is used, then this is the global learning rate.\nRecommended settings: sgd = 1, adagrad = 0.1, adadelta = 1, adam = 0.001\n' opt_mode = 'adadelta' learning_rate = 1.0 max_grad_norm = 1.0 start_decay_from = None learning_rate_decay = 0.5 last_valid_bleu = 0.0 snip_size = 10 file_tran_dir = 'wexp-gpu-nist03' laynorm = False segments = False seg_val_tst_dir = 'orule_1.7' enc_rnn_type = 'sru' enc_layer_cnt = 4 dec_rnn_type = 'sru' dec_layer_cnt = 4 with_bpe = False with_postproc = True copy_trg_emb = False model = 4 filter_window_size = [1] filter_feats_size = [96] mlp_size = 256 dynamic_cyk_decoding = False print_att = True ss_type = 1 ss_eps_begin = 1 ss_eps_end = 1 ss_decay_rate = (ss_eps_begin - ss_eps_end) / 10.0 ss_k = 0.98 self_norm_alpha = None nonlocal_mode = 'dot' gpu_id = [0]
# PROBLEM # # Now write a program that calculates the minimum fixed monthly payment needed # in order to pay off a credit card balance within 12 months. By a fixed # monthly payment, we mean a single number which does not change each month, # but instead is a constant amount that will be paid each month. # # In this problem, we will not be dealing with a minimum monthly payment rate. # # The following variables contain values as described below: # 1. balance - the outstanding balance on the credit card # 2. annualInterestRate - annual interest rate as a decimal # # The program should print out one line: the lowest monthly payment that will # pay off all debt in under 1 year, for example: # # 'Lowest Payment: 180' # # Assume that the interest is compounded monthly according to the balance at # the end of the month (after the payment for that month is made). The monthly # payment must be a multiple of $10 and is the same for all months. Notice # that it is possible for the balance to become negative using this payment # scheme, which is okay. # For test purposes balance = 5000 annualInterestRate = 0.18 # SOLUTION def yearEndBalance(balance, monthlyPayment): ''' balance: outstanding balance on the credit card (int or float) monthlyPayment: fixed monthly payment (int or float) returns: ending balance on the credit card after 12 months (int or float) ''' for month in range(12): balance = (balance - monthlyPayment) * (1 + monthlyInterestRate) return balance monthlyInterestRate = annualInterestRate / 12.0 monthlyPayment = 10*int(balance/12/10) # Initial guess set as 1/12th of balance while yearEndBalance(balance, monthlyPayment) > 0: monthlyPayment += 10 print('Lowest Payment:', monthlyPayment)
balance = 5000 annual_interest_rate = 0.18 def year_end_balance(balance, monthlyPayment): """ balance: outstanding balance on the credit card (int or float) monthlyPayment: fixed monthly payment (int or float) returns: ending balance on the credit card after 12 months (int or float) """ for month in range(12): balance = (balance - monthlyPayment) * (1 + monthlyInterestRate) return balance monthly_interest_rate = annualInterestRate / 12.0 monthly_payment = 10 * int(balance / 12 / 10) while year_end_balance(balance, monthlyPayment) > 0: monthly_payment += 10 print('Lowest Payment:', monthlyPayment)
##Hello World Example #!/user/bin/env python3 print("Hello", "world!")
print('Hello', 'world!')
buttons = { "brightness up": [9097, 4455, 635, 495, 629, 502, 632, 499, 636, 494, 630, 500, 603, 528, 627, 503, 632, 500, 603, 1628, 599, 1632, 606, 1625, 602, 1627, 600, 530, 604, 1626, 601, 1630, 628, 1603, 603, 529, 606, 525, 599, 532, 602, 530, 604, 528, 607, 524, 599, 532, 603, 528, 606, 1625, 610, 1622, 608, 1624, 603, 1627, 600, 1629, 598, 1630, 597, 1631, 596, 1634, 603], "brightness down": [9115, 4429, 629, 501, 633, 499, 635, 498, 636, 497, 628, 505, 632, 500, 631, 502, 633, 498, 626, 1610, 627, 1597, 630, 1602, 636, 1595, 631, 501, 634, 1598, 598, 1633, 635, 1595, 601, 1630, 627, 505, 629, 502, 633, 499, 604, 527, 631, 502, 629, 503, 600, 532, 634, 497, 606, 1624, 603, 1627, 600, 1630, 597, 1633, 605, 1624, 603, 1627, 600, 1629, 629], "off": [9093, 4428, 629, 500, 624, 505, 630, 499, 624, 506, 629, 500, 634, 496, 628, 502, 632, 498, 626, 1603, 625, 1604, 633, 1596, 631, 1598, 629, 500, 624, 1605, 636, 1594, 630, 1599, 628, 503, 631, 1598, 629, 501, 633, 498, 626, 504, 630, 501, 633, 497, 627, 503, 631, 1599, 628, 501, 634, 1596, 631, 1599, 628, 1601, 626, 1603, 625, 1605, 632, 1597, 630], "on": [9103, 4429, 627, 502, 633, 496, 628, 501, 633, 496, 628, 502, 632, 503, 621, 500, 624, 505, 629, 1599, 628, 1600, 627, 1600, 627, 1601, 626, 502, 633, 1595, 631, 1596, 632, 1596, 631, 1597, 629, 1599, 598, 530, 625, 503, 600, 528, 596, 531, 624, 504, 599, 529, 626, 502, 632, 497, 596, 1631, 596, 1632, 595, 1633, 625, 1603, 604, 1624, 603, 1625, 601], "red": [9119, 4420, 627, 503, 631, 495, 629, 499, 625, 503, 631, 497, 627, 502, 633, 494, 629, 499, 625, 1602, 626, 1602, 625, 1602, 624, 1603, 624, 503, 631, 1597, 630, 1597, 630, 1596, 631, 497, 627, 500, 623, 1604, 623, 505, 630, 497, 627, 501, 633, 495, 629, 499, 625, 1604, 623, 1605, 632, 497, 627, 1601, 626, 1602, 636, 1592, 624, 1605, 632, 1596, 631], "green": [9083, 4424, 623, 505, 630, 498, 625, 503, 653, 476, 627, 502, 632, 496, 628, 501, 633, 496, 628, 1600, 627, 1601, 626, 1602, 625, 1602, 625, 504, 630, 1598, 629, 1599, 668, 1560, 627, 1601, 626, 503, 631, 1597, 630, 499, 625, 504, 599, 529, 626, 503, 600, 528, 596, 532, 602, 1626, 632, 496, 597, 1631, 596, 1631, 596, 1631, 597, 1631, 596, 1631, 627], "blue": [9080, 4457, 631, 499, 625, 505, 598, 530, 604, 525, 599, 531, 604, 525, 630, 498, 605, 524, 600, 1628, 599, 1629, 598, 1630, 597, 1631, 596, 532, 602, 1627, 600, 1629, 598, 1631, 596, 533, 601, 1628, 599, 1631, 596, 533, 601, 528, 596, 533, 602, 531, 592, 533, 602, 1627, 600, 528, 596, 533, 601, 1627, 600, 1629, 598, 1630, 597, 1630, 597, 1631, 596], "white": [9045, 4456, 601, 526, 598, 530, 605, 524, 600, 528, 596, 532, 602, 526, 598, 530, 604, 523, 601, 1627, 600, 1628, 599, 1629, 598, 1631, 596, 532, 602, 1626, 601, 1627, 600, 1628, 599, 1629, 598, 1629, 598, 1630, 597, 532, 602, 526, 598, 531, 604, 525, 599, 529, 605, 524, 600, 528, 606, 522, 603, 1625, 601, 1627, 600, 1627, 600, 1627, 600, 1628, 599], "orangered": [9072, 4454, 655, 474, 597, 532, 602, 526, 598, 531, 604, 525, 598, 530, 605, 523, 600, 528, 596, 1632, 595, 1632, 595, 1632, 594, 1633, 594, 534, 601, 1627, 600, 1627, 600, 1628, 599, 530, 604, 526, 598, 530, 604, 1623, 604, 524, 600, 528, 596, 533, 601, 527, 597, 1631, 596, 1632, 605, 1624, 603, 525, 599, 1629, 597, 1631, 596, 1632, 595, 1632, 595], "mediumseagreen": [9058, 4453, 605, 523, 601, 528, 595, 544, 591, 528, 596, 533, 601, 527, 597, 532, 603, 525, 599, 1629, 598, 1629, 598, 1630, 597, 1630, 596, 533, 602, 1625, 602, 1626, 632, 1595, 601, 1626, 632, 496, 628, 500, 624, 1603, 624, 504, 630, 497, 627, 501, 633, 494, 630, 498, 626, 1601, 626, 1601, 625, 503, 632, 1595, 631, 1597, 630, 1597, 630, 1598, 629], "duke blue": [9048, 4454, 634, 494, 598, 530, 625, 504, 599, 529, 626, 502, 601, 527, 628, 500, 624, 504, 630, 1597, 630, 1598, 630, 1597, 629, 1599, 628, 500, 624, 1603, 624, 1603, 634, 1594, 633, 495, 629, 1599, 628, 500, 634, 1594, 633, 495, 629, 500, 634, 495, 629, 499, 625, 1603, 634, 494, 634, 1594, 629, 500, 624, 1603, 634, 1594, 633, 1595, 632, 1595, 632], "flash": [9093, 4425, 601, 527, 629, 499, 625, 503, 631, 497, 596, 532, 602, 526, 598, 530, 605, 523, 600, 1627, 601, 1627, 600, 1627, 600, 1628, 599, 529, 605, 1623, 604, 1624, 603, 1625, 603, 1625, 602, 1626, 601, 526, 598, 1629, 598, 530, 604, 523, 601, 527, 597, 531, 604, 524, 600, 528, 596, 1631, 600, 529, 601, 1626, 601, 1627, 600, 1627, 600, 1628, 599], "darkorange": [9091, 4425, 601, 528, 596, 533, 643, 486, 597, 532, 602, 527, 597, 532, 602, 527, 597, 532, 602, 1627, 600, 1628, 599, 1630, 597, 1631, 596, 533, 601, 1628, 599, 1629, 598, 1631, 596, 543, 592, 526, 597, 1632, 595, 1633, 605, 524, 600, 528, 596, 533, 601, 527, 597, 1632, 605, 1623, 604, 526, 598, 532, 602, 1629, 598, 1631, 607, 1623, 604, 1626, 601], "carolina blue": [9086, 4456, 602, 528, 606, 525, 599, 537, 598, 528, 606, 525, 599, 532, 602, 528, 596, 534, 600, 1630, 598, 1632, 608, 1622, 602, 1628, 599, 531, 603, 1627, 600, 1629, 598, 1632, 595, 1634, 604, 524, 600, 1629, 598, 1631, 596, 533, 602, 526, 598, 532, 602, 527, 597, 532, 602, 1627, 600, 529, 605, 524, 600, 1629, 598, 1631, 596, 1633, 605, 1624, 603], "purple": [9081, 4425, 632, 496, 629, 499, 624, 505, 630, 498, 626, 506, 628, 497, 628, 500, 634, 494, 630, 1599, 628, 1600, 627, 1601, 626, 1604, 623, 503, 632, 1596, 630, 1598, 630, 1598, 629, 499, 625, 1604, 633, 1595, 632, 1596, 631, 498, 626, 502, 632, 496, 628, 501, 633, 1596, 635, 495, 625, 505, 630, 501, 633, 1596, 631, 1597, 630, 1599, 628, 1601, 626], "strobe": [9081, 4424, 633, 496, 628, 501, 634, 495, 628, 501, 634, 496, 628, 502, 632, 497, 627, 502, 601, 1628, 599, 1630, 597, 1632, 595, 1633, 604, 525, 599, 1630, 597, 1632, 605, 1624, 603, 1626, 601, 1628, 599, 1630, 597, 1632, 605, 524, 600, 529, 595, 533, 602, 527, 596, 533, 602, 527, 597, 531, 603, 526, 598, 1631, 596, 1632, 605, 1624, 603, 1626, 601], "orange": [9082, 4424, 602, 527, 628, 500, 635, 494, 630, 499, 635, 494, 599, 531, 634, 494, 630, 499, 604, 1625, 634, 1594, 632, 1597, 630, 1598, 629, 500, 635, 1594, 633, 1595, 632, 1597, 630, 498, 626, 503, 632, 497, 627, 502, 632, 1596, 631, 497, 627, 502, 632, 496, 628, 1600, 627, 1601, 626, 1602, 626, 1601, 626, 502, 632, 1597, 630, 1599, 628, 1600, 627], "lightseagreen": [9084, 4461, 597, 533, 601, 528, 596, 533, 601, 527, 628, 501, 633, 496, 597, 531, 603, 527, 597, 1632, 595, 1634, 624, 1604, 634, 1594, 633, 496, 628, 1600, 626, 1603, 624, 1604, 634, 1595, 632, 498, 605, 525, 599, 531, 634, 1594, 633, 496, 628, 500, 634, 495, 629, 499, 625, 1604, 634, 1594, 643, 1586, 631, 497, 627, 1602, 625, 1603, 624, 1604, 633], "mediumorchid": [9100, 4455, 603, 528, 606, 525, 599, 532, 602, 529, 606, 525, 599, 532, 602, 529, 606, 525, 599, 1636, 601, 1628, 599, 1631, 596, 1634, 603, 527, 597, 1633, 604, 1625, 602, 1628, 599, 532, 602, 1628, 599, 533, 602, 526, 597, 1633, 605, 526, 598, 533, 601, 530, 605, 1626, 601, 530, 604, 1637, 590, 1631, 607, 524, 600, 1630, 597, 1634, 603, 1628, 602], "fade": [9084, 4459, 599, 532, 602, 529, 605, 525, 599, 532, 602, 528, 607, 524, 599, 532, 603, 528, 595, 1634, 604, 1626, 600, 1629, 598, 1632, 606, 524, 599, 1631, 596, 1634, 604, 1626, 601, 1629, 598, 1631, 596, 534, 600, 528, 596, 1633, 604, 525, 599, 530, 604, 531, 593, 529, 596, 533, 601, 1628, 599, 1630, 597, 532, 602, 1627, 600, 1629, 630, 1599, 597], "yellow": [9075, 4432, 625, 503, 631, 497, 627, 502, 632, 496, 628, 500, 634, 494, 630, 498, 625, 503, 632, 1597, 630, 1598, 629, 1600, 596, 1631, 627, 502, 632, 1597, 630, 1599, 628, 1603, 635, 496, 628, 502, 601, 1629, 598, 533, 632, 1599, 597, 534, 632, 500, 634, 497, 606, 1625, 633, 1598, 598, 536, 598, 1629, 598, 543, 591, 1628, 599, 1631, 596, 1633, 604], "teal": [9089, 4454, 602, 529, 626, 505, 599, 532, 602, 528, 627, 504, 631, 499, 635, 495, 629, 501, 633, 1605, 626, 1598, 626, 1605, 601, 1630, 628, 503, 632, 1599, 628, 1602, 604, 1628, 599, 1632, 626, 505, 598, 1633, 604, 528, 607, 1624, 634, 497, 627, 505, 629, 502, 632, 509, 626, 1595, 631, 499, 646, 1585, 631, 500, 635, 1595, 632, 1598, 629, 1601, 626], "pink": [9095, 4425, 633, 495, 629, 500, 634, 495, 629, 500, 624, 504, 631, 498, 626, 503, 631, 499, 636, 1595, 632, 1596, 631, 1598, 629, 1599, 628, 501, 633, 1595, 632, 1596, 632, 1597, 599, 528, 596, 1632, 595, 1633, 604, 524, 600, 1627, 600, 528, 596, 531, 604, 524, 600, 1628, 599, 529, 595, 533, 604, 1623, 601, 527, 636, 1592, 596, 1632, 605, 1624, 603], "smooth": [9078, 4423, 635, 495, 629, 502, 632, 498, 637, 494, 629, 501, 634, 497, 627, 503, 631, 499, 635, 1595, 632, 1598, 629, 1601, 626, 1604, 633, 497, 627, 1602, 625, 1605, 633, 1596, 631, 1598, 628, 1602, 625, 1604, 634, 496, 627, 1602, 625, 504, 631, 498, 636, 494, 630, 500, 634, 496, 628, 502, 633, 1597, 630, 501, 633, 1598, 629, 1601, 627, 1604, 633], } colors = { "red": (255,0,0), "green": (0,255,0), "blue": (0,0,255), "white": (255,255,255), "orangered": (255,69,0), "mediumseagreen": (60,179,113), "duke blue": (0,83,155), "darkorange": (255,140,0), "carolina blue": (123,175,233), "purple": (82,45,128), "orange": (155,165,0), "lightseagreen": (32,178,170), "mediumorchid": (186,85,211), "yellow": (255,255,0), "teal": (0,128,128), "pink": (255, 128, 255), }
buttons = {'brightness up': [9097, 4455, 635, 495, 629, 502, 632, 499, 636, 494, 630, 500, 603, 528, 627, 503, 632, 500, 603, 1628, 599, 1632, 606, 1625, 602, 1627, 600, 530, 604, 1626, 601, 1630, 628, 1603, 603, 529, 606, 525, 599, 532, 602, 530, 604, 528, 607, 524, 599, 532, 603, 528, 606, 1625, 610, 1622, 608, 1624, 603, 1627, 600, 1629, 598, 1630, 597, 1631, 596, 1634, 603], 'brightness down': [9115, 4429, 629, 501, 633, 499, 635, 498, 636, 497, 628, 505, 632, 500, 631, 502, 633, 498, 626, 1610, 627, 1597, 630, 1602, 636, 1595, 631, 501, 634, 1598, 598, 1633, 635, 1595, 601, 1630, 627, 505, 629, 502, 633, 499, 604, 527, 631, 502, 629, 503, 600, 532, 634, 497, 606, 1624, 603, 1627, 600, 1630, 597, 1633, 605, 1624, 603, 1627, 600, 1629, 629], 'off': [9093, 4428, 629, 500, 624, 505, 630, 499, 624, 506, 629, 500, 634, 496, 628, 502, 632, 498, 626, 1603, 625, 1604, 633, 1596, 631, 1598, 629, 500, 624, 1605, 636, 1594, 630, 1599, 628, 503, 631, 1598, 629, 501, 633, 498, 626, 504, 630, 501, 633, 497, 627, 503, 631, 1599, 628, 501, 634, 1596, 631, 1599, 628, 1601, 626, 1603, 625, 1605, 632, 1597, 630], 'on': [9103, 4429, 627, 502, 633, 496, 628, 501, 633, 496, 628, 502, 632, 503, 621, 500, 624, 505, 629, 1599, 628, 1600, 627, 1600, 627, 1601, 626, 502, 633, 1595, 631, 1596, 632, 1596, 631, 1597, 629, 1599, 598, 530, 625, 503, 600, 528, 596, 531, 624, 504, 599, 529, 626, 502, 632, 497, 596, 1631, 596, 1632, 595, 1633, 625, 1603, 604, 1624, 603, 1625, 601], 'red': [9119, 4420, 627, 503, 631, 495, 629, 499, 625, 503, 631, 497, 627, 502, 633, 494, 629, 499, 625, 1602, 626, 1602, 625, 1602, 624, 1603, 624, 503, 631, 1597, 630, 1597, 630, 1596, 631, 497, 627, 500, 623, 1604, 623, 505, 630, 497, 627, 501, 633, 495, 629, 499, 625, 1604, 623, 1605, 632, 497, 627, 1601, 626, 1602, 636, 1592, 624, 1605, 632, 1596, 631], 'green': [9083, 4424, 623, 505, 630, 498, 625, 503, 653, 476, 627, 502, 632, 496, 628, 501, 633, 496, 628, 1600, 627, 1601, 626, 1602, 625, 1602, 625, 504, 630, 1598, 629, 1599, 668, 1560, 627, 1601, 626, 503, 631, 1597, 630, 499, 625, 504, 599, 529, 626, 503, 600, 528, 596, 532, 602, 1626, 632, 496, 597, 1631, 596, 1631, 596, 1631, 597, 1631, 596, 1631, 627], 'blue': [9080, 4457, 631, 499, 625, 505, 598, 530, 604, 525, 599, 531, 604, 525, 630, 498, 605, 524, 600, 1628, 599, 1629, 598, 1630, 597, 1631, 596, 532, 602, 1627, 600, 1629, 598, 1631, 596, 533, 601, 1628, 599, 1631, 596, 533, 601, 528, 596, 533, 602, 531, 592, 533, 602, 1627, 600, 528, 596, 533, 601, 1627, 600, 1629, 598, 1630, 597, 1630, 597, 1631, 596], 'white': [9045, 4456, 601, 526, 598, 530, 605, 524, 600, 528, 596, 532, 602, 526, 598, 530, 604, 523, 601, 1627, 600, 1628, 599, 1629, 598, 1631, 596, 532, 602, 1626, 601, 1627, 600, 1628, 599, 1629, 598, 1629, 598, 1630, 597, 532, 602, 526, 598, 531, 604, 525, 599, 529, 605, 524, 600, 528, 606, 522, 603, 1625, 601, 1627, 600, 1627, 600, 1627, 600, 1628, 599], 'orangered': [9072, 4454, 655, 474, 597, 532, 602, 526, 598, 531, 604, 525, 598, 530, 605, 523, 600, 528, 596, 1632, 595, 1632, 595, 1632, 594, 1633, 594, 534, 601, 1627, 600, 1627, 600, 1628, 599, 530, 604, 526, 598, 530, 604, 1623, 604, 524, 600, 528, 596, 533, 601, 527, 597, 1631, 596, 1632, 605, 1624, 603, 525, 599, 1629, 597, 1631, 596, 1632, 595, 1632, 595], 'mediumseagreen': [9058, 4453, 605, 523, 601, 528, 595, 544, 591, 528, 596, 533, 601, 527, 597, 532, 603, 525, 599, 1629, 598, 1629, 598, 1630, 597, 1630, 596, 533, 602, 1625, 602, 1626, 632, 1595, 601, 1626, 632, 496, 628, 500, 624, 1603, 624, 504, 630, 497, 627, 501, 633, 494, 630, 498, 626, 1601, 626, 1601, 625, 503, 632, 1595, 631, 1597, 630, 1597, 630, 1598, 629], 'duke blue': [9048, 4454, 634, 494, 598, 530, 625, 504, 599, 529, 626, 502, 601, 527, 628, 500, 624, 504, 630, 1597, 630, 1598, 630, 1597, 629, 1599, 628, 500, 624, 1603, 624, 1603, 634, 1594, 633, 495, 629, 1599, 628, 500, 634, 1594, 633, 495, 629, 500, 634, 495, 629, 499, 625, 1603, 634, 494, 634, 1594, 629, 500, 624, 1603, 634, 1594, 633, 1595, 632, 1595, 632], 'flash': [9093, 4425, 601, 527, 629, 499, 625, 503, 631, 497, 596, 532, 602, 526, 598, 530, 605, 523, 600, 1627, 601, 1627, 600, 1627, 600, 1628, 599, 529, 605, 1623, 604, 1624, 603, 1625, 603, 1625, 602, 1626, 601, 526, 598, 1629, 598, 530, 604, 523, 601, 527, 597, 531, 604, 524, 600, 528, 596, 1631, 600, 529, 601, 1626, 601, 1627, 600, 1627, 600, 1628, 599], 'darkorange': [9091, 4425, 601, 528, 596, 533, 643, 486, 597, 532, 602, 527, 597, 532, 602, 527, 597, 532, 602, 1627, 600, 1628, 599, 1630, 597, 1631, 596, 533, 601, 1628, 599, 1629, 598, 1631, 596, 543, 592, 526, 597, 1632, 595, 1633, 605, 524, 600, 528, 596, 533, 601, 527, 597, 1632, 605, 1623, 604, 526, 598, 532, 602, 1629, 598, 1631, 607, 1623, 604, 1626, 601], 'carolina blue': [9086, 4456, 602, 528, 606, 525, 599, 537, 598, 528, 606, 525, 599, 532, 602, 528, 596, 534, 600, 1630, 598, 1632, 608, 1622, 602, 1628, 599, 531, 603, 1627, 600, 1629, 598, 1632, 595, 1634, 604, 524, 600, 1629, 598, 1631, 596, 533, 602, 526, 598, 532, 602, 527, 597, 532, 602, 1627, 600, 529, 605, 524, 600, 1629, 598, 1631, 596, 1633, 605, 1624, 603], 'purple': [9081, 4425, 632, 496, 629, 499, 624, 505, 630, 498, 626, 506, 628, 497, 628, 500, 634, 494, 630, 1599, 628, 1600, 627, 1601, 626, 1604, 623, 503, 632, 1596, 630, 1598, 630, 1598, 629, 499, 625, 1604, 633, 1595, 632, 1596, 631, 498, 626, 502, 632, 496, 628, 501, 633, 1596, 635, 495, 625, 505, 630, 501, 633, 1596, 631, 1597, 630, 1599, 628, 1601, 626], 'strobe': [9081, 4424, 633, 496, 628, 501, 634, 495, 628, 501, 634, 496, 628, 502, 632, 497, 627, 502, 601, 1628, 599, 1630, 597, 1632, 595, 1633, 604, 525, 599, 1630, 597, 1632, 605, 1624, 603, 1626, 601, 1628, 599, 1630, 597, 1632, 605, 524, 600, 529, 595, 533, 602, 527, 596, 533, 602, 527, 597, 531, 603, 526, 598, 1631, 596, 1632, 605, 1624, 603, 1626, 601], 'orange': [9082, 4424, 602, 527, 628, 500, 635, 494, 630, 499, 635, 494, 599, 531, 634, 494, 630, 499, 604, 1625, 634, 1594, 632, 1597, 630, 1598, 629, 500, 635, 1594, 633, 1595, 632, 1597, 630, 498, 626, 503, 632, 497, 627, 502, 632, 1596, 631, 497, 627, 502, 632, 496, 628, 1600, 627, 1601, 626, 1602, 626, 1601, 626, 502, 632, 1597, 630, 1599, 628, 1600, 627], 'lightseagreen': [9084, 4461, 597, 533, 601, 528, 596, 533, 601, 527, 628, 501, 633, 496, 597, 531, 603, 527, 597, 1632, 595, 1634, 624, 1604, 634, 1594, 633, 496, 628, 1600, 626, 1603, 624, 1604, 634, 1595, 632, 498, 605, 525, 599, 531, 634, 1594, 633, 496, 628, 500, 634, 495, 629, 499, 625, 1604, 634, 1594, 643, 1586, 631, 497, 627, 1602, 625, 1603, 624, 1604, 633], 'mediumorchid': [9100, 4455, 603, 528, 606, 525, 599, 532, 602, 529, 606, 525, 599, 532, 602, 529, 606, 525, 599, 1636, 601, 1628, 599, 1631, 596, 1634, 603, 527, 597, 1633, 604, 1625, 602, 1628, 599, 532, 602, 1628, 599, 533, 602, 526, 597, 1633, 605, 526, 598, 533, 601, 530, 605, 1626, 601, 530, 604, 1637, 590, 1631, 607, 524, 600, 1630, 597, 1634, 603, 1628, 602], 'fade': [9084, 4459, 599, 532, 602, 529, 605, 525, 599, 532, 602, 528, 607, 524, 599, 532, 603, 528, 595, 1634, 604, 1626, 600, 1629, 598, 1632, 606, 524, 599, 1631, 596, 1634, 604, 1626, 601, 1629, 598, 1631, 596, 534, 600, 528, 596, 1633, 604, 525, 599, 530, 604, 531, 593, 529, 596, 533, 601, 1628, 599, 1630, 597, 532, 602, 1627, 600, 1629, 630, 1599, 597], 'yellow': [9075, 4432, 625, 503, 631, 497, 627, 502, 632, 496, 628, 500, 634, 494, 630, 498, 625, 503, 632, 1597, 630, 1598, 629, 1600, 596, 1631, 627, 502, 632, 1597, 630, 1599, 628, 1603, 635, 496, 628, 502, 601, 1629, 598, 533, 632, 1599, 597, 534, 632, 500, 634, 497, 606, 1625, 633, 1598, 598, 536, 598, 1629, 598, 543, 591, 1628, 599, 1631, 596, 1633, 604], 'teal': [9089, 4454, 602, 529, 626, 505, 599, 532, 602, 528, 627, 504, 631, 499, 635, 495, 629, 501, 633, 1605, 626, 1598, 626, 1605, 601, 1630, 628, 503, 632, 1599, 628, 1602, 604, 1628, 599, 1632, 626, 505, 598, 1633, 604, 528, 607, 1624, 634, 497, 627, 505, 629, 502, 632, 509, 626, 1595, 631, 499, 646, 1585, 631, 500, 635, 1595, 632, 1598, 629, 1601, 626], 'pink': [9095, 4425, 633, 495, 629, 500, 634, 495, 629, 500, 624, 504, 631, 498, 626, 503, 631, 499, 636, 1595, 632, 1596, 631, 1598, 629, 1599, 628, 501, 633, 1595, 632, 1596, 632, 1597, 599, 528, 596, 1632, 595, 1633, 604, 524, 600, 1627, 600, 528, 596, 531, 604, 524, 600, 1628, 599, 529, 595, 533, 604, 1623, 601, 527, 636, 1592, 596, 1632, 605, 1624, 603], 'smooth': [9078, 4423, 635, 495, 629, 502, 632, 498, 637, 494, 629, 501, 634, 497, 627, 503, 631, 499, 635, 1595, 632, 1598, 629, 1601, 626, 1604, 633, 497, 627, 1602, 625, 1605, 633, 1596, 631, 1598, 628, 1602, 625, 1604, 634, 496, 627, 1602, 625, 504, 631, 498, 636, 494, 630, 500, 634, 496, 628, 502, 633, 1597, 630, 501, 633, 1598, 629, 1601, 627, 1604, 633]} colors = {'red': (255, 0, 0), 'green': (0, 255, 0), 'blue': (0, 0, 255), 'white': (255, 255, 255), 'orangered': (255, 69, 0), 'mediumseagreen': (60, 179, 113), 'duke blue': (0, 83, 155), 'darkorange': (255, 140, 0), 'carolina blue': (123, 175, 233), 'purple': (82, 45, 128), 'orange': (155, 165, 0), 'lightseagreen': (32, 178, 170), 'mediumorchid': (186, 85, 211), 'yellow': (255, 255, 0), 'teal': (0, 128, 128), 'pink': (255, 128, 255)}
# Haystack settings for running tests. DATABASE_ENGINE = 'sqlite3' DATABASE_NAME = 'haystack_tests.db' INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'haystack', 'core', ] ROOT_URLCONF = 'core.urls' HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'core.tests.mocks.MockEngine', }, }
database_engine = 'sqlite3' database_name = 'haystack_tests.db' installed_apps = ['django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'haystack', 'core'] root_urlconf = 'core.urls' haystack_connections = {'default': {'ENGINE': 'core.tests.mocks.MockEngine'}}
def first_method(): """First sibling package method.""" return 1 def second_method(): """Second sibling package method.""" return 2
def first_method(): """First sibling package method.""" return 1 def second_method(): """Second sibling package method.""" return 2
# Python program for implementation of MergeSort(Implement Divide and conquer) # MergeSort(arr[], l, r) # If r > l # 1. Find the middle point to divide the array into two halves: # middle m = l+ (r-l)/2 # 2. Call mergeSort for first half: # Call mergeSort(arr, l, m) # 3. Call mergeSort for second half: # Call mergeSort(arr, m+1, r) # 4. Merge the two halves sorted in step 2 and 3: # Call merge(arr, l, m, r) def mergeSort(arr): if len(arr) > 1: mid = len(arr)//2 L = arr[:mid] R = arr[mid:] mergeSort(L) mergeSort(R) i = j = k = 0 while i < len(L) and j < len(R): if L[i] < R[j]: arr[k] = L[i] i += 1 else: arr[k] = R[j] j += 1 k += 1 while i < len(L): arr[k] = L[i] i += 1 k += 1 while j < len(R): arr[k] = R[j] j += 1 k += 1 def printList(arr): for i in range(len(arr)): print(arr[i], end=" ") print() if __name__ == '__main__': arr = [12, 11, 13, 5, 6, 7] print("Given array is", end="\n") printList(arr) mergeSort(arr) print("Sorted array is: ", end="\n") printList(arr) # Input: # Given array is # 12 11 13 5 6 7 # Output: # Given array is # 12 11 13 5 6 7 # Sorted array is: # 5 6 7 11 12 13
def merge_sort(arr): if len(arr) > 1: mid = len(arr) // 2 l = arr[:mid] r = arr[mid:] merge_sort(L) merge_sort(R) i = j = k = 0 while i < len(L) and j < len(R): if L[i] < R[j]: arr[k] = L[i] i += 1 else: arr[k] = R[j] j += 1 k += 1 while i < len(L): arr[k] = L[i] i += 1 k += 1 while j < len(R): arr[k] = R[j] j += 1 k += 1 def print_list(arr): for i in range(len(arr)): print(arr[i], end=' ') print() if __name__ == '__main__': arr = [12, 11, 13, 5, 6, 7] print('Given array is', end='\n') print_list(arr) merge_sort(arr) print('Sorted array is: ', end='\n') print_list(arr)
# -*- coding: utf-8 -*- """Class to represent binary data as hexadecimal.""" class Hexdump(object): """Class that defines a hexadecimal representation formatter (hexdump).""" @classmethod def _FormatDataLine(cls, data, data_offset, data_size): """Formats binary data in a single line of hexadecimal representation. Args: data: String containing the binary data. data_offset: Offset of the data. data_size: Size of the data. Returns: A Unicode string containing a hexadecimal representation of the binary data. Raises: ValueError: if the data offset is out of bounds. """ if data_offset < 0 or data_offset >= data_size: raise ValueError(u'Data offset value out of bounds.') if data_size - data_offset > 16: data_size = data_offset + 16 word_values = [] for byte_offset in range(data_offset, data_size, 2): word_value = u'{0:02x}{1:02x}'.format( ord(data[byte_offset]), ord(data[byte_offset + 1])) word_values.append(word_value) byte_values = [] for byte_offset in range(data_offset, data_size): byte_value = ord(data[byte_offset]) if byte_value > 31 and byte_value < 127: byte_value = data[byte_offset] else: byte_value = u'.' byte_values.append(byte_value) return u'{0:07x}: {1:s} {2:s}'.format( data_offset, u' '.join(word_values), u''.join(byte_values)) @classmethod def FormatData(cls, data, data_offset=0, maximum_data_size=None): """Formats binary data in hexadecimal representation. All ASCII characters in the hexadecimal representation (hexdump) are translated back to their character representation. Args: data: String containing the binary data. data_offset: Optional offset within the data to start formatting. The default is 0. maximum_data_size: Optional maximum size of the data to format. The default is None which represents all of the binary data. Returns: A Unicode string containing a hexadecimal representation of the binary data. """ data_size = len(data) if maximum_data_size is not None and maximum_data_size < data_size: data_size = maximum_data_size output_strings = [] for line_offset in range(data_offset, data_size, 16): hexdump_line = cls._FormatDataLine(data, line_offset, data_size) output_strings.append(hexdump_line) return u'\n'.join(output_strings)
"""Class to represent binary data as hexadecimal.""" class Hexdump(object): """Class that defines a hexadecimal representation formatter (hexdump).""" @classmethod def __format_data_line(cls, data, data_offset, data_size): """Formats binary data in a single line of hexadecimal representation. Args: data: String containing the binary data. data_offset: Offset of the data. data_size: Size of the data. Returns: A Unicode string containing a hexadecimal representation of the binary data. Raises: ValueError: if the data offset is out of bounds. """ if data_offset < 0 or data_offset >= data_size: raise value_error(u'Data offset value out of bounds.') if data_size - data_offset > 16: data_size = data_offset + 16 word_values = [] for byte_offset in range(data_offset, data_size, 2): word_value = u'{0:02x}{1:02x}'.format(ord(data[byte_offset]), ord(data[byte_offset + 1])) word_values.append(word_value) byte_values = [] for byte_offset in range(data_offset, data_size): byte_value = ord(data[byte_offset]) if byte_value > 31 and byte_value < 127: byte_value = data[byte_offset] else: byte_value = u'.' byte_values.append(byte_value) return u'{0:07x}: {1:s} {2:s}'.format(data_offset, u' '.join(word_values), u''.join(byte_values)) @classmethod def format_data(cls, data, data_offset=0, maximum_data_size=None): """Formats binary data in hexadecimal representation. All ASCII characters in the hexadecimal representation (hexdump) are translated back to their character representation. Args: data: String containing the binary data. data_offset: Optional offset within the data to start formatting. The default is 0. maximum_data_size: Optional maximum size of the data to format. The default is None which represents all of the binary data. Returns: A Unicode string containing a hexadecimal representation of the binary data. """ data_size = len(data) if maximum_data_size is not None and maximum_data_size < data_size: data_size = maximum_data_size output_strings = [] for line_offset in range(data_offset, data_size, 16): hexdump_line = cls._FormatDataLine(data, line_offset, data_size) output_strings.append(hexdump_line) return u'\n'.join(output_strings)
class Component(object): _env = None _di = None _args = None _kwargs = None def setDi(self, di): self._di = di def getDi(self): return self._di def getEnv(self): return self._env def setEnv(self, env): self._env = env def setArgs(self, args): self._args = args def getArgs(self): return self._args def setKwargs(self,kwargs): self._kwargs = kwargs def getKwargs(self): return self._kwargs def __init__(self, env, di, args, **kwargs): self._env = env self._di = di self._args = args self._kwargs = kwargs def run(self): raise Exception("implement run in {0}".format(self))
class Component(object): _env = None _di = None _args = None _kwargs = None def set_di(self, di): self._di = di def get_di(self): return self._di def get_env(self): return self._env def set_env(self, env): self._env = env def set_args(self, args): self._args = args def get_args(self): return self._args def set_kwargs(self, kwargs): self._kwargs = kwargs def get_kwargs(self): return self._kwargs def __init__(self, env, di, args, **kwargs): self._env = env self._di = di self._args = args self._kwargs = kwargs def run(self): raise exception('implement run in {0}'.format(self))
with open('F:\\url.txt', 'r') as f: list1 = f.readlines() def remain720p(args): return args.find('720P') > 0 list2 = filter(remain720p, list1) with open('F:\\url2.txt', 'w') as f2: for str2 in list2: f2.writelines(str2)
with open('F:\\url.txt', 'r') as f: list1 = f.readlines() def remain720p(args): return args.find('720P') > 0 list2 = filter(remain720p, list1) with open('F:\\url2.txt', 'w') as f2: for str2 in list2: f2.writelines(str2)
""" This contains emperically derived constants from Hutto and Gilbert (2014) """ # (empirically derived mean sentiment intensity rating increase for booster words) B_INCR = 0.293 B_DECR = -0.293 # (empirically derived mean sentiment intensity rating increase for using ALLCAPs to emphasize a word) C_INCR = 0.733 # capitatilization scaler N_SCALAR = -0.74 BEFORE_BUT_SCALAR = 0.5 AFTER_BUT_SCALAR = 1.5
""" This contains emperically derived constants from Hutto and Gilbert (2014) """ b_incr = 0.293 b_decr = -0.293 c_incr = 0.733 n_scalar = -0.74 before_but_scalar = 0.5 after_but_scalar = 1.5
def fib(i: int) -> int: if i == 0 or i == 1: return 1 return fib(i - 1) + fib(i - 2) if __name__ == "__main__": # Using a variable to workaround # https://github.com/adsharma/py2many/issues/64 rv = fib(5) print(rv)
def fib(i: int) -> int: if i == 0 or i == 1: return 1 return fib(i - 1) + fib(i - 2) if __name__ == '__main__': rv = fib(5) print(rv)
"""Constants for the Shelly integration.""" COAP = "coap" DATA_CONFIG_ENTRY = "config_entry" DEVICE = "device" DOMAIN = "shelly" REST = "rest" CONF_COAP_PORT = "coap_port" DEFAULT_COAP_PORT = 5683 # Used in "_async_update_data" as timeout for polling data from devices. POLLING_TIMEOUT_SEC = 18 # Refresh interval for REST sensors REST_SENSORS_UPDATE_INTERVAL = 60 # Timeout used for aioshelly calls AIOSHELLY_DEVICE_TIMEOUT_SEC = 10 # Multiplier used to calculate the "update_interval" for sleeping devices. SLEEP_PERIOD_MULTIPLIER = 1.2 # Multiplier used to calculate the "update_interval" for non-sleeping devices. UPDATE_PERIOD_MULTIPLIER = 2.2 # Shelly Air - Maximum work hours before lamp replacement SHAIR_MAX_WORK_HOURS = 9000 # Map Shelly input events INPUTS_EVENTS_DICT = { "S": "single", "SS": "double", "SSS": "triple", "L": "long", "SL": "single_long", "LS": "long_single", } # List of battery devices that maintain a permanent WiFi connection BATTERY_DEVICES_WITH_PERMANENT_CONNECTION = ["SHMOS-01"] EVENT_SHELLY_CLICK = "shelly.click" ATTR_CLICK_TYPE = "click_type" ATTR_CHANNEL = "channel" ATTR_DEVICE = "device" CONF_SUBTYPE = "subtype" BASIC_INPUTS_EVENTS_TYPES = { "single", "long", } SHBTN_INPUTS_EVENTS_TYPES = { "single", "double", "triple", "long", } SUPPORTED_INPUTS_EVENTS_TYPES = SHIX3_1_INPUTS_EVENTS_TYPES = { "single", "double", "triple", "long", "single_long", "long_single", } INPUTS_EVENTS_SUBTYPES = { "button": 1, "button1": 1, "button2": 2, "button3": 3, } SHBTN_MODELS = ["SHBTN-1", "SHBTN-2"] # Kelvin value for colorTemp KELVIN_MAX_VALUE = 6500 KELVIN_MIN_VALUE_WHITE = 2700 KELVIN_MIN_VALUE_COLOR = 3000 UPTIME_DEVIATION = 5
"""Constants for the Shelly integration.""" coap = 'coap' data_config_entry = 'config_entry' device = 'device' domain = 'shelly' rest = 'rest' conf_coap_port = 'coap_port' default_coap_port = 5683 polling_timeout_sec = 18 rest_sensors_update_interval = 60 aioshelly_device_timeout_sec = 10 sleep_period_multiplier = 1.2 update_period_multiplier = 2.2 shair_max_work_hours = 9000 inputs_events_dict = {'S': 'single', 'SS': 'double', 'SSS': 'triple', 'L': 'long', 'SL': 'single_long', 'LS': 'long_single'} battery_devices_with_permanent_connection = ['SHMOS-01'] event_shelly_click = 'shelly.click' attr_click_type = 'click_type' attr_channel = 'channel' attr_device = 'device' conf_subtype = 'subtype' basic_inputs_events_types = {'single', 'long'} shbtn_inputs_events_types = {'single', 'double', 'triple', 'long'} supported_inputs_events_types = shix3_1_inputs_events_types = {'single', 'double', 'triple', 'long', 'single_long', 'long_single'} inputs_events_subtypes = {'button': 1, 'button1': 1, 'button2': 2, 'button3': 3} shbtn_models = ['SHBTN-1', 'SHBTN-2'] kelvin_max_value = 6500 kelvin_min_value_white = 2700 kelvin_min_value_color = 3000 uptime_deviation = 5
"""Hass.io const variables.""" ATTR_DISCOVERY = 'discovery' ATTR_ADDON = 'addon' ATTR_NAME = 'name' ATTR_SERVICE = 'service' ATTR_CONFIG = 'config' ATTR_UUID = 'uuid' ATTR_USERNAME = 'username' ATTR_PASSWORD = 'password' X_HASSIO = 'X-HASSIO-KEY' X_HASS_USER_ID = 'X-HASS-USER-ID' X_HASS_IS_ADMIN = 'X-HASS-IS-ADMIN'
"""Hass.io const variables.""" attr_discovery = 'discovery' attr_addon = 'addon' attr_name = 'name' attr_service = 'service' attr_config = 'config' attr_uuid = 'uuid' attr_username = 'username' attr_password = 'password' x_hassio = 'X-HASSIO-KEY' x_hass_user_id = 'X-HASS-USER-ID' x_hass_is_admin = 'X-HASS-IS-ADMIN'
#!/usr/bin/env python3 # coding=utf-8 # author: @netmanchris # -*- coding: utf-8 -*- """ This module contains functions for authenticating to the Attelani Brid Air Purifier Device API. """ class BridAuth: """ Object to hold the authentication data for the Brid API Note currently, the Brid API requires no authentication. Auth object is created to allow for caching of IP address of Brid Device and for future enhancements. :return An object of class AwairAuth to be passed into other functions to pass the authentication credentials """ def __init__(self, ipaddress): """ This class acts as the auth object for the Awair API. The token is available from the Awair developer website. :param token: str object which contains the """ self.ipaddress = ipaddress self.headers = { 'Accept': 'application/json', 'Content-Type': 'application/json', 'Accept-encoding': 'application/json'}
""" This module contains functions for authenticating to the Attelani Brid Air Purifier Device API. """ class Bridauth: """ Object to hold the authentication data for the Brid API Note currently, the Brid API requires no authentication. Auth object is created to allow for caching of IP address of Brid Device and for future enhancements. :return An object of class AwairAuth to be passed into other functions to pass the authentication credentials """ def __init__(self, ipaddress): """ This class acts as the auth object for the Awair API. The token is available from the Awair developer website. :param token: str object which contains the """ self.ipaddress = ipaddress self.headers = {'Accept': 'application/json', 'Content-Type': 'application/json', 'Accept-encoding': 'application/json'}
class Defaults(object): window_size = 7 hidden_sizes = [300] hidden_activation = 'relu' max_vocab_size = 1000000 optimizer = 'sgd' # 'adam' learning_rate = 0.1 # 1e-4 epochs = 20 iobes = True # Map tags to IOBES on input max_tokens = None # Max dataset size in tokens encoding = 'utf-8' # Data encoding output_drop_prob = 0.0 # Dropout probablility prior to output token_level_eval = False # Force token-level evaluation verbosity = 1 # 0=quiet, 1=progress bar, 2=one line per epoch fixed_wordvecs = False # Don't fine-tune word vectors word_features = True batch_size = 50 viterbi = True # Learning rate multiplier for embeddings. This is a tweak to # implement faster learning for embeddings compared to other # layers. As the feature is not yet implemented in Keras master # (see https://github.com/fchollet/keras/pull/1991), this option # currently requires the fork https://github.com/spyysalo/keras . embedding_lr_multiplier = 1.0
class Defaults(object): window_size = 7 hidden_sizes = [300] hidden_activation = 'relu' max_vocab_size = 1000000 optimizer = 'sgd' learning_rate = 0.1 epochs = 20 iobes = True max_tokens = None encoding = 'utf-8' output_drop_prob = 0.0 token_level_eval = False verbosity = 1 fixed_wordvecs = False word_features = True batch_size = 50 viterbi = True embedding_lr_multiplier = 1.0
ATOM_COLORS = { "C": "#c8c8c8", "H": "#ffffff", "N": "#8f8fff", "S": "#ffc832", "O": "#f00000", "F": "#ffff00", "P": "#ffa500", "K": "#42f4ee", "G": "#3f3f3f", } CHAIN_COLORS = { "A": "#320000", "B": "#8a2be2", "C": "#ff4500", "D": "#00bfff", "E": "#ff00ff", "F": "#ffff00", "G": "#4682b4", "H": "#ffb6c1", "I": "#a52aaa", "J": "#ee82ee", "K": "#75FF33", "L": "#FFBD33", "M": "#400040", "N": "#004000", "O": "#008080", "P": "#008080", "R": "#9c6677", "S": "#b7c5c8", } RESIDUE_COLORS = { "ALA": "#C8C8C8", "ARG": "#145AFF", "ASN": "#00DCDC", "ASP": "#E60A0A", "CYS": "#E6E600", "GLN": "#00DCDC", "GLU": "#E60A0A", "GLY": "#EBEBEB", "HIS": "#8282D2", "ILE": "#0F820F", "LEU": "#0F820F", "LYS": "#145AFF", "MET": "#E6E600", "PHE": "#3232AA", "PRO": "#DC9682", "SER": "#FA9600", "THR": "#FA9600", "TRP": "#B45AB4", "TYR": "#3232AA", "VAL": "#0F820F", "ASX": "#FF69B4", "GLX": "#FF69B4", "A": "#A0A0FF", "DA": "#A0A0FF", "G": "#FF7070", "DG": "#FF7070", "I": "#80FFFF", "C": "#FF8C4B", "DC": "#FF8C4B", "T": "#A0FFA0", "DT": "#A0FFA0", "U": "#FF8080", } RESIDUE_TYPE_COLORS = { "hydrophobic": "#00ff80", "polar": "#ff00bf", "acidic": "#ff4000", "basic": "#0040ff", "aromatic": "#ffff00", "purine": "#A00042", "pyrimidine": "#4F4600", } AMINO_ACID_CLASSES = { "hydrophobic": ["GLY", "ALA", "LEU", "ILE", "VAL", "MET", "PRO"], "polar": ["ASN", "GLN", "SER", "THR", "CYS"], "acidic": ["ASP", "GLU"], "basic": ["LYS", "ARG", "HIS"], "aromatic": ["TRP", "TYR", "PHE"], "purine": ["A", "G", "DA", "DG"], "pyrimidine": ["DT", "DC", "U", "I", "C"], } def create_mol3d_style( atoms, visualization_type="stick", color_element="atom", color_scheme=None ): """Function to create styles input for Molecule3dViewer @param atoms A list of atoms. Each atom should be a dict with keys: 'name', 'residue_name', 'chain' @param visualization_type A type of molecule visualization graphic: 'stick' | 'cartoon' | 'sphere'. @param color_element Elements to apply color scheme to: 'atom' | 'residue' | 'residue_type' | 'chain'. @param color_scheme Color scheme used to style moleule elements. This should be a dict with keys being names of atoms, residues, residue types or chains, depending on the value of color_element argument. If no value is provided, default color schemes will be used. """ if not visualization_type in ['stick', 'cartoon', 'sphere']: raise Exception("Invalid argument type: visualization_type. Should be: 'stick' | 'cartoon' | 'sphere'.") if not color_element in ['atom', 'residue', 'residue_type', 'chain']: raise Exception("Invalid argument type: color_element. Should be: 'atom' | 'residue' | 'residue_type' | 'chain'.") if not isinstance(atoms, list): raise Exception("Invalid argument type: atoms. Should be a list of dict.") if color_scheme and not isinstance(color_scheme, dict): raise Exception("Invalid argument type: color_scheme. Should be a dict.") default_color = '#ABABAB' if color_scheme is None: color_scheme = { 'atom': ATOM_COLORS, 'residue': RESIDUE_COLORS, 'residue_type': RESIDUE_TYPE_COLORS, 'chain': CHAIN_COLORS }[color_element] if color_element == 'residue_type': residue_type_colors_map = {} for aa_class_name, aa_class_members in AMINO_ACID_CLASSES.items(): for aa in aa_class_members: residue_type_colors_map[aa] = color_scheme.get(aa_class_name, default_color) color_scheme = residue_type_colors_map atom_styles = [] for a in atoms: if color_element == 'atom': atom_color = color_scheme.get(a['name'], default_color) if color_element in ['residue', 'residue_type']: atom_color = color_scheme.get(a['residue_name'], default_color) if color_element == 'chain': atom_color = color_scheme.get(a['chain'], default_color) atom_styles.append({ 'visualization_type': visualization_type, 'color': atom_color }) return atom_styles
atom_colors = {'C': '#c8c8c8', 'H': '#ffffff', 'N': '#8f8fff', 'S': '#ffc832', 'O': '#f00000', 'F': '#ffff00', 'P': '#ffa500', 'K': '#42f4ee', 'G': '#3f3f3f'} chain_colors = {'A': '#320000', 'B': '#8a2be2', 'C': '#ff4500', 'D': '#00bfff', 'E': '#ff00ff', 'F': '#ffff00', 'G': '#4682b4', 'H': '#ffb6c1', 'I': '#a52aaa', 'J': '#ee82ee', 'K': '#75FF33', 'L': '#FFBD33', 'M': '#400040', 'N': '#004000', 'O': '#008080', 'P': '#008080', 'R': '#9c6677', 'S': '#b7c5c8'} residue_colors = {'ALA': '#C8C8C8', 'ARG': '#145AFF', 'ASN': '#00DCDC', 'ASP': '#E60A0A', 'CYS': '#E6E600', 'GLN': '#00DCDC', 'GLU': '#E60A0A', 'GLY': '#EBEBEB', 'HIS': '#8282D2', 'ILE': '#0F820F', 'LEU': '#0F820F', 'LYS': '#145AFF', 'MET': '#E6E600', 'PHE': '#3232AA', 'PRO': '#DC9682', 'SER': '#FA9600', 'THR': '#FA9600', 'TRP': '#B45AB4', 'TYR': '#3232AA', 'VAL': '#0F820F', 'ASX': '#FF69B4', 'GLX': '#FF69B4', 'A': '#A0A0FF', 'DA': '#A0A0FF', 'G': '#FF7070', 'DG': '#FF7070', 'I': '#80FFFF', 'C': '#FF8C4B', 'DC': '#FF8C4B', 'T': '#A0FFA0', 'DT': '#A0FFA0', 'U': '#FF8080'} residue_type_colors = {'hydrophobic': '#00ff80', 'polar': '#ff00bf', 'acidic': '#ff4000', 'basic': '#0040ff', 'aromatic': '#ffff00', 'purine': '#A00042', 'pyrimidine': '#4F4600'} amino_acid_classes = {'hydrophobic': ['GLY', 'ALA', 'LEU', 'ILE', 'VAL', 'MET', 'PRO'], 'polar': ['ASN', 'GLN', 'SER', 'THR', 'CYS'], 'acidic': ['ASP', 'GLU'], 'basic': ['LYS', 'ARG', 'HIS'], 'aromatic': ['TRP', 'TYR', 'PHE'], 'purine': ['A', 'G', 'DA', 'DG'], 'pyrimidine': ['DT', 'DC', 'U', 'I', 'C']} def create_mol3d_style(atoms, visualization_type='stick', color_element='atom', color_scheme=None): """Function to create styles input for Molecule3dViewer @param atoms A list of atoms. Each atom should be a dict with keys: 'name', 'residue_name', 'chain' @param visualization_type A type of molecule visualization graphic: 'stick' | 'cartoon' | 'sphere'. @param color_element Elements to apply color scheme to: 'atom' | 'residue' | 'residue_type' | 'chain'. @param color_scheme Color scheme used to style moleule elements. This should be a dict with keys being names of atoms, residues, residue types or chains, depending on the value of color_element argument. If no value is provided, default color schemes will be used. """ if not visualization_type in ['stick', 'cartoon', 'sphere']: raise exception("Invalid argument type: visualization_type. Should be: 'stick' | 'cartoon' | 'sphere'.") if not color_element in ['atom', 'residue', 'residue_type', 'chain']: raise exception("Invalid argument type: color_element. Should be: 'atom' | 'residue' | 'residue_type' | 'chain'.") if not isinstance(atoms, list): raise exception('Invalid argument type: atoms. Should be a list of dict.') if color_scheme and (not isinstance(color_scheme, dict)): raise exception('Invalid argument type: color_scheme. Should be a dict.') default_color = '#ABABAB' if color_scheme is None: color_scheme = {'atom': ATOM_COLORS, 'residue': RESIDUE_COLORS, 'residue_type': RESIDUE_TYPE_COLORS, 'chain': CHAIN_COLORS}[color_element] if color_element == 'residue_type': residue_type_colors_map = {} for (aa_class_name, aa_class_members) in AMINO_ACID_CLASSES.items(): for aa in aa_class_members: residue_type_colors_map[aa] = color_scheme.get(aa_class_name, default_color) color_scheme = residue_type_colors_map atom_styles = [] for a in atoms: if color_element == 'atom': atom_color = color_scheme.get(a['name'], default_color) if color_element in ['residue', 'residue_type']: atom_color = color_scheme.get(a['residue_name'], default_color) if color_element == 'chain': atom_color = color_scheme.get(a['chain'], default_color) atom_styles.append({'visualization_type': visualization_type, 'color': atom_color}) return atom_styles
"""Ubuntu Laptop Monitoring - Django project to display laptop hardware status. .. moduleauthor:: Alexander Dupuy <[email protected]> """
"""Ubuntu Laptop Monitoring - Django project to display laptop hardware status. .. moduleauthor:: Alexander Dupuy <[email protected]> """
class Config: EPS = 1e-14 RPN_CLOBBER_POSITIVES = False RPN_NEGATIVE_OVERLAP = 0.3 RPN_POSITIVE_OVERLAP = 0.7 RPN_FG_FRACTION = 0.5 RPN_BATCHSIZE = 300 RPN_BBOX_INSIDE_WEIGHTS = (1.0, 1.0, 1.0, 1.0) RPN_POSITIVE_WEIGHT = -1.0 RPN_PRE_NMS_TOP_N = 12000 RPN_POST_NMS_TOP_N = 1000 RPN_NMS_THRESH = 0.7 RPN_MIN_SIZE = 8 # origin [11, 16, 23, 33, 48, 68, 97, 139, 198, 283] ANCHORS_HEIGHT = [23, 33, 48, 68, 97, 139]
class Config: eps = 1e-14 rpn_clobber_positives = False rpn_negative_overlap = 0.3 rpn_positive_overlap = 0.7 rpn_fg_fraction = 0.5 rpn_batchsize = 300 rpn_bbox_inside_weights = (1.0, 1.0, 1.0, 1.0) rpn_positive_weight = -1.0 rpn_pre_nms_top_n = 12000 rpn_post_nms_top_n = 1000 rpn_nms_thresh = 0.7 rpn_min_size = 8 anchors_height = [23, 33, 48, 68, 97, 139]
hps = { "0351291110650853": { "ott_len": 35, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 65, "max_risk_long": 85 }, "0561821341040643": { "ott_len": 56, "ott_percent": 182, "ott_bw_up": 134, "tps_qty_index": 104, "max_risk_long": 64 }, "0351291110200403": { "ott_len": 35, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 20, "max_risk_long": 40 }, "0572181720720673": { "ott_len": 57, "ott_percent": 218, "ott_bw_up": 172, "tps_qty_index": 72, "max_risk_long": 67 }, "0331701430640973": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 143, "tps_qty_index": 64, "max_risk_long": 97 }, "66787357652": { "ott_len": 66, "ott_percent": 78, "ott_bw_up": 73, "tps_qty_index": 57, "max_risk_long": 65 }, "0701701490000913": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 0, "max_risk_long": 91 }, "0700781390290673": { "ott_len": 70, "ott_percent": 78, "ott_bw_up": 139, "tps_qty_index": 29, "max_risk_long": 67 }, "0601050950650813": { "ott_len": 60, "ott_percent": 105, "ott_bw_up": 95, "tps_qty_index": 65, "max_risk_long": 81 }, "0400781490420563": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 42, "max_risk_long": 56 }, "0572181750000913": { "ott_len": 57, "ott_percent": 218, "ott_bw_up": 175, "tps_qty_index": 0, "max_risk_long": 91 }, "0281701690020483": { "ott_len": 28, "ott_percent": 170, "ott_bw_up": 169, "tps_qty_index": 2, "max_risk_long": 48 }, "0631701340690723": { "ott_len": 63, "ott_percent": 170, "ott_bw_up": 134, "tps_qty_index": 69, "max_risk_long": 72 }, "0691581140650703": { "ott_len": 69, "ott_percent": 158, "ott_bw_up": 114, "tps_qty_index": 65, "max_risk_long": 70 }, "0450781491120653": { "ott_len": 45, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 112, "max_risk_long": 65 }, "0691050980650663": { "ott_len": 69, "ott_percent": 105, "ott_bw_up": 98, "tps_qty_index": 65, "max_risk_long": 66 }, "0391701430640973": { "ott_len": 39, "ott_percent": 170, "ott_bw_up": 143, "tps_qty_index": 64, "max_risk_long": 97 }, "0331291110650813": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 65, "max_risk_long": 81 }, "0351291110200453": { "ott_len": 35, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 20, "max_risk_long": 45 }, "0701701380640523": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 64, "max_risk_long": 52 }, "0450781490370653": { "ott_len": 45, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 37, "max_risk_long": 65 }, "0521051340690693": { "ott_len": 52, "ott_percent": 105, "ott_bw_up": 134, "tps_qty_index": 69, "max_risk_long": 69 }, "66788842652": { "ott_len": 66, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 42, "max_risk_long": 65 }, "0640781390420673": { "ott_len": 64, "ott_percent": 78, "ott_bw_up": 139, "tps_qty_index": 42, "max_risk_long": 67 }, "0700701120370653": { "ott_len": 70, "ott_percent": 70, "ott_bw_up": 112, "tps_qty_index": 37, "max_risk_long": 65 }, "0682181720800673": { "ott_len": 68, "ott_percent": 218, "ott_bw_up": 172, "tps_qty_index": 80, "max_risk_long": 67 }, "0311051471100663": { "ott_len": 31, "ott_percent": 105, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 66 }, "0701291110370653": { "ott_len": 70, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 37, "max_risk_long": 65 }, "0400781360170653": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 136, "tps_qty_index": 17, "max_risk_long": 65 }, "0682181721120663": { "ott_len": 68, "ott_percent": 218, "ott_bw_up": 172, "tps_qty_index": 112, "max_risk_long": 66 }, "0331291490650523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 65, "max_risk_long": 52 }, "0334791750000813": { "ott_len": 33, "ott_percent": 479, "ott_bw_up": 175, "tps_qty_index": 0, "max_risk_long": 81 }, "57788850852": { "ott_len": 57, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 50, "max_risk_long": 85 }, "0581050990500523": { "ott_len": 58, "ott_percent": 105, "ott_bw_up": 99, "tps_qty_index": 50, "max_risk_long": 52 }, "0531701470690723": { "ott_len": 53, "ott_percent": 170, "ott_bw_up": 147, "tps_qty_index": 69, "max_risk_long": 72 }, "0541701430841003": { "ott_len": 54, "ott_percent": 170, "ott_bw_up": 143, "tps_qty_index": 84, "max_risk_long": 100 }, "57788842712": { "ott_len": 57, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 42, "max_risk_long": 71 }, "70709372652": { "ott_len": 70, "ott_percent": 70, "ott_bw_up": 93, "tps_qty_index": 72, "max_risk_long": 65 }, "0540971110650593": { "ott_len": 54, "ott_percent": 97, "ott_bw_up": 111, "tps_qty_index": 65, "max_risk_long": 59 }, "0331291110610813": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 61, "max_risk_long": 81 }, "0311031470410553": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 41, "max_risk_long": 55 }, "0292181721120663": { "ott_len": 29, "ott_percent": 218, "ott_bw_up": 172, "tps_qty_index": 112, "max_risk_long": 66 }, "0400781470420563": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 42, "max_risk_long": 56 }, "0541291400650653": { "ott_len": 54, "ott_percent": 129, "ott_bw_up": 140, "tps_qty_index": 65, "max_risk_long": 65 }, "0312181721100913": { "ott_len": 31, "ott_percent": 218, "ott_bw_up": 172, "tps_qty_index": 110, "max_risk_long": 91 }, "0330781470590493": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 59, "max_risk_long": 49 }, "0400781490170563": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 17, "max_risk_long": 56 }, "40789942562": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 99, "tps_qty_index": 42, "max_risk_long": 56 }, "0701291160370653": { "ott_len": 70, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 37, "max_risk_long": 65 }, "0331291170220593": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 117, "tps_qty_index": 22, "max_risk_long": 59 }, "0310781471100493": { "ott_len": 31, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 49 }, "57788872652": { "ott_len": 57, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 72, "max_risk_long": 65 }, "0660781240650673": { "ott_len": 66, "ott_percent": 78, "ott_bw_up": 124, "tps_qty_index": 65, "max_risk_long": 67 }, "0400781360480653": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 136, "tps_qty_index": 48, "max_risk_long": 65 }, "70788864712": { "ott_len": 70, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 64, "max_risk_long": 71 }, "0350781380090653": { "ott_len": 35, "ott_percent": 78, "ott_bw_up": 138, "tps_qty_index": 9, "max_risk_long": 65 }, "0331291110410523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 41, "max_risk_long": 52 }, "0331701340470523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 134, "tps_qty_index": 47, "max_risk_long": 52 }, "0311031470420523": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 42, "max_risk_long": 52 }, "0331051110270913": { "ott_len": 33, "ott_percent": 105, "ott_bw_up": 111, "tps_qty_index": 27, "max_risk_long": 91 }, "0682181731120663": { "ott_len": 68, "ott_percent": 218, "ott_bw_up": 173, "tps_qty_index": 112, "max_risk_long": 66 }, "0701701340690523": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 134, "tps_qty_index": 69, "max_risk_long": 52 }, "70788872612": { "ott_len": 70, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 72, "max_risk_long": 61 }, "0312181721100663": { "ott_len": 31, "ott_percent": 218, "ott_bw_up": 172, "tps_qty_index": 110, "max_risk_long": 66 }, "0331291490590523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 59, "max_risk_long": 52 }, "0682181571120663": { "ott_len": 68, "ott_percent": 218, "ott_bw_up": 157, "tps_qty_index": 112, "max_risk_long": 66 }, "0550781430310673": { "ott_len": 55, "ott_percent": 78, "ott_bw_up": 143, "tps_qty_index": 31, "max_risk_long": 67 }, "48788842652": { "ott_len": 48, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 42, "max_risk_long": 65 }, "0581050970270653": { "ott_len": 58, "ott_percent": 105, "ott_bw_up": 97, "tps_qty_index": 27, "max_risk_long": 65 }, "0572181390030713": { "ott_len": 57, "ott_percent": 218, "ott_bw_up": 139, "tps_qty_index": 3, "max_risk_long": 71 }, "0701701341090523": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 134, "tps_qty_index": 109, "max_risk_long": 52 }, "0331291110610493": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 61, "max_risk_long": 49 }, "0420781430420553": { "ott_len": 42, "ott_percent": 78, "ott_bw_up": 143, "tps_qty_index": 42, "max_risk_long": 55 }, "0631701380480523": { "ott_len": 63, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 48, "max_risk_long": 52 }, "0311291490650523": { "ott_len": 31, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 65, "max_risk_long": 52 }, "0330781490890673": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 89, "max_risk_long": 67 }, "0311031470030523": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 3, "max_risk_long": 52 }, "0331291490410793": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 41, "max_risk_long": 79 }, "0631701471100913": { "ott_len": 63, "ott_percent": 170, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 91 }, "0321031470840913": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 84, "max_risk_long": 91 }, "0311291160930823": { "ott_len": 31, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 93, "max_risk_long": 82 }, "0350781380640523": { "ott_len": 35, "ott_percent": 78, "ott_bw_up": 138, "tps_qty_index": 64, "max_risk_long": 52 }, "0590821210640523": { "ott_len": 59, "ott_percent": 82, "ott_bw_up": 121, "tps_qty_index": 64, "max_risk_long": 52 }, "0660781110370653": { "ott_len": 66, "ott_percent": 78, "ott_bw_up": 111, "tps_qty_index": 37, "max_risk_long": 65 }, "0631291110100523": { "ott_len": 63, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 10, "max_risk_long": 52 }, "0701701110370653": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 111, "tps_qty_index": 37, "max_risk_long": 65 }, "0331411470590593": { "ott_len": 33, "ott_percent": 141, "ott_bw_up": 147, "tps_qty_index": 59, "max_risk_long": 59 }, "0331291080590793": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 108, "tps_qty_index": 59, "max_risk_long": 79 }, "0311411471100543": { "ott_len": 31, "ott_percent": 141, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 54 }, "0311291360170653": { "ott_len": 31, "ott_percent": 129, "ott_bw_up": 136, "tps_qty_index": 17, "max_risk_long": 65 }, "0331291490980613": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 98, "max_risk_long": 61 }, "0321031490840673": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 84, "max_risk_long": 67 }, "0701701400650653": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 140, "tps_qty_index": 65, "max_risk_long": 65 }, "0321031491100913": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 91 }, "0321031240840913": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 124, "tps_qty_index": 84, "max_risk_long": 91 }, "0701291160160823": { "ott_len": 70, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 16, "max_risk_long": 82 }, "0681701340690523": { "ott_len": 68, "ott_percent": 170, "ott_bw_up": 134, "tps_qty_index": 69, "max_risk_long": 52 }, "0731291110650813": { "ott_len": 73, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 65, "max_risk_long": 81 }, "0330781470860523": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 86, "max_risk_long": 52 }, "0331031491100493": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 49 }, "0311031471070553": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 107, "max_risk_long": 55 }, "0331701710590653": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 171, "tps_qty_index": 59, "max_risk_long": 65 }, "0701291160930653": { "ott_len": 70, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 93, "max_risk_long": 65 }, "0331291490980913": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 98, "max_risk_long": 91 }, "0331291710790653": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 171, "tps_qty_index": 79, "max_risk_long": 65 }, "0312021470370653": { "ott_len": 31, "ott_percent": 202, "ott_bw_up": 147, "tps_qty_index": 37, "max_risk_long": 65 }, "0330781470840673": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 84, "max_risk_long": 67 }, "0331121490940803": { "ott_len": 33, "ott_percent": 112, "ott_bw_up": 149, "tps_qty_index": 94, "max_risk_long": 80 }, "0331701380700523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 70, "max_risk_long": 52 }, "0311571490980603": { "ott_len": 31, "ott_percent": 157, "ott_bw_up": 149, "tps_qty_index": 98, "max_risk_long": 60 }, "40788117652": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 81, "tps_qty_index": 17, "max_risk_long": 65 }, "0480781390650613": { "ott_len": 48, "ott_percent": 78, "ott_bw_up": 139, "tps_qty_index": 65, "max_risk_long": 61 }, "0321031470840773": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 84, "max_risk_long": 77 }, "0311330940420553": { "ott_len": 31, "ott_percent": 133, "ott_bw_up": 94, "tps_qty_index": 42, "max_risk_long": 55 }, "0331291490690523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 69, "max_risk_long": 52 }, "0681291350650663": { "ott_len": 68, "ott_percent": 129, "ott_bw_up": 135, "tps_qty_index": 65, "max_risk_long": 66 }, "0331761490860523": { "ott_len": 33, "ott_percent": 176, "ott_bw_up": 149, "tps_qty_index": 86, "max_risk_long": 52 }, "0371291110420653": { "ott_len": 37, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 42, "max_risk_long": 65 }, "0480781470100613": { "ott_len": 48, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 10, "max_risk_long": 61 }, "0331291450690523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 145, "tps_qty_index": 69, "max_risk_long": 52 }, "0330911470840853": { "ott_len": 33, "ott_percent": 91, "ott_bw_up": 147, "tps_qty_index": 84, "max_risk_long": 85 }, "0400781040690653": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 104, "tps_qty_index": 69, "max_risk_long": 65 }, "0441031110840693": { "ott_len": 44, "ott_percent": 103, "ott_bw_up": 111, "tps_qty_index": 84, "max_risk_long": 69 }, "0330781470770673": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 77, "max_risk_long": 67 }, "0661291100370653": { "ott_len": 66, "ott_percent": 129, "ott_bw_up": 110, "tps_qty_index": 37, "max_risk_long": 65 }, "0701701380930653": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 93, "max_risk_long": 65 }, "0331291110560823": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 56, "max_risk_long": 82 }, "0501030920420453": { "ott_len": 50, "ott_percent": 103, "ott_bw_up": 92, "tps_qty_index": 42, "max_risk_long": 45 }, "0331291490840503": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 84, "max_risk_long": 50 }, "0331701340690523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 134, "tps_qty_index": 69, "max_risk_long": 52 }, "0331031471100493": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 49 }, "68788818492": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 18, "max_risk_long": 49 }, "0311031471100553": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 55 }, "0331701380640523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 64, "max_risk_long": 52 }, "0701701380570523": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 57, "max_risk_long": 52 }, "0621291110650913": { "ott_len": 62, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 65, "max_risk_long": 91 }, "0350781340640523": { "ott_len": 35, "ott_percent": 78, "ott_bw_up": 134, "tps_qty_index": 64, "max_risk_long": 52 }, "0311291471100653": { "ott_len": 31, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 65 }, "0311701350380933": { "ott_len": 31, "ott_percent": 170, "ott_bw_up": 135, "tps_qty_index": 38, "max_risk_long": 93 }, "0311030880720553": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 88, "tps_qty_index": 72, "max_risk_long": 55 }, "0331701490640523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 64, "max_risk_long": 52 }, "66788884672": { "ott_len": 66, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 84, "max_risk_long": 67 }, "0331291050940523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 105, "tps_qty_index": 94, "max_risk_long": 52 }, "0400781470690653": { "ott_len": 40, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 69, "max_risk_long": 65 }, "0321031481100913": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 148, "tps_qty_index": 110, "max_risk_long": 91 }, "0311031470420653": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 42, "max_risk_long": 65 }, "0331291080420793": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 108, "tps_qty_index": 42, "max_risk_long": 79 }, "0331291470690523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 69, "max_risk_long": 52 }, "0331291490110653": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 11, "max_risk_long": 65 }, "0701701380570653": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 57, "max_risk_long": 65 }, "0331561340640863": { "ott_len": 33, "ott_percent": 156, "ott_bw_up": 134, "tps_qty_index": 64, "max_risk_long": 86 }, "0330781490650503": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 65, "max_risk_long": 50 }, "0311030880400553": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 88, "tps_qty_index": 40, "max_risk_long": 55 }, "0330781470690493": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 69, "max_risk_long": 49 }, "0321031490980913": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 98, "max_risk_long": 91 }, "0321031491100523": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 52 }, "0331701490590653": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 59, "max_risk_long": 65 }, "0331291490770553": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 77, "max_risk_long": 55 }, "0291291160930583": { "ott_len": 29, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 93, "max_risk_long": 58 }, "0341291471100663": { "ott_len": 34, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 66 }, "0701701380370653": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 37, "max_risk_long": 65 }, "0331291491100613": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 61 }, "33788842652": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 42, "max_risk_long": 65 }, "0331291490410673": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 41, "max_risk_long": 67 }, "0331291490590653": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 59, "max_risk_long": 65 }, "70788872532": { "ott_len": 70, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 72, "max_risk_long": 53 }, "0701701380840653": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 84, "max_risk_long": 65 }, "39788977342": { "ott_len": 39, "ott_percent": 78, "ott_bw_up": 89, "tps_qty_index": 77, "max_risk_long": 34 }, "68788856442": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 56, "max_risk_long": 44 }, "0331271710570653": { "ott_len": 33, "ott_percent": 127, "ott_bw_up": 171, "tps_qty_index": 57, "max_risk_long": 65 }, "68788872652": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 72, "max_risk_long": 65 }, "0331531490660793": { "ott_len": 33, "ott_percent": 153, "ott_bw_up": 149, "tps_qty_index": 66, "max_risk_long": 79 }, "0331291470650453": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 65, "max_risk_long": 45 }, "0330781471040523": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 104, "max_risk_long": 52 }, "0701291161100653": { "ott_len": 70, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 110, "max_risk_long": 65 }, "0310781471100523": { "ott_len": 31, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 52 }, "33788841792": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 41, "max_risk_long": 79 }, "0321291160930523": { "ott_len": 32, "ott_percent": 129, "ott_bw_up": 116, "tps_qty_index": 93, "max_risk_long": 52 }, "0331291490110503": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 11, "max_risk_long": 50 }, "0331291071100613": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 107, "tps_qty_index": 110, "max_risk_long": 61 }, "0701701381100523": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 110, "max_risk_long": 52 }, "0680781090180743": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 109, "tps_qty_index": 18, "max_risk_long": 74 }, "0651291490650523": { "ott_len": 65, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 65, "max_risk_long": 52 }, "0331701491100883": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 88 }, "0330781490640663": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 64, "max_risk_long": 66 }, "0701701380840573": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 84, "max_risk_long": 57 }, "0331291471100663": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 66 }, "68788818982": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 18, "max_risk_long": 98 }, "0331291710770653": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 171, "tps_qty_index": 77, "max_risk_long": 65 }, "0331701710110653": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 171, "tps_qty_index": 11, "max_risk_long": 65 }, "0310941471100553": { "ott_len": 31, "ott_percent": 94, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 55 }, "0321031470770553": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 77, "max_risk_long": 55 }, "0321031491060503": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 106, "max_risk_long": 50 }, "0680780881100493": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 110, "max_risk_long": 49 }, "0331291491100793": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 79 }, "0331031471060643": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 106, "max_risk_long": 64 }, "0331291330650943": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 133, "tps_qty_index": 65, "max_risk_long": 94 }, "0560781380350573": { "ott_len": 56, "ott_percent": 78, "ott_bw_up": 138, "tps_qty_index": 35, "max_risk_long": 57 }, "0331291710590523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 171, "tps_qty_index": 59, "max_risk_long": 52 }, "0331291471100523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 52 }, "0320781161100523": { "ott_len": 32, "ott_percent": 78, "ott_bw_up": 116, "tps_qty_index": 110, "max_risk_long": 52 }, "0701701380320523": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 32, "max_risk_long": 52 }, "0331031491100523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 52 }, "0331701710640633": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 171, "tps_qty_index": 64, "max_risk_long": 63 }, "0331501550690523": { "ott_len": 33, "ott_percent": 150, "ott_bw_up": 155, "tps_qty_index": 69, "max_risk_long": 52 }, "0331291380840503": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 138, "tps_qty_index": 84, "max_risk_long": 50 }, "0701291380570763": { "ott_len": 70, "ott_percent": 129, "ott_bw_up": 138, "tps_qty_index": 57, "max_risk_long": 76 }, "0331291490570523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 57, "max_risk_long": 52 }, "0331291491160523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 116, "max_risk_long": 52 }, "68788825492": { "ott_len": 68, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 25, "max_risk_long": 49 }, "0330781340640553": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 134, "tps_qty_index": 64, "max_risk_long": 55 }, "0331291710770463": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 171, "tps_qty_index": 77, "max_risk_long": 46 }, "0341291490840663": { "ott_len": 34, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 84, "max_risk_long": 66 }, "0331291490650663": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 65, "max_risk_long": 66 }, "0321291710980523": { "ott_len": 32, "ott_percent": 129, "ott_bw_up": 171, "tps_qty_index": 98, "max_risk_long": 52 }, "0451291490590523": { "ott_len": 45, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 59, "max_risk_long": 52 }, "0331291490840523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 84, "max_risk_long": 52 }, "0331031490590653": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 59, "max_risk_long": 65 }, "0301471471100553": { "ott_len": 30, "ott_percent": 147, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 55 }, "0330941470920553": { "ott_len": 33, "ott_percent": 94, "ott_bw_up": 147, "tps_qty_index": 92, "max_risk_long": 55 }, "0311031390420563": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 139, "tps_qty_index": 42, "max_risk_long": 56 }, "0340861470860523": { "ott_len": 34, "ott_percent": 86, "ott_bw_up": 147, "tps_qty_index": 86, "max_risk_long": 52 }, "0451291490770553": { "ott_len": 45, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 77, "max_risk_long": 55 }, "0331291490590913": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 59, "max_risk_long": 91 }, "0331291471040773": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 104, "max_risk_long": 77 }, "0331031160930523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 116, "tps_qty_index": 93, "max_risk_long": 52 }, "0321031491100503": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 50 }, "70788869522": { "ott_len": 70, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 69, "max_risk_long": 52 }, "0331701560110653": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 156, "tps_qty_index": 11, "max_risk_long": 65 }, "0320781481040913": { "ott_len": 32, "ott_percent": 78, "ott_bw_up": 148, "tps_qty_index": 104, "max_risk_long": 91 }, "0330781471100523": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 52 }, "0331291491100523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 110, "max_risk_long": 52 }, "0310940951100553": { "ott_len": 31, "ott_percent": 94, "ott_bw_up": 95, "tps_qty_index": 110, "max_risk_long": 55 }, "0331291490770523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 77, "max_risk_long": 52 }, "0331031470990523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 99, "max_risk_long": 52 }, "0331291490750553": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 75, "max_risk_long": 55 }, "0310941491060553": { "ott_len": 31, "ott_percent": 94, "ott_bw_up": 149, "tps_qty_index": 106, "max_risk_long": 55 }, "0331031250590653": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 125, "tps_qty_index": 59, "max_risk_long": 65 }, "0321031491060523": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 106, "max_risk_long": 52 }, "0321031471100913": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 91 }, "0331291390590523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 139, "tps_qty_index": 59, "max_risk_long": 52 }, "0331031490990523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 99, "max_risk_long": 52 }, "0331701490570523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 57, "max_risk_long": 52 }, "0331030930990523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 93, "tps_qty_index": 99, "max_risk_long": 52 }, "0331291490920553": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 92, "max_risk_long": 55 }, "0330781490840673": { "ott_len": 33, "ott_percent": 78, "ott_bw_up": 149, "tps_qty_index": 84, "max_risk_long": 67 }, "70788893512": { "ott_len": 70, "ott_percent": 78, "ott_bw_up": 88, "tps_qty_index": 93, "max_risk_long": 51 }, "0331291490750463": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 75, "max_risk_long": 46 }, "0331031471030523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 103, "max_risk_long": 52 }, "0331701490770653": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 77, "max_risk_long": 65 }, "0331291490320523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 32, "max_risk_long": 52 }, "0331031470860523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 86, "max_risk_long": 52 }, "0331031470500493": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 50, "max_risk_long": 49 }, "0331481490610653": { "ott_len": 33, "ott_percent": 148, "ott_bw_up": 149, "tps_qty_index": 61, "max_risk_long": 65 }, "0331031471040493": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 104, "max_risk_long": 49 }, "0331701440590523": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 144, "tps_qty_index": 59, "max_risk_long": 52 }, "0611291380590583": { "ott_len": 61, "ott_percent": 129, "ott_bw_up": 138, "tps_qty_index": 59, "max_risk_long": 58 }, "0701030980120503": { "ott_len": 70, "ott_percent": 103, "ott_bw_up": 98, "tps_qty_index": 12, "max_risk_long": 50 }, "0331291490930653": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 93, "max_risk_long": 65 }, "0320781481100493": { "ott_len": 32, "ott_percent": 78, "ott_bw_up": 148, "tps_qty_index": 110, "max_risk_long": 49 }, "0321701310840573": { "ott_len": 32, "ott_percent": 170, "ott_bw_up": 131, "tps_qty_index": 84, "max_risk_long": 57 }, "0331701380590653": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 59, "max_risk_long": 65 }, "0310941380570523": { "ott_len": 31, "ott_percent": 94, "ott_bw_up": 138, "tps_qty_index": 57, "max_risk_long": 52 }, "0331701490110553": { "ott_len": 33, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 11, "max_risk_long": 55 }, "0331291121060523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 112, "tps_qty_index": 106, "max_risk_long": 52 }, "0331031471100523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 52 }, "0701701380670503": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 67, "max_risk_long": 50 }, "0701701381100913": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 138, "tps_qty_index": 110, "max_risk_long": 91 }, "0331031180590453": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 118, "tps_qty_index": 59, "max_risk_long": 45 }, "0331291470920553": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 147, "tps_qty_index": 92, "max_risk_long": 55 }, "0331031490680493": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 68, "max_risk_long": 49 }, "0310941471120553": { "ott_len": 31, "ott_percent": 94, "ott_bw_up": 147, "tps_qty_index": 112, "max_risk_long": 55 }, "0331291490770663": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 77, "max_risk_long": 66 }, "0361701470570523": { "ott_len": 36, "ott_percent": 170, "ott_bw_up": 147, "tps_qty_index": 57, "max_risk_long": 52 }, "0310781291100523": { "ott_len": 31, "ott_percent": 78, "ott_bw_up": 129, "tps_qty_index": 110, "max_risk_long": 52 }, "0310941471100523": { "ott_len": 31, "ott_percent": 94, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 52 }, "0331031470510523": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 51, "max_risk_long": 52 }, "0701701490770553": { "ott_len": 70, "ott_percent": 170, "ott_bw_up": 149, "tps_qty_index": 77, "max_risk_long": 55 }, "0331031471100553": { "ott_len": 33, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 55 }, "0331291180570523": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 118, "tps_qty_index": 57, "max_risk_long": 52 }, "0311031490750553": { "ott_len": 31, "ott_percent": 103, "ott_bw_up": 149, "tps_qty_index": 75, "max_risk_long": 55 }, "0321031471100553": { "ott_len": 32, "ott_percent": 103, "ott_bw_up": 147, "tps_qty_index": 110, "max_risk_long": 55 }, "0331291110130453": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 111, "tps_qty_index": 13, "max_risk_long": 45 }, "0331291481100553": { "ott_len": 33, "ott_percent": 129, "ott_bw_up": 148, "tps_qty_index": 110, "max_risk_long": 55 }, "0321291490930913": { "ott_len": 32, "ott_percent": 129, "ott_bw_up": 149, "tps_qty_index": 93, "max_risk_long": 91 } }
hps = {'0351291110650853': {'ott_len': 35, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 65, 'max_risk_long': 85}, '0561821341040643': {'ott_len': 56, 'ott_percent': 182, 'ott_bw_up': 134, 'tps_qty_index': 104, 'max_risk_long': 64}, '0351291110200403': {'ott_len': 35, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 20, 'max_risk_long': 40}, '0572181720720673': {'ott_len': 57, 'ott_percent': 218, 'ott_bw_up': 172, 'tps_qty_index': 72, 'max_risk_long': 67}, '0331701430640973': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 143, 'tps_qty_index': 64, 'max_risk_long': 97}, '66787357652': {'ott_len': 66, 'ott_percent': 78, 'ott_bw_up': 73, 'tps_qty_index': 57, 'max_risk_long': 65}, '0701701490000913': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 0, 'max_risk_long': 91}, '0700781390290673': {'ott_len': 70, 'ott_percent': 78, 'ott_bw_up': 139, 'tps_qty_index': 29, 'max_risk_long': 67}, '0601050950650813': {'ott_len': 60, 'ott_percent': 105, 'ott_bw_up': 95, 'tps_qty_index': 65, 'max_risk_long': 81}, '0400781490420563': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 42, 'max_risk_long': 56}, '0572181750000913': {'ott_len': 57, 'ott_percent': 218, 'ott_bw_up': 175, 'tps_qty_index': 0, 'max_risk_long': 91}, '0281701690020483': {'ott_len': 28, 'ott_percent': 170, 'ott_bw_up': 169, 'tps_qty_index': 2, 'max_risk_long': 48}, '0631701340690723': {'ott_len': 63, 'ott_percent': 170, 'ott_bw_up': 134, 'tps_qty_index': 69, 'max_risk_long': 72}, '0691581140650703': {'ott_len': 69, 'ott_percent': 158, 'ott_bw_up': 114, 'tps_qty_index': 65, 'max_risk_long': 70}, '0450781491120653': {'ott_len': 45, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 112, 'max_risk_long': 65}, '0691050980650663': {'ott_len': 69, 'ott_percent': 105, 'ott_bw_up': 98, 'tps_qty_index': 65, 'max_risk_long': 66}, '0391701430640973': {'ott_len': 39, 'ott_percent': 170, 'ott_bw_up': 143, 'tps_qty_index': 64, 'max_risk_long': 97}, '0331291110650813': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 65, 'max_risk_long': 81}, '0351291110200453': {'ott_len': 35, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 20, 'max_risk_long': 45}, '0701701380640523': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 64, 'max_risk_long': 52}, '0450781490370653': {'ott_len': 45, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 37, 'max_risk_long': 65}, '0521051340690693': {'ott_len': 52, 'ott_percent': 105, 'ott_bw_up': 134, 'tps_qty_index': 69, 'max_risk_long': 69}, '66788842652': {'ott_len': 66, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 42, 'max_risk_long': 65}, '0640781390420673': {'ott_len': 64, 'ott_percent': 78, 'ott_bw_up': 139, 'tps_qty_index': 42, 'max_risk_long': 67}, '0700701120370653': {'ott_len': 70, 'ott_percent': 70, 'ott_bw_up': 112, 'tps_qty_index': 37, 'max_risk_long': 65}, '0682181720800673': {'ott_len': 68, 'ott_percent': 218, 'ott_bw_up': 172, 'tps_qty_index': 80, 'max_risk_long': 67}, '0311051471100663': {'ott_len': 31, 'ott_percent': 105, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 66}, '0701291110370653': {'ott_len': 70, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 37, 'max_risk_long': 65}, '0400781360170653': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 136, 'tps_qty_index': 17, 'max_risk_long': 65}, '0682181721120663': {'ott_len': 68, 'ott_percent': 218, 'ott_bw_up': 172, 'tps_qty_index': 112, 'max_risk_long': 66}, '0331291490650523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 65, 'max_risk_long': 52}, '0334791750000813': {'ott_len': 33, 'ott_percent': 479, 'ott_bw_up': 175, 'tps_qty_index': 0, 'max_risk_long': 81}, '57788850852': {'ott_len': 57, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 50, 'max_risk_long': 85}, '0581050990500523': {'ott_len': 58, 'ott_percent': 105, 'ott_bw_up': 99, 'tps_qty_index': 50, 'max_risk_long': 52}, '0531701470690723': {'ott_len': 53, 'ott_percent': 170, 'ott_bw_up': 147, 'tps_qty_index': 69, 'max_risk_long': 72}, '0541701430841003': {'ott_len': 54, 'ott_percent': 170, 'ott_bw_up': 143, 'tps_qty_index': 84, 'max_risk_long': 100}, '57788842712': {'ott_len': 57, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 42, 'max_risk_long': 71}, '70709372652': {'ott_len': 70, 'ott_percent': 70, 'ott_bw_up': 93, 'tps_qty_index': 72, 'max_risk_long': 65}, '0540971110650593': {'ott_len': 54, 'ott_percent': 97, 'ott_bw_up': 111, 'tps_qty_index': 65, 'max_risk_long': 59}, '0331291110610813': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 61, 'max_risk_long': 81}, '0311031470410553': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 41, 'max_risk_long': 55}, '0292181721120663': {'ott_len': 29, 'ott_percent': 218, 'ott_bw_up': 172, 'tps_qty_index': 112, 'max_risk_long': 66}, '0400781470420563': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 42, 'max_risk_long': 56}, '0541291400650653': {'ott_len': 54, 'ott_percent': 129, 'ott_bw_up': 140, 'tps_qty_index': 65, 'max_risk_long': 65}, '0312181721100913': {'ott_len': 31, 'ott_percent': 218, 'ott_bw_up': 172, 'tps_qty_index': 110, 'max_risk_long': 91}, '0330781470590493': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 59, 'max_risk_long': 49}, '0400781490170563': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 17, 'max_risk_long': 56}, '40789942562': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 99, 'tps_qty_index': 42, 'max_risk_long': 56}, '0701291160370653': {'ott_len': 70, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 37, 'max_risk_long': 65}, '0331291170220593': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 117, 'tps_qty_index': 22, 'max_risk_long': 59}, '0310781471100493': {'ott_len': 31, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 49}, '57788872652': {'ott_len': 57, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 72, 'max_risk_long': 65}, '0660781240650673': {'ott_len': 66, 'ott_percent': 78, 'ott_bw_up': 124, 'tps_qty_index': 65, 'max_risk_long': 67}, '0400781360480653': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 136, 'tps_qty_index': 48, 'max_risk_long': 65}, '70788864712': {'ott_len': 70, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 64, 'max_risk_long': 71}, '0350781380090653': {'ott_len': 35, 'ott_percent': 78, 'ott_bw_up': 138, 'tps_qty_index': 9, 'max_risk_long': 65}, '0331291110410523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 41, 'max_risk_long': 52}, '0331701340470523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 134, 'tps_qty_index': 47, 'max_risk_long': 52}, '0311031470420523': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 42, 'max_risk_long': 52}, '0331051110270913': {'ott_len': 33, 'ott_percent': 105, 'ott_bw_up': 111, 'tps_qty_index': 27, 'max_risk_long': 91}, '0682181731120663': {'ott_len': 68, 'ott_percent': 218, 'ott_bw_up': 173, 'tps_qty_index': 112, 'max_risk_long': 66}, '0701701340690523': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 134, 'tps_qty_index': 69, 'max_risk_long': 52}, '70788872612': {'ott_len': 70, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 72, 'max_risk_long': 61}, '0312181721100663': {'ott_len': 31, 'ott_percent': 218, 'ott_bw_up': 172, 'tps_qty_index': 110, 'max_risk_long': 66}, '0331291490590523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 59, 'max_risk_long': 52}, '0682181571120663': {'ott_len': 68, 'ott_percent': 218, 'ott_bw_up': 157, 'tps_qty_index': 112, 'max_risk_long': 66}, '0550781430310673': {'ott_len': 55, 'ott_percent': 78, 'ott_bw_up': 143, 'tps_qty_index': 31, 'max_risk_long': 67}, '48788842652': {'ott_len': 48, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 42, 'max_risk_long': 65}, '0581050970270653': {'ott_len': 58, 'ott_percent': 105, 'ott_bw_up': 97, 'tps_qty_index': 27, 'max_risk_long': 65}, '0572181390030713': {'ott_len': 57, 'ott_percent': 218, 'ott_bw_up': 139, 'tps_qty_index': 3, 'max_risk_long': 71}, '0701701341090523': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 134, 'tps_qty_index': 109, 'max_risk_long': 52}, '0331291110610493': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 61, 'max_risk_long': 49}, '0420781430420553': {'ott_len': 42, 'ott_percent': 78, 'ott_bw_up': 143, 'tps_qty_index': 42, 'max_risk_long': 55}, '0631701380480523': {'ott_len': 63, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 48, 'max_risk_long': 52}, '0311291490650523': {'ott_len': 31, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 65, 'max_risk_long': 52}, '0330781490890673': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 89, 'max_risk_long': 67}, '0311031470030523': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 3, 'max_risk_long': 52}, '0331291490410793': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 41, 'max_risk_long': 79}, '0631701471100913': {'ott_len': 63, 'ott_percent': 170, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 91}, '0321031470840913': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 84, 'max_risk_long': 91}, '0311291160930823': {'ott_len': 31, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 93, 'max_risk_long': 82}, '0350781380640523': {'ott_len': 35, 'ott_percent': 78, 'ott_bw_up': 138, 'tps_qty_index': 64, 'max_risk_long': 52}, '0590821210640523': {'ott_len': 59, 'ott_percent': 82, 'ott_bw_up': 121, 'tps_qty_index': 64, 'max_risk_long': 52}, '0660781110370653': {'ott_len': 66, 'ott_percent': 78, 'ott_bw_up': 111, 'tps_qty_index': 37, 'max_risk_long': 65}, '0631291110100523': {'ott_len': 63, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 10, 'max_risk_long': 52}, '0701701110370653': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 111, 'tps_qty_index': 37, 'max_risk_long': 65}, '0331411470590593': {'ott_len': 33, 'ott_percent': 141, 'ott_bw_up': 147, 'tps_qty_index': 59, 'max_risk_long': 59}, '0331291080590793': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 108, 'tps_qty_index': 59, 'max_risk_long': 79}, '0311411471100543': {'ott_len': 31, 'ott_percent': 141, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 54}, '0311291360170653': {'ott_len': 31, 'ott_percent': 129, 'ott_bw_up': 136, 'tps_qty_index': 17, 'max_risk_long': 65}, '0331291490980613': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 98, 'max_risk_long': 61}, '0321031490840673': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 84, 'max_risk_long': 67}, '0701701400650653': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 140, 'tps_qty_index': 65, 'max_risk_long': 65}, '0321031491100913': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 91}, '0321031240840913': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 124, 'tps_qty_index': 84, 'max_risk_long': 91}, '0701291160160823': {'ott_len': 70, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 16, 'max_risk_long': 82}, '0681701340690523': {'ott_len': 68, 'ott_percent': 170, 'ott_bw_up': 134, 'tps_qty_index': 69, 'max_risk_long': 52}, '0731291110650813': {'ott_len': 73, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 65, 'max_risk_long': 81}, '0330781470860523': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 86, 'max_risk_long': 52}, '0331031491100493': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 49}, '0311031471070553': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 107, 'max_risk_long': 55}, '0331701710590653': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 171, 'tps_qty_index': 59, 'max_risk_long': 65}, '0701291160930653': {'ott_len': 70, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 93, 'max_risk_long': 65}, '0331291490980913': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 98, 'max_risk_long': 91}, '0331291710790653': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 171, 'tps_qty_index': 79, 'max_risk_long': 65}, '0312021470370653': {'ott_len': 31, 'ott_percent': 202, 'ott_bw_up': 147, 'tps_qty_index': 37, 'max_risk_long': 65}, '0330781470840673': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 84, 'max_risk_long': 67}, '0331121490940803': {'ott_len': 33, 'ott_percent': 112, 'ott_bw_up': 149, 'tps_qty_index': 94, 'max_risk_long': 80}, '0331701380700523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 70, 'max_risk_long': 52}, '0311571490980603': {'ott_len': 31, 'ott_percent': 157, 'ott_bw_up': 149, 'tps_qty_index': 98, 'max_risk_long': 60}, '40788117652': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 81, 'tps_qty_index': 17, 'max_risk_long': 65}, '0480781390650613': {'ott_len': 48, 'ott_percent': 78, 'ott_bw_up': 139, 'tps_qty_index': 65, 'max_risk_long': 61}, '0321031470840773': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 84, 'max_risk_long': 77}, '0311330940420553': {'ott_len': 31, 'ott_percent': 133, 'ott_bw_up': 94, 'tps_qty_index': 42, 'max_risk_long': 55}, '0331291490690523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 69, 'max_risk_long': 52}, '0681291350650663': {'ott_len': 68, 'ott_percent': 129, 'ott_bw_up': 135, 'tps_qty_index': 65, 'max_risk_long': 66}, '0331761490860523': {'ott_len': 33, 'ott_percent': 176, 'ott_bw_up': 149, 'tps_qty_index': 86, 'max_risk_long': 52}, '0371291110420653': {'ott_len': 37, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 42, 'max_risk_long': 65}, '0480781470100613': {'ott_len': 48, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 10, 'max_risk_long': 61}, '0331291450690523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 145, 'tps_qty_index': 69, 'max_risk_long': 52}, '0330911470840853': {'ott_len': 33, 'ott_percent': 91, 'ott_bw_up': 147, 'tps_qty_index': 84, 'max_risk_long': 85}, '0400781040690653': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 104, 'tps_qty_index': 69, 'max_risk_long': 65}, '0441031110840693': {'ott_len': 44, 'ott_percent': 103, 'ott_bw_up': 111, 'tps_qty_index': 84, 'max_risk_long': 69}, '0330781470770673': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 77, 'max_risk_long': 67}, '0661291100370653': {'ott_len': 66, 'ott_percent': 129, 'ott_bw_up': 110, 'tps_qty_index': 37, 'max_risk_long': 65}, '0701701380930653': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 93, 'max_risk_long': 65}, '0331291110560823': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 56, 'max_risk_long': 82}, '0501030920420453': {'ott_len': 50, 'ott_percent': 103, 'ott_bw_up': 92, 'tps_qty_index': 42, 'max_risk_long': 45}, '0331291490840503': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 84, 'max_risk_long': 50}, '0331701340690523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 134, 'tps_qty_index': 69, 'max_risk_long': 52}, '0331031471100493': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 49}, '68788818492': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 18, 'max_risk_long': 49}, '0311031471100553': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 55}, '0331701380640523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 64, 'max_risk_long': 52}, '0701701380570523': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 57, 'max_risk_long': 52}, '0621291110650913': {'ott_len': 62, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 65, 'max_risk_long': 91}, '0350781340640523': {'ott_len': 35, 'ott_percent': 78, 'ott_bw_up': 134, 'tps_qty_index': 64, 'max_risk_long': 52}, '0311291471100653': {'ott_len': 31, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 65}, '0311701350380933': {'ott_len': 31, 'ott_percent': 170, 'ott_bw_up': 135, 'tps_qty_index': 38, 'max_risk_long': 93}, '0311030880720553': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 88, 'tps_qty_index': 72, 'max_risk_long': 55}, '0331701490640523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 64, 'max_risk_long': 52}, '66788884672': {'ott_len': 66, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 84, 'max_risk_long': 67}, '0331291050940523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 105, 'tps_qty_index': 94, 'max_risk_long': 52}, '0400781470690653': {'ott_len': 40, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 69, 'max_risk_long': 65}, '0321031481100913': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 148, 'tps_qty_index': 110, 'max_risk_long': 91}, '0311031470420653': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 42, 'max_risk_long': 65}, '0331291080420793': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 108, 'tps_qty_index': 42, 'max_risk_long': 79}, '0331291470690523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 69, 'max_risk_long': 52}, '0331291490110653': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 11, 'max_risk_long': 65}, '0701701380570653': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 57, 'max_risk_long': 65}, '0331561340640863': {'ott_len': 33, 'ott_percent': 156, 'ott_bw_up': 134, 'tps_qty_index': 64, 'max_risk_long': 86}, '0330781490650503': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 65, 'max_risk_long': 50}, '0311030880400553': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 88, 'tps_qty_index': 40, 'max_risk_long': 55}, '0330781470690493': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 69, 'max_risk_long': 49}, '0321031490980913': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 98, 'max_risk_long': 91}, '0321031491100523': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 52}, '0331701490590653': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 59, 'max_risk_long': 65}, '0331291490770553': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 77, 'max_risk_long': 55}, '0291291160930583': {'ott_len': 29, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 93, 'max_risk_long': 58}, '0341291471100663': {'ott_len': 34, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 66}, '0701701380370653': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 37, 'max_risk_long': 65}, '0331291491100613': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 61}, '33788842652': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 42, 'max_risk_long': 65}, '0331291490410673': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 41, 'max_risk_long': 67}, '0331291490590653': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 59, 'max_risk_long': 65}, '70788872532': {'ott_len': 70, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 72, 'max_risk_long': 53}, '0701701380840653': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 84, 'max_risk_long': 65}, '39788977342': {'ott_len': 39, 'ott_percent': 78, 'ott_bw_up': 89, 'tps_qty_index': 77, 'max_risk_long': 34}, '68788856442': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 56, 'max_risk_long': 44}, '0331271710570653': {'ott_len': 33, 'ott_percent': 127, 'ott_bw_up': 171, 'tps_qty_index': 57, 'max_risk_long': 65}, '68788872652': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 72, 'max_risk_long': 65}, '0331531490660793': {'ott_len': 33, 'ott_percent': 153, 'ott_bw_up': 149, 'tps_qty_index': 66, 'max_risk_long': 79}, '0331291470650453': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 65, 'max_risk_long': 45}, '0330781471040523': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 104, 'max_risk_long': 52}, '0701291161100653': {'ott_len': 70, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 110, 'max_risk_long': 65}, '0310781471100523': {'ott_len': 31, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 52}, '33788841792': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 41, 'max_risk_long': 79}, '0321291160930523': {'ott_len': 32, 'ott_percent': 129, 'ott_bw_up': 116, 'tps_qty_index': 93, 'max_risk_long': 52}, '0331291490110503': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 11, 'max_risk_long': 50}, '0331291071100613': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 107, 'tps_qty_index': 110, 'max_risk_long': 61}, '0701701381100523': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 110, 'max_risk_long': 52}, '0680781090180743': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 109, 'tps_qty_index': 18, 'max_risk_long': 74}, '0651291490650523': {'ott_len': 65, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 65, 'max_risk_long': 52}, '0331701491100883': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 88}, '0330781490640663': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 64, 'max_risk_long': 66}, '0701701380840573': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 84, 'max_risk_long': 57}, '0331291471100663': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 66}, '68788818982': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 18, 'max_risk_long': 98}, '0331291710770653': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 171, 'tps_qty_index': 77, 'max_risk_long': 65}, '0331701710110653': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 171, 'tps_qty_index': 11, 'max_risk_long': 65}, '0310941471100553': {'ott_len': 31, 'ott_percent': 94, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 55}, '0321031470770553': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 77, 'max_risk_long': 55}, '0321031491060503': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 106, 'max_risk_long': 50}, '0680780881100493': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 110, 'max_risk_long': 49}, '0331291491100793': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 79}, '0331031471060643': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 106, 'max_risk_long': 64}, '0331291330650943': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 133, 'tps_qty_index': 65, 'max_risk_long': 94}, '0560781380350573': {'ott_len': 56, 'ott_percent': 78, 'ott_bw_up': 138, 'tps_qty_index': 35, 'max_risk_long': 57}, '0331291710590523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 171, 'tps_qty_index': 59, 'max_risk_long': 52}, '0331291471100523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 52}, '0320781161100523': {'ott_len': 32, 'ott_percent': 78, 'ott_bw_up': 116, 'tps_qty_index': 110, 'max_risk_long': 52}, '0701701380320523': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 32, 'max_risk_long': 52}, '0331031491100523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 52}, '0331701710640633': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 171, 'tps_qty_index': 64, 'max_risk_long': 63}, '0331501550690523': {'ott_len': 33, 'ott_percent': 150, 'ott_bw_up': 155, 'tps_qty_index': 69, 'max_risk_long': 52}, '0331291380840503': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 138, 'tps_qty_index': 84, 'max_risk_long': 50}, '0701291380570763': {'ott_len': 70, 'ott_percent': 129, 'ott_bw_up': 138, 'tps_qty_index': 57, 'max_risk_long': 76}, '0331291490570523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 57, 'max_risk_long': 52}, '0331291491160523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 116, 'max_risk_long': 52}, '68788825492': {'ott_len': 68, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 25, 'max_risk_long': 49}, '0330781340640553': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 134, 'tps_qty_index': 64, 'max_risk_long': 55}, '0331291710770463': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 171, 'tps_qty_index': 77, 'max_risk_long': 46}, '0341291490840663': {'ott_len': 34, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 84, 'max_risk_long': 66}, '0331291490650663': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 65, 'max_risk_long': 66}, '0321291710980523': {'ott_len': 32, 'ott_percent': 129, 'ott_bw_up': 171, 'tps_qty_index': 98, 'max_risk_long': 52}, '0451291490590523': {'ott_len': 45, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 59, 'max_risk_long': 52}, '0331291490840523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 84, 'max_risk_long': 52}, '0331031490590653': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 59, 'max_risk_long': 65}, '0301471471100553': {'ott_len': 30, 'ott_percent': 147, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 55}, '0330941470920553': {'ott_len': 33, 'ott_percent': 94, 'ott_bw_up': 147, 'tps_qty_index': 92, 'max_risk_long': 55}, '0311031390420563': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 139, 'tps_qty_index': 42, 'max_risk_long': 56}, '0340861470860523': {'ott_len': 34, 'ott_percent': 86, 'ott_bw_up': 147, 'tps_qty_index': 86, 'max_risk_long': 52}, '0451291490770553': {'ott_len': 45, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 77, 'max_risk_long': 55}, '0331291490590913': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 59, 'max_risk_long': 91}, '0331291471040773': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 104, 'max_risk_long': 77}, '0331031160930523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 116, 'tps_qty_index': 93, 'max_risk_long': 52}, '0321031491100503': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 50}, '70788869522': {'ott_len': 70, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 69, 'max_risk_long': 52}, '0331701560110653': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 156, 'tps_qty_index': 11, 'max_risk_long': 65}, '0320781481040913': {'ott_len': 32, 'ott_percent': 78, 'ott_bw_up': 148, 'tps_qty_index': 104, 'max_risk_long': 91}, '0330781471100523': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 52}, '0331291491100523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 110, 'max_risk_long': 52}, '0310940951100553': {'ott_len': 31, 'ott_percent': 94, 'ott_bw_up': 95, 'tps_qty_index': 110, 'max_risk_long': 55}, '0331291490770523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 77, 'max_risk_long': 52}, '0331031470990523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 99, 'max_risk_long': 52}, '0331291490750553': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 75, 'max_risk_long': 55}, '0310941491060553': {'ott_len': 31, 'ott_percent': 94, 'ott_bw_up': 149, 'tps_qty_index': 106, 'max_risk_long': 55}, '0331031250590653': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 125, 'tps_qty_index': 59, 'max_risk_long': 65}, '0321031491060523': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 106, 'max_risk_long': 52}, '0321031471100913': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 91}, '0331291390590523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 139, 'tps_qty_index': 59, 'max_risk_long': 52}, '0331031490990523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 99, 'max_risk_long': 52}, '0331701490570523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 57, 'max_risk_long': 52}, '0331030930990523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 93, 'tps_qty_index': 99, 'max_risk_long': 52}, '0331291490920553': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 92, 'max_risk_long': 55}, '0330781490840673': {'ott_len': 33, 'ott_percent': 78, 'ott_bw_up': 149, 'tps_qty_index': 84, 'max_risk_long': 67}, '70788893512': {'ott_len': 70, 'ott_percent': 78, 'ott_bw_up': 88, 'tps_qty_index': 93, 'max_risk_long': 51}, '0331291490750463': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 75, 'max_risk_long': 46}, '0331031471030523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 103, 'max_risk_long': 52}, '0331701490770653': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 77, 'max_risk_long': 65}, '0331291490320523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 32, 'max_risk_long': 52}, '0331031470860523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 86, 'max_risk_long': 52}, '0331031470500493': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 50, 'max_risk_long': 49}, '0331481490610653': {'ott_len': 33, 'ott_percent': 148, 'ott_bw_up': 149, 'tps_qty_index': 61, 'max_risk_long': 65}, '0331031471040493': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 104, 'max_risk_long': 49}, '0331701440590523': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 144, 'tps_qty_index': 59, 'max_risk_long': 52}, '0611291380590583': {'ott_len': 61, 'ott_percent': 129, 'ott_bw_up': 138, 'tps_qty_index': 59, 'max_risk_long': 58}, '0701030980120503': {'ott_len': 70, 'ott_percent': 103, 'ott_bw_up': 98, 'tps_qty_index': 12, 'max_risk_long': 50}, '0331291490930653': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 93, 'max_risk_long': 65}, '0320781481100493': {'ott_len': 32, 'ott_percent': 78, 'ott_bw_up': 148, 'tps_qty_index': 110, 'max_risk_long': 49}, '0321701310840573': {'ott_len': 32, 'ott_percent': 170, 'ott_bw_up': 131, 'tps_qty_index': 84, 'max_risk_long': 57}, '0331701380590653': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 59, 'max_risk_long': 65}, '0310941380570523': {'ott_len': 31, 'ott_percent': 94, 'ott_bw_up': 138, 'tps_qty_index': 57, 'max_risk_long': 52}, '0331701490110553': {'ott_len': 33, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 11, 'max_risk_long': 55}, '0331291121060523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 112, 'tps_qty_index': 106, 'max_risk_long': 52}, '0331031471100523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 52}, '0701701380670503': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 67, 'max_risk_long': 50}, '0701701381100913': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 138, 'tps_qty_index': 110, 'max_risk_long': 91}, '0331031180590453': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 118, 'tps_qty_index': 59, 'max_risk_long': 45}, '0331291470920553': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 147, 'tps_qty_index': 92, 'max_risk_long': 55}, '0331031490680493': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 68, 'max_risk_long': 49}, '0310941471120553': {'ott_len': 31, 'ott_percent': 94, 'ott_bw_up': 147, 'tps_qty_index': 112, 'max_risk_long': 55}, '0331291490770663': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 77, 'max_risk_long': 66}, '0361701470570523': {'ott_len': 36, 'ott_percent': 170, 'ott_bw_up': 147, 'tps_qty_index': 57, 'max_risk_long': 52}, '0310781291100523': {'ott_len': 31, 'ott_percent': 78, 'ott_bw_up': 129, 'tps_qty_index': 110, 'max_risk_long': 52}, '0310941471100523': {'ott_len': 31, 'ott_percent': 94, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 52}, '0331031470510523': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 51, 'max_risk_long': 52}, '0701701490770553': {'ott_len': 70, 'ott_percent': 170, 'ott_bw_up': 149, 'tps_qty_index': 77, 'max_risk_long': 55}, '0331031471100553': {'ott_len': 33, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 55}, '0331291180570523': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 118, 'tps_qty_index': 57, 'max_risk_long': 52}, '0311031490750553': {'ott_len': 31, 'ott_percent': 103, 'ott_bw_up': 149, 'tps_qty_index': 75, 'max_risk_long': 55}, '0321031471100553': {'ott_len': 32, 'ott_percent': 103, 'ott_bw_up': 147, 'tps_qty_index': 110, 'max_risk_long': 55}, '0331291110130453': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 111, 'tps_qty_index': 13, 'max_risk_long': 45}, '0331291481100553': {'ott_len': 33, 'ott_percent': 129, 'ott_bw_up': 148, 'tps_qty_index': 110, 'max_risk_long': 55}, '0321291490930913': {'ott_len': 32, 'ott_percent': 129, 'ott_bw_up': 149, 'tps_qty_index': 93, 'max_risk_long': 91}}
""" A variety of examples to showcase useage of pix. Note that some libraries or other thirdparty resources may be required to run an example. """
""" A variety of examples to showcase useage of pix. Note that some libraries or other thirdparty resources may be required to run an example. """
class Configuration(object): def __init__(self, **kwargs): for key, value in kwargs.items(): if isinstance(value, dict): value = Configuration(**value) setattr(self, key, value) def to_dict(self): rv = {} for key, value in self.__dict__.items(): if isinstance(value, Configuration): value = value.to_dict() rv[key] = value return rv def __str__(self): return str(self.to_dict()) def __repr__(self): return f"<{self.__class__.__name__} '{str(self)}'>"
class Configuration(object): def __init__(self, **kwargs): for (key, value) in kwargs.items(): if isinstance(value, dict): value = configuration(**value) setattr(self, key, value) def to_dict(self): rv = {} for (key, value) in self.__dict__.items(): if isinstance(value, Configuration): value = value.to_dict() rv[key] = value return rv def __str__(self): return str(self.to_dict()) def __repr__(self): return f"<{self.__class__.__name__} '{str(self)}'>"
product = input() day = input() quantity = float(input()) price = 0 isError = False if day == 'Saturday' or day == 'Sunday': if product == 'banana': price = 2.7 elif product == 'apple': price = 1.25 elif product == 'orange': price = 0.9 elif product == 'grapefruit': price = 1.60 elif product == 'kiwi': price = 3 elif product == 'pineapple': price = 5.6 elif product == 'grapes': price = 4.2 else: print('error') isError = True elif day == 'Monday' or day == 'Tuesday' or day == 'Wednesday' or day == 'Thursday' or day == 'Friday': if product == 'banana': price = 2.5 elif product == 'apple': price = 1.2 elif product == 'orange': price = 0.85 elif product == 'grapefruit': price = 1.45 elif product == 'kiwi': price = 2.7 elif product == 'pineapple': price = 5.5 elif product == 'grapes': price = 3.85 else: print('error') isError = True else: print('error') isError = True if isError == False: print(f"{(price * quantity):.2f}")
product = input() day = input() quantity = float(input()) price = 0 is_error = False if day == 'Saturday' or day == 'Sunday': if product == 'banana': price = 2.7 elif product == 'apple': price = 1.25 elif product == 'orange': price = 0.9 elif product == 'grapefruit': price = 1.6 elif product == 'kiwi': price = 3 elif product == 'pineapple': price = 5.6 elif product == 'grapes': price = 4.2 else: print('error') is_error = True elif day == 'Monday' or day == 'Tuesday' or day == 'Wednesday' or (day == 'Thursday') or (day == 'Friday'): if product == 'banana': price = 2.5 elif product == 'apple': price = 1.2 elif product == 'orange': price = 0.85 elif product == 'grapefruit': price = 1.45 elif product == 'kiwi': price = 2.7 elif product == 'pineapple': price = 5.5 elif product == 'grapes': price = 3.85 else: print('error') is_error = True else: print('error') is_error = True if isError == False: print(f'{price * quantity:.2f}')
# -*- coding: utf-8 -*- class Precipitation(object): def __init__(self, precipitation): self.value = float(precipitation['value']) try: self.minValue = float(precipitation['minvalue']) except KeyError: self.minValue = None try: self.maxValue = float(precipitation['maxvalue']) except KeyError: self.maxValue = None def __str__(self): return '\t\t\t\tValue: {0} \n\t\t\t\tMinValue: {1} \n\t\t\t\tMaxValue: {2}'.format(self.value, self.minValue, self.maxValue)
class Precipitation(object): def __init__(self, precipitation): self.value = float(precipitation['value']) try: self.minValue = float(precipitation['minvalue']) except KeyError: self.minValue = None try: self.maxValue = float(precipitation['maxvalue']) except KeyError: self.maxValue = None def __str__(self): return '\t\t\t\tValue: {0} \n\t\t\t\tMinValue: {1} \n\t\t\t\tMaxValue: {2}'.format(self.value, self.minValue, self.maxValue)
def run(): r.setpos(0,0,0)
def run(): r.setpos(0, 0, 0)
class Command: TO_CN = 1 TO_EN = 2 JSON_FORMAT = 3 URL_ENCODE = 4 URL_DECODE = 5
class Command: to_cn = 1 to_en = 2 json_format = 3 url_encode = 4 url_decode = 5
# checking for armstrong number a = input("Enter a number") n = int(a) S = 0 while n > 0: d = n % 10 S = S + d * d * d n = n / 10 if int(a) == S: print("Armstrong Number") else: print("Not an Armstrong Number")
a = input('Enter a number') n = int(a) s = 0 while n > 0: d = n % 10 s = S + d * d * d n = n / 10 if int(a) == S: print('Armstrong Number') else: print('Not an Armstrong Number')
class BuildEnvironmentError(Exception): def __init__(self, msg, build_env): self.msg = msg self.build_env = build_env def __str__(self): return "{}({})".format(self.__class__.__name__, repr(self.msg)) class VariantDBConnectionError(BuildEnvironmentError): def __init__(self, connection, build_env): self.connection = connection self.msg = "Could not connect to database \"{}\"".format(connection) self.build_env = build_env
class Buildenvironmenterror(Exception): def __init__(self, msg, build_env): self.msg = msg self.build_env = build_env def __str__(self): return '{}({})'.format(self.__class__.__name__, repr(self.msg)) class Variantdbconnectionerror(BuildEnvironmentError): def __init__(self, connection, build_env): self.connection = connection self.msg = 'Could not connect to database "{}"'.format(connection) self.build_env = build_env
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param l1: the first list @param l2: the second list @return: the sum list of l1 and l2 """ def addLists(self, l1, l2): dummy = tail = ListNode(0) carry = 0 while l1 is not None or l2 is not None or carry == 1: tail.next = ListNode(carry) tail = tail.next if l1 is not None: tail.val += l1.val l1 = l1.next if l2 is not None: tail.val += l2.val l2 = l2.next if tail.val > 9: tail.val -= 10 carry = 1 else: carry = 0 return dummy.next
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param l1: the first list @param l2: the second list @return: the sum list of l1 and l2 """ def add_lists(self, l1, l2): dummy = tail = list_node(0) carry = 0 while l1 is not None or l2 is not None or carry == 1: tail.next = list_node(carry) tail = tail.next if l1 is not None: tail.val += l1.val l1 = l1.next if l2 is not None: tail.val += l2.val l2 = l2.next if tail.val > 9: tail.val -= 10 carry = 1 else: carry = 0 return dummy.next
#Advanced string syntax #Multiple ways to type strings print('Hello') print("That is Alice's cat") #To use a single quote throughout your code #put in a / before the quotation print('Here is the example (\')') print('Do you see how the quotation \' is shown?') #Example of types of "Escape Characters" # \' = Single Quote # \" = Double Quote # \t = Tab # \n = New Line (Line break) # \\ = Backslash print('Hello there! \nHow are you? \n I\'m fine.') # Multi line strings start with """. The """ enables the user to code without using the escape characters print("""This is an example of use of the multi string. Dear Alice, Eve's cat has been arrested for catnapping, cat burglary, and extortion. Sincerely, Drew.""") #Now we will attache this to a variable spam spam = print("""This is an example of use of the multi string. Dear Alice, Eve's cat has been arrested for catnapping, cat burglary, and extortion. Sincerely, Drew.""") spam
print('Hello') print("That is Alice's cat") print("Here is the example (')") print("Do you see how the quotation ' is shown?") print("Hello there! \nHow are you? \n I'm fine.") print("This is an example of use of the multi string.\n\nDear Alice,\nEve's cat has been arrested for catnapping, cat burglary, and extortion.\nSincerely,\nDrew.") spam = print("This is an example of use of the multi string.\n\nDear Alice,\nEve's cat has been arrested for catnapping, cat burglary, and extortion.\nSincerely,\nDrew.") spam
class Queue: def __init__(self): self.queue = list() def enqueue(self,data): if data not in self.queue: self.queue.insert(0,data) return True return False def dequeue(self): if len(self.queue)>0: return self.queue.pop() return ("Queue Empty!") def size(self): return len(self.queue) def printQueue(self): return self.queue myQueue = Queue() print(myQueue.enqueue(5)) print(myQueue.enqueue(6)) print(myQueue.enqueue(9)) print(myQueue.enqueue(5)) print(myQueue.enqueue(3)) print(myQueue.size()) print(myQueue.dequeue()) print(myQueue.dequeue()) print(myQueue.dequeue()) print(myQueue.dequeue()) print(myQueue.size()) print(myQueue.dequeue())
class Queue: def __init__(self): self.queue = list() def enqueue(self, data): if data not in self.queue: self.queue.insert(0, data) return True return False def dequeue(self): if len(self.queue) > 0: return self.queue.pop() return 'Queue Empty!' def size(self): return len(self.queue) def print_queue(self): return self.queue my_queue = queue() print(myQueue.enqueue(5)) print(myQueue.enqueue(6)) print(myQueue.enqueue(9)) print(myQueue.enqueue(5)) print(myQueue.enqueue(3)) print(myQueue.size()) print(myQueue.dequeue()) print(myQueue.dequeue()) print(myQueue.dequeue()) print(myQueue.dequeue()) print(myQueue.size()) print(myQueue.dequeue())
class Solution(object): def findDuplicate(self, nums): """ :type nums: List[int] :rtype: int """ n = len(nums) - 1 start, end = 1, n while start + 1 < end: mid = start + (end - start) / 2 count = 0 for num in nums: if num < mid: count += 1 if count >= mid: end = mid else: start = mid if nums.count(start) > nums.count(end): return start return end
class Solution(object): def find_duplicate(self, nums): """ :type nums: List[int] :rtype: int """ n = len(nums) - 1 (start, end) = (1, n) while start + 1 < end: mid = start + (end - start) / 2 count = 0 for num in nums: if num < mid: count += 1 if count >= mid: end = mid else: start = mid if nums.count(start) > nums.count(end): return start return end
class TerminalSet: NODE_TYPE = 'terminal' @classmethod def is_terminal_value(cls, node): return node['node_type'] == cls.NODE_TYPE and node.has_key('value') and (node['type'] in ['int', 'float']) @classmethod def terminal_value(cls, value): return {'node_type': cls.NODE_TYPE, 'name': str(value), 'value': value, 'type': type(value).__name__} def __init__(self): self.terminal_set = [] def add_terminal_value(self, name, value): self.terminal_set.append({'node_type': self.NODE_TYPE, 'name': name, 'value': value, 'type': type(value).__name__}) def add_terminal_function(self, name, func_ref, value_type, args=[]): self.terminal_set.append({'node_type': self.NODE_TYPE, 'name': name, 'function': func_ref, 'type': value_type, 'args': args}) def add_terminal_function_to_value(self, func_ref, args=[]): self.terminal_set.append({'node_type': self.NODE_TYPE, 'function': func_ref, 'args': args}) def get(self): return self.terminal_set
class Terminalset: node_type = 'terminal' @classmethod def is_terminal_value(cls, node): return node['node_type'] == cls.NODE_TYPE and node.has_key('value') and (node['type'] in ['int', 'float']) @classmethod def terminal_value(cls, value): return {'node_type': cls.NODE_TYPE, 'name': str(value), 'value': value, 'type': type(value).__name__} def __init__(self): self.terminal_set = [] def add_terminal_value(self, name, value): self.terminal_set.append({'node_type': self.NODE_TYPE, 'name': name, 'value': value, 'type': type(value).__name__}) def add_terminal_function(self, name, func_ref, value_type, args=[]): self.terminal_set.append({'node_type': self.NODE_TYPE, 'name': name, 'function': func_ref, 'type': value_type, 'args': args}) def add_terminal_function_to_value(self, func_ref, args=[]): self.terminal_set.append({'node_type': self.NODE_TYPE, 'function': func_ref, 'args': args}) def get(self): return self.terminal_set
""" Parameters exchanged client <-> server and client <-> compensator Copyright 2021 Reza NasiriGerdeh and Reihaneh TorkzadehMahani. All Rights Reserved. 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 Parameter: """ There are nine general categories of the parameters exchanged clients <-> server and client <-> compensator: client -> server: authentication, synchronization, monitoring, and local parameters server -> client: coordination, project, and global parameters client -> compensator: authentication, synchronization, connection, data_type, and compensation parameters compensator -> client: synchronization parameters """ AUTHENTICATION = "authentication_parameter" SYNCHRONIZATION = "synchronization_parameter" MONITORING = "monitoring_parameter" PROJECT = "project_parameter" COORDINATION = "coordination_parameter" CONNECTION = "connection_parameter" GLOBAL = "global_parameter" LOCAL = "local_parameter" COMPENSATION = "compensation_parameter" DATA_TYPE = "data_type_parameter" class AuthenticationParameter: """ Parameters to authenticate the client """ # client -> server USERNAME = "username" PASSWORD = "password" PROJECT_ID = "project_id" TOKEN = "token" # client -> compensator HASH_USERNAME = "hash_username" HASH_TOKEN = "hash_token" HASH_PROJECT_ID = "hash_project_id" class SyncParameter: """ Client -> server or client <-> compensator parameters to ensure clients, server, and compensator are synced """ # client -> server and client -> compensator PROJECT_STEP = "project_step" COMM_ROUND = "communication_round" # client -> server OPERATION_STATUS = "operation_status" COMPENSATOR_FLAG = "compensator_flag" # compensator -> client SHOULD_RETRY = "should_retry" class MonitoringParameter: """ Client -> server parameters to breakdown the runtime of the client """ COMPUTATION_TIME = "computation_time" NETWORK_SEND_TIME = "network_send_time" NETWORK_RECEIVE_TIME = "network_receive_time" IDLE_TIME = "idle_time" class HyFedProjectParameter: """ Server -> client project parameters """ ID = "id" TOOL = "tool" ALGORITHM = "algorithm" NAME = "name" DESCRIPTION = "description" COORDINATOR = "coordinator" class CoordinationParameter: """ Server -> client parameters for coordination purposes """ PROJECT_ID = "project_id" PROJECT_STATUS = "project_status" PROJECT_STEP = "project_step" COMM_ROUND = "communication_round" PROJECT_STARTED = "project_started" CLIENT_JOINED = "client_joined" class ConnectionParameter: """ Mostly used in the client """ SERVER_NAME = "server_name" SERVER_URL = "server_url" # client -> compensator COMPENSATOR_NAME = "compensator_name" COMPENSATOR_URL = "compensator_url"
""" Parameters exchanged client <-> server and client <-> compensator Copyright 2021 Reza NasiriGerdeh and Reihaneh TorkzadehMahani. All Rights Reserved. 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 Parameter: """ There are nine general categories of the parameters exchanged clients <-> server and client <-> compensator: client -> server: authentication, synchronization, monitoring, and local parameters server -> client: coordination, project, and global parameters client -> compensator: authentication, synchronization, connection, data_type, and compensation parameters compensator -> client: synchronization parameters """ authentication = 'authentication_parameter' synchronization = 'synchronization_parameter' monitoring = 'monitoring_parameter' project = 'project_parameter' coordination = 'coordination_parameter' connection = 'connection_parameter' global = 'global_parameter' local = 'local_parameter' compensation = 'compensation_parameter' data_type = 'data_type_parameter' class Authenticationparameter: """ Parameters to authenticate the client """ username = 'username' password = 'password' project_id = 'project_id' token = 'token' hash_username = 'hash_username' hash_token = 'hash_token' hash_project_id = 'hash_project_id' class Syncparameter: """ Client -> server or client <-> compensator parameters to ensure clients, server, and compensator are synced """ project_step = 'project_step' comm_round = 'communication_round' operation_status = 'operation_status' compensator_flag = 'compensator_flag' should_retry = 'should_retry' class Monitoringparameter: """ Client -> server parameters to breakdown the runtime of the client """ computation_time = 'computation_time' network_send_time = 'network_send_time' network_receive_time = 'network_receive_time' idle_time = 'idle_time' class Hyfedprojectparameter: """ Server -> client project parameters """ id = 'id' tool = 'tool' algorithm = 'algorithm' name = 'name' description = 'description' coordinator = 'coordinator' class Coordinationparameter: """ Server -> client parameters for coordination purposes """ project_id = 'project_id' project_status = 'project_status' project_step = 'project_step' comm_round = 'communication_round' project_started = 'project_started' client_joined = 'client_joined' class Connectionparameter: """ Mostly used in the client """ server_name = 'server_name' server_url = 'server_url' compensator_name = 'compensator_name' compensator_url = 'compensator_url'
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # Copyright (c) 2019 Idiap Research Institute, http://www.idiap.ch/ # Written by Bastian Schnell <[email protected]> # class EmbeddingConfig(object): def __init__(self, f_get_emb_index, num_embeddings, embedding_dim, name=None, **args): assert callable(f_get_emb_index), "f_get_emb_index must be callable." self.f_get_emb_index = f_get_emb_index self.num_embeddings = num_embeddings self.embedding_dim = embedding_dim self.name = name self.args = args def __repr__(self): if self.name is None: output = "" else: output = "{}: ".format(self.name) output += "{}x{}".format(self.num_embeddings, self.embedding_dim) if len(self.args.keys()) > 0: output += "with " + " ".join(map(str, **self.args)) return output
class Embeddingconfig(object): def __init__(self, f_get_emb_index, num_embeddings, embedding_dim, name=None, **args): assert callable(f_get_emb_index), 'f_get_emb_index must be callable.' self.f_get_emb_index = f_get_emb_index self.num_embeddings = num_embeddings self.embedding_dim = embedding_dim self.name = name self.args = args def __repr__(self): if self.name is None: output = '' else: output = '{}: '.format(self.name) output += '{}x{}'.format(self.num_embeddings, self.embedding_dim) if len(self.args.keys()) > 0: output += 'with ' + ' '.join(map(str, **self.args)) return output
y=int(input("Enter The year: ")) if(((y%2==0)or (y%400==0))and y%100!=0): print("leap Year") else: print("Not Leap year")
y = int(input('Enter The year: ')) if (y % 2 == 0 or y % 400 == 0) and y % 100 != 0: print('leap Year') else: print('Not Leap year')
class Notifier: def __init(self): pass def notify(self, msg): print(msg) def message(self, msg): print(msg) def message2(self, msg2): print(msg2)
class Notifier: def __init(self): pass def notify(self, msg): print(msg) def message(self, msg): print(msg) def message2(self, msg2): print(msg2)
# -*- coding: utf-8 -*- """Version information for the bioregistry.""" __all__ = [ 'VERSION', ] VERSION = '0.1.4-dev'
"""Version information for the bioregistry.""" __all__ = ['VERSION'] version = '0.1.4-dev'
class Solution: def reverseWords(self, s: str) -> str: list1 = s.split(' ')[::-1] new_string = "" for i in range(0,len(list1)): if(list1[i]!=""): if(len(new_string)>0): new_string+=" " new_string+=list1[i] return new_string
class Solution: def reverse_words(self, s: str) -> str: list1 = s.split(' ')[::-1] new_string = '' for i in range(0, len(list1)): if list1[i] != '': if len(new_string) > 0: new_string += ' ' new_string += list1[i] return new_string
# fig03_03.py """Using nested control statements to analyze examination results.""" # initialize variables passes = 0 # number of passes failures = 0 # number of failures # process 10 students for student in range(10): # get one exam result result = int(input('Enter result (1=pass, 2=fail): ')) if result == 1: passes = passes + 1 else: failures = failures + 1 # termination phase print('Passed:', passes) print('Failed:', failures) if passes > 8: print('Bonus to instructor') ########################################################################## # (C) Copyright 2019 by Deitel & Associates, Inc. and # # Pearson Education, Inc. All Rights Reserved. # # # # DISCLAIMER: The authors and publisher of this book have used their # # best efforts in preparing the book. These efforts include the # # development, research, and testing of the theories and programs # # to determine their effectiveness. The authors and publisher make # # no warranty of any kind, expressed or implied, with regard to these # # programs or to the documentation contained in these books. The authors # # and publisher shall not be liable in any event for incidental or # # consequential damages in connection with, or arising out of, the # # furnishing, performance, or use of these programs. # ##########################################################################
"""Using nested control statements to analyze examination results.""" passes = 0 failures = 0 for student in range(10): result = int(input('Enter result (1=pass, 2=fail): ')) if result == 1: passes = passes + 1 else: failures = failures + 1 print('Passed:', passes) print('Failed:', failures) if passes > 8: print('Bonus to instructor')
def relay_states_registar_value(relay_states): num = 0 n = 8 for relay_state in relay_states: if relay_state: num += 2**n n += 1 return num def relay_states_from_register_value(value): relay_states = [] num = value for i in range(11, 7, -1): if num >= 2**i: num -= 2**i relay_states.append(1) else: relay_states.append(0) return relay_states
def relay_states_registar_value(relay_states): num = 0 n = 8 for relay_state in relay_states: if relay_state: num += 2 ** n n += 1 return num def relay_states_from_register_value(value): relay_states = [] num = value for i in range(11, 7, -1): if num >= 2 ** i: num -= 2 ** i relay_states.append(1) else: relay_states.append(0) return relay_states
"""User variables to use toolkit for Dynatrace""" FULL_SET = { "CLUSTER_NAME": { "url":"URL GOES HERE (EVEN FOR SAAS)", "tenant": { "tenant1": "TENANT UUID GOES HERE", "tenant2": "TENANT UUID GOES HERE" }, "api_token": { "tenant1": "API TOKEN GOES HERE", "tenant2": "API TOKEN GOES HERE", }, "is_managed": True, "cluster_token": "Required for Cluster Operations in Managed" } } # ROLE TYPE KEYS # access_env # change_settings # install_agent # view_logs # view_senstive # change_sensitive USER_GROUPS = { "role_types":{ "access_env": "accessenv", "change_settings": "changesettings", "view_logs": "logviewer", "view_sensitive": "viewsensitive" }, "role_tenants":[ "nonprod", "prod" ] } USER_GROUP_TEMPLATE = "prefix_{USER_TYPE}_{TENANT}_{APP_NAME}_suffix" DEFAULT_TIMEZONE = "America/Chicago"
"""User variables to use toolkit for Dynatrace""" full_set = {'CLUSTER_NAME': {'url': 'URL GOES HERE (EVEN FOR SAAS)', 'tenant': {'tenant1': 'TENANT UUID GOES HERE', 'tenant2': 'TENANT UUID GOES HERE'}, 'api_token': {'tenant1': 'API TOKEN GOES HERE', 'tenant2': 'API TOKEN GOES HERE'}, 'is_managed': True, 'cluster_token': 'Required for Cluster Operations in Managed'}} user_groups = {'role_types': {'access_env': 'accessenv', 'change_settings': 'changesettings', 'view_logs': 'logviewer', 'view_sensitive': 'viewsensitive'}, 'role_tenants': ['nonprod', 'prod']} user_group_template = 'prefix_{USER_TYPE}_{TENANT}_{APP_NAME}_suffix' default_timezone = 'America/Chicago'
# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (C) 2012 Yahoo! Inc. All Rights Reserved. # Copyright (C) 2012 New Dream Network, LLC (DreamHost) All Rights Reserved. # # 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. def partition(fullname): """ The name should be in dotted.path:ClassName syntax. """ if ':' not in fullname: raise ValueError('Invalid entry point specifier %r' % fullname) (module_name, _, classname) = fullname.partition(':') return (module_name, classname) def import_entry_point(fullname): """ Given a name import the class and return it. """ (module_name, classname) = partition(fullname) try: module = __import__(module_name) for submodule in module_name.split('.')[1:]: module = getattr(module, submodule) cls = getattr(module, classname) except (ImportError, AttributeError) as err: raise RuntimeError('Could not load entry point %s: %s' % (fullname, err)) return cls
def partition(fullname): """ The name should be in dotted.path:ClassName syntax. """ if ':' not in fullname: raise value_error('Invalid entry point specifier %r' % fullname) (module_name, _, classname) = fullname.partition(':') return (module_name, classname) def import_entry_point(fullname): """ Given a name import the class and return it. """ (module_name, classname) = partition(fullname) try: module = __import__(module_name) for submodule in module_name.split('.')[1:]: module = getattr(module, submodule) cls = getattr(module, classname) except (ImportError, AttributeError) as err: raise runtime_error('Could not load entry point %s: %s' % (fullname, err)) return cls
# for loop # Iterating over a list print("List Iteration") l = ["Ankit", "Gupta"] for i in l: print(i) # Iterating over a tuple (immutable) print("\nTuple Iteration") t = ("ankit", "gupta") for i in t: print(i) # Iterating over a String print("\nString Iteration") s = "Ankit" for i in s: print(i) # Iterating over dictionary print("\nDictionary Iteration") d = dict() d['xyz'] = 123 d['abc'] = 345 for i in d: print("% s % d" % (i, d[i])) # for loop Using range() function # Factorial of number num = int(input('Number:')) factorial = 1 # check if the number is negative, positive or zero if num < 0: print("Sorry, factorial does not exist for negative numbers") elif num == 0: print("The factorial of 0 is 1") else: for i in range(1,num + 1): factorial = factorial*i print("The factorial of",num,"is",factorial) # printing a number for i in range(10): print(i, end=" ") print() # using range for iteration l = [10, 20, 30, 40] for i in range(len(l)): print(l[i], end=" ") print() # performing sum of first 10 numbers sum = 0 for i in range(1, 10): sum = sum + i print("Sum of first 10 numbers :", sum) # Program to print table of given number n = int(input("Enter the number ")) for i in range(1,11): c = n*i print(n,"*",i,"=",c) # Program to print even number using step size in range() n = int(input("Enter the number ")) for i in range(2,n,2): print(i) # Python program to demonstrate for-else loop for i in range(1, 4): print(i) else: # Executed because no break in for print("No Break") for i in range(1, 4): print(i) break else: # Not executed as there is a break print("Break")
print('List Iteration') l = ['Ankit', 'Gupta'] for i in l: print(i) print('\nTuple Iteration') t = ('ankit', 'gupta') for i in t: print(i) print('\nString Iteration') s = 'Ankit' for i in s: print(i) print('\nDictionary Iteration') d = dict() d['xyz'] = 123 d['abc'] = 345 for i in d: print('% s % d' % (i, d[i])) num = int(input('Number:')) factorial = 1 if num < 0: print('Sorry, factorial does not exist for negative numbers') elif num == 0: print('The factorial of 0 is 1') else: for i in range(1, num + 1): factorial = factorial * i print('The factorial of', num, 'is', factorial) for i in range(10): print(i, end=' ') print() l = [10, 20, 30, 40] for i in range(len(l)): print(l[i], end=' ') print() sum = 0 for i in range(1, 10): sum = sum + i print('Sum of first 10 numbers :', sum) n = int(input('Enter the number ')) for i in range(1, 11): c = n * i print(n, '*', i, '=', c) n = int(input('Enter the number ')) for i in range(2, n, 2): print(i) for i in range(1, 4): print(i) else: print('No Break') for i in range(1, 4): print(i) break else: print('Break')
with open('html_file.html','r') as rf: with open('output.txt','w') as of: for string in rf.readlines(): if "<a href=" in string : of.write(string) #Some Better Solution for video lecture no. 223
with open('html_file.html', 'r') as rf: with open('output.txt', 'w') as of: for string in rf.readlines(): if '<a href=' in string: of.write(string)
#!/usr/bin/env python input = input("Enter IP address: ") octets = input.split(".") first_octet = bin(int(octets[0])) second_octet = bin(int(octets[1])) third_octet = bin(int(octets[2])) forth_octet = bin(int(octets[3])) print("%-20s%-20s%-20s%-20s" % ("First Octet", "Second Octet", "Third Octet", "Forth Octet")) print("%-20s%-20s%-20s%-20s" % (first_octet, second_octet, third_octet, forth_octet))
input = input('Enter IP address: ') octets = input.split('.') first_octet = bin(int(octets[0])) second_octet = bin(int(octets[1])) third_octet = bin(int(octets[2])) forth_octet = bin(int(octets[3])) print('%-20s%-20s%-20s%-20s' % ('First Octet', 'Second Octet', 'Third Octet', 'Forth Octet')) print('%-20s%-20s%-20s%-20s' % (first_octet, second_octet, third_octet, forth_octet))
class Region: def __init__ (self, bbox, region_): self.bbox = bbox # [xmin, ymin, xmax, ymax] float self.region_ = region_ # (d_region)
class Region: def __init__(self, bbox, region_): self.bbox = bbox self.region_ = region_
# Copyright 2018 The Bazel Authors. All rights reserved. # # 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. """Proxy file for referencing processor partials.""" load( "@build_bazel_rules_apple//apple/internal/partials:app_assets_validation.bzl", _app_assets_validation_partial = "app_assets_validation_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:apple_bundle_info.bzl", _apple_bundle_info_partial = "apple_bundle_info_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:apple_symbols_file.bzl", _apple_symbols_file_partial = "apple_symbols_file_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:binary.bzl", _binary_partial = "binary_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:bitcode_symbols.bzl", _bitcode_symbols_partial = "bitcode_symbols_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:clang_rt_dylibs.bzl", _clang_rt_dylibs_partial = "clang_rt_dylibs_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:debug_symbols.bzl", _debug_symbols_partial = "debug_symbols_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:embedded_bundles.bzl", _embedded_bundles_partial = "embedded_bundles_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:extension_safe_validation.bzl", _extension_safe_validation_partial = "extension_safe_validation_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:framework_headers.bzl", _framework_headers_partial = "framework_headers_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:framework_import.bzl", _framework_import_partial = "framework_import_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:framework_provider.bzl", _framework_provider_partial = "framework_provider_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:macos_additional_contents.bzl", _macos_additional_contents_partial = "macos_additional_contents_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:messages_stub.bzl", _messages_stub_partial = "messages_stub_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:provisioning_profile.bzl", _provisioning_profile_partial = "provisioning_profile_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:resources.bzl", _resources_partial = "resources_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:settings_bundle.bzl", _settings_bundle_partial = "settings_bundle_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:static_framework_header_modulemap.bzl", _static_framework_header_modulemap_partial = "static_framework_header_modulemap_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:swift_dylibs.bzl", _swift_dylibs_partial = "swift_dylibs_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:swift_dynamic_framework.bzl", _swift_dynamic_framework_partial = "swift_dynamic_framework_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:swift_static_framework.bzl", _swift_static_framework_partial = "swift_static_framework_partial", ) load( "@build_bazel_rules_apple//apple/internal/partials:watchos_stub.bzl", _watchos_stub_partial = "watchos_stub_partial", ) partials = struct( app_assets_validation_partial = _app_assets_validation_partial, apple_bundle_info_partial = _apple_bundle_info_partial, binary_partial = _binary_partial, bitcode_symbols_partial = _bitcode_symbols_partial, clang_rt_dylibs_partial = _clang_rt_dylibs_partial, debug_symbols_partial = _debug_symbols_partial, embedded_bundles_partial = _embedded_bundles_partial, extension_safe_validation_partial = _extension_safe_validation_partial, framework_import_partial = _framework_import_partial, framework_headers_partial = _framework_headers_partial, framework_provider_partial = _framework_provider_partial, macos_additional_contents_partial = _macos_additional_contents_partial, messages_stub_partial = _messages_stub_partial, provisioning_profile_partial = _provisioning_profile_partial, resources_partial = _resources_partial, settings_bundle_partial = _settings_bundle_partial, static_framework_header_modulemap_partial = _static_framework_header_modulemap_partial, swift_dylibs_partial = _swift_dylibs_partial, swift_dynamic_framework_partial = _swift_dynamic_framework_partial, swift_static_framework_partial = _swift_static_framework_partial, apple_symbols_file_partial = _apple_symbols_file_partial, watchos_stub_partial = _watchos_stub_partial, )
"""Proxy file for referencing processor partials.""" load('@build_bazel_rules_apple//apple/internal/partials:app_assets_validation.bzl', _app_assets_validation_partial='app_assets_validation_partial') load('@build_bazel_rules_apple//apple/internal/partials:apple_bundle_info.bzl', _apple_bundle_info_partial='apple_bundle_info_partial') load('@build_bazel_rules_apple//apple/internal/partials:apple_symbols_file.bzl', _apple_symbols_file_partial='apple_symbols_file_partial') load('@build_bazel_rules_apple//apple/internal/partials:binary.bzl', _binary_partial='binary_partial') load('@build_bazel_rules_apple//apple/internal/partials:bitcode_symbols.bzl', _bitcode_symbols_partial='bitcode_symbols_partial') load('@build_bazel_rules_apple//apple/internal/partials:clang_rt_dylibs.bzl', _clang_rt_dylibs_partial='clang_rt_dylibs_partial') load('@build_bazel_rules_apple//apple/internal/partials:debug_symbols.bzl', _debug_symbols_partial='debug_symbols_partial') load('@build_bazel_rules_apple//apple/internal/partials:embedded_bundles.bzl', _embedded_bundles_partial='embedded_bundles_partial') load('@build_bazel_rules_apple//apple/internal/partials:extension_safe_validation.bzl', _extension_safe_validation_partial='extension_safe_validation_partial') load('@build_bazel_rules_apple//apple/internal/partials:framework_headers.bzl', _framework_headers_partial='framework_headers_partial') load('@build_bazel_rules_apple//apple/internal/partials:framework_import.bzl', _framework_import_partial='framework_import_partial') load('@build_bazel_rules_apple//apple/internal/partials:framework_provider.bzl', _framework_provider_partial='framework_provider_partial') load('@build_bazel_rules_apple//apple/internal/partials:macos_additional_contents.bzl', _macos_additional_contents_partial='macos_additional_contents_partial') load('@build_bazel_rules_apple//apple/internal/partials:messages_stub.bzl', _messages_stub_partial='messages_stub_partial') load('@build_bazel_rules_apple//apple/internal/partials:provisioning_profile.bzl', _provisioning_profile_partial='provisioning_profile_partial') load('@build_bazel_rules_apple//apple/internal/partials:resources.bzl', _resources_partial='resources_partial') load('@build_bazel_rules_apple//apple/internal/partials:settings_bundle.bzl', _settings_bundle_partial='settings_bundle_partial') load('@build_bazel_rules_apple//apple/internal/partials:static_framework_header_modulemap.bzl', _static_framework_header_modulemap_partial='static_framework_header_modulemap_partial') load('@build_bazel_rules_apple//apple/internal/partials:swift_dylibs.bzl', _swift_dylibs_partial='swift_dylibs_partial') load('@build_bazel_rules_apple//apple/internal/partials:swift_dynamic_framework.bzl', _swift_dynamic_framework_partial='swift_dynamic_framework_partial') load('@build_bazel_rules_apple//apple/internal/partials:swift_static_framework.bzl', _swift_static_framework_partial='swift_static_framework_partial') load('@build_bazel_rules_apple//apple/internal/partials:watchos_stub.bzl', _watchos_stub_partial='watchos_stub_partial') partials = struct(app_assets_validation_partial=_app_assets_validation_partial, apple_bundle_info_partial=_apple_bundle_info_partial, binary_partial=_binary_partial, bitcode_symbols_partial=_bitcode_symbols_partial, clang_rt_dylibs_partial=_clang_rt_dylibs_partial, debug_symbols_partial=_debug_symbols_partial, embedded_bundles_partial=_embedded_bundles_partial, extension_safe_validation_partial=_extension_safe_validation_partial, framework_import_partial=_framework_import_partial, framework_headers_partial=_framework_headers_partial, framework_provider_partial=_framework_provider_partial, macos_additional_contents_partial=_macos_additional_contents_partial, messages_stub_partial=_messages_stub_partial, provisioning_profile_partial=_provisioning_profile_partial, resources_partial=_resources_partial, settings_bundle_partial=_settings_bundle_partial, static_framework_header_modulemap_partial=_static_framework_header_modulemap_partial, swift_dylibs_partial=_swift_dylibs_partial, swift_dynamic_framework_partial=_swift_dynamic_framework_partial, swift_static_framework_partial=_swift_static_framework_partial, apple_symbols_file_partial=_apple_symbols_file_partial, watchos_stub_partial=_watchos_stub_partial)
def metade(x): s = x / 2 return s def dobro(n): return 2 * n def aumentar(n, p): return (n * (p / 100)) + n
def metade(x): s = x / 2 return s def dobro(n): return 2 * n def aumentar(n, p): return n * (p / 100) + n
# -*- coding: utf-8 -*- ''' Package containing network handshakes '''
""" Package containing network handshakes """
def _merge(a, b): members = set() members.update(a.members if isinstance(a, TagSet) else {a}) members.update(b.members if isinstance(b, TagSet) else {b}) return TagSet(members) class Tag: def __init__(self, name): self.name = name __and__ = _merge __rand__ = _merge def __repr__(self): return f"ptera.tag.{self.name}" __str__ = __repr__ class TagSet: def __init__(self, members): self.members = frozenset(members) __and__ = _merge __rand__ = _merge def __eq__(self, other): return isinstance(other, TagSet) and other.members == self.members def __repr__(self): return " & ".join(sorted(map(str, self.members))) __str__ = __repr__ class _TagFactory: def __init__(self): self._cache = {} def __getattr__(self, name): if name not in self._cache: self._cache[name] = Tag(name) return self._cache[name] def match_tag(to_match, tg): if to_match is None: return True if tg is None: return False elif isinstance(tg, TagSet): return any(cat == to_match for cat in tg.members) else: return tg == to_match def get_tags(*tags): tags = [getattr(tag, tg) if isinstance(tg, str) else tg for tg in tags] if len(tags) == 1: return tags[0] else: return TagSet(tags) tag = _TagFactory()
def _merge(a, b): members = set() members.update(a.members if isinstance(a, TagSet) else {a}) members.update(b.members if isinstance(b, TagSet) else {b}) return tag_set(members) class Tag: def __init__(self, name): self.name = name __and__ = _merge __rand__ = _merge def __repr__(self): return f'ptera.tag.{self.name}' __str__ = __repr__ class Tagset: def __init__(self, members): self.members = frozenset(members) __and__ = _merge __rand__ = _merge def __eq__(self, other): return isinstance(other, TagSet) and other.members == self.members def __repr__(self): return ' & '.join(sorted(map(str, self.members))) __str__ = __repr__ class _Tagfactory: def __init__(self): self._cache = {} def __getattr__(self, name): if name not in self._cache: self._cache[name] = tag(name) return self._cache[name] def match_tag(to_match, tg): if to_match is None: return True if tg is None: return False elif isinstance(tg, TagSet): return any((cat == to_match for cat in tg.members)) else: return tg == to_match def get_tags(*tags): tags = [getattr(tag, tg) if isinstance(tg, str) else tg for tg in tags] if len(tags) == 1: return tags[0] else: return tag_set(tags) tag = __tag_factory()
'''Unstamp Mail Submission Agent Server This server receives outgoing mail from the email client, and gives it to the Mail Transfer Agent to send. '''
"""Unstamp Mail Submission Agent Server This server receives outgoing mail from the email client, and gives it to the Mail Transfer Agent to send. """
# Copyright 2013 Locaweb. # All Rights Reserved. # # 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. # # @author: Thiago Morello (morellon), Locaweb. # @author: Willian Molinari (PotHix), Locaweb. class Formatter(object): def host(self, host_id, name, address): return { 'id': host_id, 'name': name, 'address': address } def storage(self, sr_id, name, sr_type, used_space, allocated_space, physical_size): return { 'id': sr_id, 'name': name, 'type': sr_type, 'used_space': int(used_space), 'allocated_space': int(allocated_space), 'size': int(physical_size) } def guest(self, vmid, name, cpus, mem, hdd, pvirt, tools, ip, state, host): return { 'id': vmid, 'name': name, 'cpus': int(cpus), 'memory': int(mem), 'hdd': hdd, 'paravirtualized': pvirt, 'tools_up_to_date': tools, 'ip': ip, 'state': state, 'host': host } def disk(self, disk_id, name, device, size, extra_info): return { 'id': disk_id, 'name': name, 'number': device, 'size': size, 'extra_info': extra_info } def snapshot(self, snap_id, name, state=None, path=None, created=None): return { 'id': snap_id, 'name': name, 'state': state, 'path': path, 'created': created } def network_interface(self, vif_id, device, mac, name_label, locking_mode, ipv4_allowed, ipv6_allowed, rate_limit=None): return { 'id': vif_id, 'number': device, 'mac': mac, 'locking_mode': locking_mode, 'ipv4_allowed': ipv4_allowed, 'ipv6_allowed': ipv6_allowed, 'network': name_label, 'rate_limit': rate_limit } def pool(self, used_memory, total_memory, uuid, master, software_info=None): return { "used_memory": used_memory, "total_memory": total_memory, "uuid": uuid, "master": master, "software_info": software_info }
class Formatter(object): def host(self, host_id, name, address): return {'id': host_id, 'name': name, 'address': address} def storage(self, sr_id, name, sr_type, used_space, allocated_space, physical_size): return {'id': sr_id, 'name': name, 'type': sr_type, 'used_space': int(used_space), 'allocated_space': int(allocated_space), 'size': int(physical_size)} def guest(self, vmid, name, cpus, mem, hdd, pvirt, tools, ip, state, host): return {'id': vmid, 'name': name, 'cpus': int(cpus), 'memory': int(mem), 'hdd': hdd, 'paravirtualized': pvirt, 'tools_up_to_date': tools, 'ip': ip, 'state': state, 'host': host} def disk(self, disk_id, name, device, size, extra_info): return {'id': disk_id, 'name': name, 'number': device, 'size': size, 'extra_info': extra_info} def snapshot(self, snap_id, name, state=None, path=None, created=None): return {'id': snap_id, 'name': name, 'state': state, 'path': path, 'created': created} def network_interface(self, vif_id, device, mac, name_label, locking_mode, ipv4_allowed, ipv6_allowed, rate_limit=None): return {'id': vif_id, 'number': device, 'mac': mac, 'locking_mode': locking_mode, 'ipv4_allowed': ipv4_allowed, 'ipv6_allowed': ipv6_allowed, 'network': name_label, 'rate_limit': rate_limit} def pool(self, used_memory, total_memory, uuid, master, software_info=None): return {'used_memory': used_memory, 'total_memory': total_memory, 'uuid': uuid, 'master': master, 'software_info': software_info}
class Settings: def __init__(self): # Rotors = Moveable wheels self.rotors = { "I": {"sequence": "ekmflgdqvzntowyhxuspaibrcj", "notches": ["r"]}, "II": {"sequence": "ajdksiruxblhwtmcqgznpyfvoe", "notches": ["f"]}, "III": {"sequence": "bdfhjlcprtxvznyeiwgakmusqo", "notches": ["w"]}, "IV": {"sequence": "esovpzjayquirhxlnftgkdcmwb", "notches": ["k"]}, "V": {"sequence": "vzbrgityupsdnhlxawmjqofeck", "notches": ["a"]}, "VI": {"sequence": "jpgvoumfyqbenhzrdkasxlictw", "notches": ["a", "n"]}, "VII": {"sequence": "nzjhgrcxmyswboufaivlpekqdt", "notches": ["a", "n"]}, "VIII": {"sequence": "fkqhtlxocbjspdzramewniuygv", "notches": ["a", "n"]}, } # Reflector = Reflect the letter back for a second round of encryption self.reflectors = { "UKW-B-thin": "enkqauywjicopblmdxzvfthrgs", "UKW-C-thin": "rdobjntkvehmlfcwzaxgyipsuq", } # zusatzwalze = left-most WHEEL, does not move self.zusatzwalze = { "beta": {"sequence": "leyjvcnixwpbqmdrtakzgfuhos", "notches": []}, "gamma": {"sequence": "fsokanuerhmbtiycwlqpzxvgjd", "notches": []}, } self.alphabet = "abcdefghijklmnopqrstuvwxyz" self.config = None def to_position(self, param): # convert a configuration parameter (letter or number) to the position it has in the alphabet if type(param) is str and param in self.alphabet: # Returns the position in the alphabet of a letter return self.alphabet.index(param.lower()) elif type(param) is int and param > 0 and param < 27: # This is already a number, return it - 1 return param - 1 else: raise Exception("Invalid param. '" + str(param) + "' is not a valid argument") def configure(self, configObj): # create the actual configuration object self.config = { "reflector": configObj["reflector"], "plugboard": configObj["plugboard"], "rotors": { "zusatzwalze": { "rotor": configObj["zus"].get("rot"), "starting_pos": self.to_position(configObj["zus"].get("pos")), "ringstellung": self.to_position(configObj["zus"].get("ring")), }, "rotor3": { "rotor": configObj["rot3"].get("rot"), "starting_pos": self.to_position(configObj["rot3"].get("pos")), "ringstellung": self.to_position(configObj["rot3"].get("ring")), }, "rotor2": { "rotor": configObj["rot2"].get("rot"), "starting_pos": self.to_position(configObj["rot2"].get("pos")), "ringstellung": self.to_position(configObj["rot2"].get("ring")), }, "rotor1": { "rotor": configObj["rot1"].get("rot"), "starting_pos": self.to_position(configObj["rot1"].get("pos")), "ringstellung": self.to_position(configObj["rot1"].get("ring")), }, }, } def get_rotor(self, rotorName): # return the rotor configuration after taking its name as input if self.config != None: if (rotorName in ["rotor1", "rotor2", "rotor3"]): return { "rotor": self.rotors[self.config["rotors"][rotorName]["rotor"]], "starting_pos": self.config["rotors"][rotorName]["starting_pos"], "ringstellung": self.config["rotors"][rotorName]["ringstellung"] } elif (rotorName == "zusatzwalze"): return { "rotor": self.zusatzwalze[self.config["rotors"][rotorName]["rotor"]], "starting_pos": self.config["rotors"][rotorName]["starting_pos"], "ringstellung": self.config["rotors"][rotorName]["ringstellung"] } return None def get_reflector(self): if self.config != None and self.config.get("reflector"): return self.reflectors[self.config["reflector"]] return None def plugboard(self): if self.config != None: return self.config.get("plugboard", []) return None
class Settings: def __init__(self): self.rotors = {'I': {'sequence': 'ekmflgdqvzntowyhxuspaibrcj', 'notches': ['r']}, 'II': {'sequence': 'ajdksiruxblhwtmcqgznpyfvoe', 'notches': ['f']}, 'III': {'sequence': 'bdfhjlcprtxvznyeiwgakmusqo', 'notches': ['w']}, 'IV': {'sequence': 'esovpzjayquirhxlnftgkdcmwb', 'notches': ['k']}, 'V': {'sequence': 'vzbrgityupsdnhlxawmjqofeck', 'notches': ['a']}, 'VI': {'sequence': 'jpgvoumfyqbenhzrdkasxlictw', 'notches': ['a', 'n']}, 'VII': {'sequence': 'nzjhgrcxmyswboufaivlpekqdt', 'notches': ['a', 'n']}, 'VIII': {'sequence': 'fkqhtlxocbjspdzramewniuygv', 'notches': ['a', 'n']}} self.reflectors = {'UKW-B-thin': 'enkqauywjicopblmdxzvfthrgs', 'UKW-C-thin': 'rdobjntkvehmlfcwzaxgyipsuq'} self.zusatzwalze = {'beta': {'sequence': 'leyjvcnixwpbqmdrtakzgfuhos', 'notches': []}, 'gamma': {'sequence': 'fsokanuerhmbtiycwlqpzxvgjd', 'notches': []}} self.alphabet = 'abcdefghijklmnopqrstuvwxyz' self.config = None def to_position(self, param): if type(param) is str and param in self.alphabet: return self.alphabet.index(param.lower()) elif type(param) is int and param > 0 and (param < 27): return param - 1 else: raise exception("Invalid param. '" + str(param) + "' is not a valid argument") def configure(self, configObj): self.config = {'reflector': configObj['reflector'], 'plugboard': configObj['plugboard'], 'rotors': {'zusatzwalze': {'rotor': configObj['zus'].get('rot'), 'starting_pos': self.to_position(configObj['zus'].get('pos')), 'ringstellung': self.to_position(configObj['zus'].get('ring'))}, 'rotor3': {'rotor': configObj['rot3'].get('rot'), 'starting_pos': self.to_position(configObj['rot3'].get('pos')), 'ringstellung': self.to_position(configObj['rot3'].get('ring'))}, 'rotor2': {'rotor': configObj['rot2'].get('rot'), 'starting_pos': self.to_position(configObj['rot2'].get('pos')), 'ringstellung': self.to_position(configObj['rot2'].get('ring'))}, 'rotor1': {'rotor': configObj['rot1'].get('rot'), 'starting_pos': self.to_position(configObj['rot1'].get('pos')), 'ringstellung': self.to_position(configObj['rot1'].get('ring'))}}} def get_rotor(self, rotorName): if self.config != None: if rotorName in ['rotor1', 'rotor2', 'rotor3']: return {'rotor': self.rotors[self.config['rotors'][rotorName]['rotor']], 'starting_pos': self.config['rotors'][rotorName]['starting_pos'], 'ringstellung': self.config['rotors'][rotorName]['ringstellung']} elif rotorName == 'zusatzwalze': return {'rotor': self.zusatzwalze[self.config['rotors'][rotorName]['rotor']], 'starting_pos': self.config['rotors'][rotorName]['starting_pos'], 'ringstellung': self.config['rotors'][rotorName]['ringstellung']} return None def get_reflector(self): if self.config != None and self.config.get('reflector'): return self.reflectors[self.config['reflector']] return None def plugboard(self): if self.config != None: return self.config.get('plugboard', []) return None
# Copyright 2019 Nicole Borrelli # # 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. VANILLA_FLAGS = { "garland_defeated": 0x01, "bridge_to_be_rebuilt": 0x02, "obtained_bridge": 0x03, "obtained_lute": 0x04, "obtained_ship": 0x05, "obtained_crown": 0x06, "obtained_crystal_eye": 0x07, "obtained_jolt_tonic": 0x08, "obtained_mystic_key": 0x09, "obtained_nitro_powder": 0x0a, "obtained_canal": 0x0b, "vampire_defeated": 0x0c, "obtained_ruby": 0x0d, "titan_fed": 0x0e, "obtained_earth_rod": 0x0f, "broke_earth_plate": 0x10, "lit_earth_crystal": 0x11, "obtained_canoe": 0x12, "lit_fire_crystal": 0x13, "obtained_levistone": 0x14, "airship_visible": 0x15, "can_undertake_trials": 0x16, "obtained_rats_tail": 0x17, "obtained_promotion": 0x18, "released_fairy": 0x19, "obtained_oxyale": 0x1a, "opened_sea_shrine": 0x1b, "obtained_rosetta_stone": 0x1c, "lit_water_crystal": 0x1d, "learned_lufienian": 0x1e, "obtained_chime": 0x1f, "obtained_warp_cube": 0x20, "obtained_adamantite": 0x21, "lit_air_crystal": 0x22, "obtained_excalibur": 0x23, "black_orb_removed": 0x24, "broke_lute_plate": 0x25, "defeated_chaos": 0x26, "heard_matoyas_plight": 0x27, "heard_kings_plight": 0x28, "watched_bridge_credits": 0x29 }
vanilla_flags = {'garland_defeated': 1, 'bridge_to_be_rebuilt': 2, 'obtained_bridge': 3, 'obtained_lute': 4, 'obtained_ship': 5, 'obtained_crown': 6, 'obtained_crystal_eye': 7, 'obtained_jolt_tonic': 8, 'obtained_mystic_key': 9, 'obtained_nitro_powder': 10, 'obtained_canal': 11, 'vampire_defeated': 12, 'obtained_ruby': 13, 'titan_fed': 14, 'obtained_earth_rod': 15, 'broke_earth_plate': 16, 'lit_earth_crystal': 17, 'obtained_canoe': 18, 'lit_fire_crystal': 19, 'obtained_levistone': 20, 'airship_visible': 21, 'can_undertake_trials': 22, 'obtained_rats_tail': 23, 'obtained_promotion': 24, 'released_fairy': 25, 'obtained_oxyale': 26, 'opened_sea_shrine': 27, 'obtained_rosetta_stone': 28, 'lit_water_crystal': 29, 'learned_lufienian': 30, 'obtained_chime': 31, 'obtained_warp_cube': 32, 'obtained_adamantite': 33, 'lit_air_crystal': 34, 'obtained_excalibur': 35, 'black_orb_removed': 36, 'broke_lute_plate': 37, 'defeated_chaos': 38, 'heard_matoyas_plight': 39, 'heard_kings_plight': 40, 'watched_bridge_credits': 41}
#!/usr/bin/env python3 #encoding=utf-8 #------------------------------------------------- # Usage: python3 4-getattribute_to_compute_attribute.py # Description: attribute management 4 of 4 # Same, but with generic __getattribute__ all attribute interception #------------------------------------------------- class Powers(object): # Need (object) in 2.X only def __init__(self, square, cube): self._square = square self._cube = cube def __getattribute__(self, name): if name == 'square': return object.__getattribute__(self, '_square') ** 2 # call superclass's __getattribute__, avoid recursive loop elif name == 'cube': return object.__getattribute__(self, '_cube') ** 3 # call superclass's __getattribute__, avoid recursive loop else: return object.__getattribute__(self, name) # call superclass's __getattribute__, avoid recursive loop def __setattr__(self, name, value): if name == 'square': object.__setattr__(self, '_square', value) # Or use __dict__ elif name == 'cube': object.__setattr__(self, '_cube', value) else: object.__setattr__(self, name , value) if __name__ == '__main__': X = Powers(3, 4) print(X.square) # 3 ** 2 = 9 print(X.cube) # 4 ** 3 = 64 X.square = 5 print(X.square) # 5 ** 2 = 25 X.cube = 7 print(X.cube)
class Powers(object): def __init__(self, square, cube): self._square = square self._cube = cube def __getattribute__(self, name): if name == 'square': return object.__getattribute__(self, '_square') ** 2 elif name == 'cube': return object.__getattribute__(self, '_cube') ** 3 else: return object.__getattribute__(self, name) def __setattr__(self, name, value): if name == 'square': object.__setattr__(self, '_square', value) elif name == 'cube': object.__setattr__(self, '_cube', value) else: object.__setattr__(self, name, value) if __name__ == '__main__': x = powers(3, 4) print(X.square) print(X.cube) X.square = 5 print(X.square) X.cube = 7 print(X.cube)
#!/usr/bin/python3 # files.py by Bill Weinman [http://bw.org/] # This is an exercise file from Python 3 Essential Training on lynda.com # Copyright 2010 The BearHeart Group, LLC def main(): f = open('lines.txt') for line in f: print(line, end = '') if __name__ == "__main__": main()
def main(): f = open('lines.txt') for line in f: print(line, end='') if __name__ == '__main__': main()
"""Common functions.""" __all__ = ['rshift'] def rshift(integer: int, shift: int) -> int: """Logical right binary shift.""" if integer >= 0: return integer >> shift return (integer + 0x100000000) >> shift
"""Common functions.""" __all__ = ['rshift'] def rshift(integer: int, shift: int) -> int: """Logical right binary shift.""" if integer >= 0: return integer >> shift return integer + 4294967296 >> shift
""" lab 7 """ # 3.1 i = -1 while i <6: i = i+1 if i ==3 or i ==6: continue print(i) # 3.2 i=1 result = 1 while i <=5: #print(i) result = result *i i = i+1 print(result) # 3.3 i = 1 result = 0 while i <=5: result = result +i i = i+1 print(result) # 3.4 i = 3 result = 1 while i <=8: result = result *i i = i + 1 print(result) # 3.5 # simplified to 8*7*6*5*4 i = 4 result = 1 while i<=8: result = result *i i = i+1 print(result) # 3.6 num_list = [12,32,43,35] while num_list: num_list.remove(num_list[0]) print(num_list)
""" lab 7 """ i = -1 while i < 6: i = i + 1 if i == 3 or i == 6: continue print(i) i = 1 result = 1 while i <= 5: result = result * i i = i + 1 print(result) i = 1 result = 0 while i <= 5: result = result + i i = i + 1 print(result) i = 3 result = 1 while i <= 8: result = result * i i = i + 1 print(result) i = 4 result = 1 while i <= 8: result = result * i i = i + 1 print(result) num_list = [12, 32, 43, 35] while num_list: num_list.remove(num_list[0]) print(num_list)
"""582. Word Break II """ class Solution: """ @param: s: A string @param: wordDict: A set of words. @return: All possible sentences. """ def wordBreak(self, s, wordDict): # write your code here return self.dfs(0, s, wordDict, {}) def dfs(self, idx, s, dict, memo): if idx == len(s): return [] if s[idx:] in memo: return memo[s[idx:]] res = [] path = "" for i in range(idx, len(s)): if s[idx: i + 1] not in dict: continue prefixes = self.dfs(i + 1, s, dict, memo) path = s[idx: i + 1] for prefix in prefixes: res.append(path + " " + prefix) if s[idx:] in dict: res.append(s[idx:]) memo[s[idx:]] = res return res ### Practice: return self.dfs(0, s, wordDict, {}) def dfs(self, idx, s, dict, memo): if idx == len(s): return [] if s[idx:] in memo: return memo[s[idx:]] res = [] path = "" for i in range(idx, len(s)): prefix = s[idx: i + 1] if prefix not in dict: continue path = prefix for sentence in self.dfs(i + 1, s, dict, memo): res.append(path + " " + sentence) if s[idx:] in dict: res.append(s[idx:]) ## !! memo[s[idx:]] = res return res ## return self.dfs(s, wordDict, {}) def dfs(self, s, wordDict, memo): if s in memo: return memo[s] if not s: return [] path = [] for i in range(1, len(s)): prefix = s[:i] if prefix not in wordDict: continue suffix = s[i:] partitions = self.dfs(suffix, wordDict, memo) for partition in partitions: path.append(prefix + " " + partition) if s in wordDict: path.append(s) memo[s] = path return path
"""582. Word Break II """ class Solution: """ @param: s: A string @param: wordDict: A set of words. @return: All possible sentences. """ def word_break(self, s, wordDict): return self.dfs(0, s, wordDict, {}) def dfs(self, idx, s, dict, memo): if idx == len(s): return [] if s[idx:] in memo: return memo[s[idx:]] res = [] path = '' for i in range(idx, len(s)): if s[idx:i + 1] not in dict: continue prefixes = self.dfs(i + 1, s, dict, memo) path = s[idx:i + 1] for prefix in prefixes: res.append(path + ' ' + prefix) if s[idx:] in dict: res.append(s[idx:]) memo[s[idx:]] = res return res return self.dfs(0, s, wordDict, {}) def dfs(self, idx, s, dict, memo): if idx == len(s): return [] if s[idx:] in memo: return memo[s[idx:]] res = [] path = '' for i in range(idx, len(s)): prefix = s[idx:i + 1] if prefix not in dict: continue path = prefix for sentence in self.dfs(i + 1, s, dict, memo): res.append(path + ' ' + sentence) if s[idx:] in dict: res.append(s[idx:]) memo[s[idx:]] = res return res return self.dfs(s, wordDict, {}) def dfs(self, s, wordDict, memo): if s in memo: return memo[s] if not s: return [] path = [] for i in range(1, len(s)): prefix = s[:i] if prefix not in wordDict: continue suffix = s[i:] partitions = self.dfs(suffix, wordDict, memo) for partition in partitions: path.append(prefix + ' ' + partition) if s in wordDict: path.append(s) memo[s] = path return path
#Extensions: # I have Taken Example 5.9 and extended it to dictionary #no users: usernames = { 'aes':{ 'password':'64545465', 'key' : '56' }, 'bes':{ 'password':'64545465', 'key' : '56' }, 'ces':{ 'password':'64546545', 'key' : '56' }, 'admin':{ 'password':'64546465', 'key' : '5' } } if usernames != {}: for user,info in usernames.items(): if user == 'admin': print("Hello, admin! here are all the username and password") print(usernames) else : print("hello",user,". Thank you for logging in.") for password,key in info.items(): print(password,":",key) else : print("we need to find more users.")
usernames = {'aes': {'password': '64545465', 'key': '56'}, 'bes': {'password': '64545465', 'key': '56'}, 'ces': {'password': '64546545', 'key': '56'}, 'admin': {'password': '64546465', 'key': '5'}} if usernames != {}: for (user, info) in usernames.items(): if user == 'admin': print('Hello, admin! here are all the username and password') print(usernames) else: print('hello', user, '. Thank you for logging in.') for (password, key) in info.items(): print(password, ':', key) else: print('we need to find more users.')
MACS_VERSION = "3.0.0a7" MAX_PAIRNUM = 1000 MAX_LAMBDA = 100000 FESTEP = 20 BUFFER_SIZE = 100000 # np array will increase at step of 1 million items READ_BUFFER_SIZE = 10000000 # 10M bytes for read buffer size N_MP = 2 # Number of processers
macs_version = '3.0.0a7' max_pairnum = 1000 max_lambda = 100000 festep = 20 buffer_size = 100000 read_buffer_size = 10000000 n_mp = 2
# -*- coding: utf-8 -*- """ Created on Fri Mar 30 16:26:18 2018 Accelerator BPM @author: xf18id """ bpm17_1x = EpicsSignalRO("SR:C17-BI{BPM:1}Pos:X-I", name="bpm17_1x") bpm17_1y = EpicsSignalRO("SR:C17-BI{BPM:1}Pos:Y-I", name="bpm17_1y") bpm17_2x = EpicsSignalRO("SR:C17-BI{BPM:2}Pos:X-I", name="bpm17_2x") bpm17_2y = EpicsSignalRO("SR:C17-BI{BPM:2}Pos:Y-I", name="bpm17_2y") bpm17_3x = EpicsSignalRO("SR:C17-BI{BPM:3}Pos:X-I", name="bpm17_3x") bpm17_3y = EpicsSignalRO("SR:C17-BI{BPM:3}Pos:Y-I", name="bpm17_3y") bpm17_4x = EpicsSignalRO("SR:C17-BI{BPM:4}Pos:X-I", name="bpm17_4x") bpm17_4y = EpicsSignalRO("SR:C17-BI{BPM:4}Pos:Y-I", name="bpm17_4y") bpm17_5x = EpicsSignalRO("SR:C17-BI{BPM:5}Pos:X-I", name="bpm17_5x") bpm17_5y = EpicsSignalRO("SR:C17-BI{BPM:5}Pos:Y-I", name="bpm17_5y") bpm17_6x = EpicsSignalRO("SR:C17-BI{BPM:6}Pos:X-I", name="bpm17_6x") bpm17_6y = EpicsSignalRO("SR:C17-BI{BPM:6}Pos:Y-I", name="bpm17_6y") bpm18_7x = EpicsSignalRO("SR:C18-BI{BPM:7}Pos:X-I", name="bpm18_7x") bpm18_7y = EpicsSignalRO("SR:C18-BI{BPM:7}Pos:Y-I", name="bpm18_7y") bpm18_8x = EpicsSignalRO("SR:C18-BI{BPM:8}Pos:X-I", name="bpm18_8x") bpm18_8y = EpicsSignalRO("SR:C18-BI{BPM:8}Pos:Y-I", name="bpm18_8y") bpm18_1x = EpicsSignalRO("SR:C18-BI{BPM:1}Pos:X-I", name="bpm18_1x") bpm18_1y = EpicsSignalRO("SR:C18-BI{BPM:1}Pos:Y-I", name="bpm18_1y") bpm18_2x = EpicsSignalRO("SR:C18-BI{BPM:2}Pos:X-I", name="bpm18_2x") bpm18_2y = EpicsSignalRO("SR:C18-BI{BPM:2}Pos:Y-I", name="bpm18_2y") bpm18_3x = EpicsSignalRO("SR:C18-BI{BPM:3}Pos:X-I", name="bpm18_3x") bpm18_3y = EpicsSignalRO("SR:C18-BI{BPM:3}Pos:Y-I", name="bpm18_3y") bpm18_4x = EpicsSignalRO("SR:C18-BI{BPM:4}Pos:X-I", name="bpm18_4x") bpm18_4y = EpicsSignalRO("SR:C18-BI{BPM:4}Pos:Y-I", name="bpm18_4y") bpm18_5x = EpicsSignalRO("SR:C18-BI{BPM:5}Pos:X-I", name="bpm18_5x") bpm18_5y = EpicsSignalRO("SR:C18-BI{BPM:5}Pos:Y-I", name="bpm18_5y") bpm18_6x = EpicsSignalRO("SR:C18-BI{BPM:6}Pos:X-I", name="bpm18_6x") bpm18_6y = EpicsSignalRO("SR:C18-BI{BPM:6}Pos:Y-I", name="bpm18_6y") bpm_17x = [bpm17_1x, bpm17_2x, bpm17_3x, bpm17_4x, bpm17_5x, bpm17_6x] bpm_17y = [bpm17_1y, bpm17_2y, bpm17_3y, bpm17_4y, bpm17_5y, bpm17_6y] bpm_18x = [ bpm18_1x, bpm18_2x, bpm18_3x, bpm18_4x, bpm18_5x, bpm18_6x, bpm18_7x, bpm18_8x, ] bpm_18y = [ bpm18_1y, bpm18_2y, bpm18_3y, bpm18_4y, bpm18_5y, bpm18_6y, bpm18_7y, bpm18_8y, ] bpm_17 = bpm_17x + bpm_17y bpm_18 = bpm_18x + bpm_18y # bpm_17 = [bpm17_1x,bpm17_1y, bpm17_2x,bpm17_2y,bpm17_3x,bpm17_3y, bpm17_4x,bpm17_4y, bpm17_5x,bpm17_5y, bpm17_6x,bpm17_6y] # bpm_18 = [bpm18_1x,bpm18_1y, bpm18_2x,bpm18_2y,bpm18_3x,bpm18_3y, bpm18_4x,bpm18_4y, bpm18_5x,bpm18_5y, bpm18_6x,bpm18_6y, bpm18_7x,bpm18_7y, bpm18_8x,bpm18_8y]
""" Created on Fri Mar 30 16:26:18 2018 Accelerator BPM @author: xf18id """ bpm17_1x = epics_signal_ro('SR:C17-BI{BPM:1}Pos:X-I', name='bpm17_1x') bpm17_1y = epics_signal_ro('SR:C17-BI{BPM:1}Pos:Y-I', name='bpm17_1y') bpm17_2x = epics_signal_ro('SR:C17-BI{BPM:2}Pos:X-I', name='bpm17_2x') bpm17_2y = epics_signal_ro('SR:C17-BI{BPM:2}Pos:Y-I', name='bpm17_2y') bpm17_3x = epics_signal_ro('SR:C17-BI{BPM:3}Pos:X-I', name='bpm17_3x') bpm17_3y = epics_signal_ro('SR:C17-BI{BPM:3}Pos:Y-I', name='bpm17_3y') bpm17_4x = epics_signal_ro('SR:C17-BI{BPM:4}Pos:X-I', name='bpm17_4x') bpm17_4y = epics_signal_ro('SR:C17-BI{BPM:4}Pos:Y-I', name='bpm17_4y') bpm17_5x = epics_signal_ro('SR:C17-BI{BPM:5}Pos:X-I', name='bpm17_5x') bpm17_5y = epics_signal_ro('SR:C17-BI{BPM:5}Pos:Y-I', name='bpm17_5y') bpm17_6x = epics_signal_ro('SR:C17-BI{BPM:6}Pos:X-I', name='bpm17_6x') bpm17_6y = epics_signal_ro('SR:C17-BI{BPM:6}Pos:Y-I', name='bpm17_6y') bpm18_7x = epics_signal_ro('SR:C18-BI{BPM:7}Pos:X-I', name='bpm18_7x') bpm18_7y = epics_signal_ro('SR:C18-BI{BPM:7}Pos:Y-I', name='bpm18_7y') bpm18_8x = epics_signal_ro('SR:C18-BI{BPM:8}Pos:X-I', name='bpm18_8x') bpm18_8y = epics_signal_ro('SR:C18-BI{BPM:8}Pos:Y-I', name='bpm18_8y') bpm18_1x = epics_signal_ro('SR:C18-BI{BPM:1}Pos:X-I', name='bpm18_1x') bpm18_1y = epics_signal_ro('SR:C18-BI{BPM:1}Pos:Y-I', name='bpm18_1y') bpm18_2x = epics_signal_ro('SR:C18-BI{BPM:2}Pos:X-I', name='bpm18_2x') bpm18_2y = epics_signal_ro('SR:C18-BI{BPM:2}Pos:Y-I', name='bpm18_2y') bpm18_3x = epics_signal_ro('SR:C18-BI{BPM:3}Pos:X-I', name='bpm18_3x') bpm18_3y = epics_signal_ro('SR:C18-BI{BPM:3}Pos:Y-I', name='bpm18_3y') bpm18_4x = epics_signal_ro('SR:C18-BI{BPM:4}Pos:X-I', name='bpm18_4x') bpm18_4y = epics_signal_ro('SR:C18-BI{BPM:4}Pos:Y-I', name='bpm18_4y') bpm18_5x = epics_signal_ro('SR:C18-BI{BPM:5}Pos:X-I', name='bpm18_5x') bpm18_5y = epics_signal_ro('SR:C18-BI{BPM:5}Pos:Y-I', name='bpm18_5y') bpm18_6x = epics_signal_ro('SR:C18-BI{BPM:6}Pos:X-I', name='bpm18_6x') bpm18_6y = epics_signal_ro('SR:C18-BI{BPM:6}Pos:Y-I', name='bpm18_6y') bpm_17x = [bpm17_1x, bpm17_2x, bpm17_3x, bpm17_4x, bpm17_5x, bpm17_6x] bpm_17y = [bpm17_1y, bpm17_2y, bpm17_3y, bpm17_4y, bpm17_5y, bpm17_6y] bpm_18x = [bpm18_1x, bpm18_2x, bpm18_3x, bpm18_4x, bpm18_5x, bpm18_6x, bpm18_7x, bpm18_8x] bpm_18y = [bpm18_1y, bpm18_2y, bpm18_3y, bpm18_4y, bpm18_5y, bpm18_6y, bpm18_7y, bpm18_8y] bpm_17 = bpm_17x + bpm_17y bpm_18 = bpm_18x + bpm_18y
# error if not grade for a student # OPTION 2: change the policy def get_stats(class_list): new_stats = [] for item in class_list: new_stats.append([item[0], item[1], avg(item[1])]) return new_stats def avg(grades): try: return sum(grades)/len(grades) except ZeroDivisionError: print('no grades data') return 0.0 # decided that students w/o grades get a 0 # test_grades = [[['peter', 'parker'], [10.0, 5.0, 85.0]], [['bruce', 'wayne'], [10.0, 8.0, 74.0]]] test_grades = [[['peter', 'parker'], [10.0, 5.0, 85.0]], [['bruce', 'wayne'], [10.0, 8.0, 74.0]], [['deadpool'], []]] print(get_stats(test_grades))
def get_stats(class_list): new_stats = [] for item in class_list: new_stats.append([item[0], item[1], avg(item[1])]) return new_stats def avg(grades): try: return sum(grades) / len(grades) except ZeroDivisionError: print('no grades data') return 0.0 test_grades = [[['peter', 'parker'], [10.0, 5.0, 85.0]], [['bruce', 'wayne'], [10.0, 8.0, 74.0]], [['deadpool'], []]] print(get_stats(test_grades))
class BaseHelper: def __init__(self, device): self.device = device def params(self, locals_: dict): params = locals_.copy() params.pop('self') return params
class Basehelper: def __init__(self, device): self.device = device def params(self, locals_: dict): params = locals_.copy() params.pop('self') return params
#!/usr/bin/env python # -*- coding: utf-8 -*- class Watchdog(object): KEEP_ALIVE = '\n' DEVICE = '/dev/watchdog' # STOP = 'V' in bleaglebone black not works def __init__(self): pass def notify(self, device, msg): ''' /dev/watchdog is opened and will reboot unless the watchdog is pinged within a certain time. :param device str: path of watchdog special device :param msg str: string to send ''' with open(device, 'w+') as file: file.write(msg) file.flush() def main(): Watchdog().notify(Watchdog.DEVICE, Watchdog.KEEP_ALIVE) if __name__ == '__main__': main()
class Watchdog(object): keep_alive = '\n' device = '/dev/watchdog' def __init__(self): pass def notify(self, device, msg): """ /dev/watchdog is opened and will reboot unless the watchdog is pinged within a certain time. :param device str: path of watchdog special device :param msg str: string to send """ with open(device, 'w+') as file: file.write(msg) file.flush() def main(): watchdog().notify(Watchdog.DEVICE, Watchdog.KEEP_ALIVE) if __name__ == '__main__': main()
def CheckBinarySearchTreeSequence(arr: iter): """ Checks if a binary search sequence can is feasible :param arr: An array containing the binary search tree sequence :type arr: iter """ invalidSequenceString = "sequence is invalid: %s %s %s." searchVal = arr[-1] minVal = min(arr) - 1 maxVal = max(arr) + 1 for i in arr: if i < searchVal: if i < minVal: return invalidSequenceString % (i, "<", minVal) if i == minVal: return invalidSequenceString % (i, "appears", "multiple times") minVal = i elif i > searchVal: if i > maxVal: return invalidSequenceString % (i, ">", maxVal) if i == maxVal: return invalidSequenceString % (i, "appears", "multiple times") maxVal = i return "the sequence is valid."
def check_binary_search_tree_sequence(arr: iter): """ Checks if a binary search sequence can is feasible :param arr: An array containing the binary search tree sequence :type arr: iter """ invalid_sequence_string = 'sequence is invalid: %s %s %s.' search_val = arr[-1] min_val = min(arr) - 1 max_val = max(arr) + 1 for i in arr: if i < searchVal: if i < minVal: return invalidSequenceString % (i, '<', minVal) if i == minVal: return invalidSequenceString % (i, 'appears', 'multiple times') min_val = i elif i > searchVal: if i > maxVal: return invalidSequenceString % (i, '>', maxVal) if i == maxVal: return invalidSequenceString % (i, 'appears', 'multiple times') max_val = i return 'the sequence is valid.'
"""Macros to simplify generating maven files. """ load("@google_bazel_common//tools/maven:pom_file.bzl", default_pom_file = "pom_file") def pom_file(name, targets, artifact_name, artifact_id, packaging = None, **kwargs): default_pom_file( name = name, targets = targets, preferred_group_ids = [ "com.google.common.inject", "com.google.inject", "dagger", "com.google", ], template_file = "//tools:pom-template.xml", substitutions = { "{artifact_name}": artifact_name, "{artifact_id}": artifact_id, "{packaging}": packaging or "jar", }, **kwargs ) POM_VERSION = "${project.version}"
"""Macros to simplify generating maven files. """ load('@google_bazel_common//tools/maven:pom_file.bzl', default_pom_file='pom_file') def pom_file(name, targets, artifact_name, artifact_id, packaging=None, **kwargs): default_pom_file(name=name, targets=targets, preferred_group_ids=['com.google.common.inject', 'com.google.inject', 'dagger', 'com.google'], template_file='//tools:pom-template.xml', substitutions={'{artifact_name}': artifact_name, '{artifact_id}': artifact_id, '{packaging}': packaging or 'jar'}, **kwargs) pom_version = '${project.version}'
class Solution: def backspaceCompare(self, S: str, T: str) -> bool: s_bcount, t_bcount = 0, 0 s_idx, t_idx = len(S) - 1, len(T) - 1 while s_idx >= 0 or t_idx >= 0: while s_idx >= 0: if S[s_idx] == '#': s_bcount += 1 s_idx -= 1 continue if s_bcount > 0: s_idx -= 1 s_bcount -= 1 else: break while t_idx >= 0: if T[t_idx] == '#': t_bcount += 1 t_idx -= 1 continue if t_bcount > 0: t_idx -= 1 t_bcount -= 1 else: break if s_idx >= 0 and t_idx >= 0 and S[s_idx] != T[t_idx]: return False elif (s_idx >= 0 and t_idx < 0) or (s_idx < 0 and t_idx >= 0): return False s_idx -= 1 t_idx -= 1 return True
class Solution: def backspace_compare(self, S: str, T: str) -> bool: (s_bcount, t_bcount) = (0, 0) (s_idx, t_idx) = (len(S) - 1, len(T) - 1) while s_idx >= 0 or t_idx >= 0: while s_idx >= 0: if S[s_idx] == '#': s_bcount += 1 s_idx -= 1 continue if s_bcount > 0: s_idx -= 1 s_bcount -= 1 else: break while t_idx >= 0: if T[t_idx] == '#': t_bcount += 1 t_idx -= 1 continue if t_bcount > 0: t_idx -= 1 t_bcount -= 1 else: break if s_idx >= 0 and t_idx >= 0 and (S[s_idx] != T[t_idx]): return False elif s_idx >= 0 and t_idx < 0 or (s_idx < 0 and t_idx >= 0): return False s_idx -= 1 t_idx -= 1 return True
class Solution: def ladderLength(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if endWord not in wordList: return 0 result = 0 l = len(beginWord) beginSet = {beginWord} endSet = {endWord} wordList = set(wordList) while beginSet or endSet: result += 1 if len(beginSet) < len(endSet): beginSet, endSet = endSet, beginSet newSet = set() for word in beginSet: for index in range(l): for c in string.ascii_lowercase: newWord = word[:index] + c + word[index + 1:] if newWord in endSet: return result + 1 if newWord not in wordList: continue wordList.remove(newWord) newSet.add(newWord) beginSet = newSet return 0
class Solution: def ladder_length(self, beginWord: str, endWord: str, wordList: List[str]) -> int: if endWord not in wordList: return 0 result = 0 l = len(beginWord) begin_set = {beginWord} end_set = {endWord} word_list = set(wordList) while beginSet or endSet: result += 1 if len(beginSet) < len(endSet): (begin_set, end_set) = (endSet, beginSet) new_set = set() for word in beginSet: for index in range(l): for c in string.ascii_lowercase: new_word = word[:index] + c + word[index + 1:] if newWord in endSet: return result + 1 if newWord not in wordList: continue wordList.remove(newWord) newSet.add(newWord) begin_set = newSet return 0
# coding: utf8 # try something like # coding: utf8 # try something like def index(): rows = db((db.activity.type=='stand')&(db.activity.status=='accepted')).select() if rows: return dict(projects=rows) else: return plugin_flatpage()
def index(): rows = db((db.activity.type == 'stand') & (db.activity.status == 'accepted')).select() if rows: return dict(projects=rows) else: return plugin_flatpage()
#re-learning about class and objects. class MyClass: #ini class, class adalah blueprint dari object var = "blah" #variable ini adalah object didalan class def function(self): #ini adalah fungsi didalam class print("This is a message inside the class.") myobjectx = MyClass() #myobjectx adalah variable, yang menyimpan object dari class MyClass() yang isinya berupa var(object) dan function. myobjectx.var #mengakses var print(myobjectx.var) print("####\n") ################### ## 2 object menggunakan class yang sama myobjecty = MyClass() myobjectz = MyClass() myobjectz.var = "zlah" #mendefinisikan var print(myobjectx.var) #hasilnya tetap blah print(myobjectz.var) #hasilnya akan menjadi zlah, karena habis di redefinisi print("####\n") ################### ## mengakses fungsi myobjectx.function() print("####\n") ################### ## exercise class Vehicle: name = "" kind = "car" color = "" value = 100.00 def description(self): desc = "%s is a %s %s worth $%.2f." % (self.name, self.color, self.kind, self.value) return desc car1 = Vehicle() car1.name = "Fer" car1.kind = "Convertible" car1.color = "Red" car1.value = 60000.00 car2 = Vehicle() car2.name = "Jump" car2.kind = "Van" car2.color = "Blue" car2.value = 10000 print(car1.description()) print(car2.description())
class Myclass: var = 'blah' def function(self): print('This is a message inside the class.') myobjectx = my_class() myobjectx.var print(myobjectx.var) print('####\n') myobjecty = my_class() myobjectz = my_class() myobjectz.var = 'zlah' print(myobjectx.var) print(myobjectz.var) print('####\n') myobjectx.function() print('####\n') class Vehicle: name = '' kind = 'car' color = '' value = 100.0 def description(self): desc = '%s is a %s %s worth $%.2f.' % (self.name, self.color, self.kind, self.value) return desc car1 = vehicle() car1.name = 'Fer' car1.kind = 'Convertible' car1.color = 'Red' car1.value = 60000.0 car2 = vehicle() car2.name = 'Jump' car2.kind = 'Van' car2.color = 'Blue' car2.value = 10000 print(car1.description()) print(car2.description())