content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
DEBUG = True PORT = 8080 SECRET_KEY = "secret" WTF_CSRF_ENABLED = True baseUrl = "https://hp8xm3yzr0.execute-api.us-east-2.amazonaws.com/prod/"
debug = True port = 8080 secret_key = 'secret' wtf_csrf_enabled = True base_url = 'https://hp8xm3yzr0.execute-api.us-east-2.amazonaws.com/prod/'
class DigestConfig: def __init__(self): self.digest_AAs = "KR" self.Nterm = False self.min_len = 9 self.max_len = 30 self.max_miss_cleave = 2 self.cleave_type = "full" def digest(protein, pepset, conf): if conf.cleave_type == "full": return digest_full(...
class Digestconfig: def __init__(self): self.digest_AAs = 'KR' self.Nterm = False self.min_len = 9 self.max_len = 30 self.max_miss_cleave = 2 self.cleave_type = 'full' def digest(protein, pepset, conf): if conf.cleave_type == 'full': return digest_full(p...
def split(str): splitted=str.split(" ") return splitted def join(str): joined="-".join(str) return joined str="Geeks For Geeks" splitted=split(str) print(splitted) print(join(splitted))
def split(str): splitted = str.split(' ') return splitted def join(str): joined = '-'.join(str) return joined str = 'Geeks For Geeks' splitted = split(str) print(splitted) print(join(splitted))
def stage(hub, name): ''' Take the highdata and reconcoile the extend keyword ''' high, errors = hub.idem.extend.reconcile(hub.idem.RUNS[name]['high']) hub.idem.RUNS[name]['high'] = high hub.idem.RUNS[name]['errors'] = errors
def stage(hub, name): """ Take the highdata and reconcoile the extend keyword """ (high, errors) = hub.idem.extend.reconcile(hub.idem.RUNS[name]['high']) hub.idem.RUNS[name]['high'] = high hub.idem.RUNS[name]['errors'] = errors
# Formatting configuration for locale sv_SE languages={'gv': 'manx gaeliska', 'gu': 'gujarati', 'rom': 'romani', 'ale': 'aleutiska', 'sco': 'skotska', 'mni': 'manipuri', 'gd': 'skotsk gaeliska', 'ga': u'irl\xe4ndsk gaeliska', 'osa': 'osage', 'gn': u'guaran\xed', 'gl': 'galiciska', 'mwr': 'marwari', 'ty': 'tahitiska', ...
languages = {'gv': 'manx gaeliska', 'gu': 'gujarati', 'rom': 'romani', 'ale': 'aleutiska', 'sco': 'skotska', 'mni': 'manipuri', 'gd': 'skotsk gaeliska', 'ga': u'irländsk gaeliska', 'osa': 'osage', 'gn': u'guaraní', 'gl': 'galiciska', 'mwr': 'marwari', 'ty': 'tahitiska', 'tw': 'twi', 'tt': 'tatariska', 'tr': 'turkiska',...
N = int(input()) count = 0 for i in range(1, N+1, 2): yakusuu = 0 for j in range(1, i+1, 2): if i % j == 0: yakusuu += 1 if yakusuu == 8: count += 1 print(count)
n = int(input()) count = 0 for i in range(1, N + 1, 2): yakusuu = 0 for j in range(1, i + 1, 2): if i % j == 0: yakusuu += 1 if yakusuu == 8: count += 1 print(count)
class reverse_iter: def __init__(self, elements): self.elements = elements self.start = len(self.elements) - 1 def __iter__(self): return self def __next__(self): if self.start < 0: raise StopIteration index = self.start self.start -= 1 ...
class Reverse_Iter: def __init__(self, elements): self.elements = elements self.start = len(self.elements) - 1 def __iter__(self): return self def __next__(self): if self.start < 0: raise StopIteration index = self.start self.start -= 1 ...
# syms =['["2_x00"]', '["2_0y0"]', '["2_00z"]', # '["2_xx0"]', '["2_x0x"]', '["2_0yy"]', # '["2_xmx0"]', '["2_mx0x"]', '["2_0myy"]', # # '["3_xxx"]', '["3_xmxmx"]', # '["3_mxxmx"]', '["3_mxmxx"]', # # '["m3_xxx"]', '["m3_xmxmx"]', # '["m3_mxxmx"]', '["m3_mxmxx"]', # # '["4_x00"]', '["4_0y0"]', '["4_00z"]', # # '["-4_x0...
syms_hex = ['["i_000"]', '["hex_m_x2xz"]', '["hex_m_2xxz"]', '["hex_m_x0z"]', '["hex_m_0yz"]', '["hex_2_x00"]', '["hex_2_0y0"]', '["hex_2_x2x0"]', '["hex_2_2xx0"]', '["3_00z"]', '["m3_00z"]', '["6_00z"]', '["m6_00z"]'] text = 'import matrices_new_extended as mne\nimport numpy as np\nimport sympy as sp\nfrom equality_ch...
class NetstorageError(Exception): def __init__(self, response, *args, **kwargs): super(NetstorageError, self).__init__(response) self.msg = kwargs.get('message') class NotFoundError(NetstorageError): def __init__(self, response, *args, **kwargs): message = ('Can occur if the targeted ...
class Netstorageerror(Exception): def __init__(self, response, *args, **kwargs): super(NetstorageError, self).__init__(response) self.msg = kwargs.get('message') class Notfounderror(NetstorageError): def __init__(self, response, *args, **kwargs): message = 'Can occur if the targeted o...
# numbers to letters small = ['zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen'] tens = ['mistake0','mistake1','twenty','thirty','forty','fifty','sixty','seventy','eighty','ninety'] # simple algori...
small = ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen', 'sixteen', 'seventeen', 'eighteen', 'nineteen'] tens = ['mistake0', 'mistake1', 'twenty', 'thirty', 'forty', 'fifty', 'sixty', 'seventy', 'eighty', 'ninety'] def conver...
ALPHABET = 'abcdefghijklmnopqrstuvwxyz' def increment(word: str) -> str: last_index = len(word) - 1 if word[last_index] != 'z': return word[:last_index] + ALPHABET[ALPHABET.find(word[last_index]) + 1] elif len(word) == 1: return "aa" else: return increment(word[:last_index]) + ...
alphabet = 'abcdefghijklmnopqrstuvwxyz' def increment(word: str) -> str: last_index = len(word) - 1 if word[last_index] != 'z': return word[:last_index] + ALPHABET[ALPHABET.find(word[last_index]) + 1] elif len(word) == 1: return 'aa' else: return increment(word[:last_index]) + '...
DB_CONFIG_DEV = {'host': 'host', 'usuario':'usr_pesquisabr', 'senha':'senhapesquisabr', 'database': 'pesquisabr' } DB_CONFIG_PROD = {'host': 'host', 'usuario':'usr_pesquisabr', 'senha':'senhapesquisabr', 'database': 'pesquisabr' } ...
db_config_dev = {'host': 'host', 'usuario': 'usr_pesquisabr', 'senha': 'senhapesquisabr', 'database': 'pesquisabr'} db_config_prod = {'host': 'host', 'usuario': 'usr_pesquisabr', 'senha': 'senhapesquisabr', 'database': 'pesquisabr'}
def diag_diff(matr): sum1 = 0 sum2 = 0 length = len(matr[0]) for i in range(length): for j in range(length): if i == j: sum1 = sum1 + matr[i][j] if i == length - j - 1: sum2 = sum2 + matr[i][j] return sum1 - sum2
def diag_diff(matr): sum1 = 0 sum2 = 0 length = len(matr[0]) for i in range(length): for j in range(length): if i == j: sum1 = sum1 + matr[i][j] if i == length - j - 1: sum2 = sum2 + matr[i][j] return sum1 - sum2
# # PySNMP MIB module HH3C-DOT11-RRM-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-DOT11-RRM-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:26:18 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, single_value_constraint, value_range_constraint, constraints_intersection) ...
change = 91 coin = 25 print('how many quarters in 91 cents? 3') print('how much change is left after 3 quarters taken out of 91cents? 16') print(91 / 25, 'is not the awnser to either question') print(91//25) print(91%25)
change = 91 coin = 25 print('how many quarters in 91 cents? 3') print('how much change is left after 3 quarters taken out of 91cents? 16') print(91 / 25, 'is not the awnser to either question') print(91 // 25) print(91 % 25)
a = input("Enter a number: ") prev = None flag = True if len(a)==1: flag = False for elm in a: if prev == None: prev = int(elm) else: if prev > int(elm): prev = int(elm) else: flag = False break print(flag)
a = input('Enter a number: ') prev = None flag = True if len(a) == 1: flag = False for elm in a: if prev == None: prev = int(elm) elif prev > int(elm): prev = int(elm) else: flag = False break print(flag)
BATTERY_UUID = "0000ec08-0000-1000-8000-00805f9b34fb" DEVICE_USER_NAME_UUID = "0000ec01-0000-1000-8000-00805f9b34fb" UPDATED_AT_UUID = "0000ec09-0000-1000-8000-00805f9b34fb" MODEL_NUMBER_UUID = "00002a24-0000-1000-8000-00805f9b34fb" MANUFACTURER_UUID = "00002a29-0000-1000-8000-00805f9b34fb" VALVE_MANUAL_SETTINGS_UUID ...
battery_uuid = '0000ec08-0000-1000-8000-00805f9b34fb' device_user_name_uuid = '0000ec01-0000-1000-8000-00805f9b34fb' updated_at_uuid = '0000ec09-0000-1000-8000-00805f9b34fb' model_number_uuid = '00002a24-0000-1000-8000-00805f9b34fb' manufacturer_uuid = '00002a29-0000-1000-8000-00805f9b34fb' valve_manual_settings_uuid =...
# CSC 110 - Practice Activity #2 # Tip Calculator # Section 03 # Justin Clark # 1/14/2020 # input billAmountEntered = float(input('Enter bill amount $: ')) tipPercentEntered = float(input('Enter tip %: ')) # processing tipCalculated = billAmountEntered * (tipPercentEntered / 100) amountToPay = billAmountEntered + tip...
bill_amount_entered = float(input('Enter bill amount $: ')) tip_percent_entered = float(input('Enter tip %: ')) tip_calculated = billAmountEntered * (tipPercentEntered / 100) amount_to_pay = billAmountEntered + tipCalculated receipt = '--------------------------' + '\n' + 'Receipt\n-------------------' + '\n' + 'Bill E...
# -*- coding: utf-8 -*- __version__ = (1, 0, 0) default_app_config = "taiga_contrib_fan.apps.TaigaContribFanAppConfig"
__version__ = (1, 0, 0) default_app_config = 'taiga_contrib_fan.apps.TaigaContribFanAppConfig'
i = 0 n = int(input()) while (n > 0): i += n n -= 1 print('Sum is',i)
i = 0 n = int(input()) while n > 0: i += n n -= 1 print('Sum is', i)
class Point: def __init__(self, x, y): self._cluster = 0 # Not classified yet self._visited = False self._x = x self._y = y def get_cluster(self): return self._cluster def set_cluster(self, cluster): self._cluster = cluster def get_values(...
class Point: def __init__(self, x, y): self._cluster = 0 self._visited = False self._x = x self._y = y def get_cluster(self): return self._cluster def set_cluster(self, cluster): self._cluster = cluster def get_values(self): return (self._x, se...
#! /usr/bin/env python3 def add_verticle(a, b) : global verticles if a in verticles : verticles[a].append(b) else : verticles[a] = [b] return verticles def all_paths_util(u, path = []) : global verticles if u in path and not u.upper() == u : return [] path.append(u) if u == 'end...
def add_verticle(a, b): global verticles if a in verticles: verticles[a].append(b) else: verticles[a] = [b] return verticles def all_paths_util(u, path=[]): global verticles if u in path and (not u.upper() == u): return [] path.append(u) if u == 'end': re...
class Solution: def totalHammingDistance(self, nums: List[int]) -> int: total = 0 for b in zip(*map('{:030b}'.format, nums)): zeros = b.count('0') total += zeros * (len(b) - zeros) return total
class Solution: def total_hamming_distance(self, nums: List[int]) -> int: total = 0 for b in zip(*map('{:030b}'.format, nums)): zeros = b.count('0') total += zeros * (len(b) - zeros) return total
# # PySNMP MIB module HUAWEI-VO-GENERAL-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-VO-GENERAL-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:49:30 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (def...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ...
#!/usr/bin/env python3 # Day 22: Subarray Sum Equals K # # Given an array of integers and an integer k, you need to find the total # number of continuous subarrays whose sum equals to k. class Solution: def subarraySum(self, nums: [int], k: int) -> int: count = 0 ways_to_sum = {} current_s...
class Solution: def subarray_sum(self, nums: [int], k: int) -> int: count = 0 ways_to_sum = {} current_sum = 0 for number in nums: current_sum += number if current_sum == k: count += 1 if current_sum - k in ways_to_sum: ...
gamemat = [0] * 4 for i in range(4): gamemat[i] = [0] * 4 player = 1 gameEnd = False gameResult = None def readInput(currentPlayer): print("Player " + str(currentPlayer) + " (input x and y, seperated with a space): ", end = "") try: x,y = input().split() x = int(x) y = int(y) ex...
gamemat = [0] * 4 for i in range(4): gamemat[i] = [0] * 4 player = 1 game_end = False game_result = None def read_input(currentPlayer): print('Player ' + str(currentPlayer) + ' (input x and y, seperated with a space): ', end='') try: (x, y) = input().split() x = int(x) y = int(y) ...
## # check_if_correct: # def check_if_correct(): ''' @summary reusable while loop to check if alarm time is correct @desc Infinitely loops as long as the user does not input a "Y" or "N" @author Brandon Benefield @since v1.0.0 @param {void} @return {void} ...
def check_if_correct(): """ @summary reusable while loop to check if alarm time is correct @desc Infinitely loops as long as the user does not input a "Y" or "N" @author Brandon Benefield @since v1.0.0 @param {void} @return {void} """ acceptable = False ...
# coding: utf-8 __author__ = 'deff' # Andoid-afl.https://github.com/ele7enxxh/android-afl # Fuzzing with libFuzzer. # Droid: Android application fuzzing framework.https://github.com/ajinabraham/Droid-Application-Fuzz-Framework # Writing the worlds worst Android fuzzer, and then improving it, by Gamozo 2018. # Fuzzing...
__author__ = 'deff'
def pig_latin(text_input): final = "" # create final string, couples, and split text_input couples = ['bl', 'br', 'ch', 'cl', 'cr', 'dr', 'fl', 'fr', 'gh', 'gl', 'gr', 'ph', 'pl', 'pr', 'qu', 'sh', 'sk', 'sl', 'sm', 'sn', 'sp', 'st', 'sw', 'th', 'tr', 'tw', 'wh', 'wr'] split_t...
def pig_latin(text_input): final = '' couples = ['bl', 'br', 'ch', 'cl', 'cr', 'dr', 'fl', 'fr', 'gh', 'gl', 'gr', 'ph', 'pl', 'pr', 'qu', 'sh', 'sk', 'sl', 'sm', 'sn', 'sp', 'st', 'sw', 'th', 'tr', 'tw', 'wh', 'wr'] split_text = text_input.strip().lower().split() for i in range(len(split_text)): ...
lista = [1, 3, 5, 7] lista_animal = ['cachorro', 'gato', 'elefante'] print(lista) print(lista_animal[1]) #Resultado: gato for x in lista_animal: print(x)
lista = [1, 3, 5, 7] lista_animal = ['cachorro', 'gato', 'elefante'] print(lista) print(lista_animal[1]) for x in lista_animal: print(x)
def add(x, y): '''Add two given numbers together ''' return x+y def subtract(x, y): ''' function to substrct x from y and return the remaining value''' return y - x
def add(x, y): """Add two given numbers together """ return x + y def subtract(x, y): """ function to substrct x from y and return the remaining value""" return y - x
# https://leetcode.com/problems/verifying-an-alien-dictionary/ class Solution: def isAlienSorted(self, words: [str], order: str) -> bool: m = {} for i, o in enumerate(order): m[o] = i def is_sorted(w1, w2): for c1, c2 in zip(w1, w2): if ...
class Solution: def is_alien_sorted(self, words: [str], order: str) -> bool: m = {} for (i, o) in enumerate(order): m[o] = i def is_sorted(w1, w2): for (c1, c2) in zip(w1, w2): if m[c1] == m[c2]: continue return m[...
# Character Picture Grid Practice Project # Chapter 4 - Lists (Automate the Boring Stuff with Python) # Developer: Valeriy B. def picture_grid(grid): # Creating result list resulted_list = [] # Looping through grid columns for column in range(len(grid[0])): # Creating row string ...
def picture_grid(grid): resulted_list = [] for column in range(len(grid[0])): row_grid = '' for row in range(len(grid)): row_grid += grid[row][column] resulted_list.append(row_grid + '\n') print(''.join(resulted_list)[:-1]) grid = [['.', '.', '.', '.', '.', '.'], ['.', '0...
def index(query): query = query.strip("/") fd = open("css/" + query, "r") return fd.read()
def index(query): query = query.strip('/') fd = open('css/' + query, 'r') return fd.read()
def outer (): def inner(): print(x ) x = 12 inner() outer()
def outer(): def inner(): print(x) x = 12 inner() outer()
print ("--------------------------------------------------") cad1 = "separar" print (cad1) nuevo_string1 = ",".join(cad1) print (nuevo_string1) print ("--------------------------------------------------") cad2 = "mi archivo de texto.txt" print (cad2) nuevo_string2 = cad2.split() nuevo_string2 = "_".join(nuevo_...
print('--------------------------------------------------') cad1 = 'separar' print(cad1) nuevo_string1 = ','.join(cad1) print(nuevo_string1) print('--------------------------------------------------') cad2 = 'mi archivo de texto.txt' print(cad2) nuevo_string2 = cad2.split() nuevo_string2 = '_'.join(nuevo_string2) print...
def is_even(n): if n % 2 == 0: return True def is_positive(n): if n >= 0: return True def get_result(collection): result = [str(x) for x in collection] return ", ".join(result) numbers = [int(x) for x in input().split(", ")] positive_nums = [] negative_nums = [] even_nums = [] odd_nu...
def is_even(n): if n % 2 == 0: return True def is_positive(n): if n >= 0: return True def get_result(collection): result = [str(x) for x in collection] return ', '.join(result) numbers = [int(x) for x in input().split(', ')] positive_nums = [] negative_nums = [] even_nums = [] odd_nums...
def multi_print(number = 3, word = "Hallo"): for i in range(0, number): print(str(i) + " " + word) multi_print(1, "Hallo") print("--") multi_print() print("--") multi_print(2) print("--") multi_print(word = "Welt") print("--") multi_print(word = "Welt", number = 5) print("--")
def multi_print(number=3, word='Hallo'): for i in range(0, number): print(str(i) + ' ' + word) multi_print(1, 'Hallo') print('--') multi_print() print('--') multi_print(2) print('--') multi_print(word='Welt') print('--') multi_print(word='Welt', number=5) print('--')
class Solution: def longestSubsequence(self, arr: List[int], diff: int) -> int: dp = {} for num in arr: if num - diff in dp: cnt = dp.pop(num - diff) dp[num] = max(dp.get(num, 0), cnt + 1) else: dp[num] = max(dp.get(num, 0), 1) ...
class Solution: def longest_subsequence(self, arr: List[int], diff: int) -> int: dp = {} for num in arr: if num - diff in dp: cnt = dp.pop(num - diff) dp[num] = max(dp.get(num, 0), cnt + 1) else: dp[num] = max(dp.get(num, 0), 1...
numbers = [1, 45, 31, 12, 60] for number in numbers: if number % 8 == 0: print ("THe numbers are unacccepetble") break else: print ("The Numbers are good")
numbers = [1, 45, 31, 12, 60] for number in numbers: if number % 8 == 0: print('THe numbers are unacccepetble') break else: print('The Numbers are good')
class rational: def __init__(self, x, y): gcd = self.__gcd(x, y) self.d = x // gcd # denominator self.n = y // gcd # numerator def __gcd(self, x, y): while y > 0: x, y = y, x % y return x def __add__(self, other): return rational( ...
class Rational: def __init__(self, x, y): gcd = self.__gcd(x, y) self.d = x // gcd self.n = y // gcd def __gcd(self, x, y): while y > 0: (x, y) = (y, x % y) return x def __add__(self, other): return rational(self.n * other.d + self.d * other.n, ...
#module for data updating def update_data_set(text_file_name:str, data:{'Time':int, "Mood":int, "Age":int}, class_res:int): '''Given a text file name and data, it will open the text file and update the file with new data in format "int,int,int" ''' file = open(text_file_name, "a") elements_for_dat...
def update_data_set(text_file_name: str, data: {'Time': int, 'Mood': int, 'Age': int}, class_res: int): """Given a text file name and data, it will open the text file and update the file with new data in format "int,int,int" """ file = open(text_file_name, 'a') elements_for_data_input = ['\n', data...
number_for_fibonacci = int(input("Enter Fibonacci number: ")) first_num = 0 second_num = 1 while second_num <= number_for_fibonacci: print(second_num) first_num, second_num = second_num, first_num + second_num print("Fibonacci number")
number_for_fibonacci = int(input('Enter Fibonacci number: ')) first_num = 0 second_num = 1 while second_num <= number_for_fibonacci: print(second_num) (first_num, second_num) = (second_num, first_num + second_num) print('Fibonacci number')
def collected_materials(key_materials_dict:dict, junk_materials_dict:dict, material:str, quantity:int): if material=="shards" or material=="fragments" or material=="motes": key_materials_dict[material]+=quantity else: if material not in junk_materials.keys(): junk_materials[material]...
def collected_materials(key_materials_dict: dict, junk_materials_dict: dict, material: str, quantity: int): if material == 'shards' or material == 'fragments' or material == 'motes': key_materials_dict[material] += quantity elif material not in junk_materials.keys(): junk_materials[material] = q...
t_host = "localhost" t_port = "5432" t_dbname = "insert_db_name" t_user = "insert_user" t_pw = "insert_pw" photo_request_data = { "CAD6E": { "id": 218, "coords_x": -5.9357153, "coords_y": 54.5974748, "land_hash": "1530850C9A6F5FF56B66AC16301584EC" }, "TES...
t_host = 'localhost' t_port = '5432' t_dbname = 'insert_db_name' t_user = 'insert_user' t_pw = 'insert_pw' photo_request_data = {'CAD6E': {'id': 218, 'coords_x': -5.9357153, 'coords_y': 54.5974748, 'land_hash': '1530850C9A6F5FF56B66AC16301584EC'}, 'TEST1': {'id': 1, 'coords_x': 11.111111, 'coords_y': 22.222222, 'land_h...
def algorithm(K1,K2, B, weight_vec, datapoints, true_labels, lambda_lasso, penalty_func_name='norm1', calculate_score=False): ''' Outer loop is gradient ascent algorithm, the variable 'new_weight_vec' here is the dual variable we are interested in Inner loop is still our Nlasso algorithm :para...
def algorithm(K1, K2, B, weight_vec, datapoints, true_labels, lambda_lasso, penalty_func_name='norm1', calculate_score=False): """ Outer loop is gradient ascent algorithm, the variable 'new_weight_vec' here is the dual variable we are interested in Inner loop is still our Nlasso algorithm :par...
#!/usr/bin/env python2 class RDHSSet: def __init__(self, path): with open(path, 'r') as f: self.regions = [ tuple(line.strip().split()[:4]) for line in f ] self.indexmap = { x: i for i, x in enumerate(self.regions) } self.accessionIndexMap = { x[-1]: i for i, x in enumerate(sel...
class Rdhsset: def __init__(self, path): with open(path, 'r') as f: self.regions = [tuple(line.strip().split()[:4]) for line in f] self.indexmap = {x: i for (i, x) in enumerate(self.regions)} self.accessionIndexMap = {x[-1]: i for (i, x) in enumerate(self.regions)} def __le...
def getLeapYear(year): while True: if year%400==0: return year elif year%4==0 and year%100!=0: return year else: year +=1 if __name__=='__main__': leap_year_list = [] cur_year = int(input("Enter any year :")) leap_year = getLeapYear(cur_year) for i in range(15): leap_year_list.append(leap_year)...
def get_leap_year(year): while True: if year % 400 == 0: return year elif year % 4 == 0 and year % 100 != 0: return year else: year += 1 if __name__ == '__main__': leap_year_list = [] cur_year = int(input('Enter any year :')) leap_year = get_le...
for number in range(1, 101): if number % 3 == 0 and number % 5 == 0: print(f"{number} FizzBuzz") elif number % 3 == 0: print(f"{number} Fizz") elif number % 5 == 0: print(f"{number} Buzz") else: print(number)
for number in range(1, 101): if number % 3 == 0 and number % 5 == 0: print(f'{number} FizzBuzz') elif number % 3 == 0: print(f'{number} Fizz') elif number % 5 == 0: print(f'{number} Buzz') else: print(number)
{{notice}} workers = 4 errorlog = "{{proj_root}}/run/log/gunicorn.error" accesslog = "{{proj_root}}/run/log/gunicorn.access" loglevel = "debug" bind = ["127.0.0.1:9001"]
{{notice}} workers = 4 errorlog = '{{proj_root}}/run/log/gunicorn.error' accesslog = '{{proj_root}}/run/log/gunicorn.access' loglevel = 'debug' bind = ['127.0.0.1:9001']
class Relevance(object): '''Incooperation with result file and qrels file Attributes: qid, int, query id judgement_docid_list: list of list, judged docids in TREC qrels supervised_docid_list: list, top docids from unsupervised models, e.g. BM25, QL. ''' def __init__(self, qid, judged_docid_...
class Relevance(object): """Incooperation with result file and qrels file Attributes: qid, int, query id judgement_docid_list: list of list, judged docids in TREC qrels supervised_docid_list: list, top docids from unsupervised models, e.g. BM25, QL. """ def __init__(self, qid, judged_do...
def our_range(*args): start = 0 end = 10 step = 1 if len(args) == 1: end = args[0] elif 2 <= len(args) <= 3: start = args[0] end = args[1] if len(args) == 3: step = args[2] elif len(args) > 3: raise SyntaxError i = start while i < end...
def our_range(*args): start = 0 end = 10 step = 1 if len(args) == 1: end = args[0] elif 2 <= len(args) <= 3: start = args[0] end = args[1] if len(args) == 3: step = args[2] elif len(args) > 3: raise SyntaxError i = start while i < end: ...
def part1(input_data): numbers, boards = parse_input(input_data) for number in numbers: # Put number on all boards for board in boards: for row in board: for i in range(len(row)): if number == row[i]: row[i] = "x" ...
def part1(input_data): (numbers, boards) = parse_input(input_data) for number in numbers: for board in boards: for row in board: for i in range(len(row)): if number == row[i]: row[i] = 'x' for board in boards: fo...
load("@bazel_skylib//lib:paths.bzl", "paths") load( "//caffe2/test:defs.bzl", "define_tests", ) def define_pipeline_tests(): test_files = native.glob(["**/test_*.py"]) TESTS = {} for test_file in test_files: test_file_name = paths.basename(test_file) test_name = test_file_name.rep...
load('@bazel_skylib//lib:paths.bzl', 'paths') load('//caffe2/test:defs.bzl', 'define_tests') def define_pipeline_tests(): test_files = native.glob(['**/test_*.py']) tests = {} for test_file in test_files: test_file_name = paths.basename(test_file) test_name = test_file_name.replace('test_',...
# definitions.py IbConfig = { 'telepotChatId': '572145851', 'googleServiceKeyFile' : 'GoogleCloudServiceKey.json', 'telepotToken' : '679545486:AAEbCBdedlJ1lxFXpN1a-J-6LfgFQ4cAp04', 'startMessage' : 'Hallo, ich bin unsere dolmetschende Eule. Stelle mich bitte auf deine Handflaeche und ich sage dir, was d...
ib_config = {'telepotChatId': '572145851', 'googleServiceKeyFile': 'GoogleCloudServiceKey.json', 'telepotToken': '679545486:AAEbCBdedlJ1lxFXpN1a-J-6LfgFQ4cAp04', 'startMessage': 'Hallo, ich bin unsere dolmetschende Eule. Stelle mich bitte auf deine Handflaeche und ich sage dir, was dein tauber Gegenueber schreibt. Wenn...
class Graph: def __init__(self,nodes,edges): self.graph=[] for i in range(nodes+1): self.graph.append([]) self.visited=[False]*(len(self.graph)) def addEdge(self,v1,v2): self.graph[v1].append(v2) def dfs(self,source): self.visited[source]=True print(source) for i in self.graph[source]: if not s...
class Graph: def __init__(self, nodes, edges): self.graph = [] for i in range(nodes + 1): self.graph.append([]) self.visited = [False] * len(self.graph) def add_edge(self, v1, v2): self.graph[v1].append(v2) def dfs(self, source): self.visited[source] = ...
inp = list(map(float, input().split())) inp.sort(reverse=True) a, b, c = inp if a >= b + c: print('NAO FORMA TRIANGULO') else: if a ** 2 == b ** 2 + c ** 2: print('TRIANGULO RETANGULO') elif a ** 2 > b ** 2 + c ** 2: print('TRIANGULO OBTUSANGULO') else: print('TRIANGULO ACUTAN...
inp = list(map(float, input().split())) inp.sort(reverse=True) (a, b, c) = inp if a >= b + c: print('NAO FORMA TRIANGULO') else: if a ** 2 == b ** 2 + c ** 2: print('TRIANGULO RETANGULO') elif a ** 2 > b ** 2 + c ** 2: print('TRIANGULO OBTUSANGULO') else: print('TRIANGULO ACUTANG...
__all__ = ['CONFIG', 'get'] CONFIG = { 'model_save_dir': "./output/MicroExpression", 'num_classes': 7, 'total_images': 17245, 'epochs': 20, 'batch_size': 32, 'image_shape': [3, 224, 224], 'LEARNING_RATE': { 'params': { 'lr': 0.00375 } }, 'OPT...
__all__ = ['CONFIG', 'get'] config = {'model_save_dir': './output/MicroExpression', 'num_classes': 7, 'total_images': 17245, 'epochs': 20, 'batch_size': 32, 'image_shape': [3, 224, 224], 'LEARNING_RATE': {'params': {'lr': 0.00375}}, 'OPTIMIZER': {'params': {'momentum': 0.9}, 'regularizer': {'function': 'L2', 'factor': ...
n=str(input("Enter the string")) le=len(n) dig=0 alp=0 for i in range(le): if n[i].isdigit(): dig=dig+1 elif n[i].isalpha(): alp=alp+1 else: continue print("Letters count is : %d"%alp) print("Digits count is : %d"%dig)
n = str(input('Enter the string')) le = len(n) dig = 0 alp = 0 for i in range(le): if n[i].isdigit(): dig = dig + 1 elif n[i].isalpha(): alp = alp + 1 else: continue print('Letters count is : %d' % alp) print('Digits count is : %d' % dig)
#Given a decimal number n, your task is to convert it #to its binary equivalent using a recursive function. #The binary number output must be of length 8 bits. def binary(n): if n == 0: return 0 else: return (n % 2 + 10*binary(int(n // 2))) def convert_8_bit(n): s = str(n) while len(s...
def binary(n): if n == 0: return 0 else: return n % 2 + 10 * binary(int(n // 2)) def convert_8_bit(n): s = str(n) while len(s) < 8: s = '0' + s return s def dec_to_binary(n): return convert_8_bit(binary(n)) def main(): t = int(input()) n = [] for _ in range...
''' Author: Shuailin Chen Created Date: 2021-09-14 Last Modified: 2021-12-29 content: ''' # optimizer optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) optimizer_config = dict() # learning policy lr_config = dict(policy='poly', power=0.9, min_lr=1e-4, by_epoch=False) # runtime settings runner ...
""" Author: Shuailin Chen Created Date: 2021-09-14 Last Modified: 2021-12-29 content: """ optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0005) optimizer_config = dict() lr_config = dict(policy='poly', power=0.9, min_lr=0.0001, by_epoch=False) runner = dict(type='MyIterBasedRunner', max_iters=10000...
keys = { "accept": 30, "add": 107, "apps": 93, "attn": 246, "back": 8, "browser_back": 166, "browser_forward": 167, "cancel": 3, "capital": 20, "clear": 12, "control": 17, "convert": 28, "crsel": 247, "decimal": 110, "delete": 46, "divide":...
keys = {'accept': 30, 'add': 107, 'apps': 93, 'attn': 246, 'back': 8, 'browser_back': 166, 'browser_forward': 167, 'cancel': 3, 'capital': 20, 'clear': 12, 'control': 17, 'convert': 28, 'crsel': 247, 'decimal': 110, 'delete': 46, 'divide': 111, 'down': 40, 'end': 35, 'ereof': 249, 'escape': 27, 'execute': 43, 'exsel': ...
N = int(input()) A = list(map(int, input().split())) A.sort() left, right = 0, 2*N-1 moist = A.count(0) // 2 while left < right and A[left] < 0 and A[right] > 0: if abs(A[left]) == A[right]: moist += 1 left += 1 right -= 1 elif abs(A[left]) > A[right]: left += 1 else: ...
n = int(input()) a = list(map(int, input().split())) A.sort() (left, right) = (0, 2 * N - 1) moist = A.count(0) // 2 while left < right and A[left] < 0 and (A[right] > 0): if abs(A[left]) == A[right]: moist += 1 left += 1 right -= 1 elif abs(A[left]) > A[right]: left += 1 els...
def printSlope(equation): xIndex = equation.find('x') if xIndex == -1: print(0) elif xIndex == 2: print(1) else: slopeString = equation[2:xIndex] if slopeString == "-": print(-1) else: print(slopeString) printSlope("y=2x+5") #prints 2 prin...
def print_slope(equation): x_index = equation.find('x') if xIndex == -1: print(0) elif xIndex == 2: print(1) else: slope_string = equation[2:xIndex] if slopeString == '-': print(-1) else: print(slopeString) print_slope('y=2x+5') print_slope...
def profile_most_probable_kmer(text, k, profile): highest_prob = -1 most_probable_kmer = "" for i in range(len(text) - k + 1): kmer = text[i : i+k] prob = 1 for index, nucleotide in enumerate(kmer): prob *= profile[nucleotide][index] if prob > highest_prob: ...
def profile_most_probable_kmer(text, k, profile): highest_prob = -1 most_probable_kmer = '' for i in range(len(text) - k + 1): kmer = text[i:i + k] prob = 1 for (index, nucleotide) in enumerate(kmer): prob *= profile[nucleotide][index] if prob > highest_prob: ...
ROW_COUNT = 128 COLUMN_COUNT = 8 def solve(input): return max(map(lambda i: BoardingPass(i).seat_id, input)) class BoardingPass: def __init__(self, data, row_count=ROW_COUNT, column_count=COLUMN_COUNT): self.row = self._search( data = data[:7], low_char='F', high_char='B', i=0, ...
row_count = 128 column_count = 8 def solve(input): return max(map(lambda i: boarding_pass(i).seat_id, input)) class Boardingpass: def __init__(self, data, row_count=ROW_COUNT, column_count=COLUMN_COUNT): self.row = self._search(data=data[:7], low_char='F', high_char='B', i=0, min_value=0, max_value=r...
f = open('day3.txt', 'r') data = f.readlines() oneCount = 0 threeCount = 0 fiveCount = 0 sevenCount = 0 evenCount = 0 pos1 = 0 pos3 = 0 pos5 = 0 pos7 = 0 posEven = 0 even = True for line in data: line = line.replace("\n", '') if line[pos1 % len(line)] == '#': oneCount += 1 if line[pos3 % len(line)...
f = open('day3.txt', 'r') data = f.readlines() one_count = 0 three_count = 0 five_count = 0 seven_count = 0 even_count = 0 pos1 = 0 pos3 = 0 pos5 = 0 pos7 = 0 pos_even = 0 even = True for line in data: line = line.replace('\n', '') if line[pos1 % len(line)] == '#': one_count += 1 if line[pos3 % len(...
def porrada(seq, passo): atual = 0 while len(seq) > 1: atual += passo - 1 while atual > len(seq) - 1: atual -= len(seq) seq.pop(atual) return seq[0] + 1 quantidade_de_casos = int(input()) for c in range(quantidade_de_casos): entrada = input().split() n = list(ra...
def porrada(seq, passo): atual = 0 while len(seq) > 1: atual += passo - 1 while atual > len(seq) - 1: atual -= len(seq) seq.pop(atual) return seq[0] + 1 quantidade_de_casos = int(input()) for c in range(quantidade_de_casos): entrada = input().split() n = list(rang...
n = int(input()) arr = list(map(int, input().split(' '))) arr.sort(reverse=True) res = 0 for i in range(n): res += arr[i]*2**i print(res)
n = int(input()) arr = list(map(int, input().split(' '))) arr.sort(reverse=True) res = 0 for i in range(n): res += arr[i] * 2 ** i print(res)
class Solution: def minInsertions(self, s: str) -> int: right = count = 0 for c in s: if c == '(': if right & 1: right -= 1 count += 1 right += 2 else: right -= 1 if right ...
class Solution: def min_insertions(self, s: str) -> int: right = count = 0 for c in s: if c == '(': if right & 1: right -= 1 count += 1 right += 2 else: right -= 1 if righ...
S = input() N = len(S) A = [0]*(N+1) B = [0]*(N+1) for i in range(N): if S[i] == '<': A[i+1] = A[i]+1 else: A[i+1] = 0 for i in range(N): if S[N-i-1] == '>': B[N-i-1] = B[N-i]+1 else: B[N-i-1] = 0 ans = 0 for i in range(N+1): ans += max(A[i], B[i]) print(ans)
s = input() n = len(S) a = [0] * (N + 1) b = [0] * (N + 1) for i in range(N): if S[i] == '<': A[i + 1] = A[i] + 1 else: A[i + 1] = 0 for i in range(N): if S[N - i - 1] == '>': B[N - i - 1] = B[N - i] + 1 else: B[N - i - 1] = 0 ans = 0 for i in range(N + 1): ans += max...
''' Write a program that takes an integer argument and retums all the primes between 1 and that integer. For example, if the input is 18, you should return [2, 3, 5, 7, 11, 13, 17]. ''' def generate_primes(n): # Time: O(n log log n) | Space: O(n) primes = [] # is_prime[p] represents if p is prime or not. ...
""" Write a program that takes an integer argument and retums all the primes between 1 and that integer. For example, if the input is 18, you should return [2, 3, 5, 7, 11, 13, 17]. """ def generate_primes(n): primes = [] is_prime = [False, False] + [True] * (n - 1) for p in range(2, n + 1): if is_...
n = int(input()) l = [] for i in range(0, n): l.append(int(input())) for orig_num in l: count = 0 num = orig_num while num != 0: digit = num % 10 if digit == 0: pass elif orig_num % digit == 0: count += 1 num = int(num / 10) print (count)
n = int(input()) l = [] for i in range(0, n): l.append(int(input())) for orig_num in l: count = 0 num = orig_num while num != 0: digit = num % 10 if digit == 0: pass elif orig_num % digit == 0: count += 1 num = int(num / 10) print(count)
class Qseq(str): def __init__(self, seq): self.qkey = None self.parent = None self.parental_id = None self.parental_class = None self.name = None self.item = None def __getitem__(self, item): value = s...
class Qseq(str): def __init__(self, seq): self.qkey = None self.parent = None self.parental_id = None self.parental_class = None self.name = None self.item = None def __getitem__(self, item): value = super().__getitem__(item) if self.parental_cla...
rios = { 'nilo' : 'egito', 'rio grande' : 'brasil', 'rio parana' : 'brasil' } for key,value in rios.items(): print(' O rio ' + key.title() + ' corre pelo ' + value.title()) for key in rios.keys(): print(key.title()) for value in rios.values(): print(value.title())
rios = {'nilo': 'egito', 'rio grande': 'brasil', 'rio parana': 'brasil'} for (key, value) in rios.items(): print(' O rio ' + key.title() + ' corre pelo ' + value.title()) for key in rios.keys(): print(key.title()) for value in rios.values(): print(value.title())
vowels2 = set('aeiiiouuu') word = input('Provide a word to search for vowels:').lower() found = vowels2.intersection(set(word)) for v in found: print(v)
vowels2 = set('aeiiiouuu') word = input('Provide a word to search for vowels:').lower() found = vowels2.intersection(set(word)) for v in found: print(v)
class Solution: def wordPattern(self, pattern: str, str: str) -> bool: table = {} mapped = set() words = str.split() if len(words) != len(pattern): return False for i, word in enumerate(words): if word in table: if table[wor...
class Solution: def word_pattern(self, pattern: str, str: str) -> bool: table = {} mapped = set() words = str.split() if len(words) != len(pattern): return False for (i, word) in enumerate(words): if word in table: if table[word] != pa...
HOST = 'localhost' PORT = 61613 VERSION = '1.2' BROKER = 'activemq' LOGIN, PASSCODE, VIRTUALHOST = { 'activemq': ('', '', ''), 'apollo': ('admin', 'password', 'mybroker'), 'rabbitmq': ('guest', 'guest', '/') }[BROKER]
host = 'localhost' port = 61613 version = '1.2' broker = 'activemq' (login, passcode, virtualhost) = {'activemq': ('', '', ''), 'apollo': ('admin', 'password', 'mybroker'), 'rabbitmq': ('guest', 'guest', '/')}[BROKER]
def Num2581(): M = int(input()) N = int(input()) minPrimeNum = 0 sumPrimeNum = 0 primeNums = [] for dividend in range(M, N+1): if dividend == 1: continue primeNums.append(dividend) sumPrimeNum += dividend for divisor in range(2, dividend): ...
def num2581(): m = int(input()) n = int(input()) min_prime_num = 0 sum_prime_num = 0 prime_nums = [] for dividend in range(M, N + 1): if dividend == 1: continue primeNums.append(dividend) sum_prime_num += dividend for divisor in range(2, dividend): ...
#takes a list of options as input which will be printed as a numerical list #Also optionally takes messages as input to be printed after the options but before input request #Ultimately the users choice is returned def selector(options,*messages): rego = 'y' while rego.lower() == "y": n=1 for x...
def selector(options, *messages): rego = 'y' while rego.lower() == 'y': n = 1 for x in options: print(str(n) + '. ' + str(x)) n = n + 1 n = 1 print('') for arg in messages: print(arg) choice = input(' :> ') if choice == ...
class Wrapping(object): def __init__(self, klass, wrapped_klass, dependency_functions): self._klass = klass self._wrapped_klass = wrapped_klass self._dependency_functions = dependency_functions def wrap(self): for dependency_method in self._dependency_functions: se...
class Wrapping(object): def __init__(self, klass, wrapped_klass, dependency_functions): self._klass = klass self._wrapped_klass = wrapped_klass self._dependency_functions = dependency_functions def wrap(self): for dependency_method in self._dependency_functions: sel...
def roman_number(num): if num > 3999: print("enter number less than 3999") return #take 2 list symbol and value symbol having roman of each integer in list value value = [1000,900,500,400,100,90,50,40,10,9,5,4,1] symbol = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"] ro...
def roman_number(num): if num > 3999: print('enter number less than 3999') return value = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] symbol = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'] roman = '' i = 0 while num > 0: div = num // v...
AN_ESCAPED_NEWLINE = "\n" AN_ESCAPED_TAB = "\t" A_COMMA = "," A_QUOTE = "'" A_TAB = "\t" DOUBLE_QUOTES = "\"" NEWLINE = "\n"
an_escaped_newline = '\n' an_escaped_tab = '\t' a_comma = ',' a_quote = "'" a_tab = '\t' double_quotes = '"' newline = '\n'
#!/usr/bin/env python3 # # Copyright 2019 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.. # You may obtain a copy of the License at # # https://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law...
class Scholarshipbuilder: @staticmethod def set_name(scholarship, name): scholarship['scholarshipName'] = name @staticmethod def set_id(scholarship, id): scholarship['id'] = str(int(id)) @staticmethod def set_schools_list(scholarship, schoolsList): scholarship['schools...
class MyClass: def __init__(self, name): self.__name = name def Show(self): print(self.__name) c1 = MyClass('c1') c2 = MyClass('c2') c3 = MyClass('c3') c4 = MyClass('c4') a = {x.Show() for x in {c1, c2, c3, c4} if x not in {c1, c2}}
class Myclass: def __init__(self, name): self.__name = name def show(self): print(self.__name) c1 = my_class('c1') c2 = my_class('c2') c3 = my_class('c3') c4 = my_class('c4') a = {x.Show() for x in {c1, c2, c3, c4} if x not in {c1, c2}}
@metadata_reactor def install_git(metadata): return { 'apt': { 'packages': { 'git': { 'installed': True, }, } }, }
@metadata_reactor def install_git(metadata): return {'apt': {'packages': {'git': {'installed': True}}}}
if __name__ == '__main__': n,m = map(int,input().split()) l = map(int,input().split()) a = set(map(int,input().split())) b = set(map(int,input().split())) happy = 0 for i in l: if i in a: happy += 1 elif i in b: happy -= 1 print(happy) # print(sum([(i in a) - (i in b) for i in l]))
if __name__ == '__main__': (n, m) = map(int, input().split()) l = map(int, input().split()) a = set(map(int, input().split())) b = set(map(int, input().split())) happy = 0 for i in l: if i in a: happy += 1 elif i in b: happy -= 1 print(happy)
# // This is a generated file, modify: generate/templates/binding.gyp. { "targets": [{ "target_name": "nodegit", "dependencies": [ "<(module_root_dir)/vendor/libgit2.gyp:libgit2" ], "sources": [ "src/nodegit.cc", "src/wrapper.cc", "src/functions/copy.cc", "src/attr.cc"...
{'targets': [{'target_name': 'nodegit', 'dependencies': ['<(module_root_dir)/vendor/libgit2.gyp:libgit2'], 'sources': ['src/nodegit.cc', 'src/wrapper.cc', 'src/functions/copy.cc', 'src/attr.cc', 'src/blame.cc', 'src/blame_hunk.cc', 'src/blame_options.cc', 'src/blob.cc', 'src/branch.cc', 'src/branch_iterator.cc', 'src/b...
a = 10 b = 20 c = 300000
a = 10 b = 20 c = 300000
class Solution: def addBinary(self, a: str, b: str) -> str: x=int(a,2) y=int(b,2) return bin(x+y)[2:]
class Solution: def add_binary(self, a: str, b: str) -> str: x = int(a, 2) y = int(b, 2) return bin(x + y)[2:]
for i in range(int(input())): n = int(input()) s = input() a,b = [-1 for j in range(26)],[1e5 for j in range(26)] for j in range(n): if(a[ord(s[j])-97]==-1): a[ord(s[j])-97] = j else: if(j-a[ord(s[j])-97]<b[ord(s[j])-97]): b[ord(s[j])-97] = j-a[ord...
for i in range(int(input())): n = int(input()) s = input() (a, b) = ([-1 for j in range(26)], [100000.0 for j in range(26)]) for j in range(n): if a[ord(s[j]) - 97] == -1: a[ord(s[j]) - 97] = j else: if j - a[ord(s[j]) - 97] < b[ord(s[j]) - 97]: b[...
class Solution: def minDistance(self, word1: str, word2: str) -> int: edits = [[x for x in range(len(word1) + 1)] for y in range(len(word2) + 1)] for i in range(1, len(word2) + 1): edits[i][0] = edits[i - 1][0] + 1 for i in range(1, len(word2) + 1): for j in range(1, ...
class Solution: def min_distance(self, word1: str, word2: str) -> int: edits = [[x for x in range(len(word1) + 1)] for y in range(len(word2) + 1)] for i in range(1, len(word2) + 1): edits[i][0] = edits[i - 1][0] + 1 for i in range(1, len(word2) + 1): for j in range(1...
ENHANCED_PEER_MOBILIZATION = 'enhanced_peer_mobilization' CHAMP_CAMEROON = 'champ_client_forms' TARGET_XMLNS = 'http://openrosa.org/formdesigner/A79467FD-4CDE-47B6-8218-4394699A5C95' PREVENTION_XMLNS = 'http://openrosa.org/formdesigner/DF2FBEEA-31DE-4537-9913-07D57591502C' POST_TEST_XMLNS = 'http://openrosa.org/formd...
enhanced_peer_mobilization = 'enhanced_peer_mobilization' champ_cameroon = 'champ_client_forms' target_xmlns = 'http://openrosa.org/formdesigner/A79467FD-4CDE-47B6-8218-4394699A5C95' prevention_xmlns = 'http://openrosa.org/formdesigner/DF2FBEEA-31DE-4537-9913-07D57591502C' post_test_xmlns = 'http://openrosa.org/formdes...
# You may need this if you really want to use a recursive solution! # It raises the cap on how many recursions can happen. Use this at your own risk! # sys.setrecursionlimit(100000) def read_lines(filename): try: f = open(filename,"r") lines = f.readlines() f.close() filter...
def read_lines(filename): try: f = open(filename, 'r') lines = f.readlines() f.close() filtered_contents = [] for line in lines: line = line.rstrip('\n') filtered_contents.append(list(line)) return filtered_contents except FileNotFoundError...
class MultiFilterCNNModel(object): def __init__(self, max_sequences, word_index, embed_dim, embedding_matrix, filter_sizes, num_filters, dropout, learning_rate, beta_1, beta_2, epsilon, n_classes): sequence_input = Input(shape=(max_sequences,), dtype='int32') embedding_layer = Emb...
class Multifiltercnnmodel(object): def __init__(self, max_sequences, word_index, embed_dim, embedding_matrix, filter_sizes, num_filters, dropout, learning_rate, beta_1, beta_2, epsilon, n_classes): sequence_input = input(shape=(max_sequences,), dtype='int32') embedding_layer = embedding(len(word_in...
norm_cfg = dict(type='BN', requires_grad=True) model = dict( type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict( type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=(1, 2, 1, 1), ...
norm_cfg = dict(type='BN', requires_grad=True) model = dict(type='EncoderDecoder', pretrained='open-mmlab://resnet50_v1c', backbone=dict(type='ResNetV1c', depth=50, num_stages=4, out_indices=(0, 1, 2, 3), dilations=(1, 1, 2, 4), strides=(1, 2, 1, 1), norm_cfg=dict(type='BN', requires_grad=True), norm_eval=False, style=...
class Solution: def longestAwesome(self, s: str) -> int: table = {0 : -1} mask = maxLen = 0 for i, c in enumerate(s): mask ^= (1 << int(c)) for j in range(10): mask2 = mask ^ (1 << j) if mask2 in table: maxLen = max(...
class Solution: def longest_awesome(self, s: str) -> int: table = {0: -1} mask = max_len = 0 for (i, c) in enumerate(s): mask ^= 1 << int(c) for j in range(10): mask2 = mask ^ 1 << j if mask2 in table: max_len = max...
# This is what gets created by TextField.as_tensor with a SingleIdTokenIndexer # and a TokenCharactersIndexer; see the code snippet above. This time we're using # more intuitive names for the indexers and embedders. token_tensor = { 'tokens': {'tokens': torch.LongTensor([[2, 4, 3, 5]])}, 'token_characters': {'t...
token_tensor = {'tokens': {'tokens': torch.LongTensor([[2, 4, 3, 5]])}, 'token_characters': {'token_characters': torch.LongTensor([[[2, 5, 3], [4, 0, 0], [2, 1, 4], [5, 4, 0]]])}} embedding = embedding(num_embeddings=6, embedding_dim=3) character_embedding = embedding(num_embeddings=6, embedding_dim=3) cnn_encoder = cn...
{ "targets": [ { "target_name": "decompressor", "sources": ["decompressor.cpp"] }, { "target_name": "pow_solver", "sources": ["pow_solver.cpp"] } ] }
{'targets': [{'target_name': 'decompressor', 'sources': ['decompressor.cpp']}, {'target_name': 'pow_solver', 'sources': ['pow_solver.cpp']}]}
class C4FileIO(): red_wins = 0 blue_wins = 0 def __init__(self): try: f = open("c4wins.txt", "r") lines = f.readlines() f.close() if type(lines) == list: self.deserialize_file(lines) except FileNotFoundError: print(...
class C4Fileio: red_wins = 0 blue_wins = 0 def __init__(self): try: f = open('c4wins.txt', 'r') lines = f.readlines() f.close() if type(lines) == list: self.deserialize_file(lines) except FileNotFoundError: print('F...