content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
{
"targets": [
{
"include_dirs": [
"<!(node -e \"require('nan')\")"
],
"cflags_cc": [
"-O2"
],
"libraries": [
],
"target_name": "addon",
"sources": [
... | {'targets': [{'include_dirs': ['<!(node -e "require(\'nan\')")'], 'cflags_cc': ['-O2'], 'libraries': [], 'target_name': 'addon', 'sources': ['./src/native/main.cpp', './src/native/deviceinfo.cpp', './src/native/devicecontrol.cpp', './src/native/ipforward_entry.cpp', './src/native/create_device_file.cpp', './src/native/... |
class Rect(object):
def __init__(self, *args):
try:
if len(args) == 4:
self.x, self.y, self.w, self.h = args
elif len(args) == 2:
self.x, self.y = args[0]
self.w, self.h = args[1]
else:
raise Exception()
... | class Rect(object):
def __init__(self, *args):
try:
if len(args) == 4:
(self.x, self.y, self.w, self.h) = args
elif len(args) == 2:
(self.x, self.y) = args[0]
(self.w, self.h) = args[1]
else:
raise exception... |
def Solve(board):
board.Draw()
find = Find_Empty(board)
if not find:
return True
else:
row, col = find
for i in range(1, 10):
if Valid(board, i, (row, col)):
board.Get_Board()[row][col] = i
if Solve(board):
return True
bo... | def solve(board):
board.Draw()
find = find__empty(board)
if not find:
return True
else:
(row, col) = find
for i in range(1, 10):
if valid(board, i, (row, col)):
board.Get_Board()[row][col] = i
if solve(board):
return True
bo... |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '|\x03\xc9\x8fL\xea\xa0\xa2`v\xc7\xe5\xf6L\xd3\xd2'
_lr_action_items = {'NUMBER':([3,8,12,15,33,35,39,40,43,50,52,54,55,56,57,58,63,64,65,67,68,69,71,73,74,76,77,78,79,80,81,82,83,84,85,86,... | _tabversion = '3.2'
_lr_method = 'LALR'
_lr_signature = '|\x03É\x8fLê\xa0¢`vÇåöLÓÒ'
_lr_action_items = {'NUMBER': ([3, 8, 12, 15, 33, 35, 39, 40, 43, 50, 52, 54, 55, 56, 57, 58, 63, 64, 65, 67, 68, 69, 71, 73, 74, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 96, 98, 100, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130,... |
def solution(A):
counter = {}
for num in range(1,len(A)+1):
counter[num] = 0
for num in A:
if num in counter:
counter[num] += 1
if counter[num] > 1:
return 0
else:
return 0
return 1
A = [4, 1, 3, 2]
solution(A)
| def solution(A):
counter = {}
for num in range(1, len(A) + 1):
counter[num] = 0
for num in A:
if num in counter:
counter[num] += 1
if counter[num] > 1:
return 0
else:
return 0
return 1
a = [4, 1, 3, 2]
solution(A) |
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'test_db',
'USER':'postgres',
'PASSWORD': 'Cat.iquality@gmail.com',
'HOST': '127.0.0.1',
'PORT': '5432'
}
} | databases = {'default': {'ENGINE': 'django.db.backends.postgresql', 'NAME': 'test_db', 'USER': 'postgres', 'PASSWORD': 'Cat.iquality@gmail.com', 'HOST': '127.0.0.1', 'PORT': '5432'}} |
MAIN_SECTOR = [
'Government',
'Private',
'NGO',
'Entrepreneur',
'Farmer',
'Student',
'Other',
]
SUBSECTOR = [
'Central Government',
'IAS',
'IPS',
'IFoS',
'Other UPSC Services',
'ICAR',
'State-Agriculture',
'State-Forestry',
'State-Revenue',
'State-Pol... | main_sector = ['Government', 'Private', 'NGO', 'Entrepreneur', 'Farmer', 'Student', 'Other']
subsector = ['Central Government', 'IAS', 'IPS', 'IFoS', 'Other UPSC Services', 'ICAR', 'State-Agriculture', 'State-Forestry', 'State-Revenue', 'State-Police', 'State-Cooperatives', 'State-Corporations', 'State-Other bodies', '... |
#
# PySNMP MIB module COM21-HCXVOICE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/COM21-HCXVOICE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:26:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ... |
GET = 'GET'
POST = 'POST'
PUT = 'PUT'
DELETE = 'DELETE'
| get = 'GET'
post = 'POST'
put = 'PUT'
delete = 'DELETE' |
SETTING_FILENAME = 'filename'
SETTING_RECENT_FILES = 'recentFiles'
SETTING_WIN_SIZE = 'window/size'
SETTING_WIN_POSE = 'window/position'
SETTING_WIN_GEOMETRY = 'window/geometry'
SETTING_LINE_COLOR = 'line/color'
SETTING_FILL_COLOR = 'fill/color'
SETTING_ADVANCE_MODE = 'advanced'
SETTING_WIN_STATE = 'window/state'
SETTI... | setting_filename = 'filename'
setting_recent_files = 'recentFiles'
setting_win_size = 'window/size'
setting_win_pose = 'window/position'
setting_win_geometry = 'window/geometry'
setting_line_color = 'line/color'
setting_fill_color = 'fill/color'
setting_advance_mode = 'advanced'
setting_win_state = 'window/state'
setti... |
# Source and destination file names.
test_source = "data/math.txt"
test_destination = "math_output_latex.html"
# Keyword parameters passed to publish_file.
reader_name = "standalone"
parser_name = "rst"
writer_name = "html"
# Settings
settings_overrides['math_output'] = 'latex'
# local copy of default stylesheet:
set... | test_source = 'data/math.txt'
test_destination = 'math_output_latex.html'
reader_name = 'standalone'
parser_name = 'rst'
writer_name = 'html'
settings_overrides['math_output'] = 'latex'
settings_overrides['stylesheet_path'] = 'functional/input/data/html4css1.css' |
A,B,C= input().split()
if (A==B) and (B==C):
print('Yes')
else:
print('No')
| (a, b, c) = input().split()
if A == B and B == C:
print('Yes')
else:
print('No') |
def escreva(msg):
print('^' * (len(msg) + 4))
print(f' {msg}')
print('^' * (len(msg) + 4))
escreva('oii') | def escreva(msg):
print('^' * (len(msg) + 4))
print(f' {msg}')
print('^' * (len(msg) + 4))
escreva('oii') |
# x and y store the position of the ellipse
x = 0
y = 0
# the x and y speed of the ellipse
x_speed = 5
y_speed = 5
# the dimensions of the ellipse
ellipse_width = 100
ellipse_height = 50
# setup gets called once
def setup():
# the global keyword must be used as x and y are getting changed and they are global var... | x = 0
y = 0
x_speed = 5
y_speed = 5
ellipse_width = 100
ellipse_height = 50
def setup():
global x, y
size(1280, 720)
x = width / 2
y = height / 2
def draw():
global x, y
background(0)
no_stroke()
ellipse(x, y, ellipse_width, ellipse_height)
check_edges()
x += x_speed
y += y... |
print('Ingrese:')
cadena=input()
cadena=cadena.split(' ')
terminales=['void','int','float','a','{','}','(',')','return','instrucciones']
no_terminales=['S','TipoDato','Identificador','Letra','RestoLetra','Retorno','$']
tabla = {"S":{"void":["void","Identificador","(",")","{","instrucciones","}"],
"int":["T... | print('Ingrese:')
cadena = input()
cadena = cadena.split(' ')
terminales = ['void', 'int', 'float', 'a', '{', '}', '(', ')', 'return', 'instrucciones']
no_terminales = ['S', 'TipoDato', 'Identificador', 'Letra', 'RestoLetra', 'Retorno', '$']
tabla = {'S': {'void': ['void', 'Identificador', '(', ')', '{', 'instrucciones... |
def saddle_points(m):
if len(m) == 0:
return set()
if any(len(m[0]) != len(m[i]) for i in range(1, len(m))):
raise ValueError('irregular matrix')
rowMaxs = [sorted(r, reverse=True)[0] for r in m]
colMins = [sorted(c)[0] for c in
[[m[r][c] for r in
r... | def saddle_points(m):
if len(m) == 0:
return set()
if any((len(m[0]) != len(m[i]) for i in range(1, len(m)))):
raise value_error('irregular matrix')
row_maxs = [sorted(r, reverse=True)[0] for r in m]
col_mins = [sorted(c)[0] for c in [[m[r][c] for r in range(len(m))] for c in range(len(m... |
# for @security_policy @playready @security_level
SECURITY_LEVEL = (150, 2000, 3000)
LEVEL_150 = SECURITY_LEVEL[0] # 'LEVEL_150',
LEVEL_2000 = SECURITY_LEVEL[1] # 'LEVEL_2000'
LEVEL_3000 = SECURITY_LEVEL[2] # 'LEVEL_3000'
def check(playready_security_level) -> bool:
return playready_security_level in SECURITY_... | security_level = (150, 2000, 3000)
level_150 = SECURITY_LEVEL[0]
level_2000 = SECURITY_LEVEL[1]
level_3000 = SECURITY_LEVEL[2]
def check(playready_security_level) -> bool:
return playready_security_level in SECURITY_LEVEL |
#!/usr/bin/python3
STATE = {
'running' : True,
'paused' : False,
'text' : False,
'explore' : True
}
TEXT = {
'file' : 'text_settings.txt',
'type' : 'dict',
'data' : {
'int' : {
'type' : 'int',
'data' : {
... | state = {'running': True, 'paused': False, 'text': False, 'explore': True}
text = {'file': 'text_settings.txt', 'type': 'dict', 'data': {'int': {'type': 'int', 'data': {'': 0}}, 'float': {'type': 'float', 'data': {'spd': 0.06, 'dly': 0.0}}, 'list': {'type': 'list', 'data': {'type': 'int', 'data': {'player_clr': [255, 2... |
# This sample tests for/else loops for cases where variables
# are potentially unbound.
# For with no break and no else.
def func1():
for x in []:
a = 0
# This should generate a "potentially unbound" error.
print(a)
# This should generate a "potentially unbound" error.
print(x)
# For w... | def func1():
for x in []:
a = 0
print(a)
print(x)
def func2():
for x in []:
a = 0
else:
b = 0
print(a)
print(b)
print(x)
def func3():
for x in []:
a = 0
break
else:
b = 0
print(a)
print(b)
print(x) |
class ConstraintError(Exception):
pass
class ValidationError(Exception):
pass
| class Constrainterror(Exception):
pass
class Validationerror(Exception):
pass |
# 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 search(self, node):
if not node:
return None
if not node.left and not node.... | class Solution:
def search(self, node):
if not node:
return None
if not node.left and (not node.right):
return node
ret = self.search(node.left)
if node.left:
node.left.right = node
node.left.left = node.right
node.left = None
... |
EXTRACTORS = {
"dlib-hog-face5": {"type": "dlib", "detector": "hog", "keypoints": "face5",},
"dlib-hog-face68": {"type": "dlib", "detector": "hog", "keypoints": "face68",},
"dlib-cnn-face5": {"type": "dlib", "detector": "cnn", "keypoints": "face5",},
"dlib-cnn-face68": {"type": "dlib", "detector": "cnn"... | extractors = {'dlib-hog-face5': {'type': 'dlib', 'detector': 'hog', 'keypoints': 'face5'}, 'dlib-hog-face68': {'type': 'dlib', 'detector': 'hog', 'keypoints': 'face68'}, 'dlib-cnn-face5': {'type': 'dlib', 'detector': 'cnn', 'keypoints': 'face5'}, 'dlib-cnn-face68': {'type': 'dlib', 'detector': 'cnn', 'keypoints': 'face... |
algorithm='ddpg'
env_class='Gym'
model_class='LowDim2x'
environment = {
'name': 'BipedalWalker-v2'
}
model = {
'state_size': 24,
'action_size': 4
}
agent = {
'action_size': 4,
'evaluation_only': True
}
train = {
'n_episodes': 10000,
'max_t': 2000,
'solve_score': 300.0
}
| algorithm = 'ddpg'
env_class = 'Gym'
model_class = 'LowDim2x'
environment = {'name': 'BipedalWalker-v2'}
model = {'state_size': 24, 'action_size': 4}
agent = {'action_size': 4, 'evaluation_only': True}
train = {'n_episodes': 10000, 'max_t': 2000, 'solve_score': 300.0} |
# Category description for the widget registry
NAME = "Wofry ESRF Extension"
DESCRIPTION = "Widgets for Wofry"
BACKGROUND = "#ada8a8"
ICON = "icons/esrf2.png"
PRIORITY = 14
| name = 'Wofry ESRF Extension'
description = 'Widgets for Wofry'
background = '#ada8a8'
icon = 'icons/esrf2.png'
priority = 14 |
# Enter your code here. Read input from STDIN. Print output to STDOUT
def isprime(x):
if x == 1: return False
elif x == 2: return True
else:
if x % 2 == 0:
return False
else:
bound = int(x**0.5)
for counter in range(3, bound+1, 2):
if x % c... | def isprime(x):
if x == 1:
return False
elif x == 2:
return True
elif x % 2 == 0:
return False
else:
bound = int(x ** 0.5)
for counter in range(3, bound + 1, 2):
if x % counter == 0:
return False
return True
size = int(input())
... |
# Let's use christmas date as an example
# Who doesn't like christmas? :)
# 2021-12-25
YYYY_MM_DD = "%Y-%m-%d"
# 25-12-2021
DD_MM_YYYY = "%d-%m-%Y"
# 12-25-2021
MM_DD_YYYY = "%m-%d-%Y"
# 12-2021
MM_YYYY = "%m-%Y"
# 2021-12
YYYY_MM = "%Y-%m"
# December 25, 2021
MONTH_SPACE_DD_COMA_SPACE_YYYY = "%B %d, %Y"
| yyyy_mm_dd = '%Y-%m-%d'
dd_mm_yyyy = '%d-%m-%Y'
mm_dd_yyyy = '%m-%d-%Y'
mm_yyyy = '%m-%Y'
yyyy_mm = '%Y-%m'
month_space_dd_coma_space_yyyy = '%B %d, %Y' |
NAME = 'drf-querystringfilter'
VERSION = __version__ = "2.1.0"
__author__ = 'sax'
| name = 'drf-querystringfilter'
version = __version__ = '2.1.0'
__author__ = 'sax' |
def main():
while True:
num = int(input())
print(num ** 2, flush = True)
if num < 0:
return
if __name__ == '__main__':
main()
| def main():
while True:
num = int(input())
print(num ** 2, flush=True)
if num < 0:
return
if __name__ == '__main__':
main() |
class Motor:
def __init__(self, cilindros, tipo='gasolina') -> None:
self.cilindros = cilindros
self.tipo = tipo
self.__temperatura = 0
def inyecta_gasolina(self, cantidad):
pass
| class Motor:
def __init__(self, cilindros, tipo='gasolina') -> None:
self.cilindros = cilindros
self.tipo = tipo
self.__temperatura = 0
def inyecta_gasolina(self, cantidad):
pass |
#encoding:utf-8
subreddit = 'gtaonline'
t_channel = '@redditgtaonline'
def send_post(submission, r2t):
return r2t.send_simple(submission)
| subreddit = 'gtaonline'
t_channel = '@redditgtaonline'
def send_post(submission, r2t):
return r2t.send_simple(submission) |
filename = 'programming.txt'
with open(filename, 'a') as file_object:
file_object.write("I also love finding meaning in large datasets.\n")
file_object.write("I love creating apps that can run in a browser.\n") | filename = 'programming.txt'
with open(filename, 'a') as file_object:
file_object.write('I also love finding meaning in large datasets.\n')
file_object.write('I love creating apps that can run in a browser.\n') |
class Model(object):
def predict(self, X, feature_names):
print(X)
return X
| class Model(object):
def predict(self, X, feature_names):
print(X)
return X |
def dErrors(X, y, y_hat):
DErrorsDx1 = [X[i][0]*(y[i]-y_hat[i]) for i in range(len(y))]
DErrorsDx2 = [X[i][1]*(y[i]-y_hat[i]) for i in range(len(y))]
DErrorsDb = [y[i]-y_hat[i] for i in range(len(y))]
return DErrorsDx1, DErrorsDx2, DErrorsDb
def gradientDescentStep(X, y, W, b, learn_rate = 0.01):
y... | def d_errors(X, y, y_hat):
d_errors_dx1 = [X[i][0] * (y[i] - y_hat[i]) for i in range(len(y))]
d_errors_dx2 = [X[i][1] * (y[i] - y_hat[i]) for i in range(len(y))]
d_errors_db = [y[i] - y_hat[i] for i in range(len(y))]
return (DErrorsDx1, DErrorsDx2, DErrorsDb)
def gradient_descent_step(X, y, W, b, lear... |
class Video:
def __init__(self, id: str, date: str, title: str):
self.id = id
self.date = date
self.title = title
def __members(self):
return (
self.id,
self.date,
self.title,
)
def __eq__(self, other) -> bool:
if type(oth... | class Video:
def __init__(self, id: str, date: str, title: str):
self.id = id
self.date = date
self.title = title
def __members(self):
return (self.id, self.date, self.title)
def __eq__(self, other) -> bool:
if type(other) is type(self):
return self.__m... |
class LogLevels:
def __init__(self):
self.__Load_Dict()
def __Load_Dict(self):
lines = []
with open("LogLevels.csv", 'r') as log_level_file:
for each_line in log_level_file:
each_line = each_line.replace('\n', '')
lines.append(each_line)
... | class Loglevels:
def __init__(self):
self.__Load_Dict()
def ___load__dict(self):
lines = []
with open('LogLevels.csv', 'r') as log_level_file:
for each_line in log_level_file:
each_line = each_line.replace('\n', '')
lines.append(each_line)
... |
while True:
line = input()
if line == "Stop":
break
print(line)
| while True:
line = input()
if line == 'Stop':
break
print(line) |
#
# Karl Keusgen
# 2020-09-23
#
UseJsonConfig = False
| use_json_config = False |
# 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 sumOfLeftLeaves(self, root: Optional[TreeNode]) -> int:
def s(node, isLeft=True):
if... | class Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def sum_of_left_leaves(self, root: Optional[TreeNode]) -> int:
def s(node, isLeft=True):
if not node:
return 0
... |
def main():
for tc in range(int(input())):
N, ans = int(input()), -1
for a in range(1,N//2):
b = (N*(2*a-N))//(2*(a-N))
c = N-a-b
if a+b+c==N and a*a+b*b==c*c:
ans = max(ans,a*b*c)
print(ans)
if __name__=="__main__":
main()
| def main():
for tc in range(int(input())):
(n, ans) = (int(input()), -1)
for a in range(1, N // 2):
b = N * (2 * a - N) // (2 * (a - N))
c = N - a - b
if a + b + c == N and a * a + b * b == c * c:
ans = max(ans, a * b * c)
print(ans)
if __n... |
# %% [8. String to Integer (atoi)](https://leetcode.com/problems/string-to-integer-atoi/)
class Solution:
def myAtoi(self, s: str) -> int:
try:
s = re.match(r"\+?-?[0-9]+", s.strip()).group()
return min(2147483647, max(-2147483648, int(s)))
except:
return 0
| class Solution:
def my_atoi(self, s: str) -> int:
try:
s = re.match('\\+?-?[0-9]+', s.strip()).group()
return min(2147483647, max(-2147483648, int(s)))
except:
return 0 |
# Succesfull
HTTP_200_OK: int = 200
# Client Error
HTTP_400_BAD_REQUEST: int = 400
HTTP_401_UNAUTHORIZED: int = 401
HTTP_403_FORBIDDEN: int = 403
HTTP_404_NOT_FOUND: int = 404
HTTP_405_METHOD_NOT_ALLOWED: int = 405
HTTP_409_CONFLICT: int = 409
HTTP_428_PRECONDITION_REQUIRED: int = 428
# Server Error
HTTP_500_INTERNAL... | http_200_ok: int = 200
http_400_bad_request: int = 400
http_401_unauthorized: int = 401
http_403_forbidden: int = 403
http_404_not_found: int = 404
http_405_method_not_allowed: int = 405
http_409_conflict: int = 409
http_428_precondition_required: int = 428
http_500_internal_server_error: int = 500
http_501_not_impleme... |
c, link = emk.module("c", "link")
link.depdirs += [
"$:proj:$"
]
| (c, link) = emk.module('c', 'link')
link.depdirs += ['$:proj:$'] |
adjoining = [(1, 0), (-1, 0), (0, 1), (0, -1)]
def compute_max_square(tiles):
def is_square(x, y, m):
for dx in range(m):
for dy in range(m):
uid = (x + dx, y + dy)
if uid not in tiles:
return False
return True
max_square = 0
... | adjoining = [(1, 0), (-1, 0), (0, 1), (0, -1)]
def compute_max_square(tiles):
def is_square(x, y, m):
for dx in range(m):
for dy in range(m):
uid = (x + dx, y + dy)
if uid not in tiles:
return False
return True
max_square = 0
... |
apis = {
'PhishTank': [
{
'name': 'PT_01',
'url': 'http://checkurl.phishtank.com/checkurl/',
'api_key': ''
}
],
'GoogleSafeBrowsing': [
{
'name': 'GSB_01',
'url': 'https://safebrowsing.googleapis.com/v4/threatMatches:find',
... | apis = {'PhishTank': [{'name': 'PT_01', 'url': 'http://checkurl.phishtank.com/checkurl/', 'api_key': ''}], 'GoogleSafeBrowsing': [{'name': 'GSB_01', 'url': 'https://safebrowsing.googleapis.com/v4/threatMatches:find', 'api_key': '', 'client': {'clientId': 'URL Checker', 'clientVersion': '1.0'}}], 'URLScan': [{'name': 'U... |
class WorkflowStatus:
ACTIVE = 'ACTIVE'
COMPLETED = 'COMPLETED'
FAILED = 'FAILED'
CANCELED = 'CANCELED'
TERMINATED = 'TERMINATED'
CONTINUED_AS_NEW = 'CONTINUED_AS_NEW'
TIMED_OUT = 'TIMED_OUT'
class RegistrationStatus:
REGISTERED = 'REGISTERED'
DEPRECATED = 'DEPRECATED'
| class Workflowstatus:
active = 'ACTIVE'
completed = 'COMPLETED'
failed = 'FAILED'
canceled = 'CANCELED'
terminated = 'TERMINATED'
continued_as_new = 'CONTINUED_AS_NEW'
timed_out = 'TIMED_OUT'
class Registrationstatus:
registered = 'REGISTERED'
deprecated = 'DEPRECATED' |
class Enemy:
hp = 200
def __init__(self, attack_low, attack_high):
self.attack_high = attack_high
self.attack_low = attack_low
def getAttackLow(self):
print("Low Attack", self.attack_low)
return self.attack_low
def getAttackHigh(self):
print("High Attack", sel... | class Enemy:
hp = 200
def __init__(self, attack_low, attack_high):
self.attack_high = attack_high
self.attack_low = attack_low
def get_attack_low(self):
print('Low Attack', self.attack_low)
return self.attack_low
def get_attack_high(self):
print('High Attack', ... |
def get_next_value(v):
v *= 252533
return v % 33554393
x = 1
y = 1
val = 20151125
while True:
if y == 1:
y = x + 1
x = 1
else:
x += 1
y -= 1
# print(x, y)
val = get_next_value(val)
if x == 3083 and y == 2978:
print(val)
break
| def get_next_value(v):
v *= 252533
return v % 33554393
x = 1
y = 1
val = 20151125
while True:
if y == 1:
y = x + 1
x = 1
else:
x += 1
y -= 1
val = get_next_value(val)
if x == 3083 and y == 2978:
print(val)
break |
class command_base :
def __init__(self):
self.talk = False
self.talkNum = 0 | class Command_Base:
def __init__(self):
self.talk = False
self.talkNum = 0 |
class Solution:
def maxScoreSightseeingPair(self, A: List[int]) -> int:
maxAi, result = 0, 0
# max Ai keeps track of best encountered till now A[i]+i.
# result keeps finding better results across all j's.
for j in range(len(A)):
result = max(maxAi+A[j]-j, result)
... | class Solution:
def max_score_sightseeing_pair(self, A: List[int]) -> int:
(max_ai, result) = (0, 0)
for j in range(len(A)):
result = max(maxAi + A[j] - j, result)
max_ai = max(maxAi, A[j] + j)
return result |
#!/usr/bin/env python
imagedir = parent + "/oiio-images"
command = rw_command (imagedir, "oiio.ico")
| imagedir = parent + '/oiio-images'
command = rw_command(imagedir, 'oiio.ico') |
triangle = '''75
95 64
17 47 82
18 35 87 10
20 04 82 47 65
19 01 23 75 03 34
88 02 77 73 07 63 67
99 65 04 28 06 16 70 92
41 41 26 56 83 40 80 70 33
41 48 72 33 47 32 37 16 94 29
53 71 44 65 25 43 91 52 97 51 14
70 11 33 28 77 73 17 78 39 68 17 57
91 71 52 38 17 14 91 43 58 50 27 29 48
63 66 04 68 89 53 67 30 73 16 69 ... | triangle = '75\n95 64\n17 47 82\n18 35 87 10\n20 04 82 47 65\n19 01 23 75 03 34\n88 02 77 73 07 63 67\n99 65 04 28 06 16 70 92\n41 41 26 56 83 40 80 70 33\n41 48 72 33 47 32 37 16 94 29\n53 71 44 65 25 43 91 52 97 51 14\n70 11 33 28 77 73 17 78 39 68 17 57\n91 71 52 38 17 14 91 43 58 50 27 29 48\n63 66 04 68 89 53 67 3... |
# possible cell states, bitwise-flags
CELL_MINE = 1
CELL_REVEALED = 2
CELL_FLAGGED = 4
CELL_HIDDEN = 8
CELL_EMPTY = 16
# Colours for numbered cells.
COLORS = {
1: 'blue',
2: 'green',
3: 'red',
4: 'dark-blue',
5: 'brown',
6: 'purple',
7: 'dark-green',
8: 'orange'
}
# [height, w... | cell_mine = 1
cell_revealed = 2
cell_flagged = 4
cell_hidden = 8
cell_empty = 16
colors = {1: 'blue', 2: 'green', 3: 'red', 4: 'dark-blue', 5: 'brown', 6: 'purple', 7: 'dark-green', 8: 'orange'}
difficulties = {'beginner': [9, 9, 10], 'intermediate': [16, 16, 40], 'advanced': [16, 30, 99]} |
n1 = "123"
print(n1.isdigit()) # -- ID1
n2 = "345 2"
print(n2.isdigit()) # -- ID2
n3 = "345 2b"
print(n3.isdigit()) # -- ID3
n4 = "\u0035"
print(n4.isdigit()) # -- ID4
n5 = "\u00BC"
print(n5)
print(n5.isdigit()) # -- ID5
n6 = "\u00B2343"
print(n6)
print(n6.isdigit()) # -- ID6
n7 = "8.9"
print(n7.isdigit(... | n1 = '123'
print(n1.isdigit())
n2 = '345 2'
print(n2.isdigit())
n3 = '345 2b'
print(n3.isdigit())
n4 = '5'
print(n4.isdigit())
n5 = '¼'
print(n5)
print(n5.isdigit())
n6 = '²343'
print(n6)
print(n6.isdigit())
n7 = '8.9'
print(n7.isdigit())
n8 = '123-456-975'
print(n8.isdigit()) |
expected_output = {
"ospf3-database-information": {
"ospf3-area-header": {"ospf-area": "0.0.0.0"},
"ospf3-database": [
{
"lsa-type": "Router",
"lsa-id": "0.0.0.0",
"advertising-router": "10.16.2.2",
"sequence-number": "0x800... | expected_output = {'ospf3-database-information': {'ospf3-area-header': {'ospf-area': '0.0.0.0'}, 'ospf3-database': [{'lsa-type': 'Router', 'lsa-id': '0.0.0.0', 'advertising-router': '10.16.2.2', 'sequence-number': '0x80000002', 'age': '491', 'checksum': '0x549c', 'lsa-length': '40', 'ospf3-router-lsa': {'bits': '0x0', ... |
names = ["Helder", "Fabia", "Linda", "Leonie", "Carina", "Ivan", "Lexy"]
# print(names[0])
# print(names[1])
# print(names[2])
# print(names[3])
# print(names[4])
# print(names[5])
# print(names[6])
#print all elements with position on the left
#ex:
# 0: Helder
# 1: Fabia ...
counter = 0
while counter < len(names):... | names = ['Helder', 'Fabia', 'Linda', 'Leonie', 'Carina', 'Ivan', 'Lexy']
counter = 0
while counter < len(names):
print('{}: {}'.format(counter + 1, names[counter]))
counter += 1 |
def stopTracking():
i01.headTracking.stopTracking()
i01.eyesTracking.stopTracking()
| def stop_tracking():
i01.headTracking.stopTracking()
i01.eyesTracking.stopTracking() |
def isInt(x):
return type(x) in (float, int) and int(x) == x
class CommChannel:
def __init__(self):
self.outbox = []
self.inbox = []
def put(self, update):
if len(update) > 0:
self.outbox.append(update)
def get(self):
inbox = self.inbox
self.inbox = []
return ... | def is_int(x):
return type(x) in (float, int) and int(x) == x
class Commchannel:
def __init__(self):
self.outbox = []
self.inbox = []
def put(self, update):
if len(update) > 0:
self.outbox.append(update)
def get(self):
inbox = self.inbox
self.inbox... |
class Solution :
def canPair(self, nums, k) :
n = len(nums)
if n % 2 != 0 :
return False
# Initialization of dictionary
count = [0] * k
# Filling the map
for i in range(n) :
count[nums[i]%k] += 1
#print(count)
... | class Solution:
def can_pair(self, nums, k):
n = len(nums)
if n % 2 != 0:
return False
count = [0] * k
for i in range(n):
count[nums[i] % k] += 1
if count[0] % 2 != 0 or (k % 2 == 0 and count[k // 2] % 2 != 0):
return False
limit =... |
class SingleReply:
def __init__(self, inviteeId, status):
self.inviteeId = inviteeId
self.status = status
class PartyReplyInfoBase:
def __init__(self, partyId, partyReplies):
self.partyId = partyId
self.replies = []
for oneReply in partyReplies:
self.rep... | class Singlereply:
def __init__(self, inviteeId, status):
self.inviteeId = inviteeId
self.status = status
class Partyreplyinfobase:
def __init__(self, partyId, partyReplies):
self.partyId = partyId
self.replies = []
for one_reply in partyReplies:
self.repli... |
class Solution:
# @param A : list of integers
# @return an integer
def findMinXor(self, nums):
nums.sort()
x = nums[0]
minimumXOR = 10**9
for i in range(1, len(nums)):
y = nums[i]
minimumXOR = min(minimumXOR, x^y)
x = y
return mi... | class Solution:
def find_min_xor(self, nums):
nums.sort()
x = nums[0]
minimum_xor = 10 ** 9
for i in range(1, len(nums)):
y = nums[i]
minimum_xor = min(minimumXOR, x ^ y)
x = y
return minimumXOR |
class UrlResources(object):
def __init__(self, domain, sandbox, version):
super(UrlResources, self).__init__()
self.domain = domain
self.sandbox = sandbox
self.version = version
def get_resource_url(self):
return self.get_resource_path().format(version=self.version)
... | class Urlresources(object):
def __init__(self, domain, sandbox, version):
super(UrlResources, self).__init__()
self.domain = domain
self.sandbox = sandbox
self.version = version
def get_resource_url(self):
return self.get_resource_path().format(version=self.version)
... |
# 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 isSameTree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool:
def preorderTraversal(ro... | class Solution:
def is_same_tree(self, p: Optional[TreeNode], q: Optional[TreeNode]) -> bool:
def preorder_traversal(root1, root2):
if not root1 and (not root2):
return True
elif not root1 or not root2 or root1.val != root2.val:
return False
... |
pkgname = "xinput"
pkgver = "1.6.3"
pkgrel = 0
build_style = "gnu_configure"
hostmakedepends = ["pkgconf"]
makedepends = [
"libxext-devel", "libxi-devel", "libxrandr-devel", "libxinerama-devel"
]
pkgdesc = "X input device configuration utility"
maintainer = "q66 <q66@chimera-linux.org>"
license = "MIT"
url = "https... | pkgname = 'xinput'
pkgver = '1.6.3'
pkgrel = 0
build_style = 'gnu_configure'
hostmakedepends = ['pkgconf']
makedepends = ['libxext-devel', 'libxi-devel', 'libxrandr-devel', 'libxinerama-devel']
pkgdesc = 'X input device configuration utility'
maintainer = 'q66 <q66@chimera-linux.org>'
license = 'MIT'
url = 'https://xor... |
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
n=target-nums[i]
rest_of_nums=nums[i+1:]
if n in rest_of_nums:
return[i,(rest_of_nums.index(n))+i+1]
| class Solution:
def two_sum(self, nums: List[int], target: int) -> List[int]:
for i in range(len(nums)):
n = target - nums[i]
rest_of_nums = nums[i + 1:]
if n in rest_of_nums:
return [i, rest_of_nums.index(n) + i + 1] |
class Request:
# trip: Trip
# rider: User
# pickup: Location
id: str
def __init__(self, rider, trip, pickup):
self.rider = rider
self.trip = trip
self.pickup = pickup
def accept(self):
self.trip.riders.append((self.rider, self.pickup))
def un_accept(self):
... | class Request:
id: str
def __init__(self, rider, trip, pickup):
self.rider = rider
self.trip = trip
self.pickup = pickup
def accept(self):
self.trip.riders.append((self.rider, self.pickup))
def un_accept(self):
if (self.rider, self.pickup) in self.trip.riders:
... |
radioData = [
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A10_73",
"HLC\Adaptive\9558L_L1024A30_230",... | radio_data = ['HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\9558L_L1024A10_73', 'HLC\\Adaptive\\95... |
fname = input('Enter a file name: ')
fhand = open(fname)
countAddr = dict()
for line in fhand:
if line.startswith('From '):
words = line.split()
#print(words)
countAddr[words[1]] = countAddr.get(words[1],0) + 1
print(countAddr)
| fname = input('Enter a file name: ')
fhand = open(fname)
count_addr = dict()
for line in fhand:
if line.startswith('From '):
words = line.split()
countAddr[words[1]] = countAddr.get(words[1], 0) + 1
print(countAddr) |
TOKEN = '1325729680:AAE3qwRzCXRukKJVvxM3VN_vsesEko6j4EI'
HEROKU = 'https://sauce-finder.herokuapp.com/'
BASE_TELEGRAM_URL = 'https://api.telegram.org/bot{}'.format(TOKEN)
WEBHOOK_ENDPOINT = '{}/webhook'.format(HEROKU)
TELEGRAM_INIT_WEBHOOK_URL = '{}/setWebhook?url={}'.format(BASE_TELEGRAM_URL, WEBHOOK_ENDPOINT)
TELEGRA... | token = '1325729680:AAE3qwRzCXRukKJVvxM3VN_vsesEko6j4EI'
heroku = 'https://sauce-finder.herokuapp.com/'
base_telegram_url = 'https://api.telegram.org/bot{}'.format(TOKEN)
webhook_endpoint = '{}/webhook'.format(HEROKU)
telegram_init_webhook_url = '{}/setWebhook?url={}'.format(BASE_TELEGRAM_URL, WEBHOOK_ENDPOINT)
telegra... |
# Shader Uniform
vs_uni = '''
uniform mat4 view_mat;
uniform float Z_Bias;
uniform float Z_Offset;
vec4 pos_view;
in vec3 pos;
in vec3 nrm;
void main()
{
pos_view = view_mat * vec4(pos+(nrm*Z_Offset), 1.0f);
pos_view.z = pos_view.z - Z_Bias / pos_view.z;
... | vs_uni = '\n uniform mat4 view_mat;\n uniform float Z_Bias;\n uniform float Z_Offset;\n\n vec4 pos_view;\n \n in vec3 pos;\n in vec3 nrm;\n\n\n\n void main()\n {\n pos_view = view_mat * vec4(pos+(nrm*Z_Offset), 1.0f);\n pos_view.z = pos_view.z - Z_Bias / pos_view.z; \n gl... |
##Looks like this piece of your code is in development, but this is a great place to think about using a for loop - for piece in range(32)...
## you'd need to have an array or other structure that holds the information that changes between iterations (i.e. piece1, piece1loc). I'd suggest using a dictionary
## as you ca... | piece1 = input('enter in piece abb')
piece1loc = input('enter in the order-coord of the piece (eg. 64 for h1, 32 for h5)')
print('Confirmation: You have inputted a', piece1, 'on order-coord', piece1loc)
piece2 = input('enter in piece abb')
piece2loc = input('enter in the order-coord of the piece (eg. 64 for h1, 32 for ... |
# This code solves the Levine Sequence
class LevineSequence:
def __init__(self):
self.start = ["2"]
self.split = ["2"]
self.result = ""
self.len = 0
self.path = r'./Levine_Sequence/results.txt'
def void(self):
self.start = self.split
self.split = []
... | class Levinesequence:
def __init__(self):
self.start = ['2']
self.split = ['2']
self.result = ''
self.len = 0
self.path = './Levine_Sequence/results.txt'
def void(self):
self.start = self.split
self.split = []
self.len = len(self.start)
def ... |
water_count = int(input("Write how many ml of water the coffee machine has: "))
milk_count = int(input("Write how many ml of milk the coffee machine has: "))
coffee_beans_count = int(
input("Write how many grams of coffee beans the coffee machine has: "))
number_of_drinks = int(input("Write how many cups of coffee ... | water_count = int(input('Write how many ml of water the coffee machine has: '))
milk_count = int(input('Write how many ml of milk the coffee machine has: '))
coffee_beans_count = int(input('Write how many grams of coffee beans the coffee machine has: '))
number_of_drinks = int(input('Write how many cups of coffee you w... |
# def make_hashs(word, sub_size):
# ret = set()
# current_hash = sum(ord(word[i]) * (i + 1) for i in range(sub_size))
# current_suma = sum(ord(word[i]) for i in range(sub_size))
# ret.add(current_hash)
# for initial_pos in range(1, len(word) - sub_size + 1):
# current_hash -= current_suma
... | while True:
n = int(input())
if N == 0:
break
words = tuple((input() for _ in range(N)))
min_ = 0
max_ = min((len(word) for word in words))
while True:
if min_ == max_:
break
sub_size = max(min_ + 1, min_ + (max_ - min_) // 2)
win = False
if an... |
N,S,R = map(int,input().split())
broken = list(map(int,input().split()))
plus = list(map(int,input().split()))
D = [1]*(N+1)
for i in broken:
D[i]-=1
for i in plus:
D[i]+=1
ans = 0
for i in range(1,N+1):
j = D[i]
if j >= 1:
continue
if D[i-1] >1:
D[i-1]-=1
elif i+1 < N + 1 an... | (n, s, r) = map(int, input().split())
broken = list(map(int, input().split()))
plus = list(map(int, input().split()))
d = [1] * (N + 1)
for i in broken:
D[i] -= 1
for i in plus:
D[i] += 1
ans = 0
for i in range(1, N + 1):
j = D[i]
if j >= 1:
continue
if D[i - 1] > 1:
D[i - 1] -= 1
... |
TELUGU_CORPORA = [
{'name':'telugu_text_wikisource',
'origin': 'https://github.com/cltk/telugu_text_wikisource.git',
'location':'remote',
'type':'text'},
]
| telugu_corpora = [{'name': 'telugu_text_wikisource', 'origin': 'https://github.com/cltk/telugu_text_wikisource.git', 'location': 'remote', 'type': 'text'}] |
# Address:
I2CBUS = 10 # /dev/i2c-1
EMC2301_ADDRESS = 0x2F # 8 bit version
# Register
CONF = 0x20 # Configuration
FAN_STAT = 0x24 # Fan Status
FAN_STALL = 0x25 # Fan Stall Status *
FAN_SPIN = 0x26 # Fan Spin Status *
DRIVE_FALL = 0x27... | i2_cbus = 10
emc2301_address = 47
conf = 32
fan_stat = 36
fan_stall = 37
fan_spin = 38
drive_fall = 39
fan_interrupt = 41
pwm_polarity = 42
pwm_output = 43
pwm_base = 45
fan_setting = 48
pwm_divide = 49
fan_conf1 = 50
fan_conf2 = 51
gain = 53
fan_spin_up = 54
fan_max_step = 55
fan_min_drive = 56
tach_count = 57
fan_fai... |
def gauss(X):
n = len(X)
x = [0]*n
for i in range(n):
if X[i][i] == 0.0:
return "Sorry can't excute"
for j in range(i+1,n):
rat = X[j][i]/X[i][i]
for k in range(n+1):
X[j][k] = X[j][k] - rat*X[i][k]
print(X)
x[n-1] = X[n-1][n]/X[n-... | def gauss(X):
n = len(X)
x = [0] * n
for i in range(n):
if X[i][i] == 0.0:
return "Sorry can't excute"
for j in range(i + 1, n):
rat = X[j][i] / X[i][i]
for k in range(n + 1):
X[j][k] = X[j][k] - rat * X[i][k]
print(X)
x[n - 1] = X[... |
def factorial_division(num1, num2):
sum = 1
sum2 = 1
for num in range(num1, 0, -1):
sum = sum * num
for num in range(num2, 0, -1):
sum2 = sum2 * num
result = sum / sum2
return result
num1 = int(input())
num2 = int(input())
print(f"{factorial_division(num1, num2):.2f}") | def factorial_division(num1, num2):
sum = 1
sum2 = 1
for num in range(num1, 0, -1):
sum = sum * num
for num in range(num2, 0, -1):
sum2 = sum2 * num
result = sum / sum2
return result
num1 = int(input())
num2 = int(input())
print(f'{factorial_division(num1, num2):.2f}') |
version = "1.0"
def getVersion():
return version
| version = '1.0'
def get_version():
return version |
dyn.baseball.pos[0] = 16.0
dyn.baseball.pos[1] = 0.1
dyn.baseball.pos[2] = 2.0
dyn.baseball.vel[0] = -30.0
dyn.baseball.vel[1] = -0.1
dyn.baseball.vel[2] = 1.0
dyn.baseball.theta = trick.attach_units("degree",-90.0)
dyn.baseball.phi = trick.attach_units("degree",1.0)
dyn.baseball.omega0 = trick.attach_units("revoluti... | dyn.baseball.pos[0] = 16.0
dyn.baseball.pos[1] = 0.1
dyn.baseball.pos[2] = 2.0
dyn.baseball.vel[0] = -30.0
dyn.baseball.vel[1] = -0.1
dyn.baseball.vel[2] = 1.0
dyn.baseball.theta = trick.attach_units('degree', -90.0)
dyn.baseball.phi = trick.attach_units('degree', 1.0)
dyn.baseball.omega0 = trick.attach_units('revoluti... |
# zip(*(('white', 'small'), ('red', 'big')))
colors, sizes = zip(*(('white', 'small'), ('red', 'big')))
print(colors)
print(sizes)
| (colors, sizes) = zip(*(('white', 'small'), ('red', 'big')))
print(colors)
print(sizes) |
class TestModel(object):
@staticmethod
def train(x):
# y = np.sin(3 * x[0]) * 4 * (x[0] - 1) * (x[0] + 2)
res = 0
for i in range(100000000):
res += i
y = sum(x * x)
return y
| class Testmodel(object):
@staticmethod
def train(x):
res = 0
for i in range(100000000):
res += i
y = sum(x * x)
return y |
m = 0
def findMedian(a, b ,c):
if a > b:
if a < c:
return a
elif b > c:
return b
else:
return c
else:
if a > c:
return a
elif b < c:
return b
else:
return c
def partition(A, l, r):
p =... | m = 0
def find_median(a, b, c):
if a > b:
if a < c:
return a
elif b > c:
return b
else:
return c
elif a > c:
return a
elif b < c:
return b
else:
return c
def partition(A, l, r):
p = A[l]
i = l + 1
for j in ... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2014, Trond Hindenes <trond@hindenes.com>
# Copyright: (c) 2018, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
# this is a windows documentation stub. actual code lives in the .ps1
# file of the ... | ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
documentation = '\n---\nmodule: win_chocolatey\nversion_added: "1.9"\nshort_description: Manage packages using chocolatey\ndescription:\n- Manage packages using Chocolatey (U(http://chocolatey.org/)).\n- If Chocolatey is ... |
# Approach :
# Divide the linked list to two halved
# First half is head and the remaining as rest
# The head points to the rest in a normal linked list
# In the reverse linked list , the next of current points to the prev node and the head node should point to NULL
# Keep continuing this process till the last node ... | class Solution:
def reverse_list(self, head):
if head is None or head.next is None:
return head
rest = self.reverseList(head.next)
head.next.next = head
head.next = None
return rest |
class arithmetic:
def __init__(self):
pass
def add(self, x: int, y: int) -> int:
return x + y
def sub(self, x: int, y: int) -> int:
return x - y
def mul(self, x: int, y: int) -> int:
return x * y
def div(self, x: int, y: int) -> float:
... | class Arithmetic:
def __init__(self):
pass
def add(self, x: int, y: int) -> int:
return x + y
def sub(self, x: int, y: int) -> int:
return x - y
def mul(self, x: int, y: int) -> int:
return x * y
def div(self, x: int, y: int) -> float:
return x / y |
Bag=[]
#Luggage Bag
Bag.append('Waterbottle')
Bag.append('Milk')
Bag.append('Clothes')
Bag.append('Books')
#Removing milk from the bag
Bag.remove('Milk')
print(Bag)
| bag = []
Bag.append('Waterbottle')
Bag.append('Milk')
Bag.append('Clothes')
Bag.append('Books')
Bag.remove('Milk')
print(Bag) |
#!/usr/bin/env python
def start(agent) -> None:
try:
next_step = next(agent)
try:
next_step(agent)
except TypeError:
msg = "Returned generator not a function, did you use yield from?"
raise TypeError(msg)
except StopIteration:
pass
| def start(agent) -> None:
try:
next_step = next(agent)
try:
next_step(agent)
except TypeError:
msg = 'Returned generator not a function, did you use yield from?'
raise type_error(msg)
except StopIteration:
pass |
#inserta strings en una lista
texto = input("Ingrese un string: ")
no_olvidar = texto.split(",") #la coma seria el separador
no_olvidar.sort() #Para ordenar la lista de menor a mayor (en orden alfabetico)
print(no_olvidar)
| texto = input('Ingrese un string: ')
no_olvidar = texto.split(',')
no_olvidar.sort()
print(no_olvidar) |
#!/usr/bin/env python3
#encoding=utf-8
#-----------------------------------------------
# Usage: python3 3-desc-computed.py
# Description: computed attribute with attribute descriptor
#-----------------------------------------------
# Implementation 1
class DescSquare:
def __init__(self, start):
self.va... | class Descsquare:
def __init__(self, start):
self.value = start
def __get__(self, instance, owner):
print('Descriptor DescSquare __get__ method...')
return self.value ** 2
def __set__(self, instance, value):
print('Descriptor DescSquare __set__ method...')
self.val... |
class Invoice:
def __init__(self, bill_to, date):
self.bill_to = bill_to
self.date = date
self.invoice_items = []
self.invoice_total = 0
def add_invoice_item(self, invoice_item):
'''
Write the code to append an invoice_item to the self.invoice_items list
... | class Invoice:
def __init__(self, bill_to, date):
self.bill_to = bill_to
self.date = date
self.invoice_items = []
self.invoice_total = 0
def add_invoice_item(self, invoice_item):
"""
Write the code to append an invoice_item to the self.invoice_items list
... |
# -*- coding: utf-8 -*-
DESC = "emr-2019-01-03"
INFO = {
"ScaleOutInstance": {
"params": [
{
"name": "TimeUnit",
"desc": "Time unit of scale-out. Valid values:\n<li>s: seconds. When `PayMode` is 0, `TimeUnit` can only be `s`.</li>\n<li>m: month. When `PayMode` is 1, `TimeUnit` can only be `m... | desc = 'emr-2019-01-03'
info = {'ScaleOutInstance': {'params': [{'name': 'TimeUnit', 'desc': 'Time unit of scale-out. Valid values:\n<li>s: seconds. When `PayMode` is 0, `TimeUnit` can only be `s`.</li>\n<li>m: month. When `PayMode` is 1, `TimeUnit` can only be `m`.</li>'}, {'name': 'TimeSpan', 'desc': 'Duration of sca... |
neutral_site_fields = ['Azteca Stadium', 'Estadio Azteca', 'Tottenham Hotspur',
'Tottenham Hotspur Stadium', 'Twickenham', 'Twickenham Stadium', 'Wembley',
'Wembley Stadium']
standardized_field_names = {
'Arrowhead Stadium': 'Arrowhead Stadium',
'AT&T': 'AT&T Stadium',
'AT&T Stadium': 'AT&T Stadium',
'Ba... | neutral_site_fields = ['Azteca Stadium', 'Estadio Azteca', 'Tottenham Hotspur', 'Tottenham Hotspur Stadium', 'Twickenham', 'Twickenham Stadium', 'Wembley', 'Wembley Stadium']
standardized_field_names = {'Arrowhead Stadium': 'Arrowhead Stadium', 'AT&T': 'AT&T Stadium', 'AT&T Stadium': 'AT&T Stadium', 'Bank of America': ... |
privKey = ""
with open ('privKey.txt', 'rt') as myfile: # Open file lorem.txt for reading text
for myline in myfile: # For each line, read it to a string
print(myline)
if myline == "Your ETH privkey derived from seed:":
print(myline) #Doesnt do anything, just holds that line
... | priv_key = ''
with open('privKey.txt', 'rt') as myfile:
for myline in myfile:
print(myline)
if myline == 'Your ETH privkey derived from seed:':
print(myline)
else:
priv_key = myline
print(privKey)
f = open('privKey.txt', 'w')
f.write(privKey)
f.close() |
class MinisyncError(Exception):
pass
class PermissionError(MinisyncError):
pass
| class Minisyncerror(Exception):
pass
class Permissionerror(MinisyncError):
pass |
def result(x1, y1, x2, y2):
num_list = [x1, y1, x2, y2]
for _ in range(2):
num_list.remove(max(num_list))
f = num_list[0]
g = num_list[1]
print(f"({f}, {g})")
print(f"({', '.join(num_list)})")
a = int(input())
b = int(input())
c = int(input())
d = int(input())
result(a, b, c, d)
| def result(x1, y1, x2, y2):
num_list = [x1, y1, x2, y2]
for _ in range(2):
num_list.remove(max(num_list))
f = num_list[0]
g = num_list[1]
print(f'({f}, {g})')
print(f"({', '.join(num_list)})")
a = int(input())
b = int(input())
c = int(input())
d = int(input())
result(a, b, c, d) |
class Number:
def __init__(self, num):
self.num = num
def __add__(self, num2):
print("Lets add")
return self.num + num2.num
def __mul__(self, num2):
print("Lets multiply")
return self.num * num2.num
n1 = Number(4)
n2 = Number(6)
sum = n1 + n2
mul = n... | class Number:
def __init__(self, num):
self.num = num
def __add__(self, num2):
print('Lets add')
return self.num + num2.num
def __mul__(self, num2):
print('Lets multiply')
return self.num * num2.num
n1 = number(4)
n2 = number(6)
sum = n1 + n2
mul = n1 * n2
print(su... |
# Module : kilo_to_mile_converter
# Description : This program program asks
# the user to enter a distance in kilometers,
# and then converts that distance to miles with this formula
# Miles = Kilometers * 0.6214
# Programmer : William Kpabitey Kwabla
# Date : 05/04/16
# Def... | def main():
intro()
kilometers = float(input('Please Enter Distance in Kilometers: '))
print()
kilo_to_mile(kilometers)
def intro():
print('This program program asks')
print('the user to enter a distance in kilometers,')
print('and then converts that distance to miles with this formula')
... |
# 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 invertTree(self, root: TreeNode) -> TreeNode:
self.rec(root)
return root
def rec(sel... | class Solution:
def invert_tree(self, root: TreeNode) -> TreeNode:
self.rec(root)
return root
def rec(self, root):
if root is None:
return
if root.left is None and root.right is None:
return
self.rec(root.left)
self.rec(root.right)
... |
# n ==> Size of circle
# m ==> Number of items
# k ==> Initial position
def lastPosition(n, m, k):
if (m<=n-k+1):
return m+k-1
m=m-(n-k+1)
if(m%n==0):
return n
else:
return m%n
# Driver code
n = 5
m = 8
k = 2
ans=lastPosition(n, m, k)
print(ans) | def last_position(n, m, k):
if m <= n - k + 1:
return m + k - 1
m = m - (n - k + 1)
if m % n == 0:
return n
else:
return m % n
n = 5
m = 8
k = 2
ans = last_position(n, m, k)
print(ans) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.