content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# # PySNMP MIB module HH3C-VSI-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-VSI-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:15:32 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,...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint) ...
vals = [0,10,-30,173247,123,19892122] formats = ['%o','%020o', '%-20o', '%#o', '+%o', '+%#o'] for val in vals: for fmt in formats: print(fmt+":", fmt % val)
vals = [0, 10, -30, 173247, 123, 19892122] formats = ['%o', '%020o', '%-20o', '%#o', '+%o', '+%#o'] for val in vals: for fmt in formats: print(fmt + ':', fmt % val)
# File: gcloudcomputeengine_consts.py # # Copyright (c) 2021 Splunk Inc. # # Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) # Define your constants here COMPUTE = 'compute' COMPUTE_VERSION = 'v1' # Error message handling constants ERR_CODE_MSG = "Error code unavailable" ERR_MSG_UNAVAILABL...
compute = 'compute' compute_version = 'v1' err_code_msg = 'Error code unavailable' err_msg_unavailable = 'Error message unavailable. Please check the asset configuration and|or action parameters' parse_err_msg = 'Unable to parse the error message. Please check the asset configuration and|or action parameters'
#!/usr/bin/env python3 def byterize(obj): objdict = obj.__dict__['fields'] def do_encode(dictio, key): if isinstance(dictio[key], str) and len(dictio[key]) > 0 and key not in ['SecondaryAddr']: dictio[key] = dictio[key].encode('latin-1') elif hasattr(dictio[key], '__dict__'): ...
def byterize(obj): objdict = obj.__dict__['fields'] def do_encode(dictio, key): if isinstance(dictio[key], str) and len(dictio[key]) > 0 and (key not in ['SecondaryAddr']): dictio[key] = dictio[key].encode('latin-1') elif hasattr(dictio[key], '__dict__'): subdictio = dic...
class DaftException(Exception): def __init__(self, reason): self.reason = reason def __str__(self): return "Error: " + self.reason
class Daftexception(Exception): def __init__(self, reason): self.reason = reason def __str__(self): return 'Error: ' + self.reason
class Solution: def transformArray(self, arr: List[int]) -> List[int]: na = arr[:] stable = False while not stable: stable = True for i in range(1, len(arr) - 1): if arr[i] < arr[i-1] and arr[i] < arr[i+1]: na[i] = arr[i] + 1 ...
class Solution: def transform_array(self, arr: List[int]) -> List[int]: na = arr[:] stable = False while not stable: stable = True for i in range(1, len(arr) - 1): if arr[i] < arr[i - 1] and arr[i] < arr[i + 1]: na[i] = arr[i] + 1 ...
try: p=8778 b=56434 #f = open("ab.txt") p = b/0 f = open("ab.txt") for line in f: print(line) except FileNotFoundError as e: print( e.filename) except Exception as e: print(e) except ZeroDivisionError as e: print(e) #except (FileNotFoundError , ZeroDivisionError): ...
try: p = 8778 b = 56434 p = b / 0 f = open('ab.txt') for line in f: print(line) except FileNotFoundError as e: print(e.filename) except Exception as e: print(e) except ZeroDivisionError as e: print(e)
# *************************************************************************************** # *************************************************************************************** # # Name : errors.py # Author : Paul Robson (paul@robsons.org.uk) # Date : 9th December 2018 # Purpose : Error classes # # *********...
class Compilerexception(Exception): def __init__(self, message): self.message = message def get(self): return '{0} ({1}:{2})'.format(self.message, CompilerException.FILENAME, CompilerException.LINENUMBER) CompilerException.FILENAME = 'test' CompilerException.LINENUMBER = 42 if __name__ == '__m...
def get_options_ratio(options, total): return options / total def get_faculty_rating(get_options_ratio): if get_options_ratio > .9 and get_options_ratio < 1: return "Excellent" if get_options_ratio > .8 and get_options_ratio < .9: return "Very Good" if get_options_ratio > .7 and get_opt...
def get_options_ratio(options, total): return options / total def get_faculty_rating(get_options_ratio): if get_options_ratio > 0.9 and get_options_ratio < 1: return 'Excellent' if get_options_ratio > 0.8 and get_options_ratio < 0.9: return 'Very Good' if get_options_ratio > 0.7 and get...
''' Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first letter in ...
""" Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first letter in ...
# See readme.md for instructions on running this code. class HelpHandler(object): def usage(self): return ''' This plugin will give info about Zulip to any user that types a message saying "help". This is example code; ideally, you would flesh this out for m...
class Helphandler(object): def usage(self): return '\n This plugin will give info about Zulip to\n any user that types a message saying "help".\n\n This is example code; ideally, you would flesh\n this out for more useful help pertaining to\n your Zuli...
''' Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. Example 1: Input: "ab-cd" Output: "dc-ba" Example 2: Input: "a-bC-dEf-ghIj" Output: "j-Ih-gfE-dCba" Example 3: Input: "Test1ng-Leet=code-Q!" Output: "Qedo...
""" Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. Example 1: Input: "ab-cd" Output: "dc-ba" Example 2: Input: "a-bC-dEf-ghIj" Output: "j-Ih-gfE-dCba" Example 3: Input: "Test1ng-Leet=code-Q!" Output: "Qedo...
# # PySNMP MIB module NMS-EPON-ONU-SERIAL-PORT (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-EPON-ONU-SERIAL-PORT # Produced by pysmi-0.3.4 at Mon Apr 29 20:12:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, constraints_union, value_range_constraint, single_value_constraint) ...
# A simple color module I wrote for my projects # Feel free to copy this script and use it for your own projects! class Color: purple = '\033[95m' blue = '\033[94m' green = '\033[92m' yellow = '\033[93m' red = '\033[91m' white = '\033[0m' class textType: bold = '\033[1m' underline = ...
class Color: purple = '\x1b[95m' blue = '\x1b[94m' green = '\x1b[92m' yellow = '\x1b[93m' red = '\x1b[91m' white = '\x1b[0m' class Texttype: bold = '\x1b[1m' underline = '\x1b[4m'
# LC 1268 class TrieNode: def __init__(self): self.next = dict() self.words = list() class Trie: def __init__(self): self.root = TrieNode() def insert(self, word): node = self.root for char in word: # node = node.next.setdefault(char, TrieNode()) ...
class Trienode: def __init__(self): self.next = dict() self.words = list() class Trie: def __init__(self): self.root = trie_node() def insert(self, word): node = self.root for char in word: if char not in node.next: node.next[char] = tr...
x = int(input()) y = int(input()) print(y % x)
x = int(input()) y = int(input()) print(y % x)
class OutputBase: def __init__(self): self.output_buffer = [] def __call__(self, obj): self.write(obj) def write(self, obj): pass def clear(self): self.output_buffer = []
class Outputbase: def __init__(self): self.output_buffer = [] def __call__(self, obj): self.write(obj) def write(self, obj): pass def clear(self): self.output_buffer = []
DEBUG = False # if False, "0" will be used ENABLE_STRING_SEEDING = True # use headless evaluator HEADLESS = False # === Emulator === DEVICE_NUM = 1 AVD_BOOT_DELAY = 30 AVD_SERIES = "api19_" EVAL_TIMEOUT = 120 # if run on Mac OS, use "gtimeout" TIMEOUT_CMD = "timeout" # === Env. Paths === # path should end with a '/...
debug = False enable_string_seeding = True headless = False device_num = 1 avd_boot_delay = 30 avd_series = 'api19_' eval_timeout = 120 timeout_cmd = 'timeout' android_home = '/home/shadeimi/Software/android-sdk-linux/' working_dir = '/home/shadeimi/Software/eclipseWorkspace/sapienz/' sequence_length_min = 20 sequence_...
class InvalidDataFrameException(Exception): pass class InvalidCheckTypeException(Exception): pass
class Invaliddataframeexception(Exception): pass class Invalidchecktypeexception(Exception): pass
#!/usr/bin/python # vim: set ts=4: # vim: set shiftwidth=4: # vim: set expandtab: #------------------------------------------------------------------------------- #---> Elections supported #------------------------------------------------------------------------------- # election id - base_url - election type - year -...
elections = [('20150920', 'http://ekloges.ypes.gr/current', 'v', 2015, True), ('20150125', 'http://ekloges-prev.singularlogic.eu/v2015a', 'v', 2015, True), ('20150705', 'http://ekloges-prev.singularlogic.eu/r2015', 'e', 2015, True), ('20140525', 'http://ekloges-prev.singularlogic.eu/may2014', 'e', 2014, False), ('20120...
def ortho_locs(row, col): offsets = [(-1,0), (0,-1), (0,1), (1,0)] for row_offset, col_offset in offsets: yield row + row_offset, col + col_offset def adj_locs(row, col): offsets = [(-1,-1), (-1,0), (-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)] for row_offset, col_offset in offsets: yiel...
def ortho_locs(row, col): offsets = [(-1, 0), (0, -1), (0, 1), (1, 0)] for (row_offset, col_offset) in offsets: yield (row + row_offset, col + col_offset) def adj_locs(row, col): offsets = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] for (row_offset, col_offset) in off...
def GetByTitle(type, title): type = type.upper() if type != 'ANIME' and type != 'MANGA': return False variables = { 'type' : type, 'search' : title } return variables
def get_by_title(type, title): type = type.upper() if type != 'ANIME' and type != 'MANGA': return False variables = {'type': type, 'search': title} return variables
def queryValue(cur, sql, fields=None, error=None) : row = queryRow(cur, sql, fields, error); if row is None : return None return row[0] def queryRow(cur, sql, fields=None, error=None) : row = doQuery(cur, sql, fields) try: row = cur.fetchone() return row except Exception as e: ...
def query_value(cur, sql, fields=None, error=None): row = query_row(cur, sql, fields, error) if row is None: return None return row[0] def query_row(cur, sql, fields=None, error=None): row = do_query(cur, sql, fields) try: row = cur.fetchone() return row except Exception...
HEADERS_FOR_HTTP_GET = { 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36' } AGE_CATEGORIES = [ 'JM10', 'JW10', 'JM11-14', 'JW11-14', 'JM15-17', 'JW15-17', 'SM18-19', 'SW18-19', 'SM20-24', 'SW20-24', 'SM25...
headers_for_http_get = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36'} age_categories = ['JM10', 'JW10', 'JM11-14', 'JW11-14', 'JM15-17', 'JW15-17', 'SM18-19', 'SW18-19', 'SM20-24', 'SW20-24', 'SM25-29', 'SW25-29', 'SM30-34', 'SW...
# # PySNMP MIB module MICOM-IFDNA-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MICOM-IFDNA-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:02:03 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection) ...
a = 5 b = 3 def timeit_1(): print(a + b) c = 8 def timeit_2(): print(a + b + c)
a = 5 b = 3 def timeit_1(): print(a + b) c = 8 def timeit_2(): print(a + b + c)
def some_but_not_all(seq, pred): has = [False,False] for it in seq: has[bool(pred(it))] = True # exit as fast as possible if all(has): return True # sequennce is scanned with only True or False predictions. return False
def some_but_not_all(seq, pred): has = [False, False] for it in seq: has[bool(pred(it))] = True if all(has): return True return False
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' A short description of this file A slightly longer description of this file can be found under the shorter desription. ''' def get_code(): ''' Get mysterious code... ''' return '100111011111101010110110101100'
""" A short description of this file A slightly longer description of this file can be found under the shorter desription. """ def get_code(): """ Get mysterious code... """ return '100111011111101010110110101100'
class StdoutMock(): def __init__(self, *args, **kwargs): self.content = '' def write(self, content): self.content += content def read(self): return self.content def __str__(self): return self.read()
class Stdoutmock: def __init__(self, *args, **kwargs): self.content = '' def write(self, content): self.content += content def read(self): return self.content def __str__(self): return self.read()
def flatten(list): final = [] for item in list: final += item return final def flattenN(list): if type(list[0]) != type([]): return list return flattenN(flatten(list)) list = [[[1,2],[3,4]],[[3,4],["hello","there"]]] result = flattenN(list) print(result)
def flatten(list): final = [] for item in list: final += item return final def flatten_n(list): if type(list[0]) != type([]): return list return flatten_n(flatten(list)) list = [[[1, 2], [3, 4]], [[3, 4], ['hello', 'there']]] result = flatten_n(list) print(result)
def imp_notas(quantidade, valor): return '{:.0f} nota(s) de R$ {:.2f}'.format(quantidade, valor) def imp_moedas(quantidade, valor): return '{:.0f} moeda(s) de R$ {:.2f}'.format(quantidade, valor) numero = float(input()) numero += 0.0001 if numero >= 0 or numero <= 1000000.00: notas = [100.00, 50.00, 20....
def imp_notas(quantidade, valor): return '{:.0f} nota(s) de R$ {:.2f}'.format(quantidade, valor) def imp_moedas(quantidade, valor): return '{:.0f} moeda(s) de R$ {:.2f}'.format(quantidade, valor) numero = float(input()) numero += 0.0001 if numero >= 0 or numero <= 1000000.0: notas = [100.0, 50.0, 20.0, 10....
class Wizard: def __init__(self, app): self.app = app def skip_wizard(self): driver = self.app.driver driver.find_element_by_class_name("skip").click()
class Wizard: def __init__(self, app): self.app = app def skip_wizard(self): driver = self.app.driver driver.find_element_by_class_name('skip').click()
def linked_sort(a_to_sort, a_linked, key=str): res = sorted(zip(a_to_sort, a_linked), key=key) for i in range(len(a_to_sort)): a_to_sort[i], a_linked[i] = res[i] return a_to_sort
def linked_sort(a_to_sort, a_linked, key=str): res = sorted(zip(a_to_sort, a_linked), key=key) for i in range(len(a_to_sort)): (a_to_sort[i], a_linked[i]) = res[i] return a_to_sort
# -*- coding: utf-8 -*- # :copyright: (c) 2011 - 2015 by Arezqui Belaid. # :license: MPL 2.0, see COPYING for more details. __version__ = '1.0.3' __author__ = "Arezqui Belaid" __contact__ = "info@star2billing.com" __homepage__ = "http://www.star2billing.org" __docformat__ = "restructuredtext"
__version__ = '1.0.3' __author__ = 'Arezqui Belaid' __contact__ = 'info@star2billing.com' __homepage__ = 'http://www.star2billing.org' __docformat__ = 'restructuredtext'
def print_stats(num_broke, num_profitors, sample_size, profits, loses, type): broke_percent = (num_broke / sample_size) * 100 profit_percent = (num_profitors / sample_size) * 100 try: survive_profit_percent = (num_profitors / (sample_size - num_broke)) * 100 except ZeroDivisionError: ...
def print_stats(num_broke, num_profitors, sample_size, profits, loses, type): broke_percent = num_broke / sample_size * 100 profit_percent = num_profitors / sample_size * 100 try: survive_profit_percent = num_profitors / (sample_size - num_broke) * 100 except ZeroDivisionError: survive_p...
class Similarity: def __init__(self, path, score): self.path = path self.score = score @classmethod def from_dict(cls, adict): return cls( path=adict['path'], score=adict['score'], ) def to_dict(self): return { 'path':...
class Similarity: def __init__(self, path, score): self.path = path self.score = score @classmethod def from_dict(cls, adict): return cls(path=adict['path'], score=adict['score']) def to_dict(self): return {'path': self.path, 'score': self.score} def __eq__(self, ...
EFFICIENTDET = { 'efficientdet-d0': {'input_size': 512, 'backbone': 'B0', 'W_bifpn': 64, 'D_bifpn': 2, 'D_class': 3}, 'efficientdet-d1': {'input_size': 640, 'backbone': 'B1', ...
efficientdet = {'efficientdet-d0': {'input_size': 512, 'backbone': 'B0', 'W_bifpn': 64, 'D_bifpn': 2, 'D_class': 3}, 'efficientdet-d1': {'input_size': 640, 'backbone': 'B1', 'W_bifpn': 88, 'D_bifpn': 3, 'D_class': 3}, 'efficientdet-d2': {'input_size': 768, 'backbone': 'B2', 'W_bifpn': 112, 'D_bifpn': 4, 'D_class': 3}, ...
month = int(input("Enter month: ")) year = int(input("Enter year: ")) if month == 1: monthName = "January" numberOfDaysInMonth = 31 elif month == 2: monthName = "February" if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): numberOfDaysInMonth = 29 else: numberOfDa...
month = int(input('Enter month: ')) year = int(input('Enter year: ')) if month == 1: month_name = 'January' number_of_days_in_month = 31 elif month == 2: month_name = 'February' if year % 400 == 0 or (year % 4 == 0 and year % 100 != 0): number_of_days_in_month = 29 else: number_of_da...
# Problem: Given as an input two strings, X = x_{1} x_{2}... x_{m}, and Y = y_{1} y_{2}... y_{m}, output the alignment of the strings, character by character, # so that the net penalty is minimised. gap_penalty = 3 # cost of gap mismatch_penalty = 2 # cost of mismatch memoScore = {} memoSe...
gap_penalty = 3 mismatch_penalty = 2 memo_score = {} memo_sequence = {} def sequence_alignment(seq1, seq2): if (seq1, seq2) in memoScore: return memoScore[seq1, seq2] if seq1 == '' and seq2 == '': memoSequence[seq1, seq2] = ['', ''] return 0 elif seq1 == '' or seq2 == '': ma...
A = int(input()) B = set("aeiou") for i in range(A): S = input() count = 0 for j in range(len(S)): if S[j] in B: count += 1 print(count)
a = int(input()) b = set('aeiou') for i in range(A): s = input() count = 0 for j in range(len(S)): if S[j] in B: count += 1 print(count)
# Configuration for running the Avalon Music Server under Gunicorn # http://docs.gunicorn.org # Note that this configuration omits a bunch of features that Gunicorn # has (such as running as a daemon, changing users, error and access # logging) because it is designed to be used when running Gunicorn # with supervisord...
bind = 'localhost:8000' workers = 3 preload_app = True
#check if number is prime or not n = int(input("enter a number ")) for i in range(2, n): if n % i == 0: print("not a prime number") break else: print("it is a prime number")
n = int(input('enter a number ')) for i in range(2, n): if n % i == 0: print('not a prime number') break else: print('it is a prime number')
# # PySNMP MIB module EXTREME-EAPS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EXTREME-BASE-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:07:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, constraints_union, single_value_constraint, constraints_intersection) ...
# -*- coding: utf-8 -*- operation = input() total = 0 for i in range(144): N = float(input()) line = i // 12 if (i > (13 * line)): total += N answer = total if (operation == 'S') else (total / 66) print("%.1f" % answer)
operation = input() total = 0 for i in range(144): n = float(input()) line = i // 12 if i > 13 * line: total += N answer = total if operation == 'S' else total / 66 print('%.1f' % answer)
S = [3, 1, 3, 1] N = len(S)-1 big_val = 1 << 62 # left bitwise shift is equivalent to raising 2 to the power of the positions shifted. so, big_val = 2 ^ 62. A = [[big_val for i in range(N+1)] for j in range(N+1)] def matrix_chain_cost(i, j): global A if i == j: return 0 if A[i][j] != big_val: ...
s = [3, 1, 3, 1] n = len(S) - 1 big_val = 1 << 62 a = [[big_val for i in range(N + 1)] for j in range(N + 1)] def matrix_chain_cost(i, j): global A if i == j: return 0 if A[i][j] != big_val: return A[i][j] for k in range(i, j): A[i][j] = min(A[i][j], matrix_chain_cost(i, k) + ma...
# Function: flips a pattern by mirror image # Input: # string - string pattern # direction - flip horizontally or vertically # Ouput: modified string pattern def flip(st, direction): row_strings = st.split("\n") row_strings = row_strings[:-1] st_out = '' if (direction == 'Flip Horizo...
def flip(st, direction): row_strings = st.split('\n') row_strings = row_strings[:-1] st_out = '' if direction == 'Flip Horizontally': row_strings = row_strings[::-1] for row in row_strings: st_out += row + '\n' else: for row in row_strings: st_out += r...
matrix = [[dot == '#' for dot in line.strip()] for line in open('input.txt')] diffs = [(x, y) for x in (-1, 0, 1) for y in (-1, 0, 1) if (x, y) != (0, 0)] corners = [(x, y) for x in (0, len(matrix)-1) for y in (0, len(matrix[0])-1)] for x, y in corners: matrix[x][y] = True def neighbors(matrix, x, y): for i, j...
matrix = [[dot == '#' for dot in line.strip()] for line in open('input.txt')] diffs = [(x, y) for x in (-1, 0, 1) for y in (-1, 0, 1) if (x, y) != (0, 0)] corners = [(x, y) for x in (0, len(matrix) - 1) for y in (0, len(matrix[0]) - 1)] for (x, y) in corners: matrix[x][y] = True def neighbors(matrix, x, y): fo...
def multiply(a, b): c = [[0] * 3 for _ in range(3)] for i in range(3): for j in range(3): for k in range(3): c[i][j] += a[i][k] * b[k][j] return c q = int(input()) for _ in range(q): x, y, z, t = input().split() x = float(x) y = float(y) z = float(z) ...
def multiply(a, b): c = [[0] * 3 for _ in range(3)] for i in range(3): for j in range(3): for k in range(3): c[i][j] += a[i][k] * b[k][j] return c q = int(input()) for _ in range(q): (x, y, z, t) = input().split() x = float(x) y = float(y) z = float(z) ...
# Exercise 3.1: Rewrite your pay computation to give the employee 1.5 times the # rate for hours worked above 40 hours. # Enter Hours: 45 # Enter Rate: 10 # Pay: 475.0 # Python for Everybody: Exploring Data Using Python 3 # by Charles R. Severance hours = float(input("Enter hours: ")) rate_per_hour = float(input("En...
hours = float(input('Enter hours: ')) rate_per_hour = float(input('Enter rate per hour: ')) additional_hours = hours - 40 gross_pay = 0 if additional_hours > 0: hours_with_rate_per_hour = hours - additional_hours gross_pay = hours_with_rate_per_hour * rate_per_hour modified_rate_per_hour = rate_per_hour * 1...
class BaseEmployee(): "The base class for an employee." # Note: Unlike c#, on initiliazing a child class, the base contructor is not called # unless specifically called. def __init__(self, id, city): "Constructor for the base employee class." print('Base constructor called.'); s...
class Baseemployee: """The base class for an employee.""" def __init__(self, id, city): """Constructor for the base employee class.""" print('Base constructor called.') self.id = id self.city = city def __del__(self): """Will be called on destruction of employee obj...
ix.enable_command_history() app = ix.application clarisse_win = app.get_event_window() ix.application.open_edit_color_space_window(clarisse_win) ix.disable_command_history()
ix.enable_command_history() app = ix.application clarisse_win = app.get_event_window() ix.application.open_edit_color_space_window(clarisse_win) ix.disable_command_history()
distanca = int(input()) tempo = (2 * distanca) print('%d minutos' %tempo)
distanca = int(input()) tempo = 2 * distanca print('%d minutos' % tempo)
def sayhello(name=None): if name is None: return "Hello World, Everyone!" else: return f"Hello World, {name}"
def sayhello(name=None): if name is None: return 'Hello World, Everyone!' else: return f'Hello World, {name}'
def imgcd(m,n): for i in range(1,min(m,n)+1): if m%i==0 and n%i==0: mcrf=i return mcrf a=input() b=input() c=imgcd(int(a),int(b)) print(c)
def imgcd(m, n): for i in range(1, min(m, n) + 1): if m % i == 0 and n % i == 0: mcrf = i return mcrf a = input() b = input() c = imgcd(int(a), int(b)) print(c)
class Tape(object): blank = " " def __init__(self, tape): self.tape = tape self.head = 0
class Tape(object): blank = ' ' def __init__(self, tape): self.tape = tape self.head = 0
'''' Problem: Determine if two strings are permutations. Assumptions: String is composed of lower 128 ASCII characters. Capitalization matters. ''' def isPerm(s1, s2): if len(s1) != len(s2): return False arr1 = [0] * 128 arr2 = [0] * 128 for c, d in zip(s1, s2): arr1[ord(c...
"""' Problem: Determine if two strings are permutations. Assumptions: String is composed of lower 128 ASCII characters. Capitalization matters. """ def is_perm(s1, s2): if len(s1) != len(s2): return False arr1 = [0] * 128 arr2 = [0] * 128 for (c, d) in zip(s1, s2): arr1[ord(c)] += 1 ...
#Write a function to find the longest common prefix string amongst an array of strings. #If there is no common prefix, return an empty string "". def longest_common_prefix(strs) -> str: common = "" strs.sort() for i in range(0, len(strs[0])): if strs[0][i] == strs[-1][i]: common +=...
def longest_common_prefix(strs) -> str: common = '' strs.sort() for i in range(0, len(strs[0])): if strs[0][i] == strs[-1][i]: common += strs[0][i] if strs[0][i] != strs[-1][i]: break return common print(longest_common_prefix(['flow', 'flower', 'flowing']))
def target_file(): return ".html" def target_domain(): return "https://lyricsmania.com/" def artist_query(name): return target_domain() + str.lower(name) + "_lyrics" + target_file() if __name__ == "__main__": print(artist_query("Lizzo"))
def target_file(): return '.html' def target_domain(): return 'https://lyricsmania.com/' def artist_query(name): return target_domain() + str.lower(name) + '_lyrics' + target_file() if __name__ == '__main__': print(artist_query('Lizzo'))
load("@bazel_skylib//lib:paths.bzl", "paths") GlslLibraryInfo = provider("Set of GLSL header files", fields = ["hdrs", "includes"]) SpirvLibraryInfo = provider("Set of Spirv files", fields = ["spvs", "includes"]) def _export_headers(ctx, virtual_header_prefix): strip_include_prefix = ctx.attr.strip_include_prefix...
load('@bazel_skylib//lib:paths.bzl', 'paths') glsl_library_info = provider('Set of GLSL header files', fields=['hdrs', 'includes']) spirv_library_info = provider('Set of Spirv files', fields=['spvs', 'includes']) def _export_headers(ctx, virtual_header_prefix): strip_include_prefix = ctx.attr.strip_include_prefix ...
node = S(input, "application/json") node.prop("comment", "42!") propertyNode = node.prop("comment") value = propertyNode.stringValue()
node = s(input, 'application/json') node.prop('comment', '42!') property_node = node.prop('comment') value = propertyNode.stringValue()
def moeda(funcao, moeda='R$'): return f'{moeda}{funcao:.2f}'.replace('.', ',') def aumentar(p, taxa): res = p * (1 + taxa/100) return res def diminuir(p, taxa): res = p * (1 - taxa/100) return res def dobro(p): res = p * 2 return res def metade(p): res = p / 2 return res
def moeda(funcao, moeda='R$'): return f'{moeda}{funcao:.2f}'.replace('.', ',') def aumentar(p, taxa): res = p * (1 + taxa / 100) return res def diminuir(p, taxa): res = p * (1 - taxa / 100) return res def dobro(p): res = p * 2 return res def metade(p): res = p / 2 return res
class Solution: def naive(self,root): self.res = 0 def dfs(tree,s): s_ = s*10+tree.val if tree.left==None and tree.right==None: self.res+=s_ return if tree.left: dfs(tree.left,s_) if tree.right: ...
class Solution: def naive(self, root): self.res = 0 def dfs(tree, s): s_ = s * 10 + tree.val if tree.left == None and tree.right == None: self.res += s_ return if tree.left: dfs(tree.left, s_) if tree.r...
class Solution: def getSmallestString(self, n: int, k: int) -> str: op=['a']*n k=k-n i=n-1 while k: k+=1 if k/26>=1: op[i]='z' i-=1 k=k-26 else: op[i]=chr(k+96) k=0 ...
class Solution: def get_smallest_string(self, n: int, k: int) -> str: op = ['a'] * n k = k - n i = n - 1 while k: k += 1 if k / 26 >= 1: op[i] = 'z' i -= 1 k = k - 26 else: op[i] = ch...
def summation(n,term): total,k=0,1 while k<=n: total,k = term(k) + total, k+1 return total def square(x): return x*x def pi_summantion(n): return summation(n, lambda x: 8 / ((4*x-3) * (4*x-1))) def suqare_summantio(n): return summation(n, square) print(pi_summantion(1e6)) print(s...
def summation(n, term): (total, k) = (0, 1) while k <= n: (total, k) = (term(k) + total, k + 1) return total def square(x): return x * x def pi_summantion(n): return summation(n, lambda x: 8 / ((4 * x - 3) * (4 * x - 1))) def suqare_summantio(n): return summation(n, square) print(pi_s...
class PhotoAlbum: def __init__(self, pages: int): self.pages = pages self.photos = [[] for _ in range(self.pages)] @classmethod def from_photos_count(cls, photos_count: int): pages_count = photos_count // 4 if photos_count % 4 != 0: pages_count += 1 retur...
class Photoalbum: def __init__(self, pages: int): self.pages = pages self.photos = [[] for _ in range(self.pages)] @classmethod def from_photos_count(cls, photos_count: int): pages_count = photos_count // 4 if photos_count % 4 != 0: pages_count += 1 retu...
print('hii'+str(5)) print(int(8)+5); print(float(8.5)+5); print(int(8.5)+5); #print(int('C'))
print('hii' + str(5)) print(int(8) + 5) print(float(8.5) + 5) print(int(8.5) + 5)
def compare(v1, operator, v2): if operator == ">": return v1 > v2 elif operator == "<": return v1 < v2 elif operator == ">=": return v1 >= v2 elif operator == "<=": return v1 <= v2 elif operator == "=" or "==": return v1 == v2 elif operator == "!=": ...
def compare(v1, operator, v2): if operator == '>': return v1 > v2 elif operator == '<': return v1 < v2 elif operator == '>=': return v1 >= v2 elif operator == '<=': return v1 <= v2 elif operator == '=' or '==': return v1 == v2 elif operator == '!=': ...
#pythran export fib_pythran(int) def fib_pythran(n): i, sum, last, curr = 0, 0, 0, 1 if n <= 2: return 1 while i < n - 1: sum = last + curr last = curr curr = sum i += 1 return sum #pythran export count_doubles_pythran_zip(str, int) def count_doubles_pythran_zip...
def fib_pythran(n): (i, sum, last, curr) = (0, 0, 0, 1) if n <= 2: return 1 while i < n - 1: sum = last + curr last = curr curr = sum i += 1 return sum def count_doubles_pythran_zip(val, n): total = 0 for (c1, c2) in zip(val, val[1:]): if c1 == c2...
# # PySNMP MIB module PNNI-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PNNI-EXT-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:41:07 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,...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, constraints_union, value_range_constraint, single_value_constraint, value_size_constraint) ...
# flake8: noqa bm25 = BatchRetrieve(index, "BM25") axiom = (ArgUC() & QTArg() & QTPArg()) | ORIG() # Re-rank top-20 documents with KwikSort. kwiksort = bm25 % 20 >> \ KwikSortReranker(axiom, index) pipeline = kwiksort ^ bm25
bm25 = batch_retrieve(index, 'BM25') axiom = arg_uc() & qt_arg() & qtp_arg() | orig() kwiksort = bm25 % 20 >> kwik_sort_reranker(axiom, index) pipeline = kwiksort ^ bm25
ciphertext = "WAPSD EXTCO EEREF SELIO RSARC LIETE OIHHP VASTF EGBER IPAPN TOEGI AIATH DDHIY EACYE RQAEN OHRTE TEVME BGHMF EIOWS GFHCL XEUUC OMTOT LERES SDEWW ORCCS HEURE ATTEG ALSEB APXET IURWV RTEEH IOTLO SNACN NULCV LCMTH HHCOH TIOTD ASNAL TSANA CASOR LEKAS TATCW INTLO TRYER YLTND RILER AOMAX OITDE ECOIA HAALS TYIOA ...
ciphertext = 'WAPSD EXTCO EEREF SELIO RSARC LIETE OIHHP VASTF EGBER IPAPN TOEGI AIATH DDHIY EACYE RQAEN OHRTE TEVME BGHMF EIOWS GFHCL XEUUC OMTOT LERES SDEWW ORCCS HEURE ATTEG ALSEB APXET IURWV RTEEH IOTLO SNACN NULCV LCMTH HHCOH TIOTD ASNAL TSANA CASOR LEKAS TATCW INTLO TRYER YLTND RILER AOMAX OITDE ECOIA HAALS TYIOA ...
class PractitionerTemplate: def __init__(self): super().__init__() def practitioner_default(self, data_list): keys = [] for data in data_list: key = f"{data.get('rowid')},{data.get('employee_id')}" keys.append(key) return keys
class Practitionertemplate: def __init__(self): super().__init__() def practitioner_default(self, data_list): keys = [] for data in data_list: key = f"{data.get('rowid')},{data.get('employee_id')}" keys.append(key) return keys
def update_bit(num, bit, value): mask = ~(1 << bit) return (num & mask) | (value << bit) def get_bit(num, bit): return (num & (1 << bit)) != 0 def insert_bits(n, m, i, j): for bit in range(i, j + 1): n = update_bit(n, bit, get_bit(m, bit - i)) return n def insert_bits_mask(n, m, i, j): mask = (~0 ...
def update_bit(num, bit, value): mask = ~(1 << bit) return num & mask | value << bit def get_bit(num, bit): return num & 1 << bit != 0 def insert_bits(n, m, i, j): for bit in range(i, j + 1): n = update_bit(n, bit, get_bit(m, bit - i)) return n def insert_bits_mask(n, m, i, j): mask =...
nodes = [[1,3], [0,2], [1,3], [0,2]] otherNodes = [[1,2,3], [0,2], [0,1,3], [0,2]] def isBipartite(nodes): colors = [0] * len(nodes) for index, node in enumerate(nodes): if colors[index] == 0 and not properColor(nodes, colors, 1, index): return False return True def properColor(graph, colors, color, n...
nodes = [[1, 3], [0, 2], [1, 3], [0, 2]] other_nodes = [[1, 2, 3], [0, 2], [0, 1, 3], [0, 2]] def is_bipartite(nodes): colors = [0] * len(nodes) for (index, node) in enumerate(nodes): if colors[index] == 0 and (not proper_color(nodes, colors, 1, index)): return False return True def pr...
manipulated_string = input() while True: line = input() if line == "end": break command_element = line.split(' ') command = command_element[0] first_condition = int(command_element[1]) if command == 'Right': for i in range(first_condition): manipulated_string = manipu...
manipulated_string = input() while True: line = input() if line == 'end': break command_element = line.split(' ') command = command_element[0] first_condition = int(command_element[1]) if command == 'Right': for i in range(first_condition): manipulated_string = manipu...
c = {a: 1, b: 2} fun(a, b, **c) # EXPECTED: [ ..., LOAD_NAME('fun'), ..., BUILD_TUPLE(2), ..., CALL_FUNCTION_EX(1), ..., ]
c = {a: 1, b: 2} fun(a, b, **c) [..., load_name('fun'), ..., build_tuple(2), ..., call_function_ex(1), ...]
entrada = 'Gilberto' saida = '{:+^12}'.format(entrada) print(saida) entrada = 'sensoriamento remoto' saida = entrada.capitalize() print(saida) entrada = 'sensoriamento remoto' saida = entrada.title() print(saida) entrada = 'GilberTo' saida = entrada.lower() print(saida) entrada = 'Gilberto' saida =...
entrada = 'Gilberto' saida = '{:+^12}'.format(entrada) print(saida) entrada = 'sensoriamento remoto' saida = entrada.capitalize() print(saida) entrada = 'sensoriamento remoto' saida = entrada.title() print(saida) entrada = 'GilberTo' saida = entrada.lower() print(saida) entrada = 'Gilberto' saida = '{:*<10}'.format(ent...
n = int(input()) l = {} for i in range(n): k = input() if k in l: l[k] += 1 else: l[k] = 1 print(len(l)) for i in l: print(l[i], end=" ")
n = int(input()) l = {} for i in range(n): k = input() if k in l: l[k] += 1 else: l[k] = 1 print(len(l)) for i in l: print(l[i], end=' ')
# @Time: 2022/4/12 20:29 # @Author: chang liu # @Email: chang_liu_tamu@gmail.com # @File:4-3-Creating-New-Iteration-Patterns-With-Generators.py def frange(start, stop, increment): x = start while x < stop: yield x x += increment # for n in frange(1, 5, 0.6): # print(n) def countdown(n):...
def frange(start, stop, increment): x = start while x < stop: yield x x += increment def countdown(n): print(f'starting counting from {n}') while n > 0: yield n n -= 1 print('Done') g = countdown(3) print(next(g)) print(next(g)) print(next(g)) print('*' * 30) i = ite...
# https://leetcode.com/explore/learn/card/fun-with-arrays/527/searching-for-items-in-an-array/3251/ class Solution: def validMountainArray(self, arr: List[int]) -> bool: inc = True incd = False decd = False for i,elmnt in enumerate(arr): if i == 0:continue if ...
class Solution: def valid_mountain_array(self, arr: List[int]) -> bool: inc = True incd = False decd = False for (i, elmnt) in enumerate(arr): if i == 0: continue if inc == True and arr[i] > arr[i - 1]: incd = True ...
def get_input() -> list: with open(f"{__file__.rstrip('code.py')}input.txt") as f: return [int(l[:-1]) for l in f.readlines()] def has_pair(sum_val: int, vals: list) -> bool: for idx_i, i in enumerate(vals): for j in vals[idx_i+1:]: if i + j == sum_val: return True ...
def get_input() -> list: with open(f"{__file__.rstrip('code.py')}input.txt") as f: return [int(l[:-1]) for l in f.readlines()] def has_pair(sum_val: int, vals: list) -> bool: for (idx_i, i) in enumerate(vals): for j in vals[idx_i + 1:]: if i + j == sum_val: return Tr...
n = int(input()) arr = [int(x) for x in input().split()] counter = [0]*1001 for i in range(n): counter[arr[i]] += 1 counts = [] for i in range(1001): if counter[i] > 0: counts.append((counter[i],i)) counts.sort(key=lambda x: (-x[0], x[1])) q = [] for freq,i in counts: q.extend([i]*freq) j = 0 o...
n = int(input()) arr = [int(x) for x in input().split()] counter = [0] * 1001 for i in range(n): counter[arr[i]] += 1 counts = [] for i in range(1001): if counter[i] > 0: counts.append((counter[i], i)) counts.sort(key=lambda x: (-x[0], x[1])) q = [] for (freq, i) in counts: q.extend([i] * freq) j = ...
def testIter(encoder, decoder, sentence, word2ix, ix2word, max_length=20): input_variable = sentence input_length = input_variable.size()[0] encoder_hidden = encoder.initHidden() encoder_outputs = Variable(torch.zeros(max_length, encoder.hidden_size)) if use_cuda: encoder_outputs = encoder_outputs.cuda() for ...
def test_iter(encoder, decoder, sentence, word2ix, ix2word, max_length=20): input_variable = sentence input_length = input_variable.size()[0] encoder_hidden = encoder.initHidden() encoder_outputs = variable(torch.zeros(max_length, encoder.hidden_size)) if use_cuda: encoder_outputs = encoder_...
#!/usr/bin/python ''' From careercup.com Write a pattern matching function using wild char ? Matches any char exactly one instance * Matches one or more instances of previous char Ex text = "abcd" pattern = "ab?d" True Ex text = "abccdddef" pattern = "ab?*f" True Ex text = "abccd" pattern = "ab?*ccd" false (a...
""" From careercup.com Write a pattern matching function using wild char ? Matches any char exactly one instance * Matches one or more instances of previous char Ex text = "abcd" pattern = "ab?d" True Ex text = "abccdddef" pattern = "ab?*f" True Ex text = "abccd" pattern = "ab?*ccd" false (added missing cases,...
frase = str(input('Digite uma frase:\n->')).strip() separado = frase.split() junto = ''.join(separado) correto = list(junto.upper()) invertido = list(reversed(junto.upper())) print(correto) print(invertido) if correto == invertido: print('verdadeiro') else: print('falso')
frase = str(input('Digite uma frase:\n->')).strip() separado = frase.split() junto = ''.join(separado) correto = list(junto.upper()) invertido = list(reversed(junto.upper())) print(correto) print(invertido) if correto == invertido: print('verdadeiro') else: print('falso')
# Copied from https://rosettacode.org/wiki/Trabb_Pardo%E2%80%93Knuth_algorithm#Python def f(x): return abs(x) ** 0.5 + 5 * x**3 def ask(): return [float(y) for y in input('\n11 numbers: ').strip().split()[:11]] if __name__ == '__main__': s = ask() s.reverse() for x in s: resu...
def f(x): return abs(x) ** 0.5 + 5 * x ** 3 def ask(): return [float(y) for y in input('\n11 numbers: ').strip().split()[:11]] if __name__ == '__main__': s = ask() s.reverse() for x in s: result = f(x) if result > 400: print(' %s:%s' % (x, 'TOO LARGE!'), end='') ...
def toBaseTen(n, base): ''' This function takes arguments: number that you want to convert and its base It will return an int in base 10 Examples: .................. >>> toBaseTen(2112, 3) 68 .................. >>> toBaseTen('AB12', 12) 61904 .................. >>> toBaseTen('AB12', 16) 111828 ..............
def to_base_ten(n, base): """ This function takes arguments: number that you want to convert and its base It will return an int in base 10 Examples: .................. >>> toBaseTen(2112, 3) 68 .................. >>> toBaseTen('AB12', 12) 61904 .................. >>> toBaseTen('AB12', 16) 111828 .........
vc = float(input('Qual o valor da casa: R$')) s = float(input('Qual o seu salario')) a = int(input('Em quantos anos voce quer pagar :')) m = a * 12 p = vc/m if s*(30/100) >= p : print ('O emprestimo sera feito em {} anos com prestacoes mensais de R${:.2f} e foi aprovado '.format(a,p)) else: print(' Emprestimo ...
vc = float(input('Qual o valor da casa: R$')) s = float(input('Qual o seu salario')) a = int(input('Em quantos anos voce quer pagar :')) m = a * 12 p = vc / m if s * (30 / 100) >= p: print('O emprestimo sera feito em {} anos com prestacoes mensais de R${:.2f} e foi aprovado '.format(a, p)) else: print(' Emprest...
grid = [ [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0], ] goal = [len(grid) - 1, len(grid[0]) - 1] cost = 1 # the cost associated with moving from a cell to an adjacent one delta = [ [-1, 0], # go up [0, -1], # go left [1, 0], # g...
grid = [[0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 1, 0, 0, 0, 0], [0, 0, 0, 0, 1, 0]] goal = [len(grid) - 1, len(grid[0]) - 1] cost = 1 delta = [[-1, 0], [0, -1], [1, 0], [0, 1]] delta_name = ['^', '<', 'v', '>'] def compute_value(grid, goal, cost): value = [[99 for row in range(len(grid[0]))...
## Read input as specified in the question. ## Print output as specified in the question. # Pattern 1-212-32123... # Reading number of rows row = int(input()) # Generating pattern for i in range(1,row+1): # for space for j in range(1, row+1-i): print(' ', end='') # for decreasing pattern...
row = int(input()) for i in range(1, row + 1): for j in range(1, row + 1 - i): print(' ', end='') for j in range(i, 0, -1): print(j, end='') for j in range(2, i + 1): print(j, end='') print()
#!/usr/bin/env python # -*- coding: utf-8 -*- def run(): print("run") main() return None def aaa(): print("aaa") return None def main():# print ("Hello, test is running") if __name__ == '__main__': main()
def run(): print('run') main() return None def aaa(): print('aaa') return None def main(): print('Hello, test is running') if __name__ == '__main__': main()
class GradientBoostingMachine(): def __init__(self, nEstimators = 100): self.nEstimators = nEstimators if __name__ == '__main__': gbm = GradientBoostingMachine(nEstimators=10)
class Gradientboostingmachine: def __init__(self, nEstimators=100): self.nEstimators = nEstimators if __name__ == '__main__': gbm = gradient_boosting_machine(nEstimators=10)
def exp_sum(n): p = n # calculation taken from here # https://math.stackexchange.com/questions/2675382/calculating-integer-partitions def pentagonal_number(k): return int(k * (3 * k - 1) / 2) def compute_partitions(goal): partitions = [1] for n in range(1, goal + 1): ...
def exp_sum(n): p = n def pentagonal_number(k): return int(k * (3 * k - 1) / 2) def compute_partitions(goal): partitions = [1] for n in range(1, goal + 1): partitions.append(0) for k in range(1, n + 1): coeff = (-1) ** (k + 1) ...
def encode_for_get_list(src_data, thats_all_flag, default_keys, items_fetcher, item_handler): if not isinstance(src_data, dict): src_data = {"*": None} result = {} unknown_flag = False for name, value in src_data.items(): if name == "*": for name2 in items_fetcher(): ...
def encode_for_get_list(src_data, thats_all_flag, default_keys, items_fetcher, item_handler): if not isinstance(src_data, dict): src_data = {'*': None} result = {} unknown_flag = False for (name, value) in src_data.items(): if name == '*': for name2 in items_fetcher(): ...
#!/usr/bin/python def generateSet(name, value, type, indentationLevel): finalLine = " "*indentationLevel finalLine += name finalLine += " = " if type == 'string': # Whatever you use for defining strings (either single, double, etc.) finalLine += '"' + value + '"' else: f...
def generate_set(name, value, type, indentationLevel): final_line = ' ' * indentationLevel final_line += name final_line += ' = ' if type == 'string': final_line += '"' + value + '"' else: final_line += value final_line += '\n' return finalLine def generate_if(comparison,...
# # PySNMP MIB module SIP-COMMON-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SIP-COMMON-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:04: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 2...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, value_range_constraint, constraints_intersection, constraints_union, single_value_constraint) ...
if 3 > 4 or 5 < 10: # true pass if 3 > 4 or 5 > 10: # false pass
if 3 > 4 or 5 < 10: pass if 3 > 4 or 5 > 10: pass
class Solution: # Runtime: 36 ms # Memory Usage: 16.3 MB def maxDepth(self, root: TreeNode) -> int: if root is None: return 0 return self.search(root, 0) def search(self, node, depth): depth += 1 depth_left = depth depth_right = depth ...
class Solution: def max_depth(self, root: TreeNode) -> int: if root is None: return 0 return self.search(root, 0) def search(self, node, depth): depth += 1 depth_left = depth depth_right = depth if node.left is not None: depth_left = self...
# Write a program that uses a for loop to print the numbers 8, 11, 14, 17, 20, ..., 83, 86, 89. for i in range(8, 90, 3): print(i)
for i in range(8, 90, 3): print(i)
puzzle_input = "359282-820401" pwd_interval = [int(a) for a in puzzle_input.split('-')] pwd_range = range(pwd_interval[0] , pwd_interval[1]+1) # Part 1 def is_valid_pwd(code): str_code = str(code) double = False increase = True for i in range(5): if str_code[i] == str_code[i+1]: do...
puzzle_input = '359282-820401' pwd_interval = [int(a) for a in puzzle_input.split('-')] pwd_range = range(pwd_interval[0], pwd_interval[1] + 1) def is_valid_pwd(code): str_code = str(code) double = False increase = True for i in range(5): if str_code[i] == str_code[i + 1]: double = ...