content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Copyright 2018, OpenCensus Authors
#
# 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 w... | class Timeseries(object):
"""Time series data for a given metric and time interval.
This class implements the spec for v1 TimeSeries structs as of
opencensus-proto release v0.1.0. See opencensus-proto for details:
https://github.com/census-instrumentation/opencensus-proto/blob/v0.1.0/src/opencensu... |
class Logger:
PRINT_INTERVAL = 10
def __init__(self):
self.buckets = [-1 for _ in range(self.PRINT_INTERVAL)]
self.sets = [set() for _ in range(self.PRINT_INTERVAL)]
def shouldPrintMessage(self, timestamp: int, message: str) -> bool:
bucket_index = timestamp % self.PRINT_INTERVAL
... | class Logger:
print_interval = 10
def __init__(self):
self.buckets = [-1 for _ in range(self.PRINT_INTERVAL)]
self.sets = [set() for _ in range(self.PRINT_INTERVAL)]
def should_print_message(self, timestamp: int, message: str) -> bool:
bucket_index = timestamp % self.PRINT_INTERVAL... |
#!/usr/bin/env python
NAME = 'WebTotem (WebTotem)'
def is_waf(self):
for attack in self.attacks:
r = attack(self)
if r is None:
return
_, page = r
# WebTotem returns its name in blockpage
if all(i in page for i in (b'The current request was blocked', b'WebTote... | name = 'WebTotem (WebTotem)'
def is_waf(self):
for attack in self.attacks:
r = attack(self)
if r is None:
return
(_, page) = r
if all((i in page for i in (b'The current request was blocked', b'WebTotem'))):
return True
return False |
{
'targets': [
{
'target_name': 'node_expat_object',
'sources': [
'src/parse.cc',
'src/node-expat-object.cc'
],
'include_dirs': [
'<!(node -e "require(\'nan\')")'
],
'dependencies': [
'deps/libexpat/libexpat.gyp:expat'
]
}
]
}
| {'targets': [{'target_name': 'node_expat_object', 'sources': ['src/parse.cc', 'src/node-expat-object.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")'], 'dependencies': ['deps/libexpat/libexpat.gyp:expat']}]} |
# Token types
#
# EOF (end-of-file) token is used to indicate that
# there is no more input left for lexical analysis
NUMBER, VARIABLE, VARIABLE_SET, PLUS, MINUS, MUL, DIV, LPAREN, RPAREN, EOF, LOG, SIN, COS, TAN, \
CTG, SQRT, POW, LOWER, HIGHER, HIGHER_EQ, LOWER_EQ, EQ, EQ_EQ, TRUE, FALSE, PLUS_EQUALS,\
MINUS_EQUA... | (number, variable, variable_set, plus, minus, mul, div, lparen, rparen, eof, log, sin, cos, tan, ctg, sqrt, pow, lower, higher, higher_eq, lower_eq, eq, eq_eq, true, false, plus_equals, minus_equals, mul_equals, div_equals, mod, left_shift, right_shift, pi, e_c, deg, rad) = ('NUMBER', 'VARIABLE', 'VARIABLE_SET', 'PLUS'... |
class ParamRequest(object):
"""
Represents a set of request parameters.
"""
def to_request_parameters(self):
"""
:return: list[:class:`ingenico.connect.sdk.RequestParam`] representing the HTTP request parameters
"""
raise NotImplementedError
| class Paramrequest(object):
"""
Represents a set of request parameters.
"""
def to_request_parameters(self):
"""
:return: list[:class:`ingenico.connect.sdk.RequestParam`] representing the HTTP request parameters
"""
raise NotImplementedError |
# Copyright 2013-2022 Lawrence Livermore National Security, LLC and other
# Spack Project Developers. See the top-level COPYRIGHT file for details.
#
# SPDX-License-Identifier: (Apache-2.0 OR MIT)
class PyLap(PythonPackage):
"""lap is a linear assignment problem solver using
Jonker-Volgenant algorithm for den... | class Pylap(PythonPackage):
"""lap is a linear assignment problem solver using
Jonker-Volgenant algorithm for dense (LAPJV) or sparse (LAPMOD)
matrices."""
homepage = 'https://github.com/gatagat/lap'
pypi = 'lap/lap-0.4.0.tar.gz'
version('0.4.0', sha256='c4dad9976f0e9f276d8a676a6d03632c3cb7ab7c8... |
list = ['Apple','Orange','Benana','Mango'];
name = "Md Tazri";
print('"Apple" in list : ',"Apple" in list);
print('"Kiwi" in list : ',"Kiwi" in list);
print('"Water" not in list : ',"Water" not in list);
print("'Md' in name : ",'Md' in name);
print("'Tazri' not in name : ",'Tazri' not in name); | list = ['Apple', 'Orange', 'Benana', 'Mango']
name = 'Md Tazri'
print('"Apple" in list : ', 'Apple' in list)
print('"Kiwi" in list : ', 'Kiwi' in list)
print('"Water" not in list : ', 'Water' not in list)
print("'Md' in name : ", 'Md' in name)
print("'Tazri' not in name : ", 'Tazri' not in name) |
class DiceLoss(nn.Module):
def __init__(self, tolerance=1e-8):
super(DiceLoss, self).__init__()
self.tolerance = tolerance
def forward(self, pred, label):
intersection = torch.sum(pred * label) + self.tolerance
union = torch.sum(pred) + torch.sum(label) + self.tolerance
... | class Diceloss(nn.Module):
def __init__(self, tolerance=1e-08):
super(DiceLoss, self).__init__()
self.tolerance = tolerance
def forward(self, pred, label):
intersection = torch.sum(pred * label) + self.tolerance
union = torch.sum(pred) + torch.sum(label) + self.tolerance
... |
class EventTypeFilter(TraceFilter):
"""
Indicates whether a listener should trace based on the event type.
EventTypeFilter(level: SourceLevels)
"""
def ZZZ(self):
"""hardcoded/mock instance of the class"""
return EventTypeFilter()
instance=ZZZ()
"""hardcoded/returns an instance of the class"""
... | class Eventtypefilter(TraceFilter):
"""
Indicates whether a listener should trace based on the event type.
EventTypeFilter(level: SourceLevels)
"""
def zzz(self):
"""hardcoded/mock instance of the class"""
return event_type_filter()
instance = zzz()
'hardcoded/returns an instance... |
#
# This is the Robotics Language compiler
#
# Transformations.py: Applies tranformations to the XML structure
#
# Created on: June 22, 2017
# Author: Gabriel A. D. Lopes
# Licence: Apache 2.0
# Copyright: 2014-2017 Robot Care Systems BV, The Hague, The Netherlands. All rights reserved.
#
# Licens... | atoms = {'string': 'Strings', 'boolean': 'Booleans', 'real': 'Reals', 'integer': 'Integers'}
def many_same_numbers_or_strings(x):
"""number or string"""
return all(map(lambda y: y in ['Reals', 'Integers'], x)) or all(map(lambda y: y == 'Strings', x))
def single_string(x):
"""string"""
return len(x) ==... |
class Contact:
def __init__(self, firstname, lastname, company, address, telephone, mobile, tel_work, email, email_1, www):
self.firstname = firstname
self.lastname = lastname
self.company = company
self.address = address
self.telephone = telephone
self.mobile = mobil... | class Contact:
def __init__(self, firstname, lastname, company, address, telephone, mobile, tel_work, email, email_1, www):
self.firstname = firstname
self.lastname = lastname
self.company = company
self.address = address
self.telephone = telephone
self.mobile = mobi... |
# coding: utf-8
def array_pad(l, size, value):
if size >= 0:
return l + [value] * (size - len(l))
else:
return [value] * (size * -1 - len(l)) + l
if __name__ == '__main__':
l = [12, 10, 9]
print(array_pad(l, 5, 0))
print(array_pad(l, -7, -1))
print(array_pad(l, 2, 999))
| def array_pad(l, size, value):
if size >= 0:
return l + [value] * (size - len(l))
else:
return [value] * (size * -1 - len(l)) + l
if __name__ == '__main__':
l = [12, 10, 9]
print(array_pad(l, 5, 0))
print(array_pad(l, -7, -1))
print(array_pad(l, 2, 999)) |
k=int (input())
l=int (input())
m=int (input())
n=int (input())
d=int (input())
damagedDragons = 0
for i in range (1, d+1):
if i%k == 0 or i%l == 0 or i%m == 0 or i%n == 0:
damagedDragons = damagedDragons + 1
print(damagedDragons)
| k = int(input())
l = int(input())
m = int(input())
n = int(input())
d = int(input())
damaged_dragons = 0
for i in range(1, d + 1):
if i % k == 0 or i % l == 0 or i % m == 0 or (i % n == 0):
damaged_dragons = damagedDragons + 1
print(damagedDragons) |
# Copyright 2018 Canonical Ltd.
#
# 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 writin... | """Module of exceptions that zaza may raise."""
class Missingosathenticationexception(Exception):
"""Exception when some data needed to authenticate is missing."""
pass
class Cloudinitincomplete(Exception):
"""Cloud init has not completed properly."""
pass
class Sshfailed(Exception):
"""SSH faile... |
menu = [
[ "egg", "spam", "bacon"],
[ "egg", "sausage", "bacon"],
[ "egg", "spam"],
[ "egg", "bacon", "spam"],
[ "egg", "bacon", "sausage", "spam"],
[ "spam", "bacon", "sausage", "spam"],
[ "spam", "egg", "spam", "spam", "bacon","spam"],
[ "spam", "egg", "sausage", "spam"],
[ "chicke... | menu = [['egg', 'spam', 'bacon'], ['egg', 'sausage', 'bacon'], ['egg', 'spam'], ['egg', 'bacon', 'spam'], ['egg', 'bacon', 'sausage', 'spam'], ['spam', 'bacon', 'sausage', 'spam'], ['spam', 'egg', 'spam', 'spam', 'bacon', 'spam'], ['spam', 'egg', 'sausage', 'spam'], ['chicken', 'chips']]
meals = []
for meal in menu:
... |
def divide(x: int, y: int) -> int:
result, power = 0, 32
y_power = y << power
while x >= y:
while y_power > x:
y_power >>=1
power -=1
result += 1<<power
x -= y_power
return result | def divide(x: int, y: int) -> int:
(result, power) = (0, 32)
y_power = y << power
while x >= y:
while y_power > x:
y_power >>= 1
power -= 1
result += 1 << power
x -= y_power
return result |
"""
TODO: Add description.
Date: 2021-05-27
Author: Vitali Lupusor
"""
| """
TODO: Add description.
Date: 2021-05-27
Author: Vitali Lupusor
""" |
sum = 0
for x in range(10):
sum = sum + x
print(sum)
| sum = 0
for x in range(10):
sum = sum + x
print(sum) |
"""
Classes in this file are standalone because we don't want to impose a false hierarchy
between two classes. That is, inheritance may imply a hierarchy that isn't real.
"""
class Settings(object):
kExactTestBias = 1.0339757656912846e-25
kSmallEpsilon = 5.684341886080802e-14
kLargeEpsilon = 1e-07
SM... | """
Classes in this file are standalone because we don't want to impose a false hierarchy
between two classes. That is, inheritance may imply a hierarchy that isn't real.
"""
class Settings(object):
k_exact_test_bias = 1.0339757656912846e-25
k_small_epsilon = 5.684341886080802e-14
k_large_epsilon = 1e-07
... |
f = open("io/data/file1")
print(f.readline())
print(f.readline(3))
print(f.readline(4))
print(f.readline(5))
print(f.readline())
# readline() on writable file
f = open("io/data/file1", "ab")
try:
f.readline()
except OSError:
print("OSError")
f.close()
| f = open('io/data/file1')
print(f.readline())
print(f.readline(3))
print(f.readline(4))
print(f.readline(5))
print(f.readline())
f = open('io/data/file1', 'ab')
try:
f.readline()
except OSError:
print('OSError')
f.close() |
# return an integere cycle length K of a permutation. Applying a permutation K-times to a list will return the original list.
def permutation_cycle_length(permutation):
initialArray = range(len(permutation))
permutedArray = range(len(permutation))
cycles = 0
while True:
permutedArray = [permutedArray[permu... | def permutation_cycle_length(permutation):
initial_array = range(len(permutation))
permuted_array = range(len(permutation))
cycles = 0
while True:
permuted_array = [permutedArray[permutation[i]] for i in range(len(initialArray))]
cycles += 1
if are_equal(initialArray, permutedArr... |
BLOCKCHAIN = {
'class': 'thenewboston_node.business_logic.blockchain.file_blockchain.FileBlockchain',
'kwargs': {},
}
BLOCKCHAIN_URL_PATH_PREFIX = '/blockchain/'
| blockchain = {'class': 'thenewboston_node.business_logic.blockchain.file_blockchain.FileBlockchain', 'kwargs': {}}
blockchain_url_path_prefix = '/blockchain/' |
n = int(input())
a = n // 365
n = n - a*365
m = n // 30
n = n - m*30
d = n
print('{} ano(s)'.format(a))
print('{} mes(es)'.format(m))
print('{} dia(s)'.format(d))
| n = int(input())
a = n // 365
n = n - a * 365
m = n // 30
n = n - m * 30
d = n
print('{} ano(s)'.format(a))
print('{} mes(es)'.format(m))
print('{} dia(s)'.format(d)) |
num=[10,20,30,40,50,60]
n=[i for i in num]
print(n)
n=[10,20,30,40]
s=[10,20]
n1=[i for i in n]
print(n1)
n2=[j*j for j in n]
print(n2)
n3=[s+s for s in n ]
print(n3)
for m in n:
s.append(m*m)
print(s)
#using lambda
l=[1,2,3,4]
p=list(map(lambda a:a*a ,l))
print(p)
l=list(filter(lambda x:x%2==0,l))
print(l)... | num = [10, 20, 30, 40, 50, 60]
n = [i for i in num]
print(n)
n = [10, 20, 30, 40]
s = [10, 20]
n1 = [i for i in n]
print(n1)
n2 = [j * j for j in n]
print(n2)
n3 = [s + s for s in n]
print(n3)
for m in n:
s.append(m * m)
print(s)
l = [1, 2, 3, 4]
p = list(map(lambda a: a * a, l))
print(p)
l = list(filter(lambda x: ... |
"""
PASSENGERS
"""
numPassengers = 3241
passenger_arriving = (
(2, 4, 9, 5, 2, 0, 7, 7, 4, 5, 1, 0), # 0
(1, 9, 7, 4, 1, 0, 6, 6, 9, 6, 1, 0), # 1
(5, 6, 8, 4, 3, 0, 8, 11, 5, 2, 1, 0), # 2
(4, 5, 5, 4, 2, 0, 8, 15, 0, 4, 4, 0), # 3
(5, 11, 13, 4, 3, 0, 11, 6, 3, 1, 1, 0), # 4
(9, 6, 8, 3, 0, 0, 7, 6, 9, ... | """
PASSENGERS
"""
num_passengers = 3241
passenger_arriving = ((2, 4, 9, 5, 2, 0, 7, 7, 4, 5, 1, 0), (1, 9, 7, 4, 1, 0, 6, 6, 9, 6, 1, 0), (5, 6, 8, 4, 3, 0, 8, 11, 5, 2, 1, 0), (4, 5, 5, 4, 2, 0, 8, 15, 0, 4, 4, 0), (5, 11, 13, 4, 3, 0, 11, 6, 3, 1, 1, 0), (9, 6, 8, 3, 0, 0, 7, 6, 9, 7, 4, 0), (8, 12, 3, 4, 1, 0, 4, 1... |
"""A basic example of using the SQLAlchemy Sharding API.
Sharding refers to horizontally scaling data across multiple
databases.
The basic components of a "sharded" mapping are:
* multiple databases, each assigned a 'shard id'
* a function which can return a single shard id, given an instance
to be saved; this is c... | """A basic example of using the SQLAlchemy Sharding API.
Sharding refers to horizontally scaling data across multiple
databases.
The basic components of a "sharded" mapping are:
* multiple databases, each assigned a 'shard id'
* a function which can return a single shard id, given an instance
to be saved; this is c... |
#
# PySNMP MIB module CISCO-IPSEC-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-IPSEC-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:02:28 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, constraints_union, constraints_intersection, single_value_constraint) ... |
sensorData = open('input.txt').read().splitlines()
diff = [-1, 0, 1]
key = None
trenchMap = set()
y = 0
for line in sensorData:
if not key:
key = line
elif len(line) > 0:
for x in range(len(line)):
if line[x] == '#':
trenchMap.add((x, y))
y += 1
neighboorho... | sensor_data = open('input.txt').read().splitlines()
diff = [-1, 0, 1]
key = None
trench_map = set()
y = 0
for line in sensorData:
if not key:
key = line
elif len(line) > 0:
for x in range(len(line)):
if line[x] == '#':
trenchMap.add((x, y))
y += 1
neighboorhoo... |
class Config(object):
CHROME_PATH = '/Library/Application Support/Google/chromedriver76.0.3809.68'
BROWSERMOB_PATH = '/usr/local/bin/browsermob-proxy-2.1.4/bin/browsermob-proxy'
class Docker(Config):
CHROME_PATH = '/usr/local/bin/chromedriver'
| class Config(object):
chrome_path = '/Library/Application Support/Google/chromedriver76.0.3809.68'
browsermob_path = '/usr/local/bin/browsermob-proxy-2.1.4/bin/browsermob-proxy'
class Docker(Config):
chrome_path = '/usr/local/bin/chromedriver' |
numbers = [1, 2, 3, 4, 5]
for x in numbers:
print(x)
print("--------")
for x in reversed(numbers):
print(x)
print(numbers) | numbers = [1, 2, 3, 4, 5]
for x in numbers:
print(x)
print('--------')
for x in reversed(numbers):
print(x)
print(numbers) |
a=int(input())
def s(n):
if n==3:return['***','* *','***']
x=s(n//3)
y=list(zip(x,x,x))
for i in range(len(y)):
y[i]=''.join(y[i])
z=list(zip(x,[' '*(n//3)]*(n//3),x))
for i in range(len(z)):
z[i]=''.join(z[i])
return y+z+y
print('\n'.join(s(a)))
| a = int(input())
def s(n):
if n == 3:
return ['***', '* *', '***']
x = s(n // 3)
y = list(zip(x, x, x))
for i in range(len(y)):
y[i] = ''.join(y[i])
z = list(zip(x, [' ' * (n // 3)] * (n // 3), x))
for i in range(len(z)):
z[i] = ''.join(z[i])
return y + z + y
print('... |
def dictTolist(data):
result = []
if isinstance(data, dict) and data.__len__() > 0:
result.append(data)
elif isinstance(data, list) and data.__len__() > 0:
result = data
else:
result = None
return result
| def dict_tolist(data):
result = []
if isinstance(data, dict) and data.__len__() > 0:
result.append(data)
elif isinstance(data, list) and data.__len__() > 0:
result = data
else:
result = None
return result |
########################
# * First Solution
########################
class Solution:
def searchInsert(self, nums: List[int], target: int) -> int:
low = 0
high = len(nums)-1
while low < high:
mid = (low+high) // 2
if nums[mid] == target:
return mid
... | class Solution:
def search_insert(self, nums: List[int], target: int) -> int:
low = 0
high = len(nums) - 1
while low < high:
mid = (low + high) // 2
if nums[mid] == target:
return mid
elif nums[mid] > target:
high = mid - 1... |
# Dictionary
# length (len), check a key, get, set, add
# Dictionary 1 -------------------------------------------
print(" Dictionary with string keys ".center(44, "-"))
dict_employee_IDs = {"ID01": 'John Papa',
"ID02": 'David Thompson',
"ID03": 'Terry Gao',
... | print(' Dictionary with string keys '.center(44, '-'))
dict_employee_i_ds = {'ID01': 'John Papa', 'ID02': 'David Thompson', 'ID03': 'Terry Gao', 'ID04': 'Barry Tex'}
print(dict_employee_IDs)
print(' dictionary length '.center(44, '-'))
dict_employee_i_ds_length = len(dict_employee_IDs)
print(str(dict_employee_IDs_lengt... |
class Solution:
def isUgly(self, num):
"""
:type num: int
:rtype: bool
"""
while not num:
return False
while not (num % 2):
num //= 2
while not (num % 3):
num //= 3
while not (num % 5):
num //= 5
... | class Solution:
def is_ugly(self, num):
"""
:type num: int
:rtype: bool
"""
while not num:
return False
while not num % 2:
num //= 2
while not num % 3:
num //= 3
while not num % 5:
num //= 5
retu... |
# Processing functions for various USMTF message formats
def tacelint(logger_item, message_dict, lines_list, processed_message_list):
prev_soi = []
prev_line = []
for line in lines_list:
if len(prev_line) == 0:
prev_line.append(line)
else:
del prev_line[0]
... | def tacelint(logger_item, message_dict, lines_list, processed_message_list):
prev_soi = []
prev_line = []
for line in lines_list:
if len(prev_line) == 0:
prev_line.append(line)
else:
del prev_line[0]
prev_line.append(line)
line_split = line.split('... |
class AnyOrderList:
"""Sequence that compares to a list, but allows any order.
This is only intended for comparison purposes, not as an actual list replacement.
"""
def __init__(self, list_):
self._list = list_
self._list.sort()
def __eq__(self, other):
assert isinstance(o... | class Anyorderlist:
"""Sequence that compares to a list, but allows any order.
This is only intended for comparison purposes, not as an actual list replacement.
"""
def __init__(self, list_):
self._list = list_
self._list.sort()
def __eq__(self, other):
assert isinstance(o... |
def first(n_1):
line_1 = set()
for i in range(n_1):
number = int(input())
line_1.add(number)
return line_1
def second(n_2):
line_2 = set()
for i in range(n_2):
number = int(input())
line_2.add(number)
return line_2
data = input().split()
n_1 = int(data[0])
n_2 =i... | def first(n_1):
line_1 = set()
for i in range(n_1):
number = int(input())
line_1.add(number)
return line_1
def second(n_2):
line_2 = set()
for i in range(n_2):
number = int(input())
line_2.add(number)
return line_2
data = input().split()
n_1 = int(data[0])
n_2 = ... |
"""
List Data Type(list):
- Just Like Array following indexing
- **Unlike Arrays, list can hold HETEROGENEOUS DATA TYPE
- Repetition allowed
- Multi Dimensional
"""
# Creating a Multi-Dimensional List
print(" \n-------CREATE---------- ")
List = [['Hitesh', 'kumar', 'Sahu'], [29]]
thislist = ["0", "1", "2", "3", "4"... | """
List Data Type(list):
- Just Like Array following indexing
- **Unlike Arrays, list can hold HETEROGENEOUS DATA TYPE
- Repetition allowed
- Multi Dimensional
"""
print(' \n-------CREATE---------- ')
list = [['Hitesh', 'kumar', 'Sahu'], [29]]
thislist = ['0', '1', '2', '3', '4', '5', '6', '7']
fruit_list = list(('a... |
class UnityPackException(Exception):
pass
class ArchiveNotFound(UnityPackException):
pass
| class Unitypackexception(Exception):
pass
class Archivenotfound(UnityPackException):
pass |
"""
[9/08/2014] Challenge #179 [Easy] You make me happy when clouds are gray...scale
https://www.reddit.com/r/dailyprogrammer/comments/2ftcb8/9082014_challenge_179_easy_you_make_me_happy_when/
#Description
The 'Daily Business' newspaper are a distributor of the most recent news concerning business. They have a proble... | """
[9/08/2014] Challenge #179 [Easy] You make me happy when clouds are gray...scale
https://www.reddit.com/r/dailyprogrammer/comments/2ftcb8/9082014_challenge_179_easy_you_make_me_happy_when/
#Description
The 'Daily Business' newspaper are a distributor of the most recent news concerning business. They have a proble... |
# Interview Question #5
# The problem is that we want to find duplicates in a one-dimensional array of integers in O(N) running time
# where the integer values are smaller than the length of the array!
# For example: if we have a list [1, 2, 3, 1, 5] then the algorithm can detect that there are a duplicate with value 1... | def duplicate_finder_1(nums):
duplicates = []
for n in set(nums):
if nums.count(n) > 1:
duplicates.append(n)
return duplicates if duplicates else 'The array does not contain any duplicates!'
def duplicate_finder_2(nums):
duplicates = set()
for (i, n) in enumerate(sorted(nums)):
... |
'''
sgqlc - Simple GraphQL Client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Access GraphQL endpoints using Python
=====================================
This package provide the following modules:
- :mod:`sgqlc.endpoint.base`: with abstract class
:class:`sgqlc.endpoint.base.BaseEndpoint` and helpful logging
utilities to t... | """
sgqlc - Simple GraphQL Client
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Access GraphQL endpoints using Python
=====================================
This package provide the following modules:
- :mod:`sgqlc.endpoint.base`: with abstract class
:class:`sgqlc.endpoint.base.BaseEndpoint` and helpful logging
utilities to t... |
START = {
"type": "http.response.start",
"status": 200,
"headers": [
(b"content-length", b"13"),
(b"content-type", b"text/html; charset=utf-8"),
],
}
BODY1 = {"type": "http.response.body", "body": b"Hello"}
BODY2 = {"type": "http.response.body", "body": b", world!"}
async def hellowor... | start = {'type': 'http.response.start', 'status': 200, 'headers': [(b'content-length', b'13'), (b'content-type', b'text/html; charset=utf-8')]}
body1 = {'type': 'http.response.body', 'body': b'Hello'}
body2 = {'type': 'http.response.body', 'body': b', world!'}
async def helloworld(scope, receive, send) -> None:
aw... |
load("@fbcode_macros//build_defs:platform_utils.bzl", "platform_utils")
def get_ppx_bin():
return "third-party-buck/{}/build/ocaml-lwt_ppx/lib/lwt_ppx/ppx.exe".format(platform_utils.get_platform_for_base_path(get_base_path()))
| load('@fbcode_macros//build_defs:platform_utils.bzl', 'platform_utils')
def get_ppx_bin():
return 'third-party-buck/{}/build/ocaml-lwt_ppx/lib/lwt_ppx/ppx.exe'.format(platform_utils.get_platform_for_base_path(get_base_path())) |
def append_attr(obj, attr, value):
"""
Appends value to object attribute
Attribute may be undefined
For example:
append_attr(obj, 'test', 1)
append_attr(obj, 'test', 2)
assert obj.test == [1, 2]
"""
try:
getattr(obj, attr).append(value)
exce... | def append_attr(obj, attr, value):
"""
Appends value to object attribute
Attribute may be undefined
For example:
append_attr(obj, 'test', 1)
append_attr(obj, 'test', 2)
assert obj.test == [1, 2]
"""
try:
getattr(obj, attr).append(value)
exce... |
"""DataSet base class
"""
class DataSet(object):
"""Base DataSet
"""
def __init__(self, common_params, dataset_params):
"""
common_params: A params dict
dataset_params: A params dict
"""
raise NotImplementedError
def batch(self):
"""Get batch
"""
raise NotImplementedError | """DataSet base class
"""
class Dataset(object):
"""Base DataSet
"""
def __init__(self, common_params, dataset_params):
"""
common_params: A params dict
dataset_params: A params dict
"""
raise NotImplementedError
def batch(self):
"""Get batch
"""
raise... |
# -*- coding: utf-8 -*-
class Solution:
def maxProduct(self, nums):
best_max, current_max, current_min = float('-inf'), 1, 1
for num in nums:
current_max, current_min = max(current_min * num, num, current_max * num),\
min(current_min * num, num, current_max * num)
... | class Solution:
def max_product(self, nums):
(best_max, current_max, current_min) = (float('-inf'), 1, 1)
for num in nums:
(current_max, current_min) = (max(current_min * num, num, current_max * num), min(current_min * num, num, current_max * num))
best_max = max(best_max, c... |
#!/usr/bin/env python3
"""
.. automodule:: test_phile.test_PySide2
.. automodule:: test_phile.test_asyncio
.. automodule:: test_phile.test_builtins
.. automodule:: test_phile.test_cmd
.. automodule:: test_phile.test_configuration
.. automodule:: test_phile.test_data
.. automodule:: test_phile.test_datetime
.. automodul... | """
.. automodule:: test_phile.test_PySide2
.. automodule:: test_phile.test_asyncio
.. automodule:: test_phile.test_builtins
.. automodule:: test_phile.test_cmd
.. automodule:: test_phile.test_configuration
.. automodule:: test_phile.test_data
.. automodule:: test_phile.test_datetime
.. automodule:: test_phile.test_ima... |
def limpar(tela):
telaPrincipal = tela
lista = [telaPrincipal.telefone, telaPrincipal.nome,
telaPrincipal.cep,
telaPrincipal.end,
telaPrincipal.numero,
telaPrincipal.bairro,
telaPrincipal.ref,
telaPrincipal.complemento, telaPrincipal... | def limpar(tela):
tela_principal = tela
lista = [telaPrincipal.telefone, telaPrincipal.nome, telaPrincipal.cep, telaPrincipal.end, telaPrincipal.numero, telaPrincipal.bairro, telaPrincipal.ref, telaPrincipal.complemento, telaPrincipal.devendo, telaPrincipal.taxa_2]
for i in lista:
i.clear()
tela... |
#Embedded file name: ACEStream\version.pyo
VERSION = '2.0.8.7'
VERSION_REV = '2191'
VERSION_DATE = '2013/03/28 18:36:41'
| version = '2.0.8.7'
version_rev = '2191'
version_date = '2013/03/28 18:36:41' |
credentials = {
'ldap': {
'user': '',
'pass': ''
},
'rocket': {
'user': '',
'pass': ''
}
} | credentials = {'ldap': {'user': '', 'pass': ''}, 'rocket': {'user': '', 'pass': ''}} |
# https://edabit.com/challenge/KWoj7kWiHRqJtG6S2
# There is a single operator in Python
# capable of providing the remainder of a division operation.
# Two numbers are passed as parameters.
# The first parameter divided by the second parameter will have a remainder, possibly zero.
# Return that value.
def... | def remainder(int1: int, int2: int) -> int:
leftovers = int1 % int2
return leftovers
print(remainder(5, 5)) |
#! /usr/bin/python
##
# @file
# This file is part of SeisSol.
#
# @author Sebastian Rettenberger (sebastian.rettenberger AT tum.de, http://www5.in.tum.de/wiki/index.php/Sebastian_Rettenberger)
#
# @section LICENSE
# Copyright (c) 2016, SeisSol Group
# All rights reserved.
#
# Redistribution and use in source and binar... | asagi_prog_src = '\n#include <asagi.h>\n\nint main() {\n asagi::Grid* grid = asagi::Grid::create();\n \n return 0;\n}\n'
def check_pkg(context, lib):
context.Message('Checking for ASAGI... ')
ret = context.TryAction("pkg-config --exists '%s'" % lib)[0]
context.Result(ret)
return ret
def check... |
# Script Name : data.py
# Author : Howard Zhang
# Created : 14th June 2018
# Last Modified : 14th June 2018
# Version : 1.0
# Modifications :
# Description : The struct of data to sort and display.
class Data:
# Total of data to sort
data_count = 32
def __init__(self,... | class Data:
data_count = 32
def __init__(self, value):
self.value = value
self.set_color()
def set_color(self, rgba=None):
if not rgba:
rgba = (0, 1 - self.value / (self.data_count * 2), self.value / (self.data_count * 2) + 0.5, 1)
self.color = rgba |
class Plugin:
def __init__(self):
pass
def execute(self):
print("HELLO WORLD 2. :D")
| class Plugin:
def __init__(self):
pass
def execute(self):
print('HELLO WORLD 2. :D') |
class NotAuthenticatedError(Exception):
pass
class AuthenticationFailedError(Exception):
pass
| class Notauthenticatederror(Exception):
pass
class Authenticationfailederror(Exception):
pass |
OPERATION_TYPES = [
'ADD',
'REMOVE',
'CHANGE_DATA',
'PATCH_METADATA'
]
USER_CHANGEABLE_RELEASE_STATUSES = {
'MUTABLE': [
'DRAFT',
'PENDING_RELEASE',
'PENDING_DELETE'
],
'IMMUTABLE': [
'RELEASED',
'DELETED'
]
}
RELEASE_STATUS_ALLOWED_TRANSITIONS =... | operation_types = ['ADD', 'REMOVE', 'CHANGE_DATA', 'PATCH_METADATA']
user_changeable_release_statuses = {'MUTABLE': ['DRAFT', 'PENDING_RELEASE', 'PENDING_DELETE'], 'IMMUTABLE': ['RELEASED', 'DELETED']}
release_status_allowed_transitions = {'DRAFT': ['PENDING_RELEASE'], 'PENDING_RELEASE': ['DRAFT'], 'PENDING_DELETE': []... |
total_taxis = 100
size = 4
expected_customers = 120
size_without_driver = size - 1
number_of_cars_required = expected_customers/size_without_driver
print(f"number of cars required {number_of_cars_required}")
| total_taxis = 100
size = 4
expected_customers = 120
size_without_driver = size - 1
number_of_cars_required = expected_customers / size_without_driver
print(f'number of cars required {number_of_cars_required}') |
lst = ["Peace", "of", "the", "mind", 2, 4, 7]
for i in lst:
place = "".join(map(str, lst))
print(place)
| lst = ['Peace', 'of', 'the', 'mind', 2, 4, 7]
for i in lst:
place = ''.join(map(str, lst))
print(place) |
class DebuggerStepperBoundaryAttribute(Attribute,_Attribute):
"""
Indicates the code following the attribute is to be executed in run,not step,mode.
DebuggerStepperBoundaryAttribute()
"""
def __init__(self,*args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...... | class Debuggerstepperboundaryattribute(Attribute, _Attribute):
"""
Indicates the code following the attribute is to be executed in run,not step,mode.
DebuggerStepperBoundaryAttribute()
"""
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init... |
choice = ''
def add(num1, num2):
return num1 + num2
def subs(num1, num2):
return num1 - num2
def mult(num1, num2):
return num1 * num2
def div(num1, num2):
return num1 / num2
def mod(num1, num2):
return num1 % num2
def power(num1, num2):
result = 1
for i in range(num2):
result *=... | choice = ''
def add(num1, num2):
return num1 + num2
def subs(num1, num2):
return num1 - num2
def mult(num1, num2):
return num1 * num2
def div(num1, num2):
return num1 / num2
def mod(num1, num2):
return num1 % num2
def power(num1, num2):
result = 1
for i in range(num2):
result *... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# */AIPND/intropylab-classifying-images/print_functions_for_lab_checks.py
#
# PROGRAMMER: Jennifer S.
# DATE CREATED: 05/14/2018 ... | def check_command_line_arguments(in_arg):
"""
For Lab: Classifying Images - 7. Command Line Arguments
Prints each of the command line arguments passed in as parameter in_arg,
assumes you defined all three command line arguments as outlined in
'7. Command Line Arguments'
Parameters:
in_arg... |
#!/usr/bin/env python
'''\
Given two strings, remove all characters contained in the latter from
the former. Note that order is preserved. For example:
"ab", "b" -> "a"
"abcdabcd", "acec" -> "bdbd"
What is the run-time of your algorithm? How much memory does it use? Is it
optimal?
linear search... | """Given two strings, remove all characters contained in the latter from
the former. Note that order is preserved. For example:
"ab", "b" -> "a"
"abcdabcd", "acec" -> "bdbd"
What is the run-time of your algorithm? How much memory does it use? Is it
optimal?
linear search with memcpy: O(nh**2)... |
ACACA_AcCoA = 34
ACACA_HCO3 = 2100
ACAT2_AcCoA = 29
ACLY_Citrate = 78
ACLY_CoA = 14
ACO2_Citrate = 480
ACO2_Isocitrate = 120
ACOT12_AcCoA = 47
ACOT13_AcCoA = 47
ACSS1_Acetate = 73
ACSS1_CoA = 11
ACSS2_Acetate = 73
ACSS2_CoA = 11
CS_AcCoA = 5
CS_OXa = 5.9
EP300_AcCoA = 0.28
FASN_AcCoA = 7
FASN_HCO3 = 21... | acaca__ac_co_a = 34
acaca_hco3 = 2100
acat2__ac_co_a = 29
acly__citrate = 78
acly__co_a = 14
aco2__citrate = 480
aco2__isocitrate = 120
acot12__ac_co_a = 47
acot13__ac_co_a = 47
acss1__acetate = 73
acss1__co_a = 11
acss2__acetate = 73
acss2__co_a = 11
cs__ac_co_a = 5
cs_o_xa = 5.9
ep300__ac_co_a = 0.28
fasn__ac_co_a = ... |
# Set the following variables and rename to credentials.py
USER = RPC_USERNAME
PASSWORD = RPC_PASSWORD
SITE_SECRET_KEY = BYTE_STRING
| user = RPC_USERNAME
password = RPC_PASSWORD
site_secret_key = BYTE_STRING |
def GetXSection(fileName): #[pb]
#Cross Section derived from sample name using https://cms-gen-dev.cern.ch/xsdb/
#TODO UL QCD files have PSWeights in their name, but xsdb does not include it in its name
fileName = fileName.replace("PSWeights_", "")
#TODO: UL Single Top xSection only defined for filename without inc... | def get_x_section(fileName):
file_name = fileName.replace('PSWeights_', '')
file_name = fileName.replace('5f_InclusiveDecays_', '5f_')
file_name = fileName.replace('tZq_ll_4f_ckm_NLO_TuneCP5_13TeV-amcatnlo-pythia8', 'tZq_ll_4f_ckm_NLO_TuneCP5_PSweights_13TeV-amcatnlo-pythia8')
if fileName.find('ST_t-cha... |
"""
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you.
The tropical island has its own currency and is entirely cash-only. The gold coins used there have a little picture of a starfi... | """
--- Day 1: Report Repair ---
After saving Christmas five years in a row, you've decided to take a vacation at a nice resort on a tropical island. Surely, Christmas will go on without you.
The tropical island has its own currency and is entirely cash-only. The gold coins used there have a little picture of a starfi... |
# -*- coding: utf-8 -*-
"""
To-Do application
"""
def add(todos):
"""
Add a task
"""
task = input('New task: ')
todos.append({
'task': task,
'done': False
})
def delete(todos, index=None):
"""
Delete one or all tasks
"""
if index is not None:
del todos... | """
To-Do application
"""
def add(todos):
"""
Add a task
"""
task = input('New task: ')
todos.append({'task': task, 'done': False})
def delete(todos, index=None):
"""
Delete one or all tasks
"""
if index is not None:
del todos[index]
else:
del todos[:]
def get_... |
# Copyright 2019 The Bazel Authors. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable la... | """A test rule that compares two binary files.
The rule uses a Bash command (diff) on Linux/macOS/non-Windows, and a cmd.exe
command (fc.exe) on Windows (no Bash is required).
"""
def _runfiles_path(f):
if f.root.path:
return f.path[len(f.root.path) + 1:]
else:
return f.path
def _diff_test_im... |
class Solution:
"""
@param numbers: Give an array numbers of n integer
@param target: An integer
@return: return the sum of the three integers, the sum closest target.
"""
def threeSumClosest(self, numbers, target):
numbers.sort()
ans = None
for i in range(len(numbers)):... | class Solution:
"""
@param numbers: Give an array numbers of n integer
@param target: An integer
@return: return the sum of the three integers, the sum closest target.
"""
def three_sum_closest(self, numbers, target):
numbers.sort()
ans = None
for i in range(len(numbers)... |
variant = ["_clear", "_scratched", "_crystal", "_dim", "_dark", "_bright", "_ghostly", "_ethereal", "_foreboding", "_strong"]
colors = ["white", "orange", "magenta", "light_blue", "yellow", "lime", "pink", "gray", "silver", "cyan", "purple", "blue", "brown", "green", "red", "black"]
for prefix in variant:
with open... | variant = ['_clear', '_scratched', '_crystal', '_dim', '_dark', '_bright', '_ghostly', '_ethereal', '_foreboding', '_strong']
colors = ['white', 'orange', 'magenta', 'light_blue', 'yellow', 'lime', 'pink', 'gray', 'silver', 'cyan', 'purple', 'blue', 'brown', 'green', 'red', 'black']
for prefix in variant:
with open... |
[
{
'date': '2011-01-01',
'description': 'Nieuwjaarsdag',
'locale': 'nl-NL',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2011-04-22',
'description': 'Goede Vrijdag',
'locale': 'nl-NL',
'notes': '',
'region': ''... | [{'date': '2011-01-01', 'description': 'Nieuwjaarsdag', 'locale': 'nl-NL', 'notes': '', 'region': '', 'type': 'NF'}, {'date': '2011-04-22', 'description': 'Goede Vrijdag', 'locale': 'nl-NL', 'notes': '', 'region': '', 'type': 'NRV'}, {'date': '2011-04-24', 'description': 'Eerste Paasdag', 'locale': 'nl-NL', 'notes': ''... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
__author__ = 'liying'
class Latest(object):
def __init__(self):
self.package = None
self.latest_version = None
| __author__ = 'liying'
class Latest(object):
def __init__(self):
self.package = None
self.latest_version = None |
ES_HOST = 'localhost:9200'
ES_INDEX = 'pending-dgidb'
ES_DOC_TYPE = 'association'
API_PREFIX = 'dgidb'
API_VERSION = ''
| es_host = 'localhost:9200'
es_index = 'pending-dgidb'
es_doc_type = 'association'
api_prefix = 'dgidb'
api_version = '' |
class CSVUpperTriangularPlugin:
def input(self, filename):
infile = open(filename, 'r')
self.colnames = infile.readline().strip().split(',') # Assume rownames=colnames
self.ADJ = []
for line in infile:
self.ADJ.append(line.strip().split(',')[1:])
def run(self):
pas... | class Csvuppertriangularplugin:
def input(self, filename):
infile = open(filename, 'r')
self.colnames = infile.readline().strip().split(',')
self.ADJ = []
for line in infile:
self.ADJ.append(line.strip().split(',')[1:])
def run(self):
pass
def output(se... |
"""
Python program to remove an empty element from a list.
"""
list_in = ['Hello', 34, 45, '', 40]
# result = ['Hello', 34, 45, 40]
for item in list_in:
if not item:
list_in.remove(item)
print(list_in) | """
Python program to remove an empty element from a list.
"""
list_in = ['Hello', 34, 45, '', 40]
for item in list_in:
if not item:
list_in.remove(item)
print(list_in) |
class GithubError(Exception):
pass
class GithubAPIError(GithubError):
pass
| class Githuberror(Exception):
pass
class Githubapierror(GithubError):
pass |
"""
if the number of petals is greater than the length of the list, reduce the number of petals by the length
loop though list, checking if the number of petals is greater than the length of the list
reduce the number of petals by the length of the list after every iteration until the number is less than or equal to
l... | """
if the number of petals is greater than the length of the list, reduce the number of petals by the length
loop though list, checking if the number of petals is greater than the length of the list
reduce the number of petals by the length of the list after every iteration until the number is less than or equal to
l... |
# Write a function to find the longest common prefix string amongst an array of strings.
class Solution(object):
def longestCommonPrefix(self, strs):
if len(strs) == 0:
return ""
standard = strs[0]
longest_length = len(standard)
for string in strs[1:]:
index ... | class Solution(object):
def longest_common_prefix(self, strs):
if len(strs) == 0:
return ''
standard = strs[0]
longest_length = len(standard)
for string in strs[1:]:
index = 0
while index < len(string) and index < len(standard) and (string[index] ... |
# Copyright Notice:
# Copyright 2016-2019 DMTF. All rights reserved.
# License: BSD 3-Clause License. For full text see link: https://github.com/DMTF/Redfish-Interface-Emulator/blob/master/LICENSE.md
# Redfish template
REDFISH_TEMPLATE = {
"@odata.context": "{rest_base}$metadata#Systems/cs_puid",
"@odata.id... | redfish_template = {'@odata.context': '{rest_base}$metadata#Systems/cs_puid', '@odata.id': '{rest_base}Systems/{cs_puid}', '@odata.type': '#ComputerSystem.1.0.0.ComputerSystem', 'Id': None, 'Name': 'WebFrontEnd483', 'SystemType': 'Virtual', 'AssetTag': 'Chicago-45Z-2381', 'Manufacturer': 'Redfish Computers', 'Model': '... |
class Solution:
def findMaxConsecutiveOnes(self, nums: List[int]) -> int:
consecutive = 0
ret = 0
for i in range(len(nums) + 1):
if i == len(nums) or nums[i] == 0:
ret = max(ret, consecutive)
consecutive = 0
else:
consec... | class Solution:
def find_max_consecutive_ones(self, nums: List[int]) -> int:
consecutive = 0
ret = 0
for i in range(len(nums) + 1):
if i == len(nums) or nums[i] == 0:
ret = max(ret, consecutive)
consecutive = 0
else:
co... |
""" Router memory information """
class Mem(object):
""" Router memory information """
def __init__(self, usage, total, hz, type):
self._usage = usage
self._total = total
self._hz = hz
self._type = type
def get_usage(self):
return self._usage
def get_total(se... | """ Router memory information """
class Mem(object):
""" Router memory information """
def __init__(self, usage, total, hz, type):
self._usage = usage
self._total = total
self._hz = hz
self._type = type
def get_usage(self):
return self._usage
def get_total(sel... |
def get_max_increasing_sub_sequence(arr):
i = 1
n = len(arr)
j = 0
dp = arr[:]
while i < n:
while j < i:
if dp[j] < dp[i] < dp[i] + dp[j]:
dp[i] = dp[j] + dp[i]
j += 1
i += 1
return max(dp)
if __name__ == '__main__':
# arr = [1, 101, ... | def get_max_increasing_sub_sequence(arr):
i = 1
n = len(arr)
j = 0
dp = arr[:]
while i < n:
while j < i:
if dp[j] < dp[i] < dp[i] + dp[j]:
dp[i] = dp[j] + dp[i]
j += 1
i += 1
return max(dp)
if __name__ == '__main__':
test_cases = int(in... |
# Author : BIZZOZZERO Nicolas
# Completed on Sun, 24 Jan 2016, 22:38
#
# This program find the solution of the problem 1 of the Project Euler.
# The problem is the following :
#
# If we list all the natural numbers below 10 that are multiples of 3 or
# 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
... | def is_divisible_by(n: int, divisor: int) -> bool:
"""Return True if n is divisible by divisor, False otherwise. """
return n % divisor == 0
def main():
set_of_multiples = set()
for i in range(1001):
if is_divisible_by(i, 3) or is_divisible_by(i, 5):
set_of_multiples.add(i)
prin... |
# -*- coding: utf-8 -*-
########################################
# Created on Sun Feb 11 13:35:07 2018
#
# @author: guenther.wasser
########################################
#
# Problem 7:
# ----------
#
# Implement a function that meets the specifications below.
#
# def applyF_filterG(L, f, g):
# """
# Assum... | def f(i):
"""Add 2 to a value
Args:
i ([int]): integer value
Returns:
[int]: integer value
"""
return i + 2
def g(i):
"""Evaluates value to be greater than 5
Args:
i ([int]): integer value
Returns:
[bool]: True if value is greater than 5
"""
return i > 5
... |
# this file defines available actions
# reference: https://github.com/TeamFightingICE/FightingICE/blob/master/python/Feature%20Extractor%20in%20Python/action.py
class Actions:
def __init__(self):
# map digits to actions
self.actions = [
"NEUTRAL",
"STAND",
"FORWA... | class Actions:
def __init__(self):
self.actions = ['NEUTRAL', 'STAND', 'FORWARD_WALK', 'DASH', 'BACK_STEP', 'CROUCH', 'JUMP', 'FOR_JUMP', 'BACK_JUMP', 'AIR', 'STAND_GUARD', 'CROUCH_GUARD', 'AIR_GUARD', 'STAND_GUARD_RECOV', 'CROUCH_GUARD_RECOV', 'AIR_GUARD_RECOV', 'STAND_RECOV', 'CROUCH_RECOV', 'AIR_RECOV',... |
#!/usr/bin/python3
"""
implement strongly connected components algorithm using 'SCC.txt' adjusency
list.
Problem answer (first 5): [434821, 968, 459, 313, 211]
"""
| """
implement strongly connected components algorithm using 'SCC.txt' adjusency
list.
Problem answer (first 5): [434821, 968, 459, 313, 211]
""" |
'''
Created on 16-10-2012
@author: Jacek Przemieniecki
'''
class Mixture(object):
def _calc_groups(self):
self._groups = {}
groups = self._groups
tot_grps = 0
for mol in self.moles:
m_groups = self.moles[mol].get_groups()
for m_grp in m_groups:... | """
Created on 16-10-2012
@author: Jacek Przemieniecki
"""
class Mixture(object):
def _calc_groups(self):
self._groups = {}
groups = self._groups
tot_grps = 0
for mol in self.moles:
m_groups = self.moles[mol].get_groups()
for m_grp in m_groups:
... |
extractable_regions = ["TextRegion",
"ImageRegion",
"LineDrawingRegion",
"GraphicRegion",
"TableRegion",
"ChartRegion",
"MapRegion",
"SeparatorRegion",
... | extractable_regions = ['TextRegion', 'ImageRegion', 'LineDrawingRegion', 'GraphicRegion', 'TableRegion', 'ChartRegion', 'MapRegion', 'SeparatorRegion', 'MathsRegion', 'ChemRegion', 'MusicRegion', 'AdvertRegion', 'NoiseRegion', 'NoiseRegion', 'UnknownRegion', 'CustomRegion', 'TextLine']
text_count_supported_elems = ['Te... |
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
""" Score handler
Score operation handler"""
class Score(object):
def __init__(self, kind):
""" init about importer
This module assume about import module.
Argument of 'kind' indicates the way of judging.
In __init__, dicide what ... | """ Score handler
Score operation handler"""
class Score(object):
def __init__(self, kind):
""" init about importer
This module assume about import module.
Argument of 'kind' indicates the way of judging.
In __init__, dicide what module is need."""
score_dir = kind
... |
"""Repository rule for ROCm autoconfiguration.
`rocm_configure` depends on the following environment variables:
* `TF_NEED_ROCM`: Whether to enable building with ROCm.
* `GCC_HOST_COMPILER_PATH`: The GCC host compiler path
* `ROCM_TOOLKIT_PATH`: The path to the ROCm toolkit. Default is
`/opt/rocm`.
* `TF_... | """Repository rule for ROCm autoconfiguration.
`rocm_configure` depends on the following environment variables:
* `TF_NEED_ROCM`: Whether to enable building with ROCm.
* `GCC_HOST_COMPILER_PATH`: The GCC host compiler path
* `ROCM_TOOLKIT_PATH`: The path to the ROCm toolkit. Default is
`/opt/rocm`.
* `TF_... |
# Copyright 2016 Google Inc.
#
# 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,... | def cram_test(name, srcs, deps=[]):
for s in srcs:
testname = name + '_' + s
script = testname + '_script.sh'
gr = '_gen_' + script
native.genrule(name=gr, srcs=[s], outs=[script], cmd="echo 'exec $${TEST_SRCDIR}/copybara/integration/cram " + '--xunit-file=$$XML_OUTPUT_FILE $$0\' > "... |
class Graph:
"""
The purpose of the class is to provide a clean way to define a graph for
a searching algorithm:
"""
def __init__(self):
self.edges = {} # dictionary of edges NODE: NEIGHBOURS
self.weights = {} # dictionary of NODES and their COSTS
self.herist={}
... | class Graph:
"""
The purpose of the class is to provide a clean way to define a graph for
a searching algorithm:
"""
def __init__(self):
self.edges = {}
self.weights = {}
self.herist = {}
def neighbours(self, node):
"""
The function returns the neighbour... |
#
# PySNMP MIB module RADLAN-DHCP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADLAN-DHCP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:01:12 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, value_range_constraint, single_value_constraint) ... |
def lerp(a, b, amount):
return (amount * a) + ((1 - amount) * b)
def smoothstep(edge0, edge1, amount):
x = clamp((amount - edge0) / (edge1 - edge0), 0.0, 1.0)
return x * x * (3 - 2 * x)
def smootherstep(edge0, edge1, amount):
x = clamp((amount - edge0) / (edge1 - edge0), 0.0, 1.0)
return x ... | def lerp(a, b, amount):
return amount * a + (1 - amount) * b
def smoothstep(edge0, edge1, amount):
x = clamp((amount - edge0) / (edge1 - edge0), 0.0, 1.0)
return x * x * (3 - 2 * x)
def smootherstep(edge0, edge1, amount):
x = clamp((amount - edge0) / (edge1 - edge0), 0.0, 1.0)
return x * x * x * (... |
# Time: O(n); Space: O(n)
def next_greater_element(nums1, nums2):
stack = []
d = {}
i = len(nums2) - 1
while i >= 0:
num = nums2[i]
if not stack:
d[num] = -1
stack.append(num)
i -= 1
elif stack[-1] > num:
d[num] = stack[-1]
... | def next_greater_element(nums1, nums2):
stack = []
d = {}
i = len(nums2) - 1
while i >= 0:
num = nums2[i]
if not stack:
d[num] = -1
stack.append(num)
i -= 1
elif stack[-1] > num:
d[num] = stack[-1]
stack.append(num)
... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
DEFAULT_HOST = '127.0.01'
DEFAULT_PORT = 3306
DEFAULT_USER_NAME = 'root'
DEFAULT_USER_PASS = 'root123'
DEFAULT_USER_LIST = 'accounts/user.list'
DEFAULT_WORD_LIST = 'accounts/word.list'
# text color in console | default_host = '127.0.01'
default_port = 3306
default_user_name = 'root'
default_user_pass = 'root123'
default_user_list = 'accounts/user.list'
default_word_list = 'accounts/word.list' |
# mock resource classes from peeringdb-py client
class Organization:
pass
class Facility:
pass
class Network:
pass
class InternetExchange:
pass
class InternetExchangeFacility:
pass
class InternetExchangeLan:
pass
class InternetExchangeLanPrefix:
pass
class NetworkFacility:
... | class Organization:
pass
class Facility:
pass
class Network:
pass
class Internetexchange:
pass
class Internetexchangefacility:
pass
class Internetexchangelan:
pass
class Internetexchangelanprefix:
pass
class Networkfacility:
pass
class Networkixlan:
pass
class Networkcontact... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.