content
stringlengths
7
1.05M
class A: def __init__(self,a): self.a = a a=A(1) b=A(2) c=A(3) abc = [a,b,c] for i in abc[1:]: if i.a>2: i.a=0 abc.remove(i) for i in abc: print(i.a)
# -*- coding: utf-8 -*- class TracimError(Exception): pass class RunTimeError(TracimError): pass class ContentRevisionUpdateError(RuntimeError): pass class ContentRevisionDeleteError(ContentRevisionUpdateError): pass class ConfigurationError(TracimError): pass class AlreadyExistError(Tra...
""" link: https://leetcode.com/problems/find-the-difference problem: s, t 字符串差一个字符,求该字符 solution: 丢进map里统计 solution-fix: 用异或互消 """ class Solution: def findTheDifference(self, s: str, t: str) -> str: m = {} for k in t: m[k] = m[k] + 1 if k in m else 1 for k in s: ...
class Solution: """ @param x: the base number @param n: the power number @return: the result """ def myPow(self, x, n): negative = False if n < 0: negative = True n = -n ans = 1 while n > 0: times = 1 multiply = x ...
""" Taller 2.1 Salida Estandar:Pantalla # Tu nombre aquí Mayo xx-XX """ #====================================================================== # E S P A C I O D E T R A B A J O A L U M N O # ===================================================================== def presentar_datos_personales...
# Video - https://youtu.be/PmW8NfctNpk def sum_of_digits(n): n = abs(n) digits = [] char_digits = list(str(n)) for char_digit in char_digits: digits.append(int(char_digit)) return sum(digits) tests = [ (1325132435356, 43), (123, 6), (6, 6), (-10, 1) ] for n, expected in...
#!/usr/bin/env python3 class Armor: ARMOR = { "Festival T-Shirt":{"defense":2, "value":6, "itemClass":"newb", "desc":"+02 Defense"}, "Offshore Overalls":{"defense":5, "value":10, "itemClass":"hunter", "desc":"+05 Defense - Hunter Classes Only"}, "Cotton Affliction Shirt":{"defense":...
class Get: def __init__(self,db): self.db = db def _get(self,key): try: return JsonObject(self.db, key, self.db[key]) except Exception as e: raise ValueError(f"No Key named {key} found.") def __call__(self,key): return self._get(key) class JsonObject(type({})): def __init__(self, db, key=N...
# -*- coding: utf-8 -*- # 数据库配置信息 CONFIG = { # 数据库默认配置信息,必选,且索引必须为0 0 : { "host": '127.0.0.1', # 可选,默认127.0.0.1 "user": 'root', # 可选,默认root 'password': 'root123', # 必选 'database': 'poitype_service', # 必选 'port': '3306', # 可选,默认3306 'dbms': 'mysql', # 可选,默认m...
# 创建变量 age = 26 # 条件判断 if age < 2: print("He is a baby.") elif 2 <= age < 4: print("\nHe is learning to walk.") elif 4 <= age < 13: print("\nHe is a child.") elif 13 <= age < 20: print("\nHe is a teenager.") elif 20 <= age < 65: print("\nHe is an adult.") else: print("\nHe is old.")
#Ensure there is an exceptional edge from the following case def f2(): b, d = Base, Derived try: class MyNewClass(b, d): pass except: e2 def f3(): sequence_of_four = a_global try: a, b, c = sequence_of_four except: e3 #Always treat locals as no...
for _ in range(int(input())): l,r,m=map(int,input().split()) ma=r-l for i in range(l,r+1): temp=m%i if temp<=ma and i<=m: print(i,l+temp,l) break elif i-temp<=ma: print(i,l,l+i-temp) break
text = open("text.txt","r+") #打开文件(读写) cont = text.readline() s1 = cont.replace(".","") #去掉. s2 = s1.replace(",","") #去掉, list1 = s2.split(" ") #string分成list for i in range(len(list1)): a = 0 for j in range(i-1): if list1[i] == list1[j] : a = 1 break if a :...
MOVING = "moving" SLEEPING = "sleeping" jobs: dict[str, str] = { "mine_foo": "Mining Foo", "mine_bar": "Mining Bar", "build_foobar": "Trying to build a Foobar", "sell_foobar": "Selling Foobar", "buy_robot": "Buying a robot", MOVING: "Moving", SLEEPING: "Sleeping", }
# 实现一个二分查找 # 输入:一个顺序list # 输出: 待查找的元素的位置 def binarySearch(alist, item): first = 0 last = len(alist) - 1 while first <= last: mid = (first + last)//2 print(mid) if alist[mid] > item: last = mid - 1 elif alist[mid] < item: first = mid + 1 else: ...
class defaultdict(dict): """Poor man's implementation of defaultdict for Python 2.4 """ def __init__(self, default_factory=None, **kwargs): self.default_factory = default_factory super(defaultdict, self).__init__(**kwargs) def __getitem__(self, key): if self.default_factory is...
#!/usr/bin/python3 hostname = input("What value should we set for hostname?") #hostname = "MTG" hostname = hostname.upper() if hostname == "MTG": print("The hostname was found to be mtg")
class EVBaseException(Exception): def __init__(self, msg): super(EVBaseException, self).__init__(msg) self._msg = msg # Exception.__init__(self, msg) def __str__(self): return self._msg class EVConnectionError(EVBaseException): def __init__(self, msg, exc_obj): supe...
''' Author: Yurii Bielotsytsia Version: Easy-01 Name: Ideal BMI by Brok formula ''' sex = input('Enter you sex(m if you are a man, w if you are a woman): ') height = float(input('Enter you height in cm ')) if(sex == 'm'): result=(((height*4/2.54)-128)*0.453) print('You ideal BMI is {0:.2f}'.format(resu...
# # PySNMP MIB module SW-PROJECTX-SRPRIMGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-PROJECTX-SRPRIMGMT-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:46:16 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
material_iron = 'iron' material_titanium = 'titanium' material_naonite = 'naonite' material_trinium = 'trinium' material_xanion = 'xanion' material_ogonite = 'ogonite' material_avorion = 'avorion' block_armor = 'armor' block_engine = 'engine' block_cargo = 'cargo' block_quarters = 'quarters' block_thruster = 'thruster...
# ----------------------------------------------------------------------- print('\033[32;1mDESAFIO 050 - Soma dos Pares\033[m') print('\033[32;1mALUNO:\033[m \033[36;1mJoaquim Fernandes\033[m') print('-' * 50) # ----------------------------------------------------------------------- def SomaPar(): soma= cont = 0 ...
input = """ % run with option --depgraph % the component of a must be cyclic b(1). a(X, Y) :- a(X, X), b(Y). """ output = """ DEPGRAPH: (2 atoms, 2 components) cyclic hcf stratified not_tight 0 --> 1 1 --> 1 COMPONENT 0: cyclic hcf stratified { 1 } COMPONENT 1: acyclic hcf stratified { 0 } Predicate names ...
def heapify(arr, n, i): largest = i l = 2*n +1 r = 2*n +2 if l<n and arr[largest] < arr[l]: largest = l if r<n and arr[largest] < arr[r]: largest = r if largest != i: arr[largest], arr[i] = arr[i], arr[largest] heapify(arr, n, largest) def hea...
""" sorted Return a new sorted list from the items in iterable. """ nums = [6, 1, 8, 2] sorted(nums) # [1, 2, 6, 8] print(nums) # [6, 1, 8, 2] # for dictionaries, you have to pass in how they will be sorted. users = [ {"username": "samuel", "tweets": ["I love cake", "I love pie", "hello world!"]}, {"userna...
#!/usr/bin/env python """ MIT License Copyright (c) 2017 Raphael "rGunti" Guntersweiler 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 right...
class Solution: def largestRectangleArea(self, heights: List[int]) -> int: n, heights, st, ans = len(heights), [0] + heights + [0], [], 0 for i in range(n + 2): while st and heights[st[-1]] > heights[i]: ans = max(ans, heights[st.pop(-1)] * (i - st[-1] - 1)) s...
f = open("unicode/data/utf-8_1.txt") l = f.readline() print(l) print(len(l))
class TopoHelper: def get_neighbor(self, rank, nworker): rank = rank + 1 ret = [] if rank > 1: ret.append(rank // 2 - 1) if rank * 2 - 1 < nworker: ret.append(rank * 2 - 1) if rank * 2 < nworker: ret.append(rank * 2) return ret ...
''' *********************************************************************************************************************** * Configuration file for Solar estimation tool * * Created by P.Nezval ...
kartyak = ['2383 8823 9423 1164'] for kartya in kartyak: kartyaCheck = [] for karakter in kartya: if karakter != ' ': kartyaCheck.append(karakter) print(kartyaCheck) for index, karakter in enumerate(kartyaCheck): if index%2 == 0: double = 2*int(karakter) if double >= 10: ...
# -*- coding: utf-8 -*- size = list() wordlist = list() table = list() i = a = 0 biggestword = 0 b = "-" while True: phrase = str(input("\nDigite uma frase: ")) words = phrase.split() for i in words: size.append(str(len(i))) wordlist.append(i) if len(i) >= a: a = len(i) ...
""" Given a binary tree and a sum, find all root-to-leaf paths where each path’s sum equals the given sum. For example: Given the below binary tree and sum = 22, 5 / \ 4 8 / / \ 11 13 4 / \ / \ 7 2 5 1 return [ [5,4,11,2]...
{ 'Datadog': [ 'host:dev-test', 'environment:test' ], 'Users': [ 'role:database' ] }
# random.seed(1234) # np.random.seed(1234) # torch.manual_seed(1234) # torch.cuda.manual_seed_all(1234) # torch.backends.cudnn.deterministic = True class Transition(object): def __init__( self, FromCluster, ArriveCluster, Vehicle, State, StateQTable, Action, ...
''' Part 1: Define a class named Circle which can be constructed by a radius. Compare two circles objects and return True if circles are equal. Return False if circles are not equal Take radius of these circles through Input Expected Input/Output 1: Enter Radius of Circle 1: 2 Enter Radius of circle 2: 4 Output: Fal...
while True: text = input(">>>") if (text == "python"): break print(text) print("Python is Addictive")
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"binarize_mask": "00_mask_transform.ipynb", "data_loader": "00_mask_transform.ipynb", "data_saver": "00_mask_transform.ipynb", "outpath_from_inpath": "00_mask_transform.ipynb", ...
#!/usr/bin/env python3 cfg_overridden_precisions = { # Convolution: output value inaccuracy exceeds threshold for FP16 'vgg16-IR:opid42': ['FP32'], 'vgg16-IR:opid31': ['FP32'], 'yolo-v4-tf:opid227': ['FP32'], # FusedConvolution: output value inaccuracy exceeds threshold for FP16 '3d_unet-grap...
"""4.10 Check Subtree: Tl and T2 are two very large binary trees, with Tl much bigger than T2. Create an algorith m to determine if T2 is a subtree of Tl . A tree T2 is a subtree ofTi if there exists a node n in Ti such that the subtree of n is identical to T2. That is, if you cut off the tree at node n, the two trees ...
class Solution(object): def canPartition(self, nums): """ :type nums: List[int] :rtype: bool """ if sum(nums) % 2: return False dp = set() dp.add(0) target = sum(nums) // 2 for i in range(len(nums)-1, -1, -1): nextDP =...
def count_char(text, char): count = 0 for c in text: if c == char: count += 1 return count filename = input("Enter a filename: ") with open(filename) as f: text = f.read() for char in "abcdefghijklmnopqrstuvwxyz": perc = 100 * count_char(text, char) / len(text) print("{0} - {1}%".format(char, round(perc, 2...
def pytest_addoption(parser): parser.addoption("--runexamples", action="store_true", help="run examples") parser.addoption("--runbenchmarks", action="store_true", help="run benchmarks") parser.addoption("--all", action="store_true", help="run be...
""" [2016-03-23] Challenge #259 [Intermediate] Mahjong Hands https://www.reddit.com/r/dailyprogrammer/comments/4bmdwz/20160323_challenge_259_intermediate_mahjong_hands/ # Description You are the biggest, baddest mahjong player around. Your enemies tremble at your presence on the battlefield, and you can barely walk t...
input = """ % This is also interesting for the model generator, due to the strange contraint. b :- not c. c :- not b. a :- b. :- a, not a. """ output = """ {a, b} {c} """
list1 = [6, 8, 19, 20, 23, 41, 49, 53, 56, 87] def find_max(items): if (len(items) == 1): return items[0] item1 = items[0] print(f"Item1 = {item1}") item2 = find_max(items[1:]) print(f"Item2 = {item2}") if item1 > item2: return item1 else: return item2 print(fin...
def twoSum(nums, target): """ :type nums: List[int] :type target: int :rtype: List[int] """ # Create a hash table (Python dictionary) htbl = {} for i, num in enumerate(nums): t = target - num if t in htbl.keys(): return [htbl[t], i] else: ...
class InlineIfThen (Exception): pass
lines = [] file = "output.txt" with open(file, "r") as default_branch: lines = default_branch.readlines() repos = set(lines) sort_file = file[:-4] + "_sorted" + file[-4:] with open(sort_file, "w") as default_branch: default_branch.writelines(sorted(repos))
#!/usr/bin/env python3 class Solution: def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] """ d = {} for w in sorted(strs): k = tuple(sorted(w)) d[k] = d.get(k, []) + [w] return list(d.values()) if __name_...
#!/usr/bin/env python3 # Dictionaries are data structures(blueprint for big data, definition template) # used to map key:value pairs. # As if lists were dictionaries with integer keys at range. # Dictionaries can be indexed in the same way as lists, using [] containing keys. # {key:value} can be: {"String":int} {"Stri...
class ConfusionMatrix(object): TP = TN = FP = FN = 0 def __str__(self): return "p\\t\tP\tN\nP\t{}\t{}\nN\t{}\t{}".format(self.TP, self.FP, self.FN, self.TN) def recall(self): return self.TP / float(self.TP + self.FN) def precision(self): return self.TP / floa...
# Example of what a for loop does: nums = [1, 2, 3] i_nums = iter(nums) while True: try: item = next(i_nums) print(item) except StopIteration: break
# # PySNMP MIB module CXFrameRelayInterfaceModule-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXFrameRelayInterfaceModule-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:17:14 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Pytho...
game_board = {'7': ' ', '8': ' ', '9': ' ', '4': ' ', '5': ' ', '6': ' ', '1': ' ', '2': ' ', '3': ' '} disp_board = {'1': '1', '2': '2', '3': '3', '4': '4', '5': '5', '6': '6', '7': '7', '8': '8', '9': '9'} fill_board = [] # for i in the_board: # fill_boar...
if __name__ == '__main__': print('hello.') """ The given program reads a list of single-word first names and ages (ending with -1), and outputs that list with the age incremented. The program fails and throws an exception if the second input on a line is a string rather than ...
# -*- coding: utf-8 -*- DDD = int(input()) dic = { 61: "Brasilia", 71: "Salvador", 11: "Sao Paulo", 21: "Rio de Janeiro", 32: "Juiz de Fora", 19: "Campinas", 27: "Vitoria", 31: "Belo Horizonte" } if (DDD in dic.keys()): print(dic[DDD]) else: print("DDD nao cadastrado")
class DBSCAN(object): def __init__(self, eps=0, min_points=2): self.eps = eps self.min_points = min_points self.noise = [] self.clusters = [] self.dp = [] self.near_neighbours = [] self.wp = set() self.proto_cores = set() self.points = [] ...
config_structure = { "default_user" : { "profile": { "description" : None, #string < 1000 "roster" : [], # List of champion dict "roster_ss": [], "alliance_ids": [], #list of dicts { alliance: 1234, tag: ABCDE} "alliance_tag": None, "...
class Solution: def countLetters(self, S: str) -> int: if len(S) == 1: return 1 prev_char = S[0] res = 1 flag = 1 for cur_char in S[1:]: if cur_char == prev_char: flag += 1 res += flag else: p...
i=10 for i in range(5): print(i) i = i+3 print(i) '''output 0 3 1 4 2 5 3 6 4 7 '''
"""AyudaEnPython: https://www.facebook.com/groups/ayudapython """ for i in range(10, 0, -1): print(i)
{ 'includes': [ 'common.gypi' ], 'targets': [ { 'target_name': 'webserver', 'type': 'executable', 'sources': [ 'webserver.cc', ], 'dependencies': [ './deps/libuv/uv.gyp:libuv', './deps/http-parser/http_parser.gyp:http_parser' ], }, { 'tar...
#Laboratorio 5 #ejercicio 1: def reemplazar (cadena): resultado="" contador=1 for i in range (len(cadena)): if cadena [i] in " ": resultado+=";" contador=contador + 1 else: resultado+=cadena[i] return resultado print(reemplazar("h o l a")) #ejercicio...
print('Digite um número entre 1 e 12, para ver o mês') Mes = ['1-Janeiro', '2-Fevereiro', '3-Março', '4-Abril', '5-Maio', '6-Junho', '7-Julho', '8-Agosto', '9-Setembro', '10-Outubro', '11-Novembro', '12-Dezembro'] mes = int(input('Número: ')) if 1 < mes > 12: print('Mês inválido') else: print(f'O mês é: {Mes[me...
reveal_type(len("blub")) def get_id(name: str): return len(name) reveal_type(get_id("blub")) # limitations_inference.py:1: error: Revealed type is 'builtins.int' # limitations_inference.py:7: error: Revealed type is 'Any'
MOCK_GOOD_COMMIT_1 = "\n".join([ "557fec0b69228ae803c81e38f80c3b1fb993d9cb|||<<<(((ooo+++ooo)))>>>|||Bob Dole|||<<<(((ooo+++ooo)))>>>|||bob@dole.com|||<<<(((ooo+++ooo)))>>>|||2015-05-20|||<<<(((ooo+++ooo)))>>>|||TIK-1111 - Some important change|||<<<(((ooo+++ooo)))>>>|||This change affects something really importan...
# -*- coding: utf-8 -*- __version__ = '0.0.0' __author__ = 'Mike Bland' __license__ = "CC0-1.0"
class MockLogger: @staticmethod def info(content): print(f"\nMockLogger: info - {content}") @staticmethod def debug(content): print(f"\nMockLogger: debug - {content}") def warn(self, content): self.warning(content) @staticmethod def warning(content): print(...
# simple python spark examples, as if they were typed into pyspark, not a full application # load sales sales=sc.textFile("sales_*.txt").map(lambda x:x.split('\t')) #load stores and products stores=sc.textFile("stores.txt").map(lambda x:x.split('\t')) products=sc.textFile("products.txt").map(lambda x:x.split('\t')) ...
class Student(): count=0 pycount=0 def __init__(self,USN,Name,Subject): self.USN=USN self.Name=Name self.Subject=Subject if self.Subject.lower()=="python": Student.pycount+=1 Student.count+=1 listofstud=[] n=int(input("Enter the number of students ")) for ...
# Reading input file f = open("inputs/day02.txt", "r") lines = f.readlines() def part1(): valid_passwords = 0 for line in lines: password = line.replace("\n", "").split(": ") min_occurrence = int(password[0].split(" ")[0].split("-")[0]) max_occurrence = int(password[0].split(" ")[0].spl...
__all__ = [ "category", "event_log", "org", "user", ]
# -*- coding: utf-8 -*- """ Created on Sun Nov 28 20:54:59 2021 @author: eddy9111226 """ year=int(input()) while (year!=-9999): if (year % 400 == 0 or (year % 4 == 0 and year % 100 != 0)): print("yes") else: print("no") year=int(input())
def main(): infile = open("test_master.txt","r") infileContent = infile.read(); infile.close() testsRaw = infileContent.split("==========\n") for testRaw in testsRaw: testParts = testRaw.split("----------\n") name = testParts[0].strip() inSrc = testParts[1] outSrc ...
sed50 = sed20 = sed10 = sed1 = div = 0 print('=' * 40) print('{:^40}'.format('Caixa Eletrônico')) print('=' * 40) vs = (int(input('Quanto deseja sacar? R$: '))) while True: sed50 = vs // 50 s = vs % 50 sed20 = s // 20 s = s % 20 sed10 = s // 10 s = s % 10 sed1 = s // 1 s = s % 1 if s...
n=int(input()) if n%2==0: print("I LOVE CBNU") exit(0) print("*"*n) for i in range(n//2+1): print(end=" "*(n//2-i)) if i==0: print("*") else: print("*"+" "*(i*2-1)+"*")
#!/usr/bin/env python3.7 rules = {} with open('input.txt') as fd: for line in fd: words = line[:-1].split() this_bag = words[0]+ " " + words[1] rules[this_bag] = [] b = line[:-1].split('contain') bags = b[1].split(',') for bag in bags: words = bag.split()...
# Copyright (C) 2005, Giovanni Bajo # Based on previous work under copyright (c) 2001, 2002 McMillan Enterprises, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the...
""" Dictionaries. Unordered set of key value pairs separated by a comma & enclosed by {}. Very useful for storing information in a specific format. They are mutable i.e. can be modified. Dictionary specific procedures have to be used for doing this as they are not indexed by the position of the element like lists. Th...
class Solution: def mySqrt(self, x: int) -> int: if x == 0 or x == 1: return x cur_min = x left = 0 right = x // 2 res = 0 while left <= right: mid = (left + right) // 2 cur_val = x - mid * mid if cur_val >= 0 and cur_va...
# Welcome to the sixth lesson in the Yesselman Group's Python series # Topics covered: sets, review of strings ######################################################################################################################## # Part I: sets # In programming, a container object is something that holds other types ...
#!/usr/bin/env python # encoding: utf-8 """ combination_sum.py Created by Shengwei on 2014-07-20. """ # https://oj.leetcode.com/problems/combination-sum/ # tags: medium, array, combination, sum, dp, recursion, dfs """ Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C whe...
""" Sample ``conf.py``. """ master_doc = 'index' extensions = [ 'notfound.extension', ]
n=int(input()) l=list(map(int,input().split())) count1=0 count2=0 for i in range(0,len(l)-1): if l[i]<l[i+1]: count1=count1+1 if(count1>count2): count2=count1 else: count1=0 print(count2+1)
def ilen(n, mapa): pole = [[1 for i in range(n)] for j in range(n)] for obsz in mapa: x = obsz[:2] [::-1] y = obsz[2:4] y = [y[1] - 1, y[0] - 1] poziom = obsz[4] wiersz = range(x[1], y[1] + 1) wiersze = range(x[0], y[0] + 1) for k in wiersze: ...
def gcd(A, B): while A != 0: B, A = A, B % A return B A, B = map(int, input().split()) if A >= B: GCD = gcd(B, A) else: GCD = gcd(A, B) result = A * B // GCD print(result)
#!/bin/python3 # Print string print("Strings and thigns") print("hello world lmao") print("""Hello this is a multi line string""") print("This is" + " concatination") print('\n') #new line # Maths print("math time") print(50 + 50) print(50 - 50) print(50 * 50) print(50 / 50) print(50 + 50 - 50 * 50 / 50) # PEMDAS...
class NoResponseContent(Exception): """ When the response is empty """ pass class InvalidResponseRetry(Exception): """ When the response is invalid and we want to retry """ pass class InvalidAMQPMessage(Exception): def __repr__(self): return 'The incoming AMQP message has...
description = 'Basic setup for SPHERES containing sis detector, doppler, ' \ 'sps selector and shutter' group = 'basic' includes = ['sis', 'doppler', 'cct6', 'sps', 'shutter', 'memograph', 'selector', ] startupcode = 'S...
"""Code to handle preparing equation text for image transform.""" def escape_percentage(equation): """ Escape percentage symbols in equations. Inputs: equation: string containing equation Returns string with percentage symbols escaped """ if '%' in equation: equation = equati...
"""***************************************************************************** * Copyright (C) 2019 Microchip Technology Inc. and its subsidiaries. * * Subject to your compliance with these terms, you may use Microchip software * and any derivatives exclusively with Microchip products. It is your * responsibility to ...
def test_validate(client): mimetype = "application/json" headers = { "Accept": mimetype } response = client.get(path="/validate", query_string={"numbers": "100000000" "020000000" ...
"""Module to hold sanity check functions.""" def luhn(account_string, _encoding): """Return bool if string passes Luhn test. This is based on the algorithm example found on the wikipedia article for luhn algorithm: https[:]//en[dot]wikipedia[dot]org/wiki/Luhn_algorithm :param account_string: Th...
def safe_open(*args, **kwargs): file_handle = None try: file_handle = open(*args, **kwargs) except IOError as exc: yield None, exc # return for an exception else: try: yield file_handle, None # return for success # func(file_handle, None) final...
"""Constants.""" CACHE_NAME = 'web_screen_scraper' CACHE_TIMEOUT = 3600
def process_raw_input(s): s = 'inputs/'+s with open(s) as t: return [line.strip().rstrip() for line in t.readlines()]
REACTION_SUZUKI = "[*;$(c2aaaaa2),$(c2aaaa2):1]-!@[*;$(c2aaaaa2),$(c2aaaa2):2]>>[*:1][*].[*:2][*]" SCAFFOLD_SUZUKI = 'Cc1ccc(cc1)c2cc(nn2c3ccc(cc3)S(=O)(=O)N)[*]' DECORATION_SUZUKI = '[*]c1ncncc1' TWO_DECORATIONS_SUZUKI = '[*]c1ncncc1|[*]c1ncncc1' TWO_DECORATIONS_ONE_SUZUKI = '[*]c1ncncc1|[*]C' SCAFFOLD_NO_SUZUKI = '[...
x = input('digite um palindromo: ') y = x.strip().upper() w = len(y) int(w) s = 1 v = list(x) for c in range(0, w + 1): if x[0+s] == x[w-s]: s = s + 1 if s==1: print('{} é um palindromo'.format(y)) else: print('{} não é um palindromo'.format(y))
class Solution(object): mapping = {'2':'abc', '3': 'def', '4':'ghi',\ '5':'jkl', '6':'mno', '7': 'pqrs', '8':'tuv', '9':'wxyz'} def letterCombinations(self, digits): """ :type digits: str :rtype: List[str] """ if len(digits) == 0: return lis...