content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
# (C) Datadog, Inc. 2019-present # All rights reserved # Licensed under a 3-clause BSD style license (see LICENSE) SECOND = 1 MILLISECOND = 1000 MICROSECOND = 1000000 NANOSECOND = 1000000000 TIME_UNITS = {'microsecond': MICROSECOND, 'millisecond': MILLISECOND, 'nanosecond': NANOSECOND, 'second': SECOND}
second = 1 millisecond = 1000 microsecond = 1000000 nanosecond = 1000000000 time_units = {'microsecond': MICROSECOND, 'millisecond': MILLISECOND, 'nanosecond': NANOSECOND, 'second': SECOND}
expected_output={ "interface":{ "GigabitEthernet3":{ "crypto_map_tag":"vpn-crypto-map", "ident":{ 1:{ "acl":"origin_is_acl,", "action":"PERMIT", "current_outbound_spi":"0x397C36EE(964441838)", "dh_group":"none", ...
expected_output = {'interface': {'GigabitEthernet3': {'crypto_map_tag': 'vpn-crypto-map', 'ident': {1: {'acl': 'origin_is_acl,', 'action': 'PERMIT', 'current_outbound_spi': '0x397C36EE(964441838)', 'dh_group': 'none', 'inbound_ah_sas': {}, 'inbound_esp_sas': {'spi': {'0x658F7C11(1703902225)': {'conn_id': 2076, 'crypto_...
class kycInfo: def __init__(self, registerNumber, name, gender, dob=None, address=None): self.registerNumber = registerNumber self.name = name self.gender = gender self.dob = dob self.address = address
class Kycinfo: def __init__(self, registerNumber, name, gender, dob=None, address=None): self.registerNumber = registerNumber self.name = name self.gender = gender self.dob = dob self.address = address
GOOGLE_CLOUD_SPEECH_CREDENTIALS = "Insert Google Cloud Speech API Key" mongourl = "Insert MongoDB URL" stdlib = "Insert stdlib API Key"
google_cloud_speech_credentials = 'Insert Google Cloud Speech API Key' mongourl = 'Insert MongoDB URL' stdlib = 'Insert stdlib API Key'
# These are the common special chars occured with numbers Num_Special_Chars = [',', '-', '+', ' '] # get_type_lst will sample at most x entries from a given query MAX_SAMPLE_SIZE = 500
num__special__chars = [',', '-', '+', ' '] max_sample_size = 500
# Fitur .add() print(">>> Fitur .add()") set_buah = {'Jeruk','Apel','Anggur'} set_buah.add('Melon') print(set_buah) # Fitur .clear() print(">>> Fitur .clear()") set_buah = {'Jeruk','Apel','Anggur'} set_buah.clear() print(set_buah) # Fitur .copy() print(">>> Fitur .copy()") set_buah1 = {'Jeruk','Apel','Anggur'} set_buah...
print('>>> Fitur .add()') set_buah = {'Jeruk', 'Apel', 'Anggur'} set_buah.add('Melon') print(set_buah) print('>>> Fitur .clear()') set_buah = {'Jeruk', 'Apel', 'Anggur'} set_buah.clear() print(set_buah) print('>>> Fitur .copy()') set_buah1 = {'Jeruk', 'Apel', 'Anggur'} set_buah2 = set_buah1 set_buah3 = set_buah1.copy()...
# docstyle-ignore INSTALL_CONTENT = """ # Transformers installation ! pip install transformers datasets # To install from source instead of the last release, comment the command above and uncomment the following one. # ! pip install git+https://github.com/huggingface/transformers.git """ notebook_first_cells = [{"type...
install_content = '\n# Transformers installation\n! pip install transformers datasets\n# To install from source instead of the last release, comment the command above and uncomment the following one.\n# ! pip install git+https://github.com/huggingface/transformers.git\n' notebook_first_cells = [{'type': 'code', 'conten...
""" https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/ Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation. (Recall that the number of set bits an integer has is the number of 1s present whe...
""" https://leetcode.com/problems/prime-number-of-set-bits-in-binary-representation/ Given two integers L and R, find the count of numbers in the range [L, R] (inclusive) having a prime number of set bits in their binary representation. (Recall that the number of set bits an integer has is the number of 1s present whe...
class Config: MASTER_GEOMETRY_FIELDNAME = "wkb_geometry" SCHEMA = "public" SQL_FILE_EXTENSION = ".sql" DATABASE_NAME = "gensmd" PQSL_TEMPLATE = '"c:/Program Files/PostgreSQL/9.5/bin/psql.exe" -U postgres -q -d %s -f %s\n' % DATABASE_NAME ID_FIELD_NAME = "zdroj_id" PG_CONNECTOR = "dbname=%s u...
class Config: master_geometry_fieldname = 'wkb_geometry' schema = 'public' sql_file_extension = '.sql' database_name = 'gensmd' pqsl_template = '"c:/Program Files/PostgreSQL/9.5/bin/psql.exe" -U postgres -q -d %s -f %s\n' % DATABASE_NAME id_field_name = 'zdroj_id' pg_connector = 'dbname=%s u...
palindrome = input("What word or phrase would you like to check?") palindromeNoSpace = palindrome.replace(" ","") lengthCheck = False wordLength = 0 while lengthCheck == False: if len(palindrome) == 0: print("Please enter a word or phrase") palindrome = input("What word or phrase would you like to ...
palindrome = input('What word or phrase would you like to check?') palindrome_no_space = palindrome.replace(' ', '') length_check = False word_length = 0 while lengthCheck == False: if len(palindrome) == 0: print('Please enter a word or phrase') palindrome = input('What word or phrase would you like...
# Copyright (c) 2013 Qubell Inc., http://qubell.com # # 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 agr...
__author__ = 'Vasyl Khomenko' __copyright__ = 'Copyright 2013, Qubell.com' __license__ = 'Apache' __email__ = 'vkhomenko@qubell.com'
s="Paraschiv Alexandru-Andrei" crt=0 nume=0 poz=0 i=0 lg=len(s) for i in range (lg): if (i==0 or s[i-1]==" " or s[i-1]=="-"): if s[i].islower(): print("Nume gresit") break if s[i]=="-": crt+=1 if crt>1: print("Nume gresit") b...
s = 'Paraschiv Alexandru-Andrei' crt = 0 nume = 0 poz = 0 i = 0 lg = len(s) for i in range(lg): if i == 0 or s[i - 1] == ' ' or s[i - 1] == '-': if s[i].islower(): print('Nume gresit') break if s[i] == '-': crt += 1 if crt > 1: print('Nume gresit') ...
# # PySNMP MIB module HPN-ICF-FC-TRACE-ROUTE-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-FC-TRACE-ROUTE-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:38:54 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version ...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (value_range_constraint, single_value_constraint, constraints_intersection, constraints_union, value_size_constraint) ...
class MyQueue: def __init__(self): """ Initialize your data structure here. """ self.stacks = [] self.temp = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ self.stacks += [x] def pop(self) -> int: ...
class Myqueue: def __init__(self): """ Initialize your data structure here. """ self.stacks = [] self.temp = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ self.stacks += [x] def pop(self) -> int: ...
#!/usr/bin/python """ Powerful digit sum https://projecteuler.net/problem=56 """ def digitalsum(n): n = list(str(n)) total = 0 for i in range(len(n)): total = total + int(n[i]) return total def main(): hold = 0 for i in range(1, 100): for j in range(1, 100): temp ...
""" Powerful digit sum https://projecteuler.net/problem=56 """ def digitalsum(n): n = list(str(n)) total = 0 for i in range(len(n)): total = total + int(n[i]) return total def main(): hold = 0 for i in range(1, 100): for j in range(1, 100): temp = digitalsum(i ** j)...
# -*- coding: utf-8 -*- """ Created on Fri Feb 11 09:23:21 2022 @author: ACER """ def calcularArea(): print("calcular Area") def calcularDist(x,y): print(f"la distancia es {x-y}")
""" Created on Fri Feb 11 09:23:21 2022 @author: ACER """ def calcular_area(): print('calcular Area') def calcular_dist(x, y): print(f'la distancia es {x - y}')
class StartupError(Exception): def __init__(self, message): self.message = message class DeviceRegistrationError(Exception): def __init__(self, message): self.message = message class OverlayRegistrationError(Exception): def __init__(self, message): self.message = message class ...
class Startuperror(Exception): def __init__(self, message): self.message = message class Deviceregistrationerror(Exception): def __init__(self, message): self.message = message class Overlayregistrationerror(Exception): def __init__(self, message): self.message = message class ...
# 362. Design Hit Counter # Medium # 377 # 37 # Favorite # Share # Design a hit counter which counts the number of hits received in the past 5 minutes. # Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the t...
""" First try. """ class Hitcounter(object): def __init__(self): """ Initialize your data structure here. """ self.hits = [] def hit(self, timestamp): """ Record a hit. @param timestamp - The current timestamp (in seconds granularity). :type tim...
"""1614. https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/ """ def max_depth(s: str) -> int: ans = 0 stack = [] for ch in s: if ch == '(': stack.append(ch) elif ch == ')': ans = max(ans, len(stack)) stack.pop() return ans
"""1614. https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/ """ def max_depth(s: str) -> int: ans = 0 stack = [] for ch in s: if ch == '(': stack.append(ch) elif ch == ')': ans = max(ans, len(stack)) stack.pop() return ans
s = 0 last = 1 for i in range(int(input())): if int(input()) in [2,3]: s+=1 print(s)
s = 0 last = 1 for i in range(int(input())): if int(input()) in [2, 3]: s += 1 print(s)
class PageSections(object): def __init__(self, driver): super().__init__() self.driver = driver def click_menu(self): return
class Pagesections(object): def __init__(self, driver): super().__init__() self.driver = driver def click_menu(self): return
def test_nodenet_statuslogger(app, runtime, test_nodenet): net = runtime.get_nodenet(test_nodenet) sl = net.netapi.statuslogger sl.info("Learning.Foo", sl.ACTIVE, progress=(5, 23)) logs = runtime.get_logger_messages(sl.name) assert "Learning.Foo" in logs['logs'][1]['msg'] result = app.get_json...
def test_nodenet_statuslogger(app, runtime, test_nodenet): net = runtime.get_nodenet(test_nodenet) sl = net.netapi.statuslogger sl.info('Learning.Foo', sl.ACTIVE, progress=(5, 23)) logs = runtime.get_logger_messages(sl.name) assert 'Learning.Foo' in logs['logs'][1]['msg'] result = app.get_json('...
# rotate 180 degrees # need to call show after rotating as rotating only sets the remapping bits on the remap and offset registers # show repopulates the gddram in the new correct order display.rotate(True) display.show() # rotate 0 degrees display.write_cmd(ssd1327.SET_DISP_OFFSET) # 0xA2 display.write_cmd(128 - disp...
display.rotate(True) display.show() display.write_cmd(ssd1327.SET_DISP_OFFSET) display.write_cmd(128 - display.height) display.write_cmd(ssd1327.SET_SEG_REMAP) display.write_cmd(81) display.show() display.write_cmd(ssd1327.SET_DISP_OFFSET) display.write_cmd(128 - display.height) display.write_cmd(ssd1327.SET_SEG_REMAP)...
# Created by MechAviv # Custom Puppy Damage Skin | (2439442) if sm.addDamageSkin(2439442): sm.chat("'Custom Puppy Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
if sm.addDamageSkin(2439442): sm.chat("'Custom Puppy Damage Skin' Damage Skin has been added to your account's damage skin collection.") sm.consumeItem()
# # PySNMP MIB module CISCO-WAN-NCDP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-WAN-NCDP-MIB # Produced by pysmi-0.3.4 at Wed May 1 12:20:37 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, ...
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (constraints_intersection, constraints_union, value_size_constraint, value_range_constraint, single_value_constraint) ...
"""Utilities for handling unlabelled objects when translating workflow formats.""" class Labels(object): """Track labels assigned and generate anonymous ones.""" def __init__(self): """Initialize labels that have been encountered or generated.""" self.seen_labels = set() self.anonymou...
"""Utilities for handling unlabelled objects when translating workflow formats.""" class Labels(object): """Track labels assigned and generate anonymous ones.""" def __init__(self): """Initialize labels that have been encountered or generated.""" self.seen_labels = set() self.anonymous...
substvars = { 'SCRIPTS_DIR' : 'scripts', } tasks = { 'util' : { 'features' : 'cshlib', 'source' : 'shlib/**/*.c', #'includes' : '.', #'toolchain' : 'auto-c', # 'install-files' testing 'install-files' : [ { # copy whole directory...
substvars = {'SCRIPTS_DIR': 'scripts'} tasks = {'util': {'features': 'cshlib', 'source': 'shlib/**/*.c', 'install-files': [{'src': 'scripts', 'dst': '${PREFIX}/share/${PROJECT_NAME}/${SCRIPTS_DIR}', 'chmod': 493}, {'src': 'scripts/*', 'dst': '${PREFIX}/share/${PROJECT_NAME}/${SCRIPTS_DIR}2', 'chmod': '755', 'follow-sym...
class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ if(len(nums)-len(list(set(nums)))>0): return True elif len(nums)==1: return False else: return False
class Solution(object): def contains_duplicate(self, nums): """ :type nums: List[int] :rtype: bool """ if len(nums) - len(list(set(nums))) > 0: return True elif len(nums) == 1: return False else: return False
# # PySNMP MIB module CISCO-ST-TC (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ST-TC # Produced by pysmi-0.3.4 at Mon Apr 29 17:36:22 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 0...
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString') (named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues') (single_value_constraint, value_range_constraint, constraints_intersection, constraints_union, value_size_constraint) ...
# acm thailand 2011 def refill(lf_c, lf_h, lf_v, path=''): '''recursive fill the walk path, if filled check if the walk are valid''' global answer if answer: return if lf_c == 0 and lf_h == 0 and lf_v == 0: if chk(path): ## on valid path, ignore furthermore path ## ...
def refill(lf_c, lf_h, lf_v, path=''): """recursive fill the walk path, if filled check if the walk are valid""" global answer if answer: return if lf_c == 0 and lf_h == 0 and (lf_v == 0): if chk(path): answer = True print(len(path)) return if lf_c > 0...
''' Write a function that takes in an array of positive integers and returns an integer representing the maximum sum of non-adjacent elements in the array. If a sum cannot be generated, the function should return 0. [7,10,12,7,9,14] 7+12+14=33 ''' # O(n) time | O(n) space # def maxSubsetSumNoAdjacent(array): # #...
""" Write a function that takes in an array of positive integers and returns an integer representing the maximum sum of non-adjacent elements in the array. If a sum cannot be generated, the function should return 0. [7,10,12,7,9,14] 7+12+14=33 """ def max_subset_sum_no_adjacent(array): if not len(array): ...
#number of lines you want in the new file lines_per_file = 100000 smallfile = None with open('/home/cantos/Downloads/index.jsonl') as bigfile: #give the file name and extension for lineno, line in enumerate(bigfile): if lineno % lines_per_file == 0: if smallfile: smallfile.close(...
lines_per_file = 100000 smallfile = None with open('/home/cantos/Downloads/index.jsonl') as bigfile: for (lineno, line) in enumerate(bigfile): if lineno % lines_per_file == 0: if smallfile: smallfile.close() small_filename = 'small_file_{}.jsonl'.format(lineno + lines...
''' stuff = 'X\nY' print("stuff[:] 'X\\nY'", stuff[:]) print("stuff", stuff) print("len(stuff)", len(stuff)) #fhand = open('mboxnoexists.txt') # print(fhand) fhand = open('mbox.txt') print(fhand) count = 0 for line in fhand: count = count + 1 print('mbox.txt line count: %d' % count) # read all data to memory # fh...
""" stuff = 'X Y' print("stuff[:] 'X\\nY'", stuff[:]) print("stuff", stuff) print("len(stuff)", len(stuff)) #fhand = open('mboxnoexists.txt') # print(fhand) fhand = open('mbox.txt') print(fhand) count = 0 for line in fhand: count = count + 1 print('mbox.txt line count: %d' % count) # read all data to memory # fha...
class Solution: """ @param flights: the airline status from the city i to the city j @param days: days[i][j] represents the maximum days you could take vacation in the city i in the week j @return: the maximum vacation days you could take during K weeks """ def maxVacationDays(self, flights, day...
class Solution: """ @param flights: the airline status from the city i to the city j @param days: days[i][j] represents the maximum days you could take vacation in the city i in the week j @return: the maximum vacation days you could take during K weeks """ def max_vacation_days(self, flights, ...
# sumOfSquaresReadFromFile.py # A program computes the sum of the squares of numbers read from a file. """Use the functions from the previous three problems to implement a program that computes the sum of the squares of numbers read from a file. Your program should prompt for a file name and print out the sum of the s...
"""Use the functions from the previous three problems to implement a program that computes the sum of the squares of numbers read from a file. Your program should prompt for a file name and print out the sum of the squares of the values in the file. Hint: Use readlines()""" def to_numbers(fileData): num_list = []...
nkpop_list = ["https://www.youtube.com/watch?v=VCrdiTA0RqI", "https://www.youtube.com/watch?v=S1KIh0MBBX4", "https://www.youtube.com/watch?v=qhXrye7zkwY", "https://www.youtube.com/watch?v=lNES9HTJ27U", "https://www.youtube.com/watch?v=NKIiglf4bfA", "...
nkpop_list = ['https://www.youtube.com/watch?v=VCrdiTA0RqI', 'https://www.youtube.com/watch?v=S1KIh0MBBX4', 'https://www.youtube.com/watch?v=qhXrye7zkwY', 'https://www.youtube.com/watch?v=lNES9HTJ27U', 'https://www.youtube.com/watch?v=NKIiglf4bfA', 'https://www.youtube.com/watch?v=e3D4nH9FnpY', 'https://www.youtube.com...
print('===== DESAFIO 009 =====') x = int(input('Digite um numero para ser Multiplicado : ')) x1 = 1 * x x2 = 2 * x x3 = 3 * x x4 = 4 * x x5 = 5 * x x6 = 6 * x x7 = 7 * x x8 = 8 * x x9 = 9 * x x10 = 10 * x print('-' * 12) print(f'Tabuada \n ' f'{x} x 1 = {x1} \n ' f'{x} x 2 = {x2} \n ' f'{x} x 3 =...
print('===== DESAFIO 009 =====') x = int(input('Digite um numero para ser Multiplicado : ')) x1 = 1 * x x2 = 2 * x x3 = 3 * x x4 = 4 * x x5 = 5 * x x6 = 6 * x x7 = 7 * x x8 = 8 * x x9 = 9 * x x10 = 10 * x print('-' * 12) print(f'Tabuada \n {x} x 1 = {x1} \n {x} x 2 = {x2} \n {x} x 3 = {x3} \n {x} x 4 = {x4} \n {x} ...
def solution(numbers, hand): answer = '' left = (3,0) right = (3,2) _dict = { 1:(0,0), 2:(0,1), 3:(0,2), 4:(1,0), 5:(1,1), 6:(1,2), 7:(2,0), 8:(2,1), 9:(2,2), 0:(3,1) } ...
def solution(numbers, hand): answer = '' left = (3, 0) right = (3, 2) _dict = {1: (0, 0), 2: (0, 1), 3: (0, 2), 4: (1, 0), 5: (1, 1), 6: (1, 2), 7: (2, 0), 8: (2, 1), 9: (2, 2), 0: (3, 1)} for i in numbers: if i == 1 or i == 4 or i == 7: answer += 'L' left = _dict[i] ...
# Copyright (c) 2016 Google Inc. (under http://www.apache.org/licenses/LICENSE-2.0) """TypeVar test.""" class UserDict(object): def __init__(self, initialdata = None): pass
"""TypeVar test.""" class Userdict(object): def __init__(self, initialdata=None): pass
class FactorConf(object): FACTOR_INIT_VERSION = "INIT_VERSION" GROUP_FACTOR_PREFIX = "FACTOR_KEEPER_GROUP_FACTOR_" FACTOR_LENGTH = 4740 @staticmethod def get_group_factor_name(factors): factors = sorted(factors) return FactorConf.GROUP_FACTOR_PREFIX + "#".join(factors)
class Factorconf(object): factor_init_version = 'INIT_VERSION' group_factor_prefix = 'FACTOR_KEEPER_GROUP_FACTOR_' factor_length = 4740 @staticmethod def get_group_factor_name(factors): factors = sorted(factors) return FactorConf.GROUP_FACTOR_PREFIX + '#'.join(factors)
""" WAP to compute sin(x) for given x. The user should supply x and a positive integer n. We compute the sine of x using the taylor series and the computation should use all terms in the series up through the term involving x^n sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! ... 3! = 1 * 2 * 3 * (4 * 5) = 5! * (6 * 7) =...
""" WAP to compute sin(x) for given x. The user should supply x and a positive integer n. We compute the sine of x using the taylor series and the computation should use all terms in the series up through the term involving x^n sin(x) = x - x^3/3! + x^5/5! - x^7/7! + x^9/9! ... 3! = 1 * 2 * 3 * (4 * 5) = 5! * (6 * 7) =...
def map_fn(obj, objs, apply_fn): if isinstance(obj, dict): return dict(map(lambda kv: (kv[0], map_fn(kv[1], list(map(lambda x: x[kv[0]], objs)), apply_fn)), obj.items())) elif isinstance(obj, list): return list(map(lambda e: map_fn(e[0], e[1:], apply_fn), zip(obj, *objs))) elif isinstance(obj, tuple): ...
def map_fn(obj, objs, apply_fn): if isinstance(obj, dict): return dict(map(lambda kv: (kv[0], map_fn(kv[1], list(map(lambda x: x[kv[0]], objs)), apply_fn)), obj.items())) elif isinstance(obj, list): return list(map(lambda e: map_fn(e[0], e[1:], apply_fn), zip(obj, *objs))) elif isinstance(ob...
"""Test vairables""" debug_string_test = [ "item(1)\n", "item(1)\n", "item(1)\n", "item(1)\n", "item(1)\n", "item(1)\n", "row\n", "\tcolumn\n", "\t\titem(1)\n", "\tcolumn\n", "\t\titem(1)\n", "row\n", "\tcolumn\n", "\t\titem(1)\n", "\tcolumn\n", "\t\titem(...
"""Test vairables""" debug_string_test = ['item(1)\n', 'item(1)\n', 'item(1)\n', 'item(1)\n', 'item(1)\n', 'item(1)\n', 'row\n', '\tcolumn\n', '\t\titem(1)\n', '\tcolumn\n', '\t\titem(1)\n', 'row\n', '\tcolumn\n', '\t\titem(1)\n', '\tcolumn\n', '\t\titem(5)\n', '\tcolumn\n', '\t\titem(1)\n', 'item(1)\n', 'item(1)\n', '...
class Solution: def fizzBuzz(self, n: int) -> List[str]: l = [] for i in range(1,n+1): if i%15==0 : l.append("FizzBuzz") elif i%3 == 0: l.append("Fizz") elif i%5 == 0: l.append("Buzz") else: ...
class Solution: def fizz_buzz(self, n: int) -> List[str]: l = [] for i in range(1, n + 1): if i % 15 == 0: l.append('FizzBuzz') elif i % 3 == 0: l.append('Fizz') elif i % 5 == 0: l.append('Buzz') else: ...
class Solution: def largestRectangleArea(self, heights): """ :type heights: List[int] :rtype: int """ length = len(heights) if length == 0: return 0 if length == 1: return heights[0] if length == 2: return max(min(he...
class Solution: def largest_rectangle_area(self, heights): """ :type heights: List[int] :rtype: int """ length = len(heights) if length == 0: return 0 if length == 1: return heights[0] if length == 2: return max(min...
__all__ = ['NamecheapError', 'ApiError'] class NamecheapError(Exception): pass # https://www.namecheap.com/support/api/error-codes.aspx class ApiError(NamecheapError): def __init__(self, number, text): Exception.__init__(self, '%s - %s' % (number, text)) self.number = number self.te...
__all__ = ['NamecheapError', 'ApiError'] class Namecheaperror(Exception): pass class Apierror(NamecheapError): def __init__(self, number, text): Exception.__init__(self, '%s - %s' % (number, text)) self.number = number self.text = text
def tribo(N): if N == 0 or N == 1: return 0 elif N == 2: return 1 return tribo(N-1) + tribo(N-2) def main(): N = int(input()) output = tribo(N) print(output) if __name__=='__main__': main()
def tribo(N): if N == 0 or N == 1: return 0 elif N == 2: return 1 return tribo(N - 1) + tribo(N - 2) def main(): n = int(input()) output = tribo(N) print(output) if __name__ == '__main__': main()
class dataScientist(): employees = [] def __init__(self): self.languages = [] self.department = '' def add_language(self, new_language): self.languages.append(new_language) dilara = dataScientist() pitircik = dataScientist() pitircik.add_language("R") print(pitircik.languag...
class Datascientist: employees = [] def __init__(self): self.languages = [] self.department = '' def add_language(self, new_language): self.languages.append(new_language) dilara = data_scientist() pitircik = data_scientist() pitircik.add_language('R') print(pitircik.languages) prin...
# encoding: utf-8 # module array # from (built-in) # by generator 1.147 """ This module defines an object type which can efficiently represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in the...
""" This module defines an object type which can efficiently represent an array of basic values: characters, integers, floating point numbers. Arrays are sequence types and behave very much like lists, except that the type of objects stored in them is constrained. The type is specified at object creation time by usin...
class html: def __init__(self, line) -> None: #("# oi # <teddy>oi</teddy> # oi # <teddy>5</teddy> %") self.line = line self.tm = [] self.tl = [] self.start(self.line + ' ') def start(self, line): before = line[:line.find('<teddy>')] # "# oi...
class Html: def __init__(self, line) -> None: self.line = line self.tm = [] self.tl = [] self.start(self.line + ' ') def start(self, line): before = line[:line.find('<teddy>')] self.tm.append(before) l = line.find('</teddy>') + 8 var = line[l:] ...
n = int(input()) ans = 0 if n >= 1000: ans += n - 999 if n >= 1000000: ans += n - 999999 if n >= 1000000000: ans += n - 999999999 if n >= 1000000000000: ans += n - 999999999999 if n >= 1000000000000000: ans += n - 999999999999999 print(ans)
n = int(input()) ans = 0 if n >= 1000: ans += n - 999 if n >= 1000000: ans += n - 999999 if n >= 1000000000: ans += n - 999999999 if n >= 1000000000000: ans += n - 999999999999 if n >= 1000000000000000: ans += n - 999999999999999 print(ans)
""" :synopsis: Supported metric calculations to use on validation data with NPU API for training. .. moduleauthor:: Naval Bhandari <naval@neuro-ai.co.uk> """ Accuracy = "Accuracy" # Binary_accuracy = "Binary_accuracy" # Binary_cross_entropy = "Binary_cross_entropy" # Categorical_accuracy = "Categorical_accuracy" Categ...
""" :synopsis: Supported metric calculations to use on validation data with NPU API for training. .. moduleauthor:: Naval Bhandari <naval@neuro-ai.co.uk> """ accuracy = 'Accuracy' categorical_cross_entropy = 'Categorical_cross_entropy' mean_absolute_error = 'Mean_absolute_error' mean_squared_error = 'Mean_squared_error...
def pluralize(word,num): if num > 1: if word [-3:]== "ife" : return( word[:-3] + "ives") elif word[-2:] == "sh" or word[-2:] == "ch" : return( word + "es") elif word[-2:] == "us": return(word[:-2] + "i") elif word[-2:] == "ay" or word[-2:] == "oy"...
def pluralize(word, num): if num > 1: if word[-3:] == 'ife': return word[:-3] + 'ives' elif word[-2:] == 'sh' or word[-2:] == 'ch': return word + 'es' elif word[-2:] == 'us': return word[:-2] + 'i' elif word[-2:] == 'ay' or word[-2:] == 'oy' or wor...
class Token(object): def __init__(self, symbol, spec, line): self.symbol = symbol self.spec = spec self.line = line if spec == 'error': self.value = symbol elif spec == 'const': self.value = int(symbol) elif spec == 'OCT': self.valu...
class Token(object): def __init__(self, symbol, spec, line): self.symbol = symbol self.spec = spec self.line = line if spec == 'error': self.value = symbol elif spec == 'const': self.value = int(symbol) elif spec == 'OCT': self.val...
template = { 'dns': {}, 'inbounds': [ { 'listen': '0.0.0.0', 'port': 1080, 'protocol': 'socks', 'settings': { 'auth': 'noauth', 'udp': True } }, { ...
template = {'dns': {}, 'inbounds': [{'listen': '0.0.0.0', 'port': 1080, 'protocol': 'socks', 'settings': {'auth': 'noauth', 'udp': True}}, {'listen': '0.0.0.0', 'port': 8080, 'protocol': 'http', 'settings': {'timeout': 300}}], 'log': {'access': '/dev/stdout', 'error': '/dev/stderr', 'loglevel': 'warning'}, 'outbounds':...
def exibe(v, n): for i in range(n): print(v[i], end=' ') print('') def troca(v, i, j): v[i],v[j] = v[j],v[i] def empurra(v, n): for i in range(n - 1): if v[i] > v[i+1]: troca(v, i, i+1) def bubble_sort(v, n): exibe(v, n) tam = n while tam > 1: empurr...
def exibe(v, n): for i in range(n): print(v[i], end=' ') print('') def troca(v, i, j): (v[i], v[j]) = (v[j], v[i]) def empurra(v, n): for i in range(n - 1): if v[i] > v[i + 1]: troca(v, i, i + 1) def bubble_sort(v, n): exibe(v, n) tam = n while tam > 1: ...
""" A decorator that allows you to specify a set of keyword arguments that are required by the function. If any are missing, an exception is raised which lists the missing arguments. :: @required_arguments(bar='bar', baz='qux') def my_function(x, y, bar=None, baz=None): ...something... Invoking the ...
""" A decorator that allows you to specify a set of keyword arguments that are required by the function. If any are missing, an exception is raised which lists the missing arguments. :: @required_arguments(bar='bar', baz='qux') def my_function(x, y, bar=None, baz=None): ...something... Invoking the ...
""" This submodule implements a class that can manipulate numbers """ class NumManip: """This class implements a few different types of methods to manipulate numbers Variables: class_variable (int): A simple integer Attributes: num1 (int, float): The first number num2 (int, float)...
""" This submodule implements a class that can manipulate numbers """ class Nummanip: """This class implements a few different types of methods to manipulate numbers Variables: class_variable (int): A simple integer Attributes: num1 (int, float): The first number num2 (int, float)...
n=input() for i in n: a=int(i) if(a%2!=0): print(i,end="")
n = input() for i in n: a = int(i) if a % 2 != 0: print(i, end='')
class Solution(object): def isHappy(self, n): """ :type n: int :rtype: bool """ # The smallest happy number after 1 is 7 while n > 6: # Split n into a list of squared digits squared_digits = [int(x) ** 2 for x in str(n)] # Recurse ...
class Solution(object): def is_happy(self, n): """ :type n: int :rtype: bool """ while n > 6: squared_digits = [int(x) ** 2 for x in str(n)] return self.isHappy(sum(squared_digits)) return True if n == 1 else False
class Bunch(dict): """ Dictionary-like object returned when fetching data sets. Some common options: Option | Type | Description | Default ------ | ---- | ----------- | ------- data | List[Any] | An array of data for a set of instances | List[] instance | Optional[Any] | Data for a specifi...
class Bunch(dict): """ Dictionary-like object returned when fetching data sets. Some common options: Option | Type | Description | Default ------ | ---- | ----------- | ------- data | List[Any] | An array of data for a set of instances | List[] instance | Optional[Any] | Data for a specifi...
class Node: def __init__(self, code, id, name, definition, version, revision, superclass, dictionary_code): self.code = code self.id = id self.name = name self.definition = definition self.version = version self.revision = revision self.superclass = superclas...
class Node: def __init__(self, code, id, name, definition, version, revision, superclass, dictionary_code): self.code = code self.id = id self.name = name self.definition = definition self.version = version self.revision = revision self.superclass = superclas...
with open("subreddits_list.txt", "r") as f: subreddits = f.read().splitlines() with open("script.sql", "w") as f: for i in subreddits: f.write( f"CREATE TABLE IF NOT EXISTS '{i}' (Name text, Date text, Subscribers int, Live_Users int);\n" f"INSERT INTO '{i}' SELECT * FROM measur...
with open('subreddits_list.txt', 'r') as f: subreddits = f.read().splitlines() with open('script.sql', 'w') as f: for i in subreddits: f.write(f"CREATE TABLE IF NOT EXISTS '{i}' (Name text, Date text, Subscribers int, Live_Users int);\nINSERT INTO '{i}' SELECT * FROM measures where Name='{i}';\n")
def parse(raw): depth = 0 start = 0 pairs = [] for idx, ch in enumerate(raw): if ch == '<': depth += 1 if depth == 1: pairs.append([start, idx]) elif ch == '>': depth -= 1 if depth <= 0 and start == -1: start = idx res = [] for pair in pairs: if pair[1] - pair[0] >= 10: res.append(...
def parse(raw): depth = 0 start = 0 pairs = [] for (idx, ch) in enumerate(raw): if ch == '<': depth += 1 if depth == 1: pairs.append([start, idx]) elif ch == '>': depth -= 1 if depth <= 0 and start == -1: sta...
class Snake: def __init__(self, uuid, name, pos, direction): self.uuid = uuid self.name = name self.body = [pos] self.direction = direction self.length = 6 self.colors = [[100, 100, 100]] self.ticks = 0 def get_head(self): return self.body[-1] ...
class Snake: def __init__(self, uuid, name, pos, direction): self.uuid = uuid self.name = name self.body = [pos] self.direction = direction self.length = 6 self.colors = [[100, 100, 100]] self.ticks = 0 def get_head(self): return self.body[-1] ...
class dotPartLine_t(object): # no doc aPoints = None nPoints = None PartID = None PartLineCutted = None PartLineType = None
class Dotpartline_T(object): a_points = None n_points = None part_id = None part_line_cutted = None part_line_type = None
#: The interval which http server refreshes its routing table HTTP_ROUTER_CHECKER_INTERVAL_S = 2 #: Actor name used to register actor nursery SERVE_NURSERY_NAME = "SERVE_ACTOR_NURSERY" #: KVStore connector key in bootstrap config BOOTSTRAP_KV_STORE_CONN_KEY = "kv_store_connector" #: HTTP Address DEFAULT_HTTP_ADDRESS...
http_router_checker_interval_s = 2 serve_nursery_name = 'SERVE_ACTOR_NURSERY' bootstrap_kv_store_conn_key = 'kv_store_connector' default_http_address = 'http://0.0.0.0:8000' default_http_host = '0.0.0.0' default_http_port = 8000
class UserContext: @property def user_id(self) -> int: return self._user_id @property def is_admin(self) -> bool: return self._is_admin def __init__(self, user_id: int, is_admin: bool) -> None: self._user_id = user_id self._is_admin = is_admin
class Usercontext: @property def user_id(self) -> int: return self._user_id @property def is_admin(self) -> bool: return self._is_admin def __init__(self, user_id: int, is_admin: bool) -> None: self._user_id = user_id self._is_admin = is_admin
numero = str(input('Digite um numero de 0 a 9999:')) unidade = numero[3] dezena = numero[2] centena = numero[1] milhar = numero[0] print('''unidade:{}, centena:{}, dezena:{}, milhar:{}'''.format(unidade,dezena,centena,milhar))
numero = str(input('Digite um numero de 0 a 9999:')) unidade = numero[3] dezena = numero[2] centena = numero[1] milhar = numero[0] print('unidade:{},\ncentena:{},\ndezena:{},\nmilhar:{}'.format(unidade, dezena, centena, milhar))
class PrintDT: def py_data(self,list): self.list=[] print(self.list) def py_data(self,tuple): self.tuple=() print(tuple) def py_data(self,str): self.str='' print(str) p=PrintDT() p.py_data([1,2,3]) p.py_data(('a',[8,4,6],"mouse")) p.py_data('Abhay')
class Printdt: def py_data(self, list): self.list = [] print(self.list) def py_data(self, tuple): self.tuple = () print(tuple) def py_data(self, str): self.str = '' print(str) p = print_dt() p.py_data([1, 2, 3]) p.py_data(('a', [8, 4, 6], 'mouse')) p.py_dat...
# -*- coding: utf-8 -*- extensions = [ 'sphinx.ext.intersphinx', 'sphinx.ext.mathjax', ] #'sphinxcontrib.matlab', #templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' project = u'pyrenn' copyright = u'2016, Dennis Atabay' author = u'Dennis Atabay' version = '0.1' release = '0.1' exc...
extensions = ['sphinx.ext.intersphinx', 'sphinx.ext.mathjax'] source_suffix = '.rst' master_doc = 'index' project = u'pyrenn' copyright = u'2016, Dennis Atabay' author = u'Dennis Atabay' version = '0.1' release = '0.1' exclude_patterns = ['_build'] htmlhelp_basename = 'pyrenndoc' latex_elements = {'papersize': 'a4paper...
class ConnectionError(Exception): def __init__(self, *args, **kwargs): pass @staticmethod def __new__(S, *more): """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ pass def __reduce__(self, *args, **kwargs): pass def __str__(self): """...
class Connectionerror(Exception): def __init__(self, *args, **kwargs): pass @staticmethod def __new__(S, *more): """ T.__new__(S, ...) -> a new object with type S, a subtype of T """ pass def __reduce__(self, *args, **kwargs): pass def __str__(self): """ x...
class Actions: START = 'start' SHUTDOWN = 'shutdown' DELETE = 'delete' HIBERNATE = 'hibernate' RESTORE = 'restore' def __init__(self): return class VolumeActions: ATTACH = 'attach' DETACH = 'detach' RENAME = 'rename' INCREASE_SIZE = 'increase-size' DELETE = 'delete...
class Actions: start = 'start' shutdown = 'shutdown' delete = 'delete' hibernate = 'hibernate' restore = 'restore' def __init__(self): return class Volumeactions: attach = 'attach' detach = 'detach' rename = 'rename' increase_size = 'increase-size' delete = 'delete'...
num_elves = 3014387 elves = [[1, i + 1] for i in range(num_elves)] while len(elves) > 1: for i in range(len(elves)): if elves[i][0] != 0: elves[i][0] += elves[(i + 1) % len(elves)][0] elves[(i + 1) % len(elves)][0] = 0 elves = [x for x in elves if x[0] != 0] print('The elf wit...
num_elves = 3014387 elves = [[1, i + 1] for i in range(num_elves)] while len(elves) > 1: for i in range(len(elves)): if elves[i][0] != 0: elves[i][0] += elves[(i + 1) % len(elves)][0] elves[(i + 1) % len(elves)][0] = 0 elves = [x for x in elves if x[0] != 0] print('The elf with a...
# Copyright (c) 2001-2004 Twisted Matrix Laboratories. # See LICENSE for details. # """ Client support code for Conch. Maintainer: Paul Swartz """
""" Client support code for Conch. Maintainer: Paul Swartz """
class Node: def __init__(self, data, nextNode): self.data = data self.nextNode = nextNode class Stack: def __init__(self): self.top = None def Peek(self): return self.top def Push(self, data): nextNode = self.top self.top = Node(data, nextNode) de...
class Node: def __init__(self, data, nextNode): self.data = data self.nextNode = nextNode class Stack: def __init__(self): self.top = None def peek(self): return self.top def push(self, data): next_node = self.top self.top = node(data, nextNode) ...
def resultado_f1(**podium): for posicao, piloto in podium.items(): print(f'{posicao} --> {piloto}') if __name__ == '__main__': resultado_f1(primeiro='Piloto1', segundo='Piloto2', terceiro='Piloto3')
def resultado_f1(**podium): for (posicao, piloto) in podium.items(): print(f'{posicao} --> {piloto}') if __name__ == '__main__': resultado_f1(primeiro='Piloto1', segundo='Piloto2', terceiro='Piloto3')
# coding: utf-8 class GradsCondition(object): def __init__(self, name, values): self.name = name self.values = values if self.name == 'level': self.values = [float(v) for v in self.values] def __eq__(self, other): if isinstance(other, self.__class__): r...
class Gradscondition(object): def __init__(self, name, values): self.name = name self.values = values if self.name == 'level': self.values = [float(v) for v in self.values] def __eq__(self, other): if isinstance(other, self.__class__): return self.__dict...
class Solution: def findKthPositive(self, arr: List[int], k: int) -> int: idx = 0 for nxt in itertools.count(1): if idx < len(arr) and arr[idx] == nxt: idx += 1 else: k -= 1 if k == 0: return nxt
class Solution: def find_kth_positive(self, arr: List[int], k: int) -> int: idx = 0 for nxt in itertools.count(1): if idx < len(arr) and arr[idx] == nxt: idx += 1 else: k -= 1 if k == 0: return nxt
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"get_nc_dss": "02_data.news_commentary.ipynb", "get_tatoeba_dss": "02_data.tatoeba.ipynb", "generate_from_strs": "03a_models.patch.ipynb", "gen_attention_mask": "03c_models.bert2gpt...
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url'] index = {'get_nc_dss': '02_data.news_commentary.ipynb', 'get_tatoeba_dss': '02_data.tatoeba.ipynb', 'generate_from_strs': '03a_models.patch.ipynb', 'gen_attention_mask': '03c_models.bert2gpt2.ipynb', 'BertEncoder': '03c_models.bert2gpt2.ipynb', 'GPT2Decoder'...
some_string = input() for letter in some_string: print(letter * 2, end="")
some_string = input() for letter in some_string: print(letter * 2, end='')
# This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None # O(n) time | O(1) space - where n is the number of nodes in the Linked List def removeDuplicatesFromLinkedList(linkedList): currentNode = linkedList while ...
class Linkedlist: def __init__(self, value): self.value = value self.next = None def remove_duplicates_from_linked_list(linkedList): current_node = linkedList while currentNode is not None: next_distinct_node = currentNode.next while nextDistinctNode is not None and nextDis...
number = int(input()) print(number) print(type(number)) # repl -> repeat evaluate print loop
number = int(input()) print(number) print(type(number))
x=1 y=2 z=3 # # 1s or less # diff_low_t=35 # diff_high_t=255 # target_gray = cv2.cvtColor(anh_phat_hien_crop, cv2.COLOR_BGR2GRAY) # self.previewImage('a', target_gray) # bg_gray = cv2.cvtColor(anh_nen_crop, cv2.COLOR_BGR2GRAY) # self.previewImage('a', bg_gray) # diff_gray = cv2.absdiff(target_gray,bg_gray...
x = 1 y = 2 z = 3
TheClass = """ class TheClass: def theMethod(self): pass def differentMethod(self): pass class DifferentClass: def theMethod(self): pass """ Function = """ def theFunction(): pass """
the_class = '\nclass TheClass:\n def theMethod(self):\n pass\n def differentMethod(self):\n pass\n\nclass DifferentClass:\n def theMethod(self):\n pass\n' function = '\ndef theFunction():\n pass\n'
''' enhanced_multi_table.py Multiplication table printer: Enter the number and the number of multiples to be printed ''' def multi_table(a, n): for i in range(1, n+1): print('{0} x {1} = {2}'.format(a, i, a*i)) if __name__ == '__main__': try: a = float(input('Enter a number: ')) n = f...
""" enhanced_multi_table.py Multiplication table printer: Enter the number and the number of multiples to be printed """ def multi_table(a, n): for i in range(1, n + 1): print('{0} x {1} = {2}'.format(a, i, a * i)) if __name__ == '__main__': try: a = float(input('Enter a number: ')) n ...
def fibonacci(n: int): fibs = [] for i in range(n): if i < 2: fibs.append(i) else: fibs.append(fibs[i - 1] + fibs[i - 2]) return fibs if __name__ == "__main__": ans = fibonacci(15) print(ans)
def fibonacci(n: int): fibs = [] for i in range(n): if i < 2: fibs.append(i) else: fibs.append(fibs[i - 1] + fibs[i - 2]) return fibs if __name__ == '__main__': ans = fibonacci(15) print(ans)
FIELD = "field" FOREST = "forest" GARDEN = "garden" ORCHARD = "orchard" PASTURE = "pasture" SILVOPASTURE = "silvopasture" TYPES = [ ("F", FIELD), ("W", FOREST), ("G", GARDEN), ("O", ORCHARD), ("P", PASTURE), ("S", SILVOPASTURE) ]
field = 'field' forest = 'forest' garden = 'garden' orchard = 'orchard' pasture = 'pasture' silvopasture = 'silvopasture' types = [('F', FIELD), ('W', FOREST), ('G', GARDEN), ('O', ORCHARD), ('P', PASTURE), ('S', SILVOPASTURE)]
__all__ = ["fibo", "pi"] def fibo(n): return n if n < 2 else fibo(n - 1) + fibo(n - 2) def pi(its): sum = 0 for i in range(its): sum += 1 / (i + 1) ** 2 return (6 * sum) ** 0.5
__all__ = ['fibo', 'pi'] def fibo(n): return n if n < 2 else fibo(n - 1) + fibo(n - 2) def pi(its): sum = 0 for i in range(its): sum += 1 / (i + 1) ** 2 return (6 * sum) ** 0.5
# Time: f(n) = k * f(n/k) + n/k * klogk <= O(logn * nlogk) <= O(n^2) # n is the length of S, k is the max number of special strings in each depth # Space: O(n) class Solution(object): def makeLargestSpecial(self, S): """ :type S: str :rtype: str """ result ...
class Solution(object): def make_largest_special(self, S): """ :type S: str :rtype: str """ result = [] anchor = count = 0 for (i, v) in enumerate(S): count += 1 if v == '1' else -1 if count == 0: result.append('1{}0'.f...
''' Problem: For the numbers 1 to 100, print fizz if divisible by 3, bang if divisible by 5. '''
""" Problem: For the numbers 1 to 100, print fizz if divisible by 3, bang if divisible by 5. """
class Solution: def breakPalindrome(self, palindrome: str) -> str: if len(palindrome) == 1: return "" for char in palindrome[: len(palindrome) // 2]: if char != "a": return palindrome.replace(char, "a", 1) return palindrome[:-1] + "b"
class Solution: def break_palindrome(self, palindrome: str) -> str: if len(palindrome) == 1: return '' for char in palindrome[:len(palindrome) // 2]: if char != 'a': return palindrome.replace(char, 'a', 1) return palindrome[:-1] + 'b'
cntr = 0 with open('../data/css_comvoi/train.txt', 'r', encoding='utf-8') as f: with open('../data/css10/newtrain.txt', 'w', encoding='utf-8') as f2: for line in f: if cntr % 4 != 3: print(line.rstrip(), file=f2) cntr += 1
cntr = 0 with open('../data/css_comvoi/train.txt', 'r', encoding='utf-8') as f: with open('../data/css10/newtrain.txt', 'w', encoding='utf-8') as f2: for line in f: if cntr % 4 != 3: print(line.rstrip(), file=f2) cntr += 1
Numbers = [] while True: try: V = float(input('')) D = float(input('')) R = D / 2 A = 3.14 * (R ** 2) H = V / A print('ALTURA = %0.2f' %H) print('AREA = %0.2f' %A) except EOFError: break
numbers = [] while True: try: v = float(input('')) d = float(input('')) r = D / 2 a = 3.14 * R ** 2 h = V / A print('ALTURA = %0.2f' % H) print('AREA = %0.2f' % A) except EOFError: break
i2 = input() d2 = input() s2 = input() print(i+int(i2)) print(d+float(d2)) print(s + s2)
i2 = input() d2 = input() s2 = input() print(i + int(i2)) print(d + float(d2)) print(s + s2)
def next_pws(pw): while True: idx = -1 while pw[idx] == 'z': pw[idx] = 'a' idx -= 1 pw[idx] = chr(ord(pw[idx]) + 1) yield pw has_increasing_straight = lambda pw_nums: ( any(a == b-1 == c-2 for a, b, c in zip(pw_nums, pw_nums[1:], pw_nums[2:]))) has_invali...
def next_pws(pw): while True: idx = -1 while pw[idx] == 'z': pw[idx] = 'a' idx -= 1 pw[idx] = chr(ord(pw[idx]) + 1) yield pw has_increasing_straight = lambda pw_nums: any((a == b - 1 == c - 2 for (a, b, c) in zip(pw_nums, pw_nums[1:], pw_nums[2:]))) has_invali...
""" Workbench CLI Version """ __version_info__ = (0, 3, 3) __version__ = '.'.join(map(str, __version_info__))
""" Workbench CLI Version """ __version_info__ = (0, 3, 3) __version__ = '.'.join(map(str, __version_info__))
""" 0500. Keyboard Row Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Example: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"] Note: You may use one character in the keyboard more than once. You ...
""" 0500. Keyboard Row Given a List of words, return the words that can be typed using letters of alphabet on only one row's of American keyboard like the image below. Example: Input: ["Hello", "Alaska", "Dad", "Peace"] Output: ["Alaska", "Dad"] Note: You may use one character in the keyboard more than once. You ...
# 1st solution # O(n) time | O(n) space class Solution: def findJudge(self, n: int, trust: List[List[int]]) -> int: table = [[0, 0] for _ in range(n + 1)] for a, b in trust: table[a][0] += 1 table[b][1] += 1 judges = [] for i in range(1, n + 1): if...
class Solution: def find_judge(self, n: int, trust: List[List[int]]) -> int: table = [[0, 0] for _ in range(n + 1)] for (a, b) in trust: table[a][0] += 1 table[b][1] += 1 judges = [] for i in range(1, n + 1): if table[i][0] == 0 and table[i][1] ==...
class Automaton: # finals_states: finals states array # transitions: tuples array (first, c, ends_array) first -> c -> endi, # c is the transition character and endi belongs to ends array def __init__(self, states, start_state, finals_states, transitions): self.states = states self.tags ...
class Automaton: def __init__(self, states, start_state, finals_states, transitions): self.states = states self.tags = [None] * states self.items = [[] for _ in range(states)] self.start_state = start_state self.finals_states = finals_states self.transitions = {} ...