content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class BasePermission(object): def __init__(self, queryset, lookup_field): self.queryset = queryset self.lookup_field = lookup_field def has_permission(self, user, action, pk): pass class AllowAny(BasePermission): def has_permission(self, user, action, pk): return T...
class Basepermission(object): def __init__(self, queryset, lookup_field): self.queryset = queryset self.lookup_field = lookup_field def has_permission(self, user, action, pk): pass class Allowany(BasePermission): def has_permission(self, user, action, pk): return True cl...
items = [] class ItemsModel(): def __init__(self): self.items = items def add_item(self, name, price, image, quantity): self.item_id = len(items)+1 item = { "item_id": self.item_id, "name": name, "price": price, "image": image, ...
items = [] class Itemsmodel: def __init__(self): self.items = items def add_item(self, name, price, image, quantity): self.item_id = len(items) + 1 item = {'item_id': self.item_id, 'name': name, 'price': price, 'image': image, 'quantity': quantity} self.items.append(item) ...
class Solution: def maxProfit(self, prices: List[int]) -> int: ret, mn = 0, float('inf') for price in prices: if price < mn: mn = price if price - mn > ret: ret = price-mn return ret
class Solution: def max_profit(self, prices: List[int]) -> int: (ret, mn) = (0, float('inf')) for price in prices: if price < mn: mn = price if price - mn > ret: ret = price - mn return ret
# Gerard Hanlon, 2018-13-02 # Factorial number is the number multiplied by all of the numbers smaller than it def sumall(upto): sumupto = 0 for i in range(1, upto + 1): sumupto = sumupto + i return sumupto print("The Factorial Number of the number 5 is: ", sumall(5)) print("The Factorial Number o...
def sumall(upto): sumupto = 0 for i in range(1, upto + 1): sumupto = sumupto + i return sumupto print('The Factorial Number of the number 5 is: ', sumall(5)) print('The Factorial Number of the number 7 is: ', sumall(7)) print('The Factorial Number of the number 10 is: ', sumall(10))
# # PySNMP MIB module A3COM-HUAWEI-EFM-COMMON-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-EFM-COMMON-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 16:49:58 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python versio...
(h3c_epon,) = mibBuilder.importSymbols('A3COM-HUAWEI-OID-MIB', 'h3cEpon') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, constraints_inters...
# encoding=utf-8 # General Header Fields CACHE_CONTROL = b"Cache-Control".lower() CONNECTION = b"Connection".lower() DATE = b"Date".lower() PRAGMA = b"Pragma".lower() TRAILER = b"Trailer".lower() TRANSFER_ENCODING = b"Transfer-Encoding".lower() UPGRADE = b"Upgrade".lower() VIA = b"Via".lower() WARNING = b"Warning".lo...
cache_control = b'Cache-Control'.lower() connection = b'Connection'.lower() date = b'Date'.lower() pragma = b'Pragma'.lower() trailer = b'Trailer'.lower() transfer_encoding = b'Transfer-Encoding'.lower() upgrade = b'Upgrade'.lower() via = b'Via'.lower() warning = b'Warning'.lower() accept = b'Accept'.lower() accept_cha...
def anonymize_phone_number(phone_number: str) -> str: public_digits_num = 6 phone_number = phone_number.replace("-", "") public_digits = phone_number[:public_digits_num] number_of_private_digits = len(phone_number) - public_digits_num private_digits = "-" * number_of_private_digits return f"{pub...
def anonymize_phone_number(phone_number: str) -> str: public_digits_num = 6 phone_number = phone_number.replace('-', '') public_digits = phone_number[:public_digits_num] number_of_private_digits = len(phone_number) - public_digits_num private_digits = '-' * number_of_private_digits return f'{pub...
''' This place-holder module makes the extensions directory into a Python "package", so that external user-specific modules can act as umbrella modules, and, for example: import structural_dhcp_rst2pdf.extensions.vectorpdf_r2p to bring in the PDF extension. '''
""" This place-holder module makes the extensions directory into a Python "package", so that external user-specific modules can act as umbrella modules, and, for example: import structural_dhcp_rst2pdf.extensions.vectorpdf_r2p to bring in the PDF extension. """
for number in [0, 1, 2, 3, 4]: print(number) for number in range(5): print(number)
for number in [0, 1, 2, 3, 4]: print(number) for number in range(5): print(number)
# FILE MODES: # Example: # with open(name, 'w+') as f: # f.write(data) # "r" # Read from file - YES # Write to file - NO # Create file if not exists - NO # Truncate file to zero length - NO # Cursor position - BEGINNING # # "r+" # Read from file - YES # Write to file - YES # Create file if not exists - NO # Trunc...
myfile = open('/media/cicek/D/DDownloads/example.txt', 'w+') print('---------------------------------------------------------------------') open('/media/cicek/D/DDownloads/example.txt', 'w') open('/media/cicek/D/DDownloads/example.txt', 'r') open('/media/cicek/D/DDownloads/example.txt', 'wb') open('/media/cicek/D/DDown...
_base_ = [ "../_base_/models/cascade_rcnn_r50_fpn.py", "../_base_/datasets/coco_detection.py", "../_base_/schedules/schedule_1x.py", "../_base_/default_runtime.py", ] pretrained = "https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_small_patch4_window7_224.pth" model = dict( ba...
_base_ = ['../_base_/models/cascade_rcnn_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'] pretrained = 'https://github.com/SwinTransformer/storage/releases/download/v1.0.0/swin_small_patch4_window7_224.pth' model = dict(backbone=dict(_delete_=Tru...
class Event: def __init__(self, name, **kwargs): self.name = name self.args = kwargs def __str__(self): return f"Event(name='{self.name}', args={self.args})"
class Event: def __init__(self, name, **kwargs): self.name = name self.args = kwargs def __str__(self): return f"Event(name='{self.name}', args={self.args})"
class Solution: def fourSum(self, nums: List[int], target: int) -> List[List[int]]: def kSum(nums: List[int], target: int, k: int) -> List[List[int]]: res = [] if len(nums) == 0 or nums[0] * k > target or target > nums[-1] * k: return res if k == 2: ...
class Solution: def four_sum(self, nums: List[int], target: int) -> List[List[int]]: def k_sum(nums: List[int], target: int, k: int) -> List[List[int]]: res = [] if len(nums) == 0 or nums[0] * k > target or target > nums[-1] * k: return res if k == 2: ...
''' Exercise 2 for Day 5 of 100 Days of Python In this exercise, we are going to find out the highest score from a given list of scores of a certain number of students We are going to discuss 2 methods of finding the maximum ''' def find_maximum_score(scores): ''' METHOD 1 Using the inbuilt max() function, ...
""" Exercise 2 for Day 5 of 100 Days of Python In this exercise, we are going to find out the highest score from a given list of scores of a certain number of students We are going to discuss 2 methods of finding the maximum """ def find_maximum_score(scores): """ METHOD 1 Using the inbuilt max() function, w...
def dfsUtil(G, visited, travel, s): if(visited[s]): return visited[s] = True for u in G[s]: if(not visited[u]): dfsUtil(G, visited, travel, u) travel.append(s) def dfs(G, s=1): visited = {k: False for k in G.nodes} travel = [] for u in G.nodes: if(not vi...
def dfs_util(G, visited, travel, s): if visited[s]: return visited[s] = True for u in G[s]: if not visited[u]: dfs_util(G, visited, travel, u) travel.append(s) def dfs(G, s=1): visited = {k: False for k in G.nodes} travel = [] for u in G.nodes: if not vis...
def double(x): return x*2 # Lambda Functions # In Python, you can declare a variable of type function, where implementations can be simply assigned # In some use cases, you may have to function pointer to a function for some processing logic # Best Scenario: Callback scenarios # A mechnism of defining a method i...
def double(x): return x * 2 new_double = lambda x: x * 2 print(double(10)) print(new_double(200)) def get_value(): return 10 result = get_value() print(new_double(result)) print((lambda x: x * x)(10)) formatter = lambda x, y, z='X': '{}, {}, {}'.format(x, y, z) print(formatter('R', 'J')) formatter2 = lambda x,...
# # PySNMP MIB module DLSW-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DLSW-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:07:01 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:1...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection) ...
''' Play with numbers You are given an array of n numbers and q queries. For each query you have to print the floor of the expected value(mean) of the subarray from L to R. First line contains two integers N and Q denoting number of array elements and number of queries. Next line contains N space seperated integers ...
""" Play with numbers You are given an array of n numbers and q queries. For each query you have to print the floor of the expected value(mean) of the subarray from L to R. First line contains two integers N and Q denoting number of array elements and number of queries. Next line contains N space seperated integers ...
def glyphs(): return 97 _font =\ b'\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a'\ b'\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a'\ b'\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a'\ b'\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a\x00\x4a\x5a'\ b'\x00\x4a\x5a\x00\x4a\x5...
def glyphs(): return 97 _font = b'\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x00JZ\x11KYQKNLLNKQKSLVNXQYSYVXXVYSYQXNVLSKQK\x05LXLLLXXXXLLL\x04KYRJKVYVRJ\x05LXRHLRR\\X...
class Solution: def buddyStrings(self, A: str, B: str) -> bool: if len(A) != len(B): return False if A == B: seen = set() for char in A: if char in seen: return True seen.add(char) return False ...
class Solution: def buddy_strings(self, A: str, B: str) -> bool: if len(A) != len(B): return False if A == B: seen = set() for char in A: if char in seen: return True seen.add(char) return False ...
# ------------------------------ # 560. Subarray Sum Equals K # # Description: # Given an array of integers and an integer k, you need to find the total number of # continuous subarrays whose sum equals to k. # # Example 1: # Input:nums = [1,1,1], k = 2 # Output: 2 # # Note: # The length of the array is in range [1...
class Solution: def subarray_sum(self, nums: List[int], k: int) -> int: pre_sum = 0 count = 0 sum_dict = {0: 1} for n in nums: pre_sum += n if preSum - k in sumDict: count += sumDict[preSum - k] sumDict[preSum] = sumDict.get(preSum...
# testSIF = "123456789012" testSIF = open("input.txt", 'r').read() # testSIF = "0222112222120000" x_size = 25 y_size = 6 layer_count = len(testSIF) // (x_size * y_size) layers = [] index = 0 for z in range(layer_count): layer = [] for y in range(y_size): for x in range(x_size): layer += tes...
test_sif = open('input.txt', 'r').read() x_size = 25 y_size = 6 layer_count = len(testSIF) // (x_size * y_size) layers = [] index = 0 for z in range(layer_count): layer = [] for y in range(y_size): for x in range(x_size): layer += testSIF[index] index += 1 layers.append(layer...
class Object: ## Lisp apply() to `that` object in context def apply(self, env, that): raise NotImplementedError(['apply', self, env, that])
class Object: def apply(self, env, that): raise not_implemented_error(['apply', self, env, that])
loop = 1 while (loop < 10): noun1 = input("Choose a noun: ") plur_noun = input("Choose a plural noun: ") noun2 = input("Choose a noun: ") place = input("Name a place: ") adjective = input("Choose an adjective (Describing word): ") noun3 = input("Choose a noun: ") print ("--------...
loop = 1 while loop < 10: noun1 = input('Choose a noun: ') plur_noun = input('Choose a plural noun: ') noun2 = input('Choose a noun: ') place = input('Name a place: ') adjective = input('Choose an adjective (Describing word): ') noun3 = input('Choose a noun: ') print('-----------------------...
def aumentar(n,p,formatar=False): v = n + (n * p / 100) if formatar: return moeda(v) else: return v def diminuir(n,p,formatar=False): v = n - (n * p / 100) if formatar: return moeda(v) else: return v def dobro(n,formatar=False): v = n*2 if...
def aumentar(n, p, formatar=False): v = n + n * p / 100 if formatar: return moeda(v) else: return v def diminuir(n, p, formatar=False): v = n - n * p / 100 if formatar: return moeda(v) else: return v def dobro(n, formatar=False): v = n * 2 if formatar: ...
numbers = [54, 23, 66, 12] sumEle = numbers[1] + numbers[2] print(sumEle)
numbers = [54, 23, 66, 12] sum_ele = numbers[1] + numbers[2] print(sumEle)
class Solution: def search(self, nums: List[int], target: int) -> int: #start pointers low = 0 high = len(nums) - 1 # iterate trought the array while low <= high: # define middle of array mid = low + (high - low) // 2 # if position == tar...
class Solution: def search(self, nums: List[int], target: int) -> int: low = 0 high = len(nums) - 1 while low <= high: mid = low + (high - low) // 2 if nums[mid] == target: return mid elif nums[mid] < target: low = mid + 1 ...
#-*- coding: utf-8 -*- #!/usr/bin/env python ## dummy class to replace usbio class class I2C(object): def __init__(self,module,slave): pass def searchI2CDev(self,begin,end): pass def write_register(self, reg, data): pass # def I2C(self,mo...
class I2C(object): def __init__(self, module, slave): pass def search_i2_c_dev(self, begin, end): pass def write_register(self, reg, data): pass def autodetect(): pass def setup(): pass
# Variables representing the number of candies collected by alice, bob, and carol alice_candies = 121 bob_candies = 77 carol_candies = 109 # Your code goes here! Replace the right-hand side of this assignment with an expression # involving alice_candies, bob_candies, and carol_candies total = (alice_candies + bob_cand...
alice_candies = 121 bob_candies = 77 carol_candies = 109 total = alice_candies + bob_candies + carol_candies print(total % 3)
class ProfileDoesNotExist(Exception): def __init__(self, message, info={}): self.message = message self.info = info class ScraperError(Exception): def __init__(self, message, info={}): self.message = message self.info = info
class Profiledoesnotexist(Exception): def __init__(self, message, info={}): self.message = message self.info = info class Scrapererror(Exception): def __init__(self, message, info={}): self.message = message self.info = info
field_size = 40 snakeTailX = [40,80,120] snakeTailY = [0,0,0 ] Xhead, Yhead, Xfood, Yfood = 120,0,-40,- 40 snakeDirection = 'R' foodkey = True snakeLeight = 2 deadKey = False score = 0 def setup(): global img smooth() size(1024,572) img = loadImage("gameover.jpg") size(1024,572) ...
field_size = 40 snake_tail_x = [40, 80, 120] snake_tail_y = [0, 0, 0] (xhead, yhead, xfood, yfood) = (120, 0, -40, -40) snake_direction = 'R' foodkey = True snake_leight = 2 dead_key = False score = 0 def setup(): global img smooth() size(1024, 572) img = load_image('gameover.jpg') size(1024, 572) ...
class AncapBotError(Exception): pass class InsufficientFundsError(AncapBotError): pass class NonexistentUserError(AncapBotError): pass
class Ancapboterror(Exception): pass class Insufficientfundserror(AncapBotError): pass class Nonexistentusererror(AncapBotError): pass
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Build Tower #Problem level: 6 kyu def tower_builder(n_floors): return [' '*(n_floors-x)+'*'*(2*x-1)+' '*(n_floors-x) for x in range(1,n_floors+1)]
def tower_builder(n_floors): return [' ' * (n_floors - x) + '*' * (2 * x - 1) + ' ' * (n_floors - x) for x in range(1, n_floors + 1)]
class Solution: def hitBricks(self, grid: List[List[int]], hits: List[List[int]]) -> List[int]: def dfs(y, x): if y < 0 or y > m-1 or x < 0 or x > n-1 or grid[y][x]!=1: return 0 grid[y][x] =2 ret = 1 return ret + sum(dfs(y+shift_y, x+shift_x) f...
class Solution: def hit_bricks(self, grid: List[List[int]], hits: List[List[int]]) -> List[int]: def dfs(y, x): if y < 0 or y > m - 1 or x < 0 or (x > n - 1) or (grid[y][x] != 1): return 0 grid[y][x] = 2 ret = 1 return ret + sum((dfs(y + shif...
class Handler: def __init__(self): self.trace = [] def handle(self, data): self.trace.append(f'HANDLE {data}') return data
class Handler: def __init__(self): self.trace = [] def handle(self, data): self.trace.append(f'HANDLE {data}') return data
description = 'Verify that the user cannot log in if username value is missing' pages = ['login'] def setup(data): pass def test(data): go_to('http://localhost:8000/') send_keys(login.password_input, 'admin') click(login.login_button) capture('Verify the correct error message is shown') veri...
description = 'Verify that the user cannot log in if username value is missing' pages = ['login'] def setup(data): pass def test(data): go_to('http://localhost:8000/') send_keys(login.password_input, 'admin') click(login.login_button) capture('Verify the correct error message is shown') verify...
__description__ = 'lamuda common useful tools' __license__ = 'MIT' __uri__ = 'https://github.com/hanadumal/lamud' __version__ = '21.6.28' __author__ = 'hanadumal' __email__ = 'hanadumal@outlook.com'
__description__ = 'lamuda common useful tools' __license__ = 'MIT' __uri__ = 'https://github.com/hanadumal/lamud' __version__ = '21.6.28' __author__ = 'hanadumal' __email__ = 'hanadumal@outlook.com'
{ "includes": [ "common.gypi", ], "targets": [ { "target_name": "colony", "product_name": "colony", "type": "executable", 'cflags': [ '-Wall', '-Wextra', '-Werror' ], "sources": [ '<(runtime_path)/colony/cli.c', ], 'xcode_settings': { 'OTHER_LDFL...
{'includes': ['common.gypi'], 'targets': [{'target_name': 'colony', 'product_name': 'colony', 'type': 'executable', 'cflags': ['-Wall', '-Wextra', '-Werror'], 'sources': ['<(runtime_path)/colony/cli.c'], 'xcode_settings': {'OTHER_LDFLAGS': ['-pagezero_size', '10000', '-image_base', '100000000']}, 'include_dirs': ['<(ru...
def int_to_bytes(n, num_bytes): return n.to_bytes(num_bytes, 'big') def int_from_bytes(bites): return int.from_bytes(bites, 'big') class fountain_header: length = 6 def __init__(self, encode_id, total_size=None, chunk_id=None): if total_size is None: self.encode_id, self.total_...
def int_to_bytes(n, num_bytes): return n.to_bytes(num_bytes, 'big') def int_from_bytes(bites): return int.from_bytes(bites, 'big') class Fountain_Header: length = 6 def __init__(self, encode_id, total_size=None, chunk_id=None): if total_size is None: (self.encode_id, self.total_si...
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository") def _maybe(repo_rule, name, **kwargs): if name not in native.existing_rules(): repo_rule(name = name, **kwargs) def load_bark(): _maybe( native.local_repository, name = "bark_project", path="/home/chenyang/bark", ) #_...
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository') def _maybe(repo_rule, name, **kwargs): if name not in native.existing_rules(): repo_rule(name=name, **kwargs) def load_bark(): _maybe(native.local_repository, name='bark_project', path='/home/chenyang/bark')
#then look for the enumerated Intel Movidius NCS Device();quite program if none found. devices = mvnc.EnumerateDevice(); if len(devices) == 0: print("No any Devices found"); quit; #Now get a handle to the first enumerated device and open it. device = mvnc.Device(devices[0]); device.OpenDevice();
devices = mvnc.EnumerateDevice() if len(devices) == 0: print('No any Devices found') quit device = mvnc.Device(devices[0]) device.OpenDevice()
def mirror(text): words = text.split(" ") nwords = [] for w in words: nw = w[::-1] nwords.append(nw) return " ".join(nwords) print(mirror("s'tI suoregnad ot eb thgir nehw eht tnemnrevog si .gnorw"))
def mirror(text): words = text.split(' ') nwords = [] for w in words: nw = w[::-1] nwords.append(nw) return ' '.join(nwords) print(mirror("s'tI suoregnad ot eb thgir nehw eht tnemnrevog si .gnorw"))
UNK_TOKEN = '<unk>' PAD_TOKEN = '<pad>' BOS_TOKEN = '<s>' EOS_TOKEN = '<\s>' PAD, UNK, BOS, EOS = [0, 1, 2, 3] LANGUAGE_TOKENS = {lang: '<%s>' % lang for lang in sorted(['en', 'de', 'fr', 'he'])}
unk_token = '<unk>' pad_token = '<pad>' bos_token = '<s>' eos_token = '<\\s>' (pad, unk, bos, eos) = [0, 1, 2, 3] language_tokens = {lang: '<%s>' % lang for lang in sorted(['en', 'de', 'fr', 'he'])}
class Argument(object): def __init__(self, name=None, names=(), kind=bool, default=None): if name and names: msg = "Cannot give both 'name' and 'names' arguments! Pick one." raise TypeError(msg) if not (name or names): raise TypeError("An Argument must have at lea...
class Argument(object): def __init__(self, name=None, names=(), kind=bool, default=None): if name and names: msg = "Cannot give both 'name' and 'names' arguments! Pick one." raise type_error(msg) if not (name or names): raise type_error('An Argument must have at ...
# The Pipelines section. Pipelines group related components together by piping the output # of one component into the input of another. This is a good place to write your # package / unit tests as well as initialize your flags. Package tests check that the input # received by a component is of the right specification...
flags.set('pf_settings', [100, 'PF']) flags.set('inv_pf_settings', [100, 'InvPF']) flags.set('rr_fifo_settings', [100, 'RR_FIFO']) flags.set('rr_random_settings', [100, 'RR_random']) flags.set('hybrid_inv_pf_fifo_settings', [100, 'Hybrid_InvPF_FIFO']) flags.set('broadcast_settings', [1000, 5]) flags.set('run_interval',...
pjesma = '''\ Programiranje je zabava Kada je posao gotov ako zelis da ti posao bude razbirbriga korisit Python! ''' f = open("pjesma.txt", "w") #otvara fajl sa w-pisanje f.write(pjesma) #upisuje tekst u fajl f.close() #zatvara fajl f = open("pjesma.txt") #ako nismo naveli podazumjevno je r-citanje fajla while True: ...
pjesma = 'Programiranje je zabava\nKada je posao gotov\nako zelis da ti posao bude razbirbriga\nkorisit Python!\n' f = open('pjesma.txt', 'w') f.write(pjesma) f.close() f = open('pjesma.txt') while True: linija = f.readline() if len(linija) == 0: break print(linija, end=' ') f.close()
# from __future__ import division class WarheadTypeEnum(object): UNDEFINED = 0 CONE_WARHEAD = 1 ARC_WARHEAD = 2 CARMEN_WARHEAD = 3 class SternTypeEnum(object): UNDEFINED = 0 CONE_STERN = 1 ARC_STERN = 2 class BaseMissile(object): def __init__(self): self.para_dict = {'type_...
class Warheadtypeenum(object): undefined = 0 cone_warhead = 1 arc_warhead = 2 carmen_warhead = 3 class Sterntypeenum(object): undefined = 0 cone_stern = 1 arc_stern = 2 class Basemissile(object): def __init__(self): self.para_dict = {'type_warhead': WarheadTypeEnum.UNDEFINED, ...
CREATED_AT_KEY = "created_at" TITLE_KEY = "title" DESCRIPTION_KEY = "description" PUBLISHED_AT = "published_at" LIMIT_KEY = "limit" OFFSET_KEY = "offset" # Data query limiters DEFAULT_OFFSET = 0 DEFAULT_PER_PAGE_LIMIT = 20 INDEX_KEY = "video_index" VIDEO_ID_KEY = "video_id" VIDEOS_SEARCH_QUERY_KEY = "video_search_q...
created_at_key = 'created_at' title_key = 'title' description_key = 'description' published_at = 'published_at' limit_key = 'limit' offset_key = 'offset' default_offset = 0 default_per_page_limit = 20 index_key = 'video_index' video_id_key = 'video_id' videos_search_query_key = 'video_search_query'
# Longest Name. # Create a program that takes an unknown amount of names and outputs the longest name. You will know that the inputs are done when the user has inputted a string of X user_input = '' # Empty string longest_name = '' length = 0 while user_input != 'X': user_input = input('Enter a name: ') i...
user_input = '' longest_name = '' length = 0 while user_input != 'X': user_input = input('Enter a name: ') if user_input != 'X': current_length = len(user_input) if current_length > length: length = current_length longest_name = user_input print(longest_name, 'was the lon...
# Container for information about the project class Project(object): def __init__(self, origin='', commit='', owner='', name=''): self.origin = origin self.commit = commit self.owner = owner self.name = name def _asdict(self): return self.__dict__ def __dir__(self)...
class Project(object): def __init__(self, origin='', commit='', owner='', name=''): self.origin = origin self.commit = commit self.owner = owner self.name = name def _asdict(self): return self.__dict__ def __dir__(self): return ['origin', 'commit', 'owner',...
with open("my_files_ex1.txt") as f: file = f.read() print(file)
with open('my_files_ex1.txt') as f: file = f.read() print(file)
class NewsModel: title = None url = None def __init__(self, __title__, __url__): self.title = __title__ self.url = __url__ def __str__(self): return '''["%s", "%s"]''' % (self.title, self.url)
class Newsmodel: title = None url = None def __init__(self, __title__, __url__): self.title = __title__ self.url = __url__ def __str__(self): return '["%s", "%s"]' % (self.title, self.url)
def main(): space = " " item = "o" buffer = "" for x in range(2): spacing = "" for y in range(50): spacing += space buffer = spacing + item print(buffer) for z in range(50): spacing -= space buffer = item + spacin...
def main(): space = ' ' item = 'o' buffer = '' for x in range(2): spacing = '' for y in range(50): spacing += space buffer = spacing + item print(buffer) for z in range(50): spacing -= space buffer = item + spacing ...
def x(city, name): city = open(city,'r').read() city = city.replace('\n', ';') city = city.split(';') success = [] for i in city: if i: success.append(i.lstrip().rstrip()) success = {k: v for k, v in zip(success[::2], success[1::2])} file = open('{0}.txt'.format(name), 'w...
def x(city, name): city = open(city, 'r').read() city = city.replace('\n', ';') city = city.split(';') success = [] for i in city: if i: success.append(i.lstrip().rstrip()) success = {k: v for (k, v) in zip(success[::2], success[1::2])} file = open('{0}.txt'.format(name),...
'''Libraries used by the main program All the libraries that will be used by the main program will be placed here. Contains Library with functions to create latex report. '''
"""Libraries used by the main program All the libraries that will be used by the main program will be placed here. Contains Library with functions to create latex report. """
_base_ = [ '../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py' ] cudnn_benchmark = True norm_cfg = dict(type='BN', requires_grad=True) model = dict( pretrained='torchvision://resnet50', backbone=dict( type='ResNet', depth=50, ...
_base_ = ['../_base_/models/retinanet_r50_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/default_runtime.py'] cudnn_benchmark = True norm_cfg = dict(type='BN', requires_grad=True) model = dict(pretrained='torchvision://resnet50', backbone=dict(type='ResNet', depth=50, num_stages=4, out_indices=(0, 1, 2, 3)...
# # PySNMP MIB module HH3C-SESSION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-SESSION-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:16:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, single_value_constraint, value_range_constraint, value_size_constraint) ...
file_path = 'D12/input.txt' #file_path = 'D12/test.txt' #file_path = 'D12/test2.txt' with open(file_path) as f: text = f.read().split('\n') def reset(text): data = [] for i in text: data.append(i.split('-')) distinctNodes = [] for i in data: if i[0] not in distinctNodes: ...
file_path = 'D12/input.txt' with open(file_path) as f: text = f.read().split('\n') def reset(text): data = [] for i in text: data.append(i.split('-')) distinct_nodes = [] for i in data: if i[0] not in distinctNodes: distinctNodes.append(i[0]) if i[1] not in disti...
def generate_permutations(perm, n): if len(perm) == n: print(perm) return for k in range(n): if k not in perm: perm.append(k) generate_permutations(perm, n) perm.pop() generate_permutations(perm=[], n=4)
def generate_permutations(perm, n): if len(perm) == n: print(perm) return for k in range(n): if k not in perm: perm.append(k) generate_permutations(perm, n) perm.pop() generate_permutations(perm=[], n=4)
hip = 'hip' thorax = 'thorax' r_hip = 'r_hip' r_knee = 'r_knee' r_ankle = 'r_ankle' r_ball = 'r_ball' r_toes = 'r_toes' l_hip = 'l_hip' l_knee = 'l_knee' l_ankle = 'l_ankle' l_ball = 'l_ball' l_toes = 'l_toes' neck_base = 'neck' head_center = 'head-center' head_back = 'head-back' l_uknown = 'l_uknown' l_shoulder = 'l_s...
hip = 'hip' thorax = 'thorax' r_hip = 'r_hip' r_knee = 'r_knee' r_ankle = 'r_ankle' r_ball = 'r_ball' r_toes = 'r_toes' l_hip = 'l_hip' l_knee = 'l_knee' l_ankle = 'l_ankle' l_ball = 'l_ball' l_toes = 'l_toes' neck_base = 'neck' head_center = 'head-center' head_back = 'head-back' l_uknown = 'l_uknown' l_shoulder = 'l_s...
a=0 b=1 while a<10: print(a) a,b=b,a+b
a = 0 b = 1 while a < 10: print(a) (a, b) = (b, a + b)
#program to read the mass data and find the number of islands. c=0 def f(x,y,z): if 0<=y<10 and 0<=z<10 and x[z][y]=='1': x[z][y]='0' for dy,dz in [[-1,0],[1,0],[0,-1],[0,1]]:f(x,y+dy,z+dz) print("Input 10 rows of 10 numbers representing green squares (island) as 1 and blue squares (sea) as zeros") ...
c = 0 def f(x, y, z): if 0 <= y < 10 and 0 <= z < 10 and (x[z][y] == '1'): x[z][y] = '0' for (dy, dz) in [[-1, 0], [1, 0], [0, -1], [0, 1]]: f(x, y + dy, z + dz) print('Input 10 rows of 10 numbers representing green squares (island) as 1 and blue squares (sea) as zeros') while 1: tr...
def seq(a, d, n): res = str(a) for i in range(n-1): a += d a %= 10 res += str(a) return res[::-1] l = input() r = input() limits = set() for a in range(10): for d in range(10): limits.add(int(seq(a, d, len(l)))) limits.add(int(seq(a, d, len(r)))) res = max(99*(...
def seq(a, d, n): res = str(a) for i in range(n - 1): a += d a %= 10 res += str(a) return res[::-1] l = input() r = input() limits = set() for a in range(10): for d in range(10): limits.add(int(seq(a, d, len(l)))) limits.add(int(seq(a, d, len(r)))) res = max(99 * ...
def part1(): data = [] with open("C:\\Dev\\projects\\advent-of-code\\python\\day10\\input.txt") as f: data = [int(x) for x in f.readlines()] data.append(0) data.append(max(data) + 3) data.sort() diffs = [0] * 4 for i in range(1, len(data)): d = data[i] - data[i-1] di...
def part1(): data = [] with open('C:\\Dev\\projects\\advent-of-code\\python\\day10\\input.txt') as f: data = [int(x) for x in f.readlines()] data.append(0) data.append(max(data) + 3) data.sort() diffs = [0] * 4 for i in range(1, len(data)): d = data[i] - data[i - 1] d...
class Facility: id = 0 operator = None name = None bcghg_id = None type = None naics = None description = None swrs_facility_id = None production_calculation_explanation = None production_additional_info = None production_public_info = None ciip_db_id = None def __init__(self, operator): ...
class Facility: id = 0 operator = None name = None bcghg_id = None type = None naics = None description = None swrs_facility_id = None production_calculation_explanation = None production_additional_info = None production_public_info = None ciip_db_id = None def __in...
numero1=int(input("Digite Numero Uno: ")) numero2=int(input("Digite Numero Dos: ")) operador=input(" * / + - %: ") if(operador=="+"): funcion=lambda a,b: a+b elif(operador=="-"): funcion=lambda a,b: a-b elif(operador=="/"): funcion=lambda a,b:a/b elif(operador=="*"): funcion=lambda a,b:a*b elif(oper...
numero1 = int(input('Digite Numero Uno: ')) numero2 = int(input('Digite Numero Dos: ')) operador = input(' * / + - %: ') if operador == '+': funcion = lambda a, b: a + b elif operador == '-': funcion = lambda a, b: a - b elif operador == '/': funcion = lambda a, b: a / b elif operador == '*': funcion =...
a = 1 b = a+10 print(b)
a = 1 b = a + 10 print(b)
n=99999 t=n while(t//10!=0): x=t sum=0 while(x!=0): sum += x%10 x=x//10 t=sum print(sum)
n = 99999 t = n while t // 10 != 0: x = t sum = 0 while x != 0: sum += x % 10 x = x // 10 t = sum print(sum)
def sum_odd_numbers(numbers): total = 0 odd_numbers = [num for num in numbers if num % 2 == 0] for num in odd_numbers: total += num return total sum_odd_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9])
def sum_odd_numbers(numbers): total = 0 odd_numbers = [num for num in numbers if num % 2 == 0] for num in odd_numbers: total += num return total sum_odd_numbers([1, 2, 3, 4, 5, 6, 7, 8, 9])
# Tot's reward lv 20 sm.completeQuest(5519) # Lv. 20 Equipment box sm.giveItem(2431876, 1) sm.dispose()
sm.completeQuest(5519) sm.giveItem(2431876, 1) sm.dispose()
# This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. IGNORED_FILE_PREFIXES = ["."] IGNORED_FILE_SUFFIXES = ["~", ".swp"] IGNORED_DIRS = [".git", ".svn", ".hg"] def filter_...
ignored_file_prefixes = ['.'] ignored_file_suffixes = ['~', '.swp'] ignored_dirs = ['.git', '.svn', '.hg'] def filter_filenames(filenames, ignored_files=['.hgignore']): for filename in filenames: if filename in ignored_files: continue if any([filename.startswith(suffix) for suffix in IG...
# CHANGEME w = str(input("Pattern: ")) S = str(input("Search string (s): ")) B = {} or_mask = [0]*len(w) or_mask[len(w)-1] = 1 D = [0]*len(w) done = [] for i in list(set(w)): tmp = [0]*len(w) for pos in [pos for pos, char in enumerate(w) if char == i]: tmp[len(w)-pos-1] = 1 B[i] = tmp for c in w...
w = str(input('Pattern: ')) s = str(input('Search string (s): ')) b = {} or_mask = [0] * len(w) or_mask[len(w) - 1] = 1 d = [0] * len(w) done = [] for i in list(set(w)): tmp = [0] * len(w) for pos in [pos for (pos, char) in enumerate(w) if char == i]: tmp[len(w) - pos - 1] = 1 B[i] = tmp for c in w:...
N, M = list(map(int, input().split())) grid = [['@' for x in range(M)] for y in range(N)] for i in range(N): line = input() for j in range(M): grid[i][j] = line[j] alreadySeen = False jr = jc = -1 for i in range(N): if alreadySeen: break for j in range(M): if (alreadySeen): ...
(n, m) = list(map(int, input().split())) grid = [['@' for x in range(M)] for y in range(N)] for i in range(N): line = input() for j in range(M): grid[i][j] = line[j] already_seen = False jr = jc = -1 for i in range(N): if alreadySeen: break for j in range(M): if alreadySeen: ...
''' Author : MiKueen Level : Hard Problem Statement : Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: ...
""" Author : MiKueen Level : Hard Problem Statement : Median of Two Sorted Arrays There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). You may assume nums1 and nums2 cannot be both empty. Example 1: ...
def main(): # Ask for the user's weight in pounds. weight = int(input('Please enter your weight in pounds: ')) # Ask for the user's height in inches. height = int(input('Please enter your height in inches: ')) # Calculate the BMI (BMI = weight*703/height^2) BMI = (weight * 703.0) / (height*hei...
def main(): weight = int(input('Please enter your weight in pounds: ')) height = int(input('Please enter your height in inches: ')) bmi = weight * 703.0 / (height * height) print('Your BMI is %.1f' % BMI) if BMI < 18.5: print('You are underweight.') elif BMI > 25: print('It would...
def selecao_em_vetor(): vetor = list() for i in range(100): vetor.append(float(input())) for j in range(100): if vetor[j] <= 10.0: print(f'A[{j}] = {vetor[j]:.1f}') selecao_em_vetor()
def selecao_em_vetor(): vetor = list() for i in range(100): vetor.append(float(input())) for j in range(100): if vetor[j] <= 10.0: print(f'A[{j}] = {vetor[j]:.1f}') selecao_em_vetor()
def pythoagorialTripletSum(sum1): if sum == 0: return 0 for i in range(1, int(sum1/3)+1): for j in range(i +1, int(sum1/2) + 1): k = sum1 - i - j if (i * i + j *j == k * k): print(i, j, k, end = " ") return print("No Triplet...
def pythoagorial_triplet_sum(sum1): if sum == 0: return 0 for i in range(1, int(sum1 / 3) + 1): for j in range(i + 1, int(sum1 / 2) + 1): k = sum1 - i - j if i * i + j * j == k * k: print(i, j, k, end=' ') return print('No Triplets') ...
class Scene: def __init__(self, name = ""): #print("new Scene Object created") self.srcs = [] #all sources with visible state of this scene, including srcs from nested scenes self.scenes = [] #list of all nested scenes self.name = name
class Scene: def __init__(self, name=''): self.srcs = [] self.scenes = [] self.name = name
with open("dane/liczby.txt") as f: lines = [l.strip() for l in f.readlines()] wynik42 = open("wynik42.txt", "w") div_2 = 0 div_8 = 0 for line in lines: if line[-1] == "0": div_2 += 1 if line[-1] == "0" and line[-2] == "0" and line[-3] == "0": div_8 += 1 wynik42.write(f"zadanie 4.2: {div...
with open('dane/liczby.txt') as f: lines = [l.strip() for l in f.readlines()] wynik42 = open('wynik42.txt', 'w') div_2 = 0 div_8 = 0 for line in lines: if line[-1] == '0': div_2 += 1 if line[-1] == '0' and line[-2] == '0' and (line[-3] == '0'): div_8 += 1 wynik42.write(f'zadanie 4.2: {div_2}...
st = ['id', 'pwd', 'name', 'age'] data = ['id01', 'pwd01', 'james', 30] cust = zip(st,data) print(cust) for s,d in cust: print('%s : %s' % (s,d)) dic_cust = dict(zip(st,data)) print(dic_cust)
st = ['id', 'pwd', 'name', 'age'] data = ['id01', 'pwd01', 'james', 30] cust = zip(st, data) print(cust) for (s, d) in cust: print('%s : %s' % (s, d)) dic_cust = dict(zip(st, data)) print(dic_cust)
### Quicksort 1 - Partition - Solution def quickSort(arr): pivotNum = arr[0] for i in range(1, len(arr)): if pivotNum > arr[i]: for j in range(i, 0, -1): temp = arr[j] arr[j] = arr[j-1] arr[j-1] = temp print(*arr) n = int(input()) arr = l...
def quick_sort(arr): pivot_num = arr[0] for i in range(1, len(arr)): if pivotNum > arr[i]: for j in range(i, 0, -1): temp = arr[j] arr[j] = arr[j - 1] arr[j - 1] = temp print(*arr) n = int(input()) arr = list(map(int, input().split()[:n])) ...
# 2021-01-30 # Emma Benjaminson # Quick Sort Implementation # Source: https://www.educative.io/edpresso/how-to-implement-quicksort-in-python def QuickSort(arr): elements = len(arr) # base case if elements < 2: return arr current_position = 0 # position of the partitioning element # part...
def quick_sort(arr): elements = len(arr) if elements < 2: return arr current_position = 0 for i in range(1, elements): if arr[i] <= arr[0]: current_position += 1 temp = arr[i] arr[i] = arr[current_position] arr[current_position] = temp ...
# # PySNMP MIB module HPR-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPR-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:30:23 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)...
(sna_control_point_name,) = mibBuilder.importSymbols('APPN-MIB', 'SnaControlPointName') (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraint...
def get_binary_rep(data, spacing=0, separator=" "): format(i,'b').zfill(8) def bin_rep_string_arr(data): map() return [] def bin_rep_int_arr(data): return [] def bin_rep_unicode_arr(data): return [] def bin_rep_bytes_arr(data): return [] def hex_rep_string_arr(data): return [] d...
def get_binary_rep(data, spacing=0, separator=' '): format(i, 'b').zfill(8) def bin_rep_string_arr(data): map() return [] def bin_rep_int_arr(data): return [] def bin_rep_unicode_arr(data): return [] def bin_rep_bytes_arr(data): return [] def hex_rep_string_arr(data): return [] def hex...
# Accessing tuple elements using slicing my_tuple = ('p','r','o','g','r','a','m','i','n','g') # elements 2nd to 4th print(my_tuple[1:4]) # elements beginning to 4nd print(my_tuple[:-7]) # elements 8th to end print(my_tuple[7:]) # elements beginning to end print(my_tuple[:])
my_tuple = ('p', 'r', 'o', 'g', 'r', 'a', 'm', 'i', 'n', 'g') print(my_tuple[1:4]) print(my_tuple[:-7]) print(my_tuple[7:]) print(my_tuple[:])
image_width = 400 image_height = 400 prediction_size = 8 batch_size = 10 noise_ratio = 0.1
image_width = 400 image_height = 400 prediction_size = 8 batch_size = 10 noise_ratio = 0.1
# # PySNMP MIB module ALTEON-CHEETAH-NETWORK-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALTEON-CHEETAH-NETWORK-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:05:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(aws_switch,) = mibBuilder.importSymbols('ALTEON-ROOT-MIB', 'aws-switch') (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constrai...
# # PySNMP MIB module PDN-IFDEV-IWF-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PDN-IFDEV-IWF-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:30:02 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint, constraints_union) ...
n = int(input())/10e2 if 0.1 > n: print("00") elif 5 >= n: if len(str(int(n*10))) == 1: print("0{}".format(int(n*10))) else: print(int(n*10)) elif 30 >= n: print(int(n)+50) elif 70 >= n: print((int(n) - 30)//5 + 80) else: print(89)
n = int(input()) / 1000.0 if 0.1 > n: print('00') elif 5 >= n: if len(str(int(n * 10))) == 1: print('0{}'.format(int(n * 10))) else: print(int(n * 10)) elif 30 >= n: print(int(n) + 50) elif 70 >= n: print((int(n) - 30) // 5 + 80) else: print(89)
# Gareth Duffy 2-3-2018 # example of for loop using range function as iterator # for loops are definite iterators compared to e.g. while loops (indefinite) for i in range(1, 99, 2): # change range to experiment (third value is the 'step') print(i, end=' ') # end prints all on one line instead of separate lines
for i in range(1, 99, 2): print(i, end=' ')
fairumei = "alphabet.java" henkou = fairumei.split(".") print(henkou[-1])
fairumei = 'alphabet.java' henkou = fairumei.split('.') print(henkou[-1])
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"boto3_available": "00_utils.ipynb", "setStockDataRoot": "00_utils.ipynb", "stockDataRoot": "00_utils.ipynb", "requestUrl": "00_utils.ipynb", "setSecUserAgent": "00_utils.i...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'boto3_available': '00_utils.ipynb', 'setStockDataRoot': '00_utils.ipynb', 'stockDataRoot': '00_utils.ipynb', 'requestUrl': '00_utils.ipynb', 'setSecUserAgent': '00_utils.ipynb', 'secIndexUrl': '00_utils.ipynb', 'appendSpace': '00_utils.ipynb', 'get...
# ============================================ # Global Constants # ============================================ # Shared variables PUZZLE_ROWS = 9 # Number of rows on the board. PUZZLE_COLUMNS = 9 # Number of columns on the board. # Game variables LEVEL_1_TOTAL_MEDALS = 3 LEVEL_2_TOTAL_MEDALS = 4 LEVEL_3_TOTAL_MED...
puzzle_rows = 9 puzzle_columns = 9 level_1_total_medals = 3 level_2_total_medals = 4 level_3_total_medals = 5 score = 0 moves_left = 20 gem_types = 6 bonus_types = 3 ice_rows = 5 ice_layers = 1 random_seed = None hd_scale = 1.5 base_cell_size = 30 gem_ratio = 0.9 base_margin = 70 base_text_area = 75 animation_scale = 1...
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: if root is None: return 0 ...
class Solution: def diameter_of_binary_tree(self, root: TreeNode) -> int: if root is None: return 0 self.max_dist = 0 self.helper(root) return self.max_dist - 1 def helper(self, root): if root is None: return 0 l = self.helper(root.left) ...
class Dataset(): def __init__(self, train_images, test_images, train_labels, test_labels, emotion_index_map, time_delay=None): self._train_images = train_images self._test_images = test_images self._train_labels = train_labels self._test_labels = test_labels self._emotion_i...
class Dataset: def __init__(self, train_images, test_images, train_labels, test_labels, emotion_index_map, time_delay=None): self._train_images = train_images self._test_images = test_images self._train_labels = train_labels self._test_labels = test_labels self._emotion_inde...
__author__ = 'alvertisjo' recommenderSE='http://snf-561492.vm.okeanos.grnet.gr:8080/recommender-se/rest/recommender/' recommnederProductCategories=['Home Appliances', 'Electrical Supplies', 'Kitchen Merchandise', 'Pet Care - Food', 'Clothing', 'Sports Equipment', 'Healthcare', 'Communications', 'Lubricants', 'Audio Vi...
__author__ = 'alvertisjo' recommender_se = 'http://snf-561492.vm.okeanos.grnet.gr:8080/recommender-se/rest/recommender/' recommneder_product_categories = ['Home Appliances', 'Electrical Supplies', 'Kitchen Merchandise', 'Pet Care - Food', 'Clothing', 'Sports Equipment', 'Healthcare', 'Communications', 'Lubricants', 'Au...
# Python program showing no need to # use global keyword for accessing # a global value # global variable a = 15 b = 10 # function to perform addition def add(): c = a + b print(c) # calling a function add()
a = 15 b = 10 def add(): c = a + b print(c) add()
def test(): for i in xrange(1): t = '' for j in xrange(int(1e5)): t += 'x' #print(len(t)) test()
def test(): for i in xrange(1): t = '' for j in xrange(int(100000.0)): t += 'x' test()
def miniPeaks(nums): result = [] left = 0 right = 0 for i in range(1, len(nums) - 1): left = nums[i - 1] right = nums[i + 1] if nums[i] > left and nums[i] > right: result.append(nums[i]) return result # Time Complexity : O(n) # Space Co...
def mini_peaks(nums): result = [] left = 0 right = 0 for i in range(1, len(nums) - 1): left = nums[i - 1] right = nums[i + 1] if nums[i] > left and nums[i] > right: result.append(nums[i]) return result
#!/usr/bin/env python __author__ = "Aditya Pahuja" __copyright__ = "Copyright (c) 2020" __maintainer__ = "Aditya Pahuja" __email__ = "aditya.s.pahuja@gmail.com" __status__ = "Production" class Window: def __init__(self, start_date, stop_date): self.start_date = start_date self.stop_date = stop_d...
__author__ = 'Aditya Pahuja' __copyright__ = 'Copyright (c) 2020' __maintainer__ = 'Aditya Pahuja' __email__ = 'aditya.s.pahuja@gmail.com' __status__ = 'Production' class Window: def __init__(self, start_date, stop_date): self.start_date = start_date self.stop_date = stop_date