content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#
# PySNMP MIB module HOTWIRE-MSDSL-INTERFACE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HOTWIRE-MSDSL-INTERFACE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:20:19 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, constraints_union, value_size_constraint, value_range_constraint) ... |
"""
Backwards-compatible import location for the model-based activation
workflow.
Formerly this was the default registration workflow of
django-registration, and so was found at
registration.backends.default. As of the current release, however, it
is no longer the default workflow (there is now no default), and has
ac... | """
Backwards-compatible import location for the model-based activation
workflow.
Formerly this was the default registration workflow of
django-registration, and so was found at
registration.backends.default. As of the current release, however, it
is no longer the default workflow (there is now no default), and has
ac... |
sql_user = "lopez"
# for obvious reasons this should be changed
sql_pass = "johny johny telling lies"
sql_db = "lopez"
sql_host = "localhost"
sql_port = 5432
# changing the below line will void the non-existent warranty Lopez came with
# so please don't
postgresql = "postgresql://{0}:{1}@{2}:{3}/{4}".format(
sql_us... | sql_user = 'lopez'
sql_pass = 'johny johny telling lies'
sql_db = 'lopez'
sql_host = 'localhost'
sql_port = 5432
postgresql = 'postgresql://{0}:{1}@{2}:{3}/{4}'.format(sql_user, sql_pass, sql_host, sql_port, sql_db) |
DEPS = [
'chromium',
'file',
'gsutil',
'recipe_engine/json',
'math_utils',
'recipe_engine/path',
'recipe_engine/platform',
'recipe_engine/properties',
'recipe_engine/python',
'recipe_engine/raw_io',
'recipe_engine/step',
]
| deps = ['chromium', 'file', 'gsutil', 'recipe_engine/json', 'math_utils', 'recipe_engine/path', 'recipe_engine/platform', 'recipe_engine/properties', 'recipe_engine/python', 'recipe_engine/raw_io', 'recipe_engine/step'] |
class Solution:
def XXX(self, root: TreeNode) -> List[List[int]]:
ans, d = [], [root] if root else []
while d:
ans.append([t.val for t in d])
d = [r for t in d for r in (t.left, t.right) if r]
return ans
| class Solution:
def xxx(self, root: TreeNode) -> List[List[int]]:
(ans, d) = ([], [root] if root else [])
while d:
ans.append([t.val for t in d])
d = [r for t in d for r in (t.left, t.right) if r]
return ans |
# Range -> range instance that holds all nums counting by one between 0 and first input
# List -> lists numbers from the inputted tuple
numberedContestants = range(30)
print(list(numberedContestants))
for c in list(numberedContestants):
print(f"Contestant {c} is here.")
lucky_winners = range(7, 30, 5)
print(lis... | numbered_contestants = range(30)
print(list(numberedContestants))
for c in list(numberedContestants):
print(f'Contestant {c} is here.')
lucky_winners = range(7, 30, 5)
print(list(lucky_winners)) |
class Thing:
def __init__(self, x, y, name):
self.x = x
self.y = y
self.name = name
t = Thing(12, 34, "dave")
print(vars(t)) # {'x': 12, 'y': 34, 'name': 'dave'}
| class Thing:
def __init__(self, x, y, name):
self.x = x
self.y = y
self.name = name
t = thing(12, 34, 'dave')
print(vars(t)) |
"""
module docstring for pylint
"""
print("Hello")
print("new line to test")
| """
module docstring for pylint
"""
print('Hello')
print('new line to test') |
#!/usr/bin/python
class FilterModule(object):
def filters(self):
return {
'amend_list_items': self.amend_list_items
}
def amend_list_items(self, orig_list, prefix="", postfix=""):
return list(map(lambda listelement: prefix +
str(listelement) + postfix... | class Filtermodule(object):
def filters(self):
return {'amend_list_items': self.amend_list_items}
def amend_list_items(self, orig_list, prefix='', postfix=''):
return list(map(lambda listelement: prefix + str(listelement) + postfix, orig_list)) |
"""Loads config from several locations."""
def test_multifolder(multifolder_config):
"""Check if files from 2nd folder had been loaded."""
assert 'key_config2' in multifolder_config.registry['config']
| """Loads config from several locations."""
def test_multifolder(multifolder_config):
"""Check if files from 2nd folder had been loaded."""
assert 'key_config2' in multifolder_config.registry['config'] |
"""a Django app defining markdown processing filters and tags for templates
USAGE
------------
Include this app into your installed apps. Then you can use
code like the one below in your templates
{% load markdown_tags %}
AN EXAMPLE FOR THE USE OF THE MARKDOWNF FILTER<br/>
{{ a_safe_variable_containi... | """a Django app defining markdown processing filters and tags for templates
USAGE
------------
Include this app into your installed apps. Then you can use
code like the one below in your templates
{% load markdown_tags %}
AN EXAMPLE FOR THE USE OF THE MARKDOWNF FILTER<br/>
{{ a_safe_variable_containi... |
#!/usr/bin/env python
def calcPi(limit): # Generator function
"""
Prints out the digits of PI
until it reaches the given limit
"""
q, r, t, k, n, l = 1, 0, 1, 1, 3, 3
decimal = limit
counter = 0
while counter != decimal + 1:
if 4 * q + r - t < n * t:
... | def calc_pi(limit):
"""
Prints out the digits of PI
until it reaches the given limit
"""
(q, r, t, k, n, l) = (1, 0, 1, 1, 3, 3)
decimal = limit
counter = 0
while counter != decimal + 1:
if 4 * q + r - t < n * t:
yield n
if counter == 0:
yi... |
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# Function to print the list
def print_list(self):
node = self
output = ''
while node:
output += str(node.val)
output += " "
node = node.next
prin... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
def print_list(self):
node = self
output = ''
while node:
output += str(node.val)
output += ' '
node = node.next
print(output)
def reverse_itera... |
class EmptyFactor:
"""
Empty factors, such as safeZoneX which do not get multiplied by anything
"""
def __str__(self):
return type(self).__name__
def __repr__(self):
return str(self)
def _operation_skip_if(self, skip, other, op):
if other == skip:
return se... | class Emptyfactor:
"""
Empty factors, such as safeZoneX which do not get multiplied by anything
"""
def __str__(self):
return type(self).__name__
def __repr__(self):
return str(self)
def _operation_skip_if(self, skip, other, op):
if other == skip:
return se... |
'''
prompt = "\nTell me something, and i will repeat it back to you."
prompt += "\n'quit' to end the program."
prompt += "\n"
message = ""
active = True
while active:
message = input(prompt)
if message == 'quit':
active = false
else:
print(message)
'''
current_number = 0
while current_n... | """
prompt = "
Tell me something, and i will repeat it back to you."
prompt += "
'quit' to end the program."
prompt += "
"
message = ""
active = True
while active:
message = input(prompt)
if message == 'quit':
active = false
else:
print(message)
"""
current_number = 0
while current_number... |
# -*- coding: utf-8 -*-
'''
Cluster Helpers (functions)
Functions that help with clusters.
'''
# This file can be found in our projectfolder in /softpro/ss16/swp-ss16-srk/autosarkasmus/autosarkasmus/baseline/rsrc
CLUSTER_FILE = '../rsrc/lda-topics-10-50.v2'
# Get the number of clusters
def load_number_of_clusters()... | """
Cluster Helpers (functions)
Functions that help with clusters.
"""
cluster_file = '../rsrc/lda-topics-10-50.v2'
def load_number_of_clusters():
"""Load the number of clusters from the file and return it"""
res = []
maximum = 0
with open(CLUSTER_FILE, 'r', encoding='latin-1') as fop:
for lin... |
# Program to calculate Factorial of a Number.
N = int(input("N = "))
def factorial(N):
f = 1
for i in range(1,N+1):
f *= i
print(f)
factorial(N)
| n = int(input('N = '))
def factorial(N):
f = 1
for i in range(1, N + 1):
f *= i
print(f)
factorial(N) |
'''
Author : MiKueen
Level : Easy
Problem Statement : Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
Given linked list -- head = [4,5,1,9], which looks like following:
Example 1:
Input: head = [4,5,1,9], node = 5
Output: [4,1,9... | """
Author : MiKueen
Level : Easy
Problem Statement : Delete Node in a Linked List
Write a function to delete a node (except the tail) in a singly linked list, given only access to that node.
Given linked list -- head = [4,5,1,9], which looks like following:
Example 1:
Input: head = [4,5,1,9], node = 5
Output: [4,1,9... |
class number:
"""
This product includes software developed by L. Pham-Trong and this guy rocks.
"""
def __init__(self, value: str, base):
alphabet = [str(i) for i in range(10)] + [chr(i).upper() for i in range(97, 123)]
self.val = [c for c in value]
self.alph = alphabet[:base]
... | class Number:
"""
This product includes software developed by L. Pham-Trong and this guy rocks.
"""
def __init__(self, value: str, base):
alphabet = [str(i) for i in range(10)] + [chr(i).upper() for i in range(97, 123)]
self.val = [c for c in value]
self.alph = alphabet[:base]
... |
mask=chosenMask
print('mask dimensions: {}'. format(mask.shape))
print('number of voxels in mask: {}'.format(np.sum(mask)))
# Compile preprocessed data and corresponding indices
metas = []
for run in range(1, 7):
print(run, end='--')
# retrieve from the dictionary which phase it is, assign the session
ph... | mask = chosenMask
print('mask dimensions: {}'.format(mask.shape))
print('number of voxels in mask: {}'.format(np.sum(mask)))
metas = []
for run in range(1, 7):
print(run, end='--')
phase = phasedict[run]
ses = 1
this4d = funcdata.format(ses=ses, run=run, phase=phase, sub=subject)
thismeta = pd.read_... |
def fibonnacci(nth: int) -> int:
if nth <= 1:
return 1
else:
return fibonnacci(nth - 1) + fibonnacci(nth - 2)
| def fibonnacci(nth: int) -> int:
if nth <= 1:
return 1
else:
return fibonnacci(nth - 1) + fibonnacci(nth - 2) |
def parse_review(original_cleaned_value, soup, url, post):
if "review" in original_cleaned_value:
h_review = soup.select(".h-review")
if h_review:
h_review = h_review[0]
name = h_review.select(".p-name")[0].text
if not name:
name = s... | def parse_review(original_cleaned_value, soup, url, post):
if 'review' in original_cleaned_value:
h_review = soup.select('.h-review')
if h_review:
h_review = h_review[0]
name = h_review.select('.p-name')[0].text
if not name:
name = soup.find('title... |
"""Helper function and aspect to collect first-party packages.
These are used in node rules to link the node_modules before launching a program.
This supports path re-mapping, to support short module names.
See pathMapping doc: https://github.com/Microsoft/TypeScript/issues/5039
This reads the module_root and module_... | """Helper function and aspect to collect first-party packages.
These are used in node rules to link the node_modules before launching a program.
This supports path re-mapping, to support short module names.
See pathMapping doc: https://github.com/Microsoft/TypeScript/issues/5039
This reads the module_root and module_... |
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 8 19:15:34 2016
@author: ericgrimson
"""
US = ['MIT', 'Harvard', 'Yale']
UK = ['Cambridge', 'Oxford']
Unis = [US, UK]
Unisnew = [['MIT', 'Harvard', 'Yale'], ['US', 'UK']]
# US.append('Princeton') | """
Created on Wed Jun 8 19:15:34 2016
@author: ericgrimson
"""
us = ['MIT', 'Harvard', 'Yale']
uk = ['Cambridge', 'Oxford']
unis = [US, UK]
unisnew = [['MIT', 'Harvard', 'Yale'], ['US', 'UK']] |
class Parkhaus:
"""
Class used to represent information about a car park
Attributes
----------
entry : str
how and/or where to enter the car park
entry : str
how and/or where to enter the car park
openingHours : str
opening hours of the car park
hightLimit : st... | class Parkhaus:
"""
Class used to represent information about a car park
Attributes
----------
entry : str
how and/or where to enter the car park
entry : str
how and/or where to enter the car park
openingHours : str
opening hours of the car park
hightLimit : str
... |
###################################
# File Name : enumerate.py
###################################
#!/usr/bin/python3
ALPHABET_LIST = ["a", "b", "c", "d", "e", "f"]
def get_index_basic_method():
i = 0
for ch in ALPHABET_LIST:
print ("%d : %s" % (i, ch))
i += 1
def get_index_enumerate_method()... | alphabet_list = ['a', 'b', 'c', 'd', 'e', 'f']
def get_index_basic_method():
i = 0
for ch in ALPHABET_LIST:
print('%d : %s' % (i, ch))
i += 1
def get_index_enumerate_method():
for (i, ch) in enumerate(ALPHABET_LIST):
print('%d : %s' % (i, ch))
if __name__ == '__main__':
print('... |
def merge(dbag, data):
""" Simply overwrite the existsing bag as, the whole configuration is sent every time """
if "rules" not in data:
return dbag
dbag['config'] = data['rules']
return dbag
| def merge(dbag, data):
""" Simply overwrite the existsing bag as, the whole configuration is sent every time """
if 'rules' not in data:
return dbag
dbag['config'] = data['rules']
return dbag |
# -*- coding: utf-8 -*-
# @Time : 2021/11/1 9:19
# @Software : PyCharm
# @License : GNU General Public License v3.0
# @Author : xxx
__all__ = ["tools", "skflow", "sci_formula", "gp", "cli", "backend", "source"]
| __all__ = ['tools', 'skflow', 'sci_formula', 'gp', 'cli', 'backend', 'source'] |
while True:
n = int(input())
if n == 0: break
l = 1
o = '+'
while l <= n:
v = l
c = 1
while c <= n:
if c != n: print('{:>3}'.format(v), end=' ')
else:
print('{:>3}'.format(v))
o = '-'
if v == 1: o = '+'
... | while True:
n = int(input())
if n == 0:
break
l = 1
o = '+'
while l <= n:
v = l
c = 1
while c <= n:
if c != n:
print('{:>3}'.format(v), end=' ')
else:
print('{:>3}'.format(v))
o = '-'
... |
def sort_012(input_list):
"""
Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal.
Args:
input_list(list): List to be sorted
"""
pivot = 1
i, j, k = 0, 0, len(input_list) - 1
# print("Start ", input_list)
while j <= k:
if input_list[j... | def sort_012(input_list):
"""
Given an input array consisting on only 0, 1, and 2, sort the array in a single traversal.
Args:
input_list(list): List to be sorted
"""
pivot = 1
(i, j, k) = (0, 0, len(input_list) - 1)
while j <= k:
if input_list[j] < pivot:
if i !=... |
"""
The featurecollection module provides a class for GeoJSON responses.
"""
class FeatureCollection(object):
def __init__(self):
self.features = []
self.total_features = 0
self.offset = 0
def add_features(self, features):
self.features.extend(features)
self.total_feat... | """
The featurecollection module provides a class for GeoJSON responses.
"""
class Featurecollection(object):
def __init__(self):
self.features = []
self.total_features = 0
self.offset = 0
def add_features(self, features):
self.features.extend(features)
self.total_feat... |
# Time: O(n)
# Space: O(n)
class Solution(object):
def shortestDistanceColor(self, colors, queries):
"""
:type colors: List[int]
:type queries: List[List[int]]
:rtype: List[int]
"""
dp = [[-1 for _ in range(len(colors))] for _ in range(3)]
dp[colors[0]-1][0]... | class Solution(object):
def shortest_distance_color(self, colors, queries):
"""
:type colors: List[int]
:type queries: List[List[int]]
:rtype: List[int]
"""
dp = [[-1 for _ in range(len(colors))] for _ in range(3)]
dp[colors[0] - 1][0] = 0
for i in ra... |
#!/usr/bin/env python3
def trimmest(string):
stack = []
trimmed = ''
for i, c in enumerate(string):
if(c != ' '):
first = i
break
for i, c in enumerate(string[first:]):
stack.append(c)
stk_len = len(stack)
a = stk_len - 1
for i in range(stk_len):
... | def trimmest(string):
stack = []
trimmed = ''
for (i, c) in enumerate(string):
if c != ' ':
first = i
break
for (i, c) in enumerate(string[first:]):
stack.append(c)
stk_len = len(stack)
a = stk_len - 1
for i in range(stk_len):
if stack[a] == ' ... |
host = '0.0.0.0'
port = 8080
debug = True
CORS_HEADERS = 'Content-Type'
| host = '0.0.0.0'
port = 8080
debug = True
cors_headers = 'Content-Type' |
# Python3
def spiralNumbers(n):
matrix = [[0] * n for i in range(n)]
dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)]
r, c = 0, 0
i = 0
dr, dc = dirs[i]
for num in range(1, n * n + 1):
matrix[r][c] = num
newR, newC = r + dr, c + dc
if (0 <= newR < n) and (0 <= newC < n) and (ma... | def spiral_numbers(n):
matrix = [[0] * n for i in range(n)]
dirs = [(0, 1), (1, 0), (0, -1), (-1, 0)]
(r, c) = (0, 0)
i = 0
(dr, dc) = dirs[i]
for num in range(1, n * n + 1):
matrix[r][c] = num
(new_r, new_c) = (r + dr, c + dc)
if 0 <= newR < n and 0 <= newC < n and (matr... |
# Copyright (c) 2013 Intel Corporation. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets' : [
{
'target_name': 'gio',
'type': 'none',
'variables': {
'glib_packages': 'glib-2.0 gio-unix-2.0',
},
... | {'targets': [{'target_name': 'gio', 'type': 'none', 'variables': {'glib_packages': 'glib-2.0 gio-unix-2.0'}, 'direct_dependent_settings': {'cflags': ['<!@(pkg-config --cflags <(glib_packages))']}, 'link_settings': {'ldflags': ['<!@(pkg-config --libs-only-L --libs-only-other <(glib_packages))'], 'libraries': ['<!@(pkg-c... |
class BaseActiveLearningComponent:
def fit(self, X, y):
"""
Fits the estimator and returns a reference to itself.
"""
return self
def partial_fit(self, X, y):
"""
Updates the estimator given the data X, y.
Returns a reference to itself.
"""
... | class Baseactivelearningcomponent:
def fit(self, X, y):
"""
Fits the estimator and returns a reference to itself.
"""
return self
def partial_fit(self, X, y):
"""
Updates the estimator given the data X, y.
Returns a reference to itself.
"""
... |
nums = [float(i) for i in input().split(" ")]
def rounding(numbers):
round_nums = [round(i) for i in numbers]
return round_nums
print(rounding(nums)) | nums = [float(i) for i in input().split(' ')]
def rounding(numbers):
round_nums = [round(i) for i in numbers]
return round_nums
print(rounding(nums)) |
def lipschitz_opt_lb(model, initial_max=None, num_iter=100):
""" Compute lower bound of the Lipschitz constant with optimization on gradient norm
INPUTS:
* `initial_max`: initial seed for the SGD
* `num_iter`: number of SGD iterations
If initial_max is not provided, the model must have an in... | def lipschitz_opt_lb(model, initial_max=None, num_iter=100):
""" Compute lower bound of the Lipschitz constant with optimization on gradient norm
INPUTS:
* `initial_max`: initial seed for the SGD
* `num_iter`: number of SGD iterations
If initial_max is not provided, the model must have an in... |
# cup1 = 0
# cup2 = 1
# cup3 = 0
# cup1 = cup1 + 1
# cup2 = cup1 - 1
# cup3 =cup1
# cup1= cup1 * 0
# cup2 = cup3
# cup3 = cup1
# cup1 = cup2 % 1
# cup3 = cup2
# cup2 = cup3 - cup3
#
# word1 = 'ox'
# word2 = 'owl'
# word3 = 'cow'
# word4 = 'sheep'
# word5 = 'files'
# word6 = 'trots'
# word7 = 'runs'
# word8 = 'blue'
# ... | counter = 10
while counter > 0:
print('Counter is', counter)
counter = counter + 1
print('Liftoff') |
class Solution:
def reachableNodes(self, edges: List[List[int]], maxMoves: int, n: int) -> int:
graph = [[] for _ in range(n)]
minHeap = [(0, 0)] # (d, u)
dist = [maxMoves + 1] * n
dist[0] = 0
for u, v, cnt in edges:
graph[u].append((v, cnt))
graph[v].append((u, cnt))
while minH... | class Solution:
def reachable_nodes(self, edges: List[List[int]], maxMoves: int, n: int) -> int:
graph = [[] for _ in range(n)]
min_heap = [(0, 0)]
dist = [maxMoves + 1] * n
dist[0] = 0
for (u, v, cnt) in edges:
graph[u].append((v, cnt))
graph[v].appe... |
def middleware_setting(django_version, middleware_list):
if django_version < (1, 10):
return {'MIDDLEWARE_CLASSES': middleware_list}
else:
return {'MIDDLEWARE': middleware_list, 'MIDDLEWARE_CLASSES': None}
| def middleware_setting(django_version, middleware_list):
if django_version < (1, 10):
return {'MIDDLEWARE_CLASSES': middleware_list}
else:
return {'MIDDLEWARE': middleware_list, 'MIDDLEWARE_CLASSES': None} |
class Node:
def __init__(self, value=None):
self.value = value
self.next = None
class Stack():
def __init__(self):
self.top = None
def push(self, item):
new_node = Node(item)
new_node.next = self.top
self.top = new_node
def pop(self):
current = sel... | class Node:
def __init__(self, value=None):
self.value = value
self.next = None
class Stack:
def __init__(self):
self.top = None
def push(self, item):
new_node = node(item)
new_node.next = self.top
self.top = new_node
def pop(self):
current = ... |
class Game(object):
def __init__(self, game_pairs=0):
self.throws = []
self.game_pairs = game_pairs
def __call__(self, game_pairs=0):
self.game_pairs = game_pairs
def add_throw(self, throw):
self.throws.append(throw)
def check_value_range(self, value):
if value... | class Game(object):
def __init__(self, game_pairs=0):
self.throws = []
self.game_pairs = game_pairs
def __call__(self, game_pairs=0):
self.game_pairs = game_pairs
def add_throw(self, throw):
self.throws.append(throw)
def check_value_range(self, value):
if valu... |
class LinearArray(BaseArray, IDisposable):
""" An object that represents an Array created linearly within the Revit project. """
@staticmethod
def ArrayElementsWithoutAssociation(
aDoc, dBView, ids, count, translationToAnchorMember, anchorMember
):
""" ArrayElementsWithoutAssocia... | class Lineararray(BaseArray, IDisposable):
""" An object that represents an Array created linearly within the Revit project. """
@staticmethod
def array_elements_without_association(aDoc, dBView, ids, count, translationToAnchorMember, anchorMember):
""" ArrayElementsWithoutAssociation(aDoc: Documen... |
# -*- coding: utf-8 -*-
"""
Cuttle, the simple, extendable ORM.
:license: MIT, see LICENSE for details.
"""
__version__ = '0.9.0.dev'
| """
Cuttle, the simple, extendable ORM.
:license: MIT, see LICENSE for details.
"""
__version__ = '0.9.0.dev' |
#
# PySNMP MIB module CPQRECOV-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CPQRECOV-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:12:06 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019,... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_size_constraint, value_range_constraint, constraints_intersection) ... |
#Calc sum of digits of a given no.
print("enter any no.")
n=int(input())
ssum=0
while(n!=0):
x=n%10
n=n//10
ssum+=x
print(ssum)
| print('enter any no.')
n = int(input())
ssum = 0
while n != 0:
x = n % 10
n = n // 10
ssum += x
print(ssum) |
boltzmann = 1.380649e-23
ideal_gas = 8.31446261815324
mole = 6.02214076e23
coulomb = 8.9875517923e9
e0 = 8.8541878128e-12
| boltzmann = 1.380649e-23
ideal_gas = 8.31446261815324
mole = 6.02214076e+23
coulomb = 8987551792.3
e0 = 8.8541878128e-12 |
# /$$
# | $$
# /$$$$$$ /$$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$
# /$$__ $$|____ /$$/ /$$__ $$ /$$__ $$ |____ $$ /$$__ $$
# | $$$$$$$$ /$$$$/ | $$ \__/| $$$$$$$$ /$$$$$$$| $$ | $$
... | __title__ = 'ezread'
__description__ = 'ezread provides a ridiculously simple way to fetch items within the JSON list.'
__url__ = 'https://github.com/csurfer/ezread'
__version__ = '0.0.1'
__author__ = 'Vishwas B Sharma'
__author_email__ = 'sharma.vishwas88@gmail.com'
__license__ = 'MIT'
__copyright__ = 'Copyright 2020 ... |
class Current:
def __init__(self):
self._voltage = 100000
@property
def voltage(self):
"""" Get the current voltage"""
return self._voltage
class Pizza(object):
def __init__(self):
self.toppings = []
def __call__(self, topping):
# when using '@instance_of_... | class Current:
def __init__(self):
self._voltage = 100000
@property
def voltage(self):
"""" Get the current voltage"""
return self._voltage
class Pizza(object):
def __init__(self):
self.toppings = []
def __call__(self, topping):
self.toppings.append(toppi... |
"""
This file define basic configuration for RabbitMQ and Protobuf communication
for the simulation nodes and the orchestrator nodes.
"""
base_config = {
"name": "",
"queues": {
"obnl.simulation.node.": "on_simulation",
"obnl.local.node.": "on_local",
"obnl.data.node.": "on_data",
}... | """
This file define basic configuration for RabbitMQ and Protobuf communication
for the simulation nodes and the orchestrator nodes.
"""
base_config = {'name': '', 'queues': {'obnl.simulation.node.': 'on_simulation', 'obnl.local.node.': 'on_local', 'obnl.data.node.': 'on_data'}, 'exchanges': {'obnl.local.node.': {'bin... |
# Data Types
# Strings
print("Hello"[0])
# Integer
print(123 + 345)
# Float
3.14159
# Boolean
True
False | print('Hello'[0])
print(123 + 345)
3.14159
True
False |
"""
SleekXMPP: The Sleek XMPP Library
Copyright (C) 2010 Nathanael C. Fritz
This file is part of SleekXMPP.
See the file LICENSE for copying permission.
"""
__all__ = ['xep_0004', 'xep_0009', 'xep_0012', 'xep_0030', 'xep_0033',
'xep_0045', 'xep_0050', 'xep_0060', 'xep_0066', 'xep_0082',
... | """
SleekXMPP: The Sleek XMPP Library
Copyright (C) 2010 Nathanael C. Fritz
This file is part of SleekXMPP.
See the file LICENSE for copying permission.
"""
__all__ = ['xep_0004', 'xep_0009', 'xep_0012', 'xep_0030', 'xep_0033', 'xep_0045', 'xep_0050', 'xep_0060', 'xep_0066', 'xep_0082', 'xep_0080', 'xe... |
# Print out numbers from 1 to 100 (including 100).
# But, instead of printing multiples of 3, print "Fizz"
# Instead of printing multiples of 5, print "Buzz"
# Instead of printing multiples of both 3 and 5, print "FizzBuzz".
for number in range(1, 101):
output = ''
if number % 3 == 0:
output += 'Fizz'
... | for number in range(1, 101):
output = ''
if number % 3 == 0:
output += 'Fizz'
if number % 5 == 0:
output += 'Buzz'
if len(output):
print(output)
continue
print(number) |
class MinimalRegionSet():
def __init__(self):
self.local_set = []
def add(self, region):
local_set = self.local_set
add = True
for region_in_set in local_set:
if region_in_set.contains(region):
add = False
break
if region.... | class Minimalregionset:
def __init__(self):
self.local_set = []
def add(self, region):
local_set = self.local_set
add = True
for region_in_set in local_set:
if region_in_set.contains(region):
add = False
break
if region.co... |
# Small alphabet e using Function
def for_e():
""" *'s printed in the Shape of small e """
for row in range(5):
for col in range(5):
if col ==0 and row %4 !=0 or row %4 ==0 and col %4 !=0 or row ==1 or row ==3 and col ==4:
print('*',end=' ')
else:
... | def for_e():
""" *'s printed in the Shape of small e """
for row in range(5):
for col in range(5):
if col == 0 and row % 4 != 0 or (row % 4 == 0 and col % 4 != 0) or row == 1 or (row == 3 and col == 4):
print('*', end=' ')
else:
print(' ', end=' ')... |
class Client:
"""
Class that creates new instances of client
"""
u_list = []
def __init__(self, fn, ln, email, password):
self.fn = fn
self.ln = ln
self.email = email
self.password = password
def save_client(self):
"""
Function to save clien... | class Client:
"""
Class that creates new instances of client
"""
u_list = []
def __init__(self, fn, ln, email, password):
self.fn = fn
self.ln = ln
self.email = email
self.password = password
def save_client(self):
"""
Function to save client to... |
def Mona_lisa(thoughts, eyes, eye, tongue):
return f"""
{thoughts}
{thoughts}
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>''''''<!!!!!!!!!!!!!!!!!!!!!!... | def mona_lisa(thoughts, eyes, eye, tongue):
return f'\n {thoughts}\n {thoughts}\n\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!>\'\'\'\'\'\'<!!!!!!!!!!... |
class SettingsManager:
def __init__(self, client_class):
self._client = client_class
self.access_token = ''
def get_templates(self):
# https://api.dida365.com/api/v2/templates
pass
def get_user_settings(self):
# https://api.dida365.com/api/v2/user/preferences/setti... | class Settingsmanager:
def __init__(self, client_class):
self._client = client_class
self.access_token = ''
def get_templates(self):
pass
def get_user_settings(self):
pass |
__author__ = 'Chetan'
class MyInt(type):
def __call__(cls, *args, **kwds):
print("***** Here's My int *****", args)
print("Now do whatever you want with these objects...")
return type.__call__(cls, *args, **kwds)
class int(metaclass=MyInt):
def __init__(self, x, ... | __author__ = 'Chetan'
class Myint(type):
def __call__(cls, *args, **kwds):
print("***** Here's My int *****", args)
print('Now do whatever you want with these objects...')
return type.__call__(cls, *args, **kwds)
class Int(metaclass=MyInt):
def __init__(self, x, y):
self.x = ... |
class Coordinate(object):
def __init__(self, prefix, value):
self.prefix = prefix
self.value = value
def __str__(self):
if self.prefix:
if self.value:
return self.prefix + str(self.value)
else:
return self.prefix
else:... | class Coordinate(object):
def __init__(self, prefix, value):
self.prefix = prefix
self.value = value
def __str__(self):
if self.prefix:
if self.value:
return self.prefix + str(self.value)
else:
return self.prefix
elif self... |
"""
This file assembles a toolchain for Linux using the Clang Compiler and musl.
It currently makes use of musl and not glibc because the pre-compiled libraries from the latter
have absolute paths baked in and this makes linking difficult. The pre-compiled musl library
does not have this restriction and is much easier... | """
This file assembles a toolchain for Linux using the Clang Compiler and musl.
It currently makes use of musl and not glibc because the pre-compiled libraries from the latter
have absolute paths baked in and this makes linking difficult. The pre-compiled musl library
does not have this restriction and is much easier... |
class Solution(object):
def dfs(self, start, end, record):
if start >= end:
return 0
if start + 1 == end:
return start
if record[start][end] is None:
pays = []
for i in range(start, end + 1):
prevPay = self.dfs(start, i - 1, r... | class Solution(object):
def dfs(self, start, end, record):
if start >= end:
return 0
if start + 1 == end:
return start
if record[start][end] is None:
pays = []
for i in range(start, end + 1):
prev_pay = self.dfs(start, i - 1, r... |
class ExampleMod:
def __init__(self):
self.a = 6
self.b = 7
self.c = 8
def add(self):
return self.a + self.b + self.c
def multiply(self):
return self.a * self.b * self.c
| class Examplemod:
def __init__(self):
self.a = 6
self.b = 7
self.c = 8
def add(self):
return self.a + self.b + self.c
def multiply(self):
return self.a * self.b * self.c |
"""Constants for Life360 integration."""
DOMAIN = 'life360'
CONF_AUTHORIZATION = 'authorization'
CONF_CIRCLES = 'circles'
CONF_DRIVING_SPEED = 'driving_speed'
CONF_ERROR_THRESHOLD = 'error_threshold'
CONF_MAX_GPS_ACCURACY = 'max_gps_accuracy'
CONF_MAX_UPDATE_WAIT = 'max_update_wait'
CONF_MEMBERS = 'members'
CONF_SHOW_... | """Constants for Life360 integration."""
domain = 'life360'
conf_authorization = 'authorization'
conf_circles = 'circles'
conf_driving_speed = 'driving_speed'
conf_error_threshold = 'error_threshold'
conf_max_gps_accuracy = 'max_gps_accuracy'
conf_max_update_wait = 'max_update_wait'
conf_members = 'members'
conf_show_a... |
def inference_decoding_layer(embeddings, start_token, end_token, dec_cell, initial_state, output_layer,
max_summary_length, batch_size):
'''Create the inference logits'''
start_tokens = tf.tile(tf.constant([start_token], dtype=tf.int32), [batch_size], name='start_tokens')
... | def inference_decoding_layer(embeddings, start_token, end_token, dec_cell, initial_state, output_layer, max_summary_length, batch_size):
"""Create the inference logits"""
start_tokens = tf.tile(tf.constant([start_token], dtype=tf.int32), [batch_size], name='start_tokens')
inference_helper = tf.contrib.seq2s... |
"""
:mod: `reports` -- Report Wrapper
=================================
.. module:: reports
:synopsis: Report building tools
:platform: OpenSuse 15.2 on WSL2 (Windows 10)
.. moduleauthor:: Bruno Lima <blcardoso@cos.ufrj.br>
"""
| """
:mod: `reports` -- Report Wrapper
=================================
.. module:: reports
:synopsis: Report building tools
:platform: OpenSuse 15.2 on WSL2 (Windows 10)
.. moduleauthor:: Bruno Lima <blcardoso@cos.ufrj.br>
""" |
#!/usr/bin/python3
#------------------------------------------------------------------------------
class Solution:
def fourSum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[List[int]]
"""
# Each key in pairs will be the sum of the pair... | class Solution:
def four_sum(self, nums, target):
"""
:type nums: List[int]
:type target: int
:rtype: List[List[int]]
"""
pairs = {}
for i in range(len(nums)):
for j in range(i + 1, len(nums)):
pair_sum = nums[i] + nums[j]
... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# pylint: disable-msg=C0103, C0111
def application(env, start_response):
start_response('200 OK', [('Content-Type','text/html')])
rvalue = b"Hello World\n"
rvalue += b"Test\n"
rvalue += b"Apr/14/2020\n"
return [rvalue]
| def application(env, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
rvalue = b'Hello World\n'
rvalue += b'Test\n'
rvalue += b'Apr/14/2020\n'
return [rvalue] |
"""
Module: 'onewire' on esp32 1.11.0
"""
# MCU: (sysname='esp32', nodename='esp32', release='1.11.0', version='v2.11.0.1 on 2019-07-26', machine='ESP32 module with ESP32')
# Stubber: 1.2.0
class OneWire:
''
MATCH_ROM = 85
SEARCH_ROM = 240
SKIP_ROM = 204
def _search_rom():
pass
def crc... | """
Module: 'onewire' on esp32 1.11.0
"""
class Onewire:
""""""
match_rom = 85
search_rom = 240
skip_rom = 204
def _search_rom():
pass
def crc8():
pass
def readbit():
pass
def readbyte():
pass
def readinto():
pass
def reset():
... |
p=31
q=37
r=43
n=p*q*r
print("n = p * q * r = " + str(n) + "\n")
phi=(p-1)*(q-1)*(r-1)
print("Euler's function (totient) [phi(n)]: " + str(phi) + "\n")
def gcd(a, b):
while b != 0:
c = a % b
a = b
b = c
return a
def egcd(a, b):
if a == 0:
return b, 0, 1
else:
g, y... | p = 31
q = 37
r = 43
n = p * q * r
print('n = p * q * r = ' + str(n) + '\n')
phi = (p - 1) * (q - 1) * (r - 1)
print("Euler's function (totient) [phi(n)]: " + str(phi) + '\n')
def gcd(a, b):
while b != 0:
c = a % b
a = b
b = c
return a
def egcd(a, b):
if a == 0:
return (b, ... |
class School:
def __init__(self):
self.grade_school = {}
def add_student(self, name, grade):
grade = str(grade)
value = self.grade_school.get(grade)
if value:
value.append(name)
self.grade_school.update({grade: value})
return
self.grad... | class School:
def __init__(self):
self.grade_school = {}
def add_student(self, name, grade):
grade = str(grade)
value = self.grade_school.get(grade)
if value:
value.append(name)
self.grade_school.update({grade: value})
return
self.gra... |
L = [['3', 'Avaya_control_A', 'active'], ['4', 'Avaya_control_B', 'active'], ['5', 'Avaya_voice', 'active'], ['6', 'Avaya_phone', 'active'], ['60', 'MGMT_ALTF', 'active', 'Gi3/0/8,', 'Gi4/0/8'], ['78', 'UIB', 'active'], ['100', 'Video_recorder', 'active'], ['128', 'Srv_ALTF', 'active'], ['129', 'Srv_ALTF1', 'active'], ... | l = [['3', 'Avaya_control_A', 'active'], ['4', 'Avaya_control_B', 'active'], ['5', 'Avaya_voice', 'active'], ['6', 'Avaya_phone', 'active'], ['60', 'MGMT_ALTF', 'active', 'Gi3/0/8,', 'Gi4/0/8'], ['78', 'UIB', 'active'], ['100', 'Video_recorder', 'active'], ['128', 'Srv_ALTF', 'active'], ['129', 'Srv_ALTF1', 'active'], ... |
#http://shell-storm.org/shellcode/files/shellcode-821.php
def reverse_tcp( HOST,PORT):
shellcode = r"\x01\x10\x8F\xE2"
shellcode += r"\x11\xFF\x2F\xE1"
shellcode += r"\x02\x20\x01\x21"
shellcode += r"\x92\x1a\x0f\x02"
shellcode += r"\x19\x37\x01\xdf"
shellcode += r"\x06\x1c\x08\xa1"
shel... | def reverse_tcp(HOST, PORT):
shellcode = '\\x01\\x10\\x8F\\xE2'
shellcode += '\\x11\\xFF\\x2F\\xE1'
shellcode += '\\x02\\x20\\x01\\x21'
shellcode += '\\x92\\x1a\\x0f\\x02'
shellcode += '\\x19\\x37\\x01\\xdf'
shellcode += '\\x06\\x1c\\x08\\xa1'
shellcode += '\\x10\\x22\\x02\\x37'
shellcod... |
class Solution(object):
def romanToInt(self, s):
"""
:type s: str
:rtype: int
"""
integer = 0
values = {'M': 1000, 'D': 500, 'C': 100,
'L': 50, 'X': 10, 'V': 5, 'I': 1}
left = 1000
for i in s:
integer = integer + values[i]... | class Solution(object):
def roman_to_int(self, s):
"""
:type s: str
:rtype: int
"""
integer = 0
values = {'M': 1000, 'D': 500, 'C': 100, 'L': 50, 'X': 10, 'V': 5, 'I': 1}
left = 1000
for i in s:
integer = integer + values[i] - 2 * (left < ... |
# https://www.geeksforgeeks.org/partition-a-set-into-two-subsets-such-that-the-difference-of-subset-sums-is-minimum/
def helper(arr, n, path, s):
if n == 0:
return abs((s - path) - path)
return min(
helper(arr, n-1, path+arr[n], s),
helper(arr, n-1, path, s)
)
def solve(arr):
... | def helper(arr, n, path, s):
if n == 0:
return abs(s - path - path)
return min(helper(arr, n - 1, path + arr[n], s), helper(arr, n - 1, path, s))
def solve(arr):
n = len(arr)
s = sum(arr)
dp = [[False] * (s + 1) for _ in range(n + 1)]
for i in range(n + 1):
dp[i][0] = True
f... |
## Shortest Word
## 7 kyu
## https://www.codewars.com/kata/57cebe1dc6fdc20c57000ac9
def find_short(s):
# your code here
return sorted([len(word) for word in s.split()])[0] | def find_short(s):
return sorted([len(word) for word in s.split()])[0] |
nums = 34
coins= [1,2,5,10]
temp = nums
dp = [float("inf") for _ in range(nums)]
dp[0] = 0
for i in range(1,nums):
for j in range(len(coins)):
if(coins[j] <= nums):
dp[i] = min(dp[i], dp[i-coins[j]]+1)
print(dp)
print(dp[nums-1])
| nums = 34
coins = [1, 2, 5, 10]
temp = nums
dp = [float('inf') for _ in range(nums)]
dp[0] = 0
for i in range(1, nums):
for j in range(len(coins)):
if coins[j] <= nums:
dp[i] = min(dp[i], dp[i - coins[j]] + 1)
print(dp)
print(dp[nums - 1]) |
model_name_mapping = {
'baseline': 'Baseline',
# dnn
'single_regression_2': 'SingleRegression_a',
'single_regression_11': 'SingleRegression_b',
'single_classification_22': 'SingleClassification_a',
'single_classification_42': 'SingleClassification_b',
'multi_classification_15': 'MultiCl... | model_name_mapping = {'baseline': 'Baseline', 'single_regression_2': 'SingleRegression_a', 'single_regression_11': 'SingleRegression_b', 'single_classification_22': 'SingleClassification_a', 'single_classification_42': 'SingleClassification_b', 'multi_classification_15': 'MultiClassification_a', 'multi_classification_1... |
class QueryContinueDragEventArgs(RoutedEventArgs):
""" Contains arguments for the System.Windows.DragDrop.QueryContinueDrag event. """
Action=property(lambda self: object(),lambda self,v: None,lambda self: None)
"""Gets or sets the current status of the associated drag-and-drop operation.
Get: Action(self: Q... | class Querycontinuedrageventargs(RoutedEventArgs):
""" Contains arguments for the System.Windows.DragDrop.QueryContinueDrag event. """
action = property(lambda self: object(), lambda self, v: None, lambda self: None)
'Gets or sets the current status of the associated drag-and-drop operation.\n\n\n\nGet: Act... |
def isfirstwordtitle(txt):
allchars = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',' ']
for char in allchars:
if txt.startswith(char):
return True
return False
def islower(txt,checknum=0):
txt = txt.replace(' ','')
allchars = ['a', 'b', 'c', ... | def isfirstwordtitle(txt):
allchars = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', ' ']
for char in allchars:
if txt.startswith(char):
return True
return False
def islower(txt, checknum=0):
txt = t... |
# Checks if all characters of a string are alphanumeric (a-z, A-Z and 0-9).
c = "qA2"
print(c.isalnum())
# Checks if all the characters of a string are alphabetical (a-z and A-Z).
print(c.isalpha())
# Checks if all characters in a string are digits.
print(c.isdigit())
# Checks if all characters in a string are lower... | c = 'qA2'
print(c.isalnum())
print(c.isalpha())
print(c.isdigit())
print(c.islower())
print(c.isupper())
def is_al_num(s):
return s.isalnum()
def alpha(s):
return s.isalpha()
def run_method_for_each_char(s):
print(any([char.isalnum() for char in s]))
print(any([char.isalpha() for char in s]))
pri... |
"""modular.py
Modular arithmetic helpers
"""
def modular_multiply(A, B, C):
"""Finds `(A * B) mod C`
This is equivalent to:
`(A mod C * B mod C) mod C`
https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/modular-multiplication
https://www.khanacademy.org/computin... | """modular.py
Modular arithmetic helpers
"""
def modular_multiply(A, B, C):
"""Finds `(A * B) mod C`
This is equivalent to:
`(A mod C * B mod C) mod C`
https://www.khanacademy.org/computing/computer-science/cryptography/modarithmetic/a/modular-multiplication
https://www.khanacademy.org/computin... |
# -*- coding: utf-8 -*-
class ClassTest:
def __init__(self, value1, value2):
self.value1 = value1
self._value2 = value2
@property
def value2(self):
return self._value2
@value2.setter
def value2(self, value):
self._value2 = value
| class Classtest:
def __init__(self, value1, value2):
self.value1 = value1
self._value2 = value2
@property
def value2(self):
return self._value2
@value2.setter
def value2(self, value):
self._value2 = value |
s=0
tot =0
for c in range(1, 500, 2):
if (c % 3) == 0:
s += c
tot += 1
print(s)
print(tot) | s = 0
tot = 0
for c in range(1, 500, 2):
if c % 3 == 0:
s += c
tot += 1
print(s)
print(tot) |
#!/usr/bin/python3
for a in range(1, 400):
for b in range(1, 400):
c = (1000 - a) - b
if a < b < c:
if a**2 + b**2 == c**2:
print(a * b * c)
| for a in range(1, 400):
for b in range(1, 400):
c = 1000 - a - b
if a < b < c:
if a ** 2 + b ** 2 == c ** 2:
print(a * b * c) |
# Advent of Code - Day 8 - Part Two
def result(data):
digits = {
2: 1,
4: 4,
3: 7,
7: 8
}
count = 0
for line in data:
a, b = line.split(' | ')
for word in b.split(' '):
x = len(word)
if digits.get(x):
count += 1
... | def result(data):
digits = {2: 1, 4: 4, 3: 7, 7: 8}
count = 0
for line in data:
(a, b) = line.split(' | ')
for word in b.split(' '):
x = len(word)
if digits.get(x):
count += 1
return count |
def staircase(n):
num_dict = dict({})
return staircase_faster(n, num_dict)
def staircase_faster(n, num_dict):
if n == 1:
output = 1
elif n == 2:
output = 2
elif n == 3:
output = 4
else:
if (n - 1) in num_dict:
first_output = num_dict[n - 1]
el... | def staircase(n):
num_dict = dict({})
return staircase_faster(n, num_dict)
def staircase_faster(n, num_dict):
if n == 1:
output = 1
elif n == 2:
output = 2
elif n == 3:
output = 4
else:
if n - 1 in num_dict:
first_output = num_dict[n - 1]
else... |
"""
Code taken from fsl.py https://git.fmrib.ox.ac.uk/fsl/fslpy
Copyright 2016-2017 University of Oxford, Oxford, UK.
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/licen... | """
Code taken from fsl.py https://git.fmrib.ox.ac.uk/fsl/fslpy
Copyright 2016-2017 University of Oxford, Oxford, UK.
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/licen... |
def firstNonRepeatingCharacter(string):
"""
This function takes a string and find the first character in the string which is non-repeating. This implementation is of O(n) time
complexity and O(1) space complexity where n is the length of the string and all chars in the string are lowecase that is why only 26
key va... | def first_non_repeating_character(string):
"""
This function takes a string and find the first character in the string which is non-repeating. This implementation is of O(n) time
complexity and O(1) space complexity where n is the length of the string and all chars in the string are lowecase that is why only 26
... |
if __name__ == "__main__":
primes = [2, 3, 5, 7, 11, 13, 17, 19]
s = 1
m = 1
for i in range(1, 21):
if i in primes:
s *= i
m *= i
elif m % i == 0:
pass
elif m % i != 0:
j = m
while True:
j += s
... | if __name__ == '__main__':
primes = [2, 3, 5, 7, 11, 13, 17, 19]
s = 1
m = 1
for i in range(1, 21):
if i in primes:
s *= i
m *= i
elif m % i == 0:
pass
elif m % i != 0:
j = m
while True:
j += s
... |
# Program to push , pop and display elements of a stack
st = []
r = []
def push():
print('--STACK--')
x = int(input('Book_No: '))
y = input('Book_Name: ')
r = [x, y]
st.append(r)
def display():
if len(st) > 0:
for i in range(len(st)-1, -1, -1):
print(st[i])
else:
... | st = []
r = []
def push():
print('--STACK--')
x = int(input('Book_No: '))
y = input('Book_Name: ')
r = [x, y]
st.append(r)
def display():
if len(st) > 0:
for i in range(len(st) - 1, -1, -1):
print(st[i])
else:
print('Underflow')
def pop():
if st[0] == ():
... |
class SiteConfig(dict):
def update(self, d, **kwargs):
filtered_d = {k: v for k, v in d.items() if v is not None}
super().update(filtered_d, **kwargs)
@staticmethod
def default():
return SiteConfig(
{
"depth": 5,
"delay": 1.5,
... | class Siteconfig(dict):
def update(self, d, **kwargs):
filtered_d = {k: v for (k, v) in d.items() if v is not None}
super().update(filtered_d, **kwargs)
@staticmethod
def default():
return site_config({'depth': 5, 'delay': 1.5, 'ua': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6)... |
contoh_list = [1, 'dua', 3, 4.0, 5]
print(contoh_list[0])
print(contoh_list[3])
contoh_list = [1, 'dua', 3, 4.0, 5]
contoh_list[3] = 'empat'
print(contoh_list[3])
| contoh_list = [1, 'dua', 3, 4.0, 5]
print(contoh_list[0])
print(contoh_list[3])
contoh_list = [1, 'dua', 3, 4.0, 5]
contoh_list[3] = 'empat'
print(contoh_list[3]) |
# -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations
#########################################################################
## Customize your APP title, subtitle and menus here
#########################################################################
response.logo... | response.logo = a(b('QualityPost'), xml('™ '), _class='brand', _href='http://www.qualitypost.com.mx/')
response.title = 'Asignacion Interactiva de Mensajes'
response.subtitle = 'Cliente: '
response.meta.author = 'Armando Hernandez <ahernandez@lettershopmexico.com>'
response.meta.keywords = 'web2py, python, f... |
# spaceobj.py
# A space object.
# Basically, anything that exists on the starmap.
NONETYPE = 0
FLEETTYPE = 1
STARTYPE = 2
class SpaceObj:
name = ""
x = 0
y = 0
# This is often a class variable...
sprite = ()
def __init__( s ):
pass
def moveTo( s, x, y ):
s.x = x
... | nonetype = 0
fleettype = 1
startype = 2
class Spaceobj:
name = ''
x = 0
y = 0
sprite = ()
def __init__(s):
pass
def move_to(s, x, y):
s.x = x
s.y = y
def get_location(s):
return (s.x, s.y)
def prepare_sprite(self):
self.sprite.setAnim(0)
... |
x = y = direction = 0
moves = open('input.txt', 'r').readline().strip().split(', ')
for move in moves:
if move[0] == 'L':
if direction == 0:
direction = 3
else:
direction -= 1
elif move[0] == 'R':
if direction == 3:
direction = 0
else:
... | x = y = direction = 0
moves = open('input.txt', 'r').readline().strip().split(', ')
for move in moves:
if move[0] == 'L':
if direction == 0:
direction = 3
else:
direction -= 1
elif move[0] == 'R':
if direction == 3:
direction = 0
else:
... |
with open('input.txt') as f:
lines = f.readlines()
count = 0
prevSum = 0
for i in range(len(lines)):
if i + 3 > len(lines):
break
newSum = int(lines[i]) + int(lines[i + 1]) + int(lines[i + 2])
if prevSum != 0:
if newSum > prevSum:
count += ... | with open('input.txt') as f:
lines = f.readlines()
count = 0
prev_sum = 0
for i in range(len(lines)):
if i + 3 > len(lines):
break
new_sum = int(lines[i]) + int(lines[i + 1]) + int(lines[i + 2])
if prevSum != 0:
if newSum > prevSum:
count +... |
TOKEN_LIST = [
#kovan
['ethereum', '42', 'eth', '0x0000000000000000000000000000000000000000', 18],
['ethereum', '42', 'usdt', '0xd85476c906b5301e8e9eb58d174a6f96b9dfc5ee', 6],
['ethereum', '42', 'usdc', '0xb7a4f3e9097c08da09517b5ab877f7a917224ede', 6],
['ethereum', '42', 'dai', '0xc4375b7de8af5a38a... | token_list = [['ethereum', '42', 'eth', '0x0000000000000000000000000000000000000000', 18], ['ethereum', '42', 'usdt', '0xd85476c906b5301e8e9eb58d174a6f96b9dfc5ee', 6], ['ethereum', '42', 'usdc', '0xb7a4f3e9097c08da09517b5ab877f7a917224ede', 6], ['ethereum', '42', 'dai', '0xc4375b7de8af5a38a93548eb8453a498222c4ff2', 18]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.