content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
description = 'TOF counter devices'
group = 'lowlevel'
devices = dict(
monitor = device('nicos.devices.generic.VirtualCounter',
description = 'TOFTOF monitor',
fmtstr = '%d',
type = 'monitor',
lowlevel = True,
pollinterval = None,
),
timer = device('nicos.devices.ge... | description = 'TOF counter devices'
group = 'lowlevel'
devices = dict(monitor=device('nicos.devices.generic.VirtualCounter', description='TOFTOF monitor', fmtstr='%d', type='monitor', lowlevel=True, pollinterval=None), timer=device('nicos.devices.generic.VirtualTimer', description='TOFTOF timer', fmtstr='%.2f', unit='s... |
# -*- coding: utf-8 -*-
# @Time : 2020/12/20 17:54:58
# @Author : ddvv
# @Site : https://ddvvmmzz.github.io
# @File : filetypes.py
# @Software: Visual Studio Code
FILE_TYPE_MAPPING = {
'eml': 'eml',
'html': 'html',
'zip': 'zip',
'doc': 'ole',
'docx': 'zip',
'xls': 'ole',
'xlsx': ... | file_type_mapping = {'eml': 'eml', 'html': 'html', 'zip': 'zip', 'doc': 'ole', 'docx': 'zip', 'xls': 'ole', 'xlsx': 'zip', 'ppt': 'ole', 'pptx': 'zip', 'rtf': 'rtf', 'vba': 'vba', 'exe': 'exe', 'pdf': 'pdf', 'ole': 'ole', 'lnk': 'lnk'}
other_list = ['vba', 'exe', 'pdf', 'bat']
def get_support_file_type(ext):
retur... |
#!/usr/bin/python3
"""
Given:
Return:
"""
def main():
# Parse in.txt
with open('./in.txt') as f:
for i, line in enumerate(f):
print(i, line)
if __name__ == '__main__':
main()
| """
Given:
Return:
"""
def main():
with open('./in.txt') as f:
for (i, line) in enumerate(f):
print(i, line)
if __name__ == '__main__':
main() |
# Enter your code here. Read input from STDIN. Print output to STDOUT
NumOfLines = int(input()) # taking first input 2
for j in range(NumOfLines): # makes sure we take all the lines as n
s = input() # taking 1st and 2nd line
evens, odds = '',''
for ... | num_of_lines = int(input())
for j in range(NumOfLines):
s = input()
(evens, odds) = ('', '')
for i in range(len(s)):
if i % 2 == 0:
evens += s[i]
else:
odds += s[i]
print(evens, odds) |
class MyMessage:
"""
message type definition
"""
# message to neighbor
MSG_TYPE_INIT = 1
MSG_TYPE_SEND_MSG_TO_NEIGHBOR = 2
MSG_TYPE_METRICS = 3
MSG_ARG_KEY_TYPE = "msg_type"
MSG_ARG_KEY_SENDER = "sender"
MSG_ARG_KEY_RECEIVER = "receiver"
"""
message payload keyw... | class Mymessage:
"""
message type definition
"""
msg_type_init = 1
msg_type_send_msg_to_neighbor = 2
msg_type_metrics = 3
msg_arg_key_type = 'msg_type'
msg_arg_key_sender = 'sender'
msg_arg_key_receiver = 'receiver'
'\n message payload keywords definition\n '
ms... |
def add_feature(training_df):
training_df["bin_label"] = training_df.label.apply(lambda l: "O" if l == "O" else "I")
training_df["token_num"] = training_df.token.apply(lambda t: len(t.doc))
training_df["loc"] = training_df.token.apply(lambda t: t.i)
training_df["len"] = training_df.token.apply(lambda t:... | def add_feature(training_df):
training_df['bin_label'] = training_df.label.apply(lambda l: 'O' if l == 'O' else 'I')
training_df['token_num'] = training_df.token.apply(lambda t: len(t.doc))
training_df['loc'] = training_df.token.apply(lambda t: t.i)
training_df['len'] = training_df.token.apply(lambda t:... |
"""
1. Clarification
2. Possible solutions
- Sorting
- One pointer
- Two pointers v1
- Two pointers v2
3. Coding
4. Tests
"""
# T=O(nlgn), S=O(n)
class Solution:
def sortColors(self, nums: List[int]) -> None:
nums.sort()
# T=O(n), S=O(1)
class Solution:
def sortColors(self, nums: Lis... | """
1. Clarification
2. Possible solutions
- Sorting
- One pointer
- Two pointers v1
- Two pointers v2
3. Coding
4. Tests
"""
class Solution:
def sort_colors(self, nums: List[int]) -> None:
nums.sort()
class Solution:
def sort_colors(self, nums: List[int]) -> None:
n = len(nu... |
'''
@Author: CSY
@Date: 2020-01-28 09:55:04
@LastEditors : CSY
@LastEditTime : 2020-01-28 09:55:17
'''
a=5%2==1
print(a) | """
@Author: CSY
@Date: 2020-01-28 09:55:04
@LastEditors : CSY
@LastEditTime : 2020-01-28 09:55:17
"""
a = 5 % 2 == 1
print(a) |
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 20 11:39:22 2020.
@author: Mark
"""
#%%
class VamasHeader:
"""Class for handling headers in Vamas files."""
def __init__(self):
"""
Define default values for some parameters in the header.
Returns
-------
None.
"... | """
Created on Mon Jul 20 11:39:22 2020.
@author: Mark
"""
class Vamasheader:
"""Class for handling headers in Vamas files."""
def __init__(self):
"""
Define default values for some parameters in the header.
Returns
-------
None.
"""
self.formatID = '... |
# sum of n to n verbose 1
print('sum of n to n')
number1 = int(input('input number1: '))
number2 = int(input('input number2: '))
if number1 > number2:
number1, number2 = number2, number1
sum = 0
for i in range(number1, number2 + 1):
if i < number2:
print(f'{i} + ', end='')
else:
print(f'{... | print('sum of n to n')
number1 = int(input('input number1: '))
number2 = int(input('input number2: '))
if number1 > number2:
(number1, number2) = (number2, number1)
sum = 0
for i in range(number1, number2 + 1):
if i < number2:
print(f'{i} + ', end='')
else:
print(f'{i} = ', end='')
sum +... |
#!/usr/bin/python3
# Read the file in to an array
input = []
f = open("input.txt", "r")
for l in f:
input.append(l)
def find_search_bit(position, input_list):
v = ""
for i in input_list:
v = v + i[position]
if v.count('1') == v.count('0'):
return 1
elif v.count('1') > v.count('... | input = []
f = open('input.txt', 'r')
for l in f:
input.append(l)
def find_search_bit(position, input_list):
v = ''
for i in input_list:
v = v + i[position]
if v.count('1') == v.count('0'):
return 1
elif v.count('1') > v.count('0'):
return 1
else:
return 0
def f... |
class SudokuGrid :
def __init__(self,grid=[]) :
if grid :
i = iter(grid)
j = len(next(i))
if j == 9 and all(len(l) == j for l in i):
self.grid = grid
return
self.grid = [[0 for i in range(9)] for j in range(9)]
def sho... | class Sudokugrid:
def __init__(self, grid=[]):
if grid:
i = iter(grid)
j = len(next(i))
if j == 9 and all((len(l) == j for l in i)):
self.grid = grid
return
self.grid = [[0 for i in range(9)] for j in range(9)]
def show(self):... |
def get_initializer(initializer, is_bias=False):
"""
get caffe initializer method.
:param initializer: DLMDL weight/bias initializer declaration. Dictionary
:param is_bias: whether bias or not
:return: weight/bias initializer dictinary
"""
def get_value(key, default=None):
... | def get_initializer(initializer, is_bias=False):
"""
get caffe initializer method.
:param initializer: DLMDL weight/bias initializer declaration. Dictionary
:param is_bias: whether bias or not
:return: weight/bias initializer dictinary
"""
def get_value(key, default=None):
"""
... |
class Heapsort:
def sort(self, arr):
self.__build_max_heap(arr)
size = len(arr) - 1
for i in range(size, -1, -1):
self.__max_heapify(arr, 0, i)
# swap last index with first index already sorted
arr[0], arr[i] = arr[i], arr[0]
def __build_max_heap(self, arr):
size = len(arr) - 1
... | class Heapsort:
def sort(self, arr):
self.__build_max_heap(arr)
size = len(arr) - 1
for i in range(size, -1, -1):
self.__max_heapify(arr, 0, i)
(arr[0], arr[i]) = (arr[i], arr[0])
def __build_max_heap(self, arr):
size = len(arr) - 1
for i in rang... |
# Copyright Hybrid Logic Ltd. See LICENSE file for details.
"""
Admin scripts and modules which should not be shipped with Flocker.
Since :module:`admin.release` is imported from setup.py, we need to ensure that
this only imports things from the stdlib.
"""
| """
Admin scripts and modules which should not be shipped with Flocker.
Since :module:`admin.release` is imported from setup.py, we need to ensure that
this only imports things from the stdlib.
""" |
#
# PySNMP MIB module ADTRAN-AOS-VQM (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ADTRAN-AOS-VQM
# Produced by pysmi-0.3.4 at Mon Apr 29 16:58:58 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... | (ad_gen_aos_voice, ad_gen_aos_conformance) = mibBuilder.importSymbols('ADTRAN-AOS', 'adGenAOSVoice', 'adGenAOSConformance')
(ad_identity,) = mibBuilder.importSymbols('ADTRAN-MIB', 'adIdentity')
(integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(n... |
def fahrenheit(T):
return (float(9.0) / 5) * T + 32
print(fahrenheit(0))
temp = [0, 22.5, 40, 100]
print(map(fahrenheit, temp)) # ?????????????? <map object at 0x00000214D009E080>
c = map(lambda T: (9.0 / 5) * T + 32, temp)
print(c) # <map object at 0x00000214D009E080>
print(lambda x, y: x + y)
a = [1, 2, 3... | def fahrenheit(T):
return float(9.0) / 5 * T + 32
print(fahrenheit(0))
temp = [0, 22.5, 40, 100]
print(map(fahrenheit, temp))
c = map(lambda T: 9.0 / 5 * T + 32, temp)
print(c)
print(lambda x, y: x + y)
a = [1, 2, 3]
b = [4, 5, 6]
c = [7, 8, 9]
print(map(lambda x, y: x + y, a, b))
print(map(lambda num: num * -1, a)... |
def j(n, k):
p, i, seq = list(range(n)), 0, []
while p:
i = (i+k-1) % len(p)
seq.append(p.pop(i))
return 'Prisoner killing order: %s.\nSurvivor: %i' % (', '.join(str(i) for i in seq[:-1]), seq[-1])
print(j(5, 2))
print(j(41, 3))
| def j(n, k):
(p, i, seq) = (list(range(n)), 0, [])
while p:
i = (i + k - 1) % len(p)
seq.append(p.pop(i))
return 'Prisoner killing order: %s.\nSurvivor: %i' % (', '.join((str(i) for i in seq[:-1])), seq[-1])
print(j(5, 2))
print(j(41, 3)) |
rfile = open("dictionary.txt", "r")
wfile = open("dict-5.txt","w")
for line in rfile:
if len(line) == 6:
wfile.write(line) | rfile = open('dictionary.txt', 'r')
wfile = open('dict-5.txt', 'w')
for line in rfile:
if len(line) == 6:
wfile.write(line) |
"""Functions for prediction table creation and operations."""
def format_data():
pass
def create_table(db, prediction_data):
pass
def insert():
pass
| """Functions for prediction table creation and operations."""
def format_data():
pass
def create_table(db, prediction_data):
pass
def insert():
pass |
class Solution:
def solve(self, matrix):
leaders = {(r,c):(r,c) for r in range(len(matrix)) for c in range(len(matrix[0])) if matrix[r][c] == 1}
followers = {(r,c):[(r,c)] for r in range(len(matrix)) for c in range(len(matrix[0])) if matrix[r][c] == 1}
for r in range(len(matrix)):
... | class Solution:
def solve(self, matrix):
leaders = {(r, c): (r, c) for r in range(len(matrix)) for c in range(len(matrix[0])) if matrix[r][c] == 1}
followers = {(r, c): [(r, c)] for r in range(len(matrix)) for c in range(len(matrix[0])) if matrix[r][c] == 1}
for r in range(len(matrix)):
... |
def countValues(values):
resultSet = {-1:0, 0:0, 1:0, 2:0, 3:0, 4:0, 5:0, 6:0, 7:0, 8:0, 9:0, 10:0, 11:0}
for value in values:
i = 0
valuesList = list(value)
while i < len(valuesList):
resultSet[i] += int(valuesList[i])
i += 1
resultSet[-1] += 1
... | def count_values(values):
result_set = {-1: 0, 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0, 10: 0, 11: 0}
for value in values:
i = 0
values_list = list(value)
while i < len(valuesList):
resultSet[i] += int(valuesList[i])
i += 1
resultSet[-1]... |
expected_output = {
"flow_drop": {
"inspect-fail": 67870,
"last_clearing": "10:43:33 EDT Mar 27 2019 by genie",
"nat-failed": 528,
"ssl-received-close-alert": 9,
},
"frame_drop": {
"acl-drop": 29,
"l2_acl": 35,
"last_clearing": "10:43:33 EDT Mar 27 201... | expected_output = {'flow_drop': {'inspect-fail': 67870, 'last_clearing': '10:43:33 EDT Mar 27 2019 by genie', 'nat-failed': 528, 'ssl-received-close-alert': 9}, 'frame_drop': {'acl-drop': 29, 'l2_acl': 35, 'last_clearing': '10:43:33 EDT Mar 27 2019 by genie', 'no-mcast-intrf': 31, 'rpf-violated': 23, 'sp-security-faile... |
#O(n^2) Time / O(n) Space
def threeNumberSum(arr,targetSum):
triplets=[]
arr.sort()
for i in range(len(arr)-2):
left=i+1
right=len(arr)-1
while(left<right):
currentSum=arr[i]+arr[left]+arr[right]
if currentSum==targetSum:
triplets.append([arr[i],arr[left],arr[right]])
left+... | def three_number_sum(arr, targetSum):
triplets = []
arr.sort()
for i in range(len(arr) - 2):
left = i + 1
right = len(arr) - 1
while left < right:
current_sum = arr[i] + arr[left] + arr[right]
if currentSum == targetSum:
triplets.append([arr[i]... |
Space = " "
class Solution:
def lengthOfLastWord(self, s: str) -> int:
found_word = False
word_length = 0
for i in range(len(s) - 1, -1, -1):
letter = s[i]
if letter == Space:
if found_word:
break
else:
... | space = ' '
class Solution:
def length_of_last_word(self, s: str) -> int:
found_word = False
word_length = 0
for i in range(len(s) - 1, -1, -1):
letter = s[i]
if letter == Space:
if found_word:
break
else:
... |
action_space={'11':0,'12':1,'13':2,'14':3,'15':4,'21':5,'22':6,'23':7,'24':8,'25':9,'31':10,'32':11,'33':12,'34':13,'35':14,'41':15,'42':16,'43':17,'44':18,'45':19,'51':20,'52':21,'53':22,'54':23,'55':24,'1112':25,'1121':26,'1122':27,'1113':28,'1131':29,'1133':30,'1213':31,'1211':32,'1222':33,'1232':34,'1214':35,'1312'... | action_space = {'11': 0, '12': 1, '13': 2, '14': 3, '15': 4, '21': 5, '22': 6, '23': 7, '24': 8, '25': 9, '31': 10, '32': 11, '33': 12, '34': 13, '35': 14, '41': 15, '42': 16, '43': 17, '44': 18, '45': 19, '51': 20, '52': 21, '53': 22, '54': 23, '55': 24, '1112': 25, '1121': 26, '1122': 27, '1113': 28, '1131': 29, '113... |
#
# PySNMP MIB module Juniper-Fractional-T1-CONF (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-Fractional-T1-CONF
# Produced by pysmi-0.3.4 at Mon Apr 29 19:51:59 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint) ... |
class Solution(object):
# def singleNumber(self, nums):
# """
# :type nums: List[int]
# :rtype: int
# """
# # hash
# dic = {}
# for num in nums:
# try:
# dic[num] += 1
# except KeyError:
# dic[num] = 1
... | class Solution(object):
def single_number(self, nums):
res = 0
for num in nums:
res ^= num
return res |
'''
QUESTION:
455. Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size sj. If sj >= gi... | """
QUESTION:
455. Assign Cookies
Assume you are an awesome parent and want to give your children some cookies. But, you should give each child at most one cookie. Each child i has a greed factor gi, which is the minimum size of a cookie that the child will be content with; and each cookie j has a size sj. If sj >= gi... |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def preorderTraversal(self, root: TreeNode) -> List[int]:
if root is None:
return []
val = root.val
left_list... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def preorder_traversal(self, root: TreeNode) -> List[int]:
if root is None:
return []
val = root.val
left_list = self.preorderTraversal(root.left)... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def findDuplicateSubtrees(self, root: TreeNode) -> List[TreeNode]:
trees = defaultdict()
tre... | class Solution:
def find_duplicate_subtrees(self, root: TreeNode) -> List[TreeNode]:
trees = defaultdict()
trees.default_factory = trees.__len__
count = counter()
result = []
def lookup(node):
if node:
uid = trees[node.val, lookup(node.left), loo... |
# Copyright 2017, Optimizely
# 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, softwa... | class Userprofile(object):
""" Class encapsulating information representing a user's profile.
user_id: User's identifier.
experiment_bucket_map: Dict mapping experiment ID to dict consisting of the
variation ID identifying the variation for the user.
"""
user_id_key = 'user_i... |
#!/bin/python3
'''
Generate a vector of length m with exactkly n ones
'''
def generate_vec_binary(n, m):
res = []
lower = sum(2**i for i in range(m-4))
upper = sum(2**i for i in range(m-4, m))+1
for i in range(lower, upper):
val = bin(i)[2:].zfill(8)
if sum([int(i) for i in val]) == 4... | """
Generate a vector of length m with exactkly n ones
"""
def generate_vec_binary(n, m):
res = []
lower = sum((2 ** i for i in range(m - 4)))
upper = sum((2 ** i for i in range(m - 4, m))) + 1
for i in range(lower, upper):
val = bin(i)[2:].zfill(8)
if sum([int(i) for i in val]) == 4:
... |
def mutate_string(string, position, character):
# method_#1
#str_list = list( string )
#str_list[position] = character
#str_modified = ''.join(str_list)
str_modified = mutate_string_method2( string, position, character)
return str_modified
# method_#2
def mutate_string_method2(string, p... | def mutate_string(string, position, character):
str_modified = mutate_string_method2(string, position, character)
return str_modified
def mutate_string_method2(string, position, character):
str_modified = string[:position] + character + string[position + 1:]
return str_modified
if __name__ == '__main__... |
# line intersection detection
# line1: (x1, y1) to (x2, y2)
# line2: (x3, y3) to (x4, y4)
def Intercept(x1, y1, x2, y2, x3, y3, x4, y4, d):
denom = ((y4-y3) * (x2-x1)) - ((x4-x3) * (y2-y1))
if (denom != 0):
ua = (((x4-x3) * (y1-y3)) - ((y4-y3) * (x1-x3))) / denom
if ((ua >= 0) and (ua <= 1)):... | def intercept(x1, y1, x2, y2, x3, y3, x4, y4, d):
denom = (y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1)
if denom != 0:
ua = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / denom
if ua >= 0 and ua <= 1:
ub = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / denom
if ub >... |
load("@io_bazel_rules_dotnet//dotnet:defs.bzl", "dotnet_nuget_new", "nuget_package")
dotnet_nuget_new(
name = "npgsql",
package="Npgsql",
version="3.2.7",
sha256="683bbe42cd585f28beb23822a113db5731bce44020fd0af2ac827e642fe7e301",
build_file_content="""
package(default_visibility = [ "//visi... | load('@io_bazel_rules_dotnet//dotnet:defs.bzl', 'dotnet_nuget_new', 'nuget_package')
dotnet_nuget_new(name='npgsql', package='Npgsql', version='3.2.7', sha256='683bbe42cd585f28beb23822a113db5731bce44020fd0af2ac827e642fe7e301', build_file_content='\npackage(default_visibility = [ "//visibility:public" ])\nload("@io_baze... |
# Copyright 2020 Pax Syriana Foundation. Licensed under the Apache License, Version 2.0
#
class Error:
"""
A very simple class to hold error messages.
This class is used for concatenating succession of errors that don't stop the
flow.
"""
def __init__(self):
# prev_frame = inspect.... | class Error:
"""
A very simple class to hold error messages.
This class is used for concatenating succession of errors that don't stop the
flow.
"""
def __init__(self):
self._msg = []
def __add__(self, other):
res = error()
res._msg.extend(self._msg)
res._m... |
def dominantIndex(self, nums):
i = nums.index(max(nums))
l = nums[i]
del nums[i]
if not nums: return 0
return i if l >= 2 * max(nums) else -1 | def dominant_index(self, nums):
i = nums.index(max(nums))
l = nums[i]
del nums[i]
if not nums:
return 0
return i if l >= 2 * max(nums) else -1 |
def parse_index_file(filename):
"""Parse index file."""
index = []
for line in open(filename):
index.append(int(line.strip()))
return index
def get_data_from_file(file_text, file_pos):
first_line = True
with open(file_text, encoding="utf8") as f1, open(file_pos, encoding="utf8") as f2:
... | def parse_index_file(filename):
"""Parse index file."""
index = []
for line in open(filename):
index.append(int(line.strip()))
return index
def get_data_from_file(file_text, file_pos):
first_line = True
with open(file_text, encoding='utf8') as f1, open(file_pos, encoding='utf8') as f2:
... |
text = 'i love to count words'
count = 0
for char in text:
if char == ' ':
count = count + 1
#must add one extra line for the last word
count = count + 1
print(count) | text = 'i love to count words'
count = 0
for char in text:
if char == ' ':
count = count + 1
count = count + 1
print(count) |
class Solution(object):
def isValid(self, s):
"""
:type s: str
:rtype: bool
"""
if len(s) == 0:
return True
if len(s) == 1:
return False
left = []
right = []
for i in range(len(s)):
c = s[i]
if c ... | class Solution(object):
def is_valid(self, s):
"""
:type s: str
:rtype: bool
"""
if len(s) == 0:
return True
if len(s) == 1:
return False
left = []
right = []
for i in range(len(s)):
c = s[i]
if ... |
def construct_error_response(context, api_request_id):
"""
Construct error response dict
:param context: AWS Context object, containing properties about the invocation, function, and execution environment.
:param api_request_id:
:return: dict, a dict object containing information about the aws logg... | def construct_error_response(context, api_request_id):
"""
Construct error response dict
:param context: AWS Context object, containing properties about the invocation, function, and execution environment.
:param api_request_id:
:return: dict, a dict object containing information about the aws loggr... |
r"""
Introduction
Sage has a wide support for 3D graphics, from basic shapes to implicit and
parametric plots.
The following graphics functions are supported:
- :func:`~plot3d` - plot a 3d function
- :func:`~sage.plot.plot3d.parametric_plot3d.parametric_plot3d` - a parametric three-dimensional space curve or sur... | """
Introduction
Sage has a wide support for 3D graphics, from basic shapes to implicit and
parametric plots.
The following graphics functions are supported:
- :func:`~plot3d` - plot a 3d function
- :func:`~sage.plot.plot3d.parametric_plot3d.parametric_plot3d` - a parametric three-dimensional space curve or surf... |
def sum100():
total = 0;
for i in range(101):
total += i
return total
print(sum100())
| def sum100():
total = 0
for i in range(101):
total += i
return total
print(sum100()) |
'''
Now You Code 3: Amazon Deals
Create a program that downloads and prints Today's Deals from amazon.com (https://www.amazon.com/gp/goldbox)
Hint: You will need to use selenium to scrape this page, it is loaded with JavaScript!
Example Run:
Here are Amazon.com deals!
1.) Shower Hose 79 inch (6.5 Ft.) for Hand Held... | """
Now You Code 3: Amazon Deals
Create a program that downloads and prints Today's Deals from amazon.com (https://www.amazon.com/gp/goldbox)
Hint: You will need to use selenium to scrape this page, it is loaded with JavaScript!
Example Run:
Here are Amazon.com deals!
1.) Shower Hose 79 inch (6.5 Ft.) for Hand Held... |
# Copyright 2018 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Presubmit tests for android_webview/javatests/
Runs various style checks before upload.
"""
def CheckChangeOnUpload(input_api, output_api):
results = [... | """Presubmit tests for android_webview/javatests/
Runs various style checks before upload.
"""
def check_change_on_upload(input_api, output_api):
results = []
results.extend(__check_aw_j_unit_test_runner(input_api, output_api))
results.extend(__check_no_skip_command_line_annotation(input_api, output_api))... |
class Solution(object):
def isValidSudoku(self, board):
rows = [{} for i in range(9) ]
cols = [{} for i in range(9) ]
squares = [ {} for i in range(9)]
for i in range(9):
for j in range(9):
#print("iter", i, j, board[i][j])
#print(rows)
... | class Solution(object):
def is_valid_sudoku(self, board):
rows = [{} for i in range(9)]
cols = [{} for i in range(9)]
squares = [{} for i in range(9)]
for i in range(9):
for j in range(9):
cur_val = board[i][j]
if cur_val == '.':
... |
def insertion_sort(A):
"""Sort list of comparable elements into nondecreasing order."""
for k in range(1, len(A)):
curr = A[k]
j = k
while j>0 and A[j-1] > curr:
A[j] = A[j-1]
j -= 1
A[j] = curr
return A
print(insertion_sort([234,3,4,3,45,3... | def insertion_sort(A):
"""Sort list of comparable elements into nondecreasing order."""
for k in range(1, len(A)):
curr = A[k]
j = k
while j > 0 and A[j - 1] > curr:
A[j] = A[j - 1]
j -= 1
A[j] = curr
return A
print(insertion_sort([234, 3, 4, 3, 45, 3,... |
# Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project au... | {'variables': {'use_libjpeg_turbo%': '<(use_libjpeg_turbo)', 'conditions': [['use_libjpeg_turbo==1', {'libjpeg_include_dir%': ['<(DEPTH)/third_party/libjpeg_turbo']}, {'libjpeg_include_dir%': ['<(DEPTH)/third_party/libjpeg']}]]}, 'includes': ['../build/common.gypi'], 'targets': [{'target_name': 'common_video', 'type': ... |
def portrayCell(cell):
'''
This function is registered with the visualization server to be called
each tick to indicate how to draw the cell in its current state.
:param cell: the cell in the simulation
:return: the portrayal dictionary.
'''
assert cell is not None
return {
"Sha... | def portray_cell(cell):
"""
This function is registered with the visualization server to be called
each tick to indicate how to draw the cell in its current state.
:param cell: the cell in the simulation
:return: the portrayal dictionary.
"""
assert cell is not None
return {'Shape': 'he... |
# -*- coding: utf-8 -*-
class User_stopword(object):
user_stop = ['html','head','title','base','link','meta','style','body','article','section','nav','aside','header','footer','address','p','hr','pre','blockquote','ol','ul','li','dl','dt','dd','figure','figcaption','div','main','a','em','strong','small','s','cite','... | class User_Stopword(object):
user_stop = ['html', 'head', 'title', 'base', 'link', 'meta', 'style', 'body', 'article', 'section', 'nav', 'aside', 'header', 'footer', 'address', 'p', 'hr', 'pre', 'blockquote', 'ol', 'ul', 'li', 'dl', 'dt', 'dd', 'figure', 'figcaption', 'div', 'main', 'a', 'em', 'strong', 'small', 's... |
def clojure_binary_impl(ctx):
toolchain = ctx.toolchains["@rules_clojure//:toolchain"]
deps = depset(
direct = toolchain.files.runtime,
transitive = [dep[JavaInfo].transitive_runtime_deps for dep in ctx.attr.deps],
)
executable = ctx.actions.declare_file(ctx.label.name)
ctx.action... | def clojure_binary_impl(ctx):
toolchain = ctx.toolchains['@rules_clojure//:toolchain']
deps = depset(direct=toolchain.files.runtime, transitive=[dep[JavaInfo].transitive_runtime_deps for dep in ctx.attr.deps])
executable = ctx.actions.declare_file(ctx.label.name)
ctx.actions.write(output=executable, con... |
#
# PySNMP MIB module CHIPNET-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CHIPNET-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:31:30 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, 0... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ... |
"""Constants for the Radio Thermostat integration."""
DOMAIN = "radiotherm"
TIMEOUT = 25
| """Constants for the Radio Thermostat integration."""
domain = 'radiotherm'
timeout = 25 |
electricity_bill = 0
water_bill = 20
internet_bill = 15
other_bills = 0
number_of_months = int(input())
total_el = 0
total_water = number_of_months * water_bill
total_net = number_of_months * internet_bill
total_other_bills = 0
for i in range (number_of_months):
electricity_bill = float(input())
other_bills = w... | electricity_bill = 0
water_bill = 20
internet_bill = 15
other_bills = 0
number_of_months = int(input())
total_el = 0
total_water = number_of_months * water_bill
total_net = number_of_months * internet_bill
total_other_bills = 0
for i in range(number_of_months):
electricity_bill = float(input())
other_bills = wa... |
"""
This module generates ANSI character codes to printing colors to terminals.
See: http://en.wikipedia.org/wiki/ANSI_escape_code
"""
CSI = '\033['
def code_to_chars(code):
return CSI + str(code) + 'm'
class AnsiCodes(object):
def __init__(self, codes):
for name in dir(codes):
if not n... | """
This module generates ANSI character codes to printing colors to terminals.
See: http://en.wikipedia.org/wiki/ANSI_escape_code
"""
csi = '\x1b['
def code_to_chars(code):
return CSI + str(code) + 'm'
class Ansicodes(object):
def __init__(self, codes):
for name in dir(codes):
if not nam... |
def test_errors_404(survey_runner):
response = survey_runner.test_client().get('/hfjdskahfjdkashfsa')
assert response.status_code == 404
assert '<title>Error</title' in response.get_data(True)
| def test_errors_404(survey_runner):
response = survey_runner.test_client().get('/hfjdskahfjdkashfsa')
assert response.status_code == 404
assert '<title>Error</title' in response.get_data(True) |
#from cStringIO import StringIO
class Message(object):
'''
Represents an AMQP message.
'''
def __init__(self, body=None, delivery_info=None, **properties):
if isinstance(body, unicode):
if properties.get('content_encoding', None) is None:
properties['content_encoding'] = 'utf-8'
body ... | class Message(object):
"""
Represents an AMQP message.
"""
def __init__(self, body=None, delivery_info=None, **properties):
if isinstance(body, unicode):
if properties.get('content_encoding', None) is None:
properties['content_encoding'] = 'utf-8'
body = body... |
class Solution:
def lengthOfLIS(self, nums) -> int:
# dp=[0 for i in range(len(nums))]
# res=1
# dp[0]=1
# for i in range(1,len(nums)):
# if nums[i]>nums[i-1]:
# dp[i]=dp[i-1]+1
# else:
# dp[i]=1
# res=max(res,dp[i]... | class Solution:
def length_of_lis(self, nums) -> int:
dp = [[] for i in nums]
res = 1
dp[0] = [nums[0]]
for i in range(1, len(nums)):
res = max(res, self.dfs([], nums[:i + 1], res))
return res
def dfs(self, track, nums, res):
if not nums or len(nums)... |
destinations = input()
command = input()
while not command == "Travel":
command = command.split(":")
if command[0] == "Add Stop":
index = int(command[1])
stop = command[2]
if index in range(len(destinations)):
destinations = destinations[:index] + stop + destination... | destinations = input()
command = input()
while not command == 'Travel':
command = command.split(':')
if command[0] == 'Add Stop':
index = int(command[1])
stop = command[2]
if index in range(len(destinations)):
destinations = destinations[:index] + stop + destinations[index:]
... |
# Storage for table names to remove
tables_to_remove = [
'The Barbarian',
'The Bard',
'The Cleric',
'The Druid',
'The Fighter',
'The Monk',
'The Paladin',
'The Ranger',
'The Rogue',
'The Sorcerer',
'The Warlock',
'The Wizard',
'Character Advancement',
'Multiclass... | tables_to_remove = ['The Barbarian', 'The Bard', 'The Cleric', 'The Druid', 'The Fighter', 'The Monk', 'The Paladin', 'The Ranger', 'The Rogue', 'The Sorcerer', 'The Warlock', 'The Wizard', 'Character Advancement', 'Multiclass Spellcaster: Spell Slots per Spell Level', 'Standard Exchange Rates', 'Ability Scores and Mod... |
# -*- coding: utf-8 -*-
"""
@author: yuan_xin
@contact: yuanxin9997@qq.com
@file: tabu_search_pdptw.py
@time: 2020/10/19 16:57
@description:
"""
| """
@author: yuan_xin
@contact: yuanxin9997@qq.com
@file: tabu_search_pdptw.py
@time: 2020/10/19 16:57
@description:
""" |
class Handler:
"""
The handler is responsible for running special events based on an instance.
Typical use-cases: Feed updates, email and push notifications.
Implement the handle_{action} function in order to execute code.
Default actions: create, update, delete
"""
model = None
def ... | class Handler:
"""
The handler is responsible for running special events based on an instance.
Typical use-cases: Feed updates, email and push notifications.
Implement the handle_{action} function in order to execute code.
Default actions: create, update, delete
"""
model = None
def r... |
#program to find maximum and the minimum value in a set.
#Create a set
seta = set([5, 10, 3, 15, 2, 20])
#Find maximum value
print(max(seta))
#Find minimum value
print(min(seta))
| seta = set([5, 10, 3, 15, 2, 20])
print(max(seta))
print(min(seta)) |
"""
Second test case of example xml files to parse and compare with each other.
Differences between form_xml_case_1 and form_xml_case_1_after:
- Rename 'name' to 'your_name'
- Add 'mood' field
XML of Surevey instance (answer to xform)
"""
DEFAULT_MOOD = 'good'
FIELDS_2 = [
'name', 'age', 'picture', 'has_childre... | """
Second test case of example xml files to parse and compare with each other.
Differences between form_xml_case_1 and form_xml_case_1_after:
- Rename 'name' to 'your_name'
- Add 'mood' field
XML of Surevey instance (answer to xform)
"""
default_mood = 'good'
fields_2 = ['name', 'age', 'picture', 'has_children', 'g... |
n=input("enter the enumber:")
length=len(n)
org=int(n)
sum=0
n1=int(n)
while(n1!=0):
rem=n1%10
sum+=(rem**length)
n1=n1//10
if(sum==org):
print("it is a armstrong number")
else:
print("it is not an armstrong number")
| n = input('enter the enumber:')
length = len(n)
org = int(n)
sum = 0
n1 = int(n)
while n1 != 0:
rem = n1 % 10
sum += rem ** length
n1 = n1 // 10
if sum == org:
print('it is a armstrong number')
else:
print('it is not an armstrong number') |
"""BVP Solvers."""
# class BVPFilter:
# def __init__(dynamics_model, measurement_model, initrv):
# self.kalman = MyKalman(
# dynamics_model=bridge_prior, measurement_model=measmod, initrv=initrv
# )
# def single_solve(dataset, times):
# kalman_posterior = kalman.iterated_filt... | """BVP Solvers.""" |
# https://leetcode.com/problems/simplify-path
class Solution:
def simplifyPath(self, path: str) -> str:
stack = []
for i in path.split('/'):
if stack and i == "..":
stack.pop()
elif i not in [".", "", ".."]:
stack.append(i)
... | class Solution:
def simplify_path(self, path: str) -> str:
stack = []
for i in path.split('/'):
if stack and i == '..':
stack.pop()
elif i not in ['.', '', '..']:
stack.append(i)
return '/' + '/'.join(stack) |
result=("0")
number1=int(input("Enter first number: "))
number2=int(input("Enter second number: "))
operator=str(input("""Choose from: 'addition', 'subtraction', 'multiplication' or 'division':
"""))
operator = operator.lower()
if operator == "addition":
result=str((number1+number2))
print("The result ... | result = '0'
number1 = int(input('Enter first number: '))
number2 = int(input('Enter second number: '))
operator = str(input("Choose from: 'addition', 'subtraction', 'multiplication' or 'division': \n"))
operator = operator.lower()
if operator == 'addition':
result = str(number1 + number2)
print('The result is ... |
#!/usr/bin/python
'''!
Program to compute the odds for the game of Baccarat.
@author <a href="email:fulkgl@gmail.com">George L Fulk</a>
'''
def bacc_value(num1, num2):
'''!
Compute the baccarat value with 2 inputed integer rank values (0..12).
'''
if num1 > 9:
num1 = 0
if num2 > 9:
... | """!
Program to compute the odds for the game of Baccarat.
@author <a href="email:fulkgl@gmail.com">George L Fulk</a>
"""
def bacc_value(num1, num2):
"""!
Compute the baccarat value with 2 inputed integer rank values (0..12).
"""
if num1 > 9:
num1 = 0
if num2 > 9:
num2 = 0
num1... |
def hashify(string):
dict={}
res=string+string[0]
for i,j in enumerate(string):
if dict.get(j, None):
if isinstance(dict[j], str):
dict[j]=list(dict[j])+[res[i+1]]
else:
dict[j].append(res[i+1])
else:
dict[j]=res[i+1]
re... | def hashify(string):
dict = {}
res = string + string[0]
for (i, j) in enumerate(string):
if dict.get(j, None):
if isinstance(dict[j], str):
dict[j] = list(dict[j]) + [res[i + 1]]
else:
dict[j].append(res[i + 1])
else:
dict[j... |
"""
in this module, I define a obj change, which record the change infomation of a video in a timestamp.
"""
# coding:utf-8
class Tempor:
"""
obj
"""
def __init__(self, video_id, time, views, likes, dislikes, comments):
self.video_id = video_id
self.time = time
self.views = ... | """
in this module, I define a obj change, which record the change infomation of a video in a timestamp.
"""
class Tempor:
"""
obj
"""
def __init__(self, video_id, time, views, likes, dislikes, comments):
self.video_id = video_id
self.time = time
self.views = views
self... |
def Tux(thoughts, eyes, eye, tongue):
return f"""
{thoughts}
{thoughts}
.--.
|{eye}_{eye} |
|:_/ |
// \\ \\
(| | )
/'\\_ _/\`\\
\\___)=(___/
""" | def tux(thoughts, eyes, eye, tongue):
return f"\n {thoughts}\n {thoughts}\n .--.\n |{eye}_{eye} |\n |:_/ |\n // \\ \\\n (| | )\n /'\\_ _/\\`\\\n \\___)=(___/\n\n" |
# https://github.com/ycm-core/YouCompleteMe/blob/321700e848595af129d5d75afac92d0060d3cdf9/README.md#configuring-through-vim-options
def Settings( **kwargs ):
client_data = kwargs[ 'client_data' ]
return {
'interpreter_path': client_data[ 'g:ycm_python_interpreter_path' ],
'sys_path': client_data[ 'g:ycm_pyt... | def settings(**kwargs):
client_data = kwargs['client_data']
return {'interpreter_path': client_data['g:ycm_python_interpreter_path'], 'sys_path': client_data['g:ycm_python_sys_path']} |
# https://leetcode.com/problems/number-of-1-bits/
class Solution(object):
# Runtime: 46 ms, faster than 5.64% of Python online submissions for Number of 1 Bits.
# Memory Usage: 13.4 MB, less than 34.23% of Python online submissions for Number of 1 Bits.
def hammingWeight(self, n):
"""
:... | class Solution(object):
def hamming_weight(self, n):
"""
:type n: int
:rtype: int
"""
count = 0
while n:
if n & 1:
count += 1
n = n >> 1
return count
'\nThere are a lot of different ways to solve this problem, starting ... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
class PyobsException(Exception):
pass
class ConnectionFailure(PyobsException):
pass
class MessageTimeout(PyobsException):
pass
class ObjectError(PyobsException):
pass
| class Pyobsexception(Exception):
pass
class Connectionfailure(PyobsException):
pass
class Messagetimeout(PyobsException):
pass
class Objecterror(PyobsException):
pass |
class Student:
cname='DurgaSoft' #static variable
def __init__(self,name,rollno):
self.name=name #instance variable
self.rollno=rollno
s1=Student('durga',101)
s2=Student('pawan',102)
print(s1.name,s1.rollno,s1.cname)
print(s2.name,s2.rollno,s2.cname)
| class Student:
cname = 'DurgaSoft'
def __init__(self, name, rollno):
self.name = name
self.rollno = rollno
s1 = student('durga', 101)
s2 = student('pawan', 102)
print(s1.name, s1.rollno, s1.cname)
print(s2.name, s2.rollno, s2.cname) |
"""
https://zhuanlan.zhihu.com/p/50804195
"""
def test_args(first, *args):
"""
output:
Required argument: 1
<class 'tuple'>
Optional argument: 2
Optional argument: 3
Optional argument: 4
"""
print('Required argument: ', first)
print(type(args)) # <class 'tuple'>
for v ... | """
https://zhuanlan.zhihu.com/p/50804195
"""
def test_args(first, *args):
"""
output:
Required argument: 1
<class 'tuple'>
Optional argument: 2
Optional argument: 3
Optional argument: 4
"""
print('Required argument: ', first)
print(type(args))
for v in args:
pri... |
a = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
b = [4, 5, 6]
c = [0, 0, 0]
def t():
for j in range(len(a)):
for [A1, A2, A3] in [[1, 2, 3], [1, 2, 3], [1, 2, 3]]:
for B in b:
c[A1-1] = B + A1*2
c[A2-1] = B + A2*2
c[A3-1] = B + A3*2
t()
print(c)
| a = [[1, 2, 3], [1, 2, 3], [1, 2, 3]]
b = [4, 5, 6]
c = [0, 0, 0]
def t():
for j in range(len(a)):
for [a1, a2, a3] in [[1, 2, 3], [1, 2, 3], [1, 2, 3]]:
for b in b:
c[A1 - 1] = B + A1 * 2
c[A2 - 1] = B + A2 * 2
c[A3 - 1] = B + A3 * 2
t()
print(c) |
class Item:
def __init__(self, profit, weight):
self.profit = profit
self.weight = weight
def zeroKnapsack(items, capacity, currentIndex):
if capacity <= 0 or currentIndex < 0 or currentIndex>=len(items):
return 0
elif items[currentIndex].weight <= capacity:
profit1 = items[currentIndex].profit + zeroKnapsa... | class Item:
def __init__(self, profit, weight):
self.profit = profit
self.weight = weight
def zero_knapsack(items, capacity, currentIndex):
if capacity <= 0 or currentIndex < 0 or currentIndex >= len(items):
return 0
elif items[currentIndex].weight <= capacity:
profit1 = it... |
#
# PySNMP MIB module WL400-SNMPGEN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/WL400-SNMPGEN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:36:41 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, single_value_constraint, value_size_constraint, constraints_union) ... |
__all__ = [
'update_network_static_route_model',
'rule11_model',
'rule10_model',
'update_network_content_filtering_model',
'rule8_model',
'update_network_ssid_traffic_shaping_model',
'rule7_model',
'update_organization_snmp_model',
'move_network_sm_devices_model',
'lock_... | __all__ = ['update_network_static_route_model', 'rule11_model', 'rule10_model', 'update_network_content_filtering_model', 'rule8_model', 'update_network_ssid_traffic_shaping_model', 'rule7_model', 'update_organization_snmp_model', 'move_network_sm_devices_model', 'lock_network_sm_devices_model', 'update_network_sm_devi... |
file = open('helloworld.txt', 'w+')
file.write('file: helloworld.txt\n\n')
for y in range(10):
line = ''
if y == 0:
line = 'y | x\n'
for x in range(10):
if x == 0:
line += f'{y} | '
line += x.__str__() + ' '
file.write(line + '\n')
file.close()
| file = open('helloworld.txt', 'w+')
file.write('file: helloworld.txt\n\n')
for y in range(10):
line = ''
if y == 0:
line = 'y | x\n'
for x in range(10):
if x == 0:
line += f'{y} | '
line += x.__str__() + ' '
file.write(line + '\n')
file.close() |
# ------------------------------
# 139. Word Break
#
# Description:
# Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.
# Note:
# The same word in the dictionary may be reused multi... | class Solution(object):
def word_break(self, s, wordDict):
"""
:type s: str
:type wordDict: List[str]
:rtype: bool
"""
dp = [False for _ in range(len(s) + 1)]
dp[0] = True
for i in range(1, len(s) + 1):
for j in range(i):
i... |
"""
default configure for benchmark function
"""
class XtBenchmarkConf(object):
"""benchmark conf, user also can re-set it"""
default_db_root = "/tmp/.xt_data/sqlite" # could set path by yourself
default_id = "xt_default_benchmark"
defalut_log_path = "/tmp/.xt_data/logs"
default_tb_path = "/tmp/.... | """
default configure for benchmark function
"""
class Xtbenchmarkconf(object):
"""benchmark conf, user also can re-set it"""
default_db_root = '/tmp/.xt_data/sqlite'
default_id = 'xt_default_benchmark'
defalut_log_path = '/tmp/.xt_data/logs'
default_tb_path = '/tmp/.xt_data/tensorboard'
defaul... |
#
# PySNMP MIB module CISCO-DMN-DSG-REMINDER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-DMN-DSG-REMINDER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:55:08 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_size_constraint, constraints_union, value_range_constraint) ... |
""" Given two strings S and T, return if they are equal when both are typed into
empty text editors. # means a backspace character. Note that after
backspacing an empty text, the text will continue empty.
Example 1: Input: S
= "ab#c", T = "ad#c" Output: true Explanation: Both S and T become "ac".
... | """ Given two strings S and T, return if they are equal when both are typed into
empty text editors. # means a backspace character. Note that after
backspacing an empty text, the text will continue empty.
Example 1: Input: S
= "ab#c", T = "ad#c" Output: true Explanation: Both S and T become "ac".
... |
PI = 3.14
r = 6
area = PI * r * r
#print(area)
#calulate the surface area of a circle.
def findArea(r):
PI = 3.14
return PI * (r*r);
print('area of circle',findArea(6));
| pi = 3.14
r = 6
area = PI * r * r
def find_area(r):
pi = 3.14
return PI * (r * r)
print('area of circle', find_area(6)) |
# 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, ... | load('@rules_rust//rust:defs.bzl', 'rust_binary')
def _wasm_rust_transition_impl(settings, attr):
return {'//command_line_option:platforms': '@rules_rust//rust/platform:wasm'}
def _wasi_rust_transition_impl(settings, attr):
return {'//command_line_option:platforms': '@rules_rust//rust/platform:wasi'}
wasm_rus... |
schema = {
"transaction": {
"attributes": ["category", "execution-date", "amount", "reference"],
"key": "identifier",
"representation": [
"execution-date",
"reference",
"account-of-receiver.account-number",
"amount",
],
},
"cont... | schema = {'transaction': {'attributes': ['category', 'execution-date', 'amount', 'reference'], 'key': 'identifier', 'representation': ['execution-date', 'reference', 'account-of-receiver.account-number', 'amount']}, 'contract': {'attributes': ['sign-date'], 'key': 'identifier', 'representation': ['identifier']}, 'accou... |
'''
Get the name and the value of various products.
The program should ask if the user wants to continue.
In the end show the following:
1 - The total value.
2 - How many products costs more than R$1000.
3 - The name of cheaper product.
'''
dlength = 20
division = '=-' * dlength
print(f'{divis... | """
Get the name and the value of various products.
The program should ask if the user wants to continue.
In the end show the following:
1 - The total value.
2 - How many products costs more than R$1000.
3 - The name of cheaper product.
"""
dlength = 20
division = '=-' * dlength
print(f"{divisi... |
def countWordsFromFile():
fileName = input("Enter the file name:- ")
numberOfWords = 0
file = open(fileName, 'r')
for line in file:
words = line.split()
numberOfWords=numberOfWords+len(words)
print("The number of words in this file are: ")
print(numberOfWords)
countWordsFro... | def count_words_from_file():
file_name = input('Enter the file name:- ')
number_of_words = 0
file = open(fileName, 'r')
for line in file:
words = line.split()
number_of_words = numberOfWords + len(words)
print('The number of words in this file are: ')
print(numberOfWords)
count_w... |
def rearrange(arr, n):
# Auxiliary array to hold modified array
temp = n*[None]
# Indexes of smallest and largest elements
# from remaining array.
small,large =0,n-1
# To indicate whether we need to copy rmaining
# largest or remaining smallest at next position
flag = True
... | def rearrange(arr, n):
temp = n * [None]
(small, large) = (0, n - 1)
flag = True
for i in range(n):
if flag is True:
temp[i] = arr[large]
large -= 1
else:
temp[i] = arr[small]
small += 1
flag = bool(1 - flag)
for i in range(n):
... |
# def start_end_decorator(func):
# def wrapper(number):
# print("Start")
# result = func(number)
# print("End")
# return result
# return wrapper
# @start_end_decorator
# def func(number):
# print("Inside func")
# return number + 5
# result = func(5)
# print(result)
... | def func1(func):
def now():
print('Start')
func()
print('End')
return now
@func1
def func():
print('Jatin Yadav')
func() |
# O(NlogM) / O(1)
class Solution:
def splitArray(self, nums: List[int], m: int) -> int:
def count(d):
ans, cur = 1, 0
for num in nums:
cur += num
if cur > d:
ans += 1
cur = num
return ans
... | class Solution:
def split_array(self, nums: List[int], m: int) -> int:
def count(d):
(ans, cur) = (1, 0)
for num in nums:
cur += num
if cur > d:
ans += 1
cur = num
return ans
(l, r) = (max(n... |
def f(w : list, u : list, m : int) -> int:
x = float(0)
for i in range(m):
x += (w[i]*u[i])
if x < 0.0:
return 0
return 1
def perceptron(u : list, c : float):
wt = [1.0 for _ in range(26)]
t = 1
counter = 0
while counter < 5:
zt = 1 if t % 5 < 3 else 0
... | def f(w: list, u: list, m: int) -> int:
x = float(0)
for i in range(m):
x += w[i] * u[i]
if x < 0.0:
return 0
return 1
def perceptron(u: list, c: float):
wt = [1.0 for _ in range(26)]
t = 1
counter = 0
while counter < 5:
zt = 1 if t % 5 < 3 else 0
yt = f(... |
# calculo del perimetro del cuadrado
print('calculo del perimetro cuadrado')
lado = int(input('introduce el valor del lado que conoces del cuadrado: '))
lado *= 4
print('el perimetro del cuadrado es: ',lado)
| print('calculo del perimetro cuadrado')
lado = int(input('introduce el valor del lado que conoces del cuadrado: '))
lado *= 4
print('el perimetro del cuadrado es: ', lado) |
def load(h):
return ({'abbr': 'msl', 'code': 1, 'title': 'MSL Pressure reduced to MSL Pa'},
{'abbr': 't', 'code': 11, 'title': 'T Temperature Deg C'},
{'abbr': 'pt', 'code': 13, 'title': 'PT Potential temperature K'},
{'abbr': 'ws1', 'code': 28, 'title': 'WS1 Wave spectra (1) -'}... | def load(h):
return ({'abbr': 'msl', 'code': 1, 'title': 'MSL Pressure reduced to MSL Pa'}, {'abbr': 't', 'code': 11, 'title': 'T Temperature Deg C'}, {'abbr': 'pt', 'code': 13, 'title': 'PT Potential temperature K'}, {'abbr': 'ws1', 'code': 28, 'title': 'WS1 Wave spectra (1) -'}, {'abbr': 'ws2', 'code': 29, 'title... |
# 9. Find the minimum element in an array of integers.
# You can carry some extra information through method
# arguments such as minimum value.
def findmin(A, n):
# if size = 0 means whole array
# has been traversed
if (n == 1):
#if it's the last value just return it for comparison with ... | def findmin(A, n):
if n == 1:
return A[0]
minval = min(A[n - 1], findmin(A, n - 1))
return minval
if __name__ == '__main__':
a = [10, 14, 45, 6, 50, 10, 22]
n = len(A)
print('Smallest value in array is: {}'.format(findmin(A, n))) |
{
'target_defaults': {
'variables': {
'deps': [
'libchrome-<(libbase_ver)',
],
},
},
'targets': [
{
'target_name': 'touch_keyboard_handler',
'type': 'executable',
'sources': [
'evdevsource.cc',
'fakekeyboard.cc',
'faketouchpad.cc',
... | {'target_defaults': {'variables': {'deps': ['libchrome-<(libbase_ver)']}}, 'targets': [{'target_name': 'touch_keyboard_handler', 'type': 'executable', 'sources': ['evdevsource.cc', 'fakekeyboard.cc', 'faketouchpad.cc', 'haptic/ff_driver.cc', 'haptic/touch_ff_manager.cc', 'main.cc', 'statemachine/eventkey.cc', 'statemac... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.