content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
{ 'targets': [ { 'target_name': 'xwalk_extensions_unittest', 'type': 'executable', 'dependencies': [ '../../base/base.gyp:base', '../../base/base.gyp:run_all_unittests', '../../testing/gtest.gyp:gtest', 'extensions.gyp:xwalk_extensions', ], 'sources': ...
{'targets': [{'target_name': 'xwalk_extensions_unittest', 'type': 'executable', 'dependencies': ['../../base/base.gyp:base', '../../base/base.gyp:run_all_unittests', '../../testing/gtest.gyp:gtest', 'extensions.gyp:xwalk_extensions'], 'sources': ['browser/xwalk_extension_function_handler_unittest.cc', 'common/xwalk_ext...
class Solution: @staticmethod def naive(n,edges): adj = {i:[] for i in range(n)} for u,v in edges: adj[u].append(v) adj[v].append(u) # no cycle, only one fully connected tree visited = set() def dfs(i,fro): if i in visited: ...
class Solution: @staticmethod def naive(n, edges): adj = {i: [] for i in range(n)} for (u, v) in edges: adj[u].append(v) adj[v].append(u) visited = set() def dfs(i, fro): if i in visited: return False visited.add(i...
class CardSelectionConfigController(object): cs = None controller = None pos = None def __init__(self, cs, controller, pos=-1): self.cs = cs self.controller = controller self.pos = pos def save(self): if self.pos < 0: self.controller.add_cs(self.cs) ...
class Cardselectionconfigcontroller(object): cs = None controller = None pos = None def __init__(self, cs, controller, pos=-1): self.cs = cs self.controller = controller self.pos = pos def save(self): if self.pos < 0: self.controller.add_cs(self.cs) ...
T = int(input()) for _ in range(T): n = int(input()) s = [int(s_arr) for s_arr in input().split(' ')] misere, count = 0, 0 for i in range(n): misere ^= s[i] if s[i] <= 1: count += 1 print ("Second" if (count == n and misere == 1) or (count < n and misere == 0) el...
t = int(input()) for _ in range(T): n = int(input()) s = [int(s_arr) for s_arr in input().split(' ')] (misere, count) = (0, 0) for i in range(n): misere ^= s[i] if s[i] <= 1: count += 1 print('Second' if count == n and misere == 1 or (count < n and misere == 0) else 'Firs...
# tests transition from small to large int representation by multiplication for rhs in range(2, 11): lhs = 1 for k in range(100): res = lhs * rhs print(lhs, '*', rhs, '=', res) lhs = res # below tests pos/neg combinations that overflow small int # 31-bit overflow i = 1 << 20 print(i * ...
for rhs in range(2, 11): lhs = 1 for k in range(100): res = lhs * rhs print(lhs, '*', rhs, '=', res) lhs = res i = 1 << 20 print(i * i) print(i * -i) print(-i * i) print(-i * -i) i = 1 << 40 print(i * i) print(i * -i) print(-i * i) print(-i * -i)
class Solution: def findComplement(self, num: int) -> int: r = '{:08b}'.format(num).lstrip('0') r2 = '' for i in r: if i == '0': r2 += '1' else: r2 += '0' r3 = int(r2, 2) return r3 if __name__ == '__main__': s = So...
class Solution: def find_complement(self, num: int) -> int: r = '{:08b}'.format(num).lstrip('0') r2 = '' for i in r: if i == '0': r2 += '1' else: r2 += '0' r3 = int(r2, 2) return r3 if __name__ == '__main__': s = so...
def filter_museums(request): sub = {'nature': 1, 'memorial': 2, 'art': 3, 'gallery': 4, 'history': 5} categories = [sub[i] for i in sub if request.GET.get(i) != 'false'] return categories
def filter_museums(request): sub = {'nature': 1, 'memorial': 2, 'art': 3, 'gallery': 4, 'history': 5} categories = [sub[i] for i in sub if request.GET.get(i) != 'false'] return categories
for i in range(1, 70, 2): s= str(i+1) print("printf \"26\\n30\\n" + s + "\\n\" > tile.sizes") print("./polycc --tile --parallel NusValidation.cpp") print("gcc -o nus" + s + " -O2 NusValidation.cpp.pluto.c -fopenmp -lm") print("cp nus" + s + " exp") print("./exp/nus" + s)
for i in range(1, 70, 2): s = str(i + 1) print('printf "26\\n30\\n' + s + '\\n" > tile.sizes') print('./polycc --tile --parallel NusValidation.cpp') print('gcc -o nus' + s + ' -O2 NusValidation.cpp.pluto.c -fopenmp -lm') print('cp nus' + s + ' exp') print('./exp/nus' + s)
# Puzzle Input with open('Day05_Input.txt') as puzzle_input: seats = puzzle_input.read().split('\n') # Converts a list containing a binary number to a decimal number def bin_to_decimal(bin_num): dec_num = 0 bin_len = len(bin_num) for pos, bit in enumerate(bin_num): if bit == 1: dec...
with open('Day05_Input.txt') as puzzle_input: seats = puzzle_input.read().split('\n') def bin_to_decimal(bin_num): dec_num = 0 bin_len = len(bin_num) for (pos, bit) in enumerate(bin_num): if bit == 1: dec_num += 2 ** (bin_len - pos - 1) return dec_num seat_id = [] for s in seats...
# All traversals in one: Pre, post and inorder # Time complexity: O(3n) # Space complexity: O(4n), 4 stacks are being used class Node(): def __init__(self, key): self.left = None self.value = key self.right = None def traversal(node): if node is None: return [] ...
class Node: def __init__(self, key): self.left = None self.value = key self.right = None def traversal(node): if node is None: return [] stack = [[node, 1]] preorder = [] inorder = [] postorder = [] while len(stack) != 0: curr = stack[-1][0] ...
file = open("/disk/lulu/database/TSGene/pro/TSG.genepos.qukong.txt") #f = open("out.txt", "w") for line in file: # print line, list = line.strip().split("\t") # print list if list[4] == "-": line1 = line.strip().replace("-", "") print (line1) # print >> f, "%s" % line1 ...
file = open('/disk/lulu/database/TSGene/pro/TSG.genepos.qukong.txt') for line in file: list = line.strip().split('\t') if list[4] == '-': line1 = line.strip().replace('-', '') print(line1) else: print(list[0], '\t', list[1], '\t', list[2], '\t', list[3], '\t', list[5], '\t', list[6],...
# -*- coding: utf-8 -*- class EndOfStream(Exception): pass class InvalidSyntaxError(Exception): pass class InvalidCommandFormat(InvalidSyntaxError): pass class TokenNotFound(InvalidSyntaxError): pass class DeprecatedSyntax(InvalidSyntaxError): pass class RenderingError(Exception): pa...
class Endofstream(Exception): pass class Invalidsyntaxerror(Exception): pass class Invalidcommandformat(InvalidSyntaxError): pass class Tokennotfound(InvalidSyntaxError): pass class Deprecatedsyntax(InvalidSyntaxError): pass class Renderingerror(Exception): pass class Apertureselectionerro...
src = [] include_tmp = [] if aos_global_config.compiler == 'armcc': src = Split(''' compilers/armlibc/armcc_libc.c ''') include_tmp = Split(''' compilers/armlibc ''') elif aos_global_config.compiler == 'rvct': src = Split(''' compilers/armlibc/armcc_libc.c ''') ...
src = [] include_tmp = [] if aos_global_config.compiler == 'armcc': src = split('\n compilers/armlibc/armcc_libc.c\n ') include_tmp = split('\n compilers/armlibc\n ') elif aos_global_config.compiler == 'rvct': src = split('\n compilers/armlibc/armcc_libc.c\n ') include_tmp ...
# # PySNMP MIB module CISCO-PRIVATE-VLAN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-PRIVATE-VLAN-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:33:49 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ...
class Solution: def rangeSumBST(self, root, L, R): def dfs(node): if node: if L <= node.val <= R: self.ans = self.ans + node.val if L < node.val: dfs(node.left) if R > node.val: dfs(node.r...
class Solution: def range_sum_bst(self, root, L, R): def dfs(node): if node: if L <= node.val <= R: self.ans = self.ans + node.val if L < node.val: dfs(node.left) if R > node.val: dfs(no...
#!/usr/bin/env python3 # -*- coding:utf-8 -*- # @author jsbxyyx # @since 1.0 class Types: BIT = -7 TINYINT = -6 SMALLINT = 5 INTEGER = 4 BIGINT = -5 FLOAT = 6 REAL = 7 DOUBLE = 8 NUMERIC = 2 DECIMAL = 3 CHAR = 1 VARCHAR = 12 LONGVARCHAR = -1 DATE = 91 TIME =...
class Types: bit = -7 tinyint = -6 smallint = 5 integer = 4 bigint = -5 float = 6 real = 7 double = 8 numeric = 2 decimal = 3 char = 1 varchar = 12 longvarchar = -1 date = 91 time = 92 timestamp = 93 binary = -2 varbinary = -3 longvarbinary = -...
class Count(object): version=1.5 def add(self,x,y): return x+y def sub(self,x,y): return x-y if __name__ == '__main__': c=Count() print(c.add(1,2)) print(c.sub(10,5))
class Count(object): version = 1.5 def add(self, x, y): return x + y def sub(self, x, y): return x - y if __name__ == '__main__': c = count() print(c.add(1, 2)) print(c.sub(10, 5))
expected_output = { "sensor_list": { "Environmental Monitoring": { "sensor": { "PEM Iout": {"location": "P1", "reading": "0 A", "state": "Normal"}, "PEM Vin": {"location": "P1", "reading": "104 V AC", "state": "Normal"}, "PEM Vout": {"location": "P...
expected_output = {'sensor_list': {'Environmental Monitoring': {'sensor': {'PEM Iout': {'location': 'P1', 'reading': '0 A', 'state': 'Normal'}, 'PEM Vin': {'location': 'P1', 'reading': '104 V AC', 'state': 'Normal'}, 'PEM Vout': {'location': 'P1', 'reading': '0 V DC', 'state': 'Normal'}, 'Temp: Asic1': {'location': '0'...
class AST: def __init__(self, **fields): for k, v in fields.items(): setattr(self, k, v) class mod(AST): pass class Module(mod): _fields = ('body',) class Interactive(mod): _fields = ('body',) class Expression(mod): _fields = ('body',) class Suite(mod): _fields = ('body',) cla...
class Ast: def __init__(self, **fields): for (k, v) in fields.items(): setattr(self, k, v) class Mod(AST): pass class Module(mod): _fields = ('body',) class Interactive(mod): _fields = ('body',) class Expression(mod): _fields = ('body',) class Suite(mod): _fields = ('bo...
# Approach 1 - Backtracking class Solution: def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]: def backtrack(remain, comb, next_start): if remain == 0: results.append(comb.copy()) return elif remain < 0: ...
class Solution: def combination_sum(self, candidates: List[int], target: int) -> List[List[int]]: def backtrack(remain, comb, next_start): if remain == 0: results.append(comb.copy()) return elif remain < 0: return for i in...
#Find the Prime Numbers in a given range with total count. #(so basically prime number is a number which is only divisible by '1' & itself) #examples : 2, 3, 5, 7, 11, 13,... def error(): try: #Finds the Prime Numbers in a given range: ip = int(input("Enter the range to find Prime Nu...
def error(): try: ip = int(input('Enter the range to find Prime Numbers: ')) if ip <= 0: print('Wrong Input') print('Input must be a positive value') print('Start again..') error() print('Prime Numbers: ') for num in range(1, ip + 1): ...
class Solution: def spiralMatrixIII(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]: res = [(r0, c0)] step = 1 while len(res) < R * C: # right for j in range(step): c0 += 1 if self._in_grid(c0, r0, C, R): ...
class Solution: def spiral_matrix_iii(self, R: int, C: int, r0: int, c0: int) -> List[List[int]]: res = [(r0, c0)] step = 1 while len(res) < R * C: for j in range(step): c0 += 1 if self._in_grid(c0, r0, C, R): res.append((r0, c...
def get_sql(): limit = 6 sql = f"SELEct speed from world where animal='dolphin' limit {limit}" return sql def get_query_template(): limit = 6 query_template = ( f"SELEct speed from world where animal='dolphin' group by family limit {limit}" ) return query_template def get_query()...
def get_sql(): limit = 6 sql = f"SELEct speed from world where animal='dolphin' limit {limit}" return sql def get_query_template(): limit = 6 query_template = f"SELEct speed from world where animal='dolphin' group by family limit {limit}" return query_template def get_query(): limit = 99 ...
postponed = 'POSTPONED' scheduled = 'SCHEDULED' awarded = 'AWARDED' suspended = 'SUSPENDED' inPlay = 'IN_PLAY' canceled = 'CANCELED' paused = 'PAUSED' finished = 'FINISHED' matchToBePlayedList = [scheduled, suspended, paused, inPlay]
postponed = 'POSTPONED' scheduled = 'SCHEDULED' awarded = 'AWARDED' suspended = 'SUSPENDED' in_play = 'IN_PLAY' canceled = 'CANCELED' paused = 'PAUSED' finished = 'FINISHED' match_to_be_played_list = [scheduled, suspended, paused, inPlay]
class ActionException(Exception): pass class PingTimeout(Exception): pass class MeruException(Exception): pass
class Actionexception(Exception): pass class Pingtimeout(Exception): pass class Meruexception(Exception): pass
class Table(object): def __init__(self, name, columns): self.name = name self.columns = columns
class Table(object): def __init__(self, name, columns): self.name = name self.columns = columns
def test_add_group(app, xlsx_groups): old_list = app.group.get_group_list() app.group.add_new_group(xlsx_groups) new_list = app.group.get_group_list() old_list.append(xlsx_groups) assert sorted(old_list) == sorted(new_list)
def test_add_group(app, xlsx_groups): old_list = app.group.get_group_list() app.group.add_new_group(xlsx_groups) new_list = app.group.get_group_list() old_list.append(xlsx_groups) assert sorted(old_list) == sorted(new_list)
''' Created on 18 Sep 2017 @author: ywz '''
""" Created on 18 Sep 2017 @author: ywz """
a = 3 b = 4.0 c = a + b d = a - b e = a / b tup = (a, b, c, d, e) tup
a = 3 b = 4.0 c = a + b d = a - b e = a / b tup = (a, b, c, d, e) tup
#!/usr/bin/env python NAME = 'Newdefend (NewDefend)' def is_waf(self): # Newdefend reveals itself within the server headers without any mal requests if self.matchheader(('Server', 'Newdefend')): return True for attack in self.attacks: r = attack(self) if r is None: re...
name = 'Newdefend (NewDefend)' def is_waf(self): if self.matchheader(('Server', 'Newdefend')): return True for attack in self.attacks: r = attack(self) if r is None: return (_, page) = r if any((i in page for i in (b'http://www.newdefend.com/feedback', b'/nd-...
# Example: Send Picture Message id = api.send_message( from_ = '+1234567980', to = '+1234567981', media = ['http://host/path/to/file'] )
id = api.send_message(from_='+1234567980', to='+1234567981', media=['http://host/path/to/file'])
def lps(string, result=[]): if len(string) > 0: end = 0 for i in range(1, len(string)): if string[i] == string[0] and i > end: end = i if not result: result.append(string[0: end + 1]) elif len(string[0: end+1]) > len(result[0]): re...
def lps(string, result=[]): if len(string) > 0: end = 0 for i in range(1, len(string)): if string[i] == string[0] and i > end: end = i if not result: result.append(string[0:end + 1]) elif len(string[0:end + 1]) > len(result[0]): res...
# Exercise 66 - Translator d = dict(weather = "clima", earth = "terra", rain = "chuva") def vocabulary(word): return d[word] if word in d else '' word = input('Enter word: ') print(vocabulary(word))
d = dict(weather='clima', earth='terra', rain='chuva') def vocabulary(word): return d[word] if word in d else '' word = input('Enter word: ') print(vocabulary(word))
def bytes2human(n): # http://code.activestate.com/recipes/578019 symbols = ("K", "M", "G", "T", "P", "E", "Z", "Y") prefix = {} for i, s in enumerate(symbols): prefix[s] = 1 << (i + 1) * 10 for s in reversed(symbols): if n >= prefix[s]: value = float(n) / prefix[s] ...
def bytes2human(n): symbols = ('K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y') prefix = {} for (i, s) in enumerate(symbols): prefix[s] = 1 << (i + 1) * 10 for s in reversed(symbols): if n >= prefix[s]: value = float(n) / prefix[s] return '%.1f%s' % (value, s) return '...
#!/usr/bin/env python NAME = 'Radware AppWall' def is_waf(self): if self.matchheader(('X-SL-CompState', '.')): return True for attack in self.attacks: r = attack(self) if r is None: return _, responsebody = r # Most reliable fingerprint is this on block page...
name = 'Radware AppWall' def is_waf(self): if self.matchheader(('X-SL-CompState', '.')): return True for attack in self.attacks: r = attack(self) if r is None: return (_, responsebody) = r if all((i in responsebody for i in (b'because we have detected unautho...
def domainchanger(email,newdom,olddom = "1"): email = email.split("@") if newdom != email[1]: newemail = email[0] + "@"+ newdom return f"Changed: {newemail}" else: newemail = email[0] + "@"+ email[1] return f"Unchanged: {newemail}" email = input("Enter your email: ") newdom...
def domainchanger(email, newdom, olddom='1'): email = email.split('@') if newdom != email[1]: newemail = email[0] + '@' + newdom return f'Changed: {newemail}' else: newemail = email[0] + '@' + email[1] return f'Unchanged: {newemail}' email = input('Enter your email: ') newdom...
class Vector: def __init__(self, length=3, vec=None): self._vec = [] if isinstance(vec, list): self._vec = vec.copy() else: if isinstance(length, (int, float)): for i in range(int(length)): self._vec.append(0) self._length =...
class Vector: def __init__(self, length=3, vec=None): self._vec = [] if isinstance(vec, list): self._vec = vec.copy() elif isinstance(length, (int, float)): for i in range(int(length)): self._vec.append(0) self._length = len(self._vec) de...
''' This file contains config values (like the port numbers) used by our library ''' #:port to use for socket communications PORT = 1001 #:ip address of group to use for multicast communications MULTICAST_GROUP_IP = '224.15.35.42' #:port to use for multicast communications MULTICAST_PORT = 10000 #:the default timeout f...
""" This file contains config values (like the port numbers) used by our library """ port = 1001 multicast_group_ip = '224.15.35.42' multicast_port = 10000 default_timeout = 10 max_connect_requests = 5 network_chunk_size = 8192
food_items = [ "ham", #"spam", "eggs", "nuts" ] for food in food_items: if food == "spam": print ("No spam please") break print ("Great - ", food) #else: # print ("I am glad - There was no spam") print ("Finally I have finished")
food_items = ['ham', 'eggs', 'nuts'] for food in food_items: if food == 'spam': print('No spam please') break print('Great - ', food) print('Finally I have finished')
# https://leetcode.com/problems/sum-of-two-integers/ class Solution: def getSum(self, a: int, b: int) -> int: result = sum([a, b]) return result a = 1 b = 2 s = Solution() result = s.getSum(a, b)
class Solution: def get_sum(self, a: int, b: int) -> int: result = sum([a, b]) return result a = 1 b = 2 s = solution() result = s.getSum(a, b)
class HttpHeaders: X_CORRELATION_ID = "X-Correlation-ID" CONTENT_TYPE = "Content-Type" ACCEPT = 'Accept'
class Httpheaders: x_correlation_id = 'X-Correlation-ID' content_type = 'Content-Type' accept = 'Accept'
ES_HOST = 'localhost:9200' ES_INDEX = 'pending-repodb' ES_DOC_TYPE = 'chemical' API_PREFIX = 'repodb' API_VERSION = ''
es_host = 'localhost:9200' es_index = 'pending-repodb' es_doc_type = 'chemical' api_prefix = 'repodb' api_version = ''
def match(text, pattern, base=10): text_len = len(text) pattern_len = len(pattern) text_hash = _get_hash(text[:pattern_len], base) pattern_hash = _get_hash(pattern, base) matches = [] for i in xrange(text_len - pattern_len + 1): if pattern_hash == text_hash: # If the hashe...
def match(text, pattern, base=10): text_len = len(text) pattern_len = len(pattern) text_hash = _get_hash(text[:pattern_len], base) pattern_hash = _get_hash(pattern, base) matches = [] for i in xrange(text_len - pattern_len + 1): if pattern_hash == text_hash: if pattern == tex...
class Form: company: str user: str days: int def __init__(self, company, user, days): self.company = company self.user = user self.days = days
class Form: company: str user: str days: int def __init__(self, company, user, days): self.company = company self.user = user self.days = days
def large(arr): if (len(arr)) < 0: return 0 max_sum = current = arr[0] for num in arr[1:]: current = max(current + num, num) max_sum = max(current, max_sum) return max_sum if __name__ == "__main__": print(large([1, -1, 3, -4, 5, -3, 6, -3, 2, -1]))
def large(arr): if len(arr) < 0: return 0 max_sum = current = arr[0] for num in arr[1:]: current = max(current + num, num) max_sum = max(current, max_sum) return max_sum if __name__ == '__main__': print(large([1, -1, 3, -4, 5, -3, 6, -3, 2, -1]))
for i in range(int(input())): n, k, s = list(map(int, input().split())) total = k * s count = 0 val = False m = 0 for j in range(1, s + 1): if (j % 7) != 0: count += n m += 1 else: continue if count >= total: val = True ...
for i in range(int(input())): (n, k, s) = list(map(int, input().split())) total = k * s count = 0 val = False m = 0 for j in range(1, s + 1): if j % 7 != 0: count += n m += 1 else: continue if count >= total: val = True ...
# Python program to display astrological sign # or Zodiac sign for given date of birth def zodiac_sign(day, month): # checks month and date within the valid range # of a specified zodiac if month == 'december': astro_sign = 'Sagittarius' if (day < 22) else 'capricorn' elif month == 'january'...
def zodiac_sign(day, month): if month == 'december': astro_sign = 'Sagittarius' if day < 22 else 'capricorn' elif month == 'january': astro_sign = 'Capricorn' if day < 20 else 'aquarius' elif month == 'february': astro_sign = 'Aquarius' if day < 19 else 'pisces' elif month == 'ma...
class Redirect(Exception): def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs
class Redirect(Exception): def __init__(self, *args, **kwargs): self.args = args self.kwargs = kwargs
audio = [ "aif", "cda", "mid", "midi", "mp3", "mpa", "ogg", "wav", "wma", "wpl" ] compressed = [ "arj", "deb", "gz", "pkg", "rar", "rpm", "tar", "z", "zip" ] image = [ "ai", "bmp", "gif", "ico", "jpeg", "jpg", "png",...
audio = ['aif', 'cda', 'mid', 'midi', 'mp3', 'mpa', 'ogg', 'wav', 'wma', 'wpl'] compressed = ['arj', 'deb', 'gz', 'pkg', 'rar', 'rpm', 'tar', 'z', 'zip'] image = ['ai', 'bmp', 'gif', 'ico', 'jpeg', 'jpg', 'png', 'ps', 'psd', 'svg', 'tif', 'tiff', 'webp'] spreadsheet = ['ods', 'xlr', 'xls', 'xlsx'] text = ['doc', 'docx'...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- class UnknownSizeError(Exception): def __init__(self, cls): self.cls = cls def __str__(self): return f'The size of `{self.cls}` is unkown, the object could not be generated.' class UnavalibleAttributeError(Exception): def __init__(sel...
class Unknownsizeerror(Exception): def __init__(self, cls): self.cls = cls def __str__(self): return f'The size of `{self.cls}` is unkown, the object could not be generated.' class Unavalibleattributeerror(Exception): def __init__(self, cls, attr_name): self.cls = cls sel...
# test short circuit expressions outside if conditionals print(() or 1) print((1,) or 1) print(() and 1) print((1,) and 1) print("PASS")
print(() or 1) print((1,) or 1) print(() and 1) print((1,) and 1) print('PASS')
TRAINING_DATA = [ ( "i went to amsterdem last year and the canals were beautiful", {"entities": [(10, 19, "TOURIST_DESTINATION")]}, ), ( "You should visit Paris once in your life, but the Eiffel Tower is kinda boring", {"entities": [(17, 22, "TOURIST_DESTINATION")]}, ), ...
training_data = [('i went to amsterdem last year and the canals were beautiful', {'entities': [(10, 19, 'TOURIST_DESTINATION')]}), ('You should visit Paris once in your life, but the Eiffel Tower is kinda boring', {'entities': [(17, 22, 'TOURIST_DESTINATION')]}), ("There's also a Paris in Arkansas, lol", {'entities': [...
class LoraCommands: ## Returns the firmware version and release date in format: "RN2903 X.Y.Z MMM DD YYYY HH:MM:SS" GET_VERSION = 'sys get ver' ## Resets LoRa stack RESET_STACK = 'mac reset' ## Sets the LoRA functionality to radio (needs to be done before anything else) START_RADIO_O...
class Loracommands: get_version = 'sys get ver' reset_stack = 'mac reset' start_radio_op = 'mac pause' set_radio_power = 'radio set pwr {}' get_radio_mode = 'radio get mod' get_radio_frequency = 'radio get freq' get_radio_spreading_factor = 'radio get sf' set_continuous_radio_reception =...
# DataBase Credentials database="da665kfg2oc9og" user = "aourrzrdjlrpjo" password = "12359d0fa8d70aeea4d2ef3acd96eb794f178dee42887f7c350ad49a4d78e323" host = "ec2-18-207-95-219.compute-1.amazonaws.com" port = "5432"
database = 'da665kfg2oc9og' user = 'aourrzrdjlrpjo' password = '12359d0fa8d70aeea4d2ef3acd96eb794f178dee42887f7c350ad49a4d78e323' host = 'ec2-18-207-95-219.compute-1.amazonaws.com' port = '5432'
# http://codeforces.com/contest/268/problem/C n, m = map(int, input().split()) d = min(n, m) print(d + 1) for i in range(d + 1): print("{} {}".format(d-i, i))
(n, m) = map(int, input().split()) d = min(n, m) print(d + 1) for i in range(d + 1): print('{} {}'.format(d - i, i))
infile = "input_file.txt" outfile = "output_file.txt" delete_list = [ # Your words you want to fill to filter. "Dog","Bird","Pig" ] with open(infile) as fin, open(outfile, "w+") as fout: for line in fin: for word in delete_list: line = line.replace(word, "") fout.write(line)
infile = 'input_file.txt' outfile = 'output_file.txt' delete_list = ['Dog', 'Bird', 'Pig'] with open(infile) as fin, open(outfile, 'w+') as fout: for line in fin: for word in delete_list: line = line.replace(word, '') fout.write(line)
answers =[ "Apple", "Apricot", "Avocado", "Banana", "Bilberry", "Blackberry", "Blackcurrant", "Blueberry", "Cherry", "Coconut", "Cranberry", "Date", "Dragonfruit", "Durian", "Grape", "Grapefruit", "Guava", "Jackfruit", "Jujube", "Kiwifruit"...
answers = ['Apple', 'Apricot', 'Avocado', 'Banana', 'Bilberry', 'Blackberry', 'Blackcurrant', 'Blueberry', 'Cherry', 'Coconut', 'Cranberry', 'Date', 'Dragonfruit', 'Durian', 'Grape', 'Grapefruit', 'Guava', 'Jackfruit', 'Jujube', 'Kiwifruit', 'Kumquat', 'Lemon', 'Lime', 'Longan', 'Lychee', 'Mango', 'Mangosteen', 'Melon'...
puzzle_input_list = [] with open("input.txt", "r") as puzzle_input: for line in puzzle_input: line = line.strip() puzzle_input_list.append(line) open_brackets = {"{", "(", "[", "<"} bracket_mapping = {"}": "{", ")": "(", "]": "[", ">": "<", "{": "}", "(": ")", "[": "]", "<": ">"...
puzzle_input_list = [] with open('input.txt', 'r') as puzzle_input: for line in puzzle_input: line = line.strip() puzzle_input_list.append(line) open_brackets = {'{', '(', '[', '<'} bracket_mapping = {'}': '{', ')': '(', ']': '[', '>': '<', '{': '}', '(': ')', '[': ']', '<': '>'} bracket_to_points =...
#Kunal Gautam #Codewars : @Kunalpod #Problem name: Average Scores #Problem level: 7 kyu def average(array): return round(sum(array)/len(array))
def average(array): return round(sum(array) / len(array))
class Allergies(object): items = { 'eggs': 1, 'peanuts': 2, 'shellfish': 4, 'strawberries': 8, 'tomatoes': 16, 'chocolate': 32, 'pollen': 64, 'cats': 128, } def __init__(self, score): self._score = score def is_allergic_to(self, i...
class Allergies(object): items = {'eggs': 1, 'peanuts': 2, 'shellfish': 4, 'strawberries': 8, 'tomatoes': 16, 'chocolate': 32, 'pollen': 64, 'cats': 128} def __init__(self, score): self._score = score def is_allergic_to(self, item): return bool(Allergies.items.get(item, 0) & self._score) ...
def main(): # Let's create a dictionary with student keys and GPA values student_gpa = {"john": 3.5, "jane": 4.0, "bob": 2.8, "mary": 3.2} # There are four student records in this dictionary assert len(student_gpa) == 4 # Each student has a ...
def main(): student_gpa = {'john': 3.5, 'jane': 4.0, 'bob': 2.8, 'mary': 3.2} assert len(student_gpa) == 4 assert len(student_gpa.keys()) == len(student_gpa.values()) for student in student_gpa.keys(): assert len(student) > 2 for gpa in student_gpa.values(): assert gpa > 2.0 asse...
class Heap: def __init__(self,comp): self.hp = [] self.size = 0 self.comp = comp def push(self,value): self.hp.append(value) self.size += 1 self._heapifyForInsertion() def pop(self): if self.size == 0: return None value = self.hp[0]...
class Heap: def __init__(self, comp): self.hp = [] self.size = 0 self.comp = comp def push(self, value): self.hp.append(value) self.size += 1 self._heapifyForInsertion() def pop(self): if self.size == 0: return None value = self....
names = [] for i in range(10): X =str(input('')) names.append(X) print(names[2]) print(names[6]) print(names[8])
names = [] for i in range(10): x = str(input('')) names.append(X) print(names[2]) print(names[6]) print(names[8])
def addBinary(a: str, b: str) -> str: n_a = len(a) n_b = len(b) max_n = max(n_a, n_b) a = a.rjust(max_n, "0") b = b.rjust(max_n, "0") jin_bit = 0 result = "" for i in range(max_n - 1, -1, -1): tmp_a = int(a[i]) tmp_b = int(b[i]) tmp = tmp_a + tmp_b + jin_bit ...
def add_binary(a: str, b: str) -> str: n_a = len(a) n_b = len(b) max_n = max(n_a, n_b) a = a.rjust(max_n, '0') b = b.rjust(max_n, '0') jin_bit = 0 result = '' for i in range(max_n - 1, -1, -1): tmp_a = int(a[i]) tmp_b = int(b[i]) tmp = tmp_a + tmp_b + jin_bit ...
# Performance note: I benchmarked this code using a set instead of # a list for the stopwords and was surprised to find that the list # performed /better/ than the set - maybe because it's only a small # list. stopwords = ''' i a an are as at be by for from how in is it of on or that the this ...
stopwords = '\ni\na\nan\nare\nas\nat\nbe\nby\nfor\nfrom\nhow\nin\nis\nit\nof\non\nor\nthat\nthe\nthis\nto\nwas\nwhat\nwhen\nwhere\n'.split() def strip_stopwords(sentence): """Removes stopwords - also normalizes whitespace""" words = sentence.split() sentence = [] for word in words: if word.lowe...
# st2common __all__ = ["MASKED_ATTRIBUTES_BLACKLIST", "MASKED_ATTRIBUTE_VALUE"] # A blacklist of attributes which should be masked in the log messages by default. # Note: If an attribute is an object or a dict, we try to recursively process it and mask the # values. MASKED_ATTRIBUTES_BLACKLIST = [ "password", ...
__all__ = ['MASKED_ATTRIBUTES_BLACKLIST', 'MASKED_ATTRIBUTE_VALUE'] masked_attributes_blacklist = ['password', 'auth_token', 'token', 'secret', 'credentials', 'st2_auth_token'] masked_attribute_value = '********'
combination = [(True,True,True),(True,True,False),(True,False,True),(True,False,False),(False,True,True),(False,True,False),(False,False,True),(False,False,False)] variable = {'p':0,'q':1,'r':2} kb = '' q = '' priority = {'~':3,'v':1,'^':2} def input_rules(): global kb,q kb = (input("Enter rule : ...
combination = [(True, True, True), (True, True, False), (True, False, True), (True, False, False), (False, True, True), (False, True, False), (False, False, True), (False, False, False)] variable = {'p': 0, 'q': 1, 'r': 2} kb = '' q = '' priority = {'~': 3, 'v': 1, '^': 2} def input_rules(): global kb, q kb = ...
{ 'includes': [ 'common.gypi', ], 'targets': [ { 'target_name': 'svg', 'type': 'static_library', 'include_dirs': [ '../include/config', '../include/core', '../include/xml', '../include/utils', '../include/svg', ], 'sources': [ '...
{'includes': ['common.gypi'], 'targets': [{'target_name': 'svg', 'type': 'static_library', 'include_dirs': ['../include/config', '../include/core', '../include/xml', '../include/utils', '../include/svg'], 'sources': ['../include/svg/SkSVGAttribute.h', '../include/svg/SkSVGBase.h', '../include/svg/SkSVGPaintState.h', '....
def SetUpGame(): global WreckContainer, ShipContainer, PlanetContainer, ArchiveContainer, playerShip, gameData, SystemContainer GameData = gameData() GameData.tutorial = False PlanetContainer = [Planet(0, -1050, 1000)] GameData.homePlanet = PlanetContainer[0] GameData.tasks = [] PlanetContai...
def set_up_game(): global WreckContainer, ShipContainer, PlanetContainer, ArchiveContainer, playerShip, gameData, SystemContainer game_data = game_data() GameData.tutorial = False planet_container = [planet(0, -1050, 1000)] GameData.homePlanet = PlanetContainer[0] GameData.tasks = [] PlanetC...
class SearchGoogleNewsError(Exception): pass class SearchGoogleNewsDataSourceNotFound(Exception): pass class SearchGoogleNewsParseError(Exception): pass
class Searchgooglenewserror(Exception): pass class Searchgooglenewsdatasourcenotfound(Exception): pass class Searchgooglenewsparseerror(Exception): pass
#!/usr/bin/env python3 # Character Picture Grid grid = [ [".", ".", ".", ".", ".", "."], [".", "O", "O", ".", ".", "."], ["O", "O", "O", "O", ".", "."], ["O", "O", "O", "O", "O", "."], [".", "O", "O", "O", "O", "O"], ["O", "O", "O", "O", "O", "."], ["O", "O", "O", "O", ".", "."], [".", ...
grid = [['.', '.', '.', '.', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['O', 'O', 'O', 'O', 'O', '.'], ['.', 'O', 'O', 'O', 'O', 'O'], ['O', 'O', 'O', 'O', 'O', '.'], ['O', 'O', 'O', 'O', '.', '.'], ['.', 'O', 'O', '.', '.', '.'], ['.', '.', '.', '.', '.', '.']] rows = len(grid) columns...
# # PySNMP MIB module HH3C-VM-MAN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-VM-MAN-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:30:16 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') (single_value_constraint, value_range_constraint, constraints_intersection, constraints_union, value_size_constraint) ...
# 17. Take 10 integers from keyboard using loop and print their average value on the screen. (use array to store inputs). numbers = list(map(int, input("Enter 10 numbers:").split())) if len(numbers) >= 10: numbers = numbers[0:10] print("10 Numbers are", numbers) print("Average=", sum(numbers)/len(numbers)...
numbers = list(map(int, input('Enter 10 numbers:').split())) if len(numbers) >= 10: numbers = numbers[0:10] print('10 Numbers are', numbers) print('Average=', sum(numbers) / len(numbers))
def parse_parts(line): space_separated_parts = line.split() bounds = space_separated_parts[0].split('-') char = space_separated_parts[1].split(':')[0] password = space_separated_parts[2] return int(bounds[0]), int(bounds[1]), char, password def is_valid_first(min_req, max_req, letter, password): ...
def parse_parts(line): space_separated_parts = line.split() bounds = space_separated_parts[0].split('-') char = space_separated_parts[1].split(':')[0] password = space_separated_parts[2] return (int(bounds[0]), int(bounds[1]), char, password) def is_valid_first(min_req, max_req, letter, password): ...
# Given a collection of numbers, return all possible permutations. # For example, # [1,2,3] have the following permutations: # [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1]. # [1,2] have the following permutations: # [1,2], [2,1] class Solution: # @param {integer[]} nums # @return {integer[][]} ...
class Solution: def permute(self, nums): ans = [] stack = [([], nums)] while stack: (ret, nums) = stack.pop(0) if nums: for i in range(len(nums)): stack.append((ret + [nums[i]], nums[:i] + nums[i + 1:])) else: ...
# import pytest class TestDatabase: def test___call__(self): # synced assert True def test_default_schema(self): # synced assert True def test_schema_names(self): # synced assert True def test_table_names(self): # synced assert True def test_view_names(self)...
class Testdatabase: def test___call__(self): assert True def test_default_schema(self): assert True def test_schema_names(self): assert True def test_table_names(self): assert True def test_view_names(self): assert True def test_create_table(self): ...
class Vetor: def __init__(self, x=0, y=0): self.x = x self.y = y def __repr__(self): return 'Vetor (%r,%r)' % (self.x, self.y) def __mul__(self, escalar): x = self.x * escalar y = self.y * escalar return Vetor(x, y) def __add__(self, outro): x ...
class Vetor: def __init__(self, x=0, y=0): self.x = x self.y = y def __repr__(self): return 'Vetor (%r,%r)' % (self.x, self.y) def __mul__(self, escalar): x = self.x * escalar y = self.y * escalar return vetor(x, y) def __add__(self, outro): x ...
SUBJ_REPORT = "Problem Report: ExCEED Labs" ERROR_NO_EMAIL_TO_GET_AHOLD = "We need to know how to get ahold of you!" ERROR_NO_REPORT = "Don't forget to add your problem report or request!" ERROR_NOT_SUBMITTED = "There was a problem with your submission. Please try again!" SUCCESS_REPORT_SUBMITTED = "Success! Your pro...
subj_report = 'Problem Report: ExCEED Labs' error_no_email_to_get_ahold = 'We need to know how to get ahold of you!' error_no_report = "Don't forget to add your problem report or request!" error_not_submitted = 'There was a problem with your submission. Please try again!' success_report_submitted = 'Success! Your probl...
# Sum square difference # https://projecteuler.net/problem=6 def solve(n): sn = (n*(n+1)//2) * (n*(n+1)//2) sn2 = n*(n+1)*(2*n+1)//6 # sum of first n squared natural numbers return abs(sn - sn2) print(solve(100))
def solve(n): sn = n * (n + 1) // 2 * (n * (n + 1) // 2) sn2 = n * (n + 1) * (2 * n + 1) // 6 return abs(sn - sn2) print(solve(100))
_base_ = [ '../_base_/models/paa_distil_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py' ] model = dict( type='LAD', # student pretrained='torchvision://resnet50', backbone=dict(depth=50), bbox_head=dict(...
_base_ = ['../_base_/models/paa_distil_fpn.py', '../_base_/datasets/coco_detection.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'] model = dict(type='LAD', pretrained='torchvision://resnet50', backbone=dict(depth=50), bbox_head=dict(type='PAA_LAD_Head'), teacher_pretrained='http://download.op...
class Solution(object): def solveNQueens(self, n): def dfs(queens, xy_sub, xy_plus): row = len(queens) if row == n: result.append(queens) return None for col in range(n): if col not in queens and col + row not in xy_plus and...
class Solution(object): def solve_n_queens(self, n): def dfs(queens, xy_sub, xy_plus): row = len(queens) if row == n: result.append(queens) return None for col in range(n): if col not in queens and col + row not in xy_plus...
def merge_sort_time(job_list): ''' sorts the list by timestamp :return: array ''' if len(job_list) > 1: mid = len(job_list) // 2 lefthalf = job_list[:mid] righthalf = job_list[mid:] merge_sort_time(lefthalf) merge_sort_time(righthalf) i =...
def merge_sort_time(job_list): """ sorts the list by timestamp :return: array """ if len(job_list) > 1: mid = len(job_list) // 2 lefthalf = job_list[:mid] righthalf = job_list[mid:] merge_sort_time(lefthalf) merge_sort_time(righthalf) i = 0...
# # PySNMP MIB module CHARACTER-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/CHARACTER-MIB # Produced by pysmi-0.0.7 at Sun Feb 14 00:06:47 2016 # On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose # Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52) # ( ...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ...
def write_results(results, save_path): output = [] for k, v in results.items(): output.append("{}: {}".format(k, v)) output.append("\n") output.append("If you need to access these results for the future " "they are stored in: {}".format(save_path)) with open(save_pat...
def write_results(results, save_path): output = [] for (k, v) in results.items(): output.append('{}: {}'.format(k, v)) output.append('\n') output.append('If you need to access these results for the future they are stored in: {}'.format(save_path)) with open(save_path, 'w') as fp: ...
houses = {"Harry": "Gryffindor", "Draco": "Slytherin"} houses["Hermione"] = "Gryffindor" print(houses["Harry"])
houses = {'Harry': 'Gryffindor', 'Draco': 'Slytherin'} houses['Hermione'] = 'Gryffindor' print(houses['Harry'])
# class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def oddEvenList(self, head): if not head: return None i = 0 tmp = head first = True prev = None tmp_even_head = None tail = None ...
class Solution: def odd_even_list(self, head): if not head: return None i = 0 tmp = head first = True prev = None tmp_even_head = None tail = None while tmp: if i % 2 != 0: if first: second_l...
def lineup_students(string): return sorted(string.split(), key=lambda x: (len(x), x), reverse=True) # lineup_students = lambda s: sorted(s.split(), key=lambda x: (len(x), x), reverse=True)
def lineup_students(string): return sorted(string.split(), key=lambda x: (len(x), x), reverse=True)
# Accept a positive integer and print the reverse of it. n = int(input("Enter a positive integer: ")) # | n = 123 print() rev = 0 # | rev = 0 while n > 0: # | 123 > 0 = True | 12 > 0 = True | 1 > 0 = True | ...
n = int(input('Enter a positive integer: ')) print() rev = 0 while n > 0: digit = n % 10 rev = rev * 10 + digit n = n // 10 print('The reverse of the number is:', rev)
def parse_plotter_args(parser): parser.add_option( "--name_of_3dmodel", type="string", default="airplane/airplane_0630.ply", help="name of 3D model to plot using the 'plot_subclouds' script", ) parser.add_option( "--save_plot_frames", action="store_true", ...
def parse_plotter_args(parser): parser.add_option('--name_of_3dmodel', type='string', default='airplane/airplane_0630.ply', help="name of 3D model to plot using the 'plot_subclouds' script") parser.add_option('--save_plot_frames', action='store_true', default=False, help="whether to record the 3D model shown in...
PART_NAMES = [ "nose", "leftEye", "rightEye", "leftEar", "rightEar", "leftShoulder", "rightShoulder", "leftElbow", "rightElbow", "leftWrist", "rightWrist", "leftHip", "rightHip", "leftKnee", "rightKnee", "leftAnkle", "rightAnkle" ] NUM_KEYPOINTS = len(PART_NAMES) PART_IDS = {pn: pid for pid, pn in enumer...
part_names = ['nose', 'leftEye', 'rightEye', 'leftEar', 'rightEar', 'leftShoulder', 'rightShoulder', 'leftElbow', 'rightElbow', 'leftWrist', 'rightWrist', 'leftHip', 'rightHip', 'leftKnee', 'rightKnee', 'leftAnkle', 'rightAnkle'] num_keypoints = len(PART_NAMES) part_ids = {pn: pid for (pid, pn) in enumerate(PART_NAMES)...
to_remove = input() word = input() while to_remove in word: word = word.replace(to_remove, '') print(word)
to_remove = input() word = input() while to_remove in word: word = word.replace(to_remove, '') print(word)
BASE_URL = 'https://www.instagram.com/' LOGIN_URL = BASE_URL + 'accounts/login/ajax/' LOGOUT_URL = BASE_URL + 'accounts/logout/' MEDIA_URL = BASE_URL + '{0}/media' CHROME_WIN_UA = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36' STORIES_URL = 'https://i.i...
base_url = 'https://www.instagram.com/' login_url = BASE_URL + 'accounts/login/ajax/' logout_url = BASE_URL + 'accounts/logout/' media_url = BASE_URL + '{0}/media' chrome_win_ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36' stories_url = 'https://i.in...
if __name__ == '__main__': name = ' aleX' print(name.strip()) # name = name.strip() if name.startswith('al'): print('yes') if name.endswith('X'): print('yes') print(name.replace('l', 'p')) # name = name.replace('l', 'p') print(name.split('l')) print(type(name.split('e...
if __name__ == '__main__': name = ' aleX' print(name.strip()) if name.startswith('al'): print('yes') if name.endswith('X'): print('yes') print(name.replace('l', 'p')) print(name.split('l')) print(type(name.split('e'))) print(name.upper()) print(name.lower()) print...
''' Created on 16.1.2017 @author: jm ''' class GedcomLine(object): ''' Gedcom line container, which can also carry the lower level gedcom lines. Example - level 2 - tag 'GIVN' - value 'Johan' ...} ''' # Current path elemements # See https://docs.python.org/3/faq/...
""" Created on 16.1.2017 @author: jm """ class Gedcomline(object): """ Gedcom line container, which can also carry the lower level gedcom lines. Example - level 2 - tag 'GIVN' - value 'Johan' ...} """ path_elem = [] def __init__(self, line, linenum=0): "...
'''input 1 1 1 0 1 0 0 0 1 0 1 3 4 5 6 7 8 9 -2 -3 4 -2 8 3 1 1 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 -8 6 -2 -8 -8 4 8 7 -6 2 2 -9 2 0 1 7 -5 0 -2 -6 5 5 6 -6 7 -9 6 -5 8 0 -9 -7 -7 23 2 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 3 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1 0 -2 -2 -2 -2 -2 -1 -...
"""input 1 1 1 0 1 0 0 0 1 0 1 3 4 5 6 7 8 9 -2 -3 4 -2 8 3 1 1 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 0 1 0 1 0 1 1 0 1 0 1 0 1 -8 6 -2 -8 -8 4 8 7 -6 2 2 -9 2 0 1 7 -5 0 -2 -6 5 5 6 -6 7 -9 6 -5 8 0 -9 -7 -7 23 2 1 1 1 1 1 0 0 0 0 0 0 0 0 0 0 1 1 1 1 1 3 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1 0 -2 -2 -2 -2 -2 -1 -1 -1 -1 -1 1 2 1 1...
filename = 'programming_poll.txt' responses = [] while True: response = input("\nWhy do you like programming? ") responses.append(response) continue_poll = input("Would you like to let someone else respond? (y/n) ") if continue_poll != 'y': break with open(filename, 'a') as f: for respons...
filename = 'programming_poll.txt' responses = [] while True: response = input('\nWhy do you like programming? ') responses.append(response) continue_poll = input('Would you like to let someone else respond? (y/n) ') if continue_poll != 'y': break with open(filename, 'a') as f: for response i...
# # @lc app=leetcode id=1806 lang=python3 # # [1806] Minimum Number of Operations to Reinitialize a Permutation # # @lc code=start class Solution: def reinitializePermutation(self, n: int) -> int: i, cnt = 1, 0 while not cnt or i > 1: # i != 1 doesn't work i = i * 2 % (n - 1) ...
class Solution: def reinitialize_permutation(self, n: int) -> int: (i, cnt) = (1, 0) while not cnt or i > 1: i = i * 2 % (n - 1) cnt += 1 return cnt
class TestFunctionalTest(object): counter = 0 @classmethod def setup_class(cls): cls.counter += 1 @classmethod def teardown_class(cls): cls.counter -= 1 def _run(self): assert self.counter==1 def test1(self): self._run() def test2(self): self._run(...
class Testfunctionaltest(object): counter = 0 @classmethod def setup_class(cls): cls.counter += 1 @classmethod def teardown_class(cls): cls.counter -= 1 def _run(self): assert self.counter == 1 def test1(self): self._run() def test2(self): sel...
class Parameter: ''' Defines a sampled (or "free") parameter by spin, parity, channel, rank, and whether it's an energy or width (kind). kind : "energy" or "width" "width" can be the partial width or ANC (depending on how it was set up in AZURE2) channel : channel pair...
class Parameter: """ Defines a sampled (or "free") parameter by spin, parity, channel, rank, and whether it's an energy or width (kind). kind : "energy" or "width" "width" can be the partial width or ANC (depending on how it was set up in AZURE2) channel : channel pair...
config = { # these values are related to the user's environment 'env': { 'databases': { 'postgres_host': '127.0.0.1', 'postgres_name': 'jesse_db', 'postgres_port': 5432, 'postgres_username': 'jesse_user', 'postgres_password': 'password', ...
config = {'env': {'databases': {'postgres_host': '127.0.0.1', 'postgres_name': 'jesse_db', 'postgres_port': 5432, 'postgres_username': 'jesse_user', 'postgres_password': 'password'}, 'caching': {'driver': 'pickle'}, 'logging': {'order_submission': True, 'order_cancellation': True, 'order_execution': True, 'position_ope...