content
stringlengths
7
1.05M
"""***************************************************************************** * Copyright (C) 2020 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 ...
""" 739. Daily Temperatures temperatures = [73, 74, 75, 71, 69, 72, 76, 73], your output should be [1, 1, 4, 2, 1, 1, 0, 0] """ #ascendning stack, 每次push是小的,在后面都是大的,如果stack top小于当前的 pop class Solution: def dailyTemperatures(self, temperatures): """ :type temperatures: List[int] ...
def ft_filter(function_to_apply, list_of_inputs): for elem in list_of_inputs: res = function_to_apply(elem) if res is True: yield elem
# Программа расчитывает интеграл методами парабол и правых прямоугольников, # двумя количествами делений. Находит наименее точный метод # и высчитывает количество делений, для точности eps. # a, b - отрезок # n1, n2, n - количества делений # h - шаг для делений # y - функция # I1, I2, I3, I4 - результаты методов...
STX: bytes = b"\x02" # Start of text, indicates the start of a message. ETX: bytes = b"\x03" # End of text, indicates the end of a message ENQ: bytes = b"\x05" # Enquiry about the PC interface being ready to receive a new message. ACK: bytes = b"\x06" # Positive acknowledgement to a PMS message or enquiry (ENQ). NA...
class Interval: def __init__(self, start, end): if start < end: self.start = start self.end = end else: self.start = end self.end = start def overlap(self, other): if self.start > other.start and self.start < other.end: return ...
# create a loop counter = 10 while counter > 0: print(counter) counter = counter -1 print('Blastoff!!')
"""Providers for interop between JS rules. This file has to live in the built-in so that all rules can load() the providers even if users haven't installed any of the packages/* These providers allows rules to interoperate without knowledge of each other. You can think of a provider as a message bus. A rule "publish...
# Hacer un programa que pida un caracter e indique si es una boca o no caracter = input("Digite un caracter: ").lower()# para mayusculas #caracter = caracter.lower() #caracter = caracter.upper() if caracter =="a" or caracter =="b" or caracter =="c" or caracter =="d" or caracter =="e": print("Es Una vocal") else: p...
try: num = int(input("请输入整数:")) result = 8 / num print(result) except ValueError: print("请输入正确的整数") except ZeroDivisionError: print("除 0 错误") except Exception as result: print("未知错误 %s" % result) else: # 没有异常才会执行的代码 print('没有异常才会执行的代码') pass finally: # 无论是否有异常,都会执行的代码 print("...
grocery_list = ["fish", "tomato", "apples"] # Create new list print("tomato" in grocery_list) # Check that grocery_list contains "tomato" item grocery_dict = {"fish": 1, "tomato": 6, "apples": 3} # create new dictionary print("fish" in grocery_dict)
def _impl(ctx): args = [ctx.outputs.out.path] + [f.path for f in ctx.files.chunks] args_file = ctx.actions.declare_file(ctx.label.name + ".args") ctx.actions.write( output = args_file, content = "\n".join(args), ) ctx.actions.run( mnemonic = "Concat", inputs = ctx.f...
k = int(input()) r = list(map(int, input().split())) p = set(r) # stores the sum of all unique elements x total no of groups a = sum(p)*k # stores the sum of element in the list b = sum(r) # (a - b) = (k - 1)*captains_room_no # prints the the difference of a and b divided by k-1 print((a-b)//(k-1))
""" Tema: Herencia. Curso: Curso de python, video 31. Plataforma: Youtube. Profesor: Juan diaz - Pildoras informaticas. Alumno: @edinsonrequena. """ class Vehiculo: def __init__(self, marca, modelo): self.marca = marca self.modelo = modelo self.enmarcha = False self.acelera = Fa...
def swap(arr, i, j): temp = arr[i] arr[i] = arr[j] arr[j] = temp def selectionSort(arr): for i in range(len(arr)): smallest = arr[i] for j in range(i+1, len(arr)): print(i) if smallest > arr[j]: print(f"replacing {j} th position with {i}th pos...
with open('input.txt', 'r') as reader: input = [line for line in reader.read().splitlines()] def part1(numbers): length = len(numbers[0]) sums = [0] * length for number in numbers: for i in range(length): sums[i] += int(number[i]) gamma = [1 if v > len(numbers) / 2 else 0 for v i...
class Solution(object): def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ left, right = 0, 19 while left <= right: mid = left + (right - left) / 2 if 3 ** mid == n: return True elif 3 ** mid > n: ...
"""Top-level package for QBOB.""" __author__ = """Guen Prawiroatmodjo""" __email__ = 'guenp@microsoft.com' __version__ = '0.1.0'
def sieve(n): checkArray = [1] * (n+1) checkArray[0] = 0 checkArray[1] = 0 for i in range(2,n+1): j = i + i step = j + i for j in range(j,n+1,i): checkArray[j] = 0 for i in range(0,n+1): if checkArray[i] != 0: print(i) if __name__ == "__main__": n = int(input()) sieve(n)
"""Different environment settings.""" # TODO: Add correct objects LOCATION_TYPE_MAP = { "floor": {"color": "gray", "gray_color": "gray", "mesh": ":/objects/floor.obj",}, "rack": {"color": "#62ca5f", "gray_color": "gray", "mesh": ":/objects/rack.obj",}, "wall": {"color": "black", "gray_color": "black", "mes...
#Printing 'reverse Pyramid Shape ! ''' * * * * * * * * * * * * * * * ''' n=int(input()) for i in range(n,0,-1): #for rows for j in range(0,n-i): # for space print(end=' ') for j in range(0,i): # creating star print("*",end=' ') print() #other method n=int(input()) for i in range(n,...
class StepParseError(Exception): pass class RatDisconnectedError(Exception): pass class InvalidTimeoutExceptionError(Exception): pass class RatCallbackTimeoutError(Exception): pass class MissingFileError(Exception): pass
#Classe: class carro: # Construtor: def __init__(self, Ano, Velocidade_maxima, Velocidade_atual , Nitro = 'Sem nitro', Estado = 'Desligado', Nome = 'Sem Nome'): self.Estado = Estado self.Nome = Nome self.Ano = Ano self.Velocidade_maxima = Velocidade_maxima self.Velocidade...
def max_of_maximums(dTEmax, dsRNAmax): print('Finding max of maximums') dmax = {} for i in list(dTEmax.keys()): for j in list(dsRNAmax.keys()): try: dTEmax[j] except: dmax[j] = dsRNAmax[j] else: dmax[j] = max(dTEmax[...
# -*- coding: utf-8 -*- ''' Utility for chinese ''' NUM_MAP = { "零": "0", "一": "1", "二": "2", "三": "3", "四": "4", "五": "5", "六": "6", "七": "7", "八": "8", "九": "9", "十": "10" } def chinese_num_replace(s): if not s: return s return ''.join([NUM_MAP.get(i, i) ...
# Copyright (c) Microsoft. All rights reserved. Licensed under the MIT license. # See LICENSE in the project root for license information. # Client ID and secret. client_id = '07c53e00-1adb-4fa7-8933-fd98f6a4da84' client_secret = '7CmTo1brGWMmh5RoFiTdO0n'
registry = { "centivize_service": { "grpc": 7003, }, }
''' additional_datastructures.py: File containing custom utility data structures for use in simple_rl. ''' class SimpleRLStack(object): ''' Implementation for a basic Stack data structure ''' def __init__(self, _list=None): ''' Args: _list (list) : underlying elements in the stack ...
cont = 0 while cont < 10: cont = cont + 1 nome = input('Digite o nome do paciente: ') idade = int(input('Digite a idade do paciente: ')) peso = float(input('Digite o peso do paciente: ')) altura = float(input('Digite a altura do paciente: ')) sus = int(input('Digite o número do cartão do SUS do ...
# RUN: llvmPy %s > %t1 # RUN: cat -n %t1 >&2 # RUN: cat %t1 | FileCheck %s print(1 * 2) # CHECK: 2 print(2 * 2) # CHECK-NEXT: 4 print(0 * 2) # CHECK-NEXT: 0
# 1st solution class Solution: def nthMagicalNumber(self, n: int, a: int, b: int) -> int: g = self.gcd(a, b) largest = a // g * b lst = [] numOne, numTwo = a, b while numOne <= largest and numTwo <= largest: if numOne < numTwo: lst.append(numOne) ...
class Stopper: """Base class for implementing a Tune experiment stopper. Allows users to implement experiment-level stopping via ``stop_all``. By default, this class does not stop any trials. Subclasses need to implement ``__call__`` and ``stop_all``. .. code-block:: python import time ...
def old_exponent(n, k): """ n is base, k is exponent """ answer = 1 for i in range(k): answer *= n print(answer) def newExponent(n, k): """ n is base, k is exponent """ print("newExponent({0}, {1})".format(n, k)) if k == 1: return n elif k == 0: return 1 left = int(k/2) right = k - left return new...
#default parameters #you can make default parameter(last_name= 'unknown') in last like after age #if we make all parameters defalut than ouput is unknowndef user_info(first_name='unknown', last_name= 'unknown',age = None) # None is used for numbers #'unknown' is used for string def user_info(first_name, last_name,age)...
quant = int(input('Digite a quantidade de termos que você quer ver: ')) c = 3 t1 = 0 t2 = 1 print(t1, t2 , end=' ') while c <= quant: fn = t1 + t2 print(fn, end = ' ') t1 = t2 t2 = fn c += 1
''' Calculate an optimized configuration based on overall memory, cpu, and sensible defaults. Will configure spark and yarn. The formula will be run on 5 node t2.large cluster hosted in AWS. t2.large nodes have 2 vcpus, and 8gb of memory each. 4 nodes are designed as yarn node managers. The formula will run with defa...
def total(lists): array = [] sum = 0 for i in lists: sum += i array.append(sum) return array listss = [1,2,3,5,5,4] print(total(listss))
description = 'Setup for the ma11 dom motor' devices = dict( dom = device('nicos_ess.devices.epics.motor.EpicsMotor', description = 'Sample stick rotation', motorpv = 'SQ:SANS:ma11:dom', errormsgpv = 'SQ:SANS:ma11:dom-MsgTxt', precision = 0.1, ), )
with open("input.txt", "r") as f: values = [int(e) for e in f.readlines()] windowsSum = list() index = 0 for value in values: if(index+2 < len(values)): sum = value sum += values[index+1] sum += values[index+2] windowsSum.append(sum) index...
TOKEN = "<Your Bot Token Here>" LOG_LEVEL_STDOUT = "DEBUG" # Console log level LOG_LEVEL_FILE = "INFO" # File log level
# Bus Routes # each routes[i] is a bus route that the i-th bus repeats forever # we start at bus stop S and we want to go to bus stop T # rravelling by buses only, find the least number of buses to take class Solution(object): def numBusesToDestination(self, routes, S, T): """ :type routes: List[Lis...
class Solution: """ @param matrix: the given matrix @return: True if and only if the matrix is Toeplitz """ def isToeplitzMatrix(self, matrix): # Write your code here col=len(matrix[0]) row=len(matrix) for i in range(1, row): for j in range(1, col): ...
_base_ = './retinanet_r50_fpn_1x_cityscapes.py' model = dict( backbone=dict( depth=101, init_cfg=dict(type='Pretrained', checkpoint='checkpoints/resnet101-63fe2227.pth'))) # load_from="checkpoints/retinanet_r101_fpn_mstrain_3x_coco_20210720_214650-7ee888e0.pth"
# Title : Multiply all odd number # Author : Kiran Raj R. # Date : 06:11:2020 def multiply_odd(num): """ Return sum of multiple of all odd number below user specified range """ result = 1 for i in range(1,num, 2): result*=i return result print(multiply_odd(10)) def multiply_even(num):...
class Player: def __init__(self, name, life_value, attack_value): self.name = name self.life_value = life_value self.attack_value = attack_value def attack(self, enemy_player: 'Player'): enemy_player.life_value = enemy_player.life_value - self.attack_value def is_alive(self...
""" Implémentation simple du rendu monnaie (pas de limite de nombre de pièces/billets) """ def RenduMonnaie(p,a,pieces): """ Algorithme permettant de résoudre un problèmle de rendu monnaie PARAMETRES : - p : int - prix - a : int - argent donné par le client ...
# Define physical constants P0 = 1000. # Ground pressure level. Unit: hPa SCALE_HEIGHT = 7000. # Unit: m CP = 1004. # specific heat at constant pressure for air (cp) = 1004 J/kg-K DRY_GAS_CONSTANT = 287. EARTH_RADIUS = 6.378e+6 # Unit: m EARTH_OMEGA = 7.29e-5
with open('./input.txt') as input: lines = [int(s.strip()) for s in input.readlines()] last = 999999999999 counter = 0 for (a, b, c) in zip(lines[0:-2], lines[1:-1], lines[2:]): current = a + b + c if (current > last): counter += 1 last = current print(counter) # ...
fileName = input("What's the name of the file? ../logs/") results = list(map(lambda e: e.split(" "), open( '../logs/' + fileName, 'r').readlines())) """ Interesting statistics: - Average score of all runs - Worst score - Best score - Average of worst 20% of scores - Average of best 20% of scor...
# This program saves a list of numbers to a file. def main(): # Create a list of numbers. numbers = [1, 2, 3, 4, 5, 6, 7] # Open a file for writing. outfile = open('numberlist.txt', 'w') # Write the list to the file. for item in numbers: outfile.write(str(item) + '\n') ...
x = int(input('Enter your Age: ')) print('****************') for i in range(0, 1): if x >= 18: print('You can watch content with R-rating') elif x >= 13: print('You can watch movies under parental guidance ') else: print('Cartoons permitted') print(' Thanks! ')
""" author:Wenquan Yang time:2020/6/9 1:36 content:配置文件 """ BLOCK_SIZE = 512 # 磁盘块大小Bytes BLOCK_NUM = 2560 # 磁盘块总数量 SUPER_BLOCK_NUM = 2 # 超级块占用的块数 INODE_BLOCK_NUM = 256 # 索引占用的块数 DATA_BLOCK_NUM = BLOCK_NUM - SUPER_BLOCK_NUM - INODE_BLOCK_NUM INODE_BLOCK_START_ID = SUPER_BLOCK_NUM DATA_BLOCK_START_ID = SUPER_BLO...
def internal_consistency_check(Reports_dict, reportnos=None): return_dict = {} if reportnos: search_list = reportnos else: search_list = list(Reports_dict.keys()) for reportno in search_list: rdf = pd.DataFrame() rdf = Reports_dict[reportno].copy() print('REPORT',...
N = int(input()) X = 1 K = 0 while X <= N: X *= 2 K += 1 print(max(0, K - 1))
PROCLITICS = { "ὁ", "ἡ", "οἱ", "αἱ", "ἐν", "εἰς", "ἐξ", "ἐκ", "εἰ", "ὡς", "οὐ", "οὐκ", "οὐχ", } ENCLITICS = { # personal pronouns "μου", "μοι", "με", "σου", "σοι", "σε", # indefinite pronouns "τὶς", "τὶ", "τινός", "τινί", "τινά", "τινές", "τινάς", "τινῶν", "τισίν", "τισί", ...
data_in = [3.0, 1.0, 0.0, 0.0, 1.0, 6.0, 1.0, 0.0, 1.0, 0.0, 3280.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, ...
# Parsers # Parse initial fields name to normalized form. parse_name = lambda name: str(name).replace(' ', '_').lower()
""" # IMPLEMENT POW(X, N) Implement pow(x, n), which calculates x raised to the power n (i.e. xn). Example 1: Input: x = 2.00000, n = 10 Output: 1024.00000 Example 2: Input: x = 2.10000, n = 3 Output: 9.26100 Example 3: Input: x = 2.00000, n = -2 Output: 0.25000 Explanation: 2-2 = 1/22 = 1/4 = 0.25 Constraints...
# Oct 2021 # Class for extraction.py class FoundExpression: def __init__(self, expression: str, file: str, language: str, line_no: int): self.expression = expression self.language = language self.file = file self.line_no = line_no
""" @author: magician @date: 2019/12/24 @file: rotate_array.py """ def rotate(nums, k: int) -> None: """ Do not return anything, modify nums in-place instead. """ # nums = nums[k + 1:] + nums[:k + 1] for i in range(k): nums.insert(0, nums[-1]) nums.pop() return nu...
class Solution: def minOperations(self, nums: List[int]) -> int: n = len(nums) ans = n nums = sorted(set(nums)) for i, start in enumerate(nums): end = start + n - 1 index = bisect_right(nums, end) uniqueLength = index - i ans = min(ans, n - uniqueLength) return ans
""" git-flow -- A collection of Git extensions to provide high-level repository operations for Vincent Driessen's branching model. """ # # This file is part of `gitflow`. # Copyright (c) 2010-2011 Vincent Driessen # Copyright (c) 2012 Hartmut Goebel # Distributed under a BSD-like license. For full terms see the file LI...
data = ( 'jun', # 0x00 'junj', # 0x01 'junh', # 0x02 'jud', # 0x03 'jul', # 0x04 'julg', # 0x05 'julm', # 0x06 'julb', # 0x07 'juls', # 0x08 'jult', # 0x09 'julp', # 0x0a 'julh', # 0x0b 'jum', # 0x0c 'jub', # 0x0d 'jubs', # 0x0e 'jus', # 0x0f 'juss', #...
def calculate_area(side_length=10): print(f"The area of a square with sides of length {side_length} is {side_length**2}.") length=int(input("Enter side length: ")) if length<=0: calculate_area(10) else: calculate_area(length)
def find_max(num1, num2): max_num=-1 if num2> num1: data = range(num1,num2+1) main_list = [] for x in data: b = str(x) if x < 0: b = str(x*-1) sx = list(map(int,list(b))) if len(sx)==2 and sum(sx)%3==0 and x%5==0: ...
def calc(): numOne = int(input("What is the first number of your problem?")) numTwo = int(input("What is the second number of your problem?")) numThree = input("What type of Math Problem is it, Addition, Subtraction, Multiplication, Division, Remainder, or Exponents? Type exactly.") if numThree == 'Addition': ...
class Solution: def nthUglyNumber(self, n): """ :type n: int :rtype: int """ primes, indices = [2, 3, 5], [0, 0, 0] ugly_numbers = [1] for _ in range(n): next_numbers = list(map(lambda x: x[0] * x[1], zip(primes, map(lambda x: ugly_numbers[x], indi...
"""Codewars problem to find even index.""" def find_even_index(arr): """Return the index where sum of both sides are equal.""" if len(arr) == 0: return 0 for i in range(0, len(arr)): sum1 = 0 sum2 = 0 for j in range(0, i): sum1 += arr[j] for k in range...
nan = 'Неизвестно' age = 'Возраст' gender = 'Пол' male = 'Мужчина' female = 'Женщина' check = 'Проверить' site = 'Место' torso = 'Живот' head_neck = 'Голова / Шея' palms_soles = 'Ладони / Ступни' oral_genital = 'Полость рта / Гениталии' lateral_torso = 'Бок' anterior_torso = 'Грудь' lower_extremity = 'Нижние конечности...
def read_pwscf_in(filepath): """ Note: read parameters from pwscf input template """ with open(filepath, 'r') as fin: lines = fin.readlines() control = {} system = {} electrons = {} ions = {} cell = {} for i in range(len(lines)): if li...
x_min = -2 y_min = (-(modelparams['weights'][0] * x_min) / modelparams['weights'][1] - (modelparams['bias'][0] / model_params['weights'][1])) x_max = 2 y_max = (-(modelparams['weights'][0] * x_max) / modelparams['weights'][1] - (modelparams['bias'][0] / modelparams['weights'][1])) fig, ax = plt.sub...
# -*- coding: utf-8 -*- """ Created on Thu May 27 11:00:56 2021 @author: BRUNO """ #Função que calcula (x+y)^n def main(): x = input('Digite o x: ') y = input('Digite o y: ') n = int(input('Digite o n: ')) print('O resultado é: ') print(pascal(x,y,n)) def fat(n): resultado = 1 ...
for i in range(0, 201, 2): print(i) for i in range(0, 100, 3): print(i)
PAD = 0 UNK = 1 BOS = 2 EOS = 3 PAD_WORD = "<blank>" UNK_WORD = "unk" BOS_WORD = "<s>" EOS_WORD = "</s>" BUFFER_SIZE = 64 * (1024 ** 2) TOKEN_VOCAB = "token" TYPE_VOCAB = "type" CHAR_VOCAB = "char" # dataset file fields MENTION = "mention_span" RIGHT_CTX = "right_context_token" LEFT_CTX = "left_context_token" TYP...
# ex:ts=4:sw=4:sts=4:et # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- r"""A defined list of constants available to QuickRelease users. The are some important difference between QuickRelease's L{config items<quickrelease.config>} and C{constants}: 1. C{constants} may be accessed without a L{Confi...
def reverse_number(n: int) -> int: """ This function takes in input 'n' and returns 'n' with all digits reversed. """ if len(str(n)) == 1: return n k = abs(n) reversed_n = [] while k != 0: i = k % 10 reversed_n.append(i) k = (k - i) // 10 return int(''.join(map(st...
# This is all about using strings stg_1 = "this is the first message without a tab" print(stg_1) stg_2 = "\t this is the second message with a tab" print(stg_2) stg_3 = "this is another message with a newline\n" print(stg_3)
#!/usr/bin/python # unicode.py text = u'\u041b\u0435\u0432 \u041d\u0438\u043a\u043e\u043b\u0430\ \u0435\u0432\u0438\u0447 \u0422\u043e\u043b\u0441\u0442\u043e\u0439: \n\ \u0410\u043d\u043d\u0430 \u041a\u0430\u0440\u0435\u043d\u0438\u043d\u0430' print (text)
#to have some interaction #we need an loop to look for actions def setup(): size(400, 400) #executed once println("This is the setup. Executed once. Initiate things here") #executed all the time waiting for infos def draw(): #do the bakcground color transformation noStroke() fill(map(mouseX, w...
########################################################################## # NSAp - Copyright (C) CEA, 2013 # Distributed under the terms of the CeCILL-B license, as published by # the CEA-CNRS-INRIA. Refer to the LICENSE file or to # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html # for details. ##########...
class Command: def __init__(self, name, desc="", args=[]): self.name = name self.desc = desc self.args = args
""" Return nth catalan number. Recursive Formula of Catalan Numbers says: C of (n+1) = summation of C of i* C of n-i, for range i=0 to i=n Therefore, for C of n formula becomes C of (n) = summation of C of i* C of n-1-i, for range i=0 to i=n-1 """ def getCatalan(n,dp_arr): # Lookup if (dp_arr[n] is not Non...
#!/usr/bin/python3 s0="パトカー" s1="タクシー" ret="" for idx, c in enumerate(s0): ret+=c+s1[idx] print(ret)
class SSLUnavailable(Exception): """If you haven't verified a CNAME zone within the grace period (a week), it can't be verified any more. """ pass class CustomHostnameNotFound(Exception): pass
n1,n2=map(int,input().split()) a=[] for i in range(n2): a.append(list(map(float,input().split()))) for i in zip(*a): print(sum(i)/n2)
def read_txt_file_str(filename): f=open('text_files/'+filename, "r") contents=f.read() f.close() return contents def read_txt_file_list(filename): f=open('text_files/'+filename, "r") contents=f.readlines() f.close() return contents
# Author: Jocelino F.G. n = int(input()) vetor = [n] dobro = n for i in range(0, 10): dobro = dobro * 2 vetor.append(dobro) print("N[{}] = {}".format(i, vetor[i]))
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # rule_engine/errors.py # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are # met: # # * Redistributions of source code must retain the above copyright # notice, this list...
def is_even(number): return number % 2 == 0
class Solution(object): def matrixReshape(self, nums, r, c): """ :type nums: List[List[int]] :type r: int :type c: int :rtype: List[List[int]] """ if len(nums)*len(nums[0]) != r*c: return nums kek = [] nums = [item for sublist in nu...
class InvalidOperationError(BaseException): pass class Node(): def __init__(self, value, next=None): self.value = value self.next = next class Stack(): def __init__(self, node=None): self.top = node def __len__(self): count = 0 curr = self.top while ...
""" The file provides default secret parameters used as a reference for creating your own secret.py or in testing. Make sure to create your own secret.py (in the same folder) with appropriate values for when deploying the website! """ SECRET_KEY = "2r4-$a^!rs=^glu=a8m=e5a$5*wg2uxjjob!diff-z*wzdx+4y" """ Set these if ...
# Given x = 10000.0 y = 3.0 print(x / y) print(10000 / 3) # What is happening? # Given print(x - 1 / y) print((x - 1) / y) # What is happening? # Given x = 'foo' y = 'bar' # Create 'foobar' using x and y s = x + y print(s) # Create 'foo -> bar' using x and y print(x + " -> " + y) # Given x = 'hello world' # from x ...
class Config: def __init__(self): self.data_dir = './data/' self.data_path = self.data_dir + 'peot.txt' self.pickle_path = self.data_dir + 'tang.npz' self.load_path = './checkpoints/peot9.pt' self.save_path = './checkpoints/peot9.pt' self.do_train = False sel...
# Copyright 2011 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 a...
''' @Author: Ofey Chan @Date: 2020-03-03 19:23:15 @LastEditors: Ofey Chan @LastEditTime: 2020-03-03 20:07:31 @Description: General permutation group class. @Reference: '''
# Forcing recursion for no good reason. But it passed so.... def solution_r(n): if n <= 0: return n else: if not n%3 or not n%5: return n + solution_r(n-1) else: return solution_r(n-1) def solution(number): if not number: return 0 return solutio...
class Solution: def minJumps(self, arr: List[int]) -> int: graph = defaultdict(list) for i in range(len(arr)): graph[arr[i]].append(i) visited = set() src, dest = 0, len(arr) - 1 queue = deque() queue.append((src, 0)) visited.add(src) whil...
def transitions(y,x): yield y+1,x yield y,x+1 yield y-1,x yield y,x-1 def valid_transitions(arr): # print(arr) Y = len(arr) X = len(arr[0]) def _f(y0,x0): for y,x in transitions(y0,x0): if 0 <= y < Y and 0 <= x < X and arr[y][x] != "-": yield y,x ...
# # Copyright (c) 2020 Xilinx, Inc. All rights reserved. # SPDX-License-Identifier: MIT # # Mandatory Common Configuration required sharedWs = "{buildDir}/shared_ws" XSCT_BUILD_SOURCE = "" # build source type whether to be used XSCT default or git source (i.e. XSCT_BUILD_SOURCE="git") version = "2020.2" # Vitis vers...