content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Still waiting on what Neutral should be!
ALIGNMENT_CHOICES = (
(0, 'Neutral'),
(-1000, 'Evil'),
(1000, 'Good'),
)
SEX_CHOICES = (
(0, 'None'),
(1, 'Male'),
(2, 'Female'),
)
WEAPON_TYPE_CHOICES = (
('B', 'Blunt'),
('S', 'Sharp'),
)
DIRECTION_CHOICES = (
(0, 'North'),
... | alignment_choices = ((0, 'Neutral'), (-1000, 'Evil'), (1000, 'Good'))
sex_choices = ((0, 'None'), (1, 'Male'), (2, 'Female'))
weapon_type_choices = (('B', 'Blunt'), ('S', 'Sharp'))
direction_choices = ((0, 'North'), (1, 'East'), (2, 'South'), (3, 'West'), (4, 'Up'), (5, 'Down'))
door_reset_choices = ((0, 'Open'), (1, '... |
# break
# for i in range(1, 10):
# print(i)
# if i == 3:
# break
# continue
for i in range(1, 10):
if i == 4 or i == 7:
continue
print(i)
| for i in range(1, 10):
if i == 4 or i == 7:
continue
print(i) |
#Cambio , remplazo de cadena de Letras
print("=================================================================")
archivo_texto = open("archivo.txt","r+") # Archivo de Lectura y escritura
lista_texto=archivo_texto.readlines()
lista_texto[1]= " Estas linea ha sido incluioda desde el exterior 2 \n"
archivo_texto.seek(0... | print('=================================================================')
archivo_texto = open('archivo.txt', 'r+')
lista_texto = archivo_texto.readlines()
lista_texto[1] = ' Estas linea ha sido incluioda desde el exterior 2 \n'
archivo_texto.seek(0)
archivo_texto.writelines(lista_texto)
archivo_texto.close() |
# 07/01/2019
def upc(n):
digits = [int(x) for x in f'{n:011}']
M = (sum(digits[0::2]) * 3 + sum(digits[1::2])) % 10
return 0 if M == 0 else 10 - M
assert upc(4210000526) == 4
assert upc(3600029145) == 2
assert upc(12345678910) == 4
assert upc(1234567) == 0
| def upc(n):
digits = [int(x) for x in f'{n:011}']
m = (sum(digits[0::2]) * 3 + sum(digits[1::2])) % 10
return 0 if M == 0 else 10 - M
assert upc(4210000526) == 4
assert upc(3600029145) == 2
assert upc(12345678910) == 4
assert upc(1234567) == 0 |
# -*- coding: utf-8 -*-
#
# dependencies documentation build configuration file, created by Quark
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon'
]
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = u'dependencies'
copyright = u'2015, dependencies authors'
author = ... | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon']
templates_path = ['_templates']
source_suffix = '.rst'
master_doc = 'index'
project = u'dependencies'
copyright = u'2015, dependencies authors'
author = u'dependencies authors'
version = '0.0.1'
release = '0.0.1'
language = None
exclude_patterns = ['_build']
py... |
while True:
try:
number = input('Please input hex number: ')
print(int(number, 16))
except:
break;
| while True:
try:
number = input('Please input hex number: ')
print(int(number, 16))
except:
break |
print('-'* 23)
print('\033[:31mCALCULADOR DE DESCONTOS\033[m')
print('-'* 23)
p = float(input('Valor do produto: '))
desc = (p / 100) * 95 # -> p - (p * 5 / 100)
print(f'O produto que custava {p:.2f} com desconto de 5% sae por: {desc:.2f}'.replace('.', ',')) | print('-' * 23)
print('\x1b[:31mCALCULADOR DE DESCONTOS\x1b[m')
print('-' * 23)
p = float(input('Valor do produto: '))
desc = p / 100 * 95
print(f'O produto que custava {p:.2f} com desconto de 5% sae por: {desc:.2f}'.replace('.', ',')) |
limak, bob = map(int, input().split())
years = 0
while limak <= bob:
limak *= 3
bob *= 2
years += 1
print(years) | (limak, bob) = map(int, input().split())
years = 0
while limak <= bob:
limak *= 3
bob *= 2
years += 1
print(years) |
#Settings for running headless_tests
DEVELOPMENT_SERVER_HOST='localhost'
DEVELOPMENT_SERVER_PORT=8004
PHANTOMJS_GHOSTDRIVER_PORT=8150
| development_server_host = 'localhost'
development_server_port = 8004
phantomjs_ghostdriver_port = 8150 |
# -*- coding: utf-8 -*-
MINIMUM_PULSE_CYCLE = 0.5
MAXIMUM_PULSE_CYCLE = 1.2
PPG_SAMPLE_RATE = 200
PPG_FIR_FILTER_TAP_NUM = 200
PPG_FILTER_CUTOFF = [0.5, 5.0]
PPG_SYSTOLIC_PEAK_DETECTION_THRESHOLD_COEFFICIENT = 0.5
TRAINING_DATA_RATIO = 0.75 | minimum_pulse_cycle = 0.5
maximum_pulse_cycle = 1.2
ppg_sample_rate = 200
ppg_fir_filter_tap_num = 200
ppg_filter_cutoff = [0.5, 5.0]
ppg_systolic_peak_detection_threshold_coefficient = 0.5
training_data_ratio = 0.75 |
# Turns on debugging features in Flask
DEBUG = True
# secret key:
SECRET_KEY = "MySuperSecretKey"
# Database connection parameters
DB_HOST = "127.0.0.1"
DB_PORT = 27017
DB_NAME = "cgbeacon2-test"
DB_URI = f"mongodb://{DB_HOST}:{DB_PORT}/{DB_NAME}" # standalone MongoDB instance
# DB_URI = "mongodb://localhost:27011,l... | debug = True
secret_key = 'MySuperSecretKey'
db_host = '127.0.0.1'
db_port = 27017
db_name = 'cgbeacon2-test'
db_uri = f'mongodb://{DB_HOST}:{DB_PORT}/{DB_NAME}'
organisation = dict(id='scilifelab', name='Clinical Genomics, SciLifeLab', description='A science lab', address='', contactUrl='', info=[], logoUrl='', welcom... |
string_input = input()
num = int(input())
# def string(str, n):
# new_string = ""
# for i in range(0, n):
# new_string += str
# return new_string
# def string(str, n):
# return str*n
# Recursion
def string(str, n):
if n < 1:
return ""
return str + string(str, n=n - 1)
prin... | string_input = input()
num = int(input())
def string(str, n):
if n < 1:
return ''
return str + string(str, n=n - 1)
print(string(string_input, num)) |
def add_node(v):
if v in graph:
print(v,"already present")
else:
graph[v]=[]
def add_edge(v1,v2):
if v1 not in graph:
print(v1," not present in graph")
elif v2 not in graph:
print(v2,"not present in graph")
else:
graph[v1].append(v2)
graph[v2].append(... | def add_node(v):
if v in graph:
print(v, 'already present')
else:
graph[v] = []
def add_edge(v1, v2):
if v1 not in graph:
print(v1, ' not present in graph')
elif v2 not in graph:
print(v2, 'not present in graph')
else:
graph[v1].append(v2)
graph[v2].a... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Prince Prigio
chart = ["accept", "allow", "apologise", "appeal", "appear", "approve", "await", "bear", "beat", "behave", "behold", "better", "brawl", "breed", "build", "christen", "claim", "complain", "correct", "count", "cover", "creep", "curl", "decline", "deserve", "de... | chart = (['accept', 'allow', 'apologise', 'appeal', 'appear', 'approve', 'await', 'bear', 'beat', 'behave', 'behold', 'better', 'brawl', 'breed', 'build', 'christen', 'claim', 'complain', 'correct', 'count', 'cover', 'creep', 'curl', 'decline', 'deserve', 'despise', 'disappear', 'distress', 'shun', 'draw', 'drop', 'eat... |
#! python
# Problem # : 236A
# Created on : 2019-01-14 23:41:28
def Main():
cnt = len(set(input()))
print('IGNORE HIM!' if cnt & 1 else 'CHAT WITH HER!')
if __name__ == '__main__':
Main()
| def main():
cnt = len(set(input()))
print('IGNORE HIM!' if cnt & 1 else 'CHAT WITH HER!')
if __name__ == '__main__':
main() |
class Node:
def __init__(self, index):
self.index = index
self.visited = False
self._neighbors = []
def __repr__(self):
return str(self.index)
@property
def neighbors(self):
return self._neighbors
@neighbors.setter
def neighbors(self, neighbor):... | class Node:
def __init__(self, index):
self.index = index
self.visited = False
self._neighbors = []
def __repr__(self):
return str(self.index)
@property
def neighbors(self):
return self._neighbors
@neighbors.setter
def neighbors(self, neighbor):
... |
# https://leetcode.com/problems/maximum-product-difference-between-two-pairs
class Solution:
def maxProductDifference(self, nums: List[int]) -> int:
nums = sorted(nums)
return (nums[-1] * nums[-2]) - (nums[0] * nums[1])
| class Solution:
def max_product_difference(self, nums: List[int]) -> int:
nums = sorted(nums)
return nums[-1] * nums[-2] - nums[0] * nums[1] |
# Space: O(n)
# Time: O(n)
class Solution:
def plusOne(self, digits):
temp = ''.join(map(lambda x: str(x), digits))
temp = int(temp) + 1
temp = list(str(temp))
return list(map(lambda x: int(x), temp))
| class Solution:
def plus_one(self, digits):
temp = ''.join(map(lambda x: str(x), digits))
temp = int(temp) + 1
temp = list(str(temp))
return list(map(lambda x: int(x), temp)) |
#Explain your work
#Question 1
for x in range(a):
print(a) | for x in range(a):
print(a) |
class Sentence:
def __init__(self):
self._tokens = []
self._metadata = []
def append_metadata(self, data):
self._metadata.append(data)
def append_token(self, token):
self._tokens.append(token)
def __bool__(self):
return len(self._tokens) > 0
def __len__(se... | class Sentence:
def __init__(self):
self._tokens = []
self._metadata = []
def append_metadata(self, data):
self._metadata.append(data)
def append_token(self, token):
self._tokens.append(token)
def __bool__(self):
return len(self._tokens) > 0
def __len__(s... |
class AppSettings:
allow_extra_fields = True
types = {
# Slack
'domain': str,
# come on, Okta, be consistent...
# T-Sheets
'subDomain': str,
# Engagedly
'acsUrl': str, # ACS URL
'audRestriction': str, # Entity ID
# JIRA
'baseURL... | class Appsettings:
allow_extra_fields = True
types = {'domain': str, 'subDomain': str, 'acsUrl': str, 'audRestriction': str, 'baseURL': str, 'companyName': str, 'url': str, 'requestIntegration': bool, 'authURL': str, 'usernameField': str, 'passwordField': str, 'buttonField': str, 'extraFieldSelector': str, 'ext... |
N, K = map(int, input().split())
S = list(input())
Y = 0
if N == 1:
print(0)
exit(0)
if S[0] == 'L':
Y += 1
if S[N-1] == 'R':
Y += 1
count = 0
X = 0
for i in range(N-1):
if S[i] == 'R' and S[i+1] == 'L':
X += 1
if S[i] == S[i+1]:
count += 1
count += K*2
print(min(N-1, count))
... | (n, k) = map(int, input().split())
s = list(input())
y = 0
if N == 1:
print(0)
exit(0)
if S[0] == 'L':
y += 1
if S[N - 1] == 'R':
y += 1
count = 0
x = 0
for i in range(N - 1):
if S[i] == 'R' and S[i + 1] == 'L':
x += 1
if S[i] == S[i + 1]:
count += 1
count += K * 2
print(min(N - ... |
#
# PySNMP MIB module CTRON-ROUTERS-INTERNAL-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CTRON-ROUTERS-INTERNAL-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:15:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_range_constraint, value_size_constraint, constraints_union) ... |
# -*- coding: utf-8 -*-
class Solution:
def distributeCandies(self, candies):
return min(len(candies) / 2, len(set(candies)))
if __name__ == '__main__':
solution = Solution()
assert 3 == solution.distributeCandies([1, 1, 2, 2, 3, 3])
assert 2 == solution.distributeCandies([1, 1, 2, 3])
| class Solution:
def distribute_candies(self, candies):
return min(len(candies) / 2, len(set(candies)))
if __name__ == '__main__':
solution = solution()
assert 3 == solution.distributeCandies([1, 1, 2, 2, 3, 3])
assert 2 == solution.distributeCandies([1, 1, 2, 3]) |
#
# PySNMP MIB module ELTEX-MES-IP (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ELTEX-MES-IP
# Produced by pysmi-0.3.4 at Wed May 1 13:00:06 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,... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, value_size_constraint, constraints_intersection) ... |
def print_full_name(a, b):
first_name = a
last_name = b
print("Hello", first_name, last_name + "!", "You just delved into python.") | def print_full_name(a, b):
first_name = a
last_name = b
print('Hello', first_name, last_name + '!', 'You just delved into python.') |
opt = {
# LRC1000.0
'a9a.LRC1000.0': 1.05049605396498e+07, # from TRON
'a9a.bias.LRC1000.0': 1.05049602719930e+07, # from TRON
'covtype.libsvm.binary.LRC1000.0': 2.98341912891832e+08, # from nheavy
'covtype.libsvm.binary.bias.LRC1000.0': 2.98341823726758e+08, # fro... | opt = {'a9a.LRC1000.0': 10504960.5396498, 'a9a.bias.LRC1000.0': 10504960.271993, 'covtype.libsvm.binary.LRC1000.0': 298341912.891832, 'covtype.libsvm.binary.bias.LRC1000.0': 298341823.726758, 'epsilon_normalized.LRC1000.0': 100427474.936523, 'epsilon_normalized.bias.LRC1000.0': 100427449.600054, 'kddb.LRC1000.0': 40814... |
# encoding=utf-8
def my_coroutine():
while True:
received = yield
print('Received:',received)
it = my_coroutine()
next(it)
it.send('First')
it.send('Second')
def minimize():
current = yield
while True:
value = yield current
current = min(value,current)
it = minimize()
next(it)
print(it.send(10))
prin... | def my_coroutine():
while True:
received = (yield)
print('Received:', received)
it = my_coroutine()
next(it)
it.send('First')
it.send('Second')
def minimize():
current = (yield)
while True:
value = (yield current)
current = min(value, current)
it = minimize()
next(it)
print(... |
'''
File name: p1_utils.py
Author:
Date:
'''
| """
File name: p1_utils.py
Author:
Date:
""" |
DAILY='DAILY'
WEEKLY='WEEKLY'
MONTHLY='MONTHLY'
ANNUALLY='ANNUALLY'
MONTHLY_MEAN='MONTHLY_MEAN'
ANNUAL_MEAN='ANNUAL_MEAN'
MONTHLY_SUM='MONTHLY_SUM'
ANNUAL_SUM='ANNUAL_SUM'
MONTHLY_SNAPSHOT='MONTHLY_SNAPSHOT'
ANNUAL_SNAPSHOT='ANNUAL_SNAPSHOT' | daily = 'DAILY'
weekly = 'WEEKLY'
monthly = 'MONTHLY'
annually = 'ANNUALLY'
monthly_mean = 'MONTHLY_MEAN'
annual_mean = 'ANNUAL_MEAN'
monthly_sum = 'MONTHLY_SUM'
annual_sum = 'ANNUAL_SUM'
monthly_snapshot = 'MONTHLY_SNAPSHOT'
annual_snapshot = 'ANNUAL_SNAPSHOT' |
#
# PySNMP MIB module RFC1406Ext-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RFC1406Ext-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:56:59 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint, constraints_union) ... |
MAPPING = [
{
'sid': 'Adult age binary (yes)',
'symptom': 'age',
'module': 'adult',
'gen_5_4a': 55,
'endorsed': True,
},
{
'sid': 'Adult age binary (no)',
'symptom': 'age',
'module': 'adult',
'gen_5_4a': 45,
'endorsed': False,
... | mapping = [{'sid': 'Adult age binary (yes)', 'symptom': 'age', 'module': 'adult', 'gen_5_4a': 55, 'endorsed': True}, {'sid': 'Adult age binary (no)', 'symptom': 'age', 'module': 'adult', 'gen_5_4a': 45, 'endorsed': False}, {'sid': 'Adult age binary (no-lower bound)', 'symptom': 'age', 'module': 'adult', 'gen_5_4a': 12,... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# let's create several lists
alist1 = [1, 2, 3, 4, 5]
alist2 = ['a', 'b', 'c', 'd', 'e']
alist3 = [] # empty list
alist4 = list() # Also creates an empty list. As an argument, anything iterable can be used and a list is created from it.
print(len(alist1)) # The buil... | alist1 = [1, 2, 3, 4, 5]
alist2 = ['a', 'b', 'c', 'd', 'e']
alist3 = []
alist4 = list()
print(len(alist1))
print(alist1[0])
print(alist1[-1])
print(alist1)
alist1[0] = 100
print(alist1)
alist1[1:3] = [101, 102, 103]
print(alist1)
alist1[len(alist1):] = [6]
print(alist1)
alist1.append(7)
print(alist1)
alist1[5:] = []
pr... |
__all__ = [
'feature_audio_adpcm', \
'feature_audio_adpcm_sync', \
'bv_audio_sync_manager'
]
| __all__ = ['feature_audio_adpcm', 'feature_audio_adpcm_sync', 'bv_audio_sync_manager'] |
x = int(input())
a = list(map(int,input().split()))
y = int(input())
b = list(map(int,input().split()))
f=[]
for i in b:
for j in a:
if i%j==0:
f.append(i/j)
print(f.count(max(f))) | x = int(input())
a = list(map(int, input().split()))
y = int(input())
b = list(map(int, input().split()))
f = []
for i in b:
for j in a:
if i % j == 0:
f.append(i / j)
print(f.count(max(f))) |
class mystery(object):
def __init__(this, length, values):
this.values = [0]*length
for value in values:
this.values[value] += 1
def __str__(this):
return "length {:d}: {}".format(len(this.values), this.values)
def __add__(this, value):
myst = mystery(len(this.v... | class Mystery(object):
def __init__(this, length, values):
this.values = [0] * length
for value in values:
this.values[value] += 1
def __str__(this):
return 'length {:d}: {}'.format(len(this.values), this.values)
def __add__(this, value):
myst = mystery(len(thi... |
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
class Version:
def __init__(self, version):
self._p = version.split('.')
self._v = version
def __getitem__(self, key):
return self._p[key]
def __str__(self):
return self._v
d... | class Version:
def __init__(self, version):
self._p = version.split('.')
self._v = version
def __getitem__(self, key):
return self._p[key]
def __str__(self):
return self._v
def __repr__(self):
return self._v
__version__ = version('0.1.dev5+ge0d057d.d20210625') |
def get_pair_number(list_pairs, item_left, item_right):
# Retrieve pair number
found = False
ct_pair = 0
iter_pair = 0
while not found:
if list_pairs[iter_pair, 0] == item_left and list_pairs[iter_pair, 1] == item_right:
ct_pair = iter_pair
found = True
else:
... | def get_pair_number(list_pairs, item_left, item_right):
found = False
ct_pair = 0
iter_pair = 0
while not found:
if list_pairs[iter_pair, 0] == item_left and list_pairs[iter_pair, 1] == item_right:
ct_pair = iter_pair
found = True
else:
iter_pair += 1
... |
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 |
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... |
# -*- 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__) |
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... |
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}} |
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) |
# 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... |
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) |
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:
... |
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 ... |
# 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') |
# 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) |
'''
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... |
#
# @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 =... |
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' |
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
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.