content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
"""
3047 : ABC
URL : https://www.acmicpc.net/problem/3047
Input :
1 5 3
ABC
Output :
1 3 5
"""
a = list(sorted(map(int, input().split())))
order = input()
b = []
for o in order:
b.append(a[ord(o) - ord('A')])
print(' '.join(str(c) for c in b))
| """
3047 : ABC
URL : https://www.acmicpc.net/problem/3047
Input :
1 5 3
ABC
Output :
1 3 5
"""
a = list(sorted(map(int, input().split())))
order = input()
b = []
for o in order:
b.append(a[ord(o) - ord('A')])
print(' '.join((str(c) for c in b))) |
class Solution:
def checkSubarraySum(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: bool
"""
sums = [0]
s = 0
for num in nums:
s += num
sums.append(s)
for i in range(len(sums)):
for j in range... | class Solution:
def check_subarray_sum(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: bool
"""
sums = [0]
s = 0
for num in nums:
s += num
sums.append(s)
for i in range(len(sums)):
for j in ra... |
'''Defines data and parameters in an easily resuable format.'''
# Common sequence alphabets.
ALPHABETS = {
'dna': 'ATGCNatgcn-',
'rna': 'AUGCNaugcn',
'peptide': 'ACDEFGHIKLMNPQRSTVWYXacdefghiklmnpqrstvwyx'}
COMPLEMENTS = {
'dna': {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G', 'N': 'N', 'a': 't',
... | """Defines data and parameters in an easily resuable format."""
alphabets = {'dna': 'ATGCNatgcn-', 'rna': 'AUGCNaugcn', 'peptide': 'ACDEFGHIKLMNPQRSTVWYXacdefghiklmnpqrstvwyx'}
complements = {'dna': {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G', 'N': 'N', 'a': 't', 't': 'a', 'g': 'c', 'c': 'g', 'n': 'n', '-': '-'}, 'rna': {'... |
# Created by MechAviv
# White Heaven Sun Damage Skin | (2433828)
if sm.addDamageSkin(2433828):
sm.chat("'White Heaven Sun Damage Skin' Damage Skin has been added to your account's damage skin collection.")
sm.consumeItem() | if sm.addDamageSkin(2433828):
sm.chat("'White Heaven Sun Damage Skin' Damage Skin has been added to your account's damage skin collection.")
sm.consumeItem() |
def expose(board, x, y):
if not board[y][x].flagged:
board[y][x].exposed = True
#debug print(x, y, sep='\t')
if x == 0 or x == len(board[0]) - 1 or y == 0 or y == len(board) - 1 or board[y][x].mine:
return 0
if board[y][x].neighbours == 0:
if board[y-1][x-1].exposed is Fals... | def expose(board, x, y):
if not board[y][x].flagged:
board[y][x].exposed = True
if x == 0 or x == len(board[0]) - 1 or y == 0 or (y == len(board) - 1) or board[y][x].mine:
return 0
if board[y][x].neighbours == 0:
if board[y - 1][x - 1].exposed is False:
expose(board, x - ... |
number = 5
numbers = [1,2,3,4,5]
# if statement
if number == 5:
print(number)
if len(numbers) == 5:
print(numbers[3])
if number in numbers: # if 3 in [1,2,3,4,5]
print("3 is here")
# elif and else statement
if number == 3:
print("is 3")
elif number == 5:
print("is 5")
else:
print("not 3 & 5... | number = 5
numbers = [1, 2, 3, 4, 5]
if number == 5:
print(number)
if len(numbers) == 5:
print(numbers[3])
if number in numbers:
print('3 is here')
if number == 3:
print('is 3')
elif number == 5:
print('is 5')
else:
print('not 3 & 5') |
memo = {
0: 0,
1: 1,
2: 1,
}
def fib(n):
if n in memo:
return memo[n]
val = fib(n-1) + fib(n-2)
memo[n] = val
return val
print(fib(35))
| memo = {0: 0, 1: 1, 2: 1}
def fib(n):
if n in memo:
return memo[n]
val = fib(n - 1) + fib(n - 2)
memo[n] = val
return val
print(fib(35)) |
class Screen(object):
""" Represents a display device or multiple display devices on a single system. """
def Equals(self,obj):
"""
Equals(self: Screen,obj: object) -> bool
Gets or sets a value indicating whether the specified object is equal to this Screen.
obj: The object to compare ... | class Screen(object):
""" Represents a display device or multiple display devices on a single system. """
def equals(self, obj):
"""
Equals(self: Screen,obj: object) -> bool
Gets or sets a value indicating whether the specified object is equal to this Screen.
obj: The object to compar... |
# coding: utf-8
__version__ = '0.12.0'
| __version__ = '0.12.0' |
# -*- coding: utf-8 -*-
# Caching
# https://docs.djangoproject.com/en/3.2/topics/cache/
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
'LOCATION': 'unique-snowflake',
},
'staticfiles': {
'BACKEND': 'django.core.cache.backends.locmem.LocMemCache... | caches = {'default': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake'}, 'staticfiles': {'BACKEND': 'django.core.cache.backends.locmem.LocMemCache', 'LOCATION': 'unique-snowflake'}} |
x, a, b = map(int, input().split())
if b <= a:
print('delicious')
elif b - a <= x:
print('safe')
else:
print('dangerous')
| (x, a, b) = map(int, input().split())
if b <= a:
print('delicious')
elif b - a <= x:
print('safe')
else:
print('dangerous') |
class EvaluatorTestCases:
expressions = [
("1 2 + 2.5 * 2 5 SUM", 14.5, float, 3),
("1 2 3 SUM 4 5 SUM 6 7 SUM", sum(range(8)), int, 3),
("1 2 3 SUM 4 5 SUM 6 7 SUM 8.5 *", sum(range(8)) * 8.5, float, 4),
]
not_ok = [
"""
void test(){
int a; int b... | class Evaluatortestcases:
expressions = [('1 2 + 2.5 * 2 5 SUM', 14.5, float, 3), ('1 2 3 SUM 4 5 SUM 6 7 SUM', sum(range(8)), int, 3), ('1 2 3 SUM 4 5 SUM 6 7 SUM 8.5 *', sum(range(8)) * 8.5, float, 4)]
not_ok = ['\n void test(){\n int a; int b; a = int; b = int; int a /* scope violat... |
class Args(object):
def __init__(self):
self.seed = 0
self.experiment = None
self.network = None
self.approach = None
self.parameter = []
self.taskcla = None
self.comment = None
self.log_dir = None
global args
args = Args()
| class Args(object):
def __init__(self):
self.seed = 0
self.experiment = None
self.network = None
self.approach = None
self.parameter = []
self.taskcla = None
self.comment = None
self.log_dir = None
global args
args = args() |
list1=[12,-7,5,64,-14]
for num in list1:
if num>=0:
print(num,end=" ")
list2=[12,14,-95,3]
for num in list2:
if num>=0:
print(num,end=" ")
| list1 = [12, -7, 5, 64, -14]
for num in list1:
if num >= 0:
print(num, end=' ')
list2 = [12, 14, -95, 3]
for num in list2:
if num >= 0:
print(num, end=' ') |
#Three character NHGIS codes to postal abbreviations
state_codes = {
'530':'WA',
'100':'DE',
'110':'DC',
'550':'WI',
'540':'WV',
'150':'HI',
'120':'FL',
'560':'WY',
'720':'PR',
'340':'NJ',
'350':'NM',
'480':'TX',
'220':'LA',
'370':'NC',
'380':'ND',
'310':'NE',
'470':'TN',
'360':'NY',
'420':'PA',
'02... | state_codes = {'530': 'WA', '100': 'DE', '110': 'DC', '550': 'WI', '540': 'WV', '150': 'HI', '120': 'FL', '560': 'WY', '720': 'PR', '340': 'NJ', '350': 'NM', '480': 'TX', '220': 'LA', '370': 'NC', '380': 'ND', '310': 'NE', '470': 'TN', '360': 'NY', '420': 'PA', '020': 'AK', '320': 'NV', '330': 'NH', '510': 'VA', '080':... |
def uniquePaths(m: int, n: int) -> int:
dp = [[0 for _ in range(m)] for _ in range(n)]
for i in range(m):
dp[0][i] = 1
for j in range(n):
dp[j][0] = 1
for i in range(1, n):
for j in range(1, m):
dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
return... | def unique_paths(m: int, n: int) -> int:
dp = [[0 for _ in range(m)] for _ in range(n)]
for i in range(m):
dp[0][i] = 1
for j in range(n):
dp[j][0] = 1
for i in range(1, n):
for j in range(1, m):
dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
return dp[-1][-1]
if __name__... |
if __name__ == "__main__":
base_path = "/data4/dheeraj/hashtag/all/Twitter/"
f_tweets = open(base_path + "train_post.txt", "r")
f_tags = open(base_path + "train_tag.txt", "r")
tweets = f_tweets.readlines()
tags = f_tags.readlines()
f_tags.close()
f_tweets.close()
tweets = tweets[:100]
... | if __name__ == '__main__':
base_path = '/data4/dheeraj/hashtag/all/Twitter/'
f_tweets = open(base_path + 'train_post.txt', 'r')
f_tags = open(base_path + 'train_tag.txt', 'r')
tweets = f_tweets.readlines()
tags = f_tags.readlines()
f_tags.close()
f_tweets.close()
tweets = tweets[:100]
... |
# -*- coding: utf-8 -*-
"""Bandit directory containing multi-armed bandit implementations of BLA policies in python.
**Files in this package**
* :mod:`moe.bandit.bla.bla`: :class:`~moe.bandit.bla.bla.BLA`
object for allocating bandit arms and choosing the winning arm based on BLA policy.
"""
| """Bandit directory containing multi-armed bandit implementations of BLA policies in python.
**Files in this package**
* :mod:`moe.bandit.bla.bla`: :class:`~moe.bandit.bla.bla.BLA`
object for allocating bandit arms and choosing the winning arm based on BLA policy.
""" |
#
# PySNMP MIB module IPMROUTE-STD-MIB (http://pysnmp.sf.net)
# ASN.1 source http://mibs.snmplabs.com:80/asn1/IPMROUTE-STD-MIB
# Produced by pysmi-0.0.7 at Sun Feb 14 00:18:06 2016
# On host bldfarm platform Linux version 4.1.13-100.fc21.x86_64 by user goose
# Using Python version 3.5.0 (default, Jan 5 2016, 17:11:52)... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, single_value_constraint, constraints_union, constraints_intersection) ... |
class Solution:
def wordPattern(self, pattern, str):
"""
:type pattern: str
:type str: str
:rtype: bool
"""
words = str.split(' ')
if len(pattern) != len(words) or len(set(pattern)) != len(set(words)):
return False
d = dict()
for i... | class Solution:
def word_pattern(self, pattern, str):
"""
:type pattern: str
:type str: str
:rtype: bool
"""
words = str.split(' ')
if len(pattern) != len(words) or len(set(pattern)) != len(set(words)):
return False
d = dict()
for ... |
# Problem 4: Dutch National Flag Problem
def sort_zero_one_two(input_list):
# We define 4 variables for the low, middle, high, and temporary values
lo_end = 0
hi_end = len(input_list) - 1
mid = 0
tmp = None
if len(input_list) <= 0 or input_list[mid] < 0:
return "The list is either empty... | def sort_zero_one_two(input_list):
lo_end = 0
hi_end = len(input_list) - 1
mid = 0
tmp = None
if len(input_list) <= 0 or input_list[mid] < 0:
return 'The list is either empty or invalid.'
while mid <= hi_end:
if input_list[mid] == 0:
tmp = input_list[lo_end]
... |
# -*- coding: utf-8 -*-
"""
equip.visitors.blocks
~~~~~~~~~~~~~~~~~~~~~
Callback the visit basic blocks in the program.
:copyright: (c) 2014 by Romain Gaucher (@rgaucher)
:license: Apache 2, see LICENSE for more details.
"""
class BlockVisitor(object):
"""
A basic block visitor. It first receives the... | """
equip.visitors.blocks
~~~~~~~~~~~~~~~~~~~~~
Callback the visit basic blocks in the program.
:copyright: (c) 2014 by Romain Gaucher (@rgaucher)
:license: Apache 2, see LICENSE for more details.
"""
class Blockvisitor(object):
"""
A basic block visitor. It first receives the control-flow graph,
... |
# coding=utf-8
BTC_BASED_COINS = {
'PIVX': {
'ip': '',
'port': 3000,
'url': ''
}
}
ETHEREUM_BASED_COINS = ['ETH', 'BNB', 'SENT']
ADDRESS = ''.lower()
PRIVATE_KEY = ''
FEE_PERCENTAGE = 0.01
TOKENS = [
{
'address': ADDRESS,
'decimals': 18,
'logo_url': 'https://... | btc_based_coins = {'PIVX': {'ip': '', 'port': 3000, 'url': ''}}
ethereum_based_coins = ['ETH', 'BNB', 'SENT']
address = ''.lower()
private_key = ''
fee_percentage = 0.01
tokens = [{'address': ADDRESS, 'decimals': 18, 'logo_url': 'https://s2.coinmarketcap.com/static/img/coins/64x64/1027.png', 'name': 'Ethereum', 'price_... |
def get_poisoned_worker_ids_from_log(log_path):
# Unchanged from original work
"""
:param log_path: string
"""
with open(log_path, "r") as f:
file_lines = [line.strip() for line in f.readlines() if "Poisoning data for workers:" in line]
workers = file_lines[0].split("[")[1].split("]")[... | def get_poisoned_worker_ids_from_log(log_path):
"""
:param log_path: string
"""
with open(log_path, 'r') as f:
file_lines = [line.strip() for line in f.readlines() if 'Poisoning data for workers:' in line]
workers = file_lines[0].split('[')[1].split(']')[0]
workers_list = workers.split('... |
# It must be here to retrieve this information from the dummy
core_universal_identifier = 'd9d94986-ea14-11e0-bd1d-00216a5807c8'
core_universal_identifier_human = 'Consumer'
db_database = "WebLabTests"
weblab_db_username = 'weblab'
weblab_db_password = 'weblab'
debug_mode = True
#########################
# G... | core_universal_identifier = 'd9d94986-ea14-11e0-bd1d-00216a5807c8'
core_universal_identifier_human = 'Consumer'
db_database = 'WebLabTests'
weblab_db_username = 'weblab'
weblab_db_password = 'weblab'
debug_mode = True
server_hostaddress = 'weblab.deusto.es'
server_admin = 'weblab@deusto.es'
mail_notification_enabled = ... |
__author__ = "Shaban Hassan [shaban00]"
""" Regiser all routes for flask socket io """
# SOCKET_EVENTS = [
# {
# "event": "connect",
# "func": "connect",
# "namespace": "namespace"
# }
# ]
SOCKET_EVENTS = []
| __author__ = 'Shaban Hassan [shaban00]'
' Regiser all routes for flask socket io '
socket_events = [] |
if __name__ == '__main__':
n, m = list(map(int, input().split(" ")))
arr = list(map(int, input().split(" ")))
set_a = set(map(int, input().split(" ")))
set_b = set(map(int, input().split(' ')))
print(sum([1 if e in set_a else -1 if e in set_b else 0 for e in arr]))
| if __name__ == '__main__':
(n, m) = list(map(int, input().split(' ')))
arr = list(map(int, input().split(' ')))
set_a = set(map(int, input().split(' ')))
set_b = set(map(int, input().split(' ')))
print(sum([1 if e in set_a else -1 if e in set_b else 0 for e in arr])) |
"""
You are given an m x n 2D image matrix (List of Lists) where
each integer represents a pixel. Flip it in-place along its
horizontal axis.
Example:
Input image :
1 1
0 0
Modified to :
0 0
1 1
"""
def flip_horizontal_axis(matrix):
"""
Returns a list... | """
You are given an m x n 2D image matrix (List of Lists) where
each integer represents a pixel. Flip it in-place along its
horizontal axis.
Example:
Input image :
1 1
0 0
Modified to :
0 0
1 1
"""
def flip_horizontal_axis(matrix):
"""
Returns a list ... |
# Given a binary tree, find a minimum path sum from root to a leaf.
# For example, the minimum path in this tree is [10, 5, 1, -1], which has sum 15.
# 10
# / \
# 5 5
# \ \
# 2 1
# /
# -1
class Node:
def __init__(self, value, left=None, right=None):
self.value ... | class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def min_path(node):
path_values = []
def search_path(node, path=0):
path += node.value
if node.left is None and node.right is None:
path... |
expected_output = {
"interface": {
"GigabitEthernet3.90": {
"interface": "GigabitEthernet3.90",
"neighbors": {
"FE80::5C00:40FF:FEFF:209": {
"age": "22",
"ip": "FE80::5C00:40FF:FEFF:209",
"link_layer_address"... | expected_output = {'interface': {'GigabitEthernet3.90': {'interface': 'GigabitEthernet3.90', 'neighbors': {'FE80::5C00:40FF:FEFF:209': {'age': '22', 'ip': 'FE80::5C00:40FF:FEFF:209', 'link_layer_address': '5e00.40ff.0209', 'neighbor_state': 'STALE'}}}}} |
class Solution:
def rob(self, nums: List[int]) -> int:
dp = [num for num in nums]
for i in range(2, len(nums)):
dp[i] += max(dp[:i-1])
return max(dp)
| class Solution:
def rob(self, nums: List[int]) -> int:
dp = [num for num in nums]
for i in range(2, len(nums)):
dp[i] += max(dp[:i - 1])
return max(dp) |
print("Statements")
print("Statement does something, while expression is something")
2*2 # this is an expression, it will not do anything if not using interactive interpreter.
print(2*2) #this is an statement, it does print
x=3 #this is also an statement, it has no values to print out, but x is already assigned.
| print('Statements')
print('Statement does something, while expression is something')
2 * 2
print(2 * 2)
x = 3 |
# This problem was recently asked by Google:
# Given a sorted list, create a height balanced binary search tree,
# meaning the height differences of each node can only differ by at most 1.
class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
se... | class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def __str__(self):
answer = str(self.value)
if self.left:
answer += str(self.left)
if self.right:
answer += str(self.righ... |
# Copyright 2021 PaddleFSL Authors
#
# 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... | __all__ = ['count_model_params']
def count_model_params(model):
"""
Calculate the number of parameters of the model.
Args:
model(paddle.nn.Layer): model to be counted.
Returns:
None.
"""
print(model)
param_size = {}
cnt = 0
for (name, p) in model.named_paramete... |
#---------------------------------------------------------------------------------------------------
# Tiparoj
#---------------------------------------------------------------------------------------------------
c.fonts.completion.category = "bold 8pt monospace"
c.fonts.completion.entry = "8pt monospace"
c.fonts.debug... | c.fonts.completion.category = 'bold 8pt monospace'
c.fonts.completion.entry = '8pt monospace'
c.fonts.debug_console = '8pt monospace'
c.fonts.downloads = '8pt monospace'
c.fonts.hints = 'bold 8pt monospace'
c.fonts.keyhint = '8pt monospace'
c.fonts.messages.error = '8pt monospace'
c.fonts.messages.info = '8pt monospace... |
class Account:
"""An account has a balance and a holder.
>>> a = Account('John')
>>> a.holder
'John'
>>> a.deposit(100)
100
>>> a.withdraw(90)
10
>>> a.withdraw(90)
'Insufficient funds'
>>> a.balance
10
>>> a.interest
0.02
"""
interest = 0.02 # A class ... | class Account:
"""An account has a balance and a holder.
>>> a = Account('John')
>>> a.holder
'John'
>>> a.deposit(100)
100
>>> a.withdraw(90)
10
>>> a.withdraw(90)
'Insufficient funds'
>>> a.balance
10
>>> a.interest
0.02
"""
interest = 0.02
def __i... |
_base_ = 'ranksort_cascade_rcnn_r50_fpn_1x_coco.py'
model = dict(roi_head=dict(stage_loss_weights=[1, 0.50, 0.25]))
| _base_ = 'ranksort_cascade_rcnn_r50_fpn_1x_coco.py'
model = dict(roi_head=dict(stage_loss_weights=[1, 0.5, 0.25])) |
{
"targets": [
{
"target_name": "pcap_binding",
'win_delay_load_hook': 'true',
"sources": [ "npcap_binding.cpp","npcap_session.cpp"],
"include_dirs": ["npcap/Include","<!@(node -p \"require('node-addon-api').include\")"],
"libraries": [
"<(module_root_dir)/npcap/Lib/x64/Packe... | {'targets': [{'target_name': 'pcap_binding', 'win_delay_load_hook': 'true', 'sources': ['npcap_binding.cpp', 'npcap_session.cpp'], 'include_dirs': ['npcap/Include', '<!@(node -p "require(\'node-addon-api\').include")'], 'libraries': ['<(module_root_dir)/npcap/Lib/x64/Packet.lib', '<(module_root_dir)/npcap/Lib/x64/wpcap... |
class Config(object):
# game setting
row_size = 6
column_size = 6
piece_in_line = 4
black_first = True
max_num_round = 36
# mcts
temperature = 1.0
playout_times = 100 # num of simulations for each move
c_puct = 5.
# data
num_games_per_generation = 10
... | class Config(object):
row_size = 6
column_size = 6
piece_in_line = 4
black_first = True
max_num_round = 36
temperature = 1.0
playout_times = 100
c_puct = 5.0
num_games_per_generation = 10
batch_size = 32
buffer_size = 10000
data_buffer_size = 10000
epoch_per_dataset =... |
class TooLarge(Exception):
"""The input was too long."""
def __init__(self):
super(TooLarge, self).__init__("That number was too large.")
class ImproperFormat(Exception):
"""Invalid Format was given."""
def __init__(self):
super(ImproperFormat, self).__init__("An Invalid Format was giv... | class Toolarge(Exception):
"""The input was too long."""
def __init__(self):
super(TooLarge, self).__init__('That number was too large.')
class Improperformat(Exception):
"""Invalid Format was given."""
def __init__(self):
super(ImproperFormat, self).__init__('An Invalid Format was gi... |
"""
Description
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.
Please implement encode and decode
Example
Example1
Input: ["lint","code","love","you"]
Output: ["lint","code","love","you"]
Explanation:
... | """
Description
Design an algorithm to encode a list of strings to a string. The encoded string is then sent over the network and is decoded back to the original list of strings.
Please implement encode and decode
Example
Example1
Input: ["lint","code","love","you"]
Output: ["lint","code","love","you"]
Explanation:
... |
# Demonstrate how to use dictionary comprehensions
def main():
# define a list of temperature values
ctemps = [0, 12, 34, 100]
# Use a comprehension to build a dictionary
tempDict = {t: (t * 9/5) + 32 for t in ctemps if t < 100}
print(tempDict)
print(tempDict[12])
# Merge two dictionarie... | def main():
ctemps = [0, 12, 34, 100]
temp_dict = {t: t * 9 / 5 + 32 for t in ctemps if t < 100}
print(tempDict)
print(tempDict[12])
team1 = {'Jones': 24, 'Jameson': 18, 'Smith': 58, 'Burns': 7}
team2 = {'White': 12, 'Macke': 88, 'Perce': 4}
new_team = {k: v for team in (team1, team2) for (k... |
# -*- coding: utf-8 -*-
"""Collection of exceptions raised by requests-toolbelt."""
class StreamingError(Exception):
"""Used in :mod:`requests_toolbelt.downloadutils.stream`."""
pass
class VersionMismatchError(Exception):
"""Used to indicate a version mismatch in the version of requests requir... | """Collection of exceptions raised by requests-toolbelt."""
class Streamingerror(Exception):
"""Used in :mod:`requests_toolbelt.downloadutils.stream`."""
pass
class Versionmismatcherror(Exception):
"""Used to indicate a version mismatch in the version of requests required.
The feature in use requires... |
class Config():
def __init__(self):
self.type = "a2c"
self.gamma = 0.99
self.learning_rate = 0.001
self.entropy_beta = 0.01
self.batch_size = 128
| class Config:
def __init__(self):
self.type = 'a2c'
self.gamma = 0.99
self.learning_rate = 0.001
self.entropy_beta = 0.01
self.batch_size = 128 |
width = const(7)
height = const(12)
data = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\x10\x10\x00\x00\x10\x00\x00\x00\x00lHH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x14(|(|(PP\x00\x00\x00\x108@@8Hp\x10\x10\x00\x00\x00 P \x0cp\x08\x14\x08\x00\x00\x00\x00\x00\x00\x18 TH4\x00\x00\x00\x00\x10\x10\... | width = const(7)
height = const(12)
data = b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x10\x10\x10\x10\x00\x00\x10\x00\x00\x00\x00lHH\x00\x00\x00\x00\x00\x00\x00\x00\x00\x14\x14(|(|(PP\x00\x00\x00\x108@@8Hp\x10\x10\x00\x00\x00 P \x0cp\x08\x14\x08\x00\x00\x00\x00\x00\x00\x18 TH4\x00\x00\x00\x00\x10\x10\x... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def binaryTreePaths(self, root: TreeNode) -> List[str]:
if not root: return []
result = []
... | class Solution:
def binary_tree_paths(self, root: TreeNode) -> List[str]:
if not root:
return []
result = []
if root.left or root.right:
for path in self.binaryTreePaths(root.left):
result.append(str(root.val) + '->' + path)
for path in se... |
class Solution(object):
def countComponents(self, n, edges):
"""
:type n: int
:type edges: List[List[int]]
:rtype: int
"""
V = [[] for _ in range(n)]
for e in edges:
V[e[0]].append(e[1])
V[e[1]].append(e[0])
visited = [False fo... | class Solution(object):
def count_components(self, n, edges):
"""
:type n: int
:type edges: List[List[int]]
:rtype: int
"""
v = [[] for _ in range(n)]
for e in edges:
V[e[0]].append(e[1])
V[e[1]].append(e[0])
visited = [False f... |
class Solution:
def calculate(self, s: str) -> int:
inner, outer, result, opt = 0, 0, 0, '+'
for c in s+'+':
if c == ' ': continue
if c.isdigit():
inner = 10*inner + int(c)
continue
if opt == '+':
result += outer
... | class Solution:
def calculate(self, s: str) -> int:
(inner, outer, result, opt) = (0, 0, 0, '+')
for c in s + '+':
if c == ' ':
continue
if c.isdigit():
inner = 10 * inner + int(c)
continue
if opt == '+':
... |
client_id="You need to fill this"
client_secret="You need to fill this"
user_agent="You need to fill this"
username="You need to fill this"
password="You need to fill this" | client_id = 'You need to fill this'
client_secret = 'You need to fill this'
user_agent = 'You need to fill this'
username = 'You need to fill this'
password = 'You need to fill this' |
targets = [int(target) for target in input().split()]
command = input().split()
while "End" not in command:
index = int(command[1])
if "Shoot" in command:
power = int(command[2])
if 0 <= index < len(targets):
targets[index] -= power
if targets[index] <= 0:
... | targets = [int(target) for target in input().split()]
command = input().split()
while 'End' not in command:
index = int(command[1])
if 'Shoot' in command:
power = int(command[2])
if 0 <= index < len(targets):
targets[index] -= power
if targets[index] <= 0:
... |
class Group(object):
def __init__(self, _name):
self.name = _name
self.groups = []
self.users = []
def add_group(self, group):
self.groups.append(group)
def add_user(self, user):
self.users.append(user)
def get_groups(self):
return self.groups
def ... | class Group(object):
def __init__(self, _name):
self.name = _name
self.groups = []
self.users = []
def add_group(self, group):
self.groups.append(group)
def add_user(self, user):
self.users.append(user)
def get_groups(self):
return self.groups
def... |
letter="Sai Teja";
for i in letter:
print(i);
| letter = 'Sai Teja'
for i in letter:
print(i) |
class Club:
total = 140
start_address = 751472
size = 88
max_name_size = 48
max_tla_size = 3
def __init__(self, option_file, idx):
self.option_file = option_file
self.idx = idx
self.set_addresses()
self.set_name()
self.set_tla()
def set_addresses(se... | class Club:
total = 140
start_address = 751472
size = 88
max_name_size = 48
max_tla_size = 3
def __init__(self, option_file, idx):
self.option_file = option_file
self.idx = idx
self.set_addresses()
self.set_name()
self.set_tla()
def set_addresses(sel... |
def add_one(num):
return (-(~num))
print(add_one(3))
print(add_one(99)) | def add_one(num):
return -~num
print(add_one(3))
print(add_one(99)) |
# Global constants that will be used all along the program
# Port paths
ODRIVE_USB_PORT_PATH = ""
REHASTIM_USB_PORT_PATH = ""
USB_DRIVE_PORT_PATH = ""
| odrive_usb_port_path = ''
rehastim_usb_port_path = ''
usb_drive_port_path = '' |
#!/usr/bin/env python3
class Solution:
def xorOperation(self, n: int, start: int) -> int:
res = start
for i in range(1,n):
res^=start+2*i
return res
## Intuition:
#
# - As per the requirements of the problem, we don't need to return the array itself.
# - So, we can free up any ... | class Solution:
def xor_operation(self, n: int, start: int) -> int:
res = start
for i in range(1, n):
res ^= start + 2 * i
return res |
# dude, this is a comment
# some more
hello
def dude():
yes
awesome;
# Here we have a comment
def realy_awesome(): # hi there
in_more
same_level
def one_liner(): first; second # both inside one_liner
back_down
last_statement
# dude, this is a comment
# some more
hello
if 1:... | hello
def dude():
yes
awesome
def realy_awesome():
in_more
same_level
def one_liner():
first
second
back_down
last_statement
hello
if 1:
yes
awesome
if 'hello':
in_more
same_level
if ['dude', 'dudess'].horsie():
... |
# https://open.kattis.com/problems/oddgnome
n = int(input())
for _ in range(n):
gnomes = list(map(int, input().split()))[1:]
for i in range(1, len(gnomes) - 1):
if gnomes[i + 1] > gnomes[i - 1]:
if gnomes[i] < gnomes[i - 1] and gnomes[i] < gnomes[i + 1]:
print(i + 1)
... | n = int(input())
for _ in range(n):
gnomes = list(map(int, input().split()))[1:]
for i in range(1, len(gnomes) - 1):
if gnomes[i + 1] > gnomes[i - 1]:
if gnomes[i] < gnomes[i - 1] and gnomes[i] < gnomes[i + 1]:
print(i + 1)
break
if gnomes[i] > gno... |
'''
## Questions
### 23. [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
**Example:**
```
Input:
[
1->4->5,
1->3->4,
2->6
]
Output: 1->1->2->3->4->4->5->6
'''
## Solutions
# Definit... | """
## Questions
### 23. [Merge k Sorted Lists](https://leetcode.com/problems/merge-k-sorted-lists/)
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
**Example:**
```
Input:
[
1->4->5,
1->3->4,
2->6
]
Output: 1->1->2->3->4->4->5->6
"""
class Solution:
de... |
# Palace Oasis (2103000) | Ariant Castle (260000300)
ariantCulture = 3900
if sm.hasQuest(ariantCulture):
sm.setQRValue(ariantCulture, "5", False)
sm.sendSayOkay("You used two hands to drink the clean water of the Oasis. "
"Delicious! It quenched your thirst right on the spot.")
| ariant_culture = 3900
if sm.hasQuest(ariantCulture):
sm.setQRValue(ariantCulture, '5', False)
sm.sendSayOkay('You used two hands to drink the clean water of the Oasis. Delicious! It quenched your thirst right on the spot.') |
class Dino:
@staticmethod
def exe1():
print("al carajo 1")
def exe2(self):
print("al carajo 2")
class Car(Dino):
wheels = 0
def __init__(self, color, x, func):
self.color = color
self.f = func
Car.wheels = x
while (True):
print("yey")
Dino.exe1()
din = Dino()
din.exe2()
f = lambda x: x+1
#print(f(2... | class Dino:
@staticmethod
def exe1():
print('al carajo 1')
def exe2(self):
print('al carajo 2')
class Car(Dino):
wheels = 0
def __init__(self, color, x, func):
self.color = color
self.f = func
Car.wheels = x
while True:
print('yey')
Dino.exe1()
din = d... |
#!/usr/bin/python
#
# Copyright 2007 Google Inc. All Rights Reserved.
"""CSS Lexical Grammar rules.
CSS lexical grammar from http://www.w3.org/TR/CSS21/grammar.html
"""
__author__ = ['elsigh@google.com (Lindsey Simon)',
'msamuel@google.com (Mike Samuel)']
# public symbols
__all__ = [ "NEW... | """CSS Lexical Grammar rules.
CSS lexical grammar from http://www.w3.org/TR/CSS21/grammar.html
"""
__author__ = ['elsigh@google.com (Lindsey Simon)', 'msamuel@google.com (Mike Samuel)']
__all__ = ['NEWLINE', 'HEX', 'NON_ASCII', 'UNICODE', 'ESCAPE', 'NMSTART', 'NMCHAR', 'STRING1', 'STRING2', 'IDENT', 'NAME', 'HASH', 'N... |
# Copyright (c) 2018 - 2020 Institute for High Voltage Technology and Institute for High Voltage Equipment and Grids, Digitalization and Power Economics
# RWTH Aachen University
# Contact: Thomas Offergeld (t.offergeld@iaew.rwth-aachen.de)
# #
# This module is part of CIMPyORM.
# #
# CIMPyORM is licensed un... | def test_parse_meta(acquire_db, dummy_source):
(_, session) = acquire_db
assert dummy_source.tree
assert dummy_source.nsmap == {'cim': 'http://iec.ch/TC57/2013/CIM-schema-cim16#', 'entsoe': 'http://entsoe.eu/CIM/SchemaExtension/3/1#', 'md': 'http://iec.ch/TC57/61970-552/ModelDescription/1#', 'rdf': 'http://... |
"""
Backported error classes for twisted.
"""
__docformat__ = 'epytext en'
class VerifyError(Exception):
"""Could not verify something that was supposed to be signed.
"""
class PeerVerifyError(VerifyError):
"""The peer rejected our verify error.
"""
class CertificateError(Exception):
"""
We d... | """
Backported error classes for twisted.
"""
__docformat__ = 'epytext en'
class Verifyerror(Exception):
"""Could not verify something that was supposed to be signed.
"""
class Peerverifyerror(VerifyError):
"""The peer rejected our verify error.
"""
class Certificateerror(Exception):
"""
We d... |
with open('inputs/input24.txt') as fin:
raw = fin.read()
def parse(raw):
x = [x for x in raw.splitlines()]
return x
a = parse(raw)
def part_1(data):
dictionary = {}
for a in data:
e = a.count('ne') + a.count('se')
w = a.count('nw') + a.count('sw')
x = e + 2 * (a.count('... | with open('inputs/input24.txt') as fin:
raw = fin.read()
def parse(raw):
x = [x for x in raw.splitlines()]
return x
a = parse(raw)
def part_1(data):
dictionary = {}
for a in data:
e = a.count('ne') + a.count('se')
w = a.count('nw') + a.count('sw')
x = e + 2 * (a.count('e') ... |
num = int(input('Digite um numero: '))
tot = 0
for c in range(1, num +1):
if num% c == 0 :
print('\033[33m', end='')
tot += 1
else:
print('\033[31m',end=' ')
print('{}'.format(c) , end=' ')
print('\n\033[mO numero {} foi divisivel {} vezes'.format(num, tot))
if tot == 2:
print('E... | num = int(input('Digite um numero: '))
tot = 0
for c in range(1, num + 1):
if num % c == 0:
print('\x1b[33m', end='')
tot += 1
else:
print('\x1b[31m', end=' ')
print('{}'.format(c), end=' ')
print('\n\x1b[mO numero {} foi divisivel {} vezes'.format(num, tot))
if tot == 2:
print('... |
__version__ = '0.3.7'
__title__ = 'iam-docker-run'
__description__ = 'Run Docker containers within the context of an AWS IAM Role, and other development workflow helpers.'
__url__ = 'https://github.com/billtrust/iam-docker-run'
__author__ = 'Doug Kerwin'
__author_email__ = 'dwkerwin@gmail.com'
__license__ = 'MIT'
__key... | __version__ = '0.3.7'
__title__ = 'iam-docker-run'
__description__ = 'Run Docker containers within the context of an AWS IAM Role, and other development workflow helpers.'
__url__ = 'https://github.com/billtrust/iam-docker-run'
__author__ = 'Doug Kerwin'
__author_email__ = 'dwkerwin@gmail.com'
__license__ = 'MIT'
__key... |
#!/bin/python3
#
# Copyright (c) 2019 Paulo Vital
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge,... | def fibonacci(n):
if n == 0 or n == 1:
yield 1
yield (fibonacci(n - 1) + fibonacci(n - 2))
if __name__ == '__main__':
end = input('Type a limit number: ')
print('The Fibonacci sequence for {0} is: '.format(end), list(fibonacci(int(end)))) |
"""
Module: 'uasyncio.event' on esp32 1.13.0-103
"""
# MCU: (sysname='esp32', nodename='esp32', release='1.13.0', version='v1.13-103-gb137d064e on 2020-10-09', machine='ESP32 module (spiram) with ESP32')
# Stubber: 1.3.4
class Event:
''
def clear():
pass
def is_set():
pass
def set():
... | """
Module: 'uasyncio.event' on esp32 1.13.0-103
"""
class Event:
""""""
def clear():
pass
def is_set():
pass
def set():
pass
wait = None
core = None |
NumbersBelow19 = ["One", "Two","Three","Four","Five","Six","Seven","Eight","Nine","Ten","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Ninteen"]
multiplesOf10 = ["Twenty" , "Thirty" , "Fourty" , "Fifty" , "Sixty" , "Seventy" ,"Eighty" , "Ninety"]
singleDigits = ["One", "Two","Thr... | numbers_below19 = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Ninteen']
multiples_of10 = ['Twenty', 'Thirty', 'Fourty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety']
single_digits = ['One',... |
num = int(input())
first = []
second = []
for i in range(num):
line = input().split(' ')
name = line[0]
t1 = float(line[1])
t2 = float(line[2])
first.append([name, t1])
second.append([name, t2])
first.sort(key=lambda x: x[1])
second.sort(key=lambda x: x[1])
total_time = 0
squad_list_of_lists =... | num = int(input())
first = []
second = []
for i in range(num):
line = input().split(' ')
name = line[0]
t1 = float(line[1])
t2 = float(line[2])
first.append([name, t1])
second.append([name, t2])
first.sort(key=lambda x: x[1])
second.sort(key=lambda x: x[1])
total_time = 0
squad_list_of_lists = [... |
def remdup(a):
return list(set(a))
l=[]
for i in range(0,5):
l.append(input())
print(l)
rev = l[::-1]
print(rev)
print(remdup(l))
print([i for i in range(0,10) if i%2==0])
| def remdup(a):
return list(set(a))
l = []
for i in range(0, 5):
l.append(input())
print(l)
rev = l[::-1]
print(rev)
print(remdup(l))
print([i for i in range(0, 10) if i % 2 == 0]) |
'''
Created on 1.12.2016
@author: Darren
''''''
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
Find the minimum element.
You may assume no duplicate exists in the array."
'''
| """
Created on 1.12.2016
@author: Darren
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
Find the minimum element.
You may assume no duplicate exists in the array."
""" |
# This is Pessimistic Error Pruning.
def prune(t):
# If the node is a leaf node, stop pruning.
if t.label != None:
return
L = t.leaf_sum
N = t.N
p = (t.RT + 0.5*L)/N
# When the following condition is satisfied,
# replace the subtree with a leaf node.
if t.RT + 0.5 - (N*p*(1-p))*... | def prune(t):
if t.label != None:
return
l = t.leaf_sum
n = t.N
p = (t.RT + 0.5 * L) / N
if t.RT + 0.5 - (N * p * (1 - p)) ** 0.5 < t.RT + 0.5 * L:
t.label = t.majority
return
prune(t.left)
prune(t.right) |
__author__ = 'haukurk'
def log_exception(sender, exception, **extra):
"""
Log an exception to our logging framework.
@param sender: sender
@param exception: exception triggered
@**extra: other params.
@return: void
"""
sender.logger.debug('Got exception during processing: %s', exceptio... | __author__ = 'haukurk'
def log_exception(sender, exception, **extra):
"""
Log an exception to our logging framework.
@param sender: sender
@param exception: exception triggered
@**extra: other params.
@return: void
"""
sender.logger.debug('Got exception during processing: %s', exception... |
"""Top-level package for trailscraper."""
__author__ = """Florian Sellmayr"""
__email__ = 'florian.sellmayr@gmail.com'
__version__ = '0.6.5'
| """Top-level package for trailscraper."""
__author__ = 'Florian Sellmayr'
__email__ = 'florian.sellmayr@gmail.com'
__version__ = '0.6.5' |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isCousins(self, root: 'TreeNode', x: 'int', y: 'int') -> 'bool':
m = {}
def traverse(node, parent=None, depth=0):
... | class Solution:
def is_cousins(self, root: 'TreeNode', x: 'int', y: 'int') -> 'bool':
m = {}
def traverse(node, parent=None, depth=0):
if node:
m[node.val] = (parent, depth)
traverse(node.left, node.val, depth + 1)
traverse(node.right, no... |
class Singleton(type):
instance = None
def __call__(cls, *args, **kwargs):
if not cls.instance:
cls.instance = super(Singleton, cls).__call__(*args, **kwargs)
return cls.instance
# Taken from https://github.com/tomerghelber/singleton-factory
class SingletonFactory(type):
"""
... | class Singleton(type):
instance = None
def __call__(cls, *args, **kwargs):
if not cls.instance:
cls.instance = super(Singleton, cls).__call__(*args, **kwargs)
return cls.instance
class Singletonfactory(type):
"""
Singleton Factory - keeps one object with the same hash
... |
#To find whether the number is +ve,-ve or 0
x=int(input("Enter a number"))
def check_num(x):
if x>0:
print("The",x,"is positive")
elif x<0:
print("The",x,"is negative")
else:
print("The",x,"is zero")
check_num(x)
| x = int(input('Enter a number'))
def check_num(x):
if x > 0:
print('The', x, 'is positive')
elif x < 0:
print('The', x, 'is negative')
else:
print('The', x, 'is zero')
check_num(x) |
"""Constants for propensity_matching library."""
MINIMUM_DF_COUNT = 4000
MINIMUM_POS_COUNT = 1000
UTIL_BOOST_THRESH_1 = MINIMUM_POS_COUNT
UTIL_BOOST_THRESH_2 = MINIMUM_DF_COUNT
UTIL_BOOST_THRESH_3 = 50000
SAMPLES_PER_FEATURE = 100
SMALL_MATCH_THRESHOLD = 3000**3
| """Constants for propensity_matching library."""
minimum_df_count = 4000
minimum_pos_count = 1000
util_boost_thresh_1 = MINIMUM_POS_COUNT
util_boost_thresh_2 = MINIMUM_DF_COUNT
util_boost_thresh_3 = 50000
samples_per_feature = 100
small_match_threshold = 3000 ** 3 |
class RequestError(Exception):
"""The base class for all errors."""
def __init__(self, code, error, retry_after=None):
pass
class Unauthorized(RequestError):
"""Raised if your API Key is invalid or blocked."""
def __init__(self, url, code):
self.code = code
self.error = 'Your... | class Requesterror(Exception):
"""The base class for all errors."""
def __init__(self, code, error, retry_after=None):
pass
class Unauthorized(RequestError):
"""Raised if your API Key is invalid or blocked."""
def __init__(self, url, code):
self.code = code
self.error = 'Your ... |
#!/usr/bin/python3
################################
# File Name: DocTestExample.py
# Author: Chadd Williams
# Date: 10/17/2014
# Class: CS 360
# Assignment: Lecture Examples
# Purpose: Demonstrate PyTest
################################
# Run these test cases via:
# chadd@bart:~> python3 -m doctest -v DocTestE... | def test_int_addition(left: int, right: int) -> 'sum of left and right':
"""Test the + operator for ints
Test a simple two in example
>>> testIntAddition(1,2)
3
Use the same int twice, no problem
>>> testIntAddition(2,2)
4
Try to add a list to a set! TypeError!
Only show the first and last lines... |
try:
raise Exception()
except Exception as e:
print("hello", str(e))
| try:
raise exception()
except Exception as e:
print('hello', str(e)) |
database = {
'default': 'mysql',
'connections': {
'mysql': {
'name': 'mytodo',
'username': 'root',
'password': '',
'connection': 'mysql:host=127.0.0.1',
},
},
'migrations': 'migrations',
}
| database = {'default': 'mysql', 'connections': {'mysql': {'name': 'mytodo', 'username': 'root', 'password': '', 'connection': 'mysql:host=127.0.0.1'}}, 'migrations': 'migrations'} |
# CONCATENATION
firstName = "Helder"
lastName = "Pereira"
fullName = "Helder" + " " + lastName
print(fullName) | first_name = 'Helder'
last_name = 'Pereira'
full_name = 'Helder' + ' ' + lastName
print(fullName) |
#!/usr/bin/python
# -*- coding:utf-8 -*-
'''
sqlmapapi restful interface
by zhangh (zhanghang.org#gmail.com)
'''
# api
task_new = "task/new"
task_del = "task/<taskid>/delete"
admin_task_list = "admin/<taskid>/list"
admin_task_flush = "admin/<taskid>/flush"
option_task_list = "option/<taskid>/list"
option_task_get = ... | """
sqlmapapi restful interface
by zhangh (zhanghang.org#gmail.com)
"""
task_new = 'task/new'
task_del = 'task/<taskid>/delete'
admin_task_list = 'admin/<taskid>/list'
admin_task_flush = 'admin/<taskid>/flush'
option_task_list = 'option/<taskid>/list'
option_task_get = 'option/<taskid>/get'
option_task_set = 'option/... |
def path_initial_steps(path, node):
'''
takes in a list of arcs and a node and returns the list of nodes the node can reach
'''
initial_steps = []
for arc in path:
if arc[0] == node:
initial_steps.append(arc)
return initial_steps
def path_end_points(path, node):
'''
... | def path_initial_steps(path, node):
"""
takes in a list of arcs and a node and returns the list of nodes the node can reach
"""
initial_steps = []
for arc in path:
if arc[0] == node:
initial_steps.append(arc)
return initial_steps
def path_end_points(path, node):
"""
... |
#!/usr/bin/env python3
"""
determine the shape of a matrix
"""
def matrix_shape(matrix):
"""
function to calculatre matrix shape
"""
shape = []
while type(matrix) is list:
shape.append(len(matrix))
matrix = matrix[0]
return shape
| """
determine the shape of a matrix
"""
def matrix_shape(matrix):
"""
function to calculatre matrix shape
"""
shape = []
while type(matrix) is list:
shape.append(len(matrix))
matrix = matrix[0]
return shape |
"""Basic registry for model builders."""
BUILDERS = dict()
def register(name):
"""Registers a new model builder function under the given model name."""
def add_to_dict(func):
BUILDERS[name] = func
return func
return add_to_dict
def get_builder(model_name):
"""Fetches the model bui... | """Basic registry for model builders."""
builders = dict()
def register(name):
"""Registers a new model builder function under the given model name."""
def add_to_dict(func):
BUILDERS[name] = func
return func
return add_to_dict
def get_builder(model_name):
"""Fetches the model builder... |
"""
Title | Project
Author: Keegan Skeate
Contact: <keegan@cannlytics.com>
Created:
Updated:
License: MIT License <https://github.com/cannlytics/cannlytics-ai/blob/main/LICENSE>
"""
# Initialize a Socrata client.
# app_token = os.environ.get('APP_TOKEN', None)
# client = Socrata('opendata.mass-cannabis-control.com... | """
Title | Project
Author: Keegan Skeate
Contact: <keegan@cannlytics.com>
Created:
Updated:
License: MIT License <https://github.com/cannlytics/cannlytics-ai/blob/main/LICENSE>
""" |
def x():
return 1
x()
| def x():
return 1
x() |
class Screen:
"""
Abstract class for drawing to the LCD
The main program will transition between
displaying various "screens" based on
high-level logic
"""
def draw(self, cr):
raise NotImplementedError("Must implement draw")
def stop(self):
"""
Some screens may ... | class Screen:
"""
Abstract class for drawing to the LCD
The main program will transition between
displaying various "screens" based on
high-level logic
"""
def draw(self, cr):
raise not_implemented_error('Must implement draw')
def stop(self):
"""
Some screens ma... |
class MudAction:
"""
Contains all of the information about attempted physical actions within
the world. Whenever a Mob, Item, Character, etc tries to do anything in
the game world, an instance is created and sent around to all the other
chars, items, room, etc.
"""
def __init__(self, actio... | class Mudaction:
"""
Contains all of the information about attempted physical actions within
the world. Whenever a Mob, Item, Character, etc tries to do anything in
the game world, an instance is created and sent around to all the other
chars, items, room, etc.
"""
def __init__(self, actio... |
def internet_on():
with open("error_log.csv", "a") as error_log:
error_log.write("\n{0},Log,Testing Internet connection.".format(strftime("%Y-%m-%d %H:%M:%S")))
global ledSwitch
global connected
global powerSwitch
try:
powerSwitch = 0
urllib.request.urlopen('http://216.58.207.206')
#urllib.urlopen('htt... | def internet_on():
with open('error_log.csv', 'a') as error_log:
error_log.write('\n{0},Log,Testing Internet connection.'.format(strftime('%Y-%m-%d %H:%M:%S')))
global ledSwitch
global connected
global powerSwitch
try:
power_switch = 0
urllib.request.urlopen('http://216.58.20... |
# coding: utf-8
"""*****************************************************************************
* Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* re... | """*****************************************************************************
* Copyright (C) 2018 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* responsibility to ... |
# encoding: utf-8
# module System.Linq.Dynamic calls itself Dynamic
# from Wms.RemotingImplementation,Version=1.23.1.0,Culture=neutral,PublicKeyToken=null
# by generator 1.145
# no doc
# no important
# no functions
# classes
class DynamicClass(object):
# no doc
def ZZZ(self):
"""hardcoded/mock instan... | class Dynamicclass(object):
def zzz(self):
"""hardcoded/mock instance of the class"""
return dynamic_class()
instance = zzz()
'hardcoded/returns an instance of the class'
def to_string(self):
""" ToString(self: DynamicClass) -> str """
pass
class Dynamicexpression(obje... |
"""
This problem was asked by Stripe.
Given an array of integers, find the first missing positive integer in linear time and constant space. In other words,
find the lowest positive integer that does not exist in the array. The array can contain duplicates and
negative numbers as well.
For example, the input [3, 4,... | """
This problem was asked by Stripe.
Given an array of integers, find the first missing positive integer in linear time and constant space. In other words,
find the lowest positive integer that does not exist in the array. The array can contain duplicates and
negative numbers as well.
For example, the input [3, 4,... |
# -*- coding: utf-8 -*-
"""
Created on Tue Aug 28 15:57:01 2014
Reference URL: http://carina.fcaglp.unlp.edu.ar/ida/archivos/tabla_constantes.pdf
@author: yang
"""
# ---- Universal constants
# universal gravitational constant: N/m^2/kg^{-2}
G = 6.67e-11
# ---- Earth
# acceleration due to gravity at sea level: m/s^2... | """
Created on Tue Aug 28 15:57:01 2014
Reference URL: http://carina.fcaglp.unlp.edu.ar/ida/archivos/tabla_constantes.pdf
@author: yang
"""
g = 6.67e-11
g = 9.81
re = 6370000.0
omega = 7.292e-05
rho_a = 1.25
rd = 287
cp = 1004
cv = 717
rho_w = 1000.0
rv = 461
lv = 2500000.0
epsilon = 0.622
t0 = 273.15 |
#
# PySNMP MIB module ATM-TC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ATM-TC-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:04:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_union, single_value_constraint, constraints_intersection) ... |
class Member(object):
"""
A member of the etcd cluster.
:ivar id: ID of the member
:ivar name: human-readable name of the member
:ivar peer_urls: list of URLs the member exposes to the cluster for
communication
:ivar client_urls: list of URLs the member exposes to clients f... | class Member(object):
"""
A member of the etcd cluster.
:ivar id: ID of the member
:ivar name: human-readable name of the member
:ivar peer_urls: list of URLs the member exposes to the cluster for
communication
:ivar client_urls: list of URLs the member exposes to clients f... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.