content
stringlengths
7
1.05M
class A(object): def do_this(self): print('do_this() in A') class B(A): pass class C(A): def do_this(self): print('do_this() in C') class D(B, C): pass D_instance = D() D_instance.do_this() print(D.mro()) # Method resolution order
a, b = 0, 1 while b < 10: print(b) a, b = b, a + b # 1 # 1 # 2 # 3 # 5 # 8 a, b = 0, 1 while b < 1000: print(b, end='->') a, b = b, a + b # 1->1->2->3->5->8->13->21->34->55->89->144->233->377->610->987->%
class AutoScaleSettingVO: def __init__(self, mini_size=1, max_size=1, mem_exc=0, deploy_name = ""): self.miniSize = mini_size self.maxSize = max_size self.memExc = mem_exc self.deployName = deploy_name self.operationResult = ""
#Date: 031622 #Difficulty: Easy class Solution(object): def removeElement(self, nums, val): """ :type nums: List[int] :type val: int :rtype: int """ write=0 for read in range(len(nums)): if nums[read]!=val: nums[write]=nums[read] ...
# # PySNMP MIB module STN-ATM-VPN-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/STN-ATM-VPN-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 21:03:27 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27...
class MenuItem: # Definiskan method info def info(self): print('Tampilkan nama dan harga dari menu item') menu_item1 = MenuItem() menu_item1.name = 'Roti Lapis' menu_item1.price = 5 # Panggil method info dari menu_item1 menu_item1.info() menu_item2 = MenuItem() menu_item2.name = 'Kue Coklat' menu_i...
# Rodar script online # https://trinket.io/features/python3 a = int(input('Digite um número qualquer: ')) result = 0 # Verificando se p é primo while True: p = int(input('Digite um número primo: ')) cont = 0 for i in range(1, p + 1): if p % i == 0: cont += 1 if cont == 2: break else: print('{} não é ...
#!/user/bin/python '''Number of Inversions '''
class HideX(object): # def x(): # def fget(self): # return ~self.__x # def fset(self, x): # assert isinstance(x, int), 'x must be int' # self.__x = ~x # return locals() # x = property(**x()) @property def x(self): return ~self.__x @x.setter def x(self, x): assert isinstance(x, int), 'x must be...
""" The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return the number of distinct solutions to the n-queens puzzle. Example: Input: 4, Output: 2 Explanation: There are two distinct solutions to the 4-queens puzzle as shown belo...
#coding=utf-8 ''' Created on 2015-10-10 @author: Devuser ''' class HomeTaskPath(object): left_nav_template_path="home/home_left_nav.html" sub_nav_template_path="task/home_task_leftsub_nav.html" task_index_path="task/home_task_index.html" class HomeProjectPath(object): left_nav_template_path="home/ho...
#Link Class is given! class Link: """A linked list. >>> s = Link(1, Link(2, Link(3))) >>> s.first 1 >>> s.rest Link(2, Link(3)) """ empty = () def __init__(self, first, rest=empty): assert rest is Link.empty or isinstance(rest, Link) self.first = first self...
class Reccomandation: def __init__(self, input_text): self.text = input_text def __get__(self, name ): return self.name
""" https://leetcode.com/problems/count-primes/ """ class Solution: # @param {integer} n # @return {integer} def countPrimes(self, n): if n <=2: return 0 if n == 3: return 1 count = n-2 d = [True for i in xrange(n)] for i in...
__author__ = 'nickbortolotti' """ Parte 1 1.utilizar un arreglo que almacene 2 cadenas y 2 valores enteros 2.mostrar en pantalla el la ubicacion 1 mostrar desde el 0-2 mostrar del 2 en adelante mostrar del 1 en reversa mostrar el ultimo elemento del arreglo en reversa """
def error_output(number_of_parameters): """Write the optimized error values into the params file near the corresponding parameter identicator""" try: file2 = open("parameters", "r+") file2.seek(0) position2 = file2.tell() file = open("fort.13","r") ...
num_classes = 81 # model settings model = dict( type='SOLOv2', #pretrained='torchvision://resnet50', # The backbone weights will be overwritten when using load_from or resume_from. # https://github.com/open-mmlab/mmdetection/issues/7817#issuecomment-1108503826 backbone=dict( type='ResNet', ...
#!/usr/bin/env prey async def main(): word = input("Give me a word: ") await x(f"echo {word}")
class ToolConfig (): def __init__ (self): self.one = './data/onetwothree1.wav' self.two = './data/onetwothree8.wav' self.digits_path = './data/digits'
# # PySNMP MIB module SW-DES3x50-ACLMGMT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/SW-DES3x50-ACLMGMT-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:12:30 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (d...
""" Augment 3D images of a focal lesion with 3D rotation, flip, and translation. import_mhd: Prepare patches from lung CT scan images and annotations. (See readme.md - Installation for details.) datasets: Retrieve patches after augmentation for training. classify_patch: Demonstrate the use of dataset...
# Michael O'Regan 05/May/2019 # https://www.sanfoundry.com/python-program-implement-bucket-sort/ def bucketSort(alist): largest = max(alist) length = len(alist) size = largest/length buckets = [[] for _ in range(length)] for i in range(length): j = int(alist[i]/size) if j != lengt...
""" It is commonly said that one human year is equivalent to 7 dog years. However this simple conversion fails to recognize that dogs reach adulthood in approximately two years. As a result, some people believe that it is better to count each of the first two human years as 10.5 dog years, and then count each additiona...
divs = {} def sm(x): s = 0 for i in range(2,int(x**0.5)): if x%i == 0: s += i s += x/i if i*i == x: s -= i return s+1 for i in range(10001): divs[i] = sm(i) ans = 0 for i in range(10001): for j in range(10001): if divs[i] == j and divs[j] == i and i!=j: ans += i print(ans)
####################### # MaudeMiner Settings # ####################### # Database settings DATABASE_PATH = '/Users/tklovett/maude/' DATABASE_NAME = 'maude' # These setting control where the text files and zip files retrieved from the FDA website are stored DATA_PATH = '/Users/tklovett/maude/data/' ZIPS_PATH = DATA_P...
# https://leetcode.com/problems/convert-sorted-array-to-binary-search-tree/ # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def sortedArrayToBST(self, nums:...
class _LinearWithBias(Module): __parameters__ = ["weight", "bias", ] __buffers__ = [] weight : Tensor bias : Tensor training : bool
count = 0 current_group = set() with open('in', 'r') as f: for line in f.readlines(): l = line.strip() if len(l) == 0: # this is end of the last group count += len(current_group) current_group = set() else: # add answers to the current group ...
stim_positions = { "double": [ [(0.4584, 0.2575, 0.2038), (0.4612, 0.2690, -0.0283)], # 3d location [(0.4601, 0.1549, 0.1937), (0.4614, 0.1660, -0.0358)], ], "double_20070301": [ [(0.4538, 0.2740, 0.1994), (0.4565, 0.2939, -0.0531)], # top highy [(0.4516, 0.1642, 0.1872), (...
""" 026 Pig Latin takes the first consonant of a word, moves it to the end of the word and adds on an “ay”. If a word begins with a vowel you just add “way” to the end. For example, pig becomes igpay, banana becomes ananabay, and aadvark becomes aadvarkway. Create a program that will ask the user to enter a word and ch...
class Node(object): def __init__(self): super().__init__() self.__filename = '' self.__children = [] self.__line_number = 0 self.__column_number = 0 def get_children(self) -> list: return self.__children def add_child(self, child: 'Node') -> None: a...
"""TO BE EDITED. """ # from easyml import def test_foo(): assert 1 == 1
def binary_search(nums, target): low = 0 high = len(nums) - 1 while low <= high: mid = low + ((high - low) // 2) if nums[mid] > target: high = mid-1 elif nums[mid] < target: low = mid+1 else: return mid return -1 if __name__ == "__mai...
# # PySNMP MIB module ALVARION-USER-ACCOUNT-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALVARION-USER-ACCOUNT-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 17:06:37 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3....
class Solution: def superPow(self, a: int, b: List[int]) -> int: if (a % 1337 == 0): return 0 return pow(a, reduce(lambda x, y: x * 10 + y, b), 1337)
print("Hello, world!") x = "Hello World" print(x) y = 42 print(y)
def StringToDict(s): RES = dict() for e in set(s): RES[e] = 0 for e in s: RES[e] += 1 return RES
""" Master list of constants for logger Mostly logger keys, but some other constants as well. """ # loggerkey - header HEADER = "header" # loggerkey - timing info EPOCH_START = "epoch_start" EPOCH_STOP = "epoch_stop" RUN_START = "run_start" RUN_STOP = "run_stop" BATCH_START = "batch_start" BATCH_STOP = "batch_stop" ...
##################################################################### # Trabajando con Cadenas de Texto # ##################################################################### cadena = " Hola Mundo!! " print(cadena) print(cadena[10]) print(cadena[3:]) print(cadena[:10]) print(cade...
DO_RUN_BIAS_TEST=False DEBUG = False INPUT_CSV=False ROOT_FOLDER="/home/jupyter/forms-ocr" OUTPUT_FOLDER= ROOT_FOLDER + "/sample_images" GEN_FOLDER = OUTPUT_FOLDER + "/img" LOCALE = "en_GB" DUMMY_GENERATOR=0 FIELD_DICT_3FIELDS= {'Name':(0,0),'Tax':(0,0), 'Address':(0,0) } FIELD_DICT_7FIELDS= {'N...
data = { "en": { "no_permission": "You do not have permission to use this command!", "not_command_sender": "You are not the sender of that command!", "vote_message": "Thank you for voting for Doge Utilities!", "banned_message": "You are banned from using Doge Utilities!", "er...
class Student: studentLevel = 'first year computer science 2020/2021 session' studentCounter = 0 def __init__(self, thename, thematricno, thesex, thehostelname , theage,thecsc102examscore): self.name = thename self.matricno = thematricno self.sex = thesex self.hostelname = t...
# -*- coding: utf-8 -*- """ Created on Sun Apr 19 19:32:39 2020 @author: abcdk """ # 5 Data types # Int, Float, Boolean, String, Null
# success values # sql.h SQL_INVALID_HANDLE = -2 SQL_ERROR = -1 SQL_SUCCESS = 0 SQL_SUCCESS_WITH_INFO = 1 SQL_STILL_EXECUTING = 2 SQL_NEED_DATA = 99 SQL_NO_DATA_FOUND = 100 sql_errors = [SQL_ERROR, SQL_INVALID_HANDLE] # sqlext.h SQL_FETCH_NEXT = 0x01 SQL_FETCH_FIRST = 0x02 SQL_FETCH_LAST ...
class Solution: # @param A : list of integers # @return an integer def perfectPeak(self, A): n = len(A) left = [0] * n right = [0] * n left[0] = A[0] right[n-1] = A[n-1] for i in range(1, n) : left[i] = max(left[i-1], A[i]) for i in rang...
class Matrix: def __init__(self, matrix_string: str): # Split matrix_string into lines, split lines on whitespace and cast elements as integers. self.matrix = [[int(j) for j in i.split()] for i in matrix_string.splitlines()] def row(self, index: int) -> list[int]: return self.matrix[ind...
Colors = {'snow': ('255', '250', '250'), 'ghostwhite': ('248', '248', '255'), 'GhostWhite': ('248', '248', '255'), 'whitesmoke': ('245', '245', '245'), 'WhiteSmoke': ('245', '245', '245'), 'gainsboro': ('220', '220', '220'), 'floralwhite': ('255', '250', '240'), 'FloralWhite': ('255', '250', '240'), 'oldlace': ('253', ...
''' Faça um Programa que leia um vetor de 5 números inteiros e mostre-os. ''' lista=[] for numero in range(1,6): lista.append(int(input("Digite um número: "))) print(lista)
class Student: def __init__(self, id: str, name: str) -> None: self.id = id self.name = name class Course: def __init__(self, id: str, name: str, hours: int, grades = None) -> None: self.id = id self.name = name self.hours = hours self.grades = grades or {} ...
class WebServerDefinitions: name = None root = None template = None https = False default_template = 'laravel' def __init__(self, name, root, template=None, https=False): self.name = name self.root = root self.https = https if not template: template ...
class GraphReprBase(object): @staticmethod def read_from_file(input_file): raise NotImplemented()
STATUS_MAP = { 'RECEIVED_UNREAD': b'0', 'RECEIVED_READ': b'1', 'STORED_UNSENT': b'2', 'STORED_SENT': b'3', 'ALL': b'4' } STATUS_MAP_R = { b'0': 'RECEIVED_UNREAD', b'1': 'RECEIVED_READ', b'2': 'STORED_UNSENT', b'3': 'STORED_SENT', b'4': 'ALL' } DELETE_FLAG = { 'ALL_READ': b...
def collatz(n, count): if n == 1: return count else: count = count + 1 if n % 2 == 0: n = n /2 else: n = 3 * n + 1 return collatz(n, count) max_collatz = 1 iteration = 1 for i in range(1, 1000000): count = 1 contesting = collatz(i, 1) ...
# -*- coding: utf-8 -*- """ Actually, i want to design a django model-like with fields and inline validators, of course time is against me, so i wrote this; close enough (not really) xD If 'f' is None means that validator generate the content of the field """ MAIN_FIELDS = [ { 'f': None, # From JSO...
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Functions allow variable-length argument lists def main(): kitten('meow', 'grrr', 'purr') # We treat it as a sequence, actually a tuple def kitten(*args): # It's denoted as *args. args is the conventional name if len(args): # If the length of ar...
for i in range(5): for j in range(5): if i==j: print('#',end='') else: print("+",end='') print("")
DATA_URL = 'http://archive.ics.uci.edu/ml/machine-learning-databases/auto-mpg/auto-mpg.data' DATA_COLUMNS = ['MPG', 'Cylinders', 'Displacement', 'Horsepower', 'Weight', 'Acceleration', 'Model Year', 'Origin'] NORMALIZE = False TARGET_VARIABLE = 'MPG' # FEATURES_TO_USE = [ 'Cylinders', 'Displacement', 'H...
# # @lc app=leetcode id=286 lang=python3 # # [286] Walls and Gates # # https://leetcode.com/problems/walls-and-gates/description/ # # algorithms # Medium (53.35%) # Likes: 1050 # Dislikes: 15 # Total Accepted: 113.7K # Total Submissions: 212.9K # Testcase Example: '[[2147483647,-1,0,2147483647],[2147483647,21474...
# question : https://quera.ir/problemset/contest/8901 x_n = input().split(' ') x = x_n[1] n = int(x_n[0]) default_value = { 'L': 0, 'M': 0, 'R': 0, } movements = [] for one_input in range(n): movements.append(input().split(' ')) default_value[x] = 1 for one_movement in movements: temp = default_va...
#!/usr/bin/env python3 def get_vertices(wire): x = y = steps = 0 vertices = [(x, y, 0)] for edge in wire: length = int(edge[1:]) steps += length if edge[0] == "R": x += length if edge[0] == "L": x -= length if edge[0] == "U": ...
# Ex: 051 - Desenvolva um programa que leia o primeiro termo e a razão de uma # PA. No final. mostre os 10 primeiros termos dessa progressão. print(''' -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- --Seja bem-vindo! --Exercício 051 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- ''') print('--Progressão Aritmética\n' '--...
dim=10.0 eta=0.5 steps=100 #must be integer (no decimal point) rneighb=eta
"""Константы для jim протокола, настройки""" ACTION = "action" # тип сообщения между клиентом и сервером TIME = "time" # время запроса DATA = "data" # данные пересылаемые в сообщении (вложенный словарь) TOKEN = "token" # токен RESPONSE = "response" # код ответа # Значения (Типы данных, передаваемых в поле data) ...
# automatically generated by the FlatBuffers compiler, do not modify # namespace: apemodefb class EAnimCurvePropertyFb(object): LclTranslation = 0 RotationOffset = 1 RotationPivot = 2 PreRotation = 3 PostRotation = 4 LclRotation = 5 ScalingOffset = 6 ScalingPivot = 7 LclScaling = 8...
__author__ = 'tylin' # from .bleu import Bleu # # __all__ = ['Bleu']
# General ES Constants COUNT = 'count' CREATE = 'create' DOCS = 'docs' FIELD = 'field' FIELDS = 'fields' HITS = 'hits' ID = '_id' INDEX = 'index' INDEX_NAME = 'index_name' ITEMS = 'items' KILOMETERS = 'km' MAPPING_DYNAMIC = 'dynamic' MAPPING_MULTI_FIELD = 'multi_field' MAPPING_NULL_VALUE = 'null_value' MILES = 'mi' OK ...
load("//third_party:common.bzl", "err_out", "execute") _LLVM_BINARIES = [ "clang", "clang-cpp", "ld.lld", "llvm-ar", "llvm-as", "llvm-nm", "llvm-objcopy", "llvm-objdump", "llvm-profdata", "llvm-dwp", "llvm-ranlib", "llvm-readelf", "llvm-strip", "llvm-symbolizer",...
valid=False def marray(arr,*args,**kwargs): return arr def unitsDict(*args,**kwargs): return None def varMeta(*args,**kwargs): return None
{ 'OS-EXT-STS:task_state': None, 'addresses': {'int-net': [ {'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:5d:9e:22', 'version': 4, 'addr': '192.168.1.8', 'OS-EXT-IPS:type': 'fixed' }, {'OS-EXT-IPS-MAC:mac_addr': 'fa:16:3e:5d:9e:22', 'version': 4, 'addr': '192.168.166.23', 'O...
# 打印输出直角在左下角的等腰三角形和长方形 def put_star(n): """连续输出n个*""" for _ in range(n): print('*', end='') print('直角在左下角的等腰三角形') n = int(input('腰长:')) for i in range(1, n + 1): put_star(i) print() print('长方形') h = int(input('宽:')) w = int(input('长:')) for ...
with open('input.txt') as f: lines = f.readlines() count = 0 curDepth = 0 for line in lines: newDepth = int(line) if curDepth != 0: if newDepth > curDepth: count += 1 curDepth = newDepth print(count)
def add(x, y=3): print(x + y) add(5) # 8 add(5, 8) # 13 add(y=3) # Error, missing x # -- Order of default parameters -- # def add(x=5, y): # Not OK, default parameters must go after non-default # print(x + y) # -- Usually don't use variables as default value -- default_y = 3 def add(x, y=default_y):...
''' Filippo Aleotti filippo.aleotti2@unibo.it 29 November 2019 I PROFESSIONAL MASTER'S PROGRAM, II LEVEL "SIMUR", Imola 2019 Given a list of integer, store the frequency of each value in a dict, where the key is the value. ''' def are_equals(dict1, dict2): ''' check if two dict are equal. Both the dicts...
#!/usr/bin/env python print("Hello from cx_Freeze Advanced #1\n") module = __import__("testfreeze_1")
# Create a function that takes an integer as an argument and returns "Even" for even numbers or "Odd" for odd numbers. def even_or_odd(number): if number % 2 == 0: return "Even" else: return "Odd" assert (even_or_odd(2)) == "Even", "Debe devolver Even" assert (even_or_odd(0)) == "Even", "Debe...
class Solution: def isAlienSorted(self, words, order): """ :type words: List[str] :type order: str :rtype: bool """ order = {alpha: index for index, alpha in enumerate(order)} for i in range(len(words) - 1): flag = True for j in range(m...
class Producto: """Producto de venta""" def __init__(self, nombre, desc, precio): self.nombre = nombre self.descripcion = desc self.precio = precio # Es una salida para la muestra de la info def formateo_textual(self): textoFinal = "" for atr in [self.nombre...
n = int(input()) L = list(map(int,input().split())) A = list(set(L[:])) d = {} A.sort() for i in range(len(A)): d[A[i]] = i for i in L: print(d[i],end = " ")
""" Jour de fete - Django_JDF Convertion de nombres en toutes lettres @date: 2014/09/12 @copyright: 2014 by Luc LEGER <artefacts.lle@gmail.com> @license: MIT """ class numbers : def __init__(self) : self.schu=["","UN ","DEUX ","TROIS ","QUATRE ","CINQ ","SIX ","SEPT ","HUIT "...
# Url https://leetcode.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/ class Solution: def subtractProductAndSum(self, n): prod, sum_n, curr = 1, 0, 0 while n != 0: curr = n % 10 prod = prod * curr sum_n = sum_n + curr n = n//10 ...
# Work out the first ten digits of the sum of N 50 digit numbers. total = 0 for x in range(int(input())): total += int(input().rstrip()) print(str(total)[:10])
__author__ = "Sylvain Dangin" __licence__ = "Apache 2.0" __version__ = "1.0" __maintainer__ = "Sylvain Dangin" __email__ = "sylvain.dangin@gmail.com" __status__ = "Development" class concat(): def action(input_data, params, current_row, current_index): """Concat multiple columns in the cell. :param...
""" This module is for generating a Markov chain order two from a text. """ def generate_markov_chain(tweet_array): """ Input assumes text is an array of tweets, each tweet with words separated by spaces with no new lines. This requires some changes to most transcripts ahead of time. Output will be a dictionary wi...
#!/usr/bin/env python # -*- coding:utf-8 -*- # Author: class TaskName(): Classify_Task = "classify" Detect2d_Task = "detect2d" Segment_Task = "segment" PC_Classify_Task = "pc_classify"
class TheEquation: def leastSum(self, X, Y, P): m = 2*P for i in xrange(1, P+1): for j in xrange(1, P+1): if (X*i + Y*j)%P == 0: m = min(m, i+j) return m
#!/usr/bin/env python3 """ Top students """ def top_students(mongo_collection: object): """function that returns all students sorted by average score""" top = mongo_collection.aggregate([ { "$project": { "name": "$name", "averageScore": {"$avg": "$topics.sc...
""" Map: Aplica una función a dcada elemento de una lista iterable, dvolviendo otra lista. """ def elevar_cuadrado(num): # return num * num return pow(num, 2) # numeros = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] numeros = list(range(1, 11)) # Del 1 al 10 print(numeros) numeros_elevados = list(map(elevar_cuadrado, ...
#!/usr/bin/env python3 class FakeSerial: def __init__(self): self._last_written_data = None self._response = None self.read_data = [] @property def last_written_data(self): return self._last_written_data @property def response(self): return self._response ...
# coding=utf-8 # Definition for singly-linked list. class ListNode(object): def __init__(self, x, next=None): self.val = x self.next = next class DoubleNode(object): def __init__(self, key, val, pre=None, next=None): self.key = key self.val = val self.pre = pre ...
seen = [] # Prduces the length of the longest Substring # thats comprised of just unique characters def max_diff(string): seen = [0]*256 curr_start = 0 max_start = 0 unique = 0 max_unique = 0 for n,i in enumerate(string): if seen[assn_num(i)] == 0: unique += 1 ...
# package org.apache.helix.messaging.handling #from org.apache.helix.messaging.handling import * #from java.util import HashMap #from java.util import Map class HelixTaskResult: def __init__(self): self._success = False self._message = "" self._taskResultMap = {} self._interrupte...
def _test_sources_aspect_impl(target, ctx): result = depset() if hasattr(ctx.rule.attr, "tags") and "NODE_MODULE_MARKER" in ctx.rule.attr.tags: return struct(node_test_sources=result) if hasattr(ctx.rule.attr, "deps"): for dep in ctx.rule.attr.deps: if hasattr(dep, "node_test_s...
def is_prime(n): if n > 1: for i in range(2, n // 2 + 1): if (n % i) == 0: return False else: return True else: return False def fibonacci(n): n1, n2 = 1, 1 count = 0 if n == 1: print(n1) else: while count < n: ...
###################################################################################### # Date: 2016/July/11 # # Module: module_2DScatter.py # # VERSION: 0.9 # # AUTHOR: Matt Thoburn (mthoburn@ufl.edu); # edited by Miguel A. Ibarra-Arellano(miguelib@ufl.edu) # # DESCRIPTION: This module contains a primary met...
class Solution: def maxProfit(self, prices: List[int]) -> int: running_min = prices[0] best_trans1 = [0] for p in prices[1:]: if p < running_min: running_min = p best_trans1.append(max(p - running_min, best_trans1[-1])) running_max = prices[...
# -*- coding: utf-8 -*- """ Created on Wed Jan 30 16:46:12 2019 @author: Alexandre Janin """ """Exceptions raised by pypStag""" class PypStagError(Exception): """ Main class for all pypStag """ pass class PackageWarning(PypStagError): """Raised when a precise package is needed""" def __init__(s...
version = "dev 0.0" running = False def init(): global running if not running: print("JFUtils-python \"" + version + "\" by jonnelafin") running = True
"""Utility functions not closely tied to other spec_tools types.""" # Copyright (c) 2018-2019 Collabora, Ltd. # Copyright (c) 2013-2019 The Khronos Group Inc. # # 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...
class FiniteAutomataState: def __init__(self, structure): self.states = [] self.alphabet = [] self.initial = [] self.finals = [] self.transitions = {} self._file = open(structure, "r") self._load() # print(self.validate()) def _load(self): ...
#!/usr/bin/python compteur = 0 i,j = 3,1 terrain = [] fichier = open('day3_input.txt') for l in fichier: terrain.append(fichier.readline().strip('\n')) nblig = len(terrain) nbcol = len(terrain[0]) print('nblig : %s / nbcol : %s' % (nblig,nbcol)) for f in terrain: print(f) while j<nblig: #print(i,j,terra...