content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
{
"targets": [
{
"target_name": "readpath",
"sources": [ "src/dirread.cc", "src/async.cc" ],
"include_dirs" : [
"<!(node -e \"require('nan')\")"
]
}
],
}
| {'targets': [{'target_name': 'readpath', 'sources': ['src/dirread.cc', 'src/async.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")']}]} |
class TrieNode:
def __init__(self):
self.children: Dict[str, TrieNode] = defaultdict(TrieNode)
self.word: Optional[str] = None
class Solution:
def findWords(self, board: List[List[str]], words: List[str]) -> List[str]:
m = len(board)
n = len(board[0])
ans = []
root = TrieNode()
def in... | class Trienode:
def __init__(self):
self.children: Dict[str, TrieNode] = defaultdict(TrieNode)
self.word: Optional[str] = None
class Solution:
def find_words(self, board: List[List[str]], words: List[str]) -> List[str]:
m = len(board)
n = len(board[0])
ans = []
... |
# This is a list of modules which are not required to build
# in order to test out this extension. Mostly useful for CI.
module_arkit_enabled = "no"
module_assimp_enabled = "no"
module_fbx_enabled = "no"
module_bmp_enabled = "no"
module_bullet_enabled = "no"
module_camera_enabled = "no"
module_csg_enabled = "no"
modul... | module_arkit_enabled = 'no'
module_assimp_enabled = 'no'
module_fbx_enabled = 'no'
module_bmp_enabled = 'no'
module_bullet_enabled = 'no'
module_camera_enabled = 'no'
module_csg_enabled = 'no'
module_cvtt_enabled = 'no'
module_dds_enabled = 'no'
module_enet_enabled = 'no'
module_etc_enabled = 'no'
module_gdnative_enabl... |
TEST_DATA = [(
'donation_page',
'https://adblockplus.org/donate',
), (
'update_page',
'https://new.adblockplus.org/update',
), (
'first_run_page',
'https://welcome.adblockplus.org/installed'
)]
| test_data = [('donation_page', 'https://adblockplus.org/donate'), ('update_page', 'https://new.adblockplus.org/update'), ('first_run_page', 'https://welcome.adblockplus.org/installed')] |
set_name(0x800A2AB8, "VID_OpenModule__Fv", SN_NOWARN)
set_name(0x800A2B78, "InitScreens__Fv", SN_NOWARN)
set_name(0x800A2C68, "MEM_SetupMem__Fv", SN_NOWARN)
set_name(0x800A2C94, "SetupWorkRam__Fv", SN_NOWARN)
set_name(0x800A2D24, "SYSI_Init__Fv", SN_NOWARN)
set_name(0x800A2E30, "GM_Open__Fv", SN_NOWARN)
set_name(0x800A... | set_name(2148149944, 'VID_OpenModule__Fv', SN_NOWARN)
set_name(2148150136, 'InitScreens__Fv', SN_NOWARN)
set_name(2148150376, 'MEM_SetupMem__Fv', SN_NOWARN)
set_name(2148150420, 'SetupWorkRam__Fv', SN_NOWARN)
set_name(2148150564, 'SYSI_Init__Fv', SN_NOWARN)
set_name(2148150832, 'GM_Open__Fv', SN_NOWARN)
set_name(214815... |
# basic stack implementation
# author: D1N3SHh
# https://github.com/D1N3SHh/algorithms
class StackOverflowError(BaseException):
pass
class StackEmptyError(BaseException):
pass
class Stack():
def __init__(self, max_size = 10):
self.max_size = max_size
self.s = []
def __repr__(self):... | class Stackoverflowerror(BaseException):
pass
class Stackemptyerror(BaseException):
pass
class Stack:
def __init__(self, max_size=10):
self.max_size = max_size
self.s = []
def __repr__(self):
return str(self.s)
def push(self, x):
if len(self.s) < self.max_size:
... |
class UniquenessError(ValueError):
def __init__(self, index_name):
ValueError.__init__(self, index_name)
class NotFoundError(KeyError):
pass
| class Uniquenesserror(ValueError):
def __init__(self, index_name):
ValueError.__init__(self, index_name)
class Notfounderror(KeyError):
pass |
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'market_platform_backend',
'USER': 'postgres',
'HOST': 'postgres',
'PORT': '5432',
'PASSWORD': ''
}
}
CELERY_BROKER_URL = 'redis://redis:6379'
CELERY_RESULT_BACKEND = 'redis://redis:637... | databases = {'default': {'ENGINE': 'django.db.backends.postgresql', 'NAME': 'market_platform_backend', 'USER': 'postgres', 'HOST': 'postgres', 'PORT': '5432', 'PASSWORD': ''}}
celery_broker_url = 'redis://redis:6379'
celery_result_backend = 'redis://redis:6379'
debug = False |
numero = int(input("Digite um numero para calcular tabuada: "))
tab = 0
while (tab <= 10):
print (tab ,"X",numero,"=", numero * tab)
tab +=1
| numero = int(input('Digite um numero para calcular tabuada: '))
tab = 0
while tab <= 10:
print(tab, 'X', numero, '=', numero * tab)
tab += 1 |
SPACE = 20
def print_stand_species(summary_stand):
formatted = ['STAND METRICS']
for i, row in enumerate(summary_stand):
formatted.append(''.join([j + (' ' * (SPACE - len(j))) for j in row]))
if i == 0 or i == len(summary_stand) - 2:
formatted.append('-' * (SPACE * len(row)))
r... | space = 20
def print_stand_species(summary_stand):
formatted = ['STAND METRICS']
for (i, row) in enumerate(summary_stand):
formatted.append(''.join([j + ' ' * (SPACE - len(j)) for j in row]))
if i == 0 or i == len(summary_stand) - 2:
formatted.append('-' * (SPACE * len(row)))
re... |
def hashadNum(num):
digitSum = sum([int(k) for k in str(num)])
if num % digitSum == 0:
return True
else:
return False
n = int(input())
while not (hashadNum(n)):
n += 1
print(n) | def hashad_num(num):
digit_sum = sum([int(k) for k in str(num)])
if num % digitSum == 0:
return True
else:
return False
n = int(input())
while not hashad_num(n):
n += 1
print(n) |
def parseExpression(expression):
operators = ['**', '+', '-', '*', '/', '%']
operator = '+'
for currOperator in operators:
if expression.__contains__(currOperator):
operator = currOperator
break
if bool(operator):
operands = expression.split(operator)
... | def parse_expression(expression):
operators = ['**', '+', '-', '*', '/', '%']
operator = '+'
for curr_operator in operators:
if expression.__contains__(currOperator):
operator = currOperator
break
if bool(operator):
operands = expression.split(operator)
return... |
# -*- coding: utf-8 -*-
# --- Slack configuration ---
# get your own at https://api.slack.com/docs/oauth-test-tokens
SLACK_TOKEN = "xoxp-XXX"
# the channel Slasher will send its messages to
SLACK_CHANNEL = "#random"
# Slasher's username
SLACK_USERNAME = "Slasher"
# Slasher's icon
SLACK_USER_EMOJI = ":robot_face:"
#... | slack_token = 'xoxp-XXX'
slack_channel = '#random'
slack_username = 'Slasher'
slack_user_emoji = ':robot_face:'
giphy_tags = ['fireworks', 'guitar'] |
S = input().split()
N = int(input())
print(*S)
for _ in range(N):
next_S = input().split()
for i in range(4):
p = i // 2
q = i % 2
if S[p] == next_S[q]:
next_S[q] = S[p^1]
S = next_S
print(*S)
break
else:
assert(False)
| s = input().split()
n = int(input())
print(*S)
for _ in range(N):
next_s = input().split()
for i in range(4):
p = i // 2
q = i % 2
if S[p] == next_S[q]:
next_S[q] = S[p ^ 1]
s = next_S
print(*S)
break
else:
assert False |
def start() :
driverType = irr.driverChoiceConsole();
if driverType == irr.EDT_COUNT :
return 1;
device = irr.createDevice(driverType, irr.dimension2d_u32(640, 480));
if device == None :
return 1;
driver = device.getVideoDriver();
smgr = device.getSceneManager();
device.getFileSystem().addZi... | def start():
driver_type = irr.driverChoiceConsole()
if driverType == irr.EDT_COUNT:
return 1
device = irr.createDevice(driverType, irr.dimension2d_u32(640, 480))
if device == None:
return 1
driver = device.getVideoDriver()
smgr = device.getSceneManager()
device.getFileSystem... |
class Node():
def __init__(self, name):
self.name = name
self.possValues = []
self.value = ""
self.parents = []
self.children = []
self.CPD = {}
# variables for use in Variable Elimination
self.inDeg = 0
self.used = False
| class Node:
def __init__(self, name):
self.name = name
self.possValues = []
self.value = ''
self.parents = []
self.children = []
self.CPD = {}
self.inDeg = 0
self.used = False |
def convert24(time):
if time[-2:] == "AM" and time[:2] == "12":
return "00" + time[2:-2]
elif time[-2:] == "AM":
return time[:-2]
elif time[-2:] == "PM" and time[:2] == "12":
return time[:-2]
else:
return str(int(time[:2]) + 12) + tim... | def convert24(time):
if time[-2:] == 'AM' and time[:2] == '12':
return '00' + time[2:-2]
elif time[-2:] == 'AM':
return time[:-2]
elif time[-2:] == 'PM' and time[:2] == '12':
return time[:-2]
else:
return str(int(time[:2]) + 12) + time[2:6]
tc = int(input())
while tc > 0:... |
# encoding: utf-8
class Config(object):
# Number of results to fetch from API
RESULT_COUNT = 9
# How long to cache results for
CACHE_MAX_AGE = 20 # seconds
ICON = "2B939AF4-1A27-4D41-96FE-E75C901C780F.png"
GOOGLE_ICON = "google.png"
# Algolia credentials
ALGOLIA_APP_ID = "BH4D9OD16A"
... | class Config(object):
result_count = 9
cache_max_age = 20
icon = '2B939AF4-1A27-4D41-96FE-E75C901C780F.png'
google_icon = 'google.png'
algolia_app_id = 'BH4D9OD16A'
algolia_search_only_api_key = '1d8534f83b9b0cfea8f16498d19fbcab'
algolia_search_index = 'material-ui' |
'''input
100 4 16
4554
'''
'''input
20 2 5
84
'''
# -*- coding: utf-8 -*-
# AtCoder Beginner Contest
# Problem B
def sum_digit(number):
string = str(number)
array = list(map(int, list(string)))
return sum(array)
if __name__ == '__main__':
N, A, B = list(map(int, input().split... | """input
100 4 16
4554
"""
'input\n20 2 5\n84\n'
def sum_digit(number):
string = str(number)
array = list(map(int, list(string)))
return sum(array)
if __name__ == '__main__':
(n, a, b) = list(map(int, input().split()))
total = 0
for number in range(1, N + 1):
if A <= sum_digit(number) <... |
SITE_TITLE = "Awesome Boilerplates"
FRAMEWORK_TITLE = ""
RESTRICT_PACKAGE_EDITORS = False
RESTRICT_GRID_EDITORS = False
ADMINS = [
("Vinta", "awesomeboilerplates@vinta.com.br"),
]
| site_title = 'Awesome Boilerplates'
framework_title = ''
restrict_package_editors = False
restrict_grid_editors = False
admins = [('Vinta', 'awesomeboilerplates@vinta.com.br')] |
class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def store_inorder(root, inorder):
if root is None:
return
store_inorder(root.left, inorder)
inorder.append(root.data)
store_inorder(root.right, inorder)
def count_nodes(root):... | class Node:
def __init__(self, val):
self.val = val
self.left = None
self.right = None
def store_inorder(root, inorder):
if root is None:
return
store_inorder(root.left, inorder)
inorder.append(root.data)
store_inorder(root.right, inorder)
def count_nodes(root):
... |
# To store registered users
registered_users = {}
# To store User staus Ture for Login & False for Logout
user_status = {}
user_account = {}
def total_users():
return len(registered_users)
| registered_users = {}
user_status = {}
user_account = {}
def total_users():
return len(registered_users) |
grid = [
['W', 'L', 'W', 'W', 'W'],
['W', 'L', 'W', 'W', 'W'],
['W', 'W', 'W', 'L', 'W'],
['W', 'W', 'L', 'L', 'W'],
['L', 'W', 'W', 'L', 'L'],
['L', 'L', 'W', 'W', 'W'],
]
visited_land = []
def minimum_island(grid):
min = 100
for i in range(0, len(grid)):
for j in range(0, l... | grid = [['W', 'L', 'W', 'W', 'W'], ['W', 'L', 'W', 'W', 'W'], ['W', 'W', 'W', 'L', 'W'], ['W', 'W', 'L', 'L', 'W'], ['L', 'W', 'W', 'L', 'L'], ['L', 'L', 'W', 'W', 'W']]
visited_land = []
def minimum_island(grid):
min = 100
for i in range(0, len(grid)):
for j in range(0, len(grid[0])):
coun... |
params = dict()
class Param(object):
def __init__(self, name, value=None):
self._name = name
self._value = value
params[self.format()] = self
@property
def name(self):
return self._name
def format(self):
string = self.name
if self.value is not None:
... | params = dict()
class Param(object):
def __init__(self, name, value=None):
self._name = name
self._value = value
params[self.format()] = self
@property
def name(self):
return self._name
def format(self):
string = self.name
if self.value is not None:
... |
# Databricks notebook source
BGBQHOWGGFSMHPYXGTO
NZPBFOKMJLRQHTARPERJDKKJQZPZKYQCWGGKJLOJJGHLJABIYDVAYNJVEYPYNYHIEWTJHFMDBEJXY
YGPGFWXAJUKFLCXFPXDGXTEVNVRFKDXIYKLYACCVXBWTDQOQHXDNIJXRLNXBFSLJYR
EDQHGMWXXKNBGRPVWTVEYCIQJCENTCTADVYPELTBKBMSXQNCRTZGCMFGGEJIGIVKMIEBSWQPJOGQNEXRUEGOALGKVKQPTOZMLVQKCNKLQHNWIZOPPYI
VPOCQGWW... | BGBQHOWGGFSMHPYXGTO
NZPBFOKMJLRQHTARPERJDKKJQZPZKYQCWGGKJLOJJGHLJABIYDVAYNJVEYPYNYHIEWTJHFMDBEJXY
YGPGFWXAJUKFLCXFPXDGXTEVNVRFKDXIYKLYACCVXBWTDQOQHXDNIJXRLNXBFSLJYR
EDQHGMWXXKNBGRPVWTVEYCIQJCENTCTADVYPELTBKBMSXQNCRTZGCMFGGEJIGIVKMIEBSWQPJOGQNEXRUEGOALGKVKQPTOZMLVQKCNKLQHNWIZOPPYI
VPOCQGWWXEJUUXXEUDYXOQBBKBEUUDRGYWHKMGJ... |
def test_correct_message():
pass
def test_incorrect_field():
pass
| def test_correct_message():
pass
def test_incorrect_field():
pass |
class Edge:
def __init__(self, v1: int, v2: int, f1: int, f2: int, p1: int, p2: int):
self.v1 = v1
self.v2 = v2
self.f1 = f1
self.f2 = f2
self.p1 = p1
self.p2 = p2
def __repr__(self):
return f'<Edge v=({self.v1}, {self.v2}) f=({self.f1}, {self.f2}) p=({se... | class Edge:
def __init__(self, v1: int, v2: int, f1: int, f2: int, p1: int, p2: int):
self.v1 = v1
self.v2 = v2
self.f1 = f1
self.f2 = f2
self.p1 = p1
self.p2 = p2
def __repr__(self):
return f'<Edge v=({self.v1}, {self.v2}) f=({self.f1}, {self.f2}) p=({s... |
def min_max_from_inputV2():
inp_list = []
while True:
string_num = input('Enter a number: ')
if string_num == 'done':
break
try:
num = int(string_num)
except:
print('Invalid input')
continue
inp_list.append(num)
... | def min_max_from_input_v2():
inp_list = []
while True:
string_num = input('Enter a number: ')
if string_num == 'done':
break
try:
num = int(string_num)
except:
print('Invalid input')
continue
inp_list.append(num)
maximum... |
#
# PySNMP MIB module RFC-HIPPI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RFC-HIPPI-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:56:15 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, single_value_constraint, constraints_union, value_range_constraint) ... |
n,k=list(map(int,input().split()))
s=list(map(int,input().split()))
ans=int(len([i for i in s if 5-i>=k])/3)
print(ans)
| (n, k) = list(map(int, input().split()))
s = list(map(int, input().split()))
ans = int(len([i for i in s if 5 - i >= k]) / 3)
print(ans) |
def add(a, b):
return a + b
add()
def add(a, b):
print(a+b)
def say_hello():
print("hello")
say_hello()
| def add(a, b):
return a + b
add()
def add(a, b):
print(a + b)
def say_hello():
print('hello')
say_hello() |
class Goods(object):
__slots__ = ('id', 'name', 'price')
def __init__(self,id,name,price):
self.id=id
self.name=name
self.price=price | class Goods(object):
__slots__ = ('id', 'name', 'price')
def __init__(self, id, name, price):
self.id = id
self.name = name
self.price = price |
# configuration file for interface "jms_1"
# this file exists as a reference for configuring JMS interfaces
#
# copy this file to your own cage, possibly renaming into
# config_interface_YOUR_INTERFACE_NAME.py, then modify the copy
#
# this particular configuration works with OpenMQ and file-based JNDI
config = dict \... | config = dict(protocol='jms', java='C:\\JDK\\BIN\\java.exe', arguments=('-Dfile.encoding=windows-1251',), classpath='c:\\pythomnic3k\\lib;c:\\pythomnic3k\\lib\\jms.jar;c:\\pythomnic3k\\lib\\imq.jar;c:\\pythomnic3k\\lib\\fscontext.jar', jndi={'java.naming.factory.initial': 'com.sun.jndi.fscontext.RefFSContextFactory', '... |
'''
Created on May 1, 2016
@author: Drew
'''
PlayBtnPos = (0, 0, 0.0)
PlayBtnHidePos = (0, 0, -1.1)
OptionsBtnPos = (-.9, 0, -0.6)
OptionsBtnHidePos = (-.9, 0, -1.7)
DiscordBtnPos = (-.3, 0, -0.6)
DiscordBtnHidePos = (-.3, 0, -1.7)
CreditsBtnPos = (.3, 0, -0.6)
CreditsBtnHidePos = (.3, 0, -1.7)
QuitBtnPos = (.9, ... | """
Created on May 1, 2016
@author: Drew
"""
play_btn_pos = (0, 0, 0.0)
play_btn_hide_pos = (0, 0, -1.1)
options_btn_pos = (-0.9, 0, -0.6)
options_btn_hide_pos = (-0.9, 0, -1.7)
discord_btn_pos = (-0.3, 0, -0.6)
discord_btn_hide_pos = (-0.3, 0, -1.7)
credits_btn_pos = (0.3, 0, -0.6)
credits_btn_hide_pos = (0.3, 0, -1.... |
# @Author: Ozan YILDIZ@2022
# Boolean Variable Literal Examples
booleanTrue = True
booleanFalse = False
four = True + 3
two = False - 0
trueResult = (four == 4)
falseResult = (two == 3)
if __name__ == '__main__':
print("Boolean True (True)", booleanTrue)
print("Boolean False (False)", booleanFalse)
print("F... | boolean_true = True
boolean_false = False
four = True + 3
two = False - 0
true_result = four == 4
false_result = two == 3
if __name__ == '__main__':
print('Boolean True (True)', booleanTrue)
print('Boolean False (False)', booleanFalse)
print('Four:', four)
print('Two:', two)
print('True result:', tr... |
# -*- coding: utf-8 -*-
# Copyright 2014 Mirantis, Inc.
#
# 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 requi... | _ip_address_schema = {'type': 'string', 'format': 'ipv4'}
_net_address_schema = {'type': 'string', 'pattern': '^(({octet}\\.){{3}}{octet})({prefix})?$'.format(octet='(2(5[0-5]|[0-4][0-9])|[01]?[0-9][0-9]?)', prefix='/(3[012]|[12]?[0-9])')}
_mac_address_schema = {'type': 'string', 'pattern': '^([0-9A-Fa-f]{2}[:-]){5}([0... |
# Employees salute when they "cross".
# Hallway exits do not count.
# Key algorithms: regular expression, counting, indexing
# For each > (right-going employee),
# count < (left-going employee).
# Then double the total encounters (because they greet "each other").
# string.count("char")
# list.index(element)
# stri... | example_salute = '--->-><-><-->-'
test_salute1 = '>----<'
test_salute2 = '<<>><'
def solution(s):
hall = s.replace('-', '')
crosses = 0
for (i, char) in enumerate(hall):
if char == '>':
crosses += hall[i:].count('<')
salutes = crosses * 2
return salutes
print(solution(example_sa... |
tweet_at = '@Attribution'
tweet_url = 'https://example.com/additional-url'
tweet_hashtag = '#MyHashtag'
tweet_data = [
{ 'image': 'https://example.com/image.jpg',
'id': 'image_id',
'title': 'Example title',
'desc': 'Example description with lots of text that probably goes well over the 280 character lim... | tweet_at = '@Attribution'
tweet_url = 'https://example.com/additional-url'
tweet_hashtag = '#MyHashtag'
tweet_data = [{'image': 'https://example.com/image.jpg', 'id': 'image_id', 'title': 'Example title', 'desc': 'Example description with lots of text that probably goes well over the 280 character limit. The python scr... |
def rabbit_pairs(n,k):
if(n==1):
return 1
if(n==2):
return 1
else:
return k*rabbit_pairs(n-2,k)+rabbit_pairs(n-1,k)
def main():
with open('datasets/rosalind_fib.txt') as input_data:
n,k=map(int,input_data.read().strip().split())
# n=5
# k=3
pairs=str... | def rabbit_pairs(n, k):
if n == 1:
return 1
if n == 2:
return 1
else:
return k * rabbit_pairs(n - 2, k) + rabbit_pairs(n - 1, k)
def main():
with open('datasets/rosalind_fib.txt') as input_data:
(n, k) = map(int, input_data.read().strip().split())
pairs = str(rabbit_... |
def digits_product(product):
if product<10:
return 10+product
res=factorization(product)
for i in res:
if i>=10:
return -1
reduce(res)
total=0
for i,j in enumerate(res):
total+=10**(len(res)-i-1)*j
return total
def factorization(n):
res=[]
factor=2... | def digits_product(product):
if product < 10:
return 10 + product
res = factorization(product)
for i in res:
if i >= 10:
return -1
reduce(res)
total = 0
for (i, j) in enumerate(res):
total += 10 ** (len(res) - i - 1) * j
return total
def factorization(n):... |
a=10
b=20
a+b #addition
a/b #divde
a-b #substraction
a*b #multiplication
a%b #reminder
a**b #exponent
a//b #floor devision
| a = 10
b = 20
a + b
a / b
a - b
a * b
a % b
a ** b
a // b |
NEW_FEATURES = [3, 5, 6, 7]
FEATURES = [
1, # L
2, # S
4, # B
8, # A
3, # LS
5, # LB
6, # SB
9, # LA
9, # LA
9, # LA
9, # LA
9, # LA
10, # SA
10, # SA
10, # SA
10, # SA
10, # SA
12, # BA
12, # BA
12, # BA
12, # BA
... | new_features = [3, 5, 6, 7]
features = [1, 2, 4, 8, 3, 5, 6, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 12, 12, 12, 12, 12, 7, 11, 11, 11, 11, 13, 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 15]
new_weights = [None, None, None, None]
weights = [None, None, None, None, [0.3, 0.7], [0.3, 0.7], [0.3, 0.7], None, [0.6, 0.4], [... |
class Solution:
def summaryRanges(self, nums: List[int]) -> List[str]:
res = []
if not nums:
return nums
nums = nums + [nums[-1]+2]
head = nums[0]
for i in range(1,len(nums)):
if nums[i]-nums[i-1]>1:
if head ==nums[i-1]:
... | class Solution:
def summary_ranges(self, nums: List[int]) -> List[str]:
res = []
if not nums:
return nums
nums = nums + [nums[-1] + 2]
head = nums[0]
for i in range(1, len(nums)):
if nums[i] - nums[i - 1] > 1:
if head == nums[i - 1]:
... |
def quick_sort(arr, a, b):
if a >= b: return
pivot = arr[(a+b)//2]
left = a
right = b
while True:
while arr[left] < pivot: left += 1
while pivot < arr[right]: right -= 1
if left >= right: break
arr[left], arr[right] = arr[right], arr[left]
left += 1
... | def quick_sort(arr, a, b):
if a >= b:
return
pivot = arr[(a + b) // 2]
left = a
right = b
while True:
while arr[left] < pivot:
left += 1
while pivot < arr[right]:
right -= 1
if left >= right:
break
(arr[left], arr[right]) = ... |
# This file serves as an example for what's needed in your secrets.py file.
# You can make a copy of this and rename it secrets.py.
# Create an application at https://discord.com/developers/applications
# Then go to the `bot` section of your app and see the token.
DISCORD_TOKEN = 'YOUR TOKEN HERE'
# Create a client ... | discord_token = 'YOUR TOKEN HERE'
blizzard_client_id = 'YOUR TOKEN HERE'
blizzard_client_secret = 'YOUR TOKEN HERE' |
class Curve_Colors():
##!
##! Set colors
##!
def Curve_Colors_Take(self,colordefs):
bcolor=self.BackGround_Color()
for color in colordefs.keys():
self.Color_Schemes[ bcolor ][ color ]=colordefs[ color ]
##!
##! Sets Analytical Evolute colors.
##!
... | class Curve_Colors:
def curve__colors__take(self, colordefs):
bcolor = self.BackGround_Color()
for color in colordefs.keys():
self.Color_Schemes[bcolor][color] = colordefs[color]
def evolute__analytical__colors(self):
bcolor = self.BackGround_Color()
self.Curve_Colo... |
valores = []
while True:
valores.append(int(input('Digite um valor:')))
resp = str(input('Quer continuar: ')).upper()[0]
if resp == 'N':
break
pares = []
impares = []
for v in valores:
if v % 2 == 0:
pares.append(v)
else:
impares.append(v)
print(f'Os valores digitados foram {... | valores = []
while True:
valores.append(int(input('Digite um valor:')))
resp = str(input('Quer continuar: ')).upper()[0]
if resp == 'N':
break
pares = []
impares = []
for v in valores:
if v % 2 == 0:
pares.append(v)
else:
impares.append(v)
print(f'Os valores digitados foram {... |
# SWEA 2050
string = input()
for c in string:
print(ord(c) - ord("A") + 1, end=" ")
| string = input()
for c in string:
print(ord(c) - ord('A') + 1, end=' ') |
'''
Write a Python function named printAsterisks that is passed a positive integer value n, and prints
out a line of n asterisks. If n is greater than 75, then only 75 asterisks should be displayed.
'''
def printAsterix(n):
return '*'*(n if n<75 else 75)
print(printAsterix(int(input("Enter number: "))))
| """
Write a Python function named printAsterisks that is passed a positive integer value n, and prints
out a line of n asterisks. If n is greater than 75, then only 75 asterisks should be displayed.
"""
def print_asterix(n):
return '*' * (n if n < 75 else 75)
print(print_asterix(int(input('Enter number: ')))) |
def consecutive_elements_opt(arr,k):
window_sum=0
for i in range(k):
window_sum+=arr[i]
max_sum=window_sum
for j in range(k,len(arr)):
window_sum=window_sum-arr[j-k]+arr[j]
print(arr[j-k],arr[j])
max_sum=max(max_sum,window_sum)
return max_sum
... | def consecutive_elements_opt(arr, k):
window_sum = 0
for i in range(k):
window_sum += arr[i]
max_sum = window_sum
for j in range(k, len(arr)):
window_sum = window_sum - arr[j - k] + arr[j]
print(arr[j - k], arr[j])
max_sum = max(max_sum, window_sum)
return max_sum
inp... |
#
# PySNMP MIB module REDSTONE-TEMPLATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/REDSTONE-TEMPLATE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:55:53 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (def... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, value_range_constraint, constraints_intersection, constraints_union) ... |
# --------------
def palindrome(num):
if num < 9:
num = num+1
return num
else:
while(str(num) != str(num)[::-1]):
num = num + 1
return int(num)
palindrome(13456)
# --------------
def a_scramble(str_1,str_2):
result=True
for i in (str_2.lower()):
... | def palindrome(num):
if num < 9:
num = num + 1
return num
else:
while str(num) != str(num)[::-1]:
num = num + 1
return int(num)
palindrome(13456)
def a_scramble(str_1, str_2):
result = True
for i in str_2.lower():
if i not in str_1.lower():
... |
class Auth(object):
def __init__(self, values=None):
self.values = values or {}
def __setattr__(self, name, value):
if name != "values":
self.values[name] = value
else:
super().__setattr__(name, value)
def __getattribute__(self, key):
if key != "valu... | class Auth(object):
def __init__(self, values=None):
self.values = values or {}
def __setattr__(self, name, value):
if name != 'values':
self.values[name] = value
else:
super().__setattr__(name, value)
def __getattribute__(self, key):
if key != 'val... |
d = int(input())
a, b = map(int, input().split())
result = 10 ** 15
for i in range(d + 1):
result = min(result, i * a + (d - i) * b)
print(result)
| d = int(input())
(a, b) = map(int, input().split())
result = 10 ** 15
for i in range(d + 1):
result = min(result, i * a + (d - i) * b)
print(result) |
# import sys
# print(sys.version)
ok_result = ['to','be','or','not','to','be','that','is','the','question']
initial = [ 'not','to','be', 'is','that','the','question']
# add missing
result=['to','be','or']
result.extend(initial)
# miss.reverse()
# for m in miss:
# result.insert(0,m)
# flip 6,7
flip=result[6]
resul... | ok_result = ['to', 'be', 'or', 'not', 'to', 'be', 'that', 'is', 'the', 'question']
initial = ['not', 'to', 'be', 'is', 'that', 'the', 'question']
result = ['to', 'be', 'or']
result.extend(initial)
flip = result[6]
result[6] = result[7]
result[7] = flip
print(result) |
#!/usr/bin/python
# -*- coding: UTF-8 -*-
DATA_HEAD_LENGTH = 16
def encode_image_array(image_shape=None):
if image_shape is not None:
# TODO:
return None
return None
def data_receive_length(data_head=None):
if data_head is not None:
# TODO:
return 0
return 0
def de... | data_head_length = 16
def encode_image_array(image_shape=None):
if image_shape is not None:
return None
return None
def data_receive_length(data_head=None):
if data_head is not None:
return 0
return 0
def decode_image_array(image_array=None, data_head=None):
if image_array is not ... |
class Solution:
def Rob(self, nums, m, n) -> int:
prev, curr = nums[m], max(nums[m], nums[m + 1])
for i in range(m + 2, n):
prev, curr = curr, max(prev + nums[i], curr)
return curr
def rob(self, nums: List[int]) -> int:
if len(nums) == 0:
return 0
... | class Solution:
def rob(self, nums, m, n) -> int:
(prev, curr) = (nums[m], max(nums[m], nums[m + 1]))
for i in range(m + 2, n):
(prev, curr) = (curr, max(prev + nums[i], curr))
return curr
def rob(self, nums: List[int]) -> int:
if len(nums) == 0:
return ... |
# TODO
def test_DAI(DAI, accounts):
assert DAI.decimals() == 18
DAI._mint_for_testing(10000000, {'from': accounts[0]})
assert DAI.balanceOf(accounts[0]) == 10000000
tx = DAI.transfer(accounts[1], 1000, {'from': accounts[0]})
assert tx.return_value is True
def test_USDT(USDT, accounts):
as... | def test_dai(DAI, accounts):
assert DAI.decimals() == 18
DAI._mint_for_testing(10000000, {'from': accounts[0]})
assert DAI.balanceOf(accounts[0]) == 10000000
tx = DAI.transfer(accounts[1], 1000, {'from': accounts[0]})
assert tx.return_value is True
def test_usdt(USDT, accounts):
assert USDT.dec... |
# HTML tag to default to if no prefix is found
md_default_tag = "p"
# Markdown to HTML key
md_html = [
("#", "h1"),
("##", "h2"),
("###", "h3"),
("####", "h4"),
("#####", "h5"),
("######", "h6"),
("`", "code"),
("*", "i"),
("**", "strong"),
("~~", "strike"),
("-", "li")
... | md_default_tag = 'p'
md_html = [('#', 'h1'), ('##', 'h2'), ('###', 'h3'), ('####', 'h4'), ('#####', 'h5'), ('######', 'h6'), ('`', 'code'), ('*', 'i'), ('**', 'strong'), ('~~', 'strike'), ('-', 'li')] |
def solve(string):
z, o = 0, 0
for c in string:
if c == '0':
z+=1
else:
o+=1
if z == 1 or o == 1:
return "Yes"
else:
return "No"
if __name__ == "__main__":
T = int(input())
for t in range(0,T):
D = input()
print(solve(D))... | def solve(string):
(z, o) = (0, 0)
for c in string:
if c == '0':
z += 1
else:
o += 1
if z == 1 or o == 1:
return 'Yes'
else:
return 'No'
if __name__ == '__main__':
t = int(input())
for t in range(0, T):
d = input()
print(sol... |
class Solution:
def setZeroes(self, matrix):
dummy1=[1]*len(matrix)
dummy2=[1]*len(matrix[0])
for i in range(len(matrix)):
for j in range(len(matrix[0])):
if matrix[i][j]==0:
dummy1[i]=0
dummy2[j]=0
for i in range... | class Solution:
def set_zeroes(self, matrix):
dummy1 = [1] * len(matrix)
dummy2 = [1] * len(matrix[0])
for i in range(len(matrix)):
for j in range(len(matrix[0])):
if matrix[i][j] == 0:
dummy1[i] = 0
dummy2[j] = 0
f... |
N=int(input("Enter the number of test cases:"))
for i in range(0,N):
L,D,S,C=map(int,input().split())
for i in range(1,D):
if(S>=L):
S+=C*S
break
if L<= S:
print("ALIVE AND KICKING")
else:
print("DEAD AND ROTTING") | n = int(input('Enter the number of test cases:'))
for i in range(0, N):
(l, d, s, c) = map(int, input().split())
for i in range(1, D):
if S >= L:
s += C * S
break
if L <= S:
print('ALIVE AND KICKING')
else:
print('DEAD AND ROTTING') |
class Solution:
def increasingTriplet(self, nums: List[int]) -> bool:
first = second = math.inf
for i in nums:
if i <=first:
first = i
elif i<=second:
second = i
else:
return True
return False | class Solution:
def increasing_triplet(self, nums: List[int]) -> bool:
first = second = math.inf
for i in nums:
if i <= first:
first = i
elif i <= second:
second = i
else:
return True
return False |
DynamoTable # unused import (dynamo_query/__init__.py:8)
DynamoRecord # unused variable (dynamo_query/__init__.py:12)
create # unused function (dynamo_query/data_table.py:119)
memo # unused variable (dynamo_query/data_table.py:137)
filter_keys # unused function (dynamo_query/data_table.py:299)
get_column # unused... | DynamoTable
DynamoRecord
create
memo
filter_keys
get_column
drop_duplicates
sanitize_key
compute_key
sanitize
get_field_names
DynamoAutoscaler
deregister_auto_scaling
register_auto_scaling
get_last_evaluated_key
reset_start_key
get_raw_responses
DynamoTable
delete_table
invalidate_cache
cached_batch_get
batch_get_recor... |
preamble = [int(input()) for _ in range(25)]
for _ in range(975):
x = int(input())
valid = False
for i, a in enumerate(preamble[:-1]):
for b in preamble[i+1:]:
if a + b == x:
valid = True
if not valid:
print(x)
break
preamble = preamble[1:] + [... | preamble = [int(input()) for _ in range(25)]
for _ in range(975):
x = int(input())
valid = False
for (i, a) in enumerate(preamble[:-1]):
for b in preamble[i + 1:]:
if a + b == x:
valid = True
if not valid:
print(x)
break
preamble = preamble[1:] + [... |
# https://www.codechef.com/AUG21C/problems/SPCTRIPS
for T in range(int(input())):
n,c=int(input()),0
for x in range(1,n+1):
for y in range(x,n+1,x): c+=((n-(x+y))//y+1)
print(c) | for t in range(int(input())):
(n, c) = (int(input()), 0)
for x in range(1, n + 1):
for y in range(x, n + 1, x):
c += (n - (x + y)) // y + 1
print(c) |
ignore_validation = {
"/api/v1/profile": ("POST", "PUT"),
"/api/v1/exchange": "GET",
"/api/v1/validation": "GET",
"/api/v1/meals/search" : "GET",
"/api/v1/meals/browse" : "GET"
} | ignore_validation = {'/api/v1/profile': ('POST', 'PUT'), '/api/v1/exchange': 'GET', '/api/v1/validation': 'GET', '/api/v1/meals/search': 'GET', '/api/v1/meals/browse': 'GET'} |
load("//bazel/rules/image:png_to_xpm.bzl", "png_to_xpm")
load("//bazel/rules/image:xpm_to_ppm.bzl", "xpm_to_ppm")
load("//bazel/rules/image:ppm_to_mask.bzl", "ppm_to_mask")
load("//bazel/rules/image:ppm_to_xpm.bzl", "ppm_to_xpm")
load("//bazel/rules/image:xpm_to_xbm.bzl", "xpm_to_xbm")
load("//bazel/rules/image:png_mir... | load('//bazel/rules/image:png_to_xpm.bzl', 'png_to_xpm')
load('//bazel/rules/image:xpm_to_ppm.bzl', 'xpm_to_ppm')
load('//bazel/rules/image:ppm_to_mask.bzl', 'ppm_to_mask')
load('//bazel/rules/image:ppm_to_xpm.bzl', 'ppm_to_xpm')
load('//bazel/rules/image:xpm_to_xbm.bzl', 'xpm_to_xbm')
load('//bazel/rules/image:png_mir... |
a = {'a': 1, 'b': 2}
b = a
del b['a']
print(a)
print(b)
c = 5
del a
del b, c
| a = {'a': 1, 'b': 2}
b = a
del b['a']
print(a)
print(b)
c = 5
del a
del b, c |
class Keys():
ERROR = 'ERROR'
DEBUG = 'DEBUG'
WARN = 'WARN'
INFO = 'INFO'
URL = 'url'
TAG = 'tag'
MESSAGE = 'message'
LOG_LEVEL = 'level'
REQUEST_METHOD = 'method'
RESPONSE_STATUS = 'status'
PAGE = 'page'
SHOW = 'show'
ALL = 'all'
| class Keys:
error = 'ERROR'
debug = 'DEBUG'
warn = 'WARN'
info = 'INFO'
url = 'url'
tag = 'tag'
message = 'message'
log_level = 'level'
request_method = 'method'
response_status = 'status'
page = 'page'
show = 'show'
all = 'all' |
#
# Copyright(c) 2019-2020 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause-Clear
#
class PresentationPolicy:
def __init__(self, standard_log, group_begin_func):
self.standard = standard_log
self.group_begin = group_begin_func
def std_log_entry(msg_id, msg, log_result, html_node):
p... | class Presentationpolicy:
def __init__(self, standard_log, group_begin_func):
self.standard = standard_log
self.group_begin = group_begin_func
def std_log_entry(msg_id, msg, log_result, html_node):
pass
def group_log_begin(msg_id, msg, html_node):
return (html_node, html_node)
null_policy... |
class Solution:
def fractionToDecimal(self, numerator: int, denominator: int) -> str:
if numerator == 0:
return '0'
if numerator ^ denominator < 0:
result = '-'
else:
result = ''
numerator = abs(numerator)
denominator = abs(denomin... | class Solution:
def fraction_to_decimal(self, numerator: int, denominator: int) -> str:
if numerator == 0:
return '0'
if numerator ^ denominator < 0:
result = '-'
else:
result = ''
numerator = abs(numerator)
denominator = abs(denominator)
... |
def factors(x):
result = []
i = 1
while i*i <= x:
if x % i == 0:
result.append(i)
if x//i != i:
result.append(x//i)
i += 1
return result
for _ in range(int(input())):
a, b = [int(i) for i in input().split()]
m = 0
x = 0
for i in range(a, b + 1):
result = factors(i)
if ... | def factors(x):
result = []
i = 1
while i * i <= x:
if x % i == 0:
result.append(i)
if x // i != i:
result.append(x // i)
i += 1
return result
for _ in range(int(input())):
(a, b) = [int(i) for i in input().split()]
m = 0
x = 0
for ... |
# 92. Reverse Linked List II
# Runtime: 59 ms, faster than 5.80% of Python3 online submissions for Reverse Linked List II.
# Memory Usage: 14.7 MB, less than 5.82% of Python3 online submissions for Reverse Linked List II.
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=No... | class Solution:
def __init__(self) -> None:
self._left_node: ListNode = None
self._stop: bool = False
def reverse_between(self, head: ListNode, left: int, right: int) -> ListNode:
if head is None:
return None
self._left_node = head
self._recurse_reverse(head... |
def conta_letras(frase, contar="vogais"):
''' Account the amount of consonants or vowels that the sentence has'''
lista_ord_vogais = [65, 69, 73, 79, 85, 97, 101, 105, 111, 117]
lista_ord_cosoantes = [66, 67, 68, 70, 71, 72, 74, 75, 76, 77, 78, 80,
81, 82, 83, 84, 86, 87, 88, 89, 90, 98, 99, 100, 102,... | def conta_letras(frase, contar='vogais'):
""" Account the amount of consonants or vowels that the sentence has"""
lista_ord_vogais = [65, 69, 73, 79, 85, 97, 101, 105, 111, 117]
lista_ord_cosoantes = [66, 67, 68, 70, 71, 72, 74, 75, 76, 77, 78, 80, 81, 82, 83, 84, 86, 87, 88, 89, 90, 98, 99, 100, 102, 103, ... |
class SingletonMeta(type):
def __init__(cls, name, bases, namespace):
super().__init__(name, bases, namespace)
cls.instance = None
def __call__(cls, *args, **kwargs):
if cls.instance is None:
cls.instance = super().__call__(*args, **kwargs)
return cls.instance
cla... | class Singletonmeta(type):
def __init__(cls, name, bases, namespace):
super().__init__(name, bases, namespace)
cls.instance = None
def __call__(cls, *args, **kwargs):
if cls.instance is None:
cls.instance = super().__call__(*args, **kwargs)
return cls.instance
clas... |
# Solution by PauloBA
def digital_root(n):
n = str(n)
ls = []
ans = 0
for i in n:
ls.append(int(i))
for i in ls:
ans = ans + i
if ans < 10:
return ans
else:
return digital_root(ans)
print(digital_root(24)) | def digital_root(n):
n = str(n)
ls = []
ans = 0
for i in n:
ls.append(int(i))
for i in ls:
ans = ans + i
if ans < 10:
return ans
else:
return digital_root(ans)
print(digital_root(24)) |
def gcd(a, b):
if min(a, b) == 0:
return max(a, b)
a_1 = max(a, b) % min(a, b)
return gcd(a_1, min(a, b))
def lcm(a, b):
return (a * b) // gcd(a, b) | def gcd(a, b):
if min(a, b) == 0:
return max(a, b)
a_1 = max(a, b) % min(a, b)
return gcd(a_1, min(a, b))
def lcm(a, b):
return a * b // gcd(a, b) |
class HelloMixin:
def display(self):
print('HelloMixin hello')
class SuperHelloMixin:
def display(self):
print('SuperHello hello')
class A(SuperHelloMixin, HelloMixin):
pass
if __name__ == '__main__':
a = A()
a.display()
| class Hellomixin:
def display(self):
print('HelloMixin hello')
class Superhellomixin:
def display(self):
print('SuperHello hello')
class A(SuperHelloMixin, HelloMixin):
pass
if __name__ == '__main__':
a = a()
a.display() |
def isPalindrome(string):
return string == string[::-1]
# OR
# left_pos = 0
# right_pos = len(string) - 1
#
# while right_pos >= left_pos:
# if(string[left_pos] != string[right_pos]):
# return False
# left_pos += 1
# right_pos -= 1
#
# re... | def is_palindrome(string):
return string == string[::-1]
print(is_palindrome('aza')) |
# Semigroup = non-empty set with an associative binary operation
# using addition
print((2 + 3) + 4 == 2 + (3 + 4) == 9)
# We get a property of closure, because the number we get is still a number of the same set,
# natural numbers, including 0
# (2 + 3) + 4
# 2 + (3 + 4)
# 9
| print(2 + 3 + 4 == 2 + (3 + 4) == 9) |
class Solution:
def maxPower(self, s: str) -> int:
power = []
i, temp = 1, ""
for s_char in s:
if s_char == temp:
i += 1
else:
power.append( i )
i = 1
temp = s_char
power.append(i)
r... | class Solution:
def max_power(self, s: str) -> int:
power = []
(i, temp) = (1, '')
for s_char in s:
if s_char == temp:
i += 1
else:
power.append(i)
i = 1
temp = s_char
power.append(i)
return ... |
# Used Python for handling large integers
for _ in range(int(input())):
a,b = list(map(int,input().split()))
print(a*b)
| for _ in range(int(input())):
(a, b) = list(map(int, input().split()))
print(a * b) |
def solution(a, b):
answer = ''
month = {0:0, 1:31, 2:29, 3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30, 12:31}
day = {1:'FRI',2:'SAT',3:'SUN', 4:'MON',5:'TUE',6:'WED', 0:'THU'}
d = 0
for i in range(0, a):
d += month[i]
d += b
answer = day[(d % 7)]
return answer | def solution(a, b):
answer = ''
month = {0: 0, 1: 31, 2: 29, 3: 31, 4: 30, 5: 31, 6: 30, 7: 31, 8: 31, 9: 30, 10: 31, 11: 30, 12: 31}
day = {1: 'FRI', 2: 'SAT', 3: 'SUN', 4: 'MON', 5: 'TUE', 6: 'WED', 0: 'THU'}
d = 0
for i in range(0, a):
d += month[i]
d += b
answer = day[d % 7]
... |
# Function to calculate median
def calcMedian(arr, startIndex, endIndex):
index = ( startIndex + endIndex ) // 2
if (endIndex - startIndex + 1) % 2 == 0:
# return median for even no of elements
return ( arr[index] + arr[index + 1] ) // 2
else:
# return median for odd no of elements
... | def calc_median(arr, startIndex, endIndex):
index = (startIndex + endIndex) // 2
if (endIndex - startIndex + 1) % 2 == 0:
return (arr[index] + arr[index + 1]) // 2
else:
return arr[index]
n = int(input())
x = list(map(int, input().split()))
X.sort()
q1 = calc_median(X, 0, n // 2 - 1)
q2 = ca... |
class Solution:
# @param {integer[]} nums
# @return {integer}
def singleNumber(self, nums):
a = set(nums)
a = sum(a)*2
singleNumber = a - sum(nums)
return singleNumber
| class Solution:
def single_number(self, nums):
a = set(nums)
a = sum(a) * 2
single_number = a - sum(nums)
return singleNumber |
#!/usr/bin/env python3
# Transistors.
"2N3904"
"2SC1815" # NPN?
"2SA9012"
"2SA1015" # PNP?
| """2N3904"""
'2SC1815'
'2SA9012'
'2SA1015' |
class Car:
# constructor
def __init__(self,name,fuel,consumption,passengers,capacity):
self.name = name
self.fuel = fuel
self.consumption = consumption
self.km = 0.0
self.passengers = passengers
self.capacity = capacity
# Behavior
def print_car(sel... | class Car:
def __init__(self, name, fuel, consumption, passengers, capacity):
self.name = name
self.fuel = fuel
self.consumption = consumption
self.km = 0.0
self.passengers = passengers
self.capacity = capacity
def print_car(self):
print(f'--- Car {self.... |
vector = [{"name": "John Doe", "age": 37}, {"name": "Anna Doe", "age": 35}]
# for item in vector:
# print(item["name"])
print(list(map(lambda item: item["name"], vector)))
| vector = [{'name': 'John Doe', 'age': 37}, {'name': 'Anna Doe', 'age': 35}]
print(list(map(lambda item: item['name'], vector))) |
class FormattedWord:
def __init__(self, word, capitalize=False) -> None:
self.word = word
self.capitalize = capitalize
class Sentence(list):
def __init__(self, plain_text):
for word in plain_text.split(' '):
self.append(FormattedWord(word))
def __str__(self) -> str:
... | class Formattedword:
def __init__(self, word, capitalize=False) -> None:
self.word = word
self.capitalize = capitalize
class Sentence(list):
def __init__(self, plain_text):
for word in plain_text.split(' '):
self.append(formatted_word(word))
def __str__(self) -> str:
... |
casa = float(input('Valor da casa: R$'))
salario = float(input('Salario do comprador R$'))
anos = int(input('Quantos anos de financiamento? '))
prestacao = casa / (anos * 12)
minimo = salario * 30 / 100
print('Para pagar uma casa de R${:.2f} em {} anos'.format(casa, anos))
if prestacao < minimo:
print('Emprestimo ... | casa = float(input('Valor da casa: R$'))
salario = float(input('Salario do comprador R$'))
anos = int(input('Quantos anos de financiamento? '))
prestacao = casa / (anos * 12)
minimo = salario * 30 / 100
print('Para pagar uma casa de R${:.2f} em {} anos'.format(casa, anos))
if prestacao < minimo:
print('Emprestimo p... |
class AutomatonListHelper:
'''
' Removes repeated elements from a list
'
' @param list array List that will be iterate
'
' @return list
'''
@staticmethod
def removeDuplicates(array):
final_list = []
for num in array:
if num not in final_list:
... | class Automatonlisthelper:
"""
' Removes repeated elements from a list
'
' @param list array List that will be iterate
'
' @return list
"""
@staticmethod
def remove_duplicates(array):
final_list = []
for num in array:
if num not in final_list:
... |
#! /usr/bin/python3
def print_sorted_dictionary_pairs(dict):
for key in sorted(dict):
print(key, dict[key])
def add_or_change_dictionary_value(dict, key, value):
dict[key] = value
def delete_dictionary_entry(dict, key):
if key in dict:
del dict[key]
else:
print(key, 'not found... | def print_sorted_dictionary_pairs(dict):
for key in sorted(dict):
print(key, dict[key])
def add_or_change_dictionary_value(dict, key, value):
dict[key] = value
def delete_dictionary_entry(dict, key):
if key in dict:
del dict[key]
else:
print(key, 'not found in dictionary')
def... |
def printPacket(packet):
print(packet.to_json())
| def print_packet(packet):
print(packet.to_json()) |
#
# PySNMP MIB module IANA-PWE3-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IANA-PWE3-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:30:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, value_range_constraint, value_size_constraint, single_value_constraint) ... |
# expected data for tests using FBgn0031208.gff and FBgn0031208.gtf files
# list the children and their expected first-order parents for the GFF test file.
GFF_parent_check_level_1 = {'FBtr0300690':['FBgn0031208'],
'FBtr0300689':['FBgn0031208'],
'CG11023:1':['FB... | gff_parent_check_level_1 = {'FBtr0300690': ['FBgn0031208'], 'FBtr0300689': ['FBgn0031208'], 'CG11023:1': ['FBtr0300689', 'FBtr0300690'], 'five_prime_UTR_FBgn0031208:1_737': ['FBtr0300689', 'FBtr0300690'], 'CDS_FBgn0031208:1_737': ['FBtr0300689', 'FBtr0300690'], 'intron_FBgn0031208:1_FBgn0031208:2': ['FBtr0300690'], 'in... |
# 1. Even Numbers
# Write a program that receives a sequence of numbers (integers), separated by a single space.
# It should print a list of only the even numbers. Use filter().
def filter_even(iters):
return list(filter(lambda x: x % 2 == 0, iters))
nums = map(int, input().split())
print(filter_even(nums))
| def filter_even(iters):
return list(filter(lambda x: x % 2 == 0, iters))
nums = map(int, input().split())
print(filter_even(nums)) |
class Foo:
def __init__(self, id):
self.id = id
def __str__(self):
return 'Foo instance id: {}'.format(self.id)
class Bar:
def __init__(self, id):
self.id = id
def __str__(self):
return 'Bar instance id: {}'.format(self.id)
class Baz:
def __init__(self, id):
... | class Foo:
def __init__(self, id):
self.id = id
def __str__(self):
return 'Foo instance id: {}'.format(self.id)
class Bar:
def __init__(self, id):
self.id = id
def __str__(self):
return 'Bar instance id: {}'.format(self.id)
class Baz:
def __init__(self, id):
... |
#===========================================================================
#
# Convert decoded data to MQTT messages.
#
#===========================================================================
#===========================================================================
def convert( config, data ):
# List of t... | def convert(config, data):
msgs = []
if hasattr(data, 'battery'):
topic = config.mqttBattery % data.location
payload = {'time': data.time, 'battery': data.battery}
msgs.append((topic, payload))
if hasattr(data, 'signal'):
topic = config.mqttRssi % data.location
payloa... |
def special_sort(alphabet, s):
a = {c: i for i, c in enumerate(alphabet)}
return ''.join(sorted(list(s), key=lambda x: a[x.lower()]))
a = 'wvutsrqponmlkjihgfedcbaxyz'
t = 'camelCasE'
print(special_sort(a, t))
| def special_sort(alphabet, s):
a = {c: i for (i, c) in enumerate(alphabet)}
return ''.join(sorted(list(s), key=lambda x: a[x.lower()]))
a = 'wvutsrqponmlkjihgfedcbaxyz'
t = 'camelCasE'
print(special_sort(a, t)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.