content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# 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 ...
class Solution: def backspace_compare(self, S: str, T: str) -> bool: def build(str): res = [] skip = 0 for c in reversed(str): if c == '#': skip += 1 elif skip: skip -= 1 else: ...
"""Define application constants. """ # Selected configuration keyword. KW_CONF_SEL = 'selected'
"""Define application constants. """ 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...
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)) print(2 ...
# 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)
class Elasticwrapper: def __init__(self, item): self.client = elasticsearch(item, maxsize=100) 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,...
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 =...
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 = i...
# 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...
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 Mango(Fruit): def __init__(self, ...
# 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...
class Solution(object): def complex_number_multiply(self, a, b): """ :type a: str :type b: str :rtype: str """ a = [int(i) for i in a[:-1].split('+')] b = [int(i) for i in b[:-1].split('+')] c = a[0] * b[0] - a[1] * b[1] d = a[0] * b[1] + a[1]...
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 _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...
def create_demo_page(new_font_name, texts): css_style = 'body {font-family:' + new_font_name + ';}' html = '\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8">\n <title>{0}</title>\n <link rel="stylesheet" href="{0}.css">\n <style>\n {2}\n <...
"""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...
"""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 ...
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 co...
# # 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...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, value_size_constraint, single_value_constraint, constraints_union, constraints_intersection) ...
# 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...
print('Enter your name:') name = input() print('Enter distance in km:') km = input() mi = float(km) / 1.607 print(f'Hello {name}! {km} km is equivalent to {mi:.1f} miles')
# # 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...
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_union, value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint) ...
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
class Solution(object): def can_construct(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'
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 '**********************'
__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...
""" This module contains the security aspects of the AAS metamodel. Currently, the security model is not ready yet, so this module doesn't do anything. """ class Security: """ Security model is not ready yet. This is just a placeholder class. """ pass
# # Copyright (c) 2018 CountStarlight # Licensed under The MIT License (MIT) # See: LICENSE # def flatten_idx(position, size): (x, y) = position return x * size + y
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: ...
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: print('%s is prime' % y)
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...
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.register_action...
# -*- 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...
installed_apps = ['django_rq'] databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}} logging = {'version': 1, 'disable_existing_loggers': False, 'formatters': {'rq_console': {'format': '%(asctime)s %(message)s', 'datefmt': '%H:%M:%S'}}, 'handlers': {'rq_console': {'level': 'DEBUG', 'clas...
#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(...
n = int(input('Enter the length of the array:\n')) arr = [] for i in range(0, n): print('Element', i + 1) ele = int(input()) arr.append(ele) c = 0 mini = 1000000 for ele in arr: if ele < mini: mini = ele min_in = c c = c + 1 print('Number of rotataions = ', min_in)
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)
def whoami(r): while next(iter(r)): print('before') yield next(r) print('after') def mysterious(m): while m > 0: yield m m -= 1 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: ...
class Solution: def reach_number(self, target: int) -> int: target = abs(target) s = k = 0 while s < target: k += 1 s += k d = s - target if d % 2 == 0: return k return k + 1 + k % 2
""" Mock """ class BadValueError(Exception): pass
""" 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: ...
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 ...
def foo(): bar() def bar(): pass
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): ...
with open('day15.in') as f: data = f.read() def get_gen_values(data): generators = [] for line in data.splitlines(): line = [word for word in line.split()] generators.append(line[-1]) return (int(generators[0]), int(generators[1])) def get_next_a(gen_a): mult_a = 16807 div_by =...
"""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...
"""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 = 'posi...
# 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 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 = '' for i in range(...
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...
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 lon...
#!/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 __...
""" @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 __name__ == '__main__': t = int(input()) val...
# -*- 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: ...
{'name': 'OpenERP Adblock', 'version': '0.1', 'category': '', 'depends': ['mail'], 'author': 'Elico Corp', 'license': 'AGPL-3', 'website': 'https://www.elico-corp.com', 'description': '\n Module which hides the OpenERP announcement bar.\n ', 'images': [], 'js': ['static/src/js/announcement.js'], 'installable'...
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 ...
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()
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' ...
class Hokidialogue(object): def __init__(self): self.RED = '\x1b[31;1m' self.ORANGE = '\x1b[33;1m' self.GREEN = '\x1b[32;1m' self.BLUE = '\x1b[36;1m' self.ENDC = '\x1b[0m' self.BOLD = '\x1b[1m' self.UND = '\x1b[4m' self.BCKG = '\x1b[46;1m' def in...
## O(n) solution class Solution: def defangIPaddr(self, address: str) -> str: result = "" for c in address: if c == '.': result += "[.]" else: result += c return result
class Solution: def defang_i_paddr(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
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...
class Solution: def change(self, amount: int, coins: List[int]) -> int: cache = {} def dfs(coin_index, current_amount): if current_amount == amount: return 1 if current_amount > amount or coin_index == len(coins): return 0 if (coi...
""" 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 ...
""" 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() def my_func() -> int: return 1 a = my_func...
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
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
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:...
class Strategy(object): def apply(self, account): raise not_implemented_error() class Scaledetfstrategy(Strategy): def __init__(self, symbol, amplifier=1, **kwargs): self._sym = symbol self._amp = amplifier self._kwargs = kwargs def __str__(self): tmpl = 'Scaled E...
# 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:...
print('jonny') print('jonny ' + '27') print('1\t2\t3') print('1\n2\n3\n') num1 = input('please select number1:') num2 = input('please select number2:') num3 = input('please select number3:') num4 = input('please select number4:') print(num1 + num2 + num3 + num4) print(int(num1) + int(num2) + int(num3) + int(num4)) num1...
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")
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...
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...
# 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...
load('@rules_proto//proto:defs.bzl', 'ProtoInfo') def _proto_path(proto): path = proto.path root = proto.root.path ws = proto.owner.workspace_root if path.startswith(root): path = path[len(root):] if path.startswith('/'): path = path[1:] if path.startswith(ws): path = pa...
# 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...
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: return (print(ro...
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...
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', 'hoofdgerecht': 'AH ...
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...
input = '\n\n rule(r1). head(p,r1). nbl(q,r1). \n\n rule(r2). head(q,r2). nbl(neg_q,r2).\n\n rule(r3). head(neg_p,r3). nbl(p,r3).\n\n rule(r4). head(p,r4). nbl(neg_p,r4).\n\n opp(p,neg_p). \n opp(q,neg_q). \n\n pr(r1,r2). pr(r2,r3). pr(r3,r4).\n\n\n' output = '\n\n rule(r1). head(p,r1). nbl(q,r1). \n\n rule(r2). head(q...
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
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...
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) < litres: return 0 if contai...
#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****************...
print('Please do enter a value') user_input = 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')
__all__ = [ 'ncep' ]
__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 Redirects(object): __slots__ = () def redirect_permanently(self, location): """ 301 Moved Permanently. The HTTP response status code 301 Moved Permanently is used for permanent URL redirection, meaning current links or records using the URL that the response is received f...
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 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:...
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 print_movie(self): print('Movie Title: ', self.__title) print('Release Yea...
# # 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...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) ...
"""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...
"""Aprendendo a extrair dados da API da RIOT.""" url = {'base_summoner': 'https://{region}.api.riotgames.com/lol/summoner/{url}', 'base_matchlist': 'https://{region}.api.riotgames.com/lol/match/{url}', 'base_matchPerChamp': 'https://{region}.api.riotgames.com/lol/match/{url}', 'base_match': 'https://{region}.api.riotga...
# 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...
class Solution: def find_and_replace_pattern2(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]] != pattern[i] or (pattern[i] in d...
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...
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: ...
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: return [[1], [1, 1]] res = [[1], [1, ...
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...
int_bits = 32 def get_index(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):...
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...
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 Qiwiinvalidbillid(...
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): ...
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
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()
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", ...
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', 'imdb': 'tt2015381', 'tmdb': 118340}}} checkin_episode = {'id': 3373536620,...
def stock_list(listOfArt, listOfCat): if len(listOfArt) == 0 or len(listOfCat) == 0: return "" books = {} result = [] for book in listOfArt: title_num = book.split() title = title_num[0] num = title_num[1] if title[0] in books: books[title[0]] += int...
def stock_list(listOfArt, listOfCat): if len(listOfArt) == 0 or len(listOfCat) == 0: return '' books = {} result = [] for book in listOfArt: title_num = book.split() title = title_num[0] num = title_num[1] if title[0] in books: books[title[0]] += int(n...
list = ['a','e','i','o','u'] a = input("Enter a character: ") if a in list : print(a, "is vowel") else : print(a, "is consonant")
list = ['a', 'e', 'i', 'o', 'u'] a = input('Enter a character: ') if a in list: print(a, 'is vowel') else: print(a, 'is consonant')
#MOSTRAR TDS OS NUMEROS PARES QUE ESTAO NO INTERVALO DE 1 A 50 for par in range(1,51):#COLOCOU DE 1 ATE 51 PQ TEM Q MOSTRAR O 50 JA QUE ELE E PAR if(par%2==0): print(par, end=' ') #esse end deixa o numero do lado " " coloca espaco print("\n")
for par in range(1, 51): if par % 2 == 0: print(par, end=' ') print('\n')
class HivenError(Exception): """Base class for all Hiven exceptions""" pass
class Hivenerror(Exception): """Base class for all Hiven exceptions""" pass
# Day 1, puzzle 2: Sonar Sweep with open("input", "r") as fd: depths = [int(x) for x in fd.readlines()] # this solution is largely going to be similar with 1-1's, but repeated to # create appropriate sliding windows (which then get zipped for comparison) window_a = zip(depths, depths[1:], depths[2:]) window_b = ...
with open('input', 'r') as fd: depths = [int(x) for x in fd.readlines()] window_a = zip(depths, depths[1:], depths[2:]) window_b = zip(depths[1:], depths[2:], depths[3:]) depth_increases = sum([1 if sum(x) < sum(y) else 0 for (x, y) in zip(window_a, window_b)]) print(depth_increases)
class Solution(object): def addStrings(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ output = [] carry = 0 p1 = len(num1) - 1 p2 = len(num2) - 1 print('Hello World') while p1 >= 0 or p2 >= 0: ...
class Solution(object): def add_strings(self, num1, num2): """ :type num1: str :type num2: str :rtype: str """ output = [] carry = 0 p1 = len(num1) - 1 p2 = len(num2) - 1 print('Hello World') while p1 >= 0 or p2 >= 0: ...
def solution(A): num_count = {} for num in A: num_count[num] = num_count.get(num, 0) + 1 for num, count in num_count.items(): if count > len(A) // 2: return A.index(num) return -1 # https://codility.com/media/train/6-Leader.pdf def solution_2(A): size, value = 0, N...
def solution(A): num_count = {} for num in A: num_count[num] = num_count.get(num, 0) + 1 for (num, count) in num_count.items(): if count > len(A) // 2: return A.index(num) return -1 def solution_2(A): (size, value) = (0, None) for num in A: if size == 0: ...
""" Given an undirected graph with n vertices and m edges, compute the number of connected components in it. """ def vertices_to_components(g): """ Build dictionary of vertices to connected component keys """ vertex_to_component = {} key = 0 vertices = g.get_vertices() for vertex in verti...
""" Given an undirected graph with n vertices and m edges, compute the number of connected components in it. """ def vertices_to_components(g): """ Build dictionary of vertices to connected component keys """ vertex_to_component = {} key = 0 vertices = g.get_vertices() for vertex in vertic...
class User: def __init__(self,name): self.name=name def show(self): print(self.name) @classmethod def class_foo(cls): print(cls) def printMessage(self): print("hi") user =User("ada66") user.show() user.age=35 user.class_foo() print(user.age) def showMsg(): print("hi") user.show=showMsg ...
class User: def __init__(self, name): self.name = name def show(self): print(self.name) @classmethod def class_foo(cls): print(cls) def print_message(self): print('hi') user = user('ada66') user.show() user.age = 35 user.class_foo() print(user.age) def show_msg()...
for nname, net in ctx.nets: ctx.lockNetRouting(nname) ctx.cells["slice_i"].addInput("A0") ctx.connectPort("ctr[26]", "slice_i", "A0") ctx.cells["slice_i"].setParam("LUT0_INITVAL", "0101010101010101") # LED is active low so invert ctx.cells["slice_i"].setParam("A0MUX", "A0") # remove constant mux on LUT input
for (nname, net) in ctx.nets: ctx.lockNetRouting(nname) ctx.cells['slice_i'].addInput('A0') ctx.connectPort('ctr[26]', 'slice_i', 'A0') ctx.cells['slice_i'].setParam('LUT0_INITVAL', '0101010101010101') ctx.cells['slice_i'].setParam('A0MUX', 'A0')
ALPHABET = ''.join([chr(ord('a')+i) for i in range(26)]) class Possibility: def __init__(self, letter, complete, extendable_end, extendable_start): self.letter = letter self.complete = complete self.extendable_end = extendable_end self.extendable_start = extendable_start class Pa...
alphabet = ''.join([chr(ord('a') + i) for i in range(26)]) class Possibility: def __init__(self, letter, complete, extendable_end, extendable_start): self.letter = letter self.complete = complete self.extendable_end = extendable_end self.extendable_start = extendable_start class P...
class AddRequestToFormMixin(object): def get_form_kwargs(self): kwargs = super(AddRequestToFormMixin, self).get_form_kwargs() kwargs.update({ 'request': self.request, }) return kwargs
class Addrequesttoformmixin(object): def get_form_kwargs(self): kwargs = super(AddRequestToFormMixin, self).get_form_kwargs() kwargs.update({'request': self.request}) return kwargs
# Environment variables ENV_GCS_PROJECT = "GCS_PROJECT" ENV_GCS_BUCKET = "GCS_BUCKET" ENV_GCS_ROOT = "GCS_ROOT" ENV_CATALOG_PATH = "CATALOG_PATH"
env_gcs_project = 'GCS_PROJECT' env_gcs_bucket = 'GCS_BUCKET' env_gcs_root = 'GCS_ROOT' env_catalog_path = 'CATALOG_PATH'
l = [] while True: try: e = str(input()) if not e in l: l.append(e) except EOFError: print(len(l)) break
l = [] while True: try: e = str(input()) if not e in l: l.append(e) except EOFError: print(len(l)) break
SITE_PREFIX = '/infoset' API_PREFIX = '{}/api/v1'.format(SITE_PREFIX) API_EXECUTABLE = 'infoset-ng-api' API_GUNICORN_AGENT = 'infoset-ng-gunicorn' INGESTER_EXECUTABLE = 'infoset-ng-ingester'
site_prefix = '/infoset' api_prefix = '{}/api/v1'.format(SITE_PREFIX) api_executable = 'infoset-ng-api' api_gunicorn_agent = 'infoset-ng-gunicorn' ingester_executable = 'infoset-ng-ingester'
def checkPrime(a): # start_times.append(datetime.now()) i = 1 while i < (a - 1): i += 1 if a % i == 0: return False return True lim = int(input("Choose integer: ")) list_to_lim = list() for i in range(2, lim + 1): if i%2==0: continue else: list_to_lim...
def check_prime(a): i = 1 while i < a - 1: i += 1 if a % i == 0: return False return True lim = int(input('Choose integer: ')) list_to_lim = list() for i in range(2, lim + 1): if i % 2 == 0: continue else: list_to_lim.append(i) prime_list = list() for i in...
students = [] def read_file(): try: f = open("students.txt", "r") # read text from a file using access mode r for student in read_students(f): students.append(student) f.close() except Exception: print("Could not read file") # use generator with yield to read eac...
students = [] def read_file(): try: f = open('students.txt', 'r') for student in read_students(f): students.append(student) f.close() except Exception: print('Could not read file') def read_students(f): for line in f: yield line read_file() print(student...
class Multiselect: def __init__(self,data): self.data=data @classmethod def init_from_options(cls,options): data=[{"key":x,"value":False} for x in options] return(cls(data)) def keys(self): keys=[x["key"] for x in self.data] return(keys) def val...
class Multiselect: def __init__(self, data): self.data = data @classmethod def init_from_options(cls, options): data = [{'key': x, 'value': False} for x in options] return cls(data) def keys(self): keys = [x['key'] for x in self.data] return keys def value...
# -*- coding:utf-8 -*- # file: __init__.py # author: Mundy # date: 2017/5/10 0010 """ """
""" """
TITLE = 'Roguelike' AUTHOR = 'Lukas Singer, Daniel Nimmervoll' EMAIL = 'lukas42singer (at) gmail (dot) com' COPYRIGHT = 'Copyright (C) 2017 - 2018 by {}'.format(AUTHOR) CREDITS = [ "https://www.python.org/", "https://vim.sourceforge.io/", "http://www.roguebasin.com/", ""] # the whole screen size SCREE...
title = 'Roguelike' author = 'Lukas Singer, Daniel Nimmervoll' email = 'lukas42singer (at) gmail (dot) com' copyright = 'Copyright (C) 2017 - 2018 by {}'.format(AUTHOR) credits = ['https://www.python.org/', 'https://vim.sourceforge.io/', 'http://www.roguebasin.com/', ''] screen_x = 0 screen_y = 0 screen_w = 80 screen_h...
"""Internal module that keeps the abstract Tracker class.""" class Tracker(object): """This class is an abstraction for all supported trackers.""" NOT_IMPLEMENTED_MSG = 'To be implemented in device-linked class' def __init__(self): """Create an instance ready for connecting.""" self.__co...
"""Internal module that keeps the abstract Tracker class.""" class Tracker(object): """This class is an abstraction for all supported trackers.""" not_implemented_msg = 'To be implemented in device-linked class' def __init__(self): """Create an instance ready for connecting.""" self.__conn...
### Beautiful Days at the Movies - Solution def beautifulDays(i, j, k): count = 0 for x in range(i, j+1): if abs(x - int(str(x)[::-1])) % k == 0: count += 1 print(count) i, j, k = map(int, input().split()) beautifulDays(i, j, k)
def beautiful_days(i, j, k): count = 0 for x in range(i, j + 1): if abs(x - int(str(x)[::-1])) % k == 0: count += 1 print(count) (i, j, k) = map(int, input().split()) beautiful_days(i, j, k)
# Copyright (c) 2017 Dustin Doloff # Licensed under Apache License v2.0 # Default methods and attributes associated with Targets. This is due to limitations in Bazel being # unable to detect if an attribute of an object is a method or really an attribute DEFAULT_TARGET_STRUCT_KEYS = [ "data_runfiles", "default...
default_target_struct_keys = ['data_runfiles', 'default_runfiles', 'files', 'files_to_run', 'label', 'output_group', 'output_groups'] def default_none(value, default): """ Returns |value| if it is not None, otherwise returns |default|. """ return value if value != None else default
class Transformers: @staticmethod def list2string(string_list: list, separator='\n') -> str: """ Turn list of objects into one string object. :param separator: :param string_list: :return: """ if len(string_list) > 0: return ''.join([f'{item}{s...
class Transformers: @staticmethod def list2string(string_list: list, separator='\n') -> str: """ Turn list of objects into one string object. :param separator: :param string_list: :return: """ if len(string_list) > 0: return ''.join([f'{item}{...
# -*- coding: utf-8 -*- VIDEO_RESOLUTIONS = ["highest", "high", "medium", "low"] def findnth(haystack, needle, n): """ Find the nth occurrence of one string in another """ parts = haystack.split(needle, n + 1) if len(parts) <= n + 1: return -1 return len(haystack) - len(parts[-1]) - l...
video_resolutions = ['highest', 'high', 'medium', 'low'] def findnth(haystack, needle, n): """ Find the nth occurrence of one string in another """ parts = haystack.split(needle, n + 1) if len(parts) <= n + 1: return -1 return len(haystack) - len(parts[-1]) - len(needle)
""" In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the mi...
""" In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the value 1 representing a fresh orange; the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the mi...
"Public providers, aspects and helpers that are shipped in the built-in rules_nodejs repository." load( "//nodejs/private/providers:declaration_info.bzl", _DeclarationInfo = "DeclarationInfo", _declaration_info = "declaration_info", ) load( "//nodejs/private/providers:js_providers.bzl", _JSModuleIn...
"""Public providers, aspects and helpers that are shipped in the built-in rules_nodejs repository.""" load('//nodejs/private/providers:declaration_info.bzl', _DeclarationInfo='DeclarationInfo', _declaration_info='declaration_info') load('//nodejs/private/providers:js_providers.bzl', _JSModuleInfo='JSModuleInfo', _js_mo...
def insertion_sort(A): for i in range(1,len(A)): key=A[i] j=i-1 while j>=0 and A[j]>key: A[j+1]=A[j] j-=1 A[j+1]=key return A
def insertion_sort(A): for i in range(1, len(A)): key = A[i] j = i - 1 while j >= 0 and A[j] > key: A[j + 1] = A[j] j -= 1 A[j + 1] = key return A
def test_min(prepared_tree_for_minimax): assert prepared_tree_for_minimax[0][0] == 2 assert prepared_tree_for_minimax[0][1] == 1 assert prepared_tree_for_minimax[0][2] == -1 def test_max(prepared_tree_for_minimax): assert prepared_tree_for_minimax[1][0] == 100 assert prepared_tree_for_minimax[1][1...
def test_min(prepared_tree_for_minimax): assert prepared_tree_for_minimax[0][0] == 2 assert prepared_tree_for_minimax[0][1] == 1 assert prepared_tree_for_minimax[0][2] == -1 def test_max(prepared_tree_for_minimax): assert prepared_tree_for_minimax[1][0] == 100 assert prepared_tree_for_minimax[1][1]...
id = [] val = [] soma, cont = 0, 0 while True: vid = int(input('Id: ')) if vid < 0: break vval = int(input('Valor a pagar: ')) id.append(vid) val.append(vval) cont += 1 soma += vval for i in range(cont): print(f'Id: {id[i]}\nValor: {val[i]}') print(f'Total: {soma}')
id = [] val = [] (soma, cont) = (0, 0) while True: vid = int(input('Id: ')) if vid < 0: break vval = int(input('Valor a pagar: ')) id.append(vid) val.append(vval) cont += 1 soma += vval for i in range(cont): print(f'Id: {id[i]}\nValor: {val[i]}') print(f'Total: {soma}')
## Set up SW Trigger # Create an instance of the Software Trigger Module (ziDAQRecorder class). trigger = daq.record() trigger_path = '/%s/demods/%d/sample' % (device, demod_index) triggernode = trigger_path + '.TrigAWGTrig1'#'.r' trigger.set('trigger/0/triggernode', triggernode) # Use an edge trigger. trigg...
trigger = daq.record() trigger_path = '/%s/demods/%d/sample' % (device, demod_index) triggernode = trigger_path + '.TrigAWGTrig1' trigger.set('trigger/0/triggernode', triggernode) trigger.set('trigger/0/type', 1) trigger.set('trigger/0/edge', 1) trigger_level = 0.5 * amplitude print('Setting trigger/0/level to {:.3f}.'...