content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Replace:
def __init__(self, data):
self.data = data
def replace(self, index):
if index == 0:
if self.data % 10 == 0:
self.data = "%d-%d" %((int(self.data / 10) - 1) * 10 + 1, self.data)
else:
self.data = "%d-%d" %((int(self.data / 10) * 10 + 1, ((int(self.data / 10) + 1) * 10)))
if index == 8:
if self.data == 0:
self.data = "No-capital-gain"
elif 0 < self.data < 99999:
self.data = "Gain-some-capital"
else:
self.data = "Gain-vast-capital"
if index == 9:
if self.data == 0:
self.data = "No-capital-loss"
else:
self.data = "Loss-some-capital"
if index == 10:
if self.data == 0:
self.data = "Not-working"
elif 0 < self.data < 35:
self.data = "Part-time"
elif 35 <= self.data <= 40:
self.data = "Full-time"
else:
self.data = "Over-time"
return self.data | class Replace:
def __init__(self, data):
self.data = data
def replace(self, index):
if index == 0:
if self.data % 10 == 0:
self.data = '%d-%d' % ((int(self.data / 10) - 1) * 10 + 1, self.data)
else:
self.data = '%d-%d' % (int(self.data / 10) * 10 + 1, (int(self.data / 10) + 1) * 10)
if index == 8:
if self.data == 0:
self.data = 'No-capital-gain'
elif 0 < self.data < 99999:
self.data = 'Gain-some-capital'
else:
self.data = 'Gain-vast-capital'
if index == 9:
if self.data == 0:
self.data = 'No-capital-loss'
else:
self.data = 'Loss-some-capital'
if index == 10:
if self.data == 0:
self.data = 'Not-working'
elif 0 < self.data < 35:
self.data = 'Part-time'
elif 35 <= self.data <= 40:
self.data = 'Full-time'
else:
self.data = 'Over-time'
return self.data |
class Error(Exception):
pass
class HttpError(Error):
def __init__(
self,
error,
error_description,
error_detail=None,
status_code=None,
url=None):
self.error = error
self.error_description = error_description
self.error_detail = error_detail
self.status_code = status_code
self.url = url
def __repr__(self):
s = '<%s "%s": %s' % (self.__class__.__name__,
self.error, self.error_description)
if self.status_code and self.url:
s += ' (%s from %s)' % (self.status_code, self.url)
if self.error_detail:
s += ', ' + str(self.error_detail)
return s + '>'
__str__ = __repr__
def _asdict(self):
data = {
'error': self.error,
'error_description': self.error_description
}
if self.error_detail:
data['error_detail'] = self.error_detail
if self.status_code:
data['status_code'] = self.status_code
if self.url:
data['url'] = self.url
return data
class BadRequest(HttpError):
pass
class Unauthorized(HttpError):
pass
class Forbidden(HttpError):
pass
class NotFound(HttpError):
pass
class MethodNotAllowed(HttpError):
pass
class Conflict(HttpError):
pass
class InternalServerError(HttpError):
pass
class UnsupportedURI(Error):
pass
class InvalidDataFormat(Error):
pass
class ResourceNotFound(Error):
pass
class InvalidPathException(Error):
def __init__(self, path):
self.path = path
class EtagHashNotMatch(Error):
pass
| class Error(Exception):
pass
class Httperror(Error):
def __init__(self, error, error_description, error_detail=None, status_code=None, url=None):
self.error = error
self.error_description = error_description
self.error_detail = error_detail
self.status_code = status_code
self.url = url
def __repr__(self):
s = '<%s "%s": %s' % (self.__class__.__name__, self.error, self.error_description)
if self.status_code and self.url:
s += ' (%s from %s)' % (self.status_code, self.url)
if self.error_detail:
s += ', ' + str(self.error_detail)
return s + '>'
__str__ = __repr__
def _asdict(self):
data = {'error': self.error, 'error_description': self.error_description}
if self.error_detail:
data['error_detail'] = self.error_detail
if self.status_code:
data['status_code'] = self.status_code
if self.url:
data['url'] = self.url
return data
class Badrequest(HttpError):
pass
class Unauthorized(HttpError):
pass
class Forbidden(HttpError):
pass
class Notfound(HttpError):
pass
class Methodnotallowed(HttpError):
pass
class Conflict(HttpError):
pass
class Internalservererror(HttpError):
pass
class Unsupporteduri(Error):
pass
class Invaliddataformat(Error):
pass
class Resourcenotfound(Error):
pass
class Invalidpathexception(Error):
def __init__(self, path):
self.path = path
class Etaghashnotmatch(Error):
pass |
class SessionProxy:
@property
def session(self):
"""Proxy for ``self._session``."""
return self._session # pragma: no cover
@property
def query(self):
"""Proxy for ``self._session.query``."""
return self._session.query # pragma: no cover
def add(self, *args, **kwargs):
"""Proxy for ``self._session.add()``."""
return self._session.add(*args, **kwargs) # pragma: no cover
def add_all(self, *args, **kwargs):
"""Proxy for ``self._session.add_all()``."""
return self._session.add_all(*args, **kwargs) # pragma: no cover
def begin(self, *args, **kwargs):
"""Proxy for ``self._session.begin()``."""
return self._session.begin(*args, **kwargs) # pragma: no cover
def begin_nested(self, *args, **kwargs):
"""Proxy for ``self._session.begin_nested()``."""
return self._session.begin_nested(*args, **kwargs) # pragma: no cover
def commit(self, *args, **kwargs):
"""Proxy for ``self._session.commit()``."""
return self._session.commit(*args, **kwargs) # pragma: no cover
def connection(self, *args, **kwargs):
"""Proxy for ``self._session.connection()``."""
return self._session.connection(*args, **kwargs) # pragma: no cover
def delete(self, *args, **kwargs):
"""Proxy for ``self._session.delete()``."""
return self._session.delete(*args, **kwargs) # pragma: no cover
def execute(self, *args, **kwargs):
"""Proxy for ``self._session.execute()``."""
return self._session.execute(*args, **kwargs) # pragma: no cover
def expire(self, *args, **kwargs):
"""Proxy for ``self._session.expire()``."""
return self._session.expire(*args, **kwargs) # pragma: no cover
def expire_all(self, *args, **kwargs):
"""Proxy for ``self._session.expire_all()``."""
return self._session.expire_all(*args, **kwargs) # pragma: no cover
def expunge(self, *args, **kwargs):
"""Proxy for ``self._session.expunge()``."""
return self._session.expunge(*args, **kwargs) # pragma: no cover
def expunge_all(self, *args, **kwargs):
"""Proxy for ``self._session.expunge_all()``."""
return self._session.expunge_all(*args, **kwargs) # pragma: no cover
def flush(self, *args, **kwargs):
"""Proxy for ``self._session.flush()``."""
return self._session.flush(*args, **kwargs) # pragma: no cover
def invalidate(self, *args, **kwargs):
"""Proxy for ``self._session.invalidate()``."""
return self._session.invalidate(*args, **kwargs) # pragma: no cover
def is_modified(self, *args, **kwargs):
"""Proxy for ``self._session.is_modified()``."""
return self._session.is_modified(*args, **kwargs) # pragma: no cover
def merge(self, *args, **kwargs):
"""Proxy for ``self._session.merge()``."""
return self._session.merge(*args, **kwargs) # pragma: no cover
def prepare(self, *args, **kwargs):
"""Proxy for ``self._session.prepare()``."""
return self._session.prepare(*args, **kwargs) # pragma: no cover
def prune(self, *args, **kwargs):
"""Proxy for ``self._session.prune()``."""
return self._session.prune(*args, **kwargs) # pragma: no cover
def refresh(self, *args, **kwargs):
"""Proxy for ``self._session.refresh()``."""
return self._session.refresh(*args, **kwargs) # pragma: no cover
def remove(self, *args, **kwargs):
"""Proxy for ``self._session.remove()``."""
return self._session.remove(*args, **kwargs) # pragma: no cover
def rollback(self, *args, **kwargs):
"""Proxy for ``self._session.rollback()``."""
return self._session.rollback(*args, **kwargs) # pragma: no cover
def scalar(self, *args, **kwargs):
"""Proxy for ``self._session.scalar()``."""
return self._session.scalar(*args, **kwargs) # pragma: no cover
| class Sessionproxy:
@property
def session(self):
"""Proxy for ``self._session``."""
return self._session
@property
def query(self):
"""Proxy for ``self._session.query``."""
return self._session.query
def add(self, *args, **kwargs):
"""Proxy for ``self._session.add()``."""
return self._session.add(*args, **kwargs)
def add_all(self, *args, **kwargs):
"""Proxy for ``self._session.add_all()``."""
return self._session.add_all(*args, **kwargs)
def begin(self, *args, **kwargs):
"""Proxy for ``self._session.begin()``."""
return self._session.begin(*args, **kwargs)
def begin_nested(self, *args, **kwargs):
"""Proxy for ``self._session.begin_nested()``."""
return self._session.begin_nested(*args, **kwargs)
def commit(self, *args, **kwargs):
"""Proxy for ``self._session.commit()``."""
return self._session.commit(*args, **kwargs)
def connection(self, *args, **kwargs):
"""Proxy for ``self._session.connection()``."""
return self._session.connection(*args, **kwargs)
def delete(self, *args, **kwargs):
"""Proxy for ``self._session.delete()``."""
return self._session.delete(*args, **kwargs)
def execute(self, *args, **kwargs):
"""Proxy for ``self._session.execute()``."""
return self._session.execute(*args, **kwargs)
def expire(self, *args, **kwargs):
"""Proxy for ``self._session.expire()``."""
return self._session.expire(*args, **kwargs)
def expire_all(self, *args, **kwargs):
"""Proxy for ``self._session.expire_all()``."""
return self._session.expire_all(*args, **kwargs)
def expunge(self, *args, **kwargs):
"""Proxy for ``self._session.expunge()``."""
return self._session.expunge(*args, **kwargs)
def expunge_all(self, *args, **kwargs):
"""Proxy for ``self._session.expunge_all()``."""
return self._session.expunge_all(*args, **kwargs)
def flush(self, *args, **kwargs):
"""Proxy for ``self._session.flush()``."""
return self._session.flush(*args, **kwargs)
def invalidate(self, *args, **kwargs):
"""Proxy for ``self._session.invalidate()``."""
return self._session.invalidate(*args, **kwargs)
def is_modified(self, *args, **kwargs):
"""Proxy for ``self._session.is_modified()``."""
return self._session.is_modified(*args, **kwargs)
def merge(self, *args, **kwargs):
"""Proxy for ``self._session.merge()``."""
return self._session.merge(*args, **kwargs)
def prepare(self, *args, **kwargs):
"""Proxy for ``self._session.prepare()``."""
return self._session.prepare(*args, **kwargs)
def prune(self, *args, **kwargs):
"""Proxy for ``self._session.prune()``."""
return self._session.prune(*args, **kwargs)
def refresh(self, *args, **kwargs):
"""Proxy for ``self._session.refresh()``."""
return self._session.refresh(*args, **kwargs)
def remove(self, *args, **kwargs):
"""Proxy for ``self._session.remove()``."""
return self._session.remove(*args, **kwargs)
def rollback(self, *args, **kwargs):
"""Proxy for ``self._session.rollback()``."""
return self._session.rollback(*args, **kwargs)
def scalar(self, *args, **kwargs):
"""Proxy for ``self._session.scalar()``."""
return self._session.scalar(*args, **kwargs) |
a = int(input())
t = 0
for x in range(a,50):
if x % 2 !=0 and t <6:
t = t+1
print(x)
| a = int(input())
t = 0
for x in range(a, 50):
if x % 2 != 0 and t < 6:
t = t + 1
print(x) |
def pangkat_tiga(angka):
return angka ** 3
# argumen # nilai kembalian
pangkat_tiga_1 = lambda angka_1, angka_2, larik : [angka_1 ** 3 if angka_1 % 3 == 0 else angka_1 + 3,
angka_2 ** 2,
[elemen * 2 for elemen in larik]]
print(pangkat_tiga(3))
print(pangkat_tiga_1(4, 4, [2,3,4]))
# Fungsi sebagai argumen/parameter
def bagi_dua(hasil_pangkat_tiga):
return hasil_pangkat_tiga / 2
print(bagi_dua(pangkat_tiga(4)))
# Fungsi di dalam fungsi sebagai nilai balik
def halo(nama):
print(nama, "cuaca hari ini cerah ya?")
def sapa(nama):
return halo(nama)
sapa("Sanji")
# Generator
def ini_generator():
yield 1
yield 2
yield 3
yield "JoJo"
for i in ini_generator():
print(i)
def balok(panjang, lebar, tinggi):
volume = panjang * lebar * tinggi
yield volume
luas_permukaan = 2 * (panjang * lebar) + 2 * (panjang * tinggi) + 2 * (tinggi * lebar)
yield luas_permukaan
def balok_1(panjang, lebar, tinggi):
volume = panjang * lebar * tinggi
luas_permukaan = 2 * (panjang * lebar) + 2 * (panjang * tinggi) + 2 * (tinggi * lebar)
return volume, luas_permukaan
for i in balok_1(10, 10, 10):
print(i)
print(balok(5,5,5)) | def pangkat_tiga(angka):
return angka ** 3
pangkat_tiga_1 = lambda angka_1, angka_2, larik: [angka_1 ** 3 if angka_1 % 3 == 0 else angka_1 + 3, angka_2 ** 2, [elemen * 2 for elemen in larik]]
print(pangkat_tiga(3))
print(pangkat_tiga_1(4, 4, [2, 3, 4]))
def bagi_dua(hasil_pangkat_tiga):
return hasil_pangkat_tiga / 2
print(bagi_dua(pangkat_tiga(4)))
def halo(nama):
print(nama, 'cuaca hari ini cerah ya?')
def sapa(nama):
return halo(nama)
sapa('Sanji')
def ini_generator():
yield 1
yield 2
yield 3
yield 'JoJo'
for i in ini_generator():
print(i)
def balok(panjang, lebar, tinggi):
volume = panjang * lebar * tinggi
yield volume
luas_permukaan = 2 * (panjang * lebar) + 2 * (panjang * tinggi) + 2 * (tinggi * lebar)
yield luas_permukaan
def balok_1(panjang, lebar, tinggi):
volume = panjang * lebar * tinggi
luas_permukaan = 2 * (panjang * lebar) + 2 * (panjang * tinggi) + 2 * (tinggi * lebar)
return (volume, luas_permukaan)
for i in balok_1(10, 10, 10):
print(i)
print(balok(5, 5, 5)) |
class Generator:
"""
Base generator class. Analogous to Input class.
Object Propertie(s):
------------------
data : Dict
A dictionary to hold all the node & edge information.
See also:
---------
RandomGNP
"""
def __init__(self):
self.data = {}
self.data['nodes'] = {}
self.data['edges'] = {}
| class Generator:
"""
Base generator class. Analogous to Input class.
Object Propertie(s):
------------------
data : Dict
A dictionary to hold all the node & edge information.
See also:
---------
RandomGNP
"""
def __init__(self):
self.data = {}
self.data['nodes'] = {}
self.data['edges'] = {} |
def solution(s, n):
answer = ''
for char in s:
if char == " ": answer += " "
else:
if (ord(char) + n > 90 and ord(char) >= 65
and ord(char) <= 90) or (ord(char) + n > 122
and ord(char) >= 97
and ord(char) <= 122):
answer += chr(ord(char) + n - 26)
else:
answer += chr(ord(char) + n)
return answer
print(solution('AB', 1))
print(solution('z', 1))
print(solution('Z', 10))
print(solution(' aBZ', 4))
| def solution(s, n):
answer = ''
for char in s:
if char == ' ':
answer += ' '
elif ord(char) + n > 90 and ord(char) >= 65 and (ord(char) <= 90) or (ord(char) + n > 122 and ord(char) >= 97 and (ord(char) <= 122)):
answer += chr(ord(char) + n - 26)
else:
answer += chr(ord(char) + n)
return answer
print(solution('AB', 1))
print(solution('z', 1))
print(solution('Z', 10))
print(solution(' aBZ', 4)) |
__all__ = ['SpikeSource']
class SpikeSource(object):
"""
A source of spikes.
An object that can be used as a source of spikes for objects such as
`SpikeMonitor`, `Synapses`, etc.
The defining properties of `SpikeSource` are that it should have:
* A length that can be extracted with ``len(obj)``, where the maximum spike
index possible is ``len(obj)-1``.
* An attribute `spikes`, an array of ints each from 0 to
``len(obj)-1`` with no repeats (but possibly not in sorted order). This
should be updated each time step.
* A `clock` attribute, this will be used as the default clock for objects
with this as a source.
.. attribute:: spikes
An array of ints, each from 0 to ``len(obj)-1`` with no repeats (but
possibly not in sorted order). Updated each time step.
.. attribute:: clock
The clock on which the spikes will be updated.
"""
# No implementation, just used for documentation purposes.
pass | __all__ = ['SpikeSource']
class Spikesource(object):
"""
A source of spikes.
An object that can be used as a source of spikes for objects such as
`SpikeMonitor`, `Synapses`, etc.
The defining properties of `SpikeSource` are that it should have:
* A length that can be extracted with ``len(obj)``, where the maximum spike
index possible is ``len(obj)-1``.
* An attribute `spikes`, an array of ints each from 0 to
``len(obj)-1`` with no repeats (but possibly not in sorted order). This
should be updated each time step.
* A `clock` attribute, this will be used as the default clock for objects
with this as a source.
.. attribute:: spikes
An array of ints, each from 0 to ``len(obj)-1`` with no repeats (but
possibly not in sorted order). Updated each time step.
.. attribute:: clock
The clock on which the spikes will be updated.
"""
pass |
# Prgram to demonstrate keyword argument
def display(name,course="AI"):
print("The name is",name)
print("The course is",course)
display(course="AI",name="adi")
display(name="ram")
| def display(name, course='AI'):
print('The name is', name)
print('The course is', course)
display(course='AI', name='adi')
display(name='ram') |
class Transaction:
def __init__(self, ticker, trans_type, quantity, owned, balance):
self.ticker = ticker
self.trans_type = trans_type
self.quantity = quantity
self.owned = owned
self.balance = balance
@classmethod
def failed(cls):
return cls("FAILED", "FAILED", 0, 0, 0)
def __str__(self):
s = "STK\tTYPE\tQ\tOwn\tBal\n"
s += self.ticker + "\t"
s += self.trans_type + "\t"
s += str(self.quantity) + "\t"
s += str(self.owned) + "\t"
s += str(self.balance)
return s
| class Transaction:
def __init__(self, ticker, trans_type, quantity, owned, balance):
self.ticker = ticker
self.trans_type = trans_type
self.quantity = quantity
self.owned = owned
self.balance = balance
@classmethod
def failed(cls):
return cls('FAILED', 'FAILED', 0, 0, 0)
def __str__(self):
s = 'STK\tTYPE\tQ\tOwn\tBal\n'
s += self.ticker + '\t'
s += self.trans_type + '\t'
s += str(self.quantity) + '\t'
s += str(self.owned) + '\t'
s += str(self.balance)
return s |
INITALQCFINISHEDLIB = {
'17' : 'Bioanalyzer QC (Library Validation) 4.0',
'20' : 'CaliperGX QC (DNA)',
'24' : 'Customer Gel QC',
'62' : 'qPCR QC (Library Validation) 4.0',
'64' : 'Quant-iT QC (Library Validation) 4.0',
'67' : 'Qubit QC (Library Validation) 4.0',
'904' : 'Automated Quant-iT QC (Library Validation) 4.0',
'1154' : 'Fragment Analyzer QC (Library Validation) 4.0'}
INITALQC = {
'16' : 'Bioanalyzer QC (DNA) 4.0',
'18' : 'Bioanalyzer QC (RNA) 4.0',
'20' : 'CaliperGX QC (DNA)',
'24' : 'Customer Gel QC',
'63' : 'Quant-iT QC (DNA) 4.0',
'65' : 'Quant-iT QC (RNA) 4.0',
'66' : 'Qubit QC (DNA) 4.0',
'68' : 'Qubit QC (RNA) 4.0',
'116' : 'CaliperGX QC (RNA)',
'504' : 'Volume Measurement QC',
'954' : 'Automated Quant-iT QC (DNA) 4.0',
'1054' : 'Automated Quant-iT QC (RNA) 4.0',
'1157' : 'Fragment Analyzer QC (DNA) 4.0',
'1354' : 'Fragment Analyzer QC (RNA) 4.0'}
AGRINITQC = {
'7' : 'Aggregate QC (DNA) 4.0',
'9' : 'Aggregate QC (RNA) 4.0'}
PREPREPSTART = {
'74' : 'Shear DNA (SS XT) 4.0',
'304' : 'Adapter ligation and reverse transcription (TruSeq small RNA) 1.0',
'1104' : 'RAD-seq Library Indexing v1.0',
'1706' : 'GEM Generation (Chromium Genome v2)',
'2054' : 'Sectioning and HE Staining'}
POOLING = {
'42' : 'Library Pooling (Illumina SBS) 4.0',
'43' : 'Library Pooling (MiSeq) 4.0',
'44' : 'Library Pooling (TruSeq Amplicon) 4.0',
'45' : 'Library Pooling (TruSeq Exome) 4.0',
'58' : 'Pooling For Multiplexed Sequencing (SS XT) 4.0',
'255' : 'Library Pooling (Finished Libraries) 4.0',
'308' : 'Library Pooling (TruSeq Small RNA) 1.0',
'404' : 'Pre-Pooling (Illumina SBS) 4.0',
'506' : 'Pre-Pooling (MiSeq) 4.0',
'508' : 'Applications Pre-Pooling',
'716' : 'Library Pooling (HiSeq X) 1.0',
'1105' : 'Library Pooling (RAD-seq) v1.0',
'1307' : 'Library Pooling (MinION) 1.0',
'1506' : 'Pre-Pooling (NovaSeq) v2.0',
'1507' : 'Library Pooling (NovaSeq) v2.0',
'1906' : 'Pre-Pooling (NextSeq) v1.0',
'1907' : 'Library Pooling (NextSeq) v1.0'}
PREPSTARTFINLIB = {
'255' : 'Library Pooling (Finished Libraries) 4.0'}
PREPSTART = {
'10' : 'Aliquot Libraries for Hybridization (SS XT)',
'33' : 'Fragment DNA (TruSeq DNA) 4.0',
'47' : 'mRNA Purification, Fragmentation & cDNA synthesis (TruSeq RNA) 4.0',
'117' : 'Applications Generic Process',
'308' : 'Library Pooling (TruSeq Small RNA) 1.0',
'405' : 'RiboZero depletion',
'407' : 'Fragment DNA (ThruPlex)',
'454' : 'ThruPlex template preparation and synthesis',
'605' : 'Tagmentation, Strand displacement and AMPure purification',
'612' : 'Fragmentation & cDNA synthesis (TruSeq RNA) 4.0',#sometimes, the earlier steps are skipped.
'1105' : 'Library Pooling (RAD-seq) v1.0',
'1305' : 'Adapter Ligation (MinION) 1.0',
'1404' : 'Fragmentation & cDNA synthesis (SMARTer Pico) 4.0',
'1705' : 'Library preparation (Chromium Genome v2)',
'1856' : 'Sample Crosslinking',
'1861' : 'Chromatin capture, digestion, end ligation and crosslink reversal (HiC) 1.0',
'2058' : 'Permeabilization and Second Strand Synthesis',
'2104' : 'Selection, cDNA Synthesis and Library Construction',
'2154' : 'PCR1 (Amplicon)',
'2155' : 'PCR2 (Amplicon)'}
PREPEND = {
'109' : 'CA Purification',
'111' : 'Amplify Captured Libraries to Add Index Tags (SS XT) 4.0',
'157' : 'Applications Finish Prep',
'311' : 'Sample Placement (Size Selection)',
'406' : 'End repair, size selection, A-tailing and adapter ligation (TruSeq PCR-free DNA) 4.0',
'456' : 'Purification (ThruPlex)',
'606' : 'Size Selection (Pippin)',
'805' : 'NeoPrep Library Prep v1.0',
'1307' : 'Library Pooling (MinION) 1.0',
'1554' : 'Purification',
'1705' : 'Library preparation (Chromium Genome v2)',
'2060' : 'Visium Library Construction',
'2105' : 'Amplification and Purification'}
LIBVAL = {
'17' : 'Bioanalyzer QC (Library Validation) 4.0',
'20' : 'CaliperGX QC (DNA)',
'62' : 'qPCR QC (Library Validation) 4.0',
'64' : 'Quant-iT QC (Library Validation) 4.0',
'67' : 'Qubit QC (Library Validation) 4.0',
'504' : 'Volume Measurement QC',
'904' : 'Automated Quant-iT QC (Library Validation) 4.0',
'1154' : 'Fragment Analyzer QC (Library Validation) 4.0'}
LIBVALFINISHEDLIB = {
'17' : 'Bioanalyzer QC (Library Validation) 4.0',
'20' : 'CaliperGX QC (DNA)',
'24' : 'Customer Gel QC',
'62' : 'qPCR QC (Library Validation) 4.0',
'64' : 'Quant-iT QC (Library Validation) 4.0',
'67' : 'Qubit QC (Library Validation) 4.0',
'504' : 'Volume Measurement QC',
'904' : 'Automated Quant-iT QC (Library Validation) 4.0',
'1154' : 'Fragment Analyzer QC (Library Validation) 4.0'}
AGRLIBVAL = {
'8' : 'Aggregate QC (Library Validation) 4.0',
'806' : 'NeoPrep Library QC v1.0'}
SEQSTART = {
'23' :'Cluster Generation (Illumina SBS) 4.0',
'26' :'Denature, Dilute and Load Sample (MiSeq) 4.0',
'710' :'Cluster Generation (HiSeq X) 1.0',
'1306' : 'Load Sample and Sequencing (MinION) 1.0',
'1458' : 'Load to Flowcell (NovaSeq 6000 v2.0)',
'1910' : 'Load to Flowcell (NextSeq v1.0)'}
DILSTART = {
'39' : 'Library Normalization (Illumina SBS) 4.0',
'40' : 'Library Normalization (MiSeq) 4.0',
'715': 'Library Normalization (HiSeq X) 1.0',
'1505': 'Library Normalization (NovaSeq) v2.0',
'1905' : 'Library Normalization (NextSeq) v1.0'}
SEQUENCING = {
'38' : 'Illumina Sequencing (Illumina SBS) 4.0',
'46' : 'MiSeq Run (MiSeq) 4.0',
'714': 'Illumina Sequencing (HiSeq X) 1.0',
'1306' : 'Load Sample and Sequencing (MinION) 1.0',
'1454': 'AUTOMATED - NovaSeq Run (NovaSeq 6000 v2.0)',
'1908' : 'Illumina Sequencing (NextSeq) v1.0'}
WORKSET = {
'204' : 'Setup Workset/Plate'}
SUMMARY = {
'356' : 'Project Summary 1.3'}
DEMULTIPLEX={
'13' : 'Bcl Conversion & Demultiplexing (Illumina SBS) 4.0'}
CALIPER = {
'20' : 'CaliperGX QC (DNA)',
'116' : 'CaliperGX QC (RNA)'}
FRAGMENT_ANALYZER = {
'1354' : 'Fragment Analyzer QC (RNA) 4.0',
'1154' : 'Fragment Analyzer QC (Library Validation) 4.0',
'1157' : 'Fragment Analyzer QC (DNA) 4.0'}
FINLIB = ['Finished library', 'Amplicon']
PROJ_UDF_EXCEPTIONS = ['customer_reference','uppnex_id','reference_genome','application']
SAMP_UDF_EXCEPTIONS = ['customer_name','reads_requested_(millions)','min_reads',
'm_reads','dup_rm','status_auto','status_manual','average_size_bp','incoming_qc_status']
PROCESSCATEGORIES = {'INITALQCFINISHEDLIB' : INITALQCFINISHEDLIB,
'INITALQC':INITALQC,
'AGRINITQC':AGRINITQC,
'PREPREPSTART':PREPREPSTART,
'POOLING':POOLING,
'PREPSTART':PREPSTART,
'PREPEND':PREPEND,
'LIBVAL':LIBVAL,
'LIBVALFINISHEDLIB':LIBVALFINISHEDLIB,
'AGRLIBVAL':AGRLIBVAL,
'SEQSTART':SEQSTART,
'DILSTART':DILSTART,
'SEQUENCING':SEQUENCING,
'WORKSET':WORKSET,
'SUMMARY':SUMMARY,
'DEMULTIPLEX':DEMULTIPLEX,
'CALIPER':CALIPER}
| initalqcfinishedlib = {'17': 'Bioanalyzer QC (Library Validation) 4.0', '20': 'CaliperGX QC (DNA)', '24': 'Customer Gel QC', '62': 'qPCR QC (Library Validation) 4.0', '64': 'Quant-iT QC (Library Validation) 4.0', '67': 'Qubit QC (Library Validation) 4.0', '904': 'Automated Quant-iT QC (Library Validation) 4.0', '1154': 'Fragment Analyzer QC (Library Validation) 4.0'}
initalqc = {'16': 'Bioanalyzer QC (DNA) 4.0', '18': 'Bioanalyzer QC (RNA) 4.0', '20': 'CaliperGX QC (DNA)', '24': 'Customer Gel QC', '63': 'Quant-iT QC (DNA) 4.0', '65': 'Quant-iT QC (RNA) 4.0', '66': 'Qubit QC (DNA) 4.0', '68': 'Qubit QC (RNA) 4.0', '116': 'CaliperGX QC (RNA)', '504': 'Volume Measurement QC', '954': 'Automated Quant-iT QC (DNA) 4.0', '1054': 'Automated Quant-iT QC (RNA) 4.0', '1157': 'Fragment Analyzer QC (DNA) 4.0', '1354': 'Fragment Analyzer QC (RNA) 4.0'}
agrinitqc = {'7': 'Aggregate QC (DNA) 4.0', '9': 'Aggregate QC (RNA) 4.0'}
preprepstart = {'74': 'Shear DNA (SS XT) 4.0', '304': 'Adapter ligation and reverse transcription (TruSeq small RNA) 1.0', '1104': 'RAD-seq Library Indexing v1.0', '1706': 'GEM Generation (Chromium Genome v2)', '2054': 'Sectioning and HE Staining'}
pooling = {'42': 'Library Pooling (Illumina SBS) 4.0', '43': 'Library Pooling (MiSeq) 4.0', '44': 'Library Pooling (TruSeq Amplicon) 4.0', '45': 'Library Pooling (TruSeq Exome) 4.0', '58': 'Pooling For Multiplexed Sequencing (SS XT) 4.0', '255': 'Library Pooling (Finished Libraries) 4.0', '308': 'Library Pooling (TruSeq Small RNA) 1.0', '404': 'Pre-Pooling (Illumina SBS) 4.0', '506': 'Pre-Pooling (MiSeq) 4.0', '508': 'Applications Pre-Pooling', '716': 'Library Pooling (HiSeq X) 1.0', '1105': 'Library Pooling (RAD-seq) v1.0', '1307': 'Library Pooling (MinION) 1.0', '1506': 'Pre-Pooling (NovaSeq) v2.0', '1507': 'Library Pooling (NovaSeq) v2.0', '1906': 'Pre-Pooling (NextSeq) v1.0', '1907': 'Library Pooling (NextSeq) v1.0'}
prepstartfinlib = {'255': 'Library Pooling (Finished Libraries) 4.0'}
prepstart = {'10': 'Aliquot Libraries for Hybridization (SS XT)', '33': 'Fragment DNA (TruSeq DNA) 4.0', '47': 'mRNA Purification, Fragmentation & cDNA synthesis (TruSeq RNA) 4.0', '117': 'Applications Generic Process', '308': 'Library Pooling (TruSeq Small RNA) 1.0', '405': 'RiboZero depletion', '407': 'Fragment DNA (ThruPlex)', '454': 'ThruPlex template preparation and synthesis', '605': 'Tagmentation, Strand displacement and AMPure purification', '612': 'Fragmentation & cDNA synthesis (TruSeq RNA) 4.0', '1105': 'Library Pooling (RAD-seq) v1.0', '1305': 'Adapter Ligation (MinION) 1.0', '1404': 'Fragmentation & cDNA synthesis (SMARTer Pico) 4.0', '1705': 'Library preparation (Chromium Genome v2)', '1856': 'Sample Crosslinking', '1861': 'Chromatin capture, digestion, end ligation and crosslink reversal (HiC) 1.0', '2058': 'Permeabilization and Second Strand Synthesis', '2104': 'Selection, cDNA Synthesis and Library Construction', '2154': 'PCR1 (Amplicon)', '2155': 'PCR2 (Amplicon)'}
prepend = {'109': 'CA Purification', '111': 'Amplify Captured Libraries to Add Index Tags (SS XT) 4.0', '157': 'Applications Finish Prep', '311': 'Sample Placement (Size Selection)', '406': 'End repair, size selection, A-tailing and adapter ligation (TruSeq PCR-free DNA) 4.0', '456': 'Purification (ThruPlex)', '606': 'Size Selection (Pippin)', '805': 'NeoPrep Library Prep v1.0', '1307': 'Library Pooling (MinION) 1.0', '1554': 'Purification', '1705': 'Library preparation (Chromium Genome v2)', '2060': 'Visium Library Construction', '2105': 'Amplification and Purification'}
libval = {'17': 'Bioanalyzer QC (Library Validation) 4.0', '20': 'CaliperGX QC (DNA)', '62': 'qPCR QC (Library Validation) 4.0', '64': 'Quant-iT QC (Library Validation) 4.0', '67': 'Qubit QC (Library Validation) 4.0', '504': 'Volume Measurement QC', '904': 'Automated Quant-iT QC (Library Validation) 4.0', '1154': 'Fragment Analyzer QC (Library Validation) 4.0'}
libvalfinishedlib = {'17': 'Bioanalyzer QC (Library Validation) 4.0', '20': 'CaliperGX QC (DNA)', '24': 'Customer Gel QC', '62': 'qPCR QC (Library Validation) 4.0', '64': 'Quant-iT QC (Library Validation) 4.0', '67': 'Qubit QC (Library Validation) 4.0', '504': 'Volume Measurement QC', '904': 'Automated Quant-iT QC (Library Validation) 4.0', '1154': 'Fragment Analyzer QC (Library Validation) 4.0'}
agrlibval = {'8': 'Aggregate QC (Library Validation) 4.0', '806': 'NeoPrep Library QC v1.0'}
seqstart = {'23': 'Cluster Generation (Illumina SBS) 4.0', '26': 'Denature, Dilute and Load Sample (MiSeq) 4.0', '710': 'Cluster Generation (HiSeq X) 1.0', '1306': 'Load Sample and Sequencing (MinION) 1.0', '1458': 'Load to Flowcell (NovaSeq 6000 v2.0)', '1910': 'Load to Flowcell (NextSeq v1.0)'}
dilstart = {'39': 'Library Normalization (Illumina SBS) 4.0', '40': 'Library Normalization (MiSeq) 4.0', '715': 'Library Normalization (HiSeq X) 1.0', '1505': 'Library Normalization (NovaSeq) v2.0', '1905': 'Library Normalization (NextSeq) v1.0'}
sequencing = {'38': 'Illumina Sequencing (Illumina SBS) 4.0', '46': 'MiSeq Run (MiSeq) 4.0', '714': 'Illumina Sequencing (HiSeq X) 1.0', '1306': 'Load Sample and Sequencing (MinION) 1.0', '1454': 'AUTOMATED - NovaSeq Run (NovaSeq 6000 v2.0)', '1908': 'Illumina Sequencing (NextSeq) v1.0'}
workset = {'204': 'Setup Workset/Plate'}
summary = {'356': 'Project Summary 1.3'}
demultiplex = {'13': 'Bcl Conversion & Demultiplexing (Illumina SBS) 4.0'}
caliper = {'20': 'CaliperGX QC (DNA)', '116': 'CaliperGX QC (RNA)'}
fragment_analyzer = {'1354': 'Fragment Analyzer QC (RNA) 4.0', '1154': 'Fragment Analyzer QC (Library Validation) 4.0', '1157': 'Fragment Analyzer QC (DNA) 4.0'}
finlib = ['Finished library', 'Amplicon']
proj_udf_exceptions = ['customer_reference', 'uppnex_id', 'reference_genome', 'application']
samp_udf_exceptions = ['customer_name', 'reads_requested_(millions)', 'min_reads', 'm_reads', 'dup_rm', 'status_auto', 'status_manual', 'average_size_bp', 'incoming_qc_status']
processcategories = {'INITALQCFINISHEDLIB': INITALQCFINISHEDLIB, 'INITALQC': INITALQC, 'AGRINITQC': AGRINITQC, 'PREPREPSTART': PREPREPSTART, 'POOLING': POOLING, 'PREPSTART': PREPSTART, 'PREPEND': PREPEND, 'LIBVAL': LIBVAL, 'LIBVALFINISHEDLIB': LIBVALFINISHEDLIB, 'AGRLIBVAL': AGRLIBVAL, 'SEQSTART': SEQSTART, 'DILSTART': DILSTART, 'SEQUENCING': SEQUENCING, 'WORKSET': WORKSET, 'SUMMARY': SUMMARY, 'DEMULTIPLEX': DEMULTIPLEX, 'CALIPER': CALIPER} |
# Copyright 2020 Google LLC
#
# 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.
# This file contains rule definitions for running
# the test binary to produce output json and protobuf files,
# subset diff the input and output json files, and golden file
# testing the output protobuf files against the expected files.
# It also defines a Macro that simplifies defining a protobuf test
# over a sample P4 program.
load("//:p4c.bzl", "run_p4c")
load("//p4_symbolic/bmv2:test.bzl", "exact_diff_test")
# Macro that defines our end to end tests.
# Given a p4 program, this macro runs our main binary
# on the p4 program and its table entries (if they exist).
# The binary outputs a debugging dump of the underlying smt program,
# as well as the output test packets.
# The macro compares both of these outputs against the provided
# expected golden files.
# The macro defines these rules in order:
# 1. A rule for producing bmv2 json and p4info files from a .p4 file using p4c.
# 2. A rule for running the main binary on the inputs using p4_symbolic/main.cc,
# and dumping both output files.
# 3. Two rules for golden file testing of the two output files.
# 4. A test suite combining the two rules above with the same name
# as given to the macro.
# Use the p4_deps list to specify dependent files that p4_program input
# file depends on (e.g. by including them).
def end_to_end_test(
name,
p4_program,
output_golden_file,
smt_golden_file,
table_entries = None,
p4_deps = []):
p4c_name = "%s_p4c" % name
run_name = "%s_main" % name
p4info_file = "%s_bazel-p4c-tmp-output/p4info.pb.txt" % p4c_name
output_test_name = "%s_output" % name
smt_test_name = "%s_smt" % name
optional_table_entries = []
optional_table_entry_arg = ""
if table_entries:
optional_table_entries = [table_entries]
optional_table_entry_arg = "--entries=$(location %s)" % table_entries
# Run p4c to get bmv2 JSON and p4info.pb.txt files.
run_p4c(
name = p4c_name,
src = p4_program,
deps = p4_deps,
p4runtime_files = [p4info_file],
)
# Use p4_symbolic/main.cc to run our tool on the p4 program
# and produce a debugging smt file and an output file with
# interesting testing packets.
output_filename = name + ".txt"
output_smt_filename = name + ".smt2"
native.genrule(
name = run_name,
srcs = [":" + p4c_name, p4info_file] + optional_table_entries,
outs = [output_filename, output_smt_filename],
tools = ["//p4_symbolic:main"],
cmd = (
"$(location //p4_symbolic:main) --bmv2=$(location %s) " +
"--p4info=$(location %s) %s --debug=$(location %s) " +
"--hardcoded_parser=false &> $(location %s)"
) % (
":" + p4c_name,
p4info_file,
optional_table_entry_arg,
output_smt_filename,
output_filename,
),
)
# Exact diff test for the packet output file.
exact_diff_test(
name = output_test_name,
actual = output_filename,
expected = output_golden_file,
)
# Exact diff test for the smt output file.
exact_diff_test(
name = smt_test_name,
actual = output_smt_filename,
expected = smt_golden_file,
)
# Group tests into a test_suite with the given name.
# This is just to make the provided name alias to something.
native.test_suite(
name = name,
tests = [
":" + output_test_name,
":" + smt_test_name,
],
)
| load('//:p4c.bzl', 'run_p4c')
load('//p4_symbolic/bmv2:test.bzl', 'exact_diff_test')
def end_to_end_test(name, p4_program, output_golden_file, smt_golden_file, table_entries=None, p4_deps=[]):
p4c_name = '%s_p4c' % name
run_name = '%s_main' % name
p4info_file = '%s_bazel-p4c-tmp-output/p4info.pb.txt' % p4c_name
output_test_name = '%s_output' % name
smt_test_name = '%s_smt' % name
optional_table_entries = []
optional_table_entry_arg = ''
if table_entries:
optional_table_entries = [table_entries]
optional_table_entry_arg = '--entries=$(location %s)' % table_entries
run_p4c(name=p4c_name, src=p4_program, deps=p4_deps, p4runtime_files=[p4info_file])
output_filename = name + '.txt'
output_smt_filename = name + '.smt2'
native.genrule(name=run_name, srcs=[':' + p4c_name, p4info_file] + optional_table_entries, outs=[output_filename, output_smt_filename], tools=['//p4_symbolic:main'], cmd=('$(location //p4_symbolic:main) --bmv2=$(location %s) ' + '--p4info=$(location %s) %s --debug=$(location %s) ' + '--hardcoded_parser=false &> $(location %s)') % (':' + p4c_name, p4info_file, optional_table_entry_arg, output_smt_filename, output_filename))
exact_diff_test(name=output_test_name, actual=output_filename, expected=output_golden_file)
exact_diff_test(name=smt_test_name, actual=output_smt_filename, expected=smt_golden_file)
native.test_suite(name=name, tests=[':' + output_test_name, ':' + smt_test_name]) |
# Longest Sequence with two unique numbers
class Solution:
def findSequence(self, arr):
last_num = -1
second_last_num = -1
last_num_count = 0
current_max = 0
maximum = 0
for num in arr:
if num == last_num or num == second_last_num:
current_max += 1
else:
current_max = last_num_count + 1
if num == last_num:
last_num_count += 1
else:
last_num_count = 1
second_last_num = last_num
last_num = num
maximum = max(current_max, maximum)
return maximum
if __name__ == "__main__":
arr = [1, 3, 5, 3, 1, 3, 1, 5]
print(Solution().findSequence(arr))
arr = [1, 1, 6, 5, 6, 6, 1, 1, 1, 1]
print(Solution().findSequence(arr))
| class Solution:
def find_sequence(self, arr):
last_num = -1
second_last_num = -1
last_num_count = 0
current_max = 0
maximum = 0
for num in arr:
if num == last_num or num == second_last_num:
current_max += 1
else:
current_max = last_num_count + 1
if num == last_num:
last_num_count += 1
else:
last_num_count = 1
second_last_num = last_num
last_num = num
maximum = max(current_max, maximum)
return maximum
if __name__ == '__main__':
arr = [1, 3, 5, 3, 1, 3, 1, 5]
print(solution().findSequence(arr))
arr = [1, 1, 6, 5, 6, 6, 1, 1, 1, 1]
print(solution().findSequence(arr)) |
class Rate:
def buildRateRequest(self):
rateReq = {
"items": [
{
"productId": 3387821,
"variantId": 12009212,
"weight_unit": "grams",
"weight": 2,
"quantity": 1
}
]
}
return rateReq
def getRates(self):
#req = self.buildRateRequest()
res = {
"rateHashKey": "zsTUi",
"shipment_price": 27.00
}
return res
class Shipment:
def buildRequest(self):
req = {
"rateHashKey": "zsTUi",
"packageWt": 23
}
return req
def getShipment(self):
#req = self.buildRequest()
res = {
"shipmentId": 'kjuiujs'
}
return res | class Rate:
def build_rate_request(self):
rate_req = {'items': [{'productId': 3387821, 'variantId': 12009212, 'weight_unit': 'grams', 'weight': 2, 'quantity': 1}]}
return rateReq
def get_rates(self):
res = {'rateHashKey': 'zsTUi', 'shipment_price': 27.0}
return res
class Shipment:
def build_request(self):
req = {'rateHashKey': 'zsTUi', 'packageWt': 23}
return req
def get_shipment(self):
res = {'shipmentId': 'kjuiujs'}
return res |
"""
Programming for linguists
Implementation of the data structures "Node" and "Binary Tree"
"""
class Node:
"""Node class."""
def __init__(self, val):
self.value = val
self.left_child = None
self.right_child = None
def insert(self, data):
"""Insert data as node's child"""
if self.value == data:
return False
if self.value > data:
if self.left_child:
return self.left_child.insert(data)
self.left_child = Node(data)
return True
if self.right_child:
return self.right_child.insert(data)
self.right_child = Node(data)
return True
def find(self, data):
"""Find data in the node."""
if self.value == data:
return True
if self.value > data:
if self.left_child:
return self.left_child.find(data)
return False
if self.right_child:
return self.right_child.find(data)
return False
def get_height(self):
"""Get height of the node."""
if self.left_child and self.right_child:
return 1 + max(self.left_child.get_height(), self.right_child.get_height())
if self.left_child:
return 1 + self.left_child.get_height()
if self.right_child:
return 1 + self.right_child.get_height()
return 1
def depth_in_order_print(self):
"""Go to depth and print values."""
if self:
if self.left_child:
self.left_child.depth_in_order_print()
print(str(self.value), end=' ')
if self.right_child:
self.right_child.depth_in_order_print()
class BinaryTree:
"""Binary tree class."""
def __init__(self):
self.root = None
def insert(self, data):
"""Insert data to the tree."""
self._validate_data(data)
if self.root:
return self.root.insert(data)
self.root = Node(data)
return True
def find(self, data):
"""Find data in the tree."""
self._validate_data(data)
if self.root:
return self.root.find(data)
return False
def get_height(self):
"""Get haight of the tree."""
if self.root:
return self.root.get_height()
return 0
def remove(self, data):
"""Remove data from the tree."""
self._validate_data(data)
# empty tree
if self.root is None:
return False
# data is in root node
if self.root.value == data:
self._remove_root()
return True
parent = None
node = self.root
# find node to remove
while node and node.value != data:
parent = node
if data < node.value:
node = node.left_child
elif data > node.value:
node = node.right_child
# case 1: data not found
if node is None or node.value != data:
return False
# case 2: remove-node has no children
if node.left_child is None and node.right_child is None:
self._remove_node(data, node, parent, mode='no')
# case 3: remove-node has left child only
elif node.left_child and node.right_child is None:
self._remove_node(data, node, parent, mode='left')
# case 4: remove-node has right child only
elif node.left_child is None and node.right_child:
self._remove_node(data, node, parent, mode='right')
# case 5: remove-node has left and right children
else:
self._remove_node_two_children(node)
return True
def _remove_root(self):
"""Remove root."""
if self.root.left_child is None and self.root.right_child is None:
self.root = None
elif self.root.left_child and self.root.right_child is None:
self.root = self.root.left_child
elif self.root.left_child is None and self.root.right_child:
self.root = self.root.right_child
elif self.root.left_child and self.root.right_child:
del_node_parent = self.root
del_node = self.root.right_child
while del_node.left_child:
del_node_parent = del_node
del_node = del_node.left_child
if del_node.right_child:
if del_node_parent.value > del_node.value:
del_node_parent.left_child = del_node.right_child
elif del_node_parent.value < del_node.value:
del_node_parent.right_child = del_node.right_child
else:
if del_node.value < del_node_parent.value:
del_node_parent.left_child = None
else:
del_node_parent.right_child = None
self.root.value = del_node.value
@staticmethod
def _remove_node(data, node, parent, mode='no'):
mode_dict = {'no': None, 'left': node.left_child, 'right': node.right_child}
if data < parent.value:
parent.left_child = mode_dict[mode]
else:
parent.right_child = mode_dict[mode]
@staticmethod
def _remove_node_two_children(node):
"""Remove node with two children."""
del_node_parent = node
del_node = node.right_child
while del_node.left_child:
del_node_parent = del_node
del_node = del_node.left_child
node.value = del_node.value
if del_node.right_child:
if del_node_parent.value > del_node.value:
del_node_parent.left_child = del_node.right_child
elif del_node_parent.value < del_node.value:
del_node_parent.right_child = del_node.right_child
else:
if del_node.value < del_node_parent.value:
del_node_parent.left_child = None
else:
del_node_parent.right_child = None
def depth_in_order_print(self):
"""Go to depth and print values."""
if self.root is not None:
self.root.depth_in_order_print()
print('', end='\n')
@staticmethod
def _validate_data(data):
"""Validate data."""
if not isinstance(data, int):
raise ValueError('Data is not integer.')
| """
Programming for linguists
Implementation of the data structures "Node" and "Binary Tree"
"""
class Node:
"""Node class."""
def __init__(self, val):
self.value = val
self.left_child = None
self.right_child = None
def insert(self, data):
"""Insert data as node's child"""
if self.value == data:
return False
if self.value > data:
if self.left_child:
return self.left_child.insert(data)
self.left_child = node(data)
return True
if self.right_child:
return self.right_child.insert(data)
self.right_child = node(data)
return True
def find(self, data):
"""Find data in the node."""
if self.value == data:
return True
if self.value > data:
if self.left_child:
return self.left_child.find(data)
return False
if self.right_child:
return self.right_child.find(data)
return False
def get_height(self):
"""Get height of the node."""
if self.left_child and self.right_child:
return 1 + max(self.left_child.get_height(), self.right_child.get_height())
if self.left_child:
return 1 + self.left_child.get_height()
if self.right_child:
return 1 + self.right_child.get_height()
return 1
def depth_in_order_print(self):
"""Go to depth and print values."""
if self:
if self.left_child:
self.left_child.depth_in_order_print()
print(str(self.value), end=' ')
if self.right_child:
self.right_child.depth_in_order_print()
class Binarytree:
"""Binary tree class."""
def __init__(self):
self.root = None
def insert(self, data):
"""Insert data to the tree."""
self._validate_data(data)
if self.root:
return self.root.insert(data)
self.root = node(data)
return True
def find(self, data):
"""Find data in the tree."""
self._validate_data(data)
if self.root:
return self.root.find(data)
return False
def get_height(self):
"""Get haight of the tree."""
if self.root:
return self.root.get_height()
return 0
def remove(self, data):
"""Remove data from the tree."""
self._validate_data(data)
if self.root is None:
return False
if self.root.value == data:
self._remove_root()
return True
parent = None
node = self.root
while node and node.value != data:
parent = node
if data < node.value:
node = node.left_child
elif data > node.value:
node = node.right_child
if node is None or node.value != data:
return False
if node.left_child is None and node.right_child is None:
self._remove_node(data, node, parent, mode='no')
elif node.left_child and node.right_child is None:
self._remove_node(data, node, parent, mode='left')
elif node.left_child is None and node.right_child:
self._remove_node(data, node, parent, mode='right')
else:
self._remove_node_two_children(node)
return True
def _remove_root(self):
"""Remove root."""
if self.root.left_child is None and self.root.right_child is None:
self.root = None
elif self.root.left_child and self.root.right_child is None:
self.root = self.root.left_child
elif self.root.left_child is None and self.root.right_child:
self.root = self.root.right_child
elif self.root.left_child and self.root.right_child:
del_node_parent = self.root
del_node = self.root.right_child
while del_node.left_child:
del_node_parent = del_node
del_node = del_node.left_child
if del_node.right_child:
if del_node_parent.value > del_node.value:
del_node_parent.left_child = del_node.right_child
elif del_node_parent.value < del_node.value:
del_node_parent.right_child = del_node.right_child
elif del_node.value < del_node_parent.value:
del_node_parent.left_child = None
else:
del_node_parent.right_child = None
self.root.value = del_node.value
@staticmethod
def _remove_node(data, node, parent, mode='no'):
mode_dict = {'no': None, 'left': node.left_child, 'right': node.right_child}
if data < parent.value:
parent.left_child = mode_dict[mode]
else:
parent.right_child = mode_dict[mode]
@staticmethod
def _remove_node_two_children(node):
"""Remove node with two children."""
del_node_parent = node
del_node = node.right_child
while del_node.left_child:
del_node_parent = del_node
del_node = del_node.left_child
node.value = del_node.value
if del_node.right_child:
if del_node_parent.value > del_node.value:
del_node_parent.left_child = del_node.right_child
elif del_node_parent.value < del_node.value:
del_node_parent.right_child = del_node.right_child
elif del_node.value < del_node_parent.value:
del_node_parent.left_child = None
else:
del_node_parent.right_child = None
def depth_in_order_print(self):
"""Go to depth and print values."""
if self.root is not None:
self.root.depth_in_order_print()
print('', end='\n')
@staticmethod
def _validate_data(data):
"""Validate data."""
if not isinstance(data, int):
raise value_error('Data is not integer.') |
nlinhas = input('linhas a serem lidas:')
frase = []
for i in range(len(nlinhas)):
s = input('digite a frase:')
frase.append(s)
cripto = []
for i in range(len(nlinhas)):
f = frase[i].split('')
print(f)
#primeiro
for k in range(len(f)):
if f[k] in '1234567890':
pass
else:
f[k] = chr(ord(f[k]) + 1)
print(f)
| nlinhas = input('linhas a serem lidas:')
frase = []
for i in range(len(nlinhas)):
s = input('digite a frase:')
frase.append(s)
cripto = []
for i in range(len(nlinhas)):
f = frase[i].split('')
print(f)
for k in range(len(f)):
if f[k] in '1234567890':
pass
else:
f[k] = chr(ord(f[k]) + 1)
print(f) |
def get_date_restriction_text(tag, events):
"""Generates the text that tells the user the dates that the event they are adding/updating must be in between,
this text changes based on which events already exist, hence the if statements for when reminders are present."""
date_text_dict = {
"mps": [f"Must be before Go Live {_get_event_date_string('go_live', events)}"],
"go_live": [
f"Must be after MPS {_get_event_date_string('mps', events)}",
f"Must be before Return by {_get_event_date_string('return_by', events)}",
],
"return_by": [
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}",
],
"exercise_end": [f"Must be after Return by {_get_event_date_string('return_by', events)}"],
"reminder": [
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}",
],
"reminder2": [
f"Must be after First Reminder {_get_event_date_string('reminder', events)}",
f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}",
],
"reminder3": [
f"Must be after Second Reminder {_get_event_date_string('reminder2', events)}",
f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}",
],
"ref_period_start": [f"Must be before Reference Period end {_get_event_date_string('ref_period_end', events)}"],
"ref_period_end": [
f"Must be after Reference Period start " f"{_get_event_date_string('ref_period_start', events)}"
],
"nudge_email_0": [
"Maximum of five nudge email allowed",
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Return by {_get_event_date_string('return_by', events)}",
],
"nudge_email_1": [
"Maximum of five nudge email allowed",
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Return by {_get_event_date_string('return_by', events)}",
],
"nudge_email_2": [
"Maximum of five nudge email allowed",
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Return by {_get_event_date_string('return_by', events)}",
],
"nudge_email_3": [
"Maximum of five nudge email allowed",
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Return by {_get_event_date_string('return_by', events)}",
],
"nudge_email_4": [
"Maximum of five nudge email allowed",
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Return by {_get_event_date_string('return_by', events)}",
],
"employment": None,
}
if _get_event_date_string("reminder2", events):
date_text_dict["reminder"] = [
f"Must be after Go Live {_get_event_date_string('go_live', events)}",
f"Must be before Second Reminder {_get_event_date_string('reminder2', events)}",
]
if _get_event_date_string("reminder3", events):
date_text_dict["reminder2"] = [
f"Must be after First Reminder {_get_event_date_string('reminder', events)}",
f"Must be before Third Reminder {_get_event_date_string('reminder3', events)}",
]
return date_text_dict[tag]
def _get_event_date_string(tag, events):
try:
return f"{events[tag]['day']} {events[tag]['date']} {events[tag]['time']}"
except KeyError:
return ""
| def get_date_restriction_text(tag, events):
"""Generates the text that tells the user the dates that the event they are adding/updating must be in between,
this text changes based on which events already exist, hence the if statements for when reminders are present."""
date_text_dict = {'mps': [f"Must be before Go Live {_get_event_date_string('go_live', events)}"], 'go_live': [f"Must be after MPS {_get_event_date_string('mps', events)}", f"Must be before Return by {_get_event_date_string('return_by', events)}"], 'return_by': [f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}"], 'exercise_end': [f"Must be after Return by {_get_event_date_string('return_by', events)}"], 'reminder': [f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}"], 'reminder2': [f"Must be after First Reminder {_get_event_date_string('reminder', events)}", f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}"], 'reminder3': [f"Must be after Second Reminder {_get_event_date_string('reminder2', events)}", f"Must be before Exercise end {_get_event_date_string('exercise_end', events)}"], 'ref_period_start': [f"Must be before Reference Period end {_get_event_date_string('ref_period_end', events)}"], 'ref_period_end': [f"Must be after Reference Period start {_get_event_date_string('ref_period_start', events)}"], 'nudge_email_0': ['Maximum of five nudge email allowed', f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Return by {_get_event_date_string('return_by', events)}"], 'nudge_email_1': ['Maximum of five nudge email allowed', f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Return by {_get_event_date_string('return_by', events)}"], 'nudge_email_2': ['Maximum of five nudge email allowed', f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Return by {_get_event_date_string('return_by', events)}"], 'nudge_email_3': ['Maximum of five nudge email allowed', f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Return by {_get_event_date_string('return_by', events)}"], 'nudge_email_4': ['Maximum of five nudge email allowed', f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Return by {_get_event_date_string('return_by', events)}"], 'employment': None}
if _get_event_date_string('reminder2', events):
date_text_dict['reminder'] = [f"Must be after Go Live {_get_event_date_string('go_live', events)}", f"Must be before Second Reminder {_get_event_date_string('reminder2', events)}"]
if _get_event_date_string('reminder3', events):
date_text_dict['reminder2'] = [f"Must be after First Reminder {_get_event_date_string('reminder', events)}", f"Must be before Third Reminder {_get_event_date_string('reminder3', events)}"]
return date_text_dict[tag]
def _get_event_date_string(tag, events):
try:
return f"{events[tag]['day']} {events[tag]['date']} {events[tag]['time']}"
except KeyError:
return '' |
def load_text(path, num_heads=0, num_samples=-1):
lines = []
with open(path, encoding="utf-8") as f:
if num_heads > 0:
for _ in range(num_heads):
next(f)
for i, line in enumerate(f):
if (num_samples > 0) and (i >= num_samples):
break
lines.append(line.rstrip("\n"))
return lines
def load_parallel_text(source_path, target_path, num_heads=0, num_samples=-1):
sources = load_text(source_path, num_heads, num_samples)
targets = load_text(target_path, num_heads, num_samples)
if len(sources) != len(targets):
raise ValueError("Parallel corpus must have same length two files")
return sources, targets
def load_wikitext(path, num_lines=-1):
"""
Wikitext format
= Head1 =
text ...
text ...
= = 2ead = =
text ...
text ...
"""
if num_lines <= 0:
with open(path, encoding="utf-8") as f:
texts = f.read().split("\n =")
else:
lines = []
with open(path, encoding="utf-8") as f:
for i, line in enumerate(f):
if i >= num_lines:
break
lines.append(line)
texts = "".join(lines).split("\n =")
# fix missing prefix
texts = [texts[0]] + [f" ={text}" for text in texts[1:]]
return texts
| def load_text(path, num_heads=0, num_samples=-1):
lines = []
with open(path, encoding='utf-8') as f:
if num_heads > 0:
for _ in range(num_heads):
next(f)
for (i, line) in enumerate(f):
if num_samples > 0 and i >= num_samples:
break
lines.append(line.rstrip('\n'))
return lines
def load_parallel_text(source_path, target_path, num_heads=0, num_samples=-1):
sources = load_text(source_path, num_heads, num_samples)
targets = load_text(target_path, num_heads, num_samples)
if len(sources) != len(targets):
raise value_error('Parallel corpus must have same length two files')
return (sources, targets)
def load_wikitext(path, num_lines=-1):
"""
Wikitext format
= Head1 =
text ...
text ...
= = 2ead = =
text ...
text ...
"""
if num_lines <= 0:
with open(path, encoding='utf-8') as f:
texts = f.read().split('\n =')
else:
lines = []
with open(path, encoding='utf-8') as f:
for (i, line) in enumerate(f):
if i >= num_lines:
break
lines.append(line)
texts = ''.join(lines).split('\n =')
texts = [texts[0]] + [f' ={text}' for text in texts[1:]]
return texts |
"""Input an array of numbers, return the sum of all of the positives ones."""
def positive_sum(arr):
"""Return the sum of positive integers in a list of numbers."""
if arr:
return sum([a for a in arr if a > 0])
return 0
| """Input an array of numbers, return the sum of all of the positives ones."""
def positive_sum(arr):
"""Return the sum of positive integers in a list of numbers."""
if arr:
return sum([a for a in arr if a > 0])
return 0 |
class Solution:
def numMatchingSubseq(self, S: str, words: List[str]) -> int:
"""Array.
Running time: O(s + w) where s == len(S) and w == sum(length of each word in words).
"""
n = len(words)
d = collections.defaultdict(list)
for word in words:
d[word[0]].append(iter(word[1:]))
res = 0
for s in S:
iters = d.pop(s, [])
for i in iters:
d[next(i, "")].append(i)
return len(d[""])
| class Solution:
def num_matching_subseq(self, S: str, words: List[str]) -> int:
"""Array.
Running time: O(s + w) where s == len(S) and w == sum(length of each word in words).
"""
n = len(words)
d = collections.defaultdict(list)
for word in words:
d[word[0]].append(iter(word[1:]))
res = 0
for s in S:
iters = d.pop(s, [])
for i in iters:
d[next(i, '')].append(i)
return len(d['']) |
class Rec2TapsError(ValueError):
pass
class UnequalSampleRate(Rec2TapsError):
'Stimuli file and the recording file have unequal sample rate'
def __init__(self, stimuli_file, recording_file, stimuli_sr, recording_sr):
self.stimuli_file = stimuli_file
self.recording_file = recording_file
self.stimuli_sr = stimuli_sr
self.recording_sr = recording_sr
super().__init__(('{} and {} do not have the same sample rate '
'({} != {})').format(stimuli_file, recording_file,
stimuli_sr, recording_sr))
class SignalTooShortForConvolution(Rec2TapsError):
pass
class StimuliShorterThanRecording(Rec2TapsError):
'Stimuli signal is shorter than recording signal'
def __init__(self, stimuli_file, recording_file):
super().__init__(('Stimuli file ({}) is shorter than recording file '
'({}).').format(stimuli_file, recording_file))
| class Rec2Tapserror(ValueError):
pass
class Unequalsamplerate(Rec2TapsError):
"""Stimuli file and the recording file have unequal sample rate"""
def __init__(self, stimuli_file, recording_file, stimuli_sr, recording_sr):
self.stimuli_file = stimuli_file
self.recording_file = recording_file
self.stimuli_sr = stimuli_sr
self.recording_sr = recording_sr
super().__init__('{} and {} do not have the same sample rate ({} != {})'.format(stimuli_file, recording_file, stimuli_sr, recording_sr))
class Signaltooshortforconvolution(Rec2TapsError):
pass
class Stimulishorterthanrecording(Rec2TapsError):
"""Stimuli signal is shorter than recording signal"""
def __init__(self, stimuli_file, recording_file):
super().__init__('Stimuli file ({}) is shorter than recording file ({}).'.format(stimuli_file, recording_file)) |
'''
Title : Find the Second Largest Number
Subdomain : Basic Data Types
Domain : Python
Author : codeperfectplus
Created : 17 January 2020
Problem :
Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up.
'''
if __name__ == '__main__':
n = int(input())
arr = map(int, input().split())
new_list = []
for i in arr:
if i not in new_list:
new_list.append(i)
sort_list = sorted(new_list)
print(sort_list[-2]) | """
Title : Find the Second Largest Number
Subdomain : Basic Data Types
Domain : Python
Author : codeperfectplus
Created : 17 January 2020
Problem :
Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given scores. Store them in a list and find the score of the runner-up.
"""
if __name__ == '__main__':
n = int(input())
arr = map(int, input().split())
new_list = []
for i in arr:
if i not in new_list:
new_list.append(i)
sort_list = sorted(new_list)
print(sort_list[-2]) |
def addition(*numbers) -> int:
total_sum = 0
for number in numbers:
total_sum += number
return total_sum
sum = addition(2, 3)
print(f'sum: {sum}')
| def addition(*numbers) -> int:
total_sum = 0
for number in numbers:
total_sum += number
return total_sum
sum = addition(2, 3)
print(f'sum: {sum}') |
x = {'a': 1, 'b': 2}
y = {'b': 3, 'c': 4}
# Python merges dictionary keys
# in the order listed in the expression, overwriting
# duplicates from left to right.
#
# Works in Python 3.5+
print({**x, **y})
| x = {'a': 1, 'b': 2}
y = {'b': 3, 'c': 4}
print({**x, **y}) |
class Debt(object):
def __init__(self,data=None):
self.fromUser = data["from"]
self.toUser = data["to"]
self.amount = data["amount"]
if "currency_code" in data:
self.currency_code = data["currency_code"]
else:
self.currency_code = None
def getFromUser(self):
return self.fromUser
def getToUser(self):
return self.toUser
def getAmount(self):
return self.amount
def getCurrencyCode(self):
return self.currency_code
| class Debt(object):
def __init__(self, data=None):
self.fromUser = data['from']
self.toUser = data['to']
self.amount = data['amount']
if 'currency_code' in data:
self.currency_code = data['currency_code']
else:
self.currency_code = None
def get_from_user(self):
return self.fromUser
def get_to_user(self):
return self.toUser
def get_amount(self):
return self.amount
def get_currency_code(self):
return self.currency_code |
#
# PySNMP MIB module TPLINK-PRODUCTS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPLINK-PRODUCTS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:25:39 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")
ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
Counter32, Integer32, ObjectIdentity, MibIdentifier, Bits, TimeTicks, Unsigned32, Gauge32, ModuleIdentity, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Counter64, NotificationType, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "Counter32", "Integer32", "ObjectIdentity", "MibIdentifier", "Bits", "TimeTicks", "Unsigned32", "Gauge32", "ModuleIdentity", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Counter64", "NotificationType", "IpAddress")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
tplinkProducts, = mibBuilder.importSymbols("TPLINK-MIB", "tplinkProducts")
tplink_tlsl5428 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 1)).setLabel("tplink-tlsl5428")
tplink_tlsl3452 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 2)).setLabel("tplink-tlsl3452")
tplink_tlsg3424 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 3)).setLabel("tplink-tlsg3424")
tplink_tlsg3216 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 4)).setLabel("tplink-tlsg3216")
tplink_tlsg3210 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 5)).setLabel("tplink-tlsg3210")
tplink_tlsl3428 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 6)).setLabel("tplink-tlsl3428")
tplink_tlsg5428 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 7)).setLabel("tplink-tlsg5428")
tplink_tlsg3424p = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 8)).setLabel("tplink-tlsg3424p")
tplink_tlsg5412f = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 9)).setLabel("tplink-tlsg5412f")
tplink_t2700_28tct = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 10)).setLabel("tplink-t2700-28tct")
tplink_tlsl2428 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 11)).setLabel("tplink-tlsl2428")
tplink_tlsg2216 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 12)).setLabel("tplink-tlsg2216")
tplink_tlsg2424 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 13)).setLabel("tplink-tlsg2424")
tplink_tlsg5428cn = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 14)).setLabel("tplink-tlsg5428cn")
tplink_tlsg2452 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 15)).setLabel("tplink-tlsg2452")
tplink_tlsl2218 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 16)).setLabel("tplink-tlsl2218")
tplink_tlsg2424p = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 17)).setLabel("tplink-tlsg2424p")
tplink_tlsg2210 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 18)).setLabel("tplink-tlsg2210")
tplink_tlsl2210 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 19)).setLabel("tplink-tlsl2210")
tplink_t3700g_28tq = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 20)).setLabel("tplink-t3700g-28tq")
tplink_tlsl2226p = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 21)).setLabel("tplink-tlsl2226p")
tplink_tlsl2452 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 22)).setLabel("tplink-tlsl2452")
tplink_tlsl2218p = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 23)).setLabel("tplink-tlsl2218p")
tplink_tlsg3424_ipv6 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 24)).setLabel("tplink-tlsg3424-ipv6")
tplink_tlsg2008 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 25)).setLabel("tplink-tlsg2008")
tplink_tlsg2210p = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 26)).setLabel("tplink-tlsg2210p")
tplink_t2700g_28tq = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 27)).setLabel("tplink-t2700g-28tq")
tplink_t1600g_28ts = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 28)).setLabel("tplink-t1600g-28ts")
tplink_t1600g_52ts = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 29)).setLabel("tplink-t1600g-52ts")
tplink_t3700g_54tq = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 30)).setLabel("tplink-t3700g-54tq")
tplink_t1700g_28tq = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 31)).setLabel("tplink-t1700g-28tq")
tplink_t1700g_52tq = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 32)).setLabel("tplink-t1700g-52tq")
tplink_t2600g_28ts = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 33)).setLabel("tplink-t2600g-28ts")
tplink_t2600g_52ts = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 34)).setLabel("tplink-t2600g-52ts")
tplink_t1600g_28ps = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 37)).setLabel("tplink-t1600g-28ps")
tplink_t1600g_52ps = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 38)).setLabel("tplink-t1600g-52ps")
tplink_tlsg2224p = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 39)).setLabel("tplink-tlsg2224p")
tplink_tlsg3428 = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 40)).setLabel("tplink-tlsg3428")
tplink_t1700x_16ts = MibIdentifier((1, 3, 6, 1, 4, 1, 11863, 5, 41)).setLabel("tplink-t1700x-16ts")
mibBuilder.exportSymbols("TPLINK-PRODUCTS-MIB", tplink_tlsg2008=tplink_tlsg2008, tplink_tlsg5428cn=tplink_tlsg5428cn, tplink_t1700g_28tq=tplink_t1700g_28tq, tplink_tlsg3216=tplink_tlsg3216, tplink_tlsg3424_ipv6=tplink_tlsg3424_ipv6, tplink_tlsg2210p=tplink_tlsg2210p, tplink_tlsg2210=tplink_tlsg2210, tplink_tlsg3428=tplink_tlsg3428, tplink_tlsg2224p=tplink_tlsg2224p, tplink_t1600g_52ps=tplink_t1600g_52ps, tplink_tlsg2424=tplink_tlsg2424, tplink_tlsg5428=tplink_tlsg5428, tplink_t3700g_54tq=tplink_t3700g_54tq, tplink_tlsl2218p=tplink_tlsl2218p, tplink_t1600g_28ts=tplink_t1600g_28ts, tplink_tlsl2452=tplink_tlsl2452, tplink_tlsl3428=tplink_tlsl3428, tplink_t1600g_52ts=tplink_t1600g_52ts, tplink_tlsl5428=tplink_tlsl5428, tplink_tlsg2216=tplink_tlsg2216, tplink_tlsl2210=tplink_tlsl2210, tplink_t2700g_28tq=tplink_t2700g_28tq, tplink_tlsg5412f=tplink_tlsg5412f, tplink_tlsl2428=tplink_tlsl2428, tplink_t1700g_52tq=tplink_t1700g_52tq, tplink_tlsg3210=tplink_tlsg3210, tplink_t2700_28tct=tplink_t2700_28tct, tplink_tlsg3424p=tplink_tlsg3424p, tplink_t2600g_52ts=tplink_t2600g_52ts, tplink_tlsg2452=tplink_tlsg2452, tplink_t3700g_28tq=tplink_t3700g_28tq, tplink_tlsl3452=tplink_tlsl3452, tplink_t1700x_16ts=tplink_t1700x_16ts, tplink_tlsl2226p=tplink_tlsl2226p, tplink_tlsg2424p=tplink_tlsg2424p, tplink_t2600g_28ts=tplink_t2600g_28ts, tplink_tlsg3424=tplink_tlsg3424, tplink_tlsl2218=tplink_tlsl2218, tplink_t1600g_28ps=tplink_t1600g_28ps)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(counter32, integer32, object_identity, mib_identifier, bits, time_ticks, unsigned32, gauge32, module_identity, mib_scalar, mib_table, mib_table_row, mib_table_column, iso, counter64, notification_type, ip_address) = mibBuilder.importSymbols('SNMPv2-SMI', 'Counter32', 'Integer32', 'ObjectIdentity', 'MibIdentifier', 'Bits', 'TimeTicks', 'Unsigned32', 'Gauge32', 'ModuleIdentity', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'iso', 'Counter64', 'NotificationType', 'IpAddress')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
(tplink_products,) = mibBuilder.importSymbols('TPLINK-MIB', 'tplinkProducts')
tplink_tlsl5428 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 1)).setLabel('tplink-tlsl5428')
tplink_tlsl3452 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 2)).setLabel('tplink-tlsl3452')
tplink_tlsg3424 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 3)).setLabel('tplink-tlsg3424')
tplink_tlsg3216 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 4)).setLabel('tplink-tlsg3216')
tplink_tlsg3210 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 5)).setLabel('tplink-tlsg3210')
tplink_tlsl3428 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 6)).setLabel('tplink-tlsl3428')
tplink_tlsg5428 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 7)).setLabel('tplink-tlsg5428')
tplink_tlsg3424p = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 8)).setLabel('tplink-tlsg3424p')
tplink_tlsg5412f = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 9)).setLabel('tplink-tlsg5412f')
tplink_t2700_28tct = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 10)).setLabel('tplink-t2700-28tct')
tplink_tlsl2428 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 11)).setLabel('tplink-tlsl2428')
tplink_tlsg2216 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 12)).setLabel('tplink-tlsg2216')
tplink_tlsg2424 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 13)).setLabel('tplink-tlsg2424')
tplink_tlsg5428cn = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 14)).setLabel('tplink-tlsg5428cn')
tplink_tlsg2452 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 15)).setLabel('tplink-tlsg2452')
tplink_tlsl2218 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 16)).setLabel('tplink-tlsl2218')
tplink_tlsg2424p = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 17)).setLabel('tplink-tlsg2424p')
tplink_tlsg2210 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 18)).setLabel('tplink-tlsg2210')
tplink_tlsl2210 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 19)).setLabel('tplink-tlsl2210')
tplink_t3700g_28tq = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 20)).setLabel('tplink-t3700g-28tq')
tplink_tlsl2226p = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 21)).setLabel('tplink-tlsl2226p')
tplink_tlsl2452 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 22)).setLabel('tplink-tlsl2452')
tplink_tlsl2218p = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 23)).setLabel('tplink-tlsl2218p')
tplink_tlsg3424_ipv6 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 24)).setLabel('tplink-tlsg3424-ipv6')
tplink_tlsg2008 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 25)).setLabel('tplink-tlsg2008')
tplink_tlsg2210p = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 26)).setLabel('tplink-tlsg2210p')
tplink_t2700g_28tq = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 27)).setLabel('tplink-t2700g-28tq')
tplink_t1600g_28ts = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 28)).setLabel('tplink-t1600g-28ts')
tplink_t1600g_52ts = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 29)).setLabel('tplink-t1600g-52ts')
tplink_t3700g_54tq = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 30)).setLabel('tplink-t3700g-54tq')
tplink_t1700g_28tq = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 31)).setLabel('tplink-t1700g-28tq')
tplink_t1700g_52tq = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 32)).setLabel('tplink-t1700g-52tq')
tplink_t2600g_28ts = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 33)).setLabel('tplink-t2600g-28ts')
tplink_t2600g_52ts = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 34)).setLabel('tplink-t2600g-52ts')
tplink_t1600g_28ps = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 37)).setLabel('tplink-t1600g-28ps')
tplink_t1600g_52ps = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 38)).setLabel('tplink-t1600g-52ps')
tplink_tlsg2224p = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 39)).setLabel('tplink-tlsg2224p')
tplink_tlsg3428 = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 40)).setLabel('tplink-tlsg3428')
tplink_t1700x_16ts = mib_identifier((1, 3, 6, 1, 4, 1, 11863, 5, 41)).setLabel('tplink-t1700x-16ts')
mibBuilder.exportSymbols('TPLINK-PRODUCTS-MIB', tplink_tlsg2008=tplink_tlsg2008, tplink_tlsg5428cn=tplink_tlsg5428cn, tplink_t1700g_28tq=tplink_t1700g_28tq, tplink_tlsg3216=tplink_tlsg3216, tplink_tlsg3424_ipv6=tplink_tlsg3424_ipv6, tplink_tlsg2210p=tplink_tlsg2210p, tplink_tlsg2210=tplink_tlsg2210, tplink_tlsg3428=tplink_tlsg3428, tplink_tlsg2224p=tplink_tlsg2224p, tplink_t1600g_52ps=tplink_t1600g_52ps, tplink_tlsg2424=tplink_tlsg2424, tplink_tlsg5428=tplink_tlsg5428, tplink_t3700g_54tq=tplink_t3700g_54tq, tplink_tlsl2218p=tplink_tlsl2218p, tplink_t1600g_28ts=tplink_t1600g_28ts, tplink_tlsl2452=tplink_tlsl2452, tplink_tlsl3428=tplink_tlsl3428, tplink_t1600g_52ts=tplink_t1600g_52ts, tplink_tlsl5428=tplink_tlsl5428, tplink_tlsg2216=tplink_tlsg2216, tplink_tlsl2210=tplink_tlsl2210, tplink_t2700g_28tq=tplink_t2700g_28tq, tplink_tlsg5412f=tplink_tlsg5412f, tplink_tlsl2428=tplink_tlsl2428, tplink_t1700g_52tq=tplink_t1700g_52tq, tplink_tlsg3210=tplink_tlsg3210, tplink_t2700_28tct=tplink_t2700_28tct, tplink_tlsg3424p=tplink_tlsg3424p, tplink_t2600g_52ts=tplink_t2600g_52ts, tplink_tlsg2452=tplink_tlsg2452, tplink_t3700g_28tq=tplink_t3700g_28tq, tplink_tlsl3452=tplink_tlsl3452, tplink_t1700x_16ts=tplink_t1700x_16ts, tplink_tlsl2226p=tplink_tlsl2226p, tplink_tlsg2424p=tplink_tlsg2424p, tplink_t2600g_28ts=tplink_t2600g_28ts, tplink_tlsg3424=tplink_tlsg3424, tplink_tlsl2218=tplink_tlsl2218, tplink_t1600g_28ps=tplink_t1600g_28ps) |
def add(x:int, y:int) -> int:
pass
print(add.__annotations__)
# Annotations usually show up in documentation and also are used
# by third party tools
| def add(x: int, y: int) -> int:
pass
print(add.__annotations__) |
# https://app.codesignal.com/arcade/code-arcade/book-market/G9wj2j6zaWwFWsise
def isCaseInsensitivePalindrome(input_string):
# Check if word is a palindrome ignoring casing.
word = input_string.lower()
return word == word[::-1]
| def is_case_insensitive_palindrome(input_string):
word = input_string.lower()
return word == word[::-1] |
def spring(point, N, reeks):
if point in reeks:
print(reeks)
for i in (point.x, N):
point.x = + 1
if point.x <= N and (point.y + 1) <= N:
spring(Point(point.x + 2, point.y + 1), N, reeks)
point.x -= 1
reeks.append(point)
class Point:
def __init__(self, x, y) -> None:
super().__init__()
self.x = x
self.y = y
def __eq__(self, o: object) -> bool:
return self.x == o.x and self.y == o.y
if __name__ == '__main__':
spring(0, 0, 8, [])
| def spring(point, N, reeks):
if point in reeks:
print(reeks)
for i in (point.x, N):
point.x = +1
if point.x <= N and point.y + 1 <= N:
spring(point(point.x + 2, point.y + 1), N, reeks)
point.x -= 1
reeks.append(point)
class Point:
def __init__(self, x, y) -> None:
super().__init__()
self.x = x
self.y = y
def __eq__(self, o: object) -> bool:
return self.x == o.x and self.y == o.y
if __name__ == '__main__':
spring(0, 0, 8, []) |
# Instruksi:
# Buat variabel-variabel berikut dan definisikan sesuai nilai yang diminta:
#
# angka_saya memiliki nilai 1945
# float_saya diisi dengan desimal 17.8
# boolean_saya menjadi True
angka_saya = 1945
float_saya = 17.8
boolean = True
print(angka_saya,boolean) | angka_saya = 1945
float_saya = 17.8
boolean = True
print(angka_saya, boolean) |
class Result:
def __init__(self, value, pos):
self.value = value
self.pos = pos
def __repr__(self):
return "Result(%s, %d)" % (self.value, self.pos)
class Parser:
def __add__(self, other):
return Concat(self, other)
def __mul__(self, other):
return Exp(self, other)
def __or__(self, other):
return Alternate(self, other)
def __xor__(self, function):
return Process(self, function)
class Tag(Parser):
def __init__(self, tag):
self.tag = tag
def __call__(self, tokens, pos):
if pos < len(tokens) and tokens[pos][1] is self.tag:
return Result(tokens[pos][0], pos + 1)
else:
return None
class Reserved(Parser):
def __init__(self, value, tag):
self.value = value
self.tag = tag
def __call__(self, tokens, pos):
if pos < len(tokens) and \
tokens[pos][0] == self.value and \
tokens[pos][1] is self.tag:
return Result(tokens[pos][0], pos + 1)
else:
return None
class Concat(Parser):
def __init__(self, left, right):
self.left = left
self.right = right
def __call__(self, tokens, pos):
left_result = self.left(tokens, pos)
if left_result:
right_result = self.right(tokens, left_result.pos)
if right_result:
combined_value = (left_result.value, right_result.value)
return Result(combined_value, right_result.pos)
return None
class Exp(Parser):
def __init__(self, parser, separator):
self.parser = parser
self.separator = separator
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
def process_next(parsed):
(sepfunc, right) = parsed
return sepfunc(result.value, right)
next_parser = self.separator + self.parser ^ process_next
next_result = result
while next_result:
next_result = next_parser(tokens, result.pos)
if next_result:
result = next_result
return result
class Alternate(Parser):
def __init__(self, left, right):
self.left = left
self.right = right
def __call__(self, tokens, pos):
left_result = self.left(tokens, pos)
if left_result:
return left_result
else:
right_result = self.right(tokens, pos)
return right_result
class Opt(Parser):
def __init__(self, parser):
self.parser = parser
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
if result:
return result
else:
return Result(None, pos)
class Rep(Parser):
def __init__(self, parser):
self.parser = parser
def __call__(self, tokens, pos):
results = []
result = self.parser(tokens, pos)
while result:
results.append(result.value)
pos = result.pos
result = self.parser(tokens, pos)
return Result(results, pos)
class Process(Parser):
def __init__(self, parser, function):
self.parser = parser
self.function = function
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
if result:
result.value = self.function(result.value)
return result
class Lazy(Parser):
def __init__(self, parser_func):
self.parser = None
self.parser_func = parser_func
def __call__(self, tokens, pos):
if not self.parser:
self.parser = self.parser_func()
return self.parser(tokens, pos)
class Phrase(Parser):
def __init__(self, parser):
self.parser = parser
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
if result and result.pos == len(tokens):
return result
else:
return None
| class Result:
def __init__(self, value, pos):
self.value = value
self.pos = pos
def __repr__(self):
return 'Result(%s, %d)' % (self.value, self.pos)
class Parser:
def __add__(self, other):
return concat(self, other)
def __mul__(self, other):
return exp(self, other)
def __or__(self, other):
return alternate(self, other)
def __xor__(self, function):
return process(self, function)
class Tag(Parser):
def __init__(self, tag):
self.tag = tag
def __call__(self, tokens, pos):
if pos < len(tokens) and tokens[pos][1] is self.tag:
return result(tokens[pos][0], pos + 1)
else:
return None
class Reserved(Parser):
def __init__(self, value, tag):
self.value = value
self.tag = tag
def __call__(self, tokens, pos):
if pos < len(tokens) and tokens[pos][0] == self.value and (tokens[pos][1] is self.tag):
return result(tokens[pos][0], pos + 1)
else:
return None
class Concat(Parser):
def __init__(self, left, right):
self.left = left
self.right = right
def __call__(self, tokens, pos):
left_result = self.left(tokens, pos)
if left_result:
right_result = self.right(tokens, left_result.pos)
if right_result:
combined_value = (left_result.value, right_result.value)
return result(combined_value, right_result.pos)
return None
class Exp(Parser):
def __init__(self, parser, separator):
self.parser = parser
self.separator = separator
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
def process_next(parsed):
(sepfunc, right) = parsed
return sepfunc(result.value, right)
next_parser = self.separator + self.parser ^ process_next
next_result = result
while next_result:
next_result = next_parser(tokens, result.pos)
if next_result:
result = next_result
return result
class Alternate(Parser):
def __init__(self, left, right):
self.left = left
self.right = right
def __call__(self, tokens, pos):
left_result = self.left(tokens, pos)
if left_result:
return left_result
else:
right_result = self.right(tokens, pos)
return right_result
class Opt(Parser):
def __init__(self, parser):
self.parser = parser
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
if result:
return result
else:
return result(None, pos)
class Rep(Parser):
def __init__(self, parser):
self.parser = parser
def __call__(self, tokens, pos):
results = []
result = self.parser(tokens, pos)
while result:
results.append(result.value)
pos = result.pos
result = self.parser(tokens, pos)
return result(results, pos)
class Process(Parser):
def __init__(self, parser, function):
self.parser = parser
self.function = function
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
if result:
result.value = self.function(result.value)
return result
class Lazy(Parser):
def __init__(self, parser_func):
self.parser = None
self.parser_func = parser_func
def __call__(self, tokens, pos):
if not self.parser:
self.parser = self.parser_func()
return self.parser(tokens, pos)
class Phrase(Parser):
def __init__(self, parser):
self.parser = parser
def __call__(self, tokens, pos):
result = self.parser(tokens, pos)
if result and result.pos == len(tokens):
return result
else:
return None |
"""
File:baginterface.py
Author:yeyuning
"""
class BagInterface(object):
"""Interface for all bag types"""
# Constructor
def __init__(self, SourceCollection=None):
"""Sets the initial state of self, which includes the contents of sourceCollection,
if it's present."""
pass
# Accessor methods
def isEmpty(self):
"""Returns True if len(self) == 0 or False otherwise."""
return True
def __len__(self):
"""Returns the number of items in self."""
return 0
def __str__(self):
"""Returns the string representation of self."""
return ""
def __iter__(self):
"""Support iteration over a view of self."""
return None
def __add__(self, other):
"""Returns a new bag containing the contents of self and other"""
return None
def __eq__(self, other):
"""Returns True if self equals other, or False otherwise."""
return False
# Mutator methods
def clear(self):
"""Marks self become empty."""
pass
def add(self, item):
"""Adds item to self."""
pass
def remove(self, item):
"""Precondition: item is in self.
Raises: KeyError if item in not in self.
Postcondition: item is removed from self."""
pass
| """
File:baginterface.py
Author:yeyuning
"""
class Baginterface(object):
"""Interface for all bag types"""
def __init__(self, SourceCollection=None):
"""Sets the initial state of self, which includes the contents of sourceCollection,
if it's present."""
pass
def is_empty(self):
"""Returns True if len(self) == 0 or False otherwise."""
return True
def __len__(self):
"""Returns the number of items in self."""
return 0
def __str__(self):
"""Returns the string representation of self."""
return ''
def __iter__(self):
"""Support iteration over a view of self."""
return None
def __add__(self, other):
"""Returns a new bag containing the contents of self and other"""
return None
def __eq__(self, other):
"""Returns True if self equals other, or False otherwise."""
return False
def clear(self):
"""Marks self become empty."""
pass
def add(self, item):
"""Adds item to self."""
pass
def remove(self, item):
"""Precondition: item is in self.
Raises: KeyError if item in not in self.
Postcondition: item is removed from self."""
pass |
# Wraps DB-API 2.0 query results to provide a nice list and dictionary interface.
# Copyright (C) 2002 Dr. Conan C. Albrecht <conan_albrecht@byu.edu>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# I created this class and related functions because I like accessing
# database results by field name rather than field number. Accessing
# by field number has many problems: code is less readable, code gets
# broken when field positions change or fields are added or deleted from
# the query, etc.
#
# This class should have little overhead if you are already using fetchall().
# It wraps each result row in a ResultRow class which allows you to
# retrieve results via a dictionary interface (by column name). The regular
# list interface (by column number) is also provided.
#
# I can't believe the DB-API 2.0 api didn't include dictionary-style results.
# I'd love to see the reasoning behind not requiring them of database connection
# classes.
# This module comes from:
# http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/163605
def get_rows(cursor, sql):
"""Return a list of ResultRow objects from an SQL query."""
# run the query
cursor.execute(sql)
# return the list
return getdict(cursor.fetchall(), cursor.description)
def getdict(results, description):
"""Return the list of DBRows in `results` with a given description."""
# get the field names
fields = {}
for i in range(len(description)):
fields[description[i][0]] = i
# generate the list of DBRow objects
rows = []
for result in results:
rows.append(DBRow(result, fields))
# return to the user
return rows
class DBRow(object):
"""A single row in a result set.
Each DBRow has a dictionary-style and list-style interface.
"""
def __init__(self, row, fields):
"""Called by ResultSet function. Don't call directly"""
self.fields = fields
self.row = row
self._extra_fields = {}
def __repr__(self):
return "<DBrow with %s fields>" % len(self)
def __str__(self):
"""Return a string representation"""
return str(self.row)
def __getattr__(self, attr):
return self.row[self.fields[attr]]
def set_extra_attr(self, attr, value):
self._extra_fields[attr] = value
def __getitem__(self, key):
"""Return the value of the named column"""
if type(key) == type(1): # if a number
return self.row[key]
else: # a field name
return self.row[self.fields[key]]
def __setitem__(self, key, value):
"""Not used in this implementation"""
raise TypeError("can't set an item of a result set")
def __getslice__(self, i, j):
"""Return the value of the numbered column"""
return self.row[i: j]
def __setslice__(self, i, j, list):
"""Not used in this implementation"""
raise TypeError("can't set an item of a result set")
def keys(self):
"""Return the field names"""
return self.fields.keys()
def keymappings(self):
"""Return a dictionary of the keys and their indices in the row"""
return self.fields
def has_key(self, key):
"""Return whether the given key is valid"""
return self.fields.has_key(key)
def as_dict(self):
d = {}
for field_name, pos in self.fields.iteritems():
d[field_name] = self.row[pos]
for field_name, field in self._extra_fields.iteritems():
d[field_name] = field
return d
def __len__(self):
"""Return how many columns are in this row"""
return len(self.row)
def __nonzero__(self):
return len(self.row) != 0
def __eq__(self, other):
## Error if other is not set
if other == None:
return False
return self.fields == other.fields
| def get_rows(cursor, sql):
"""Return a list of ResultRow objects from an SQL query."""
cursor.execute(sql)
return getdict(cursor.fetchall(), cursor.description)
def getdict(results, description):
"""Return the list of DBRows in `results` with a given description."""
fields = {}
for i in range(len(description)):
fields[description[i][0]] = i
rows = []
for result in results:
rows.append(db_row(result, fields))
return rows
class Dbrow(object):
"""A single row in a result set.
Each DBRow has a dictionary-style and list-style interface.
"""
def __init__(self, row, fields):
"""Called by ResultSet function. Don't call directly"""
self.fields = fields
self.row = row
self._extra_fields = {}
def __repr__(self):
return '<DBrow with %s fields>' % len(self)
def __str__(self):
"""Return a string representation"""
return str(self.row)
def __getattr__(self, attr):
return self.row[self.fields[attr]]
def set_extra_attr(self, attr, value):
self._extra_fields[attr] = value
def __getitem__(self, key):
"""Return the value of the named column"""
if type(key) == type(1):
return self.row[key]
else:
return self.row[self.fields[key]]
def __setitem__(self, key, value):
"""Not used in this implementation"""
raise type_error("can't set an item of a result set")
def __getslice__(self, i, j):
"""Return the value of the numbered column"""
return self.row[i:j]
def __setslice__(self, i, j, list):
"""Not used in this implementation"""
raise type_error("can't set an item of a result set")
def keys(self):
"""Return the field names"""
return self.fields.keys()
def keymappings(self):
"""Return a dictionary of the keys and their indices in the row"""
return self.fields
def has_key(self, key):
"""Return whether the given key is valid"""
return self.fields.has_key(key)
def as_dict(self):
d = {}
for (field_name, pos) in self.fields.iteritems():
d[field_name] = self.row[pos]
for (field_name, field) in self._extra_fields.iteritems():
d[field_name] = field
return d
def __len__(self):
"""Return how many columns are in this row"""
return len(self.row)
def __nonzero__(self):
return len(self.row) != 0
def __eq__(self, other):
if other == None:
return False
return self.fields == other.fields |
class CleanUpTask:
def __init__(self, block_color, goal_room_color, block_name=None, goal_room_name=None):
'''
You can choose which attributes you would like to have represent the blocks and the rooms
'''
self.goal_room_name = goal_room_name
self.block_color = block_color
self.goal_room_color = goal_room_color
self.block_name = block_name
def __str__(self):
if self.goal_room_name is None and self.block_name is None:
return self.block_color + " to the " + self.goal_room_color + " room"
elif self.block_name is None:
return self.block_color + " to the room named " + self.goal_room_name
elif self.goal_room_name is None:
return "The block named " + self.block_name + " to the " + self.goal_room_color + " room"
else:
return "The block named " + self.block_name + " to the room named " + self.goal_room_name
| class Cleanuptask:
def __init__(self, block_color, goal_room_color, block_name=None, goal_room_name=None):
"""
You can choose which attributes you would like to have represent the blocks and the rooms
"""
self.goal_room_name = goal_room_name
self.block_color = block_color
self.goal_room_color = goal_room_color
self.block_name = block_name
def __str__(self):
if self.goal_room_name is None and self.block_name is None:
return self.block_color + ' to the ' + self.goal_room_color + ' room'
elif self.block_name is None:
return self.block_color + ' to the room named ' + self.goal_room_name
elif self.goal_room_name is None:
return 'The block named ' + self.block_name + ' to the ' + self.goal_room_color + ' room'
else:
return 'The block named ' + self.block_name + ' to the room named ' + self.goal_room_name |
class UnexpectedError(Exception):
"""Uneforseen Error."""
def __init__(self, message=None):
ErrorMsg = ("An Unexpected Error has occured.")
self.message = (ErrorMsg + " " + message) if message is not None else ErrorMsg
super().__init__(self.message)
class InvalidEncryptionMode(Exception):
"""The encryption mode entered is invalid."""
def __init__(self, mode):
self.ErrorMsg = f"Unsupported Encryption/Decryption Mode: {mode}"
AvailableModes = "AES, DES, Salsa20"
super().__init__(self.ErrorMsg + "\n Currently Supported Modes are: (Case Insensitive): \n " + AvailableModes)
class EmptyDataFile(Exception):
"""The Data File provided is empty."""
def __init__(self, path=None):
self.ErrorMsg = "Data File Provided is empty." if not path else f"{path} is empty."
super().__init__(self.ErrorMsg)
class NotAWAVFile(Exception):
"""The file provided is not a WAV file."""
def __init__(self, path=None):
self.ErrorMsg = "The file provided must be a WAV file." if not path else f"{path} is not a WAV File."
super().__init__(self.ErrorMsg)
class URLError(Exception):
"""The URL provided is invalid."""
def __init__(self):
super().__init__("Invalid URL.")
class FileDoesNotExist(Exception):
"""The path provided is invalid."""
def __init__(self, path=None):
self.ErrorMsg = "File does not exist." if not path else f"{path} is invalid."
super().__init__(self.ErrorMsg)
class LSBError(Exception):
"""LSB must be specified for extraction."""
def __init__(self):
super().__init__("The LSB value must be specified for extraction/retrieval.")
class NBytesError(Exception):
"""NBytes must be specified during extraction/retrieval."""
def __init__(self):
super().__init__("The number of bytes to extract must be specified for extraction/retrieval.")
if __name__ == "__main__":
raise NBytesError()
| class Unexpectederror(Exception):
"""Uneforseen Error."""
def __init__(self, message=None):
error_msg = 'An Unexpected Error has occured.'
self.message = ErrorMsg + ' ' + message if message is not None else ErrorMsg
super().__init__(self.message)
class Invalidencryptionmode(Exception):
"""The encryption mode entered is invalid."""
def __init__(self, mode):
self.ErrorMsg = f'Unsupported Encryption/Decryption Mode: {mode}'
available_modes = 'AES, DES, Salsa20'
super().__init__(self.ErrorMsg + '\n Currently Supported Modes are: (Case Insensitive): \n ' + AvailableModes)
class Emptydatafile(Exception):
"""The Data File provided is empty."""
def __init__(self, path=None):
self.ErrorMsg = 'Data File Provided is empty.' if not path else f'{path} is empty.'
super().__init__(self.ErrorMsg)
class Notawavfile(Exception):
"""The file provided is not a WAV file."""
def __init__(self, path=None):
self.ErrorMsg = 'The file provided must be a WAV file.' if not path else f'{path} is not a WAV File.'
super().__init__(self.ErrorMsg)
class Urlerror(Exception):
"""The URL provided is invalid."""
def __init__(self):
super().__init__('Invalid URL.')
class Filedoesnotexist(Exception):
"""The path provided is invalid."""
def __init__(self, path=None):
self.ErrorMsg = 'File does not exist.' if not path else f'{path} is invalid.'
super().__init__(self.ErrorMsg)
class Lsberror(Exception):
"""LSB must be specified for extraction."""
def __init__(self):
super().__init__('The LSB value must be specified for extraction/retrieval.')
class Nbyteserror(Exception):
"""NBytes must be specified during extraction/retrieval."""
def __init__(self):
super().__init__('The number of bytes to extract must be specified for extraction/retrieval.')
if __name__ == '__main__':
raise n_bytes_error() |
# Definition for binary tree with next pointer.
# class TreeLinkNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
# self.next = None
class Solution(object):
def connect(self, root):
"""
:type root: TreeLinkNode
:rtype: nothing
"""
if not root:
return None
root.next = None
self.recurse(root)
def recurse(self, node):
if not node or not node.left:
return
node.left.next = node.right
if node.next:
node.right.next = node.next.left
else:
node.right.next = None
self.recurse(node.left)
self.recurse(node.right)
| class Solution(object):
def connect(self, root):
"""
:type root: TreeLinkNode
:rtype: nothing
"""
if not root:
return None
root.next = None
self.recurse(root)
def recurse(self, node):
if not node or not node.left:
return
node.left.next = node.right
if node.next:
node.right.next = node.next.left
else:
node.right.next = None
self.recurse(node.left)
self.recurse(node.right) |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jan 22 18:27:25 2022
@author: victor
"""
def make_pizza(topping='bacon'):
"""Make a single-topping pizza."""
print("Have a " + topping + " pizza!")
make_pizza()
make_pizza('pepperoni') | """
Created on Sat Jan 22 18:27:25 2022
@author: victor
"""
def make_pizza(topping='bacon'):
"""Make a single-topping pizza."""
print('Have a ' + topping + ' pizza!')
make_pizza()
make_pizza('pepperoni') |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
head = ListNode(0)
result = head
if list1 is None:
return list2
elif list2 is None:
return list1
elif list1 is None and list2 is None:
return []
while list1 and list2:
if list1.val > list2.val:
head.next = ListNode(list2.val)
list2 = list2.next
head = head.next
else:
head.next = ListNode(list1.val)
list1 = list1.next
head = head.next
while list2:
head.next = ListNode(list2.val)
list2 = list2.next
head = head.next
while list1:
head.next = ListNode(list1.val)
list1 = list1.next
head = head.next
return result.next
class Solution:
def mergeTwoLists(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:
if l1 is None and l2 is None:
return None
elif l1 is None:
return l2
elif l2 is None:
return l1
else:
listnode = ListNode()
cursor = listnode
while l1 and l2:
if l1.val > l2.val:
cursor.next = ListNode(l2.val)
cursor = cursor.next
l2 = l2.next
else:
cursor.next = ListNode(l1.val)
cursor = cursor.next
l1 = l1.next
while l1:
cursor.next = ListNode(l1.val)
l1 = l1.next
cursor = cursor.next
while l2:
cursor.next = ListNode(l2.val)
l2 = l2.next
cursor = cursor.next
return listnode.next
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeTwoLists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
head = ListNode()
temp = head
while list1 and list2:
if list1.val < list2.val:
temp.next = list1
list1 = list1.next
else:
temp.next = list2
list2 = list2.next
temp = temp.next
if list1:
temp.next = list1
if list2:
temp.next = list2
return head.next
| class Solution:
def merge_two_lists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
head = list_node(0)
result = head
if list1 is None:
return list2
elif list2 is None:
return list1
elif list1 is None and list2 is None:
return []
while list1 and list2:
if list1.val > list2.val:
head.next = list_node(list2.val)
list2 = list2.next
head = head.next
else:
head.next = list_node(list1.val)
list1 = list1.next
head = head.next
while list2:
head.next = list_node(list2.val)
list2 = list2.next
head = head.next
while list1:
head.next = list_node(list1.val)
list1 = list1.next
head = head.next
return result.next
class Solution:
def merge_two_lists(self, l1: Optional[ListNode], l2: Optional[ListNode]) -> Optional[ListNode]:
if l1 is None and l2 is None:
return None
elif l1 is None:
return l2
elif l2 is None:
return l1
else:
listnode = list_node()
cursor = listnode
while l1 and l2:
if l1.val > l2.val:
cursor.next = list_node(l2.val)
cursor = cursor.next
l2 = l2.next
else:
cursor.next = list_node(l1.val)
cursor = cursor.next
l1 = l1.next
while l1:
cursor.next = list_node(l1.val)
l1 = l1.next
cursor = cursor.next
while l2:
cursor.next = list_node(l2.val)
l2 = l2.next
cursor = cursor.next
return listnode.next
class Solution:
def merge_two_lists(self, list1: Optional[ListNode], list2: Optional[ListNode]) -> Optional[ListNode]:
head = list_node()
temp = head
while list1 and list2:
if list1.val < list2.val:
temp.next = list1
list1 = list1.next
else:
temp.next = list2
list2 = list2.next
temp = temp.next
if list1:
temp.next = list1
if list2:
temp.next = list2
return head.next |
class BottomReached(Exception):
pass
class TopReached(Exception):
pass
| class Bottomreached(Exception):
pass
class Topreached(Exception):
pass |
def validBraces(string):
open = ["(","[","{"]
close = [")","]","}"]
stack = []
for i in string:
if i in open:
stack.append(i)
else:
pos = close.index(i)
if len(stack) > 0 and open[pos] == stack[len(stack)-1]:
stack.pop()
else:
return False
return True if len(stack) == 0 else False | def valid_braces(string):
open = ['(', '[', '{']
close = [')', ']', '}']
stack = []
for i in string:
if i in open:
stack.append(i)
else:
pos = close.index(i)
if len(stack) > 0 and open[pos] == stack[len(stack) - 1]:
stack.pop()
else:
return False
return True if len(stack) == 0 else False |
# !/usr/bin/env python3
# Author: C.K
# Email: theck17@163.com
# DateTime:2021-10-15 20:03:00
# Description:
class Solution:
def findRelativeRanks(self, score: List[int]) -> List[str]:
Medal = ["Gold Medal", "Silver Medal", "Bronze Medal"]
size = len(score)
res = [""] * size
my_map = {}
for i in range(size):
my_map[score[i]] = i
score.sort(reverse=True)
for i in range(size):
if i < 3:
res[my_map[score[i]]] = Medal[i]
else:
res[my_map[score[i]]] = str(i + 1)
return res
if __name__ == "__main__":
pass
| class Solution:
def find_relative_ranks(self, score: List[int]) -> List[str]:
medal = ['Gold Medal', 'Silver Medal', 'Bronze Medal']
size = len(score)
res = [''] * size
my_map = {}
for i in range(size):
my_map[score[i]] = i
score.sort(reverse=True)
for i in range(size):
if i < 3:
res[my_map[score[i]]] = Medal[i]
else:
res[my_map[score[i]]] = str(i + 1)
return res
if __name__ == '__main__':
pass |
# -*- coding: utf-8 -*-
a = int(input("digite a primeira variavel: "))
b = int(input("digite a segunda variavel: "))
crescente = int(input("digite qualquer variavel: "))
if a < b:
print(a,b)
else:
crescente = b
b = a
a = crescente
print (a,b)
| a = int(input('digite a primeira variavel: '))
b = int(input('digite a segunda variavel: '))
crescente = int(input('digite qualquer variavel: '))
if a < b:
print(a, b)
else:
crescente = b
b = a
a = crescente
print(a, b) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
stream = "{{{{{{{<\"\"!>,<!<'}'ui!!!>!!!>!<{!!!!!>>},{}},{<<'\"i!!a!{oe!>!!e!!!,<u!>},<a>,{<}{a\",!',!!!>},<u,!!!>!}<,'!o<!>,<>}},{<!!!>'\"i!!!>u!>uai!<o>,<i!!!>!>},<!>,<!>!>}o!>},<!>,<!>},<!>,<!!!>>}},{{{<!!,!!!>oo\"!!a>}},{{{{<i!!!!{,!!}>}},{{{<a>},{{<a!{!!>}}}},{<!>!!i'!!!>\"\"\"!>>,{}}},{{},{{<!>'!>,e!>},<e!>},<,,{\"{\"!!!>'>}}},{{{{<\"ao!>!!!><!>,<!!}{{!!euai>,{<{!>,<!>!>,<!\"u}<!,>}},{<<!>,<!>,<<<}a!!!!a!>,<>,<!!uu!>!!!!!>!!\"oe!!,o{!>},<}!>},<<!>!a!!!>>}}},{{{{<>}}},{{<!ei}\"!>!!!>!!!>!!!>!>},<eu<!!<>,<\"!>},<i!!!>!>},<!>,<'!!!>!!io>},{{{{<}!!!><!>},<u!!!},!!!>!>},<a,!!<'>},{<'!>,<!!>}},<<!!,au!!uu!!!>,<!!{o>},{<e}!!!>},<!!{'{eu!!,{!!aei!>,<<!!,a!!!>>}},{{<u!,>},<}{a!oei!aa,}\"!!,e!>!!!>'!!}{>}}}}},{{{{<u!!!>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!!>}a,!!u!>},<!!!>\"!>},<!{>,{}}}}}}}}"
def puzzle():
def track_garbage(idx):
i = 1
count = 0
while stream[idx + i] != '>':
if stream[idx + i] == '!':
i += 2
else:
i += 1
count += 1
return i, count
def track_group(idx, score):
level = score
count = 0
i = 1
while stream[idx + i] != '}':
if stream[idx + i] == '!':
# skip the next character
i += 2
continue
elif stream[idx + i] == '<':
# start of some garbage
dif, c = track_garbage(idx + i)
i += dif
count += c
continue
elif stream[idx + i] == '{':
# start of a new group
s, dif, c = track_group(idx + i, level + 1)
score += s
i += dif + 1
count += c
else:
# random character
i += 1
return score, i, count
s, i, c = track_group(0, 1)
return s, c
if __name__ == "__main__":
p1, p2 = puzzle()
print("1: {}\n2: {}".format(p1, p2))
| stream = '{{{{{{{<""!>,<!<\'}\'ui!!!>!!!>!<{!!!!!>>},{}},{<<\'"i!!a!{oe!>!!e!!!,<u!>},<a>,{<}{a",!\',!!!>},<u,!!!>!}<,\'!o<!>,<>}},{<!!!>\'"i!!!>u!>uai!<o>,<i!!!>!>},<!>,<!>!>}o!>},<!>,<!>},<!>,<!!!>>}},{{{<!!,!!!>oo"!!a>}},{{{{<i!!!!{,!!}>}},{{{<a>},{{<a!{!!>}}}},{<!>!!i\'!!!>"""!>>,{}}},{{},{{<!>\'!>,e!>},<e!>},<,,{"{"!!!>\'>}}},{{{{<"ao!>!!!><!>,<!!}{{!!euai>,{<{!>,<!>!>,<!"u}<!,>}},{<<!>,<!>,<<<}a!!!!a!>,<>,<!!uu!>!!!!!>!!"oe!!,o{!>},<}!>},<<!>!a!!!>>}}},{{{{<>}}},{{<!ei}"!>!!!>!!!>!!!>!>},<eu<!!<>,<"!>},<i!!!>!>},<!>,<\'!!!>!!io>},{{{{<}!!!><!>},<u!!!},!!!>!>},<a,!!<\'>},{<\'!>,<!!>}},<<!!,au!!uu!!!>,<!!{o>},{<e}!!!>},<!!{\'{eu!!,{!!aei!>,<<!!,a!!!>>}},{{<u!,>},<}{a!oei!aa,}"!!,e!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count = 0
while stream[idx + i] != '>':
if stream[idx + i] == '!':
i += 2
else:
i += 1
count += 1
return (i, count)
def track_group(idx, score):
level = score
count = 0
i = 1
while stream[idx + i] != '}':
if stream[idx + i] == '!':
i += 2
continue
elif stream[idx + i] == '<':
(dif, c) = track_garbage(idx + i)
i += dif
count += c
continue
elif stream[idx + i] == '{':
(s, dif, c) = track_group(idx + i, level + 1)
score += s
i += dif + 1
count += c
else:
i += 1
return (score, i, count)
(s, i, c) = track_group(0, 1)
return (s, c)
if __name__ == '__main__':
(p1, p2) = puzzle()
print('1: {}\n2: {}'.format(p1, p2)) |
class ViewHelpers:
def __init__(self, view):
self.view = view
def __iter__(self):
for sel in self.view.sel():
yield ViewHelper(self.view, sel)
class ViewHelper:
def __init__(self, view, sel):
self.view = view
self.sel = sel
def initial_xpos(self):
return self.view.text_to_layout(self.initial_cursor_position())[0]
def initial_cursor_position(self):
return self.initial_selection().b
def initial_selection(self):
return self.sel
def initial_column(self):
return self.view.rowcol(self.initial_cursor_position())[1]
def initial_row(self):
return self.view.rowcol(self.initial_cursor_position())[0]
def cursor_at_top_of_selection(self):
return self.initial_selection().a > self.initial_selection().b
def cursor_at_bottom_of_selection(self):
return self.initial_selection().b > self.initial_selection().a
def target_column(self, target, indent_offset):
tab_size = self.view.settings().get("tab_size")
offset_column = self.initial_column() + tab_size * indent_offset
end_of_line = self.view.rowcol(self.find_eol(target))[1]
if offset_column > end_of_line:
return end_of_line
else:
return offset_column
def find_eol(self, point):
return self.view.line(point).end()
def find_bol(self, point):
return self.view.line(point).begin()
| class Viewhelpers:
def __init__(self, view):
self.view = view
def __iter__(self):
for sel in self.view.sel():
yield view_helper(self.view, sel)
class Viewhelper:
def __init__(self, view, sel):
self.view = view
self.sel = sel
def initial_xpos(self):
return self.view.text_to_layout(self.initial_cursor_position())[0]
def initial_cursor_position(self):
return self.initial_selection().b
def initial_selection(self):
return self.sel
def initial_column(self):
return self.view.rowcol(self.initial_cursor_position())[1]
def initial_row(self):
return self.view.rowcol(self.initial_cursor_position())[0]
def cursor_at_top_of_selection(self):
return self.initial_selection().a > self.initial_selection().b
def cursor_at_bottom_of_selection(self):
return self.initial_selection().b > self.initial_selection().a
def target_column(self, target, indent_offset):
tab_size = self.view.settings().get('tab_size')
offset_column = self.initial_column() + tab_size * indent_offset
end_of_line = self.view.rowcol(self.find_eol(target))[1]
if offset_column > end_of_line:
return end_of_line
else:
return offset_column
def find_eol(self, point):
return self.view.line(point).end()
def find_bol(self, point):
return self.view.line(point).begin() |
def common_elements(list1, list2):
"""common elements between two sorted arrays
Arguments:
list1 sorted array
list2 sorted array
Returns:
array with common elements
"""
result = []
visited_elements = []
for item in list1:
index = len(visited_elements)
while index < len(list2):
if(item >= list2[index]):
visited_elements.append(list2[index])
if(item == list2[index]):
result.append(list2[index])
break
index += 1
pass
pass
return result
def common_elements_pro(list1, list2):
pointer1 = 0
pointer2 = 0
result = []
while pointer1 < len(list1) and pointer2 < len(list2):
if(list1[pointer1] == list2[pointer2]):
result.append(list1[pointer1])
pointer1 += 1
pointer2 += 1
if(list1[pointer1] > list2[pointer2]):
pointer2 += 1
else:
pointer1 += 1
return result
| def common_elements(list1, list2):
"""common elements between two sorted arrays
Arguments:
list1 sorted array
list2 sorted array
Returns:
array with common elements
"""
result = []
visited_elements = []
for item in list1:
index = len(visited_elements)
while index < len(list2):
if item >= list2[index]:
visited_elements.append(list2[index])
if item == list2[index]:
result.append(list2[index])
break
index += 1
pass
pass
return result
def common_elements_pro(list1, list2):
pointer1 = 0
pointer2 = 0
result = []
while pointer1 < len(list1) and pointer2 < len(list2):
if list1[pointer1] == list2[pointer2]:
result.append(list1[pointer1])
pointer1 += 1
pointer2 += 1
if list1[pointer1] > list2[pointer2]:
pointer2 += 1
else:
pointer1 += 1
return result |
"""
spider.unsupervised_learning sub-package
__init__.py
@author: kgilman
Primitive that performs GRASTA to learn low-rank subspace and sparse outliers from streaming data
defines the module index
"""
# to allow from spider.unsupervized_learning import *
__all__ = [
"grasta",
]
| """
spider.unsupervised_learning sub-package
__init__.py
@author: kgilman
Primitive that performs GRASTA to learn low-rank subspace and sparse outliers from streaming data
defines the module index
"""
__all__ = ['grasta'] |
# Copyright (c) 2018-2019 Alexander L. Hayes (@hayesall)
#
# 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.
def cytoscapeFormat(predType, val1, val2):
"""
.. versionadded:: 0.3.0
Converts inputs into the triples format used by Cytoscape.
:param predType: The action which relates one or more values.
:type predType: str.
:param val1: The first value.
:type val1: str.
:param val2: The second value.
:type val2: str.
Cytoscape is mostly built around binary predicates: two entities (nodes)
connected by a relation (edge). Because hyperedges are not implicitly
built-in, this function requires three parameters.
>>> cytoscapeFormat('action', 'value1', 'value2')
'value1 action value2'
>>> cytoscapeFormat('friends', 'harry', 'ron')
'harry friends ron'
>>> cytoscapeFormat('liked', 'person1', 'story3')
'person1 liked story3'
If the outputs of this function are written to a file, it may be imported
to Cytoscape as follows:
1. ``File > Import > Network > File`` (choose where you wrote the file).
2. ``Advanced Options``: Select 'Space', Uncheck 'Use first line as column
names'
3. Set ``Column 1`` as ``Source Node`` (green circle).
4. Set ``Column 2`` as ``Interaction Type`` (violet triangle).
5. Set ``Column 3`` as ``Target Node`` (red target).
6. Click 'Ok'
.. seealso::
"Cytoscape is an open source software platform for visualizing complex
networks and integrating these with any type of attribute data."
The desktop version of Cytoscape includes an option to import a network
``File > Import > Network > File``. This function may be used to create
such files for visualization.
http://www.cytoscape.org/
"""
return val1.replace(' ', '') + ' ' + \
predType.replace(' ', '') + ' ' + \
val2.replace(' ', '')
| def cytoscape_format(predType, val1, val2):
"""
.. versionadded:: 0.3.0
Converts inputs into the triples format used by Cytoscape.
:param predType: The action which relates one or more values.
:type predType: str.
:param val1: The first value.
:type val1: str.
:param val2: The second value.
:type val2: str.
Cytoscape is mostly built around binary predicates: two entities (nodes)
connected by a relation (edge). Because hyperedges are not implicitly
built-in, this function requires three parameters.
>>> cytoscapeFormat('action', 'value1', 'value2')
'value1 action value2'
>>> cytoscapeFormat('friends', 'harry', 'ron')
'harry friends ron'
>>> cytoscapeFormat('liked', 'person1', 'story3')
'person1 liked story3'
If the outputs of this function are written to a file, it may be imported
to Cytoscape as follows:
1. ``File > Import > Network > File`` (choose where you wrote the file).
2. ``Advanced Options``: Select 'Space', Uncheck 'Use first line as column
names'
3. Set ``Column 1`` as ``Source Node`` (green circle).
4. Set ``Column 2`` as ``Interaction Type`` (violet triangle).
5. Set ``Column 3`` as ``Target Node`` (red target).
6. Click 'Ok'
.. seealso::
"Cytoscape is an open source software platform for visualizing complex
networks and integrating these with any type of attribute data."
The desktop version of Cytoscape includes an option to import a network
``File > Import > Network > File``. This function may be used to create
such files for visualization.
http://www.cytoscape.org/
"""
return val1.replace(' ', '') + ' ' + predType.replace(' ', '') + ' ' + val2.replace(' ', '') |
class Document :
# Default constructor
def __init__ ( self , _id ):
# initialize
self.id = _id
self.title =""
self.text= ""
self.succ = dict()
self.pred = dict()
#Setters
def setText(self,Text):
self.text = Text
def setTitle(self,Title):
self.title = Title
def addSuccessor(self,idDoc):
if ( idDoc in self.succ ):
self.succ[idDoc] += 1
else :
self.succ[idDoc] = 1
def addPredecessor(self,idDoc):
if ( idDoc in self.pred ):
self.pred[idDoc] += 1
else :
self.pred[idDoc] = 1
#Getters
def getId (self):
return self.id
def getText (self):
return self.text
def getTitle (self):
return self.title
def getSucessors(self):
return self.succ
def getPredecessors(self):
return self.pred
def getJsonFormat (self):
return { "Title" : self.title , "Text" : self.text , "sucessors" : self.succ , "predecessors" : self.pred }
| class Document:
def __init__(self, _id):
self.id = _id
self.title = ''
self.text = ''
self.succ = dict()
self.pred = dict()
def set_text(self, Text):
self.text = Text
def set_title(self, Title):
self.title = Title
def add_successor(self, idDoc):
if idDoc in self.succ:
self.succ[idDoc] += 1
else:
self.succ[idDoc] = 1
def add_predecessor(self, idDoc):
if idDoc in self.pred:
self.pred[idDoc] += 1
else:
self.pred[idDoc] = 1
def get_id(self):
return self.id
def get_text(self):
return self.text
def get_title(self):
return self.title
def get_sucessors(self):
return self.succ
def get_predecessors(self):
return self.pred
def get_json_format(self):
return {'Title': self.title, 'Text': self.text, 'sucessors': self.succ, 'predecessors': self.pred} |
class Calculator():
def __init__(self):
pass
def add(self, val1, val2):
try:
return val1 + val2
except:
raise ValueError("Not int")
def subtract(self, val1, val2):
val1 = self._checker(val1)
val2 = self._checker(val2)
if val1 and val2:
return val1 - val2
def multiply(self, val1, val2):
val1 = self._checker(val1)
val2 = self._checker(val2)
if val1 and val2:
return val1 * val2
def divide(self, val1, val2):
if val2 == 0:
raise ValueError("0 division error.")
val1 = self._checker(val1)
val2 = self._checker(val2)
if val1 and val2:
return val1 / val2
def _checker(self, val):
if type(val) is int:
return val
elif type(val) is float:
return val
# convert string representation of number to float
try:
return float(val)
except ValueError:
return False
# # convert string number to float
# try:
# return int(val)
# except ValueError:
# return False
obj = Calculator()
result = obj._checker("2.0")
print(result)
| class Calculator:
def __init__(self):
pass
def add(self, val1, val2):
try:
return val1 + val2
except:
raise value_error('Not int')
def subtract(self, val1, val2):
val1 = self._checker(val1)
val2 = self._checker(val2)
if val1 and val2:
return val1 - val2
def multiply(self, val1, val2):
val1 = self._checker(val1)
val2 = self._checker(val2)
if val1 and val2:
return val1 * val2
def divide(self, val1, val2):
if val2 == 0:
raise value_error('0 division error.')
val1 = self._checker(val1)
val2 = self._checker(val2)
if val1 and val2:
return val1 / val2
def _checker(self, val):
if type(val) is int:
return val
elif type(val) is float:
return val
try:
return float(val)
except ValueError:
return False
obj = calculator()
result = obj._checker('2.0')
print(result) |
class Torre:
def __init__(self):
self.id = int()
self.nome = str()
self.endereco = str()
def cadastrar(self, id, nome, endereco):
self.id = id
self.nome = nome
self.endereco = endereco
def imprimir(self):
print("ID TORRE:", self.id, " - TORRE", self.nome, " -", self.endereco)
| class Torre:
def __init__(self):
self.id = int()
self.nome = str()
self.endereco = str()
def cadastrar(self, id, nome, endereco):
self.id = id
self.nome = nome
self.endereco = endereco
def imprimir(self):
print('ID TORRE:', self.id, ' - TORRE', self.nome, ' -', self.endereco) |
# Copyright 2018-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
"""Exposes an auto-public version of android_library"""
def visible_android_library(**kwargs):
"""android_library that is by default public"""
kwargs["visibility"] = ["PUBLIC"]
android_library(**kwargs)
| """Exposes an auto-public version of android_library"""
def visible_android_library(**kwargs):
"""android_library that is by default public"""
kwargs['visibility'] = ['PUBLIC']
android_library(**kwargs) |
#!/usr/bin/env python3
# pylint: disable=C0111
def all_steps(state):
result = list()
for action in range(len(state[0])):
if state[0][action] != 0:
next_state = jump(state, action, 1) or jump(state, action, 2)
if next_state:
result = result + all_steps(next_state)
else:
result = result + [state]
return result
def jump(state, action, distance):
destination = distance * state[0][action] + action
if destination < 0 or destination >= len(state[0]):
return None
if state[0][destination] != 0:
return None
result = list(state[0])
result[destination] = result[action]
result[action] = 0
return result, [action] + state[1]
print("\n".join(["%s : %s" % (x[0], [i for i in reversed(x[1])])
for x in all_steps([[1, 1, 1, 0, -1, -1, -1], []])
if x[0] == [-1, -1, -1, 0, 1, 1, 1]]))
| def all_steps(state):
result = list()
for action in range(len(state[0])):
if state[0][action] != 0:
next_state = jump(state, action, 1) or jump(state, action, 2)
if next_state:
result = result + all_steps(next_state)
else:
result = result + [state]
return result
def jump(state, action, distance):
destination = distance * state[0][action] + action
if destination < 0 or destination >= len(state[0]):
return None
if state[0][destination] != 0:
return None
result = list(state[0])
result[destination] = result[action]
result[action] = 0
return (result, [action] + state[1])
print('\n'.join(['%s : %s' % (x[0], [i for i in reversed(x[1])]) for x in all_steps([[1, 1, 1, 0, -1, -1, -1], []]) if x[0] == [-1, -1, -1, 0, 1, 1, 1]])) |
'''
codegen: this is the code generator for our Cuppa3 compiler
NOTE: this code generator does not need access to the symbol table,
the abstraction level of the AST has been lowered already to the level
of the abstract machine code
'''
#########################################################################
# curr_frame_size: we use this global variable to broadcast the frame
# size of the current function definition to all the statements within
# the function body -- the return statement needs this information in order
# to generate the proper pop frame instruction. Outside of a
# function definition this value is set to None
curr_frame_size = None
#########################################################################
def push_args(args):
if args[0] != 'LIST':
raise ValueError("expected an argument list")
# reversing the arg list because we need to push
# args in reverse order
# NOTE: reverse is an in-place op in Python
ll = args[1].copy()
ll.reverse()
code = list()
for e in ll:
(ecode, eloc) = walk(e)
code += ecode
code += [('pushv', eloc)]
return code
#########################################################################
def pop_args(args):
if args[0] != 'LIST':
raise ValueError("expected an argument list")
ll = args[1]
code = list()
for e in ll:
code += [('popv',)]
return code
#########################################################################
def init_formal_args(formal_args, frame_size):
'''
in order to understand this function recall that the stack
in the called function after the frame has been pushed
looks like this
...
actual arg n
actual arg n-1
...
actual arg 1
return address
local var m
local var m-1
local var 1 <- tsx
The local vars include the formal parameters. Here the frame size is m.
In order to find the location of the first actual argument we have to s
kip over the frame and the return address:
first actual arg: %tsx[0-m-1]
second actual arg: %tsx[-1-m-1]
...
nth actual arg: %tsx[-(n-1)-m-1]
'''
if formal_args[0] != 'LIST':
raise ValueError("expected an argument list")
ll = formal_args[1]
code = list()
arg_ix = 0
for id in ll:
(ADDR, sym) = id
if ADDR != 'ADDR':
raise ValueError("Expected and address.")
offset = str(arg_ix - frame_size - 1)
code += [('store', sym, '%tsx['+offset+']')]
arg_ix -= 1
return code
#########################################################################
# node functions
#########################################################################
# Statements
#########################################################################
def stmtlist(node):
(STMTLIST, lst) = node
code = list()
for stmt in lst:
code += walk(stmt)
return code
#########################################################################
def fundef_stmt(node):
global curr_frame_size
# unpack node
(FUNDEF,
(ADDR, name),
formal_arglist,
body,
(FRAMESIZE, curr_frame_size)) = node
ignore_label = label()
code = list()
code += [('jump', ignore_label)]
code += [('#','####################################')]
code += [('#','Start Function ' + name)]
code += [('#','####################################')]
code += [(name + ':',)]
code += [('pushf', str(curr_frame_size))]
code += init_formal_args(formal_arglist, curr_frame_size)
code += walk(body)
code += [('popf', str(curr_frame_size))]
code += [('return',)]
code += [('#','####################################')]
code += [('#','End Function ' + name)]
code += [('#','####################################')]
code += [(ignore_label + ':',)]
code += [('noop',)]
curr_frame_size = None
return code
#########################################################################
def call_stmt(node):
(CALLSTMT, (ADDR, name), actual_args) = node
code = list()
code += push_args(actual_args)
code += [('call', name)]
code += pop_args(actual_args)
return code
#########################################################################
def return_stmt(node):
global curr_frame_size
(RETURN, exp) = node
code = list()
# if return has a return value
if exp[0] != 'NIL':
(ecode, eloc) = walk(exp)
code += ecode
code += [('store', '%rvx', eloc)]
code += [('popf', str(curr_frame_size))]
code += [('return',)]
return code
#########################################################################
def assign_stmt(node):
(ASSIGN, (ADDR, target), exp) = node
(ecode, eloc) = walk(exp)
code = list()
code += ecode
code += [('store', target, eloc)]
return code
#########################################################################
def get_stmt(node):
(GET, (ADDR, target)) = node
code = [('input', target)]
return code
#########################################################################
def put_stmt(node):
(PUT, exp) = node
(ecode, eloc) = walk(exp)
code = list()
code += ecode
code += [('print', eloc)]
return code
#########################################################################
def while_stmt(node):
(WHILE, cond, body) = node
top_label = label()
bottom_label = label()
(cond_code, cond_loc) = walk(cond)
body_code = walk(body)
code = list()
code += [(top_label + ':',)]
code += cond_code
code += [('jumpf', cond_loc, bottom_label)]
code += body_code
code += [('jump', top_label)]
code += [(bottom_label + ':',)]
code += [('noop',)]
return code
#########################################################################
def if_stmt(node):
(IF, cond, s1, s2) = node
if s2[0] == 'NIL':
end_label = label();
(cond_code, cond_loc) = walk(cond)
s1_code = walk(s1)
code = list()
code += cond_code
code += [('jumpf', cond_loc, end_label)]
code += s1_code
code += [(end_label + ':',)]
code += [('noop',)]
return code
else:
else_label = label()
end_label = label()
(cond_code, cond_loc) = walk(cond)
s1_code = walk(s1)
s2_code = walk(s2)
code = list()
code += cond_code
code += [('jumpf', cond_loc, else_label)]
code += s1_code
code += [('jump', end_label)]
code += [(else_label + ':',)]
code += s2_code
code += [(end_label + ':',)]
code += [('noop',)]
return code
#########################################################################
def block_stmt(node):
(BLOCK, s) = node
code = walk(s)
return code
#########################################################################
# Expressions
#########################################################################
def binop_exp(node):
(OP, (ADDR, target), c1, c2) = node
if OP == 'PLUS':
OPSYM = '+'
elif OP == 'MINUS':
OPSYM = '-'
elif OP == 'MUL':
OPSYM = '*'
elif OP == 'DIV':
OPSYM = '/'
elif OP == 'EQ':
OPSYM = '=='
elif OP == 'LE':
OPSYM = '=<'
else:
raise ValueError('unknown operation: ' + OP)
(lcode, lloc) = walk(c1)
(rcode, rloc) = walk(c2)
code = list()
code += lcode
code += rcode
code += [('store', target, '(' + OPSYM + ' ' + lloc + ' ' + rloc + ')')]
return (code, target)
#########################################################################
def call_exp(node):
(CALLEXP, (ADDR, target), (ADDR, name), actual_args) = node
code = list()
code += push_args(actual_args)
code += [('call', name)]
code += pop_args(actual_args)
code += [('store', target, '%rvx')]
return (code, target)
#########################################################################
def integer_exp(node):
(INTEGER, value) = node
code = list()
loc = str(value)
return (code, loc)
#########################################################################
def addr_exp(node):
(ADDR, loc) = node
code = list()
return (code, loc)
#########################################################################
def uminus_exp(node):
(UMINUS, (ADDR, target), e) = node
(ecode, eloc) = walk(e)
code = list()
code += ecode
code += [('store', target, '-' + eloc)]
loc = target
return (code, loc)
#########################################################################
def not_exp(node):
(NOT, (ADDR, target), e) = node
(ecode, eloc) = walk(e)
code = list()
code += ecode
code += [('store', target, '!' + eloc)]
loc = target
return (code, loc)
#########################################################################
# walk
#########################################################################
def walk(node):
node_type = node[0]
if node_type in dispatch_dict:
node_function = dispatch_dict[node_type]
return node_function(node)
else:
raise ValueError("walk: unknown tree node type: " + node_type)
# a dictionary to associate tree nodes with node functions
dispatch_dict = {
'STMTLIST' : stmtlist,
'FUNDEF' : fundef_stmt,
'CALLSTMT' : call_stmt,
'RETURN' : return_stmt,
'ASSIGN' : assign_stmt,
'GET' : get_stmt,
'PUT' : put_stmt,
'WHILE' : while_stmt,
'IF' : if_stmt,
'BLOCK' : block_stmt,
'CALLEXP' : call_exp,
'INTEGER' : integer_exp,
'ADDR' : addr_exp,
'UMINUS' : uminus_exp,
'NOT' : not_exp,
'PLUS' : binop_exp,
'MINUS' : binop_exp,
'MUL' : binop_exp,
'DIV' : binop_exp,
'EQ' : binop_exp,
'LE' : binop_exp,
}
#########################################################################
label_id = 0
def label():
global label_id
s = 'L' + str(label_id)
label_id += 1
return s
#########################################################################
| """
codegen: this is the code generator for our Cuppa3 compiler
NOTE: this code generator does not need access to the symbol table,
the abstraction level of the AST has been lowered already to the level
of the abstract machine code
"""
curr_frame_size = None
def push_args(args):
if args[0] != 'LIST':
raise value_error('expected an argument list')
ll = args[1].copy()
ll.reverse()
code = list()
for e in ll:
(ecode, eloc) = walk(e)
code += ecode
code += [('pushv', eloc)]
return code
def pop_args(args):
if args[0] != 'LIST':
raise value_error('expected an argument list')
ll = args[1]
code = list()
for e in ll:
code += [('popv',)]
return code
def init_formal_args(formal_args, frame_size):
"""
in order to understand this function recall that the stack
in the called function after the frame has been pushed
looks like this
...
actual arg n
actual arg n-1
...
actual arg 1
return address
local var m
local var m-1
local var 1 <- tsx
The local vars include the formal parameters. Here the frame size is m.
In order to find the location of the first actual argument we have to s
kip over the frame and the return address:
first actual arg: %tsx[0-m-1]
second actual arg: %tsx[-1-m-1]
...
nth actual arg: %tsx[-(n-1)-m-1]
"""
if formal_args[0] != 'LIST':
raise value_error('expected an argument list')
ll = formal_args[1]
code = list()
arg_ix = 0
for id in ll:
(addr, sym) = id
if ADDR != 'ADDR':
raise value_error('Expected and address.')
offset = str(arg_ix - frame_size - 1)
code += [('store', sym, '%tsx[' + offset + ']')]
arg_ix -= 1
return code
def stmtlist(node):
(stmtlist, lst) = node
code = list()
for stmt in lst:
code += walk(stmt)
return code
def fundef_stmt(node):
global curr_frame_size
(fundef, (addr, name), formal_arglist, body, (framesize, curr_frame_size)) = node
ignore_label = label()
code = list()
code += [('jump', ignore_label)]
code += [('#', '####################################')]
code += [('#', 'Start Function ' + name)]
code += [('#', '####################################')]
code += [(name + ':',)]
code += [('pushf', str(curr_frame_size))]
code += init_formal_args(formal_arglist, curr_frame_size)
code += walk(body)
code += [('popf', str(curr_frame_size))]
code += [('return',)]
code += [('#', '####################################')]
code += [('#', 'End Function ' + name)]
code += [('#', '####################################')]
code += [(ignore_label + ':',)]
code += [('noop',)]
curr_frame_size = None
return code
def call_stmt(node):
(callstmt, (addr, name), actual_args) = node
code = list()
code += push_args(actual_args)
code += [('call', name)]
code += pop_args(actual_args)
return code
def return_stmt(node):
global curr_frame_size
(return, exp) = node
code = list()
if exp[0] != 'NIL':
(ecode, eloc) = walk(exp)
code += ecode
code += [('store', '%rvx', eloc)]
code += [('popf', str(curr_frame_size))]
code += [('return',)]
return code
def assign_stmt(node):
(assign, (addr, target), exp) = node
(ecode, eloc) = walk(exp)
code = list()
code += ecode
code += [('store', target, eloc)]
return code
def get_stmt(node):
(get, (addr, target)) = node
code = [('input', target)]
return code
def put_stmt(node):
(put, exp) = node
(ecode, eloc) = walk(exp)
code = list()
code += ecode
code += [('print', eloc)]
return code
def while_stmt(node):
(while, cond, body) = node
top_label = label()
bottom_label = label()
(cond_code, cond_loc) = walk(cond)
body_code = walk(body)
code = list()
code += [(top_label + ':',)]
code += cond_code
code += [('jumpf', cond_loc, bottom_label)]
code += body_code
code += [('jump', top_label)]
code += [(bottom_label + ':',)]
code += [('noop',)]
return code
def if_stmt(node):
(if, cond, s1, s2) = node
if s2[0] == 'NIL':
end_label = label()
(cond_code, cond_loc) = walk(cond)
s1_code = walk(s1)
code = list()
code += cond_code
code += [('jumpf', cond_loc, end_label)]
code += s1_code
code += [(end_label + ':',)]
code += [('noop',)]
return code
else:
else_label = label()
end_label = label()
(cond_code, cond_loc) = walk(cond)
s1_code = walk(s1)
s2_code = walk(s2)
code = list()
code += cond_code
code += [('jumpf', cond_loc, else_label)]
code += s1_code
code += [('jump', end_label)]
code += [(else_label + ':',)]
code += s2_code
code += [(end_label + ':',)]
code += [('noop',)]
return code
def block_stmt(node):
(block, s) = node
code = walk(s)
return code
def binop_exp(node):
(op, (addr, target), c1, c2) = node
if OP == 'PLUS':
opsym = '+'
elif OP == 'MINUS':
opsym = '-'
elif OP == 'MUL':
opsym = '*'
elif OP == 'DIV':
opsym = '/'
elif OP == 'EQ':
opsym = '=='
elif OP == 'LE':
opsym = '=<'
else:
raise value_error('unknown operation: ' + OP)
(lcode, lloc) = walk(c1)
(rcode, rloc) = walk(c2)
code = list()
code += lcode
code += rcode
code += [('store', target, '(' + OPSYM + ' ' + lloc + ' ' + rloc + ')')]
return (code, target)
def call_exp(node):
(callexp, (addr, target), (addr, name), actual_args) = node
code = list()
code += push_args(actual_args)
code += [('call', name)]
code += pop_args(actual_args)
code += [('store', target, '%rvx')]
return (code, target)
def integer_exp(node):
(integer, value) = node
code = list()
loc = str(value)
return (code, loc)
def addr_exp(node):
(addr, loc) = node
code = list()
return (code, loc)
def uminus_exp(node):
(uminus, (addr, target), e) = node
(ecode, eloc) = walk(e)
code = list()
code += ecode
code += [('store', target, '-' + eloc)]
loc = target
return (code, loc)
def not_exp(node):
(not, (addr, target), e) = node
(ecode, eloc) = walk(e)
code = list()
code += ecode
code += [('store', target, '!' + eloc)]
loc = target
return (code, loc)
def walk(node):
node_type = node[0]
if node_type in dispatch_dict:
node_function = dispatch_dict[node_type]
return node_function(node)
else:
raise value_error('walk: unknown tree node type: ' + node_type)
dispatch_dict = {'STMTLIST': stmtlist, 'FUNDEF': fundef_stmt, 'CALLSTMT': call_stmt, 'RETURN': return_stmt, 'ASSIGN': assign_stmt, 'GET': get_stmt, 'PUT': put_stmt, 'WHILE': while_stmt, 'IF': if_stmt, 'BLOCK': block_stmt, 'CALLEXP': call_exp, 'INTEGER': integer_exp, 'ADDR': addr_exp, 'UMINUS': uminus_exp, 'NOT': not_exp, 'PLUS': binop_exp, 'MINUS': binop_exp, 'MUL': binop_exp, 'DIV': binop_exp, 'EQ': binop_exp, 'LE': binop_exp}
label_id = 0
def label():
global label_id
s = 'L' + str(label_id)
label_id += 1
return s |
def generate_code_str(body, argname, global_name):
""" Generate python code to eval()
"""
body = body.replace('\n', '\n ')
return f"""def f({argname}):
{body}
output = f({global_name})"""
| def generate_code_str(body, argname, global_name):
""" Generate python code to eval()
"""
body = body.replace('\n', '\n ')
return f'def f({argname}):\n {body}\n\noutput = f({global_name})' |
def double(oldimage):
oldw = oldimage.getWidth()
oldh = oldimage.getHeight()
newim = EmptyImage(oldw*2,oldh*2)
for row in range(newim.getWidth()): #// \label{lst:dib1}
for col in range(newim.getHeight()): #// \label{lst:dib2}
originalCol = col//2 #// \label{lst:dib3}
originalRow = row//2 #// \label{lst:dib4}
oldpixel = oldimage.getPixel(originalCol,originalRow)
newim.setPixel(col,row,oldpixel)
return newim
| def double(oldimage):
oldw = oldimage.getWidth()
oldh = oldimage.getHeight()
newim = empty_image(oldw * 2, oldh * 2)
for row in range(newim.getWidth()):
for col in range(newim.getHeight()):
original_col = col // 2
original_row = row // 2
oldpixel = oldimage.getPixel(originalCol, originalRow)
newim.setPixel(col, row, oldpixel)
return newim |
# 1
stringHamlet_1 = 'To be or not to be.'
# 2
print(len(stringHamlet_1))
# 3
stringHamlet_2 = 'That is the question.'
# 4
stringHamlet = stringHamlet_1 + stringHamlet_2
# 5
stringHamletTrinity = stringHamlet * 3 | string_hamlet_1 = 'To be or not to be.'
print(len(stringHamlet_1))
string_hamlet_2 = 'That is the question.'
string_hamlet = stringHamlet_1 + stringHamlet_2
string_hamlet_trinity = stringHamlet * 3 |
"""
Task Score: 100%
Complexity: O(N * log(N))
"""
def is_triangle(a, b, c):
# apply given formulate to triplet
return a + b > c and \
b + c > a and \
a + c > b
def solution(A):
"""
I am sure there is a mathematical proof for this somewhere, however I
thought by looking at the problem that if there are three values that match
the given criteria, they are most likely to be found in numbers that are
very close together.
Following that line of thought, I have solved this as follows:
1. Order the array (ascending or descending does not matter here)
2. Do a single pass and check consecutive values
"""
# sort array
A = sorted(A)
for i in range(len(A) - 2):
# check triplet
if is_triangle(*A[i:i + 3]):
return 1
return 0
| """
Task Score: 100%
Complexity: O(N * log(N))
"""
def is_triangle(a, b, c):
return a + b > c and b + c > a and (a + c > b)
def solution(A):
"""
I am sure there is a mathematical proof for this somewhere, however I
thought by looking at the problem that if there are three values that match
the given criteria, they are most likely to be found in numbers that are
very close together.
Following that line of thought, I have solved this as follows:
1. Order the array (ascending or descending does not matter here)
2. Do a single pass and check consecutive values
"""
a = sorted(A)
for i in range(len(A) - 2):
if is_triangle(*A[i:i + 3]):
return 1
return 0 |
# For defining [Topic]hint_type, [Question]hint_type, [NLP_hints]hint_type
HINT_TYPE_CHOICES = (
('NONE', 'No hint'),
('WHERE', 'Where'),
('WHO', 'Who'),
('HOW MANY', 'How many'),
('WHEN', 'When'),
)
# nlp_exporter uses for requesting all available hints from NLP-Hints service
QUESTION_TYPES = (
{ 'ID': 1, 'Question': 'Where did it happen?' },
{ 'ID': 2, 'Question': 'Who was there?' },
{ 'ID': 3, 'Question': 'How many were there?' },
{ 'ID': 4, 'Question': 'When did it happen?' }
)
# nlp_importer uses for mapping question_id back to hint_type
QUESTION_TO_HINT_TYPE = {
1: 'WHERE',
2: 'WHO',
3: 'HOW MANY',
4: 'WHEN'
}
| hint_type_choices = (('NONE', 'No hint'), ('WHERE', 'Where'), ('WHO', 'Who'), ('HOW MANY', 'How many'), ('WHEN', 'When'))
question_types = ({'ID': 1, 'Question': 'Where did it happen?'}, {'ID': 2, 'Question': 'Who was there?'}, {'ID': 3, 'Question': 'How many were there?'}, {'ID': 4, 'Question': 'When did it happen?'})
question_to_hint_type = {1: 'WHERE', 2: 'WHO', 3: 'HOW MANY', 4: 'WHEN'} |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Created by pat on 5/11/18
"""
.. currentmodule:: modlit.testing
.. moduleauthor:: Pat Daburu <pat@daburu.net>
This package contains resources for testing your data model.
"""
| """
.. currentmodule:: modlit.testing
.. moduleauthor:: Pat Daburu <pat@daburu.net>
This package contains resources for testing your data model.
""" |
"""
Private fields are specified by prefixing an attribute's name with a double
underscore.
They can be accessed directly by methods of the containing class
Private attrib behaviour is implemented witha a simple transformation of the
attribute name.
__private_field transforms to _ClassName__private_field.
Why doesn't the syntax for private attributes actually enforce strict visibility?
-> We are all consenting adults here
ROFLOL
"""
class MyObject(object):
def __init__(self):
self.public_field = 5
self.__private_field = 10
def get_private_field(self):
return self.__private_field
class MyOtherObject(object):
def __init__(self):
self.__private_field = 71
@classmethod
def get_private_field_of_instance(cls, instance):
return instance.__private_field
class MyParentObject(object):
"""A subclass can not access its parents class's private field
"""
def __init__(self):
self.__private_field = 71
class MyChildObject(MyParentObject):
def get_private_field(self):
return self.__private_field
def main():
foo = MyObject()
assert foo.public_field == 5
assert foo.get_private_field() == 10
bar = MyOtherObject()
assert bar.get_private_field_of_instance(bar) == 71
baz = MyChildObject()
# trying to access a private field that is set by the parent
# will result in an attribute error
try:
baz.get_private_field()
except AttributeError as e:
print('A child can not access its parents private fields')
# we can access the private field of the parent using the name transform
assert baz._MyParentObject__private_field == 71
print(baz.__dict__) # {'_MyParentObject__private_field': 71
if __name__ == '__main__':
main()
| """
Private fields are specified by prefixing an attribute's name with a double
underscore.
They can be accessed directly by methods of the containing class
Private attrib behaviour is implemented witha a simple transformation of the
attribute name.
__private_field transforms to _ClassName__private_field.
Why doesn't the syntax for private attributes actually enforce strict visibility?
-> We are all consenting adults here
ROFLOL
"""
class Myobject(object):
def __init__(self):
self.public_field = 5
self.__private_field = 10
def get_private_field(self):
return self.__private_field
class Myotherobject(object):
def __init__(self):
self.__private_field = 71
@classmethod
def get_private_field_of_instance(cls, instance):
return instance.__private_field
class Myparentobject(object):
"""A subclass can not access its parents class's private field
"""
def __init__(self):
self.__private_field = 71
class Mychildobject(MyParentObject):
def get_private_field(self):
return self.__private_field
def main():
foo = my_object()
assert foo.public_field == 5
assert foo.get_private_field() == 10
bar = my_other_object()
assert bar.get_private_field_of_instance(bar) == 71
baz = my_child_object()
try:
baz.get_private_field()
except AttributeError as e:
print('A child can not access its parents private fields')
assert baz._MyParentObject__private_field == 71
print(baz.__dict__)
if __name__ == '__main__':
main() |
## TuplesAndLists
#
# Demonstration of techniques with tuples and lists
# Tuples cannot be changed, values enclosed with parenthesis.
# Tuples can be used as replacement for constant arrays
# available in other languages.
# Lists can be modified.
list1 = [ 10, 20, 30, 40, 50, 5, 2 ]
tuple1 = ( 10, 20, 30, 40, 50, 5, 2 )
list2 = [ 'apple', 'orange', 'banana' ]
tuple2 = ( 'apple', 'orange', 'banana' )
list3 = [ 10, 'apple', 30 ]
tuple3 = ( 10, 'apple', 30 )
list4 = [ 'aba', 'a1a', 'b5c', 'eaa' ]
# Two dimension list
list6 = [ [ 81, 82, 83 ], # Row 0
[ 84, 85, 86 ], # Row 1
[ 87, 88, 89 ] ] # Row 2
# Tuple using key-pair as dictionary lookup
Countries = { 'United Kingdom': 'London',
'France' : 'Paris',
'Spain' : 'Madrid' }
## Tuple returning values ######################################################
# Show capital
print( Countries[ 'France' ] )
# Country not found - gives runtime error
print( Countries[ 'USA'] )
## List adding elements ########################################################
# Appending to single dimension list
print( list1 )
list1.append( 80 )
print( list1 )
# Appending to two dimension list - list will have 4 columns instead of 3
print( list6 )
list6[ 0 ].append( 10 )
list6[ 1 ].append( 11 )
list6[ 2 ].append( 12 )
print( list6 )
## List iteration ##############################################################
# Print full list
print( list1 )
print( tuple1 )
# Can iterate manually - for integer list convert to str for printing
for listIndex, listItem in enumerate( list1 ):
print( 'Index: ' + str( listIndex ) + ' ListItem: ' + str( listItem ) )
# Iterating a string list
for listIndex, listItem in enumerate( list2 ):
print( 'Index: ' + str( listIndex ) + ' ListItem: ' + listItem )
# Iterate two dimension list
for rowIndex, rowItem in enumerate( list6 ):
print( '---' )
for colIndex, colItem in enumerate( rowItem ):
print( 'Row:' + str( rowIndex ) + ' Col: ' + str( colIndex ) + ' Value: ' + str( colItem ) )
## List Min/Max/Sum ############################################################
# Get maximum element
print( 'Max list ' + str( max( list1 ) ) )
print( 'Max tuple ' + str( max( tuple1 ) ) )
# Get minimum element
print( 'Min list ' + str( min( list1 ) ) )
print( 'Min tuple ' + str( min( tuple1 ) ) )
# For string elements shows highest value alphabetically
print( 'Max string list ' + str( max( list2 ) ) )
print( 'Max string tuple ' + str( max( tuple2 ) ) )
## List element conversion #####################################################
# Convert elements from integer to string
print( list3 )
liststr1 = []
for listItem in list3:
liststr1.append( str( listItem ) )
print( liststr1 )
# We can assign new list to old list
list3 = liststr1
# Now we can get max, was failling because elements were of different data types
print( 'Max list ' + str( max( list3 ) ) )
## List sorting ################################################################
# Sort list using sort
list1.sort()
print( list1 )
# Sort list using sort, reverse
list1.sort( reverse = True )
print( list1 )
# Sort list using sorted
list1a = sorted( list1 )
print( list1a )
# Custom sort function - strings are 0 offset based
def sortOnSecondElement( AElement ):
return AElement[ 1 ]
# Custom sort by calling a function for element comparison - sorting on second element
list4.sort( key = sortOnSecondElement )
print( list4 )
| list1 = [10, 20, 30, 40, 50, 5, 2]
tuple1 = (10, 20, 30, 40, 50, 5, 2)
list2 = ['apple', 'orange', 'banana']
tuple2 = ('apple', 'orange', 'banana')
list3 = [10, 'apple', 30]
tuple3 = (10, 'apple', 30)
list4 = ['aba', 'a1a', 'b5c', 'eaa']
list6 = [[81, 82, 83], [84, 85, 86], [87, 88, 89]]
countries = {'United Kingdom': 'London', 'France': 'Paris', 'Spain': 'Madrid'}
print(Countries['France'])
print(Countries['USA'])
print(list1)
list1.append(80)
print(list1)
print(list6)
list6[0].append(10)
list6[1].append(11)
list6[2].append(12)
print(list6)
print(list1)
print(tuple1)
for (list_index, list_item) in enumerate(list1):
print('Index: ' + str(listIndex) + ' ListItem: ' + str(listItem))
for (list_index, list_item) in enumerate(list2):
print('Index: ' + str(listIndex) + ' ListItem: ' + listItem)
for (row_index, row_item) in enumerate(list6):
print('---')
for (col_index, col_item) in enumerate(rowItem):
print('Row:' + str(rowIndex) + ' Col: ' + str(colIndex) + ' Value: ' + str(colItem))
print('Max list ' + str(max(list1)))
print('Max tuple ' + str(max(tuple1)))
print('Min list ' + str(min(list1)))
print('Min tuple ' + str(min(tuple1)))
print('Max string list ' + str(max(list2)))
print('Max string tuple ' + str(max(tuple2)))
print(list3)
liststr1 = []
for list_item in list3:
liststr1.append(str(listItem))
print(liststr1)
list3 = liststr1
print('Max list ' + str(max(list3)))
list1.sort()
print(list1)
list1.sort(reverse=True)
print(list1)
list1a = sorted(list1)
print(list1a)
def sort_on_second_element(AElement):
return AElement[1]
list4.sort(key=sortOnSecondElement)
print(list4) |
DEFAULT = False
called = DEFAULT
def reset_app():
global called
called = DEFAULT
def generate_sampledata(options):
global called
assert called == DEFAULT
called = True
| default = False
called = DEFAULT
def reset_app():
global called
called = DEFAULT
def generate_sampledata(options):
global called
assert called == DEFAULT
called = True |
# Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
x=0
tot=0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") : continue
pos=line.find(":")
l=line[pos+1:]
l=l.strip()
tot+=float(l)
x+=1
print("Average spam confidence: "+str(tot/x))
| fname = input('Enter file name: ')
fh = open(fname)
x = 0
tot = 0
for line in fh:
if not line.startswith('X-DSPAM-Confidence:'):
continue
pos = line.find(':')
l = line[pos + 1:]
l = l.strip()
tot += float(l)
x += 1
print('Average spam confidence: ' + str(tot / x)) |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
if not head or not head.next:
return head
p = self.reverseList(head.next)
head.next.next = head # main part - refer to notes
head.next = None
return p
if __name__ == "__main__":
a = ListNode(1)
b = ListNode(2)
c = ListNode(3)
d = ListNode(4)
e = ListNode(5)
a.next = b
b.next = c
c.next = d
d.next = e
head = Solution().reverseList(a)
while head:
print(head.val)
head = head.next
| class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def reverse_list(self, head: ListNode) -> ListNode:
if not head or not head.next:
return head
p = self.reverseList(head.next)
head.next.next = head
head.next = None
return p
if __name__ == '__main__':
a = list_node(1)
b = list_node(2)
c = list_node(3)
d = list_node(4)
e = list_node(5)
a.next = b
b.next = c
c.next = d
d.next = e
head = solution().reverseList(a)
while head:
print(head.val)
head = head.next |
# https://leetcode.com/problems/3sum/
#%%
nums = [-1,0,1,2,-1,-4]
target = 0
#%%
def threeSum(nums: list):
nums.sort()
indeces = []
values = []
uniqueIndeces = {}
#need to stop when I reach len(nums) - 2 because that I am going to deal with 2 pointers
for ind in range(0, len(nums) - 2):
lowInd = ind + 1
highInd = len(nums) - 1
while(lowInd < highInd):
sum_value = nums[ind] + nums[lowInd] + nums[highInd]
#print(sum_value)
if sum_value == 0:
if str(nums[ind]) + ' ' + str(nums[lowInd]) + ' ' + str(nums[lowInd]) not in uniqueIndeces:
uniqueIndeces[str(nums[ind]) + ' ' + str(nums[lowInd]) + ' ' + str(nums[lowInd])] = [ind, lowInd, highInd]
indeces.append([ind, lowInd, highInd])
values.append([nums[ind], nums[lowInd], nums[highInd]])
if sum_value > 0:
highInd -= 1
else:
lowInd += 1
return values
threeSum(nums)
# %%
| nums = [-1, 0, 1, 2, -1, -4]
target = 0
def three_sum(nums: list):
nums.sort()
indeces = []
values = []
unique_indeces = {}
for ind in range(0, len(nums) - 2):
low_ind = ind + 1
high_ind = len(nums) - 1
while lowInd < highInd:
sum_value = nums[ind] + nums[lowInd] + nums[highInd]
if sum_value == 0:
if str(nums[ind]) + ' ' + str(nums[lowInd]) + ' ' + str(nums[lowInd]) not in uniqueIndeces:
uniqueIndeces[str(nums[ind]) + ' ' + str(nums[lowInd]) + ' ' + str(nums[lowInd])] = [ind, lowInd, highInd]
indeces.append([ind, lowInd, highInd])
values.append([nums[ind], nums[lowInd], nums[highInd]])
if sum_value > 0:
high_ind -= 1
else:
low_ind += 1
return values
three_sum(nums) |
input = """
c num blocks = 1
c num vars = 180
c minblockids[0] = 1
c maxblockids[0] = 180
p cnf 180 795
5 49 137 0
-146 -16 161 0
-116 106 -77 0
28 -33 -87 0
-70 -56 -28 0
123 76 88 0
-160 128 45 0
-29 169 180 0
-96 -69 100 0
56 82 -38 0
-14 -108 -88 0
-147 -93 4 0
-130 6 38 0
-50 -149 8 0
142 -96 -68 0
-104 47 168 0
159 148 -128 0
92 111 31 0
-53 -137 65 0
-55 147 -42 0
24 127 92 0
108 -13 171 0
-73 -41 150 0
-46 -29 -179 0
28 52 -166 0
2 -94 37 0
154 -121 163 0
3 167 135 0
-86 171 -168 0
-63 -39 -100 0
158 -50 -151 0
102 158 32 0
-69 173 49 0
112 -114 -125 0
65 -23 -163 0
-122 -110 -15 0
-46 -8 -136 0
-103 -39 -96 0
85 -162 74 0
-25 121 -37 0
-50 -85 -147 0
25 14 155 0
62 -70 124 0
-62 -160 -83 0
116 -137 13 0
166 62 61 0
56 53 3 0
-143 82 20 0
100 89 53 0
95 64 -142 0
176 -74 -39 0
155 156 163 0
14 -96 32 0
-88 -79 120 0
95 152 70 0
75 149 -50 0
92 71 -156 0
-41 -155 55 0
-54 -144 -101 0
60 -38 -75 0
168 127 109 0
52 98 -126 0
171 129 -148 0
-146 167 -22 0
-39 -137 -76 0
90 -96 12 0
-132 110 -124 0
130 -170 -82 0
124 163 179 0
144 -4 108 0
-82 -144 -71 0
156 15 -93 0
20 -83 -78 0
136 18 42 0
-65 31 -41 0
-21 -155 -138 0
32 -131 112 0
90 112 -66 0
153 -52 -175 0
-86 71 -96 0
-73 68 -3 0
-11 29 126 0
-38 155 98 0
150 127 146 0
120 -136 108 0
47 179 155 0
169 158 129 0
15 75 72 0
169 137 64 0
-14 -115 49 0
-51 53 -172 0
-2 -23 -33 0
-79 148 2 0
-27 -2 -73 0
157 168 -71 0
-113 66 14 0
-77 -42 -12 0
-39 99 -5 0
-163 -21 81 0
-2 -163 71 0
11 126 -144 0
-34 159 -43 0
94 102 178 0
-112 49 -133 0
79 30 167 0
-104 -103 -28 0
-116 -125 -107 0
-167 -62 130 0
53 55 48 0
77 21 114 0
-31 138 -117 0
-25 -88 -127 0
66 -14 -29 0
66 -89 159 0
67 22 -14 0
110 4 -117 0
-8 -69 83 0
142 -133 94 0
61 146 -38 0
136 165 -168 0
142 -40 83 0
103 50 165 0
-10 -154 73 0
122 50 -48 0
-170 -164 24 0
83 -53 -61 0
7 -103 16 0
81 -106 35 0
80 -106 178 0
161 173 -137 0
-87 -145 2 0
30 136 94 0
59 -123 -61 0
-28 -102 136 0
-34 -175 -55 0
138 2 77 0
36 17 -175 0
-123 -171 93 0
92 -149 -180 0
125 118 -59 0
124 -30 -43 0
8 -82 14 0
166 -144 81 0
-45 31 173 0
-106 -43 -67 0
87 113 -107 0
78 94 -52 0
-165 12 103 0
155 -31 163 0
178 -87 123 0
102 17 -104 0
1 -167 -104 0
-160 13 -47 0
-77 -149 24 0
6 -76 -44 0
-164 93 -82 0
95 96 8 0
-81 -24 94 0
-55 -51 176 0
-158 155 175 0
-158 -166 -79 0
-114 -10 -14 0
140 -46 70 0
-32 97 -3 0
166 38 -133 0
120 170 13 0
102 -140 -150 0
-179 60 -58 0
-124 168 46 0
-30 122 -124 0
25 -91 79 0
-80 -14 119 0
-143 -44 86 0
114 -148 15 0
20 137 -78 0
-41 6 106 0
62 104 -83 0
37 -176 92 0
65 74 64 0
86 33 120 0
-180 166 -125 0
-58 17 141 0
-173 -95 -154 0
69 179 78 0
-178 126 -162 0
75 97 25 0
156 78 57 0
-93 111 6 0
-40 -29 -179 0
125 51 22 0
36 73 53 0
-167 99 -117 0
-122 130 72 0
56 51 134 0
65 66 -150 0
-119 39 -135 0
143 152 -111 0
-17 25 7 0
170 30 -11 0
-130 36 161 0
-180 -18 -40 0
66 -28 159 0
13 144 -21 0
-168 80 -161 0
153 -73 -30 0
33 -171 173 0
114 124 -148 0
-156 32 -128 0
179 164 -133 0
-151 -157 162 0
-72 -170 -147 0
10 119 75 0
-29 -12 -50 0
-131 -130 -81 0
-171 23 -162 0
102 61 23 0
-107 -67 -52 0
85 -73 15 0
-63 128 9 0
98 -68 154 0
29 111 -156 0
-118 99 -15 0
8 54 -174 0
-151 174 133 0
-155 139 -101 0
-6 67 164 0
37 -118 -46 0
-139 86 -25 0
37 5 -154 0
-46 134 141 0
87 -111 52 0
129 -131 -91 0
-120 126 -8 0
63 38 -70 0
-65 -89 -145 0
101 -1 57 0
-161 -115 -162 0
7 157 39 0
-42 174 180 0
-20 53 14 0
-177 75 112 0
105 165 -26 0
10 -119 -60 0
-70 102 -8 0
151 -134 113 0
-116 75 175 0
57 -43 133 0
-161 163 159 0
44 -26 -110 0
-91 -118 -22 0
133 46 -105 0
89 144 -133 0
41 153 113 0
-102 -70 -111 0
-93 131 -5 0
108 55 129 0
22 -115 173 0
122 -151 97 0
139 -36 -71 0
48 -173 -59 0
-91 -144 -71 0
4 -146 -23 0
83 -80 3 0
126 -74 -60 0
74 93 -101 0
78 29 124 0
83 -79 89 0
5 20 88 0
30 -154 67 0
-175 -55 -31 0
72 40 34 0
-159 -161 -106 0
175 57 72 0
-53 106 6 0
-72 -71 118 0
-30 169 -116 0
75 -160 88 0
-41 -38 162 0
-81 144 94 0
50 107 -59 0
15 -27 -56 0
114 -3 -15 0
180 -83 -119 0
82 35 -30 0
-47 148 127 0
-177 56 -178 0
-37 -175 -96 0
-177 -23 36 0
156 -108 -112 0
9 24 -112 0
99 -131 -124 0
-91 26 -22 0
94 82 175 0
-120 136 105 0
-156 168 26 0
-80 -24 128 0
167 106 10 0
77 161 62 0
-30 105 -86 0
170 179 -126 0
-9 -62 -104 0
41 52 1 0
136 -85 28 0
-140 146 -77 0
-62 75 -160 0
-23 106 -141 0
-101 -95 120 0
-140 72 1 0
-22 -161 -46 0
-162 -139 136 0
25 70 136 0
20 118 60 0
162 -45 -96 0
132 -98 -164 0
-18 -141 123 0
-44 65 177 0
-37 -129 -145 0
-37 -92 110 0
76 68 -111 0
144 -51 -155 0
93 94 98 0
49 3 8 0
-108 -43 -110 0
-20 132 71 0
-26 73 44 0
23 72 -5 0
117 71 -22 0
-25 47 157 0
-176 -86 -172 0
115 57 -135 0
-67 -140 139 0
125 165 172 0
109 67 -17 0
125 -87 -133 0
78 -33 25 0
-89 -116 37 0
137 127 42 0
-64 -25 -161 0
120 35 -141 0
71 111 14 0
106 160 -89 0
96 180 -41 0
109 65 -15 0
58 152 164 0
33 -79 74 0
-169 -71 172 0
-11 -163 -17 0
-22 76 2 0
-42 27 83 0
103 27 110 0
178 121 -110 0
-2 -128 166 0
-122 112 8 0
58 -143 -172 0
106 80 17 0
51 178 -82 0
-4 -162 -72 0
-50 -94 146 0
-20 138 -12 0
-135 -134 36 0
-166 32 37 0
39 -156 168 0
177 -173 -108 0
-52 66 -68 0
-74 -164 -11 0
120 168 -53 0
-63 1 130 0
50 56 -61 0
83 110 -101 0
51 -169 105 0
67 78 -179 0
-130 -177 -46 0
119 20 -48 0
-129 -26 168 0
162 105 -70 0
32 -38 10 0
142 145 -72 0
-37 -76 173 0
-35 79 61 0
121 -113 -35 0
145 -72 98 0
-90 -79 -121 0
11 92 -42 0
-177 144 -109 0
-33 -3 177 0
-151 77 -131 0
-138 175 -101 0
41 -49 -40 0
-7 71 -118 0
-167 -11 105 0
7 85 69 0
-122 -145 17 0
-149 28 -17 0
-111 78 27 0
172 -89 174 0
138 92 -174 0
88 -59 15 0
87 -26 47 0
-73 22 -133 0
-180 -144 -8 0
-19 155 55 0
8 102 -151 0
-55 -81 69 0
-142 -46 -80 0
-156 -24 146 0
92 72 -42 0
65 -37 -88 0
-177 -66 25 0
-164 166 38 0
126 53 -159 0
159 142 -29 0
-105 23 76 0
-44 133 180 0
-169 -16 -94 0
-103 -70 -112 0
-125 -135 -131 0
-7 21 -22 0
173 174 -18 0
146 32 106 0
-155 130 -127 0
-29 109 9 0
-95 -25 149 0
-59 162 -160 0
-20 33 163 0
-90 -56 -48 0
72 35 26 0
178 -87 -125 0
-144 -107 -122 0
-128 -71 -31 0
-20 -174 50 0
134 -13 -47 0
154 119 24 0
-144 173 -69 0
-61 -8 179 0
-7 -86 -160 0
170 -65 151 0
-88 -30 -35 0
-176 -8 49 0
-135 -44 114 0
-156 -61 -66 0
89 159 77 0
-22 -168 -8 0
-2 -119 -89 0
58 -82 137 0
170 108 -86 0
51 168 -62 0
-114 171 144 0
173 5 40 0
-17 -149 176 0
-114 -8 -42 0
-178 157 -46 0
-72 -82 -80 0
-136 -98 -2 0
39 -85 157 0
-10 104 -25 0
-86 -114 -102 0
-127 -109 -167 0
36 -164 -43 0
180 -7 162 0
-171 -145 175 0
12 177 -69 0
27 -91 159 0
-100 -105 -102 0
90 85 -119 0
75 30 157 0
-148 175 124 0
-106 -57 -133 0
-134 102 -129 0
-55 16 90 0
160 -120 49 0
153 -135 -71 0
87 -85 -27 0
3 -67 -10 0
-75 -161 51 0
17 67 -161 0
180 82 -139 0
87 102 96 0
144 6 -174 0
155 -32 -102 0
66 -105 -8 0
163 -173 -24 0
4 109 -73 0
-126 -53 175 0
98 156 99 0
61 -59 -71 0
-65 -102 -37 0
-40 -157 -179 0
-130 -110 -64 0
84 28 4 0
18 58 -175 0
115 -140 -141 0
14 65 24 0
101 -107 165 0
-9 154 -58 0
-16 -10 49 0
143 125 -174 0
27 99 -31 0
29 -94 -20 0
-173 22 -75 0
-124 7 -131 0
23 -147 110 0
58 -78 132 0
148 52 157 0
-101 176 -147 0
-87 93 -178 0
-90 169 121 0
5 -27 36 0
-121 144 171 0
-132 -22 31 0
155 27 173 0
-6 125 -32 0
-28 19 112 0
-93 4 77 0
-122 4 -131 0
75 15 -170 0
-94 -54 -100 0
4 50 163 0
-180 58 -5 0
154 54 -72 0
164 -66 -69 0
45 -77 117 0
59 -111 67 0
11 82 10 0
75 88 95 0
-12 -49 171 0
3 83 -12 0
2 153 -176 0
-46 110 64 0
-72 -81 -93 0
117 12 -28 0
75 127 -66 0
-54 -95 -72 0
155 133 148 0
40 156 -176 0
-114 175 95 0
-142 -169 135 0
177 -39 -143 0
162 -64 95 0
41 14 -6 0
114 -47 82 0
110 -70 25 0
-71 16 156 0
20 -96 60 0
16 -83 63 0
-165 -158 -50 0
160 -99 102 0
-55 110 66 0
1 -100 -6 0
34 -160 -100 0
172 54 -175 0
111 -152 99 0
-100 -139 -2 0
61 -58 84 0
121 59 36 0
-69 106 156 0
179 54 -120 0
-81 7 23 0
116 111 130 0
61 45 -149 0
-5 -7 -41 0
-124 -19 48 0
164 -50 -32 0
172 -49 -23 0
-121 -15 -124 0
-2 152 118 0
174 -132 18 0
151 -65 -19 0
59 131 18 0
-86 173 110 0
-94 -27 -151 0
47 24 -161 0
55 -91 -95 0
73 -15 -158 0
93 76 -159 0
-132 -29 81 0
130 165 -122 0
169 47 174 0
-152 -75 39 0
180 9 -107 0
-39 -50 -55 0
104 113 -40 0
127 -174 131 0
117 130 -77 0
-178 -27 168 0
-121 143 73 0
15 -141 -60 0
127 116 32 0
-146 92 50 0
128 72 -32 0
-167 -118 128 0
75 128 -155 0
-155 -75 -131 0
-137 176 -139 0
54 130 37 0
165 34 -68 0
22 2 -47 0
-178 -16 80 0
-170 175 100 0
-73 119 6 0
-159 -69 -88 0
7 169 32 0
-81 166 -21 0
-80 23 -94 0
-41 143 -99 0
-166 -82 23 0
61 -69 84 0
-169 31 126 0
-163 34 -180 0
-123 -29 -96 0
136 43 -57 0
76 -167 -155 0
-101 -2 120 0
-110 -23 -165 0
5 127 -117 0
-156 -13 77 0
-152 -76 -4 0
-73 98 -140 0
-46 109 -56 0
35 -30 157 0
144 6 -19 0
114 -105 44 0
-65 -46 157 0
135 -58 -128 0
26 22 39 0
110 34 23 0
-168 113 64 0
-77 -107 -125 0
103 50 -147 0
-105 1 -89 0
118 -154 9 0
-14 -67 -118 0
-45 -94 -55 0
125 69 -36 0
29 161 -25 0
112 -28 -78 0
148 170 96 0
-26 -71 126 0
-78 132 97 0
161 117 111 0
131 118 143 0
155 -111 -167 0
73 -92 -154 0
-32 -21 -173 0
-86 -123 -117 0
-56 107 91 0
-8 104 2 0
-90 -163 -167 0
-120 179 87 0
-158 56 -37 0
127 -95 -143 0
171 -179 -10 0
108 -171 -35 0
118 -154 -133 0
173 -143 -149 0
156 148 118 0
-115 78 -58 0
16 65 84 0
-76 123 125 0
37 -142 -27 0
-4 176 116 0
-94 95 170 0
22 80 92 0
143 17 -165 0
-80 -27 -162 0
-13 -152 35 0
119 -15 148 0
-162 -75 -111 0
-2 86 1 0
168 -83 -118 0
146 -36 -168 0
-121 -49 -155 0
29 173 38 0
75 -139 12 0
156 -82 1 0
-173 161 20 0
-15 88 105 0
166 -137 -21 0
118 -88 63 0
106 -138 -89 0
42 -26 -48 0
-36 -41 -103 0
142 -108 -119 0
115 144 84 0
1 102 -64 0
97 173 156 0
-52 163 -175 0
-127 139 -116 0
24 163 -75 0
-74 -105 31 0
-134 -101 -16 0
67 -167 112 0
-145 106 113 0
-33 -118 -59 0
16 62 -92 0
-37 5 -74 0
28 71 -130 0
-33 -18 134 0
59 76 -2 0
157 17 -127 0
-49 158 146 0
148 -24 169 0
25 -46 24 0
141 -36 -15 0
-111 129 -140 0
-68 43 -145 0
70 12 180 0
48 168 15 0
173 -159 46 0
-166 163 29 0
-19 51 95 0
134 2 64 0
-105 74 18 0
76 178 -4 0
-21 27 -12 0
143 -76 35 0
148 -19 -135 0
71 171 76 0
-171 70 156 0
43 -145 -175 0
7 86 -2 0
24 11 -83 0
-38 10 -100 0
99 -161 -164 0
51 68 -102 0
88 -173 -59 0
48 167 -6 0
160 -114 50 0
49 -164 54 0
113 -27 38 0
-51 -27 -140 0
-114 -175 152 0
-14 132 -107 0
129 173 152 0
33 -46 -156 0
49 29 -117 0
134 168 -57 0
-65 -100 -97 0
113 -116 -145 0
-48 -99 -123 0
-43 21 -148 0
103 13 43 0
-4 -165 89 0
30 -136 -35 0
-84 -112 85 0
95 -159 -8 0
175 12 -116 0
7 174 90 0
110 146 23 0
96 -28 -67 0
-49 -158 93 0
-83 -74 76 0
-179 180 -73 0
-107 141 -24 0
88 167 -163 0
34 -175 -87 0
-96 151 80 0
-107 3 19 0
-178 -79 166 0
-111 61 -167 0
-168 107 -132 0
96 -120 117 0
-25 -77 -6 0
-61 101 -141 0
115 -158 -6 0
-9 -171 135 0
-71 65 25 0
-57 -123 -172 0
-41 23 -99 0
121 -79 37 0
139 141 -69 0
107 62 -15 0
-23 149 62 0
135 -142 72 0
78 13 -8 0
152 -74 -149 0
95 -16 63 0
-72 105 -5 0
141 37 5 0
-98 -175 117 0
138 -50 -84 0
-115 126 -34 0
-169 -26 151 0
81 -59 9 0
-138 -134 165 0
154 2 1 0
102 40 -50 0
-178 -91 4 0
-130 71 -63 0
-26 -20 -65 0
-98 -120 48 0
-11 -53 -172 0
30 85 106 0
-42 58 -113 0
-151 -119 81 0
-55 83 102 0
"""
output = "SAT"
| input = '\nc num blocks = 1\nc num vars = 180\nc minblockids[0] = 1\nc maxblockids[0] = 180\np cnf 180 795\n5 49 137 0\n-146 -16 161 0\n-116 106 -77 0\n28 -33 -87 0\n-70 -56 -28 0\n123 76 88 0\n-160 128 45 0\n-29 169 180 0\n-96 -69 100 0\n56 82 -38 0\n-14 -108 -88 0\n-147 -93 4 0\n-130 6 38 0\n-50 -149 8 0\n142 -96 -68 0\n-104 47 168 0\n159 148 -128 0\n92 111 31 0\n-53 -137 65 0\n-55 147 -42 0\n24 127 92 0\n108 -13 171 0\n-73 -41 150 0\n-46 -29 -179 0\n28 52 -166 0\n2 -94 37 0\n154 -121 163 0\n3 167 135 0\n-86 171 -168 0\n-63 -39 -100 0\n158 -50 -151 0\n102 158 32 0\n-69 173 49 0\n112 -114 -125 0\n65 -23 -163 0\n-122 -110 -15 0\n-46 -8 -136 0\n-103 -39 -96 0\n85 -162 74 0\n-25 121 -37 0\n-50 -85 -147 0\n25 14 155 0\n62 -70 124 0\n-62 -160 -83 0\n116 -137 13 0\n166 62 61 0\n56 53 3 0\n-143 82 20 0\n100 89 53 0\n95 64 -142 0\n176 -74 -39 0\n155 156 163 0\n14 -96 32 0\n-88 -79 120 0\n95 152 70 0\n75 149 -50 0\n92 71 -156 0\n-41 -155 55 0\n-54 -144 -101 0\n60 -38 -75 0\n168 127 109 0\n52 98 -126 0\n171 129 -148 0\n-146 167 -22 0\n-39 -137 -76 0\n90 -96 12 0\n-132 110 -124 0\n130 -170 -82 0\n124 163 179 0\n144 -4 108 0\n-82 -144 -71 0\n156 15 -93 0\n20 -83 -78 0\n136 18 42 0\n-65 31 -41 0\n-21 -155 -138 0\n32 -131 112 0\n90 112 -66 0\n153 -52 -175 0\n-86 71 -96 0\n-73 68 -3 0\n-11 29 126 0\n-38 155 98 0\n150 127 146 0\n120 -136 108 0\n47 179 155 0\n169 158 129 0\n15 75 72 0\n169 137 64 0\n-14 -115 49 0\n-51 53 -172 0\n-2 -23 -33 0\n-79 148 2 0\n-27 -2 -73 0\n157 168 -71 0\n-113 66 14 0\n-77 -42 -12 0\n-39 99 -5 0\n-163 -21 81 0\n-2 -163 71 0\n11 126 -144 0\n-34 159 -43 0\n94 102 178 0\n-112 49 -133 0\n79 30 167 0\n-104 -103 -28 0\n-116 -125 -107 0\n-167 -62 130 0\n53 55 48 0\n77 21 114 0\n-31 138 -117 0\n-25 -88 -127 0\n66 -14 -29 0\n66 -89 159 0\n67 22 -14 0\n110 4 -117 0\n-8 -69 83 0\n142 -133 94 0\n61 146 -38 0\n136 165 -168 0\n142 -40 83 0\n103 50 165 0\n-10 -154 73 0\n122 50 -48 0\n-170 -164 24 0\n83 -53 -61 0\n7 -103 16 0\n81 -106 35 0\n80 -106 178 0\n161 173 -137 0\n-87 -145 2 0\n30 136 94 0\n59 -123 -61 0\n-28 -102 136 0\n-34 -175 -55 0\n138 2 77 0\n36 17 -175 0\n-123 -171 93 0\n92 -149 -180 0\n125 118 -59 0\n124 -30 -43 0\n8 -82 14 0\n166 -144 81 0\n-45 31 173 0\n-106 -43 -67 0\n87 113 -107 0\n78 94 -52 0\n-165 12 103 0\n155 -31 163 0\n178 -87 123 0\n102 17 -104 0\n1 -167 -104 0\n-160 13 -47 0\n-77 -149 24 0\n6 -76 -44 0\n-164 93 -82 0\n95 96 8 0\n-81 -24 94 0\n-55 -51 176 0\n-158 155 175 0\n-158 -166 -79 0\n-114 -10 -14 0\n140 -46 70 0\n-32 97 -3 0\n166 38 -133 0\n120 170 13 0\n102 -140 -150 0\n-179 60 -58 0\n-124 168 46 0\n-30 122 -124 0\n25 -91 79 0\n-80 -14 119 0\n-143 -44 86 0\n114 -148 15 0\n20 137 -78 0\n-41 6 106 0\n62 104 -83 0\n37 -176 92 0\n65 74 64 0\n86 33 120 0\n-180 166 -125 0\n-58 17 141 0\n-173 -95 -154 0\n69 179 78 0\n-178 126 -162 0\n75 97 25 0\n156 78 57 0\n-93 111 6 0\n-40 -29 -179 0\n125 51 22 0\n36 73 53 0\n-167 99 -117 0\n-122 130 72 0\n56 51 134 0\n65 66 -150 0\n-119 39 -135 0\n143 152 -111 0\n-17 25 7 0\n170 30 -11 0\n-130 36 161 0\n-180 -18 -40 0\n66 -28 159 0\n13 144 -21 0\n-168 80 -161 0\n153 -73 -30 0\n33 -171 173 0\n114 124 -148 0\n-156 32 -128 0\n179 164 -133 0\n-151 -157 162 0\n-72 -170 -147 0\n10 119 75 0\n-29 -12 -50 0\n-131 -130 -81 0\n-171 23 -162 0\n102 61 23 0\n-107 -67 -52 0\n85 -73 15 0\n-63 128 9 0\n98 -68 154 0\n29 111 -156 0\n-118 99 -15 0\n8 54 -174 0\n-151 174 133 0\n-155 139 -101 0\n-6 67 164 0\n37 -118 -46 0\n-139 86 -25 0\n37 5 -154 0\n-46 134 141 0\n87 -111 52 0\n129 -131 -91 0\n-120 126 -8 0\n63 38 -70 0\n-65 -89 -145 0\n101 -1 57 0\n-161 -115 -162 0\n7 157 39 0\n-42 174 180 0\n-20 53 14 0\n-177 75 112 0\n105 165 -26 0\n10 -119 -60 0\n-70 102 -8 0\n151 -134 113 0\n-116 75 175 0\n57 -43 133 0\n-161 163 159 0\n44 -26 -110 0\n-91 -118 -22 0\n133 46 -105 0\n89 144 -133 0\n41 153 113 0\n-102 -70 -111 0\n-93 131 -5 0\n108 55 129 0\n22 -115 173 0\n122 -151 97 0\n139 -36 -71 0\n48 -173 -59 0\n-91 -144 -71 0\n4 -146 -23 0\n83 -80 3 0\n126 -74 -60 0\n74 93 -101 0\n78 29 124 0\n83 -79 89 0\n5 20 88 0\n30 -154 67 0\n-175 -55 -31 0\n72 40 34 0\n-159 -161 -106 0\n175 57 72 0\n-53 106 6 0\n-72 -71 118 0\n-30 169 -116 0\n75 -160 88 0\n-41 -38 162 0\n-81 144 94 0\n50 107 -59 0\n15 -27 -56 0\n114 -3 -15 0\n180 -83 -119 0\n82 35 -30 0\n-47 148 127 0\n-177 56 -178 0\n-37 -175 -96 0\n-177 -23 36 0\n156 -108 -112 0\n9 24 -112 0\n99 -131 -124 0\n-91 26 -22 0\n94 82 175 0\n-120 136 105 0\n-156 168 26 0\n-80 -24 128 0\n167 106 10 0\n77 161 62 0\n-30 105 -86 0\n170 179 -126 0\n-9 -62 -104 0\n41 52 1 0\n136 -85 28 0\n-140 146 -77 0\n-62 75 -160 0\n-23 106 -141 0\n-101 -95 120 0\n-140 72 1 0\n-22 -161 -46 0\n-162 -139 136 0\n25 70 136 0\n20 118 60 0\n162 -45 -96 0\n132 -98 -164 0\n-18 -141 123 0\n-44 65 177 0\n-37 -129 -145 0\n-37 -92 110 0\n76 68 -111 0\n144 -51 -155 0\n93 94 98 0\n49 3 8 0\n-108 -43 -110 0\n-20 132 71 0\n-26 73 44 0\n23 72 -5 0\n117 71 -22 0\n-25 47 157 0\n-176 -86 -172 0\n115 57 -135 0\n-67 -140 139 0\n125 165 172 0\n109 67 -17 0\n125 -87 -133 0\n78 -33 25 0\n-89 -116 37 0\n137 127 42 0\n-64 -25 -161 0\n120 35 -141 0\n71 111 14 0\n106 160 -89 0\n96 180 -41 0\n109 65 -15 0\n58 152 164 0\n33 -79 74 0\n-169 -71 172 0\n-11 -163 -17 0\n-22 76 2 0\n-42 27 83 0\n103 27 110 0\n178 121 -110 0\n-2 -128 166 0\n-122 112 8 0\n58 -143 -172 0\n106 80 17 0\n51 178 -82 0\n-4 -162 -72 0\n-50 -94 146 0\n-20 138 -12 0\n-135 -134 36 0\n-166 32 37 0\n39 -156 168 0\n177 -173 -108 0\n-52 66 -68 0\n-74 -164 -11 0\n120 168 -53 0\n-63 1 130 0\n50 56 -61 0\n83 110 -101 0\n51 -169 105 0\n67 78 -179 0\n-130 -177 -46 0\n119 20 -48 0\n-129 -26 168 0\n162 105 -70 0\n32 -38 10 0\n142 145 -72 0\n-37 -76 173 0\n-35 79 61 0\n121 -113 -35 0\n145 -72 98 0\n-90 -79 -121 0\n11 92 -42 0\n-177 144 -109 0\n-33 -3 177 0\n-151 77 -131 0\n-138 175 -101 0\n41 -49 -40 0\n-7 71 -118 0\n-167 -11 105 0\n7 85 69 0\n-122 -145 17 0\n-149 28 -17 0\n-111 78 27 0\n172 -89 174 0\n138 92 -174 0\n88 -59 15 0\n87 -26 47 0\n-73 22 -133 0\n-180 -144 -8 0\n-19 155 55 0\n8 102 -151 0\n-55 -81 69 0\n-142 -46 -80 0\n-156 -24 146 0\n92 72 -42 0\n65 -37 -88 0\n-177 -66 25 0\n-164 166 38 0\n126 53 -159 0\n159 142 -29 0\n-105 23 76 0\n-44 133 180 0\n-169 -16 -94 0\n-103 -70 -112 0\n-125 -135 -131 0\n-7 21 -22 0\n173 174 -18 0\n146 32 106 0\n-155 130 -127 0\n-29 109 9 0\n-95 -25 149 0\n-59 162 -160 0\n-20 33 163 0\n-90 -56 -48 0\n72 35 26 0\n178 -87 -125 0\n-144 -107 -122 0\n-128 -71 -31 0\n-20 -174 50 0\n134 -13 -47 0\n154 119 24 0\n-144 173 -69 0\n-61 -8 179 0\n-7 -86 -160 0\n170 -65 151 0\n-88 -30 -35 0\n-176 -8 49 0\n-135 -44 114 0\n-156 -61 -66 0\n89 159 77 0\n-22 -168 -8 0\n-2 -119 -89 0\n58 -82 137 0\n170 108 -86 0\n51 168 -62 0\n-114 171 144 0\n173 5 40 0\n-17 -149 176 0\n-114 -8 -42 0\n-178 157 -46 0\n-72 -82 -80 0\n-136 -98 -2 0\n39 -85 157 0\n-10 104 -25 0\n-86 -114 -102 0\n-127 -109 -167 0\n36 -164 -43 0\n180 -7 162 0\n-171 -145 175 0\n12 177 -69 0\n27 -91 159 0\n-100 -105 -102 0\n90 85 -119 0\n75 30 157 0\n-148 175 124 0\n-106 -57 -133 0\n-134 102 -129 0\n-55 16 90 0\n160 -120 49 0\n153 -135 -71 0\n87 -85 -27 0\n3 -67 -10 0\n-75 -161 51 0\n17 67 -161 0\n180 82 -139 0\n87 102 96 0\n144 6 -174 0\n155 -32 -102 0\n66 -105 -8 0\n163 -173 -24 0\n4 109 -73 0\n-126 -53 175 0\n98 156 99 0\n61 -59 -71 0\n-65 -102 -37 0\n-40 -157 -179 0\n-130 -110 -64 0\n84 28 4 0\n18 58 -175 0\n115 -140 -141 0\n14 65 24 0\n101 -107 165 0\n-9 154 -58 0\n-16 -10 49 0\n143 125 -174 0\n27 99 -31 0\n29 -94 -20 0\n-173 22 -75 0\n-124 7 -131 0\n23 -147 110 0\n58 -78 132 0\n148 52 157 0\n-101 176 -147 0\n-87 93 -178 0\n-90 169 121 0\n5 -27 36 0\n-121 144 171 0\n-132 -22 31 0\n155 27 173 0\n-6 125 -32 0\n-28 19 112 0\n-93 4 77 0\n-122 4 -131 0\n75 15 -170 0\n-94 -54 -100 0\n4 50 163 0\n-180 58 -5 0\n154 54 -72 0\n164 -66 -69 0\n45 -77 117 0\n59 -111 67 0\n11 82 10 0\n75 88 95 0\n-12 -49 171 0\n3 83 -12 0\n2 153 -176 0\n-46 110 64 0\n-72 -81 -93 0\n117 12 -28 0\n75 127 -66 0\n-54 -95 -72 0\n155 133 148 0\n40 156 -176 0\n-114 175 95 0\n-142 -169 135 0\n177 -39 -143 0\n162 -64 95 0\n41 14 -6 0\n114 -47 82 0\n110 -70 25 0\n-71 16 156 0\n20 -96 60 0\n16 -83 63 0\n-165 -158 -50 0\n160 -99 102 0\n-55 110 66 0\n1 -100 -6 0\n34 -160 -100 0\n172 54 -175 0\n111 -152 99 0\n-100 -139 -2 0\n61 -58 84 0\n121 59 36 0\n-69 106 156 0\n179 54 -120 0\n-81 7 23 0\n116 111 130 0\n61 45 -149 0\n-5 -7 -41 0\n-124 -19 48 0\n164 -50 -32 0\n172 -49 -23 0\n-121 -15 -124 0\n-2 152 118 0\n174 -132 18 0\n151 -65 -19 0\n59 131 18 0\n-86 173 110 0\n-94 -27 -151 0\n47 24 -161 0\n55 -91 -95 0\n73 -15 -158 0\n93 76 -159 0\n-132 -29 81 0\n130 165 -122 0\n169 47 174 0\n-152 -75 39 0\n180 9 -107 0\n-39 -50 -55 0\n104 113 -40 0\n127 -174 131 0\n117 130 -77 0\n-178 -27 168 0\n-121 143 73 0\n15 -141 -60 0\n127 116 32 0\n-146 92 50 0\n128 72 -32 0\n-167 -118 128 0\n75 128 -155 0\n-155 -75 -131 0\n-137 176 -139 0\n54 130 37 0\n165 34 -68 0\n22 2 -47 0\n-178 -16 80 0\n-170 175 100 0\n-73 119 6 0\n-159 -69 -88 0\n7 169 32 0\n-81 166 -21 0\n-80 23 -94 0\n-41 143 -99 0\n-166 -82 23 0\n61 -69 84 0\n-169 31 126 0\n-163 34 -180 0\n-123 -29 -96 0\n136 43 -57 0\n76 -167 -155 0\n-101 -2 120 0\n-110 -23 -165 0\n5 127 -117 0\n-156 -13 77 0\n-152 -76 -4 0\n-73 98 -140 0\n-46 109 -56 0\n35 -30 157 0\n144 6 -19 0\n114 -105 44 0\n-65 -46 157 0\n135 -58 -128 0\n26 22 39 0\n110 34 23 0\n-168 113 64 0\n-77 -107 -125 0\n103 50 -147 0\n-105 1 -89 0\n118 -154 9 0\n-14 -67 -118 0\n-45 -94 -55 0\n125 69 -36 0\n29 161 -25 0\n112 -28 -78 0\n148 170 96 0\n-26 -71 126 0\n-78 132 97 0\n161 117 111 0\n131 118 143 0\n155 -111 -167 0\n73 -92 -154 0\n-32 -21 -173 0\n-86 -123 -117 0\n-56 107 91 0\n-8 104 2 0\n-90 -163 -167 0\n-120 179 87 0\n-158 56 -37 0\n127 -95 -143 0\n171 -179 -10 0\n108 -171 -35 0\n118 -154 -133 0\n173 -143 -149 0\n156 148 118 0\n-115 78 -58 0\n16 65 84 0\n-76 123 125 0\n37 -142 -27 0\n-4 176 116 0\n-94 95 170 0\n22 80 92 0\n143 17 -165 0\n-80 -27 -162 0\n-13 -152 35 0\n119 -15 148 0\n-162 -75 -111 0\n-2 86 1 0\n168 -83 -118 0\n146 -36 -168 0\n-121 -49 -155 0\n29 173 38 0\n75 -139 12 0\n156 -82 1 0\n-173 161 20 0\n-15 88 105 0\n166 -137 -21 0\n118 -88 63 0\n106 -138 -89 0\n42 -26 -48 0\n-36 -41 -103 0\n142 -108 -119 0\n115 144 84 0\n1 102 -64 0\n97 173 156 0\n-52 163 -175 0\n-127 139 -116 0\n24 163 -75 0\n-74 -105 31 0\n-134 -101 -16 0\n67 -167 112 0\n-145 106 113 0\n-33 -118 -59 0\n16 62 -92 0\n-37 5 -74 0\n28 71 -130 0\n-33 -18 134 0\n59 76 -2 0\n157 17 -127 0\n-49 158 146 0\n148 -24 169 0\n25 -46 24 0\n141 -36 -15 0\n-111 129 -140 0\n-68 43 -145 0\n70 12 180 0\n48 168 15 0\n173 -159 46 0\n-166 163 29 0\n-19 51 95 0\n134 2 64 0\n-105 74 18 0\n76 178 -4 0\n-21 27 -12 0\n143 -76 35 0\n148 -19 -135 0\n71 171 76 0\n-171 70 156 0\n43 -145 -175 0\n7 86 -2 0\n24 11 -83 0\n-38 10 -100 0\n99 -161 -164 0\n51 68 -102 0\n88 -173 -59 0\n48 167 -6 0\n160 -114 50 0\n49 -164 54 0\n113 -27 38 0\n-51 -27 -140 0\n-114 -175 152 0\n-14 132 -107 0\n129 173 152 0\n33 -46 -156 0\n49 29 -117 0\n134 168 -57 0\n-65 -100 -97 0\n113 -116 -145 0\n-48 -99 -123 0\n-43 21 -148 0\n103 13 43 0\n-4 -165 89 0\n30 -136 -35 0\n-84 -112 85 0\n95 -159 -8 0\n175 12 -116 0\n7 174 90 0\n110 146 23 0\n96 -28 -67 0\n-49 -158 93 0\n-83 -74 76 0\n-179 180 -73 0\n-107 141 -24 0\n88 167 -163 0\n34 -175 -87 0\n-96 151 80 0\n-107 3 19 0\n-178 -79 166 0\n-111 61 -167 0\n-168 107 -132 0\n96 -120 117 0\n-25 -77 -6 0\n-61 101 -141 0\n115 -158 -6 0\n-9 -171 135 0\n-71 65 25 0\n-57 -123 -172 0\n-41 23 -99 0\n121 -79 37 0\n139 141 -69 0\n107 62 -15 0\n-23 149 62 0\n135 -142 72 0\n78 13 -8 0\n152 -74 -149 0\n95 -16 63 0\n-72 105 -5 0\n141 37 5 0\n-98 -175 117 0\n138 -50 -84 0\n-115 126 -34 0\n-169 -26 151 0\n81 -59 9 0\n-138 -134 165 0\n154 2 1 0\n102 40 -50 0\n-178 -91 4 0\n-130 71 -63 0\n-26 -20 -65 0\n-98 -120 48 0\n-11 -53 -172 0\n30 85 106 0\n-42 58 -113 0\n-151 -119 81 0\n-55 83 102 0\n'
output = 'SAT' |
#Leia uma distancia em milhas e apresente-a convertida em quilometros.
#A formula de conversao eh K =M*1.61 ,
# sendo K a distancia em quilometros e M em milhas.
m=float(input("Informe a distancia em milhas: "))
K=m*1.61
print(f"A distancia convertida em km eh {K}km/h") | m = float(input('Informe a distancia em milhas: '))
k = m * 1.61
print(f'A distancia convertida em km eh {K}km/h') |
"""
Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
Input: [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s.
The maximum number of consecutive 1s is 3.
Note:
The input array will only contain 0 and 1.
The length of input array is a positive integer and will not exceed 10,000
Your runtime beats 83.76 % of python submissions.
"""
class Solution(object):
def findMaxConsecutiveOnes(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
#Method 1
maxval = 0
counter = 0
for i in range(len(nums)):
if nums[i] == 1:
counter += 1
if i == len(nums)-1:
if counter > maxval: maxval = counter
else:
if counter > maxval: maxval = counter
counter = 0
return maxval
# #Method 2
return len(max(str(nums)[1:-1].replace(", ", "").split("0")))
| """
Given a binary array, find the maximum number of consecutive 1s in this array.
Example 1:
Input: [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s.
The maximum number of consecutive 1s is 3.
Note:
The input array will only contain 0 and 1.
The length of input array is a positive integer and will not exceed 10,000
Your runtime beats 83.76 % of python submissions.
"""
class Solution(object):
def find_max_consecutive_ones(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
maxval = 0
counter = 0
for i in range(len(nums)):
if nums[i] == 1:
counter += 1
if i == len(nums) - 1:
if counter > maxval:
maxval = counter
else:
if counter > maxval:
maxval = counter
counter = 0
return maxval
return len(max(str(nums)[1:-1].replace(', ', '').split('0'))) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def pruneTree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
def contain1(root):
if not root:
return False
left = contain1(root.left)
right = contain1(root.right)
if not left:
root.left = None
if not right:
root.right = None
return left or right or root.val == 1
return root if contain1(root) else None
| class Solution:
def prune_tree(self, root):
"""
:type root: TreeNode
:rtype: TreeNode
"""
def contain1(root):
if not root:
return False
left = contain1(root.left)
right = contain1(root.right)
if not left:
root.left = None
if not right:
root.right = None
return left or right or root.val == 1
return root if contain1(root) else None |
class TaskType:
JOINT = 'joint'
MENTION_LOCALIZATION = 'mention_localization'
COREFERENCE_RESOLUTION = 'coreference_resolution'
ENTITY_CLASSIFICATION = 'entity_classification'
RELATION_CLASSIFICATION = 'rel_classification'
| class Tasktype:
joint = 'joint'
mention_localization = 'mention_localization'
coreference_resolution = 'coreference_resolution'
entity_classification = 'entity_classification'
relation_classification = 'rel_classification' |
def multiuply(multiplyer,multiplycant):
result = multiplyer * multiplycant
return result
answer = multiuply(10.5,4)
print(answer)
print (multiuply(8,10))
def __init__(self):
return(__init__+3) | def multiuply(multiplyer, multiplycant):
result = multiplyer * multiplycant
return result
answer = multiuply(10.5, 4)
print(answer)
print(multiuply(8, 10))
def __init__(self):
return __init__ + 3 |
"""
Set up Google authentication parameters here.
"""
#GOOGLE_AUTH = {
# 'account': '<gmail address>',
# 'password': '<password>',
#}
| """
Set up Google authentication parameters here.
""" |
RECURSE_INTO = {
"p",
"blockquote",
"div",
"em",
"i",
"b",
"u",
"strong",
"h2",
"figure",
}
INCLUDE_TAGNAME = {
"blockquote",
"em",
"i",
"b",
"u",
"strong",
"h2",
}
INCLUDE_VERBATIM = {"li", "ul", "ol"}
NEWLINE_AFTER = {
"blockquote",
"h2",
}
DOUBLE_NEWLINE_AFTER = {"p", "br", "img"}
AVOID = {
"header",
}
USE_IMAGE_ANALYSIS = {"img"}
| recurse_into = {'p', 'blockquote', 'div', 'em', 'i', 'b', 'u', 'strong', 'h2', 'figure'}
include_tagname = {'blockquote', 'em', 'i', 'b', 'u', 'strong', 'h2'}
include_verbatim = {'li', 'ul', 'ol'}
newline_after = {'blockquote', 'h2'}
double_newline_after = {'p', 'br', 'img'}
avoid = {'header'}
use_image_analysis = {'img'} |
def first_check():
pass
def second_check():
pass
def main():
print('badge checks TODO')
first_check()
second_check()
if __name__ == "__main__":
main()
| def first_check():
pass
def second_check():
pass
def main():
print('badge checks TODO')
first_check()
second_check()
if __name__ == '__main__':
main() |
# Copyright 2015 The LUCI Authors. All rights reserved.
# Use of this source code is governed under the Apache License, Version 2.0
# that can be found in the LICENSE file.
"""Tests that step_data can accept multiple specs at once."""
DEPS = [
'step',
]
def RunSteps(api):
raise TypeError("BAD DOGE")
def GenTests(api):
yield (
api.test('basic') +
api.expect_exception('TypeError')
)
| """Tests that step_data can accept multiple specs at once."""
deps = ['step']
def run_steps(api):
raise type_error('BAD DOGE')
def gen_tests(api):
yield (api.test('basic') + api.expect_exception('TypeError')) |
''' Print Asterisks
Write a program that can print the line of asterisks. I have to define a founction called printAsterisks(). This finction should take single argument/parameter. This argument will take an interger value that represents the number of asterisks. My program should print the number of asterisks on a single line based on supplied integer value.
'''
def printAsterisks(N):
print("*" * N) # **********
# main program starts here
printAsterisks(10) # When the app is run [printAsterisks(10)] replaces the N on line 5 with [10], then the print statement replaces it,s N with 10, and then prints out 10 asterisks as shown.
| """ Print Asterisks
Write a program that can print the line of asterisks. I have to define a founction called printAsterisks(). This finction should take single argument/parameter. This argument will take an interger value that represents the number of asterisks. My program should print the number of asterisks on a single line based on supplied integer value.
"""
def print_asterisks(N):
print('*' * N)
print_asterisks(10) |
N = int(input())
L = len(str(N))
ans = 0
for i in range(2, L+1, 2):
if i == L:
head = int(str(N)[:i//2])
tail = int(str(N)[i//2:])
if head <= 9:
if head > tail:
head -= 1
ans += head
else:
if head > tail:
head -= 1
ans += max(0, head-ans)
else:
ans += 9*int('1'+'0'*((i//2)-1))
print(ans)
| n = int(input())
l = len(str(N))
ans = 0
for i in range(2, L + 1, 2):
if i == L:
head = int(str(N)[:i // 2])
tail = int(str(N)[i // 2:])
if head <= 9:
if head > tail:
head -= 1
ans += head
else:
if head > tail:
head -= 1
ans += max(0, head - ans)
else:
ans += 9 * int('1' + '0' * (i // 2 - 1))
print(ans) |
#
# Copyright 2017 Google Inc. 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.
#
{
'includes' : [
'../common.gypi',
],
'target_defaults': {
'type': 'static_library',
'includes' : [
'../dev/target_visibility.gypi',
],
'conditions': [
['OS == "nacl"', {
'link_settings': {
'libraries': [
'-lnacl_io',
],
},
}],
], # conditions
},
'targets' : [
{
'target_name' : 'remote_assets',
'type': 'static_library',
'includes' : [
'../dev/zipasset_generator.gypi',
],
'sources': [
'res/calltrace.iad',
'res/nodegraph.iad',
'res/resources.iad',
'res/root.iad',
'res/settings.iad',
'res/shader_editor.iad',
'res/tracing.iad',
# Excluded conditionally below.
'res/geturi_asmjs.iad',
'res/geturi_cc.iad',
],
'conditions': [
['OS in ["asmjs", "nacl"]', {
'sources!': [
'res/geturi_cc.iad',
],
}, { # else
'sources!': [
'res/geturi_asmjs.iad',
],
}],
], # conditions
'dependencies' : [
'<(ion_dir)/port/port.gyp:ionport',
],
},
{
'target_name' : 'ionremote',
'sources': [
'calltracehandler.cc',
'calltracehandler.h',
'httpserver.cc',
'httpserver.h',
'nodegraphhandler.cc',
'nodegraphhandler.h',
'remoteserver.cc',
'remoteserver.h',
'resourcehandler.cc',
'resourcehandler.h',
'settinghandler.cc',
'settinghandler.h',
'shaderhandler.cc',
'shaderhandler.h',
'tracinghandler.cc',
'tracinghandler.h',
],
'dependencies': [
':remote_assets',
'<(ion_dir)/analytics/analytics.gyp:ionanalytics',
'<(ion_dir)/base/base.gyp:ionbase',
'<(ion_dir)/external/external.gyp:ionmongoose',
'<(ion_dir)/external/external.gyp:ionstblib',
'<(ion_dir)/external/external.gyp:ionzlib',
'<(ion_dir)/external/imagecompression.gyp:ionimagecompression',
'<(ion_dir)/gfx/gfx.gyp:iongfx',
'<(ion_dir)/gfxprofile/gfxprofile.gyp:iongfxprofile',
'<(ion_dir)/gfxutils/gfxutils.gyp:iongfxutils',
'<(ion_dir)/image/image.gyp:ionimage',
'<(ion_dir)/port/port.gyp:ionport',
'<(ion_dir)/portgfx/portgfx.gyp:ionportgfx',
'<(ion_dir)/profile/profile.gyp:ionprofile',
],
},
{
'target_name': 'ionremote_test_utils',
'type': 'static_library',
'sources': [
'tests/getunusedport.cc',
'tests/getunusedport.h',
],
'dependencies' : [
'<(ion_dir)/base/base.gyp:ionbase_for_tests',
],
}, # target: ionremote_test_utils
{
'target_name': 'ionremote_for_tests',
'type': 'static_library',
'sources': [
'tests/getunusedport.cc',
'tests/getunusedport.h',
'tests/httpservertest.h',
],
'dependencies' : [
':httpclient',
':ionremote',
':ionremote_test_utils',
':portutils',
'<(ion_dir)/base/base.gyp:ionbase_for_tests',
'<(ion_dir)/gfx/gfx.gyp:iongfx_for_tests',
'<(ion_dir)/gfxutils/gfxutils.gyp:iongfxutils_for_tests',
'<(ion_dir)/image/image.gyp:ionimage_for_tests',
'<(ion_dir)/portgfx/portgfx.gyp:ionportgfx_for_tests',
],
}, # target: ionremote_for_tests
{
'target_name': 'httpclient',
'type': 'static_library',
'sources': [
'httpclient.cc',
'httpclient.h',
],
'dependencies': [
':remote_assets',
'<(ion_dir)/base/base.gyp:ionbase',
'<(ion_dir)/port/port.gyp:ionport',
'<(ion_dir)/external/external.gyp:ionmongoose',
],
}, # target: httpclient
{
'target_name': 'portutils',
'type': 'static_library',
'sources': [
'portutils.cc',
'portutils.h',
],
'dependencies': [
'<(ion_dir)/base/base.gyp:ionbase',
'<(ion_dir)/port/port.gyp:ionport',
],
}, # target: portutils
],
}
| {'includes': ['../common.gypi'], 'target_defaults': {'type': 'static_library', 'includes': ['../dev/target_visibility.gypi'], 'conditions': [['OS == "nacl"', {'link_settings': {'libraries': ['-lnacl_io']}}]]}, 'targets': [{'target_name': 'remote_assets', 'type': 'static_library', 'includes': ['../dev/zipasset_generator.gypi'], 'sources': ['res/calltrace.iad', 'res/nodegraph.iad', 'res/resources.iad', 'res/root.iad', 'res/settings.iad', 'res/shader_editor.iad', 'res/tracing.iad', 'res/geturi_asmjs.iad', 'res/geturi_cc.iad'], 'conditions': [['OS in ["asmjs", "nacl"]', {'sources!': ['res/geturi_cc.iad']}, {'sources!': ['res/geturi_asmjs.iad']}]], 'dependencies': ['<(ion_dir)/port/port.gyp:ionport']}, {'target_name': 'ionremote', 'sources': ['calltracehandler.cc', 'calltracehandler.h', 'httpserver.cc', 'httpserver.h', 'nodegraphhandler.cc', 'nodegraphhandler.h', 'remoteserver.cc', 'remoteserver.h', 'resourcehandler.cc', 'resourcehandler.h', 'settinghandler.cc', 'settinghandler.h', 'shaderhandler.cc', 'shaderhandler.h', 'tracinghandler.cc', 'tracinghandler.h'], 'dependencies': [':remote_assets', '<(ion_dir)/analytics/analytics.gyp:ionanalytics', '<(ion_dir)/base/base.gyp:ionbase', '<(ion_dir)/external/external.gyp:ionmongoose', '<(ion_dir)/external/external.gyp:ionstblib', '<(ion_dir)/external/external.gyp:ionzlib', '<(ion_dir)/external/imagecompression.gyp:ionimagecompression', '<(ion_dir)/gfx/gfx.gyp:iongfx', '<(ion_dir)/gfxprofile/gfxprofile.gyp:iongfxprofile', '<(ion_dir)/gfxutils/gfxutils.gyp:iongfxutils', '<(ion_dir)/image/image.gyp:ionimage', '<(ion_dir)/port/port.gyp:ionport', '<(ion_dir)/portgfx/portgfx.gyp:ionportgfx', '<(ion_dir)/profile/profile.gyp:ionprofile']}, {'target_name': 'ionremote_test_utils', 'type': 'static_library', 'sources': ['tests/getunusedport.cc', 'tests/getunusedport.h'], 'dependencies': ['<(ion_dir)/base/base.gyp:ionbase_for_tests']}, {'target_name': 'ionremote_for_tests', 'type': 'static_library', 'sources': ['tests/getunusedport.cc', 'tests/getunusedport.h', 'tests/httpservertest.h'], 'dependencies': [':httpclient', ':ionremote', ':ionremote_test_utils', ':portutils', '<(ion_dir)/base/base.gyp:ionbase_for_tests', '<(ion_dir)/gfx/gfx.gyp:iongfx_for_tests', '<(ion_dir)/gfxutils/gfxutils.gyp:iongfxutils_for_tests', '<(ion_dir)/image/image.gyp:ionimage_for_tests', '<(ion_dir)/portgfx/portgfx.gyp:ionportgfx_for_tests']}, {'target_name': 'httpclient', 'type': 'static_library', 'sources': ['httpclient.cc', 'httpclient.h'], 'dependencies': [':remote_assets', '<(ion_dir)/base/base.gyp:ionbase', '<(ion_dir)/port/port.gyp:ionport', '<(ion_dir)/external/external.gyp:ionmongoose']}, {'target_name': 'portutils', 'type': 'static_library', 'sources': ['portutils.cc', 'portutils.h'], 'dependencies': ['<(ion_dir)/base/base.gyp:ionbase', '<(ion_dir)/port/port.gyp:ionport']}]} |
w = grenal = inter = gremio = empates = 0
while w == 0:
grenal += 1
g1, g2 = input().split(' ')
g1 = int(g1)
g2 = int(g2)
if g1 == g2:
empates += 1
elif g1 > g2:
inter += 1
else:
gremio += 1
print('Novo grenal (1-sim 2-nao)')
op = int(input())
if op == 2:
w = 1
print('{} grenais'.format(grenal))
print('Inter:{}'.format(inter))
print('Gremio:{}'.format(gremio))
print('Empates:{}'.format(empates))
if(inter > gremio):
print('Inter venceu mais')
else:
print('Gremio venceu mais') | w = grenal = inter = gremio = empates = 0
while w == 0:
grenal += 1
(g1, g2) = input().split(' ')
g1 = int(g1)
g2 = int(g2)
if g1 == g2:
empates += 1
elif g1 > g2:
inter += 1
else:
gremio += 1
print('Novo grenal (1-sim 2-nao)')
op = int(input())
if op == 2:
w = 1
print('{} grenais'.format(grenal))
print('Inter:{}'.format(inter))
print('Gremio:{}'.format(gremio))
print('Empates:{}'.format(empates))
if inter > gremio:
print('Inter venceu mais')
else:
print('Gremio venceu mais') |
"""
Soft Actor Critic (SAC) Control
===============================
"""
| """
Soft Actor Critic (SAC) Control
===============================
""" |
# Copyright 2021 Kotaro Terada
#
# 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.
# Model Types
MODEL_ISING = "ising"
MODEL_QUBO = "qubo"
# Interaction Body Types
INTERACTION_LINEAR = 1 # 1-body
INTERACTION_QUADRATIC = 2 # 2-body
# Default label for Constraints
DEFAULT_LABEL_N_HOT = "Default N-hot Constraint"
DEFAULT_LABEL_EQUALITY = "Default Equality Constraint"
DEFAULT_LABEL_0_OR_1_HOT = "Default Zero-or-One-hot Constraint"
# Select format
SELECT_SERIES = "series"
SELECT_DICT = "dict"
# Algorithms
ALGORITHM_ATTENUATION = "attenuation"
ALGORITHM_DELTA = "delta"
ALGORITHM_INCREMENTAL = "incremental"
ALGORITHM_PARTIAL = "partial"
ALGORITHM_WINDOW = "window"
# Pick-up mode for Sawatabi Solver
PICKUP_MODE_RANDOM = "random"
PICKUP_MODE_SEQUENTIAL = "sequential"
| model_ising = 'ising'
model_qubo = 'qubo'
interaction_linear = 1
interaction_quadratic = 2
default_label_n_hot = 'Default N-hot Constraint'
default_label_equality = 'Default Equality Constraint'
default_label_0_or_1_hot = 'Default Zero-or-One-hot Constraint'
select_series = 'series'
select_dict = 'dict'
algorithm_attenuation = 'attenuation'
algorithm_delta = 'delta'
algorithm_incremental = 'incremental'
algorithm_partial = 'partial'
algorithm_window = 'window'
pickup_mode_random = 'random'
pickup_mode_sequential = 'sequential' |
query = """
select * from languages;
"""
query = """
select *
from games
where test=0
"""
def get_query1():
query = (
f"SELEct max(weight) from world where ocean='Atlantic' and water is not null"
)
return query
def get_query2():
limit = 6
query = f"SELEct speed from world where animal='dolphin' limit {limit}"
return query
def get_query3():
query = 'select 5'
return query
| query = '\n select * from languages;\n'
query = '\n select *\n from games\n where test=0\n'
def get_query1():
query = f"SELEct max(weight) from world where ocean='Atlantic' and water is not null"
return query
def get_query2():
limit = 6
query = f"SELEct speed from world where animal='dolphin' limit {limit}"
return query
def get_query3():
query = 'select 5'
return query |
# Write a Python program to multiplies all the items in a list.
def multiply_list(items):
multiply_numbers = 1
for x in items:
multiply_numbers *= x
return multiply_numbers
print(multiply_list([5,2,-8])) | def multiply_list(items):
multiply_numbers = 1
for x in items:
multiply_numbers *= x
return multiply_numbers
print(multiply_list([5, 2, -8])) |
def _jar_jar_impl(ctx):
ctx.action(
inputs=[ctx.file.rules, ctx.file.input_jar],
outputs=[ctx.outputs.jar],
executable=ctx.executable._jarjar_runner,
progress_message="jarjar %s" % ctx.label,
arguments=["process", ctx.file.rules.path, ctx.file.input_jar.path, ctx.outputs.jar.path])
return JavaInfo(
output_jar = ctx.outputs.jar,
compile_jar = ctx.outputs.jar
)
jar_jar = rule(
implementation = _jar_jar_impl,
attrs = {
"input_jar": attr.label(allow_files=True, single_file=True),
"rules": attr.label(allow_files=True, single_file=True),
"_jarjar_runner": attr.label(executable=True, cfg="host", default=Label("@com_github_johnynek_bazel_jar_jar//:jarjar_runner")),
},
outputs = {
"jar": "%{name}.jar"
},
provides = [JavaInfo])
def _mvn_name(coord):
nocolon = "_".join(coord.split(":"))
nodot = "_".join(nocolon.split("."))
nodash = "_".join(nodot.split("-"))
return nodash
def _mvn_jar(coord, sha, bname, serv):
nm = _mvn_name(coord)
native.maven_jar(
name = nm,
artifact = coord,
sha1 = sha,
server = serv
)
native.bind(name=("com_github_johnynek_bazel_jar_jar/%s" % bname), actual = "@%s//jar" % nm)
def jar_jar_repositories(server=None):
_mvn_jar(
"org.pantsbuild:jarjar:1.6.3",
"cf54d4b142f5409c394095181c8d308a81869622",
"jarjar",
server)
_mvn_jar(
"org.ow2.asm:asm:5.0.4",
"0da08b8cce7bbf903602a25a3a163ae252435795",
"asm",
server)
_mvn_jar(
"org.ow2.asm:asm-commons:5.0.4",
"5a556786086c23cd689a0328f8519db93821c04c",
"asm_commons",
server)
| def _jar_jar_impl(ctx):
ctx.action(inputs=[ctx.file.rules, ctx.file.input_jar], outputs=[ctx.outputs.jar], executable=ctx.executable._jarjar_runner, progress_message='jarjar %s' % ctx.label, arguments=['process', ctx.file.rules.path, ctx.file.input_jar.path, ctx.outputs.jar.path])
return java_info(output_jar=ctx.outputs.jar, compile_jar=ctx.outputs.jar)
jar_jar = rule(implementation=_jar_jar_impl, attrs={'input_jar': attr.label(allow_files=True, single_file=True), 'rules': attr.label(allow_files=True, single_file=True), '_jarjar_runner': attr.label(executable=True, cfg='host', default=label('@com_github_johnynek_bazel_jar_jar//:jarjar_runner'))}, outputs={'jar': '%{name}.jar'}, provides=[JavaInfo])
def _mvn_name(coord):
nocolon = '_'.join(coord.split(':'))
nodot = '_'.join(nocolon.split('.'))
nodash = '_'.join(nodot.split('-'))
return nodash
def _mvn_jar(coord, sha, bname, serv):
nm = _mvn_name(coord)
native.maven_jar(name=nm, artifact=coord, sha1=sha, server=serv)
native.bind(name='com_github_johnynek_bazel_jar_jar/%s' % bname, actual='@%s//jar' % nm)
def jar_jar_repositories(server=None):
_mvn_jar('org.pantsbuild:jarjar:1.6.3', 'cf54d4b142f5409c394095181c8d308a81869622', 'jarjar', server)
_mvn_jar('org.ow2.asm:asm:5.0.4', '0da08b8cce7bbf903602a25a3a163ae252435795', 'asm', server)
_mvn_jar('org.ow2.asm:asm-commons:5.0.4', '5a556786086c23cd689a0328f8519db93821c04c', 'asm_commons', server) |
def square(a):
return a * a
print(square(4))
| def square(a):
return a * a
print(square(4)) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This is Blogofile -- http://www.Blogofile.com
Definition: Blogophile --
A person who is fond of or obsessed with blogs or blogging.
Definition: Blogofile --
A static file blog engine/compiler, inspired by Jekyll.
Blogofile transforms a set of templates into an entire blog consisting of static
HTML files. All categories, tags, RSS/Atom feeds are automatically maintained by
Blogofile. This blog can be hosted on any HTTP web server. Since the blog is
just HTML, CSS, and Javascript, no CGI environment, or database is required.
With the addition of a of third-party comment and trackback provider (like
Disqus or IntenseDebate) a modern and interactive blog can be hosted very
inexpensively.
Please take a moment to read LICENSE.txt. It's short.
"""
__author__ = "Ryan McGuire (ryan@enigmacurry.com)"
__version__ = '1.0.0-DEV'
| """
This is Blogofile -- http://www.Blogofile.com
Definition: Blogophile --
A person who is fond of or obsessed with blogs or blogging.
Definition: Blogofile --
A static file blog engine/compiler, inspired by Jekyll.
Blogofile transforms a set of templates into an entire blog consisting of static
HTML files. All categories, tags, RSS/Atom feeds are automatically maintained by
Blogofile. This blog can be hosted on any HTTP web server. Since the blog is
just HTML, CSS, and Javascript, no CGI environment, or database is required.
With the addition of a of third-party comment and trackback provider (like
Disqus or IntenseDebate) a modern and interactive blog can be hosted very
inexpensively.
Please take a moment to read LICENSE.txt. It's short.
"""
__author__ = 'Ryan McGuire (ryan@enigmacurry.com)'
__version__ = '1.0.0-DEV' |
#!/usr/bin/env python
NAME = 'SiteGround (SiteGround)'
def is_waf(self):
for attack in self.attacks:
r = attack(self)
if r is None:
return
_, page = r
if any(i in page for i in (b'Our system thinks you might be a robot!',
b'The page you are trying to access is restricted due to a security rule')):
return True
return False | name = 'SiteGround (SiteGround)'
def is_waf(self):
for attack in self.attacks:
r = attack(self)
if r is None:
return
(_, page) = r
if any((i in page for i in (b'Our system thinks you might be a robot!', b'The page you are trying to access is restricted due to a security rule'))):
return True
return False |
class Solution:
def solve(self, a, b):
def multiply(x,y,c):
m = x*y + c
return m//10,m%10
e1,e2 = -1,-1
si = 1
if a[0] == "-":
e1 = 0
si *=-1
if b[0] == "-":
e2 = 0
si *=-1
n1 = len(a)
n2 = len(b)
final = 0
ans = ""
c = 0
k = ""
for i in range(n1-1,e1,-1):
for j in range(n2-1,e2,-1):
c,s = multiply(int(a[i]),int(b[j]),c)
ans = str(s) + ans
if c:
ans = str(c) + ans
final += int(ans)
ans = k + "0"
k += "0"
c = 0
final *= si
return str(final)
| class Solution:
def solve(self, a, b):
def multiply(x, y, c):
m = x * y + c
return (m // 10, m % 10)
(e1, e2) = (-1, -1)
si = 1
if a[0] == '-':
e1 = 0
si *= -1
if b[0] == '-':
e2 = 0
si *= -1
n1 = len(a)
n2 = len(b)
final = 0
ans = ''
c = 0
k = ''
for i in range(n1 - 1, e1, -1):
for j in range(n2 - 1, e2, -1):
(c, s) = multiply(int(a[i]), int(b[j]), c)
ans = str(s) + ans
if c:
ans = str(c) + ans
final += int(ans)
ans = k + '0'
k += '0'
c = 0
final *= si
return str(final) |
# Copyright 2015 by Hurricane Labs LLC
#
# 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.
"""HTTPStatus exception class."""
class HTTPStatus(Exception):
"""Represents a generic HTTP status.
Raise an instance of this class from a hook, middleware, or
responder to short-circuit request processing in a manner similar
to ``falcon.HTTPError``, but for non-error status codes.
Attributes:
status (str): HTTP status line, e.g. '748 Confounded by Ponies'.
headers (dict): Extra headers to add to the response.
body (str or unicode): String representing response content. If
Unicode, Falcon will encode as UTF-8 in the response.
Args:
status (str): HTTP status code and text, such as
'748 Confounded by Ponies'.
headers (dict): Extra headers to add to the response.
body (str or unicode): String representing response content. If
Unicode, Falcon will encode as UTF-8 in the response.
"""
__slots__ = (
'status',
'headers',
'body'
)
def __init__(self, status, headers=None, body=None):
self.status = status
self.headers = headers
self.body = body
| """HTTPStatus exception class."""
class Httpstatus(Exception):
"""Represents a generic HTTP status.
Raise an instance of this class from a hook, middleware, or
responder to short-circuit request processing in a manner similar
to ``falcon.HTTPError``, but for non-error status codes.
Attributes:
status (str): HTTP status line, e.g. '748 Confounded by Ponies'.
headers (dict): Extra headers to add to the response.
body (str or unicode): String representing response content. If
Unicode, Falcon will encode as UTF-8 in the response.
Args:
status (str): HTTP status code and text, such as
'748 Confounded by Ponies'.
headers (dict): Extra headers to add to the response.
body (str or unicode): String representing response content. If
Unicode, Falcon will encode as UTF-8 in the response.
"""
__slots__ = ('status', 'headers', 'body')
def __init__(self, status, headers=None, body=None):
self.status = status
self.headers = headers
self.body = body |
# %% [markdown]
# # 1 - Print
# %% [markdown]
# `print()` is build in function in python that takes any type of object as it's parameter
#
# The [print](https://docs.python.org/3/library/functions.html#print) function let's you send an output to the terminal
#
#
# Python [built-in functions](https://docs.python.org/3/library/functions.html)
# %%
print("Hello, World!")
# %% [markdown]
# You can enclose strings in **double** quotes (" ") or **single** quotes (' ')
# %%
print('Hello, World!')
# %% [markdown]
# In case you have to use a signle quote in a string (for example: I'm a string) you can use the escape sequence (\) or use double quotes for the string
# %%
print("I'm a string")
print('I\'m a string')
# %% [markdown]
# You can combine strings with + or , <br />
# The difference is that + concatenates strings, while , joins strings
# %%
# Concatinate strings with sign +
print("Hello, " + "World!")
print("Hello,", "World!", "!")
# %% [markdown]
# How to print a new line in python?
# %%
print("Hello, World!")
# print a blank line
print()
print("This is a new line")
# %%
# print a line with \n
# \n is a special character sequence that tells Python to start a new line
print("This is the first line \nThis is the second line")
# %%
# print a line with a tab
print("This is a regular line")
print("\tThis is a new line with a tab")
# %% [markdown]
# Another usefull built-in function in python is `input()` <br />
# It allows you to prompt the user to input a value <br />
# But you need to declare a variable to hold the user's value in it
# %%
# Here name is variable that will hold the user's input
name = input("Please eneter your name: ")
print("Your name is:", name) | print('Hello, World!')
print('Hello, World!')
print("I'm a string")
print("I'm a string")
print('Hello, ' + 'World!')
print('Hello,', 'World!', '!')
print('Hello, World!')
print()
print('This is a new line')
print('This is the first line \nThis is the second line')
print('This is a regular line')
print('\tThis is a new line with a tab')
name = input('Please eneter your name: ')
print('Your name is:', name) |
#
# PySNMP MIB module AC-PM-ATM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AC-PM-ATM-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 16:54:33 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
Integer, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsUnion, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection", "ValueRangeConstraint")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Bits, Counter32, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, MibIdentifier, NotificationType, iso, Integer32, ObjectIdentity, ModuleIdentity, Counter64, IpAddress, TimeTicks, enterprises = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "Counter32", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "MibIdentifier", "NotificationType", "iso", "Integer32", "ObjectIdentity", "ModuleIdentity", "Counter64", "IpAddress", "TimeTicks", "enterprises")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
audioCodes = MibIdentifier((1, 3, 6, 1, 4, 1, 5003))
acRegistrations = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 7))
acGeneric = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 8))
acProducts = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 9))
acPerformance = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 10))
acPMAtm = ModuleIdentity((1, 3, 6, 1, 4, 1, 5003, 10, 12))
if mibBuilder.loadTexts: acPMAtm.setLastUpdated('200601261643Z')
if mibBuilder.loadTexts: acPMAtm.setOrganization('AudioCodes Ltd')
acPMAtmConfiguration = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1))
acPMAtmConfigurationPeriodLength = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 894780))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: acPMAtmConfigurationPeriodLength.setStatus('current')
acPMAtmConfigurationResetTotalCounters = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("resetCountersDone", 1), ("resetTotalCounters", 2)))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: acPMAtmConfigurationResetTotalCounters.setStatus('current')
acPMAtmCellAttributes = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31))
acPMAtmCellAttributesTxHighThreshold = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 3000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: acPMAtmCellAttributesTxHighThreshold.setStatus('current')
acPMAtmCellAttributesTxLowThreshold = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 3000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: acPMAtmCellAttributesTxLowThreshold.setStatus('current')
acPMAtmCellAttributesRxHighThreshold = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 3000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: acPMAtmCellAttributesRxHighThreshold.setStatus('current')
acPMAtmCellAttributesRxLowThreshold = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(100, 3000))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: acPMAtmCellAttributesRxLowThreshold.setStatus('current')
acPMAtmData = MibIdentifier((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2))
acPMAtmDataAcPMAtmTimeFromStartOfInterval = MibScalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmDataAcPMAtmTimeFromStartOfInterval.setStatus('current')
acPMAtmCellTxTable = MibTable((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21), )
if mibBuilder.loadTexts: acPMAtmCellTxTable.setStatus('current')
acPMAtmCellTxEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1), ).setIndexNames((0, "AC-PM-ATM-MIB", "acPMAtmCellTxInterface"), (0, "AC-PM-ATM-MIB", "acPMAtmCellTxInterval"))
if mibBuilder.loadTexts: acPMAtmCellTxEntry.setStatus('current')
acPMAtmCellTxInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2)))
if mibBuilder.loadTexts: acPMAtmCellTxInterface.setStatus('current')
acPMAtmCellTxInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2)))
if mibBuilder.loadTexts: acPMAtmCellTxInterval.setStatus('current')
acPMAtmCellTxAverage = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxAverage.setStatus('current')
acPMAtmCellTxMax = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxMax.setStatus('current')
acPMAtmCellTxMin = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxMin.setStatus('current')
acPMAtmCellTxVolume = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxVolume.setStatus('current')
acPMAtmCellTxTimeBelowLowThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxTimeBelowLowThreshold.setStatus('current')
acPMAtmCellTxTimeBetweenThresholds = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxTimeBetweenThresholds.setStatus('current')
acPMAtmCellTxTimeAboveHighThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxTimeAboveHighThreshold.setStatus('current')
acPMAtmCellTxFullDayAverage = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellTxFullDayAverage.setStatus('current')
acPMAtmCellRxTable = MibTable((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22), )
if mibBuilder.loadTexts: acPMAtmCellRxTable.setStatus('current')
acPMAtmCellRxEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1), ).setIndexNames((0, "AC-PM-ATM-MIB", "acPMAtmCellRxInterface"), (0, "AC-PM-ATM-MIB", "acPMAtmCellRxInterval"))
if mibBuilder.loadTexts: acPMAtmCellRxEntry.setStatus('current')
acPMAtmCellRxInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2)))
if mibBuilder.loadTexts: acPMAtmCellRxInterface.setStatus('current')
acPMAtmCellRxInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2)))
if mibBuilder.loadTexts: acPMAtmCellRxInterval.setStatus('current')
acPMAtmCellRxAverage = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxAverage.setStatus('current')
acPMAtmCellRxMax = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxMax.setStatus('current')
acPMAtmCellRxMin = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxMin.setStatus('current')
acPMAtmCellRxVolume = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 6), Counter32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxVolume.setStatus('current')
acPMAtmCellRxTimeBelowLowThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 7), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxTimeBelowLowThreshold.setStatus('current')
acPMAtmCellRxTimeBetweenThresholds = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxTimeBetweenThresholds.setStatus('current')
acPMAtmCellRxTimeAboveHighThreshold = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 100))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxTimeAboveHighThreshold.setStatus('current')
acPMAtmCellRxFullDayAverage = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(-1, 2147483647))).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellRxFullDayAverage.setStatus('current')
acPMAtmCellDiscardedTable = MibTable((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23), )
if mibBuilder.loadTexts: acPMAtmCellDiscardedTable.setStatus('current')
acPMAtmCellDiscardedEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1), ).setIndexNames((0, "AC-PM-ATM-MIB", "acPMAtmCellDiscardedInterface"), (0, "AC-PM-ATM-MIB", "acPMAtmCellDiscardedInterval"))
if mibBuilder.loadTexts: acPMAtmCellDiscardedEntry.setStatus('current')
acPMAtmCellDiscardedInterface = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2)))
if mibBuilder.loadTexts: acPMAtmCellDiscardedInterface.setStatus('current')
acPMAtmCellDiscardedInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2)))
if mibBuilder.loadTexts: acPMAtmCellDiscardedInterval.setStatus('current')
acPMAtmCellDiscardedVal = MibTableColumn((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1, 3), Gauge32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: acPMAtmCellDiscardedVal.setStatus('current')
mibBuilder.exportSymbols("AC-PM-ATM-MIB", acPMAtmCellRxInterval=acPMAtmCellRxInterval, acPMAtmCellRxTimeBelowLowThreshold=acPMAtmCellRxTimeBelowLowThreshold, acPMAtmConfigurationPeriodLength=acPMAtmConfigurationPeriodLength, acPMAtmCellTxFullDayAverage=acPMAtmCellTxFullDayAverage, acPerformance=acPerformance, acPMAtmConfiguration=acPMAtmConfiguration, acPMAtmData=acPMAtmData, acPMAtmCellTxTable=acPMAtmCellTxTable, acPMAtmCellTxAverage=acPMAtmCellTxAverage, acPMAtmCellDiscardedTable=acPMAtmCellDiscardedTable, acPMAtmDataAcPMAtmTimeFromStartOfInterval=acPMAtmDataAcPMAtmTimeFromStartOfInterval, acPMAtmCellTxTimeBetweenThresholds=acPMAtmCellTxTimeBetweenThresholds, acPMAtmCellRxAverage=acPMAtmCellRxAverage, acPMAtmCellRxVolume=acPMAtmCellRxVolume, acPMAtmCellRxMax=acPMAtmCellRxMax, acPMAtmCellAttributesTxLowThreshold=acPMAtmCellAttributesTxLowThreshold, PYSNMP_MODULE_ID=acPMAtm, acPMAtmCellRxTimeBetweenThresholds=acPMAtmCellRxTimeBetweenThresholds, acPMAtmCellRxTimeAboveHighThreshold=acPMAtmCellRxTimeAboveHighThreshold, acPMAtmCellTxTimeAboveHighThreshold=acPMAtmCellTxTimeAboveHighThreshold, acProducts=acProducts, acPMAtmCellDiscardedVal=acPMAtmCellDiscardedVal, acGeneric=acGeneric, acPMAtmCellTxEntry=acPMAtmCellTxEntry, acPMAtmCellRxFullDayAverage=acPMAtmCellRxFullDayAverage, acPMAtmCellRxMin=acPMAtmCellRxMin, acPMAtmConfigurationResetTotalCounters=acPMAtmConfigurationResetTotalCounters, acPMAtmCellAttributesTxHighThreshold=acPMAtmCellAttributesTxHighThreshold, acPMAtmCellRxTable=acPMAtmCellRxTable, acPMAtmCellTxTimeBelowLowThreshold=acPMAtmCellTxTimeBelowLowThreshold, acPMAtmCellTxMin=acPMAtmCellTxMin, acPMAtmCellTxMax=acPMAtmCellTxMax, acPMAtmCellAttributes=acPMAtmCellAttributes, acPMAtmCellAttributesRxLowThreshold=acPMAtmCellAttributesRxLowThreshold, acPMAtmCellAttributesRxHighThreshold=acPMAtmCellAttributesRxHighThreshold, acPMAtmCellTxVolume=acPMAtmCellTxVolume, acRegistrations=acRegistrations, acPMAtmCellTxInterval=acPMAtmCellTxInterval, acPMAtmCellRxInterface=acPMAtmCellRxInterface, acPMAtmCellDiscardedInterval=acPMAtmCellDiscardedInterval, acPMAtm=acPMAtm, acPMAtmCellDiscardedEntry=acPMAtmCellDiscardedEntry, acPMAtmCellTxInterface=acPMAtmCellTxInterface, acPMAtmCellDiscardedInterface=acPMAtmCellDiscardedInterface, acPMAtmCellRxEntry=acPMAtmCellRxEntry, audioCodes=audioCodes)
| (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_size_constraint, constraints_intersection, value_range_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsUnion', 'SingleValueConstraint', 'ValueSizeConstraint', 'ConstraintsIntersection', 'ValueRangeConstraint')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(bits, counter32, unsigned32, mib_scalar, mib_table, mib_table_row, mib_table_column, gauge32, mib_identifier, notification_type, iso, integer32, object_identity, module_identity, counter64, ip_address, time_ticks, enterprises) = mibBuilder.importSymbols('SNMPv2-SMI', 'Bits', 'Counter32', 'Unsigned32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Gauge32', 'MibIdentifier', 'NotificationType', 'iso', 'Integer32', 'ObjectIdentity', 'ModuleIdentity', 'Counter64', 'IpAddress', 'TimeTicks', 'enterprises')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
audio_codes = mib_identifier((1, 3, 6, 1, 4, 1, 5003))
ac_registrations = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 7))
ac_generic = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 8))
ac_products = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 9))
ac_performance = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 10))
ac_pm_atm = module_identity((1, 3, 6, 1, 4, 1, 5003, 10, 12))
if mibBuilder.loadTexts:
acPMAtm.setLastUpdated('200601261643Z')
if mibBuilder.loadTexts:
acPMAtm.setOrganization('AudioCodes Ltd')
ac_pm_atm_configuration = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1))
ac_pm_atm_configuration_period_length = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 894780))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
acPMAtmConfigurationPeriodLength.setStatus('current')
ac_pm_atm_configuration_reset_total_counters = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 2), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('resetCountersDone', 1), ('resetTotalCounters', 2)))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
acPMAtmConfigurationResetTotalCounters.setStatus('current')
ac_pm_atm_cell_attributes = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31))
ac_pm_atm_cell_attributes_tx_high_threshold = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 1), integer32().subtype(subtypeSpec=value_range_constraint(100, 3000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
acPMAtmCellAttributesTxHighThreshold.setStatus('current')
ac_pm_atm_cell_attributes_tx_low_threshold = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 2), integer32().subtype(subtypeSpec=value_range_constraint(100, 3000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
acPMAtmCellAttributesTxLowThreshold.setStatus('current')
ac_pm_atm_cell_attributes_rx_high_threshold = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 3), integer32().subtype(subtypeSpec=value_range_constraint(100, 3000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
acPMAtmCellAttributesRxHighThreshold.setStatus('current')
ac_pm_atm_cell_attributes_rx_low_threshold = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 1, 31, 4), integer32().subtype(subtypeSpec=value_range_constraint(100, 3000))).setMaxAccess('readwrite')
if mibBuilder.loadTexts:
acPMAtmCellAttributesRxLowThreshold.setStatus('current')
ac_pm_atm_data = mib_identifier((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2))
ac_pm_atm_data_ac_pm_atm_time_from_start_of_interval = mib_scalar((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmDataAcPMAtmTimeFromStartOfInterval.setStatus('current')
ac_pm_atm_cell_tx_table = mib_table((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21))
if mibBuilder.loadTexts:
acPMAtmCellTxTable.setStatus('current')
ac_pm_atm_cell_tx_entry = mib_table_row((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1)).setIndexNames((0, 'AC-PM-ATM-MIB', 'acPMAtmCellTxInterface'), (0, 'AC-PM-ATM-MIB', 'acPMAtmCellTxInterval'))
if mibBuilder.loadTexts:
acPMAtmCellTxEntry.setStatus('current')
ac_pm_atm_cell_tx_interface = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 2)))
if mibBuilder.loadTexts:
acPMAtmCellTxInterface.setStatus('current')
ac_pm_atm_cell_tx_interval = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 2)))
if mibBuilder.loadTexts:
acPMAtmCellTxInterval.setStatus('current')
ac_pm_atm_cell_tx_average = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxAverage.setStatus('current')
ac_pm_atm_cell_tx_max = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxMax.setStatus('current')
ac_pm_atm_cell_tx_min = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxMin.setStatus('current')
ac_pm_atm_cell_tx_volume = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 6), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxVolume.setStatus('current')
ac_pm_atm_cell_tx_time_below_low_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(-1, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxTimeBelowLowThreshold.setStatus('current')
ac_pm_atm_cell_tx_time_between_thresholds = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(-1, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxTimeBetweenThresholds.setStatus('current')
ac_pm_atm_cell_tx_time_above_high_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(-1, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxTimeAboveHighThreshold.setStatus('current')
ac_pm_atm_cell_tx_full_day_average = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 21, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellTxFullDayAverage.setStatus('current')
ac_pm_atm_cell_rx_table = mib_table((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22))
if mibBuilder.loadTexts:
acPMAtmCellRxTable.setStatus('current')
ac_pm_atm_cell_rx_entry = mib_table_row((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1)).setIndexNames((0, 'AC-PM-ATM-MIB', 'acPMAtmCellRxInterface'), (0, 'AC-PM-ATM-MIB', 'acPMAtmCellRxInterval'))
if mibBuilder.loadTexts:
acPMAtmCellRxEntry.setStatus('current')
ac_pm_atm_cell_rx_interface = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 2)))
if mibBuilder.loadTexts:
acPMAtmCellRxInterface.setStatus('current')
ac_pm_atm_cell_rx_interval = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 2)))
if mibBuilder.loadTexts:
acPMAtmCellRxInterval.setStatus('current')
ac_pm_atm_cell_rx_average = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 3), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxAverage.setStatus('current')
ac_pm_atm_cell_rx_max = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 4), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxMax.setStatus('current')
ac_pm_atm_cell_rx_min = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 5), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxMin.setStatus('current')
ac_pm_atm_cell_rx_volume = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 6), counter32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxVolume.setStatus('current')
ac_pm_atm_cell_rx_time_below_low_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 7), integer32().subtype(subtypeSpec=value_range_constraint(-1, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxTimeBelowLowThreshold.setStatus('current')
ac_pm_atm_cell_rx_time_between_thresholds = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 8), integer32().subtype(subtypeSpec=value_range_constraint(-1, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxTimeBetweenThresholds.setStatus('current')
ac_pm_atm_cell_rx_time_above_high_threshold = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 9), integer32().subtype(subtypeSpec=value_range_constraint(-1, 100))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxTimeAboveHighThreshold.setStatus('current')
ac_pm_atm_cell_rx_full_day_average = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 22, 1, 10), integer32().subtype(subtypeSpec=value_range_constraint(-1, 2147483647))).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellRxFullDayAverage.setStatus('current')
ac_pm_atm_cell_discarded_table = mib_table((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23))
if mibBuilder.loadTexts:
acPMAtmCellDiscardedTable.setStatus('current')
ac_pm_atm_cell_discarded_entry = mib_table_row((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1)).setIndexNames((0, 'AC-PM-ATM-MIB', 'acPMAtmCellDiscardedInterface'), (0, 'AC-PM-ATM-MIB', 'acPMAtmCellDiscardedInterval'))
if mibBuilder.loadTexts:
acPMAtmCellDiscardedEntry.setStatus('current')
ac_pm_atm_cell_discarded_interface = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1, 1), integer32().subtype(subtypeSpec=value_range_constraint(0, 2)))
if mibBuilder.loadTexts:
acPMAtmCellDiscardedInterface.setStatus('current')
ac_pm_atm_cell_discarded_interval = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1, 2), integer32().subtype(subtypeSpec=value_range_constraint(0, 2)))
if mibBuilder.loadTexts:
acPMAtmCellDiscardedInterval.setStatus('current')
ac_pm_atm_cell_discarded_val = mib_table_column((1, 3, 6, 1, 4, 1, 5003, 10, 12, 2, 23, 1, 3), gauge32()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
acPMAtmCellDiscardedVal.setStatus('current')
mibBuilder.exportSymbols('AC-PM-ATM-MIB', acPMAtmCellRxInterval=acPMAtmCellRxInterval, acPMAtmCellRxTimeBelowLowThreshold=acPMAtmCellRxTimeBelowLowThreshold, acPMAtmConfigurationPeriodLength=acPMAtmConfigurationPeriodLength, acPMAtmCellTxFullDayAverage=acPMAtmCellTxFullDayAverage, acPerformance=acPerformance, acPMAtmConfiguration=acPMAtmConfiguration, acPMAtmData=acPMAtmData, acPMAtmCellTxTable=acPMAtmCellTxTable, acPMAtmCellTxAverage=acPMAtmCellTxAverage, acPMAtmCellDiscardedTable=acPMAtmCellDiscardedTable, acPMAtmDataAcPMAtmTimeFromStartOfInterval=acPMAtmDataAcPMAtmTimeFromStartOfInterval, acPMAtmCellTxTimeBetweenThresholds=acPMAtmCellTxTimeBetweenThresholds, acPMAtmCellRxAverage=acPMAtmCellRxAverage, acPMAtmCellRxVolume=acPMAtmCellRxVolume, acPMAtmCellRxMax=acPMAtmCellRxMax, acPMAtmCellAttributesTxLowThreshold=acPMAtmCellAttributesTxLowThreshold, PYSNMP_MODULE_ID=acPMAtm, acPMAtmCellRxTimeBetweenThresholds=acPMAtmCellRxTimeBetweenThresholds, acPMAtmCellRxTimeAboveHighThreshold=acPMAtmCellRxTimeAboveHighThreshold, acPMAtmCellTxTimeAboveHighThreshold=acPMAtmCellTxTimeAboveHighThreshold, acProducts=acProducts, acPMAtmCellDiscardedVal=acPMAtmCellDiscardedVal, acGeneric=acGeneric, acPMAtmCellTxEntry=acPMAtmCellTxEntry, acPMAtmCellRxFullDayAverage=acPMAtmCellRxFullDayAverage, acPMAtmCellRxMin=acPMAtmCellRxMin, acPMAtmConfigurationResetTotalCounters=acPMAtmConfigurationResetTotalCounters, acPMAtmCellAttributesTxHighThreshold=acPMAtmCellAttributesTxHighThreshold, acPMAtmCellRxTable=acPMAtmCellRxTable, acPMAtmCellTxTimeBelowLowThreshold=acPMAtmCellTxTimeBelowLowThreshold, acPMAtmCellTxMin=acPMAtmCellTxMin, acPMAtmCellTxMax=acPMAtmCellTxMax, acPMAtmCellAttributes=acPMAtmCellAttributes, acPMAtmCellAttributesRxLowThreshold=acPMAtmCellAttributesRxLowThreshold, acPMAtmCellAttributesRxHighThreshold=acPMAtmCellAttributesRxHighThreshold, acPMAtmCellTxVolume=acPMAtmCellTxVolume, acRegistrations=acRegistrations, acPMAtmCellTxInterval=acPMAtmCellTxInterval, acPMAtmCellRxInterface=acPMAtmCellRxInterface, acPMAtmCellDiscardedInterval=acPMAtmCellDiscardedInterval, acPMAtm=acPMAtm, acPMAtmCellDiscardedEntry=acPMAtmCellDiscardedEntry, acPMAtmCellTxInterface=acPMAtmCellTxInterface, acPMAtmCellDiscardedInterface=acPMAtmCellDiscardedInterface, acPMAtmCellRxEntry=acPMAtmCellRxEntry, audioCodes=audioCodes) |
def Shell(A):
t = int(len(A)/2)
while t > 0:
for i in range(len(A)-t):
j = i
while j >= 0 and A[j] > A[j+t]:
A[j], A[j+t] = A[j+t], A[j]
j -= 1
t = int(t/2) | def shell(A):
t = int(len(A) / 2)
while t > 0:
for i in range(len(A) - t):
j = i
while j >= 0 and A[j] > A[j + t]:
(A[j], A[j + t]) = (A[j + t], A[j])
j -= 1
t = int(t / 2) |
"""
479. Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers.
Since the result could be very large, you should return the largest palindrome mod 1337.
Example:
Input: 2
Output: 987
Explanation: 99 x 91 = 9009, 9009 % 1337 = 987
Note:
The range of n is [1,8].
"""
class Solution(object):
def largestPalindrome(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 0
d1 = d2 = int([9]*n)
class Solution(object):
def largestPalindrome(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 0
lst = ['9']*n
#print(''.join(lst))
d1 = d2 = int(''.join(lst))
results = []
flag = False
def is_palindrome(n):
s = str(n)
for i in range(len(s)/2):
if s[i] != s[len(s)-1-i]:
return False
return True
print(d1,d2)
while d2 > 0:
#print(d1*d2)
if is_palindrome(d1*d2):
#print(d1,d2)
results.append(d1*d2)
break
d2-=1
print(d1,d2)
d2 = d1
print(d1,d2)
while d2 > 0:
if is_palindrome(d1*d2):
results.append(d1*d2)
break
if flag == False:
d2-=1
flag = True
else:
d1-=1
flag = False
print(results)
return max(results)%1337
| """
479. Largest Palindrome Product
Find the largest palindrome made from the product of two n-digit numbers.
Since the result could be very large, you should return the largest palindrome mod 1337.
Example:
Input: 2
Output: 987
Explanation: 99 x 91 = 9009, 9009 % 1337 = 987
Note:
The range of n is [1,8].
"""
class Solution(object):
def largest_palindrome(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 0
d1 = d2 = int([9] * n)
class Solution(object):
def largest_palindrome(self, n):
"""
:type n: int
:rtype: int
"""
if n == 0:
return 0
lst = ['9'] * n
d1 = d2 = int(''.join(lst))
results = []
flag = False
def is_palindrome(n):
s = str(n)
for i in range(len(s) / 2):
if s[i] != s[len(s) - 1 - i]:
return False
return True
print(d1, d2)
while d2 > 0:
if is_palindrome(d1 * d2):
results.append(d1 * d2)
break
d2 -= 1
print(d1, d2)
d2 = d1
print(d1, d2)
while d2 > 0:
if is_palindrome(d1 * d2):
results.append(d1 * d2)
break
if flag == False:
d2 -= 1
flag = True
else:
d1 -= 1
flag = False
print(results)
return max(results) % 1337 |
# Copyright 2022 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in 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.
"""Provides attack points for AES."""
class AESSBOX:
"""Provides functions for getting attack points when provided with key,
plaintext pair. Attack points:
key: The key itself.
sub_bytes_in: key xor plaintext (what goes into AES SBOX).
sub_bytes_out: each byte of sub_bytes_in is remapped using the SBOX
(what goes out of the SBOX).
"""
_SB = [
# pylint: disable=C0301
0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76,
0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0,
0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15,
0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75,
0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84,
0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf,
0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8,
0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2,
0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73,
0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb,
0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79,
0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08,
0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a,
0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e,
0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf,
0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16,
] # yapf: disable
# Number of classes used in ML. We are predicting a single byte => 256.
_MAX_VAL = 256
# Length of the key in bytes
KEY_LENGTH = 16
# Length of the plaintext in bytes
PLAINTEXT_LENGTH = 16
# The attack points info used in scaaml.io.Dataset.
ATTACK_POINTS_INFO = {
"sub_bytes_in": {
"len": 16,
"max_val": _MAX_VAL,
},
"sub_bytes_out": {
"len": 16,
"max_val": _MAX_VAL,
},
"key": {
"len": 16,
"max_val": _MAX_VAL,
}
}
@staticmethod
def key(key: bytearray, plaintext: bytearray) -> bytearray:
"""Return the key. Useful for getting all attack points."""
assert len(key) == len(plaintext)
return key
@staticmethod
def sub_bytes_in(key: bytearray, plaintext: bytearray) -> bytearray:
"""Return what goes into the SBOX."""
assert len(key) == len(plaintext)
return bytearray(x ^ y for (x, y) in zip(key, plaintext))
@staticmethod
def sub_bytes_out(key: bytearray, plaintext: bytearray) -> bytearray:
"""Return what goes out of the SBOX."""
assert len(key) == len(plaintext)
return bytearray(AESSBOX._SB[x ^ y] for (x, y) in zip(key, plaintext))
@classmethod
def get_attack_point(cls, name: str, **kwargs: bytearray) -> bytearray:
"""Return the correct attack point.
Typical usage example:
attack_point_names = ["key", "sub_bytes_in", "sub_bytes_out"]
attack_points = {
ap: AESSBOX.get_attack_point(ap, key=key, plaintext=plaintext)
for ap in attack_point_names
}
"""
function = getattr(cls, name, None)
if not function or not callable(function):
raise ValueError(f"{name} is not a defined attack point")
return function(**kwargs)
| """Provides attack points for AES."""
class Aessbox:
"""Provides functions for getting attack points when provided with key,
plaintext pair. Attack points:
key: The key itself.
sub_bytes_in: key xor plaintext (what goes into AES SBOX).
sub_bytes_out: each byte of sub_bytes_in is remapped using the SBOX
(what goes out of the SBOX).
"""
_sb = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22]
_max_val = 256
key_length = 16
plaintext_length = 16
attack_points_info = {'sub_bytes_in': {'len': 16, 'max_val': _MAX_VAL}, 'sub_bytes_out': {'len': 16, 'max_val': _MAX_VAL}, 'key': {'len': 16, 'max_val': _MAX_VAL}}
@staticmethod
def key(key: bytearray, plaintext: bytearray) -> bytearray:
"""Return the key. Useful for getting all attack points."""
assert len(key) == len(plaintext)
return key
@staticmethod
def sub_bytes_in(key: bytearray, plaintext: bytearray) -> bytearray:
"""Return what goes into the SBOX."""
assert len(key) == len(plaintext)
return bytearray((x ^ y for (x, y) in zip(key, plaintext)))
@staticmethod
def sub_bytes_out(key: bytearray, plaintext: bytearray) -> bytearray:
"""Return what goes out of the SBOX."""
assert len(key) == len(plaintext)
return bytearray((AESSBOX._SB[x ^ y] for (x, y) in zip(key, plaintext)))
@classmethod
def get_attack_point(cls, name: str, **kwargs: bytearray) -> bytearray:
"""Return the correct attack point.
Typical usage example:
attack_point_names = ["key", "sub_bytes_in", "sub_bytes_out"]
attack_points = {
ap: AESSBOX.get_attack_point(ap, key=key, plaintext=plaintext)
for ap in attack_point_names
}
"""
function = getattr(cls, name, None)
if not function or not callable(function):
raise value_error(f'{name} is not a defined attack point')
return function(**kwargs) |
"""
- domain: Sphere online judge
- contest: list of classical problems
- problem: JULKA - Julka
- link: https://www.spoj.com/problems/JULKA/
- hash: $$$$$$$$$$name
- author: Vitor SRG
- version: $$$$$$$$$$date
- tags: tests biginteger
- language: Python3
"""
# Please contact for the solution
"""
- test:
input: |
10
2
output: |
6
4
"""
| """
- domain: Sphere online judge
- contest: list of classical problems
- problem: JULKA - Julka
- link: https://www.spoj.com/problems/JULKA/
- hash: $$$$$$$$$$name
- author: Vitor SRG
- version: $$$$$$$$$$date
- tags: tests biginteger
- language: Python3
"""
'\n - test:\n input: |\n 10\n 2\n output: |\n 6\n 4\n' |
def validMountainArray(arr):
N = len(arr)
i = 0
while i + 1 < N and arr[i] < arr[i+1]:
i += 1
if i == 0 or i == N-1:
return False
while i + 1 < N and arr[i] > arr [i+1]:
i += 1
return i == N-1
arr = [2,1]
x = validMountainArray(arr)
print(x)
arr1 = [3,5,5]
x = validMountainArray(arr1)
print(x)
arr2 = [0,3,2,1]
x = validMountainArray(arr2)
print(x)
| def valid_mountain_array(arr):
n = len(arr)
i = 0
while i + 1 < N and arr[i] < arr[i + 1]:
i += 1
if i == 0 or i == N - 1:
return False
while i + 1 < N and arr[i] > arr[i + 1]:
i += 1
return i == N - 1
arr = [2, 1]
x = valid_mountain_array(arr)
print(x)
arr1 = [3, 5, 5]
x = valid_mountain_array(arr1)
print(x)
arr2 = [0, 3, 2, 1]
x = valid_mountain_array(arr2)
print(x) |
""" Django package for use typograf in models. """
VERSION = 0, 1, 2
__version__ = '.'.join(map(str, VERSION))
| """ Django package for use typograf in models. """
version = (0, 1, 2)
__version__ = '.'.join(map(str, VERSION)) |
def main(j, args, params, tags, tasklet):
page = args.page
filters = dict()
tagsmap = {
'jsname': 'name',
'jsorganization': 'organization',
}
fieldids = ['id', 'jsname', 'jsorganization', 'category', 'descr']
for tag, val in args.tags.tags.iteritems():
key = tagsmap.get(tag, tag)
if tag in fieldids:
val = args.getTag(tag)
filters[key] = val
else:
val = args.getTag(tag)
filters["tags"] = {"$regex": ("%s|(?=.*%s:%s)" % (filters["tags"]['$regex'], key, val))} if "tags" in filters else {"$regex": "(?=.*%s:%s)" % (key, val)}
for k in filters.keys():
if filters[k] is None:
del filters[k]
modifier = j.html.getPageModifierGridDataTables(page)
def makeID(row, field):
_id = row[field]
link = "[%s|/grid/jumpscript?id=%s]" % (_id, _id)
return link
fields = [
{'name': 'ID',
'id': 'id',
'value': makeID},
{'name': 'Name',
'id': 'name',
'value': 'name'},
{'name': 'Organization',
'id': 'organization',
'value': 'organization'},
{'name': 'Category',
'id': 'category',
'value': 'category'},
{'name': 'Description',
'id': 'descr',
'value': 'descr'},
]
tableid = modifier.addTableFromModel('system', 'jumpscript', fields, filters)
modifier.addSearchOptions('#%s' % tableid)
modifier.addSorting('#%s' % tableid, 1, 'desc')
params.result = page
return params
def match(j, args, params, tags, tasklet):
return True
| def main(j, args, params, tags, tasklet):
page = args.page
filters = dict()
tagsmap = {'jsname': 'name', 'jsorganization': 'organization'}
fieldids = ['id', 'jsname', 'jsorganization', 'category', 'descr']
for (tag, val) in args.tags.tags.iteritems():
key = tagsmap.get(tag, tag)
if tag in fieldids:
val = args.getTag(tag)
filters[key] = val
else:
val = args.getTag(tag)
filters['tags'] = {'$regex': '%s|(?=.*%s:%s)' % (filters['tags']['$regex'], key, val)} if 'tags' in filters else {'$regex': '(?=.*%s:%s)' % (key, val)}
for k in filters.keys():
if filters[k] is None:
del filters[k]
modifier = j.html.getPageModifierGridDataTables(page)
def make_id(row, field):
_id = row[field]
link = '[%s|/grid/jumpscript?id=%s]' % (_id, _id)
return link
fields = [{'name': 'ID', 'id': 'id', 'value': makeID}, {'name': 'Name', 'id': 'name', 'value': 'name'}, {'name': 'Organization', 'id': 'organization', 'value': 'organization'}, {'name': 'Category', 'id': 'category', 'value': 'category'}, {'name': 'Description', 'id': 'descr', 'value': 'descr'}]
tableid = modifier.addTableFromModel('system', 'jumpscript', fields, filters)
modifier.addSearchOptions('#%s' % tableid)
modifier.addSorting('#%s' % tableid, 1, 'desc')
params.result = page
return params
def match(j, args, params, tags, tasklet):
return True |
bad_result_count = int(input())
count_bad = 0
count = 0
last_problem = ''
all_score = 0
while True:
task = input()
if task == 'Enough':
break
rating = float(input())
if rating <= 4:
count_bad += 1
if count_bad == bad_result_count:
print(f'You need a break, {bad_result_count} poor grades.')
break
count += 1
last_problem = task
all_score += rating
if count_bad != bad_result_count:
average = all_score / count
print(f'Average score: {average:.2f}')
print(f'Number of problems: {count}')
print(f'Last problem: {last_problem}')
| bad_result_count = int(input())
count_bad = 0
count = 0
last_problem = ''
all_score = 0
while True:
task = input()
if task == 'Enough':
break
rating = float(input())
if rating <= 4:
count_bad += 1
if count_bad == bad_result_count:
print(f'You need a break, {bad_result_count} poor grades.')
break
count += 1
last_problem = task
all_score += rating
if count_bad != bad_result_count:
average = all_score / count
print(f'Average score: {average:.2f}')
print(f'Number of problems: {count}')
print(f'Last problem: {last_problem}') |
"""
# Definition for a Node.
class Node:
def __init__(self, val, prev, next, child):
self.val = val
self.prev = prev
self.next = next
self.child = child
"""
class Solution:
def flatten(self, head: 'Node') -> 'Node':
def post(node):
if node:
post(node.next)
post(node.child)
node.next = self.suc
node.child = None
if self.suc:
self.suc.prev = node
self.suc = node
self.suc = None
post(head)
return head
| """
# Definition for a Node.
class Node:
def __init__(self, val, prev, next, child):
self.val = val
self.prev = prev
self.next = next
self.child = child
"""
class Solution:
def flatten(self, head: 'Node') -> 'Node':
def post(node):
if node:
post(node.next)
post(node.child)
node.next = self.suc
node.child = None
if self.suc:
self.suc.prev = node
self.suc = node
self.suc = None
post(head)
return head |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.