content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def compute_list_average(number_list): return sum(number_list) / len(number_list) number_list = [] for i in range(5): number_list.append(float(input("Give a number: "))) print(compute_list_average(number_list))
def compute_list_average(number_list): return sum(number_list) / len(number_list) number_list = [] for i in range(5): number_list.append(float(input('Give a number: '))) print(compute_list_average(number_list))
a = int(input()) b = int(input()) c = int(input()) if a == b == c: print(3) elif (a == b and a != c) or (a == c and a != b) or (b == c and a != c): print(2) else: print(0)
a = int(input()) b = int(input()) c = int(input()) if a == b == c: print(3) elif a == b and a != c or (a == c and a != b) or (b == c and a != c): print(2) else: print(0)
#triangular star pattern ''' Print the following pattern for the given N number of rows. Pattern for N = 4 * ** *** **** ''' rows=int(input()) for i in range(rows): for j in range(i+1): print("*",end="") print()
""" Print the following pattern for the given N number of rows. Pattern for N = 4 * ** *** **** """ rows = int(input()) for i in range(rows): for j in range(i + 1): print('*', end='') print()
class ContestError(Exception): def __init__(self, message: str = 'UGrade Error', *args) -> None: super(ContestError, self).__init__(message, *args) class NoSuchLanguageError(ContestError): def __init__(self, message: str = 'No Such Language') -> None: super(NoSuchLanguageError, self).__init__(...
class Contesterror(Exception): def __init__(self, message: str='UGrade Error', *args) -> None: super(ContestError, self).__init__(message, *args) class Nosuchlanguageerror(ContestError): def __init__(self, message: str='No Such Language') -> None: super(NoSuchLanguageError, self).__init__(mes...
n = int(input()) if n % 2 == 1 or 6 <= n <= 20: print('Weird') elif 2 <= n <= 5 or n > 20: print('Not Weird')
n = int(input()) if n % 2 == 1 or 6 <= n <= 20: print('Weird') elif 2 <= n <= 5 or n > 20: print('Not Weird')
class Solution: def sumOddLengthSubarrays(self, arr: List[int]) -> int: n = len(arr) k = 1 m = 0 total_sum = 0 while k <= n: for i in range(n - m): total_sum = total_sum + sum(arr[i:i + k]) if k <= n: k += 2 ...
class Solution: def sum_odd_length_subarrays(self, arr: List[int]) -> int: n = len(arr) k = 1 m = 0 total_sum = 0 while k <= n: for i in range(n - m): total_sum = total_sum + sum(arr[i:i + k]) if k <= n: k += 2 ...
arquivo = open("exercicio_1.txt", "w") arquivo.write("\nTeste 3") arquivo.write("\nTeste 4") arquivo.close() arquivo = open("exercicio_1.txt", "a") arquivo.write("\nTeste 5") arquivo.write("\nTeste 6") arquivo.close() arquivo = open("exercicio_1.txt", "w") arquivo.write("\nTeste 7") arquivo.write("\nTeste 8") arquivo...
arquivo = open('exercicio_1.txt', 'w') arquivo.write('\nTeste 3') arquivo.write('\nTeste 4') arquivo.close() arquivo = open('exercicio_1.txt', 'a') arquivo.write('\nTeste 5') arquivo.write('\nTeste 6') arquivo.close() arquivo = open('exercicio_1.txt', 'w') arquivo.write('\nTeste 7') arquivo.write('\nTeste 8') arquivo.c...
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def sortList(self, head: Optional[ListNode]) -> Optional[ListNode]: temp=head dd=[] ## looping through the LInklist ...
class Solution: def sort_list(self, head: Optional[ListNode]) -> Optional[ListNode]: temp = head dd = [] while temp: dd.append(temp.val) temp = temp.next dd.sort() temp = head for i in dd: temp.val = i temp = temp.next ...
class Report: def __init__(self): self.set_age('') self.set_date('') self.set_cause('') self.set_location('') self.set_remarks('') self.set_source('') def clear(): self.data = [] def empty(self): return (len(self.name) == 0) ...
class Report: def __init__(self): self.set_age('') self.set_date('') self.set_cause('') self.set_location('') self.set_remarks('') self.set_source('') def clear(): self.data = [] def empty(self): return len(self.name) == 0 def get_name(...
class AbstractMiddleware: def send_data(self): pass #def process_middleware_response(self): # pass
class Abstractmiddleware: def send_data(self): pass
# Lab 3: String Data Type # Exercise 1: The String Data Type myString="This is a string." print(myString) print(type(myString)) print(myString + " is of data type " + str(type(myString))) # Exercise 2: String Concatenation firstString="water" secondString="fall" thirdString= firstString + secondString ...
my_string = 'This is a string.' print(myString) print(type(myString)) print(myString + ' is of data type ' + str(type(myString))) first_string = 'water' second_string = 'fall' third_string = firstString + secondString print(thirdString) name = input('What is your name? ') print(name) color = input('What is your favorit...
def filter_child_dictionary(dictionary, key, value): newdict = {} for child_name in dictionary: child = dictionary[child_name] if not key in child: continue if str(child[key]) != str(value): continue newdict[child_name] = child return newdict def filter_child_attr(dictionary, key, ava...
def filter_child_dictionary(dictionary, key, value): newdict = {} for child_name in dictionary: child = dictionary[child_name] if not key in child: continue if str(child[key]) != str(value): continue newdict[child_name] = child return newdict def filt...
# x = 0x0a # y = 0x02 # z = x & y # print(f'Hex: x = {x:02X}, y = {y:02X}, z = {z:02X}') # print(f'Bin: x = {x:08b}, y = {y:08b}, z = {z:08b}') x = 0x0a y = 0x05 z = x ^ y print(f'Hex: x = {x:02X}, y = {y:02X}, z = {z:02X}') print(f'Bin: x = {x:08b}, y = {y:08b}, z = {z:08b}') # x = 0x0a # y = 0x02 # z ...
x = 10 y = 5 z = x ^ y print(f'Hex: x = {x:02X}, y = {y:02X}, z = {z:02X}') print(f'Bin: x = {x:08b}, y = {y:08b}, z = {z:08b}')
## Script (Python) "getFotos" ##bind container=container ##bind context=context ##bind namespace= ##bind script=script ##bind subpath=traverse_subpath ##parameters= ##title= root = context.portal_url.getPortalObject().getPhysicalPath()[1] path = '/' + root + '/multimidia/fotos' fotos = context.portal_catalog.searchRe...
root = context.portal_url.getPortalObject().getPhysicalPath()[1] path = '/' + root + '/multimidia/fotos' fotos = context.portal_catalog.searchResults(Type='Image', path=path) return fotos
selfish_mining_strategy = \ [ [ # irrelevant ['*', '*', '*', '*', '*', '*', '*', '*', '*', '*'], ['w', '*', 'a', '*', '*', '*', '*', '*', '*', '*'], ['w', 'w', '*', 'a', '*', '*', '*', '*', '*', '*'], ['w', 'w', 'w', '*', 'a', '*', '*', '*', '*', '*'], ['w', 'w', 'w', 'w', '...
selfish_mining_strategy = [[['*', '*', '*', '*', '*', '*', '*', '*', '*', '*'], ['w', '*', 'a', '*', '*', '*', '*', '*', '*', '*'], ['w', 'w', '*', 'a', '*', '*', '*', '*', '*', '*'], ['w', 'w', 'w', '*', 'a', '*', '*', '*', '*', '*'], ['w', 'w', 'w', 'w', '*', 'a', '*', '*', '*', '*'], ['w', 'w', 'w', 'w', 'w', '*', '...
'''An example of an internal module within the package Although the intenals are not explicity exposed, they are still available via import mhlib mhlib.eg.MhEg().runMhEg() import mhlib.l2.l2 mhlib.l2.l2.L2EG_VAR '''
"""An example of an internal module within the package Although the intenals are not explicity exposed, they are still available via import mhlib mhlib.eg.MhEg().runMhEg() import mhlib.l2.l2 mhlib.l2.l2.L2EG_VAR """
# argparse TRAIN_ARGS = [ '-i', 'flowers', '-o', 'checkpoints', '-a', 'resnet101', '--input_size', '2048', '--output_size', '102', '--hidden_layers', '1024', '512', '--learning_rate', '0.001', '--epochs', '3', '--gpu' ] PREDICT_ARGS = [ '--input_img', 'flowers/test/1/image_06743...
train_args = ['-i', 'flowers', '-o', 'checkpoints', '-a', 'resnet101', '--input_size', '2048', '--output_size', '102', '--hidden_layers', '1024', '512', '--learning_rate', '0.001', '--epochs', '3', '--gpu'] predict_args = ['--input_img', 'flowers/test/1/image_06743.jpg', '--checkpoint', 'checkpoints/checkpoint.pth', '-...
def ResponseModel(data,message): return { "data":[data], "code":200, "message":message } def ResponseCreateModel(message): return { "data": 1, "code":201, "message":message } def ErrorResponseModel(error,code,message): return { "error":error...
def response_model(data, message): return {'data': [data], 'code': 200, 'message': message} def response_create_model(message): return {'data': 1, 'code': 201, 'message': message} def error_response_model(error, code, message): return {'error': error, 'code': code, 'message': message}
__author__ = 'davidl' class BaseMonitorDriver(object): def notify(self,fixture_id, info): print (info) def notify_blocking_request(self,fixture_id, info): print (info) return True
__author__ = 'davidl' class Basemonitordriver(object): def notify(self, fixture_id, info): print(info) def notify_blocking_request(self, fixture_id, info): print(info) return True
new_list = [] people = ['agnes', 'andrew','jane','peter'] for person in people: if person[0] == 'a': new_list.append(person) print(new_list)
new_list = [] people = ['agnes', 'andrew', 'jane', 'peter'] for person in people: if person[0] == 'a': new_list.append(person) print(new_list)
try: num1 = int(input("TELL ME YOUR AGE\n")) num2 = int(input("TELL ME YOUR name\n")) print(num1 + num2) # print(num2) except Exception as dfdfe: print(dfdfe) print("HELLO\n")
try: num1 = int(input('TELL ME YOUR AGE\n')) num2 = int(input('TELL ME YOUR name\n')) print(num1 + num2) except Exception as dfdfe: print(dfdfe) print('HELLO\n')
# # PySNMP MIB module DFRAP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DFRAP-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:42:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, constraints_intersection, value_size_constraint, constraints_union, single_value_constraint) ...
#!/opt/evawiz/python/bin/python #normal python defination code here def pyAdd(x,y): return abs(x)+abs(y)
def py_add(x, y): return abs(x) + abs(y)
class Solution: def scheduleCourse(self, courses: List[List[int]]) -> int: best = 0 timeSpent = 0 h = [] current = 0 courses.sort(key=lambda x: x[1]) for duration, last in courses: heapq.heappush(h, -duration) timeSpent += duration ...
class Solution: def schedule_course(self, courses: List[List[int]]) -> int: best = 0 time_spent = 0 h = [] current = 0 courses.sort(key=lambda x: x[1]) for (duration, last) in courses: heapq.heappush(h, -duration) time_spent += duration ...
# -*- coding:utf-8 -*- WENCAI_LOGIN_URL = { "scrape_transaction": 'http://www.iwencai.com/traceback/strategy/transaction', "scrape_report": 'http://www.iwencai.com/traceback/strategy/submit', 'strategy': 'http://www.iwencai.com/traceback/strategy/submit', "search": "http://www.iwencai.com/data-robot/e...
wencai_login_url = {'scrape_transaction': 'http://www.iwencai.com/traceback/strategy/transaction', 'scrape_report': 'http://www.iwencai.com/traceback/strategy/submit', 'strategy': 'http://www.iwencai.com/traceback/strategy/submit', 'search': 'http://www.iwencai.com/data-robot/extract-new', 'recommend_strategy': 'http:/...
class ConfigAttributeDataTypes: data_types = { 0: 'None', 1: 'Base64', 2: 'Boolean', 3: 'CaseExactString', 4: 'CaseIgnoreList', 5: 'CaseIgnoreString, String', 6: 'Counter', 7: 'DistinguishedName', 8: 'EMailAddress', 9: 'FaxNum...
class Configattributedatatypes: data_types = {0: 'None', 1: 'Base64', 2: 'Boolean', 3: 'CaseExactString', 4: 'CaseIgnoreList', 5: 'CaseIgnoreString, String', 6: 'Counter', 7: 'DistinguishedName', 8: 'EMailAddress', 9: 'FaxNumber', 10: 'Hold', 11: 'Integer', 12: 'Interval', 13: 'IPNetworkAddress', 14: 'NetworkAddres...
# Python code to demonstrate the working of # "+" and "*" # initializing list 1 lis = [1, 2, 3] # initializing list 2 lis1 = [4, 5, 6] # using "+" to concatenate lists lis2= lis + lis1 # priting concatenated lists print ("list after concatenation is : ", end="") for i in range(0,len(lis2)): print (lis2[i...
lis = [1, 2, 3] lis1 = [4, 5, 6] lis2 = lis + lis1 print('list after concatenation is : ', end='') for i in range(0, len(lis2)): print(lis2[i], end=' ') print('\r') lis3 = lis * 3 print('list after combining is : ', end='') for i in range(0, len(lis3)): print(lis3[i], end=' ')
# -*- coding: utf-8 -*- stuff = ['hello', 'hi', 'how are you doing', 'im fine', 'how about you'] length_of_stuff = len(stuff) index = 0 while index < length_of_stuff: print(stuff[index]) index += 1
stuff = ['hello', 'hi', 'how are you doing', 'im fine', 'how about you'] length_of_stuff = len(stuff) index = 0 while index < length_of_stuff: print(stuff[index]) index += 1
# Returns list of a specific attribute in yaml file. Attribute could be aliases/filter/category/id. def icon_list(p_list, *pos): if pos: return [p_list[i][pos[0]] for i in range(len(p_list)) if (p_list[i][pos[0]] is not None)] else: return [p_list[i][2] for i in range(len(p_list))] # Displays l...
def icon_list(p_list, *pos): if pos: return [p_list[i][pos[0]] for i in range(len(p_list)) if p_list[i][pos[0]] is not None] else: return [p_list[i][2] for i in range(len(p_list))] def icon_output(l): print('Icon(s) matched this criteria :') for i in l: print(i) def give_id_uni...
for x in range(10): pass for x in range(5): a += x b += 2 if False: break else: continue else: c = 3 for index, val in enumerate(range(5)): val *= 2
for x in range(10): pass for x in range(5): a += x b += 2 if False: break else: continue else: c = 3 for (index, val) in enumerate(range(5)): val *= 2
# Que 20 Leap Year print ("Leap Year Has 366 Days...") print ('The Year Perfectly Divisible by 4 is A Leap Year') z=0 for i in range(2010,2101,1): if i%4==0: z=z+1 if z<=10: print(i,end=" ") else: z=1 print() print(i,end=" ")
print('Leap Year Has 366 Days...') print('The Year Perfectly Divisible by 4 is A Leap Year') z = 0 for i in range(2010, 2101, 1): if i % 4 == 0: z = z + 1 if z <= 10: print(i, end=' ') else: z = 1 print() print(i, end=' ')
def get_ns_declare(fd): while True: line = fd.readline() if line.strip().startswith('(ns'): return line def get_ns(filename): with open(filename, 'r') as infile: ns_declare = get_ns_declare(infile) splited = ns_declare.split() ns = splited[-1] if ns....
def get_ns_declare(fd): while True: line = fd.readline() if line.strip().startswith('(ns'): return line def get_ns(filename): with open(filename, 'r') as infile: ns_declare = get_ns_declare(infile) splited = ns_declare.split() ns = splited[-1] if ns.e...
num1 = int(input()) num2 = int(input()) if num1 > num2: print(num1-num2) else: print(num1+num2)
num1 = int(input()) num2 = int(input()) if num1 > num2: print(num1 - num2) else: print(num1 + num2)
def gp(a,r,n): for i in range(n): temp = a*pow(r,i) print(temp,end=" ") a = int(input()) r = int(input()) n = int(input()) gp(a,r,n)
def gp(a, r, n): for i in range(n): temp = a * pow(r, i) print(temp, end=' ') a = int(input()) r = int(input()) n = int(input()) gp(a, r, n)
class BatchReferenceSampler: def __init__( self, dataset, batch_size, label_sampler, annotation_sampler, point_sampler ): self._dataset = dataset self._batch_size = batch_size self._label_sampler = label_sampler self._annotation_sampler = annotation_sampler self....
class Batchreferencesampler: def __init__(self, dataset, batch_size, label_sampler, annotation_sampler, point_sampler): self._dataset = dataset self._batch_size = batch_size self._label_sampler = label_sampler self._annotation_sampler = annotation_sampler self._point_sampler...
name = 'pybk8500' version = '1.2.0' description = 'BK-8500-Electronic-Load python library' url = 'https://github.com/justengel/pybk8500' author = 'Justin Engel' author_email = 'jtengel08@gmail.com'
name = 'pybk8500' version = '1.2.0' description = 'BK-8500-Electronic-Load python library' url = 'https://github.com/justengel/pybk8500' author = 'Justin Engel' author_email = 'jtengel08@gmail.com'
# 1.11 # Replace list elements #Replacing list elements is pretty easy. Simply subset the list and assign new values to the subset. You can select single elements or you can change entire list slices at once. #Use the IPython Shell to experiment with the commands below. Can you tell what's happening and why? #x = ["a...
areas = ['hallway', 11.25, 'kitchen', 18.0, 'living room', 20.0, 'bedroom', 10.75, 'bathroom', 9.5] areas[-1] = 10.5 areas[4] = 'chill zone'
class Solution: def fullJustify(self, words: List[str], maxWidth: int) -> List[str]: ans = [] todo = [] todo_size = 0 def combine(todo, todo_size): spaces = maxWidth - todo_size if len(todo) == 1: return todo[0] + " " * spaces b...
class Solution: def full_justify(self, words: List[str], maxWidth: int) -> List[str]: ans = [] todo = [] todo_size = 0 def combine(todo, todo_size): spaces = maxWidth - todo_size if len(todo) == 1: return todo[0] + ' ' * spaces ba...
# Python - 3.6.0 BASIC_TESTS = ( (('45', '1'), '1451'), (('13', '200'), '1320013'), (('Soon', 'Me'), 'MeSoonMe'), (('U', 'False'), 'UFalseU') ) test.describe('Basic Tests') for pair, result in BASIC_TESTS: test.it("'{}', '{}'".format(*pair)) test.assert_equals(solution(*pair), result)
basic_tests = ((('45', '1'), '1451'), (('13', '200'), '1320013'), (('Soon', 'Me'), 'MeSoonMe'), (('U', 'False'), 'UFalseU')) test.describe('Basic Tests') for (pair, result) in BASIC_TESTS: test.it("'{}', '{}'".format(*pair)) test.assert_equals(solution(*pair), result)
#list_intro.py #What is a list? # A collection of items in a particular order. # Ex: The alphabet, digits 0-9, names of family # Typically we will plural nouns for list names star_treks = ['TOS', 'TNG', 'Voyager', 'DS9'] #print(star_treks) #Accessing Elements #Because lists are ordered, each element has an ind...
star_treks = ['TOS', 'TNG', 'Voyager', 'DS9'] print(star_treks[0].title()) print(star_treks[-1]) print(star_treks[-3]) message = f'The first star trek I watched was {star_treks[0].title()}.' print(message)
width = const(10) height = const(16) data = [ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, # Character 0x00 (0) 0x00,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,0x00,0x08,...
width = const(10) height = const(16) data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 8, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 54, 0, 54, 0, 54, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
def merge_the_tools(string, n): out = [list(string)[k:k+n] for k in range(0,len(list(string)),n)] for x in out: print(''.join(sorted(set(x), key=x.index)))
def merge_the_tools(string, n): out = [list(string)[k:k + n] for k in range(0, len(list(string)), n)] for x in out: print(''.join(sorted(set(x), key=x.index)))
def calculate_determinant(matrix): if len(matrix) is 1: return matrix[0][0] elif len(matrix) is 2: return (matrix[0][0] * matrix[1][1]) - (matrix[1][0] * matrix[0][1]) total = float() for i in range(0, len(matrix)): cofactor = (-1 ^ i) * matrix[0][i] minor = [ ] for y in range(1, len(matrix)): sub = ...
def calculate_determinant(matrix): if len(matrix) is 1: return matrix[0][0] elif len(matrix) is 2: return matrix[0][0] * matrix[1][1] - matrix[1][0] * matrix[0][1] total = float() for i in range(0, len(matrix)): cofactor = (-1 ^ i) * matrix[0][i] minor = [] for y ...
if __name__ == '__main__': # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode: def __init__(self): ...
if __name__ == '__main__': class Listnode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode: def __init__(self): self.head = None ...
#! /usr/bin/env python3 description = ''' Roman numerals Problem 89 The rules for writing Roman numerals allow for many ways of writing each number (see About Roman Numerals...). However, there is always a "best" way of writing a particular number. For example, the following represent all of the legitimate ways of wr...
description = '\nRoman numerals\nProblem 89\nThe rules for writing Roman numerals allow for many ways of writing each number (see About Roman Numerals...). However, there is always a "best" way of writing a particular number.\n\nFor example, the following represent all of the legitimate ways of writing the number sixte...
# Finding the longest increasing subsequence in an array # [3, 4, -1, 0, 6, 2, 3] -> [-1, 0, 2, 3] # [2, 5, 1, 8, 3] -> [2, 5, 8] def finding_longest_subsequence(arr): if not arr: return 0 longest_subsequence = 1 longest_arr = [arr[0]] max_observed = float('-inf') for idx in ran...
def finding_longest_subsequence(arr): if not arr: return 0 longest_subsequence = 1 longest_arr = [arr[0]] max_observed = float('-inf') for idx in range(1, len(arr)): ele = arr[idx] while True: if longest_arr and longest_arr[-1] > ele: longest_arr.p...
class OpenPoseSkeleton(object): def __init__(self): self.root = 'MidHip' self.keypoint2index = { 'Nose': 0, 'Neck': 1, 'RShoulder': 2, 'RElbow': 3, 'RWrist': 4, 'LShoulder': 5, 'LElbow': 6, 'LWrist': 7, ...
class Openposeskeleton(object): def __init__(self): self.root = 'MidHip' self.keypoint2index = {'Nose': 0, 'Neck': 1, 'RShoulder': 2, 'RElbow': 3, 'RWrist': 4, 'LShoulder': 5, 'LElbow': 6, 'LWrist': 7, 'MidHip': 8, 'RHip': 9, 'RKnee': 10, 'RAnkle': 11, 'LHip': 12, 'LKnee': 13, 'LAnkle': 14, 'REye':...
class CountingSort: def __init__(self,a): self.a = a def result(self): maxSize = max(self.a) presence = [0 for x in range(maxSize+1)] for element in self.a: presence[element] += 1 for i in range(1,len(presence)): presence[i] = presence[i] + presen...
class Countingsort: def __init__(self, a): self.a = a def result(self): max_size = max(self.a) presence = [0 for x in range(maxSize + 1)] for element in self.a: presence[element] += 1 for i in range(1, len(presence)): presence[i] = presence[i] + ...
class BlockcertValidationError(Exception): pass class InvalidUrlError(Exception): pass
class Blockcertvalidationerror(Exception): pass class Invalidurlerror(Exception): pass
## ##Namelog.py ## ## ##uses list to load name ## playerName = "???" def nameWrite(): text_file = open("name.txt", "w+") print('Girl: What was your name?') ins = input() if ins == "": ins = "Hazel" print('I couldnt be bothered to put a name so call me Hazel') text_f...
player_name = '???' def name_write(): text_file = open('name.txt', 'w+') print('Girl: What was your name?') ins = input() if ins == '': ins = 'Hazel' print('I couldnt be bothered to put a name so call me Hazel') text_file.write(ins) text_file.close() def name_read(): text_f...
# Scrapy settings for Newengland project # # For simplicity, this file contains only the most important settings by # default. All the other settings are documented here: # # http://doc.scrapy.org/en/latest/topics/settings.html # BOT_NAME = 'Newengland' SPIDER_MODULES = ['Newengland.spiders'] NEWSPIDER_MODULE = '...
bot_name = 'Newengland' spider_modules = ['Newengland.spiders'] newspider_module = 'Newengland.spiders'
''' this file contains all the functions that contribute in the making of tic tac toe __________ about the game __________ 1-the grid shape : 1 | 2 | 3 ----------- 4 | 5 | 6 ----------- 7 | 8 | 9 2-how to play the game : the player...
""" this file contains all the functions that contribute in the making of tic tac toe __________ about the game __________ 1-the grid shape : 1 | 2 | 3 ----------- 4 | 5 | 6 ----------- 7 | 8 | 9 2-how to play the game : the player...
# # @lc app=leetcode id=401 lang=python3 # # [401] Binary Watch # # @lc code=start class Solution: def readBinaryWatch(self, num: int) -> List[str]: if num > 10: return [] times = [] for h in range(12): # 4 LEDs represent the hours (0-11) for m in range(60): # 6...
class Solution: def read_binary_watch(self, num: int) -> List[str]: if num > 10: return [] times = [] for h in range(12): for m in range(60): if (bin(h) + bin(m)).count('1') == num: hour_str = str(h) minute_str ...
def prepare_knapsack(items, capacity): ''' "capacity" is a numeric value representing a max weight. this capacity will be modified as items are added. --- "storage" is a list (usually a set) of item tuples. the tuples inside store an item's name, value, and weight. this variable represents all possible items ava...
def prepare_knapsack(items, capacity): """ "capacity" is a numeric value representing a max weight. this capacity will be modified as items are added. --- "storage" is a list (usually a set) of item tuples. the tuples inside store an item's name, value, and weight. this variable represents all possible items ...
class Error(object): def __init__(self, msg: str = "") -> None: super().__init__() self._msg = msg def __str__(self) -> str: return self._msg def __repr__(self) -> str: return self._msg def __eq__(self, o: object) -> bool: return self._msg == o.__repr__ de...
class Error(object): def __init__(self, msg: str='') -> None: super().__init__() self._msg = msg def __str__(self) -> str: return self._msg def __repr__(self) -> str: return self._msg def __eq__(self, o: object) -> bool: return self._msg == o.__repr__ def...
def lcs(x,y,m,n): if m==0 or n==0: return 0; elif x[m-1]==y[n-1]: return 1+lcs(x,y,m-1,n-1); else: return max(lcs(x,y,m,n-1),lcs(x,y,m-1,n)); x="AGGTAB" y="GXTXAYB" print("length of lcs is",lcs(x,y,len(x),len(y)));
def lcs(x, y, m, n): if m == 0 or n == 0: return 0 elif x[m - 1] == y[n - 1]: return 1 + lcs(x, y, m - 1, n - 1) else: return max(lcs(x, y, m, n - 1), lcs(x, y, m - 1, n)) x = 'AGGTAB' y = 'GXTXAYB' print('length of lcs is', lcs(x, y, len(x), len(y)))
#! /usr/bin/env python __author__ = "yatbear <sapphirejyt@gmail.com>" __date__ = "$Dec 21, 2015" # Map the infrequent words (count < 5) to a common symbol _RARE_ def remap(): # Read original training data trainset = [line.strip().split() for line in open('gene.train', 'r').readlines()] rare_candidates = d...
__author__ = 'yatbear <sapphirejyt@gmail.com>' __date__ = '$Dec 21, 2015' def remap(): trainset = [line.strip().split() for line in open('gene.train', 'r').readlines()] rare_candidates = dict() for sample in trainset: if len(sample) == 0: continue word = sample[0] if wor...
# Sylvia Dee <sylvia_dee@brown.edu> # PRYSM # PSM for Lacustrine Sedimentary Archives # SENSOR MODEL: GDGT-based measurements, e.g. TEX86, MBT5e # Function 'gdgt_sensor' # Modified 03/8/2016 <sylvia_dee@brown.edu> #==================================================================== def gdgt_sensor(LST,MAAT,beta=(1/50)...
def gdgt_sensor(LST, MAAT, beta=1 / 50, model='TEX86-loomis'): """ SENSOR SUB-MODEL for GDGT proxy data INPUTS: LST: LAKE SURFACE TEMPERATURE (C) MAAT: MEAN ANNUAL AIR TEMPERATURE (C) beta: User-Specified transfer fucntion of LST to TEX/GDGT model: Published calibrations for GDGTs. Options: ...
class Bruxo: def bruxeis(self): print('The dead are coming back to life') class Genio: def genieis(self): print('Los muertos vuelven a la vida') class Deus: def deuseis(self): print('De doden komen weer tot leven') seres = [Bruxo(), Genio(), Deus()] for ser in seres: if is...
class Bruxo: def bruxeis(self): print('The dead are coming back to life') class Genio: def genieis(self): print('Los muertos vuelven a la vida') class Deus: def deuseis(self): print('De doden komen weer tot leven') seres = [bruxo(), genio(), deus()] for ser in seres: if isin...
ERROR = { 'INPUT': { 'code': 20001, 'message': 'invalid request data', 'data': 'invalid request data', }, 'REGISTER': { 'code': 20002, 'data': '', 'message': 'failed to register user' }, 'USER_NOT_FOUND': { 'code': 20003, 'data': '', ...
error = {'INPUT': {'code': 20001, 'message': 'invalid request data', 'data': 'invalid request data'}, 'REGISTER': {'code': 20002, 'data': '', 'message': 'failed to register user'}, 'USER_NOT_FOUND': {'code': 20003, 'data': '', 'message': 'invalid username'}, 'INVALID_PASSWORD': {'code': 20004, 'data': '', 'message': 'i...
class NoDataFileException(Exception): def __init__(self, message="No data file", errors=[]): super().__init__(message, errors) pass
class Nodatafileexception(Exception): def __init__(self, message='No data file', errors=[]): super().__init__(message, errors) pass
age = 17 print("You are " + str(age)) if age >= 21: # Is the age equal to or over 21? print("You can drink!") if age >= 18: # Is the age equal to or over 18? print("You are an adult!") if age >= 16: # Is the age equal to or over 16? print("You can drive!") if age < 16: # Is the age ...
age = 17 print('You are ' + str(age)) if age >= 21: print('You can drink!') if age >= 18: print('You are an adult!') if age >= 16: print('You can drive!') if age < 16: print("You can't do anything!")
''' Models simple up/down counter that maintains a single count Methods: get_count() incrememt() decrement() set() reset() 'to_string' ''' ## Start your class with the keyword 'class' and the name of the class: class Counter: #---------------------------------------------------------------------------- ...
""" Models simple up/down counter that maintains a single count Methods: get_count() incrememt() decrement() set() reset() 'to_string' """ class Counter: def __init__(self): self.__count = 0 def get_count(self): return self.__count def increment(self): self.__count +=...
def foo(): global x x="juanito" print(f"El valor de x es {x}") x=5 print(x) foo() print(x)
def foo(): global x x = 'juanito' print(f'El valor de x es {x}') x = 5 print(x) foo() print(x)
def make_data_tensor(self, train=True): if train: folders = self.metatrain_character_folders # number of tasks, not number of meta-iterations. (divide by metabatch size to measure) num_total_batches = 200000 else: folders = self.metaval_character_folders num_total_batches...
def make_data_tensor(self, train=True): if train: folders = self.metatrain_character_folders num_total_batches = 200000 else: folders = self.metaval_character_folders num_total_batches = 600 print('Generating filenames') all_filenames = [] for _ in range(num_total_bat...
class Mother: def __init__(self): self.eye_color = "brown" self.hair_color = "dark brown" self.hair_type = "curly" class Father: def __init__(self): self.eye_color = "blue" self.hair_color = "blond" self.hair_type = "straight" class Child(Mother,...
class Mother: def __init__(self): self.eye_color = 'brown' self.hair_color = 'dark brown' self.hair_type = 'curly' class Father: def __init__(self): self.eye_color = 'blue' self.hair_color = 'blond' self.hair_type = 'straight' class Child(Mother, Father): ...
hparams = { 'batch_size': 32, 'epochs': 8, 'lr': 0.0001, 'name': 'mind_news', 'loss': 'cross_entropy_loss', 'optimizer': 'adam', 'version': 'v3', 'description': 'NRMS lr=5e-4, with weight_decay', 'pretrained_model': './data/utils/embedding.npy', 'model': { 'dct_size': 'au...
hparams = {'batch_size': 32, 'epochs': 8, 'lr': 0.0001, 'name': 'mind_news', 'loss': 'cross_entropy_loss', 'optimizer': 'adam', 'version': 'v3', 'description': 'NRMS lr=5e-4, with weight_decay', 'pretrained_model': './data/utils/embedding.npy', 'model': {'dct_size': 'auto', 'nhead': 20, 'embed_size': 300, 'encoder_size...
class Sprite: # Getter Functions def getCurrentFramePath(cls): pass def getCurrentFrameDelay(cls): pass def getCurrentPos(cls): pass # Interface for main to call def init(cls, xcoord: int, ycoord: int): pass def update(cls): pass # Interface to set sprite properties class Sprit...
class Sprite: def get_current_frame_path(cls): pass def get_current_frame_delay(cls): pass def get_current_pos(cls): pass def init(cls, xcoord: int, ycoord: int): pass def update(cls): pass class Spriteproperties: pass def on_left_click(...
with open("input1.txt","r") as f: data = f.readlines() data[0] = data[0].split(',') data[1] = data[1].split(',') # Might need to change w if too big w = 22000 h = w # 2000x2000 Wirespace wireSpace = [[0 for x in range(w)] for y in range(h)] centerX = w//2 centerY = h//2 currentPosX = centerX currentPosY = center...
with open('input1.txt', 'r') as f: data = f.readlines() data[0] = data[0].split(',') data[1] = data[1].split(',') w = 22000 h = w wire_space = [[0 for x in range(w)] for y in range(h)] center_x = w // 2 center_y = h // 2 current_pos_x = centerX current_pos_y = centerY for command in data[0]: (opcode, parameter)...
html_theme = 'classic' exclude_patterns = ['_build'] latex_documents = [ ('index', 'SphinxTests.tex', 'Testing maxlistdepth=10', 'Georg Brandl', 'howto'), ] latex_elements = { 'maxlistdepth': '10', }
html_theme = 'classic' exclude_patterns = ['_build'] latex_documents = [('index', 'SphinxTests.tex', 'Testing maxlistdepth=10', 'Georg Brandl', 'howto')] latex_elements = {'maxlistdepth': '10'}
# Simple Python3 program to find # n'th node from end class Node: def __init__(self, new_data): self.data = new_data self.next = None class LinkedList: def __init__(self): self.head = None # createNode and and make linked list def push(self, new_data): new_node = Node(new_data) new_node.next ...
class Node: def __init__(self, new_data): self.data = new_data self.next = None class Linkedlist: def __init__(self): self.head = None def push(self, new_data): new_node = node(new_data) new_node.next = self.head self.head = new_node def print_nth_fro...
NEED = 40 # mm def rain_amount(rain_amount: int) -> str: give = NEED - rain_amount if give > 0: return f"You need to give your plant {give}mm of water" else: return "Your plant has had more than enough water for today!"
need = 40 def rain_amount(rain_amount: int) -> str: give = NEED - rain_amount if give > 0: return f'You need to give your plant {give}mm of water' else: return 'Your plant has had more than enough water for today!'
class Solution: def reverse(self, x: int) -> int: if x%10==x: return x elif x>0: x = int (str(x).rstrip('0')[::-1]) return x if x <= ((1<<31)-1) else 0 elif x<0: x = -int (str(abs(x)).rstrip('0')[::-1]) return x if x >= -(1<<31) els...
class Solution: def reverse(self, x: int) -> int: if x % 10 == x: return x elif x > 0: x = int(str(x).rstrip('0')[::-1]) return x if x <= (1 << 31) - 1 else 0 elif x < 0: x = -int(str(abs(x)).rstrip('0')[::-1]) return x if x >= -(1...
# Solution 1 # O(n^2) time / O(1) space def twoNumberSum(array, targetSum): for i in range(len(array) - 1): firstNum = array[i] for j in range(i + 1, len(array)): secondNum = array[j] if firstNum + secondNum == targetSum: return [firstNum, secondNum] ret...
def two_number_sum(array, targetSum): for i in range(len(array) - 1): first_num = array[i] for j in range(i + 1, len(array)): second_num = array[j] if firstNum + secondNum == targetSum: return [firstNum, secondNum] return [] def two_number_sum(array, targ...
''' Merge sort time complexity: O(nlogn) space complexity: O(logn) + O(n) = O(n) ''' # merge two sorted array def merge(arr1, arr2): merge_arr = [] idx1, idx2 = 0, 0 while idx1 < len(arr1) and idx2 < len(arr2): if arr1[idx1] < arr2[idx2]: merge_arr.append(arr1[idx1]) idx1 =...
""" Merge sort time complexity: O(nlogn) space complexity: O(logn) + O(n) = O(n) """ def merge(arr1, arr2): merge_arr = [] (idx1, idx2) = (0, 0) while idx1 < len(arr1) and idx2 < len(arr2): if arr1[idx1] < arr2[idx2]: merge_arr.append(arr1[idx1]) idx1 = idx1 + 1 else...
# coding: utf-8 AUTHOR = 'R-Koubou' VERSION = '0.7.0' URL = 'https://github.com/r-koubou/XLS2ExpressionMap' VERSION_0_6 = 0x006000 VERSION_0_7 = 0x007000 VERSION_NUMBER = VERSION_0_7 if __name__ == '__main__': print( VERSION )
author = 'R-Koubou' version = '0.7.0' url = 'https://github.com/r-koubou/XLS2ExpressionMap' version_0_6 = 24576 version_0_7 = 28672 version_number = VERSION_0_7 if __name__ == '__main__': print(VERSION)
expected_output = { "route-information": { "route-table": [ { "active-route-count": "13", "destination-count": "13", "hidden-route-count": "0", "holddown-route-count": "0", "rt": [ { ...
expected_output = {'route-information': {'route-table': [{'active-route-count': '13', 'destination-count': '13', 'hidden-route-count': '0', 'holddown-route-count': '0', 'rt': [{'rt-announced-count': '1', 'rt-destination': '10.55.0.1/32', 'rt-entry': {'active-tag': '*', 'age': {'#text': '13'}, 'announce-bits': '2', 'ann...
class Solution: def partition(self, s: str) -> List[List[str]]: ans = [] self.helper(s, 0, [], ans) return ans def helper(self, s, idx, partition, ans): if idx == len(s): ans.append(partition[:]) else: for end in range(idx + 1, len(s) + 1)...
class Solution: def partition(self, s: str) -> List[List[str]]: ans = [] self.helper(s, 0, [], ans) return ans def helper(self, s, idx, partition, ans): if idx == len(s): ans.append(partition[:]) else: for end in range(idx + 1, len(s) + 1): ...
# page 100 // homework 2021-01-07 # TASK 1: fix bug # total = 0 number = 1 # bugfix: define the 'number' varible to a value that meets the condition of the loop below # nbb: the proposed solution of the book to duplicate functional code is a no go for pre-initializing variables (duplicate code -> increase of...
total = 0 number = 1 while number != 0: number = input('enter a number: ') number = int(number) total = total + number print(total)
a = True b = False print(a is b) print(a is not b)
a = True b = False print(a is b) print(a is not b)
expected_output = { "interfaces": { "Ethernet1/3": { "neighbors": { "fe80::f816:3eff:feff:9f9b": { "homeagent_flag": 0, "is_router": True, "addr_flag": 0, "ip": "fe80::f816:3eff:feff:9f9b", ...
expected_output = {'interfaces': {'Ethernet1/3': {'neighbors': {'fe80::f816:3eff:feff:9f9b': {'homeagent_flag': 0, 'is_router': True, 'addr_flag': 0, 'ip': 'fe80::f816:3eff:feff:9f9b', 'lifetime': 1800, 'current_hop_limit': 64, 'retransmission_time': 0, 'last_update': '2.8', 'mtu': 1500, 'preference': 'medium', 'other_...
words=[ 'redcoat', 'railing', 'waist', 'pinnacle', 'bribery', 'abjure', 'Swiss', 'chancel', 'groveler', 'chaser', 'curlew', 'markedly', 'admirer', 'coarse', 'slough', 'debrief', 'saltwater', 'spotty', 'photon', 'nephew', 'swath', 'elder', 'overnight', 'charm', 'rations', 'shrivel', 'quibbler', 'British', 'secretary', '...
words = ['redcoat', 'railing', 'waist', 'pinnacle', 'bribery', 'abjure', 'Swiss', 'chancel', 'groveler', 'chaser', 'curlew', 'markedly', 'admirer', 'coarse', 'slough', 'debrief', 'saltwater', 'spotty', 'photon', 'nephew', 'swath', 'elder', 'overnight', 'charm', 'rations', 'shrivel', 'quibbler', 'British', 'secretary', ...
#Class to calculate the LastPriceWindow and LastPriceTotal class CUtilsSpread: def GetLastPriceWindow(self, data_object, list_index, time_window_index): while data_object.m_DatetimeList[list_index] <= data_object.m_strTimeWindowList[time_window_index]: list_index += 1 if li...
class Cutilsspread: def get_last_price_window(self, data_object, list_index, time_window_index): while data_object.m_DatetimeList[list_index] <= data_object.m_strTimeWindowList[time_window_index]: list_index += 1 if list_index >= len(data_object.m_fPriceList): break ...
''' Author: tusikalanse Date: 2021-07-13 20:13:20 LastEditTime: 2021-07-13 20:30:51 LastEditors: tusikalanse Description: ''' lis = [0, 2] for i in range(1, 34): lis.extend([1, 2 * i, 1]) def gcd(a, b): return a if b == 0 else gcd(b, a % b) def gao(n): numerator, denominator = lis[n], 1 for i in ra...
""" Author: tusikalanse Date: 2021-07-13 20:13:20 LastEditTime: 2021-07-13 20:30:51 LastEditors: tusikalanse Description: """ lis = [0, 2] for i in range(1, 34): lis.extend([1, 2 * i, 1]) def gcd(a, b): return a if b == 0 else gcd(b, a % b) def gao(n): (numerator, denominator) = (lis[n], 1) for i in ...
#pylint:disable=E0001 ''' We shall consider fractions like, 30/50 = 3/5, to be trivial examples. There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator. If the product of these four fractions is given in its lowest commo...
""" We shall consider fractions like, 30/50 = 3/5, to be trivial examples. There are exactly four non-trivial examples of this type of fraction, less than one in value, and containing two digits in the numerator and denominator. If the product of these four fractions is given in its lowest common terms, find the valu...
# Plot statistics # Mean global flow completion time vs. utilization pFabric lambdasdata = [4000, 6000, 10000, 15000, 22500, 37000, 60000] lambdasweb = [3600, 5200, 7000, 8900, 11100, 14150, 19000] row = 0 for x in lambdasweb: file = "../temp_save/albert/pFabric/web_search_workload/"+str(x)+"/SPPIFO8_pFabric/analy...
lambdasdata = [4000, 6000, 10000, 15000, 22500, 37000, 60000] lambdasweb = [3600, 5200, 7000, 8900, 11100, 14150, 19000] row = 0 for x in lambdasweb: file = '../temp_save/albert/pFabric/web_search_workload/' + str(x) + '/SPPIFO8_pFabric/analysis/flow_completion.statistics' r = open(file, 'r') lines = r.read...
# Do not edit the class below except for the buildHeap, # siftDown, siftUp, peek, remove, and insert methods. # Feel free to add new properties and methods to the class. class MinHeap: def __init__(self, array): # Do not edit the line below. self.heap = self.buildHeap(array) def buildHeap(se...
class Minheap: def __init__(self, array): self.heap = self.buildHeap(array) def build_heap(self, array): first_parent_idx = (len(array) - 2) // 2 for curr_idx in reversed(range(firstParentIdx + 1)): self.siftDown(currIdx, len(array) - 1, array) return array def...
class Button: def __init__(self, x, y, w, h, text, callback): self.pos = x, y self.size = w, h self.text = text self.callback = callback self.bg_colour = [0, 0, 0] self.text_colour = [255, 255, 255] self.pushed_colour = [155, 155, 155] self.pushed = F...
class Button: def __init__(self, x, y, w, h, text, callback): self.pos = (x, y) self.size = (w, h) self.text = text self.callback = callback self.bg_colour = [0, 0, 0] self.text_colour = [255, 255, 255] self.pushed_colour = [155, 155, 155] self.pushed...
class Trie: def __init__(self) -> None: self.root = {} self.endOfWord = ' ' def insert(self, word: str) -> None: node = self.root for char in word: node = node.setdefault(char, {}) node[self.endOfWord] = self.endOfWord def search(self, word: str) -> bool...
class Trie: def __init__(self) -> None: self.root = {} self.endOfWord = ' ' def insert(self, word: str) -> None: node = self.root for char in word: node = node.setdefault(char, {}) node[self.endOfWord] = self.endOfWord def search(self, word: str) -> boo...
# library to handle stuff about your ship ########################## # necessary imports go here ########################## ################################## # Inaugural frigate class - Atron ################################## # a ship needs to have certain stats # it needs a pilot (usually the player) it needs a ...
class Atron: def __init__(self, hp, location): self.hp = hp self.cargo = [] self.location = location self.score = 0 self.killmarks = 0 def structure_rep(self): rep_amt = 100 - self.hp self.hp += rep_amt def add_cargo(self, items): self.cargo...
# # PySNMP MIB module Juniper-ERX-Registry (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-ERX-Registry # Produced by pysmi-0.3.4 at Wed May 1 14:02:31 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_size_constraint, constraints_union, value_range_constraint, constraints_intersection, single_value_constraint) ...
# Part 1 def parsephrase(phrase): sp = phrase.lower().split() checked = [] for p in sp: if p in checked: return(False) else: checked += [p] return(True) def phrases(lines): x = 0 for l in lines.split("\n"): pp = parsephrase(l.lower()) if p...
def parsephrase(phrase): sp = phrase.lower().split() checked = [] for p in sp: if p in checked: return False else: checked += [p] return True def phrases(lines): x = 0 for l in lines.split('\n'): pp = parsephrase(l.lower()) if pp: ...
__title__ = 'trylogging' #__package_name__ = 'not-a-package' __version__ = '0.0.1' __description__ = "Just an example of using the Python logging module to remind me about using it." __email__ = "notNeededForThisExample@null.net" __author__ = 'Matt McCright' __github__ = 'https://github.com/mccright/PPythonLoggingExamp...
__title__ = 'trylogging' __version__ = '0.0.1' __description__ = 'Just an example of using the Python logging module to remind me about using it.' __email__ = 'notNeededForThisExample@null.net' __author__ = 'Matt McCright' __github__ = 'https://github.com/mccright/PPythonLoggingExamples' __license__ = 'MIT' __copyright...
#!/usr/bin/python #protexam_output.py ''' Output functions for ProtExAM. '''
""" Output functions for ProtExAM. """
n, k = map(int, input().split()) s = str(input()) sl = [] c = 1 if (s[0] == "1"): sl.append(0) for i in range(n): if (i != 0): if (s[i] == s[i-1]): c += 1 else: sl.append(c) c = 1 sl.append(c) ruisekiwa = [0] sums = [] ans = 0 w = 2*k+1 if (w > len(sl)): ...
(n, k) = map(int, input().split()) s = str(input()) sl = [] c = 1 if s[0] == '1': sl.append(0) for i in range(n): if i != 0: if s[i] == s[i - 1]: c += 1 else: sl.append(c) c = 1 sl.append(c) ruisekiwa = [0] sums = [] ans = 0 w = 2 * k + 1 if w > len(sl): p...
# # libjingle # Copyright 2012 Google Inc. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright notice, # this list of conditions and the following d...
{'includes': ['build/common.gypi'], 'targets': [{'target_name': 'relayserver', 'type': 'executable', 'dependencies': ['libjingle.gyp:libjingle', 'libjingle.gyp:libjingle_p2p'], 'sources': ['examples/relayserver/relayserver_main.cc']}, {'target_name': 'stunserver', 'type': 'executable', 'dependencies': ['libjingle.gyp:l...
#lab1 ex2 print('Please insert Your name, surname and year of birth:') a = input() b = a.split() name = b[0] surname = b[1] year_of_birth = b[2] print(surname, year_of_birth, name)
print('Please insert Your name, surname and year of birth:') a = input() b = a.split() name = b[0] surname = b[1] year_of_birth = b[2] print(surname, year_of_birth, name)
class HTML_Icon(): HTML_Icon_Color_Default_Display='inline' HTML_Icon_Color_Default_Show='blue' HTML_Icon_Color_Default_Hide='grey' HTML_Icon_Size_Default=0 HTML_Icon_Sizes=[ '', 'fa-lg', 'fa-2x', 'fa-xs','fa-sm', 'fa-3x','fa-5x','fa-7x','fa-10x', ...
class Html_Icon: html__icon__color__default__display = 'inline' html__icon__color__default__show = 'blue' html__icon__color__default__hide = 'grey' html__icon__size__default = 0 html__icon__sizes = ['', 'fa-lg', 'fa-2x', 'fa-xs', 'fa-sm', 'fa-3x', 'fa-5x', 'fa-7x', 'fa-10x'] def html__icon(self...
# logic: # a function which would accept a number #the number would be tried agains all the positive numbers less than itself excpet 0 wo see if it is a prime number #the result would be returned def prime(number): divi=[ i for i in range(1,number) if number%i==0] if number==1: return print('the number...
def prime(number): divi = [i for i in range(1, number) if number % i == 0] if number == 1: return print('the number is not prime') if divi.__len__() > 2: print('the number is not prime') else: print('the number is prime') prime(1381)
def stop(): pass class Load(): def __init__(self, chan): self.channel = chan.channel self.all_channels = chan.owner.channels self.botnick = chan.botnick self.sendmsg = chan.sendmsg self.name = "broadcast" def run(self, ircmsg): if ircmsg.lowe...
def stop(): pass class Load: def __init__(self, chan): self.channel = chan.channel self.all_channels = chan.owner.channels self.botnick = chan.botnick self.sendmsg = chan.sendmsg self.name = 'broadcast' def run(self, ircmsg): if ircmsg.lower().find(self.cha...