content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class News: ''' news class to define news Objects ''' def __init__(self, id, name, description, url, category, language, country): self.id =id self.name = name self.description= description self.url =url self.category=category self.language = language ...
class News: """ news class to define news Objects """ def __init__(self, id, name, description, url, category, language, country): self.id = id self.name = name self.description = description self.url = url self.category = category self.language = languag...
# Copyright 2016 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
def generate_makefile(sources, executable_name, compile_command, link_command, link_command_suffix): link_rule_template = '\n{executable_name}: {object_files}\n\t{link_command} {object_files} -o {executable_name} {link_command_suffix}\n' compile_rule_template = '\n{name}.o: {name}.cpp\n\t{compile_command} -c {n...
class Solution: # 1st solution, TLE def shortestPath(self, grid: List[List[int]], k: int) -> int: ans = [float("inf")] self.bfs(grid, 0, 0, 0, k, ans) return ans[0] if ans[0] != float("inf") else -1 def bfs(self, grid, i, j, steps, k, ans): if k < 0: return ...
class Solution: def shortest_path(self, grid: List[List[int]], k: int) -> int: ans = [float('inf')] self.bfs(grid, 0, 0, 0, k, ans) return ans[0] if ans[0] != float('inf') else -1 def bfs(self, grid, i, j, steps, k, ans): if k < 0: return m = len(grid) ...
class Solution: def customSortString(self, S: str, T: str) -> str: char_map = {} for el in S: char_map[el] = 0 for el in T: if el in char_map: char_map[el] = char_map[el] + 1 else: char_map[el] = 1 output_str = "" ...
class Solution: def custom_sort_string(self, S: str, T: str) -> str: char_map = {} for el in S: char_map[el] = 0 for el in T: if el in char_map: char_map[el] = char_map[el] + 1 else: char_map[el] = 1 output_str = ''...
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe") load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def taskflow_repository(): maybe( http_archive, name = "taskflow", urls = [ "https://github.com/taskflow/taskflow/archive/refs/tags/v3.2.0.zip", ...
load('@bazel_tools//tools/build_defs/repo:utils.bzl', 'maybe') load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive') def taskflow_repository(): maybe(http_archive, name='taskflow', urls=['https://github.com/taskflow/taskflow/archive/refs/tags/v3.2.0.zip'], sha256='dec011fcd9d73ae4bd8ae4d2714c2c108a0...
line = input() abbr = line[0] for i in range(len(line)): if line[i] == "-": abbr += line[i+1] print(abbr)
line = input() abbr = line[0] for i in range(len(line)): if line[i] == '-': abbr += line[i + 1] print(abbr)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed May 6 11:24:11 2020 provides formatting for COVID-19 Notebook @author: seanlucas """ def html_catalog(catalog): metadata = catalog.get_metadata() dataproduct_rows = '' for dataproduct in metadata['dataProducts']: dataproduct_rows ...
""" Created on Wed May 6 11:24:11 2020 provides formatting for COVID-19 Notebook @author: seanlucas """ def html_catalog(catalog): metadata = catalog.get_metadata() dataproduct_rows = '' for dataproduct in metadata['dataProducts']: dataproduct_rows += f"""\n <tr style="border: 1px solid b...
class BinaryTree: def __init__(self, value): self.value = value self.left = None self.right = None def nodeDepths(root, depth=0): if root is None: return 0 return (depth + nodeDepths(root.left, depth + 1) + nodeDepths(root.right, depth + 1))
class Binarytree: def __init__(self, value): self.value = value self.left = None self.right = None def node_depths(root, depth=0): if root is None: return 0 return depth + node_depths(root.left, depth + 1) + node_depths(root.right, depth + 1)
def sqrt(x): y = 1.0 while abs(y*y - x) > 1e-6 : print(y) y=(y+x/y)/2 return y if __name__=='__main__': print(sqrt(99))
def sqrt(x): y = 1.0 while abs(y * y - x) > 1e-06: print(y) y = (y + x / y) / 2 return y if __name__ == '__main__': print(sqrt(99))
a1 = str(input('Digite o nome completo de uma pessoa : ')) a3 = a1.strip().lower().find('silva') if a3 < 0: print('O nome {} nao possui a palavra Silva'.format(a1)) else: print('O nome {} possui a palavra Silva'.format(a1)) # ou nom = str(input('digite o nome : ')).strip() print('seu nome tem silva? {}'.format(...
a1 = str(input('Digite o nome completo de uma pessoa : ')) a3 = a1.strip().lower().find('silva') if a3 < 0: print('O nome {} nao possui a palavra Silva'.format(a1)) else: print('O nome {} possui a palavra Silva'.format(a1)) nom = str(input('digite o nome : ')).strip() print('seu nome tem silva? {}'.format('silv...
#=============================================== #RESOLUTION KEYWORDS #=============================================== oref = 0 #over refine factor - should typically be set to 0 n_ref = 32 #when n_particles > n_ref, octree refines further zoom_box_len = 100 #kpc; so the box will be +/- zoom_box_len from the center bbo...
oref = 0 n_ref = 32 zoom_box_len = 100 bbox_lim = 100000.0 n_processes = 16 n_mpi_processes = 1 n_photons_initial = 100000.0 n_photons_imaging = 100000.0 n_photons_raytracing_sources = 100000.0 n_photons_raytracing_dust = 100000.0 force_random_seed = False seed = -12345 dustdir = '/home/desika.narayanan/hyperion-dust-0...
# # PySNMP MIB module CISCO-VLAN-BRIDGING-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-VLAN-BRIDGING-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:18:48 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_size_constraint, constraints_union, value_range_constraint, single_value_constraint) ...
# Error Handling def inp(a): while True: try: n = int(input(a)) except ValueError: print('Please enter a number only !!') else: return n print(inp("Enter a number: ")) try: while x: print("Hello\n") raise NameError except NameError as e...
def inp(a): while True: try: n = int(input(a)) except ValueError: print('Please enter a number only !!') else: return n print(inp('Enter a number: ')) try: while x: print('Hello\n') raise NameError except NameError as e: print(e) finall...
class Diff: def __init__(self): self.user = None self.date = None self.note = None self.fields = {} def diff_historical_object(original_historical_object, changed_historical_object): """ Performs a diff between two historical objects to determine which fields have changed. ...
class Diff: def __init__(self): self.user = None self.date = None self.note = None self.fields = {} def diff_historical_object(original_historical_object, changed_historical_object): """ Performs a diff between two historical objects to determine which fields have changed. ...
high = 0 for x in range(100,1000): for y in range(100,1000): if str(x*y) == str(x*y)[::-1] and x*y>high: high = x*y print(high)
high = 0 for x in range(100, 1000): for y in range(100, 1000): if str(x * y) == str(x * y)[::-1] and x * y > high: high = x * y print(high)
# %% [504. Base 7](https://leetcode.com/problems/base-7/) class Solution: def convertToBase7(self, num: int) -> str: sign, num = "-" * (num < 0), abs(num) res = [] while num: res.append(str(num % 7)) num //= 7 return sign + "".join(res[::-1] or ["0"])
class Solution: def convert_to_base7(self, num: int) -> str: (sign, num) = ('-' * (num < 0), abs(num)) res = [] while num: res.append(str(num % 7)) num //= 7 return sign + ''.join(res[::-1] or ['0'])
class ModelConfig(object): def __init__(self, max_epochs, batch_size, learning_rate, per_series_lr_multip, gradient_eps, gradient_clipping_threshold, lr_scheduler_step_size, noise_std, level_variability_penalty, tau, c_state_penalty, state_hsize, dilation...
class Modelconfig(object): def __init__(self, max_epochs, batch_size, learning_rate, per_series_lr_multip, gradient_eps, gradient_clipping_threshold, lr_scheduler_step_size, noise_std, level_variability_penalty, tau, c_state_penalty, state_hsize, dilations, add_nl_layer, seasonality, input_size, output_size, frequ...
''' class Solution { public ListNode swapNodes(ListNode head, int k) { int listLength = 0; ListNode currentNode = head; // find the length of linked list while (currentNode != null) { listLength++; currentNode = currentNode.next; } // set the f...
""" class Solution { public ListNode swapNodes(ListNode head, int k) { int listLength = 0; ListNode currentNode = head; // find the length of linked list while (currentNode != null) { listLength++; currentNode = currentNode.next; } // set the f...
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def is_balanced(self, root): """ :type root: TreeNode :rtype: bool """ def check...
class Solution(object): def is_balanced(self, root): """ :type root: TreeNode :rtype: bool """ def check(root): if root is None: return 0 left = check(root.left) right = check(root.right) if left == -1 or right...
#9.28 6:23AM def reverse_sub_list(head, p, q): # TODO: Write your code here # to capture the apart pre_p, post_q = head, head # to capture the range p_node, q_node = head, head # to track others pointer = head oneStep = pointer.next while oneStep is not None: if oneStep.value == p: pre_p = ...
def reverse_sub_list(head, p, q): (pre_p, post_q) = (head, head) (p_node, q_node) = (head, head) pointer = head one_step = pointer.next while oneStep is not None: if oneStep.value == p: pre_p = pointer p_node = oneStep elif pointer.value == q: post...
class MotorControllerCANStatus(): """CTRE TalonSRX/VictorSPX motor controller CAN bus status frame decoder The base arbitration ID for the TalonSRX is 0x02040000 and 0x01040000 for the VictorSPX. The arbitration device ID is a 6-bit value between 0x00 and 0x3F. The arbitration status ID's are as foll...
class Motorcontrollercanstatus: """CTRE TalonSRX/VictorSPX motor controller CAN bus status frame decoder The base arbitration ID for the TalonSRX is 0x02040000 and 0x01040000 for the VictorSPX. The arbitration device ID is a 6-bit value between 0x00 and 0x3F. The arbitration status ID's are as follow...
""" Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's serialization of this node is [3,4,5]...
""" Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's serialization of this node is [3,4,5]...
# # PySNMP MIB module ADTRAN-ATLAS-MODULE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADTRAN-ATLAS-MODULE-MIB # Produced by pysmi-0.3.4 at Wed May 1 11:14:30 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 ...
(ad_atlas_unit_fp_status, ad_atlas_unit_slot_address, ad_atlas_unit_port_address) = mibBuilder.importSymbols('ADTRAN-ATLAS-UNIT-MIB', 'adATLASUnitFPStatus', 'adATLASUnitSlotAddress', 'adATLASUnitPortAddress') (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier'...
""" Given an unsorted list of integers, sort those integers using the Bubble Sort algorithm. Return the number of swaps required to sort the list. Bubble Sort is a simple sorting algorithm that works as follows: 1. Start at the beginning of the list, and traverse through each element. 2. For each element, if the elem...
""" Given an unsorted list of integers, sort those integers using the Bubble Sort algorithm. Return the number of swaps required to sort the list. Bubble Sort is a simple sorting algorithm that works as follows: 1. Start at the beginning of the list, and traverse through each element. 2. For each element, if the elem...
# https://www.codewars.com/kata/555eded1ad94b00403000071/train/python def series_sum(n): if n == 0: return "0.00" if n == 1: return "1.00" sum = 1 floor = 4 for _ in range(n-1): sum += (1/floor) floor += 3 return '%.2f' % round(sum,2)
def series_sum(n): if n == 0: return '0.00' if n == 1: return '1.00' sum = 1 floor = 4 for _ in range(n - 1): sum += 1 / floor floor += 3 return '%.2f' % round(sum, 2)
# magicblast_alignment.py # # Author: Jan Piotr Buchmann <jan.buchmann@sydney.edu.au> # Description: # # Version: 0.0 class MappingAlignment: class Read: def __init__(self, name, start, stop, strand, qlen): self.name = name self.length = int(qlen) self.sra_rowid = name.split('.')[1] ...
class Mappingalignment: class Read: def __init__(self, name, start, stop, strand, qlen): self.name = name self.length = int(qlen) self.sra_rowid = name.split('.')[1] self.start = int(start) - 1 self.stop = int(stop) - 1 self.strand = ...
# SPDX-License-Identifier: Apache-2.0 # # The OpenSearch Contributors require contributions made to # this file be licensed under the Apache-2.0 license or a # compatible open source license. class CiTarget: version: str name: str snapshot: bool def __init__(self, version: str, name: str, snapshot: b...
class Citarget: version: str name: str snapshot: bool def __init__(self, version: str, name: str, snapshot: bool=True) -> None: self.version = version self.name = name self.snapshot = snapshot @property def opensearch_version(self) -> str: return self.version + ...
''' Exercise 1: 1. Write a recursive function print_all(numbers) that prints all the elements of list of integers, one per line (use no while loops or for loops). The parameters numbers to the function is a list of int. 2. Same problem as the last one but prints out the elements in reverse order. ''' #printing all in...
""" Exercise 1: 1. Write a recursive function print_all(numbers) that prints all the elements of list of integers, one per line (use no while loops or for loops). The parameters numbers to the function is a list of int. 2. Same problem as the last one but prints out the elements in reverse order. """ def print_all(num...
class Generations(object): def __init__(self): self.age = self.next_age = 0 self.neighbors = [None] * 8 self.live_count = 0 def count_live_neighbors(self): self.live_count = 0 for n in self.neighbors: if n.age == 1: self.live_count += 1 ...
class Generations(object): def __init__(self): self.age = self.next_age = 0 self.neighbors = [None] * 8 self.live_count = 0 def count_live_neighbors(self): self.live_count = 0 for n in self.neighbors: if n.age == 1: self.live_count += 1 ...
def word_len(word): """Returns the length of word not counting spaces >>> word_len("a la carte") 8 >>> word_len("hello") 5 >>> word_len('') 0 >>> word_len("coup d'etat") 10 """ num = len(word) for i in range(len(word)): if word[i] == " ": num = num-1 ...
def word_len(word): """Returns the length of word not counting spaces >>> word_len("a la carte") 8 >>> word_len("hello") 5 >>> word_len('') 0 >>> word_len("coup d'etat") 10 """ num = len(word) for i in range(len(word)): if word[i] == ' ': num = num - ...
def gray_to_binary(gray,bits=4): """converts a given gray code to its binary number""" mask = 1 << (bits - 1) binary = gray & mask for i in xrange(bits-1): bmask = 1 << (bits - i-1) gmask = bmask >> 1 if (binary & bmask) ^ ((gray & gmask) << 1): binary = binary | gm...
def gray_to_binary(gray, bits=4): """converts a given gray code to its binary number""" mask = 1 << bits - 1 binary = gray & mask for i in xrange(bits - 1): bmask = 1 << bits - i - 1 gmask = bmask >> 1 if binary & bmask ^ (gray & gmask) << 1: binary = binary | gmask ...
# Problem URL: https://leetcode.com/problems/search-in-rotated-sorted-array-ii class Solution: def binarySearch(self, array, begin, end, target): mid = (begin + end)//2 while (begin<=end): if array[mid] == target: return True elif array[mid] < target:...
class Solution: def binary_search(self, array, begin, end, target): mid = (begin + end) // 2 while begin <= end: if array[mid] == target: return True elif array[mid] < target: begin = mid + 1 return self.binarySearch(array, beg...
# -*- coding: utf-8 -*- class Solution: def largestOddNumber(self, num: str) -> str: for index, digit in enumerate(reversed(num)): if int(digit) % 2 == 1: return num[:len(num) - index] return '' if __name__ == '__main__': solution = Solution() assert '5' == so...
class Solution: def largest_odd_number(self, num: str) -> str: for (index, digit) in enumerate(reversed(num)): if int(digit) % 2 == 1: return num[:len(num) - index] return '' if __name__ == '__main__': solution = solution() assert '5' == solution.largestOddNumber...
produce = ['apple','banana', 'cucumber'] volumes = ['one piece', 'cup', 'handful'] d = {} for i in range(len(produce)): if produce[i] not in d: d[produce[i]] = volumes[i] print(d.items())
produce = ['apple', 'banana', 'cucumber'] volumes = ['one piece', 'cup', 'handful'] d = {} for i in range(len(produce)): if produce[i] not in d: d[produce[i]] = volumes[i] print(d.items())
"""This test's if user successfully registered """ def test_successful_register(successful_registration): assert successful_registration.email == 'example@email.com' assert successful_registration.password == 'Password' assert successful_registration.confirm == 'Password' response = successful_registra...
"""This test's if user successfully registered """ def test_successful_register(successful_registration): assert successful_registration.email == 'example@email.com' assert successful_registration.password == 'Password' assert successful_registration.confirm == 'Password' response = successful_registra...
""" For the opening ceremony of the upcoming sports event an even number of athletes were picked. They formed a correct lineup, i.e. such a lineup in which no two boys or two girls stand together. The first person in the lineup was a girl. As a part of the performance, adjacent pairs of athletes (i.e. the first one tog...
""" For the opening ceremony of the upcoming sports event an even number of athletes were picked. They formed a correct lineup, i.e. such a lineup in which no two boys or two girls stand together. The first person in the lineup was a girl. As a part of the performance, adjacent pairs of athletes (i.e. the first one tog...
def get_settings_dot_py_changes(config): """Return dictionaries with changed strings of settings.py""" INSERTED = { # Value inserted before line with key "from pathlib import Path": "import sys, os\n", "# Quick-start development settings": ( '# Environment flag\n' ...
def get_settings_dot_py_changes(config): """Return dictionaries with changed strings of settings.py""" inserted = {'from pathlib import Path': 'import sys, os\n', '# Quick-start development settings': '# Environment flag\nENVIRONMENT = os.environ.get("DJANGO_ENVIRONMENT", default="development")\n\n', 'ALLOWED_H...
class Jobs: tag = '' time_requested = 0 finished = False def __init__(self, tag_, time_requested_): self.tag = tag_ self.time_requested = time_requested_
class Jobs: tag = '' time_requested = 0 finished = False def __init__(self, tag_, time_requested_): self.tag = tag_ self.time_requested = time_requested_
class Solution: #given a list of integer #return an integer def maxArea(self, height): res = 0 left = 0 right = len(height) - 1 while left < right: if height[left] < height[right]: res = max(res, height[left] * (right - left)) left ...
class Solution: def max_area(self, height): res = 0 left = 0 right = len(height) - 1 while left < right: if height[left] < height[right]: res = max(res, height[left] * (right - left)) left += 1 else: res = max(r...
l3 = list(filter(lambda x: 1000 <= x <= 9999, list(int(n * (n + 1)/2) for n in range(9999)))) l4 = list(filter(lambda x: 1000 <= x <= 9999, list(int(n*n) for n in range(9999)))) l5 = list(filter(lambda x: 1000 <= x ...
l3 = list(filter(lambda x: 1000 <= x <= 9999, list((int(n * (n + 1) / 2) for n in range(9999))))) l4 = list(filter(lambda x: 1000 <= x <= 9999, list((int(n * n) for n in range(9999))))) l5 = list(filter(lambda x: 1000 <= x <= 9999, list((int(n * (3 * n - 1) / 2) for n in range(9999))))) l6 = list(filter(lambda x: 1000 ...
# # PySNMP MIB module FN100-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/FN100-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:00:25 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...
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ...
def aio_documented_by(original): def wrapper(target): target.__doc__ = "Aio function: {original_doc}".format(original_doc=original.__doc__) return target return wrapper def documented_by(original): def wrapper(target): target.__doc__ = original.__doc__ return target r...
def aio_documented_by(original): def wrapper(target): target.__doc__ = 'Aio function: {original_doc}'.format(original_doc=original.__doc__) return target return wrapper def documented_by(original): def wrapper(target): target.__doc__ = original.__doc__ return target re...
class TurboSMSRouter(object): app_label = 'turbosms' db_name = 'turbosms' def db_for_read(self, model, **hints): if model._meta.app_label == self.app_label: return self.db_name return None def db_for_write(self, model, **hints): if model._meta.app_label == self...
class Turbosmsrouter(object): app_label = 'turbosms' db_name = 'turbosms' def db_for_read(self, model, **hints): if model._meta.app_label == self.app_label: return self.db_name return None def db_for_write(self, model, **hints): if model._meta.app_label == self.app_...
""" This module implements the FLOAT class, used (sparingly please!) for real number storage and manipulation. (Ian Howie Mackenzie - April 2009, July 2017) """ class FLOAT(float): """ simple float handling """ def __new__(self, x=0.0): """ create our (immutable) float force invalid x to...
""" This module implements the FLOAT class, used (sparingly please!) for real number storage and manipulation. (Ian Howie Mackenzie - April 2009, July 2017) """ class Float(float): """ simple float handling """ def __new__(self, x=0.0): """ create our (immutable) float force invalid x to ...
BROWSER_IMPLICIT_WAIT_TIME = 5 MODAL_TRANSITION_WAIT_TIME = 2 BOOTSTRAP_SWITCH_TRANSITION_WAIT_TIME = 1 PAGE_LOADING_WAIT_TIME = 5 PAGE_LOADING_LONG_WAIT_TIME = 10
browser_implicit_wait_time = 5 modal_transition_wait_time = 2 bootstrap_switch_transition_wait_time = 1 page_loading_wait_time = 5 page_loading_long_wait_time = 10
''' Class /is holding plate = True / attributes:/ / \ / tables_responsible = [4, 5, 6] waiter (object) \ \ / def take_order(table, order) ...
""" Class /is holding plate = True / attributes:/ / / tables_responsible = [4, 5, 6] waiter (object) \\ / def take_order(table, order) / ...
# Split-initiator sequences from # Sequences retrieved from https://dev.biologists.org/content/develop/suppl/2018/06/21/145.12.dev165753.DC1/DEV165753supp.pdf # Sequences below include 2nt spacers on 3' end of odd and 5' end of even to allow for bending to present initiator. initiators = { "B1": { "odd": "...
initiators = {'B1': {'odd': 'gAggAgggCAgCAAACggAA', 'even': 'TAgAAgAgTCTTCCTTTACg'}, 'B2': {'odd': 'CCTCgTAAATCCTCATCAAA', 'even': 'AAATCATCCAgTAAACCgCC'}, 'B3': {'odd': 'gTCCCTgCCTCTATATCTTT', 'even': 'TTCCACTCAACTTTAACCCg'}, 'B4': {'odd': 'CCTCAACCTACCTCCAACAA', 'even': 'ATTCTCACCATATTCgCTTC'}, 'B5': {'odd': 'CTCACTC...
# Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. class ChoiceFactoryOptions: def __init__( self, inline_separator: str = None, inline_or: str = None, inline_or_more: str = None, include_numbers: bool = None, ) -> None: ...
class Choicefactoryoptions: def __init__(self, inline_separator: str=None, inline_or: str=None, inline_or_more: str=None, include_numbers: bool=None) -> None: """Initializes a new instance. Refer to the code in the ConfirmPrompt for an example of usage. :param object: :type object:...
""" Time complexity: O(n*m) (where n = nth sequence, m = length of the longest sequence) Space complexity: O(m) (for the resulting sequence) """ def look_and_say(n): sequence = "1" for _ in range(n - 1): sequence = "".join(groups(sequence)) return sequence """ Return an array with pairs [occurrences...
""" Time complexity: O(n*m) (where n = nth sequence, m = length of the longest sequence) Space complexity: O(m) (for the resulting sequence) """ def look_and_say(n): sequence = '1' for _ in range(n - 1): sequence = ''.join(groups(sequence)) return sequence '\nReturn an array with pairs [occu...
#!/usr/bin/env python # $Id: listsets.py,v 2.1 2004/07/14 17:38:53 zeller Exp $ def listminus(c1, c2): """Return a list of all elements of C1 that are not in C2.""" s2 = {} for delta in c2: s2[delta] = 1 c = [] for delta in c1: if not s2.has_key(delta): c.append...
def listminus(c1, c2): """Return a list of all elements of C1 that are not in C2.""" s2 = {} for delta in c2: s2[delta] = 1 c = [] for delta in c1: if not s2.has_key(delta): c.append(delta) return c def listintersect(c1, c2): """Return the common elements of C1 a...
2227 247 2216 3705 555 166 977 1900 4858 1337 3934 3599 4200 1598 2940 2359 2756 3753 1332 3646 706 428 3958 974 2744 2501 1209 2579 4987 334 2169 2175 4273 2890 3569 1006 2539 3855 1353 2677 1369 2008 59 311 1294 3008 1717 3271 1563 867 3466 187 4939 4719 1485 1243 1898 1169 4667 228 1743 4146 661 2831 158 724 2289 19...
2227 247 2216 3705 555 166 977 1900 4858 1337 3934 3599 4200 1598 2940 2359 2756 3753 1332 3646 706 428 3958 974 2744 2501 1209 2579 4987 334 2169 2175 4273 2890 3569 1006 2539 3855 1353 2677 1369 2008 59 311 1294 3008 1717 3271 1563 867 3466 187 4939 4719 1485 1243 1898 1169 4667 228 1743 4146 661 2831 158 724 2289 19...
def docking_data_01(lines): mask = None data = dict() for line in [line.split() for line in lines]: if line[0] == 'mask': mask = line[2] else: index = line[0] bits = "{0:b}".format(int(line[2])) bits = (36-len(bits))*'0' + bits mask...
def docking_data_01(lines): mask = None data = dict() for line in [line.split() for line in lines]: if line[0] == 'mask': mask = line[2] else: index = line[0] bits = '{0:b}'.format(int(line[2])) bits = (36 - len(bits)) * '0' + bits ...
# File: smime_consts.py # Copyright (c) 2020 Splunk Inc. # # Licensed under Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt) # Sign email action related constants SMIME_SIGN_PROGRESS_MSG = "Signing email message" SMIME_SIGN_OK_MSG = "Email message signed successfully" SMIME_SIGN_ERR_MSG = "Error occurred w...
smime_sign_progress_msg = 'Signing email message' smime_sign_ok_msg = 'Email message signed successfully' smime_sign_err_msg = 'Error occurred while signing message. {err}' smime_verify_progress_msg = 'Verifying signed email message' smime_verify_ok_msg = 'Signed email message verified successfully' smime_verify_err_ms...
_list = ['int', 'bool', 'str'] def sys_macro_load(): result = '' for _type in _list: with open(f'cool_compiler/codegen/v1_mips_generate/general_macros//{_type}.mips') as mips: text = mips.read() mips.close() result += text[text.index('#region'): text.index('#endregi...
_list = ['int', 'bool', 'str'] def sys_macro_load(): result = '' for _type in _list: with open(f'cool_compiler/codegen/v1_mips_generate/general_macros//{_type}.mips') as mips: text = mips.read() mips.close() result += text[text.index('#region'):text.index('#endregion...
# coding=utf-8 class App: TESTING = True # ReverseProxy.HTTP_X_SCRIPT_NAME='/__' HOST_URL = 'http://pay.lvye.com' class Checkout: ZYT_MAIN_PAGE = 'http://pay.lvye.com/__/main' VALID_NETLOCS = ['pay.lvye.com'] AES_KEY = "2HF5UKPIADDYBHDSKOVP9GMA80MU2IV2" PAYMENT_CHECKOUT_VALID_SECONDS = 1 * 60 ...
class App: testing = True host_url = 'http://pay.lvye.com' class Checkout: zyt_main_page = 'http://pay.lvye.com/__/main' valid_netlocs = ['pay.lvye.com'] aes_key = '2HF5UKPIADDYBHDSKOVP9GMA80MU2IV2' payment_checkout_valid_seconds = 1 * 60 * 60 class Lvyepaysitepayclientconfig: root_url = 'http...
""" This module contains the TissueMAPs interface to Napari plugin. """
""" This module contains the TissueMAPs interface to Napari plugin. """
def get_file_list(num_files): """ formats number of files in olympus format :param num_files: :return: list of file numbers """ file_list = [] for num in range(1, num_files+1): num = str(num) to_add = 4-len(num) final = '0'*to_add+num file_list.append(final) ...
def get_file_list(num_files): """ formats number of files in olympus format :param num_files: :return: list of file numbers """ file_list = [] for num in range(1, num_files + 1): num = str(num) to_add = 4 - len(num) final = '0' * to_add + num file_list.append(...
n = int(input()) p_list = sorted(list(map(int, input().split()))) ret = 0 for i in range(n): ret += (n-i) * p_list[i] print(ret)
n = int(input()) p_list = sorted(list(map(int, input().split()))) ret = 0 for i in range(n): ret += (n - i) * p_list[i] print(ret)
expected_output = { "power_stack": { "Powerstack-1": { "allocated_power": 575, "mode": "SP-PS", "power_supply_num": 1, "reserved_power": 0, "switch_num": 1, "switches": { 1: { "allocated_power": 575,...
expected_output = {'power_stack': {'Powerstack-1': {'allocated_power': 575, 'mode': 'SP-PS', 'power_supply_num': 1, 'reserved_power': 0, 'switch_num': 1, 'switches': {1: {'allocated_power': 575, 'available_power': 525, 'consumed_power_poe': 0, 'consumed_power_sys': 155, 'power_budget': 1100, 'power_supply_a': 1100, 'po...
class HtmlEmitter(object): def emit(self, s): self.file.write(s) def emit_line(self, s=""): self.emit(s) self.emit("\n") def initialize(self, filename, title, author, date): self.file = open(filename, "w") self.emit_line("""<html> <head> <link re...
class Htmlemitter(object): def emit(self, s): self.file.write(s) def emit_line(self, s=''): self.emit(s) self.emit('\n') def initialize(self, filename, title, author, date): self.file = open(filename, 'w') self.emit_line('<html>\n<head>\n <link rel="stylesheet" ...
# # PySNMP MIB module ENTERASYS-ACTIVATION-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENTERASYS-ACTIVATION-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:03:07 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7....
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection, constraints_union) ...
def Qklnu(cfg,k,l,nu) : #function q=Qklnu(k,l,nu) # #% Computes Q, neccesary constant#% Computes Q, neccesary consta...
def qklnu(cfg, k, l, nu): aux_1 = cfg.power(-1, k + nu) / cfg.power(4.0, k) aux_2 = cfg.sqrt((2 * l + 4 * k + 3) / 3.0) aux_3 = cfg.trinomial(nu, k - nu, l + nu + 1) * cfg.nchoosek(2 * (l + nu + 1 + k), l + nu + 1 + k) aux_4 = cfg.nchoosek(2.0 * (l + nu + 1), l + nu + 1) q = aux_1 * aux_2 * aux_3 / ...
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017-05-23 16:23 # @Author : Max # @File : singleton.py def singleton(cls): instance = cls() instance.__call__ = lambda: instance return instance
def singleton(cls): instance = cls() instance.__call__ = lambda : instance return instance
# HSX hsxuc_events.v1.00p hsxuc_derived.v1.00p # aliases aliases = { "QPIRxMatch1": "Q_Py_PCI_RX_PMON_BOX_MATCH1", "QPIRxMask1": "Q_Py_PCI_RX_PMON_BOX_MASK1", "IRPFilter": "IRP_PCI_PMON_BOX_FILTER", "PCUFilter": "PCU_MSR_PMON_BOX_FILTER", "QPIRxMask0": "Q_Py_PCI_RX_PMON_BOX_MASK0", "CBoFi...
aliases = {'QPIRxMatch1': 'Q_Py_PCI_RX_PMON_BOX_MATCH1', 'QPIRxMask1': 'Q_Py_PCI_RX_PMON_BOX_MASK1', 'IRPFilter': 'IRP_PCI_PMON_BOX_FILTER', 'PCUFilter': 'PCU_MSR_PMON_BOX_FILTER', 'QPIRxMask0': 'Q_Py_PCI_RX_PMON_BOX_MASK0', 'CBoFilter0': 'Cn_MSR_PMON_BOX_FILTER', 'HA_AddrMatch0': 'HAn_PCI_PMON_BOX_ADDRMATCH0', 'QPITxM...
def find_syntax_error(line): correct = True incorrect_char = None complete = True closing_chars = [] to_close = [] chunk_characters = { '(': ')', '{': '}', '[': ']', '<': '>' } for char in line: if char in chunk_characters.keys(): ...
def find_syntax_error(line): correct = True incorrect_char = None complete = True closing_chars = [] to_close = [] chunk_characters = {'(': ')', '{': '}', '[': ']', '<': '>'} for char in line: if char in chunk_characters.keys(): to_close.append(char) elif chunk_ch...
class Solution: def getMaximumGenerated(self, n: int) -> int: nums = [0,1] + [0]*(n-1) if n < 2: return nums[n] for i in range(2, n+1): if i % 2 == 0 and i//2 <= n: nums[i] = nums[i//2] if i % 2 == 1 and i//2 + 1 <= n: nums[i] = nums[i//2] + nums[i//2+1] return max(nums)
class Solution: def get_maximum_generated(self, n: int) -> int: nums = [0, 1] + [0] * (n - 1) if n < 2: return nums[n] for i in range(2, n + 1): if i % 2 == 0 and i // 2 <= n: nums[i] = nums[i // 2] if i % 2 == 1 and i // 2 + 1 <= n: ...
# Copyright 2018 The go-python Authors. All rights reserved. # Use of this source code is governed by a BSD-style # license that can be found in the LICENSE file. doc="str" assert str(b"") == "b''" assert str(b"hello") == r"b'hello'" assert str(rb"""hel"lo""") == r"""b'hel"lo'""" assert str(b"""he llo""") == r"""b'he...
doc = 'str' assert str(b'') == "b''" assert str(b'hello') == "b'hello'" assert str(b'hel"lo') == 'b\'hel"lo\'' assert str(b'he\nllo') == "b'he\\nllo'" assert str(b"hel'lo") == 'b"hel\'lo"' assert str(b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1a\x1b\x1c\x1d\x1e...
setup( name="better-max-tools-installer", version="1.0.0", description="Installer for the Better Max Tools Python package.", long_description="", long_description_content_type="text/markdown", url="https://github.com/thomascswalker/better-max-tools", author="Thomas Walker", author_email=...
setup(name='better-max-tools-installer', version='1.0.0', description='Installer for the Better Max Tools Python package.', long_description='', long_description_content_type='text/markdown', url='https://github.com/thomascswalker/better-max-tools', author='Thomas Walker', author_email='thomascswalker@gmail.com', licen...
def merge(A, left, mid, right): global cnt inf = 10**9 L = A[left:mid] + [inf] R = A[mid:right] + [inf] i = 0 j = 0 for k in range(left, right): cnt += 1 if L[i] < R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 def...
def merge(A, left, mid, right): global cnt inf = 10 ** 9 l = A[left:mid] + [inf] r = A[mid:right] + [inf] i = 0 j = 0 for k in range(left, right): cnt += 1 if L[i] < R[j]: A[k] = L[i] i += 1 else: A[k] = R[j] j += 1 def...
""" Python Program to check Armstrong Number (as 153) """ def checkArmstrong(num): num = str(num) order = len(num) res = 0 for i in num: res += pow(int(i),order) return True if res == int(num) else False N = int(input("Enter the number: ")) if checkArmstrong(N): print(N,"is...
""" Python Program to check Armstrong Number (as 153) """ def check_armstrong(num): num = str(num) order = len(num) res = 0 for i in num: res += pow(int(i), order) return True if res == int(num) else False n = int(input('Enter the number: ')) if check_armstrong(N): print(N, 'is an arms...
class Solution: def recursiveExist(self, board, i, j, visited, word, k): # visited.add((i, j)) visited.append((i, j)) if k == len(word): return True elif board[i][j] == word[k]: for di, dj in [[0, 1], [0, -1], [1, 0], [-1, 0]]: i_, j_ = i +...
class Solution: def recursive_exist(self, board, i, j, visited, word, k): visited.append((i, j)) if k == len(word): return True elif board[i][j] == word[k]: for (di, dj) in [[0, 1], [0, -1], [1, 0], [-1, 0]]: (i_, j_) = (i + di, j + dj) ...
class Weekdays(object): """A mock enum. When pep 435 rolls out, this can be upgraded to be a proper enum. ref: http://www.python.org/dev/peps/pep-0435/ """ Sunday = 0 Monday = 1 Tuesday = 2 Wednesday = 3 Thursday = 4 Friday = 5 Saturday = 6 _to_string = { 0: 'Su...
class Weekdays(object): """A mock enum. When pep 435 rolls out, this can be upgraded to be a proper enum. ref: http://www.python.org/dev/peps/pep-0435/ """ sunday = 0 monday = 1 tuesday = 2 wednesday = 3 thursday = 4 friday = 5 saturday = 6 _to_string = {0: 'Sunday', 1: ...
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "mango"] thislist[1:3] = ["blackcurrant", "watermelon"] print(thislist)
thislist = ['apple', 'banana', 'cherry', 'orange', 'kiwi', 'mango'] thislist[1:3] = ['blackcurrant', 'watermelon'] print(thislist)
print("Hello Word.") def nome(parameter_list): a = parameter_list.split(" ", 2) print(a) nome('dag cirino mano dev') nome('dagmar aparecido')
print('Hello Word.') def nome(parameter_list): a = parameter_list.split(' ', 2) print(a) nome('dag cirino mano dev') nome('dagmar aparecido')
def construct_square(s): p = len(s) d_max = int((10**p)**.5) d_min = int((10**(p-1))**.5) for d in range(d_max, d_min -1, -1): n = str(d * d) if sorted(s.count(c) for c in set(s)) == sorted(n.count(c) for c in set(n)): return int(n) return -1 if __name__ == '__main__':...
def construct_square(s): p = len(s) d_max = int((10 ** p) ** 0.5) d_min = int((10 ** (p - 1)) ** 0.5) for d in range(d_max, d_min - 1, -1): n = str(d * d) if sorted((s.count(c) for c in set(s))) == sorted((n.count(c) for c in set(n))): return int(n) return -1 if __name__ ...
# Lexical scoping in Python and an interesting scenario with resolving value in class. # Author: Zhuo Lu # Test suite 1 def test1(): """ Try to change a nonlocal variable of a parent frame. """ def noeffect(): # Uncomment the following line to show that local variable referenced before assign...
def test1(): """ Try to change a nonlocal variable of a parent frame. """ def noeffect(): a = 2 print(a) a = 1 print(a) noeffect() print(a) def test2(): """ Correct way to change a nonlocal variable. """ def affect(): nonlocal a print(a)...
# nested2.py # # Nested loop Example 2 # CSC 110 # Fall 2011 #accumulators for the outer loop sumOuter = 0 for outer in [1, 2, 3, 4]: print('Outer loop iteration', outer) sumOuter += outer sumInner = 0 # accumulator for this inner loop # notice that the inner loop's repetitions is based on the va...
sum_outer = 0 for outer in [1, 2, 3, 4]: print('Outer loop iteration', outer) sum_outer += outer sum_inner = 0 for inner in range(1, outer + 1): print(' Inner loop iteration', inner) sum_inner += inner print(' Inner loop sum = ', sumInner) print() print('Outer loop sum = ',...
class Atom(object): """ """ def __init__(self, index, name=None, residue_index=-1, residue_name=None): """Create an Atom object Args: index (int): index of atom in the molecule name (str): name of the atom (eg., N, CH) residue_index (int): index of residue i...
class Atom(object): """ """ def __init__(self, index, name=None, residue_index=-1, residue_name=None): """Create an Atom object Args: index (int): index of atom in the molecule name (str): name of the atom (eg., N, CH) residue_index (int): index of residue ...
#-----------------------------------------------------------------------------# # MODULE DESCRIPTION # #-----------------------------------------------------------------------------# """RedBrick Options Module; contains RBOpt class.""" #------------------------...
"""RedBrick Options Module; contains RBOpt class.""" __version__ = '$Revision: 1.5 $' __author__ = 'Cillian Sharkey' class Rbopt: """Class for storing options to be shared by modules""" def __init__(self): """Create new RBOpt object.""" self.override = None self.test = None sel...
def method1(ll1, ll2, n1, n2): hs = set() for i in range(0, n1): hs.add(ll1[i]) print("Intersection:") for i in range(0, n2): if ll2[i] in hs: print(ll2[i], end=" ") if __name__ == "__main__": """ from timeit import timeit ll1 = [7, 1, 5, 2, 3, 6] ll2 = [3, ...
def method1(ll1, ll2, n1, n2): hs = set() for i in range(0, n1): hs.add(ll1[i]) print('Intersection:') for i in range(0, n2): if ll2[i] in hs: print(ll2[i], end=' ') if __name__ == '__main__': '\n from timeit import timeit\n ll1 = [7, 1, 5, 2, 3, 6]\n ll2 = [3, 8...
# rock = 0 # paper = 1 # scissors = 2 # paper beats rock # scissors beats paper # rock beats scissors print("Player 1: Type 0 for rock, type 1 for paper, type 2 for scissors") first_player = int(input()) print("Player 2: Type 0 for rock, type 1 for paper, type 2 for scissors") second_player = int(input()) if first_pl...
print('Player 1: Type 0 for rock, type 1 for paper, type 2 for scissors') first_player = int(input()) print('Player 2: Type 0 for rock, type 1 for paper, type 2 for scissors') second_player = int(input()) if first_player == 1 and second_player == 0: print('Player 1 wins') elif first_player == 2 and second_player ==...
#!/usr/bin/env python3 """ Module with functions to performs element-wise operations """ def np_elementwise(mat1, mat2): """ addition, subtraction, multiplication, and division Returns the new matrix """ return(mat1 + mat2, mat1 - mat2, mat1 * mat2, mat1 / mat2)
""" Module with functions to performs element-wise operations """ def np_elementwise(mat1, mat2): """ addition, subtraction, multiplication, and division Returns the new matrix """ return (mat1 + mat2, mat1 - mat2, mat1 * mat2, mat1 / mat2)
table_id_map = { 1: "__all_core_table", 2: "__all_root_table", 3: "__all_table", 4: "__all_column", 5: "__all_ddl_operation", 101: "__all_meta_table", 102: "__all_user", 103: "__all_user_history", 104: "__all_database", 105: "__all_database_history", 106: "__all_tablegroup", 107: "__all_tablegro...
table_id_map = {1: '__all_core_table', 2: '__all_root_table', 3: '__all_table', 4: '__all_column', 5: '__all_ddl_operation', 101: '__all_meta_table', 102: '__all_user', 103: '__all_user_history', 104: '__all_database', 105: '__all_database_history', 106: '__all_tablegroup', 107: '__all_tablegroup_history', 108: '__all_...
# # PySNMP MIB module HUAWEI-RIPV2-EXT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-RIPV2-EXT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:36:24 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (defau...
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ...
"""Commonly used utilities.""" __all__ = ('sexpr', 'bap_comment', 'run', 'ida', 'abstract_ida_plugins', 'config', 'bap_taint')
"""Commonly used utilities.""" __all__ = ('sexpr', 'bap_comment', 'run', 'ida', 'abstract_ida_plugins', 'config', 'bap_taint')
# -*- coding: utf-8 -*- """ pip_services_runtime.commands.ICommand ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Interface for commands. :copyright: Digital Living Software Corp. 2015-2016, see AUTHORS for more details. :license: MIT, see LICENSE for more details. """ class ICommand(object): ...
""" pip_services_runtime.commands.ICommand ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Interface for commands. :copyright: Digital Living Software Corp. 2015-2016, see AUTHORS for more details. :license: MIT, see LICENSE for more details. """ class Icommand(object): """ Interface for c...
# Copyright 2015 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"). You # may not use this file except in compliance with the License. A copy of # the License is located at # # http://aws.amazon.com/apache2.0/ # # or in the "license" file acc...
def substring_search(word, collection): """Finds all matches in the `collection` for the specified `word`. If `word` is empty, returns all items in `collection`. :type word: str :param word: The substring to search for. :type collection: collection, usually a list :param collection: A collect...
class Expansion(object): __expansion_table = [ 31, 0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9, 10, 11, 12, 11, 12, 13, 14, 15, 16, 15, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 24, 23, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31, 0 ] __p = [ 1, 2, 3, 4, 5, 8, 9, 10, 11, 14, 15, 16, 17, 20,...
class Expansion(object): __expansion_table = [31, 0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 8, 7, 8, 9, 10, 11, 12, 11, 12, 13, 14, 15, 16, 15, 16, 17, 18, 19, 20, 19, 20, 21, 22, 23, 24, 23, 24, 25, 26, 27, 28, 27, 28, 29, 30, 31, 0] __p = [1, 2, 3, 4, 5, 8, 9, 10, 11, 14, 15, 16, 17, 20, 21, 22, 23, 26, 27, 28, 29, 32, 3...
""" Finding a peak element: Given an array of integers.Find a peak element in it. An array element is peak if it is NOT smaller than its neighbors. For corner elements, we need to consider only one neighbor. For example, for input array {5,10,20,15}, 20 is the only peak element. """ # A python 3 program to find a p...
""" Finding a peak element: Given an array of integers.Find a peak element in it. An array element is peak if it is NOT smaller than its neighbors. For corner elements, we need to consider only one neighbor. For example, for input array {5,10,20,15}, 20 is the only peak element. """ def find_peak_util(arr, low, high...
# # PySNMP MIB module TIPPINGPOINT-REG-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIPPINGPOINT-REG-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:23:40 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') (constraints_intersection, value_size_constraint, single_value_constraint, value_range_constraint, constraints_union) ...
class SandwichBar: def whichOrder(self, available, orders): for i, o in enumerate(orders): if all(map(lambda e: e in available, o.split())): return i return -1
class Sandwichbar: def which_order(self, available, orders): for (i, o) in enumerate(orders): if all(map(lambda e: e in available, o.split())): return i return -1
CENTS_PER_DOLLAR = 100 class Order(object): def __init__(self, id, owner, ticker, type, price, qty): if int(id) < 0: raise ValueError() if round(float(price), 2) <= 0: raise ValueError() if int(qty) <= 0: raise ValueError() self.__id = id ...
cents_per_dollar = 100 class Order(object): def __init__(self, id, owner, ticker, type, price, qty): if int(id) < 0: raise value_error() if round(float(price), 2) <= 0: raise value_error() if int(qty) <= 0: raise value_error() self.__id = id ...
# fileType=Python, blankLineCounts=3, commentCounts=5, commentInLineCounts=0, fileSize=259, lineCounts=7, rowLineCounts=15 def add(x, y): """ Hello World """ ''' # Real Second line ''' '''Second''' ''' line ''' string = "Hello World #\ " y += len(string) # Add the two ...
def add(x, y): """ Hello World # Real Second line """ 'Second line\n ' string = 'Hello World # ' y += len(string) x + y
#!/usr/bin/python3 for i in range(ord('z'), ord('a') - 1, -1): if (i % 2 != 0): i = i - 32 i = chr(i) print("{}".format(i), end='')
for i in range(ord('z'), ord('a') - 1, -1): if i % 2 != 0: i = i - 32 i = chr(i) print('{}'.format(i), end='')
VERSION = (0, 4, 2) def get_version(): return '%s.%s.%s' % VERSION version = get_version()
version = (0, 4, 2) def get_version(): return '%s.%s.%s' % VERSION version = get_version()
""" URL: https://codeforces.com/problemset/problem/49/A Author: Safiul Kabir [safiulanik at gmail.com] """ s = ''.join(input().split()).lower() if s[-2] in ['a', 'e', 'i', 'o', 'u', 'y']: print('YES') else: print('NO')
""" URL: https://codeforces.com/problemset/problem/49/A Author: Safiul Kabir [safiulanik at gmail.com] """ s = ''.join(input().split()).lower() if s[-2] in ['a', 'e', 'i', 'o', 'u', 'y']: print('YES') else: print('NO')
""" Connecting Cities With Minimum Cost There are n cities labeled from 1 to n. You are given the integer n and an array connections where connections[i] = [xi, yi, costi] indicates that the cost of connecting city xi and city yi (bidirectional connection) is costi. Return the minimum cost to connect all the n cit...
""" Connecting Cities With Minimum Cost There are n cities labeled from 1 to n. You are given the integer n and an array connections where connections[i] = [xi, yi, costi] indicates that the cost of connecting city xi and city yi (bidirectional connection) is costi. Return the minimum cost to connect all the n cit...
cont = contIdade = contHomens = contMulher20 = 0 print('-=' * 15, '\nCadastro de Pessoas') print('-=' * 15) while True: idade = int(input('\033[1mDigite a idade:\033[m ')) if idade >= 18: contIdade += 1 sexo = ' ' while sexo not in 'MmFf': sexo = str(input('\033[1mDigite o sexo [M/F]:\03...
cont = cont_idade = cont_homens = cont_mulher20 = 0 print('-=' * 15, '\nCadastro de Pessoas') print('-=' * 15) while True: idade = int(input('\x1b[1mDigite a idade:\x1b[m ')) if idade >= 18: cont_idade += 1 sexo = ' ' while sexo not in 'MmFf': sexo = str(input('\x1b[1mDigite o sexo [M/F]...
n = int(input().strip()) for i in range(1, n + 1): cnt = 0 for j in list(str(i)): if j in ['3', '6', '9']: cnt += 1 if cnt > 0: print('-' * cnt, end=' ') else: print(i, end=' ')
n = int(input().strip()) for i in range(1, n + 1): cnt = 0 for j in list(str(i)): if j in ['3', '6', '9']: cnt += 1 if cnt > 0: print('-' * cnt, end=' ') else: print(i, end=' ')
def test_add_group(app, json_groups): group = json_groups old_groups = app.group.get_group_list() app.group.create(group) # new list is longer, because we added 1 element assert app.group.count() == len(old_groups) + 1 # if new list length is correct, then we can compare lists. # so we can...
def test_add_group(app, json_groups): group = json_groups old_groups = app.group.get_group_list() app.group.create(group) assert app.group.count() == len(old_groups) + 1 new_groups = app.group.get_group_list() old_groups.append(group) assert sorted(new_groups) == sorted(old_groups)