content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class MinIONBasecallerException(Exception):
pass
class TooLargeEditDistance(MinIONBasecallerException):
pass
class MissingRNN1DBasecall(MinIONBasecallerException):
pass
class BlockSizeYTooSmall(MinIONBasecallerException):
pass
class InsufficientDataBlocks(MinIONBasecallerException):
pass
c... | class Minionbasecallerexception(Exception):
pass
class Toolargeeditdistance(MinIONBasecallerException):
pass
class Missingrnn1Dbasecall(MinIONBasecallerException):
pass
class Blocksizeytoosmall(MinIONBasecallerException):
pass
class Insufficientdatablocks(MinIONBasecallerException):
pass
class ... |
# https://programmers.co.kr/learn/courses/30/lessons/42747
def solution(citations):
citations.sort()
citations_cnt = len(citations)
result = 0
for idx in range(citations_cnt):
if citations[idx] >= citations_cnt-idx:
result = citations_cnt-idx
break
return result
p... | def solution(citations):
citations.sort()
citations_cnt = len(citations)
result = 0
for idx in range(citations_cnt):
if citations[idx] >= citations_cnt - idx:
result = citations_cnt - idx
break
return result
print(solution([3, 0, 6, 1, 5]) == 3)
print(solution([0, 0, ... |
def _Test_ConstuctGraphFromJson():
g=ConstructGraphFromJSON(nameJSON='Graph_JSON_test')
string = GetBackJSON(nameJSON='Graph_JSON_test')
JSONObject = DataGraph(string)
passedtests=0
failedtests=0
#Compare graph created from JSON and JSON itself
__Pass_Test('nodes', __TestConstructNodes(g, JSONObject), True)
... | def __test__constuct_graph_from_json():
g = construct_graph_from_json(nameJSON='Graph_JSON_test')
string = get_back_json(nameJSON='Graph_JSON_test')
json_object = data_graph(string)
passedtests = 0
failedtests = 0
___pass__test('nodes', ___test_construct_nodes(g, JSONObject), True)
___pass__... |
n=int(input("Enter a 3 digit number "))
i=n%10
j=(n//10)%10
k=n//100
s=i+j+k
print(s)
| n = int(input('Enter a 3 digit number '))
i = n % 10
j = n // 10 % 10
k = n // 100
s = i + j + k
print(s) |
num = {}
def fib(n):
if n in num:
return num[n]
if n <= 2:
f = 1
else:
f = fib(n-1) + fib(n-2)
num[n]=f
return f
number=int(input("enter the range"))
print( fib(number))
| num = {}
def fib(n):
if n in num:
return num[n]
if n <= 2:
f = 1
else:
f = fib(n - 1) + fib(n - 2)
num[n] = f
return f
number = int(input('enter the range'))
print(fib(number)) |
#!/usr/bin/env python3
NOTE_ON = 0x90
NOTE_OFF = 0x80
| note_on = 144
note_off = 128 |
k = int(input())
if(k == 1):
print("Top 1")
elif(k <= 3):
print("Top 3")
elif(k <= 5):
print("Top 5")
elif(k <= 10):
print("Top 10")
elif(k <= 25):
print("Top 25")
elif(k <= 50):
print("Top 50")
elif(k <= 100):
print("Top 100") | k = int(input())
if k == 1:
print('Top 1')
elif k <= 3:
print('Top 3')
elif k <= 5:
print('Top 5')
elif k <= 10:
print('Top 10')
elif k <= 25:
print('Top 25')
elif k <= 50:
print('Top 50')
elif k <= 100:
print('Top 100') |
def collect_minima(m_space, x_space, a_space, params):
U_data = np.zeros((len(m_space), len(x_space), len(a_space)))
gmin_overm = []; b1_overm = []; b2_overm = []; inf_overm = [];
capture2minima = []; capture_mvals = [];
for mi, mm in enumerate(m_space):
gmin_coords = []; bi1_coords = ... | def collect_minima(m_space, x_space, a_space, params):
u_data = np.zeros((len(m_space), len(x_space), len(a_space)))
gmin_overm = []
b1_overm = []
b2_overm = []
inf_overm = []
capture2minima = []
capture_mvals = []
for (mi, mm) in enumerate(m_space):
gmin_coords = []
bi1_... |
def euclide(a: int, b: int) -> int:
if b == 0:
return a
return euclide(b, a % b)
def euclide_etendu(a: int, b: int) -> tuple:
if b == 0:
return (a, 1, 0)
else:
(pgcd, u, v) = euclide_etendu(b, a % b)
return (pgcd, v, u - (a // b) * v)
def pgcd(a: int, b: int) -> int:
... | def euclide(a: int, b: int) -> int:
if b == 0:
return a
return euclide(b, a % b)
def euclide_etendu(a: int, b: int) -> tuple:
if b == 0:
return (a, 1, 0)
else:
(pgcd, u, v) = euclide_etendu(b, a % b)
return (pgcd, v, u - a // b * v)
def pgcd(a: int, b: int) -> int:
... |
def Mergesort(L):
if len(L) <= 1: return L
mid = len(L) // 2
left = Mergesort(L[:mid])
right = Mergesort(L[mid:])
return Merge(left, right)
def Merge(left, right):
i, j = 0, 0
result = []
while (i < len(left)) and (j < len(right)):
if left[i] < right[j]:
result.a... | def mergesort(L):
if len(L) <= 1:
return L
mid = len(L) // 2
left = mergesort(L[:mid])
right = mergesort(L[mid:])
return merge(left, right)
def merge(left, right):
(i, j) = (0, 0)
result = []
while i < len(left) and j < len(right):
if left[i] < right[j]:
resu... |
CODE_MESSAGES = {
"0x00": "IP has never been observed scanning the Internet",
"0x01": "IP has been observed by the GreyNoise sensor network",
"0x02": (
"IP has been observed scanning the GreyNoise sensor network, "
"but has not completed a full connection, meaning this can be spoofed"
),... | code_messages = {'0x00': 'IP has never been observed scanning the Internet', '0x01': 'IP has been observed by the GreyNoise sensor network', '0x02': 'IP has been observed scanning the GreyNoise sensor network, but has not completed a full connection, meaning this can be spoofed', '0x03': 'IP is adjacent to another host... |
class MockSocket:
def __init__(self, host, port):
self.host = host
self.port = port
self.connected = False
self.closed = False
self.out_buffer = []
self.in_buffer = []
self.timeout = None
def connect(self, addr):
if addr == (self.host, self.por... | class Mocksocket:
def __init__(self, host, port):
self.host = host
self.port = port
self.connected = False
self.closed = False
self.out_buffer = []
self.in_buffer = []
self.timeout = None
def connect(self, addr):
if addr == (self.host, self.port)... |
# TODO-USC Shape rewards here
class Rewards:
def __init__(self):
self.obs = None
self.agent_list = None
self.died_agents = 0
def setAgentList(self, agents):
self.agent_list = agents
def update_state(self, obs):
self.obs = obs
def agent_died(self, agent):
... | class Rewards:
def __init__(self):
self.obs = None
self.agent_list = None
self.died_agents = 0
def set_agent_list(self, agents):
self.agent_list = agents
def update_state(self, obs):
self.obs = obs
def agent_died(self, agent):
self.died_agents += 1
... |
# This challenge use a disjoint set with set size tracking.
# In addition to the basic disjoint set operations, we keep
# track of the total elements in a set with (#1), and add a
# method (#2) to get the set size.
class DisjointSet:
def __init__(self, N):
self.parent = [i for i in range(N)]
self.total = [1... | class Disjointset:
def __init__(self, N):
self.parent = [i for i in range(N)]
self.total = [1] * N
def union(self, a, b):
a_parent = self.find(a)
b_parent = self.find(b)
if a_parent != b_parent:
self.parent[b_parent] = a_parent
self.total[a_paren... |
def func1(num2):
num1 = 1
print(num1)
print(num2 + num1)
func1(12)
print(num1)
| def func1(num2):
num1 = 1
print(num1)
print(num2 + num1)
func1(12)
print(num1) |
class PrepareNetworkActionResult(object):
def __init__(self):
self.actionId = ''
self.success = True
self.infoMessage = ''
self.errorMessage = ''
self.type = 'PrepareNetwork'
self.access_key = ''
self.secret_key = ''
class PrepareSubnetActionResult(object):
... | class Preparenetworkactionresult(object):
def __init__(self):
self.actionId = ''
self.success = True
self.infoMessage = ''
self.errorMessage = ''
self.type = 'PrepareNetwork'
self.access_key = ''
self.secret_key = ''
class Preparesubnetactionresult(object):
... |
#!/usr/bin/env python3
#
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
#
# https://opensource.apple.com/source/cctools/cctools-795/include/mach-o/loader.h
# magic
# MAGIC_32 = 0xFEEDFACE
# MAGIC_64 = 0xFEEDFACF
# MAGIC_FAT = 0xBEBAFECA
MAGIC_... | magic_32 = [4277009102, 3472551422]
magic_64 = [4277009103, 3489328638]
magic_fat = [3199925962, 3405691582]
cpu_type_x8664 = 16777223
cpu_type_arm64 = 16777228
cpu_type_x86 = 7
cpu_subtype_arm64_all = 6
cpu_subtype_x8664_all = 48
cpu_subtype_i386_all = 48
mh_dylinker = 7
mh_execute = 2
lc_segment_64 = 25
lc_segment = ... |
'''this program aims to decrypt the message given.
notes:
that A = 65, B = 66 etc
and that a = 97, b = 98 etc
ord(A) returns ascii value for letter
chr(65) returns letter for ascii value
int() tells python that the item is a number
^ is an xor function
'''
message = [1,9,9,24,1,9,3,25,24,31,5... | """this program aims to decrypt the message given.
notes:
that A = 65, B = 66 etc
and that a = 97, b = 98 etc
ord(A) returns ascii value for letter
chr(65) returns letter for ascii value
int() tells python that the item is a number
^ is an xor function
"""
message = [1, 9, 9, 24, 1, 9, 3, 25, 2... |
# dictionary
# indexed by keys, can be any immutable type
d = {"pet": "dog", "age": 5, "name": "kgb"}
print(type(d))
d = dict(pet="dog", age=5, name="spot")
print(d.items())
print(d.keys())
print(d.values())
print(d["pet"])
# add an item
d["add"] = "sit"
# remove an item
del d["add"] # the value as... | d = {'pet': 'dog', 'age': 5, 'name': 'kgb'}
print(type(d))
d = dict(pet='dog', age=5, name='spot')
print(d.items())
print(d.keys())
print(d.values())
print(d['pet'])
d['add'] = 'sit'
del d['add']
for key in d.keys():
print(f'{key} = {d[key]}') |
#coding=utf-8
class DBQueryError(Exception):
pass
class CoreError(Exception):
pass
class UserError(Exception):
pass
class NotAnError(Exception):
pass
class SpiderFinish(NotAnError):
pass
| class Dbqueryerror(Exception):
pass
class Coreerror(Exception):
pass
class Usererror(Exception):
pass
class Notanerror(Exception):
pass
class Spiderfinish(NotAnError):
pass |
# Boolen
while input("Do you know what a boolean is ?[yes/no]") != "yes":
continue
print("Nice")
def f(x):
if x > 0:
return True | while input('Do you know what a boolean is ?[yes/no]') != 'yes':
continue
print('Nice')
def f(x):
if x > 0:
return True |
class IncorrectAPIFormatException(Exception):
pass
class PageNotFoundException(Exception):
pass
class UnsupportedLanguageException(Exception):
pass
class TitleNotFound(Exception):
pass
| class Incorrectapiformatexception(Exception):
pass
class Pagenotfoundexception(Exception):
pass
class Unsupportedlanguageexception(Exception):
pass
class Titlenotfound(Exception):
pass |
def findDecision(obj): #obj[0]: Coupon, obj[1]: Education, obj[2]: Occupation
# {"feature": "Education", "instances": 51, "metric_value": 0.9997, "depth": 1}
if obj[1]>0:
# {"feature": "Occupation", "instances": 31, "metric_value": 0.9629, "depth": 2}
if obj[2]<=20:
# {"feature": "Coupon", "instances": 29, "me... | def find_decision(obj):
if obj[1] > 0:
if obj[2] <= 20:
if obj[0] > 3:
return 'False'
elif obj[0] <= 3:
return 'False'
else:
return 'False'
elif obj[2] > 20:
return 'True'
else:
return... |
x = int(input())
s1 = input()
y = int(input())
s2 = input()
z = int(input())
if s1 == '*':
conta = x * y
if s2 == '+':
conta = conta + z
print(int(conta), end="")
elif s2 == '-':
conta = conta - z
print(int(conta), end="")
elif s1 == '/':
if y == 0:
print("erro",... | x = int(input())
s1 = input()
y = int(input())
s2 = input()
z = int(input())
if s1 == '*':
conta = x * y
if s2 == '+':
conta = conta + z
print(int(conta), end='')
elif s2 == '-':
conta = conta - z
print(int(conta), end='')
elif s1 == '/':
if y == 0:
print('erro', ... |
# When one base class is extending one parent class
# Child class is able to access parent class methods and variables
class Parent:
def __init__(self):
super().__init__()
print('Parent constructor')
def displayP(self):
print('Parent Display')
class Child(Parent): #Inherited fro... | class Parent:
def __init__(self):
super().__init__()
print('Parent constructor')
def display_p(self):
print('Parent Display')
class Child(Parent):
def __init__(self):
super().__init__()
print('Child constructor')
def display_c(self):
print('Child Disp... |
class Node:
def __init__(self,key):
self.left=None
self.right=None
self.key=key
self.extremness=0
def __str__(self):
return(str("the key is "+str(self.key)+" "+str(self.right)+" "+str(self.left)))
root=Node(23)
root.right=None
root.left=None
root.extremness=0
vrt_line=d... | class Node:
def __init__(self, key):
self.left = None
self.right = None
self.key = key
self.extremness = 0
def __str__(self):
return str('the key is ' + str(self.key) + ' ' + str(self.right) + ' ' + str(self.left))
root = node(23)
root.right = None
root.left = None
root... |
#!/usr/bin/env python3
def love(a):
print( "I love my {}".format(a))
def decorator_love(func):
def inner_love(a):
print( "I miss my dog, Cherie.")
return func(a)
return inner_love
new_func = decorator_love(love)
new_func("Kit")
| def love(a):
print('I love my {}'.format(a))
def decorator_love(func):
def inner_love(a):
print('I miss my dog, Cherie.')
return func(a)
return inner_love
new_func = decorator_love(love)
new_func('Kit') |
def format(matrix):
rows = len(matrix)
for x in range(rows):
columns = len(matrix[x])
for i in range(columns):
print(matrix[x][i], end=' ')
print()
def format_tester():
matrix = [ [1,2,3],[4,5,6],[7,8,9] ]
format(matrix)
matrix2 = [ [1,2,3],[4,5,6],[7,8,9],[10,1... | def format(matrix):
rows = len(matrix)
for x in range(rows):
columns = len(matrix[x])
for i in range(columns):
print(matrix[x][i], end=' ')
print()
def format_tester():
matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
format(matrix)
matrix2 = [[1, 2, 3], [4, 5, 6], [7,... |
class Queue:
# initialize your data structure here.
def __init__(self):
self.stk1 = []
self.stk2 = []
self.head = None
# @param x, an integer
# @return nothing
def push(self, x):
self.stk1.append(x)
if self.head is None:
self.head = x
# @ret... | class Queue:
def __init__(self):
self.stk1 = []
self.stk2 = []
self.head = None
def push(self, x):
self.stk1.append(x)
if self.head is None:
self.head = x
def pop(self):
while len(self.stk1):
self.stk2.append(self.stk1.pop())
... |
src = Split('''
spi_flash.c
spi_flash_platform.c
''')
component = aos_component('Lib_SPI_Flash_Library', src) | src = split('\n spi_flash.c\n spi_flash_platform.c \n')
component = aos_component('Lib_SPI_Flash_Library', src) |
# Third-party dependencies fetched by Bazel
# Unlike WORKSPACE, the content of this file is unordered.
# We keep them separate to make the WORKSPACE file more maintainable.
# Install the nodejs "bootstrap" package
# This provides the basic tools for running and packaging nodejs programs in Bazel
load("@bazel_tools//to... | load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')
def fetch_dependencies():
http_archive(name='bazel_skylib', urls=['https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz', 'https://mirro... |
class TerraformComplianceInvalidConfig(Exception):
pass
class TerraformComplianceInvalidConfigurationType(Exception):
pass
class Failure(Exception):
pass
class TerraformComplianceNotImplemented(Exception):
pass
class TerraformComplianceInternalFailure(Exception):
pass
| class Terraformcomplianceinvalidconfig(Exception):
pass
class Terraformcomplianceinvalidconfigurationtype(Exception):
pass
class Failure(Exception):
pass
class Terraformcompliancenotimplemented(Exception):
pass
class Terraformcomplianceinternalfailure(Exception):
pass |
def group_by_f(f, lst):
dct = {}
for i in range(0, len(lst)):
if f(lst[i]) not in dct :
dct[f(lst[i])] = []
for i in dct:
for j in range(0, len(lst)):
if f(lst[j]) == i : #zashto ne raboti dct[i] ?
dct[i].append(lst[j])
retur... | def group_by_f(f, lst):
dct = {}
for i in range(0, len(lst)):
if f(lst[i]) not in dct:
dct[f(lst[i])] = []
for i in dct:
for j in range(0, len(lst)):
if f(lst[j]) == i:
dct[i].append(lst[j])
return dct
print(group_by_f(lambda a: a % 2 == 0, [1, 2, ... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"process_dirs": "00_encryption.ipynb",
"encrypt_file": "00_encryption.ipynb",
"pv": "00_encryption.ipynb",
"decrypt_file": "00_encryption.ipynb",
"txt2encrypted_file": "01_... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'process_dirs': '00_encryption.ipynb', 'encrypt_file': '00_encryption.ipynb', 'pv': '00_encryption.ipynb', 'decrypt_file': '00_encryption.ipynb', 'txt2encrypted_file': '01_talker.ipynb', 'encrypted_file2txt': '01_talker.ipynb', 'HttpConnectionFailur... |
general_settings = {
"auto_connect_to_ip": "127.0.0.1:5555",
}
connection_settings = {
"disable_logging": True
}
userinterface_settings = {
"dont_show_button_prompts": False,
}
# Debug Settings
debug_switches = (
"debug_skip_ip",
"debug_skip_new_save_file_message",
"debug_skip_name_when_creating_new_sa... | general_settings = {'auto_connect_to_ip': '127.0.0.1:5555'}
connection_settings = {'disable_logging': True}
userinterface_settings = {'dont_show_button_prompts': False}
debug_switches = ('debug_skip_ip', 'debug_skip_new_save_file_message', 'debug_skip_name_when_creating_new_save_files', 'debug_skip_empire_name_when_cre... |
# save file with RMSE scores from Weyn et al. (2020): https://github.com/pangeo-data/WeatherBench/blob/master/notebooks/Weyn2020-scores.ipynb
def generate_weyn_scores():
lead_time = [ 6., 12., 18., 24., 30., 36., 42., 48., 54., 60., 66.,
72., 78., 84., 90., 96., 102., 108., 114., 120., 1... | def generate_weyn_scores():
lead_time = [6.0, 12.0, 18.0, 24.0, 30.0, 36.0, 42.0, 48.0, 54.0, 60.0, 66.0, 72.0, 78.0, 84.0, 90.0, 96.0, 102.0, 108.0, 114.0, 120.0, 126.0, 132.0, 138.0, 144.0, 150.0, 156.0, 162.0, 168.0, 174.0, 180.0, 186.0, 192.0, 198.0, 204.0, 210.0, 216.0, 222.0, 228.0, 234.0, 240.0, 246.0, 252.0... |
class History:
def __init__(self, aspects=()):
self.history = {aspect: [] for aspect in ["generation"] + list(aspects)}
def record(self, data):
for key in data:
self.history[key].append(data[key])
def __getitem__(self, item):
return self.history[item]
| class History:
def __init__(self, aspects=()):
self.history = {aspect: [] for aspect in ['generation'] + list(aspects)}
def record(self, data):
for key in data:
self.history[key].append(data[key])
def __getitem__(self, item):
return self.history[item] |
# Copyright 2021 Invana
#
# 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 ... | class Propertiesobject:
def __repr__(self):
__str = ''
for (k, v) in self.__dict__.items():
__str += f'{k}={v} '
return __str
class Elementbase:
id = None
label = None
def __init__(self, *args, **kwargs):
self.properties = properties_object()
def to_js... |
WANDB = True
start_molecule = None #'CCn1c(Sc2ncnc3onc(C)c23)nnc1N1CCOCC1'
epsilon_start = 1.0
epsilon_end = 0.01
epsilon_decay = 2000
optimizer = "Adam"
polyak = 0.995
atom_types = ["C", "O", "N"]
num_episodes = 10000
max_steps_per_episode = 40
allow_removal = True
allow_no_modification = True
allow_bonds_between_rin... | wandb = True
start_molecule = None
epsilon_start = 1.0
epsilon_end = 0.01
epsilon_decay = 2000
optimizer = 'Adam'
polyak = 0.995
atom_types = ['C', 'O', 'N']
num_episodes = 10000
max_steps_per_episode = 40
allow_removal = True
allow_no_modification = True
allow_bonds_between_rings = False
allowed_ring_sizes = [3, 4, 5,... |
GUIDs = {
"LENOVO_SYSTEM_USB_SWITCH_DXE_GUID": [1293931, 8600, 17393, 147, 186, 42, 126, 215, 177, 225, 204],
"LENOVO_SYSTEM_SCSI_BUS_DXE_GUID": [23579844, 53495, 20257, 163, 239, 158, 100, 183, 205, 206, 139],
"LENOVO_SYSTEM_AHCI_BUS_DXE_GUID": [23579844, 53495, 20257, 163, 239, 158, 100, 183, 205, 206, 1... | gui_ds = {'LENOVO_SYSTEM_USB_SWITCH_DXE_GUID': [1293931, 8600, 17393, 147, 186, 42, 126, 215, 177, 225, 204], 'LENOVO_SYSTEM_SCSI_BUS_DXE_GUID': [23579844, 53495, 20257, 163, 239, 158, 100, 183, 205, 206, 139], 'LENOVO_SYSTEM_AHCI_BUS_DXE_GUID': [23579844, 53495, 20257, 163, 239, 158, 100, 183, 205, 206, 140], 'LENOVO_... |
BLACK = 0
RED = 1
class Node:
def __init__(self, key, color=BLACK, parent=None, left=None, right=None):
self.color = color
self.key = key
self.parent = parent
self.left = left
self.right = right
class Tree:
def __init__(self, root=None):
self.root = root
def... | black = 0
red = 1
class Node:
def __init__(self, key, color=BLACK, parent=None, left=None, right=None):
self.color = color
self.key = key
self.parent = parent
self.left = left
self.right = right
class Tree:
def __init__(self, root=None):
self.root = root
def ... |
def divide_nums(a, b):
return a / 5
def multiply_nums(a, b):
return a * b
def subtract_nums(a, b):
return a - b
def add_nums(a, b):
return a + b
def raise_to_power(a, b):
return a ** b
def calculate(string):
a, sign, b = string.split()
a, b = float(a), int(b)
if sign == '/':
... | def divide_nums(a, b):
return a / 5
def multiply_nums(a, b):
return a * b
def subtract_nums(a, b):
return a - b
def add_nums(a, b):
return a + b
def raise_to_power(a, b):
return a ** b
def calculate(string):
(a, sign, b) = string.split()
(a, b) = (float(a), int(b))
if sign == '/':
... |
def ranged_xor(m, n):
f_m = [m, 1, m + 1, 0][m % 4]
f_n = [n, 1, n + 1, 0][n % 4]
return f_m ^ f_n
def solution(start, length):
xor = 0
for i in range(length):
xor ^= ranged_xor(start - 1, start + length - i - 1)
start += length
return xor
print(solution(0,3))
prin... | def ranged_xor(m, n):
f_m = [m, 1, m + 1, 0][m % 4]
f_n = [n, 1, n + 1, 0][n % 4]
return f_m ^ f_n
def solution(start, length):
xor = 0
for i in range(length):
xor ^= ranged_xor(start - 1, start + length - i - 1)
start += length
return xor
print(solution(0, 3))
print(solution(17... |
#IDEAS
# Languages: tuples with code/name and options
# FIRST ONE IS THE BASE ONE
LANGUAGES = [
('it', 'Italiano'),
('en', 'English'),
]
LANGUAGE_CODE = 'it'
#LANGUAGE_SELECTORS = ['prefix'] # 'query_string', 'cookie', 'header', ...
SITE_MODULES = [
'cms_theme_bootstrap',
'cmz_translations',
... | languages = [('it', 'Italiano'), ('en', 'English')]
language_code = 'it'
site_modules = ['cms_theme_bootstrap', 'cmz_translations', 'cms_content', 'cms_news', 'cms_cookieconsent']
cookieconsent_options = {'message': 'This is a custom message from CMZ!', 'theme': 'dark-bottom', 'link': '/example-cookie-policy/', 'dismis... |
# Ant Warrior
n = int(input())
data = list(map(int, input().split()))
dynamic_table = [0] * 101
for select_point in range(0, n):
if select_point == 0:
dynamic_table[0] = data[0]
elif select_point == 1:
dynamic_table[1] = max(data[0], data[1])
else:
dynamic_table[select_point] = m... | n = int(input())
data = list(map(int, input().split()))
dynamic_table = [0] * 101
for select_point in range(0, n):
if select_point == 0:
dynamic_table[0] = data[0]
elif select_point == 1:
dynamic_table[1] = max(data[0], data[1])
else:
dynamic_table[select_point] = max(dynamic_table[s... |
class NotFoundException(Exception):
pass
class TooManyElementsException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(*args, **kwargs)
class IllegalArgumentException(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(*args, **kwargs)
| class Notfoundexception(Exception):
pass
class Toomanyelementsexception(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(*args, **kwargs)
class Illegalargumentexception(Exception):
def __init__(self, *args, **kwargs):
Exception.__init__(*args, **kwargs) |
globalVar1:int = 0
# Semantic Rule 8: In function and method bodies, there must be no assignment
# to variables (nonlocal or global), whose binding is inherited implicitly
# (that is, without an explicit nonlocal or global declaration). See bad_local_assign.py.
# 1. Global function
def globalFunc1():
localVar1:st... | global_var1: int = 0
def global_func1():
local_var1: str = 'Hello'
def nested_func1():
local_var1 = 'Start'
global_var1 = globalVar1 + 1
class Class1(object):
def method1(self: 'class1'):
local_var1: str = 'Hello'
def nested_func1():
local_var1 = 'Start'
... |
class Wikilink(object):
def __init__(self, wikilink):
if not isinstance(wikilink, str):
raise BadWikilinkException("Wikilink not a string")
if not wikilink[:2] == "[[" or not wikilink[-2:] == "]]":
raise BadWikilinkException("No wikilink in supplied string")
self.wiki... | class Wikilink(object):
def __init__(self, wikilink):
if not isinstance(wikilink, str):
raise bad_wikilink_exception('Wikilink not a string')
if not wikilink[:2] == '[[' or not wikilink[-2:] == ']]':
raise bad_wikilink_exception('No wikilink in supplied string')
self... |
class Solution:
def findMaximumXOR(self, nums, ans = 0):
ans = 0
for bit in range(30, -1, -1):
ans <<= 1
attempt = ans | 1
prefix = set()
for x in nums:
p = x >> bit
if attempt ^ p in prefix:
ans = at... | class Solution:
def find_maximum_xor(self, nums, ans=0):
ans = 0
for bit in range(30, -1, -1):
ans <<= 1
attempt = ans | 1
prefix = set()
for x in nums:
p = x >> bit
if attempt ^ p in prefix:
ans = a... |
#These functions are involved in returning a unique key
def sub_key_gen(new, parent_key_substring, **dictionary):
tmp_key = "null"
max_increment = 100
for key in dictionary:
l = len(parent_key_substring)
if key[:l] == parent_key_substring:
increment = int(key[-3:])
... | def sub_key_gen(new, parent_key_substring, **dictionary):
tmp_key = 'null'
max_increment = 100
for key in dictionary:
l = len(parent_key_substring)
if key[:l] == parent_key_substring:
increment = int(key[-3:])
if increment >= max_increment:
max_increme... |
''' teachers and centers are lists of Teacher objects and ExamCenter objects respectively
class Teacher and class ExamCentre and defined in locatable.py
Link : https://github.com/aahnik/mapTeachersToCenters/blob/master/locatable.py '''
def algorithm(teachers, centers): # algorithm v
connections = {} ... | """ teachers and centers are lists of Teacher objects and ExamCenter objects respectively
class Teacher and class ExamCentre and defined in locatable.py
Link : https://github.com/aahnik/mapTeachersToCenters/blob/master/locatable.py """
def algorithm(teachers, centers):
connections = {}
for teacher i... |
# http://codingbat.com/prob/p153599
def front_back(str):
if len(str) <= 1:
return str
return str[len(str)-1] + str[1:-1] + str[0]
| def front_back(str):
if len(str) <= 1:
return str
return str[len(str) - 1] + str[1:-1] + str[0] |
# -- encoding: UTF-8 --
STANDARD = { # BGR -- this is the normal Windows color map
0: 0x000000,
1: 0x800000,
2: 0x00aa00,
3: 0xaaaa00,
4: 0x0000aa,
5: 0x800080,
6: 0x00aaaa,
7: 0xc0c0c0,
8: 0x808080,
9: 0xff0000,
10: 0x00ff00,
11: 0xffff00,
12: 0x0000ff,
13: 0xf... | standard = {0: 0, 1: 8388608, 2: 43520, 3: 11184640, 4: 170, 5: 8388736, 6: 43690, 7: 12632256, 8: 8421504, 9: 16711680, 10: 65280, 11: 16776960, 12: 255, 13: 16711935, 14: 65535, 15: 16777215}
gamma = dict(enumerate([0, 9830400, 43520, 11184640, 170, 8388736, 43690, 12632256, 8421504, 16711680, 65280, 16776960, 255, 1... |
# yacc_parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftsemixleftopxleftbopxleftbdotxrightudotxbofx eofx linefeedx newlinex lpackagex rpackagex interpolationx indentx dedentx stringx funx slicex numberx namex eopx iopx bopx opx uopx ropx u... | _tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'leftsemixleftopxleftbopxleftbdotxrightudotxbofx eofx linefeedx newlinex lpackagex rpackagex interpolationx indentx dedentx stringx funx slicex numberx namex eopx iopx bopx opx uopx ropx udotx bdotx semix commax colonx lparx rparx lketx rketx lkcax lpcax\n\tcode\... |
# Write a progra, to read two numbers and print their quotient and remainder
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
quotient = num1 / num2
remainder = num1 % num2
print(f"{num1} / {num2} = {quotient}")
print(f"{num1} % {num2} = {remainder}")
| num1 = float(input('Enter the first number: '))
num2 = float(input('Enter the second number: '))
quotient = num1 / num2
remainder = num1 % num2
print(f'{num1} / {num2} = {quotient}')
print(f'{num1} % {num2} = {remainder}') |
password = input("Enter a password: ")
abc = "abcdefghijklmnopqrstuvwxyz"
ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
digits = "0123456789"
special = "!@#$%&*+-=?^_~"
length_indicator = False
abc_indicator = False
ABC_indicator = False
digits_indicator = False
special_indicator = False
# check length
if len(password) >= 8 an... | password = input('Enter a password: ')
abc = 'abcdefghijklmnopqrstuvwxyz'
abc = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digits = '0123456789'
special = '!@#$%&*+-=?^_~'
length_indicator = False
abc_indicator = False
abc_indicator = False
digits_indicator = False
special_indicator = False
if len(password) >= 8 and len(password) <=... |
class BlobArg(object):
bucket_name: str
path: str
def __init__(self, bucket_name: str, path: str):
self.bucket_name = bucket_name
self.path = path
def __repr__(self) -> str:
return f"BlobArg(bucket_name={self.bucket_name},path={self.path})"
| class Blobarg(object):
bucket_name: str
path: str
def __init__(self, bucket_name: str, path: str):
self.bucket_name = bucket_name
self.path = path
def __repr__(self) -> str:
return f'BlobArg(bucket_name={self.bucket_name},path={self.path})' |
def _print_aspect_impl(target, ctx):
if hasattr(ctx.rule.attr, "srcjar"):
srcjar = ctx.rule.attr.srcjar
if srcjar != None:
for f in srcjar.files.to_list():
if f != None:
print(f.path)
return []
print_aspect = aspect(
implementation = _print_as... | def _print_aspect_impl(target, ctx):
if hasattr(ctx.rule.attr, 'srcjar'):
srcjar = ctx.rule.attr.srcjar
if srcjar != None:
for f in srcjar.files.to_list():
if f != None:
print(f.path)
return []
print_aspect = aspect(implementation=_print_aspect_imp... |
file = open("test.txt", "r")
content=file.read()
measurements=content.split('\n')
class Log:
def __init__(self, alt,temp,acceleration,orientation,pressure):
#self.time = time
self.alt=float(alt)
self.temp = float(temp)
self.orientation=[float(i) for i in orientation]
... | file = open('test.txt', 'r')
content = file.read()
measurements = content.split('\n')
class Log:
def __init__(self, alt, temp, acceleration, orientation, pressure):
self.alt = float(alt)
self.temp = float(temp)
self.orientation = [float(i) for i in orientation]
self.acceleration = ... |
'''
Sieve of Eratosthenes
Input: Integer n
Output: Intger
'''
def sieve(n):
not_prime = []
for i in xrange(2, n+1):
if i not in not_prime:
print(i)
for j in xrange(i*i, n+1, i):
not_prime.append(j)
x = int(raw_input())
sieve(x) | """
Sieve of Eratosthenes
Input: Integer n
Output: Intger
"""
def sieve(n):
not_prime = []
for i in xrange(2, n + 1):
if i not in not_prime:
print(i)
for j in xrange(i * i, n + 1, i):
not_prime.append(j)
x = int(raw_input())
sieve(x) |
class Fact:
def __init__(self, name: str):
self.name = name
self.watched = False
def __eq__(self, other):
if not isinstance(other, Fact):
raise ValueError()
return self.name == other.name
def __str__(self):
return self.name
def __repr__(self):
... | class Fact:
def __init__(self, name: str):
self.name = name
self.watched = False
def __eq__(self, other):
if not isinstance(other, Fact):
raise value_error()
return self.name == other.name
def __str__(self):
return self.name
def __repr__(self):
... |
# coding = utf-8
# Create date: 2018-11-07
# Author :Hailong
def test_ros_config(ros_kvm_with_paramiko, cloud_config_url):
fb_cc_hostname = 'hostname3'
command_cc_hostname = 'sudo ros config get hostname'
client = ros_kvm_with_paramiko(cloud_config='{url}/test_ros_config.yml'.format(url=cloud_config_url))... | def test_ros_config(ros_kvm_with_paramiko, cloud_config_url):
fb_cc_hostname = 'hostname3'
command_cc_hostname = 'sudo ros config get hostname'
client = ros_kvm_with_paramiko(cloud_config='{url}/test_ros_config.yml'.format(url=cloud_config_url))
(stdin, stdout, stderr) = client.exec_command(command_cc_h... |
def isTree(nums):
n = len(nums)
if n == 0:
return True
last_root, i = n / 2, 0
while i < last_root:
if (nums[2 * i + 1] >= nums[i] or nums[2 * i + 2] <= nums[i]):
break
i+=1
return i == last_root
if __name__=='__main__':
s = input()
nums = [int(x) for x ... | def is_tree(nums):
n = len(nums)
if n == 0:
return True
(last_root, i) = (n / 2, 0)
while i < last_root:
if nums[2 * i + 1] >= nums[i] or nums[2 * i + 2] <= nums[i]:
break
i += 1
return i == last_root
if __name__ == '__main__':
s = input()
nums = [int(x) f... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"Config": "00_helpers.ipynb",
"download_url": "00_helpers.ipynb",
"download_data": "00_helpers.ipynb",
"file_extract": "00_helpers.ipynb",
"URLs": "01_url.ipynb",
... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'Config': '00_helpers.ipynb', 'download_url': '00_helpers.ipynb', 'download_data': '00_helpers.ipynb', 'file_extract': '00_helpers.ipynb', 'URLs': '01_url.ipynb', 'FastDownload': '01_url.ipynb'}
modules = ['helper.py', 'url.py']
doc_url = 'https://f... |
arquivo = open('pessoa.csv') # abrindo arquivo
dados = arquivo.read() # fazendo leitura e armazenando dados do arquivo na variavel
arquivo.close() # fechando arquivo
for registro in dados.splitlines():
registro = registro.split(',')
print(f'Nome: {registro[0]}, Idade: {registro[1]} anos')
| arquivo = open('pessoa.csv')
dados = arquivo.read()
arquivo.close()
for registro in dados.splitlines():
registro = registro.split(',')
print(f'Nome: {registro[0]}, Idade: {registro[1]} anos') |
class Solution:
def intersect(self, nums1, nums2):
'''
1. sort the two arrays.
2. compare the elements in the two arrays
'''
nums1 = sorted(nums1)
nums2 = sorted(nums2)
result = []
i, j = 0, 0
while i < len(nums1) and j < len(nums2):
... | class Solution:
def intersect(self, nums1, nums2):
"""
1. sort the two arrays.
2. compare the elements in the two arrays
"""
nums1 = sorted(nums1)
nums2 = sorted(nums2)
result = []
(i, j) = (0, 0)
while i < len(nums1) and j < len(nums2):
... |
'''
FINDING LONGEST PALINDROMIC SUBSTRING IN THE STRING.
'''
s=input()
l,m,u=[],[],[]
for i in range(1,len(s)+1):
for j in range(i):
s_=s[j:i]
l.append(s_)
for i in l:
if i==i[::-1]:
m.append(i)
for i in m:
u.append(len(i))
z=list(zip(u,m))
z=sorted(z)
print(z[-1][1])
| """
FINDING LONGEST PALINDROMIC SUBSTRING IN THE STRING.
"""
s = input()
(l, m, u) = ([], [], [])
for i in range(1, len(s) + 1):
for j in range(i):
s_ = s[j:i]
l.append(s_)
for i in l:
if i == i[::-1]:
m.append(i)
for i in m:
u.append(len(i))
z = list(zip(u, m))
z = sorted(z)
print(z... |
with open("day06.txt", "r") as f:
inputdata = f.readlines()
theabc = "abcdefghijklmnopqrstuvwxyz"
abc = [0 for i in range(26)]
totsum = 0
for line in inputdata:
if line == "\n":
summ = abc.count(1)
totsum += 26 - summ #Part 1 without the 26, just + summ
abc = [0 for i in ran... | with open('day06.txt', 'r') as f:
inputdata = f.readlines()
theabc = 'abcdefghijklmnopqrstuvwxyz'
abc = [0 for i in range(26)]
totsum = 0
for line in inputdata:
if line == '\n':
summ = abc.count(1)
totsum += 26 - summ
abc = [0 for i in range(26)]
else:
line = line.rstrip()
... |
REDDIT_USERNAME = 'HERE' #YOUR USERNAME as string
REDDIT_PASS = 'HERE' # YOUR PASSWORD as string
MYUID = 'HERE'
MYTOKEN = 'HERE'
| reddit_username = 'HERE'
reddit_pass = 'HERE'
myuid = 'HERE'
mytoken = 'HERE' |
###
s = 'Hello, world!'
str(s)
###
| s = 'Hello, world!'
str(s) |
{
'rules': [['Q', 'Q', ' ', 'Qualification'],
['PL', 'PL', '313.04_2', 'Damage/destroy 1st buoy'],
['PL', 'PL', '311.01.6', 'Penalty from prev. start (restart)'],
['NQ', 'NQ', ' ', 'No Qualification'],
['LL', 'LL', '313.02_1', 'Rounding a mark in the wrong way'],
... | {'rules': [['Q', 'Q', ' ', 'Qualification'], ['PL', 'PL', '313.04_2', 'Damage/destroy 1st buoy'], ['PL', 'PL', '311.01.6', 'Penalty from prev. start (restart)'], ['NQ', 'NQ', ' ', 'No Qualification'], ['LL', 'LL', '313.02_1', 'Rounding a mark in the wrong way'], ['LL', 'LL', '307.04_3', 'Engine rotation prior the green... |
proteins = [{'accession': u'sp|Q13449|LSAMP_HUMAN Limbic system-associated membrane protein',
'id': 1,
'search_database_id': 1,
'sequence': u'MVRRVQPDRKQLPLVLLRLLCLLPTGLPVRSVDFNRGTDNITVRQGDTAILRCVVEDKNSKVAWLNRSGIIFAGHDKWSLDPRVELEKRHSLEYSLRIQKVDVYDEGSYTCSVQTQHEPKTSQVYLIVQVPPKISNISS... | proteins = [{'accession': u'sp|Q13449|LSAMP_HUMAN Limbic system-associated membrane protein', 'id': 1, 'search_database_id': 1, 'sequence': u'MVRRVQPDRKQLPLVLLRLLCLLPTGLPVRSVDFNRGTDNITVRQGDTAILRCVVEDKNSKVAWLNRSGIIFAGHDKWSLDPRVELEKRHSLEYSLRIQKVDVYDEGSYTCSVQTQHEPKTSQVYLIVQVPPKISNISSDVTVNEGSNVTLVCMANGRPEPVITWRHLTPTGREFEGE... |
'''
Author: tusikalanse
Date: 2021-07-23 15:06:55
LastEditTime: 2021-07-23 15:44:19
LastEditors: tusikalanse
Description:
'''
def next_permutation(a):
for i in reversed(range(len(a) - 1)):
if a[i] < a[i + 1]:
break
else:
return False
j = next(j for j in reversed(range(i + 1, l... | """
Author: tusikalanse
Date: 2021-07-23 15:06:55
LastEditTime: 2021-07-23 15:44:19
LastEditors: tusikalanse
Description:
"""
def next_permutation(a):
for i in reversed(range(len(a) - 1)):
if a[i] < a[i + 1]:
break
else:
return False
j = next((j for j in reversed(range(i + 1, l... |
# The_Captain_Room
# Enter your code here. Read input from STDIN. Print output to STDOUT
a,b = int(input()), list(map(int, input().split()))
m=set()
n=set()
for i in b:
if i not in m:
m.add(i)
else:
n.add(i)
print(m.difference(n).pop())
| (a, b) = (int(input()), list(map(int, input().split())))
m = set()
n = set()
for i in b:
if i not in m:
m.add(i)
else:
n.add(i)
print(m.difference(n).pop()) |
def search(arr, target):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if target == arr[mid]:
return mid
if target > arr[mid]:
low = mid + 1
else:
high = mid - 1
return None
def b_sort(l):
for i in rang... | def search(arr, target):
low = 0
high = len(arr) - 1
while low <= high:
mid = (low + high) // 2
if target == arr[mid]:
return mid
if target > arr[mid]:
low = mid + 1
else:
high = mid - 1
return None
def b_sort(l):
for i in range(le... |
class colors:
class set:
bold = "\x1b[1m"
dim = "\x1b[2m"
underline = "\x1b[4m"
blink = "\x1b[5m"
reverse = "\x1b[7m"
hidden = "\x1b[8m"
class reset:
all = "\x1b[0m"
bold = "\x1b[21m"
dim = "\x1b[22m"
underline = "\x1b[24m"
blink = "\x1b[25m"
reverse = "\x1b[27m"
hidden = "\x1b[28m"
class f... | class Colors:
class Set:
bold = '\x1b[1m'
dim = '\x1b[2m'
underline = '\x1b[4m'
blink = '\x1b[5m'
reverse = '\x1b[7m'
hidden = '\x1b[8m'
class Reset:
all = '\x1b[0m'
bold = '\x1b[21m'
dim = '\x1b[22m'
underline = '\x1b[24m'
... |
def my_integ_tester(event, context):
message = "hello world!"
return {"message": message}
| def my_integ_tester(event, context):
message = 'hello world!'
return {'message': message} |
def is_abba(input_str: str) -> bool:
first = input_str[0:2]
second = input_str[3] + input_str[2]
return first == second and input_str[0] != input_str[1]
def is_aba(input_str: str) -> bool:
return input_str[0] == input_str[2] and input_str[0] != input_str[1]
def create_target(input_str: str, start_i... | def is_abba(input_str: str) -> bool:
first = input_str[0:2]
second = input_str[3] + input_str[2]
return first == second and input_str[0] != input_str[1]
def is_aba(input_str: str) -> bool:
return input_str[0] == input_str[2] and input_str[0] != input_str[1]
def create_target(input_str: str, start_inde... |
# Part 1 of the Python Review lab.
def hello_world():
print("hello world")
def greet_by_name(name):
print("hello "+str(name))
def encode(x):
return int(x*3953531)
def decode(coded_message):
return coded_message / 3953531
print(decode(encode(5))) | def hello_world():
print('hello world')
def greet_by_name(name):
print('hello ' + str(name))
def encode(x):
return int(x * 3953531)
def decode(coded_message):
return coded_message / 3953531
print(decode(encode(5))) |
#
# PySNMP MIB module JUNIPER-SP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-SP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:58:35 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, value_range_constraint, value_size_constraint, single_value_constraint) ... |
#eg1
a = 10
b = 20
c = 100
d = 5
print((a+b)/c*d) # 1.1
print(a+(b/c)*d) # 1.2
print(a+b/(c*d)) # 1.3
print((a+b)/(c*d)) # 1.4
#eg2
print(10*4//6)
#eg3
print(10*(4//6))
#eg4
print(((((20+10)*5)-10)/2)-25)
#eg5
print(2**2**3)
#eg6
print((2**2)**3)
#eg7
print(0 or 'Python' and 1)
#eg8
... | a = 10
b = 20
c = 100
d = 5
print((a + b) / c * d)
print(a + b / c * d)
print(a + b / (c * d))
print((a + b) / (c * d))
print(10 * 4 // 6)
print(10 * (4 // 6))
print(((20 + 10) * 5 - 10) / 2 - 25)
print(2 ** 2 ** 3)
print((2 ** 2) ** 3)
print(0 or ('Python' and 1))
print(10 * 8 % 3)
print(5 * (10 % 2)) |
n = int(input("Enter Any Number "))
def isPerfect(n):
sum=0
for i in range(1,n):
if n%i==0:
sum += i
if sum == n:
return 1
else:
return 0
if isPerfect(n):
print("Perfect Number")
else:
print("Not A Perfect Number")
| n = int(input('Enter Any Number '))
def is_perfect(n):
sum = 0
for i in range(1, n):
if n % i == 0:
sum += i
if sum == n:
return 1
else:
return 0
if is_perfect(n):
print('Perfect Number')
else:
print('Not A Perfect Number') |
# Autogenerated for the ucla2 variant
core_addr = "192.168.1.76"
device_db = {
"core": {
"type": "local",
"module": "artiq.coredevice.core",
"class": "Core",
"arguments": {"host": core_addr, "ref_period": 1e-09, "target": "or1k"},
},
"core_log": {
"type": "controll... | core_addr = '192.168.1.76'
device_db = {'core': {'type': 'local', 'module': 'artiq.coredevice.core', 'class': 'Core', 'arguments': {'host': core_addr, 'ref_period': 1e-09, 'target': 'or1k'}}, 'core_log': {'type': 'controller', 'host': '::1', 'port': 1068, 'command': 'aqctl_corelog -p {port} --bind {bind} ' + core_addr}... |
cdns_dict = {
'cerulean': '<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cerulean/bootstrap.min.css" rel="stylesheet" integrity="sha384-C++cugH8+Uf86JbNOnQoBweHHAe/wVKN/mb0lTybu/NZ9sEYbd+BbbYtNpWYAsNP" crossorigin="anonymous">',
'cosmo': '<link href="https://stackpath.bootstrapcdn.com/bootswat... | cdns_dict = {'cerulean': '<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/cerulean/bootstrap.min.css" rel="stylesheet" integrity="sha384-C++cugH8+Uf86JbNOnQoBweHHAe/wVKN/mb0lTybu/NZ9sEYbd+BbbYtNpWYAsNP" crossorigin="anonymous">', 'cosmo': '<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.3.1/... |
#
# PySNMP MIB module NMS-EAPS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NMS-EAPS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:11:48 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,... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_union, constraints_intersection, single_value_constraint) ... |
#This program prompts the user for numbers and prints the maximum and minimum of
#the numbers
count = 0
numbers = []
while True:
# prompts the user for a number
line = input("Enter a number: ")
try:
line = int(line)
numbers.append(line)
count = count + 1
maximum = max(numbers... | count = 0
numbers = []
while True:
line = input('Enter a number: ')
try:
line = int(line)
numbers.append(line)
count = count + 1
maximum = max(numbers)
minimum = min(numbers)
except:
if line == 'done':
break
else:
print('Invalid... |
class BinaryTree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
# O(n) time \\ O(n) space
def branchSums(root):
sums = []
calculateBranchSums(root, 0, sums)
return sums
def calculateBranchSums(node, runningSum, sums):
if node is None:
... | class Binarytree:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def branch_sums(root):
sums = []
calculate_branch_sums(root, 0, sums)
return sums
def calculate_branch_sums(node, runningSum, sums):
if node is None:
return
new_r... |
class rotor(object):
def __init__(self, arg):
self.arg = arg
self.rotors = {
# EKMFLGDQVZNTOWYHXUSPAIBRCJ
1: {1: 5, 2: 11, 3: 13, 4: 6, 5: 12, 6: 7, 7: 4, 8: 17, 9: 22, 10: 26, 11: 14, 12: 20, 13: 15, 14: 23, 15: 25, 16: 8, 17: 24, 18: 21, 19: 19, 20: 16, 21: 1, 22: 9, 23: 2, 24: 18, 25: 3, 26: 10}
... | class Rotor(object):
def __init__(self, arg):
self.arg = arg
self.rotors = {1: {1: 5, 2: 11, 3: 13, 4: 6, 5: 12, 6: 7, 7: 4, 8: 17, 9: 22, 10: 26, 11: 14, 12: 20, 13: 15, 14: 23, 15: 25, 16: 8, 17: 24, 18: 21, 19: 19, 20: 16, 21: 1, 22: 9, 23: 2, 24: 18, 25: 3, 26: 10}, 2: {1: 1, 2: 10, 3: 4, 4: 11... |
class ListNode:
def __init__(self, val, next = None):
self.val = val
self.next = next
class Solution:
def isPalindrome(self, head):
if not head or not head.next:
return True
# Find the middle
slow = fast = head
while fast.next and fast.next.next:
... | class Listnode:
def __init__(self, val, next=None):
self.val = val
self.next = next
class Solution:
def is_palindrome(self, head):
if not head or not head.next:
return True
slow = fast = head
while fast.next and fast.next.next:
slow = slow.next
... |
# noinspection PyUnusedLocal
# skus = unicode string
def checkout(skus):
raise NotImplementedError()
| def checkout(skus):
raise not_implemented_error() |
# Recieving user input
yellowC, blueC = map(int, input().split())
yellowB, greenB, blueB = map(int, input().split())
# Counting the deficit
yellowC -= (2 * yellowB + greenB)
blueC -= (greenB + 3 * blueB)
# Totalling the amount required
requiredC = 0
if yellowC < 0:
requiredC += yellowC * -1
if blueC < 0:
requir... | (yellow_c, blue_c) = map(int, input().split())
(yellow_b, green_b, blue_b) = map(int, input().split())
yellow_c -= 2 * yellowB + greenB
blue_c -= greenB + 3 * blueB
required_c = 0
if yellowC < 0:
required_c += yellowC * -1
if blueC < 0:
required_c += blueC * -1
print(requiredC) |
# This problem was recently asked by Twitter:
# Given a binary tree and an integer k, filter the binary tree such that its leaves don't contain the value k.
# Here are the rules:
# - If a leaf node has a value of k, remove it.
# - If a parent node has a value of k, and all of its children are removed, remove it.
cla... | class Node:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
def __repr__(self):
return f'value: {self.value}, left: ({self.left.__repr__()}), right: ({self.right.__repr__()})'
def filter(tree, k):
if tree is None:
... |
a=1
b=1
print(id(a))
print(id(b))
| a = 1
b = 1
print(id(a))
print(id(b)) |
class ServerAccess:
_url = "" # type: str
_token = "" # type: str
def __init__(self, url: str, token: str):
self._url = url
self._token = token
@staticmethod
def from_config(config: dict):
return ServerAccess(config['url'], config['token'])
def get_url(self):
... | class Serveraccess:
_url = ''
_token = ''
def __init__(self, url: str, token: str):
self._url = url
self._token = token
@staticmethod
def from_config(config: dict):
return server_access(config['url'], config['token'])
def get_url(self):
return self._url
de... |
def count_down(n):
print(n)
if n > 0:
return count_down(n - 1)
count_down(5)
| def count_down(n):
print(n)
if n > 0:
return count_down(n - 1)
count_down(5) |
def nd_6_sigma(img: np.ndarray, **kwargs) -> np.ndarray:
for key, value in kwargs.items():
if key == "sigma":
_s_level: int = value
else:
_s_level: int = 4 # default sigma level
_s_yield: float = 0.0
if _s_level == 1: _s_yield = 0.69
... | def nd_6_sigma(img: np.ndarray, **kwargs) -> np.ndarray:
for (key, value) in kwargs.items():
if key == 'sigma':
_s_level: int = value
else:
_s_level: int = 4
_s_yield: float = 0.0
if _s_level == 1:
_s_yield = 0.69
elif _s_level == 2:
_s_yield = 0.3... |
numItem = int(input('What is your maximum number for the list of triples? '))
def cost(numItem):
while numItem > 0:
print(numItem * 3)
numItem -= 1
cost(numItem)
| num_item = int(input('What is your maximum number for the list of triples? '))
def cost(numItem):
while numItem > 0:
print(numItem * 3)
num_item -= 1
cost(numItem) |
class Queue:
def __init__(self,n):
self.maxsize = n
self.front = 0
self.rear = 0
self.queue = []
def enqueue(self,data):
if (self.rear >= self.maxsize):
print("Queue is full")
else :
self.front+=1
self.rear+=1
... | class Queue:
def __init__(self, n):
self.maxsize = n
self.front = 0
self.rear = 0
self.queue = []
def enqueue(self, data):
if self.rear >= self.maxsize:
print('Queue is full')
else:
self.front += 1
self.rear += 1
s... |
name = input("Escreva seu nome: ")
print("Bem vindo ao PyCgarm,", name)
| name = input('Escreva seu nome: ')
print('Bem vindo ao PyCgarm,', name) |
# table of specific heat capacities [in Joules per kilogram Kelvin]
materials = {
"iron": "440",
"aluminium": "887",
"copper": "385",
"steel": "452",
"gold": "129",
"mercury": "140",
"copper": "385",
"aluminum": "902",
"water": "4197",
"air": "1000",
"ice": "2003",
"sil... | materials = {'iron': '440', 'aluminium': '887', 'copper': '385', 'steel': '452', 'gold': '129', 'mercury': '140', 'copper': '385', 'aluminum': '902', 'water': '4197', 'air': '1000', 'ice': '2003', 'silver': '236', 'tin': '226', 'zinc': '389', 'sand': '780'} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.