content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# --------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
#
# Code generated by Microsoft (R) AutoRest Code Generator.
# Changes may cause incor... | def maintenance_public_configuration_list(client):
return client.list()
def maintenance_public_configuration_show(client, resource_name):
return client.get(resource_name=resource_name)
def maintenance_applyupdate_show(client, resource_group_name, provider_name, resource_type, resource_name, apply_update_name)... |
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
class ADOConstants:
"""
Constants specific to Azure Devops API clients and classes
"""
work_item_relations = {
'parent': 'System.LinkTypes.Hierarchy-Reverse',
'child': 'System.LinkTypes.Hierarchy-Forward'
}
| class Adoconstants:
"""
Constants specific to Azure Devops API clients and classes
"""
work_item_relations = {'parent': 'System.LinkTypes.Hierarchy-Reverse', 'child': 'System.LinkTypes.Hierarchy-Forward'} |
class Solution:
def subarraySum(self, nums: List[int], k: int) -> int:
cum_sum = [0]
for num in nums:
cum_sum.append(num+cum_sum[-1])
cum_sum.pop(0)
seen_map = {0:1}
ans = 0
for csum in cum_sum:
if csum-k in seen_map:
ans+=s... | class Solution:
def subarray_sum(self, nums: List[int], k: int) -> int:
cum_sum = [0]
for num in nums:
cum_sum.append(num + cum_sum[-1])
cum_sum.pop(0)
seen_map = {0: 1}
ans = 0
for csum in cum_sum:
if csum - k in seen_map:
ans... |
height = float(input("Please enter the height in m: \n"))
weight = float(input("Please enter the weight in kg: \n"))
bmi = weight / height ** 2
print(int(bmi)) | height = float(input('Please enter the height in m: \n'))
weight = float(input('Please enter the weight in kg: \n'))
bmi = weight / height ** 2
print(int(bmi)) |
#The file contains only the CTC function and the proposed model format. (Not the complete code)
def ctc_lambda_func(args):
y_pred, labels, input_length, label_length = args
y_pred = y_pred[:, 2:, :]
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
def train(img_w, load=False):
# I... | def ctc_lambda_func(args):
(y_pred, labels, input_length, label_length) = args
y_pred = y_pred[:, 2:, :]
return K.ctc_batch_cost(labels, y_pred, input_length, label_length)
def train(img_w, load=False):
img_h = 64
conv_filters = 16
kernel_size = (3, 3)
pool_size = 2
time_dense_size = 32... |
# -*- coding: utf-8 -*-
__title__ = 'ahegao'
__description__ = 'Ahegao API wrapper'
__url__ = 'https://github.com/AhegaoTeam/AhegaoAPI'
__version__ = '1.0.1'
__build__ = 11
__author__ = 'SantaSpeen'
__author_email__ = 'admin@ahegao.ovh'
__license__ = "MIT"
__copyright__ = 'Copyright 2022 Ahegao Team'
| __title__ = 'ahegao'
__description__ = 'Ahegao API wrapper'
__url__ = 'https://github.com/AhegaoTeam/AhegaoAPI'
__version__ = '1.0.1'
__build__ = 11
__author__ = 'SantaSpeen'
__author_email__ = 'admin@ahegao.ovh'
__license__ = 'MIT'
__copyright__ = 'Copyright 2022 Ahegao Team' |
# design in each module
class Cube(object):
def __init__(self):
pass
class Rhombic(object):
def __init__(self):
pass
class Sphere(object):
def __init__(self):
pass
| class Cube(object):
def __init__(self):
pass
class Rhombic(object):
def __init__(self):
pass
class Sphere(object):
def __init__(self):
pass |
# write a program to print out all the numbers from 0 to 100 that are divisble by 7
for i in range(0, 101, 7):
print(i)
| for i in range(0, 101, 7):
print(i) |
class Solution:
def solve(self, matrix):
pq = [[0, i] for i in range(len(matrix[0]))]
for r in range(len(matrix)):
new_pq = []
for c in range(len(matrix[0])):
if pq[0][1] == c:
top = heappop(pq)
heappush(new_pq, [pq[0]... | class Solution:
def solve(self, matrix):
pq = [[0, i] for i in range(len(matrix[0]))]
for r in range(len(matrix)):
new_pq = []
for c in range(len(matrix[0])):
if pq[0][1] == c:
top = heappop(pq)
heappush(new_pq, [pq[0][... |
def rotate(text, key):
num_letters = 26
key = key % num_letters
l_min = ord('a')
u_min = ord('A')
text = list(
map((lambda s:
s if not s.isalpha()
else chr(l_min + (((ord(s) - l_min) + key) % num_letters))
... | def rotate(text, key):
num_letters = 26
key = key % num_letters
l_min = ord('a')
u_min = ord('A')
text = list(map(lambda s: s if not s.isalpha() else chr(l_min + (ord(s) - l_min + key) % num_letters) if s.islower() else chr(u_min + (ord(s) - u_min + key) % num_letters), list(text)))
return ''.jo... |
# coding: utf-8
def sumSquare(n):
'''takes a positive integer n and returns sum of dquares of all the positive integers smaller than n'''
if n < 0:
return 'Needs a positive number. But Negative given'
else:
return sum([x**2 for x in range(1, n)])
print(sumSquare(4))
| def sum_square(n):
"""takes a positive integer n and returns sum of dquares of all the positive integers smaller than n"""
if n < 0:
return 'Needs a positive number. But Negative given'
else:
return sum([x ** 2 for x in range(1, n)])
print(sum_square(4)) |
#
# @lc app=leetcode id=327 lang=python3
#
# [327] Count of Range Sum
#
# https://leetcode.com/problems/count-of-range-sum/description/
#
# algorithms
# Hard (35.94%)
# Likes: 995
# Dislikes: 116
# Total Accepted: 48.9K
# Total Submissions: 135.4K
# Testcase Example: '[-2,5,-1]\n-2\n2'
#
# Given an integer array... | class Solution:
def __init__(self):
self.prefix_sum = [0]
self.count = 0
def count_range_sum(self, nums: List[int], lower: int, upper: int) -> int:
running_sum = 0
for i in range(len(nums)):
running_sum += nums[i]
self.prefix_sum.append(running_sum)
... |
# Author: btjanaka (Bryon Tjanaka)
# Problem: (HackerRank) the-minion-game
# Title: The Minion Game
# Link: https://www.hackerrank.com/challenges/the-minion-game/
# Idea: The basic idea is to count all substrings for each player, but we can't
# just list out all the substrings because that is O(n^2), and the string can... | def minion_game(string):
consonants = 0
vowels = 0
for i in range(len(string)):
score = len(string) - i
if string[i] in 'AEIOU':
vowels += score
else:
consonants += score
if consonants > vowels:
print(f'Stuart {consonants}')
elif consonants < v... |
class LevenshteinCostCalculator:
"""
Cost calculator using Levenshtein minimum edit distance costs of 1 for insertion and deletion and 2 for substitution
(given a letter is not substituted for itself).
Can also be used as a basic cost calculator for non-letter inputs.
"""
def insertion_cost(sel... | class Levenshteincostcalculator:
"""
Cost calculator using Levenshtein minimum edit distance costs of 1 for insertion and deletion and 2 for substitution
(given a letter is not substituted for itself).
Can also be used as a basic cost calculator for non-letter inputs.
"""
def insertion_cost(sel... |
class APIException(OSError):
def __init__(self, message = None, url="https://Bungie.net/"):
msg = "There was an error when accessing the Destiny API"
if message is not None:
msg += ": " + message
super().__init__(msg)
self._url = url
self._message = msg... | class Apiexception(OSError):
def __init__(self, message=None, url='https://Bungie.net/'):
msg = 'There was an error when accessing the Destiny API'
if message is not None:
msg += ': ' + message
super().__init__(msg)
self._url = url
self._message = msg
@prope... |
IN_PREFIXES = {
'BA',
'BS',
'BUS MS',
'Certificate',
'Graduate Certificate',
'MA',
'Master of Arts',
'Master\'s',
'MBA/MA',
'ME Certificate',
'ME MD/PhD Program',
'ME Program',
'MS',
'P.B.C.',
'Post Bacc Certificate',
'Post Baccalaureate Certificate',
... | in_prefixes = {'BA', 'BS', 'BUS MS', 'Certificate', 'Graduate Certificate', 'MA', 'Master of Arts', "Master's", 'MBA/MA', 'ME Certificate', 'ME MD/PhD Program', 'ME Program', 'MS', 'P.B.C.', 'Post Bacc Certificate', 'Post Baccalaureate Certificate', "Post Master's Cert", 'Post-Baccalaureate Certificate', 'Post-Masters ... |
class Disc:
_instance_count = 0
def __init__(self, name, symbol, code=None):
cls = type(self)
self.code = cls._instance_count if code is None else code
self.name = name
self.symbol = symbol
cls._instance_count += 1 if cls._instance_count < 1000 else 0
def __int__(se... | class Disc:
_instance_count = 0
def __init__(self, name, symbol, code=None):
cls = type(self)
self.code = cls._instance_count if code is None else code
self.name = name
self.symbol = symbol
cls._instance_count += 1 if cls._instance_count < 1000 else 0
def __int__(se... |
def list_towers():
raise NotImplementedError
def create_tower(body):
raise NotImplementedError
def get_tower(tower_id):
raise NotImplementedError
def update_tower(tower_id, body):
raise NotImplementedError
def delete_tower(tower_id):
raise NotImplementedError
| def list_towers():
raise NotImplementedError
def create_tower(body):
raise NotImplementedError
def get_tower(tower_id):
raise NotImplementedError
def update_tower(tower_id, body):
raise NotImplementedError
def delete_tower(tower_id):
raise NotImplementedError |
# sample input
array = [ 2, 1, 2, 2, 2, 3, 4, 2 ]
to_move = 2
expected = [4, 1, 3, 2, 2, 2, 2, 2]
# Simple testing function
def test(expected, actual):
if expected == actual:
print('Working')
else:
print('Not working, expected:', expected, 'actual:', actual)
# O(n) solution
def move_element_to_... | array = [2, 1, 2, 2, 2, 3, 4, 2]
to_move = 2
expected = [4, 1, 3, 2, 2, 2, 2, 2]
def test(expected, actual):
if expected == actual:
print('Working')
else:
print('Not working, expected:', expected, 'actual:', actual)
def move_element_to_end(array, toMove):
i = 0
swap = len(array) - 1
... |
#
# @lc app=leetcode.cn id=72 lang=python3
#
# [72] edit-distance
#
None
# @lc code=end | None |
"""
Update Index
"""
name = "02_upgrade_users_unique_email"
dependencies = ["01_upgrade_users"]
def upgrade(db):
db.users.create_index([('email', 1)], unique=True)
def downgrade(db):
pass
| """
Update Index
"""
name = '02_upgrade_users_unique_email'
dependencies = ['01_upgrade_users']
def upgrade(db):
db.users.create_index([('email', 1)], unique=True)
def downgrade(db):
pass |
#
# PySNMP MIB module HM2-NETCONFIG-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HM2-NETCONFIG-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:19:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) ... |
def binary_search(A, target):
A = str(A)
lo = 0
hi = len(A)
index = None
while lo <= hi:
mid = round(lo + (hi - lo) / 2)
mid_ele = int(A[mid])
if mid_ele == target:
index = mid
break
if mid_ele < target:
lo = mid + 1
else:... | def binary_search(A, target):
a = str(A)
lo = 0
hi = len(A)
index = None
while lo <= hi:
mid = round(lo + (hi - lo) / 2)
mid_ele = int(A[mid])
if mid_ele == target:
index = mid
break
if mid_ele < target:
lo = mid + 1
else:
... |
tree = PipelineElement('DecisionTreeClassifier',
hyperparameters={'criterion': ['gini'],
'min_samples_split': IntegerRange(2, 4)})
svc = PipelineElement('LinearSVC',
hyperparameters={'C': FloatRange(0.5, 25)})
my_pipe += Stack('fin... | tree = pipeline_element('DecisionTreeClassifier', hyperparameters={'criterion': ['gini'], 'min_samples_split': integer_range(2, 4)})
svc = pipeline_element('LinearSVC', hyperparameters={'C': float_range(0.5, 25)})
my_pipe += stack('final_stack', [tree, svc], use_probabilities=True)
my_pipe += pipeline_element('LinearSV... |
class Solution:
def assignTasks(self, servers: List[int], tasks: List[int]) -> List[int]:
ans = []
free = [] # (weight, index, freeTime)
used = [] # (freeTime, weight, index)
for i, weight in enumerate(servers):
heapq.heappush(free, (weight, i, 0))
for i, executionTime in enumerate(tasks... | class Solution:
def assign_tasks(self, servers: List[int], tasks: List[int]) -> List[int]:
ans = []
free = []
used = []
for (i, weight) in enumerate(servers):
heapq.heappush(free, (weight, i, 0))
for (i, execution_time) in enumerate(tasks):
while used... |
#
# PySNMP MIB module XYLAN-IP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XYLAN-IP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:38:41 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, constraints_intersection, constraints_union, single_value_constraint) ... |
"""
Given a string, determine if it is a palindrome, considering only alphanumeric
characters and ignoring cases.
For example 'A man, a plan, a canal: Panama' is a palindrome
while 'race a car' is not.
"""
def is_palindrome(sentence):
def normalize():
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '... | """
Given a string, determine if it is a palindrome, considering only alphanumeric
characters and ignoring cases.
For example 'A man, a plan, a canal: Panama' is a palindrome
while 'race a car' is not.
"""
def is_palindrome(sentence):
def normalize():
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', '... |
def sign_out() -> str:
return """
public func signOut() {
SessionManager.shared.session = nil
}
""".strip() + '\n'
| def sign_out() -> str:
return '\npublic func signOut() {\n SessionManager.shared.session = nil\n}\n '.strip() + '\n' |
class IBANValidationException(Exception):
"""The IBAN did not validate"""
class BankDoesNotExistException(IBANValidationException):
"""The Bank does not exists"""
| class Ibanvalidationexception(Exception):
"""The IBAN did not validate"""
class Bankdoesnotexistexception(IBANValidationException):
"""The Bank does not exists""" |
# from test_mpu65c02.py, 71 tests
class Common65C02Tests:
"""CMOS 65C02 Tests"""
# Reset
def test_reset_clears_decimal_flag(self):
# W65C02S Datasheet, Apr 14 2009, Table 7-1 Operational Enhancements
# NMOS 6502 decimal flag = indetermine after reset, CMOS 65C02 = 0
mpu = self._mak... | class Common65C02Tests:
"""CMOS 65C02 Tests"""
def test_reset_clears_decimal_flag(self):
mpu = self._make_mpu()
mpu.p = mpu.DECIMAL
mpu.reset()
self.assertEqual(0, mpu.p & mpu.DECIMAL)
def test_adc_bcd_off_zp_ind_carry_clear_in_accumulator_zeroes(self):
mpu = self._... |
# Time: O(nlogn + nlogw), n = len(nums), w = max(nums)-min(nums)
# Space: O(1)
# Given an integer array, return the k-th smallest distance among all the pairs.
# The distance of a pair (A, B) is defined as the absolute difference between A and B.
#
# Example 1:
# Input:
# nums = [1,3,1]
# k = 1
# Output: 0
# Explanat... | class Solution(object):
def smallest_distance_pair(self, nums, k):
"""
:type nums: List[int]
:type k: int
:rtype: int
"""
def possible(guess, nums, k):
(count, left) = (0, 0)
for (right, num) in enumerate(nums):
while num - nu... |
class A:
def f(self):
print("f() in A")
class B:
def f(self):
print("f() in B")
class D(A,B):
pass
class E(B,A):
pass
print(D.mro())
print(E.mro())
d = D()
d.f()
e = E()
e.f()
| class A:
def f(self):
print('f() in A')
class B:
def f(self):
print('f() in B')
class D(A, B):
pass
class E(B, A):
pass
print(D.mro())
print(E.mro())
d = d()
d.f()
e = e()
e.f() |
def is_pangram(text):
"""
Checks if a string is a pangram.
"""
alphabet = 'abcdefghijklmnopqrstuvwxyz'
text = text.lower()
for letter in alphabet:
if letter not in text:
return False
return True
print(is_pangram('The quick brown fox jumps over the lazy dog.'))
def needl... | def is_pangram(text):
"""
Checks if a string is a pangram.
"""
alphabet = 'abcdefghijklmnopqrstuvwxyz'
text = text.lower()
for letter in alphabet:
if letter not in text:
return False
return True
print(is_pangram('The quick brown fox jumps over the lazy dog.'))
def needle... |
'''
* @Author: csy
* @Date: 2019-04-28 13:50:45
* @Last Modified by: csy
* @Last Modified time: 2019-04-28 13:50:45
'''
digits = list(range(0, 10))
print(digits)
print(min(digits))
print(max(digits))
print(sum(digits))
| """
* @Author: csy
* @Date: 2019-04-28 13:50:45
* @Last Modified by: csy
* @Last Modified time: 2019-04-28 13:50:45
"""
digits = list(range(0, 10))
print(digits)
print(min(digits))
print(max(digits))
print(sum(digits)) |
class Solution(object):
def setZeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
colZeroFlag = False
for i in range(0, len(matrix)):
if matrix[i][0] == 0:
colZeroFlag = True
for j in range(1, len... | class Solution(object):
def set_zeroes(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-place instead.
"""
col_zero_flag = False
for i in range(0, len(matrix)):
if matrix[i][0] == 0:
col_zero_flag ... |
class constants:
NONE = 0
X = 1
O = 2
class variables:
explored = 0
def print_board(board):
print(simbol(board[0])+"|"+simbol(board[1])+"|"+simbol(board[2]))
print("-----")
print(simbol(board[3])+"|"+simbol(board[4])+"|"+simbol(board[5]))
print("-----")
print(simbo... | class Constants:
none = 0
x = 1
o = 2
class Variables:
explored = 0
def print_board(board):
print(simbol(board[0]) + '|' + simbol(board[1]) + '|' + simbol(board[2]))
print('-----')
print(simbol(board[3]) + '|' + simbol(board[4]) + '|' + simbol(board[5]))
print('-----')
print(simbol... |
RequiredKeyIsMissing = \
"No value was found for the required key `{key_name}`"
RequiredKeyIsWrongType = (
"Required key `{key_name}` has the wrong " +
"type of `{invalid_type}`. The value of this key " +
"should have the type `{expected_type}`"
)
DirectiveStructureError = (
"The following directi... | required_key_is_missing = 'No value was found for the required key `{key_name}`'
required_key_is_wrong_type = 'Required key `{key_name}` has the wrong ' + 'type of `{invalid_type}`. The value of this key ' + 'should have the type `{expected_type}`'
directive_structure_error = 'The following directive `{directive}` has ... |
def source():
pass
def sink(x):
pass
def alarm():
x = source()
sink(x)
| def source():
pass
def sink(x):
pass
def alarm():
x = source()
sink(x) |
# from: http://www.rosettacode.org/wiki/Babbage_problem#Python
def main():
print([x for x in range(30000) if (x * x) % 1000000 == 269696][0])
if __name__ == "__main__":
main()
| def main():
print([x for x in range(30000) if x * x % 1000000 == 269696][0])
if __name__ == '__main__':
main() |
def song_decoder(song):
result = song.replace("WUB" , " ")
result = ' '.join(result.split())
return result
| def song_decoder(song):
result = song.replace('WUB', ' ')
result = ' '.join(result.split())
return result |
# -*- coding: utf-8 -*-
def platform2str(platform: str) -> str:
""" get full platform name """
if platform == "amd":
return "AMD Tahiti 7970"
elif platform == "nvidia":
return "NVIDIA GTX 970"
else:
raise LookupError
def escape_suite_name(g: str) -> str:
""" format benchma... | def platform2str(platform: str) -> str:
""" get full platform name """
if platform == 'amd':
return 'AMD Tahiti 7970'
elif platform == 'nvidia':
return 'NVIDIA GTX 970'
else:
raise LookupError
def escape_suite_name(g: str) -> str:
""" format benchmark suite name for display ... |
def print_row(star_count):
for _ in range(star_count, size - 1):
print(' ', end='')
for _ in range(star_count):
print('*', end=' ')
print('*')
size = int(input())
for star_count in range(size):
print_row(star_count)
for star_count in range(size - 2, -1, -1):
print_row(star_count... | def print_row(star_count):
for _ in range(star_count, size - 1):
print(' ', end='')
for _ in range(star_count):
print('*', end=' ')
print('*')
size = int(input())
for star_count in range(size):
print_row(star_count)
for star_count in range(size - 2, -1, -1):
print_row(star_count) |
def recur_fibo(n):
if n <= 1:
return n
else:
return (recur_fibo(n - 1) + recur_fibo(n - 2))
nterms = int(input('You want output many elements '))
if nterms < 0:
print('Enter the positive number')
else:
print("fibonacci sequence")
for i in range(nterms):
print(recur_fibo(i))... | def recur_fibo(n):
if n <= 1:
return n
else:
return recur_fibo(n - 1) + recur_fibo(n - 2)
nterms = int(input('You want output many elements '))
if nterms < 0:
print('Enter the positive number')
else:
print('fibonacci sequence')
for i in range(nterms):
print(recur_fibo(i)) |
class Solution:
def twoSum(self, numbers: List[int], target: int) -> List[int]:
n = len(numbers)
last_num = None
for i in range(n):
num1 = numbers[i]
if num1 != last_num:
for j in range(i+1, n):
num2 = numbers[j]
... | class Solution:
def two_sum(self, numbers: List[int], target: int) -> List[int]:
n = len(numbers)
last_num = None
for i in range(n):
num1 = numbers[i]
if num1 != last_num:
for j in range(i + 1, n):
num2 = numbers[j]
... |
NInput = int(input())
xcoor = []
ycoor = []
for i in range(NInput):
x, y = map(int, input().split())
xcoor.append(x)
ycoor.append(y)
for i in range(0, len(xcoor)):
minIndex = i
for j in range(i+1, len(xcoor)):
if xcoor[j] < xcoor[minIndex]:
xcoor[j], xcoor[minIndex] = xcoor[minIn... | n_input = int(input())
xcoor = []
ycoor = []
for i in range(NInput):
(x, y) = map(int, input().split())
xcoor.append(x)
ycoor.append(y)
for i in range(0, len(xcoor)):
min_index = i
for j in range(i + 1, len(xcoor)):
if xcoor[j] < xcoor[minIndex]:
(xcoor[j], xcoor[minIndex]) = (xc... |
# Should only need to modify these paths in this file:
# - BTFM_BASE
# - LSP_DATASET_DIR
# - LSPET_DATASET_DIR
# - COCO_DATASET_DIR
# - MPII_DATASET_DIR
# - TDPW_DATASET_DIR
# - MI3_DATASET_DIR
# - MI3_PP_DATASET_DIR
# - UPI_S1H_DATASET_DIR
# Note that this relies on a filesystem that supports symli... | btfm_base = '/media/data/btfm'
btfm_pp = '/pp'
btfm_pp_lsp = BTFM_PP + '/lsp'
btfm_pp_lspet = BTFM_PP + '/lspet'
btfm_pp_mpii = BTFM_PP + '/mpii'
btfm_pp_3_dpw = BTFM_PP + '/3dpw'
btfm_pp_3_dpw_silhouette = BTFM_PP_3DPW + '/silhouette'
btfm_pp_3_dpw_silhouette_valid = BTFM_PP_3DPW + '/good_3dpw_annotations.pkl'
btfm_pp... |
class Solution:
def calPoints(self, ops: List[str]) -> int:
array = []
for op in ops:
if op == 'C':
array.pop()
elif op == 'D':
array.append(array[-1]*2)
elif op == "+":
array.append(array[-1] + array[-2])
... | class Solution:
def cal_points(self, ops: List[str]) -> int:
array = []
for op in ops:
if op == 'C':
array.pop()
elif op == 'D':
array.append(array[-1] * 2)
elif op == '+':
array.append(array[-1] + array[-2])
... |
# stringparser.py
#
# Ronald Rihoo
def findFirstQuotationMarkFromTheLeft(string):
for i in xrange(len(string) - 1, 0, -1):
if string[i] == '"':
return i
def findFirstQuotationMarkFromTheRight(string):
for i in range(len(string)):
if string[i] == '"':
return i
def splitLeftAspect_toChar(stri... | def find_first_quotation_mark_from_the_left(string):
for i in xrange(len(string) - 1, 0, -1):
if string[i] == '"':
return i
def find_first_quotation_mark_from_the_right(string):
for i in range(len(string)):
if string[i] == '"':
return i
def split_left_aspect_to_char(str... |
#!/usr/bin/python
# coding=utf-8
class Fibs(object):
def __init__(self):
self.a = 0
self.b = 1
def next(self):
self.a, self.b = self.b, self.a + self.b
return self.a
def __iter__(self):
return self
if __name__ == "__main__":
fibs = Fibs()
for fib in fibs:... | class Fibs(object):
def __init__(self):
self.a = 0
self.b = 1
def next(self):
(self.a, self.b) = (self.b, self.a + self.b)
return self.a
def __iter__(self):
return self
if __name__ == '__main__':
fibs = fibs()
for fib in fibs:
if fib > 1000:
... |
# This sample tests that arbitrary expressions (including
# subscripts) work for decorators. This support was added
# in Python 3.9.
my_decorators = (staticmethod, classmethod, property)
class Foo:
# This should generate an error if version < 3.9.
@my_decorators[0]
def my_static_method():
return 3... | my_decorators = (staticmethod, classmethod, property)
class Foo:
@my_decorators[0]
def my_static_method():
return 3
@my_decorators[1]
def my_class_method(cls):
return 3
@my_decorators[2]
def my_property(self):
return 3
Foo.my_static_method()
Foo.my_class_method()
foo(... |
largura=l=int(input("digite a largura: "))
altura=a=int(input("digite a altura: "))
while altura>0:
largura=l
while largura >0:
if (altura==a or altura ==1):
print("#", end="")
else:
if largura==1 or largura ==l:
print("#", end="")
else:
... | largura = l = int(input('digite a largura: '))
altura = a = int(input('digite a altura: '))
while altura > 0:
largura = l
while largura > 0:
if altura == a or altura == 1:
print('#', end='')
elif largura == 1 or largura == l:
print('#', end='')
else:
p... |
'''
Author: jianzhnie
Date: 2021-11-08 18:25:03
LastEditTime: 2022-02-25 11:12:28
LastEditors: jianzhnie
Description:
'''
| """
Author: jianzhnie
Date: 2021-11-08 18:25:03
LastEditTime: 2022-02-25 11:12:28
LastEditors: jianzhnie
Description:
""" |
#String Rotation:Assumeyou have a method isSubstringwhich checks if oneword is a substring of another. Given two strings, sl and s2, write code to check if s2 is a rotation of sl using only one call to isSubstring (e.g., "waterbottle" is a rotation of"erbottlewat").
#do special caracters as spaces are in the strign or ... | def rotation(str1, str2):
ith = 0
jth = 0
while jth < len(str2):
if str1[ith] == str2[jth]:
ith += 1
else:
ith = 0
jth += 1
return is_substring(str2[:-ith], str1)
def is_substring(str1, str2):
return str1 in str2
print(rotation('terbottlewa', 'erbottl... |
def fibbs(n):
"""
Input: the nth number.
Output: the number of the Fibonacci sequence via iteration.
"""
sequence = []
for i in range(n+1):
if i == 0:
sequence.append(0)
elif i == 1:
sequence.append(1)
else:
total = sequence[i - 2] + se... | def fibbs(n):
"""
Input: the nth number.
Output: the number of the Fibonacci sequence via iteration.
"""
sequence = []
for i in range(n + 1):
if i == 0:
sequence.append(0)
elif i == 1:
sequence.append(1)
else:
total = sequence[i - 2] + ... |
def fromETH(amt, px):
return amt*px
def toETH(amt, px):
return amt/px
def toOVL(amt, px):
return fromETH(amt, px)
def fromOVL(amt, px):
return toETH(amt, px)
def px_from_ret(px0: float, ret: float) -> float:
'''get the new price given a return'''
ret = ret/100
return (ret + 1)*px0
def pn... | def from_eth(amt, px):
return amt * px
def to_eth(amt, px):
return amt / px
def to_ovl(amt, px):
return from_eth(amt, px)
def from_ovl(amt, px):
return to_eth(amt, px)
def px_from_ret(px0: float, ret: float) -> float:
"""get the new price given a return"""
ret = ret / 100
return (ret + 1... |
class Results:
def __init__(self, error, error_type, description, sequence, activity=None, activity_class=None):
self.error = error
self.error_type = error_type
self.description = description
self.sequence = sequence
self.activity = activity
self.activity_class = acti... | class Results:
def __init__(self, error, error_type, description, sequence, activity=None, activity_class=None):
self.error = error
self.error_type = error_type
self.description = description
self.sequence = sequence
self.activity = activity
self.activity_class = act... |
n=3
z=65
for i in range(n):
k=z
for j in range(n-i):
print(' ',end='')
for j in range(2*i+1):
print(chr(k),end='')
k-=1
z=z+2
print()
for i in range(1,n):
c=z-4
for j in range(i):
print(' ',end='')
for j in range((2*n)-2*i-1):
prin... | n = 3
z = 65
for i in range(n):
k = z
for j in range(n - i):
print(' ', end='')
for j in range(2 * i + 1):
print(chr(k), end='')
k -= 1
z = z + 2
print()
for i in range(1, n):
c = z - 4
for j in range(i):
print(' ', end='')
for j in range(2 * n - 2 * i - 1... |
with open("pos_tweets.txt") as input_file:
text = input_file.read()
text_set = set(text.split(" "))
for word in text_set:
print(word,text.count(word)) | with open('pos_tweets.txt') as input_file:
text = input_file.read()
text_set = set(text.split(' '))
for word in text_set:
print(word, text.count(word)) |
#coding=utf-8
__all__ = ["ModelConfig", "TrainerConfig"]
class ModelConfig(object):
vocab_size = 104810
embedding_dim = 300
embedding_droprate = 0.3
lstm_depth = 3
lstm_hidden_dim = 300
lstm_hidden_droprate = 0.3
passage_indep_embedding_dim = 300
passage_aligned_embedding_dim = 300
... | __all__ = ['ModelConfig', 'TrainerConfig']
class Modelconfig(object):
vocab_size = 104810
embedding_dim = 300
embedding_droprate = 0.3
lstm_depth = 3
lstm_hidden_dim = 300
lstm_hidden_droprate = 0.3
passage_indep_embedding_dim = 300
passage_aligned_embedding_dim = 300
beam_size = 32... |
a0 = 27.5
a4 = a0 * 2 ** 4
default_key = "c"
match_roman = "[ivIV]?[ivIV]?[iI]?"
intervals = {"P1": 0, "m2": 1, "M2": 2, "m3": 3, "M3": 4, "P4": 5, "TT": 6, "P5": 7, "m6": 8, "M6": 9, "m7": 10, "M7": 11, "P8": 12, "m9": 13, "M9": 14, "m10": 15, "M10": 16, "P11": 17, "d12": 18, "P12": 19, "m13": 20, "M13": 21, "m14": 22... | a0 = 27.5
a4 = a0 * 2 ** 4
default_key = 'c'
match_roman = '[ivIV]?[ivIV]?[iI]?'
intervals = {'P1': 0, 'm2': 1, 'M2': 2, 'm3': 3, 'M3': 4, 'P4': 5, 'TT': 6, 'P5': 7, 'm6': 8, 'M6': 9, 'm7': 10, 'M7': 11, 'P8': 12, 'm9': 13, 'M9': 14, 'm10': 15, 'M10': 16, 'P11': 17, 'd12': 18, 'P12': 19, 'm13': 20, 'M13': 21, 'm14': 22... |
def cipher():
user_input = input("Please provide a word: ") | def cipher():
user_input = input('Please provide a word: ') |
# -*- coding: utf-8 -*-
usr_number = int(input("Enter a number to calculate: "))
if usr_number > 1:
for n in range(2, usr_number):
if (usr_number % n == 0):
print(f'{n} is not a prime number')
else:
print(f'{n} is a prime number')
| usr_number = int(input('Enter a number to calculate: '))
if usr_number > 1:
for n in range(2, usr_number):
if usr_number % n == 0:
print(f'{n} is not a prime number')
else:
print(f'{n} is a prime number') |
date_fullyear = '[0-9]{4}'
date_mday = '[0-9]{2}'
date_month = '[0-9]{2}'
full_date = f'{date_fullyear}-{date_month}-{date_mday}'
time_hour = '[0-9]{2}'
time_minute = '[0-9]{2}'
time_second = '[0-9]{2}'
time_secfrac = '\\.[0-9]+'
partial_time = f'{time_hour}:{time_minute}:{time_second}({time_secfrac})?'
time_numoffset ... | date_fullyear = '[0-9]{4}'
date_mday = '[0-9]{2}'
date_month = '[0-9]{2}'
full_date = f'{date_fullyear}-{date_month}-{date_mday}'
time_hour = '[0-9]{2}'
time_minute = '[0-9]{2}'
time_second = '[0-9]{2}'
time_secfrac = '\\.[0-9]+'
partial_time = f'{time_hour}:{time_minute}:{time_second}({time_secfrac})?'
time_numoffset ... |
__author__ = 'schien'
INSTALLED_APPS += ('storages',)
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
S3_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL
AWS_LOCATION = '/static'
AWS_HEADERS = { # see http://developer.yahoo.com/performance/rules.html#expires
'E... | __author__ = 'schien'
installed_apps += ('storages',)
staticfiles_storage = 'storages.backends.s3boto.S3BotoStorage'
s3_url = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
static_url = S3_URL
aws_location = '/static'
aws_headers = {'Expires': 'Thu, 31 Dec 2099 20:00:00 GMT', 'Cache-Control': 'max-age=9460800... |
class SubMerchant:
def __init__(self):
self.cardAcceptorID = None
self.country = None
self.phoneNumber = None
self.address1 = None
self.postalCode = None
self.locality = None
self.name = None
self.administrativeArea = None
self.region = None
... | class Submerchant:
def __init__(self):
self.cardAcceptorID = None
self.country = None
self.phoneNumber = None
self.address1 = None
self.postalCode = None
self.locality = None
self.name = None
self.administrativeArea = None
self.region = None
... |
environment = 'MountainCar-v0'
bin_count = 9
goal_positon = 0.5
position_min = -1.2
position_max = 0.6
velocity_min = -0.07
velocity_max = 0.07
num_episodes = 10000
max_steps_in_episode = 200
verbose = 100
learning_rate = 10e-3
eps = 1
discount_factor = 0.9
panelty = -300
test_episodes = 100
bonus = 500
q_table_pa... | environment = 'MountainCar-v0'
bin_count = 9
goal_positon = 0.5
position_min = -1.2
position_max = 0.6
velocity_min = -0.07
velocity_max = 0.07
num_episodes = 10000
max_steps_in_episode = 200
verbose = 100
learning_rate = 0.01
eps = 1
discount_factor = 0.9
panelty = -300
test_episodes = 100
bonus = 500
q_table_path = '... |
#!/usr/bin/python
def BubbleSort(val):
for passnum in range(len(val)-1,0,-1):
for i in range(passnum):
if val[i]>val[i+1]:
temp = val[i]
val[i] = val[i+1]
val[i+1] = temp
DaftarAngka = [23,7,32,99,4,15,11,20]
BubbleSort(DaftarAngka)
print(DaftarAngka)
| def bubble_sort(val):
for passnum in range(len(val) - 1, 0, -1):
for i in range(passnum):
if val[i] > val[i + 1]:
temp = val[i]
val[i] = val[i + 1]
val[i + 1] = temp
daftar_angka = [23, 7, 32, 99, 4, 15, 11, 20]
bubble_sort(DaftarAngka)
print(Dafta... |
"""Slack toolbox"""
def make_slack_response(
response_type="ephemeral", text="", attachments=None, blocks=None
):
return {
"response_type": response_type,
"text": text,
"attachments": [attachments] if attachments else [],
"blocks": blocks if blocks else [],
}
| """Slack toolbox"""
def make_slack_response(response_type='ephemeral', text='', attachments=None, blocks=None):
return {'response_type': response_type, 'text': text, 'attachments': [attachments] if attachments else [], 'blocks': blocks if blocks else []} |
# 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, ... | """Constants for GradientFuzz training process."""
data_gen_timeout = 60 * 60 * 1
train_timeout = 60 * 60 * 2
loc_gen_timeout = 60 * 60 * 3
mut_gen_timeout = 60 * 60 * 3
min_num_inputs = 10
num_test_epochs = 5
num_epochs = 50
gradientfuzz_dir = 'gradientfuzz'
corpus_dir = 'corpus'
corpus_suffix = '-raw-inputs'
generate... |
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not u... | user_owner_type = 'User'
dashboard_owner_type = 'Dashboard'
name_field = 'name'
description_field = 'description'
json_metadata_field = 'json_metadata'
owner_id_field = 'owner_id'
owner_type_field = 'owner_type'
dashboard_id_field = 'dashboard_id'
owner_object_field = 'owner_object'
dashboard_field = 'dashboard'
params... |
def paired_digits_count(data, skip):
return sum([int(d) for i, d in enumerate(data) if data[i - skip] == d])
with open("day01.txt") as f:
data = f.readline()
half = int(len(data) / 2)
print("2017 day 1 part 1: %d" % paired_digits_count(data, 1))
print("2017 day 1 part 2: %d" % paired_digits_count(d... | def paired_digits_count(data, skip):
return sum([int(d) for (i, d) in enumerate(data) if data[i - skip] == d])
with open('day01.txt') as f:
data = f.readline()
half = int(len(data) / 2)
print('2017 day 1 part 1: %d' % paired_digits_count(data, 1))
print('2017 day 1 part 2: %d' % paired_digits_count(... |
# Soultion for Project Euler Problem #8 - https://projecteuler.net/problem=8
# (c) 2017 dpetker
TEST_VAL = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950... | test_val = '73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358907... |
"""
Sponge Knowledge Base
Demo - action context actions
"""
class ActionWithContextActions(Action):
def onConfigure(self):
self.withLabel("Action with context actions").withArgs([
StringType("arg1").withLabel("Argument 1"),
StringType("arg2").withLabel("Argument 2")
]).withN... | """
Sponge Knowledge Base
Demo - action context actions
"""
class Actionwithcontextactions(Action):
def on_configure(self):
self.withLabel('Action with context actions').withArgs([string_type('arg1').withLabel('Argument 1'), string_type('arg2').withLabel('Argument 2')]).withNoResult().withFeature('context... |
city = "narva"
estonianPopulation = [
["tallinn", 441000],
["tartu", 94000],
["narva", 58000],
["parnu", 41000]
]
for p in estonianPopulation:
if p[0] == city:
print("Population of " + p[0].capitalize() + ": " + str(p[1]))
break
| city = 'narva'
estonian_population = [['tallinn', 441000], ['tartu', 94000], ['narva', 58000], ['parnu', 41000]]
for p in estonianPopulation:
if p[0] == city:
print('Population of ' + p[0].capitalize() + ': ' + str(p[1]))
break |
"""
def my_function():
print("I'm inside function")
def function1():
var2 = 5
print(var1)
def function2():
var3 = 7
print(var3)
print(var1)
#print(var2)
"""
def func():
var4 = 6
if var4 > var1:
print("var4 is bigger in func")
else:
print("var4 is smaller in func")
def my_... | """
def my_function():
print("I'm inside function")
def function1():
var2 = 5
print(var1)
def function2():
var3 = 7
print(var3)
print(var1)
#print(var2)
"""
def func():
var4 = 6
if var4 > var1:
print('var4 is bigger in func')
else:
print('var4 is smaller in func')
def my_f()... |
def iter_rings(data, pathcodes):
ring = []
# TODO: Do this smartly by finding when pathcodes changes value and do
# smart indexing on data, instead of iterating over each coordinate
for point, code in zip(data, pathcodes):
if code == 'M':
# Emit the path and start a new one
... | def iter_rings(data, pathcodes):
ring = []
for (point, code) in zip(data, pathcodes):
if code == 'M':
if len(ring):
yield ring
ring = [point]
elif code == 'L':
ring.append(point)
else:
raise value_error('Unrecognized code: {... |
text = 'hello'
fileName = 'data.txt'
file=open(fileName, 'w')
file.write(text)
file.close()
file = open(fileName, 'r')
input_text = file.readline()
file.close()
print(input_text)
| text = 'hello'
file_name = 'data.txt'
file = open(fileName, 'w')
file.write(text)
file.close()
file = open(fileName, 'r')
input_text = file.readline()
file.close()
print(input_text) |
class SearchNode:
def __init__(self, pos, parent=None, cost_to_origin=0, cost_to_target=0):
self.pos = pos # Might have to change to tuple
self.parent = parent
self.neighbours = []
self.cost_to_origin = cost_to_origin
self.cost_to_target = cost_to_target
def get_total_... | class Searchnode:
def __init__(self, pos, parent=None, cost_to_origin=0, cost_to_target=0):
self.pos = pos
self.parent = parent
self.neighbours = []
self.cost_to_origin = cost_to_origin
self.cost_to_target = cost_to_target
def get_total_cost(self):
"""
F... |
def sl_a_func():
pass
def sl_a_func2():
pass
class SlAClass():
def __init__(self):
pass
| def sl_a_func():
pass
def sl_a_func2():
pass
class Slaclass:
def __init__(self):
pass |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def new_tips(argv):
def tips(func):
def nei(a, b):
print("start %s %s" %(argv, func.__name__))
func(a, b)
print("stop")
return nei
return tips
@new_tips('add_modules')
def add(a, b):
print(a + b)
@new_ti... | def new_tips(argv):
def tips(func):
def nei(a, b):
print('start %s %s' % (argv, func.__name__))
func(a, b)
print('stop')
return nei
return tips
@new_tips('add_modules')
def add(a, b):
print(a + b)
@new_tips('sub_modules')
def sub(a, b):
print(a - b... |
def spacify(string, spaces=2):
"""Add spaces to the beginning of each line in a multi-line string."""
return spaces * " " + (spaces * " ").join(string.splitlines(True))
def multilinify(sequence, sep=","):
"""Make a multi-line string out of a sequence of strings."""
sep += "\n"
return "\n" + sep.jo... | def spacify(string, spaces=2):
"""Add spaces to the beginning of each line in a multi-line string."""
return spaces * ' ' + (spaces * ' ').join(string.splitlines(True))
def multilinify(sequence, sep=','):
"""Make a multi-line string out of a sequence of strings."""
sep += '\n'
return '\n' + sep.joi... |
def tail(filepath, n):
"""Similate Unix' tail -n, read in filepath, parse it into a list,
strip newlines and return a list of the last n lines"""
with open(filepath) as f:
file = f.read()
tail_result = file.split('\n')[-n:]
return tail_result | def tail(filepath, n):
"""Similate Unix' tail -n, read in filepath, parse it into a list,
strip newlines and return a list of the last n lines"""
with open(filepath) as f:
file = f.read()
tail_result = file.split('\n')[-n:]
return tail_result |
"""
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"""
class Solution:
"""
@param two ListNodes
@return a ListNode
"""
def mergeTwoLists(self, l1, l2):
if l1 is None:
return l2
if l2... | """
Definition of ListNode
class ListNode(object):
def __init__(self, val, next=None):
self.val = val
self.next = next
"""
class Solution:
"""
@param two ListNodes
@return a ListNode
"""
def merge_two_lists(self, l1, l2):
if l1 is None:
return l2
if... |
N, M = map(int, input().split())
A = list(map(int, input().split()))
days = N - sum(A)
if days < 0:
print(-1)
else:
print(days) | (n, m) = map(int, input().split())
a = list(map(int, input().split()))
days = N - sum(A)
if days < 0:
print(-1)
else:
print(days) |
a, b = map(int, input().split())
if b >= 45:
print(a, b-45)
elif a != 0 and b < 45:
print(a-1, b+15)
else:
print(23, b+15)
| (a, b) = map(int, input().split())
if b >= 45:
print(a, b - 45)
elif a != 0 and b < 45:
print(a - 1, b + 15)
else:
print(23, b + 15) |
N = int(input())
soma = 0
for k in range(N):
X = int(input())
if X >= 10 and X <= 20: soma+=1
print("%d in" % (soma))
print("%d out" % (abs(N-soma)))
| n = int(input())
soma = 0
for k in range(N):
x = int(input())
if X >= 10 and X <= 20:
soma += 1
print('%d in' % soma)
print('%d out' % abs(N - soma)) |
"""
Using up to one million tiles
how many different "hollow" square laminae can be formed?
"""
def cal():
TILES = 10**6
answer = 0
for n in range(3, TILES // 4 + 2): # Outer square length
for k in range(n - 2, 0, -2): # Inner square length
if n * n - k * k > TILES:
break
answer += 1
return str(answ... | """
Using up to one million tiles
how many different "hollow" square laminae can be formed?
"""
def cal():
tiles = 10 ** 6
answer = 0
for n in range(3, TILES // 4 + 2):
for k in range(n - 2, 0, -2):
if n * n - k * k > TILES:
break
answer += 1
return str(... |
class Metric(object):
"""
A performance measure that is associated with Element
:param metricId: Metric FQN
:type metricId: string
:param metricType: Metric Type
:type metricType: string
:param sparseDataStrategy: Sparse data strategy
:type sparseDataStrate... | class Metric(object):
"""
A performance measure that is associated with Element
:param metricId: Metric FQN
:type metricId: string
:param metricType: Metric Type
:type metricType: string
:param sparseDataStrategy: Sparse data strategy
:type sparseDataStrategy... |
# Time: O(h)
# Space: O(1)
# Definition for a Node.
class Node:
def __init__(self, val):
pass
class Solution(object):
def lowestCommonAncestor(self, p, q):
"""
:type node: Node
:rtype: Node
"""
a, b = p, q
while a != b:
a = a.parent if a els... | class Node:
def __init__(self, val):
pass
class Solution(object):
def lowest_common_ancestor(self, p, q):
"""
:type node: Node
:rtype: Node
"""
(a, b) = (p, q)
while a != b:
a = a.parent if a else q
b = b.parent if b else p
... |
class ValueType(object):
'''Define _key() and inherit from this class to implement comparison and hashing'''
# def __init__(self, *args, **kwargs): super(ValueType, self).__init__(*args, **kwargs)
def __eq__(self, other): return type(self) == type(other) and self._key() == other._key()
def __ne__(self, ... | class Valuetype(object):
"""Define _key() and inherit from this class to implement comparison and hashing"""
def __eq__(self, other):
return type(self) == type(other) and self._key() == other._key()
def __ne__(self, other):
return type(self) != type(other) or self._key() != other._key()
... |
def is_even(number:int):
"""
This function verifies if the number is even or not
Returns:
True if even false other wise
"""
return number % 2 == 0
def is_prime(number: int):
"""
This function finds if the number is prime
Returns:
True if prime false otherwise
"""
... | def is_even(number: int):
"""
This function verifies if the number is even or not
Returns:
True if even false other wise
"""
return number % 2 == 0
def is_prime(number: int):
"""
This function finds if the number is prime
Returns:
True if prime false otherwise
"""
... |
"""
Follow up for "Find Minimum in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
Find the minimum element.
The array may conta... | """
Follow up for "Find Minimum in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
Find the minimum element.
The array may conta... |
#
# PySNMP MIB module CISCO-SRST-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-SRST-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:12:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ... |
# bootstrap glyph icon
ICON_TYPE_GLYPH = 'glyph'
# image relative to Flask static folder
ICON_TYPE_IMAGE = 'image'
# external image
ICON_TYPE_IMAGE_URL = 'image-url'
| icon_type_glyph = 'glyph'
icon_type_image = 'image'
icon_type_image_url = 'image-url' |
array = []
while True:
line = input()
if "DEBUG" == line:
break
array += list(map(int, filter(None, line.split(" "))))
for i in range(len(array) - 6):
if array[i] == 32656 and array[i + 1] == 19759 and array[i + 2] == 32763:
n = array[i + 4]
start = i + 6
end = start +... | array = []
while True:
line = input()
if 'DEBUG' == line:
break
array += list(map(int, filter(None, line.split(' '))))
for i in range(len(array) - 6):
if array[i] == 32656 and array[i + 1] == 19759 and (array[i + 2] == 32763):
n = array[i + 4]
start = i + 6
end = start + ... |
"""
Minimalistic application with fields, managers etc. for full text search support in PostgreSQL.
Inspired by: https://github.com/linuxlewis/djorm-ext-pgfulltext
"""
__version__ = '0.1.0'
FTS_CONFIGURATIONS = {
'simple': 'simple',
'en': 'english',
'da': 'danish',
'nl': 'dutch',
'fi': 'finnish',... | """
Minimalistic application with fields, managers etc. for full text search support in PostgreSQL.
Inspired by: https://github.com/linuxlewis/djorm-ext-pgfulltext
"""
__version__ = '0.1.0'
fts_configurations = {'simple': 'simple', 'en': 'english', 'da': 'danish', 'nl': 'dutch', 'fi': 'finnish', 'fr': 'french', 'de': ... |
pens_pack_price = 5.80
markers_pack_price = 7.20
whiteboard_cleaner_per_liter_price = 1.20
amount_pen_packs = int(input("Enter the amount of pen packs: "))
amount_marker_packs = int(input("Enter the amount of marker packs: "))
whiteboard_cleaner_liters = int(input("Enter the ampunt of liters of whiteboard cleaner: "))... | pens_pack_price = 5.8
markers_pack_price = 7.2
whiteboard_cleaner_per_liter_price = 1.2
amount_pen_packs = int(input('Enter the amount of pen packs: '))
amount_marker_packs = int(input('Enter the amount of marker packs: '))
whiteboard_cleaner_liters = int(input('Enter the ampunt of liters of whiteboard cleaner: '))
dis... |
def configure(self):
#Add Components
compress = self.add('compress', CompressionSystem())
mission = self.add('mission', Mission())
pod = self.add('pod', Pod())
flow_limit = self.add('flow_limit', TubeLimitFlow())
tube_wall_temp = self.add('tube_wall_temp', TubeWallTemp())
#Boundary Input C... | def configure(self):
compress = self.add('compress', compression_system())
mission = self.add('mission', mission())
pod = self.add('pod', pod())
flow_limit = self.add('flow_limit', tube_limit_flow())
tube_wall_temp = self.add('tube_wall_temp', tube_wall_temp())
self.connect('Mach_pod_max', 'comp... |
# Copyright 2015 gRPC 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 writing... | """Constants shared among tests throughout RPC Framework."""
time_allowance = 10
short_timeout = 4
long_timeout = 3000
default_timeout = 300
maximum_timeout = 3600
stream_length = 200
payload_size = 256 * 1024 + 17
rpc_concurrency = 200
thread_concurrency = 25
pool_size = 10 |
n, d = [int(i) for i in input().split()]
A = {}
C = {}
shoots = 0
def rangeD(e1, s2, e2):
tmp = min(e1, e2) - s2+1
return(tmp if tmp >= 0 else -1)
for _ in range(n):
s, e, t, num = [i for i in input().split()]
s, e, num = int(s), int(e), int(num)
shoots += (e-s+1)*num
if (t == "A"):
... | (n, d) = [int(i) for i in input().split()]
a = {}
c = {}
shoots = 0
def range_d(e1, s2, e2):
tmp = min(e1, e2) - s2 + 1
return tmp if tmp >= 0 else -1
for _ in range(n):
(s, e, t, num) = [i for i in input().split()]
(s, e, num) = (int(s), int(e), int(num))
shoots += (e - s + 1) * num
if t == 'A... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.