content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
vacation_cost = float(input()) available_money = float(input()) spending_counter = 0 days_passed = 0 saved = True while available_money < vacation_cost: #spend or save action_type = input() current_sum = float(input()) days_passed += 1 if action_type == 'spend': spending_counter += 1 ...
vacation_cost = float(input()) available_money = float(input()) spending_counter = 0 days_passed = 0 saved = True while available_money < vacation_cost: action_type = input() current_sum = float(input()) days_passed += 1 if action_type == 'spend': spending_counter += 1 available_money -=...
NOT_FOUND = -1 class Search(object): def __init__(self, sample): self.sample = sample
not_found = -1 class Search(object): def __init__(self, sample): self.sample = sample
__all__ = 'MissingContextVariable', class MissingContextVariable(KeyError): pass
__all__ = ('MissingContextVariable',) class Missingcontextvariable(KeyError): pass
# with-Statement def setup(): size(400, 400) background(255) def draw(): fill(color(255, 153, 0)) ellipse(100, 100, 50, 50) with pushStyle(): fill(color(255, 51, 51)) strokeWeight(5) ellipse(200, 200, 50, 50) ellipse(300, 300, 50, 50)
def setup(): size(400, 400) background(255) def draw(): fill(color(255, 153, 0)) ellipse(100, 100, 50, 50) with push_style(): fill(color(255, 51, 51)) stroke_weight(5) ellipse(200, 200, 50, 50) ellipse(300, 300, 50, 50)
# Develop a program that calculates the sum between all the odd numbers # that are multiples of three and are in the range of 1 to 500. sum = 0 for i in range(1,501): if (i % 2 != 0 ) and (i % 3 == 0): sum += i print(sum)
sum = 0 for i in range(1, 501): if i % 2 != 0 and i % 3 == 0: sum += i print(sum)
# https://www.codewars.com/kata/526571aae218b8ee490006f4/ ''' Instructions : Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. Example: The binary representation of 1234 is ...
""" Instructions : Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case ...
# this is a part of binary search tree class. # The right, left and parent functions can be found in the binary search tree implementation. def TreeSearch(T,p,k): if k == p.key(): return p # successful search elif k < p.key() and T.left(p) is not None: return Tree...
def tree_search(T, p, k): if k == p.key(): return p elif k < p.key() and T.left(p) is not None: return tree_search(T, T.left(p), k) elif k > p.key() and T.right(p) is not None: return tree_search(T, T.right(p), k) return p
def isNode(data): if type(data) == Node: return True else: return False class Node: def __init__(self, data=None) -> None: self.data = data self.previous = None self.next = None def __str__(self) -> str: if self.previous == None and self.next == None: ...
def is_node(data): if type(data) == Node: return True else: return False class Node: def __init__(self, data=None) -> None: self.data = data self.previous = None self.next = None def __str__(self) -> str: if self.previous == None and self.next == None: ...
"""test too short name """ __revision__ = 1 A = None def a(): """yo""" pass
"""test too short name """ __revision__ = 1 a = None def a(): """yo""" pass
# weight = [3, 5, 7] # n = len(weight) # a = 6 # # for i in range(n): # print(weight) # if weight[i] < a: # weight.remove(weight[i]) # # print(weight) # arr8 = [4, 3, 4, 4, 4, 2] # # print('start') # for i in range(len(arr8) - 1): # print(arr8[:i+1], arr8[i+1:], " - ", i) def solution(arr): s...
def solution(arr): size = 0 value = 0 for i in range(len(arr)): if size == 0: value = arr[i] size += 1 elif value != arr[i] and size != 0: size -= 1 else: size += 1 leader = value if arr.count(leader) <= len(arr) // 2: r...
"""Demo assignment with separate test files.""" def square(x): """Return x squared.""" return x * x def double(x): """Return x doubled.""" return x # Incorrect
"""Demo assignment with separate test files.""" def square(x): """Return x squared.""" return x * x def double(x): """Return x doubled.""" return x
class GeometryBase(CommonObject,IDisposable,ISerializable): # no doc def ComponentIndex(self): """ ComponentIndex(self: GeometryBase) -> ComponentIndex """ pass def ConstructConstObject(self,*args): """ ConstructConstObject(self: CommonObject,parentObject: object,subobject_index: int) """ pass def D...
class Geometrybase(CommonObject, IDisposable, ISerializable): def component_index(self): """ ComponentIndex(self: GeometryBase) -> ComponentIndex """ pass def construct_const_object(self, *args): """ ConstructConstObject(self: CommonObject,parentObject: object,subobject_index: int) """...
def sort(elements): while True: swapped = False for i in range(len(elements)-1): if elements[i] > elements[i+1]: # swap temp = elements[i] elements[i] = elements[i+1] elements[i+1] = temp swapped = True ...
def sort(elements): while True: swapped = False for i in range(len(elements) - 1): if elements[i] > elements[i + 1]: temp = elements[i] elements[i] = elements[i + 1] elements[i + 1] = temp swapped = True if not swapp...
PORT = 8000 URL = "http://localhost:{}".format(PORT) SITE_LOCATION = 'test_site/index.html' csv_log_single_site_init = [(False, False, True), (False, False, False)] # TODO: Add logs and csv tests # (True, False, True), (False, False, True), (True, True, True)] variations = [{ 'element': 'id', 'element_id':...
port = 8000 url = 'http://localhost:{}'.format(PORT) site_location = 'test_site/index.html' csv_log_single_site_init = [(False, False, True), (False, False, False)] variations = [{'element': 'id', 'element_id': 'header', 'expected_amount': 1}, {'element': 'id', 'element_id': 'headerLeft', 'expected_amount': 1}, {'eleme...
# # PySNMP MIB module ELTEX-MES-HWENVIROMENT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-MES-HWENVIROMENT-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:01:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
class Solution: def levelOrder(self, root: 'Node') -> List[List[int]]: if root==None: return [] list_trans=[] queue=[root] while queue: child=[] nodes=[] for node in queue: child.append(node.val) ...
class Solution: def level_order(self, root: 'Node') -> List[List[int]]: if root == None: return [] list_trans = [] queue = [root] while queue: child = [] nodes = [] for node in queue: child.append(node.val) ...
MAP_SIZE = 24 TILE_SIZE = 16 ENTITY_ID = 1 ARROW_SPEED = 9999 ENTITYMAP = {} PLAYER_ENTITIES = [] TILEMAP = {} GAMEINFO = {} # playerid, gameinstance # REMOVE = []
map_size = 24 tile_size = 16 entity_id = 1 arrow_speed = 9999 entitymap = {} player_entities = [] tilemap = {} gameinfo = {}
# coding: utf-8 """ author: Olivier Chabrol updated by: Louai KB """ class Node: """ Node of a list """ def __init__(self, data): """constructor Args: data (float): the data of the node """ self.data = data self.next = None def __str__(self): ...
""" author: Olivier Chabrol updated by: Louai KB """ class Node: """ Node of a list """ def __init__(self, data): """constructor Args: data (float): the data of the node """ self.data = data self.next = None def __str__(self): """string...
obstacleSet = set([(10, 2, 4, 5), (3, 4), (4, 4), (5, 4)]) print((2, 4) in obstacleSet) print(obstacleSet) print(set([(1, 2), (3, 4)]))
obstacle_set = set([(10, 2, 4, 5), (3, 4), (4, 4), (5, 4)]) print((2, 4) in obstacleSet) print(obstacleSet) print(set([(1, 2), (3, 4)]))
def quickSort(array, head, tail): # an implementation of quicksort algorithm if head >= tail: return else: pivot = partition(array, head, tail) quickSort(array, head, pivot) quickSort(array, pivot+1, tail) def partition(array, h...
def quick_sort(array, head, tail): if head >= tail: return else: pivot = partition(array, head, tail) quick_sort(array, head, pivot) quick_sort(array, pivot + 1, tail) def partition(array, head, tail): pivot = array[head] i = head + 1 for j in range(head + 1, tail): ...
passports = [] x=0 vCount=0 keys = {"byr", "iyr", "eyr", "hgt", "hcl", "ecl", "pid"} with open("Day4\\test2.txt", "r") as data: passports = [i.replace('\n', ' ').split() for i in data.read().split('\n\n')] for i in passports: print(i) ...
passports = [] x = 0 v_count = 0 keys = {'byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid'} with open('Day4\\test2.txt', 'r') as data: passports = [i.replace('\n', ' ').split() for i in data.read().split('\n\n')] for i in passports: print(i) print(i[0:1]) print(keys)
''' Vanir OS exception hierarchy ''' class VanirException(Exception): '''Exception that can be shown to the user''' class VanirVMNotFoundError(VanirException, KeyError): '''Domain cannot be found in the system''' def __init__(self, vmname): super(VanirVMNotFoundError, self).__init__( ...
""" Vanir OS exception hierarchy """ class Vanirexception(Exception): """Exception that can be shown to the user""" class Vanirvmnotfounderror(VanirException, KeyError): """Domain cannot be found in the system""" def __init__(self, vmname): super(VanirVMNotFoundError, self).__init__('No such doma...
def entrada(): n,l = map(int,input().split()) return n,l def perimetro(n,lado): return n*lado def main(): n,l=entrada() print(perimetro(n,l)) main()
def entrada(): (n, l) = map(int, input().split()) return (n, l) def perimetro(n, lado): return n * lado def main(): (n, l) = entrada() print(perimetro(n, l)) main()
# # PySNMP MIB module DES-1228p-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DES-1228P-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:23:55 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 201...
(octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, single_value_constraint, value_range_constraint, constraints_union, value_size_constraint) ...
BOT_PREFIX = '[bot] ' BOT_SUFFIX = '\n' class BotReply: def send_reply(self, dest, tg_socket): raise NotImplementedError
bot_prefix = '[bot] ' bot_suffix = '\n' class Botreply: def send_reply(self, dest, tg_socket): raise NotImplementedError
products = [ { 'id': 1, 'name': 'Apple', 'price': 200, 'quantity': 20 }, { 'id': 2, 'name': 'Milk', 'price': 20, 'quantity': 100 }, { 'id': 3, 'name': 'Rice', 'price': 500, 'quantity': 20 }, { 'id': 4, 'name': 'Pepsi', ...
products = [{'id': 1, 'name': 'Apple', 'price': 200, 'quantity': 20}, {'id': 2, 'name': 'Milk', 'price': 20, 'quantity': 100}, {'id': 3, 'name': 'Rice', 'price': 500, 'quantity': 20}, {'id': 4, 'name': 'Pepsi', 'price': 55, 'quantity': 20}] print('-----------------------------------------------') print('\t\tSuper Marke...
class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node
class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node
""" CSCI-603: Trees (week 10) Author: Sean Strout @ RIT CS This is an implementation of a binary tree node. """ class BTNode: """ A binary tree node contains: :slot val: A user defined value :slot left: A left child (BTNode or None) :slot right: A right child (BTNode or None) """ __slo...
""" CSCI-603: Trees (week 10) Author: Sean Strout @ RIT CS This is an implementation of a binary tree node. """ class Btnode: """ A binary tree node contains: :slot val: A user defined value :slot left: A left child (BTNode or None) :slot right: A right child (BTNode or None) """ __slot...
def load(file = "data.txt"): data = [] for line in open(file): data.append(line) return data
def load(file='data.txt'): data = [] for line in open(file): data.append(line) return data
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: if root is None: return 0 diameter = 0 def ge...
class Solution: def diameter_of_binary_tree(self, root: TreeNode) -> int: if root is None: return 0 diameter = 0 def get_tree_height(node): nonlocal diameter if node.left is None and node.right is None: return 0 left_height = ...
def listToString(s): """ Description: Need to build function because argparse function returns list, not string. Called from main. :param s: argparse output :return: string of url """ # initialize an empty string url_string = "" # traverse in the string for ele in s: url_str...
def list_to_string(s): """ Description: Need to build function because argparse function returns list, not string. Called from main. :param s: argparse output :return: string of url """ url_string = '' for ele in s: url_string += ele return url_string if __name__ == '__main__': ...
def prefix_prefix(w, m): def naive_scan(i, j): r = 0 while i + r <= m and j + r <= m and w[i + r] == w[j + r]: r += 1 return r PREF, s = [-1] * 2 + [0] * (m - 1), 1 for i in range(2, m + 1): # niezmiennik: s jest takie, ze s + PREF[s] - 1 jest maksymalne i PREF[s] > 0 k = i - s + 1 s...
def prefix_prefix(w, m): def naive_scan(i, j): r = 0 while i + r <= m and j + r <= m and (w[i + r] == w[j + r]): r += 1 return r (pref, s) = ([-1] * 2 + [0] * (m - 1), 1) for i in range(2, m + 1): k = i - s + 1 s_max = s + PREF[s] - 1 if s_max < i...
class lz78(object): @staticmethod def name(): return 'LZ78' @staticmethod def compress(data, *args, **kwargs): '''LZ78 compression ''' d, word = {0: ''}, 0 dyn_d = ( lambda d, key: d.get(key) or d.__setitem__(key, len(d)) or 0 ) ret...
class Lz78(object): @staticmethod def name(): return 'LZ78' @staticmethod def compress(data, *args, **kwargs): """LZ78 compression """ (d, word) = ({0: ''}, 0) dyn_d = lambda d, key: d.get(key) or d.__setitem__(key, len(d)) or 0 return [token for char in...
def insideBoard(board, x, y): """detecta si la ficha que quieres poner esta dentro de los limites del tablero Args: board (list): lista que contiene el tablero x (int): posicion x en la que quieres poner en el tablero y (int): posicion y en la que quieres poner en el tablero Return...
def inside_board(board, x, y): """detecta si la ficha que quieres poner esta dentro de los limites del tablero Args: board (list): lista que contiene el tablero x (int): posicion x en la que quieres poner en el tablero y (int): posicion y en la que quieres poner en el tablero Retur...
longname = {'S': 'Susceptible', 'E': 'Exposed', 'I': 'Infected (symptomatic)', 'A': 'Asymptomatically Infected', 'R': 'Recovered', 'H': 'Hospitalised', 'C': 'Critical', 'D': 'Deaths', 'O': 'Offsite', 'Q'...
longname = {'S': 'Susceptible', 'E': 'Exposed', 'I': 'Infected (symptomatic)', 'A': 'Asymptomatically Infected', 'R': 'Recovered', 'H': 'Hospitalised', 'C': 'Critical', 'D': 'Deaths', 'O': 'Offsite', 'Q': 'Quarantined', 'U': 'No ICU Care', 'CS': 'Change in Susceptible', 'CE': 'Change in Exposed', 'CI': 'Change in Infec...
l = [0]*101 for i in range(1, 10): for j in range(1, 10): l[i*j] = 1 n = int(input()) if l[n] == 1: print("Yes") else: print("No")
l = [0] * 101 for i in range(1, 10): for j in range(1, 10): l[i * j] = 1 n = int(input()) if l[n] == 1: print('Yes') else: print('No')
""" @date: 2021/7/5 @description: """
""" @date: 2021/7/5 @description: """
class RomanNumerals: def to_roman(val): result = '' symbols = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'] nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] nums_len = len(nums) i = 0 while i < nums_len: if nums[i]...
class Romannumerals: def to_roman(val): result = '' symbols = ['M', 'CM', 'D', 'CD', 'C', 'XC', 'L', 'XL', 'X', 'IX', 'V', 'IV', 'I'] nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1] nums_len = len(nums) i = 0 while i < nums_len: if nums[i] <...
''' Write an algorithm Sums-One-Two-Three(n) that takes an integer n and, in time O(n), returns the number of possible ways to write n as a sum of 1, 2, and 3. For example, Sums-One-Two-Three(4) must return 7 because there are 7 ways to write 4 as a sum of ones, twos, and threes (1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2, 1+3,...
""" Write an algorithm Sums-One-Two-Three(n) that takes an integer n and, in time O(n), returns the number of possible ways to write n as a sum of 1, 2, and 3. For example, Sums-One-Two-Three(4) must return 7 because there are 7 ways to write 4 as a sum of ones, twos, and threes (1+1+1+1, 1+1+2, 1+2+1, 2+1+1, 2+2, 1+3,...
# Write your solution for 1.3 here! a=0 i=1 while a < 10000: a+=i i+=1 print(i) ##### a=0 i=2 while a<10000: a+=i i+=2 print(i)
a = 0 i = 1 while a < 10000: a += i i += 1 print(i) a = 0 i = 2 while a < 10000: a += i i += 2 print(i)
class account: def check_password_length(self, password): if len(password) > 8: return True else: return False if __name__ == '__main__': accVerify = account() print('The password length is ' + str(accVerify.check_password_length('offtoschool')))
class Account: def check_password_length(self, password): if len(password) > 8: return True else: return False if __name__ == '__main__': acc_verify = account() print('The password length is ' + str(accVerify.check_password_length('offtoschool')))
""" Some useful data sets to be used in the analysis The command :func:`sequana.sequana_data` may be used to retrieved data from this package. For example, a small but standard reference (phix) is used in some NGS experiments. The file is small enough that it is provided within sequana and its filename (full path)...
""" Some useful data sets to be used in the analysis The command :func:`sequana.sequana_data` may be used to retrieved data from this package. For example, a small but standard reference (phix) is used in some NGS experiments. The file is small enough that it is provided within sequana and its filename (full path)...
class Node: def __init__(self, init_data, pointer = None): self.data = init_data self.pointer = pointer def get_data(self): return self.data def get_next(self): return self.pointer def set_data(self, data): self.data = data ...
class Node: def __init__(self, init_data, pointer=None): self.data = init_data self.pointer = pointer def get_data(self): return self.data def get_next(self): return self.pointer def set_data(self, data): self.data = data def set_next(self, data): ...
def tennis_set(s1, s2): n1 = min(s1, s2) n2 = max(s1, s2) if n2 == 6: return n1 < 5 return n2 == 7 and n1 >= 5 and n1 < n2
def tennis_set(s1, s2): n1 = min(s1, s2) n2 = max(s1, s2) if n2 == 6: return n1 < 5 return n2 == 7 and n1 >= 5 and (n1 < n2)
class people: def __init__(self): self.nick_name = "" self.qq_number = "" self.topic_name = "" def display(self): print("------------------------topic_name = %s------------------------" % self.topic_name) print("nick_name = ", self.nick_name) print("%-13s%s" % ("...
class People: def __init__(self): self.nick_name = '' self.qq_number = '' self.topic_name = '' def display(self): print('------------------------topic_name = %s------------------------' % self.topic_name) print('nick_name = ', self.nick_name) print('%-13s%s' % (...
def get_object_or_none(model, *args, **kwargs): try: return model._default_manager.get(*args, **kwargs) except model.DoesNotExist: return None def get_object_or_this(model, this, *args, **kwargs): return get_object_or_none(model, *args, **kwargs) or this
def get_object_or_none(model, *args, **kwargs): try: return model._default_manager.get(*args, **kwargs) except model.DoesNotExist: return None def get_object_or_this(model, this, *args, **kwargs): return get_object_or_none(model, *args, **kwargs) or this
class Solution: def merge(self, nums1, m, nums2, n): i=m-1 j=n-1 tmp=m+n-1 while i>=0 and j>=0: if nums1[i]<nums2[j]: nums1[tmp]=nums2[j] tmp-=1 j-=1 else: nums1[tmp]=nums1[i] tmp-...
class Solution: def merge(self, nums1, m, nums2, n): i = m - 1 j = n - 1 tmp = m + n - 1 while i >= 0 and j >= 0: if nums1[i] < nums2[j]: nums1[tmp] = nums2[j] tmp -= 1 j -= 1 else: nums1[tmp] = ...
# -*- coding: utf-8 -*- # {name: (aka, width, height, aspect ratio)} HIGH_DEFINITION_MAP = { "NHD": ("nHD", 640, 360, (16, 9)), "QHD": ("qHD", 960, 540, (16, 9)), "HD": ("HD", 1280, 720, (16, 9)), "HD PLUS": ("HD+", 1600, 900, (16, 9)), "FHD": ("FHD", 1920, 1080, (16, 9)), "WQHD": ("WQHD", 2560...
high_definition_map = {'NHD': ('nHD', 640, 360, (16, 9)), 'QHD': ('qHD', 960, 540, (16, 9)), 'HD': ('HD', 1280, 720, (16, 9)), 'HD PLUS': ('HD+', 1600, 900, (16, 9)), 'FHD': ('FHD', 1920, 1080, (16, 9)), 'WQHD': ('WQHD', 2560, 1440, (16, 9)), 'QHD PLUS': ('QHD+', 3200, 1800, (16, 9)), 'UHD 4K': ('4K UHD', 3840, 2160, (...
def shape_legend(node, ax, handles, labels, reverse=False, **kwargs): """Plot legend manipulation. This code is copied from the oemof example script see link here: https://github.com/oemof/oemof-examples/tree/master/oemof_examples/oemof.solph/v0.3.x/plotting_examples """ handels = handles labels =...
def shape_legend(node, ax, handles, labels, reverse=False, **kwargs): """Plot legend manipulation. This code is copied from the oemof example script see link here: https://github.com/oemof/oemof-examples/tree/master/oemof_examples/oemof.solph/v0.3.x/plotting_examples """ handels = handles labels = l...
def remove_background(frame): fgbg = cv2.createBackgroundSubtractorMOG2(history=20) fgmask = fgbg.apply(frame) kernel = np.ones((3, 3), np.uint8) fgmask = cv2.erode(fgmask, kernel, iterations=1) res = cv2.bitwise_and(frame, frame, mask=fgmask) return res # gamma transfer def gamma_trans(img,gam...
def remove_background(frame): fgbg = cv2.createBackgroundSubtractorMOG2(history=20) fgmask = fgbg.apply(frame) kernel = np.ones((3, 3), np.uint8) fgmask = cv2.erode(fgmask, kernel, iterations=1) res = cv2.bitwise_and(frame, frame, mask=fgmask) return res def gamma_trans(img, gamma): gamma_t...
def urlify(str, length=None): """Write a method to replace all spaces with '%20'. Args: str - String whose spaces should be replaced by '%20' length - length of str minus any spaces padded at the beginning or end Returns: A string similar to str except whose spaces have been replace...
def urlify(str, length=None): """Write a method to replace all spaces with '%20'. Args: str - String whose spaces should be replaced by '%20' length - length of str minus any spaces padded at the beginning or end Returns: A string similar to str except whose spaces have been replace...
class ElectricalDemandFactorRule(Enum, IComparable, IFormattable, IConvertible): """ This enum describes the different demand factor rule types available to the application. Within a demand factor a rule will be referenced and the user will have to enter values corresponding to that rule. ...
class Electricaldemandfactorrule(Enum, IComparable, IFormattable, IConvertible): """ This enum describes the different demand factor rule types available to the application. Within a demand factor a rule will be referenced and the user will have to enter values corresponding to that rule. enum Elect...
#as a list: l=[3,4] l+=[5,6] print(l) #as a stack: #top input #lifo l.append(10) print(l) l.pop()#pops the ele that is inserted at last #as a queue #fifo l.insert(0,5) l.pop()
l = [3, 4] l += [5, 6] print(l) l.append(10) print(l) l.pop() l.insert(0, 5) l.pop()
print('Hello World!') long_mssg = """ ................................................. This script should be replaced for an AI-script of your own which has an output of some sort that you are interested in getting ................................................ """ print(long_mssg)
print('Hello World!') long_mssg = '\n .................................................\n This script should be replaced for an AI-script\n of your own which has an output of some sort that\n you are interested in getting\n ................................................\n ' print(long_mssg)
#--------------------------------------------# # My Solution # #--------------------------------------------# def checkio(words: str): count = 0 for word in words.split(): if word.isalpha(): count += 1 else: count = 0 if count == 3: return True return False #-----------------------------...
def checkio(words: str): count = 0 for word in words.split(): if word.isalpha(): count += 1 else: count = 0 if count == 3: return True return False a = checkio('Hello World hello') b = checkio('He is 123 man') c = checkio('1 2 3 4') d = checkio('bl...
class Player: def __init__(self, type_): self.hp = 200 self.type = type_ def combat_simulation(f): map = [] players = [] for line in f.readlines(): row = [] for c in line.strip(): if c == '#': row.append(False) elif c == '.': ...
class Player: def __init__(self, type_): self.hp = 200 self.type = type_ def combat_simulation(f): map = [] players = [] for line in f.readlines(): row = [] for c in line.strip(): if c == '#': row.append(False) elif c == '.': ...
"""Constants for testclient.""" # these have different places than in the gateway PLUTO_PSK = '/tmp/psk.txt' PLUTO_PIDFILE = '/tmp/pluto.pid' OPENL2TP_PIDFILE = '/tmp/openl2tp.pid' POOL_SIZE=5
"""Constants for testclient.""" pluto_psk = '/tmp/psk.txt' pluto_pidfile = '/tmp/pluto.pid' openl2_tp_pidfile = '/tmp/openl2tp.pid' pool_size = 5
# created by RomaOkorosso at 21.03.2021 # config.py db_url = "postgres://USER:PASSWORD@IP:PORT/DATABASE_NAME"
db_url = 'postgres://USER:PASSWORD@IP:PORT/DATABASE_NAME'
def tree_transplant(self, u, v): if(u.pai == None): self.raiz = v elif(u.pai.left == u): u.pai.left = v else: u.pai.right = v if(v != None): v.pai = u.pai
def tree_transplant(self, u, v): if u.pai == None: self.raiz = v elif u.pai.left == u: u.pai.left = v else: u.pai.right = v if v != None: v.pai = u.pai
""" Baseline training file used in app production ----------------OBSOLETE---------------- import os import sqlite3 from sklearn.linear_model import LogisticRegression from basilica import Connection import psycopg2 # Load in basilica api key API_KEY = "d3c5e936-18b0-3aac-8a2c-bf95511eaaa5" # Filepath fo...
""" Baseline training file used in app production ----------------OBSOLETE---------------- import os import sqlite3 from sklearn.linear_model import LogisticRegression from basilica import Connection import psycopg2 # Load in basilica api key API_KEY = "d3c5e936-18b0-3aac-8a2c-bf95511eaaa5" # Filepath fo...
"""Test case for variable redefined in inner loop.""" for item in range(0, 5): print("hello") for item in range(5, 10): #[redefined-outer-name] print(item) print("yay") print(item) print("done")
"""Test case for variable redefined in inner loop.""" for item in range(0, 5): print('hello') for item in range(5, 10): print(item) print('yay') print(item) print('done')
def longestWord(sentence): wordArray = sentence.split(" ") longest = "" for word in wordArray: if(len(word) >= len(longest)): longest = word return longest print(longestWord("Hello World"))
def longest_word(sentence): word_array = sentence.split(' ') longest = '' for word in wordArray: if len(word) >= len(longest): longest = word return longest print(longest_word('Hello World'))
c = str(input()) if c[0] == c[1] == c[2]: print("Won") else: print("Lost")
c = str(input()) if c[0] == c[1] == c[2]: print('Won') else: print('Lost')
class Node: def __init__(self,data=None): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def showlist(self): while self.head is not None: print(self.head.data) self.head=self.head.next list=LinkedList() list.head...
class Node: def __init__(self, data=None): self.data = data self.next = None class Linkedlist: def __init__(self): self.head = None def showlist(self): while self.head is not None: print(self.head.data) self.head = self.head.next list = linked_list...
### Left and Right product lists ### class Solution1: def productExceptSelf(self, nums: List[int]) -> List[int]: l = 1 r = 1 length = len(nums) ans = [1]*length for i in range( 0, length ): ans[i] *=l ans[length -i-1] *= r l *= num...
class Solution1: def product_except_self(self, nums: List[int]) -> List[int]: l = 1 r = 1 length = len(nums) ans = [1] * length for i in range(0, length): ans[i] *= l ans[length - i - 1] *= r l *= nums[i] r *= nums[length - i -...
print("welcome to calculator \n") a=int(input("enter first value")) b=int(input("enter seconde value")) print("which operation you want two perform \n add sub mul div") c=input() if c=="add": d=a+b print(d) if c=="sub": d=a-b print(d) if c=="mul": d=a*b print(d) if c=="div": d=a/b print(...
print('welcome to calculator \n') a = int(input('enter first value')) b = int(input('enter seconde value')) print('which operation you want two perform \n add sub mul div') c = input() if c == 'add': d = a + b print(d) if c == 'sub': d = a - b print(d) if c == 'mul': d = a * b print(d) if c == '...
#!/usr/bin/env python3 print('hello world') print('hello', 'world') ## use "sep" parameter to change output print('hello', 'world', sep = '_')
print('hello world') print('hello', 'world') print('hello', 'world', sep='_')
people=30 cars=40 trucks=15 if cars>people: print("We should take the cars") elif cars<people: print("We should not take the cars") else: print("We can't decide") if trucks>cars: print("That's too many trucks") elif trucks<cars: print("Maybe we could take the trucks") else: print("We still can't...
people = 30 cars = 40 trucks = 15 if cars > people: print('We should take the cars') elif cars < people: print('We should not take the cars') else: print("We can't decide") if trucks > cars: print("That's too many trucks") elif trucks < cars: print('Maybe we could take the trucks') else: print("...
''' Description Given a continuous stream of data, write a function that returns the first unique number (including the last number) when the terminating number arrives. If the terminating number is not found, return -1. Example Example1 Input: [1, 2, 2, 1, 3, 4, 4, 5, 6] 5 Output: 3 Example2 Input: [1, 2, 2, 1, 3...
""" Description Given a continuous stream of data, write a function that returns the first unique number (including the last number) when the terminating number arrives. If the terminating number is not found, return -1. Example Example1 Input: [1, 2, 2, 1, 3, 4, 4, 5, 6] 5 Output: 3 Example2 Input: [1, 2, 2, 1, 3...
def armsinside(): i01.rightArm.rotate.attach() i01.rightArm.rotate.moveTo(0) sleep(7) i01.rightArm.rotate.detach()
def armsinside(): i01.rightArm.rotate.attach() i01.rightArm.rotate.moveTo(0) sleep(7) i01.rightArm.rotate.detach()
Byte = { 'LF': '\x0A', 'NULL': '\x00' } class Frame: def __init__(self, command, headers, body): self.command = command self.headers = headers self.body = '' if body is None else body def __str__(self): lines = [self.command] skipContentLength = 'content-lengt...
byte = {'LF': '\n', 'NULL': '\x00'} class Frame: def __init__(self, command, headers, body): self.command = command self.headers = headers self.body = '' if body is None else body def __str__(self): lines = [self.command] skip_content_length = 'content-length' in self....
fin = open('input_24.txt') def getdir(text): while text: direction = text[:2] if direction in ['nw','ne','sw','se']: text = text[2:] yield direction else: text = text[1:] yield direction[0] ftiles = set() # (row,column) # row, column moves ...
fin = open('input_24.txt') def getdir(text): while text: direction = text[:2] if direction in ['nw', 'ne', 'sw', 'se']: text = text[2:] yield direction else: text = text[1:] yield direction[0] ftiles = set() moves = {'nw': (-1, -1), 'w': (0, -...
# automatically generated by the FlatBuffers compiler, do not modify # namespace: quantra class FlowType(object): Interest = 0 PastInterest = 1 Notional = 2
class Flowtype(object): interest = 0 past_interest = 1 notional = 2
#!/usr/bin/env python3 list1 = ['cisco-nxos', 'arista_eos', 'cisco-ios'] print(list1) print(list1[1]) list1.extend(['juniper']) print(list1) list1.append(['10.1.0.1','10.2.0.1','10.3.0.1']) print(list1) print("4th element in list1 is ".format(list1[4])) print(list1[4][0])
list1 = ['cisco-nxos', 'arista_eos', 'cisco-ios'] print(list1) print(list1[1]) list1.extend(['juniper']) print(list1) list1.append(['10.1.0.1', '10.2.0.1', '10.3.0.1']) print(list1) print('4th element in list1 is '.format(list1[4])) print(list1[4][0])
if __name__ == '__main__': print("TESTOUTPUT")
if __name__ == '__main__': print('TESTOUTPUT')
class Solution(object): def binaryTreePaths(self, root): if not root: return [] arrow = '->' ans = [] stack = [] stack.append((root, '')) while stack: node, path = stack.pop() path += arrow+str(node.val) if path else str(node.val) #a...
class Solution(object): def binary_tree_paths(self, root): if not root: return [] arrow = '->' ans = [] stack = [] stack.append((root, '')) while stack: (node, path) = stack.pop() path += arrow + str(node.val) if path else str(node...
def insert_user_list(): keys = ['_id', 'name', 'is_zero_user', 'gender', 'location', 'business', 'education', 'motto', 'answer_num', 'collection_num', 'followed_column_num', 'followed_topic_num', 'followee_num', 'follower_num', 'post_num', 'question_num', 'thank_num', ...
def insert_user_list(): keys = ['_id', 'name', 'is_zero_user', 'gender', 'location', 'business', 'education', 'motto', 'answer_num', 'collection_num', 'followed_column_num', 'followed_topic_num', 'followee_num', 'follower_num', 'post_num', 'question_num', 'thank_num', 'upvote_num', 'photo_url', 'weibo_url'] out...
# automatically generated by the FlatBuffers compiler, do not modify # namespace: DeepSeaSceneLighting class LightUnion(object): NONE = 0 DirectionalLight = 1 PointLight = 2 SpotLight = 3
class Lightunion(object): none = 0 directional_light = 1 point_light = 2 spot_light = 3
def ciagCyfr(x): lista = [] for i in range(x): if i%2 == 0: i = i+1 lista.append(i) else: i = (i+1)*(-1) lista.append(i) print(lista)
def ciag_cyfr(x): lista = [] for i in range(x): if i % 2 == 0: i = i + 1 lista.append(i) else: i = (i + 1) * -1 lista.append(i) print(lista)
""" Largest Element in Array: Given an array find the largest element in the array """ """Solution: """ def largest_element(a) -> int: le = 0 for i in a: if i > le: le = i return le def main(): arr_input = [40, 100, 8, 50] a = largest_element(arr_input) print(a) # Usi...
""" Largest Element in Array: Given an array find the largest element in the array """ 'Solution: ' def largest_element(a) -> int: le = 0 for i in a: if i > le: le = i return le def main(): arr_input = [40, 100, 8, 50] a = largest_element(arr_input) print(a) if __name__ ==...
def bubbleSort(l, n): for i in range(n): for j in range(n-1-i): if l[j][0] > l[j+1][0]: l[j], l[j+1] = l[j+1], l[j] return l[:] def selectionSort(l, n): for i in range(n): minj = i for j in range(i+1, n): if l[j][0] < l[minj][0]: ...
def bubble_sort(l, n): for i in range(n): for j in range(n - 1 - i): if l[j][0] > l[j + 1][0]: (l[j], l[j + 1]) = (l[j + 1], l[j]) return l[:] def selection_sort(l, n): for i in range(n): minj = i for j in range(i + 1, n): if l[j][0] < l[minj]...
# Version of the migration tool VERSION = "0.6" LOG_DIR="/var/log" LOG_FILE_PATH="%s/filerobot-migrate.log" % LOG_DIR UPLOADED_UUIDS_PATH="%s/filerobot-migrate-uploaded-uuids.log" % LOG_DIR LOG_FAILED_PATH="%s/filerobot-migrate-failed" % LOG_DIR LOG_RETRY_FAILED_PATH="%s/filerobot-migrate-retry-failed.log" % LOG_DIR D...
version = '0.6' log_dir = '/var/log' log_file_path = '%s/filerobot-migrate.log' % LOG_DIR uploaded_uuids_path = '%s/filerobot-migrate-uploaded-uuids.log' % LOG_DIR log_failed_path = '%s/filerobot-migrate-failed' % LOG_DIR log_retry_failed_path = '%s/filerobot-migrate-retry-failed.log' % LOG_DIR default_input_file = 'in...
md_icons = { 'md-3d-rotation': u"\uf000", 'md-accessibility': u"\uf001", 'md-account-balance': u"\uf002", 'md-account-balance-wallet': u"\uf003", 'md-account-box': u"\uf004", 'md-account-child': u"\uf005", 'md-account-circle': u"\uf006", 'md-add-shopping-cart': u"\uf007", 'md-alarm': ...
md_icons = {'md-3d-rotation': u'\uf000', 'md-accessibility': u'\uf001', 'md-account-balance': u'\uf002', 'md-account-balance-wallet': u'\uf003', 'md-account-box': u'\uf004', 'md-account-child': u'\uf005', 'md-account-circle': u'\uf006', 'md-add-shopping-cart': u'\uf007', 'md-alarm': u'\uf008', 'md-alarm-add': u'\uf009'...
# Time: O(n) # Space: O(n) class Solution(object): def isPrefixOfWord(self, sentence, searchWord): """ :type sentence: str :type searchWord: str :rtype: int """ def KMP(text, pattern): def getPrefix(pattern): prefix = [-1] * len(pattern) ...
class Solution(object): def is_prefix_of_word(self, sentence, searchWord): """ :type sentence: str :type searchWord: str :rtype: int """ def kmp(text, pattern): def get_prefix(pattern): prefix = [-1] * len(pattern) j = -1...
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # * RUNTIME SHENG TRANSLATOR - CORE * # ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ # * Welcome to Runtime Sheng translator. v1.0.0 * # * MIT License, Copyright(c) 2018, Antony Muga * # * All Rights...
project_details = "\n\t\t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\t\t* RUNTIME SHENG TRANSLATOR *\n\t\t++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n\t\t* Welcome to Runtime Sheng translator. v1.0.0 *\n\t\t* MIT License, Copyright(c) 2018, Anto...
# # PySNMP MIB module XYPLEX-IPX-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYPLEX-IPX-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:40:03 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ...
''' ''' def load(config): data = [] with open(config['SimLex-999']['Dataset_File'], 'r') as stream: # skip headers stream.readline() # load data for line in stream: (w1, w2, _, score, _) = [s.strip() for s in line.split('\t', 4)] data.append((w1, w2, floa...
""" """ def load(config): data = [] with open(config['SimLex-999']['Dataset_File'], 'r') as stream: stream.readline() for line in stream: (w1, w2, _, score, _) = [s.strip() for s in line.split('\t', 4)] data.append((w1, w2, float(score))) return data
class Solution: def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ sumStr = str(int(a) + int(b)) sumList = [int(sumStr[i]) for i in range(len(sumStr))] for i in range(0, len(sumList) - 1): k = len(sumList) - i - 1 ...
class Solution: def add_binary(self, a, b): """ :type a: str :type b: str :rtype: str """ sum_str = str(int(a) + int(b)) sum_list = [int(sumStr[i]) for i in range(len(sumStr))] for i in range(0, len(sumList) - 1): k = len(sumList) - i - 1 ...
""" Provides Python modules such as; * LiteXXX referenced as submodules. * (Maybe?) pip installable libraries like; - colorterm - hexfile - etc """
""" Provides Python modules such as; * LiteXXX referenced as submodules. * (Maybe?) pip installable libraries like; - colorterm - hexfile - etc """
class Missed(object): pass class Null: pass class RaiseKeyError: pass class LazyCache(object): """Wraps a Django cache object to provide more features.""" missed = Missed() def __init__(self, cache, default_timeout=None): self.cache = cache self.default_timeout = default_...
class Missed(object): pass class Null: pass class Raisekeyerror: pass class Lazycache(object): """Wraps a Django cache object to provide more features.""" missed = missed() def __init__(self, cache, default_timeout=None): self.cache = cache self.default_timeout = default_time...
def poly_sum(xs, ys): # return the list representing the sum of the polynomials represented by the # lists xs and ys zs = [] l = min(len(xs), len(ys)) for i in range(0, l): zs.append(xs[i] + ys[i]) if len(xs) > len(ys): for i in range(l, len(xs)): zs.append(xs[i]) ...
def poly_sum(xs, ys): zs = [] l = min(len(xs), len(ys)) for i in range(0, l): zs.append(xs[i] + ys[i]) if len(xs) > len(ys): for i in range(l, len(xs)): zs.append(xs[i]) else: for i in range(l, len(ys)): zs.append(ys[i]) return zs def test(test_ca...
class Stack: def __init__(self, data=[]): self.data = data def __repr__(self) -> str: return f"{self.data}" def peek(self): if self.data: return self.data[-1] else: return None def pop(self): return self.data.pop() def push(self, d)...
class Stack: def __init__(self, data=[]): self.data = data def __repr__(self) -> str: return f'{self.data}' def peek(self): if self.data: return self.data[-1] else: return None def pop(self): return self.data.pop() def push(self, d...
"""esta clase va a manejar las fracciones""" def validaEntero(funcion): def validar(*args): if len(args) == 2: numero1=args[0] numero2=args[1] numero1=convierteTipo(numero1) numero2=convierteTipo(numero2) return funcion(numero1, numero2) e...
"""esta clase va a manejar las fracciones""" def valida_entero(funcion): def validar(*args): if len(args) == 2: numero1 = args[0] numero2 = args[1] numero1 = convierte_tipo(numero1) numero2 = convierte_tipo(numero2) return funcion(numero1, numero...
_asmm_version = '1.3.2' _xml_version = '1.0b' _py_version = '3.5.1' _eclipse_version = '4.6.3' _qt_version = '5.9' _report_version = '3.4.0'
_asmm_version = '1.3.2' _xml_version = '1.0b' _py_version = '3.5.1' _eclipse_version = '4.6.3' _qt_version = '5.9' _report_version = '3.4.0'
a = int(input("a :")) b = int(input("b :")) c = int(input("c :")) delta = (b**2) - (4*a*c) print(delta)
a = int(input('a :')) b = int(input('b :')) c = int(input('c :')) delta = b ** 2 - 4 * a * c print(delta)
def test_hello_svc_without_param(hello_svc_client): """ Given: hello svc running on cluster And: I have cluster ip address And: I have service port When: I do a get call Then: I should get back 200 Ok And: I should get back string Hi there, !" """ status, response = hello_svc_client...
def test_hello_svc_without_param(hello_svc_client): """ Given: hello svc running on cluster And: I have cluster ip address And: I have service port When: I do a get call Then: I should get back 200 Ok And: I should get back string Hi there, !" """ (status, response) = hello_svc_clien...
class Solution: # Count Consecutive Groups (Top Voted), O(n) time and space def countBinarySubstrings(self, s: str) -> int: s = list(map(len, s.replace('01', '0 1').replace('10', '1 0').split())) return sum(min(a, b) for a, b in zip(s, s[1:])) # Linear Scan (Solution), O(n) time, O(1) space...
class Solution: def count_binary_substrings(self, s: str) -> int: s = list(map(len, s.replace('01', '0 1').replace('10', '1 0').split())) return sum((min(a, b) for (a, b) in zip(s, s[1:]))) def count_binary_substrings(self, s: str) -> int: (ans, prev, cur) = (0, 0, 1) for i in ...
# class FmeRenderer(object): RENDER_MODE_CONSOLE = 1 RENDER_MODE_GRAPH = 2 def __init__(self, render_mode=RENDER_MODE_CONSOLE): self.name = 'apps.fme.FmeRender' self.render_mode = render_mode def render_obs(self, obs): pass
class Fmerenderer(object): render_mode_console = 1 render_mode_graph = 2 def __init__(self, render_mode=RENDER_MODE_CONSOLE): self.name = 'apps.fme.FmeRender' self.render_mode = render_mode def render_obs(self, obs): pass
# Set options for certfile, ip, password, and toggle off c.NotebookApp.certfile = '/tmp/mycert.pem' c.NotebookApp.keyfile = '/tmp/mykey.key' # Set ip to '*' to bind on all interfaces (ips) for the public server c.NotebookApp.ip = '*' # It is a good idea to set a known, fixed port for server access c.NotebookApp.port ...
c.NotebookApp.certfile = '/tmp/mycert.pem' c.NotebookApp.keyfile = '/tmp/mykey.key' c.NotebookApp.ip = '*' c.NotebookApp.port = 8888 c.NotebookApp.open_browser = False
class Solution: def canJump(self, nums: List[int]) -> bool: maxlen = 0 i = 0 while i <= maxlen and i < len(nums): maxlen = max(maxlen, i + nums[i]) i += 1 if maxlen >= len(nums) - 1: return True return False
class Solution: def can_jump(self, nums: List[int]) -> bool: maxlen = 0 i = 0 while i <= maxlen and i < len(nums): maxlen = max(maxlen, i + nums[i]) i += 1 if maxlen >= len(nums) - 1: return True return False