content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def parse_commands(lines):
commands = []
for l in lines:
c, offset = l.split()
commands.append([c, int(offset)])
return commands
def run_command(command, idx, acc):
c, offset = command
if c == 'acc':
acc += offset
idx += 1
elif c == 'jmp':
idx += offset
elif c == 'nop':
idx += 1
return idx, acc
def run_program(commands):
terminated, visited = True, [False for _ in commands]
acc, idx = 0, 0
while idx < len(commands):
if visited[idx]:
terminated = False
break
visited[idx] = True
idx, acc = run_command(commands[idx], idx, acc)
return acc, terminated
| def parse_commands(lines):
commands = []
for l in lines:
(c, offset) = l.split()
commands.append([c, int(offset)])
return commands
def run_command(command, idx, acc):
(c, offset) = command
if c == 'acc':
acc += offset
idx += 1
elif c == 'jmp':
idx += offset
elif c == 'nop':
idx += 1
return (idx, acc)
def run_program(commands):
(terminated, visited) = (True, [False for _ in commands])
(acc, idx) = (0, 0)
while idx < len(commands):
if visited[idx]:
terminated = False
break
visited[idx] = True
(idx, acc) = run_command(commands[idx], idx, acc)
return (acc, terminated) |
languages = ["Python", "Perl", "Ruby", "Go", "Java", "C"]
lengths = [len(language) for language in languages]
print(lengths)
z = [x for x in range(0,101) if x%3 ==0]
print(z)
| languages = ['Python', 'Perl', 'Ruby', 'Go', 'Java', 'C']
lengths = [len(language) for language in languages]
print(lengths)
z = [x for x in range(0, 101) if x % 3 == 0]
print(z) |
class RGB:
def __init__(self, r: int, g: int, b: int):
self.r = r
self.g = g
self.b = b | class Rgb:
def __init__(self, r: int, g: int, b: int):
self.r = r
self.g = g
self.b = b |
N = int(input())
if N % 2 == 0:
print(N)
else:
print(2 * N)
| n = int(input())
if N % 2 == 0:
print(N)
else:
print(2 * N) |
# Class which represents the university object and its data
class University:
def __init__(self, world_rank, name, national_rank, education_quality, alumni_employment, faculty_quality,
publications, influence, citations, impact, patents, aggregate_rank):
self.id = world_rank
self.name = name
self.national_rank = national_rank
self.education_quality = education_quality
self.alumni_employment = alumni_employment
self.faculty_quality = faculty_quality
self.publications = publications
self.influence = influence
self.citations = citations
self.impact = impact
self.patents = patents
self.aggregate_rank = aggregate_rank
def __gt__(self, uni):
return self.id < uni.id
| class University:
def __init__(self, world_rank, name, national_rank, education_quality, alumni_employment, faculty_quality, publications, influence, citations, impact, patents, aggregate_rank):
self.id = world_rank
self.name = name
self.national_rank = national_rank
self.education_quality = education_quality
self.alumni_employment = alumni_employment
self.faculty_quality = faculty_quality
self.publications = publications
self.influence = influence
self.citations = citations
self.impact = impact
self.patents = patents
self.aggregate_rank = aggregate_rank
def __gt__(self, uni):
return self.id < uni.id |
"""
761. Smallest Subset
https://www.lintcode.com/problem/smallest-subset/description
first sort, then calculate prefix sum.
"""
class Solution:
"""
@param arr: an array of non-negative integers
@return: minimum number of elements
"""
def minElements(self, arr):
# write your code here
if not arr:
return -1
arr = sorted(arr)
n = len(arr)
prefix_sum = [0] * (n + 1)
for i in range(1, n + 1):
prefix_sum[i] = prefix_sum[i - 1] + arr[i - 1]
now_sum = 0
count = 0
for i in range(n - 1, -1, -1):
now_sum += arr[i]
count += 1
if now_sum > prefix_sum[i]:
return count
return -1 | """
761. Smallest Subset
https://www.lintcode.com/problem/smallest-subset/description
first sort, then calculate prefix sum.
"""
class Solution:
"""
@param arr: an array of non-negative integers
@return: minimum number of elements
"""
def min_elements(self, arr):
if not arr:
return -1
arr = sorted(arr)
n = len(arr)
prefix_sum = [0] * (n + 1)
for i in range(1, n + 1):
prefix_sum[i] = prefix_sum[i - 1] + arr[i - 1]
now_sum = 0
count = 0
for i in range(n - 1, -1, -1):
now_sum += arr[i]
count += 1
if now_sum > prefix_sum[i]:
return count
return -1 |
"""shaarli-client"""
__title__ = 'shaarli_client'
__brief__ = 'CLI to interact with a Shaarli instance'
__version__ = '0.4.0'
__author__ = 'The Shaarli Community'
| """shaarli-client"""
__title__ = 'shaarli_client'
__brief__ = 'CLI to interact with a Shaarli instance'
__version__ = '0.4.0'
__author__ = 'The Shaarli Community' |
'''
Since 1926, the Belmont Stakes is a 1.5 mile-long race of 3-year old thoroughbred horses. Secretariat ran the fastest Belmont Stakes in history in 1973. While that was the fastest year, 1970 was the slowest because of unusually wet and sloppy conditions. With these two outliers removed from the data set, compute the mean and standard deviation of the Belmont winners' times. Sample out of a Normal distribution with this mean and standard deviation using the np.random.normal() function and plot a CDF. Overlay the ECDF from the winning Belmont times. Are these close to Normally distributed?
Note: Justin scraped the data concerning the Belmont Stakes from the Belmont Wikipedia page.
'''
# Compute mean and standard deviation: mu, sigma
mu = np.mean(belmont_no_outliers)
sigma = np.std(belmont_no_outliers)
# Sample out of a normal distribution with this mu and sigma: samples
samples = np.random.normal(mu, sigma, 10000)
# Get the CDF of the samples and of the data
x_theor, y_theor = ecdf(samples)
x, y = ecdf(belmont_no_outliers)
# Plot the CDFs and show the plot
_ = plt.plot(x_theor, y_theor)
_ = plt.plot(x, y, marker='.', linestyle='none')
_ = plt.xlabel('Belmont winning time (sec.)')
_ = plt.ylabel('CDF')
plt.show()
| """
Since 1926, the Belmont Stakes is a 1.5 mile-long race of 3-year old thoroughbred horses. Secretariat ran the fastest Belmont Stakes in history in 1973. While that was the fastest year, 1970 was the slowest because of unusually wet and sloppy conditions. With these two outliers removed from the data set, compute the mean and standard deviation of the Belmont winners' times. Sample out of a Normal distribution with this mean and standard deviation using the np.random.normal() function and plot a CDF. Overlay the ECDF from the winning Belmont times. Are these close to Normally distributed?
Note: Justin scraped the data concerning the Belmont Stakes from the Belmont Wikipedia page.
"""
mu = np.mean(belmont_no_outliers)
sigma = np.std(belmont_no_outliers)
samples = np.random.normal(mu, sigma, 10000)
(x_theor, y_theor) = ecdf(samples)
(x, y) = ecdf(belmont_no_outliers)
_ = plt.plot(x_theor, y_theor)
_ = plt.plot(x, y, marker='.', linestyle='none')
_ = plt.xlabel('Belmont winning time (sec.)')
_ = plt.ylabel('CDF')
plt.show() |
# Test for existing rows
def check_row_number(cur, tables):
"""
Check number of rows greater one for sql tables
Args:
cur (object): PostgreSQL curser object
tables (list): List of string of table names
"""
for table in tables:
cur.execute(f"SELECT COUNT(*) FROM {table}")
if cur.rowcount < 1:
print(f"ERROR table {table} is empty")
else:
print(f"Quality check for {table} successfull")
def check_column_names(cur, tables, column_dict):
"""
Check column names of sql tables
Args:
cur (object): PostgreSQL curser object
tables (list): List of string of table names
column_dict (dict): Dict table names and list of corresponding column names
"""
for table in tables:
cur.execute(f"SELECT * FROM {table} LIMIT 5")
colnames = [desc[0] for desc in cur.description]
if colnames != column_dict[table]:
print(f"Column names of {table} do not correspond to the ones in column_dict")
else:
print(f"Successfal column names test for {table}")
def check_dtypes(cur, tables, dtype_dict):
"""
Check column names of sql tables
Args:
cur (object): PostgreSQL curser object
tables (list): List of string of table names
dtype_dict (dict): Dict table names and list of corresponding dtypes of columns
"""
for table in tables:
cur.execute(f"SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{table}'")
dtype = [_[0] for _ in cur]
if dtype != dtype_dict[table]:
print(f"Data types of {table} do not correspond to the ones in dtype_dict")
else:
print(f"Successfal data types test for {table}")
| def check_row_number(cur, tables):
"""
Check number of rows greater one for sql tables
Args:
cur (object): PostgreSQL curser object
tables (list): List of string of table names
"""
for table in tables:
cur.execute(f'SELECT COUNT(*) FROM {table}')
if cur.rowcount < 1:
print(f'ERROR table {table} is empty')
else:
print(f'Quality check for {table} successfull')
def check_column_names(cur, tables, column_dict):
"""
Check column names of sql tables
Args:
cur (object): PostgreSQL curser object
tables (list): List of string of table names
column_dict (dict): Dict table names and list of corresponding column names
"""
for table in tables:
cur.execute(f'SELECT * FROM {table} LIMIT 5')
colnames = [desc[0] for desc in cur.description]
if colnames != column_dict[table]:
print(f'Column names of {table} do not correspond to the ones in column_dict')
else:
print(f'Successfal column names test for {table}')
def check_dtypes(cur, tables, dtype_dict):
"""
Check column names of sql tables
Args:
cur (object): PostgreSQL curser object
tables (list): List of string of table names
dtype_dict (dict): Dict table names and list of corresponding dtypes of columns
"""
for table in tables:
cur.execute(f"SELECT DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = '{table}'")
dtype = [_[0] for _ in cur]
if dtype != dtype_dict[table]:
print(f'Data types of {table} do not correspond to the ones in dtype_dict')
else:
print(f'Successfal data types test for {table}') |
#if else can be done as
a=int(input())
b=int(input())
c=a%2
if a>b:
print("{} is greater than {}".format(a,b))
elif a==b:
print("{} and {} are equal".format(a,b))
else:
print("{} is greater than {}".format(b,a))
#if can be done in single line as
if a>b: print("{} is greater".format(a))
print("{} is even".format(a)) if c==0 else print("{} is odd".format(a)) | a = int(input())
b = int(input())
c = a % 2
if a > b:
print('{} is greater than {}'.format(a, b))
elif a == b:
print('{} and {} are equal'.format(a, b))
else:
print('{} is greater than {}'.format(b, a))
if a > b:
print('{} is greater'.format(a))
print('{} is even'.format(a)) if c == 0 else print('{} is odd'.format(a)) |
# Reading first input, not used anywhere in the program
first_input = input()
# Reading the input->split->parse to int->elements to set
set1 = set(map(int, input().split()))
# Same as second_input
second_input = input()
# Same as set2
set2 = set(map(int, input().split()))
# Union of set1 and set2 returns the set of all elements combining set1 and set2
# We can also use set1 | set2 , the or operator.
set3 = set1.union(set2)
# Printing the count of elements in Set
print(len(set3)) | first_input = input()
set1 = set(map(int, input().split()))
second_input = input()
set2 = set(map(int, input().split()))
set3 = set1.union(set2)
print(len(set3)) |
self.description = "Remove a no longer needed package (multiple provision)"
lp1 = pmpkg("pkg1")
lp1.provides = ["imaginary"]
self.addpkg2db("local", lp1)
lp2 = pmpkg("pkg2")
lp2.provides = ["imaginary"]
self.addpkg2db("local", lp2)
lp3 = pmpkg("pkg3")
lp3.depends = ["imaginary"]
self.addpkg2db("local", lp3)
self.args = "-R %s" % lp1.name
self.addrule("PACMAN_RETCODE=0")
self.addrule("!PKG_EXIST=pkg1")
self.addrule("PKG_EXIST=pkg2")
| self.description = 'Remove a no longer needed package (multiple provision)'
lp1 = pmpkg('pkg1')
lp1.provides = ['imaginary']
self.addpkg2db('local', lp1)
lp2 = pmpkg('pkg2')
lp2.provides = ['imaginary']
self.addpkg2db('local', lp2)
lp3 = pmpkg('pkg3')
lp3.depends = ['imaginary']
self.addpkg2db('local', lp3)
self.args = '-R %s' % lp1.name
self.addrule('PACMAN_RETCODE=0')
self.addrule('!PKG_EXIST=pkg1')
self.addrule('PKG_EXIST=pkg2') |
def multiple(first,second):
return first * second * 3
def add(x,y):
return x+y
| def multiple(first, second):
return first * second * 3
def add(x, y):
return x + y |
config = {
'max_length' : 512,
'class_names' : ['O', 'B-C', 'B-P', 'I-C', 'I-P'],
'ft_data_folders' : ['/content/change-my-view-modes/v2.0/data/'],
'max_tree_size' : 10,
'max_labelled_users_per_tree':10,
'batch_size' : 4,
'd_model': 512,
'init_alphas': [0.0, 0.0, 0.0, -10000., -10000.],
'transition_init': [[0.01, -10000., -10000., 0.01, 0.01],
[0.01, -10000., -10000., 0.01, 0.01],
[0.01, -10000., -10000., 0.01, 0.01],
[-10000., 0.01, -10000., 0.01, -10000.],
[-10000., -10000., 0.01, -10000., 0.01]],
'scale_factors':[1.0, 10.0, 10.0, 1.0, 1.0],
'n_epochs' :10,
'max_grad_norm': 1.0,
'learning_rate':0.0001,
'n_layers' : 5,
} | config = {'max_length': 512, 'class_names': ['O', 'B-C', 'B-P', 'I-C', 'I-P'], 'ft_data_folders': ['/content/change-my-view-modes/v2.0/data/'], 'max_tree_size': 10, 'max_labelled_users_per_tree': 10, 'batch_size': 4, 'd_model': 512, 'init_alphas': [0.0, 0.0, 0.0, -10000.0, -10000.0], 'transition_init': [[0.01, -10000.0, -10000.0, 0.01, 0.01], [0.01, -10000.0, -10000.0, 0.01, 0.01], [0.01, -10000.0, -10000.0, 0.01, 0.01], [-10000.0, 0.01, -10000.0, 0.01, -10000.0], [-10000.0, -10000.0, 0.01, -10000.0, 0.01]], 'scale_factors': [1.0, 10.0, 10.0, 1.0, 1.0], 'n_epochs': 10, 'max_grad_norm': 1.0, 'learning_rate': 0.0001, 'n_layers': 5} |
load("//:import_external.bzl", import_external = "safe_wix_scala_maven_import_external")
def dependencies():
import_external(
name = "commons_lang_commons_lang",
artifact = "commons-lang:commons-lang:2.6",
jar_sha256 = "50f11b09f877c294d56f24463f47d28f929cf5044f648661c0f0cfbae9a2f49c",
srcjar_sha256 = "66c2760945cec226f26286ddf3f6ffe38544c4a69aade89700a9a689c9b92380",
)
| load('//:import_external.bzl', import_external='safe_wix_scala_maven_import_external')
def dependencies():
import_external(name='commons_lang_commons_lang', artifact='commons-lang:commons-lang:2.6', jar_sha256='50f11b09f877c294d56f24463f47d28f929cf5044f648661c0f0cfbae9a2f49c', srcjar_sha256='66c2760945cec226f26286ddf3f6ffe38544c4a69aade89700a9a689c9b92380') |
## Class responsible for representing a Sonobouy within Hunting the Plark
class Sonobuoy():
def __init__(self, active_range):
self.type = "SONOBUOY"
self.col = None
self.row = None
self.range = active_range
self.state = "COLD"
self.size = 1
## Setstate allows the change of state which will happen when detection occurs
def setState(self,state):
self.state = state
## Gets the state of the sonobuoy
def getState(self):
return self.state
## Getter to return range of sonobuoy
def getRange(self):
return self.range
## Getter for returning the object type.
def getType(self):
return self.type
def setLocation(self, col, row):
self.col = col
self.row = row | class Sonobuoy:
def __init__(self, active_range):
self.type = 'SONOBUOY'
self.col = None
self.row = None
self.range = active_range
self.state = 'COLD'
self.size = 1
def set_state(self, state):
self.state = state
def get_state(self):
return self.state
def get_range(self):
return self.range
def get_type(self):
return self.type
def set_location(self, col, row):
self.col = col
self.row = row |
def clamp(a, b):
if (b < 0 and a >= b) or (b > 0 and a <= b):
return a
def field(a, b, then):
val = clamp(a, b)
if val is not None:
return round(then(val), 3)
def sign_and_magnitude(intg, fract):
if fract > 100:
return None
val = (intg & 0x7F) + fract * 0.01
if intg & 0x80 == 0:
return val
return -val
| def clamp(a, b):
if b < 0 and a >= b or (b > 0 and a <= b):
return a
def field(a, b, then):
val = clamp(a, b)
if val is not None:
return round(then(val), 3)
def sign_and_magnitude(intg, fract):
if fract > 100:
return None
val = (intg & 127) + fract * 0.01
if intg & 128 == 0:
return val
return -val |
def countfreq(input):
freq={}
for i in input:
freq[i]=input.count(i)
for key,value in freq.items():
print("%d:%d"%(key,value))
input=[1, 1, 1, 5, 5, 3, 1, 3, 3, 1, 4, 4, 4, 2, 2, 2, 2]
countfreq(input)
| def countfreq(input):
freq = {}
for i in input:
freq[i] = input.count(i)
for (key, value) in freq.items():
print('%d:%d' % (key, value))
input = [1, 1, 1, 5, 5, 3, 1, 3, 3, 1, 4, 4, 4, 2, 2, 2, 2]
countfreq(input) |
"""
28. How to find all the local maxima (or peaks) in a numeric series?
"""
"""
Difficiulty Level: L3
"""
"""
Get the positions of peaks (values surrounded by smaller values on both sides) in ser.
"""
"""
Input
"""
"""
ser = pd.Series([2, 10, 3, 4, 9, 10, 2, 7, 3])
"""
"""
Desired output
"""
"""
array([1, 5, 7])
"""
| """
28. How to find all the local maxima (or peaks) in a numeric series?
"""
'\nDifficiulty Level: L3\n'
'\nGet the positions of peaks (values surrounded by smaller values on both sides) in ser.\n'
'\nInput\n'
'\nser = pd.Series([2, 10, 3, 4, 9, 10, 2, 7, 3])\n'
'\nDesired output\n'
'\narray([1, 5, 7])\n' |
#
# @lc app=leetcode.cn id=66 lang=python3
#
# [66] plus-one
#
None
# @lc code=end | None |
class Solution:
"""
@param n: a positive integer
@return: An integer
"""
def numSquares(self, n):
def issq(n):
x = int(n**.5)
return x * x == n
if issq(n):
return 1
dp = [0, 1]
for i in xrange(2, n + 1):
if issq(i):
ans = 1
else:
ans = 4
for k in xrange(1, int(i**.5) + 1):
t = i - k * k
ans = min(ans, dp[t] + 1)
dp.append(ans)
return dp[-1]
| class Solution:
"""
@param n: a positive integer
@return: An integer
"""
def num_squares(self, n):
def issq(n):
x = int(n ** 0.5)
return x * x == n
if issq(n):
return 1
dp = [0, 1]
for i in xrange(2, n + 1):
if issq(i):
ans = 1
else:
ans = 4
for k in xrange(1, int(i ** 0.5) + 1):
t = i - k * k
ans = min(ans, dp[t] + 1)
dp.append(ans)
return dp[-1] |
class ZipDataLoader:
"""
A data loader that zips together two underlying data loaders. The data loaders must be
sampling the same batch size and :code:`drop_last` must be set to `True` on data loaders that
sample from a fixed-size dataset. Whenever one of the data loaders has a fixed size, this data
loader defines a length. This length is given as the minimum of the both lengths divided by
their respective counts.
A common use case for this class are Wasserstein GANs where the critic is trained for multiple
iterations for each data batch.
"""
def __init__(self, lhs_loader, rhs_loader, lhs_count=1, rhs_count=1):
"""
Initializes a new data loader.
Parameters
----------
lhs_dataset: torch.utils.data.DataLoader
The dataset to sample from for the first item of the data tuple.
rhs_dataset: torch.utils.data.DataLoader
The dataset to sample from for the second item of the data tuple.
lhs_count: int
The number of items to sample for the first item of the data tuple.
rhs_count: int
The number of items to sample for the second item of the data tuple.
"""
if lhs_loader.batch_size != rhs_loader.batch_size:
raise ValueError("Both given data loaders must have the same batch size.")
self.lhs_loader = lhs_loader
self.rhs_loader = rhs_loader
self.lhs_count = lhs_count
self.rhs_count = rhs_count
def __len__(self):
result = None
try:
result = len(self.lhs_loader) // self.lhs_count
except: # pylint: disable=bare-except
pass
try:
rhs_len = len(self.rhs_loader) // self.rhs_count
if result is None:
result = rhs_len
else:
result = min(result, rhs_len)
except: # pylint: disable=bare-except
pass
if result is None:
raise TypeError("__len__ not implemented for instance of ZipDataLoader")
return result
def __iter__(self):
lhs_it = iter(self.lhs_loader)
rhs_it = iter(self.rhs_loader)
while True:
try:
lhs_items = [next(lhs_it) for _ in range(self.lhs_count)]
rhs_items = [next(rhs_it) for _ in range(self.rhs_count)]
except StopIteration:
return
yield lhs_items, rhs_items
| class Zipdataloader:
"""
A data loader that zips together two underlying data loaders. The data loaders must be
sampling the same batch size and :code:`drop_last` must be set to `True` on data loaders that
sample from a fixed-size dataset. Whenever one of the data loaders has a fixed size, this data
loader defines a length. This length is given as the minimum of the both lengths divided by
their respective counts.
A common use case for this class are Wasserstein GANs where the critic is trained for multiple
iterations for each data batch.
"""
def __init__(self, lhs_loader, rhs_loader, lhs_count=1, rhs_count=1):
"""
Initializes a new data loader.
Parameters
----------
lhs_dataset: torch.utils.data.DataLoader
The dataset to sample from for the first item of the data tuple.
rhs_dataset: torch.utils.data.DataLoader
The dataset to sample from for the second item of the data tuple.
lhs_count: int
The number of items to sample for the first item of the data tuple.
rhs_count: int
The number of items to sample for the second item of the data tuple.
"""
if lhs_loader.batch_size != rhs_loader.batch_size:
raise value_error('Both given data loaders must have the same batch size.')
self.lhs_loader = lhs_loader
self.rhs_loader = rhs_loader
self.lhs_count = lhs_count
self.rhs_count = rhs_count
def __len__(self):
result = None
try:
result = len(self.lhs_loader) // self.lhs_count
except:
pass
try:
rhs_len = len(self.rhs_loader) // self.rhs_count
if result is None:
result = rhs_len
else:
result = min(result, rhs_len)
except:
pass
if result is None:
raise type_error('__len__ not implemented for instance of ZipDataLoader')
return result
def __iter__(self):
lhs_it = iter(self.lhs_loader)
rhs_it = iter(self.rhs_loader)
while True:
try:
lhs_items = [next(lhs_it) for _ in range(self.lhs_count)]
rhs_items = [next(rhs_it) for _ in range(self.rhs_count)]
except StopIteration:
return
yield (lhs_items, rhs_items) |
for i in range(1,5):
for j in range(i,5):
print(j," " ,end="")
print()
str1 = "ABCD"
str2 = "PQR"
for i in range(4):
print(str1[:i+1]+str2[i:]) | for i in range(1, 5):
for j in range(i, 5):
print(j, ' ', end='')
print()
str1 = 'ABCD'
str2 = 'PQR'
for i in range(4):
print(str1[:i + 1] + str2[i:]) |
def new(a,b):
return a - b
def x(a,b):
return a
def y(z,t):
return z(*t)
def inModule2(a,b):
return a+b
def outerMethod(a,b):
def innerMethod(a,b):
if a < b:
return a+b
else:
return a-b
return innerMethod(a+2, b+4)
| def new(a, b):
return a - b
def x(a, b):
return a
def y(z, t):
return z(*t)
def in_module2(a, b):
return a + b
def outer_method(a, b):
def inner_method(a, b):
if a < b:
return a + b
else:
return a - b
return inner_method(a + 2, b + 4) |
"""
:testcase_name greet
:author Sriteja Kummita
:script_type Class
:description __getattr__ is called when a property/method of a class is used. This class allows three functions which
are not defined in the class but can be called using reflection
"""
class Greet:
def __init__(self, name):
self.name = name
def __getattr__(self, function_name):
allowed = ['good_morning', 'good_afternoon', 'good_night']
def call_():
greeting = function_name.replace('_', ' ')
if function_name in allowed:
return f"{greeting.capitalize()}, {self.name}!"
else:
raise ValueError(f"Invalid name or greeting. name: {self.name}, greeting: {greeting}")
return call_
if __name__ == '__main__':
greet = Greet("Nemo")
print(greet.good_morning())
# Outputs: Good morning, Nemo!
print(greet.good_afternoon())
# Outputs: Good afternoon, Nemo!
print(greet.good_night())
# Outputs: Good night, Nemo!
| """
:testcase_name greet
:author Sriteja Kummita
:script_type Class
:description __getattr__ is called when a property/method of a class is used. This class allows three functions which
are not defined in the class but can be called using reflection
"""
class Greet:
def __init__(self, name):
self.name = name
def __getattr__(self, function_name):
allowed = ['good_morning', 'good_afternoon', 'good_night']
def call_():
greeting = function_name.replace('_', ' ')
if function_name in allowed:
return f'{greeting.capitalize()}, {self.name}!'
else:
raise value_error(f'Invalid name or greeting. name: {self.name}, greeting: {greeting}')
return call_
if __name__ == '__main__':
greet = greet('Nemo')
print(greet.good_morning())
print(greet.good_afternoon())
print(greet.good_night()) |
#!/usr/bin/env python3
class Observer:
"""
Objects that are interested in a subject should
inherit from this class.
"""
def notify(self, sender: object):
pass
| class Observer:
"""
Objects that are interested in a subject should
inherit from this class.
"""
def notify(self, sender: object):
pass |
# This function takes a single parameter and prints it.
def print_value(x):
print(x)
print_value(12)
print_value("dog") | def print_value(x):
print(x)
print_value(12)
print_value('dog') |
__version__ = '1.3.0'
__url__ = 'https://github.com/mdawar/rq-exporter'
__description__ = 'Prometheus exporter for Python RQ (Redis Queue)'
__author__ = 'Pierre Mdawar'
__author_email__ = 'pierre@mdawar.dev'
__license__ = 'MIT'
| __version__ = '1.3.0'
__url__ = 'https://github.com/mdawar/rq-exporter'
__description__ = 'Prometheus exporter for Python RQ (Redis Queue)'
__author__ = 'Pierre Mdawar'
__author_email__ = 'pierre@mdawar.dev'
__license__ = 'MIT' |
class ArgErrorType(Exception):
"""Raised when provided argument is of unsupported type."""
pass
class UnreadableFileError(Exception):
"""Raised when pydicom cannot read provided file."""
pass | class Argerrortype(Exception):
"""Raised when provided argument is of unsupported type."""
pass
class Unreadablefileerror(Exception):
"""Raised when pydicom cannot read provided file."""
pass |
# All possible values that should be constant through the entire script
ERR_CODE_NON_EXISTING_FILE = 404
ERR_CODE_CREATING_XML = 406
ERR_CODE_COMMAND_LINE_ARGS = 407
ERR_CODE_NON_EXISTING_DIRECTORY = 408
ERR_CODE_NON_EXISTING_W_E = 409
WARNING_CODE_INVALID_FORMAT = 405
WARNING_CODE_NO_PAIR_FOUND = 406
WARNING_NOT_A_TMX_FILE = 407
COMMAND_LINE_MIN_ARGS = 2
COMMAND_LINE_COMMAND_NAME_POSITION = 1
COMMAND_NAME_HELP = '-help'
COMMAND_NAME_CREATE_TMX = '-mktmx'
COMMAND_NAME_CREATE_VTT = '-mkvtt'
COMMAND_NAME_DEV = "-dev"
TMX_MIN_ARGS = [4, 2]
VTT_MIN_ARGS = [2]
WINDOW_GENERATE_TMX = 1
WINDOW_GENERATE_VTT = 2
WINDOW_ABOUT = 3
SUPPRESS_CONSOLE_PRINT = True
PRINT_MESSAGEBOX = 1
PRINT_CONSOLE = 2
MESSAGE_INFO = 1
MESSAGE_ERROR = 2
WINDOW_WIDTH = 300
WINDOW_HEIGHT = 280
GRID_CONFIGURATIONS = {
'padx': 12,
'pady': 6
}
| err_code_non_existing_file = 404
err_code_creating_xml = 406
err_code_command_line_args = 407
err_code_non_existing_directory = 408
err_code_non_existing_w_e = 409
warning_code_invalid_format = 405
warning_code_no_pair_found = 406
warning_not_a_tmx_file = 407
command_line_min_args = 2
command_line_command_name_position = 1
command_name_help = '-help'
command_name_create_tmx = '-mktmx'
command_name_create_vtt = '-mkvtt'
command_name_dev = '-dev'
tmx_min_args = [4, 2]
vtt_min_args = [2]
window_generate_tmx = 1
window_generate_vtt = 2
window_about = 3
suppress_console_print = True
print_messagebox = 1
print_console = 2
message_info = 1
message_error = 2
window_width = 300
window_height = 280
grid_configurations = {'padx': 12, 'pady': 6} |
'''
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
'''
class Solution(object):
def helper(self, row, col, mem):
m,n = len(mem), len(mem[0])
if row == m or col == n:
return 0
if row == m-1 and col == n-1:
return 1
if mem[row][col] != -1: return mem[row][col]
mem[row][col] = self.helper(row+1,col,mem) + self.helper(row,col+1,mem)
return mem[row][col]
def uniquePaths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
mem = [[-1 for j in range(n)] for i in range(m)]
return self.helper(0,0,mem)
'''
follow-up
Follow up for "Unique Paths":
Now consider if some obstacles are added to the grids. How many unique paths would there be?
An obstacle and empty space is marked as 1 and 0 respectively in the grid.
For example,
There is one obstacle in the middle of a 3x3 grid as illustrated below.
[
[0,0,0],
[0,1,0],
[0,0,0]
]
'''
class Solution(object):
def helper(self, row, col, grid, mem):
m,n = len(mem), len(mem[0])
if row == m or col == n or grid[row][col] == 1:
return 0
if row == m-1 and col == n-1:
return 1
if mem[row][col] != -1: return mem[row][col]
mem[row][col] = self.helper(row+1,col,grid, mem) + self.helper(row,col+1,grid,mem)
return mem[row][col]
def uniquePathsWithObstacles(self, grid):
"""
:type obstacleGrid: List[List[int]]
:rtype: int
"""
m,n = len(grid), len(grid[0])
mem = [[-1 for j in range(n)] for i in range(m)]
return self.helper(0,0,grid, mem)
| """
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).
The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below).
How many possible unique paths are there?
"""
class Solution(object):
def helper(self, row, col, mem):
(m, n) = (len(mem), len(mem[0]))
if row == m or col == n:
return 0
if row == m - 1 and col == n - 1:
return 1
if mem[row][col] != -1:
return mem[row][col]
mem[row][col] = self.helper(row + 1, col, mem) + self.helper(row, col + 1, mem)
return mem[row][col]
def unique_paths(self, m, n):
"""
:type m: int
:type n: int
:rtype: int
"""
mem = [[-1 for j in range(n)] for i in range(m)]
return self.helper(0, 0, mem)
'\nfollow-up\nFollow up for "Unique Paths":\n\nNow consider if some obstacles are added to the grids. How many unique paths would there be?\n\nAn obstacle and empty space is marked as 1 and 0 respectively in the grid.\n\nFor example,\nThere is one obstacle in the middle of a 3x3 grid as illustrated below.\n[\n [0,0,0],\n [0,1,0],\n [0,0,0]\n]\n'
class Solution(object):
def helper(self, row, col, grid, mem):
(m, n) = (len(mem), len(mem[0]))
if row == m or col == n or grid[row][col] == 1:
return 0
if row == m - 1 and col == n - 1:
return 1
if mem[row][col] != -1:
return mem[row][col]
mem[row][col] = self.helper(row + 1, col, grid, mem) + self.helper(row, col + 1, grid, mem)
return mem[row][col]
def unique_paths_with_obstacles(self, grid):
"""
:type obstacleGrid: List[List[int]]
:rtype: int
"""
(m, n) = (len(grid), len(grid[0]))
mem = [[-1 for j in range(n)] for i in range(m)]
return self.helper(0, 0, grid, mem) |
# -*- coding: utf-8 -*-
class wcstr(str):
def __new__(*args, **kwargs):
return str.__new__(*args, **kwargs)
def __init__(self, *args, **kwargs):
self._update()
def _update(self):
self.bitindex = []
for i,j in zip(str(self), range(len(str(self)))):
iwidth = 1 if len(i.encode('utf8')) <= 2 else 2
self.bitindex += [j] * iwidth
def __len__(self):
return len(self.bitindex)
def __getitem__(self, y):
if type(y) == int:
return wcstr(super(wcstr, self).__getitem__(
self.bitindex[y]))
elif type(y) == slice:
start = self.bitindex[y.start] if y.start else None
stop = self.bitindex[y.stop] if y.stop else None
step = y.step
return wcstr(super(wcstr, self).__getitem__(slice(
start, stop, step)))
else: return
def dupstr(self):
# return a duplicated string with every element
# indicating one-width character
return ''.join([self[i] for i in range(len(self))])
# alias for other str methods
def __add__(self, *args, **kwargs):
return wcstr(super(wcstr, self).__add__(*args, **kwargs))
def __mul__(self, value):
return wcstr(super(wcstr, self).__mul__(value))
def __rmul__(self, *args, **kwargs):
return wcstr(super(wcstr, self).__rmul__(*args, **kwargs))
def __format__(self, *args, **kwargs):
return wcstr(super(wcstr, self).__format__(*args, **kwargs))
def center(self, width, fillchar=' '):
filllen = (width - len(self)) // 2
return wcstr(fillchar * filllen + self + fillchar * (width - len(self) - filllen))
def ljust(self, width, fillchar=' '):
return wcstr(super(wcstr, self).ljust(width - len(self) +
len(str(self)), fillchar))
def rjust(self, width, fillchar=' '):
return wcstr(super(wcstr, self).rjust(width - len(self) +
len(str(self)), fillchar))
def casefold(self, *args, **kwargs):
return wcstr(super(wcstr, self).casefold(*args, **kwargs))
def capitalize(self, *args, **kwargs):
return wcstr(super(wcstr, self).capitalize(*args, **kwargs))
def expandtabs(self, *args, **kwargs):
return wcstr(super(wcstr, self).expandtabs(*args, **kwargs))
def format(self, *args, **kwargs):
return wcstr(super(wcstr, self).format(*args, **kwargs))
def format_map(self, *args, **kwargs):
return wcstr(super(wcstr, self).format_map(*args, **kwargs))
def join(self, *args, **kwargs):
return wcstr(super(wcstr, self).join(*args, **kwargs))
def lower(self, *args, **kwargs):
return wcstr(super(wcstr, self).lower(*args, **kwargs))
def lstrip(self, *args, **kwargs):
return wcstr(super(wcstr, self).lstrip(*args, **kwargs))
def replace(self, *args, **kwargs):
return wcstr(super(wcstr, self).replace(*args, **kwargs))
def rstrip(self, *args, **kwargs):
return wcstr(super(wcstr, self).rstrip(*args, **kwargs))
def strip(self, *args, **kwargs):
return wcstr(super(wcstr, self).strip(*args, **kwargs))
def swapcase(self, *args, **kwargs):
return wcstr(super(wcstr, self).swapcase(*args, **kwargs))
def title(self, *args, **kwargs):
return wcstr(super(wcstr, self).title(*args, **kwargs))
def translate(self, *args, **kwargs):
return wcstr(super(wcstr, self).translate(*args, **kwargs))
def upper(self, *args, **kwargs):
return wcstr(super(wcstr, self).upper(*args, **kwargs))
def zfill(self, *args, **kwargs):
return wcstr(super(wcstr, self).zfill(*args, **kwargs))
| class Wcstr(str):
def __new__(*args, **kwargs):
return str.__new__(*args, **kwargs)
def __init__(self, *args, **kwargs):
self._update()
def _update(self):
self.bitindex = []
for (i, j) in zip(str(self), range(len(str(self)))):
iwidth = 1 if len(i.encode('utf8')) <= 2 else 2
self.bitindex += [j] * iwidth
def __len__(self):
return len(self.bitindex)
def __getitem__(self, y):
if type(y) == int:
return wcstr(super(wcstr, self).__getitem__(self.bitindex[y]))
elif type(y) == slice:
start = self.bitindex[y.start] if y.start else None
stop = self.bitindex[y.stop] if y.stop else None
step = y.step
return wcstr(super(wcstr, self).__getitem__(slice(start, stop, step)))
else:
return
def dupstr(self):
return ''.join([self[i] for i in range(len(self))])
def __add__(self, *args, **kwargs):
return wcstr(super(wcstr, self).__add__(*args, **kwargs))
def __mul__(self, value):
return wcstr(super(wcstr, self).__mul__(value))
def __rmul__(self, *args, **kwargs):
return wcstr(super(wcstr, self).__rmul__(*args, **kwargs))
def __format__(self, *args, **kwargs):
return wcstr(super(wcstr, self).__format__(*args, **kwargs))
def center(self, width, fillchar=' '):
filllen = (width - len(self)) // 2
return wcstr(fillchar * filllen + self + fillchar * (width - len(self) - filllen))
def ljust(self, width, fillchar=' '):
return wcstr(super(wcstr, self).ljust(width - len(self) + len(str(self)), fillchar))
def rjust(self, width, fillchar=' '):
return wcstr(super(wcstr, self).rjust(width - len(self) + len(str(self)), fillchar))
def casefold(self, *args, **kwargs):
return wcstr(super(wcstr, self).casefold(*args, **kwargs))
def capitalize(self, *args, **kwargs):
return wcstr(super(wcstr, self).capitalize(*args, **kwargs))
def expandtabs(self, *args, **kwargs):
return wcstr(super(wcstr, self).expandtabs(*args, **kwargs))
def format(self, *args, **kwargs):
return wcstr(super(wcstr, self).format(*args, **kwargs))
def format_map(self, *args, **kwargs):
return wcstr(super(wcstr, self).format_map(*args, **kwargs))
def join(self, *args, **kwargs):
return wcstr(super(wcstr, self).join(*args, **kwargs))
def lower(self, *args, **kwargs):
return wcstr(super(wcstr, self).lower(*args, **kwargs))
def lstrip(self, *args, **kwargs):
return wcstr(super(wcstr, self).lstrip(*args, **kwargs))
def replace(self, *args, **kwargs):
return wcstr(super(wcstr, self).replace(*args, **kwargs))
def rstrip(self, *args, **kwargs):
return wcstr(super(wcstr, self).rstrip(*args, **kwargs))
def strip(self, *args, **kwargs):
return wcstr(super(wcstr, self).strip(*args, **kwargs))
def swapcase(self, *args, **kwargs):
return wcstr(super(wcstr, self).swapcase(*args, **kwargs))
def title(self, *args, **kwargs):
return wcstr(super(wcstr, self).title(*args, **kwargs))
def translate(self, *args, **kwargs):
return wcstr(super(wcstr, self).translate(*args, **kwargs))
def upper(self, *args, **kwargs):
return wcstr(super(wcstr, self).upper(*args, **kwargs))
def zfill(self, *args, **kwargs):
return wcstr(super(wcstr, self).zfill(*args, **kwargs)) |
def twenty_twenty():
"""Come up with the most creative expression that evaluates to 2020,
using only numbers and the +, *, and - operators.
>>> twenty_twenty()
2020
"""
return 2019+1 | def twenty_twenty():
"""Come up with the most creative expression that evaluates to 2020,
using only numbers and the +, *, and - operators.
>>> twenty_twenty()
2020
"""
return 2019 + 1 |
T = (1,) + (2,3)
print(T)
print(type(T)) #<class 'tuple'>
T = T[0], T[1:2], T * 3 # (1, (2,), (1, 2, 3, 1, 2, 3, 1, 2, 3))
print(T)
# sorting is not available
T = ('aa', 'cc', 'dd', 'bb')
tmp = list(T)
tmp.sort()
T = tuple(tmp)
print(T)
# or sorted(T)
T = ('aa', 'cc', 'dd', 'bb')
T = sorted(T) # ['aa', 'bb', 'cc', 'dd']
print(T)
T = 1, 2, 3, 4, 5
L = [x + 100 for x in T]
print(L) # [101, 102, 103, 104, 105]
T = 1, 2, 2, 3, 4, 2, 5
print(T.count(2)) # 3
print(T.index(2)) # 1
print(T.index(2, 3)) # 5
T = (1, [2, 3], 4)
# T[0] = 'test' - error
T[1].append('test')
print(T) # (1, [2, 3, 'test'], 4)
| t = (1,) + (2, 3)
print(T)
print(type(T))
t = (T[0], T[1:2], T * 3)
print(T)
t = ('aa', 'cc', 'dd', 'bb')
tmp = list(T)
tmp.sort()
t = tuple(tmp)
print(T)
t = ('aa', 'cc', 'dd', 'bb')
t = sorted(T)
print(T)
t = (1, 2, 3, 4, 5)
l = [x + 100 for x in T]
print(L)
t = (1, 2, 2, 3, 4, 2, 5)
print(T.count(2))
print(T.index(2))
print(T.index(2, 3))
t = (1, [2, 3], 4)
T[1].append('test')
print(T) |
class Solution:
def exist(self, board, word):
m, n, o = len(board), len(board and board[0]), len(word)
def explore(i, j, k, q):
for x, y in ((i - 1, j), (i, j - 1), (i + 1, j), (i, j + 1)):
if k>=o or (0<=x<m and 0<=y<n and board[x][y]==word[k] and (x,y) not in q and explore(x,y,k+1,q|{(x,y)})): return True
return False
for i in range(m):
for j in range(n):
if board[i][j] == word[0] and explore(i, j, 1, {(i, j)}): return True
return False | class Solution:
def exist(self, board, word):
(m, n, o) = (len(board), len(board and board[0]), len(word))
def explore(i, j, k, q):
for (x, y) in ((i - 1, j), (i, j - 1), (i + 1, j), (i, j + 1)):
if k >= o or (0 <= x < m and 0 <= y < n and (board[x][y] == word[k]) and ((x, y) not in q) and explore(x, y, k + 1, q | {(x, y)})):
return True
return False
for i in range(m):
for j in range(n):
if board[i][j] == word[0] and explore(i, j, 1, {(i, j)}):
return True
return False |
# Copyright 2013-2021 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
class RHdrcde(RPackage):
"""Computation of highest density regions in one and two
dimensions, kernel estimation of univariate density functions
conditional on one covariate,and multimodal regression."""
cran = 'hdrcde'
version('3.4', sha256='4341c6a021da46dcae3b1ef6d580e84dcf625c2b2139f537d0c26ec90899149b')
depends_on('r@2.15:', type=('build', 'run'))
depends_on('r-locfit', type=('build', 'run'))
depends_on('r-ash', type=('build', 'run'))
depends_on('r-ks', type=('build', 'run'))
depends_on('r-kernsmooth', type=('build', 'run'))
depends_on('r-ggplot2', type=('build', 'run'))
depends_on('r-rcolorbrewer', type=('build', 'run'))
| class Rhdrcde(RPackage):
"""Computation of highest density regions in one and two
dimensions, kernel estimation of univariate density functions
conditional on one covariate,and multimodal regression."""
cran = 'hdrcde'
version('3.4', sha256='4341c6a021da46dcae3b1ef6d580e84dcf625c2b2139f537d0c26ec90899149b')
depends_on('r@2.15:', type=('build', 'run'))
depends_on('r-locfit', type=('build', 'run'))
depends_on('r-ash', type=('build', 'run'))
depends_on('r-ks', type=('build', 'run'))
depends_on('r-kernsmooth', type=('build', 'run'))
depends_on('r-ggplot2', type=('build', 'run'))
depends_on('r-rcolorbrewer', type=('build', 'run')) |
f=open("input.txt")
Input=sorted(map(int, f.read().split("\n")))
Input = [0] + Input
f.close()
print(Input)
combinationCounts = [1] + [0] * (len(Input) - 1)
for i, value in enumerate(Input):
for j, adapterValue in enumerate(Input[i+1:], start=i+1):
if(adapterValue > value + 3):
break
combinationCounts[j] += combinationCounts[i]
print(combinationCounts)
| f = open('input.txt')
input = sorted(map(int, f.read().split('\n')))
input = [0] + Input
f.close()
print(Input)
combination_counts = [1] + [0] * (len(Input) - 1)
for (i, value) in enumerate(Input):
for (j, adapter_value) in enumerate(Input[i + 1:], start=i + 1):
if adapterValue > value + 3:
break
combinationCounts[j] += combinationCounts[i]
print(combinationCounts) |
# coding: utf-8
country = {
'ARG': 'Argentina',
'BOL': 'Bolivia',
'CHI': 'Chile',
'COL': 'Colombia',
'COS': 'Costa Rica',
'CUB': 'Cuba',
'EQU': 'Ecuador',
'SPA': 'Spain',
'MEX': 'Mexico',
'PER': 'Peru',
'POR': 'Portugal',
'BRA': 'Brazil',
'SOU': 'South Africa',
'URY': 'Uruguay',
'VEN': 'Venezuela',
'BUL': 'Switzerland',
'ANN': 'Italy',
'MED': 'United States',
'REV': 'United States'
}
| country = {'ARG': 'Argentina', 'BOL': 'Bolivia', 'CHI': 'Chile', 'COL': 'Colombia', 'COS': 'Costa Rica', 'CUB': 'Cuba', 'EQU': 'Ecuador', 'SPA': 'Spain', 'MEX': 'Mexico', 'PER': 'Peru', 'POR': 'Portugal', 'BRA': 'Brazil', 'SOU': 'South Africa', 'URY': 'Uruguay', 'VEN': 'Venezuela', 'BUL': 'Switzerland', 'ANN': 'Italy', 'MED': 'United States', 'REV': 'United States'} |
class Solution:
def subsets(self, nums):
count = len(nums)
result = [[]]
for i in range(1, 2 ** count):
result.append([nums[j] for j in range(count) if i & (2 ** j)])
return result
| class Solution:
def subsets(self, nums):
count = len(nums)
result = [[]]
for i in range(1, 2 ** count):
result.append([nums[j] for j in range(count) if i & 2 ** j])
return result |
class Solution:
def maximumTime(self, time: str) -> str:
hour = time.split(':')[0]
minite = time.split(':')[1]
if hour[0] == '?':
if hour[1] == '?':
res_hour = '23'
elif hour[1] <= '3':
res_hour = str(2)+str(hour[1])
else:
res_hour = str(1)+str(hour[1])
else:
if hour[1] == '?':
if hour[0] <= '1':
res_hour = str(hour[0])+str(9)
else:
res_hour = str(hour[0])+str(3)
else:
res_hour = hour
if minite[0] == '?':
if minite[1] == '?':
res_minite = '59'
else:
res_minite = str(5)+str(minite[1])
else:
if minite[1] == '?':
res_minite = str(minite[0])+str(9)
else:
res_minite = minite
return res_hour+':'+res_minite
| class Solution:
def maximum_time(self, time: str) -> str:
hour = time.split(':')[0]
minite = time.split(':')[1]
if hour[0] == '?':
if hour[1] == '?':
res_hour = '23'
elif hour[1] <= '3':
res_hour = str(2) + str(hour[1])
else:
res_hour = str(1) + str(hour[1])
elif hour[1] == '?':
if hour[0] <= '1':
res_hour = str(hour[0]) + str(9)
else:
res_hour = str(hour[0]) + str(3)
else:
res_hour = hour
if minite[0] == '?':
if minite[1] == '?':
res_minite = '59'
else:
res_minite = str(5) + str(minite[1])
elif minite[1] == '?':
res_minite = str(minite[0]) + str(9)
else:
res_minite = minite
return res_hour + ':' + res_minite |
texto = 'python'
for l in texto:
if l == 't':
l += 't'.upper()
print(l,end='')
else:
print(l,end='') | texto = 'python'
for l in texto:
if l == 't':
l += 't'.upper()
print(l, end='')
else:
print(l, end='') |
# ------------------------------
# 722. Remove Comments
#
# Description:
#
# Too long description. Check https://leetcode.com/problems/remove-comments/description/
#
# Example 2:
# Input:
# source = ["a/*comment", "line", "more_comment*/b"]
# Output: ["ab"]
# Explanation: The original source string is "a/*comment\nline\nmore_comment*/b", where we have bolded the newline characters. After deletion, the implicit newline characters are deleted, leaving the string "ab", which when delimited by newline characters becomes ["ab"].
#
# Version: 1.0
# 09/14/18 by Jianfa
# ------------------------------
class Solution(object):
def removeComments(self, source):
"""
:type source: List[str]
:rtype: List[str]
"""
inCommentBlock = False
res = []
for line in source:
if not inCommentBlock:
newline = []
i = 0
while i < len(line):
if line[i:i+2] == '/*' and not inCommentBlock:
inCommentBlock = True
i += 1
elif line[i:i+2] == '*/' and inCommentBlock:
inCommentBlock = False
i += 1
elif line[i:i+2] == '//' and not inCommentBlock:
break
elif not inCommentBlock:
newline.append(line[i])
i += 1
if newline and not inCommentBlock:
res.append("".join(newline))
return res
# Used for testing
if __name__ == "__main__":
test = Solution()
# ------------------------------
# Summary:
# Take care of the second example.
# e.g.
# a = 1; /* this
# is a comment */ b = 1;
#
# will return
# a = 1; b = 1; | class Solution(object):
def remove_comments(self, source):
"""
:type source: List[str]
:rtype: List[str]
"""
in_comment_block = False
res = []
for line in source:
if not inCommentBlock:
newline = []
i = 0
while i < len(line):
if line[i:i + 2] == '/*' and (not inCommentBlock):
in_comment_block = True
i += 1
elif line[i:i + 2] == '*/' and inCommentBlock:
in_comment_block = False
i += 1
elif line[i:i + 2] == '//' and (not inCommentBlock):
break
elif not inCommentBlock:
newline.append(line[i])
i += 1
if newline and (not inCommentBlock):
res.append(''.join(newline))
return res
if __name__ == '__main__':
test = solution() |
def flatten(lst_of_lst: list) -> list:
return [item for sublist in lst_of_lst for item in sublist]
def tests() -> None:
print(flatten([[1, 2], [3, 4], [5, 6]]))
print(flatten([[1, 4], [5, 4], [5, 6]]))
if __name__ == "__main__":
tests()
| def flatten(lst_of_lst: list) -> list:
return [item for sublist in lst_of_lst for item in sublist]
def tests() -> None:
print(flatten([[1, 2], [3, 4], [5, 6]]))
print(flatten([[1, 4], [5, 4], [5, 6]]))
if __name__ == '__main__':
tests() |
class OceanProviders:
"""Ocean assets class."""
def __init__(self, keeper, did_resolver, config):
self._keeper = keeper
self._did_resolver = did_resolver
self._config = config
def add(self, did, provider_address, account):
return self._keeper.did_registry.add_provider(did, provider_address, account)
def remove(self, did, provider_address, account):
return self._keeper.did_registry.remove_provider(did, provider_address, account)
def list(self, did):
return self._keeper.did_registry.get_did_providers(did)
| class Oceanproviders:
"""Ocean assets class."""
def __init__(self, keeper, did_resolver, config):
self._keeper = keeper
self._did_resolver = did_resolver
self._config = config
def add(self, did, provider_address, account):
return self._keeper.did_registry.add_provider(did, provider_address, account)
def remove(self, did, provider_address, account):
return self._keeper.did_registry.remove_provider(did, provider_address, account)
def list(self, did):
return self._keeper.did_registry.get_did_providers(did) |
class Solution(object):
def removeOuterParentheses(self, s):
"""
:type s: str
:rtype: str
"""
new_string = ''
tmp_string = ''
left = 0
right = 0
for s_ in s:
tmp_string += s_
if s_ == '(':
left += 1
else:
right += 1
if left == right:
left = 0
right = 0
new_string += tmp_string[1:-1]
tmp_string = ''
return new_string | class Solution(object):
def remove_outer_parentheses(self, s):
"""
:type s: str
:rtype: str
"""
new_string = ''
tmp_string = ''
left = 0
right = 0
for s_ in s:
tmp_string += s_
if s_ == '(':
left += 1
else:
right += 1
if left == right:
left = 0
right = 0
new_string += tmp_string[1:-1]
tmp_string = ''
return new_string |
__version__ = "0.19.0-dev"
__libnetwork_plugin_version__ = "v0.8.0-dev"
__libcalico_version__ = "v0.14.0-dev"
__felix_version__ = "1.4.0b1-dev"
| __version__ = '0.19.0-dev'
__libnetwork_plugin_version__ = 'v0.8.0-dev'
__libcalico_version__ = 'v0.14.0-dev'
__felix_version__ = '1.4.0b1-dev' |
#
# Created on Mon Jun 14 2021
#
# The MIT License (MIT)
# Copyright (c) 2021 Vishnu Suresh
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software
# and associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
# subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or substantial
# portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
# TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#
class RightHandTree():
def __init__(self):
self.left = None
self.right = None
self.data = None
def insertNode(self, value):
# print("need to add value ",value)
if self.data == None:
# print("Value added when None ", value)
self.data = value
elif "$" in self.data:
# print("node contain variable need to change ",self.data)
temp = self.data
self.data=value
self.right=None
self.left = RightHandTree()
self.left.insertNode(temp)
elif self.right == None:
# print("Add to right value :- ",value, " Current parent :- ",self.data )
# print("Current tree :- ")
# self.PrintTree()
self.right = RightHandTree()
self.right.insertNode(value=value)
else:
self.right.insertNode(value=value)
# else:
# self.right.insertNode(value=value)
# else:
# if "$" in self.right.data:
# # print("right is not none and $ ",value)
# temp = self.right
# self.right = RightHandTree()
# self.right.insertNode(value=value)
# self.right.left = temp
# else:
# # print("right is not none ",value)
# self.right.insertNode(value)
def PrintTree(self, nodePostion="root", height=0):
print(f'{self.data} : {nodePostion}, Height : {height}'),
if self.left:
self.left.PrintTree(nodePostion="left", height=height+1)
if self.right:
self.right.PrintTree(nodePostion="right", height=height+1)
def makeTape(self):
tape = []
while self.data is not None:
tape.append(self.data)
if self.left is not None:
tape.append(self.left.data)
if self.right is not None:
self = self.right
else:
break
return tape
| class Righthandtree:
def __init__(self):
self.left = None
self.right = None
self.data = None
def insert_node(self, value):
if self.data == None:
self.data = value
elif '$' in self.data:
temp = self.data
self.data = value
self.right = None
self.left = right_hand_tree()
self.left.insertNode(temp)
elif self.right == None:
self.right = right_hand_tree()
self.right.insertNode(value=value)
else:
self.right.insertNode(value=value)
def print_tree(self, nodePostion='root', height=0):
(print(f'{self.data} : {nodePostion}, Height : {height}'),)
if self.left:
self.left.PrintTree(nodePostion='left', height=height + 1)
if self.right:
self.right.PrintTree(nodePostion='right', height=height + 1)
def make_tape(self):
tape = []
while self.data is not None:
tape.append(self.data)
if self.left is not None:
tape.append(self.left.data)
if self.right is not None:
self = self.right
else:
break
return tape |
class Attachment(object):
def __init__(self, name, data, length, content_type, origin):
self.name = name
self.data = data
self.length = length
self.content_type = content_type
self.origin = origin
def __str__(self):
return f"[{self.length} byte; {self.content_type}; {self.name}]"
| class Attachment(object):
def __init__(self, name, data, length, content_type, origin):
self.name = name
self.data = data
self.length = length
self.content_type = content_type
self.origin = origin
def __str__(self):
return f'[{self.length} byte; {self.content_type}; {self.name}]' |
#!/usr/bin/env python
NAME = 'Wallarm (Wallarm Inc.)'
def is_waf(self):
if self.matchheader(('Server', r"nginx\-wallarm")):
return True
return False
| name = 'Wallarm (Wallarm Inc.)'
def is_waf(self):
if self.matchheader(('Server', 'nginx\\-wallarm')):
return True
return False |
# -*- coding: utf-8 -*-
"""
Solution to Project Euler problem 124 - Ordered radicals
Author: Jaime Liew
https://github.com/jaimeliew1/Project_Euler_Solutions
Modified sieve of Eratosthenes that records the product of prime factors. This
list is then sorted and the 10000ths entry is returned.
"""
def run():
N = 100000
rad = {i: 1 for i in range(N + 1)}
rad.pop(0)
is_prime = [True for _ in range(N + 1)]
for i in range(2, N + 1):
n = i
if not is_prime[n]:
continue
rad[n] *= i
n += i
while n <= N:
is_prime[n] = False
rad[n] *= i
n += i
rad_sorted = [k for k, v in sorted(rad.items(), key=lambda item: item[1])]
return rad_sorted[10000 - 1]
if __name__ == "__main__":
print(run())
| """
Solution to Project Euler problem 124 - Ordered radicals
Author: Jaime Liew
https://github.com/jaimeliew1/Project_Euler_Solutions
Modified sieve of Eratosthenes that records the product of prime factors. This
list is then sorted and the 10000ths entry is returned.
"""
def run():
n = 100000
rad = {i: 1 for i in range(N + 1)}
rad.pop(0)
is_prime = [True for _ in range(N + 1)]
for i in range(2, N + 1):
n = i
if not is_prime[n]:
continue
rad[n] *= i
n += i
while n <= N:
is_prime[n] = False
rad[n] *= i
n += i
rad_sorted = [k for (k, v) in sorted(rad.items(), key=lambda item: item[1])]
return rad_sorted[10000 - 1]
if __name__ == '__main__':
print(run()) |
class Point:
def __init__(self, new_x=0, new_y=0):
self.x = new_x
self.y = new_y
def set_point(self, point):
(self.x, self.y) = (point.x, point.y)
| class Point:
def __init__(self, new_x=0, new_y=0):
self.x = new_x
self.y = new_y
def set_point(self, point):
(self.x, self.y) = (point.x, point.y) |
test = { 'name': 'q7b',
'points': 1,
'suites': [ { 'cases': [ { 'code': '>>> '
"movies.head(1)['plots'][0]=='Two "
'imprisoned men bond over a '
'number of years, finding '
'solace and eventual redemption '
'through acts of common '
"decency.'\n"
'True',
'hidden': False,
'locked': False},
{ 'code': ">>> movies['plots'][23]=='An "
'undercover cop and a mole in '
'the police attempt to identify '
'each other while infiltrating '
'an Irish gang in South '
"Boston.'\n"
'True',
'hidden': False,
'locked': False}],
'scored': True,
'setup': '',
'teardown': '',
'type': 'doctest'}]}
| test = {'name': 'q7b', 'points': 1, 'suites': [{'cases': [{'code': ">>> movies.head(1)['plots'][0]=='Two imprisoned men bond over a number of years, finding solace and eventual redemption through acts of common decency.'\nTrue", 'hidden': False, 'locked': False}, {'code': ">>> movies['plots'][23]=='An undercover cop and a mole in the police attempt to identify each other while infiltrating an Irish gang in South Boston.'\nTrue", 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]} |
csp = {
'default-src': [
'\'self\''
],
'script-src': [
'https://kit.fontawesome.com/4b9ba14b0f.js',
'http://localhost:5500/livereload.js',
'https://use.fontawesome.com/releases/v5.3.1/js/all.js',
'http://localhost:5000/static/js/base.js',
'http://localhost:5500/static/js/base.js',
'\'sha256-MclZcNa5vMtp/wzxRW6+KS3i8mRUf6thpmjT3pkIT5I=\''
],
'style-src': [
'\'self\'',
'https://cdnjs.cloudflare.com',
'https://fonts.googleapis.com/css2',
'https://ka-f.fontawesome.com/releases/v5.15.3/css/free-v4-font-face.min.css',
'https://use.fontawesome.com',
'\'sha256-mCk+PuH4k8s22RWyQ0yVST1TXl6y5diityhSgV9XfOc=\'',
'\'sha256-Ni2urx9+Bf7ppgnlSfFIqsvlGMFm+9lurWkFfilXQq8=\'',
'\'sha256-JdCH8SP11p44kp0La4MPFI5qR9musjNwAg5WtqgDI4o=\'',
'\'sha256-bviLPwiqrYk7TOtr5i2eb7I5exfGcGEvVuxmITyg//c=\'',
'\'sha256-tUCWndpLW480EWA+8o4oeW9K2GGRBQIDiewZzv/cL4o=\''
],
'connect-src': [
'https://ka-f.fontawesome.com',
'ws://localhost:5500/livereload'
],
'font-src': [
'https://fonts.gstatic.com',
'https://ka-f.fontawesome.com'
],
'img-src': [
'\'self\'',
'data:'
],
'frame-ancestors': 'none'
} | csp = {'default-src': ["'self'"], 'script-src': ['https://kit.fontawesome.com/4b9ba14b0f.js', 'http://localhost:5500/livereload.js', 'https://use.fontawesome.com/releases/v5.3.1/js/all.js', 'http://localhost:5000/static/js/base.js', 'http://localhost:5500/static/js/base.js', "'sha256-MclZcNa5vMtp/wzxRW6+KS3i8mRUf6thpmjT3pkIT5I='"], 'style-src': ["'self'", 'https://cdnjs.cloudflare.com', 'https://fonts.googleapis.com/css2', 'https://ka-f.fontawesome.com/releases/v5.15.3/css/free-v4-font-face.min.css', 'https://use.fontawesome.com', "'sha256-mCk+PuH4k8s22RWyQ0yVST1TXl6y5diityhSgV9XfOc='", "'sha256-Ni2urx9+Bf7ppgnlSfFIqsvlGMFm+9lurWkFfilXQq8='", "'sha256-JdCH8SP11p44kp0La4MPFI5qR9musjNwAg5WtqgDI4o='", "'sha256-bviLPwiqrYk7TOtr5i2eb7I5exfGcGEvVuxmITyg//c='", "'sha256-tUCWndpLW480EWA+8o4oeW9K2GGRBQIDiewZzv/cL4o='"], 'connect-src': ['https://ka-f.fontawesome.com', 'ws://localhost:5500/livereload'], 'font-src': ['https://fonts.gstatic.com', 'https://ka-f.fontawesome.com'], 'img-src': ["'self'", 'data:'], 'frame-ancestors': 'none'} |
#encoding:utf-8
subreddit = 'pics'
t_channel = '@r_pics_redux'
def send_post(submission, r2t):
return r2t.send_simple(submission,
text=False,
gif=False,
img='{title}\n{short_link}',
album=False,
other=False
)
| subreddit = 'pics'
t_channel = '@r_pics_redux'
def send_post(submission, r2t):
return r2t.send_simple(submission, text=False, gif=False, img='{title}\n{short_link}', album=False, other=False) |
# Lesson3: while loop
# source: code/while.py
text = ''
while text != 'stop':
text = input('Tell me something:\n')
print('you told me:', text)
print('... and I\'m stopping')
| text = ''
while text != 'stop':
text = input('Tell me something:\n')
print('you told me:', text)
print("... and I'm stopping") |
workers = 1
worker_class = 'gevent'
bind = '0.0.0.0:5000'
pidfile = '/tmp/gunicorn-inspector.pid'
debug = True
reload = True
loglevel = 'info'
errorlog = '/tmp/gunicorn_inspector_error.log'
accesslog = '/tmp/gunicorn_inspector_access.log'
daemon = False
| workers = 1
worker_class = 'gevent'
bind = '0.0.0.0:5000'
pidfile = '/tmp/gunicorn-inspector.pid'
debug = True
reload = True
loglevel = 'info'
errorlog = '/tmp/gunicorn_inspector_error.log'
accesslog = '/tmp/gunicorn_inspector_access.log'
daemon = False |
"""
author : Ali Emre SAVAS
Link : https://www.hackerrank.com/challenges/text-wrap/problem
"""
def wrap(string, max_width):
newString = ""
for i in range(0, len(string), max_width):
newString += string[i:(i+max_width)] + "\n" # \n for new line.
# newString = newString[:(len(newString)-1)] If you do not want to print last blank line, you can add this line for this.
return newString
if __name__ == '__main__':
string, max_width = input(), int(input())
result = wrap(string, max_width)
print(result)
| """
author : Ali Emre SAVAS
Link : https://www.hackerrank.com/challenges/text-wrap/problem
"""
def wrap(string, max_width):
new_string = ''
for i in range(0, len(string), max_width):
new_string += string[i:i + max_width] + '\n'
return newString
if __name__ == '__main__':
(string, max_width) = (input(), int(input()))
result = wrap(string, max_width)
print(result) |
# -*- coding: utf8 -*-
########################################################################################
# This file is part of exhale. Copyright (c) 2017-2019, Stephen McDowell. #
# Full BSD 3-Clause license available here: #
# #
# https://github.com/svenevs/exhale/blob/master/LICENSE #
########################################################################################
"""
The ``tests`` package contains all of the test classes / functions.
"""
| """
The ``tests`` package contains all of the test classes / functions.
""" |
# (User) Problem
# We know / We have: 3 number: win draw lose
# We need / We don't have: points for team
# We must: use: 3 points for win, 1 for draw, 0 for loss
# name of function must be: football_points
#
# Solution (Product)
# function with 3 inputs
def football_points(wins, draws, losses):
return wins * 3 + draws
# alt: Lambda Version
#
# football_points = lambda x, y, z: x * 3 + y
| def football_points(wins, draws, losses):
return wins * 3 + draws |
users = [
{ "id": 0, "name": "Hero" },
{ "id": 1, "name": "Dunn" },
{ "id": 2, "name": "Sue" },
{ "id": 3, "name": "Chi" },
{ "id": 4, "name": "Thor" },
{ "id": 5, "name": "Clive" },
{ "id": 6, "name": "Hicks" },
{ "id": 7, "name": "Devin" },
{ "id": 8, "name": "Kate" },
{ "id": 9, "name": "Klein" }
]
friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4),
(4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)]
endorsements = [(0, 1), (1, 0), (0, 2), (2, 0), (1, 2),
(2, 1), (1, 3), (2, 3), (3, 4), (5, 4),
(5, 6), (7, 5), (6, 8), (8, 7), (8, 9)] | users = [{'id': 0, 'name': 'Hero'}, {'id': 1, 'name': 'Dunn'}, {'id': 2, 'name': 'Sue'}, {'id': 3, 'name': 'Chi'}, {'id': 4, 'name': 'Thor'}, {'id': 5, 'name': 'Clive'}, {'id': 6, 'name': 'Hicks'}, {'id': 7, 'name': 'Devin'}, {'id': 8, 'name': 'Kate'}, {'id': 9, 'name': 'Klein'}]
friendships = [(0, 1), (0, 2), (1, 2), (1, 3), (2, 3), (3, 4), (4, 5), (5, 6), (5, 7), (6, 8), (7, 8), (8, 9)]
endorsements = [(0, 1), (1, 0), (0, 2), (2, 0), (1, 2), (2, 1), (1, 3), (2, 3), (3, 4), (5, 4), (5, 6), (7, 5), (6, 8), (8, 7), (8, 9)] |
# Constants
Background = 'FF111111'
BackgroundDark = 'FF0A0A0A'
# OverlayVeryDark = GetAlpha(FF000000, 90),
# OverlayDark = GetAlpha(FF000000, 70),
# OverlayMed = GetAlpha(FF000000, 50),
# OverlayLht = GetAlpha(FF000000, 35),
Border = 'FF1F1F1F'
Empty = 'FF1F1F1F'
Card = 'FF1F1F1F'
Button = 'FF1F1F1F'
ButtonDark = 'FF171717'
ButtonLht = 'FF555555'
ButtonMed = 'FF2D2D2D'
Indicator = 'FF999999'
Text = 'FFFFFFFF'
Subtitle = 'FF999999'
# These are dependent on the regions background color
# TextLht = GetAlpha(FFFFFFFF, 90),
# TextMed = GetAlpha(FFFFFFFF, 75),
# TextDim = GetAlpha(FFFFFFFF, 50),
# TextDis = GetAlpha(FFFFFFFF, 30),
# TextDimDis = GetAlpha(FFFFFFFF, 10),
Transparent = '00000000'
Black = 'FF000000'
Blue = 'FF0033CC'
Red = 'FFC23529'
RedAlt = 'FFD9534F'
Green = 'FF5CB85C'
Orange = 'FFCC7B19'
OrangeLight = 'FFF9BE03'
# Component specific
# SettingsBg = 'FF2C2C2C'
# ScrollbarBg = GetAlpha(FFFFFFFF, 10),
# ScrollbarFgFocus = GetAlpha('Orange' 70),
# ScrollbarFg = GetAlpha(FFFFFFFF, 25),
# IndicatorBorder = 'FF000000'
# Separator = 'FF000000'
# Modal = GetAlpha(FF000000, 85),
# Focus = Orange,
# FocusToggle = OrangeLight,
# ListFocusBg = GetAlpha(FF000000, 40),
# TrackActionsBg = GetAlpha(FF000000, 30),
# ListBg = GetAlpha(FFFFFFFF, 10),
# ListBgNoBlur = GetAlpha(FF666666, 40),
# ListImageBorder = 'FF595959'
SearchBg = 'FF2D2D2D'
SearchButton = 'FF282828'
SearchButtonDark = 'FF1F1F1F'
SearchButtonLight = 'FF555555'
InputBg = 'FF000000'
InputButton = 'FF282828'
InputButtonDark = 'FF1F1F1F'
InputButtonLight = 'FF555555'
class _noAlpha:
def __getattr__(self, name):
return globals()[name][2:]
noAlpha = _noAlpha()
# def getAlpha(color, percent):
# if isinstance(color, basestring):
# color = COLORS[color]
# if isinstance(color, int):
# util.ERROR_LOG(str(color) + " is not found in object")
# return color and int((percent / 100 * 255) - 256)
| background = 'FF111111'
background_dark = 'FF0A0A0A'
border = 'FF1F1F1F'
empty = 'FF1F1F1F'
card = 'FF1F1F1F'
button = 'FF1F1F1F'
button_dark = 'FF171717'
button_lht = 'FF555555'
button_med = 'FF2D2D2D'
indicator = 'FF999999'
text = 'FFFFFFFF'
subtitle = 'FF999999'
transparent = '00000000'
black = 'FF000000'
blue = 'FF0033CC'
red = 'FFC23529'
red_alt = 'FFD9534F'
green = 'FF5CB85C'
orange = 'FFCC7B19'
orange_light = 'FFF9BE03'
search_bg = 'FF2D2D2D'
search_button = 'FF282828'
search_button_dark = 'FF1F1F1F'
search_button_light = 'FF555555'
input_bg = 'FF000000'
input_button = 'FF282828'
input_button_dark = 'FF1F1F1F'
input_button_light = 'FF555555'
class _Noalpha:
def __getattr__(self, name):
return globals()[name][2:]
no_alpha = _no_alpha() |
API_KEY = "PK3OA9F3DZ47286MDM81"
SECRET_KEY = "oJxGYAqcrIrhpLyXGJyIb3wsCrh2cR3xwaO662yp"
HEADERS = {
'APCA-API-KEY-ID': API_KEY,
'APCA-API-SECRET-KEY': SECRET_KEY
}
BARS_URL = 'https://data.alpaca.markets/v1/bars'
| api_key = 'PK3OA9F3DZ47286MDM81'
secret_key = 'oJxGYAqcrIrhpLyXGJyIb3wsCrh2cR3xwaO662yp'
headers = {'APCA-API-KEY-ID': API_KEY, 'APCA-API-SECRET-KEY': SECRET_KEY}
bars_url = 'https://data.alpaca.markets/v1/bars' |
n=int(input())
a=[int(i) for i in input().split()]
d=[a[0]]
for i in range(1,n):
x=a[i]
if x>d[-1]: d+=[x]
elif d[0]>=x: d[0]=x
else:
l,r=0,len(d)
while(r>l+1):
m=(l+r)//2
if(d[m]<x): l=m
else: r=m
d[r]=x
print(len(d))
| n = int(input())
a = [int(i) for i in input().split()]
d = [a[0]]
for i in range(1, n):
x = a[i]
if x > d[-1]:
d += [x]
elif d[0] >= x:
d[0] = x
else:
(l, r) = (0, len(d))
while r > l + 1:
m = (l + r) // 2
if d[m] < x:
l = m
else:
r = m
d[r] = x
print(len(d)) |
#!/usr/bin/env python3
# Write a program that prints out the position, frame, and letter of the DNA
# Try coding this with a single loop
# Try coding this with nested loops
dna = 'ATGGCCTTT'
"""
0 0 A
1 1 T
2 2 G
3 0 G
4 1 C
5 2 C
6 0 T
7 1 T
8 2 T
"""
#Frame is index modulo 3...
print("single loop")
for index in range(0,len(dna)):
print (index, index % 3, dna[index])
# two loops...
# NOTE: this does no range checking... only works if the
# length of dna is a multiple of 3.
#
# Outer loop iterates over index
# Inner loop iterates over frame
print("\nnested loops")
framesize = 3
for index in range(0, len(dna), framesize):
for frameOffset in range(0, framesize):
print (index+frameOffset, frameOffset, dna[index+frameOffset])
| dna = 'ATGGCCTTT'
'\n0 0 A\n1 1 T\n2 2 G\n3 0 G\n4 1 C\n5 2 C\n6 0 T\n7 1 T\n8 2 T\n'
print('single loop')
for index in range(0, len(dna)):
print(index, index % 3, dna[index])
print('\nnested loops')
framesize = 3
for index in range(0, len(dna), framesize):
for frame_offset in range(0, framesize):
print(index + frameOffset, frameOffset, dna[index + frameOffset]) |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 26 20:22:25 2020
@author: xianbingu
"""
def maximum(A):
#delete the following line and insert your code
#the built-in max() is not allowed to use here
pass
##---test---##
##You can comment out them when you write and test your code.
if __name__ == "__main__":
A = [8]
print(maximum(A))
A = [3, 2, 5, 7, 9, 10]
print(maximum(A))
| """
Created on Mon Oct 26 20:22:25 2020
@author: xianbingu
"""
def maximum(A):
pass
if __name__ == '__main__':
a = [8]
print(maximum(A))
a = [3, 2, 5, 7, 9, 10]
print(maximum(A)) |
# Copyright 2016 Twitter. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
################################################################################
# Global variable to store config map and verbosity
################################################################################
config_opts = dict()
verbose_flag = False
trace_execution_flag = False
################################################################################
# Get config opts from the global variable
################################################################################
def get_heron_config():
opt_list = []
for (k, v) in config_opts.items():
opt_list.append('%s=%s' % (k, v))
all_opts = '-Dheron.options=' + (','.join(opt_list)).replace(' ', '%%%%')
return all_opts
################################################################################
# Get config opts from the config map
################################################################################
def get_config(k):
global config_opts
if config_opts.has_key(k):
return config_opts[k]
return None
################################################################################
# Store a config opt in the config map
################################################################################
def set_config(k, v):
global config_opts
config_opts[k] = v
################################################################################
# Clear all the config in the config map
################################################################################
def clear_config():
global config_opts
config_opts = dict()
################################################################################
# Methods to get and set verbose levels
################################################################################
def set_verbose():
global verbose_flag
verbose_flag = True
def verbose():
global verbose_flag
return verbose_flag
################################################################################
# Methods to get and set trace execution
################################################################################
def set_trace_execution():
global trace_execution_flag
trace_execution_flag = True
set_verbose()
def trace_execution():
global trace_execution_flag
return trace_execution_flag
| config_opts = dict()
verbose_flag = False
trace_execution_flag = False
def get_heron_config():
opt_list = []
for (k, v) in config_opts.items():
opt_list.append('%s=%s' % (k, v))
all_opts = '-Dheron.options=' + ','.join(opt_list).replace(' ', '%%%%')
return all_opts
def get_config(k):
global config_opts
if config_opts.has_key(k):
return config_opts[k]
return None
def set_config(k, v):
global config_opts
config_opts[k] = v
def clear_config():
global config_opts
config_opts = dict()
def set_verbose():
global verbose_flag
verbose_flag = True
def verbose():
global verbose_flag
return verbose_flag
def set_trace_execution():
global trace_execution_flag
trace_execution_flag = True
set_verbose()
def trace_execution():
global trace_execution_flag
return trace_execution_flag |
ENABLE_EXTERNAL_PATHS = False
SOURCE_DEFINITION = ['Landroid/telephony/TelephonyManager;->getDeviceId(',
'Landroid/telephony/TelephonyManager;->getSubscriberId(',
'Landroid/telephony/TelephonyManager;->getSimSerialNumber(',
'Landroid/telephony/TelephonyManager;->getLine1Number(']
#[
# 'Landroid/accounts/AccountManager;->getAccounts(',
# 'Landroid/app/Activity;->findViewById(',
# 'Landroid/app/Activity;->getIntent(',
# 'Landroid/app/Activity;->onActivityResult(',
# 'Landroid/app/PendingIntent;->getActivity(',
# 'Landroid/app/PendingIntent;->getBroadcast(',
# 'Landroid/app/PendingIntent;->getService(',
# 'Landroid/bluetooth/BluetoothAdapter;->getAddress(',
# 'Landroid/content/ContentResolver;->query(',
# 'Landroid/content/pm/PackageManager;->getInstalledApplications(',
# 'Landroid/content/pm/PackageManager;->getInstalledPackages(',
# 'Landroid/content/pm/PackageManager;->queryBroadcastReceivers(',
# 'Landroid/content/pm/PackageManager;->queryContentProviders(',
# 'Landroid/content/pm/PackageManager;->queryIntentActivities(',
# 'Landroid/content/pm/PackageManager;->queryIntentServices(',
# 'Landroid/content/SharedPreferences;->getDefaultSharedPreferences(',
# 'Landroid/database/Cursor;->getString(',
# 'Landroid/database/sqlite/SQLiteDatabase;->query(',
# 'Landroid/location/Location;->getLatitude(',
# 'Landroid/location/Location;->getLongitude(',
# 'Landroid/location/LocationManager;->getLastKnownLocation(',
# 'Landroid/media/AudioRecord;->read(',
# 'Landroid/net/wifi/WifiInfo;->getMacAddress(',
# 'Landroid/net/wifi/WifiInfo;->getSSID(',
# 'Landroid/os/Bundle;->get(',
# 'Landroid/os/Bundle;->getBoolean(',
# 'Landroid/os/Bundle;->getBooleanArray(',
# 'Landroid/os/Bundle;->getBundle(',
# 'Landroid/os/Bundle;->getByte(',
# 'Landroid/os/Bundle;->getByteArray(',
# 'Landroid/os/Bundle;->getChar(',
# 'Landroid/os/Bundle;->getCharArray(',
# 'Landroid/os/Bundle;->getCharSequence(',
# 'Landroid/os/Bundle;->getCharSequenceArray(',
# 'Landroid/os/Bundle;->getCharSequenceArrayList(',
# 'Landroid/os/Bundle;->getClassLoader(',
# 'Landroid/os/Bundle;->getDouble(',
# 'Landroid/os/Bundle;->getDoubleArray(',
# 'Landroid/os/Bundle;->getFloat(',
# 'Landroid/os/Bundle;->getFloatArray(',
# 'Landroid/os/Bundle;->getInt(',
# 'Landroid/os/Bundle;->getIntArray(',
# 'Landroid/os/Bundle;->getIntegerArrayList(',
# 'Landroid/os/Bundle;->getLong(',
# 'Landroid/os/Bundle;->getLongArray(',
# 'Landroid/os/Bundle;->getParcelable(',
# 'Landroid/os/Bundle;->getParcelableArray(',
# 'Landroid/os/Bundle;->getParcelableArrayList(',
# 'Landroid/os/Bundle;->getSerializable(',
# 'Landroid/os/Bundle;->getShort(',
# 'Landroid/os/Bundle;->getShortArray(',
# 'Landroid/os/Bundle;->getSparseParcelableArray(',
# 'Landroid/os/Bundle;->getString(',
# 'Landroid/os/Bundle;->getStringArrayList(',
# 'Landroid/os/Handler;->obtainMessage(',
# 'Landroid/provider/Browser;->getAllBookmarks(',
# 'Landroid/provider/Browser;->getAllVisitedUrls(',
# 'Landroid/telephony/gsm/GsmCellLocation;->getCid(',
# 'Landroid/telephony/gsm/GsmCellLocation;->getLac(',
# 'Landroid/telephony/TelephonyManager;->getDeviceId(',
# 'Landroid/telephony/TelephonyManager;->getLine1Number(',
# 'Landroid/telephony/TelephonyManager;->getSimSerialNumber(',
# 'Landroid/telephony/TelephonyManager;->getSubscriberId(',
# 'Ljava/net/URLConnection;->getInputStream(',
# 'Ljava/net/URLConnection;->getOutputStream(',
# 'Ljava/net/URL;->openConnection(',
# 'Ljava/util/Calendar;->getTimeZone(',
# 'Ljava/util/Locale;->getCountry(',
# 'Lorg/apache/http/HttpResponse;->getEntity(',
# 'Lorg/apache/http/util/EntityUtils;->getContentCharSet(',
# 'Lorg/apache/http/util/EntityUtils;->toByteArray(',
# 'Lorg/apache/http/util/EntityUtils;->toString(',
#]# SINKS taken from the flowdroid
SINK_DEFINITION = ['Landroid/util/Log;->d(',
'Landroid/util/Log;->e(',
'Landroid/util/Log;->i(',
'Landroid/util/Log;->v(',
'Landroid/util/Log;->w(',
'Landroid/util/Log;->wtf(',
'Ljava.io.OutputStream;->write('
]
#[
# 'Landroid/app/Activity;->bindService(',
# 'Landroid/app/Activity;->sendBroadcast(',
# 'Landroid/app/Activity;->sendBroadcastAsUser(',
# 'Landroid/app/Activity;->sendOrderedBroadcast(',
# 'Landroid/app/Activity;->sendOrderedBroadcastAsUser(',
# 'Landroid/app/Activity;->sendStickyBroadcast(',
# 'Landroid/app/Activity;->sendStickyBroadcastAsUser(',
# 'Landroid/app/Activity;->sendStickyOrderedBroadcast(',
# 'Landroid/app/Activity;->sendStickyOrderedBroadcastAsUser(',
# 'Landroid/app/Activity;->setResult(',
# 'Landroid/app/Activity;->startActivities(',
# 'Landroid/app/Activity;->startActivity(',
# 'Landroid/app/Activity;->startActivityForResult(',
# 'Landroid/app/Activity;->startActivityFromChild(',
# 'Landroid/app/Activity;->startActivityFromFragment(',
# 'Landroid/app/Activity;->startActivityIfNeeded(',
# 'Landroid/app/Activity;->startService(',
# 'Landroid/content/ContentResolver;->delete(',
# 'Landroid/content/ContentResolver;->insert(',
# 'Landroid/content/ContentResolver;->query(',
# 'Landroid/content/ContentResolver;->update(',
# 'Landroid/content/Context;->bindService(',
# 'Landroid/content/Context;->registerReceiver(',
# 'Landroid/content/Context;->sendBroadcast(',
# 'Landroid/content/Context;->startActivities(',
# 'Landroid/content/Context;->startActivity(',
# 'Landroid/content/Context;->startService(',
# 'Landroid/content/IntentFilter;->addAction(',
# 'Landroid/content/Intent;->setAction(',
# 'Landroid/content/Intent;->setClassName(',
# 'Landroid/content/Intent;->setComponent(',
# 'Landroid/content/SharedPreferences$Editor;->putBoolean(',
# 'Landroid/content/SharedPreferences$Editor;->putFloat(',
# 'Landroid/content/SharedPreferences$Editor;->putInt(',
# 'Landroid/content/SharedPreferences$Editor;->putLong(',
# 'Landroid/content/SharedPreferences$Editor;->putString(',
# 'Landroid/media/MediaRecorder;->setPreviewDisplay(',
# 'Landroid/media/MediaRecorder;->setVideoSource(',
# 'Landroid/media/MediaRecorder;->start(',
# 'Landroid/os/Bundle;->putAll(',
# 'Landroid/os/Bundle;->putBinder(',
# 'Landroid/os/Bundle;->putBoolean(',
# 'Landroid/os/Bundle;->putBooleanArray(',
# 'Landroid/os/Bundle;->putBundle(',
# 'Landroid/os/Bundle;->putByte(',
# 'Landroid/os/Bundle;->putByteArray(',
# 'Landroid/os/Bundle;->putChar(',
# 'Landroid/os/Bundle;->putCharArray(',
# 'Landroid/os/Bundle;->putCharSequence(',
# 'Landroid/os/Bundle;->putCharSequenceArray(',
# 'Landroid/os/Bundle;->putCharSequenceArrayList(',
# 'Landroid/os/Bundle;->putDouble(',
# 'Landroid/os/Bundle;->putDoubleArray(',
# 'Landroid/os/Bundle;->putFloat(',
# 'Landroid/os/Bundle;->putFloatArray(',
# 'Landroid/os/Bundle;->putInt(',
# 'Landroid/os/Bundle;->putIntArray(',
# 'Landroid/os/Bundle;->putIntegerArrayList(',
# 'Landroid/os/Bundle;->putLong(',
# 'Landroid/os/Bundle;->putLongArray(',
# 'Landroid/os/Bundle;->putParcelable(',
# 'Landroid/os/Bundle;->putParcelableArray(',
# 'Landroid/os/Bundle;->putParcelableArrayList(',
# 'Landroid/os/Bundle;->putSerializable(',
# 'Landroid/os/Bundle;->putShort(',
# 'Landroid/os/Bundle;->putShortArray(',
# 'Landroid/os/Bundle;->putSparseParcelableArray(',
# 'Landroid/os/Bundle;->putString(',
# 'Landroid/os/Bundle;->putStringArray(',
# 'Landroid/os/Bundle;->putStringArrayList(',
# 'Landroid/os/Handler;->sendMessage(',
# 'Landroid/telephony/SmsManager;->sendDataMessage(',
# 'Landroid/telephony/SmsManager;->sendMultipartTextMessage(',
# 'Landroid/telephony/SmsManager;->sendTextMessage(',
# 'Landroid/util/Log;->d(',
# 'Landroid/util/Log;->e(',
# 'Landroid/util/Log;->i(',
# 'Landroid/util/Log;->v(',
# 'Landroid/util/Log;->w(',
# 'Landroid/util/Log;->wtf(',
# 'Ljava/io/FileOutputStream;->write(',
# 'Ljava/io/OutputStream;->write(',
# 'Ljava/io/Writer;->write(',
# 'Ljava/net/Socket;->connect(',
# 'Ljava/net/URLConnection;->setRequestProperty(',
# 'Ljava/net/URL;-><init>(',
# 'Ljava/net/URL;->set(',
# 'Lorg/apache/http/client/HttpClient;->execute(',
# 'Lorg/apache/http/impl/client/DefaultHttpClient;->execute(',
# 'Lorg/apache/http/message/BasicNameValuePair;-><init>('
#]
NOPS = ['return-void',
'return',
'return-wide',
'return-object',
'monitor-exit',
'monitor-enter',
'move-exception', #only for backward analysis. in forward, this can be a tainting propagation, and will be checked!
'check-cast',
'instance-of',
'array-length', #@todo: hidden propagation?
'goto',
'goto/16',
'goto/32',
'packed-switch', #@todo: hidden propagation?
'sparse-switch', #@todo: hidden propagation?
'cmpl-float',
'cmpg-float',
'cmpl-double',
'cmpg-double',
'cmp-long',
'if-eq',
'if-ne',
'if-lt',
'if-ge',
'if-gt',
'if-le',
'if-eqz',
'if-nez',
'if-ltz',
'if-gez',
'if-gtz',
'if-lez'
]
UNTAINT = ['const/4',
'const/16',
'const',
'const/high16',
'const-wide/16',
'const-wide/32',
'const-wide',
'const-wide/high16',
'const-string',
'const-string/jumbo',
'const-class',
'new-instance', #what if the init taints THIS? -> then init is called afterwards!
'new-array',
'fill-array-data' #@sketchy
]
INSTRUCTION_PROPAGATION = { # if key is the instruction:
# taint all variables in value[1] (0-indexed, 0 could be target!)
# IF at least one entry in value[0] is tainted after this line
'move': [[0], [1]],
'move/from16': [[0], [1]],
'move-wide': [[0], [1]],
'move-wide/from16': [[0], [1]],
'move-object': [[0], [1]],
'move-object/from16': [[0], [1]],
'aget': [[0], [1]],
'aget-wide': [[0], [1]], #@todo: does not taint the index!
'aget-object': [[0], [1]],
'aget-boolean': [[0], [1]],
'aget-byte': [[0], [1]],
'aget-char': [[0], [1]],
'aget-short': [[0], [1]],
'aput': [[1], [0]],
'aput-wide': [[1], [0]],
'aput-object': [[1], [0]],
'aput-boolean': [[1], [0]],
'aput-byte': [[1], [0]],
'aput-char': [[1], [0]],
'aput-short': [[1], [0]],
'neg-int': [[0], [1]],
'not-int': [[0], [1]],
'neg-long': [[0], [1]],
'not-long': [[0], [1]],
'neg-float': [[0], [1]],
'not-float': [[0], [1]],
'neg-double': [[0], [1]],
'not-double': [[0], [1]],
'int-to-long': [[0], [1]],
'int-to-float': [[0], [1]],
'int-to-double': [[0], [1]],
'long-to-int': [[0], [1]],
'long-to-float': [[0], [1]],
'long-to-double': [[0], [1]],
'float-to-int': [[0], [1]],
'float-to-long': [[0], [1]],
'float-to-double': [[0], [1]],
'double-to-int': [[0], [1]],
'double-to-long': [[0], [1]],
'double-to-float': [[0], [1]],
'int-to-byte': [[0], [1]],
'int-to-char': [[0], [1]],
'int-to-short': [[0], [1]],
'add-int': [[0], [1, 2]],
'sub-int': [[0], [1, 2]],
'rsub-int': [[0], [1, 2]],
'mul-int': [[0], [1, 2]],
'div-int': [[0], [1, 2]],
'rem-int': [[0], [1, 2]],
'and-int': [[0], [1, 2]],
'or-int': [[0], [1, 2]],
'xor-int': [[0], [1, 2]],
'shl-int': [[0], [1, 2]],
'shr-int': [[0], [1, 2]],
'ushr-int': [[0], [1, 2]],
'add-long': [[0], [1, 2]],
'sub-long': [[0], [1, 2]],
'mul-long': [[0], [1, 2]],
'div-long': [[0], [1, 2]],
'rem-long': [[0], [1, 2]],
'and-long': [[0], [1, 2]],
'or-long': [[0], [1, 2]],
'xor-long': [[0], [1, 2]],
'shl-long': [[0], [1, 2]],
'shr-long': [[0], [1, 2]],
'ushr-long': [[0], [1, 2]],
'add-float': [[0], [1, 2]],
'sub-float': [[0], [1, 2]],
'mul-float': [[0], [1, 2]],
'div-float': [[0], [1, 2]],
'rem-float': [[0], [1, 2]],
'add-double': [[0], [1, 2]],
'sub-double': [[0], [1, 2]],
'mul-double': [[0], [1, 2]],
'div-double': [[0], [1, 2]],
'rem-double': [[0], [1, 2]],
'add-int/2addr': [[0],[0, 1]],
'sub-int/2addr': [[0],[0, 1]],
'mul-int/2addr': [[0],[0, 1]],
'div-int/2addr': [[0],[0, 1]],
'rem-int/2addr': [[0],[0, 1]],
'and-int/2addr': [[0],[0, 1]],
'or-int/2addr': [[0],[0, 1]],
'xor-int/2addr': [[0],[0, 1]],
'shl-int/2addr': [[0],[0, 1]],
'shr-int/2addr': [[0],[0, 1]],
'ushr-int/2addr': [[0],[0, 1]],
'add-long/2addr': [[0],[0, 1]],
'sub-long/2addr': [[0],[0, 1]],
'mul-long/2addr': [[0],[0, 1]],
'div-long/2addr': [[0],[0, 1]],
'rem-long/2addr': [[0],[0, 1]],
'and-long/2addr': [[0],[0, 1]],
'or-long/2addr': [[0],[0, 1]],
'xor-long/2addr': [[0],[0, 1]],
'shl-long/2addr': [[0],[0, 1]],
'shr-long/2addr': [[0],[0, 1]],
'ushr-long/2addr': [[0],[0, 1]],
'add-float/2addr': [[0],[0, 1]],
'sub-float/2addr': [[0],[0, 1]],
'mul-float/2addr': [[0],[0, 1]],
'div-float/2addr': [[0],[0, 1]],
'rem-float/2addr': [[0],[0, 1]],
'add-double/2addr': [[0],[0, 1]],
'sub-double/2addr': [[0],[0, 1]],
'mul-double/2addr': [[0],[0, 1]],
'div-double/2addr': [[0],[0, 1]],
'rem-double/2addr': [[0],[0, 1]],
'add-int/lit8': [[0], [1]],
'sub-int/lit8': [[0], [1]],
'rsub-int/lit8': [[0], [1]],
'mul-int/lit8': [[0], [1]],
'div-int/lit8': [[0], [1]],
'rem-int/lit8': [[0], [1]],
'and-int/lit8': [[0], [1]],
'or-int/lit8': [[0], [1]],
'xor-int/lit8': [[0], [1]],
'shl-int/lit8': [[0], [1]],
'shr-int/lit8': [[0], [1]],
'ushr-int/lit8': [[0], [1]],
'add-int/lit16': [[0], [1]],
'sub-int/lit16': [[0], [1]],
'rsub-int/lit16': [[0], [1]],
'mul-int/lit16': [[0], [1]],
'div-int/lit16': [[0], [1]],
'rem-int/lit16': [[0], [1]],
'and-int/lit16': [[0], [1]],
'or-int/lit16': [[0], [1]],
'xor-int/lit16': [[0], [1]],
'shl-int/lit16': [[0], [1]],
'shr-int/lit16': [[0], [1]],
'ushr-int/lit16': [[0], [1]],
#the following are only available in optimized dex files
#execute-inline
#invoke-*-quick
#iput/get - quick
}
## [
## 'Landroid/telephony/TelephonyManager;->getDeviceId(',
## 'Landroid/telephony/TelephonyManager;->getLine1Number(',
## 'Landroid/telephony/TelephonyManager;->getSubscriberId(',
## 'Landroid/telephony/TelephonyManager;->getCellLocation('
## ],
## # SINKS taken from the permissionmap, for PERMISSION_INTERNET
## [
## 'Landroid/webkit/WebSettings;->setBlockNetworkLoads(',
## 'Landroid/webkit/WebSettings;->verifyNetworkAccess(',
## 'Landroid/webkit/WebView;-><init>(',
## 'Landroid/webkit/WebViewCore;-><init>(',
## 'Lcom/android/http/multipart/FilePart;->sendData(',
## 'Lcom/android/http/multipart/FilePart;->sendDispositionHeader(',
## 'Lcom/android/http/multipart/Part;->send(',
## 'Lcom/android/http/multipart/Part;->sendStart(',
## 'Lcom/android/http/multipart/Part;->sendTransferEncodingHeader(',
## 'Lcom/android/http/multipart/StringPart;->sendData(',
## 'Ljava/net/DatagramSocket;-><init>(',
## 'Ljava/net/HttpURLConnection;-><init>(',
## 'Ljava/net/HttpURLConnection;->connect(',
## 'Ljava/net/MulticastSocket;-><init>(',
## 'Ljava/net/NetworkInterface;-><init>(',
## 'Ljava/net/ServerSocket;-><init>(',
## 'Ljava/net/ServerSocket;->bind(',
## 'Ljava/net/Socket;-><init>(',
## 'Ljava/net/URL;->getContent(',
## 'Ljava/net/URL;->openConnection(',
## 'Ljava/net/URL;->openStream(',
## 'Ljava/net/URLConnection;->connect(',
## 'Ljava/net/URLConnection;->getInputStream(',
## 'Lorg/apache/http/impl/client/DefaultHttpClient;-><init>(',
## 'Lorg/apache/http/impl/client/DefaultHttpClient;->execute(',
## 'Ljava/io/OutputStream;->write(',
##' Lorg/apache/http/impl/client/HttpClient;->execute']) | enable_external_paths = False
source_definition = ['Landroid/telephony/TelephonyManager;->getDeviceId(', 'Landroid/telephony/TelephonyManager;->getSubscriberId(', 'Landroid/telephony/TelephonyManager;->getSimSerialNumber(', 'Landroid/telephony/TelephonyManager;->getLine1Number(']
sink_definition = ['Landroid/util/Log;->d(', 'Landroid/util/Log;->e(', 'Landroid/util/Log;->i(', 'Landroid/util/Log;->v(', 'Landroid/util/Log;->w(', 'Landroid/util/Log;->wtf(', 'Ljava.io.OutputStream;->write(']
nops = ['return-void', 'return', 'return-wide', 'return-object', 'monitor-exit', 'monitor-enter', 'move-exception', 'check-cast', 'instance-of', 'array-length', 'goto', 'goto/16', 'goto/32', 'packed-switch', 'sparse-switch', 'cmpl-float', 'cmpg-float', 'cmpl-double', 'cmpg-double', 'cmp-long', 'if-eq', 'if-ne', 'if-lt', 'if-ge', 'if-gt', 'if-le', 'if-eqz', 'if-nez', 'if-ltz', 'if-gez', 'if-gtz', 'if-lez']
untaint = ['const/4', 'const/16', 'const', 'const/high16', 'const-wide/16', 'const-wide/32', 'const-wide', 'const-wide/high16', 'const-string', 'const-string/jumbo', 'const-class', 'new-instance', 'new-array', 'fill-array-data']
instruction_propagation = {'move': [[0], [1]], 'move/from16': [[0], [1]], 'move-wide': [[0], [1]], 'move-wide/from16': [[0], [1]], 'move-object': [[0], [1]], 'move-object/from16': [[0], [1]], 'aget': [[0], [1]], 'aget-wide': [[0], [1]], 'aget-object': [[0], [1]], 'aget-boolean': [[0], [1]], 'aget-byte': [[0], [1]], 'aget-char': [[0], [1]], 'aget-short': [[0], [1]], 'aput': [[1], [0]], 'aput-wide': [[1], [0]], 'aput-object': [[1], [0]], 'aput-boolean': [[1], [0]], 'aput-byte': [[1], [0]], 'aput-char': [[1], [0]], 'aput-short': [[1], [0]], 'neg-int': [[0], [1]], 'not-int': [[0], [1]], 'neg-long': [[0], [1]], 'not-long': [[0], [1]], 'neg-float': [[0], [1]], 'not-float': [[0], [1]], 'neg-double': [[0], [1]], 'not-double': [[0], [1]], 'int-to-long': [[0], [1]], 'int-to-float': [[0], [1]], 'int-to-double': [[0], [1]], 'long-to-int': [[0], [1]], 'long-to-float': [[0], [1]], 'long-to-double': [[0], [1]], 'float-to-int': [[0], [1]], 'float-to-long': [[0], [1]], 'float-to-double': [[0], [1]], 'double-to-int': [[0], [1]], 'double-to-long': [[0], [1]], 'double-to-float': [[0], [1]], 'int-to-byte': [[0], [1]], 'int-to-char': [[0], [1]], 'int-to-short': [[0], [1]], 'add-int': [[0], [1, 2]], 'sub-int': [[0], [1, 2]], 'rsub-int': [[0], [1, 2]], 'mul-int': [[0], [1, 2]], 'div-int': [[0], [1, 2]], 'rem-int': [[0], [1, 2]], 'and-int': [[0], [1, 2]], 'or-int': [[0], [1, 2]], 'xor-int': [[0], [1, 2]], 'shl-int': [[0], [1, 2]], 'shr-int': [[0], [1, 2]], 'ushr-int': [[0], [1, 2]], 'add-long': [[0], [1, 2]], 'sub-long': [[0], [1, 2]], 'mul-long': [[0], [1, 2]], 'div-long': [[0], [1, 2]], 'rem-long': [[0], [1, 2]], 'and-long': [[0], [1, 2]], 'or-long': [[0], [1, 2]], 'xor-long': [[0], [1, 2]], 'shl-long': [[0], [1, 2]], 'shr-long': [[0], [1, 2]], 'ushr-long': [[0], [1, 2]], 'add-float': [[0], [1, 2]], 'sub-float': [[0], [1, 2]], 'mul-float': [[0], [1, 2]], 'div-float': [[0], [1, 2]], 'rem-float': [[0], [1, 2]], 'add-double': [[0], [1, 2]], 'sub-double': [[0], [1, 2]], 'mul-double': [[0], [1, 2]], 'div-double': [[0], [1, 2]], 'rem-double': [[0], [1, 2]], 'add-int/2addr': [[0], [0, 1]], 'sub-int/2addr': [[0], [0, 1]], 'mul-int/2addr': [[0], [0, 1]], 'div-int/2addr': [[0], [0, 1]], 'rem-int/2addr': [[0], [0, 1]], 'and-int/2addr': [[0], [0, 1]], 'or-int/2addr': [[0], [0, 1]], 'xor-int/2addr': [[0], [0, 1]], 'shl-int/2addr': [[0], [0, 1]], 'shr-int/2addr': [[0], [0, 1]], 'ushr-int/2addr': [[0], [0, 1]], 'add-long/2addr': [[0], [0, 1]], 'sub-long/2addr': [[0], [0, 1]], 'mul-long/2addr': [[0], [0, 1]], 'div-long/2addr': [[0], [0, 1]], 'rem-long/2addr': [[0], [0, 1]], 'and-long/2addr': [[0], [0, 1]], 'or-long/2addr': [[0], [0, 1]], 'xor-long/2addr': [[0], [0, 1]], 'shl-long/2addr': [[0], [0, 1]], 'shr-long/2addr': [[0], [0, 1]], 'ushr-long/2addr': [[0], [0, 1]], 'add-float/2addr': [[0], [0, 1]], 'sub-float/2addr': [[0], [0, 1]], 'mul-float/2addr': [[0], [0, 1]], 'div-float/2addr': [[0], [0, 1]], 'rem-float/2addr': [[0], [0, 1]], 'add-double/2addr': [[0], [0, 1]], 'sub-double/2addr': [[0], [0, 1]], 'mul-double/2addr': [[0], [0, 1]], 'div-double/2addr': [[0], [0, 1]], 'rem-double/2addr': [[0], [0, 1]], 'add-int/lit8': [[0], [1]], 'sub-int/lit8': [[0], [1]], 'rsub-int/lit8': [[0], [1]], 'mul-int/lit8': [[0], [1]], 'div-int/lit8': [[0], [1]], 'rem-int/lit8': [[0], [1]], 'and-int/lit8': [[0], [1]], 'or-int/lit8': [[0], [1]], 'xor-int/lit8': [[0], [1]], 'shl-int/lit8': [[0], [1]], 'shr-int/lit8': [[0], [1]], 'ushr-int/lit8': [[0], [1]], 'add-int/lit16': [[0], [1]], 'sub-int/lit16': [[0], [1]], 'rsub-int/lit16': [[0], [1]], 'mul-int/lit16': [[0], [1]], 'div-int/lit16': [[0], [1]], 'rem-int/lit16': [[0], [1]], 'and-int/lit16': [[0], [1]], 'or-int/lit16': [[0], [1]], 'xor-int/lit16': [[0], [1]], 'shl-int/lit16': [[0], [1]], 'shr-int/lit16': [[0], [1]], 'ushr-int/lit16': [[0], [1]]} |
weather = []
for i in range(4):
x = input().split()
| weather = []
for i in range(4):
x = input().split() |
def sol(preorder,inorder):
ret = []
def print_postorder(preorder, inorder):
n = len(preorder)
if n == 0:
return
root = preorder[0]
i = inorder.index(root)
print_postorder(preorder[1 : i + 1], inorder[:i])
print_postorder(preorder[i + 1 :], inorder[i + 1 :])
ret.append(root)
print_postorder(preorder, inorder)
print(*ret)
test_case = int(input())
for _ in range(test_case):
num_node = int(input())
preorder = [int(x) for x in input().split()]
inorder = [int(x) for x in input().split()]
sol(preorder, inorder) | def sol(preorder, inorder):
ret = []
def print_postorder(preorder, inorder):
n = len(preorder)
if n == 0:
return
root = preorder[0]
i = inorder.index(root)
print_postorder(preorder[1:i + 1], inorder[:i])
print_postorder(preorder[i + 1:], inorder[i + 1:])
ret.append(root)
print_postorder(preorder, inorder)
print(*ret)
test_case = int(input())
for _ in range(test_case):
num_node = int(input())
preorder = [int(x) for x in input().split()]
inorder = [int(x) for x in input().split()]
sol(preorder, inorder) |
__version__ = '0.2.0'
__pdoc__ = {
'__version__': "The version of the installed nflfan module.",
}
| __version__ = '0.2.0'
__pdoc__ = {'__version__': 'The version of the installed nflfan module.'} |
{
"targets": [
{
"target_name": "math",
"sources": [ "math.cc" ],
"libraries": [
"<(module_root_dir)/libmath.a"
]
}
]
} | {'targets': [{'target_name': 'math', 'sources': ['math.cc'], 'libraries': ['<(module_root_dir)/libmath.a']}]} |
{
'target_defaults': {
'default_configuration': 'Release'
},
"targets": [
{
'configurations': {
'Debug': {
'cflags': ['-g3', '-O0'],
'msvs_settings': {
'VCCLCompilerTool': {
'BasicRuntimeChecks': 3, # /RTC1
'ExceptionHandling': 1, # /EHsc
'Optimization': '0', # /Od, no optimization
'WarningLevel': 4
},
'VCLinkerTool': {
'GenerateDebugInformation': 'true',
'LinkIncremental': 2 # enable incremental linking
}
}
},
'Release': {
'cflags': ['-O2', '-W', '-Wall', '-Wextra', '-ansi', '-pedantic'],
'msvs_settings': {
'VCCLCompilerTool': {
'AdditionalOptions': ['/Zc:inline', '/MP'],
'BufferSecurityCheck': 'true',
'ExceptionHandling': 1, # /EHsc
'FavorSizeOrSpeed': '1',
'OmitFramePointers': 'false', # Ideally, we should only disable for x64
'Optimization': '2',
'StringPooling': 'true',
'WarningLevel': 3,
'WholeProgramOptimization': 'true'
},
'VCLinkerTool': {
'DataExecutionPrevention': 2, # enable DEP
'EnableCOMDATFolding': 2, # /OPT:ICF
'LinkIncremental': 1, # disable incremental linking
'LinkTimeCodeGeneration': 1, # link-time code generation
'OptimizeReferences': 2, # /OPT:REF
'RandomizedBaseAddress': 2, # enable ASLR
'SetChecksum': 'true'
}
}
}
},
"target_name": "<(module_name)",
'lflags': ['-lm'],
"include_dirs": [
"zopfli/src/zopfli",
"zopfli/src/zopflipng",
"<!(node -e \"require('nan')\")"
],
"sources": [
"src/zopfli-binding.cc",
"src/png/zopflipng.cc",
"zopfli/src/zopfli/blocksplitter.c",
"zopfli/src/zopfli/cache.c",
"zopfli/src/zopfli/deflate.c",
"zopfli/src/zopfli/gzip_container.c",
"zopfli/src/zopfli/hash.c",
"zopfli/src/zopfli/katajainen.c",
"zopfli/src/zopfli/lz77.c",
"zopfli/src/zopfli/squeeze.c",
"zopfli/src/zopfli/tree.c",
"zopfli/src/zopfli/util.c",
"zopfli/src/zopfli/zlib_container.c",
"zopfli/src/zopfli/zopfli_lib.c",
"zopfli/src/zopflipng/zopflipng_lib.cc",
"zopfli/src/zopflipng/lodepng/lodepng.cpp",
"zopfli/src/zopflipng/lodepng/lodepng_util.cpp"
],
"cflags": [
"-Wall",
"-O3"
]
},
{
"target_name": "action_after_build",
"type": "none",
"dependencies": ["<(module_name)"],
"copies": [
{
"files": ["<(PRODUCT_DIR)/<(module_name).node"],
"destination": "<(module_path)"
}
]
}
]
}
| {'target_defaults': {'default_configuration': 'Release'}, 'targets': [{'configurations': {'Debug': {'cflags': ['-g3', '-O0'], 'msvs_settings': {'VCCLCompilerTool': {'BasicRuntimeChecks': 3, 'ExceptionHandling': 1, 'Optimization': '0', 'WarningLevel': 4}, 'VCLinkerTool': {'GenerateDebugInformation': 'true', 'LinkIncremental': 2}}}, 'Release': {'cflags': ['-O2', '-W', '-Wall', '-Wextra', '-ansi', '-pedantic'], 'msvs_settings': {'VCCLCompilerTool': {'AdditionalOptions': ['/Zc:inline', '/MP'], 'BufferSecurityCheck': 'true', 'ExceptionHandling': 1, 'FavorSizeOrSpeed': '1', 'OmitFramePointers': 'false', 'Optimization': '2', 'StringPooling': 'true', 'WarningLevel': 3, 'WholeProgramOptimization': 'true'}, 'VCLinkerTool': {'DataExecutionPrevention': 2, 'EnableCOMDATFolding': 2, 'LinkIncremental': 1, 'LinkTimeCodeGeneration': 1, 'OptimizeReferences': 2, 'RandomizedBaseAddress': 2, 'SetChecksum': 'true'}}}}, 'target_name': '<(module_name)', 'lflags': ['-lm'], 'include_dirs': ['zopfli/src/zopfli', 'zopfli/src/zopflipng', '<!(node -e "require(\'nan\')")'], 'sources': ['src/zopfli-binding.cc', 'src/png/zopflipng.cc', 'zopfli/src/zopfli/blocksplitter.c', 'zopfli/src/zopfli/cache.c', 'zopfli/src/zopfli/deflate.c', 'zopfli/src/zopfli/gzip_container.c', 'zopfli/src/zopfli/hash.c', 'zopfli/src/zopfli/katajainen.c', 'zopfli/src/zopfli/lz77.c', 'zopfli/src/zopfli/squeeze.c', 'zopfli/src/zopfli/tree.c', 'zopfli/src/zopfli/util.c', 'zopfli/src/zopfli/zlib_container.c', 'zopfli/src/zopfli/zopfli_lib.c', 'zopfli/src/zopflipng/zopflipng_lib.cc', 'zopfli/src/zopflipng/lodepng/lodepng.cpp', 'zopfli/src/zopflipng/lodepng/lodepng_util.cpp'], 'cflags': ['-Wall', '-O3']}, {'target_name': 'action_after_build', 'type': 'none', 'dependencies': ['<(module_name)'], 'copies': [{'files': ['<(PRODUCT_DIR)/<(module_name).node'], 'destination': '<(module_path)'}]}]} |
# ---
# jupyter:
# jupytext:
# formats: ipynb,md,py
# text_representation:
# extension: .py
# format_name: light
# format_version: '1.5'
# jupytext_version: 1.4.2
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
# # Jonathan Date-Chong
# **Instructions:** This is an individual assignment. Complete the following code and push to get your score.
# I am providing the autograder answers locally so you may test your code before pushing. I will be reviewing your submissions, and if I find you are circumventing the autograder in any manner, you will receive a 0 on this assignment and your case will be reported to the honor board for review. i.e., approach the assignment in a genuine manner and you have nothing to worry about.
#
# **Question 1.**
# When will new material be available each week?
# You can answer the question by defining an anonymous function. This creates a function that I can test using pytest. You don't have to worry about the details. You just need to answer the question by changing the string argument that is currently set to "D". I know this is a bit weird, but I want you to get used to submitting code as early as possible.
# Nothing to modify in this cell
def question_1(answer):
answers = {
"A": "Monday morning",
"B": "Sunday night",
"C": "Monday evening",
"D": "I don't know"
}
try:
return answers[answer]
except:
return "Not a valid answer"
# YOUR SOLUTION HERE
# Sample incorrect answer
answer_question_1 = lambda: question_1("C")
# **Question 2.**
# Do I need to buy the textbook?
# Nothing to modify in this cell
def question_2(answer):
answers = {
"A": "No",
"B": "Maybe",
"C": "Yes. You will struggle with some of the chapters without the textbook",
}
try:
return answers[answer]
except:
return "Not a valid answer"
# YOUR SOLUTION HERE
# Sample incorrect answer
answer_question_2 = lambda: question_2("C")
# **Question 3.**
# Are these any required times that I be online?
# Nothing to modify in this cell
def question_3(answer):
answers = {
"A": "Yes",
"B": "No"
}
try:
return answers[answer]
except:
return "Not a valid answer"
# YOUR SOLUTION HERE
# Sample incorrect answer
answer_question_3 = lambda: question_3("A")
# **Question 4.**
# What software will I use to complete the assignments?
# Nothing to modify in this cell
def question_4(answer):
answers = {
"A": "Java",
"B": "Netbeans",
"C": "Anaconda"
}
try:
return answers[answer]
except:
return "Not a valid answer"
# YOUR SOLUTION HERE
# Sample incorrect answer
answer_question_4 = lambda: question_4("C")
# **Question 5.**
# Do I need to participate in this class or can I just do the labs and assignments?
# Nothing to modify in this cell
def question_5(answer):
answers = {
"A": "Yes. If you want to get anything higher than a C, you'll need to do more than the labs and assignments",
"B": "No",
}
try:
return answers[answer]
except:
return "Not a valid answer"
# YOUR SOLUTION HERE
# Sample incorrect answer
answer_question_5 = lambda: question_5("A")
# Don't forget to push!
| def question_1(answer):
answers = {'A': 'Monday morning', 'B': 'Sunday night', 'C': 'Monday evening', 'D': "I don't know"}
try:
return answers[answer]
except:
return 'Not a valid answer'
answer_question_1 = lambda : question_1('C')
def question_2(answer):
answers = {'A': 'No', 'B': 'Maybe', 'C': 'Yes. You will struggle with some of the chapters without the textbook'}
try:
return answers[answer]
except:
return 'Not a valid answer'
answer_question_2 = lambda : question_2('C')
def question_3(answer):
answers = {'A': 'Yes', 'B': 'No'}
try:
return answers[answer]
except:
return 'Not a valid answer'
answer_question_3 = lambda : question_3('A')
def question_4(answer):
answers = {'A': 'Java', 'B': 'Netbeans', 'C': 'Anaconda'}
try:
return answers[answer]
except:
return 'Not a valid answer'
answer_question_4 = lambda : question_4('C')
def question_5(answer):
answers = {'A': "Yes. If you want to get anything higher than a C, you'll need to do more than the labs and assignments", 'B': 'No'}
try:
return answers[answer]
except:
return 'Not a valid answer'
answer_question_5 = lambda : question_5('A') |
for i in range(1, 10+1):
if i%3 == 0:
print('hello')
elif i%5 == 0:
print('world')
else:
print(i)
| for i in range(1, 10 + 1):
if i % 3 == 0:
print('hello')
elif i % 5 == 0:
print('world')
else:
print(i) |
def place(arr, mask, vals):
# TODO(beam2d): Implement it
raise NotImplementedError
def put(a, ind, v, mode='raise'):
# TODO(beam2d): Implement it
raise NotImplementedError
def putmask(a, mask, values):
# TODO(beam2d): Implement it
raise NotImplementedError
def fill_diagonal(a, val, wrap=False):
# TODO(beam2d): Implement it
raise NotImplementedError
| def place(arr, mask, vals):
raise NotImplementedError
def put(a, ind, v, mode='raise'):
raise NotImplementedError
def putmask(a, mask, values):
raise NotImplementedError
def fill_diagonal(a, val, wrap=False):
raise NotImplementedError |
# maps biome IDs to supported biomes
biome_map = {
"Plains": [1, 129],
"Forest": [4, 18, 132],
"Birch Forest": [27, 28, 155, 156],
"Dark Forest": [29, 157],
"Swamp": [6, 134],
"Jungle": [21, 22, 23, 149, 151],
"River Beach": [7, 11, 16, 25],
"Taiga": [5, 19, 133, 30, 31, 158, 32, 33, 160, 161],
"Ice": [12, 140, 26],
"Mountains": [3, 13, 34, 131, 162, 20],
"Mushroom": [14, 15],
"Desert": [2, 17, 130],
"Savanna": [35, 36, 163, 164],
"Badlands": [37, 38, 39, 165, 166, 167],
"Aquatic": [0, 10, 24, 44, 45, 46, 47, 48, 49, 50]
}
| biome_map = {'Plains': [1, 129], 'Forest': [4, 18, 132], 'Birch Forest': [27, 28, 155, 156], 'Dark Forest': [29, 157], 'Swamp': [6, 134], 'Jungle': [21, 22, 23, 149, 151], 'River Beach': [7, 11, 16, 25], 'Taiga': [5, 19, 133, 30, 31, 158, 32, 33, 160, 161], 'Ice': [12, 140, 26], 'Mountains': [3, 13, 34, 131, 162, 20], 'Mushroom': [14, 15], 'Desert': [2, 17, 130], 'Savanna': [35, 36, 163, 164], 'Badlands': [37, 38, 39, 165, 166, 167], 'Aquatic': [0, 10, 24, 44, 45, 46, 47, 48, 49, 50]} |
def pprint(obj):
return repr(obj)
def to_hex_str(data):
return ''.join("{0:x}".format(b) for b in data)
| def pprint(obj):
return repr(obj)
def to_hex_str(data):
return ''.join(('{0:x}'.format(b) for b in data)) |
# -*- coding: utf-8 -*-
class PluginException(Exception):
pass
class PluginTypeNotFound(PluginException):
pass
| class Pluginexception(Exception):
pass
class Plugintypenotfound(PluginException):
pass |
class gr():
def __init__(self):
age = 28
def stop(self):
return 1+1
if __name__ == "__main__":
print("hello")
pass | class Gr:
def __init__(self):
age = 28
def stop(self):
return 1 + 1
if __name__ == '__main__':
print('hello')
pass |
# Kata url: https://www.codewars.com/kata/574b1916a3ebd6e4fa0012e7.
def is_opposite(s1: str, s2: str) -> bool:
return len(s1) and s1 == s2.swapcase()
| def is_opposite(s1: str, s2: str) -> bool:
return len(s1) and s1 == s2.swapcase() |
def sectrails(domain,requests,api):
print("[+] Consultando securitytrails")
url = "https://api.securitytrails.com/v1/domain/"+domain+"/subdomains"
querystring = {"children_only":"false","include_inactive":"true"}
headers = {"Accept": "application/json","APIKEY": api}
subs = []
# Insira sua chave de API em APIKEY
try:
response = requests.request("GET", url, headers=headers, params=querystring)
for x in response.json()['subdomains']:
sub = '{}.{}'.format(x,domain)
subs.append(sub)
return subs
except:
print('[!] Error: '+response.json()['message'],'\n')
return | def sectrails(domain, requests, api):
print('[+] Consultando securitytrails')
url = 'https://api.securitytrails.com/v1/domain/' + domain + '/subdomains'
querystring = {'children_only': 'false', 'include_inactive': 'true'}
headers = {'Accept': 'application/json', 'APIKEY': api}
subs = []
try:
response = requests.request('GET', url, headers=headers, params=querystring)
for x in response.json()['subdomains']:
sub = '{}.{}'.format(x, domain)
subs.append(sub)
return subs
except:
print('[!] Error: ' + response.json()['message'], '\n')
return |
"""
mimetypes
~~~~~~~~~
Define some constants for different mimetypes
"""
CSV_MIMETYPE = 'text/csv'
FILEUPLOAD_MIMETYPE = 'multipart/form-data'
FORMURL_MIMETYPE = 'application/x-www-form-urlencoded'
JSON_MIMETYPE = 'application/json'
JSONAPI_MIMETYPE = 'application/vnd.api+json'
| """
mimetypes
~~~~~~~~~
Define some constants for different mimetypes
"""
csv_mimetype = 'text/csv'
fileupload_mimetype = 'multipart/form-data'
formurl_mimetype = 'application/x-www-form-urlencoded'
json_mimetype = 'application/json'
jsonapi_mimetype = 'application/vnd.api+json' |
# -*- coding: utf-8 -*-
"""
idfy_rest_client.models.reminder
This file was automatically generated for Idfy by APIMATIC v2.0 ( https://apimatic.io )
"""
class Reminder(object):
"""Implementation of the 'Reminder' enum.
TODO: type enum description here.
Attributes:
OFF: TODO: type description here.
SENDSMS: TODO: type description here.
SENDEMAIL: TODO: type description here.
SENDBOTH: TODO: type description here.
"""
OFF = 'off'
SENDSMS = 'sendSms'
SENDEMAIL = 'sendEmail'
SENDBOTH = 'sendBoth'
| """
idfy_rest_client.models.reminder
This file was automatically generated for Idfy by APIMATIC v2.0 ( https://apimatic.io )
"""
class Reminder(object):
"""Implementation of the 'Reminder' enum.
TODO: type enum description here.
Attributes:
OFF: TODO: type description here.
SENDSMS: TODO: type description here.
SENDEMAIL: TODO: type description here.
SENDBOTH: TODO: type description here.
"""
off = 'off'
sendsms = 'sendSms'
sendemail = 'sendEmail'
sendboth = 'sendBoth' |
class Node:
def __init__(self, data):
self.data = data
self.right_child = None
self.left_child = None
| class Node:
def __init__(self, data):
self.data = data
self.right_child = None
self.left_child = None |
secret_number = 9
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input("Guess any no. from 1-10: "))
guess_count+=1
if guess == secret_number:
print("You won")
break
else:
print("Better luck next time")
| secret_number = 9
guess_count = 0
guess_limit = 3
while guess_count < guess_limit:
guess = int(input('Guess any no. from 1-10: '))
guess_count += 1
if guess == secret_number:
print('You won')
break
else:
print('Better luck next time') |
# Linear Search Implementation
def linear_search(arr, search):
# Iterate over the array
for _, ele in enumerate(arr):
# Check for search element
if ele == search:
return True
return False
if __name__ == "__main__":
# Read input array from stdin
arr = list(map(int, input().strip().split()))
# Read search elements from stdin
search = list(map(int, input().strip().split()))
# Search in the array
for s in search:
print(f"Searching for {s} in [{arr}]:", end=" -> ")
flag = linear_search(arr, s)
print("Found:", flag)
| def linear_search(arr, search):
for (_, ele) in enumerate(arr):
if ele == search:
return True
return False
if __name__ == '__main__':
arr = list(map(int, input().strip().split()))
search = list(map(int, input().strip().split()))
for s in search:
print(f'Searching for {s} in [{arr}]:', end=' -> ')
flag = linear_search(arr, s)
print('Found:', flag) |
#!/usr/bin/env python
"""
Copyright 2014-2020 by Taxamo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
class GetDomesticSummaryReportOut:
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually."""
def __init__(self):
self.swaggerTypes = {
'end_date': 'str',
'domestic_refunds_amount': 'number',
'currency_code': 'str',
'global_refunds_tax_amount': 'number',
'domestic_refunds_tax_amount': 'number',
'eu_tax_deducted_refunds': 'number',
'global_sales_amount': 'number',
'global_refunds_amount': 'number',
'global_sales_tax_amount': 'number',
'eu_tax_deducted_sales': 'number',
'start_date': 'str',
'domestic_tax_amount': 'number',
'domestic_sales_amount': 'number'
}
#Period end date in yyyy-MM-dd'T'hh:mm:ss'Z' format.
self.end_date = None # str
#Domestic sales refunds amount.
self.domestic_refunds_amount = None # number
#Three-letter ISO currency code.
self.currency_code = None # str
#Global sales refunds amount. This includes refunds from domestic country too.
self.global_refunds_tax_amount = None # number
#Domestic sales refunds tax amout.
self.domestic_refunds_tax_amount = None # number
#EU deducted tax sales.
self.eu_tax_deducted_refunds = None # number
#Global sales amount. This includes sales from domestic country too.
self.global_sales_amount = None # number
#Global sales refunds amount. This includes refunds from domestic country too.
self.global_refunds_amount = None # number
#Global sales amount. This includes sales from domestic country too.
self.global_sales_tax_amount = None # number
#EU deducted tax sales.
self.eu_tax_deducted_sales = None # number
#Period start date in yyyy-MM-dd'T'hh:mm:ss'Z' format.
self.start_date = None # str
#Domestic sales tax amout.
self.domestic_tax_amount = None # number
#Domestic sales amount.
self.domestic_sales_amount = None # number
| """
Copyright 2014-2020 by Taxamo
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
class Getdomesticsummaryreportout:
"""NOTE: This class is auto generated by the swagger code generator program.
Do not edit the class manually."""
def __init__(self):
self.swaggerTypes = {'end_date': 'str', 'domestic_refunds_amount': 'number', 'currency_code': 'str', 'global_refunds_tax_amount': 'number', 'domestic_refunds_tax_amount': 'number', 'eu_tax_deducted_refunds': 'number', 'global_sales_amount': 'number', 'global_refunds_amount': 'number', 'global_sales_tax_amount': 'number', 'eu_tax_deducted_sales': 'number', 'start_date': 'str', 'domestic_tax_amount': 'number', 'domestic_sales_amount': 'number'}
self.end_date = None
self.domestic_refunds_amount = None
self.currency_code = None
self.global_refunds_tax_amount = None
self.domestic_refunds_tax_amount = None
self.eu_tax_deducted_refunds = None
self.global_sales_amount = None
self.global_refunds_amount = None
self.global_sales_tax_amount = None
self.eu_tax_deducted_sales = None
self.start_date = None
self.domestic_tax_amount = None
self.domestic_sales_amount = None |
BASE_URL = "https://www.zhixue.com"
class Url:
SERVICE_URL = f"{BASE_URL}:443/ssoservice.jsp"
SSO_URL = f"https://sso.zhixue.com/sso_alpha/login?service={SERVICE_URL}"
TEST_PASSWORD_URL = f"{BASE_URL}/weakPwdLogin/?from=web_login"
TEST_URL = f"{BASE_URL}/container/container/teacher/teacherAccountNew"
GET_LOGIN_STATE = f"{BASE_URL}/loginState/" | base_url = 'https://www.zhixue.com'
class Url:
service_url = f'{BASE_URL}:443/ssoservice.jsp'
sso_url = f'https://sso.zhixue.com/sso_alpha/login?service={SERVICE_URL}'
test_password_url = f'{BASE_URL}/weakPwdLogin/?from=web_login'
test_url = f'{BASE_URL}/container/container/teacher/teacherAccountNew'
get_login_state = f'{BASE_URL}/loginState/' |
class Solution:
def isRectangleOverlap(self, rec1, rec2):
"""
:type rec1: List[int]
:type rec2: List[int]
:rtype: bool
"""
# [x1, y1, x2, y2]
return not (rec2[2] <= rec1[0] or rec1[2] <= rec2[0] or rec2[3] <= rec1[1] or rec1[3] <= rec2[1]) | class Solution:
def is_rectangle_overlap(self, rec1, rec2):
"""
:type rec1: List[int]
:type rec2: List[int]
:rtype: bool
"""
return not (rec2[2] <= rec1[0] or rec1[2] <= rec2[0] or rec2[3] <= rec1[1] or (rec1[3] <= rec2[1])) |
#!/usr/bin/env python2.7
# Copyright (c) 2014 Franco Fichtner <franco@packetwerk.com>
# Copyright (c) 2014 Tobias Boertitz <tobias@packetwerk.com>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
countries = []
with open('contrib/tzdata/iso3166.tab', 'r') as lines:
for line in lines:
country = line.strip().split('\t')
if country[0][0] == "#" or len(country) != 2:
# ignore garbage
continue
# be paranoid about upper case
country[0] = country[0].upper()
countries.append(country)
if len(countries) == 0:
exit(0)
# special case: not in the database when database isn't empty
countries.append(["XX", "undefined"])
countries.sort(key=lambda country: country[0])
def insertIntoFile(fileName, beginString, endString, insertString):
file_content = 0
insert_begin = -1
line_idx = -1
del_list = list()
# read destination file and prepare for writing
with open(fileName, 'r') as dest_file:
insert_section = False
file_content = dest_file.readlines()
# remove not needed / outdated lines and find insertion point
for line in file_content:
line_idx += 1
if line == beginString:
insert_section = True
insert_begin = line_idx
continue
elif line == endString:
insert_section = False
break
# collect obsolete line
# insert in front, so we delete form bottom up later on
if insert_section == True:
del_list.insert(0, line_idx)
# delete obsolete lines
for line_idx in del_list:
del file_content[line_idx]
line_idx = -1
# insert definitions
with open(fileName, 'w') as dest_file:
for line in file_content:
line_idx += 1
# write normal file data
dest_file.write(line)
# insert given string when insertion point is reached
if line_idx == insert_begin:
dest_file.write(insertString)
# prepare string for insertion into header file
header_string = "\n"
header_string += "/*\n"
header_string += " * Begin of autogenerated section. DO NOT EDIT.\n"
header_string += " */\n"
header_string += "\n"
header_string += "struct locate_item {\n"
header_string += "\tunsigned int guid;\n"
header_string += "\tconst char *name;\n"
header_string += "\tconst char *desc;\n"
header_string += "};\n\n"
header_string += "enum {\n"
header_string += "\tLOCATE_UNKNOWN = 0U,\n"
for country in countries:
header_string += "\tLOCATE_" + country[0] + ",\n"
header_string += "\tLOCATE_MAX\t/* last element */\n"
header_string += "};\n"
header_string += "\n"
header_string += "/*\n"
header_string += " * End of autogenerated section. YOU MAY CONTINUE.\n"
header_string += " */\n\n"
# prepare string for insertion into source file
source_string = "\n"
source_string += "/*\n"
source_string += " * Begin of autogenerated section. DO NOT EDIT.\n"
source_string += " */\n"
source_string += "\n"
source_string += "static const struct locate_item locate_items[] = {\n"
source_string += "\t{ LOCATE_UNKNOWN, \"\", \"unknown\" },\t/* `unknown' placeholder */\n"
for country in countries:
source_string += "\t{ LOCATE_" + country[0] + ", \"" + \
country[0] + "\", \"" + country[1] + "\" },\n"
source_string += "};\n\n"
source_string += "/*\n"
source_string += " * End of autogenerated section. YOU MAY CONTINUE.\n"
source_string += " */\n\n"
# insert relevant data into the target files
insertIntoFile('lib/peak_locate.h', "#define PEAK_LOCATE_H\n", \
"#define LOCATE_MAGIC\t0x10CA7E10CA7E7412ull\n", header_string)
insertIntoFile('lib/peak_locate.c', "#define LOCATE_DEFAULT\t\"/usr/local/var/peak/locate.bin\"\n", \
"struct peak_locates {\n", source_string)
| countries = []
with open('contrib/tzdata/iso3166.tab', 'r') as lines:
for line in lines:
country = line.strip().split('\t')
if country[0][0] == '#' or len(country) != 2:
continue
country[0] = country[0].upper()
countries.append(country)
if len(countries) == 0:
exit(0)
countries.append(['XX', 'undefined'])
countries.sort(key=lambda country: country[0])
def insert_into_file(fileName, beginString, endString, insertString):
file_content = 0
insert_begin = -1
line_idx = -1
del_list = list()
with open(fileName, 'r') as dest_file:
insert_section = False
file_content = dest_file.readlines()
for line in file_content:
line_idx += 1
if line == beginString:
insert_section = True
insert_begin = line_idx
continue
elif line == endString:
insert_section = False
break
if insert_section == True:
del_list.insert(0, line_idx)
for line_idx in del_list:
del file_content[line_idx]
line_idx = -1
with open(fileName, 'w') as dest_file:
for line in file_content:
line_idx += 1
dest_file.write(line)
if line_idx == insert_begin:
dest_file.write(insertString)
header_string = '\n'
header_string += '/*\n'
header_string += ' * Begin of autogenerated section. DO NOT EDIT.\n'
header_string += ' */\n'
header_string += '\n'
header_string += 'struct locate_item {\n'
header_string += '\tunsigned int guid;\n'
header_string += '\tconst char *name;\n'
header_string += '\tconst char *desc;\n'
header_string += '};\n\n'
header_string += 'enum {\n'
header_string += '\tLOCATE_UNKNOWN = 0U,\n'
for country in countries:
header_string += '\tLOCATE_' + country[0] + ',\n'
header_string += '\tLOCATE_MAX\t/* last element */\n'
header_string += '};\n'
header_string += '\n'
header_string += '/*\n'
header_string += ' * End of autogenerated section. YOU MAY CONTINUE.\n'
header_string += ' */\n\n'
source_string = '\n'
source_string += '/*\n'
source_string += ' * Begin of autogenerated section. DO NOT EDIT.\n'
source_string += ' */\n'
source_string += '\n'
source_string += 'static const struct locate_item locate_items[] = {\n'
source_string += '\t{ LOCATE_UNKNOWN, "", "unknown" },\t/* `unknown\' placeholder */\n'
for country in countries:
source_string += '\t{ LOCATE_' + country[0] + ', "' + country[0] + '", "' + country[1] + '" },\n'
source_string += '};\n\n'
source_string += '/*\n'
source_string += ' * End of autogenerated section. YOU MAY CONTINUE.\n'
source_string += ' */\n\n'
insert_into_file('lib/peak_locate.h', '#define PEAK_LOCATE_H\n', '#define LOCATE_MAGIC\t0x10CA7E10CA7E7412ull\n', header_string)
insert_into_file('lib/peak_locate.c', '#define LOCATE_DEFAULT\t"/usr/local/var/peak/locate.bin"\n', 'struct peak_locates {\n', source_string) |
#
# PySNMP MIB module HPN-ICF-LI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPN-ICF-LI-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:27:25 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
SingleValueConstraint, ConstraintsUnion, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsUnion", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint")
hpnicfCommon, = mibBuilder.importSymbols("HPN-ICF-OID-MIB", "hpnicfCommon")
InterfaceIndexOrZero, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndexOrZero")
InetAddressType, InetAddressPrefixLength, InetAddress, InetPortNumber = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddressType", "InetAddressPrefixLength", "InetAddress", "InetPortNumber")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Counter32, Integer32, NotificationType, TimeTicks, Gauge32, ModuleIdentity, Unsigned32, Bits, MibIdentifier, IpAddress, Counter64, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Counter32", "Integer32", "NotificationType", "TimeTicks", "Gauge32", "ModuleIdentity", "Unsigned32", "Bits", "MibIdentifier", "IpAddress", "Counter64", "ObjectIdentity")
DisplayString, RowStatus, MacAddress, DateAndTime, TruthValue, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "MacAddress", "DateAndTime", "TruthValue", "TextualConvention")
hpnicfLI = ModuleIdentity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111))
hpnicfLI.setRevisions(('2009-08-25 10:00',))
if mibBuilder.loadTexts: hpnicfLI.setLastUpdated('200908251000Z')
if mibBuilder.loadTexts: hpnicfLI.setOrganization('')
hpnicfLICommon = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1))
hpnicfLITrapBindObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 1))
hpnicfLIBoardInformation = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 1, 1), Unsigned32()).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: hpnicfLIBoardInformation.setStatus('current')
hpnicfLINotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2))
hpnicfLINotificationsPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0))
hpnicfLIActive = NotificationType((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0, 1)).setObjects(("HPN-ICF-LI-MIB", "hpnicfLIStreamtype"))
if mibBuilder.loadTexts: hpnicfLIActive.setStatus('current')
hpnicfLITimeOut = NotificationType((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0, 2)).setObjects(("HPN-ICF-LI-MIB", "hpnicfLIMediationRowStatus"))
if mibBuilder.loadTexts: hpnicfLITimeOut.setStatus('current')
hpnicfLIFailureInformation = NotificationType((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0, 3)).setObjects(("HPN-ICF-LI-MIB", "hpnicfLIStreamtype"), ("HPN-ICF-LI-MIB", "hpnicfLIBoardInformation"))
if mibBuilder.loadTexts: hpnicfLIFailureInformation.setStatus('current')
hpnicfLIObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3))
hpnicfLINewIndex = MibScalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: hpnicfLINewIndex.setStatus('current')
hpnicfLIMediationTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2), )
if mibBuilder.loadTexts: hpnicfLIMediationTable.setStatus('current')
hpnicfLIMediationEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1), ).setIndexNames((0, "HPN-ICF-LI-MIB", "hpnicfLIMediationIndex"))
if mibBuilder.loadTexts: hpnicfLIMediationEntry.setStatus('current')
hpnicfLIMediationIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647)))
if mibBuilder.loadTexts: hpnicfLIMediationIndex.setStatus('current')
hpnicfLIMediationDestAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 2), InetAddressType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationDestAddrType.setStatus('current')
hpnicfLIMediationDestAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 3), InetAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationDestAddr.setStatus('current')
hpnicfLIMediationDestPort = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 4), InetPortNumber()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationDestPort.setStatus('current')
hpnicfLIMediationSrcInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 5), InterfaceIndexOrZero()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationSrcInterface.setStatus('current')
hpnicfLIMediationDscp = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 6), Integer32().clone(34)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationDscp.setStatus('current')
hpnicfLIMediationTimeOut = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 7), DateAndTime()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationTimeOut.setStatus('current')
hpnicfLIMediationTransport = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1))).clone(namedValues=NamedValues(("udp", 1)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationTransport.setStatus('current')
hpnicfLIMediationNotificationEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 9), TruthValue().clone('true')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMediationNotificationEnable.setStatus('current')
hpnicfLIMediationRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 10), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hpnicfLIMediationRowStatus.setStatus('current')
hpnicfLIStreamTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3), )
if mibBuilder.loadTexts: hpnicfLIStreamTable.setStatus('current')
hpnicfLIStreamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1), ).setIndexNames((0, "HPN-ICF-LI-MIB", "hpnicfLIMediationIndex"), (0, "HPN-ICF-LI-MIB", "hpnicfLIStreamIndex"))
if mibBuilder.loadTexts: hpnicfLIStreamEntry.setStatus('current')
hpnicfLIStreamIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2147483647)))
if mibBuilder.loadTexts: hpnicfLIStreamIndex.setStatus('current')
hpnicfLIStreamtype = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("ip", 1), ("mac", 2), ("userConnection", 3)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIStreamtype.setStatus('current')
hpnicfLIStreamEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 3), TruthValue().clone('false')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIStreamEnable.setStatus('current')
hpnicfLIStreamPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 4), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hpnicfLIStreamPackets.setStatus('current')
hpnicfLIStreamDrops = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 5), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hpnicfLIStreamDrops.setStatus('current')
hpnicfLIStreamHPackets = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 6), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hpnicfLIStreamHPackets.setStatus('current')
hpnicfLIStreamHDrops = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 7), Counter64()).setMaxAccess("readonly")
if mibBuilder.loadTexts: hpnicfLIStreamHDrops.setStatus('current')
hpnicfLIStreamRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 8), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hpnicfLIStreamRowStatus.setStatus('current')
hpnicfLIIPStream = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2))
hpnicfLIIPStreamObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1))
hpnicfLIIPStreamTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1), )
if mibBuilder.loadTexts: hpnicfLIIPStreamTable.setStatus('current')
hpnicfLIIPStreamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1), ).setIndexNames((0, "HPN-ICF-LI-MIB", "hpnicfLIMediationIndex"), (0, "HPN-ICF-LI-MIB", "hpnicfLIStreamIndex"))
if mibBuilder.loadTexts: hpnicfLIIPStreamEntry.setStatus('current')
hpnicfLIIPStreamInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 1), InterfaceIndexOrZero()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamInterface.setStatus('current')
hpnicfLIIPStreamAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 2), InetAddressType().clone('ipv4')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamAddrType.setStatus('current')
hpnicfLIIPStreamDestAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 3), InetAddress().clone(hexValue="00000000")).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamDestAddr.setStatus('current')
hpnicfLIIPStreamDestAddrLength = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 4), InetAddressPrefixLength()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamDestAddrLength.setStatus('current')
hpnicfLIIPStreamSrcAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 5), InetAddress().clone(hexValue="00000000")).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamSrcAddr.setStatus('current')
hpnicfLIIPStreamSrcAddrLength = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 6), InetAddressPrefixLength()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamSrcAddrLength.setStatus('current')
hpnicfLIIPStreamTosByte = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamTosByte.setStatus('current')
hpnicfLIIPStreamTosByteMask = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamTosByteMask.setStatus('current')
hpnicfLIIPStreamFlowId = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 1048575), )).clone(-1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamFlowId.setStatus('current')
hpnicfLIIPStreamProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 10), Integer32().subtype(subtypeSpec=ConstraintsUnion(ValueRangeConstraint(-1, -1), ValueRangeConstraint(0, 255), )).clone(-1)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamProtocol.setStatus('current')
hpnicfLIIPStreamDestL4PortMin = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 11), InetPortNumber()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamDestL4PortMin.setStatus('current')
hpnicfLIIPStreamDestL4PortMax = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 12), InetPortNumber().clone(65535)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamDestL4PortMax.setStatus('current')
hpnicfLIIPStreamSrcL4PortMin = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 13), InetPortNumber()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamSrcL4PortMin.setStatus('current')
hpnicfLIIPStreamSrcL4PortMax = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 14), InetPortNumber().clone(65535)).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamSrcL4PortMax.setStatus('current')
hpnicfLIIPStreamVRF = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 15), SnmpAdminString()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIIPStreamVRF.setStatus('current')
hpnicfLIIPStreamRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 18), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hpnicfLIIPStreamRowStatus.setStatus('current')
hpnicfLIMACStream = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3))
hpnicfLIMACStreamObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1))
hpnicfLIMACStreamTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1), )
if mibBuilder.loadTexts: hpnicfLIMACStreamTable.setStatus('current')
hpnicfLIMACStreamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1), ).setIndexNames((0, "HPN-ICF-LI-MIB", "hpnicfLIMediationIndex"), (0, "HPN-ICF-LI-MIB", "hpnicfLIStreamIndex"))
if mibBuilder.loadTexts: hpnicfLIMACStreamEntry.setStatus('current')
hpnicfLIMACStreamFields = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 1), Bits().clone(namedValues=NamedValues(("interface", 0), ("dstMacAddress", 1), ("srcMacAddress", 2), ("ethernetPid", 3), ("dSap", 4), ("sSap", 5)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamFields.setStatus('current')
hpnicfLIMACStreamInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 2), InterfaceIndexOrZero()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamInterface.setStatus('current')
hpnicfLIMACStreamDestAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 3), MacAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamDestAddr.setStatus('current')
hpnicfLIMACStreamSrcAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 4), MacAddress()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamSrcAddr.setStatus('current')
hpnicfLIMACStreamEthPid = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 5), Unsigned32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamEthPid.setStatus('current')
hpnicfLIMACStreamDSap = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 6), Unsigned32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamDSap.setStatus('current')
hpnicfLIMACStreamSSap = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 7), Unsigned32()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIMACStreamSSap.setStatus('current')
hpnicfLIMACStreamRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 8), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hpnicfLIMACStreamRowStatus.setStatus('current')
hpnicfLIUserStream = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4))
hpnicfLIUserStreamObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1))
hpnicfLIUserStreamTable = MibTable((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1), )
if mibBuilder.loadTexts: hpnicfLIUserStreamTable.setStatus('current')
hpnicfLIUserStreamEntry = MibTableRow((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1, 1), ).setIndexNames((0, "HPN-ICF-LI-MIB", "hpnicfLIMediationIndex"), (0, "HPN-ICF-LI-MIB", "hpnicfLIStreamIndex"))
if mibBuilder.loadTexts: hpnicfLIUserStreamEntry.setStatus('current')
hpnicfLIUserStreamAcctSessID = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1, 1, 1), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 253))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: hpnicfLIUserStreamAcctSessID.setStatus('current')
hpnicfLIUserStreamRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1, 1, 2), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: hpnicfLIUserStreamRowStatus.setStatus('current')
mibBuilder.exportSymbols("HPN-ICF-LI-MIB", hpnicfLIStreamDrops=hpnicfLIStreamDrops, hpnicfLIIPStreamDestAddrLength=hpnicfLIIPStreamDestAddrLength, hpnicfLIMACStreamFields=hpnicfLIMACStreamFields, hpnicfLIIPStreamSrcL4PortMax=hpnicfLIIPStreamSrcL4PortMax, hpnicfLIMediationRowStatus=hpnicfLIMediationRowStatus, hpnicfLIIPStream=hpnicfLIIPStream, hpnicfLIMACStreamTable=hpnicfLIMACStreamTable, hpnicfLIIPStreamFlowId=hpnicfLIIPStreamFlowId, hpnicfLIMediationSrcInterface=hpnicfLIMediationSrcInterface, hpnicfLIMACStreamSrcAddr=hpnicfLIMACStreamSrcAddr, hpnicfLIMACStreamRowStatus=hpnicfLIMACStreamRowStatus, hpnicfLIIPStreamDestL4PortMax=hpnicfLIIPStreamDestL4PortMax, hpnicfLIUserStreamTable=hpnicfLIUserStreamTable, hpnicfLIUserStreamEntry=hpnicfLIUserStreamEntry, hpnicfLIIPStreamTable=hpnicfLIIPStreamTable, PYSNMP_MODULE_ID=hpnicfLI, hpnicfLIMediationIndex=hpnicfLIMediationIndex, hpnicfLIIPStreamProtocol=hpnicfLIIPStreamProtocol, hpnicfLITrapBindObjects=hpnicfLITrapBindObjects, hpnicfLIMediationDestAddrType=hpnicfLIMediationDestAddrType, hpnicfLIMediationEntry=hpnicfLIMediationEntry, hpnicfLIIPStreamInterface=hpnicfLIIPStreamInterface, hpnicfLIMediationTransport=hpnicfLIMediationTransport, hpnicfLIIPStreamDestL4PortMin=hpnicfLIIPStreamDestL4PortMin, hpnicfLIMACStreamEthPid=hpnicfLIMACStreamEthPid, hpnicfLIStreamRowStatus=hpnicfLIStreamRowStatus, hpnicfLIMACStreamObjects=hpnicfLIMACStreamObjects, hpnicfLIStreamtype=hpnicfLIStreamtype, hpnicfLINotifications=hpnicfLINotifications, hpnicfLIIPStreamVRF=hpnicfLIIPStreamVRF, hpnicfLIStreamEnable=hpnicfLIStreamEnable, hpnicfLI=hpnicfLI, hpnicfLIIPStreamObjects=hpnicfLIIPStreamObjects, hpnicfLIIPStreamSrcAddr=hpnicfLIIPStreamSrcAddr, hpnicfLIFailureInformation=hpnicfLIFailureInformation, hpnicfLIIPStreamSrcAddrLength=hpnicfLIIPStreamSrcAddrLength, hpnicfLIMediationNotificationEnable=hpnicfLIMediationNotificationEnable, hpnicfLIMediationTimeOut=hpnicfLIMediationTimeOut, hpnicfLITimeOut=hpnicfLITimeOut, hpnicfLIStreamTable=hpnicfLIStreamTable, hpnicfLIIPStreamAddrType=hpnicfLIIPStreamAddrType, hpnicfLIUserStreamObjects=hpnicfLIUserStreamObjects, hpnicfLIMediationTable=hpnicfLIMediationTable, hpnicfLIMediationDestPort=hpnicfLIMediationDestPort, hpnicfLIMACStreamInterface=hpnicfLIMACStreamInterface, hpnicfLIIPStreamTosByte=hpnicfLIIPStreamTosByte, hpnicfLIMACStreamSSap=hpnicfLIMACStreamSSap, hpnicfLINotificationsPrefix=hpnicfLINotificationsPrefix, hpnicfLIIPStreamEntry=hpnicfLIIPStreamEntry, hpnicfLIIPStreamTosByteMask=hpnicfLIIPStreamTosByteMask, hpnicfLIUserStreamAcctSessID=hpnicfLIUserStreamAcctSessID, hpnicfLIIPStreamDestAddr=hpnicfLIIPStreamDestAddr, hpnicfLIMACStreamDestAddr=hpnicfLIMACStreamDestAddr, hpnicfLIStreamHPackets=hpnicfLIStreamHPackets, hpnicfLIUserStreamRowStatus=hpnicfLIUserStreamRowStatus, hpnicfLIMediationDestAddr=hpnicfLIMediationDestAddr, hpnicfLIIPStreamSrcL4PortMin=hpnicfLIIPStreamSrcL4PortMin, hpnicfLIBoardInformation=hpnicfLIBoardInformation, hpnicfLIMACStreamEntry=hpnicfLIMACStreamEntry, hpnicfLINewIndex=hpnicfLINewIndex, hpnicfLIStreamIndex=hpnicfLIStreamIndex, hpnicfLIMACStream=hpnicfLIMACStream, hpnicfLIIPStreamRowStatus=hpnicfLIIPStreamRowStatus, hpnicfLIStreamEntry=hpnicfLIStreamEntry, hpnicfLICommon=hpnicfLICommon, hpnicfLIStreamPackets=hpnicfLIStreamPackets, hpnicfLIMediationDscp=hpnicfLIMediationDscp, hpnicfLIStreamHDrops=hpnicfLIStreamHDrops, hpnicfLIObjects=hpnicfLIObjects, hpnicfLIActive=hpnicfLIActive, hpnicfLIMACStreamDSap=hpnicfLIMACStreamDSap, hpnicfLIUserStream=hpnicfLIUserStream)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, constraints_intersection, value_size_constraint, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'SingleValueConstraint', 'ConstraintsUnion', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint')
(hpnicf_common,) = mibBuilder.importSymbols('HPN-ICF-OID-MIB', 'hpnicfCommon')
(interface_index_or_zero,) = mibBuilder.importSymbols('IF-MIB', 'InterfaceIndexOrZero')
(inet_address_type, inet_address_prefix_length, inet_address, inet_port_number) = mibBuilder.importSymbols('INET-ADDRESS-MIB', 'InetAddressType', 'InetAddressPrefixLength', 'InetAddress', 'InetPortNumber')
(snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(mib_scalar, mib_table, mib_table_row, mib_table_column, iso, counter32, integer32, notification_type, time_ticks, gauge32, module_identity, unsigned32, bits, mib_identifier, ip_address, counter64, object_identity) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'iso', 'Counter32', 'Integer32', 'NotificationType', 'TimeTicks', 'Gauge32', 'ModuleIdentity', 'Unsigned32', 'Bits', 'MibIdentifier', 'IpAddress', 'Counter64', 'ObjectIdentity')
(display_string, row_status, mac_address, date_and_time, truth_value, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'RowStatus', 'MacAddress', 'DateAndTime', 'TruthValue', 'TextualConvention')
hpnicf_li = module_identity((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111))
hpnicfLI.setRevisions(('2009-08-25 10:00',))
if mibBuilder.loadTexts:
hpnicfLI.setLastUpdated('200908251000Z')
if mibBuilder.loadTexts:
hpnicfLI.setOrganization('')
hpnicf_li_common = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1))
hpnicf_li_trap_bind_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 1))
hpnicf_li_board_information = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 1, 1), unsigned32()).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
hpnicfLIBoardInformation.setStatus('current')
hpnicf_li_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2))
hpnicf_li_notifications_prefix = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0))
hpnicf_li_active = notification_type((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0, 1)).setObjects(('HPN-ICF-LI-MIB', 'hpnicfLIStreamtype'))
if mibBuilder.loadTexts:
hpnicfLIActive.setStatus('current')
hpnicf_li_time_out = notification_type((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0, 2)).setObjects(('HPN-ICF-LI-MIB', 'hpnicfLIMediationRowStatus'))
if mibBuilder.loadTexts:
hpnicfLITimeOut.setStatus('current')
hpnicf_li_failure_information = notification_type((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 2, 0, 3)).setObjects(('HPN-ICF-LI-MIB', 'hpnicfLIStreamtype'), ('HPN-ICF-LI-MIB', 'hpnicfLIBoardInformation'))
if mibBuilder.loadTexts:
hpnicfLIFailureInformation.setStatus('current')
hpnicf_li_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3))
hpnicf_li_new_index = mib_scalar((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hpnicfLINewIndex.setStatus('current')
hpnicf_li_mediation_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2))
if mibBuilder.loadTexts:
hpnicfLIMediationTable.setStatus('current')
hpnicf_li_mediation_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1)).setIndexNames((0, 'HPN-ICF-LI-MIB', 'hpnicfLIMediationIndex'))
if mibBuilder.loadTexts:
hpnicfLIMediationEntry.setStatus('current')
hpnicf_li_mediation_index = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 2147483647)))
if mibBuilder.loadTexts:
hpnicfLIMediationIndex.setStatus('current')
hpnicf_li_mediation_dest_addr_type = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 2), inet_address_type()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationDestAddrType.setStatus('current')
hpnicf_li_mediation_dest_addr = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 3), inet_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationDestAddr.setStatus('current')
hpnicf_li_mediation_dest_port = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 4), inet_port_number()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationDestPort.setStatus('current')
hpnicf_li_mediation_src_interface = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 5), interface_index_or_zero()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationSrcInterface.setStatus('current')
hpnicf_li_mediation_dscp = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 6), integer32().clone(34)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationDscp.setStatus('current')
hpnicf_li_mediation_time_out = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 7), date_and_time()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationTimeOut.setStatus('current')
hpnicf_li_mediation_transport = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 8), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1))).clone(namedValues=named_values(('udp', 1)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationTransport.setStatus('current')
hpnicf_li_mediation_notification_enable = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 9), truth_value().clone('true')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMediationNotificationEnable.setStatus('current')
hpnicf_li_mediation_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 2, 1, 10), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hpnicfLIMediationRowStatus.setStatus('current')
hpnicf_li_stream_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3))
if mibBuilder.loadTexts:
hpnicfLIStreamTable.setStatus('current')
hpnicf_li_stream_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1)).setIndexNames((0, 'HPN-ICF-LI-MIB', 'hpnicfLIMediationIndex'), (0, 'HPN-ICF-LI-MIB', 'hpnicfLIStreamIndex'))
if mibBuilder.loadTexts:
hpnicfLIStreamEntry.setStatus('current')
hpnicf_li_stream_index = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(1, 2147483647)))
if mibBuilder.loadTexts:
hpnicfLIStreamIndex.setStatus('current')
hpnicf_li_streamtype = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3))).clone(namedValues=named_values(('ip', 1), ('mac', 2), ('userConnection', 3)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIStreamtype.setStatus('current')
hpnicf_li_stream_enable = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 3), truth_value().clone('false')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIStreamEnable.setStatus('current')
hpnicf_li_stream_packets = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 4), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hpnicfLIStreamPackets.setStatus('current')
hpnicf_li_stream_drops = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 5), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hpnicfLIStreamDrops.setStatus('current')
hpnicf_li_stream_h_packets = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 6), counter64()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hpnicfLIStreamHPackets.setStatus('current')
hpnicf_li_stream_h_drops = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 7), counter64()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
hpnicfLIStreamHDrops.setStatus('current')
hpnicf_li_stream_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 1, 3, 3, 1, 8), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hpnicfLIStreamRowStatus.setStatus('current')
hpnicf_liip_stream = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2))
hpnicf_liip_stream_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1))
hpnicf_liip_stream_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1))
if mibBuilder.loadTexts:
hpnicfLIIPStreamTable.setStatus('current')
hpnicf_liip_stream_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1)).setIndexNames((0, 'HPN-ICF-LI-MIB', 'hpnicfLIMediationIndex'), (0, 'HPN-ICF-LI-MIB', 'hpnicfLIStreamIndex'))
if mibBuilder.loadTexts:
hpnicfLIIPStreamEntry.setStatus('current')
hpnicf_liip_stream_interface = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 1), interface_index_or_zero()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamInterface.setStatus('current')
hpnicf_liip_stream_addr_type = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 2), inet_address_type().clone('ipv4')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamAddrType.setStatus('current')
hpnicf_liip_stream_dest_addr = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 3), inet_address().clone(hexValue='00000000')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamDestAddr.setStatus('current')
hpnicf_liip_stream_dest_addr_length = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 4), inet_address_prefix_length()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamDestAddrLength.setStatus('current')
hpnicf_liip_stream_src_addr = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 5), inet_address().clone(hexValue='00000000')).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamSrcAddr.setStatus('current')
hpnicf_liip_stream_src_addr_length = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 6), inet_address_prefix_length()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamSrcAddrLength.setStatus('current')
hpnicf_liip_stream_tos_byte = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamTosByte.setStatus('current')
hpnicf_liip_stream_tos_byte_mask = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(0, 255))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamTosByteMask.setStatus('current')
hpnicf_liip_stream_flow_id = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 9), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 1048575))).clone(-1)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamFlowId.setStatus('current')
hpnicf_liip_stream_protocol = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 10), integer32().subtype(subtypeSpec=constraints_union(value_range_constraint(-1, -1), value_range_constraint(0, 255))).clone(-1)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamProtocol.setStatus('current')
hpnicf_liip_stream_dest_l4_port_min = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 11), inet_port_number()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamDestL4PortMin.setStatus('current')
hpnicf_liip_stream_dest_l4_port_max = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 12), inet_port_number().clone(65535)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamDestL4PortMax.setStatus('current')
hpnicf_liip_stream_src_l4_port_min = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 13), inet_port_number()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamSrcL4PortMin.setStatus('current')
hpnicf_liip_stream_src_l4_port_max = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 14), inet_port_number().clone(65535)).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamSrcL4PortMax.setStatus('current')
hpnicf_liip_stream_vrf = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 15), snmp_admin_string()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIIPStreamVRF.setStatus('current')
hpnicf_liip_stream_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 2, 1, 1, 1, 18), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hpnicfLIIPStreamRowStatus.setStatus('current')
hpnicf_limac_stream = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3))
hpnicf_limac_stream_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1))
hpnicf_limac_stream_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1))
if mibBuilder.loadTexts:
hpnicfLIMACStreamTable.setStatus('current')
hpnicf_limac_stream_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1)).setIndexNames((0, 'HPN-ICF-LI-MIB', 'hpnicfLIMediationIndex'), (0, 'HPN-ICF-LI-MIB', 'hpnicfLIStreamIndex'))
if mibBuilder.loadTexts:
hpnicfLIMACStreamEntry.setStatus('current')
hpnicf_limac_stream_fields = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 1), bits().clone(namedValues=named_values(('interface', 0), ('dstMacAddress', 1), ('srcMacAddress', 2), ('ethernetPid', 3), ('dSap', 4), ('sSap', 5)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamFields.setStatus('current')
hpnicf_limac_stream_interface = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 2), interface_index_or_zero()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamInterface.setStatus('current')
hpnicf_limac_stream_dest_addr = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 3), mac_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamDestAddr.setStatus('current')
hpnicf_limac_stream_src_addr = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 4), mac_address()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamSrcAddr.setStatus('current')
hpnicf_limac_stream_eth_pid = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 5), unsigned32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamEthPid.setStatus('current')
hpnicf_limac_stream_d_sap = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 6), unsigned32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamDSap.setStatus('current')
hpnicf_limac_stream_s_sap = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 7), unsigned32()).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIMACStreamSSap.setStatus('current')
hpnicf_limac_stream_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 3, 1, 1, 1, 8), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hpnicfLIMACStreamRowStatus.setStatus('current')
hpnicf_li_user_stream = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4))
hpnicf_li_user_stream_objects = mib_identifier((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1))
hpnicf_li_user_stream_table = mib_table((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1))
if mibBuilder.loadTexts:
hpnicfLIUserStreamTable.setStatus('current')
hpnicf_li_user_stream_entry = mib_table_row((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1, 1)).setIndexNames((0, 'HPN-ICF-LI-MIB', 'hpnicfLIMediationIndex'), (0, 'HPN-ICF-LI-MIB', 'hpnicfLIStreamIndex'))
if mibBuilder.loadTexts:
hpnicfLIUserStreamEntry.setStatus('current')
hpnicf_li_user_stream_acct_sess_id = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1, 1, 1), octet_string().subtype(subtypeSpec=value_size_constraint(0, 253))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
hpnicfLIUserStreamAcctSessID.setStatus('current')
hpnicf_li_user_stream_row_status = mib_table_column((1, 3, 6, 1, 4, 1, 11, 2, 14, 11, 15, 2, 111, 4, 1, 1, 1, 2), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
hpnicfLIUserStreamRowStatus.setStatus('current')
mibBuilder.exportSymbols('HPN-ICF-LI-MIB', hpnicfLIStreamDrops=hpnicfLIStreamDrops, hpnicfLIIPStreamDestAddrLength=hpnicfLIIPStreamDestAddrLength, hpnicfLIMACStreamFields=hpnicfLIMACStreamFields, hpnicfLIIPStreamSrcL4PortMax=hpnicfLIIPStreamSrcL4PortMax, hpnicfLIMediationRowStatus=hpnicfLIMediationRowStatus, hpnicfLIIPStream=hpnicfLIIPStream, hpnicfLIMACStreamTable=hpnicfLIMACStreamTable, hpnicfLIIPStreamFlowId=hpnicfLIIPStreamFlowId, hpnicfLIMediationSrcInterface=hpnicfLIMediationSrcInterface, hpnicfLIMACStreamSrcAddr=hpnicfLIMACStreamSrcAddr, hpnicfLIMACStreamRowStatus=hpnicfLIMACStreamRowStatus, hpnicfLIIPStreamDestL4PortMax=hpnicfLIIPStreamDestL4PortMax, hpnicfLIUserStreamTable=hpnicfLIUserStreamTable, hpnicfLIUserStreamEntry=hpnicfLIUserStreamEntry, hpnicfLIIPStreamTable=hpnicfLIIPStreamTable, PYSNMP_MODULE_ID=hpnicfLI, hpnicfLIMediationIndex=hpnicfLIMediationIndex, hpnicfLIIPStreamProtocol=hpnicfLIIPStreamProtocol, hpnicfLITrapBindObjects=hpnicfLITrapBindObjects, hpnicfLIMediationDestAddrType=hpnicfLIMediationDestAddrType, hpnicfLIMediationEntry=hpnicfLIMediationEntry, hpnicfLIIPStreamInterface=hpnicfLIIPStreamInterface, hpnicfLIMediationTransport=hpnicfLIMediationTransport, hpnicfLIIPStreamDestL4PortMin=hpnicfLIIPStreamDestL4PortMin, hpnicfLIMACStreamEthPid=hpnicfLIMACStreamEthPid, hpnicfLIStreamRowStatus=hpnicfLIStreamRowStatus, hpnicfLIMACStreamObjects=hpnicfLIMACStreamObjects, hpnicfLIStreamtype=hpnicfLIStreamtype, hpnicfLINotifications=hpnicfLINotifications, hpnicfLIIPStreamVRF=hpnicfLIIPStreamVRF, hpnicfLIStreamEnable=hpnicfLIStreamEnable, hpnicfLI=hpnicfLI, hpnicfLIIPStreamObjects=hpnicfLIIPStreamObjects, hpnicfLIIPStreamSrcAddr=hpnicfLIIPStreamSrcAddr, hpnicfLIFailureInformation=hpnicfLIFailureInformation, hpnicfLIIPStreamSrcAddrLength=hpnicfLIIPStreamSrcAddrLength, hpnicfLIMediationNotificationEnable=hpnicfLIMediationNotificationEnable, hpnicfLIMediationTimeOut=hpnicfLIMediationTimeOut, hpnicfLITimeOut=hpnicfLITimeOut, hpnicfLIStreamTable=hpnicfLIStreamTable, hpnicfLIIPStreamAddrType=hpnicfLIIPStreamAddrType, hpnicfLIUserStreamObjects=hpnicfLIUserStreamObjects, hpnicfLIMediationTable=hpnicfLIMediationTable, hpnicfLIMediationDestPort=hpnicfLIMediationDestPort, hpnicfLIMACStreamInterface=hpnicfLIMACStreamInterface, hpnicfLIIPStreamTosByte=hpnicfLIIPStreamTosByte, hpnicfLIMACStreamSSap=hpnicfLIMACStreamSSap, hpnicfLINotificationsPrefix=hpnicfLINotificationsPrefix, hpnicfLIIPStreamEntry=hpnicfLIIPStreamEntry, hpnicfLIIPStreamTosByteMask=hpnicfLIIPStreamTosByteMask, hpnicfLIUserStreamAcctSessID=hpnicfLIUserStreamAcctSessID, hpnicfLIIPStreamDestAddr=hpnicfLIIPStreamDestAddr, hpnicfLIMACStreamDestAddr=hpnicfLIMACStreamDestAddr, hpnicfLIStreamHPackets=hpnicfLIStreamHPackets, hpnicfLIUserStreamRowStatus=hpnicfLIUserStreamRowStatus, hpnicfLIMediationDestAddr=hpnicfLIMediationDestAddr, hpnicfLIIPStreamSrcL4PortMin=hpnicfLIIPStreamSrcL4PortMin, hpnicfLIBoardInformation=hpnicfLIBoardInformation, hpnicfLIMACStreamEntry=hpnicfLIMACStreamEntry, hpnicfLINewIndex=hpnicfLINewIndex, hpnicfLIStreamIndex=hpnicfLIStreamIndex, hpnicfLIMACStream=hpnicfLIMACStream, hpnicfLIIPStreamRowStatus=hpnicfLIIPStreamRowStatus, hpnicfLIStreamEntry=hpnicfLIStreamEntry, hpnicfLICommon=hpnicfLICommon, hpnicfLIStreamPackets=hpnicfLIStreamPackets, hpnicfLIMediationDscp=hpnicfLIMediationDscp, hpnicfLIStreamHDrops=hpnicfLIStreamHDrops, hpnicfLIObjects=hpnicfLIObjects, hpnicfLIActive=hpnicfLIActive, hpnicfLIMACStreamDSap=hpnicfLIMACStreamDSap, hpnicfLIUserStream=hpnicfLIUserStream) |
def inorder(root):
res = []
if not root:
return res
stack = []
while root and stack:
while root:
stack.append(root)
root = root.left
root = stack.pop()
res.add(root.val)
root = root.right
return res
| def inorder(root):
res = []
if not root:
return res
stack = []
while root and stack:
while root:
stack.append(root)
root = root.left
root = stack.pop()
res.add(root.val)
root = root.right
return res |
class Solution:
def partition(self, s: str) -> list[list[str]]:
# TODO: add explanation, make clearer
if len(s) == 0:
return [[]]
result = []
def backtrack(current: list[str], prefix: str) -> None:
if len(prefix) == 0:
result.append(current)
return
for index in range(1, len(prefix)+1):
substring = prefix[:index]
if substring == substring[::-1]:
backtrack(current + [substring], prefix[index:])
backtrack([], s)
return result
tests = [
(
("aab",),
[["a", "a", "b"], ["aa", "b"]],
),
(
("a",),
[["a"]],
),
]
| class Solution:
def partition(self, s: str) -> list[list[str]]:
if len(s) == 0:
return [[]]
result = []
def backtrack(current: list[str], prefix: str) -> None:
if len(prefix) == 0:
result.append(current)
return
for index in range(1, len(prefix) + 1):
substring = prefix[:index]
if substring == substring[::-1]:
backtrack(current + [substring], prefix[index:])
backtrack([], s)
return result
tests = [(('aab',), [['a', 'a', 'b'], ['aa', 'b']]), (('a',), [['a']])] |
def geobox2rect(geobox):
x, y, w, h = geobox
return x - int(w / 2), y - int(h / 2), w, h
def geobox2ptrect(geobox):
x, y, w, h = geobox2rect(geobox)
return x, y, x + w, y + h
def rect2geobox(x, y, w, h):
return x + int(w / 2), y + int(h / 2), w, h
def ptrect2geobox(x1, y1, x2, y2):
return rect2geobox(x1, y1, x2 - x1, y2 - y1)
def bbox2rect(bbox):
return geobox2rect(bbox2geobox(bbox))
def bbox2lt(bbox):
x1, y1, x2, y2 = geobox2ptrect(bbox2geobox(bbox))
return x1, y1
def bbox2lb(bbox):
x1, y1, x2, y2 = geobox2ptrect(bbox2geobox(bbox))
return x1, y2
def bbox2rt(bbox):
x1, y1, x2, y2 = geobox2ptrect(bbox2geobox(bbox))
return x2, y1
def bbox2rb(bbox):
x1, y1, x2, y2 = geobox2ptrect(bbox2geobox(bbox))
return x2, y2
def bbox2name(bbox):
return bbox[0]
def bbox2score(bbox):
return bbox[1]
def bbox2geobox(bbox):
return bbox[2]
def bbox2center(bbox):
return bbox[2][:2]
def to_box(name, score, geobox):
return name, score, geobox
def margin_geobox(geobox, margin_ratio):
x, y, w, h = geobox
w_margin = int(w * margin_ratio)
h_margin = int(h * margin_ratio)
return x, y, w + (2 * w_margin), h + (2 * h_margin)
def margin_box(box, margin_ratio):
name, score, geobox = box
geobox = margin_geobox(geobox, margin_ratio)
return to_box(name, score, geobox)
| def geobox2rect(geobox):
(x, y, w, h) = geobox
return (x - int(w / 2), y - int(h / 2), w, h)
def geobox2ptrect(geobox):
(x, y, w, h) = geobox2rect(geobox)
return (x, y, x + w, y + h)
def rect2geobox(x, y, w, h):
return (x + int(w / 2), y + int(h / 2), w, h)
def ptrect2geobox(x1, y1, x2, y2):
return rect2geobox(x1, y1, x2 - x1, y2 - y1)
def bbox2rect(bbox):
return geobox2rect(bbox2geobox(bbox))
def bbox2lt(bbox):
(x1, y1, x2, y2) = geobox2ptrect(bbox2geobox(bbox))
return (x1, y1)
def bbox2lb(bbox):
(x1, y1, x2, y2) = geobox2ptrect(bbox2geobox(bbox))
return (x1, y2)
def bbox2rt(bbox):
(x1, y1, x2, y2) = geobox2ptrect(bbox2geobox(bbox))
return (x2, y1)
def bbox2rb(bbox):
(x1, y1, x2, y2) = geobox2ptrect(bbox2geobox(bbox))
return (x2, y2)
def bbox2name(bbox):
return bbox[0]
def bbox2score(bbox):
return bbox[1]
def bbox2geobox(bbox):
return bbox[2]
def bbox2center(bbox):
return bbox[2][:2]
def to_box(name, score, geobox):
return (name, score, geobox)
def margin_geobox(geobox, margin_ratio):
(x, y, w, h) = geobox
w_margin = int(w * margin_ratio)
h_margin = int(h * margin_ratio)
return (x, y, w + 2 * w_margin, h + 2 * h_margin)
def margin_box(box, margin_ratio):
(name, score, geobox) = box
geobox = margin_geobox(geobox, margin_ratio)
return to_box(name, score, geobox) |
def pythag_triple(n):
for a in range(1, n // 2):
b = (n**2/2 - n*a)/(n - a)
if b.is_integer():
return int(a*b*(n - a - b))
return None
print(pythag_triple(1000))
# Copyright Junipyr. All rights reserved.
# https://github.com/Junipyr | def pythag_triple(n):
for a in range(1, n // 2):
b = (n ** 2 / 2 - n * a) / (n - a)
if b.is_integer():
return int(a * b * (n - a - b))
return None
print(pythag_triple(1000)) |
mylitta = [1, 2, 3, 4, 5]
l2 = list([1, 2, 3, 4, 5])
l3 = list("casa de papel")
l4 = "alberto torres".split()
l5 = "alberto torres,carolina torres,mauricio torres".split(",")
cadena = " - ".join(l5)
mylitta = mylitta + [12, 13]
mylitta += [15, 16]
mylitta.append(9)
mylitta.extend([10, 11])
print(mylitta)
print(l2)
print(l3)
print(l4)
print(l5)
print(cadena)
print(l3.index("s"))
print(l3[-2])
| mylitta = [1, 2, 3, 4, 5]
l2 = list([1, 2, 3, 4, 5])
l3 = list('casa de papel')
l4 = 'alberto torres'.split()
l5 = 'alberto torres,carolina torres,mauricio torres'.split(',')
cadena = ' - '.join(l5)
mylitta = mylitta + [12, 13]
mylitta += [15, 16]
mylitta.append(9)
mylitta.extend([10, 11])
print(mylitta)
print(l2)
print(l3)
print(l4)
print(l5)
print(cadena)
print(l3.index('s'))
print(l3[-2]) |
# open the fil2.txt in read mode. causes error if no such file exists.
fileptr = open("file2.txt", "r")
# stores all the data of the file into the variable content
content = fileptr.readlines()
# prints the content of the file
print(content)
# closes the opened file
fileptr.close() | fileptr = open('file2.txt', 'r')
content = fileptr.readlines()
print(content)
fileptr.close() |
# -*- coding: utf-8 -*-
# Copyright 2019 Cohesity Inc.
class TypeSqlProtectionSourceEnum(object):
"""Implementation of the 'Type_SqlProtectionSource' enum.
Specifies the type of the managed Object in a SQL Protection Source.
Examples of SQL Objects include 'kInstance' and 'kDatabase'.
'kInstance' indicates that SQL server instance is being protected.
'kDatabase' indicates that SQL server database is being protected.
'kAAG' indicates that SQL AAG (AlwaysOn Availability Group) is being
protected.
'kAAGRootContainer' indicates that SQL AAG's root container is being
protected.
'kRootContainer' indicates root container for SQL sources.
Attributes:
KINSTANCE: TODO: type description here.
KDATABASE: TODO: type description here.
KAAG: TODO: type description here.
KAAGROOTCONTAINER: TODO: type description here.
KROOTCONTAINER: TODO: type description here.
"""
KINSTANCE = 'kInstance'
KDATABASE = 'kDatabase'
KAAG = 'kAAG'
KAAGROOTCONTAINER = 'kAAGRootContainer'
KROOTCONTAINER = 'kRootContainer'
| class Typesqlprotectionsourceenum(object):
"""Implementation of the 'Type_SqlProtectionSource' enum.
Specifies the type of the managed Object in a SQL Protection Source.
Examples of SQL Objects include 'kInstance' and 'kDatabase'.
'kInstance' indicates that SQL server instance is being protected.
'kDatabase' indicates that SQL server database is being protected.
'kAAG' indicates that SQL AAG (AlwaysOn Availability Group) is being
protected.
'kAAGRootContainer' indicates that SQL AAG's root container is being
protected.
'kRootContainer' indicates root container for SQL sources.
Attributes:
KINSTANCE: TODO: type description here.
KDATABASE: TODO: type description here.
KAAG: TODO: type description here.
KAAGROOTCONTAINER: TODO: type description here.
KROOTCONTAINER: TODO: type description here.
"""
kinstance = 'kInstance'
kdatabase = 'kDatabase'
kaag = 'kAAG'
kaagrootcontainer = 'kAAGRootContainer'
krootcontainer = 'kRootContainer' |
# Advent of Code 2017
#
# From https://adventofcode.com/2017/day/4
#
passwords = [row.strip().split() for row in open('../inputs/Advent2017_04.txt', 'r')]
print(sum(len(row) == len(set(row)) for row in passwords))
print(sum(len(row) == len(set("".join(sorted(x)) for x in row)) for row in passwords))
| passwords = [row.strip().split() for row in open('../inputs/Advent2017_04.txt', 'r')]
print(sum((len(row) == len(set(row)) for row in passwords)))
print(sum((len(row) == len(set((''.join(sorted(x)) for x in row))) for row in passwords))) |
'''
Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Clarification:
Confused why the returned value is an integer but your answer is an array?
Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.
Internally you can think of this:
// nums is passed in by reference. (i.e., without making a copy)
int len = removeDuplicates(nums);
// any modification to nums in your function would be known by the caller.
// using the length returned by your function, it prints the first len elements.
for (int i = 0; i < len; i++) {
print(nums[i]);
}
Example 1:
Input: nums = [1,1,2]
Output: 2, nums = [1,2]
Explanation: Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.
Example 2:
Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5, nums = [0,1,2,3,4]
Explanation: Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively. It doesn't matter what values are set beyond the returned length.
Constraints:
0 <= nums.length <= 3 * 104
-104 <= nums[i] <= 104
nums is sorted in ascending order.
'''
class Solution:
def removeDuplicates(self, nums: List[int]) -> int:
new_len = len(nums)
if new_len == 0:
return 0
else:
# define counters and constants
target = nums[0]
# target2 = None ## needs to be unique
counter = 0
# clean the array
for idx in range(1,len(nums)):
if nums[idx]==target:
# if counter>0:
# nums[idx] = target2
counter += 1
new_len -= 1
else:
target = nums[idx]
if counter > 0:
nums[idx-counter] = nums[idx]
# nums[idx] = target2
# print(idx,target,nums,new_len)
return new_len
| """
Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Clarification:
Confused why the returned value is an integer but your answer is an array?
Note that the input array is passed in by reference, which means a modification to the input array will be known to the caller as well.
Internally you can think of this:
// nums is passed in by reference. (i.e., without making a copy)
int len = removeDuplicates(nums);
// any modification to nums in your function would be known by the caller.
// using the length returned by your function, it prints the first len elements.
for (int i = 0; i < len; i++) {
print(nums[i]);
}
Example 1:
Input: nums = [1,1,2]
Output: 2, nums = [1,2]
Explanation: Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.
Example 2:
Input: nums = [0,0,1,1,1,2,2,3,3,4]
Output: 5, nums = [0,1,2,3,4]
Explanation: Your function should return length = 5, with the first five elements of nums being modified to 0, 1, 2, 3, and 4 respectively. It doesn't matter what values are set beyond the returned length.
Constraints:
0 <= nums.length <= 3 * 104
-104 <= nums[i] <= 104
nums is sorted in ascending order.
"""
class Solution:
def remove_duplicates(self, nums: List[int]) -> int:
new_len = len(nums)
if new_len == 0:
return 0
else:
target = nums[0]
counter = 0
for idx in range(1, len(nums)):
if nums[idx] == target:
counter += 1
new_len -= 1
else:
target = nums[idx]
if counter > 0:
nums[idx - counter] = nums[idx]
return new_len |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.