content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#!/usr/bin/env python
# coding: utf-8
# In[2]:
def utopianTree(cycles):
h=1
for cyc_no in range(cycles):
if (cyc_no%2==0):
h=h*2
elif (cyc_no):
h+=1
return h
if __name__=='__main__':
n=int(input())
for itr in range(n):
cycles=int(input())
pr... | def utopian_tree(cycles):
h = 1
for cyc_no in range(cycles):
if cyc_no % 2 == 0:
h = h * 2
elif cyc_no:
h += 1
return h
if __name__ == '__main__':
n = int(input())
for itr in range(n):
cycles = int(input())
print(utopian_tree(cycles)) |
def divisors(integer):
aux = [i for i in range(2, integer) if integer % i == 0]
if len(aux) == 0:
return "{} is prime".format(integer)
else:
return aux | def divisors(integer):
aux = [i for i in range(2, integer) if integer % i == 0]
if len(aux) == 0:
return '{} is prime'.format(integer)
else:
return aux |
# coding: utf-8
pyslim_version = '0.700'
slim_file_version = '0.7'
# other file versions that require no modification
compatible_slim_file_versions = ['0.7']
| pyslim_version = '0.700'
slim_file_version = '0.7'
compatible_slim_file_versions = ['0.7'] |
def format_as_vsys(amount):
abs_amount = abs(amount)
whole = int(abs_amount / 100000000)
fraction = abs_amount % 100000000
if amount < 0:
whole *= -1
return f'{whole}.{str(fraction).rjust(8, "0")}'
| def format_as_vsys(amount):
abs_amount = abs(amount)
whole = int(abs_amount / 100000000)
fraction = abs_amount % 100000000
if amount < 0:
whole *= -1
return f"{whole}.{str(fraction).rjust(8, '0')}" |
class Solution:
def canVisitAllRooms(self, rooms):
stack = [0]
visited = set(stack)
while stack:
curr = stack.pop()
for room in rooms[curr]:
if room not in visited:
stack.append(room)
visited.add(room)
... | class Solution:
def can_visit_all_rooms(self, rooms):
stack = [0]
visited = set(stack)
while stack:
curr = stack.pop()
for room in rooms[curr]:
if room not in visited:
stack.append(room)
visited.add(room)
... |
__author__ = 'spersinger'
class Configuration:
@staticmethod
def run():
Configuration.enforce_ttl = True
Configuration.ttl = 60
Configuration.run()
| __author__ = 'spersinger'
class Configuration:
@staticmethod
def run():
Configuration.enforce_ttl = True
Configuration.ttl = 60
Configuration.run() |
#####
# https://github.com/sushiswap/sushiswap-subgraph
# https://dev.sushi.com/api/overview
# https://github.com/sushiswap/sushiswap-analytics/blob/c6919d56523b4418d174224a6b8964982f2a7948/src/core/api/index.js
# CP_API_TOKEN = os.environ.get("cp_api_token")
#"https://gateway.thegraph.com/api/c8eae2e5ac9d2e9d5d5459c33... | url = {'sushiexchange': 'https://api.thegraph.com/subgraphs/name/sushiswap/exchange', 'sushibar': 'https://api.thegraph.com/subgraphs/name/matthewlilley/bar', 'aave': 'https://api.thegraph.com/subgraphs/name/aave/protocol-v2'} |
# -*- coding: utf-8 -*-
commands = {
'start_AfterAuthorized':
u'Welcome to remoteSsh_bot\n\n'
u'If you known password - use /on\n'
u'else - connect to admin',
'start_BeforeAuthorized':
u'Hello!\n'
... | commands = {'start_AfterAuthorized': u'Welcome to remoteSsh_bot\n\nIf you known password - use /on\nelse - connect to admin', 'start_BeforeAuthorized': u'Hello!\nIf you want information about this bot - use /information\nIf you want command list - use /help', 'help_AfterAuthorized': u'If you known password - use /on\ne... |
'''
'''
def main():
info('Pump Microbone')
close(description="Jan Inlet")
if is_closed('F'):
open(description= 'Microbone to CO2 Laser')
else:
close(name="T", description="Microbone to CO2 Laser")
sleep(1)
close(description= 'CO2 Laser to Roughing')
#close(description... | """
"""
def main():
info('Pump Microbone')
close(description='Jan Inlet')
if is_closed('F'):
open(description='Microbone to CO2 Laser')
else:
close(name='T', description='Microbone to CO2 Laser')
sleep(1)
close(description='CO2 Laser to Roughing')
open(description='Microbone... |
def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse,... | def find_decision(obj):
if obj[11] > 1:
if obj[12] > 3:
if obj[13] > 1:
if obj[9] <= 1:
if obj[16] > 1.0:
if obj[10] <= 0:
return 'True'
elif obj[10] > 0:
i... |
bil = 0
count = 0
hasil = 0
while(bil <= 100):
if(bil % 2 == 1):
count += 1
hasil += bil
print(bil)
bil += 1
print('Banyaknya bilangan ganjil :', count)
print('Jumlah seluruh bilangan :', hasil)
| bil = 0
count = 0
hasil = 0
while bil <= 100:
if bil % 2 == 1:
count += 1
hasil += bil
print(bil)
bil += 1
print('Banyaknya bilangan ganjil :', count)
print('Jumlah seluruh bilangan :', hasil) |
def mapping_Luo(t=1):
names = [ 'Yao_6_2', 'AB_TMA_2', 'ABA_TMA_2',
'ABAB_TMA_2', 'ABABA_TMA_2', 'ABABA_IPrMeP_2']
xlocs = [ 21400, 5500, -7200,
-11700, -17200, -30700]
ylocs = [ 0, 0, 0,
0, ... | def mapping__luo(t=1):
names = ['Yao_6_2', 'AB_TMA_2', 'ABA_TMA_2', 'ABAB_TMA_2', 'ABABA_TMA_2', 'ABABA_IPrMeP_2']
xlocs = [21400, 5500, -7200, -11700, -17200, -30700]
ylocs = [0, 0, 0, 0, 0, 0]
zlocs = [2700, 2700, 2700, 2700, 2700, 2700]
x_range = [[0, 500, 21], [0, 500, 21], [0, 500, 21], [0, 500... |
def alpha_numeric(m):
return re.sub('[^A-Za-z0-9]+', ' ', m)
def uri_from_fields(fields):
string = '_'.join(alpha_numeric(f.strip().lower()) for f in fields)
if len(string) == len(fields)-1:
return ''
return string
def splitLocation(location):
return re.search('[NS]',location).start()
def getLatitude(s,l):
... | def alpha_numeric(m):
return re.sub('[^A-Za-z0-9]+', ' ', m)
def uri_from_fields(fields):
string = '_'.join((alpha_numeric(f.strip().lower()) for f in fields))
if len(string) == len(fields) - 1:
return ''
return string
def split_location(location):
return re.search('[NS]', location).start(... |
def solve(input, days):
# Lanternfish with internal timer t are the number of lanternfish with timer t+1 after a day
for day in range(days):
aux = input[0]
input[0] = input[1]
input[1] = input[2]
input[2] = input[3]
input[3] = input[4]
input[4] = input[5]
... | def solve(input, days):
for day in range(days):
aux = input[0]
input[0] = input[1]
input[1] = input[2]
input[2] = input[3]
input[3] = input[4]
input[4] = input[5]
input[5] = input[6]
input[6] = input[7] + aux
input[7] = input[8]
input[8... |
def funcao1(funcao, *args, **kwargs):
return funcao(*args, **kwargs)
def funcao2(nome):
return f'Oi {nome}'
def funcao3(nome, saudacao):
return f'{saudacao} {nome}'
executando = funcao1(funcao2, 'Luiz')
print(executando)
executando = funcao1(funcao3, 'Luiz', saudacao='Bom dia')
print(executando)
| def funcao1(funcao, *args, **kwargs):
return funcao(*args, **kwargs)
def funcao2(nome):
return f'Oi {nome}'
def funcao3(nome, saudacao):
return f'{saudacao} {nome}'
executando = funcao1(funcao2, 'Luiz')
print(executando)
executando = funcao1(funcao3, 'Luiz', saudacao='Bom dia')
print(executando) |
true = True;
false = False;
true1 = "True";
false1 = "False";
true2 = true; ''' I was trying to check if keyword is case sensitive which it is not but here the above defined variable value is taken which is bool
This technique can be used to define case insensitive keywords at start to py program.'''
false2 = false;
pr... | true = True
false = False
true1 = 'True'
false1 = 'False'
true2 = true
' I was trying to check if keyword is case sensitive which it is not but here the above defined variable value is taken which is bool\nThis technique can be used to define case insensitive keywords at start to py program.'
false2 = false
print(true,... |
## input = 1,2,3,4
## output = ['1','2','3','4'], ('1','2','3','4')
def abc():
values = input()
print("----")
print(values)
print("----")
x = values.split(",")
print(x)
y = tuple(x)
print("===")
print(y)
if __name__ == "__main__":
abc()
| def abc():
values = input()
print('----')
print(values)
print('----')
x = values.split(',')
print(x)
y = tuple(x)
print('===')
print(y)
if __name__ == '__main__':
abc() |
#!/usr/bin/env python3
FILENAME = "/tmp/passed"
bmks = []
with open(FILENAME, "r") as f:
for l in f:
[m, a] = l.split(" ")
t = (m, a.strip())
bmks.append(t)
def quote(s):
return '"{}"'.format(s)
indent = " "
output = '{}[ {}\n{}]'.format(indent, f'\n{indent}, '.join(f'("{m}", "{a}"... | filename = '/tmp/passed'
bmks = []
with open(FILENAME, 'r') as f:
for l in f:
[m, a] = l.split(' ')
t = (m, a.strip())
bmks.append(t)
def quote(s):
return '"{}"'.format(s)
indent = ' '
output = '{}[ {}\n{}]'.format(indent, f'\n{indent}, '.join((f'("{m}", "{a}")' for (m, a) in bmks)), i... |
{
"includes": [
"../common.gypi"
],
"targets": [
{
"target_name": "libgdal_ogr_vrt_frmt",
"type": "static_library",
"sources": [
"../gdal/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp",
"../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdriver.cpp",
"../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdatasource.cpp"
],
"include... | {'includes': ['../common.gypi'], 'targets': [{'target_name': 'libgdal_ogr_vrt_frmt', 'type': 'static_library', 'sources': ['../gdal/ogr/ogrsf_frmts/vrt/ogrvrtlayer.cpp', '../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdriver.cpp', '../gdal/ogr/ogrsf_frmts/vrt/ogrvrtdatasource.cpp'], 'include_dirs': ['../gdal/ogr/ogrsf_frmts/vrt']}]... |
def subarraysCountBySum(a, k, s):
ans=0
n=len(a)
t=0
ii=1
while(k+t<=n):
tmp=[]
for i in range(t,ii+t):
tmp.append(a[i])
print(tmp)
ii+=1
if len(tmp)<=k and sum(tmp)==s:
ans+=1
t+=1
else:
break
return ans
a=list(ma... | def subarrays_count_by_sum(a, k, s):
ans = 0
n = len(a)
t = 0
ii = 1
while k + t <= n:
tmp = []
for i in range(t, ii + t):
tmp.append(a[i])
print(tmp)
ii += 1
if len(tmp) <= k and sum(tmp) == s:
ans += 1
t += 1
else:... |
def main(request, response):
response.headers.set(b"Content-Type", b"text/plain")
response.status = 200
response.content = request.headers.get(b"Content-Type")
response.close_connection = True
| def main(request, response):
response.headers.set(b'Content-Type', b'text/plain')
response.status = 200
response.content = request.headers.get(b'Content-Type')
response.close_connection = True |
fruits = ['banana', 'orange', 'mango', 'lemon']
fruit = str(input('Enter a fruit: ')).strip().lower()
if fruit not in fruits:
fruits.append(fruit)
print(fruits)
else:
print(f'{fruit} already in the list')
| fruits = ['banana', 'orange', 'mango', 'lemon']
fruit = str(input('Enter a fruit: ')).strip().lower()
if fruit not in fruits:
fruits.append(fruit)
print(fruits)
else:
print(f'{fruit} already in the list') |
amount = 20
num=1
def setup():
size(640, 640)
stroke(0, 150, 255, 100)
def draw():
global num, amount
fill(0, 40)
rect(-1, -1, width+1, height+1)
maxX = map(mouseX, 0, width, 1, 250)
translate(width/2, height/2)
for i in range(0,360,amount):
x = sin(radians(i+num)) * maxX
... | amount = 20
num = 1
def setup():
size(640, 640)
stroke(0, 150, 255, 100)
def draw():
global num, amount
fill(0, 40)
rect(-1, -1, width + 1, height + 1)
max_x = map(mouseX, 0, width, 1, 250)
translate(width / 2, height / 2)
for i in range(0, 360, amount):
x = sin(radians(i + num... |
# Copyright (c) Microsoft Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in wri... | async def test_listeners(page, server):
log = []
def print_response(response):
log.append(response)
page.on('response', print_response)
await page.goto(f'{server.PREFIX}/input/textarea.html')
assert len(log) > 0
page.remove_listener('response', print_response)
log = []
await pag... |
class Backend(object):
# should be implemented all methods
def set(self, name, value):
raise NotImplementedError()
def get(self, name):
raise NotImplementedError()
def delete(self, name):
raise NotImplementedError()
def set_fields(self):
raise NotImplementedError()... | class Backend(object):
def set(self, name, value):
raise not_implemented_error()
def get(self, name):
raise not_implemented_error()
def delete(self, name):
raise not_implemented_error()
def set_fields(self):
raise not_implemented_error()
def fields(self):
... |
number_of_days = int(input())
type_of_room = str(input())
rating = str(input())
room_for_one_person = 18.00
apartment = 25.00
president_apartment = 35.00
apartment_discount = 0
president_apartment_discount = 0
total_price_for_a_room = 0
total_price_for_apartment = 0
total_price_for_presidential_apartment = 0
addition... | number_of_days = int(input())
type_of_room = str(input())
rating = str(input())
room_for_one_person = 18.0
apartment = 25.0
president_apartment = 35.0
apartment_discount = 0
president_apartment_discount = 0
total_price_for_a_room = 0
total_price_for_apartment = 0
total_price_for_presidential_apartment = 0
additional_di... |
LIST_WORKFLOWS_GQL = '''
query workflowList {
workflowList {
edges{
node {
id
name
objectType
initialPrefetch
initialState {
id
name
}
initialTransition {
id
name
}
}
}
}
}
'''
LIST_STATES_GQL... | list_workflows_gql = '\nquery workflowList {\n workflowList {\n edges{\n node {\n id\n name\n objectType\n initialPrefetch\n initialState {\n id\n name\n }\n initialTransition {\n id\n name\n }\n }\n }\n }\n}\n... |
with open("text.txt", "w") as my_file:
my_file.write("Tretas dos Bronzetas")
if my_file.closed == False:
my_file.close()
print(my_file.closed)
| with open('text.txt', 'w') as my_file:
my_file.write('Tretas dos Bronzetas')
if my_file.closed == False:
my_file.close()
print(my_file.closed) |
DESCRIBE_VMS = [
{
"id": "/subscriptions/00-00-00-00/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/TestVM",
"type": "Microsoft.Compute/virtualMachines",
"location": "West US",
"resource_group": "TestRG",
"name": "TestVM",
"plan": {
"pro... | describe_vms = [{'id': '/subscriptions/00-00-00-00/resourceGroups/TestRG/providers/Microsoft.Compute/virtualMachines/TestVM', 'type': 'Microsoft.Compute/virtualMachines', 'location': 'West US', 'resource_group': 'TestRG', 'name': 'TestVM', 'plan': {'product': 'Standard'}, 'handware_profile': {'vm_size': 'Standard_D2s_v... |
'''
Pattern
Enter number of rows: 5
1
21
321
4321
54321
'''
print('Number Pattern:')
number_rows=int(input('Enter number of rows: '))
for row in range(1,number_rows+1):
for column in range(row,0,-1):
if column < 10:
print(f'0{column}',end=' ')
else:
print(column,end=' ')
print() | """
Pattern
Enter number of rows: 5
1
21
321
4321
54321
"""
print('Number Pattern:')
number_rows = int(input('Enter number of rows: '))
for row in range(1, number_rows + 1):
for column in range(row, 0, -1):
if column < 10:
print(f'0{column}', end=' ')
else:
print(column, end=... |
class Solution:
def isStrobogrammatic(self, num: str) -> bool:
dic = {'1': '1', '6': '9', '8': '8', '9': '6', '0': '0'}
l, r = 0, len(num)-1
while l <= r:
if num[l] not in dic or dic[num[l]] != num[r]:
return False
l += 1
r -= 1
ret... | class Solution:
def is_strobogrammatic(self, num: str) -> bool:
dic = {'1': '1', '6': '9', '8': '8', '9': '6', '0': '0'}
(l, r) = (0, len(num) - 1)
while l <= r:
if num[l] not in dic or dic[num[l]] != num[r]:
return False
l += 1
r -= 1
... |
# -*- coding: utf-8 -*-
name = 'usd'
version = '20.02'
requires = [
'alembic-1.5',
'boost-1.55',
'tbb-4.4.6',
'opensubdiv-3.2',
'ilmbase-2.2',
'jinja-2',
'jemalloc-4',
'openexr-2.2',
'pyilmbase-2.2',
'materialx',
'oiio-1.8',
'ptex-2.0',
'PyOpenGL',
'embree_lib'... | name = 'usd'
version = '20.02'
requires = ['alembic-1.5', 'boost-1.55', 'tbb-4.4.6', 'opensubdiv-3.2', 'ilmbase-2.2', 'jinja-2', 'jemalloc-4', 'openexr-2.2', 'pyilmbase-2.2', 'materialx', 'oiio-1.8', 'ptex-2.0', 'PyOpenGL', 'embree_lib', 'glew', 'renderman-22.6', 'ocio-1.0.9']
build_requires = ['pyside-1.2']
private_bu... |
contador = 1
while contador <= 9:
for contador2 in range(7, 4, -1):
print(f'I={contador} J={contador2}')
contador += 2 | contador = 1
while contador <= 9:
for contador2 in range(7, 4, -1):
print(f'I={contador} J={contador2}')
contador += 2 |
# Advent of Code - Day 4
valid_passport_data = {
'ecl', 'pid', 'eyr', 'hcl',
'byr', 'iyr', 'hgt',
}
count_required_data = len(valid_passport_data)
def ecl_rule(value):
return value in {'amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth'}
def pid_rule(value):
try:
int(value)
isnumber = True... | valid_passport_data = {'ecl', 'pid', 'eyr', 'hcl', 'byr', 'iyr', 'hgt'}
count_required_data = len(valid_passport_data)
def ecl_rule(value):
return value in {'amb', 'blu', 'brn', 'gry', 'grn', 'hzl', 'oth'}
def pid_rule(value):
try:
int(value)
isnumber = True
except:
isnumber = Fals... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#-----------------------------------
# AutoNaptPython
#
# Copyright (c) 2018 RainForest
#
# This software is released under the MIT License.
# http://opensource.org/licenses/mit-license.php
#-----------------------------------
class Event2(object):
def __init__(self,... | class Event2(object):
def __init__(self, doc=None):
self.handlers = []
self.__doc__ = doc
def __str__(self):
return 'Event<%s>' % str(self.__doc__)
def add(self, handler):
self.handlers.append(handler)
return self
def remove(self, handler):
self.handle... |
class Parser:
def __init__(self, directory, rel_path):
pass
def parse(self):
return {}, []
def get_parser(): return 5
| class Parser:
def __init__(self, directory, rel_path):
pass
def parse(self):
return ({}, [])
def get_parser():
return 5 |
# Set up constants
WIDTH = 25
HEIGHT = 6
LAYER_SIZE = WIDTH * HEIGHT
# Read in the input file and convert to a list
pixel_string = ""
with open("./input.txt") as f:
pixel_string = f.readline()
unlayered_pixel_values = list(pixel_string.strip())
# Make into a list of layers
idx = 0
layers = []
while idx < len(unla... | width = 25
height = 6
layer_size = WIDTH * HEIGHT
pixel_string = ''
with open('./input.txt') as f:
pixel_string = f.readline()
unlayered_pixel_values = list(pixel_string.strip())
idx = 0
layers = []
while idx < len(unlayered_pixel_values):
layers.append(unlayered_pixel_values[idx:idx + LAYER_SIZE])
idx += L... |
class CommandBuilder():
def __init__(self, cindex):
self.cindex = cindex
class CodeBuilder(CommandBuilder):
def __init__(self, cindex, cmd):
super().__init__(cindex)
self.cmd = cmd
def __str__(self):
return self.cmd
class SlugBuilder(CommandBuilder):
def __init__(self,... | class Commandbuilder:
def __init__(self, cindex):
self.cindex = cindex
class Codebuilder(CommandBuilder):
def __init__(self, cindex, cmd):
super().__init__(cindex)
self.cmd = cmd
def __str__(self):
return self.cmd
class Slugbuilder(CommandBuilder):
def __init__(self... |
model_filename = "cifar10.model"
data_filename = "cifar10.npz"
model_url = "#"
data_url = "https://github.com/danielwilczak101/EasyNN/raw/datasets/cifar/cifar10.npz"
labels = {
0: "airplane",
1: "automobile",
2: "bird",
3: "cat",
4: "deer",
5: "d... | model_filename = 'cifar10.model'
data_filename = 'cifar10.npz'
model_url = '#'
data_url = 'https://github.com/danielwilczak101/EasyNN/raw/datasets/cifar/cifar10.npz'
labels = {0: 'airplane', 1: 'automobile', 2: 'bird', 3: 'cat', 4: 'deer', 5: 'dog', 6: 'frog', 7: 'horse', 8: 'ship', 9: 'truck'} |
#Normalmenet se declara asi
#numero = 9
#La variable que se relaciona con la instancia de una clase
class Persona:
edad=18#Clase Persona con variable de clase que es edad
def __init__(self,nombre,nacionalidad):
self.nombre=nombre#variables de instancia
self.nacionalidad=nacionalidad
persona1= Persona("Jose","Me... | class Persona:
edad = 18
def __init__(self, nombre, nacionalidad):
self.nombre = nombre
self.nacionalidad = nacionalidad
persona1 = persona('Jose', 'Mexicano')
print(Persona.edad)
persona2 = persona('Franklin', 'Colombo-Argentino')
print(persona2.nombre) |
#
# PySNMP MIB module SIAE-IFEXT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file://./sm_ifext.mib
# Produced by pysmi-0.3.2 at Fri Jul 19 08:18:02 2019
# On host 0e190c6811ee platform Linux version 4.9.125-linuxkit by user root
# Using Python version 3.7.3 (default, Apr 3 2019, 05:39:12)
#
Integer, OctetString, O... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ... |
a = float(input("a = "))
b = float(input("b = "))
c = float(input("c = "))
if a==b==c:
print('nothing')
elif a==c:
print(2)
elif b==a:
print(3)
elif b==c:
print(1)
else:
print('nothing')
| a = float(input('a = '))
b = float(input('b = '))
c = float(input('c = '))
if a == b == c:
print('nothing')
elif a == c:
print(2)
elif b == a:
print(3)
elif b == c:
print(1)
else:
print('nothing') |
def fib(n):
'''
uses generater to return fibonacci sequence
up to given # n dynamically
'''
a,b = 1,1
for _ in range(0,n):
yield a
a,b = b,a+b
return a
| def fib(n):
"""
uses generater to return fibonacci sequence
up to given # n dynamically
"""
(a, b) = (1, 1)
for _ in range(0, n):
yield a
(a, b) = (b, a + b)
return a |
config = {
"qqGroup": "",
"pro_ids": ['11111', '22222'],
"daily": {
"pro_ids": ['11111']
},
# "pk": {
# "me": "22222",
# "vs": ['33333']
# }
"dailyInterval": 25,
"pkInterval": 30
}
| config = {'qqGroup': '', 'pro_ids': ['11111', '22222'], 'daily': {'pro_ids': ['11111']}, 'dailyInterval': 25, 'pkInterval': 30} |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swapPairs(self, head):
if not head:
return None
if not head.next:
return head
curr = head
after = head.next
pre = None
head = after
while after:
curr.next = after.next
after.next = cur... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def swap_pairs(self, head):
if not head:
return None
if not head.next:
return head
curr = head
after = head.next
pre = None
head = after... |
{
'targets': [
{
'target_name': 'brotli',
'type': 'static_library',
'include_dirs': ['c/include'],
'conditions': [
['OS=="linux"', {
'defines': [
'OS_LINUX'
]
}],
['OS=="freebsd"', {
'defines': [
'OS_FREEBSD'
... | {'targets': [{'target_name': 'brotli', 'type': 'static_library', 'include_dirs': ['c/include'], 'conditions': [['OS=="linux"', {'defines': ['OS_LINUX']}], ['OS=="freebsd"', {'defines': ['OS_FREEBSD']}], ['OS=="mac"', {'defines': ['OS_MACOSX']}]], 'direct_dependent_settings': {'include_dirs': ['c/include']}, 'libraries'... |
{
'variables': {
'base_cflags': [
'-Wall',
'-Wextra',
'-Wno-unused-parameter',
'-std=c++11',
],
'debug_cflags': ['-g', '-O0'],
'release_cflags': ['-O3'],
},
'targets': [
{
'target_name': 'tonclient',
'sources': ['binding.cc'],
'conditions': [
[... | {'variables': {'base_cflags': ['-Wall', '-Wextra', '-Wno-unused-parameter', '-std=c++11'], 'debug_cflags': ['-g', '-O0'], 'release_cflags': ['-O3']}, 'targets': [{'target_name': 'tonclient', 'sources': ['binding.cc'], 'conditions': [['OS == "win"', {'libraries': ['../tonclient.lib', 'advapi32.lib', 'ws2_32.lib', 'usere... |
int1 = input("Enter first integer: ")
int2 = input("Enter second integer: ")
sum = int(int1) + int(int2)
if sum in range(105, 201):
print(200)
| int1 = input('Enter first integer: ')
int2 = input('Enter second integer: ')
sum = int(int1) + int(int2)
if sum in range(105, 201):
print(200) |
# Create Plotter
acc_plotter = skdiscovery.data_structure.series.accumulators.Plotter('Plotter')
# Create stage containter for Plotter
sc_plotter = StageContainer(acc_plotter)
| acc_plotter = skdiscovery.data_structure.series.accumulators.Plotter('Plotter')
sc_plotter = stage_container(acc_plotter) |
# ----------------------------------------------------------------------
# ctokens.py
#
# Token specifications for symbols in ANSI C and C++. This file is
# meant to be used as a library in other tokenizers.
# ----------------------------------------------------------------------
# Reserved words
tokens = [... | tokens = ['ID', 'TYPEID', 'INTEGER', 'FLOAT', 'STRING', 'CHARACTER', 'PLUS', 'MINUS', 'TIMES', 'DIVIDE', 'MODULO', 'OR', 'AND', 'NOT', 'XOR', 'LSHIFT', 'RSHIFT', 'LOR', 'LAND', 'LNOT', 'LT', 'LE', 'GT', 'GE', 'EQ', 'NE', 'EQUALS', 'TIMESEQUAL', 'DIVEQUAL', 'MODEQUAL', 'PLUSEQUAL', 'MINUSEQUAL', 'LSHIFTEQUAL', 'RSHIFTEQ... |
twitch_icon = "<:twitch:404633403603025921> "
cmd_fail = "<:tickNo:342738745092734976> "
cmd_success = "<:tickYes:342738345673228290> "
loading = "<a:loading:515632705262583819> "
bullet = "<:bullet:516382013779869726> "
right_arrow_alt = "<:arrow:343407434746036224>"
left_arrow = "<a:a_left_arrow:527634992415899650>"
... | twitch_icon = '<:twitch:404633403603025921> '
cmd_fail = '<:tickNo:342738745092734976> '
cmd_success = '<:tickYes:342738345673228290> '
loading = '<a:loading:515632705262583819> '
bullet = '<:bullet:516382013779869726> '
right_arrow_alt = '<:arrow:343407434746036224>'
left_arrow = '<a:a_left_arrow:527634992415899650>'
... |
list_a = [10, 20, 30]
list_b = ["Jan", "Peter", "Max"]
list_c = [True, False, True]
for val_a, val_b, val_c in zip(list_a, list_b, list_c):
print(val_a, val_b, val_c)
print("\n")
for i in range(len(list_a)):
print(i, list_a[i])
print("\n")
for i, val in enumerate(list_a):
print(i, val)
| list_a = [10, 20, 30]
list_b = ['Jan', 'Peter', 'Max']
list_c = [True, False, True]
for (val_a, val_b, val_c) in zip(list_a, list_b, list_c):
print(val_a, val_b, val_c)
print('\n')
for i in range(len(list_a)):
print(i, list_a[i])
print('\n')
for (i, val) in enumerate(list_a):
print(i, val) |
PATH_DATA = "../train_data/pan20-author-profiling-training-2020-02-23"
PATH_DATA_EN = "../train_data/pan20-author-profiling-training-2020-02-23/en"
PATH_DATA_ES = "../train_data/pan20-author-profiling-training-2020-02-23/es"
PATH_DATA_EN_TRUTH = "../train_data/pan20-author-profiling-training-2020-02-23/en/truth.txt"
PA... | path_data = '../train_data/pan20-author-profiling-training-2020-02-23'
path_data_en = '../train_data/pan20-author-profiling-training-2020-02-23/en'
path_data_es = '../train_data/pan20-author-profiling-training-2020-02-23/es'
path_data_en_truth = '../train_data/pan20-author-profiling-training-2020-02-23/en/truth.txt'
pa... |
__all__ = ['Meta']
class Meta:
pass
| __all__ = ['Meta']
class Meta:
pass |
def good():
return ['Harry', 'Ron', 'Hermione']
# expected output:
'''
['Harry', 'Ron', 'Hermione']
'''
print( good() ) | def good():
return ['Harry', 'Ron', 'Hermione']
"\n['Harry', 'Ron', 'Hermione'] \n"
print(good()) |
glosario = {'listas' : "Se pueden identificar con []", 'tuplas' : "Se identifican con *()",
'glosario' : "Se identifican con {}", 'if' : "Condicional", 'for' : "Ciclo", '#' : "Para crear un comentario",
'str' : "Abreviacion de String", '==' : "usado para comparar elementos", "=!" : "Usado para verificar que dos eleme... | glosario = {'listas': 'Se pueden identificar con []', 'tuplas': 'Se identifican con *()', 'glosario': 'Se identifican con {}', 'if': 'Condicional', 'for': 'Ciclo', '#': 'Para crear un comentario', 'str': 'Abreviacion de String', '==': 'usado para comparar elementos', '=!': 'Usado para verificar que dos elementos son di... |
n = 8
fib0 = 0
fib1 = 1
if n > 0:
temp = fib0
fib0 = fib1
fib1 = fib1 + temp
n = n - 1
else:
print(f'Resultado {fib0}') | n = 8
fib0 = 0
fib1 = 1
if n > 0:
temp = fib0
fib0 = fib1
fib1 = fib1 + temp
n = n - 1
else:
print(f'Resultado {fib0}') |
class ShellGame(object):
def __init__(self, start, swaps):
self.start = start
self.swaps = swaps
def find_the_ball(self):
if len(self.swaps) == 0:
return self.start
else:
for pos in self.swaps:
for x in pos:
self.start ... | class Shellgame(object):
def __init__(self, start, swaps):
self.start = start
self.swaps = swaps
def find_the_ball(self):
if len(self.swaps) == 0:
return self.start
else:
for pos in self.swaps:
for x in pos:
self.start... |
ROP_POPJUMPLR_STACK12 = 0x0101CD24;
ROP_POPJUMPLR_STACK20 = 0x01024D88;
ROP_CALLFUNC = 0x01080274;
ROP_CALLR28_POP_R28_TO_R31 = 0x0107DD70;
ROP_POP_R28R29R30R31 = 0x0101D8D4;
ROP_POP_R27 = 0x0101CB00;
ROP_POP_R24_TO_R31 = 0x010204C8;
ROP_CALLFUNCPTR_WITHARGS_FROM_R3MEM = 0x010253C0;
ROP_SETR3TOR31_POP_R31 = 0x0101CC10;... | rop_popjumplr_stack12 = 16895268
rop_popjumplr_stack20 = 16928136
rop_callfunc = 17302132
rop_callr28_pop_r28_to_r31 = 17292656
rop_pop_r28_r29_r30_r31 = 16898260
rop_pop_r27 = 16894720
rop_pop_r24_to_r31 = 16909512
rop_callfuncptr_withargs_from_r3_mem = 16929728
rop_setr3_tor31_pop_r31 = 16894992
rop__register = 16938... |
#
# PySNMP MIB module CISCO-VPN-LIC-USAGE-MONITOR-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-VPN-LIC-USAGE-MONITOR-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:03:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Pytho... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, single_value_constraint, value_range_constraint, constraints_union) ... |
# Copyright(c) 2017, Intel Corporation
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the followin... | metadata_guid = b'XeonFPGA\xb7GBSv001'
sizeof_len_field = 4
guid_len = len(METADATA_GUID) |
{
"targets": [
{
"target_name": "lmdb-queue",
"include_dirs" : [
"<!(node -e \"require('nan')\")",
"<!(node -e \"require('nnu')\")",
"deps"
],
"dependencies": [
"<(module_root_dir)/deps/lmdb.gyp:lmdb"
],
"sources": [
"src/module.cc",
... | {'targets': [{'target_name': 'lmdb-queue', 'include_dirs': ['<!(node -e "require(\'nan\')")', '<!(node -e "require(\'nnu\')")', 'deps'], 'dependencies': ['<(module_root_dir)/deps/lmdb.gyp:lmdb'], 'sources': ['src/module.cc', 'src/env.h', 'src/env.cc', 'src/topic.h', 'src/topic.cc', 'src/consumer.h', 'src/consumer.cc', ... |
# the key is the name of the class of the workload and the value is the program argument string
def get_workloads(checkpoint, analytics_data_paths: list, lda_data_paths: list, gbt_data_path: str,
pagerank_data_path: str, k: int, iterations: int, checkpoint_interval: int,
sampling_fra... | def get_workloads(checkpoint, analytics_data_paths: list, lda_data_paths: list, gbt_data_path: str, pagerank_data_path: str, k: int, iterations: int, checkpoint_interval: int, sampling_fraction: float=0.01, analytics_only: bool=False) -> dict:
if analytics_only:
workloads = {'Analytics': f'--sampling-fracti... |
__author__ = 'Cib'
class interface():
pass
| __author__ = 'Cib'
class Interface:
pass |
class MyStack:
def __init__(self):
self.q = deque()
def push(self, x: int) -> None:
self.q.append(x)
def pop(self) -> int:
for i in range(len(self.q)-1):
self.q.append(self.q.popleft())
return self.q.popleft()
def top(self) -> int:
temp = self.pop()
... | class Mystack:
def __init__(self):
self.q = deque()
def push(self, x: int) -> None:
self.q.append(x)
def pop(self) -> int:
for i in range(len(self.q) - 1):
self.q.append(self.q.popleft())
return self.q.popleft()
def top(self) -> int:
temp = self.po... |
N = int(input())
A = list(map(int, input().split()))
ans = 0
max_tall = 0
for i in range(0, N):
if max_tall > A[i]:
ans += max_tall - A[i]
if A[i] > max_tall:
max_tall = A[i]
print(ans) | n = int(input())
a = list(map(int, input().split()))
ans = 0
max_tall = 0
for i in range(0, N):
if max_tall > A[i]:
ans += max_tall - A[i]
if A[i] > max_tall:
max_tall = A[i]
print(ans) |
#
# PySNMP MIB module A3COM0027-RMON-EXTENSIONS (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM0027-RMON-EXTENSIONS
# Produced by pysmi-0.3.4 at Wed May 1 11:08:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.... | (rmon_extensions,) = mibBuilder.importSymbols('A3COM0004-GENERIC', 'rmonExtensions')
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_c... |
class ps_data:
@property
def train_data(self):
return self._train_data
@property
def indexs(self):
return self._indexs
@train_data.setter
def train_data(self, val):
self._train_data=val
@indexs.setter
def indexs(self, val):
self._indexs=val
| class Ps_Data:
@property
def train_data(self):
return self._train_data
@property
def indexs(self):
return self._indexs
@train_data.setter
def train_data(self, val):
self._train_data = val
@indexs.setter
def indexs(self, val):
self._indexs = val |
class Advice:
def __init__(self):
self.clothes = []
self.weather = None
def add_cloth(self, cloth):
self.clothes.append(cloth)
def add_message(self, message):
self.clothes.append(message)
def add_weather(self, weather):
self.weather = weather
| class Advice:
def __init__(self):
self.clothes = []
self.weather = None
def add_cloth(self, cloth):
self.clothes.append(cloth)
def add_message(self, message):
self.clothes.append(message)
def add_weather(self, weather):
self.weather = weather |
__all__= [
'table',
'projects',
'annotations',
'converters',
'metrics'
]
__version__ = '0.0.3'
| __all__ = ['table', 'projects', 'annotations', 'converters', 'metrics']
__version__ = '0.0.3' |
'''
lab2
'''
#3.1
my_name = "Tom"
print(my_name.upper())
#3.2
my_id = 123
print(my_id)
#3.3
# 123=my_id
my_id=your_id=123
print(my_id)
print(your_id)
#3.4
my_id_str= "123"
print(my_id_str)
#3.5
#print(my_name+my_id)
#3.6
print(my_name+my_id_str)
#3.7
print(my_name*3)
#3.8
print('hello, world. This is my fi... | """
lab2
"""
my_name = 'Tom'
print(my_name.upper())
my_id = 123
print(my_id)
my_id = your_id = 123
print(my_id)
print(your_id)
my_id_str = '123'
print(my_id_str)
print(my_name + my_id_str)
print(my_name * 3)
print('hello, world. This is my first python string'.split('.'))
message = "Tom's id is 123"
print(message) |
#/usr/bin/env python
def my_func1(callback):
def func_wrapper(x):
print("my_func1: {0} ".format(callback(x)))
return func_wrapper
@my_func1
def my_func2(x):
return x
# Actuall call sequence is similar to:
# deco = my_func1(my_func2)
# deco("test") => func_wrapper("test")
my_func2("test")
#-------... | def my_func1(callback):
def func_wrapper(x):
print('my_func1: {0} '.format(callback(x)))
return func_wrapper
@my_func1
def my_func2(x):
return x
my_func2('test')
def dec_param(param):
def my_func3(callback):
def func_wrapper(x):
print('my_func3: {0} {1} '.format(param, c... |
# HARD
# Rolling Hash Method
# abc ==> a *26^2, b * 26^1, c * 26^0.
# ex: 123 ==> 1*10^2, 2 * 10^1, 3 * 10^0
# we find every possible substring to find if exist a duplicated one
# start with mid, if possible ==> find longer one else find shorter one
# Time O(NlogN) Space: O(N)
class Solution:
def longestD... | class Solution:
def longest_dup_substring(self, S: str) -> str:
n = len(S)
nums = [ord(S[i]) - ord('a') for i in range(n)]
a = 26
mod = 2 ** 32
(left, right) = (1, n)
while left <= right:
mid = left + (right - left >> 1)
if self.match(mid, a, ... |
def squareme(x):
return(x**2)
myvar = input("Give me a number to square: ")
myvar = float(myvar)
print("The square of %f is %f." % (myvar, squareme(myvar)) )
| def squareme(x):
return x ** 2
myvar = input('Give me a number to square: ')
myvar = float(myvar)
print('The square of %f is %f.' % (myvar, squareme(myvar))) |
class Solution:
def rotate(self, N, D):
D = D%16
val1 = ((N << D) % (2 ** 16)) ^ int(N // (2 ** (16 - D)))
#val1 = (N << D) | (N >> (16 - D))
val2 = (N >> D) ^ int((2 ** (16 - D)) * (N % (2 ** D)))
return [val1, val2]
if __name__ == '__main__':
t = int(input... | class Solution:
def rotate(self, N, D):
d = D % 16
val1 = (N << D) % 2 ** 16 ^ int(N // 2 ** (16 - D))
val2 = N >> D ^ int(2 ** (16 - D) * (N % 2 ** D))
return [val1, val2]
if __name__ == '__main__':
t = int(input())
for _ in range(t):
(n, d) = input().strip().split(... |
#
# PySNMP MIB module HUAWEI-PPP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-PPP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:36:10 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... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, single_value_constraint, value_size_constraint) ... |
class ColorLanguageTranslator:
START = "CRYCYMCRW"
END = "CMW"
@staticmethod
def base7(num):
if num == 0:
return '0'
new_num_string = ''
current = num
while current != 0:
remainder = current % 7
remainder_string = str(remainder)
... | class Colorlanguagetranslator:
start = 'CRYCYMCRW'
end = 'CMW'
@staticmethod
def base7(num):
if num == 0:
return '0'
new_num_string = ''
current = num
while current != 0:
remainder = current % 7
remainder_string = str(remainder)
... |
#https://codeforces.com/problemset/problem/734/A
input()
string = input()
a = string.count('A')
d = string.count('D')
if(a>d):
print('Anton')
elif d>a:
print('Danik')
else:
print('Friendship') | input()
string = input()
a = string.count('A')
d = string.count('D')
if a > d:
print('Anton')
elif d > a:
print('Danik')
else:
print('Friendship') |
# Round the number from input to the required number of
# decimals.
# The input format:
# Two lines: the first with a floating-point number, the second
# with an integer representing the decimal count.
# The output format:
# A formatted string containing the rounded number.
# Do NOT forget to convert the input num... | decimal = float(input())
nth_place = int(input())
print(f'%.{nth_place}f' % decimal)
print(f'{decimal:.{nth_place}f}')
print(f'{float(input()):.{int(input())}f}') |
'''
This is the position of all the pieces, in a dictionary. This data is essential for the gameplay to work
'''
position_dic = { 'a1': "Left White Rook", 'b1': "Left White Knight", 'c1': "Left White Bishop", 'd1': "White Queen", 'e1': "White King", 'f1': "Right White Bishop", 'g1': "Right White Knight", 'h1': "Righ... | """
This is the position of all the pieces, in a dictionary. This data is essential for the gameplay to work
"""
position_dic = {'a1': 'Left White Rook', 'b1': 'Left White Knight', 'c1': 'Left White Bishop', 'd1': 'White Queen', 'e1': 'White King', 'f1': 'Right White Bishop', 'g1': 'Right White Knight', 'h1': 'Right Wh... |
count = 0
def max_ind_set(nodes, edges):
global count
if len(nodes) <= 1: return len(nodes)
node = nodes[0] # pick a node
# case 1: node lies in independent set => remove neighbours as well
nodes1 = [ n for n in nodes if n != node and (node, n) not in edges ]
size1 = 1 + max_ind_set(nodes1, ed... | count = 0
def max_ind_set(nodes, edges):
global count
if len(nodes) <= 1:
return len(nodes)
node = nodes[0]
nodes1 = [n for n in nodes if n != node and (node, n) not in edges]
size1 = 1 + max_ind_set(nodes1, edges)
count += 1
nodes2 = [n for n in nodes if n != node]
size2 = max_... |
ENCRYPTED_MESSAGE = 'IQ PQTVJ CV PQQP'
DECRYPTED_MESSAGE = 'GO NORTH AT NOON'
CIPHER_OPTIONS = ['null','caesar','atbash']
cipher_used_in_this_example = CIPHER_OPTIONS[1] # replace with the index of the cipher used in this encryption
| encrypted_message = 'IQ PQTVJ CV PQQP'
decrypted_message = 'GO NORTH AT NOON'
cipher_options = ['null', 'caesar', 'atbash']
cipher_used_in_this_example = CIPHER_OPTIONS[1] |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"img_resize": "00_clipmodel.ipynb",
"imgs_resize": "00_clipmodel.ipynb",
"dict_to_device": "00_clipmodel.ipynb",
"norm": "00_clipmodel.ipynb",
"detach_norm": "00_clipmodel.... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'img_resize': '00_clipmodel.ipynb', 'imgs_resize': '00_clipmodel.ipynb', 'dict_to_device': '00_clipmodel.ipynb', 'norm': '00_clipmodel.ipynb', 'detach_norm': '00_clipmodel.ipynb', 'text2clip_en': '00_clipmodel.ipynb', 'images2clip_en': '00_clipmodel... |
# -*- coding: utf-8 -*-
__author__ = 'Russell Davies'
__copyright__ = 'Copyright (c) 2019-present - Russell Davies'
__description__ = 'The blakemere package provides a collection of python libraries created by Russell Davies.'
__email__ = 'russell@blakemere.ca'
__license__ = 'MIT'
__title__ = 'blakemere'
__version__ =... | __author__ = 'Russell Davies'
__copyright__ = 'Copyright (c) 2019-present - Russell Davies'
__description__ = 'The blakemere package provides a collection of python libraries created by Russell Davies.'
__email__ = 'russell@blakemere.ca'
__license__ = 'MIT'
__title__ = 'blakemere'
__version__ = '0.1.0' |
def mergeList(lis1, list2):
print("list1 =", list1)
print("list2 =", list2)
list3 = []
for i in list1:
if(i % 2 == 1):
list3.append(i)
for i in list2:
if(i % 2 == 0):
list3.append(i)
return list3
list1 = [10, 20, 23, 11, 17]
list2 = [13, 43, 24, 36, 12]
print("Result List ... | def merge_list(lis1, list2):
print('list1 =', list1)
print('list2 =', list2)
list3 = []
for i in list1:
if i % 2 == 1:
list3.append(i)
for i in list2:
if i % 2 == 0:
list3.append(i)
return list3
list1 = [10, 20, 23, 11, 17]
list2 = [13, 43, 24, 36, 12]
pri... |
#daemon = True
# 1 core should equal 2*1+1=3 workers
workers = 3
# we want to use threads for concurrency. we estimate that a maximum of 3*7=21 users will use the application simultaneously
worker_class = "gthread"
threads = 7
#accesslog = "logs/access.log"
#errorlog = "logs/error.log"
| workers = 3
worker_class = 'gthread'
threads = 7 |
#! /usr/bin/env python
# Copyright Lajos Katona
#
# 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... | def search_linear(mylist, t):
for (i, l) in enumerate(mylist):
if l == t:
return i
return -1
def search_logarithm(mylist, t):
lower_b = 0
upper_b = len(mylist)
while True:
if lower_b == upper_b:
return -1
mid = (lower_b + upper_b) // 2
mid_ite... |
# Customer class
class Customer:
def __init__(self, name, address, phone):
self.__name = name
self.__address = address
self.__phone = phone
def set_name(self, name):
self.__name = name
def set_address(self, address):
self.__address = address
def set_phone(self,... | class Customer:
def __init__(self, name, address, phone):
self.__name = name
self.__address = address
self.__phone = phone
def set_name(self, name):
self.__name = name
def set_address(self, address):
self.__address = address
def set_phone(self, phone):
... |
# %% [695. Max Area of Island](https://leetcode.com/problems/max-area-of-island/)
class Solution:
def maxAreaOfIsland(self, grid: List[List[int]]) -> int:
n, m = len(grid), len(grid[0])
u = unionfind(n, m)
for i in range(n):
for j in range(m):
if j + 1 < m and gri... | class Solution:
def max_area_of_island(self, grid: List[List[int]]) -> int:
(n, m) = (len(grid), len(grid[0]))
u = unionfind(n, m)
for i in range(n):
for j in range(m):
if j + 1 < m and grid[i][j] == grid[i][j + 1] == 1:
u.unite((i, j), (i, j ... |
# Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project au... | {'includes': ['../build/common.gypi'], 'targets': [{'target_name': 'webrtc_test_common', 'type': 'static_library', 'sources': ['configurable_frame_size_encoder.cc', 'configurable_frame_size_encoder.h', 'direct_transport.cc', 'direct_transport.h', 'encoder_settings.cc', 'encoder_settings.h', 'fake_audio_device.cc', 'fak... |
#!/usr/bin/python3
'''This module contains the add_integer function
'''
def add_integer(a, b=98):
'''add_integer adds two integers and/or floats together
and returns an integer of their sum
'''
if not isinstance(a, (int, float)):
raise TypeError("a must be an integer")
if not isinstance(b,... | """This module contains the add_integer function
"""
def add_integer(a, b=98):
"""add_integer adds two integers and/or floats together
and returns an integer of their sum
"""
if not isinstance(a, (int, float)):
raise type_error('a must be an integer')
if not isinstance(b, (int, float)):
... |
class Config(object):
def __init__(self, stellar_sed, laser_sed,
filt, nsamples, sample_rate, pulse_duration):
self.stellar_sed = stellar_sed
self.laser_sed = laser_sed
self.filt = filt
self.nsamples = nsamples # in ns
self.sample_rate = sample_rate # in ... | class Config(object):
def __init__(self, stellar_sed, laser_sed, filt, nsamples, sample_rate, pulse_duration):
self.stellar_sed = stellar_sed
self.laser_sed = laser_sed
self.filt = filt
self.nsamples = nsamples
self.sample_rate = sample_rate
self.pulse_duration = pul... |
# This is a util to create the advancement files
# Advancement list from https://github.com/jan00bl/mcfunction-novum/blob/master/lib/1.16/id/advancement.json
advancements = [
"minecraft:adventure/adventuring_time",
"minecraft:adventure/arbalistic",
"minecraft:adventure/bullseye",
"minecraft:adventure/h... | advancements = ['minecraft:adventure/adventuring_time', 'minecraft:adventure/arbalistic', 'minecraft:adventure/bullseye', 'minecraft:adventure/hero_of_the_village', 'minecraft:adventure/honey_block_slide', 'minecraft:adventure/kill_all_mobs', 'minecraft:adventure/kill_a_mob', 'minecraft:adventure/ol_betsy', 'minecraft:... |
#
# PySNMP MIB module HOTWIRE-MSDSL-INTERFACE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HOTWIRE-MSDSL-INTERFACE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:20:19 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, constraints_union, value_size_constraint, value_range_constraint) ... |
sql_user = "lopez"
# for obvious reasons this should be changed
sql_pass = "johny johny telling lies"
sql_db = "lopez"
sql_host = "localhost"
sql_port = 5432
# changing the below line will void the non-existent warranty Lopez came with
# so please don't
postgresql = "postgresql://{0}:{1}@{2}:{3}/{4}".format(
sql_us... | sql_user = 'lopez'
sql_pass = 'johny johny telling lies'
sql_db = 'lopez'
sql_host = 'localhost'
sql_port = 5432
postgresql = 'postgresql://{0}:{1}@{2}:{3}/{4}'.format(sql_user, sql_pass, sql_host, sql_port, sql_db) |
DEPS = [
'chromium',
'file',
'gsutil',
'recipe_engine/json',
'math_utils',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/python',
'recipe_engine/raw_io',
'recipe_engine/step',
]
| deps = ['chromium', 'file', 'gsutil', 'recipe_engine/json', 'math_utils', 'recipe_engine/path', 'recipe_engine/platform', 'recipe_engine/properties', 'recipe_engine/python', 'recipe_engine/raw_io', 'recipe_engine/step'] |
class Solution:
def XXX(self, root: TreeNode) -> List[List[int]]:
ans, d = [], [root] if root else []
while d:
ans.append([t.val for t in d])
d = [r for t in d for r in (t.left, t.right) if r]
return ans
| class Solution:
def xxx(self, root: TreeNode) -> List[List[int]]:
(ans, d) = ([], [root] if root else [])
while d:
ans.append([t.val for t in d])
d = [r for t in d for r in (t.left, t.right) if r]
return ans |
# Range -> range instance that holds all nums counting by one between 0 and first input
# List -> lists numbers from the inputted tuple
numberedContestants = range(30)
print(list(numberedContestants))
for c in list(numberedContestants):
print(f"Contestant {c} is here.")
lucky_winners = range(7, 30, 5)
print(lis... | numbered_contestants = range(30)
print(list(numberedContestants))
for c in list(numberedContestants):
print(f'Contestant {c} is here.')
lucky_winners = range(7, 30, 5)
print(list(lucky_winners)) |
class Thing:
def __init__(self, x, y, name):
self.x = x
self.y = y
self.name = name
t = Thing(12, 34, "dave")
print(vars(t)) # {'x': 12, 'y': 34, 'name': 'dave'}
| class Thing:
def __init__(self, x, y, name):
self.x = x
self.y = y
self.name = name
t = thing(12, 34, 'dave')
print(vars(t)) |
#!/usr/bin/python
class FilterModule(object):
def filters(self):
return {
'amend_list_items': self.amend_list_items
}
def amend_list_items(self, orig_list, prefix="", postfix=""):
return list(map(lambda listelement: prefix +
str(listelement) + postfix... | class Filtermodule(object):
def filters(self):
return {'amend_list_items': self.amend_list_items}
def amend_list_items(self, orig_list, prefix='', postfix=''):
return list(map(lambda listelement: prefix + str(listelement) + postfix, orig_list)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.