content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Command(object):
def get_option(self, name):
pass
def run(self, ):
raise NotImplementedError
| class Command(object):
def get_option(self, name):
pass
def run(self):
raise NotImplementedError |
a, b, c, d = map(int, input().split())
if a+b > c+d:
print("Left")
elif a+b < c+d:
print("Right")
else:
print("Balanced")
| (a, b, c, d) = map(int, input().split())
if a + b > c + d:
print('Left')
elif a + b < c + d:
print('Right')
else:
print('Balanced') |
# pyre-ignore-all-errors
# TODO: Change `pyre-ignore-all-errors` to `pyre-strict` on line 1, so we get
# to see all type errors in this file.
# A (hypothetical) Python developer is having trouble with a typing-related
# issue. Here is what the code looks like:
class ConfigA:
pass
class ConfigB:
some_attri... | class Configa:
pass
class Configb:
some_attribute: int = 1
class Helperbase:
def __init__(self, config: ConfigA | ConfigB) -> None:
self.config = config
def common_fn(self) -> None:
pass
class Helpera(HelperBase):
def __init__(self, config: ConfigA) -> None:
super().__i... |
#
# PySNMP MIB module CISCO-LWAPP-LOCAL-AUTH-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-LOCAL-AUTH-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:48:42 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_union, constraints_intersection, single_value_constraint) ... |
class Human:
def method(self):
return print(f'Hello - {self}')
@classmethod
def classmethod(cls):
return print('it is a species of "Homo sapiens"')
@staticmethod
def staticmethod():
return print('Congratulations')
name_human = input('Enter your name: ')
Human.method(na... | class Human:
def method(self):
return print(f'Hello - {self}')
@classmethod
def classmethod(cls):
return print('it is a species of "Homo sapiens"')
@staticmethod
def staticmethod():
return print('Congratulations')
name_human = input('Enter your name: ')
Human.method(name_h... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
SUCCESS = "0"
NEED_SMS = "1"
SMS_FAIL = "2"
| success = '0'
need_sms = '1'
sms_fail = '2' |
#Vigenere cipher + b64 - substitution
'''
method = sys.argv[1]
key = sys.argv[2]
string = sys.argv[3]
'''
def encode(key, string) :
encoded_chars = []
for i in range(len(string)) :
key_c = key[i % len(key)]
encoded_c = chr(ord(string[i]) + ord(key_c) % 256)
encoded_chars.append(encoded... | """
method = sys.argv[1]
key = sys.argv[2]
string = sys.argv[3]
"""
def encode(key, string):
encoded_chars = []
for i in range(len(string)):
key_c = key[i % len(key)]
encoded_c = chr(ord(string[i]) + ord(key_c) % 256)
encoded_chars.append(encoded_c)
encoded_string = ''.join(encoded_... |
def mult_by_two(num):
return num * 2
def mult_by_five(num):
return num * 5
def square(num):
return num * num
def add_one(num):
return num + 1
def apply(num, func):
return func(num)
result = apply(10, mult_by_two)
print(result)
print(apply(10, mult_by_five))
print(apply(10, square))
print(... | def mult_by_two(num):
return num * 2
def mult_by_five(num):
return num * 5
def square(num):
return num * num
def add_one(num):
return num + 1
def apply(num, func):
return func(num)
result = apply(10, mult_by_two)
print(result)
print(apply(10, mult_by_five))
print(apply(10, square))
print(apply(1... |
class BisectionMap(object):
__slots__ = ('nodes')
#//-------------------------------------------------------//
def __init__(self, dict = {} ):
self.nodes = []
for key, value in dict.iteritems():
self[ key ] = value
#//----------------------------... | class Bisectionmap(object):
__slots__ = 'nodes'
def __init__(self, dict={}):
self.nodes = []
for (key, value) in dict.iteritems():
self[key] = value
def __find_position(self, key):
nodes = self.nodes
pos = 0
end = len(nodes)
while pos < end:
... |
# -*- coding: utf-8 -*-
test = 0
while True:
test += 1
deposits = int(input())
if deposits == 0:
break
delta = 0
print("Teste %d" % test)
for i in range(deposits):
values = input().split()
a = int(values[0])
b = int(values[1])
delta += a - b
... | test = 0
while True:
test += 1
deposits = int(input())
if deposits == 0:
break
delta = 0
print('Teste %d' % test)
for i in range(deposits):
values = input().split()
a = int(values[0])
b = int(values[1])
delta += a - b
print(delta)
print('') |
#LEETOCDE: 104. Maximum Depth of Binary Tree
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def maxDepth(root: TreeNode) -> int:
if not root: return 0
else: return max(1+maxDepth(root.left), 1+maxDepth(root.right))
#TODO: Implement iterativ... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
def max_depth(root: TreeNode) -> int:
if not root:
return 0
else:
return max(1 + max_depth(root.left), 1 + max_depth(root.right))
def max_depth_ii(root: TreeNode) -> int:
pri... |
# Definition for a binary tree node.
# from typing import List
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def solve(self, preorder: List[int], inorder: List[int]) -> TreeNode:
if not preorder:
r... | class Solution:
def solve(self, preorder: List[int], inorder: List[int]) -> TreeNode:
if not preorder:
return None
root = tree_node(preorder[0])
if len(inorder) == 1:
return root
root_idx_inorder = inorder.index(preorder[0])
lchild = self.solve(preord... |
# sorting algorithms
# mergeSort
def merge_sort(a):
n = len(a)
if n < 2:
return a
q = int(n / 2)
left = a[:q]
right = a[q:]
# print("left : {%s} , right : {%s}, A : {%s}" % (left, right, a))
merge_sort(left)
merge_sort(right)
a = merge(a, left, right)
# print("Result ... | def merge_sort(a):
n = len(a)
if n < 2:
return a
q = int(n / 2)
left = a[:q]
right = a[q:]
merge_sort(left)
merge_sort(right)
a = merge(a, left, right)
return a
def merge(a, left, right):
l = len(left)
r = len(right)
(i, j, k) = (0, 0, 0)
while i < l and j < ... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"file_exists": "01_data.ipynb",
"ds_file_exists": "01_data.ipynb",
"filter_for_exists": "01_data.ipynb",
"drop_missing_files": "01_data.ipynb",
"add_ds": "01_data.ipynb",
... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'file_exists': '01_data.ipynb', 'ds_file_exists': '01_data.ipynb', 'filter_for_exists': '01_data.ipynb', 'drop_missing_files': '01_data.ipynb', 'add_ds': '01_data.ipynb', 'merge_ds': '01_data.ipynb', 'remove_special_characters': '01_data.ipynb', 'ch... |
# Copyright 2021 Jason Rumney
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | domain = 'metlink'
attribution = 'Data provided by Greater Wellington Regional Council'
conf_stops = 'stops'
conf_stop_id = 'stop_id'
conf_dest = 'destination'
conf_route = 'route'
conf_num_departures = 'num_departures'
attr_accessible = 'wheelchair_accessible'
attr_aimed = 'aimed'
attr_arrival = 'arrival'
attr_closed ... |
def cria_matriz(linhas, colunas, valor):
matriz = []
for i in range(linhas):
lin = []
for j in range(colunas):
lin.append(valor)
matriz.append(lin)
return matriz
def le_matriz():
linhas = int(input("Digite a quantidade de linhas: "))
colunas = int(input("Digite a qu... | def cria_matriz(linhas, colunas, valor):
matriz = []
for i in range(linhas):
lin = []
for j in range(colunas):
lin.append(valor)
matriz.append(lin)
return matriz
def le_matriz():
linhas = int(input('Digite a quantidade de linhas: '))
colunas = int(input('Digite a... |
ELECTION_HOME="election@home"
ELECTION_VIEW="election@view"
ELECTION_META="election@meta"
ELECTION_EDIT="election@edit"
ELECTION_SCHEDULE="election@schedule"
ELECTION_EXTEND="election@extend"
ELECTION_ARCHIVE="election@archive"
ELECTION_COPY="election@copy"
ELECTION_BADGE="election@badge"
ELECTION_TRUSTEES_HOME="elect... | election_home = 'election@home'
election_view = 'election@view'
election_meta = 'election@meta'
election_edit = 'election@edit'
election_schedule = 'election@schedule'
election_extend = 'election@extend'
election_archive = 'election@archive'
election_copy = 'election@copy'
election_badge = 'election@badge'
election_tru... |
class IdentifierLabels:
ID = "CMPLNT_NUM"
class DateTimeEventLabels:
EVENT_START_TIMESTAMP = "CMPLNT_FR_DT"
EVENT_END_TIMESTAMP = "CMPLNT_TO_DT"
class DateTimeSubmissionLabels:
SUBMISSION_TO_POLICE_TIMESTAMP = "RPT_DT"
class LawBreakingLabels:
KEY_CODE = "KY_CD"
PD_CODE = "PD_CD"
LAW_B... | class Identifierlabels:
id = 'CMPLNT_NUM'
class Datetimeeventlabels:
event_start_timestamp = 'CMPLNT_FR_DT'
event_end_timestamp = 'CMPLNT_TO_DT'
class Datetimesubmissionlabels:
submission_to_police_timestamp = 'RPT_DT'
class Lawbreakinglabels:
key_code = 'KY_CD'
pd_code = 'PD_CD'
law_brea... |
class Solution:
def longestArithSeqLength(self, A: List[int]) -> int:
if len(A) <= 2:
return len(A)
ans = 2
dp = collections.defaultdict(set)
for i, num in enumerate(A):
if num in dp:
for d, cnt in dp.pop(num):
dp[num + d].a... | class Solution:
def longest_arith_seq_length(self, A: List[int]) -> int:
if len(A) <= 2:
return len(A)
ans = 2
dp = collections.defaultdict(set)
for (i, num) in enumerate(A):
if num in dp:
for (d, cnt) in dp.pop(num):
dp[nu... |
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
for i1 in range(H):
for i2 in range(i1 + 1, H):
for j1 in range(W):
for j2 in range(j1 + 1, W):
if A[i1][j1] + A[i2][j2] > A[i2][j1] + A[i1][j2]:
print('No')
... | (h, w) = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
for i1 in range(H):
for i2 in range(i1 + 1, H):
for j1 in range(W):
for j2 in range(j1 + 1, W):
if A[i1][j1] + A[i2][j2] > A[i2][j1] + A[i1][j2]:
print('No')
... |
# s.remove(0)
s = {1, 2, 3}
s.remove(0)
print(s)
# bug as it should return a KeyError exception !!!
| s = {1, 2, 3}
s.remove(0)
print(s) |
class Contacts:
def __init__(self, first_name=None, last_name=None, id=None, email_1=None, email_2=None, email_3=None,
home_phone=None, mobile_phone=None, work_phone=None):
self.first_name = first_name
self.last_name = last_name
self.mobile_phone = mobile_phone
self... | class Contacts:
def __init__(self, first_name=None, last_name=None, id=None, email_1=None, email_2=None, email_3=None, home_phone=None, mobile_phone=None, work_phone=None):
self.first_name = first_name
self.last_name = last_name
self.mobile_phone = mobile_phone
self.home_phone = hom... |
'''
The rows of levels in the .azr file are converted to list of strings. These
indices make it more convenient to access the desired parameter.
'''
J_INDEX = 0
PI_INDEX = 1
ENERGY_INDEX = 2
ENERGY_FIXED_INDEX = 3
CHANNEL_INDEX = 5
WIDTH_INDEX = 11
WIDTH_FIXED_INDEX = 10
SEPARATION_ENERGY_INDEX = 21
CHANNEL_RADIUS_INDE... | """
The rows of levels in the .azr file are converted to list of strings. These
indices make it more convenient to access the desired parameter.
"""
j_index = 0
pi_index = 1
energy_index = 2
energy_fixed_index = 3
channel_index = 5
width_index = 11
width_fixed_index = 10
separation_energy_index = 21
channel_radius_inde... |
class ModelMinxi:
def to_dict(self,*exclude):
attr_dict = {}
for field in self._meta.fields:
name = field.attname
if name not in exclude:
attr_dict[name] = getattr(self,name)
return attr_dict | class Modelminxi:
def to_dict(self, *exclude):
attr_dict = {}
for field in self._meta.fields:
name = field.attname
if name not in exclude:
attr_dict[name] = getattr(self, name)
return attr_dict |
numbers = []
for i in range(1,101) :
numbers.append(i)
prime_number = []
for number in numbers :
zero_mod = []
if number == 1 :
continue
else :
for divider in range(1,number+1) :
remain = number % divider
if remain == 0 :
zero_mod.append(divider)
... | numbers = []
for i in range(1, 101):
numbers.append(i)
prime_number = []
for number in numbers:
zero_mod = []
if number == 1:
continue
else:
for divider in range(1, number + 1):
remain = number % divider
if remain == 0:
zero_mod.append(divider)
... |
def get_data():
data = []
data_file = open("data.txt")
# data_file = open("test.txt")
for val in data_file:
data.append(val.strip())
data_file.close()
cubes = {}
for row in range(len(data)):
for col in range(len(data[row])):
if data[row][col] == '#':
... | def get_data():
data = []
data_file = open('data.txt')
for val in data_file:
data.append(val.strip())
data_file.close()
cubes = {}
for row in range(len(data)):
for col in range(len(data[row])):
if data[row][col] == '#':
cubes[f'{row}|{col}|0|0'] = 1
... |
# Write a python program to get a single string from two givan string, separated by a space
# and swap a first two char of each string
# Simple string = "abc", "xyz"
# Expected result = "xyc", "abz"
# st = "abc", "xyz"
# print(st[1][:2] + st[0][-1:])
# print(st[0][:2] + st[1][-1:])
def char_swap(a, b):
x = b[:2... | def char_swap(a, b):
x = b[:2] + a[2:]
y = a[:2] + b[2:]
return x + ' ' + y
if __name__ == '__main__':
print(char_swap('abc', 'xyz')) |
'''
Write a function that takes variable number of arguments and returns the sum , sum of squares, sum of
cubes, average, multiplication, multiplication of squares, multiplication of cubes of that numbers.
'''
def calc(*a):
sum = 0
mul = 1
sumSQR = 0
sumCubes = 0
mulSQR = 1
mulCubes... | """
Write a function that takes variable number of arguments and returns the sum , sum of squares, sum of
cubes, average, multiplication, multiplication of squares, multiplication of cubes of that numbers.
"""
def calc(*a):
sum = 0
mul = 1
sum_sqr = 0
sum_cubes = 0
mul_sqr = 1
mul_cubes = 1
... |
# URLs
MEXC_BASE_URL = "https://www.mexc.com"
MEXC_SYMBOL_URL = '/open/api/v2/market/symbols'
MEXC_TICKERS_URL = '/open/api/v2/market/ticker'
MEXC_DEPTH_URL = '/open/api/v2/market/depth?symbol={trading_pair}&depth=200'
MEXC_PRICE_URL = '/open/api/v2/market/ticker?symbol={trading_pair}'
MEXC_PING_URL = '/open/api/v2/... | mexc_base_url = 'https://www.mexc.com'
mexc_symbol_url = '/open/api/v2/market/symbols'
mexc_tickers_url = '/open/api/v2/market/ticker'
mexc_depth_url = '/open/api/v2/market/depth?symbol={trading_pair}&depth=200'
mexc_price_url = '/open/api/v2/market/ticker?symbol={trading_pair}'
mexc_ping_url = '/open/api/v2/common/pin... |
CONFUSION_MATRIX = "confusion_matrix"
AP = "ap"
DETECTION_AP = "detection_mAP"
DETECTION_APS = "detection_APs"
MOTA = "MOTA"
MOTP = "MOTP"
FALSE_POSITIVES = "false_positives"
FALSE_NEGATIVES = "false_negatives"
ID_SWITCHES = "id_switches"
AP_INTERPOLATED = "ap_interpolated"
ERRORS = "errors"
IOU = "iou"
BINARY_IOU = "b... | confusion_matrix = 'confusion_matrix'
ap = 'ap'
detection_ap = 'detection_mAP'
detection_aps = 'detection_APs'
mota = 'MOTA'
motp = 'MOTP'
false_positives = 'false_positives'
false_negatives = 'false_negatives'
id_switches = 'id_switches'
ap_interpolated = 'ap_interpolated'
errors = 'errors'
iou = 'iou'
binary_iou = 'b... |
class GitRequire(object):
def __init__(self, git_url=None, branch=None, submodule=False):
self.git_url = git_url
self.submodule = submodule
self.branch = branch
def clone_params(self):
clone_params = {"single_branch": True}
if self.branch is not None:
clone_p... | class Gitrequire(object):
def __init__(self, git_url=None, branch=None, submodule=False):
self.git_url = git_url
self.submodule = submodule
self.branch = branch
def clone_params(self):
clone_params = {'single_branch': True}
if self.branch is not None:
clone_... |
# Object in Python do not have a fixed layout.
class X:
def __init__(self, a):
self.a = a
x = X(1)
print(x.a) # 1
# For example, we can add new attributes to objects:
x.b = 5
print(x.b) # 5
# Or even new methods into a class:
X.foo = lambda self: 10
print(x.foo()) # 10
# Or even changing base classes d... | class X:
def __init__(self, a):
self.a = a
x = x(1)
print(x.a)
x.b = 5
print(x.b)
X.foo = lambda self: 10
print(x.foo())
class A:
def foo(self):
return 1
class B(A):
pass
class C:
def foo(self):
return 2
b = b()
print(b.foo(), B.__bases__)
B.__bases__ = (C,)
print(b.foo(), ... |
class Solution:
# @param A : list of strings
# @return a strings
def longestCommonPrefix(self, A):
common_substring = ""
if A:
common_substring = A[0]
for s in A[1:]:
i = 0
l = len(min(common_substring, s))
while i < l:
... | class Solution:
def longest_common_prefix(self, A):
common_substring = ''
if A:
common_substring = A[0]
for s in A[1:]:
i = 0
l = len(min(common_substring, s))
while i < l:
if s[i] != common_substring[i]:
... |
# Link to the problem: https://www.codechef.com/LTIME63B/problems/EID
def EID():
_ = input()
A = list(map(int, input().split()))
A.sort()
size = len(A)
diff = A[size - 1]
for i in range(size - 1):
tempDiff = A[i + 1] - A[i]
if tempDiff < diff:
diff = tempDiff
return diff
def main():
T = ... | def eid():
_ = input()
a = list(map(int, input().split()))
A.sort()
size = len(A)
diff = A[size - 1]
for i in range(size - 1):
temp_diff = A[i + 1] - A[i]
if tempDiff < diff:
diff = tempDiff
return diff
def main():
t = int(input())
while T:
t -= 1... |
monster = ['fairy', 'goblin', 'ogre', 'werewolf',
'vampire', 'gargoyle', 'pirate', 'undead']
weapon1 = ['dagger', 'stone', 'pistol', 'knife']
weapon2 = ['sword', 'war hammer', 'machine gun', 'battle axe', 'war scythe']
scene = ['grass and yellow wildflowers.',
'sand and sea shells',
... | monster = ['fairy', 'goblin', 'ogre', 'werewolf', 'vampire', 'gargoyle', 'pirate', 'undead']
weapon1 = ['dagger', 'stone', 'pistol', 'knife']
weapon2 = ['sword', 'war hammer', 'machine gun', 'battle axe', 'war scythe']
scene = ['grass and yellow wildflowers.', 'sand and sea shells', 'sand and cactus']
place = ['field',... |
# if-elif-else ladder
'''
if is a conditional statement that is used to perform different actions based on different conditions.
'''
if (5 < 6):
print('5 is less than 6')
print()
print()
a = 6
if (a == 5):
print('a is equal to 5')
else:
print('a is not equal to 5')
print()
print()
a = 6
b = 5
if ... | """
if is a conditional statement that is used to perform different actions based on different conditions.
"""
if 5 < 6:
print('5 is less than 6')
print()
print()
a = 6
if a == 5:
print('a is equal to 5')
else:
print('a is not equal to 5')
print()
print()
a = 6
b = 5
if a < b:
print('a is less than b')
... |
def conta_votos(lista_candidatos_numeros, lista_votos, numeros):
brancos = 0
nulos = 0
contagem_geral = []
for i in range(len(lista_candidatos_numeros)):
contagem_individual = [lista_candidatos_numeros[i][0], numeros[i], 0]
contagem_geral.append(contagem_individual)
for v in votos:
... | def conta_votos(lista_candidatos_numeros, lista_votos, numeros):
brancos = 0
nulos = 0
contagem_geral = []
for i in range(len(lista_candidatos_numeros)):
contagem_individual = [lista_candidatos_numeros[i][0], numeros[i], 0]
contagem_geral.append(contagem_individual)
for v in votos:
... |
global T_D,EPS,MU,ETA,dt
T_D = 12.0
L0 = 1.0
EPS = 0.05
# Osborne 2017 params
MU = -50.
ETA = 1.0
dt = 0.005 #hours
| global T_D, EPS, MU, ETA, dt
t_d = 12.0
l0 = 1.0
eps = 0.05
mu = -50.0
eta = 1.0
dt = 0.005 |
class Solution:
def numberOfArithmeticSlices(self, nums: List[int]) -> int:
if len(nums)<3:
return 0
output=[]
slices=[nums[0], nums[1]]
for num in nums[2:]:
if num-slices[-1]==slices[1]-slices[0]:
slices.append(num)
else:
... | class Solution:
def number_of_arithmetic_slices(self, nums: List[int]) -> int:
if len(nums) < 3:
return 0
output = []
slices = [nums[0], nums[1]]
for num in nums[2:]:
if num - slices[-1] == slices[1] - slices[0]:
slices.append(num)
... |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def isSymmetric(self, root: TreeNode) -> bool:
if not root:
return True
return self.isSymmetricHelper(root.left, root.r... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def is_symmetric(self, root: TreeNode) -> bool:
if not root:
return True
return self.isSymmetricHelper(root.left, root.right)
def is_symmetric_helper... |
# Copyright 2019 The TensorFlow Authors. All Rights Reserved.
#
# 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 applica... | def preprocess_input(x, data_format=None, mode=None):
if mode == 'tf':
x /= 127.5
x -= 1.0
return x
elif mode == 'torch':
x /= 255.0
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
elif mode == 'caffe':
if data_format == 'channels_first':
... |
### Insertion Sort - Part 2 - Solution
def insertionSort2(nums):
for i in range(1, len(nums)):
comp, prev = nums[i], i-1
while (prev >= 0) and (nums[prev] > comp):
nums[prev+1] = nums[prev]
prev -= 1
nums[prev+1] = comp
print(*nums)
n = int(input())
nums = ... | def insertion_sort2(nums):
for i in range(1, len(nums)):
(comp, prev) = (nums[i], i - 1)
while prev >= 0 and nums[prev] > comp:
nums[prev + 1] = nums[prev]
prev -= 1
nums[prev + 1] = comp
print(*nums)
n = int(input())
nums = list(map(int, input().split()[:n]))... |
### CLASSES
class TrackPoint:
def __init__(self, time, coordinates, alt):
self.time = time
self.coordinates = coordinates
self.alt = alt
def __repr__(self):
return "%s %s %dm" % (self.time.strftime("%H:%m:%S"), self.coordinates, self.alt)
| class Trackpoint:
def __init__(self, time, coordinates, alt):
self.time = time
self.coordinates = coordinates
self.alt = alt
def __repr__(self):
return '%s %s %dm' % (self.time.strftime('%H:%m:%S'), self.coordinates, self.alt) |
VARS = [
{'name': 'script_name',
'required': True,
'example': 'fancy_script'},
{'name': 'description',
'example': 'Super fancy script'}
]
| vars = [{'name': 'script_name', 'required': True, 'example': 'fancy_script'}, {'name': 'description', 'example': 'Super fancy script'}] |
def test_api_docs(api_client):
rv = api_client.get("/apidocs", follow_redirects=True)
assert rv.status_code == 200
assert b"JournalsDB API Docs" in rv.data
| def test_api_docs(api_client):
rv = api_client.get('/apidocs', follow_redirects=True)
assert rv.status_code == 200
assert b'JournalsDB API Docs' in rv.data |
# Solution A
class Solution:
def isLongPressedName(self, name: str, typed: str) -> bool:
i = 0
name += "1"
for s in typed:
if s == name[i]:
i += 1
elif s != name[i - 1]:
return False
return i == len(name) - 1
# Solution B
clas... | class Solution:
def is_long_pressed_name(self, name: str, typed: str) -> bool:
i = 0
name += '1'
for s in typed:
if s == name[i]:
i += 1
elif s != name[i - 1]:
return False
return i == len(name) - 1
class Solution:
def is... |
#!/usr/bin/env python
# coding: utf-8
# # Re-implement some Python built-in functions
# In[1]:
def my_max(l1):
max_number = l1[0]
for number in l1:
if number > max_number:
max_number = number
return max_number
# In[2]:
def my_min(l1):
min_number = l1[0]
for number in l1:
... | def my_max(l1):
max_number = l1[0]
for number in l1:
if number > max_number:
max_number = number
return max_number
def my_min(l1):
min_number = l1[0]
for number in l1:
if number < min_number:
min_number = number
return min_number
def my_sum(l1):
tota... |
# Copyright 2021 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
register_npcx_project(
project_name="herobrine_npcx9",
zephyr_board="herobrine_npcx9",
dts_overlays=[
"gpio.dts",
"battery.dts... | register_npcx_project(project_name='herobrine_npcx9', zephyr_board='herobrine_npcx9', dts_overlays=['gpio.dts', 'battery.dts', 'i2c.dts', 'motionsense.dts', 'switchcap.dts', 'usbc.dts']) |
num1=num2=res=0
def cn():
global canal
canal="CFB Cursos"
cn()
print(canal) | num1 = num2 = res = 0
def cn():
global canal
canal = 'CFB Cursos'
cn()
print(canal) |
class Db:
def __init__(self):
self._db = None
self._connection = None
@property
def db(self):
return self._db
@db.setter
def db(self, db):
self._db = db
async def _make_connection(self):
self._connection = await self.db.acquire()
async def _close_c... | class Db:
def __init__(self):
self._db = None
self._connection = None
@property
def db(self):
return self._db
@db.setter
def db(self, db):
self._db = db
async def _make_connection(self):
self._connection = await self.db.acquire()
async def _close_... |
# -*- coding: utf-8 -*-
# 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 writing, softw... | _hw_ns = 'hw:'
_cpu_ns = _HW_NS + 'cpu:'
_cpu_x86_ns = _CPU_NS + 'x86:'
hw_cpu_x86_avx = _CPU_X86_NS + 'avx'
hw_cpu_x86_avx2 = _CPU_X86_NS + 'avx2'
hw_cpu_x86_clmul = _CPU_X86_NS + 'clmul'
hw_cpu_x86_fma3 = _CPU_X86_NS + 'fma3'
hw_cpu_x86_fma4 = _CPU_X86_NS + 'fma4'
hw_cpu_x86_f16_c = _CPU_X86_NS + 'f16c'
hw_cpu_x86_mm... |
#
# PySNMP MIB module CISCO-MEDIATRACE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-MEDIATRACE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:07:08 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, constraints_union, single_value_constraint, value_size_constraint) ... |
# %% [1128. Number of Equivalent Domino Pairs](https://leetcode.com/problems/number-of-equivalent-domino-pairs/)
class Solution:
def numEquivDominoPairs(self, dominoes: List[List[int]]) -> int:
c = collections.Counter(tuple(sorted(i)) for i in dominoes)
return sum(n * (n - 1) // 2 for n in c.values(... | class Solution:
def num_equiv_domino_pairs(self, dominoes: List[List[int]]) -> int:
c = collections.Counter((tuple(sorted(i)) for i in dominoes))
return sum((n * (n - 1) // 2 for n in c.values())) |
print("hi\nmyname is : abdullah")
print("And in this code we will do ")
#Files
print("Files")
#______________________#
with open("information.txt" , "r") as f:
print(f.read()) | print('hi\nmyname is : abdullah')
print('And in this code we will do ')
print('Files')
with open('information.txt', 'r') as f:
print(f.read()) |
def canTransform1(start, end):
startX = "".join([c for c in start if c != "X"])
endX = "".join([c for c in end if c != "X"])
if startX != endX: return False
startR = [i for i in range(len(start)) if start[i] == "R"]
startL = [i for i in range(len(start)) if start[i] == "L"]
endR = [i for i... | def can_transform1(start, end):
start_x = ''.join([c for c in start if c != 'X'])
end_x = ''.join([c for c in end if c != 'X'])
if startX != endX:
return False
start_r = [i for i in range(len(start)) if start[i] == 'R']
start_l = [i for i in range(len(start)) if start[i] == 'L']
end_r = ... |
n = int(input())
lst = sorted([int(input()) for i in range(n)])
ans = sorted(set(range(lst[0], lst[len(lst) - 1])).difference(lst))
if lst[0] > 1:
for i in range(1, lst[0]):
ans.append(i)
if (len(ans) != 0):
print(*sorted(ans), sep='\n')
else:
print("good job")
| n = int(input())
lst = sorted([int(input()) for i in range(n)])
ans = sorted(set(range(lst[0], lst[len(lst) - 1])).difference(lst))
if lst[0] > 1:
for i in range(1, lst[0]):
ans.append(i)
if len(ans) != 0:
print(*sorted(ans), sep='\n')
else:
print('good job') |
#
# PySNMP MIB module HH3C-RCR-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-RCR-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:29:21 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection) ... |
DATA_DIR = "/path/your_data_path"
IDX_DIR = "/path/your_index_path"
FILE_ROOT = "./test"
CALIB_FILE = "./imagenet_int8_cache"
MODEL_FILE = "./resnet_imagenet.uff" | data_dir = '/path/your_data_path'
idx_dir = '/path/your_index_path'
file_root = './test'
calib_file = './imagenet_int8_cache'
model_file = './resnet_imagenet.uff' |
APP_DIRECTORY_NAME = "APP"
SRC_DIRECTORY_NAME = "src"
TEMPLATES_DIRECTORY_NAME = "templates"
# Production React Js Template files having Github Repository Links
REACTJS_TEMPLATES_URLS_DICT = {
"package.json-tpl": "https://raw.githubusercontent.com/Jitensid/django-webpack-dev-server/main/assets/reactjs/package.json... | app_directory_name = 'APP'
src_directory_name = 'src'
templates_directory_name = 'templates'
reactjs_templates_urls_dict = {'package.json-tpl': 'https://raw.githubusercontent.com/Jitensid/django-webpack-dev-server/main/assets/reactjs/package.json-tpl', 'webpack.config.js-tpl': 'https://raw.githubusercontent.com/Jitensi... |
# SPDX-License-Identifier: GPL-3.0-only
def make_definitions(f, ecpp, bcpp, all_enums, all_bitfields, all_structs_arranged):
f.write("// SPDX-License-Identifier: GPL-3.0-only\n\n// This file was auto-generated.\n// If you want to edit this, edit the .json definitions and rerun the generator script, instead.\n\n")
... | def make_definitions(f, ecpp, bcpp, all_enums, all_bitfields, all_structs_arranged):
f.write('// SPDX-License-Identifier: GPL-3.0-only\n\n// This file was auto-generated.\n// If you want to edit this, edit the .json definitions and rerun the generator script, instead.\n\n')
header_name = 'INVADER__TAG__HEK__CLA... |
def run_gbrt(d, r, t, ne=0, lr=0.1, md=3, trs=0, frs=0, mf=7):
X_train, X_test, y_train, y_test = train_test_split(
np.append(r, d, 1), t, random_state=trs)
gbrt = GradientBoostingClassifier(
n_estimators=ne, learning_rate=lr, max_depth=md, max_features=mf, random_state=frs)
gbrt.fit(X_train... | def run_gbrt(d, r, t, ne=0, lr=0.1, md=3, trs=0, frs=0, mf=7):
(x_train, x_test, y_train, y_test) = train_test_split(np.append(r, d, 1), t, random_state=trs)
gbrt = gradient_boosting_classifier(n_estimators=ne, learning_rate=lr, max_depth=md, max_features=mf, random_state=frs)
gbrt.fit(X_train[:, 1:], y_tra... |
class Solution:
def buildArray(self, target: List[int], n: int) -> List[str]:
res = []
n = min(max(target), n)
for i in range(1, n+1):
if i in target:
res += ["Push"]
else:
res += ["Push","Pop"]
return res
| class Solution:
def build_array(self, target: List[int], n: int) -> List[str]:
res = []
n = min(max(target), n)
for i in range(1, n + 1):
if i in target:
res += ['Push']
else:
res += ['Push', 'Pop']
return res |
expected_output = {
"vrf": {
"default": {
"source_address": "172.16.10.13",
"path": {
"172.16.121.10 BRI0": {
"neighbor_address": "172.16.121.10",
"neighbor_host": "sj1.cisco.com",
"distance_preferred_lookup"... | expected_output = {'vrf': {'default': {'source_address': '172.16.10.13', 'path': {'172.16.121.10 BRI0': {'neighbor_address': '172.16.121.10', 'neighbor_host': 'sj1.cisco.com', 'distance_preferred_lookup': True, 'recursion_count': 0, 'interface_name': 'BRI0', 'originated_topology': 'ipv4 unicast base', 'lookup_topology'... |
a = True
b = False
if a == b:
print(1)
else:
print(0)
| a = True
b = False
if a == b:
print(1)
else:
print(0) |
#!/usr/bin/env python3
i = 1
for x in range(-10000, 10000):
for y in range(-10000, 10000):
if (abs(x)+abs(y)) < 100:
i += 1
print(i)
| i = 1
for x in range(-10000, 10000):
for y in range(-10000, 10000):
if abs(x) + abs(y) < 100:
i += 1
print(i) |
class BaseChild:
payload = {
"patient": {
"lastName": "Deeererederepwswdwewwdw",
"firstName": "Allakirillohldldwwwlflrereeeded",
"middleName": "Ballerffffff",
"birthDate": "2011-05-29",
"sex": True,
"isAutoPhone": True
},
... | class Basechild:
payload = {'patient': {'lastName': 'Deeererederepwswdwewwdw', 'firstName': 'Allakirillohldldwwwlflrereeeded', 'middleName': 'Ballerffffff', 'birthDate': '2011-05-29', 'sex': True, 'isAutoPhone': True}, 'linkType': '6'}
def __init__(self):
pass
def post_info(self, payload):
... |
# Write a dictionary or list to hdfs
best_params = {
"Key1": 123,
"Key2": "hello"
}
save_path = "hdfs://nameservice1/user/duc.nguyenv3/projects/01_lgbm_modeling/data/output/best_params.json"
sdf = (
spark
.sparkContext
.parallelize([best_params])
.toDF()
.coalesce(1)
... | best_params = {'Key1': 123, 'Key2': 'hello'}
save_path = 'hdfs://nameservice1/user/duc.nguyenv3/projects/01_lgbm_modeling/data/output/best_params.json'
sdf = spark.sparkContext.parallelize([best_params]).toDF().coalesce(1).write.mode('overwrite').json(save_path)
json_df = spark.read.json(save_path) |
'''
Title : sWAP cASE
Subdomain : Strings
Domain : Python
Author : Kalpak Seal
Created : 29 September 2016
'''
__author__ = 'Kalpak Seal'
inputString = raw_input()
finalString = ""
for i in range(0, len(inputString)):
currentChar = inputString[i]
if currentChar.islower() or currentChar... | """
Title : sWAP cASE
Subdomain : Strings
Domain : Python
Author : Kalpak Seal
Created : 29 September 2016
"""
__author__ = 'Kalpak Seal'
input_string = raw_input()
final_string = ''
for i in range(0, len(inputString)):
current_char = inputString[i]
if currentChar.islower() or currentChar.isupper():... |
class Singleton(object):
def __init__(self, func):
self._func = func
def Instance(self,*a,**k):
try:
return self._instance
except AttributeError:
self._instance = self._func(*a,**k)
return self._instance
def __call__(self):
raise TypeError(... | class Singleton(object):
def __init__(self, func):
self._func = func
def instance(self, *a, **k):
try:
return self._instance
except AttributeError:
self._instance = self._func(*a, **k)
return self._instance
def __call__(self):
raise type... |
#
# PySNMP MIB module BLUECOAT-AV-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/BLUECOAT-AV-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:22:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, value_size_constraint, single_value_constraint, constraints_intersection) ... |
class PartialFillHandlingEnum:
PARTIAL_FILL_UNSET = 0
PARTIAL_FILL_HANDLING_REDUCE_QUANTITY = 1
PARTIAL_FILL_HANDLING_IMMEDIATE_CANCEL = 2
| class Partialfillhandlingenum:
partial_fill_unset = 0
partial_fill_handling_reduce_quantity = 1
partial_fill_handling_immediate_cancel = 2 |
SKILL_SAMPLE_TYPES = (
("dc", "DC"),
("mod", "Modifier"),
)
| skill_sample_types = (('dc', 'DC'), ('mod', 'Modifier')) |
def emulate(instructions):
# did we already run a specific instruction?
previous = [False for _ in range(len(instructions))]
acc, i = 0, 0
while i < len(instructions):
# infinite loop detected
if previous[i]:
return None
previous[i] = True
instr, value = instructions[i]
... | def emulate(instructions):
previous = [False for _ in range(len(instructions))]
(acc, i) = (0, 0)
while i < len(instructions):
if previous[i]:
return None
previous[i] = True
(instr, value) = instructions[i]
if instr == 'acc':
acc += value
elif ... |
flowerpot_price = 4.00
flower_seeds_price = 1.00
soil_price = 5.00
tax_rate = 0.06
number_of_pots = int(input('How many flowerpots? '))
number_of_seeds = int(input('How many packs of seeds? '))
number_of_bags = int(input('How many bags of soil? '))
cost_of_items = (number_of_pots * flowerpot_price)
+ (number_of_seeds... | flowerpot_price = 4.0
flower_seeds_price = 1.0
soil_price = 5.0
tax_rate = 0.06
number_of_pots = int(input('How many flowerpots? '))
number_of_seeds = int(input('How many packs of seeds? '))
number_of_bags = int(input('How many bags of soil? '))
cost_of_items = number_of_pots * flowerpot_price
+(number_of_seeds * flowe... |
class Field:
cells = ()
def __init__(self, w, h):
print('Game Field Created!')
| class Field:
cells = ()
def __init__(self, w, h):
print('Game Field Created!') |
class Entry(object):
def __init__(self, record, value):
self.record = record
self.value = value
def __lt__(self, other):
# to make a max-heap
return self.value > other.value
def to_json(self):
return {"record": self.record.to_json(), "value": self.value}
| class Entry(object):
def __init__(self, record, value):
self.record = record
self.value = value
def __lt__(self, other):
return self.value > other.value
def to_json(self):
return {'record': self.record.to_json(), 'value': self.value} |
#
# PySNMP MIB module HUAWEI-TASK-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-TASK-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:37: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... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, single_value_constraint, constraints_union) ... |
# keyword param for the ProfileHandler
KEY_DATASET_OBJECT_ID = 'dataset_object_id'
KEY_SAVE_ROW_COUNT = 'save_row_count'
KEY_DATASET_IS_DJANGO_FILEFIELD = 'dataset_is_django_filefield'
KEY_DATASET_IS_FILEPATH = 'dataset_is_filepath'
VAR_TYPE_BOOLEAN = 'Boolean'
VAR_TYPE_CATEGORICAL = 'Categorical'
VAR_TYPE_NUMERICAL ... | key_dataset_object_id = 'dataset_object_id'
key_save_row_count = 'save_row_count'
key_dataset_is_django_filefield = 'dataset_is_django_filefield'
key_dataset_is_filepath = 'dataset_is_filepath'
var_type_boolean = 'Boolean'
var_type_categorical = 'Categorical'
var_type_numerical = 'Numerical'
var_type_integer = 'Integer... |
#! /usr/bin/env python3
# check if a word is palindromic without reversing it
def isPalindrome(word):
end = len(word)
start = 0
retval = True
while start < end+1:
left = word[start]
right = word[end-1]
if left != right:
retval = False
break
start... | def is_palindrome(word):
end = len(word)
start = 0
retval = True
while start < end + 1:
left = word[start]
right = word[end - 1]
if left != right:
retval = False
break
start += 1
end -= 1
return retval
print(is_palindrome('wwaabbaawwz')... |
class Pessoa:
olhos = 2
def __init__(self, *filhos, nome=None, idade=46):
self.idade = idade
self.nome = nome
self.filhos = list(filhos)
def cumprimentar(self):
return f'Ola {id(self)}'
if __name__ == '__main__':
nilton = Pessoa(nome='Nilton')
roberto = Pessoa(nil... | class Pessoa:
olhos = 2
def __init__(self, *filhos, nome=None, idade=46):
self.idade = idade
self.nome = nome
self.filhos = list(filhos)
def cumprimentar(self):
return f'Ola {id(self)}'
if __name__ == '__main__':
nilton = pessoa(nome='Nilton')
roberto = pessoa(nilto... |
AIRTABLE_EXPORT_JOB_DOWNLOADING_PENDING = "pending"
AIRTABLE_EXPORT_JOB_DOWNLOADING_FAILED = "failed"
AIRTABLE_EXPORT_JOB_DOWNLOADING_FINISHED = "finished"
AIRTABLE_EXPORT_JOB_DOWNLOADING_BASE = "downloading-base"
AIRTABLE_EXPORT_JOB_CONVERTING = "converting"
AIRTABLE_EXPORT_JOB_DOWNLOADING_FILES = "downloading-files"
... | airtable_export_job_downloading_pending = 'pending'
airtable_export_job_downloading_failed = 'failed'
airtable_export_job_downloading_finished = 'finished'
airtable_export_job_downloading_base = 'downloading-base'
airtable_export_job_converting = 'converting'
airtable_export_job_downloading_files = 'downloading-files'
... |
print("Rathinn")
print("AM.EN.U4AIE19052")
print("AIE")
print("Anime Rocks")
| print('Rathinn')
print('AM.EN.U4AIE19052')
print('AIE')
print('Anime Rocks') |
# Backtracking
class Solution:
def combinationSum(self, candidates: List[int], target: int) -> List[List[int]]:
if not candidates:
return
candidates.sort()
paths = []
results = []
index = 0
cursum = 0
# paths, results,... | class Solution:
def combination_sum(self, candidates: List[int], target: int) -> List[List[int]]:
if not candidates:
return
candidates.sort()
paths = []
results = []
index = 0
cursum = 0
self.dfs(paths, results, index, candidates, cursum, target)
... |
# final
def sum_of_args(args):
result = 0
for i in args:
result += i
return result
print(sum_of_args(args=[1,2,3,4]))
| def sum_of_args(args):
result = 0
for i in args:
result += i
return result
print(sum_of_args(args=[1, 2, 3, 4])) |
'''
https://leetcode.com/contest/weekly-contest-182/problems/find-lucky-integer-in-an-array/
'''
class Solution:
def findLucky(self, arr: List[int]) -> int:
for a in sorted(arr)[::-1]:
if a == arr.count(a):
return a
return -1
| """
https://leetcode.com/contest/weekly-contest-182/problems/find-lucky-integer-in-an-array/
"""
class Solution:
def find_lucky(self, arr: List[int]) -> int:
for a in sorted(arr)[::-1]:
if a == arr.count(a):
return a
return -1 |
####Use the loop 'while'
# input a and b
a = int(input())
b = int(input())
if a > b :
print('it is not the total')
else :
i = a
total = 0
while i <= b :
total += i
i += 1
print(total) | a = int(input())
b = int(input())
if a > b:
print('it is not the total')
else:
i = a
total = 0
while i <= b:
total += i
i += 1
print(total) |
# Write your solution for 1.3 here!
x=0
i=0
while x<10000:
i+=1
x+=i
print(i)
| x = 0
i = 0
while x < 10000:
i += 1
x += i
print(i) |
tile_size = 25
# size of tiles in the board
screen_width = 400
# width of the screen
screen_height = 400
# height of the screen
| tile_size = 25
screen_width = 400
screen_height = 400 |
class Queue:
def __init__(self,list = None):
if list == None:
self.item =[]
else :
self.item = list
def enQueue(self,i):
self.item.append(i)
def size(self):
return len(self.item)
def isEmpty(self):
return len(self.item)==0
def deQueue... | class Queue:
def __init__(self, list=None):
if list == None:
self.item = []
else:
self.item = list
def en_queue(self, i):
self.item.append(i)
def size(self):
return len(self.item)
def is_empty(self):
return len(self.item) == 0
def ... |
def test_signup_new_account(app):
username = "user1"
password = "test"
app.james.ensure_user_exists(username, password) | def test_signup_new_account(app):
username = 'user1'
password = 'test'
app.james.ensure_user_exists(username, password) |
list_var = [1, 2]
dict_var = {
"key1": "value1"
}
setVar = {1, 2, 3} | list_var = [1, 2]
dict_var = {'key1': 'value1'}
set_var = {1, 2, 3} |
n = int(input())
cnt1, cnt2 = {}, {}
for i in range(n):
x, y = map(int, input().split())
cnt1[x+y] = cnt1.get(x+y, 0) + 1
cnt2[x-y] = cnt2.get(x-y, 0) + 1
ans = 0
for t in cnt1.values():
ans += t*(t-1)//2
for t in cnt2.values():
ans += t*(t-1)//2
print(ans)
| n = int(input())
(cnt1, cnt2) = ({}, {})
for i in range(n):
(x, y) = map(int, input().split())
cnt1[x + y] = cnt1.get(x + y, 0) + 1
cnt2[x - y] = cnt2.get(x - y, 0) + 1
ans = 0
for t in cnt1.values():
ans += t * (t - 1) // 2
for t in cnt2.values():
ans += t * (t - 1) // 2
print(ans) |
def valid_oci_group(parser):
add_oci_group(parser)
def add_oci_group(parser):
oci_group = parser.add_argument_group(title="OCI arguments")
oci_group.add_argument("--oci-profile-name", default="")
oci_group.add_argument("--oci-profile-compartment-id", default="")
# HACK to extract the set provider... | def valid_oci_group(parser):
add_oci_group(parser)
def add_oci_group(parser):
oci_group = parser.add_argument_group(title='OCI arguments')
oci_group.add_argument('--oci-profile-name', default='')
oci_group.add_argument('--oci-profile-compartment-id', default='')
oci_group.add_argument('--oci', acti... |
class Card:
def __repr__(self):
return str((self.name, self.rules, self.value))
class Batman(Card):
def __init__(self):
self.name = 'Batman'
self.value = 1
self.rules = "Guess a player's hand"
self.action = 'guess'
class Catwoman(Card):
def __init__(self):
... | class Card:
def __repr__(self):
return str((self.name, self.rules, self.value))
class Batman(Card):
def __init__(self):
self.name = 'Batman'
self.value = 1
self.rules = "Guess a player's hand"
self.action = 'guess'
class Catwoman(Card):
def __init__(self):
... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def inorderSuccessor(self, root: 'TreeNode', p: 'TreeNode') -> 'TreeNode':
'''
in-order traversal
'''
sel... | class Solution:
def inorder_successor(self, root: 'TreeNode', p: 'TreeNode') -> 'TreeNode':
"""
in-order traversal
"""
self.found = False
def inorder(node, target):
if not node:
return
if node.left:
l = inorder(node.le... |
db_host_name="127.0.0.1"
db_name="TestDB"
db_user="testuser"
db_password="test123"
db_table_name="brady"
| db_host_name = '127.0.0.1'
db_name = 'TestDB'
db_user = 'testuser'
db_password = 'test123'
db_table_name = 'brady' |
'''
Created on 13 Jun 2016
@author: a
'''
class InvalidPasswords():
BAD_PASSWORDS = ['1234567890','qwertyuiop','123456789','password1','photoshop',
'11111111','12345678','1qaz2wsx','access14','adobe123','baseball',
'bigdaddy','butthead','cocacola','comp... | """
Created on 13 Jun 2016
@author: a
"""
class Invalidpasswords:
bad_passwords = ['1234567890', 'qwertyuiop', '123456789', 'password1', 'photoshop', '11111111', '12345678', '1qaz2wsx', 'access14', 'adobe123', 'baseball', 'bigdaddy', 'butthead', 'cocacola', 'computer', 'corvette', 'danielle', 'dolphins', 'einstei... |
# None datatype
a = None
print(a)
# Numeric datatype (int,float,complex,bool)
b = 4
print(type(b))
c = 2.5
print(type(c))
d = 4 + 5j
print(type(d))
bool = b > c
print(type(bool))
e = int(c)
print(e)
f = complex(e, b)
print(f)
print(int(True))
# List datatype
lst = [1, 2, 3, 4, 5]
print(lst)
# Set datatype
s = {4, 8,... | a = None
print(a)
b = 4
print(type(b))
c = 2.5
print(type(c))
d = 4 + 5j
print(type(d))
bool = b > c
print(type(bool))
e = int(c)
print(e)
f = complex(e, b)
print(f)
print(int(True))
lst = [1, 2, 3, 4, 5]
print(lst)
s = {4, 8, 2, 1, 6, 3}
print(s)
tup = (10, 20, 50, 40, 30)
print(tup)
str = 'Sunny'
print(str)
k = list(... |
# this menu.py only installs the SetLoop examples.
# get script location (necessaary for loading toolsets)
dirName = os.path.dirname( os.path.abspath(__file__)).replace('\\', '/')
# get node toolbar
nodes = nuke.menu('Nodes')
# make group entry for examples in toolsets menu
group = nodes.addMenu('ToolSets/SetLoop... | dir_name = os.path.dirname(os.path.abspath(__file__)).replace('\\', '/')
nodes = nuke.menu('Nodes')
group = nodes.addMenu('ToolSets/SetLoop Examples', index=2)
def add_example(fileName, toolSetName):
group.addCommand('(' + toolSetName + ') ' + fileName, "nuke.loadToolset('" + dirName + '/' + fileName + ".nk')", ic... |
_base_ = ["./FlowNet512_1.5AugCosyAAEGray_Flat_Pbr_01_ape.py"]
OUTPUT_DIR = "output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_Flat_lmPbr_SO/camera"
DATASETS = dict(TRAIN=("lm_pbr_camera_train",), TEST=("lm_real_camera_test",))
# bbnc7
# objects camera Avg(1)
# ad_2 26.86 26.86
# ad_5 84.41 84.41
# a... | _base_ = ['./FlowNet512_1.5AugCosyAAEGray_Flat_Pbr_01_ape.py']
output_dir = 'output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_Flat_lmPbr_SO/camera'
datasets = dict(TRAIN=('lm_pbr_camera_train',), TEST=('lm_real_camera_test',)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.