content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
"""
Collatz Conjecture exercise
"""
def steps(number):
"""
Count the number of steps
"""
if number <= 0:
raise ValueError("Only positive integers are allowed")
step = 0
while number != 1:
number = 3 * number + 1 if number % 2 else number // 2
step += 1
retur... | """
Collatz Conjecture exercise
"""
def steps(number):
"""
Count the number of steps
"""
if number <= 0:
raise value_error('Only positive integers are allowed')
step = 0
while number != 1:
number = 3 * number + 1 if number % 2 else number // 2
step += 1
retur... |
HDL_PORT = 6000
EMAIL_ADDRESS_FROM = 'sender@example.com'
EMAIL_ADDRESS_TO = 'receiver@example.com'
SMTP_HOST = 'smtp.example.com'
SMTP_PORT = 587
SMTP_USERNAME = 'sender'
SMTP_PASSWORD = 'topsecret'
| hdl_port = 6000
email_address_from = 'sender@example.com'
email_address_to = 'receiver@example.com'
smtp_host = 'smtp.example.com'
smtp_port = 587
smtp_username = 'sender'
smtp_password = 'topsecret' |
######################################### BeatDetector #############################################
# Author: Dan Boehm
#
# Copyright: 2011
#
# Description: The MusicFrameData class contains all of the information necessary for the
# LightSelector to make its decisions. It provides an easily accessible format f... | class Musicframedata:
beat_detected = False
beat__main = 0
beat__bands = [0]
def __init__(self, beatDetected, beat_Main, beat_Bands):
self.beatDetected = beatDetected
self.beat_Main = beat_Main
self.beat_Bands = beat_Bands |
# -*- coding: utf-8 -*-
"""
[Python 2.7 (Mayavi is not yet compatible with Python 3+)]
Created on Wed Apr 6 13:51:02 2016
@author: Ryan Stauffer
https://github.com/ryanpstauffer/market-vis
Market Visualization Prototype
__init__.py
"""
__version__ = "0.0.1"
| """
[Python 2.7 (Mayavi is not yet compatible with Python 3+)]
Created on Wed Apr 6 13:51:02 2016
@author: Ryan Stauffer
https://github.com/ryanpstauffer/market-vis
Market Visualization Prototype
__init__.py
"""
__version__ = '0.0.1' |
class StringValidator(object):
def __init__(self, max_length=-1):
self.max_length = max_length
self.value = None | class Stringvalidator(object):
def __init__(self, max_length=-1):
self.max_length = max_length
self.value = None |
#
# PySNMP MIB module ALTIGA-PPTP-STATS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALTIGA-PPTP-STATS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:05:53 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (al_pptp_mib_module,) = mibBuilder.importSymbols('ALTIGA-GLOBAL-REG', 'alPptpMibModule')
(al_pptp_group, al_stats_pptp) = mibBuilder.importSymbols('ALTIGA-MIB', 'alPptpGroup', 'alStatsPptp')
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(name... |
# 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 increasingBST(self, root: TreeNode) -> TreeNode:
l=[]
self.inorder(root,l)
t = ... | class Solution:
def increasing_bst(self, root: TreeNode) -> TreeNode:
l = []
self.inorder(root, l)
t = tree_node(val=l[0])
head = t
for i in l[1:]:
t.right = tree_node(val=i)
t = t.right
return head
def inorder(self, head, l):
if ... |
sum = 1
nnn = 2
mmm = 666666666
| sum = 1
nnn = 2
mmm = 666666666 |
def build_report_table(extra_queries):
table = []
column_names = ["Serializer", "Field", "Function", "Max queries"]
rows = [query.to_row() for query in extra_queries]
max_width = max(len(item) for row in rows for item in row)
table.append(
" | ".join(column_name.ljust(max_width) for column... | def build_report_table(extra_queries):
table = []
column_names = ['Serializer', 'Field', 'Function', 'Max queries']
rows = [query.to_row() for query in extra_queries]
max_width = max((len(item) for row in rows for item in row))
table.append(' | '.join((column_name.ljust(max_width) for column_name in... |
SAMPLE_TEXT = """title: FH Technikum Wien
subline: Elektronische Informationsdienste
externalurl: http://technikum-wien.at
duration: "abgeschlossen: 2006"
date: 2006-12-30 12:00
---
* Leistungsstipendium mehrmals erhalten: wird pro Studiengang (ca. 240 Studenten) an 6 Studenten pro Jahr vergeben.
* Teammitglied der [Au... | sample_text = 'title: FH Technikum Wien\nsubline: Elektronische Informationsdienste\nexternalurl: http://technikum-wien.at\nduration: "abgeschlossen: 2006"\ndate: 2006-12-30 12:00\n---\n* Leistungsstipendium mehrmals erhalten: wird pro Studiengang (ca. 240 Studenten) an 6 Studenten pro Jahr vergeben.\n* Teammitglied de... |
# -*- coding:utf-8 -*-
# @Time : 2021/8/18 13:43
# @Author : Charon.
__version_info__ = ('1', '2', '0')
__version__ = '.'.join(__version_info__)
| __version_info__ = ('1', '2', '0')
__version__ = '.'.join(__version_info__) |
#in_both (ch 8.9)
#brupoon 2014
def in_both(word1, word2):
"""Prints all letters in word1 that appear in word2"""
for letter in word1:
if letter in word2:
print(letter)
if __name__ == '__main__':
in_both("apple","orange")
| def in_both(word1, word2):
"""Prints all letters in word1 that appear in word2"""
for letter in word1:
if letter in word2:
print(letter)
if __name__ == '__main__':
in_both('apple', 'orange') |
class FilterIntegerRule(FilterNumericValueRule,IDisposable):
"""
A filter rule that operates on integer values in a Revit project.
FilterIntegerRule(valueProvider: FilterableValueProvider,evaluator: FilterNumericRuleEvaluator,ruleValue: int)
"""
def Dispose(self):
""" Dispose(self: FilterRule,A_0: b... | class Filterintegerrule(FilterNumericValueRule, IDisposable):
"""
A filter rule that operates on integer values in a Revit project.
FilterIntegerRule(valueProvider: FilterableValueProvider,evaluator: FilterNumericRuleEvaluator,ruleValue: int)
"""
def dispose(self):
""" Dispose(self: FilterRule,A... |
numero = int(input('Ingresa un numero positivo'))
if numero <= 0:
print('Le indicamos que el valor sea positivo')
# print("El valor capturado es ", numero)
print("I'm")
print(f"El valor capturado es {numero} por tanto es correcto")
| numero = int(input('Ingresa un numero positivo'))
if numero <= 0:
print('Le indicamos que el valor sea positivo')
print("I'm")
print(f'El valor capturado es {numero} por tanto es correcto') |
class Switch:
def __init__(self):
self.cases = {}
def case(self, case, function, parameters=None):
self.cases[str(case)] = {"name": function, "parameters": parameters}
def switch(self, case):
if (func := self.cases.get(str(case))):
name = func['name']
if fun... | class Switch:
def __init__(self):
self.cases = {}
def case(self, case, function, parameters=None):
self.cases[str(case)] = {'name': function, 'parameters': parameters}
def switch(self, case):
if (func := self.cases.get(str(case))):
name = func['name']
if fu... |
#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-
# +------------------------------------------------------------------+
# | ____ _ _ __ __ _ __ |
# | / ___| |__ ___ ___| | __ | \/ | |/ / |
# | | | | '_ \ / _ \/ __| |/ /... | register_rulegroup('activechecks', _('Active checks (HTTP, TCP, etc.)'), _('Configure active networking checks like HTTP and TCP'))
group = 'activechecks'
check_icmp_params = [('rta', tuple(title=_('Round trip average'), elements=[float(title=_('Warning if above'), unit='ms', default_value=200.0), float(title=_('Critic... |
def shellSort(arr):
gaps = [701, 301, 132, 57, 23, 10, 4, 1]
#go through each gap
for gap in gaps:
#no point in going through a gap larger than the array
if gap > len(arr):
continue
#perform insertion sort on the sublists created by the gap value
for start in range(gap):
#for every element in the c... | def shell_sort(arr):
gaps = [701, 301, 132, 57, 23, 10, 4, 1]
for gap in gaps:
if gap > len(arr):
continue
for start in range(gap):
for j in range(start, len(arr), gap):
current = arr[j]
sorted_index = j
while sorted_index >... |
#!/usr/bin/env python3
def main():
for _ in range(int(input())):
n, m = [int(n) for n in input().split()]
ans = '<' if n < m else '>' if n > m else '='
print(ans)
if __name__ == '__main__':
main()
| def main():
for _ in range(int(input())):
(n, m) = [int(n) for n in input().split()]
ans = '<' if n < m else '>' if n > m else '='
print(ans)
if __name__ == '__main__':
main() |
def sort(numbers):
for i in range(len(numbers) - 1, 0, -1):
for j in range(i):
if numbers[j] > numbers[j + 1]:
temp = numbers[j]
numbers[j] = numbers[j + 1]
numbers[j + 1] = temp
| def sort(numbers):
for i in range(len(numbers) - 1, 0, -1):
for j in range(i):
if numbers[j] > numbers[j + 1]:
temp = numbers[j]
numbers[j] = numbers[j + 1]
numbers[j + 1] = temp |
class Order:
def __init__(self, orderId: int, orderDate, customerId: int, productId: int, unitsOrdered: int, remarks):
self.orderId = orderId
self.orderDate = orderDate
self.customerId = customerId
self.productId = productId
self.unitsOrdered = unitsOrdered
self.remar... | class Order:
def __init__(self, orderId: int, orderDate, customerId: int, productId: int, unitsOrdered: int, remarks):
self.orderId = orderId
self.orderDate = orderDate
self.customerId = customerId
self.productId = productId
self.unitsOrdered = unitsOrdered
self.rema... |
A,B = map(int,input().split())
change = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
input()
num = list(map(int,input().split()))
if num[0] != 0:
change_num = ""
for i in num:
change_num += change[i]
ten_num = int(change_num,A)
rem = []
while ten_num:
rem.append(ten_num%B)
ten_n... | (a, b) = map(int, input().split())
change = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
input()
num = list(map(int, input().split()))
if num[0] != 0:
change_num = ''
for i in num:
change_num += change[i]
ten_num = int(change_num, A)
rem = []
while ten_num:
rem.append(ten_num % B)
... |
PRACTICE = False
with open("test.txt" if PRACTICE else "input.txt", "r") as f:
content = f.read().strip()
required_close_brackets = {
x[0]: x[1] for x in ("()", "[]", "{}", "<>")
}
score_key = {")": 1, "]": 2, "}": 3, ">": 4}
scores = []
for line in content.split("\n"):
stack = []
for i, c in enumer... | practice = False
with open('test.txt' if PRACTICE else 'input.txt', 'r') as f:
content = f.read().strip()
required_close_brackets = {x[0]: x[1] for x in ('()', '[]', '{}', '<>')}
score_key = {')': 1, ']': 2, '}': 3, '>': 4}
scores = []
for line in content.split('\n'):
stack = []
for (i, c) in enumerate(line... |
# -*- coding: utf-8 -*-
"""
This package contains modules wrapping different functions to call the system's status. Some
parts of this package are specific to Raspberry Pi and Raspbian, and are marked accordingly
in their respective doc strings.
"""
| """
This package contains modules wrapping different functions to call the system's status. Some
parts of this package are specific to Raspberry Pi and Raspbian, and are marked accordingly
in their respective doc strings.
""" |
def getSmallestElement(array):
smallestElement = array[0]
smallestIndex = 0
for i in range(1, len(array)):
if array[i] < smallestElement:
smallestElement = array[i]
smallestIndex = i
return smallestIndex
def selectionSort(array):
newArray = []
for i in range(len... | def get_smallest_element(array):
smallest_element = array[0]
smallest_index = 0
for i in range(1, len(array)):
if array[i] < smallestElement:
smallest_element = array[i]
smallest_index = i
return smallestIndex
def selection_sort(array):
new_array = []
for i in ra... |
S = input()
K = int(input())
for i in range(len(S)):
if S[i] == '1':
K -= 1
if K == 0:
print(S[i])
break
else:
print(S[i])
break
| s = input()
k = int(input())
for i in range(len(S)):
if S[i] == '1':
k -= 1
if K == 0:
print(S[i])
break
else:
print(S[i])
break |
class BaseScraper:
def __init__(self, url):
self.url = url
def scrape(self):
return {} | class Basescraper:
def __init__(self, url):
self.url = url
def scrape(self):
return {} |
username = driver.find_element_by_id('username')
username.send_keys('username')
password = driver.find_element_by_id('password')
password.send_keys('password')
login = driver.find_element_by_id('login')
login.click()
header = driver.find_element_by_id('header')
assert 'logged in' in header.get_attribute('text')
next = ... | username = driver.find_element_by_id('username')
username.send_keys('username')
password = driver.find_element_by_id('password')
password.send_keys('password')
login = driver.find_element_by_id('login')
login.click()
header = driver.find_element_by_id('header')
assert 'logged in' in header.get_attribute('text')
next = ... |
{ "name" : "Foyer",
"description" : "You're standing in the foyer of the building. You have stepped in here to escape a roaring thunderstorm which has left you soaked. You can see a doorway to the north.",
"neighbors" : {"n" : 2}
}
| {'name': 'Foyer', 'description': "You're standing in the foyer of the building. You have stepped in here to escape a roaring thunderstorm which has left you soaked. You can see a doorway to the north.", 'neighbors': {'n': 2}} |
"""Top-level numpy-api-bench __init__.py.
.. codeauthor:: Derek Huang <djh458@stern.nyu.edu>
"""
__version__ = "0.1.0" | """Top-level numpy-api-bench __init__.py.
.. codeauthor:: Derek Huang <djh458@stern.nyu.edu>
"""
__version__ = '0.1.0' |
def func():
outra_variavel = 'Denetrius'
return outra_variavel
def func2(arg):
print(arg)
var = func()
func2(var)
| def func():
outra_variavel = 'Denetrius'
return outra_variavel
def func2(arg):
print(arg)
var = func()
func2(var) |
"""constants.py Stores constants such as number of nodes NNODES etc."""
NNODES_ov_RLL10deg_CSne4 = 683
NNODES_outCSne8 = 386
NNODES_outCSne30 = 5402
NNODES_outRLL1deg = 64442
DATAVARS_outCSne30 = 2
| """constants.py Stores constants such as number of nodes NNODES etc."""
nnodes_ov_rll10deg_c_sne4 = 683
nnodes_out_c_sne8 = 386
nnodes_out_c_sne30 = 5402
nnodes_out_rll1deg = 64442
datavars_out_c_sne30 = 2 |
# URI Online Judge 1164
N = int(input())
for i in range(N):
sum = 0
entrada = int(input())
for j in range(1,entrada):
if entrada%j==0:
sum += j
if entrada == sum:
print("{} eh perfeito".format(entrada))
else:
print("{} nao eh perfeito".format(entrada)) | n = int(input())
for i in range(N):
sum = 0
entrada = int(input())
for j in range(1, entrada):
if entrada % j == 0:
sum += j
if entrada == sum:
print('{} eh perfeito'.format(entrada))
else:
print('{} nao eh perfeito'.format(entrada)) |
class Ponto:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
class Vetor:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
class Segmento:
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
class Reta:
def _... | class Ponto:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
class Vetor:
def __init__(self, x, y, z):
self.x = x
self.y = y
self.z = z
class Segmento:
def __init__(self, p1, p2):
self.p1 = p1
self.p2 = p2
class Reta:
d... |
#base class
class person:
def dislay(self):
print("Here the element of base class person...!!!! \n")
#derived class_1
class employee(person):
def printing(self):
print("Here the element of first element of derived class.....!!!! \n")
# derived class_2
class programmer(employee):
def sh... | class Person:
def dislay(self):
print('Here the element of base class person...!!!! \n')
class Employee(person):
def printing(self):
print('Here the element of first element of derived class.....!!!! \n')
class Programmer(employee):
def show(self):
print('Here the 2nd derived cl... |
class ODLRemoveOpenflowFlow(object):
def __init__(self, odl_client, logger):
"""
:param cloudshell.sdn.odl.client.ODLClient odl_client:
:param logging.Logger logger:
"""
self._odl_client = odl_client
self._logger = logger
def execute_flow(self, node_id, table_id... | class Odlremoveopenflowflow(object):
def __init__(self, odl_client, logger):
"""
:param cloudshell.sdn.odl.client.ODLClient odl_client:
:param logging.Logger logger:
"""
self._odl_client = odl_client
self._logger = logger
def execute_flow(self, node_id, table_i... |
contador=0
somador=0
while contador< 5:
contador = contador + 1
valor = float(input('digite o'+str(contador)+ 'valor:'))
somador = somador + valor
print ('soma = ', somador)
| contador = 0
somador = 0
while contador < 5:
contador = contador + 1
valor = float(input('digite o' + str(contador) + 'valor:'))
somador = somador + valor
print('soma = ', somador) |
#!/usr/bin/python
# encoding: utf-8
"""
@author: Ian
@file: main.py
@time: 2019-06-19 15:42
"""
if __name__ == '__main__':
while True:
print('please select: 1) data explore; 2) train; 3) test')
a = input()
if a == 'q':
print(f'bye! {a}')
break
print(f'hi {a}'... | """
@author: Ian
@file: main.py
@time: 2019-06-19 15:42
"""
if __name__ == '__main__':
while True:
print('please select: 1) data explore; 2) train; 3) test')
a = input()
if a == 'q':
print(f'bye! {a}')
break
print(f'hi {a}') |
string = "Hello, World!"
string2 = "- Hello to you!"
string3 = string + '' + string2
count = len(string)
print(f"Count symbols: {count}")
print(string3)
print((string + "")*3)
string = "I aM a StrinG aNd i wAnt To Be pRinTed"
print(string.upper())
print(string.lower())
print(string.capitalize())
print(string.title())
s... | string = 'Hello, World!'
string2 = '- Hello to you!'
string3 = string + '' + string2
count = len(string)
print(f'Count symbols: {count}')
print(string3)
print((string + '') * 3)
string = 'I aM a StrinG aNd i wAnt To Be pRinTed'
print(string.upper())
print(string.lower())
print(string.capitalize())
print(string.title())... |
# Control
def double(a: int) -> int:
return 2*a
# Remove the brackets
def double(a: int) -> (int):
return 2*a
# Some newline variations
def double(a: int) -> (
int):
return 2*a
def double(a: int) -> (int
):
return 2*a
def double(a: int) -> (
int
):
return 2*a
# Don't lose the comments
d... | def double(a: int) -> int:
return 2 * a
def double(a: int) -> int:
return 2 * a
def double(a: int) -> int:
return 2 * a
def double(a: int) -> int:
return 2 * a
def double(a: int) -> int:
return 2 * a
def double(a: int) -> int:
return 2 * a
def double(a: int) -> int:
return 2 * a
def f... |
# -*- coding: utf-8 -*-
db_config = {
'user': 'root',
'password': 'root',
'host': 'localhost',
'db': 'bac_db'
}
bot_code = "INSERT:TELEGRAM-BOT-TOKEN- HERE"
| db_config = {'user': 'root', 'password': 'root', 'host': 'localhost', 'db': 'bac_db'}
bot_code = 'INSERT:TELEGRAM-BOT-TOKEN- HERE' |
# ====================================================================================================
# This file provides class with the necessary sub functions for the calculation of breakpoint distance
# ====================================================================================================
class bp_a... | class Bp_Assist:
def bp_assister(self, dist, usr_ht):
if usr_ht < 13:
c = 0
elif usr_ht >= 13 and usr_ht <= 23:
c = ((usr_ht - 13) / 10) ** 1.5 * self.g(dist)
return C
def g(self, dist):
if dist < 18:
g = 0
return G
else:
... |
class IResponseCallback:
def on_response(self, response):
"""handle the async response of the mqtt request
:param response:
:return:
"""
print('[async] receive {} successfully, code: {}'.format(response.get_class(), str(response.get_code())))
def on_failure(self, except... | class Iresponsecallback:
def on_response(self, response):
"""handle the async response of the mqtt request
:param response:
:return:
"""
print('[async] receive {} successfully, code: {}'.format(response.get_class(), str(response.get_code())))
def on_failure(self, except... |
test_cases = int(input().strip())
for t in range(1, test_cases + 1):
n, m, k = tuple(map(int, input().strip().split()))
persons = list(map(int, input().strip().split()))
persons.sort()
result = 1
cnt = 1
for p in persons:
fish = (p // m) * k
if fish - cnt < 0:
result... | test_cases = int(input().strip())
for t in range(1, test_cases + 1):
(n, m, k) = tuple(map(int, input().strip().split()))
persons = list(map(int, input().strip().split()))
persons.sort()
result = 1
cnt = 1
for p in persons:
fish = p // m * k
if fish - cnt < 0:
result ... |
"""Color palette 'The New Defaults' from clrs.cc"""
clrs = {
"aqua": "#7FDBFF",
"blue": "#0074D9",
"navy": "#001F3F",
"teal": "#39CCCC",
"green": "#2ECC40",
"olive": "#3D9970",
"lime": "#01FF70",
"yellow": "#FFDC00",
"orange": "#FF851B",
"red": "#FF4136",
"fuchsia": "#F012BE"... | """Color palette 'The New Defaults' from clrs.cc"""
clrs = {'aqua': '#7FDBFF', 'blue': '#0074D9', 'navy': '#001F3F', 'teal': '#39CCCC', 'green': '#2ECC40', 'olive': '#3D9970', 'lime': '#01FF70', 'yellow': '#FFDC00', 'orange': '#FF851B', 'red': '#FF4136', 'fuchsia': '#F012BE', 'purple': '#B10DC9', 'maroon': '#85144B', '... |
# https://leetcode.com/problems/minimum-number-of-frogs-croaking
class Solution:
def minNumberOfFrogs(self, croakOfFrogs: str) -> int:
min_frog = 0
status = [0,0,0,0,0]
cindex_dict = {
"c": 0,
"r": 1,
"o": 2,
"a": 3,
"k": 4
... | class Solution:
def min_number_of_frogs(self, croakOfFrogs: str) -> int:
min_frog = 0
status = [0, 0, 0, 0, 0]
cindex_dict = {'c': 0, 'r': 1, 'o': 2, 'a': 3, 'k': 4}
for c in croakOfFrogs:
cindex = cindex_dict.get(c)
if cindex == 0:
status[cin... |
## Automatically adapted for numpy Apr 14, 2006 by convertcode.py
class infodata:
def __init__(self, filenm):
self.breaks = 0
for line in open(filenm):
if line.startswith(" Data file name"):
self.basenm = line.split("=")[-1].strip()
continue
i... | class Infodata:
def __init__(self, filenm):
self.breaks = 0
for line in open(filenm):
if line.startswith(' Data file name'):
self.basenm = line.split('=')[-1].strip()
continue
if line.startswith(' Telescope'):
self.telescope = ... |
cpal = [
0.0000060916,
0.0000090829,
0.0000166305,
0.0000300004,
0.0000543398,
0.0000914975,
0.0001482915,
0.0001569609,
0.0001661808,
0.0002504709
]
qpal = [
0.0171114387,
0.0179425966,
0.0118157289,
0.0111629430,
0.0099376996,
0.0104620373,
0.0122294195,
0.0105990863,
0.0102895846,
0.0119658362
]
cole = [
0.0000812... | cpal = [6.0916e-06, 9.0829e-06, 1.66305e-05, 3.00004e-05, 5.43398e-05, 9.14975e-05, 0.0001482915, 0.0001569609, 0.0001661808, 0.0002504709]
qpal = [0.0171114387, 0.0179425966, 0.0118157289, 0.011162943, 0.0099376996, 0.0104620373, 0.0122294195, 0.0105990863, 0.0102895846, 0.0119658362]
cole = [8.12625e-05, 0.0001426769... |
'''
Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
'''
def getServiceNameFromChannel(channel, pub):
# Public channels are of form /bot/<NAME>
# Private channels are of form /service/bot/<NAME>/(request|response)
parts = channel.sp... | """
Copyright (c) The Dojo Foundation 2011. All Rights Reserved.
Copyright (c) IBM Corporation 2008, 2011. All Rights Reserved.
"""
def get_service_name_from_channel(channel, pub):
parts = channel.split('/')
if pub:
if 3 == len(parts):
return parts[2]
elif 5 == len(parts) and ('request'... |
class ConfigError(Exception):
def __init__(self, config_option, value):
self.config_option = config_option
self.value = value
class UnhandledObjectError(Exception):
def __init__(self, obj_type):
self.obj_type = obj_type
class UnimplementedOutcomeError(Exception):
def __init__(sel... | class Configerror(Exception):
def __init__(self, config_option, value):
self.config_option = config_option
self.value = value
class Unhandledobjecterror(Exception):
def __init__(self, obj_type):
self.obj_type = obj_type
class Unimplementedoutcomeerror(Exception):
def __init__(se... |
''' Univesidade Federal de Pernambuco -- UFPE (http://www.ufpe.br)
Centro de Informatica -- CIn (http://www.cin.ufpe.br) IF969 --
Algoritmos e Estruturas de Dados
Autor: Saulo de Sousa Joseph
Email: ssj2@cin.ufpe.br
Data: 10/09/2019
Descricao: lista de monitoria Q1
Licenca: The MIT License (MIT)
'''
... | """ Univesidade Federal de Pernambuco -- UFPE (http://www.ufpe.br)
Centro de Informatica -- CIn (http://www.cin.ufpe.br) IF969 --
Algoritmos e Estruturas de Dados
Autor: Saulo de Sousa Joseph
Email: ssj2@cin.ufpe.br
Data: 10/09/2019
Descricao: lista de monitoria Q1
Licenca: The MIT License (MIT)
"""
c... |
#Filename : 9x9.py
#author by: Thomas.Wu
#use for
print("------------------Use for to do 9x9----------------")
for i in range(1, 10):
for j in range(1, i+1):
print('{}x{}={}\t'.format(j, i, i*j), end='')
print()
#V2
#use while
print("------------------Use While to 9x9------------------")
i = 1
while i... | print('------------------Use for to do 9x9----------------')
for i in range(1, 10):
for j in range(1, i + 1):
print('{}x{}={}\t'.format(j, i, i * j), end='')
print()
print('------------------Use While to 9x9------------------')
i = 1
while i <= 9:
j = 1
while j <= i:
print('{}x{}={}\t'.... |
# -*- coding: utf-8 -*-
n = int(input())
for x in range(n):
qtd_pessoas = int(input())
lista = []
for y in range(qtd_pessoas):
lista.append(input())
if all(e == lista[0] for e in lista):
print(lista[0])
else:
print('ingles')
| n = int(input())
for x in range(n):
qtd_pessoas = int(input())
lista = []
for y in range(qtd_pessoas):
lista.append(input())
if all((e == lista[0] for e in lista)):
print(lista[0])
else:
print('ingles') |
class Solution(object):
def isAdditiveNumberInternal(self, num, l1, l2):
n1 = num[:l1]
n2 = num[l1:l1 + l2]
if (len(n1) > 1 and n1[0] == '0') or (len(n2) > 1 and n2[0] == '0'):
return False
n1, n2 = int(n1), int(n2)
cur = l1 + l2
while True:
if... | class Solution(object):
def is_additive_number_internal(self, num, l1, l2):
n1 = num[:l1]
n2 = num[l1:l1 + l2]
if len(n1) > 1 and n1[0] == '0' or (len(n2) > 1 and n2[0] == '0'):
return False
(n1, n2) = (int(n1), int(n2))
cur = l1 + l2
while True:
... |
# We can get a part of list by using slice.
my_list = ["h", "e", "l", "l", "o", "!"]
print(my_list[0:3]) # Returns 0 - 2nd index
print(my_list[:]) # clone full list
print(my_list[-1]) # Special way to get last element
del my_list[2] # delete item from list.
print(my_list)
| my_list = ['h', 'e', 'l', 'l', 'o', '!']
print(my_list[0:3])
print(my_list[:])
print(my_list[-1])
del my_list[2]
print(my_list) |
def get_python_executables():
"""
:return: Linux maya python executables
:rtype: dict
"""
maya_pythons = {}
return maya_pythons
| def get_python_executables():
"""
:return: Linux maya python executables
:rtype: dict
"""
maya_pythons = {}
return maya_pythons |
# !/usr/bin/python
# -*- coding:utf-8 -*-
# ***********************************************************************
# Author: Zhichang Fu
# Created Time: 2018-08-25 11:04:06
# Function:
# Exception module
# ***********************************************************************
class UnknownDB(Exception):
"""r... | class Unknowndb(Exception):
"""raised for unsupported dbn"""
pass
class Unknownparamstyle(Exception):
"""
raised for unsupported db paramstyles
(currently supported: qmark, numeric, format, pyformat)
"""
pass
class _Itplerror(ValueError):
def __init__(self, text, pos):
ValueE... |
'''
Given a string and a pattern, find out if the string contains any permutation of the pattern.
Example: s="oidbcaf", pattern="abc", Output: True
Time complexity: O(len(pattern) + len(s))
Space complexity: O(len(pattern))
'''
class Solution:
def checkInclusion(self, pattern: str, s: str) -> bool:
# re... | """
Given a string and a pattern, find out if the string contains any permutation of the pattern.
Example: s="oidbcaf", pattern="abc", Output: True
Time complexity: O(len(pattern) + len(s))
Space complexity: O(len(pattern))
"""
class Solution:
def check_inclusion(self, pattern: str, s: str) -> bool:
cha... |
# Maximize Distance to Closest Person
'''
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).
There is at least one empty seat, and at least one person sitting.
Alex wants to sit in the ... | """
You are given an array representing a row of seats where seats[i] = 1 represents a person sitting in the ith seat, and seats[i] = 0 represents that the ith seat is empty (0-indexed).
There is at least one empty seat, and at least one person sitting.
Alex wants to sit in the seat such that the distance between him... |
#!/usr/local/bin/python3
INPUT = "597662997341859357902611157036208771903818242152098532077631945761286356313596828766120793552153504735776047215557289042266690216296378293233573125233893740967616776128472704996683708081711977654975119692404514948640287120457947767118622758534054654011813904187289966467945017396009280... | input = '59766299734185935790261115703620877190381824215209853207763194576128635631359682876612079355215350473577604721555728904226669021629637829323357312523389374096761677612847270499668370808171197765497511969240451494864028712045794776711862275853405465401181390418728996646794501739600928008413106803610665694684578... |
OPERATION_VALIDATION_PLUGIN_PATH_VALUE = "operation_verification"
AUCTION_REQ_VALIDATION_PLUGIN_PATH_VALUE = "auction_req_validation"
AUCTION_REQ_PROCESSOR_PLUGIN_PATH_VALUE = "auction_req_processor"
BANK_REQ_VALIDATION_PLUGIN_PATH_VALUE = "bank_req_validation"
BANK_REQ_PROCESSOR_PLUGIN_PATH_VALUE = "bank_req_processor... | operation_validation_plugin_path_value = 'operation_verification'
auction_req_validation_plugin_path_value = 'auction_req_validation'
auction_req_processor_plugin_path_value = 'auction_req_processor'
bank_req_validation_plugin_path_value = 'bank_req_validation'
bank_req_processor_plugin_path_value = 'bank_req_processor... |
total = 0
totalRibbon = 0
f = open("input.txt")
for line in f:
temp = ""
length = 0
width = 0
height = 0
for c in line:
if c.isdigit():
temp += c
else:
if length == 0:
length = int(temp)
elif width == 0:
width = int(temp)
elif height == 0:
height = int(temp)
temp = ""
area = ... | total = 0
total_ribbon = 0
f = open('input.txt')
for line in f:
temp = ''
length = 0
width = 0
height = 0
for c in line:
if c.isdigit():
temp += c
else:
if length == 0:
length = int(temp)
elif width == 0:
width = int... |
def rounding(*args):
result = []
for el in args[0]:
result.append(round(float(el)))
return result
print(rounding(input().split()))
| def rounding(*args):
result = []
for el in args[0]:
result.append(round(float(el)))
return result
print(rounding(input().split())) |
Carless = Goalkeeper('Ben Carless', 68, 65, 66, 67)
Kyriakides = Outfield_Player('Dan Kyriakides', 'DF', 63, 74, 67, 63, 66, 65)
Cornick = Outfield_Player('Andrew Cornick', 'MF', 67, 66, 68, 63, 69, 65)
Brignull = Outfield_Player('Liam Brignull', 'MF', 62, 69, 65, 69, 67, 65)
Furlong = Outfield_Player('Gareth Furlo... | carless = goalkeeper('Ben Carless', 68, 65, 66, 67)
kyriakides = outfield__player('Dan Kyriakides', 'DF', 63, 74, 67, 63, 66, 65)
cornick = outfield__player('Andrew Cornick', 'MF', 67, 66, 68, 63, 69, 65)
brignull = outfield__player('Liam Brignull', 'MF', 62, 69, 65, 69, 67, 65)
furlong = outfield__player('Gareth Furlo... |
def playHand(hand, wordList, n):
"""
Allows the user to play the given hand, as follows:
* The hand is displayed.
* The user may input a word or a single period (the string ".")
to indicate they're done playing
* Invalid words are rejected, and a message is displayed asking
the user to... | def play_hand(hand, wordList, n):
"""
Allows the user to play the given hand, as follows:
* The hand is displayed.
* The user may input a word or a single period (the string ".")
to indicate they're done playing
* Invalid words are rejected, and a message is displayed asking
the user t... |
#
# @lc app=leetcode id=735 lang=python3
#
# [735] Asteroid Collision
#
# https://leetcode.com/problems/asteroid-collision/description/
#
# algorithms
# Medium (40.39%)
# Likes: 882
# Dislikes: 100
# Total Accepted: 53.2K
# Total Submissions: 131.6K
# Testcase Example: '[5,10,-5]'
#
#
# We are given an array as... | def collide(left_a, right_a):
return right_a < 0 < left_a
class Solution:
def asteroid_collision(self, asteroids: List[int]) -> List[int]:
survivors = []
for a in asteroids:
abs_a = abs(a)
while survivors and collide(survivors[-1], a):
if survivors[-1] <... |
USER_ABS_ENDPOINT_NAME = '/user'
REQ_USER_ID_KEY_NAME = 'id'
RES_USER_ID_KEY_NAME = 'id'
RES_USER_EMAIL_KEY_NAME = 'email'
RES_USER_FIRST_NAME_KEY_NAME = 'first_name'
RES_USER_LAST_NAME_KEY_NAME = 'last_name'
RES_USER_PROFILE_PICTURE_URL_KEY_NAME = 'profile_image_url'
RES_USER_GENDER_KEY_NAME = 'gender'
... | user_abs_endpoint_name = '/user'
req_user_id_key_name = 'id'
res_user_id_key_name = 'id'
res_user_email_key_name = 'email'
res_user_first_name_key_name = 'first_name'
res_user_last_name_key_name = 'last_name'
res_user_profile_picture_url_key_name = 'profile_image_url'
res_user_gender_key_name = 'gender'
res_user_birthd... |
## -*- coding: utf-8 -*-
nodo = {
"nombre": "juan",
"edad": 15
} | nodo = {'nombre': 'juan', 'edad': 15} |
def binary_length(n):
if n == 0: return 0
else: return 1 + binary_length(n / 256)
def to_binary_array(n,L=None):
if L is None: L = binary_length(n)
if n == 0: return []
else:
x = to_binary_array(n / 256)
x.append(n % 256)
return x
def to_binary(n,L=None): return ''.join([ch... | def binary_length(n):
if n == 0:
return 0
else:
return 1 + binary_length(n / 256)
def to_binary_array(n, L=None):
if L is None:
l = binary_length(n)
if n == 0:
return []
else:
x = to_binary_array(n / 256)
x.append(n % 256)
return x
def to_bin... |
def input_file_to_list(file_path):
with open(file_path, 'r') as input_file:
output = list(map(int, input_file.read().split(',')))
return output
def run_intcode_program(intcode_input):
index = 0
while intcode_input[index] in [1, 2]:
opcode, first_value, second_value, position = intcode_... | def input_file_to_list(file_path):
with open(file_path, 'r') as input_file:
output = list(map(int, input_file.read().split(',')))
return output
def run_intcode_program(intcode_input):
index = 0
while intcode_input[index] in [1, 2]:
(opcode, first_value, second_value, position) = intcode... |
class BaseConfig(object):
DEBUG = False
TESTING = False
SECRET_KEY = 'this-really-needs-to-be-changed'
MONGO_USERNAME = 'username'
MONGO_PASSWORD = 'password'
MONGO_URI = f'mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@localhost:27017/photoseleven'
TOKEN_EXPIRATION_DAYS = 365
UPLOADS_DIR =... | class Baseconfig(object):
debug = False
testing = False
secret_key = 'this-really-needs-to-be-changed'
mongo_username = 'username'
mongo_password = 'password'
mongo_uri = f'mongodb://{MONGO_USERNAME}:{MONGO_PASSWORD}@localhost:27017/photoseleven'
token_expiration_days = 365
uploads_dir =... |
"""
Simple solution
Step-1: Find the sum (s) of all the values in array[]
Step-2: Replace every arra[i] with s/arra[i]
"""
def solution(input_list):
product = 1
for i in input_list:
product *= i
for i in range(len(input_list)):
input_list[i] = int(product / input_list[i])
if __n... | """
Simple solution
Step-1: Find the sum (s) of all the values in array[]
Step-2: Replace every arra[i] with s/arra[i]
"""
def solution(input_list):
product = 1
for i in input_list:
product *= i
for i in range(len(input_list)):
input_list[i] = int(product / input_list[i])
if __name_... |
"""
Given an infinite number of quarters (25 cents), dimes (10 cents),
nickels (5 cents) and pennies (1 cent), write code to calculate the
number of ways of representing n cents
"""
| """
Given an infinite number of quarters (25 cents), dimes (10 cents),
nickels (5 cents) and pennies (1 cent), write code to calculate the
number of ways of representing n cents
""" |
n = int(input())
i = 1
print(i, end=" ")
while True:
if i * 2 > n:
break
print(i * 2, end=" ")
i *= 2
| n = int(input())
i = 1
print(i, end=' ')
while True:
if i * 2 > n:
break
print(i * 2, end=' ')
i *= 2 |
def sortByHeight(a):
copy = a[:]
while -1 in copy:
copy.remove(-1)
copy.sort()
counter = 0
for number in range(len(a)):
if a[number] != -1:
a[number] = copy[counter]
counter += 1
return a | def sort_by_height(a):
copy = a[:]
while -1 in copy:
copy.remove(-1)
copy.sort()
counter = 0
for number in range(len(a)):
if a[number] != -1:
a[number] = copy[counter]
counter += 1
return a |
def resolve():
'''
code here
'''
N = int(input())
As = [int(item) for item in input().split()]
memo = As[0]
res = 0
for i in range(N-1):
res += (memo * As[i+1])%(10**9 + 7)
memo += As[i+1]
print(res % (10**9 + 7))
if __name__ == "__main__":
resolve()
| def resolve():
"""
code here
"""
n = int(input())
as = [int(item) for item in input().split()]
memo = As[0]
res = 0
for i in range(N - 1):
res += memo * As[i + 1] % (10 ** 9 + 7)
memo += As[i + 1]
print(res % (10 ** 9 + 7))
if __name__ == '__main__':
resolve() |
#
# PySNMP MIB module HPN-ICF-USER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-USER-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:29:41 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ... |
DATE_STRING_FORMAT = '%Y-%m-%d'
COLLOQUIAL_DATE_LOOKUP = (
'Today',
'Tomorrow',
)
WEEKDAY_LOOKUP = (
'Monday',
'Tuesday',
'Wednesday',
'Thursday',
'Friday',
'Saturday',
'Sunday',
)
| date_string_format = '%Y-%m-%d'
colloquial_date_lookup = ('Today', 'Tomorrow')
weekday_lookup = ('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday') |
#
# PySNMP MIB module ARMILLAIRE2000-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ARMILLAIRE2000-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:25:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ... |
TRAIN_BEGIN = 'TRAIN_BEGIN'
TRAIN_END = 'TRAIN_END'
EPOCH_BEGIN = 'EPOCH_BEGIN'
EPOCH_END = 'EPOCH_END'
BATCH_BEGIN = 'BATCH_BEGIN'
BATCH_END = 'BATCH_END'
| train_begin = 'TRAIN_BEGIN'
train_end = 'TRAIN_END'
epoch_begin = 'EPOCH_BEGIN'
epoch_end = 'EPOCH_END'
batch_begin = 'BATCH_BEGIN'
batch_end = 'BATCH_END' |
"""An implementation of the Enigma Machine in Python.
This is a toy project intending to implement the Enigma Machine as originally
designed by Arthur Scherbius.
Based on project: https://github.com/ZAdamMac/python-enigma
Modyfication by Adam Jurkiewicz adam(at)abixedukacja.eu - 2020
Apache 2.0 License
"""
default_... | """An implementation of the Enigma Machine in Python.
This is a toy project intending to implement the Enigma Machine as originally
designed by Arthur Scherbius.
Based on project: https://github.com/ZAdamMac/python-enigma
Modyfication by Adam Jurkiewicz adam(at)abixedukacja.eu - 2020
Apache 2.0 License
"""
default_r... |
r"""
Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the
absolute difference between the sum of all left subtree node values and the sum of all right subtree
node values. Null node has tilt 0. The tilt of the whole tree is defined as the sum of all nodes' tilt.
Example:
... | """
Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the
absolute difference between the sum of all left subtree node values and the sum of all right subtree
node values. Null node has tilt 0. The tilt of the whole tree is defined as the sum of all nodes' tilt.
Example:
... |
class Solution:
def isPalindrome(self, x: int) -> bool:
output = []
if x < 0:
return False
elif x == 0:
return True
i = 0
while x > 0:
last_digit = x % 10
if i == 0 and last_digit == 0:
return False
i... | class Solution:
def is_palindrome(self, x: int) -> bool:
output = []
if x < 0:
return False
elif x == 0:
return True
i = 0
while x > 0:
last_digit = x % 10
if i == 0 and last_digit == 0:
return False
... |
def counting_sort(x):
N = len(x)
M = max(x) + 1
a = [0] * M
for v in x:
a[v] += 1
res = []
for i in range(M):
for j in range(a[i]):
res.append(i)
return res
def counting_sort2(x):
N = len(x)
M = max(x) + 1
c = [0] * M
for v in x:
c[v] += ... | def counting_sort(x):
n = len(x)
m = max(x) + 1
a = [0] * M
for v in x:
a[v] += 1
res = []
for i in range(M):
for j in range(a[i]):
res.append(i)
return res
def counting_sort2(x):
n = len(x)
m = max(x) + 1
c = [0] * M
for v in x:
c[v] += 1... |
class Solution:
def countSubstrings(self, s):
dp = [[0] * len(s) for i in range(len(s))]
res = 0
for r in range(len(s)):
for l in range(r+1):
if s[r] == s[l]:
if r == l or r+1 == l or dp[l+1][r-1] == 1:
dp[l][r] = 1
... | class Solution:
def count_substrings(self, s):
dp = [[0] * len(s) for i in range(len(s))]
res = 0
for r in range(len(s)):
for l in range(r + 1):
if s[r] == s[l]:
if r == l or r + 1 == l or dp[l + 1][r - 1] == 1:
dp[l][r... |
# coding: utf-8
#
# Copyright 2022 :Barry-Thomas-Paul: Moss
#
# 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 applicab... | class Copytablecontinuation(object):
"""
Const Class
specifies the possible continuations when copying a table row via a CopyTableWizard failed.
See Also:
`API CopyTableContinuation <https://api.libreoffice.org/docs/idl/ref/namespacecom_1_1sun_1_1star_1_1sdb_1_1application_1_1CopyTableContinua... |
"""
A module with a well-specified function
Author: Walker M. White
Date: February 14, 2019
"""
def number_vowels(w):
"""
Returns: number of vowels in string w.
Vowels are defined to be 'a','e','i','o', and 'u'. 'y' is a
vowel if it is not at the start of the word.
Repeated vowels are counte... | """
A module with a well-specified function
Author: Walker M. White
Date: February 14, 2019
"""
def number_vowels(w):
"""
Returns: number of vowels in string w.
Vowels are defined to be 'a','e','i','o', and 'u'. 'y' is a
vowel if it is not at the start of the word.\x0b
Repeated vowels are coun... |
# projecteuler.net/problem=52
def main():
answer = PermutatedMul()
print("Answer: {}".format(answer))
def PermutatedMul():
i = 1
muls = [2,3,4,5,6]
while True:
found = True
i += 1
si = list(str(i))
ops = list(map(lambda x: x * i, muls))
for... | def main():
answer = permutated_mul()
print('Answer: {}'.format(answer))
def permutated_mul():
i = 1
muls = [2, 3, 4, 5, 6]
while True:
found = True
i += 1
si = list(str(i))
ops = list(map(lambda x: x * i, muls))
for num in ops:
if len(str(i)) != ... |
YEAR_IN_S = 31557600.
GEV_IN_KEV = 1.e6
C_KMSEC = 299792.458
NUCLEON_MASS = 0.938272 # Nucleon mass in GeV
P_MAGMOM = 2.793 # proton magnetic moment, PDG Live
N_MAGMOM = -1.913 # neutron magnetic moment, PDG Live
NUCLEAR_MASSES = {
'xenon': 122.298654871,
'germanium': 67.663731424,
'argon': 37.2113263068,... | year_in_s = 31557600.0
gev_in_kev = 1000000.0
c_kmsec = 299792.458
nucleon_mass = 0.938272
p_magmom = 2.793
n_magmom = -1.913
nuclear_masses = {'xenon': 122.298654871, 'germanium': 67.663731424, 'argon': 37.2113263068, 'silicon': 26.1614775455, 'sodium': 21.4140502327, 'iodine': 118.206437626, 'fluorine': 17.6969003039... |
class FrameworkTextComposition(TextComposition):
""" Represents a composition during the text input events of a System.Windows.Controls.TextBox. """
def Complete(self):
"""
Complete(self: FrameworkTextComposition)
Finalizes the composition.
"""
pass
CompositionLength=property(lambda self: object(... | class Frameworktextcomposition(TextComposition):
""" Represents a composition during the text input events of a System.Windows.Controls.TextBox. """
def complete(self):
"""
Complete(self: FrameworkTextComposition)
Finalizes the composition.
"""
pass
composition_length = property(lam... |
def get_version(testbed: str):
path = [e for e in testbed.split(" ") if e.find("/") > -1][0]
full_name = path.split("/")[-1]
return full_name.replace(".jar", "")
def parse_engine_name(testbed: str):
return get_version(testbed).split("-")[0]
| def get_version(testbed: str):
path = [e for e in testbed.split(' ') if e.find('/') > -1][0]
full_name = path.split('/')[-1]
return full_name.replace('.jar', '')
def parse_engine_name(testbed: str):
return get_version(testbed).split('-')[0] |
def predict(text, with_neu=True): # requires string input.
start_at = time.time()
x_test = pad_sequences(tokenizer.texts_to_sequences([text]), maxlen=seq_len)
score = model.predict([x_test])[0]
label = decode_sentiment(score, with_neu=with_neu)
score = float(score)
return {print(f"label: {label}... | def predict(text, with_neu=True):
start_at = time.time()
x_test = pad_sequences(tokenizer.texts_to_sequences([text]), maxlen=seq_len)
score = model.predict([x_test])[0]
label = decode_sentiment(score, with_neu=with_neu)
score = float(score)
return {print(f'label: {label}, score: {score}, calcula... |
def get_session_attributes(previous_intent = "", previous_intent_attributes = "", requested_value = "", previous_requested_value = "", questions_urls = [], question_now_id = 0, question_name = "", answers_ids = [], answer_now_id = 0, comments_ids = [], comment_now_id = 0, complete_answer = [], complete_code = [], comp... | def get_session_attributes(previous_intent='', previous_intent_attributes='', requested_value='', previous_requested_value='', questions_urls=[], question_now_id=0, question_name='', answers_ids=[], answer_now_id=0, comments_ids=[], comment_now_id=0, complete_answer=[], complete_code=[], complete_code_now_id=0):
se... |
def bag_of_words(text):
"""Returns bag-of-words representation of the input text.
Args:
text: A string containing the text.
Returns:
A dictionary of strings to integers.
"""
bag = {}
for word in text.lower().split():
bag[word] = bag.get(word, 0) + 1
return bag
| def bag_of_words(text):
"""Returns bag-of-words representation of the input text.
Args:
text: A string containing the text.
Returns:
A dictionary of strings to integers.
"""
bag = {}
for word in text.lower().split():
bag[word] = bag.get(word, 0) + 1
return bag |
STATS = [
{
"num_node_expansions": 0,
"search_time": 0.0929848,
"total_time": 0.206795,
"plan_length": 209,
"plan_cost": 209,
"objects_used": 145,
"objects_total": 253,
"neural_net_time": 0.09392738342285156,
"num_replanning_steps": 0,
... | stats = [{'num_node_expansions': 0, 'search_time': 0.0929848, 'total_time': 0.206795, 'plan_length': 209, 'plan_cost': 209, 'objects_used': 145, 'objects_total': 253, 'neural_net_time': 0.09392738342285156, 'num_replanning_steps': 0, 'wall_time': 0.9533143043518066}, {'num_node_expansions': 0, 'search_time': 0.0644765,... |
# -*- coding: utf-8 -*-
"""
Created on Sun Sep 17 10:43:46 2017
@author: ASUS
This code snippet finds the given spliced motif within the given DNA sequence
"""
#I put \n manually so that it fits to my solution
fasta_formatted_input = ">Rosalind_4080\nGTTACTGCCGAGTGCAAGCAACTTATTGCTGATTGGTCCGTGTAGGCTGTTAGCAGTTAGAATCTCT... | """
Created on Sun Sep 17 10:43:46 2017
@author: ASUS
This code snippet finds the given spliced motif within the given DNA sequence
"""
fasta_formatted_input = '>Rosalind_4080\nGTTACTGCCGAGTGCAAGCAACTTATTGCTGATTGGTCCGTGTAGGCTGTTAGCAGTTAGAATCTCTTAGCCTCAGCACAGTTTGTTTTCACGAAACAATGCGGAAACTATCTAGAACAACAAAAACATTATTGGAAGTTTG... |
"""
Files in nftfw - and a description of what they do
PackageIndex.txt this file
__init__.py amend the Python module lookup
Main nftfw application
----------------------
__main__.py Main application, deals with argument decode
and dispatch
config.py Class Config - supplies default... | """
Files in nftfw - and a description of what they do
PackageIndex.txt this file
__init__.py amend the Python module lookup
Main nftfw application
----------------------
__main__.py Main application, deals with argument decode
and dispatch
config.py Class Config - supplies default... |
# Copyright (c) 2020 Trail of Bits, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is di... | class Colors:
class C:
green = '\x1b[92m'
yellow = '\x1b[93m'
red = '\x1b[91m'
magneta = '\x1b[95m'
bg_yellow = '\x1b[43m'
orange = '\x1b[38;5;202m'
reset = '\x1b[0m'
def get_result_color(total, success):
if total == 0:
return Colors.c.magneta
if... |
# container.py - Creates META-INF/content.xml within the epub file
def create_container(epub_file):
epub_file.writestr('META-INF/container.xml', '''<?xml version="1.0"?>
<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">
<rootfiles>
<rootfile full-path="OEBPS/cont... | def create_container(epub_file):
epub_file.writestr('META-INF/container.xml', '<?xml version="1.0"?>\n<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container">\n <rootfiles>\n <rootfile full-path="OEBPS/content.opf" media-type="application/oebps-package+xml"/>\n </rootfiles>\n</... |
APP_MIN_WIDTH = 1024
APP_MIN_HEIGHT = 800
APP_NAME = 'Fractals'
APP_FONT = 12
| app_min_width = 1024
app_min_height = 800
app_name = 'Fractals'
app_font = 12 |
s = input()
ans = []
i=0
while i<len(s):
if s[i]=='.':
ans.append('0')
else:
if s[i+1]=='.':
ans.append('1')
else:
ans.append('2')
i=i+1
i+=1
for j in ans:
print(j,end='') | s = input()
ans = []
i = 0
while i < len(s):
if s[i] == '.':
ans.append('0')
else:
if s[i + 1] == '.':
ans.append('1')
else:
ans.append('2')
i = i + 1
i += 1
for j in ans:
print(j, end='') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.