content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
def mark_spot(n): if type(n) is not int or n <= 0 or n % 2 == 0: return "?" p1, s = 0, 2*n - 3 result = "" for i in range(1,n // 2 + 1): result += " " * p1 + "X" + " " * s + "X\n" p1 += 2 s -= 4 result += " " * p1 + "X\n" for i in range(n // 2 + 2,n+1): p...
def mark_spot(n): if type(n) is not int or n <= 0 or n % 2 == 0: return '?' (p1, s) = (0, 2 * n - 3) result = '' for i in range(1, n // 2 + 1): result += ' ' * p1 + 'X' + ' ' * s + 'X\n' p1 += 2 s -= 4 result += ' ' * p1 + 'X\n' for i in range(n // 2 + 2, n + 1): ...
class OrderState: OPEN_PENDING_INT = 1 OPEN_PENDING_EXT = 2 OPEN_FAILED = 3 OPENED = 4 PARTIALLY_FILLED = 5 FILLED = 6 CANCEL_PENDING_INT = 7 CANCEL_PENDING_EXT = 8 CANCEL_FAILED = 9 CANCELED = 10 REJECTED = 11 EXPIRED = 12
class Orderstate: open_pending_int = 1 open_pending_ext = 2 open_failed = 3 opened = 4 partially_filled = 5 filled = 6 cancel_pending_int = 7 cancel_pending_ext = 8 cancel_failed = 9 canceled = 10 rejected = 11 expired = 12
# ---------------------------------------------------------------- # Copyright 2017 Cisco Systems # # 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/LICENS...
""" class_enum_printer.py prints Go enum class method """ class Enumprinter(object): def __init__(self, ctx): self.ctx = ctx def print_enum(self, enum_class): self._print_enum_header(enum_class) self._print_enum_body(enum_class) self._print_enum_trailer(enum_class) def...
class Solution: def findProductExceptSelf(self,arr): output=[1] for i in range(len(arr)-1,0,-1): output.append(output[-1]*arr[i]) output=output[::-1] left = 1 for i in range(len(arr)): output[i]= output[i]*left left*=arr[i] return o...
class Solution: def find_product_except_self(self, arr): output = [1] for i in range(len(arr) - 1, 0, -1): output.append(output[-1] * arr[i]) output = output[::-1] left = 1 for i in range(len(arr)): output[i] = output[i] * left left *= arr...
# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages try: # pragma: no cover __import__("pkg_resources").declare_namespace(__name__) except ImportError: # pragma: no cover __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
try: __import__('pkg_resources').declare_namespace(__name__) except ImportError: __import__('pkgutil').extend_path(__path__, __name__)
# HEAD # Classes Introduction - Methods # DESCRIPTION # Describes how to create methods in classes # Use classes to create objects with own methods # RESOURCES # # Creating a custom class # Class name - MethodDefs class MethodDefs(): # Simple public method doing just printing # # Method follows a...
class Methoddefs: def method(self): print('Some value') def method_two_names(self): return 'Some Value' def method_three(self, a1, a2, a3='DefaultValue'): print('a1, a2, a3', a1, a2, a3) return ('Multiple Returns', a1, a2, a3) def method_four(self, *args): pri...
#25points | Easy # -*- coding: utf-8 -*- """ Created on Mon Dec 16 12:16:48 2019 @author: Ravi """ def convertToList(n): z = str(n) list = [] for i in z: list.append(i) return findDigit(list,n) #newlist = finddigits(1012) def findDigit(list,n): count = 0 for i in list: if int...
""" Created on Mon Dec 16 12:16:48 2019 @author: Ravi """ def convert_to_list(n): z = str(n) list = [] for i in z: list.append(i) return find_digit(list, n) def find_digit(list, n): count = 0 for i in list: if int(i) != 0: if n % int(i) == 0: count ...
""""" Variables: Names that we give to certain values in our programs. Variable names are CASE SENSITIVE. Syntax: Variable = Value Restrictions: - Can't use any reserved word - Don't use spaces - Must start with a letter or undersco...
""""" Variables: Names that we give to certain values in our programs. Variable names are CASE SENSITIVE. Syntax: Variable = Value Restrictions: - Can't use any reserved word - Don't use spaces - Must start with a letter or undersco...
def solution(n): res = "" answer = ["4", "1", "2"] while(n): res = answer[int(n%3)] + res if (not(n%3)): n = int(n/3) -1 else: n = int(n/3) print(res) return res # reference # https://mungto.tistory.com/206 # others solution # def change124(n): # ...
def solution(n): res = '' answer = ['4', '1', '2'] while n: res = answer[int(n % 3)] + res if not n % 3: n = int(n / 3) - 1 else: n = int(n / 3) print(res) return res if __name__ == '__main__': solution(1) solution(2) solution(3) soluti...
# apparel # Classifier libraries for Apparel # # Author: Benjamin Bengfort <benjamin@bengfort.com> # Created: Thu Feb 05 20:24:45 2015 -0500 # # Copyright (C) 2014 Bengfort.com # For license information, see LICENSE.txt # # ID: __init__.py [] benjamin@bengfort.com $ """ Classifier libraries for Apparel """ #######...
""" Classifier libraries for Apparel """ __version__ = (1, 0, 0) def get_version(): """ Returns a string of the version """ return '.'.join(['%i' % i for i in __version__])
def tree(label, branches=[]): """Construct a tree with the given label value and a list of branches.""" for branch in branches: assert is_tree(branch), 'branches must be trees' return [label] + list(branches) def label(tree): """Return the label value of a tree.""" return tree[0] def branc...
def tree(label, branches=[]): """Construct a tree with the given label value and a list of branches.""" for branch in branches: assert is_tree(branch), 'branches must be trees' return [label] + list(branches) def label(tree): """Return the label value of a tree.""" return tree[0] def branc...
# =============================================================================== # Copyright 2015 Jake Ross # # 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...
def ps(t): return '{}s'.format(t) def camel_case(name, delimiters=None): if delimiters is None: delimiters = ('_', '/', ' ') name = '{}{}'.format(name[0].upper(), name[1:]) for d in delimiters: if d in name: name = ''.join((a.title() for a in name.split(d))) return name ...
# 343. Integer Break # Runtime: 36 ms, faster than 55.89% of Python3 online submissions for Integer Break. # Memory Usage: 14.3 MB, less than 47.74% of Python3 online submissions for Integer Break. class Solution: # Dynamic Programming def integerBreak(self, n: int) -> int: prdct = [0] * (n + 1) ...
class Solution: def integer_break(self, n: int) -> int: prdct = [0] * (n + 1) prdct[1] = 1 for i in range(2, n + 1): for j in range(1, i): prdct[i] = max(prdct[i], prdct[i - j] * j, j * (i - j)) return prdct[-1]
GRAPH_SIZE = (800, 800) GRAPH_BOUNDARIES = ((0, 0), (1000, 1000)) GRAPH_PADDING = 20 GRAPH_COORDS_BOTTOM_LEFT = (0 - GRAPH_PADDING, 0 - GRAPH_PADDING) GRAPH_COORDS_TOP_RIGHT = (GRAPH_BOUNDARIES[1][0] + GRAPH_PADDING, GRAPH_BOUNDARIES[1][1] + GRAPH_PADDING)
graph_size = (800, 800) graph_boundaries = ((0, 0), (1000, 1000)) graph_padding = 20 graph_coords_bottom_left = (0 - GRAPH_PADDING, 0 - GRAPH_PADDING) graph_coords_top_right = (GRAPH_BOUNDARIES[1][0] + GRAPH_PADDING, GRAPH_BOUNDARIES[1][1] + GRAPH_PADDING)
config = { "interfaces": { "google.privacy.dlp.v2beta1.DlpService": { "retry_codes": { "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], "non_idempotent": [] }, "retry_params": { "default": { "initial_r...
config = {'interfaces': {'google.privacy.dlp.v2beta1.DlpService': {'retry_codes': {'idempotent': ['DEADLINE_EXCEEDED', 'UNAVAILABLE'], 'non_idempotent': []}, 'retry_params': {'default': {'initial_retry_delay_millis': 100, 'retry_delay_multiplier': 1.3, 'max_retry_delay_millis': 60000, 'initial_rpc_timeout_millis': 2000...
# Write a program that creates gramatically valid English sentences. # Here, we consider a sentence to be gramatically correct when it follows the simple English grammar of the form: Article Adjective Noun Verb. That is, even the sentence A insect fly. is, for the moment, considered correct. Use the files inside t...
with open('C:/Users/23300/IdeaProjects/docker_notebooks/notebooks/data/verbs') as verbs_file: verbs = verbs_file.read().split('\n') with open('C:/Users/23300/IdeaProjects/docker_notebooks/notebooks/data/nouns') as nouns_file: nouns = nouns_file.read().split('\n') with open('C:/Users/23300/IdeaProjects/docker_no...
ch=input("enter a character:") if(ch=='a' or ch=='A' or ch=='e' or ch=='E' or ch=='i' or ch=='I' or ch=='o' or ch=='O' or ch=='u' or ch=='U'): print("entered character is vowel.") else: print("entered character is consonant.")
ch = input('enter a character:') if ch == 'a' or ch == 'A' or ch == 'e' or (ch == 'E') or (ch == 'i') or (ch == 'I') or (ch == 'o') or (ch == 'O') or (ch == 'u') or (ch == 'U'): print('entered character is vowel.') else: print('entered character is consonant.')
HANGMAN = ( """ ----- | | | | | | | | | -------- """, """ ----- | | | 0 | | | | | | -------- """, """ ----- | | | 0 | -+- | | | | | -------- """, """ ----- | | | 0 | /-+- | | | | | -------- """, """ ----- | | | 0 | /-+-\ | | | | | --------...
hangman = ('\n-----\n| |\n|\n|\n|\n|\n|\n|\n|\n--------\n', '\n-----\n| |\n| 0\n|\n|\n|\n|\n|\n|\n--------\n', '\n-----\n| |\n| 0\n| -+-\n|\n|\n|\n|\n|\n--------\n', '\n-----\n| |\n| 0\n| /-+-\n|\n|\n|\n|\n|\n--------\n', '\n-----\n| |\n| 0\n| /-+-\\ \n|\n|\n|\n|\n|\n--------\n', '\n-----\n| |\n| ...
EMPTY_GRAPH = """ digraph EMPTY { } """ FLOWCHART = """ digraph FLOWCHART { a [label="node one"]; b [label="node two"]; c [label="node three"]; a -> b -> c; } """ SIMPLE_GRAPH = """ digraph G { a [label="a"]; b [label="b"]; c [label="c"]; d [label="d"]; a -> b; a -> c; b -> d; c -> d; } """ PRUNED_SIMPLE_GRAPH = ...
empty_graph = '\ndigraph EMPTY {\n}\n' flowchart = '\ndigraph FLOWCHART {\na [label="node one"];\nb [label="node two"];\nc [label="node three"];\na -> b -> c;\n}\n' simple_graph = '\ndigraph G {\na [label="a"];\nb [label="b"];\nc [label="c"];\nd [label="d"];\na -> b;\na -> c;\nb -> d;\nc -> d;\n}\n' pruned_simple_gr...
load("//bazel/linux:providers.bzl", "KernelBundleInfo", "KernelImageInfo", "RuntimeBundleInfo", "RuntimeInfo") load("//bazel/linux:utils.bzl", "expand_deps", "get_compatible") load("//bazel/utils:messaging.bzl", "location", "package") load("//bazel/utils:files.bzl", "files_to_dir") load("@bazel_skylib//lib:shell.bzl", ...
load('//bazel/linux:providers.bzl', 'KernelBundleInfo', 'KernelImageInfo', 'RuntimeBundleInfo', 'RuntimeInfo') load('//bazel/linux:utils.bzl', 'expand_deps', 'get_compatible') load('//bazel/utils:messaging.bzl', 'location', 'package') load('//bazel/utils:files.bzl', 'files_to_dir') load('@bazel_skylib//lib:shell.bzl', ...
#!/usr/bin/env python # _*_ coding: utf-8 _*_ # ================================== # ================================== class cp2k_dft_real_time_propagation_print_current_each: def __init__(self): self.params = { } self.status = False def to_input(self, fout): ...
class Cp2K_Dft_Real_Time_Propagation_Print_Current_Each: def __init__(self): self.params = {} self.status = False def to_input(self, fout): """ fout: a file stream for writing """ fout.write('\t\t\t\t\t&EACH\n') for item in self.params: if se...
class Config: # Threshold = 0.92 exp = '' phase = 'train' data_dir = 'data' model_name = "seresnext26d_32x4d" label_smoothing_rate = 0.1 fold_num = 5 batch_size = 64 num_workers = 4 seed = 555 deterministic = True if phase == 'test' else False tta = True # SOTA #...
class Config: exp = '' phase = 'train' data_dir = 'data' model_name = 'seresnext26d_32x4d' label_smoothing_rate = 0.1 fold_num = 5 batch_size = 64 num_workers = 4 seed = 555 deterministic = True if phase == 'test' else False tta = True
# -*- coding: utf-8 -*- # # Copyright (c) 2017 Hewlett Packard Enterprise Development LP # # 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 # # Unl...
manifest = {'Name': 'interface_state_stats_monitor', 'Description': 'Interface Link state and Statistics Monitoring Agent', 'Version': '1.0', 'Author': 'Aruba Networks'} parameter_definitions = {'interface_id': {'Name': 'Interface Id', 'Description': 'Interface to be monitored', 'Type': 'string', 'Default': '1/1/1'}} ...
for _ in range(int(input())): a,b=1,0 for i in range(int(input())): a,b=b,a+b print(a,b)
for _ in range(int(input())): (a, b) = (1, 0) for i in range(int(input())): (a, b) = (b, a + b) print(a, b)
""" Spammer ======= Spammer package contains the whole logic responsible for collecting data from Jira and Bitbucket and sending it to slack. Adapters -------- This module contains adapters that are responsible for connecting to REST APIs delivered by 3rd party products such as Jira, BitBucket and Slack. Adapters c...
""" Spammer ======= Spammer package contains the whole logic responsible for collecting data from Jira and Bitbucket and sending it to slack. Adapters -------- This module contains adapters that are responsible for connecting to REST APIs delivered by 3rd party products such as Jira, BitBucket and Slack. Adapters c...
_base_ = './htc_r50_fpn_1x_coco.py' model = dict( pretrained='open-mmlab://resnext101_32x4d', backbone=dict( type='ResNeXt', depth=101, groups=32, base_width=4, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requi...
_base_ = './htc_r50_fpn_1x_coco.py' model = dict(pretrained='open-mmlab://resnext101_32x4d', backbone=dict(type='ResNeXt', depth=101, groups=32, base_width=4, num_stages=4, out_indices=(0, 1, 2, 3), frozen_stages=1, norm_cfg=dict(type='BN', requires_grad=True), norm_eval=True, style='pytorch', dcn=dict(type='DCN', defo...
class Solver: def __init__(self,draw_winner): self.draw=draw_winner self.INFINITY=1000000 self.draw_value=0 self.proven_win=10000 self.proven_loss=-10000 def turn_color(self,color): if color=='white': return 'black' else: return ...
class Solver: def __init__(self, draw_winner): self.draw = draw_winner self.INFINITY = 1000000 self.draw_value = 0 self.proven_win = 10000 self.proven_loss = -10000 def turn_color(self, color): if color == 'white': return 'black' else: ...
COGNITO_DOMAIN = "auth-aotuai-prod.auth.us-east-1.amazoncognito.com" """Cognito hosted sign-in domain""" CLIENT_ID = "5ud60vi8nr5lg0rdsv9j95mrro" """Client ID of the Application known by Cognito""" OAUTH_SCOPES = [ "https://api.aotu.ai/admin.brainframe-licenses", "https://api.aotu.ai/admin.brainframe-analytic...
cognito_domain = 'auth-aotuai-prod.auth.us-east-1.amazoncognito.com' 'Cognito hosted sign-in domain' client_id = '5ud60vi8nr5lg0rdsv9j95mrro' 'Client ID of the Application known by Cognito' oauth_scopes = ['https://api.aotu.ai/admin.brainframe-licenses', 'https://api.aotu.ai/admin.brainframe-analytics']
''' Deserializes mutation sequence data to a more easily digestable format USAGE EXAMPLE: arr = np.array([[1,2,3], [4,5,6]]) ms = MutationSequence(numpy_matrix) for mutation in ms: # Do something with mutation object ''' class Mutation: END_OF_SEQUENCE = 17 def __init__(self, serialized_params): ...
""" Deserializes mutation sequence data to a more easily digestable format USAGE EXAMPLE: arr = np.array([[1,2,3], [4,5,6]]) ms = MutationSequence(numpy_matrix) for mutation in ms: # Do something with mutation object """ class Mutation: end_of_sequence = 17 def __init__(self, serialized_params): ...
def calc(listH): max = listH[0] for i in listH: if i >= max: max = i if listH[listH.index(max)-1] >= max or listH[listH.index(max)+1] >= max: max = 0 return listH.count(max) T = int(input()) for i in range(T): N = int(input()) listH = [] for j in range(N...
def calc(listH): max = listH[0] for i in listH: if i >= max: max = i if listH[listH.index(max) - 1] >= max or listH[listH.index(max) + 1] >= max: max = 0 return listH.count(max) t = int(input()) for i in range(T): n = int(input()) list_h = [] for j in rang...
''' Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. Also, the subsets should be sorted in ascending ( lexicographic ) order. The list is not necessarily sorted. Example : If S = [1,2,3], ...
""" Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. Also, the subsets should be sorted in ascending ( lexicographic ) order. The list is not necessarily sorted. Example : If S = [1,2,3], ...
__author__ = 'Amine Kerkeni' # Source server parameters from_server_ip = "hostname1" from_server_user = "username1" from_server_password = "password1" # Destination server parameters to_server_ip = "hostname2" to_server_user = "username2" to_server_password = "password2"
__author__ = 'Amine Kerkeni' from_server_ip = 'hostname1' from_server_user = 'username1' from_server_password = 'password1' to_server_ip = 'hostname2' to_server_user = 'username2' to_server_password = 'password2'
class Solution: def minSubArrayLen(self, s, nums): """ :type s: int :type nums: List[int] :rtype: int """ # n positive integer lo = acc = 0 ans = math.inf for hi, num in enumerate(nums): acc += num if acc >= s: ...
class Solution: def min_sub_array_len(self, s, nums): """ :type s: int :type nums: List[int] :rtype: int """ lo = acc = 0 ans = math.inf for (hi, num) in enumerate(nums): acc += num if acc >= s: while lo < hi an...
class events: def __init__(self, logging, cfg, db): self.__logging = logging self.__cfg = cfg self.__db = db async def on_ready(self): self.__logging.info('Rankie successfully started!') print('Rankie Successfully Started!') async def on_command_error(self, ctx, err...
class Events: def __init__(self, logging, cfg, db): self.__logging = logging self.__cfg = cfg self.__db = db async def on_ready(self): self.__logging.info('Rankie successfully started!') print('Rankie Successfully Started!') async def on_command_error(self, ctx, er...
''' Implement-Queue-Using-Stack Problem Statement : Implement a Queue using 2 stacks s1 and s2 . A Query Q is of 2 Types (i) 1 x (a query of this type means pushing 'x' into the queue) (ii) 2 (a query of this type means to pop element ...
""" Implement-Queue-Using-Stack Problem Statement : Implement a Queue using 2 stacks s1 and s2 . A Query Q is of 2 Types (i) 1 x (a query of this type means pushing 'x' into the queue) (ii) 2 (a query of this type means to pop element ...
# TODO: use gmpy.mpq when available? class mpq(tuple): """ Rational number type, only intended for internal use. """ """ def _mpmath_(self, prec, rounding): # XXX return mp.make_mpf(from_rational(self[0], self[1], prec, rounding)) #(mpf(self[0])/self[1])._mpf_ ...
class Mpq(tuple): """ Rational number type, only intended for internal use. """ '\n def _mpmath_(self, prec, rounding):\n # XXX\n return mp.make_mpf(from_rational(self[0], self[1], prec, rounding))\n #(mpf(self[0])/self[1])._mpf_\n\n ' def __int__(self): (a, b) = ...
print('Welcome to random pizza delivery!') size = input('What size pizza do you want? S,M,L?\n:').upper() bill = 0 if size == 'S': bill = 15 elif size == 'M': bill = 20 elif size == 'L': bill = 25 print(f'Your bill is {bill}') pepperoni = input('Do you want extra Pepperoni?Y/N?\n:').upper() if pepperoni =...
print('Welcome to random pizza delivery!') size = input('What size pizza do you want? S,M,L?\n:').upper() bill = 0 if size == 'S': bill = 15 elif size == 'M': bill = 20 elif size == 'L': bill = 25 print(f'Your bill is {bill}') pepperoni = input('Do you want extra Pepperoni?Y/N?\n:').upper() if pepperoni == ...
#!/usr/bin/env python3 """ Module to transpose a matrix """ def matrix_transpose(matrix): """ function to transpose a matrix """ return [[row[i] for row in matrix] for i in range(len(matrix[0]))]
""" Module to transpose a matrix """ def matrix_transpose(matrix): """ function to transpose a matrix """ return [[row[i] for row in matrix] for i in range(len(matrix[0]))]
class Composite(object): """ Composite class as part of the Composite pattern. - External Usage Documentation: U{https://github.com/tylerlaberge/PyPattyrn#composite-pattern} - External Composite Pattern documentation: U{https://en.wikipedia.org/wiki/Composite_pattern} """ def __init__(self, int...
class Composite(object): """ Composite class as part of the Composite pattern. - External Usage Documentation: U{https://github.com/tylerlaberge/PyPattyrn#composite-pattern} - External Composite Pattern documentation: U{https://en.wikipedia.org/wiki/Composite_pattern} """ def __init__(self, in...
""" *Pondered* Metrics generated after the self-play phase of an iteration. """ f64 = float class Pondered: samples_gen_speed: f64 average_exploration_depth: f64 mcts_memory_footprint: int memory_size: int memory_num_distinct_boards: int # def glimpsed(realization, _, player): # me...
""" *Pondered* Metrics generated after the self-play phase of an iteration. """ f64 = float class Pondered: samples_gen_speed: f64 average_exploration_depth: f64 mcts_memory_footprint: int memory_size: int memory_num_distinct_boards: int '\n\n\n sampling_frequency`: average number of samp...
# !/usr/bin/env python3 ####################################################################################### # # # Program purpose: Converts all units of time into seconds. # # Program Author : Happi...
if __name__ == '__main__': days = int(input('Input days: ')) * 3600 * 24 hours = int(input('Input hours: ')) * 3600 minutes = int(input('Input minutes: ')) * 60 seconds = int(input('Input seconds: ')) time = days + hours + minutes + seconds print(f'The amount of seconds: {time}')
''' This function gets the data specified in the "Headings" for each sample within the specified cyc_range. If a cycle_step_idx argument is passed, then it only passes values for that subset of the cycle. Note: As of 1/29/20, if you pass a cycle_step_idx, you can only get the data for one cycle range, otherwise the tim...
""" This function gets the data specified in the "Headings" for each sample within the specified cyc_range. If a cycle_step_idx argument is passed, then it only passes values for that subset of the cycle. Note: As of 1/29/20, if you pass a cycle_step_idx, you can only get the data for one cycle range, otherwise the tim...
#!/usr/bin/env python # -*- coding: utf-8 -*- # Author: Arne Neumann <discoursegraphs.programming@arne.cl> """ This module contains code that is used by more than one RST-related modules. """ class RSTBaseTree(object): """Base class for converter's from from RST file formats into DGParentedTree-based trees. ...
""" This module contains code that is used by more than one RST-related modules. """ class Rstbasetree(object): """Base class for converter's from from RST file formats into DGParentedTree-based trees. """ def _repr_png_(self): """This PNG representation will be automagically used inside ...
# Copyright 2018 ZTE Corporation. 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 ...
show_limits = {'status_code': [200], 'response_body': {'type': 'object', 'properties': {'limits': {'type': 'object', 'properties': {'rate': {'type': 'array'}, 'absolute': {'type': 'object', 'properties': {'totalSnapshotsUsed': {'type': 'integer'}, 'maxTotalBackups': {'type': 'integer'}, 'maxTotalVolumeGigabytes': {'typ...
# -*- coding: utf-8 -*- """ knn """ def run_knn(): ''' run knn ''' print('\n' + '-' * 30 + '\n It\'s knn!')
""" knn """ def run_knn(): """ run knn """ print('\n' + '-' * 30 + "\n It's knn!")
def hourglassSum(arr): maxsum=-63 for i in range(4): for j in range(4): top=sum(arr[i][j:j+3]) mid=arr[i+1][j+1] bottom=sum(arr[i+2][j:j+3]) hourglass =top+mid+bottom if hourglass>maxsum: maxsum=hourglass return maxsum Test_...
def hourglass_sum(arr): maxsum = -63 for i in range(4): for j in range(4): top = sum(arr[i][j:j + 3]) mid = arr[i + 1][j + 1] bottom = sum(arr[i + 2][j:j + 3]) hourglass = top + mid + bottom if hourglass > maxsum: maxsum = hourg...
BIG_PRIME = 8078431 OFFSET = 48918939481 with open("cache_test.txt", "w+") as f: for i in range(4096): f.write("{:08x}\n".format((OFFSET + i * BIG_PRIME) & 0xFFFFFFFF))
big_prime = 8078431 offset = 48918939481 with open('cache_test.txt', 'w+') as f: for i in range(4096): f.write('{:08x}\n'.format(OFFSET + i * BIG_PRIME & 4294967295))
class BdProdutos: produtos = [(0,'Refrigerador A', 999.90, 0.751), (1,'Celular', 2911.12, 0.0000899), (2,'TV 55', 4346.99, 0.400), (3,'TV 50', 3999.90, 0.290), (4,'TV 42', 2999.00, 0.200), (5,'Notebook A', 2499.90, 0.00350), (6,'Ventilador', 19...
class Bdprodutos: produtos = [(0, 'Refrigerador A', 999.9, 0.751), (1, 'Celular', 2911.12, 8.99e-05), (2, 'TV 55', 4346.99, 0.4), (3, 'TV 50', 3999.9, 0.29), (4, 'TV 42', 2999.0, 0.2), (5, 'Notebook A', 2499.9, 0.0035), (6, 'Ventilador', 199.9, 0.496), (7, 'Microondas A', 308.66, 0.0424), (8, 'Microondas B', 429.9,...
__all__ = ["__title__", "__url__", "__version__"] __title__ = "squarified_treemap" __url__ = "https://github.com/alexandrseverinov/squarified_treemap.git" __version__ = "0.1.1"
__all__ = ['__title__', '__url__', '__version__'] __title__ = 'squarified_treemap' __url__ = 'https://github.com/alexandrseverinov/squarified_treemap.git' __version__ = '0.1.1'
names = { } creatures = { 'bear': { 'health': 500, 'defence': 2, 'attack': 30, }, 'deer': { 'health': 150, 'defence': 1, 'attack': 30, }, } suffixes = { '': 0 } prefixes = { 'Dire': { 'flat_health': 0, 'flat_defence': 1, 'fl...
names = {} creatures = {'bear': {'health': 500, 'defence': 2, 'attack': 30}, 'deer': {'health': 150, 'defence': 1, 'attack': 30}} suffixes = {'': 0} prefixes = {'Dire': {'flat_health': 0, 'flat_defence': 1, 'flat_attack': 0, 'scale_health': 1.5, 'scale_defence': 1, 'scale_attack': 1.2}} abilities = {} class Unit: ...
# Track Types: TRACK_TYPE_ROAD = "ROAD" TRACK_TYPE_WALKING = "WALKING" TRACK_TYPE_BIKE = "BIKE" TRACK_TYPE_HORSE = "HORSE" # Track Directions: TRACK_DIRECTION_BOTH = "BOTH" TRACK_DIRECTION_FORWARD = "FORWARD" TRACK_DIRECTION_BACKWARD = "BACKWARD" # Track Status Values: TRACK_STATUS_OPEN = "OPEN" TRA...
track_type_road = 'ROAD' track_type_walking = 'WALKING' track_type_bike = 'BIKE' track_type_horse = 'HORSE' track_direction_both = 'BOTH' track_direction_forward = 'FORWARD' track_direction_backward = 'BACKWARD' track_status_open = 'OPEN' track_status_closed = 'CLOSED' road_width = 0.0001 trail_width = 3e-05 point_size...
''' Sum all the odd numbers multiples of 3 between 1 and 500 ''' numbers_summed = 0 numbers_shown = 0 for count in range(3, 500, 6): numbers_summed += count numbers_shown += 1 print(f'The sum of all \033[34m{numbers_shown}\033[m requested numbers equals \033[32m{numbers_summed}\033[m')
""" Sum all the odd numbers multiples of 3 between 1 and 500 """ numbers_summed = 0 numbers_shown = 0 for count in range(3, 500, 6): numbers_summed += count numbers_shown += 1 print(f'The sum of all \x1b[34m{numbers_shown}\x1b[m requested numbers equals \x1b[32m{numbers_summed}\x1b[m')
class StopApplication: def __init__(self, exception=None): self.exception = exception class ExceptionOccured: def __init__(self, exception): self.exception = exception class KeyStroke: def __init__(self, key): self.key = key class ButtonEvent: def __init__(self, identifier)...
class Stopapplication: def __init__(self, exception=None): self.exception = exception class Exceptionoccured: def __init__(self, exception): self.exception = exception class Keystroke: def __init__(self, key): self.key = key class Buttonevent: def __init__(self, identifier...
#!/usr/bin/env python3 seen = set() changes = [] with open("input.txt") as f: for line in f: changes.append(int(line.strip())) total = 0 ind = 0 num_changes = len(changes) while True: total += changes[ind] if total not in seen: seen.add(total) else: print(total) exit() ...
seen = set() changes = [] with open('input.txt') as f: for line in f: changes.append(int(line.strip())) total = 0 ind = 0 num_changes = len(changes) while True: total += changes[ind] if total not in seen: seen.add(total) else: print(total) exit() ind += 1 ind %= n...
def split(combined_keys, global_command_key): """ Given a list of combined_keys (i.e. keys potentially contains second stroke) return a split version of keys with each key represent a single key stroke """ if global_command_key is None: return combined_keys keys = [] command_key_len...
def split(combined_keys, global_command_key): """ Given a list of combined_keys (i.e. keys potentially contains second stroke) return a split version of keys with each key represent a single key stroke """ if global_command_key is None: return combined_keys keys = [] command_key_leng...
n = int(input()) xs = [int(x) for x in input().split()] m = int(input()) ys = [int(x) for x in input().split()] N = max(max(xs), max(ys)) factors = [[1] for i in range(N+1)] # factors[1].append(1) for m in range(2,N+1): for i in range(m, N+1, m): factors[i].append(m) # print(factors) highest_ratio = 1 c...
n = int(input()) xs = [int(x) for x in input().split()] m = int(input()) ys = [int(x) for x in input().split()] n = max(max(xs), max(ys)) factors = [[1] for i in range(N + 1)] for m in range(2, N + 1): for i in range(m, N + 1, m): factors[i].append(m) highest_ratio = 1 count = 0 divisors = set(xs) for b in ...
CLIENT_SIDE_DIRECTORY_PATH = "../client-side/" PORT_NUMBER = 8811 # Whether to show only 'busy' on each event. Can be "true" or "false". PRIVACY = "true" # Whether to show weather color swatches at all. Can be "true" or "false". SHOW_WEATHER = "false" # Whether to show *text* at the top of each day saying the weather...
client_side_directory_path = '../client-side/' port_number = 8811 privacy = 'true' show_weather = 'false' show_weather_text = 'true' max_results_per_calendar = 200 cal_name_to_id = {'Away': 'e2r5nqkil48kbshsql3ke1c61c@group.calendar.google.com', 'Events': 'mf1urita2cmb4omf980ibv7bp4@group.calendar.google.com', 'Home': ...
a, b = input().split() a = bool(int(a)) b = bool(int(b)) print(not a and not b)
(a, b) = input().split() a = bool(int(a)) b = bool(int(b)) print(not a and (not b))
class array_cache(object): """ Arguments: cache_strs (list-like): List like object with __len__ and __getitem__ cache_block_size (int): number of strings to cache in one cache block. Default: 64 cache_size (int): number of caches blocks to store before removing (LRU). Default: 32 Att...
class Array_Cache(object): """ Arguments: cache_strs (list-like): List like object with __len__ and __getitem__ cache_block_size (int): number of strings to cache in one cache block. Default: 64 cache_size (int): number of caches blocks to store before removing (LRU). Default: 32 Att...
a = input("Enter the character:") if (ord(a)>64 and ord(a) < 91) or( ord(a) > 96 and ord(a) < 123): print(a,"is an alphabet") else: print(a,"is not an alphabet")
a = input('Enter the character:') if ord(a) > 64 and ord(a) < 91 or (ord(a) > 96 and ord(a) < 123): print(a, 'is an alphabet') else: print(a, 'is not an alphabet')
class Alignment: """ Constants for text alignment. """ LEFT = 0 RIGHT = 1 CENTER = 2
class Alignment: """ Constants for text alignment. """ left = 0 right = 1 center = 2
class ScreenLogger(object): """ Minimal wrapper class around the built-in print function replicating some functionality of the mpunet Logger class so that this class can be used in a similar fashion while only printing to screen and not a log file """ def __init__(self, print_to_screen=True): ...
class Screenlogger(object): """ Minimal wrapper class around the built-in print function replicating some functionality of the mpunet Logger class so that this class can be used in a similar fashion while only printing to screen and not a log file """ def __init__(self, print_to_screen=True): ...
''' Making a box plot for the petal lengths is unnecessary because the iris data set is not too large and the bee swarm plot works fine. However, it is always good to get some practice. Make a box plot of the iris petal lengths. You have a pandas DataFrame, df, which contains the petal length data, in your namespace. I...
""" Making a box plot for the petal lengths is unnecessary because the iris data set is not too large and the bee swarm plot works fine. However, it is always good to get some practice. Make a box plot of the iris petal lengths. You have a pandas DataFrame, df, which contains the petal length data, in your namespace. I...
#!/usr/bin/env python # -*- coding: utf-8 -*- """solution to the csv parsing problem, handling quotes and numric values""" def convert_to_number(value): """converts the passed over string to a number, if possible""" try: return int(value) except ValueError: pass return value def csv_...
"""solution to the csv parsing problem, handling quotes and numric values""" def convert_to_number(value): """converts the passed over string to a number, if possible""" try: return int(value) except ValueError: pass return value def csv_parsing(csv): """returns list of string/nume...
def cadastrar(): email = input("E-mail: ") name = input("Nome:") password = input("Senha: ") #adiciona user no arquivo de login f = open("logins.txt","r") content = f.readlines() content.append(email + ',' + name + ',' + password + '\n') f.close() f = open("logins.txt","w") f.wri...
def cadastrar(): email = input('E-mail: ') name = input('Nome:') password = input('Senha: ') f = open('logins.txt', 'r') content = f.readlines() content.append(email + ',' + name + ',' + password + '\n') f.close() f = open('logins.txt', 'w') f.writelines(content) f.close() li...
""" Condicional de notas escolares """ def notas(): notadef = input("Ingrese su nota definitiva (Rango de 00 a 50): ") try: notadef = int(notadef) except ValueError: print ("No ingreso un valor valido!! solo se admiten numeros") notas() if notadef > 50 or notadef < 00 : ...
""" Condicional de notas escolares """ def notas(): notadef = input('Ingrese su nota definitiva (Rango de 00 a 50): ') try: notadef = int(notadef) except ValueError: print('No ingreso un valor valido!! solo se admiten numeros') notas() if notadef > 50 or notadef < 0: pri...
# Question: https://projecteuler.net/problem=37 primes = set() with open('../inputs/primes_1e6.txt', 'r') as f: for p in f: primes.add(int(p.strip())) def check(n): ns = str(n) # left for i in range(1, len(ns)): if not int(ns[i:]) in primes: return False # right fo...
primes = set() with open('../inputs/primes_1e6.txt', 'r') as f: for p in f: primes.add(int(p.strip())) def check(n): ns = str(n) for i in range(1, len(ns)): if not int(ns[i:]) in primes: return False for i in range(1, len(ns)): if not int(ns[:i]) in primes: ...
def waxs_S_edge_cherun(t=1): dets = [pil300KW, pil1M] # yield from bps.mv(stage.th, 0) # yield from bps.mv(stage.y, 6) # names = ['bar1_sa01_2','bar1_sa02_2','bar1_sa03_2','bar1_sa04_2','bar1_sa05_2','bar1_sa06_2','bar1_sa07_2','bar1_sa08_2' # ,'bar1_sa09_2','bar1_sa10_2','bar1_sa11_2'...
def waxs_s_edge_cherun(t=1): dets = [pil300KW, pil1M] names = ['bar3_sa07_2'] x = [4000] y = [-5000] energies = np.arange(2450, 2476, 5).tolist() + np.arange(2476, 2486, 1).tolist() + np.arange(2486, 2496, 3).tolist() + np.arange(2496, 2511, 5).tolist() waxs_arc = np.linspace(0, 32.5, 6) for...
class RemoteJobRunnerError(Exception): """ Errors related to running the job on the remote system. """ class RemoteJobTransfererError(Exception): """ Errors related to transferring file to and from the remote system. """ class RemoteJobBatchError(Exception): """ Errors related to r...
class Remotejobrunnererror(Exception): """ Errors related to running the job on the remote system. """ class Remotejobtransferererror(Exception): """ Errors related to transferring file to and from the remote system. """ class Remotejobbatcherror(Exception): """ Errors related to run...
# direction bytes fwd = b'\xA0' rev = b'\x0A' rotl = b'\x00' rotr = b'\xAA' strl = b'\x22' strr = b'\x88' # Our neural network is trained on 300 x 300 images CAMERA_RESOLUTION = (300, 300) CAMERA_FRAMERATE = 10 #Assuming that the picture is 300x300 CENTER_LINEx1y1 = (150, 0) CENTER_LINEx2y2 = (150, 300) # Focal leng...
fwd = b'\xa0' rev = b'\n' rotl = b'\x00' rotr = b'\xaa' strl = b'"' strr = b'\x88' camera_resolution = (300, 300) camera_framerate = 10 center_lin_ex1y1 = (150, 0) center_lin_ex2y2 = (150, 300) focal_length = 3.04 pixel_per_mm = 102.3 error_val = 3.3 mothership_side_error = 7 obstacle_height = 35 target_height = 15 mot...
# 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 insertIntoMaxTree(self, root, val): """ :type root: TreeNode :type val: int :rtype: T...
class Solution(object): def insert_into_max_tree(self, root, val): """ :type root: TreeNode :type val: int :rtype: TreeNode """ self.new_node = tree_node(val) if val > root.val: self.new_node.left = root return self.new_node if...
AUTHOR="Zawadi Done" DESCRIPTION="This module wil install/update findsploit" INSTALL_TYPE="GIT" REPOSITORY_LOCATION="https://github.com/1N3/Findsploit" INSTALL_LOCATION="findsploit" DEBIAN="exploitdb" AFTER_COMMANDS="ln -s /usr/local/bin/searchsploit /usr/bin/searchsploit, cd {INSTALL_LOCATION}, ./findsploit ...
author = 'Zawadi Done' description = 'This module wil install/update findsploit' install_type = 'GIT' repository_location = 'https://github.com/1N3/Findsploit' install_location = 'findsploit' debian = 'exploitdb' after_commands = 'ln -s /usr/local/bin/searchsploit /usr/bin/searchsploit, cd {INSTALL_LOCATION}, ./findspl...
def largest_contiguous_sum(arr): current_sum = 0 maximum = -1000000 for num in arr: current_sum += num if current_sum > maximum: maximum = current_sum if current_sum < 0: current_sum = 0 return maximum # Tests print(largest_contiguous_sum([5, -9...
def largest_contiguous_sum(arr): current_sum = 0 maximum = -1000000 for num in arr: current_sum += num if current_sum > maximum: maximum = current_sum if current_sum < 0: current_sum = 0 return maximum print(largest_contiguous_sum([5, -9, 6, -2, 3])) print...
class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ self.nums, self.length = nums, len(nums) return [[]] + self.subsetHelper(0) def subsetHelper(self, start): result = [] for i in range(start, se...
class Solution(object): def subsets(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ (self.nums, self.length) = (nums, len(nums)) return [[]] + self.subsetHelper(0) def subset_helper(self, start): result = [] for i in range(star...
'''7.1 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case. Use the file words.txt to produce the output below. You can download the sample data at http://www.py4e.com/code3/words.txt''' name=input('Enter the name of the file y...
"""7.1 Write a program that prompts for a file name, then opens that file and reads through the file, and print the contents of the file in upper case. Use the file words.txt to produce the output below. You can download the sample data at http://www.py4e.com/code3/words.txt""" name = input('Enter the name of the file ...
def CountValidTriangles(lines: list[str]) -> int: result = 0 for line in lines: values = sorted(list(map(int, line.strip().split()))) if values[0] + values[1] > values[2]: result += 1 return result def CountValidTriangles2(lines: list[str]) -> int: result = 0 i = 0 ...
def count_valid_triangles(lines: list[str]) -> int: result = 0 for line in lines: values = sorted(list(map(int, line.strip().split()))) if values[0] + values[1] > values[2]: result += 1 return result def count_valid_triangles2(lines: list[str]) -> int: result = 0 i = 0 ...
a = int(input("Enter: ")) temp1 = a temp2 = a-1 for i in range(1,a+1): print(" "*temp1+"*"*(2*i)+" "*(2*temp2)+"*"*(2*i)) temp1-=1 temp2-=1 temp3 = a*2 temp4 = temp3 for i in range(1,temp3+1): print(" "*i +"*"*(2*temp4)) temp4-=1
a = int(input('Enter: ')) temp1 = a temp2 = a - 1 for i in range(1, a + 1): print(' ' * temp1 + '*' * (2 * i) + ' ' * (2 * temp2) + '*' * (2 * i)) temp1 -= 1 temp2 -= 1 temp3 = a * 2 temp4 = temp3 for i in range(1, temp3 + 1): print(' ' * i + '*' * (2 * temp4)) temp4 -= 1
def factorial(n): p = 1 for i in range(1,n+1): p *= i return p def get_permutatuions(a,b,c,d): if (a+b)>(c+d): return 0 if (a+b)==0: return 1 return int(factorial(c+d)/(factorial(c+d-a-b)*factorial(c)*factorial(d))) def is_valid(n,m): for i in range(10): if ...
def factorial(n): p = 1 for i in range(1, n + 1): p *= i return p def get_permutatuions(a, b, c, d): if a + b > c + d: return 0 if a + b == 0: return 1 return int(factorial(c + d) / (factorial(c + d - a - b) * factorial(c) * factorial(d))) def is_valid(n, m): for i ...
class Employee: # class name raise_amount = 1.05 # class variable def __init__(self, first_name, last_name, email, salary): """Constructor ,automatically initialized at obj creation time These are the setting of instance variables, each instance would have seperate copies. A...
class Employee: raise_amount = 1.05 def __init__(self, first_name, last_name, email, salary): """Constructor ,automatically initialized at obj creation time These are the setting of instance variables, each instance would have seperate copies. Arguments: first_name ...
# Time complexity: O(n*n) # Approach: Define slope by tuple of numerator and denomenator and then store count by slope in dictionary. class Solution: def count_lines(self, i): lines, h_lines, ct, dups = {}, 1, 1, 0 def get_slope(x1, x2, y1, y2): dx, dy = x1-x2, y1-y2 ...
class Solution: def count_lines(self, i): (lines, h_lines, ct, dups) = ({}, 1, 1, 0) def get_slope(x1, x2, y1, y2): (dx, dy) = (x1 - x2, y1 - y2) if dx == 0: return (0, 0) elif dy == 0: return (sys.maxsize, sys.maxsize) ...
"""Advent of Code 2018 Day 18.""" OPEN = '.' TREES = '|' LUMBERYARD = '#' ADJACENT = ( (-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1), ) def main(file_input='input.txt'): grid = [[*line.strip()] for line in get_file_contents(file_input)] runs = ( ...
"""Advent of Code 2018 Day 18.""" open = '.' trees = '|' lumberyard = '#' adjacent = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)) def main(file_input='input.txt'): grid = [[*line.strip()] for line in get_file_contents(file_input)] runs = (('10', 10), ('1 billion', 1000000000)) for...
""" Item 11: Know How to Slice Sequences """ a = [i for i in 'abcdefgh'] # Typical examples # The form is a[start: end] with start being inclusive and end exclusive. # Positive and negative integer indices are allowed. print(f'a[:] is {a[:]}') # print(f'a[:5] is {a[:5]}') # print(f'a[:-1] is {a[:-1]...
""" Item 11: Know How to Slice Sequences """ a = [i for i in 'abcdefgh'] print(f'a[:] is {a[:]}') print(f'a[:5] is {a[:5]}') print(f'a[:-1] is {a[:-1]}') print(f'a[4:] is {a[4:]}') print(f'a[-3:] is {a[-3:]}') print(f'a[2:5] is {a[2:5]}') print(f'a[2:-1] is {a[2:-1]}') print(f'a[-3:-1] is {a[-3:-1]}') print('Before '...
""" MIT License Copyright (c) 2022 Texas Tech University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, pu...
""" MIT License Copyright (c) 2022 Texas Tech University Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, pu...
# new class Figure class Figure: def __init__(self, name, angles): if self.__class__ == Figure: raise Exception("abstract method") self.name = name self.angles = angles def get_name(self): return self.name def get_angles(self): return self.angles de...
class Figure: def __init__(self, name, angles): if self.__class__ == Figure: raise exception('abstract method') self.name = name self.angles = angles def get_name(self): return self.name def get_angles(self): return self.angles def area(self): ...
class EggD800HID(object): '''ABC for EGG-D800 HID elements.''' def __init__(self): self.report_num = None self.packed_fmt = None @property def output_report(self): pass def get_input_report(self): '''Get an input report from the HID handle.''' return...
class Eggd800Hid(object): """ABC for EGG-D800 HID elements.""" def __init__(self): self.report_num = None self.packed_fmt = None @property def output_report(self): pass def get_input_report(self): """Get an input report from the HID handle.""" return self.h...
""" Copyright (C) 2018 University of Massachusetts Amherst. This file is part of "coref_tools" http://github.com/nmonath/coref_tools 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....
""" Copyright (C) 2018 University of Massachusetts Amherst. This file is part of "coref_tools" http://github.com/nmonath/coref_tools 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....
num = 1 num =1111 num =3333333333334 num = 4 num4 =12312312 num3 =123123
num = 1 num = 1111 num = 3333333333334 num = 4 num4 = 12312312 num3 = 123123
if True: print("Holberton") else: print("School")
if True: print('Holberton') else: print('School')
def valid_passports_01(lines): num_valid = 0 current_line = '' for line in lines: if line == '\n': count = current_line.count(' ') num_valid += 1 if count == 8 or (count == 7 and 'cid:' not in current_line) else 0 current_line = '' else: cu...
def valid_passports_01(lines): num_valid = 0 current_line = '' for line in lines: if line == '\n': count = current_line.count(' ') num_valid += 1 if count == 8 or (count == 7 and 'cid:' not in current_line) else 0 current_line = '' else: curren...
def flip_hand_side(target_side, hand_side): # Flip if needed if target_side == "right" and hand_side == "left": flip = True hand_side = "right" elif target_side == "left" and hand_side == "right": flip = True hand_side = "left" else: flip = False return hand_s...
def flip_hand_side(target_side, hand_side): if target_side == 'right' and hand_side == 'left': flip = True hand_side = 'right' elif target_side == 'left' and hand_side == 'right': flip = True hand_side = 'left' else: flip = False return (hand_side, flip)
class Solution: def sortedSquares(self, nums: List[int]) -> List[int]: if not nums or len(nums) == 0: return [] result = collections.deque() index = len(nums) - 1 left, right = 0, len(nums) - 1 while index > -1: i, j = nums[left], num...
class Solution: def sorted_squares(self, nums: List[int]) -> List[int]: if not nums or len(nums) == 0: return [] result = collections.deque() index = len(nums) - 1 (left, right) = (0, len(nums) - 1) while index > -1: (i, j) = (nums[left], nums[right])...
# Flask settings FLASK_SERVER_NAME = 'api.craft.htb' FLASK_DEBUG = False # Do not use debug mode in production # Flask-Restplus settings RESTPLUS_SWAGGER_UI_DOC_EXPANSION = 'list' RESTPLUS_VALIDATE = True RESTPLUS_MASK_SWAGGER = False RESTPLUS_ERROR_404_HELP = False CRAFT_API_SECRET = 'hz66OCkDtv8G6D' # database MYS...
flask_server_name = 'api.craft.htb' flask_debug = False restplus_swagger_ui_doc_expansion = 'list' restplus_validate = True restplus_mask_swagger = False restplus_error_404_help = False craft_api_secret = 'hz66OCkDtv8G6D' mysql_database_user = 'craft' mysql_database_password = 'qLGockJ6G2J75O' mysql_database_db = 'craf...
""" Write a python program to accept the user's first and last name and then getting them printed in the reverse order with a space between first name and lst name. """ first_name = input("First name: ") last_name = input("Last name: ") full_name = first_name + " " + last_name print(full_name) rev_name = fu...
""" Write a python program to accept the user's first and last name and then getting them printed in the reverse order with a space between first name and lst name. """ first_name = input('First name: ') last_name = input('Last name: ') full_name = first_name + ' ' + last_name print(full_name) rev_name = full_name[::...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"length": "ch01_problem01.ipynb", "DataManager": "ch01_problem01.ipynb", "attach_std": "ch01_problem01.ipynb", "plot_scatter": "ch01_problem01.ipynb", "plot_predictions_act...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'length': 'ch01_problem01.ipynb', 'DataManager': 'ch01_problem01.ipynb', 'attach_std': 'ch01_problem01.ipynb', 'plot_scatter': 'ch01_problem01.ipynb', 'plot_predictions_actual': 'ch01_problem01.ipynb', 'plot_predictions_residuals': 'ch01_problem01.i...
# -*- coding:utf-8 -*- # Author: hankcs # Date: 2019-12-28 18:44 CTB_HOME = 'https://github.com/SUDA-LA/CIP/archive/master.zip#' CTB5_DEP_HOME = CTB_HOME + 'BPNN/data/ctb5/' CTB5_DEP_TRAIN = CTB5_DEP_HOME + 'train.conll' CTB5_DEP_VALID = CTB5_DEP_HOME + 'dev.conll' CTB5_DEP_TEST = CTB5_DEP_HOME + 'test.conll' CTB7_...
ctb_home = 'https://github.com/SUDA-LA/CIP/archive/master.zip#' ctb5_dep_home = CTB_HOME + 'BPNN/data/ctb5/' ctb5_dep_train = CTB5_DEP_HOME + 'train.conll' ctb5_dep_valid = CTB5_DEP_HOME + 'dev.conll' ctb5_dep_test = CTB5_DEP_HOME + 'test.conll' ctb7_home = CTB_HOME + 'BPNN/data/ctb7/' ctb7_dep_train = CTB7_HOME + 'tra...
# Copyright (c) 2012 Oscar Campos <oscar.campos@member.fsf.org> # See LICENSE for more details """ .. module:: output :platform: Unix, Windows :synopsys: Output facilities, inspired on Gentoo portage This code is taken straight from https://github.com/PyMamba/mamba-framework .. moduleauthor:: Oscar Cam...
""" .. module:: output :platform: Unix, Windows :synopsys: Output facilities, inspired on Gentoo portage This code is taken straight from https://github.com/PyMamba/mamba-framework .. moduleauthor:: Oscar Campos <oscar.campos@member.fsf.org> """ havecolor = 1 esc_seq = '\x1b[' codes = {'normal': '{}0m'....
# coding: utf-8 class Action(object): ''' A class that generates actions to be used in button templates, etc. See the official documentation for more information. URL: https://developers.worksmobile.com/document/1005050 ''' def postback_action(self, label, data, display_text): p...
class Action(object): """ A class that generates actions to be used in button templates, etc. See the official documentation for more information. URL: https://developers.worksmobile.com/document/1005050 """ def postback_action(self, label, data, display_text): postback_action = {'type': '...
def versionOpinion(version): opinion = "Undefined version" color = "black" if version=="TLSv1.2": opinion = "Good.\n TLSv1.2 is the latest version of the TLS protocol" color = "green" elif version=="SSLv3": opinion = "Bad.\n SSLv3 is deprecated and has been comprehensivley bro...
def version_opinion(version): opinion = 'Undefined version' color = 'black' if version == 'TLSv1.2': opinion = 'Good.\n TLSv1.2 is the latest version of the TLS protocol' color = 'green' elif version == 'SSLv3': opinion = 'Bad.\n SSLv3 is deprecated and has been comprehensivley b...
#!/usr/bin/python3 """ provides the low level driver for pwm dutycycle and frequency control of a dc motor using an h_bridge hooked up to a Raspberry Pi using pigpio """ class dc_h_bridge(): """ A class that provides the low level interface to drive a dc motor through an h-bridge with direct control via gp...
""" provides the low level driver for pwm dutycycle and frequency control of a dc motor using an h_bridge hooked up to a Raspberry Pi using pigpio """ class Dc_H_Bridge: """ A class that provides the low level interface to drive a dc motor through an h-bridge with direct control via gpio pins using the pig...
""" Bond order information. """ CCDC_BOND_ORDERS = { # http://cima.chem.usyd.edu.au:8080/cif/skunkworks/html/ddl1/mif/bond.html 'S': 1.0, # single (two-electron) bond or sigma bond to metal 'D': 2.0, # double (four-electron) bond 'T': 3.0, # triple (six-electron) bond 'Q': 4.0, # quadruple (eigh...
""" Bond order information. """ ccdc_bond_orders = {'S': 1.0, 'D': 2.0, 'T': 3.0, 'Q': 4.0, 'A': 1.5, 'C': 1.0, 'E': 1.5, 'P': 1.0, 'Am': 1.41, 1.0: 'S', 2.0: 'D', 3.0: 'T', 4.0: 'Q', 1.5: 'A', 1.41: 'Am'}