content
stringlengths
7
1.05M
class Solution: def removeDuplicates(self, nums): """ :type nums: List[int] :rtype: int """ i = 0 while i < len(nums)-1: ##此处索引一直更新所以不会超限 if nums[i] == nums[i+1]: nums.remove(nums[i]) else: i += 1 return ...
CURRENT_NEWS_API_KEY = '' # Replace with your news.org API keys news = { 'api_key': '', 'base_everything_url': 'https://newsapi.org/v2/everything' }
''' Given a square matrix of N rows and columns, find out whether it is symmetric or not. >>Input Format: The first line of the input contains an integer number n which represents the number of rows and the number of columns. From the second line, take n lines input with each line containing n integer elements with ea...
#在0的位置进行移动到target的位置,每次可以选择向左或者向右,第n次移动n步,问最短移动到target的次数 def reachNumber(target): """ :param target: int :return: number """ t = abs(target) k = 0 s = 0 while s<t: k+=1 s+=k dt = s-t if dt%2==0: return k else: if k%2==0: return k+...
ENV='development' DEBUG=True SQLALCHEMY_DATABASE_URI='sqlite:///data_base.db' #SQLALCHEMY_ECHO=True SQLALCHEMY_TRACK_MODIFICATIONS=False SCHEDULER_API_ENABLED = True
# Exercise number 2 - Python WorkOut # Author: Barrios Ramirez Luis Fernando # Language: Python3 3.8.2 64-bit def my_sum(*numbers): # The "splat" operator is used when we need an arbitrary amount of arguments output = numbers[0] for i in numbers[1:]: # It returns a tuple output += i return output...
n = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'B', 'H'] i = sorted(n.index(x) for x in input().split()) c = (i[1] - i[0], i[2] - i[1]) if c in ((4, 3), (3, 5), (5, 4)): print('major') elif c in ((3, 4), (4, 5), (5, 3)): print('minor') else: print('strange')
template=''' def __init__(self, base_space, **kwargs): super().__init__() # Time scheme is set from Model.__init__() # Set base space (manifold) #------------------------------ assert base_space.dimension == len(self.coordinates), \ "...
class Solution(object): def isBoomerang(self, points): """ :type points: List[List[int]] :rtype: bool """ p1, p2, p3 = points[0], points[1], points[2] if p2[0] != p1[0]: a = (p2[1] - p1[1]) / float(p2[0] - p1[0]) b = p1[1] - a * p1[0] ...
aPL = 4.412E-10 nPL = 5.934 G13 = 5290. enerPlas = aPL/G13*90.65**(nPL + 1.)*nPL/(nPL + 1.)*0.2**3 enerFrac = 0.788*0.2*0.2 enerTotal = enerPlas+enerFrac parameters = { "results": [ { "type": "max", "step": "Step-7", "identifier": { "symbo...
x = int(input("숫자?: ")) i = 2 while i == 2: if x%i == 0: print(i, end=' ') x = x / i continue else: i += 1 while i <= x: if x%i == 0: print(i, end=' ') x = x / i continue i += 2
# -*- coding: utf-8 -*- # Scrapy settings for jn_scraper project # # For simplicity, this file contains only settings considered important or # commonly used. You can find more settings consulting the documentation: # # https://doc.scrapy.org/en/latest/topics/settings.html # https://doc.scrapy.org/en/latest/to...
def rounding(numbers): num = [round(float(x)) for x in numbers] return num print(rounding(input().split(" ")))
expected_output={ 'interface': { 'HundredGigE2/0/1': { 'if_id': '0x3', 'inst': 0, 'asic': 0, 'core': 5, 'ifg_id': 1, 'port': 0, 'subport': 0, 'mac': 1, 'last_serdes': 1, 'cntx': 0, 'lpn': 1, 'gpn': 769, 'type': 'NIF', 'active': 'Y...
""" In a town, there are n people labeled from 1 to n. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is exactly one person that satisfies properties 1 an...
# DOBRO, TRIPLO E RAIZ QUADRADA """Lê um número e exibe seu dobro, seu triplo e sua raiz quadrada""" n = float(input('Digite um número: _ ')) print('O dobro de {} é {:.2f}'.format(n, n * 2)) print('O triplo de {} é {:.2f}'.format(n, n * 3)) print('A raiz quadrada de {} é {:.2f}'.format(n, n ** 0.5))
class Solution: def PredictTheWinner(self, nums) -> bool: def score(start, end, player): # player == 1 表示玩家1,player == -1 表示玩家2 # 返回当前玩家在当前状态下可以得到的最优分数(用玩家1-玩家2的差值表示)。 if start == end: return nums[start] * player left_score = nums[start] * play...
n = 0 totn = 0 soma = 0 while n != 999: soma = soma + n n = int(input('Digite um número: ')) if n == 999: break totn = totn + 1 print(f'total de numeros: {totn}') print(f'soma: {soma}')
{'73c02eb6f6524b1bab84ccaa733260d2': {'cmd': '$ cat ' '/home/gk/repos/terminal_markdown_viewer/src/mdv/plugins/config.py', 'res': '# fmt:off\n' "environ_prefix = 'MDV_'\n" ...
class Hero: def __init__(self, nama, attack,health,defense): self.name = nama self.attack = attack self.health = health self.defense = defense
def compress(string): counter = 1 result = [] for i in range(len(string)): if not (i + 1) == len(string) and string[i] == string[i + 1]: counter += 1 else: result.append(string[i] + str(counter)) counter = 1 final = "".join(result) if len(string...
__project__ = "nerblackbox" __author__ = "Felix Stollenwerk" __version__ = "0.0.13" __license__ = "Apache 2.0"
s=input() s=s.split(" ") n=int(s[0]) k=int(s[1]) m=n//2 if n%2==1: m+=1 if k<=m: print(2*k-1) else: k=k-m print(2*k)
class ImproperlyConfigured(Exception): """ Raised in the event ``operations-api`` has not been properly configured """ pass class HTTPError(Exception): """ Raised in the event ``operations-api`` was not able to get data from remote server """ pass
def merge(A, n1i, n2j): for k in range(len(A)): if(len(n2j) == 0 and len(n1i) != 0): A[k] = n1i.pop(0); elif(len(n1i) == 0 and len(n2j) != 0): A[k] = n2j.pop(0); else: if(n1i[0] >= n2j[0]): A[k] = n1i.pop(0); ...
class Solution: d = { 'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000, 'IV': 4, 'IX': 9, 'XL': 40, 'XC': 90, 'CD': 400, 'CM': 900 } def romanToInt(self, s): n,i = 0,0 whil...
def between_markers(text: str, begin: str, end: str) -> str: """ returns substring between two given markers """ return ('' if len(text.split(begin)[0]) > len(text.split(end)[0]) and begin in text and end in text else text.split(begin)[-1].split(end)[0] if begin i...
class Person: def __init__(self, fname, lname): self.fname = fname self.lname = lname def __repr__(self): return f'{self.fname} {self.lname}' p1 = Person('John', 'Smith') class Student(Person): pass if __name__ == '__main__': s = Student('Tom', 'Adams') print(s) p...
# Solution to exercise PermMissingElem # http://www.codility.com/train/ def solution(A): N = len(A) # The array with the missing entry added should sum to (N+2)(N+1)/2 # so the missing entry can be determined by subtracting the sum of # the entries of A missing_element = (N+2)*(N+1)/2 - sum(A)...
with open("input.txt") as f: lines = f.readlines() S = lines.pop(0).strip() lines.pop(0) rules = {} for r in lines: s = r.strip().split(" -> ") rules[s[0]] = s[1] for n in range(10): S = S[0] + "".join(list(map(lambda x,y: rules[x+y] + y, S[0:-1], S[1:]))) # Histogram f = {} for c in S: ...
class dataManager(): """ This class manage all data about scores and teams """ def __init__(self): """ Constructor """ self.choix = 0 self.nameBlueTeam = "" self.nameGreyTeam = "" self.nameBlackTeam = ""
""" A Libraray to initilize the avaiable modules and data structures """
class Solution: def countArrangement(self, n: int) -> int: state = '1' * n # dp[state] means number of targ arrangement # easily dp[state] = sum(dp[possible_next_state]) dp = {} dp['0'*n] = 1 def dfs(state_now, index): # basic if state_now in ...
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"AlreadyImportedError": "00_core.ipynb", "InvalidFilePath": "00_core.ipynb", "InvalidFolderPath": "00_core.ipynb", "InvalidFileExtension": "00_core.ipynb", "Pdf": "00_core....
class Solution: def maxPower(self, s: str) -> int: ans = cur = 0 prev = '' for c in s: if c == prev: cur += 1 else: cur = 1 prev = c if cur > ans: ans = cur return ans
"""AyudaEnPython: https://www.facebook.com/groups/ayudapython """ suma = 0 # si son 100 personas, se cambia 10 por 100 (dentro de range) for _ in range(10): peso = float(input("Ingresar peso: ")) suma += peso print(f"Peso acumulado {suma}")
class CommandError(Exception): def __init__(self, msg): self.msg = msg class SilentError(Exception): # log and drop, don't reveal details to caller. The timing difference is # ok. pass class ReplayError(Exception): pass class WrongVerfkeyError(Exception): pass class BadSignatureErro...
# For Capstone Engine. AUTO-GENERATED FILE, DO NOT EDIT [x86_const.py] X86_REG_INVALID = 0 X86_REG_AH = 1 X86_REG_AL = 2 X86_REG_AX = 3 X86_REG_BH = 4 X86_REG_BL = 5 X86_REG_BP = 6 X86_REG_BPL = 7 X86_REG_BX = 8 X86_REG_CH = 9 X86_REG_CL = 10 X86_REG_CS = 11 X86_REG_CX = 12 X86_REG_DH = 13 X86_REG_DI = 14 X86_REG_DIL ...
""" Taller 2.2 Espacios de Color # Tu nombre aquí Mayo xx-XX """ # Definición de Funciones (Dividir) #====================================================================== # E S P A C I O P R E _ _ C O N F I G U R A D O # ===================================================================== def c...
n = int(input()) d = [] for i in range(n): d.append(input()) # [d1, d2, d3, ..., dN] a = [int(m) for m in d]#int型に直す ans = 0 for i in range(n): if i == n - 1: ans += a[i] // 2 else: ans += a[i] // 2 ans += (a[i + 1] + a[i] % 2) // 2 if a[i + 1] > 0: a[i + 1] = a[i...
class FileParser: def __init__(self, filepath): self.filepath = filepath def GetNonEmptyLinesAsList(self): with open(self.filepath, "r") as f: return [line for line in f.readlines() if line and line != "\n"]
#Altere os exercicios e armazene em um vetor as idades. a=int(input("Digite quantas vezes vc quer informar a idade")) i=0 n=[] for i in range(a): n.append(int(input("Digite uma idade"))) i=i+1 print (n)
# -*- coding: utf-8 -*- """ Settings for the game that can be modified. """ __author__ = "Jakrin Juangbhanich" __email__ = "juangbhanich.k@gmail.com" N_HINT_TOKENS_MAX = 8 N_FUSE_TOKENS_MAX = 3 N_PLAYERS = 4 N_SIMULATIONS = 1 CARD_DECK_DISTRIBUTION = [1, 1, 1, 2, 2, 3, 3, 4, 4, 5]
num = int(input("Enter Any Number : ")) if num % 2 == 1: print(num, " is odd!") elif num % 2 == 0: print(num, " is even!") else: print("Error")
def conference_picker(cities_visited, cities_offered): for city in cities_offered: if city not in cities_visited: return city return 'No worthwhile conferences this year!'
#!/usr/bin/env python """ @package package_generator_template @file functions.py @author Anthony Remazeilles @brief List of aditional functions that can be used in the template Copyright (C) 2018 Tecnalia Research and Innovation Distributed under the Apache 2.0 license. """ def get_package_type(context): """extr...
# -*- coding: utf-8 -*- # # Automatically generated from unicode.xml by gen_xml_dic.py # uni2latex = { 0x0023: '\\#', 0x0024: '\\textdollar', 0x0025: '\\%', 0x0026: '\\&', 0x0027: '\\textquotesingle', 0x002A: '\\ast', 0x005C: '\\textbackslash', 0x005E: '\\^{}', 0x005F: '\\_', 0x0060: '\\textasciigrave', 0x007B: '\\lbr...
n1 = int(input('Enter number 1: ')) n2 = int(input('Enter number 2: ')) n3 = int(input('Enter number 3: ')) menor = n1 if n2 < n1 and n2 < n3: menor = n2 if n3 < n1 and n3 < n2: menor = n3 maior = n1 if n2 > n1 and n2 > n3: maior = n2 if n3 > n1 and n3 > n2: maior = n3 print("Menor e {}".format(menor)) print...
# ********************************* # ****** SECTION 1 - CLASSES ****** # ********************************* # A "Class" is like a blueprint for an object # Objects can be many different things # In a grade tracking program objects might be: Course, Period, Teacher, Student, Gradable Assignment, Comment, Etc. # In Mari...
_base_ = [ # './_base_/models/segformer.py', '../configs/_base_/datasets/mapillary.py', '../configs/_base_/default_runtime.py', './_base_/schedules/schedule_1600k_adamw.py' ] norm_cfg = dict(type='BN', requires_grad=True) backbone_norm_cfg = dict(type='LN', requires_grad=True) model = dict( type='E...
""" https://leetcode.com/problems/average-of-levels-in-binary-tree/ Given a non-empty binary tree, return the average value of the nodes on each level in the form of an array. Example 1: Input: 3 / \ 9 20 / \ 15 7 Output: [3, 14.5, 11] Explanation: The average value of nodes on level 0 is 3, on lev...
M1, D1 = [int(x) for x in input().split()] M2, D2 = [int(x) for x in input().split()] if M1 != M2: print(1) else: print(0)
def start_streaming_dataframe(): "Start a Spark Streaming DataFrame from a Kafka Input source" schema = StructType( [StructField(f["name"], f["type"], True) for f in field_metadata] ) kafka_options = { "kafka.ssl.protocol":"TLSv1.2", "kafka.ssl.enabled.protocols":"TLSv1.2", ...
{ 'targets': [ { 'target_name': 'rdpcred', 'conditions': [ [ 'OS=="win"', { 'sources': [ 'rdpcred.cc' ], 'msvs_settings': { 'VCLinkerTool': { 'AdditionalDependencies': [ 'Crypt32.lib' ] } } } ] ] } ] }
# Unicode symbol in string: print("Ѣ") # Using the character name: print("\N{Cyrillic Capital Letter Yat}") # Using a 16-bit hex value code point: print("\u0462") # Using a 32-bit hex value code point: print("\U00000462")
class Fibo(object): """docstring for Fibo""" def __init__(self): self.memo = [] def fibonacci(self, n, debug=False): if debug: print(self.memo) if self.memo[n] != 0: return self.memo[n] if n==1 or n==2: self.memo[n] = 1 el...
""" 0944. Delete Columns to Make Sorted Easy We are given an array A of N lowercase letter strings, all of the same length. Now, we may choose any set of deletion indices, and for each string, we delete all the characters in those indices. For example, if we have an array A = ["abcdef","uvwxyz"] and deletion indices...
class Solution: def connect(self, root: 'Optional[Node]') -> 'Optional[Node]': if not root: return d = collections.deque() d.append(root) while d: node = d.popleft() if node.left and node.right: node.left....
pro = 1 tar = 1 cur = 1 pos = 1 i = 1 while i < 8 : lcur = list(str(cur)) if len(lcur) > tar - pos: pro *= int(lcur[tar-pos]) i += 1 tar *= 10 pos += len(lcur) cur += 1 print(pro)
n = int(input()) for _ in range(n): store = int(input()) loc = list(map(int, input().split())) dist = 2 * (max(loc) - min(loc)) print(dist)
# Given head which is a reference node to a singly-linked list. # The value of each node in the linked list is either 0 or 1. # The linked list holds the binary representation of a number. # Return the decimal value of the number in the linked list. # Example 1: # Input: head = [1,0,1] # Output: 5 # Explanation: (10...
graph_file_name="/home/cluster_share/graph/soc-LiveJournal1_notmap.txt" out_put_file_name='/home/amax/Graph_json/livejournal_not_mapped_json' graph_file = open(graph_file_name) output_file = open(out_put_file_name, 'w') edge = dict() for line in graph_file: #line = line[:-2] res = line.split() #print(res...
""" Melwin memberships ================== Connects the melwin code for membership with human readable description "_id" : ObjectId("54970947a01ed2381196c9f5"), "name" : "Familie Medlemsskap", "id" : "FAM" """ _schema = { 'id': {'type': 'string', 'r...
class ParkingLot(object): def __init__(self, commands: str, first_ticket_number: int = 5000, parking_lot_size: int = 10): # Counter set to 5k by default. self.counter = first_ticket_number self.parking_lot_size = parking_lot_size # Save as a dictionary. Keys will serve as the parki...
text = input() for i in range(len(text)): if text[i] == ":": print(text[i] + text[i + 1])
class ExternalFileUtils(object): """ A utility class containing functions related to external file references. """ @staticmethod def GetAllExternalFileReferences(aDoc): """ GetAllExternalFileReferences(aDoc: Document) -> ICollection[ElementId] Gets the ids of all elements which are external file r...
DEBUG = True SERVE_MEDIA = DEBUG TEMPLATE_DEBUG = DEBUG EMAIL_DEBUG = DEBUG THUMBNAIL_DEBUG = DEBUG DEBUG_PROPAGATE_EXCEPTIONS = False # DATABASE_ENGINE = 'postgresql_psycopg2' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'. # DATABASE_HOST = '192.168.0.2' # Set to empty s...
# Example of Iterator Design Pattern def count_to(count): numbers = ["one", "two", "three", "four", "five"] for number in numbers[:count]: yield number count_to_two = count_to(2) count_to_five = count_to(5) for count in [count_to_two, count_to_five]: for number in count: print(number, e...
"""AoC Day 10""" pairs = ( "{", "}", "[", "]", "<", ">", "(", ")", ) openings = pairs[0::2] closings = pairs[1::2] def compose(*functions): def inner(arg): for f in reversed(functions): arg = f(arg) return arg return inner def find_corrupted(line...
n1 = int(input('Número 1: ')) n2 = int(input('Número 2: ')) n3 = int(input('Número 3: ')) if n1 > n2: m = n1 else: m = n2 if n3 > m: m = n3 print('Maior: {}'.format(m))
class Layout: def __init__(self, keyboard): if keyboard == "azerty": self.up = 'Z' self.down = 'S' self.left = 'Q' self.right = 'D' self.ok = 'C' self.no = 'K' self.drop = 'L' self.change = 'P' self...
# Factorial program with memoization using decorators. # Memoization is a technique of recording the intermediate results so that it can be used to avoid repeated calculations and speed up the programs. # memoization can be done with the help of function decorators. def Memoize(func): history={} def wr...
NUM, IMG_SIZE, FACE = 8, 720, False def config(): return None config.expName = None config.checkpoint_dir = None config.train = lambda: None config.train.batch_size = 4 config.train.lr = 0.001 config.train.decay = 0.001 config.train.epochs = 10 config.latent_code_garms_sz = 1024 config.PCA_ = 35 co...
# -*- coding: utf-8 -*- def main(): n = int(input()) b = [0 for _ in range(n)] for i in range(n): ai = int(input()) ai -= 1 b[ai] += 1 y = 0 x = 0 for index, bi in enumerate(b, 1): if bi == 0: x = index elif bi == 2: ...
class VoteBreakdownTotals: def __init__(self, headers: list[str]): self.__headers = headers self.__failures = {} self.__current_row = 0 votes = "votes" if votes in self.__headers: self.__votes_index = self.__headers.index(votes) else: self.__v...
print('=' * 20) print('{:^20}'.format('CAIXA ELETRÔNICO')) print('=' * 20) print('O caixa apresenta cédulas de R$50, R$20, R$10 e R$1.') ced = 50 totced = 0 valor = int(input('Qual valor você deseja sacar? R$ ')) total = valor while True: if total >= ced: total -= ced totced += 1 else: i...
# 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 rob(self, root: Optional[TreeNode]) -> int: """ subproblems: 1. rob...
def splitCols(saleRow): '''this function will split a string with '. Some columns are quoted with "". So we need to handle it''' saleRow = saleRow.split(',') result = [] flag = True # if flag is false, the current i is within a pair of " for i in range(len(saleRow)): if flag: ...
# # PySNMP MIB module H3C-OBJECT-INFO-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/H3C-OBJECT-INFO-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 19:10:08 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default...
# Most football fans love it for the goals and excitement. Well, this problem does not. # You are up to handle the referee's little notebook and count the players who were sent off for fouls and misbehavior. # The rules: Two teams, named "A" and "B" have 11 players each. The players on each team are numbered from 1 to ...
K, X = tuple(map(int, input().split())) start = X - K + 1 end = X + K print(*range(start, end))
# -*- coding: utf-8 -*- config = { "consumer_key": "VALUE", "consumer_secret": "VALUE", "access_token": "VALUE", "access_token_secret": "VALUE", }
class Solution: # @param {integer[]} nums # @return {integer[][]} def permuteUnique(self, nums): if len(nums) == 0: return nums if len(nums) == 1: return [nums] res = [] bag = set() for i in range(len(nums)): if nums[i] not in bag:...
def benjHochFDR(pVals,pValColumn=1): """ pVals = 2D list(hypothesis,p-value) hypothesis could = geneName tested for enrichment pValColumn = integer of column index containing the p-value. returns _ALL_ items passed to it with no filtering at the moment. """ assert type(pValColumn) ==...
{ "targets": [ { "target_name": "posix", "sources": [ "src/posix.cc" ] } ] }
DATABASE_NAME = "glass_rooms.sqlite" STARTING_ROOM_NUMBER = 1 ENDING_ROOM_NUMBER = 9 TABLE_NAME_HEADER = "Room_" TABLE_NAME = "Bookings" URL_HEADER = "https://www.scss.tcd.ie/cgi-bin/webcal/sgmr/sgmr" URL_ENDER = ".pl" URL_BOOKING = ".request" # Regex Constants # DATE_HEADER_REGEX: regex to match '4 Nov 2015 (Wednesda...
class TagsArgument(object): """Parse the tags argument""" def __init__(self): """ Initialize the class """ super(TagsArgument, self).__init__() def parse(self, configuration): """ Parse tags from the configuration file and return it formatted :param ...
#!/usr/bin/python3 def bubbleSort(arr, reverse=False): length = len(arr) for i in range(0, length-1): for j in range(0, length-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] if reverse: arr.reverse() return arr
# 手机参数 # 无法通过activity启动的app前使用#标记 activities = { 'zhaoshang': 'cmb.pb/.app.mainframe.container.PBMainActivity', 'toutiao': 'com.ss.android.article.lite/.activity.SplashActivity', 'kuaishou': 'com.kuaishou.nebula/com.yxcorp.gifshow.HomeActivity', 'douyin': 'com.ss.android.ugc.aweme.lite/com.ss.android....
# https://www.hackerrank.com/challenges/minimum-loss/problem def minimumLoss(price): min_loss = list() price = [(i,j) for i,j in zip(range(len(price)), price)] price = sorted(price,key=lambda x: x[1]) for i in range(len(price)-1): if(price[i][0]>price[i+1][0] and price[i][1]<price[i+1][1]): ...
# recursive function # O(n) time | O(h) space def nodedepth(root, depth=0): if root is None: return 0 return depth + nodedepth(root.left, depth + 1) + nodedepth(root.right, depth+1) # iterative function # O(n) time | O(h) space def findtheddepth(root): stack = [{"node": root, "depth": 0}] sum...
#!/usr/bin/env python3 # # Copyright (C) 2018 ETH Zurich and University of Bologna # # 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 # # Unl...
class Event: # TODO: This gonna abstract the concept of row data in traditional ML approach pass
def parse(file_path): # Method to read the config file. # Using a custom function for parsing so that we have only one config for # both the scripts and the mapreduce tasks. config = {} with open(file_path) as f: for line in f: data = line.strip() if(data and not dat...
# -*- coding: utf-8 -*- ############################################################################### # # Copyright (C) 2021-TODAY Prof-Dev Integrated(<http://www.prof-dev.com>). ############################################################################### { 'name': 'Prof-Dev School MGMT', 'version': '...
class Solution: def xorOperation(self, n: int, start: int) -> int: nums = [start + 2 * i for i in range(n)]; ret = 0; for val in nums: ret ^= val return ret
text = '' with open('/home/reagan/code/proj/familienanlichkeiten/data/DeReKo-2014-II-MainArchive-STT.100000.freq', 'r+') as f: text = f.read() def process_line(line: str): parts = line.split('\t') return (parts[1], parts[2]) known = set() lemmas = [] for line in text.splitlines(): lemma = process_lin...
EXCHANGE_COSMOS_BLOCKCHAIN = "cosmos_blockchain" CUR_ATOM = "ATOM" MILLION = 1000000.0 CURRENCIES = { "ibc/14F9BC3E44B8A9C1BE1FB08980FAB87034C9905EF17CF2F5008FC085218811CC": "OSMO" }
''' Given an n-ary tree, return the level order traversal of its nodes' values. Nary-Tree input serialization is represented in their level order traversal, each group of children is separated by the null value (See examples). Example: 1 / | \ 3 2 4 / \ 5 6 Input: root = [1,nul...
def secant(f, x_a, x_b, e=10**(-12)): while True: x = x_b - f(x_b) * ((x_b - x_a) / (f(x_b) - f(x_a))) t_e = abs(x - x_b) if t_e < e: return x x_a = x_b x_b = x if __name__ == "__main__": f = lambda x: x**2 - 10 x_a = 3 x_b = 4 print('Secante Pro...