content
stringlengths
7
1.05M
# -*- coding: utf-8 -*- """ Db方法介绍 执行sql语句 query(sql, tuple_value) 参数 必填 说明 sql 必填 需要执行的sql语句 tuple_value 非必填 需要替换占位符的元组 该方法是执行sql语句,返回执行成功后的游标状态 例1:res = DB('user').query('select * from user') res.fetchall() 例2:res = DB('user').query('select * from user where id = %s', (7,)) res.fetchone() 新增数据 insert(data) 参数 必填 说...
#kasaHesabi=a,alinanCeklerHesabi=b,bankalarHesabi=c,alicakSenetelerHesabi=d,ticariMallarHesabi=e,binalarHesabi=f,tasitlarHesabi=g,demirbaslarHesabi=h #bankaKredileriKisa=i,saticilarHesabi=j,bankaKredileriUzun=k,borcSenetleri=l,sermayeHesabi=m class donenVarliklar: a=20000 b=10000 c=5000 d=28000 e=65...
origins = set() with open('cars.csv') as f: next(f), next(f) for row in f: origin = row.strip('\n').split(';')[-1] origins.add(origin) print(origins)
# # # # # # # # # # for i in range(4): for j in range(4): if j<=i: print("#", end=" ") print() # second method for i in range(4): for j in range(i+1): print("#", end=" ") print()
''' Created on Apr 12, 2011 @author: svenkratz ''' Triangle = [-11.6989,66.1471,0,-16.7297,53.6023,0,-20.9605,40.2224,0,-25.1012,26.8512,0,-30.375,14.6689,0,-36.3905,3.62857,0,-42.5839,-7.21708,0,-48.2647,-18.8834,0,-48.5197,-26.3401,0,-39.7211,-27.1884,0,-30.9196,-28.0427,0,-22.1053,-28.1357,0,-13.2896,-28.1357,0,-4...
def main(request, response): if request.method == "OPTIONS" and request.cookies.get("foo"): response.status = 400 else: response.headers.set("Cache-Control", "no-store") response.headers.set("Access-Control-Allow-Origin", request.headers.get("origin")) response.headers.set("Acces...
def reverse(st): word = st.split() st_reversed = " ".join(word[::-1]) return st_reversed
# Create a set of all pairs of similar words. Then iterate of zip(S1, S2) and all pairs should be in the set or w1==w2. class Solution: def areSentencesSimilar(self, words1: List[str], words2: List[str], pairs: List[List[str]]) -> bool: if len(words1)!=len(words2): return False pairs ...
class BinTreeNode(object): def __init__(self, data, left=None, right=None): self.data, self.left, self.right = data, left, right class BinTree(object): def __init__(self, root=None): self.root = root @classmethod def build_from(cls, node_list): """ param node_list: a li...
# An irrational decimal fraction is created by concatenating the positive integers: # # 0.123456789101112131415161718192021... # # It can be seen that the 12th digit of the fractional part is 1. # # If dn represents the nth digit of the fractional part, find the value of the following expression. # # d1 × d10 × d100 ×...
class TeleinfoError(Exception): """Basic exception for errors raised by teleinfo""" class BaseFormatError(TeleinfoError): """The format of a frame is invalid""" def __init__(self, string_verified, object_type_verified: str, errors: str = None): if isinstance(string_verified, str)...
# Copyright (c) 2021 Qianyun, Inc. All rights reserved. # common NODE_INSTANCE = 'node-instance' RELATIONSHIP_INSTANCE = 'relationship-instance' COMPUTE_CONNECTED_TO_NETWORK = 'cloudchef.abstract.relationships.compute_connected_to_network' VOLUME_CONTAINED_IN_COMPUTE = 'cloudchef.abstract.relationships.volume_containe...
reference_profiles = { "naval": { "name": "Naval Ravikant", "birthDate": "1980-01-01" }, "ryan": { "bio": "Co-founder of Onename (YC S14, USV). Working on decentralized identity.", "account": [{ "identifier": "c7520f2e8553df62c5353a84a662d060714c3ad3", ...
# A simple Python function def fun(): print("Welcome to GFG") # Driver code to call a function fun()
class Solution: def XXX(self, s: str) -> int: newlist = s.split(" ") newlist.reverse() for i in newlist: if(i != ""): return(len(i))
while True: try: input() except: break v = [int(x) for x in input().split()] v = sorted(v) t = len(v) // 2 print(t, v[t]-v[t-1])
for k in range(int(input())): T = input() tiros = tuple(map(int,input().split())) pulos = input() tot = 0 for t,p in zip(tiros,pulos): if p == 'S' and t <= 2: tot += 1 elif p == 'J' and t > 2: tot += 1 print(tot)
n = int(input()) swifts = [int(s) for s in input().split()] semaphores = [int(s) for s in input().split()] def sum_of_arr(arr, stop_idx): sum = 0 for i in range(stop_idx+1): sum += arr[i] return sum k = 0 for i in range(len(swifts)): if sum_of_arr(swifts, i) == sum_of_arr(semaphores, i):...
def valores(num): a = sorted(num) print(f"O menor valor digitado foi {a[0]}") print(f"O maior valor digitado foi {a[-1]}") def estruc(): cont = 0 num = list() while True: num.append(int(input("Digite um numero: ").strip())) cont+=1 if cont % 3 ==0: decida ...
""" Prime power triples """ def prime(n): array = [True] * n array[0] = array[1] = False for i in range(2, int(n ** 0.5) + 1): if array[i]: for j in range(2 * i, n, i): array[j] = False p = [] for i in range(n): if array[i]: p.append(i) r...
# -*- coding: utf-8 -*- def decorator(aClass): class newClass: # Returns a new class newClass in the decorator def __init__(self, age): self.total_display = 0 self.wrapped = aClass(age) # Record the object in the original object def display(self): self...
# LeetCode 844. Backspace String Compare `E` # acc | 87% | 67' # A~0h22 class Solution: def backspaceCompare(self, S: str, T: str) -> bool: def build(str): res = [] skip = 0 for c in reversed(str): if c == "#": skip += 1 ...
"""Define application constants. """ # Selected configuration keyword. KW_CONF_SEL = 'selected'
def square(x): return x * x def fast_exp(a, n): if n == 0: return 1 if n % 2 == 0: return square(fast_exp(a, n // 2)) else: return a * fast_exp(a, n - 1) def normal_exp(a, n): if n == 0: return 1 return a * normal_exp(a, n - 1) print(normal_exp(2, 500)) pri...
# # @lc app=leetcode.cn id=692 lang=python3 # # [692] 前K个高频单词 # # https://leetcode-cn.com/problems/top-k-frequent-words/description/ # # algorithms # Medium (52.22%) # Likes: 332 # Dislikes: 0 # Total Accepted: 54.6K # Total Submissions: 94K # Testcase Example: '["i", "love", "leetcode", "i", "love", "coding"]\n...
# http://rosettacode.org/wiki/Respond_to_an_unknown_method_call#Python class ElasticWrapper(): def __init__(self, item): self.client = Elasticsearch(item, maxsize=100) # max connections to each node def __getattr__(self, item): return getattr(self.client, item)
def quick_sort(data): if len(data) <= 1: return data pivot = data[0] small = [i for i in data[1:] if i <= pivot] large = [i for i in data[1:] if i > pivot] small = quick_sort(small) large = quick_sort(large) return small + [pivot] + large if __name__ == '__main__': data = [1, 4,...
class Pair: """ A hashable, comparable object for any set of two inputs where order doesn't matter. Args: item1 (object): the pair's first object item2 (object): the pair's second object """ def __init__(self, item1, item2): self.item1 = item1 self.item2 =...
# Do not change the following lines of code. class Fruit: Total_order=0 def __init__(self, Order_ID, weight): self.Order_ID=Order_ID self.weight=weight Fruit.Total_order=Fruit.Total_order+1 def __str__(self): return self.Order_ID+", Weight: "+str(self.weight) class...
# Source : https://leetcode.com/problems/complex-number-multiplication/#/description # Author : Han Zichi # Date : 2017-04-23 class Solution(object): def complexNumberMultiply(self, a, b): """ :type a: str :type b: str :rtype: str """ a = [int(i) for i in a[:-1].sp...
def _busqueda_binaria(lista, elemento, desde, hasta): if desde > hasta: return -1 medio = (hasta + desde) // 2 if lista[medio] == elemento: return medio if elemento < lista[medio]: return _busqueda_binaria(lista, elemento, desde, medio - 1) return _busqueda_binaria(lista, ele...
def create_demo_page(new_font_name, texts): css_style = "body {font-family:" + new_font_name + ";}" html = """ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>{0}</title> <link rel="stylesheet" href="{0}.css"> <style> {2} </style...
"""Module to calculate fuel needs.""" __all__ = ["get_fuel_needed", "get_fuel_needed_complete"] def get_fuel_needed(mass: int) -> int: """Calculate fuel needed to launch mass.""" return mass // 3 - 2 def get_fuel_needed_complete(mass: int) -> int: """Calculate fuel needed to launch mass and fuel itself...
class NetworkAddressManager: """ Class will contain variables and methods to create, update, return and manage network addresses This includes creating an addresses file Updating and addresses file, when new addresses are discovered returning addresses to a NetworkManager method, when client must ...
# coding: utf-8 # In[ ]: #算法思路: #最后一位单独谈论 #定义一个判断是否进位的变量carry #如果第一位都还在进位 #则在左侧添加一个1 class Solution: def plusOne(self, digits): n = len(digits) carry = 0 cur = n-1 if digits[cur] == 9: digits[cur] = 0 carry =1 cur -= 1 else: ...
# # PySNMP MIB module Juniper-Ping-CONF (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-Ping-CONF # Produced by pysmi-0.3.4 at Mon Apr 29 19:53:12 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Ma...
# DISTANCE CONVERTER CONVERTING KILOMETERS TO MILES # Take two inputs from user: # 1-first name # 2-the distance in km # Print: # Greet user by name and show km, and mile values # 1mile is 1.609 kilometers print("Enter your name:") name = input() print("Enter distance in km:") km = input() mi = float(km)/1.607 prin...
# # PySNMP MIB module Nortel-MsCarrier-MscPassport-BusMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-MsCarrier-MscPassport-BusMIB # Produced by pysmi-0.3.4 at Wed May 1 14:29:30 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Usi...
class Solution(object): def canConstruct(self, ransomNote, magazine): """ :type ransomNote: str :type magazine: str :rtype: bool """ for i in set(ransomNote): if ransomNote.count(i) > magazine.count(i): return False return True
bind = '0.0.0.0:443' workers = 4 reload = True keyfile = '/etc/keys/yiwen_dot_date/ssl/yiwen.date.key' certfile = '/etc/keys/yiwen_dot_date/ssl/yiwen.date.crt'
__author__ = ['lorenzo@pramantha.net'] def return_api_key(): return '**********************'
# Copyright (c) 2019 the Eclipse BaSyx Authors # # This program and the accompanying materials are made available under the terms of the MIT License, available in # the LICENSE file of this project. # # SPDX-License-Identifier: MIT """ This module contains the security aspects of the AAS metamodel. Currently, the secur...
# # Copyright (c) 2018 CountStarlight # Licensed under The MIT License (MIT) # See: LICENSE # def flatten_idx(position, size): (x, y) = position return x * size + y
#!/usr/bin/env python3 #encoding=utf-8 #----------------------------- # Usage: python3 break_else.py # Description: find prime #----------------------------- y = int(input('Enter an integer: ')) x = y // 2 while x > 1: if y % x == 0: print('%s has factor %s' % (y, x)) break x -= 1 else: ...
def print_popup(gameobject_model, view_factory): action_id = 1 html = '<b>[Transform] GameObject: ' + gameobject_model.get_name() + \ '</b><br><a href="' + str(action_id) + '">Show definition </a> <br>' action = view_factory.get_goto_reference_action(gameobject_model.get_id()) view_factory.regis...
# -*- coding: utf-8 -*- INSTALLED_APPS = ['django_rq'] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:', }, } LOGGING = { "version": 1, "disable_existing_loggers": False, "formatters": { "rq_console": { "format": "%(asctim...
#In this problem we have to state the count of rotations a sorted array has #gone through. # For Ex: # 4 5 6 1 2 3 4 # The above array has gone through 3 rotations n=int(input("Enter the length of the array:\n")) arr=[] #taking input for i in range(0,n): print("Element",i+1) ele = int(input(...
def whoami(r): while next(iter(r)): print("before") yield next(r) print("after") def mysterious(m): while m > 0: yield m m -= 1 # Will this ever terminate? # If so, what's the output? for x in whoami(mysterious(4)): print(x)
# # @lc app=leetcode id=754 lang=python3 # # [754] Reach a Number # # @lc code=start class Solution: def reachNumber(self, target: int) -> int: target = abs(target) s = k = 0 while s < target: k += 1 s += k d = s - target if d % 2 == 0: ...
""" Mock """ class BadValueError(Exception): pass
print('Rail Fence Cipher with 2 rows so as to make it keyless') plaintext = input('Message text:') n = len(plaintext) encrypted = '' print('Encrypting...') for i in range(n): if n%2 == 0: if i<n//2: encrypted += plaintext[2*i] else: encrypted += plaintext[2*(i%(n//2))+1] else: if i<(n//2)+1: ...
def foo(): bar() def bar(): pass
################################ # Advent of Code 2017 # # Day 15: Dueling Generators # # April Jackson # ################################ # Get the data with open('day15.in') as f: data = f.read() # Helper: Parse the data for each generator's initial value def get_gen_values(data): ...
"""IHC component constants.""" CONF_AUTOSETUP = 'auto_setup' CONF_INFO = 'info' CONF_XPATH = 'xpath' CONF_NODE = 'node' CONF_INVERTING = 'inverting' CONF_DIMMABLE = 'dimmable' CONF_BINARY_SENSOR = 'binary_sensor' CONF_LIGHT = 'light' CONF_SENSOR = 'sensor' CONF_SWITCH = 'switch' CONF_NAME = 'name' CONF_POSITION = 'pos...
# bit <-> str class BitStream: def __init__(self, fileName, mode): self.file = open(fileName, mode) self.word = 0 if mode[0] == 'r': self.pos = -1 elif mode[0] == 'w': self.pos = 7 self.mode = mode def read(self, size): ret = '' fo...
class lines: intro = ['You wake up. The room is dim and you have little visibility in the treehouse while it\'s in its current state.', 'You climb out of your hammock and walk out onto the suspended wooden ledge outside.', 'You behold the vastness of the mountain range before you.', 'You wish you could stay here l...
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ @created: 08.11.19 @author: felix """ def check_for_exceptions(x: str, y: str) -> None: try: print(int(x) // int(y)) except ZeroDivisionError as e: print(f'Error Code: {e}') except ValueError as e: print(f'Error Code: {e}') if __...
# -*- coding: utf-8 -*- ############################################################################## # # OpenERP, Open Source Management Solution # Copyright (c) 2010-2013 Elico Corp. All Rights Reserved. # Augustin Cisterne-Kaas <augustin.cisterne-kaaas@elico-corp.com> # # This program is free software: ...
arr1 = ["A", "B", "C", "D", "E", "F", "G", "I", "J", "K"] class Node: def __init__(self, val=None, left=None, right=None): self.data = val self.left = left self.right = right class snode: def __int__(self, data=None, left=None, right=None): self.data = data self.left ...
requires = ['d', 'e'] provides = ['c_one', 'c_two'] def c_one(): print("c_one") d_one() def c_two(): print("c_two") e_two()
class HokiDialogue(object): def __init__(self): self.RED = '\u001b[31;1m' self.ORANGE = '\u001b[33;1m' self.GREEN = '\u001b[32;1m' self.BLUE = '\u001b[36;1m' self.ENDC = '\033[0m' self.BOLD = '\033[1m' self.UND = '\033[4m' self.BCKG='\u001b[46;1m' ...
## O(n) solution class Solution: def defangIPaddr(self, address: str) -> str: result = "" for c in address: if c == '.': result += "[.]" else: result += c return result
name="" while name!="Nina" and name!="Anime": print("Please input a name.Enter 'q' to quit:") name=input() if name=="q": break
# Leetcode 518. Coin Change 2 # # Link: https://leetcode.com/problems/coin-change-2/ # Difficulty: Medium # Solution using DFS # Complexity: # O(N*M) time | where N represent the number of coins and M the amount we are # searching for # O(N*M) space | where M represent the amount we are searching f...
""" Ejemplos de funciones * python == 3.7 Ref #: https://docs.python.org/3/tutorial/controlflow.html#defining-functions Ref #: https://docs.python.org/3/tutorial/controlflow.html#more-on-defining-functions """ def my_func() -> None: print("Hello Kitty!") my_func() # Hello Kitty! def my_func() -> int: return ...
# list_a = [a ** 2 for a in range(6)] # print(list_a) # # genera_a = (a ** 2 for a in range(6)) def genera_func(): yield 1 g=genera_func() print(next(g)) # 执行器 #方法
class CircularBuffer(object): def __init__(self,max_size): self.max_size = max_size self.log = [0] * self.max_size self.current = 0 def record(self, eye_num): self.log[self.current] = eye_num self.current = ((self.current+1) % self.max_size) #O(1) insertion
# A composição basicamente é uma boa escolha quando se trata # de um objeto que está dentro de outro ou deve estar #por exemplo quando uma classe mais simples "A" está dentro de #uma classe mais complexa "b" # class Aluno: def __init__(self, nome): self.__nome = nome def retornaNome(self): ret...
class Strategy(object): def apply(self, account): raise NotImplementedError() class ScaledETFStrategy(Strategy): def __init__( self, symbol, amplifier=1, **kwargs): self._sym = symbol self._amp = amplifier self._kwargs = kwargs def __str__(self): tmpl = ( 'Scaled ETF strategy:...
# print your name print("jonny") # use concat to print your name and age (don't forget to space) print("jonny " + "27") # print 3 numbers separated by tabs print("1\t2\t3") # print 3 numbers separated by newlines print("1\n2\n3\n") # get 4 numbers using input and print their sum num1 = input('please select number1:...
a=[int(i) for i in input().split()];b=[int(i) for i in input().split()] c=b[1]//a[0];d=a[1]//b[0] if b[1]%a[0]>0: c+=1 if a[1]%b[0]>0: d+=1 if c==d: print("DRAW") elif c<d: print("PLAYER A") else: print("PLAYER B")
def Partition(Array,left,right): ''' Partition function to sort the array with respect to the pivot ''' pivot = Array[right] i = left-1 for j in range(left,right,1): if (Array[j] < pivot): i += 1 Array[i],Array[j] = Array[j],Array[i] Array[i+1],Array[right] = Array[right],Array[i+1] retu...
# Copyright 2018- The Pixie Authors. # # 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 agreed to in w...
# node definition class Node: def __init__(self,value): self.left = None self.right = None self.value = value def inorder(root): if root == None: return inorder(root.left) print(root.value), inorder(root.right) def preorder(root): if root == None: retu...
ingredients = { 'voorgerecht': "UNOX soep in pak tomatensoep met balletjes 1l", 'hoofdgerecht': "AH rundergehakt 300 gAH mager rundergehakt 300 g", 'nagerecht': "Mona Gezingspudding griesmeel met saus 500 g", 'drinken': "AH Zuid-afrika huiswijn fris", 'voorgerecht': "AH Greenfields rosbief naturel", 'ho...
input = """ rule(r1). head(p,r1). nbl(q,r1). rule(r2). head(q,r2). nbl(neg_q,r2). rule(r3). head(neg_p,r3). nbl(p,r3). rule(r4). head(p,r4). nbl(neg_p,r4). opp(p,neg_p). opp(q,neg_q). pr(r1,r2). pr(r2,r3). pr(r3,r4). """ output = """ rule(r1). head(p,r1). nbl(q,r1). rule(r2). he...
# -*- coding: utf-8 -*- model = { u'je ': 0, u' pr': 1, u' po': 2, u' je': 3, u' v ': 4, u' za': 5, u' na': 6, u'pre': 7, u'da ': 8, u' da': 9, u'ki ': 10, u'ti ': 11, u'ja ': 12, u'ne ': 13, u' in': 14, u'in ': 15, u'li ': 16, u'no ': 17, u'na ': 18, u'ni ': 19, u' bi': 20, u'jo ': 21, u' ne': 2...
class Agent: """A class of an agent""" def __init__(self): self.idx = None self.policy_net = None self.target_net = None self.optimizer = None self.loss = None
def read_input(): file = open("Data/day17.txt", "r") containers = [] for line in file: line = int(line.strip("\n")) containers.append(line) return sorted(containers, reverse = True) def count_combinations(containers, litres): if sum(containers) < litre...
#Writeing to check Simple Else statements. print("Please do enter a value"); UserInput=int(input()); if(UserInput<3): print("User has entered a number that is less than 3"); else: print("User has entered an number that is either equal to 3 or greater than 3"); #*****************End of the Program****************...
# 입력 t1, v1 = map(int, input().split()) t2, v2 = map(int, input().split()) # 출력 if t2 < 0 and v2 >= 10: print("A storm warning for tomorrow! Be careful and stay home if possible!") elif t2 < t1: print("MCHS warns! Low temperature is expected tomorrow.") elif v1 < v2: print("MCHS warns! Strong wind is exp...
__all__ = [ 'ncep' ]
# -*- coding: utf-8 -*- # Copyright (c) 2018-2020 Christiaan Frans Rademan <chris@fwiw.co.za>. # All rights reserved. # # 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 ...
class Solution: def rotate(self, nums: List[int], k: int) -> None: """ Do not return anything, modify nums in-place instead. """ k = k % len(nums) res = nums[-k:] res.extend(nums[:-k]) for i in range(len(nums)): nums[i] = res[i]
class Movie: def __init__(self, title, rlsyr, runTime, genre, link): self.__title = title self.__rlsyr = rlsyr self.__runTime = runTime self.__genre = genre self.__link = link def printMovie(self): print('Movie Title: ', self.__title) print('Release Year:...
# # PySNMP MIB module Nortel-Magellan-Passport-BaseRoutingMIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-Magellan-Passport-BaseRoutingMIB # Produced by pysmi-0.3.4 at Wed May 1 14:26:32 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwan...
def cor(x): ''' Função que gera um codigo de cores no padrão escape sequence ANSI. :param x: numero de posição do codigo ANSI na tupla cores. :return: retorna o codigo da cor. ''' cores = ( '\033[m', # 0 - sem cor '\033[1;30m', # 1 - branco '\033[1;7;30m', # 2...
def reverso(n): numeroInvertido = int(str(n)[::-1]) print(numeroInvertido) n = int(input("Digite o número: ")) reverso(n)
"""Aprendendo a extrair dados da API da RIOT.""" # 20 requests every 1 seconds(s) # 100 requests every 2 minutes(s) URL = { 'base_summoner': 'https://{region}.api.riotgames.com/lol/summoner/{url}', 'base_matchlist': 'https://{region}.api.riotgames.com/lol/match/{url}', 'base_matchPerChamp': 'https://{regi...
# 890. Find and Replace Pattern class Solution: def findAndReplacePattern2(self, words, pattern: str): ans = [] for w in words: d = {} flag = True if len(w) == len(pattern): for i in range(len(w)): if w[i] in d and d[w[i]] != pa...
def _strip_prefix(text, prefix): if text.startswith(prefix): return text[len(prefix):] return text def _zip_impl(ctx): strip_prefixes = ctx.attr.strip_prefixes args = ctx.actions.args() args.add("c", ctx.outputs.zip.path) inputs = [] for src in ctx.attr.srcs: for f in src.fi...
# https://leetcode.com/problems/pascals-triangle/ class Solution(object): def generate(self, numRows): """ :type numRows: int :rtype: List[List[int]] """ if numRows == 0: return [] if numRows == 1: return [[1]] if numRows == 2: ...
INT_BITS = 32 def getIndex(element): index = int(element / INT_BITS) offset = element % INT_BITS bit = 1 << offset return (index, bit) class Set: def __init__(self, capacity): self.vector = [0] * (1 + int(capacity / INT_BITS)) self.capacity = capacity def add(self, element): (index, bit) = ge...
class QiwiInvalidToken(Exception): pass class QiwiInvalidAmountValue(Exception): pass class QiwiTooLongComment(Exception): pass class QiwiTooLongDescription(Exception): pass class QiwiPaymentMethodNotSelected(Exception): pass class QiwiInvalidDelay(Exception): pass class QiwiInvalidB...
products = [] class ProductsModel(object): def __init__(self,name,price,image,quantity): self.product_id = len(products)+1 self.products = products self.name = name self.price = price self.image = image self.quantity = quantity def add_item(self): ...
class State: ''' this class would hold the game snapshot, used by the q learner to index it's table, as well as reward function to determine the reward of that particular state. ''' def __init__(self, player, enemy): self.player = player self.enemy = enemy
#Definicion de funcion def hello(name="humano"): print("Hellow world", name) hello("dl") hello()
CHECKIN_MOVIE = { "id": 3373536619, "watched_at": "2014-08-06T01:11:37.000Z", "sharing": {"twitter": True, "tumblr": False}, "movie": { "title": "Guardians of the Galaxy", "year": 2014, "ids": { "trakt": 28, "slug": "guardians-of-the-galaxy-2014", ...
# -*- coding: utf-8 -*- ''' File name: code\silver_dollar_game\sol_344.py Author: Vaidic Joshi Date created: Oct 20, 2018 Python Version: 3.x ''' # Solution to Project Euler Problem #344 :: Silver dollar game # # For more information see: # https://projecteuler.net/problem=344 # Problem Statement '...
jp_to_en_tuples = [ ('全ての親', 'ParentNode'), ('操作中心', 'ControlNode'), ('センター', 'Center'), ('センター', 'Center'), ('グループ', 'Group'), ('グルーブ', 'Groove'), ('キャンセル', 'Cancel'), ('上半身', 'UpperBody'), ('下半身', 'LowerBody'), ('手首', 'Wrist'), ('足首', 'Ankle'), ('首', 'Neck'), ('頭', 'Head'), ...