content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
description = 'W&T Box * 0-10V * Nr. 2'
includes = []
_wutbox = 'wut-0-10-02'
_wutbox_dev = _wutbox.replace('-','_')
devices = {
_wutbox_dev +'_1': device('nicos_mlz.sans1.devices.wut.WutValue',
hostname = _wutbox + '.sans1.frm2',
port = '1',
description = 'input 1 voltage',
fmtstr... | description = 'W&T Box * 0-10V * Nr. 2'
includes = []
_wutbox = 'wut-0-10-02'
_wutbox_dev = _wutbox.replace('-', '_')
devices = {_wutbox_dev + '_1': device('nicos_mlz.sans1.devices.wut.WutValue', hostname=_wutbox + '.sans1.frm2', port='1', description='input 1 voltage', fmtstr='%.3F', lowlevel=False, loglevel='info', p... |
#!/usr/bin/env python
class ProxyAtom(object):
"""docstring for ProxyAtom"""
def __init__(self, ips, ports):
super(ProxyAtom, self).__init__()
result = dict(zip(ips, ports))
self.items = set([':'.join((host, port)) for host, port in result.items()])
| class Proxyatom(object):
"""docstring for ProxyAtom"""
def __init__(self, ips, ports):
super(ProxyAtom, self).__init__()
result = dict(zip(ips, ports))
self.items = set([':'.join((host, port)) for (host, port) in result.items()]) |
#!/usr/bin/env python
NAME = 'FortiWeb (Fortinet)'
def is_waf(self):
if self.matchcookie(r'^FORTIWAFSID='):
return True
for attack in self.attacks:
r = attack(self)
if r is None:
return
_, responsepage = r
# Found a site running a tweaked version of Fortiweb... | name = 'FortiWeb (Fortinet)'
def is_waf(self):
if self.matchcookie('^FORTIWAFSID='):
return True
for attack in self.attacks:
r = attack(self)
if r is None:
return
(_, responsepage) = r
if all((m in responsepage for m in (b'fgd_icon', b'Web Page Blocked', b'UR... |
def checkResult(netSales, eps):
try:
crfo = float(netSales[0])
except:
crfo = 0.0
try:
prfo = float(netSales[1])
except:
prfo = 0.0
try:
lrfo = float(netSales[2])
except:
lrfo = 0.0
try:
cqe = float(eps[0])
except:
cqe = 0.0... | def check_result(netSales, eps):
try:
crfo = float(netSales[0])
except:
crfo = 0.0
try:
prfo = float(netSales[1])
except:
prfo = 0.0
try:
lrfo = float(netSales[2])
except:
lrfo = 0.0
try:
cqe = float(eps[0])
except:
cqe = 0.... |
'''
A centered decagonal number is a centered figurate number that represents
a decagon with a dot in the center and all other dots surrounding the center
dot in successive decagonal layers.
The centered decagonal number for n is given by the formula
5n^2+5n+1
'''
def centeredDecagonal (num):... | """
A centered decagonal number is a centered figurate number that represents
a decagon with a dot in the center and all other dots surrounding the center
dot in successive decagonal layers.
The centered decagonal number for n is given by the formula
5n^2+5n+1
"""
def centered_decagonal(num):... |
# class Solution:
# def convert(self, s: str, numRows: int) -> str:
# lst = []
# N = len(s)
# print (N//(2*numRows-2))
# [lst.append([s[i]]) for i in range(numRows)]
# step = 2*numRows-2
# for k in range(N//step):
# if k:
# [lst[i].append(s... | class Solution:
def convert(self, s: str, numRows: int) -> str:
(lst, idx) = ([], 0)
(p_down, p_up) = (0, numRows - 2)
n = len(s)
if numRows == 1 or N <= 2 or numRows >= N:
return s
[lst.append(s[i]) for i in range(numRows)]
idx += numRows
while i... |
""" moe.py
A set of functions that can be used to select an item from a list using the
"Eeny, Meeny, Miny, Moe" method.
There are a few versions of the rhyme. The "regular" one is as follows:
Eeny, Meeny, Miny, Moe
Catch a tiger by his toe
If he hollers let him go
Eeny, Meeny, Miny, Moe
My mother told me
To pick the... | """ moe.py
A set of functions that can be used to select an item from a list using the
"Eeny, Meeny, Miny, Moe" method.
There are a few versions of the rhyme. The "regular" one is as follows:
Eeny, Meeny, Miny, Moe
Catch a tiger by his toe
If he hollers let him go
Eeny, Meeny, Miny, Moe
My mother told me
To pick the... |
def cpu_processing_time(cycles: int, freq: float):
"""
:param cycles
:param freq: MHz
:return: seconds
"""
return (cycles / (freq * pow(10, 6))) * pow(10, 3)
if __name__ == "__main__":
print(cpu_processing_time(1.05149 * pow(10, 6), 1300))
| def cpu_processing_time(cycles: int, freq: float):
"""
:param cycles
:param freq: MHz
:return: seconds
"""
return cycles / (freq * pow(10, 6)) * pow(10, 3)
if __name__ == '__main__':
print(cpu_processing_time(1.05149 * pow(10, 6), 1300)) |
"""
21.25%
"""
class Solution(object):
def firstMissingPositive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 1
nums = sorted(list(set(nums)))
n = 0
for index, num in enumerate(nums):
if num <= 0:
... | """
21.25%
"""
class Solution(object):
def first_missing_positive(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums:
return 1
nums = sorted(list(set(nums)))
n = 0
for (index, num) in enumerate(nums):
if num <=... |
class Solution(object):
def exclusiveTime(self, n, logs):
"""
:type n: int
:type logs: List[str]
:rtype: List[int]
"""
stack = []
overhead = [0]
res = [0 for i in range(n)]
for log_str in logs:
log = log_str.split(':')
... | class Solution(object):
def exclusive_time(self, n, logs):
"""
:type n: int
:type logs: List[str]
:rtype: List[int]
"""
stack = []
overhead = [0]
res = [0 for i in range(n)]
for log_str in logs:
log = log_str.split(':')
... |
#!/usr/bin/env python
# encoding: utf-8
"""
remove_dups_from_sorted_list_ii.py
Created by Shengwei on 2014-07-05.
"""
# https://oj.leetcode.com/problems/remove-duplicates-from-sorted-list-ii/
# tags: medium, linked-list, pointer, dups, edge cases
"""
Given a sorted linked list, delete all nodes that have duplicate n... | """
remove_dups_from_sorted_list_ii.py
Created by Shengwei on 2014-07-05.
"""
'\nGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.\n\nFor example,\nGiven 1->2->3->3->4->4->5, return 1->2->5.\nGiven 1->1->1->2->3, return 2->3.\n'
class Solut... |
"""This question was asked by BufferBox.
Given a binary tree where all nodes are either 0 or 1, prune the tree so that subtrees containing all 0s are removed.
For example, given the following tree:
0
/ \
1 0
/ \
1 0
/ \
0 0
should be pruned to:
0
/ \
1 0
/
1
We do not remove the... | """This question was asked by BufferBox.
Given a binary tree where all nodes are either 0 or 1, prune the tree so that subtrees containing all 0s are removed.
For example, given the following tree:
0
/ 1 0
/ 1 0
/ 0 0
should be pruned to:
0
/ 1 0
/
1
We do not remove the tree at... |
NO_RESET = 0b0
BATCH_RESET = 0b1
EPOCH_RESET = 0b10
NONE_METER = 'none'
SCALAR_METER = 'scalar'
TEXT_METER = 'text'
IMAGE_METER = 'image'
HIST_METER = 'hist'
GRAPH_METER = 'graph'
AUDIO_METER = 'audio'
| no_reset = 0
batch_reset = 1
epoch_reset = 2
none_meter = 'none'
scalar_meter = 'scalar'
text_meter = 'text'
image_meter = 'image'
hist_meter = 'hist'
graph_meter = 'graph'
audio_meter = 'audio' |
lower=100
upper=999
for num in range(lower,upper+1):
order=len(str(num))
sum=0
temp=num
while temp>0:
digit=temp%10
sum+=digit**order
temp//=10
if num==sum:
print(num)
| lower = 100
upper = 999
for num in range(lower, upper + 1):
order = len(str(num))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** order
temp //= 10
if num == sum:
print(num) |
def is_interesting(number, awesome_phrases):
if number<98: return 0
elif check(number, awesome_phrases) and number>=100: return 2
for i in range(number+1, number+3):
if i>=100 and check(i, awesome_phrases):
return 1
return 0
def check(n, awesome_phrases):
return equal(n) or all_z... | def is_interesting(number, awesome_phrases):
if number < 98:
return 0
elif check(number, awesome_phrases) and number >= 100:
return 2
for i in range(number + 1, number + 3):
if i >= 100 and check(i, awesome_phrases):
return 1
return 0
def check(n, awesome_phrases):
... |
with open('input', 'r') as expense_report:
expenses = [ int(a.strip()) for a in expense_report.readlines() ]
expenses = sorted(expenses)
def part1():
for a in expenses:
for b in expenses:
if a + b == 2020:
print(f"{a} + {b} = 2020, {a} * {b} = {a * b}")
... | with open('input', 'r') as expense_report:
expenses = [int(a.strip()) for a in expense_report.readlines()]
expenses = sorted(expenses)
def part1():
for a in expenses:
for b in expenses:
if a + b == 2020:
print(f'{a} + {b} = 2020, {a} * {b} = {a * b}')
ret... |
"""Migration for a given Submitty course database."""
def up(config, database, semester, course):
"""
Run up migration.
:param config: Object holding configuration details about Submitty
:type config: migrator.config.Config
:param database: Object for interacting with given database for environme... | """Migration for a given Submitty course database."""
def up(config, database, semester, course):
"""
Run up migration.
:param config: Object holding configuration details about Submitty
:type config: migrator.config.Config
:param database: Object for interacting with given database for environmen... |
##
# \file exceptions.py
# \brief User-specific exceptions
#
# \author Michael Ebner (michael.ebner.14@ucl.ac.uk)
# \date June 2017
#
##
# Error handling in case the directory does not contain valid nifti file
# \date 2017-06-14 11:11:37+0100
#
class InputFilesNotValid(Exception):
##
# \... | class Inputfilesnotvalid(Exception):
def __init__(self, directory):
self.directory = directory
def __str__(self):
error = "Folder '%s' does not contain valid nifti files." % self.directory
return error
class Objectnotcreated(Exception):
def __init__(self, function_call):
... |
# Testing
with open("stuck_in_a_rut.in") as file1:
N = int(file1.readline().strip())
cows = [[value if index == 0 else int(value) for index, value in enumerate(i.strip().split())] for i in file1.readlines()]
# Actual
# N = int(input())
# cow_numbers = [input() for _ in range(N)]
# cows = [[value if index == ... | with open('stuck_in_a_rut.in') as file1:
n = int(file1.readline().strip())
cows = [[value if index == 0 else int(value) for (index, value) in enumerate(i.strip().split())] for i in file1.readlines()]
future_path = {}
(max_x, max_y) = (max(cows, key=lambda x: x[1])[1], max(cows, key=lambda x: x[2])[2])
for i in ... |
__all__ = [
'DataFSError', 'UnsupportedOperation', 'InvalidOpenMode',
'DataFileNotExist', 'MetaKeyNotExist',
]
class DataFSError(Exception):
"""Base class for all :class:`DataFS` errors."""
class UnsupportedOperation(DataFSError):
"""
Class to indicate that a requested operation is not supported... | __all__ = ['DataFSError', 'UnsupportedOperation', 'InvalidOpenMode', 'DataFileNotExist', 'MetaKeyNotExist']
class Datafserror(Exception):
"""Base class for all :class:`DataFS` errors."""
class Unsupportedoperation(DataFSError):
"""
Class to indicate that a requested operation is not supported by the
s... |
# Time: O(max(h, k))
# Space: O(h)
# 230
# Given a binary search tree, write a function kthSmallest to find the kth smallest element in it.
#
# Note:
# You may assume k is always valid, 1 <= k <= BST's total elements.
#
# Follow up:
# What if the BST is modified (insert/delete operations) often and
# you need to find... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def kth_smallest(self, root, k):
stack = [(root, False)]
while stack:
(cur, visited) = stack.pop()
if cur:
if visited:
... |
height = int(input("Height: "))
width = int(input("Width: "))
for i in range(height):
for j in range(width):
print("* ",end='')
print()
| height = int(input('Height: '))
width = int(input('Width: '))
for i in range(height):
for j in range(width):
print('* ', end='')
print() |
shader_assignment = []
for shadingEngine in renderPartition.inputs():
if not shadingEngine.members():
continue
if shadingEngine.name() == 'initialShadingGroup':
continue
nameSE = shadingEngine.name()
nameSH = shadingEngine.surfaceShader.inputs()[0].name()
shader_assignment.appe... | shader_assignment = []
for shading_engine in renderPartition.inputs():
if not shadingEngine.members():
continue
if shadingEngine.name() == 'initialShadingGroup':
continue
name_se = shadingEngine.name()
name_sh = shadingEngine.surfaceShader.inputs()[0].name()
shader_assignment.append(... |
# Python - 2.7.6
Test.assert_equals(calculate_tip(30, 'poor'), 2)
Test.assert_equals(calculate_tip(20, 'Excellent'), 4)
Test.assert_equals(calculate_tip(20, 'hi'), 'Rating not recognised')
Test.assert_equals(calculate_tip(107.65, 'GReat'), 17)
Test.assert_equals(calculate_tip(20, 'great!'), 'Rating not recognised')
| Test.assert_equals(calculate_tip(30, 'poor'), 2)
Test.assert_equals(calculate_tip(20, 'Excellent'), 4)
Test.assert_equals(calculate_tip(20, 'hi'), 'Rating not recognised')
Test.assert_equals(calculate_tip(107.65, 'GReat'), 17)
Test.assert_equals(calculate_tip(20, 'great!'), 'Rating not recognised') |
# -*- coding: utf-8 -*-
#################################################################################
# Author : Webkul Software Pvt. Ltd. (<https://webkul.com/>)
# Copyright(c): 2015-Present Webkul Software Pvt. Ltd.
# All Rights Reserved.
#
#
#
# This program is copyright property of the author mentioned abo... | {'name': 'Website Webkul Addons', 'summary': 'Manage Webkul Website Addons', 'category': 'Website', 'version': '2.0.1', 'author': 'Webkul Software Pvt. Ltd.', 'website': 'https://store.webkul.com/Odoo.html', 'description': 'Website Webkul Addons', 'live_test_url': 'http://odoodemo.webkul.com/?module=website_webkul_addo... |
#------------------------------------------------------------------------------
# simple_universe/room.py
# Copyright 2011 Joseph Schilz
# Licensed under Apache v2
#------------------------------------------------------------------------------
class SimpleRoom(object):
ID = [-1, -1]
exits = []
desc... | class Simpleroom(object):
id = [-1, -1]
exits = []
description = ''
def __init__(self, ID=[-1, -1], exits=False, description=False, contents=False):
self.ID = ID
self.exits = exits
self.description = description
self.THIS_WORLD = False
self.contents = []
... |
# Time: O(n)
# Space: O(1)
# 751
# Given a start IP address ip and a number of ips we need to cover n,
# return a representation of the range as a list (of smallest possible length) of CIDR blocks.
#
# A CIDR block is a string consisting of an IP, followed by a slash,
# and then the prefix length. For example: "123.4... | class Solution(object):
def ip_to_cidr(self, ip, n):
"""
:type ip: str
:type n: int
:rtype: List[str]
"""
def ip2int(ip):
result = 0
for i in ip.split('.'):
result = 256 * result + int(i)
return result
def... |
def example_bytes_slice():
word = b'the lazy brown dog jumped'
for i in range(10):
# Memoryview slicing is 10x faster than bytes slicing
if word[0:i] == 'the':
return True
def example_bytes_slice_as_arg(word: bytes):
for i in range(10):
# Memoryview slicing is 10x faster... | def example_bytes_slice():
word = b'the lazy brown dog jumped'
for i in range(10):
if word[0:i] == 'the':
return True
def example_bytes_slice_as_arg(word: bytes):
for i in range(10):
if word[0:i] == 'the':
return True |
prve_stiri = [2, 3, 5, 7]
def je_prastevilo(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return n > 1
def trunctable_z_desne(n):
for indeks in range(1, len(str(n))):
if not je_prastevilo(int(str(n)[0:indeks])):
return False
return n... | prve_stiri = [2, 3, 5, 7]
def je_prastevilo(n):
i = 2
while i * i <= n:
if n % i == 0:
return False
i += 1
return n > 1
def trunctable_z_desne(n):
for indeks in range(1, len(str(n))):
if not je_prastevilo(int(str(n)[0:indeks])):
return False
return n... |
low=1
high=2
third=0
sum=0
temp=0
while(third<4000000):
third=low+high
if(third%2==0):
sum+=third
low=high
high=third
print(sum+2)
| low = 1
high = 2
third = 0
sum = 0
temp = 0
while third < 4000000:
third = low + high
if third % 2 == 0:
sum += third
low = high
high = third
print(sum + 2) |
#Skill: array iteration
#You are given an array of integers. Return the smallest positive integer that is not present in the array. The array may contain duplicate entries.
#For example, the input [3, 4, -1, 1] should return 2 because it is the smallest positive integer that doesn't exist in the array.
#Your solution... | class Solution:
def first_missing_positive(self, nums):
low = (1 << 31) - 1
high = 0
for i in nums:
if low > i and i > 0:
low = i
if high < i:
high = i
first_miss = low + 1
searchmiss = firstMiss
found = False
... |
class Solution:
def maxProfit(self, inventory: List[int], orders: int) -> int:
# [5, 5, 2]
inventory.sort(reverse=True)
inventory.append(0)
ans = 0
idx = 0
n = len(inventory)
while orders:
# find the first index such that inv[j] < inv[i]
... | class Solution:
def max_profit(self, inventory: List[int], orders: int) -> int:
inventory.sort(reverse=True)
inventory.append(0)
ans = 0
idx = 0
n = len(inventory)
while orders:
(lo, hi) = (idx + 1, n - 1)
while lo < hi:
mid = ... |
# Copyright (c) 2014 Mirantis Inc.
# Copyright (c) 2016 Codethink Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by ap... | """
This module defines types for comment entries.
"""
story_created = 'story_created'
story_details_changed = 'story_details_changed'
tags_added = 'tags_added'
tags_deleted = 'tags_deleted'
user_comment = 'user_comment'
task_created = 'task_created'
task_details_changed = 'task_details_changed'
task_status_changed = '... |
"""
This module defines the AtlasMetaData container type.
"""
class AtlasMetaData(object):
"""
Container class for an Atlas's metadata.
Readable metadata fields:
number_of_points (long)
number_of_lines (long)
number_of_areas (long)
number_of_nodes (long)
number_of_edges (long)
num... | """
This module defines the AtlasMetaData container type.
"""
class Atlasmetadata(object):
"""
Container class for an Atlas's metadata.
Readable metadata fields:
number_of_points (long)
number_of_lines (long)
number_of_areas (long)
number_of_nodes (long)
number_of_edges (long)
numb... |
"""
A Harness for creating and using GPs for inference.
-- kandasamy@cs.cmu.edu
"""
| """
A Harness for creating and using GPs for inference.
-- kandasamy@cs.cmu.edu
""" |
'''
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1] = 3 A[2] = 9
A[3] = 3... | """
A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired.
For example, in array A such that:
A[0] = 9 A[1] = 3 A[2] = 9
A[3] = 3 ... |
def maven_dependencies(callback):
callback({"artifact": "antlr:antlr:2.7.6", "lang": "java", "sha1": "cf4f67dae5df4f9932ae7810f4548ef3e14dd35e", "repository": "https://repo.maven.apache.org/maven2/", "name": "antlr_antlr", "actual": "@antlr_antlr//jar", "bind": "jar/antlr/antlr"})
callback({"artifact": "aopalli... | def maven_dependencies(callback):
callback({'artifact': 'antlr:antlr:2.7.6', 'lang': 'java', 'sha1': 'cf4f67dae5df4f9932ae7810f4548ef3e14dd35e', 'repository': 'https://repo.maven.apache.org/maven2/', 'name': 'antlr_antlr', 'actual': '@antlr_antlr//jar', 'bind': 'jar/antlr/antlr'})
callback({'artifact': 'aopalli... |
def solve(lines):
longest_intersec = []
for line in lines:
(r1, r2) = line.split("-")
(r1_start, r1_end) = map(int, r1.split(","))
(r2_start, r2_end) = map(int, r2.split(","))
current_longest_intersec = set(range(r1_start, r1_end + 1)) & set(range(r2_start, r2_end + 1))
i... | def solve(lines):
longest_intersec = []
for line in lines:
(r1, r2) = line.split('-')
(r1_start, r1_end) = map(int, r1.split(','))
(r2_start, r2_end) = map(int, r2.split(','))
current_longest_intersec = set(range(r1_start, r1_end + 1)) & set(range(r2_start, r2_end + 1))
i... |
def make_dist():
return default_python_distribution(
python_version="3.8"
)
def make_exe(dist):
policy = dist.make_python_packaging_policy()
policy.extension_module_filter = "all"
# policy.file_scanner_classify_files = True
policy.allow_files = True
policy.file_scanner_emit_files = ... | def make_dist():
return default_python_distribution(python_version='3.8')
def make_exe(dist):
policy = dist.make_python_packaging_policy()
policy.extension_module_filter = 'all'
policy.allow_files = True
policy.file_scanner_emit_files = True
policy.resources_location = 'in-memory'
python_co... |
def double(num):
return num * 2
# way 1
multiply = lambda x,y: x*y
print(multiply(5,10))
# way 2
print((lambda x,y: x+y)(6, 82))
numbers = [23, 73, 62, 3]
added = [ x*2 for x in numbers]
print(added)
added = [double(x) for x in numbers]
print(added)
added = [ (lambda x: x*2)(x) for x in numbers]
print(added)
... | def double(num):
return num * 2
multiply = lambda x, y: x * y
print(multiply(5, 10))
print((lambda x, y: x + y)(6, 82))
numbers = [23, 73, 62, 3]
added = [x * 2 for x in numbers]
print(added)
added = [double(x) for x in numbers]
print(added)
added = [(lambda x: x * 2)(x) for x in numbers]
print(added)
added = map(d... |
class AspectManager(object):
def __init__(self):
super(AspectManager, self).__init__()
def get_module_hooker(self, name):
return None
def load_aspects(self):
pass
| class Aspectmanager(object):
def __init__(self):
super(AspectManager, self).__init__()
def get_module_hooker(self, name):
return None
def load_aspects(self):
pass |
SECRET_KEY = 'example'
TIME_ZONE = 'Asia/Shanghai'
DEFAULT_XFILES_FACTOR = 0
URL_PREFIX = '/'
LOG_DIR = '/var/log/graphite'
GRAPHITE_ROOT = '/opt/graphite'
CONF_DIR = '/etc/graphite'
DASHBOARD_CONF = '/etc/graphite/dashboard.conf'
GRAPHTEMPLATES_CONF = '/etc/graphite/graphTemplates.conf'
# STORAGE_DIR = '/opt/graphite/... | secret_key = 'example'
time_zone = 'Asia/Shanghai'
default_xfiles_factor = 0
url_prefix = '/'
log_dir = '/var/log/graphite'
graphite_root = '/opt/graphite'
conf_dir = '/etc/graphite'
dashboard_conf = '/etc/graphite/dashboard.conf'
graphtemplates_conf = '/etc/graphite/graphTemplates.conf'
storage_finders = ('graphite.gr... |
n = int(input("Enter a number: "))
for x in range(1,16):
print(n,"x",x,"=",(n*x))
| n = int(input('Enter a number: '))
for x in range(1, 16):
print(n, 'x', x, '=', n * x) |
#
# PySNMP MIB module TIMETRA-LLDP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-LLDP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:11:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar ... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint) ... |
class kdtree:
def __init__(self, points, dimensions):
self.dimensions = dimensions
self.tree = self._build([(i, p) for i,p in enumerate(points)])
def closest(self, point):
return self._closest(self.tree, point)
def _build(self,points, depth=0):
n = len(point... | class Kdtree:
def __init__(self, points, dimensions):
self.dimensions = dimensions
self.tree = self._build([(i, p) for (i, p) in enumerate(points)])
def closest(self, point):
return self._closest(self.tree, point)
def _build(self, points, depth=0):
n = len(points)
... |
def A_type_annotation(integer: int, boolean: bool, string: str):
pass
def B_annotation_as_documentation(argument: 'One of the usages in PEP-3107'):
pass
def C_annotation_and_default(integer: int=42, list_: list=None):
pass
def D_annotated_kw_only_args(*, kwo: int, with_default: str='value'):
pass
... | def a_type_annotation(integer: int, boolean: bool, string: str):
pass
def b_annotation_as_documentation(argument: 'One of the usages in PEP-3107'):
pass
def c_annotation_and_default(integer: int=42, list_: list=None):
pass
def d_annotated_kw_only_args(*, kwo: int, with_default: str='value'):
pass
de... |
class Solution:
def addSpaces(self, s: str, spaces: List[int]) -> str:
ans = ""
prev = 0
for sp in spaces:
ans += s[prev:sp] + " "
prev = sp
return ans + s[prev:]
| class Solution:
def add_spaces(self, s: str, spaces: List[int]) -> str:
ans = ''
prev = 0
for sp in spaces:
ans += s[prev:sp] + ' '
prev = sp
return ans + s[prev:] |
print('Congratulations on running this script!!')
msg = 'hello world'
print(msg)
| print('Congratulations on running this script!!')
msg = 'hello world'
print(msg) |
def test_post_sub_category(app, client):
mock_request_data = {
"category_fk": "47314685-54c1-4863-9918-09f58b981eea",
"name": "teste",
"description": "testado testando"
}
response = client.post('/sub_categorys', json=mock_request_data)
assert response.status_code == 201
expec... | def test_post_sub_category(app, client):
mock_request_data = {'category_fk': '47314685-54c1-4863-9918-09f58b981eea', 'name': 'teste', 'description': 'testado testando'}
response = client.post('/sub_categorys', json=mock_request_data)
assert response.status_code == 201
expected = 'successfully registered... |
# %%
class WalletSwiss:
coversion_rates = {"usd" :1.10, "gpd": 0.81, "euro": 0.95, "yen": 123.84 }
#shows swiss conversion rates for each each currency starting at $1
def __init__(self,currency_amount):
self.currency_amount = currency_amount
self.currency_type = "franc"
def convert_currenc... | class Walletswiss:
coversion_rates = {'usd': 1.1, 'gpd': 0.81, 'euro': 0.95, 'yen': 123.84}
def __init__(self, currency_amount):
self.currency_amount = currency_amount
self.currency_type = 'franc'
def convert_currency(self, currency_type):
conversion_rate = WalletSwiss.coversion_ra... |
#
# from src/whrnd.c
#
# void init_rnd(int, int, int) to whrnd; .init
# double rnd(void) to whrnd; .__call__
#
class whrnd:
def __init__(self, x=1, y=1, z=1):
self.init(x, y, z)
def init(self, x, y, z):
self.x, self.y, self.z = x, y, z
def __call__(self):
self.x = 171 * (self.x... | class Whrnd:
def __init__(self, x=1, y=1, z=1):
self.init(x, y, z)
def init(self, x, y, z):
(self.x, self.y, self.z) = (x, y, z)
def __call__(self):
self.x = 171 * (self.x % 177) - 2 * (self.x // 177)
self.y = 172 * (self.y % 176) - 35 * (self.y // 176)
self.z = 17... |
#
# PySNMP MIB module DNOS-DCBX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DNOS-DCBX-MIB
# Produced by pysmi-0.3.4 at Wed May 1 12:51:23 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_size_constraint, constraints_union, value_range_constraint) ... |
description = 'system setup'
group = 'lowlevel'
display_order = 90
sysconfig = dict(
cache = 'localhost',
instrument = 'NEUTRA',
experiment = 'Exp',
datasinks = ['conssink', 'dmnsink', 'livesink', 'asciisink', 'shuttersink'],
notifiers = ['email'],
)
requires = ['shutters']
modules = [
'nic... | description = 'system setup'
group = 'lowlevel'
display_order = 90
sysconfig = dict(cache='localhost', instrument='NEUTRA', experiment='Exp', datasinks=['conssink', 'dmnsink', 'livesink', 'asciisink', 'shuttersink'], notifiers=['email'])
requires = ['shutters']
modules = ['nicos.commands.standard', 'nicos_sinq.commands... |
'''
Log in color from
https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python
usage :
import log
log.info("Hello World")
log.err("System Error")
'''
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD ... | """
Log in color from
https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python
usage :
import log
log.info("Hello World")
log.err("System Error")
"""
header = '\x1b[95m'
okblue = '\x1b[94m'
okgreen = '\x1b[92m'
warning = '\x1b[93m'
fail = '\x1b[91m'
endc = '\x1b[0m'
bold ... |
class SpecialError(Exception):
"""
Exception raised when there is an error while parsing a special.
"""
def __init__(self, attribute, content=None):
self.attribute = attribute
self.content = content
def __str__(self):
return (f"Unable to parse '{self.attribute}'\n"
... | class Specialerror(Exception):
"""
Exception raised when there is an error while parsing a special.
"""
def __init__(self, attribute, content=None):
self.attribute = attribute
self.content = content
def __str__(self):
return f"Unable to parse '{self.attribute}'\nContent: '{... |
#!/usr/bin/python
#
# Provides __ROR4__, __ROR8__, __ROL4__ and __ROL8__ functions.
#
# Author: Satoshi Tanda
#
################################################################################
# The MIT License (MIT)
#
# Copyright (c) 2014 tandasat
#
# Permission is hereby granted, free of charge, to any person obtaini... | def _rol(val, bits, bit_size):
return val << bits % bit_size & 2 ** bit_size - 1 | (val & 2 ** bit_size - 1) >> bit_size - bits % bit_size
def _ror(val, bits, bit_size):
return (val & 2 ** bit_size - 1) >> bits % bit_size | val << bit_size - bits % bit_size & 2 ** bit_size - 1
__ror4__ = lambda val, bits: _ror... |
'''
PARTITION PROBLEM
The problem is to identify if a given set of n elements can be divided
into two separate subsets such that sum of elements of both the subsets
is equal.
'''
def check(a, total, ind):
if total == 0:
return True
if ind == -1 or total < 0:
return False
if a[ind] > total:... | """
PARTITION PROBLEM
The problem is to identify if a given set of n elements can be divided
into two separate subsets such that sum of elements of both the subsets
is equal.
"""
def check(a, total, ind):
if total == 0:
return True
if ind == -1 or total < 0:
return False
if a[ind] > total:... |
n = int(input())
arr = list(map(str, input().split()))[:n]
ans = ""
for i in range(len(arr)):
ans += chr(int(arr[i], 16))
print(ans) | n = int(input())
arr = list(map(str, input().split()))[:n]
ans = ''
for i in range(len(arr)):
ans += chr(int(arr[i], 16))
print(ans) |
# File: D (Python 2.4)
GAME_DURATION = 300
GAME_COUNTDOWN = 10
GAME_OFF = 0
GAME_ON = 1
COOP_MODE = 0
TEAM_MODE = 1
FREE_MODE = 2
SHIP_DEPOSIT = 0
AV_DEPOSIT = 1
AV_MAX_CARRY = 200
GameTypes = [
'Cooperative',
'Team vs. Team',
'Free For All']
TeamNames = [
'Red',
'Blue',
'Green',
'Orange',
... | game_duration = 300
game_countdown = 10
game_off = 0
game_on = 1
coop_mode = 0
team_mode = 1
free_mode = 2
ship_deposit = 0
av_deposit = 1
av_max_carry = 200
game_types = ['Cooperative', 'Team vs. Team', 'Free For All']
team_names = ['Red', 'Blue', 'Green', 'Orange', 'England', 'France', 'Iraq']
team_colors = [(0.588, ... |
# -*- coding: utf-8 -*-
"""
Created on Wed Dec 19 13:58:37 2018
@author: Nihar
"""
sqr=[]
for i in range(10):
sq=(i+1)*(i+1)
sqr.append(sq)
print(sqr)
cube=[]
for i in range(10):
sq=(i+1)**3
cube.append(sq)
print(cube) | """
Created on Wed Dec 19 13:58:37 2018
@author: Nihar
"""
sqr = []
for i in range(10):
sq = (i + 1) * (i + 1)
sqr.append(sq)
print(sqr)
cube = []
for i in range(10):
sq = (i + 1) ** 3
cube.append(sq)
print(cube) |
"""
PredictGrade.py
================================================
This module contains the runner code for the predict grade package.
"""
# from DataSet import DataSet
# from Models import Models
# from Predictor import Predictor
# from ModelType import ModelType
# from Grade import Grade
# from TextInterface import... | """
PredictGrade.py
================================================
This module contains the runner code for the predict grade package.
"""
data_path = 'gradesComparison.cvs'
num_columns = 2
validation_size = 5
seed = 7
def main(dataLocation: str, numColumns: int, validationSize: int, seed: int) -> None:
"""
... |
"""Coins.
Given an infinite supply of quarters dimes, nickels, and pennies,
wrote code to represent the number of ways to represent n cents.
"""
def calc_num_coins(n):
"""Calc the num of coins."""
def add_coin(total=0):
"""."""
if total > n:
return 0
if total == n:
... | """Coins.
Given an infinite supply of quarters dimes, nickels, and pennies,
wrote code to represent the number of ways to represent n cents.
"""
def calc_num_coins(n):
"""Calc the num of coins."""
def add_coin(total=0):
"""."""
if total > n:
return 0
if total == n:
... |
#!/usr/bin/python
class TaggedAttribute(object):
"""Simple container object to tag values with attributes.
Feel free to initialize any node with a TA instead of its actual
value only and it will then have the desired metadata. For example:
from pylink import TaggedAttribute as TA
tx_power = TA(... | class Taggedattribute(object):
"""Simple container object to tag values with attributes.
Feel free to initialize any node with a TA instead of its actual
value only and it will then have the desired metadata. For example:
from pylink import TaggedAttribute as TA
tx_power = TA(2,
... |
#program to find the position of the second occurrence of a given string in another given string.
def find_string(txt, str1):
return txt.find(str1, txt.find(str1)+1)
print(find_string("The quick brown fox jumps over the lazy dog", "the"))
print(find_string("the quick brown fox jumps over the lazy dog", "the")) | def find_string(txt, str1):
return txt.find(str1, txt.find(str1) + 1)
print(find_string('The quick brown fox jumps over the lazy dog', 'the'))
print(find_string('the quick brown fox jumps over the lazy dog', 'the')) |
lines = []
header = "| "
for multiplikator in range(1,11):
line = "|" + f"{multiplikator}".rjust(3)
header += "|" + f"{multiplikator}".rjust(3)
for multiplikand in range(1,11):
line += "|" + f"{multiplikator * multiplikand}".rjust(3)
lines.append("|---" + "+---"*10 + "|")
lines.append(lin... | lines = []
header = '| '
for multiplikator in range(1, 11):
line = '|' + f'{multiplikator}'.rjust(3)
header += '|' + f'{multiplikator}'.rjust(3)
for multiplikand in range(1, 11):
line += '|' + f'{multiplikator * multiplikand}'.rjust(3)
lines.append('|---' + '+---' * 10 + '|')
lines.append(... |
def foo(a, b):
return a + b
print("%d" % 10, end='')
| def foo(a, b):
return a + b
print('%d' % 10, end='') |
def test_training():
pass
| def test_training():
pass |
"""
[2017-05-18] Challenge #315 [Intermediate] Game of life that has a twist
https://www.reddit.com/r/dailyprogrammer/comments/6bumxo/20170518_challenge_315_intermediate_game_of_life/
So for the first part of the description I am borrowing /u/Elite6809 challenge of a while ago
[link](https://www.reddit.com/r/dailypro... | """
[2017-05-18] Challenge #315 [Intermediate] Game of life that has a twist
https://www.reddit.com/r/dailyprogrammer/comments/6bumxo/20170518_challenge_315_intermediate_game_of_life/
So for the first part of the description I am borrowing /u/Elite6809 challenge of a while ago
[link](https://www.reddit.com/r/dailypro... |
files = "newsequence.txt"
write = "compress.txt"
reverse = "reversed.txt"
seq = dict()
global key_max
#Stores the sequence in a dictionary
def store_seq(key, value):
if key not in seq:
seq.update({key:value})
#breaks each line down into sequences and counts the number of occurence of each sequence
def c... | files = 'newsequence.txt'
write = 'compress.txt'
reverse = 'reversed.txt'
seq = dict()
global key_max
def store_seq(key, value):
if key not in seq:
seq.update({key: value})
def check_exists(data):
data = data.strip()
size = len(data)
start = 0
endpoint = size - 7
dna = open(files, 'r')... |
man = 1
wives = man * 7
madai = wives * 7
cats = madai * 7
kitties = cats * 7
total = man + wives + madai + cats + kitties
print(total)
| man = 1
wives = man * 7
madai = wives * 7
cats = madai * 7
kitties = cats * 7
total = man + wives + madai + cats + kitties
print(total) |
ES_HOST = 'localhost:9200'
ES_INDEX = 'pending-gwascatalog'
ES_DOC_TYPE = 'variant'
API_PREFIX = 'gwascatalog'
API_VERSION = ''
| es_host = 'localhost:9200'
es_index = 'pending-gwascatalog'
es_doc_type = 'variant'
api_prefix = 'gwascatalog'
api_version = '' |
def sumall(upto):
sumupto = 0
for i in range(1, upto + 1):
sumupto = sumupto + i
return sumupto
print("The sum of the values from 1 to 50 inclusive is: ", sumall(50))
print("The sum of the values from 1 to 5 inclusive is: ", sumall(5))
print("The sum of the values from 1 to 10 inclusive is: ", s... | def sumall(upto):
sumupto = 0
for i in range(1, upto + 1):
sumupto = sumupto + i
return sumupto
print('The sum of the values from 1 to 50 inclusive is: ', sumall(50))
print('The sum of the values from 1 to 5 inclusive is: ', sumall(5))
print('The sum of the values from 1 to 10 inclusive is: ', sumal... |
class BatchClassifier:
# Implement methods of this class to use it in main.py
def train(self, filenames, image_classes):
'''
Train the classifier.
:param filenames: the list of filenames to be used for training
:type filenames: [str]
:param image_classes: a mapping of... | class Batchclassifier:
def train(self, filenames, image_classes):
"""
Train the classifier.
:param filenames: the list of filenames to be used for training
:type filenames: [str]
:param image_classes: a mapping of filename to class
:type image_classes: {str: int}
... |
# Suppose an array sorted in ascending order 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.
#
# You may assume no duplicate exists in the array.
#
# Example 1:
#
# Input: [3,4,5,1,2]
# Output: 1
# Example 2:
#
# Input: [4,5,6... | class Solution(object):
def find_min(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
if not nums or len(nums) == 0:
return 0
if len(nums) == 1:
return nums[0]
(begin, end) = (0, len(nums) - 1)
return self.search(nums, be... |
carros = ["audi", "bmw", "ferrari","honda"]
for carro in carros:
if carro == "bmw":
print(carro.upper())
else:
print(carro.title()) | carros = ['audi', 'bmw', 'ferrari', 'honda']
for carro in carros:
if carro == 'bmw':
print(carro.upper())
else:
print(carro.title()) |
setup(
name="earthinversion",
version="1.0.0",
description="Go to earthinversion blog",
long_description=README,
long_description_content_type="text/markdown",
url="https://github.com/earthinversion/",
author="Utpal Kumar",
author_email="office@earthinversion.com",
license="MIT",
... | setup(name='earthinversion', version='1.0.0', description='Go to earthinversion blog', long_description=README, long_description_content_type='text/markdown', url='https://github.com/earthinversion/', author='Utpal Kumar', author_email='office@earthinversion.com', license='MIT', classifiers=['License :: OSI Approved ::... |
API_LOGIN = "/users/sign_in"
API_DEVICE_RELATIONS = "/device_relations"
API_SYSTEMS = "/systems"
API_ZONES = "/zones"
API_EVENTS = "/events"
# 2020-04-18: extracted from https://airzonecloud.com/assets/application-506494af86e686bf472b872d02048b42.js
MODES_CONVERTER = {
"0": {"name": "stop", "description": "Stop"}... | api_login = '/users/sign_in'
api_device_relations = '/device_relations'
api_systems = '/systems'
api_zones = '/zones'
api_events = '/events'
modes_converter = {'0': {'name': 'stop', 'description': 'Stop'}, '1': {'name': 'cool-air', 'description': 'Air cooling'}, '2': {'name': 'heat-radiant', 'description': 'Radiant hea... |
'''
The MADLIBS QUIZ
Use string concatenation (putting strings together)
Ex: I ama traveling to ____ using ___ and its carrying ____ passegers for ____ kilometers
Thank you for watching ________ channel please ________
'''
youtube_channel = ""
print("thank you for watching " + youtube_channel + "Channel ")
prin... | """
The MADLIBS QUIZ
Use string concatenation (putting strings together)
Ex: I ama traveling to ____ using ___ and its carrying ____ passegers for ____ kilometers
Thank you for watching ________ channel please ________
"""
youtube_channel = ''
print('thank you for watching ' + youtube_channel + 'Channel ')
print(... |
# PEMDAS is followed for calculations.
# Exponentiation
print("2^2 = " + str(2 ** 2))
# Division always returns a float
print ("1 / 2 = " + str(1 / 2))
# For integer division, use double forward-slashes
print ("1 // 2 = " + str(1 // 2))
# Modulo is like division except it returns the remainder
print ("10 % 3 = " + ... | print('2^2 = ' + str(2 ** 2))
print('1 / 2 = ' + str(1 / 2))
print('1 // 2 = ' + str(1 // 2))
print('10 % 3 = ' + str(10 % 3)) |
"""
Demonstrates a try...except statement
"""
#Prompts the user to enter a number.
line = input("Enter a number: ")
try:
#Converts the input to an int.
number = int(line)
#Prints the number the user entered.
print(number)
except ValueError:
#This statement will execute if the input could not be
#convert... | """
Demonstrates a try...except statement
"""
line = input('Enter a number: ')
try:
number = int(line)
print(number)
except ValueError:
print('Invalid value')
print('Goodbye!') |
#!/usr/bin/env python3
# Write a program that compares two files of names to find:
# Names unique to file 1
# Names unique to file 2
# Names shared in both files
"""
python3 checklist.py --file1 --file2
"""
| """
python3 checklist.py --file1 --file2
""" |
class Solution:
def fib(self, n: int) -> int:
prev, cur = 0, 1
if n == 0:
return prev
if n == 1:
return cur
for i in range(n):
prev, cur = cur, prev + cur
return prev
| class Solution:
def fib(self, n: int) -> int:
(prev, cur) = (0, 1)
if n == 0:
return prev
if n == 1:
return cur
for i in range(n):
(prev, cur) = (cur, prev + cur)
return prev |
"""
django-faktura
Homepage: https://github.com/ricco386/django-faktura
See the LICENSE file for copying permission.
"""
__version__ = "0.1"
__author__ = "Richard Kellner"
default_app_config = "faktura.apps.FakturaConfig"
| """
django-faktura
Homepage: https://github.com/ricco386/django-faktura
See the LICENSE file for copying permission.
"""
__version__ = '0.1'
__author__ = 'Richard Kellner'
default_app_config = 'faktura.apps.FakturaConfig' |
def test_countries_and_timezones(app_adm):
app_adm.home_page.open_countries()
country_page = app_adm.country_page
countries_list = country_page.get_countries()
sorted_countries = sorted(countries_list)
for country in range(len(countries_list)):
assert countries_list[country] == sorted_countr... | def test_countries_and_timezones(app_adm):
app_adm.home_page.open_countries()
country_page = app_adm.country_page
countries_list = country_page.get_countries()
sorted_countries = sorted(countries_list)
for country in range(len(countries_list)):
assert countries_list[country] == sorted_countr... |
class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
self.node_count = 0
def __str__(self):
curr = self.head
temp = []
while curr is not None:
temp.append(str(curr.... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
self.node_count = 0
def __str__(self):
curr = self.head
temp = []
while curr is not None:
temp.append(str(cur... |
class HowLongToBeatEntry:
def __init__(self,detailId,gameName,description,playableOn,imageUrl,timeLabels,gameplayMain,gameplayMainExtra,gameplayCompletionist):
self.detailId = detailId
self.gameName = gameName
self.description = description
self.playableOn = playableOn
self.i... | class Howlongtobeatentry:
def __init__(self, detailId, gameName, description, playableOn, imageUrl, timeLabels, gameplayMain, gameplayMainExtra, gameplayCompletionist):
self.detailId = detailId
self.gameName = gameName
self.description = description
self.playableOn = playableOn
... |
'''
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
'''
class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify m... | """
You are given an n x n 2D matrix representing an image.
Rotate the image by 90 degrees (clockwise).
Follow up:
Could you do this in-place?
"""
class Solution(object):
def rotate(self, matrix):
"""
:type matrix: List[List[int]]
:rtype: void Do not return anything, modify matrix in-pla... |
class MyDeque:
def __init__(self, max_size):
self.max_size = max_size
self.items = [None] * self.max_size
self.size = 0
self.head = 0
self.tail = 0
def push_back(self, value):
if self.size == self.max_size:
raise IndexError('error')
self.item... | class Mydeque:
def __init__(self, max_size):
self.max_size = max_size
self.items = [None] * self.max_size
self.size = 0
self.head = 0
self.tail = 0
def push_back(self, value):
if self.size == self.max_size:
raise index_error('error')
self.ite... |
"""
Collection of miscellaneous functions and utilities for
admin tasks.
"""
__version__ = '0.1.0dev2'
| """
Collection of miscellaneous functions and utilities for
admin tasks.
"""
__version__ = '0.1.0dev2' |
def findadjacent(y,x):
global horizontal
global vertical
global map
countlocal=0
for richtingy in range(-1,2):
for richtingx in range(-1,2):
if richtingx!=0 or richtingy!=0:
offsetcounter=0
found=0
while found==0:
... | def findadjacent(y, x):
global horizontal
global vertical
global map
countlocal = 0
for richtingy in range(-1, 2):
for richtingx in range(-1, 2):
if richtingx != 0 or richtingy != 0:
offsetcounter = 0
found = 0
while found == 0:
... |
class Solution:
def fourSum(self, nums: List[int], target: int) -> List[List[int]]:
nums.sort()
ans=[]
st=set()
for i in range(0,len(nums)-2):
for j in range(i+1,len(nums)-2):
l=j+1
r=len(nums)-1
while(l<r):
... | class Solution:
def four_sum(self, nums: List[int], target: int) -> List[List[int]]:
nums.sort()
ans = []
st = set()
for i in range(0, len(nums) - 2):
for j in range(i + 1, len(nums) - 2):
l = j + 1
r = len(nums) - 1
while ... |
n = int(input("Please enter a positive integer : "))
print(n)
while n != 1:
n = n // 2 if n % 2 == 0 else 3*n + 1
print(n)
| n = int(input('Please enter a positive integer : '))
print(n)
while n != 1:
n = n // 2 if n % 2 == 0 else 3 * n + 1
print(n) |
def hip(a, b, c):
if b < a > c and a ** 2 == b ** 2 + c ** 2: return True
elif a < b > c and b ** 2 == a ** 2 + c ** 2: return True
elif a < c > b and c ** 2 == a ** 2 + b ** 2: return True
else: return False
e = str(input()).split()
a = int(e[0])
b = int(e[1])
c = int(e[2])
if(a < b + c and b < a + c... | def hip(a, b, c):
if b < a > c and a ** 2 == b ** 2 + c ** 2:
return True
elif a < b > c and b ** 2 == a ** 2 + c ** 2:
return True
elif a < c > b and c ** 2 == a ** 2 + b ** 2:
return True
else:
return False
e = str(input()).split()
a = int(e[0])
b = int(e[1])
c = int(e[... |
class CNF:
def __init__(self, n_variables, clauses, occur_list, comments):
self.n_variables = n_variables
self.clauses = clauses
self.occur_list = occur_list
self.comments = comments
def __str__(self):
return f"""Number of variables: {self.n_variables}
Clauses: {str(self... | class Cnf:
def __init__(self, n_variables, clauses, occur_list, comments):
self.n_variables = n_variables
self.clauses = clauses
self.occur_list = occur_list
self.comments = comments
def __str__(self):
return f'Number of variables: {self.n_variables}\nClauses: {str(self... |
#!/usr/bin/env python3
def left_join(phrases):
return ','.join(phrases).replace("right", "left")
if __name__ == '__main__':
print(left_join(["right", "right", "left", "left", "forward"]))
assert left_join(["right", "right", "left", "left", "forward"]) == "left,left,left,left,forward"
assert left_join(... | def left_join(phrases):
return ','.join(phrases).replace('right', 'left')
if __name__ == '__main__':
print(left_join(['right', 'right', 'left', 'left', 'forward']))
assert left_join(['right', 'right', 'left', 'left', 'forward']) == 'left,left,left,left,forward'
assert left_join(['alright outright', 'squ... |
#!/usr/bin/env python
# -*- coding:utf-8 _*-
"""
@author: Lu Chong
@file: __init__.py
@time: 2021/8/17/11:38
"""
| """
@author: Lu Chong
@file: __init__.py
@time: 2021/8/17/11:38
""" |
DATABASE_NAME = "lzhaoDemoDB"
TABLE_NAME = "MarketPriceGTest"
HT_TTL_HOURS = 24
CT_TTL_DAYS = 7
ONE_GB_IN_BYTES = 1073741824
| database_name = 'lzhaoDemoDB'
table_name = 'MarketPriceGTest'
ht_ttl_hours = 24
ct_ttl_days = 7
one_gb_in_bytes = 1073741824 |
# -*- encoding=utf-8 -*-
"""
# **********************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# [openeuler-jenkins] is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of t... | """
# **********************************************************************************
# Copyright (c) Huawei Technologies Co., Ltd. 2020-2020. All rights reserved.
# [openeuler-jenkins] is licensed under the Mulan PSL v1.
# You can use this software according to the terms and conditions of the Mulan PSL v1.
# You ma... |
class Solution:
def recursion(self,idx,arr,n,maxx,size,k):
if idx == n:
return maxx * size
if (idx,size,maxx) in self.dp: return self.dp[(idx,size,maxx)]
ch1 = self.recursion(idx+1,arr,n,max(maxx,arr[idx]),size+1,k) if size < k else 0
ch2 = self.recursion(idx+1,arr,n,ar... | class Solution:
def recursion(self, idx, arr, n, maxx, size, k):
if idx == n:
return maxx * size
if (idx, size, maxx) in self.dp:
return self.dp[idx, size, maxx]
ch1 = self.recursion(idx + 1, arr, n, max(maxx, arr[idx]), size + 1, k) if size < k else 0
ch2 = ... |
class Action:
def do(self) -> None:
raise NotImplementedError
def undo(self) -> None:
raise NotImplementedError
def redo(self) -> None:
raise NotImplementedError
| class Action:
def do(self) -> None:
raise NotImplementedError
def undo(self) -> None:
raise NotImplementedError
def redo(self) -> None:
raise NotImplementedError |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.