content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
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... |
'''
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) |
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... |
###################################
# 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('... |
# -*- 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 = '-'
... |
#!/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... |
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)) |
# 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... |
#
# 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 ... |
# 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 |
# 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... |
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... |
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 |
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... |
#!/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] |
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... |
# 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... |
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... |
# -*- 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... |
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]... |
DEBIAN = 'debian'
CENTOS = 'centos'
OPENSUSE = 'opensuse'
UBUNTU = 'ubuntu'
| debian = 'debian'
centos = 'centos'
opensuse = 'opensuse'
ubuntu = 'ubuntu' |
cand1 = 0
cand2 = 0
cand3 = 0
eleitores = int(input('Digite a quantidade de eleitores: '))
print('Para votar no Candidato 1 digite [1]\nPara votar no Candidato 2 digite [2]\nPara votar no Candidato 3 digite [3]')
for cont in range(0, eleitores):
voto = str(input('Digite seu voto: '))
if voto == '1':
can... | cand1 = 0
cand2 = 0
cand3 = 0
eleitores = int(input('Digite a quantidade de eleitores: '))
print('Para votar no Candidato 1 digite [1]\nPara votar no Candidato 2 digite [2]\nPara votar no Candidato 3 digite [3]')
for cont in range(0, eleitores):
voto = str(input('Digite seu voto: '))
if voto == '1':
can... |
# ----------------------------------------------------------------------
# Copyright (c) Microsoft Corporation.
# All rights reserved.
# ----------------------------------------------------------------------
# TODO: Consider just inheriting from Python's set type -MPL
class SymbolSet:
def __init__(self):
... | class Symbolset:
def __init__(self):
self._symbol_set_collection = set()
@property
def size(self):
return len(self._symbol_set_collection)
def add(self, new_symbol):
self._symbol_set_collection.add(new_symbol)
def merge(self, sym_set):
if sym_set is not None:
... |
fix = {'5':'S', '0':'O', '1':'I'}
def correct(s):
return "".join(fix.get(c, c) for c in s)
| fix = {'5': 'S', '0': 'O', '1': 'I'}
def correct(s):
return ''.join((fix.get(c, c) for c in s)) |
#!/usr/bin/python3
def test_erc165_support(nft):
erc165_interface_id = "0x01ffc9a7"
assert nft.supportsInterface(erc165_interface_id) is True
def test_erc721_support(nft):
erc721_interface_id = "0x80ac58cd"
assert nft.supportsInterface(erc721_interface_id) is True
| def test_erc165_support(nft):
erc165_interface_id = '0x01ffc9a7'
assert nft.supportsInterface(erc165_interface_id) is True
def test_erc721_support(nft):
erc721_interface_id = '0x80ac58cd'
assert nft.supportsInterface(erc721_interface_id) is True |
def fatorial(_numero = 1, show = False):
resultado = 1
for item in range(1, _numero + 1):
resultado *= item
if show:
texto = ''
for item in reversed(range(1, _numero + 1)):
texto += '{} '.format(item)
if item == 1:
texto += '= {}'.format(resul... | def fatorial(_numero=1, show=False):
resultado = 1
for item in range(1, _numero + 1):
resultado *= item
if show:
texto = ''
for item in reversed(range(1, _numero + 1)):
texto += '{} '.format(item)
if item == 1:
texto += '= {}'.format(resultado)... |
BLACK = '\x1b[0;30m'
RED = '\x1b[0;31m'
GREEN = '\x1b[0;32m'
BROWN = '\x1b[0;33m'
BLUE = '\x1b[0;34m'
PURPLE = '\x1b[0;35m'
CYAN = '\x1b[0;36m'
LIGHT_GRAY = '\x1b[0;37m'
DARK_GRAY = '\x1b[1;30m'
LIGHT_RED = '\x1b[1;31m'
LIGHT_GREEN = '\x1b[1;32m'
YELLOW = '\x1b[1;33m'
LIGHT_BLUE = '\x1b[1;34m'
LIGHT_PURPLE = '\x1b[1;3... | black = '\x1b[0;30m'
red = '\x1b[0;31m'
green = '\x1b[0;32m'
brown = '\x1b[0;33m'
blue = '\x1b[0;34m'
purple = '\x1b[0;35m'
cyan = '\x1b[0;36m'
light_gray = '\x1b[0;37m'
dark_gray = '\x1b[1;30m'
light_red = '\x1b[1;31m'
light_green = '\x1b[1;32m'
yellow = '\x1b[1;33m'
light_blue = '\x1b[1;34m'
light_purple = '\x1b[1;35... |
authentication = {
"type": "object",
"properties": {
"access": {
"type": "object",
"properties": {
"token": {
"type": "object",
"properties": {
"id": {
"type": "string"
... | authentication = {'type': 'object', 'properties': {'access': {'type': 'object', 'properties': {'token': {'type': 'object', 'properties': {'id': {'type': 'string'}}, 'required': ['id']}, 'serviceCatalog': {'type': 'array'}}, 'required': ['token', 'serviceCatalog']}}, 'required': ['access']} |
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Queue:
def __init__(self):
self.front = None
self.rear = None
def enqueue(self, data):
node = Node(data)
if self.rear:
self.rear.next = node
self.rear... | class Node:
def __init__(self, value):
self.value = value
self.next = None
class Queue:
def __init__(self):
self.front = None
self.rear = None
def enqueue(self, data):
node = node(data)
if self.rear:
self.rear.next = node
self.rear ... |
class Customer:
def __init__(self, name, age, phone_no, address):
self.name = name
self.age = age
self.phone_no = phone_no
self.address = address
def view_details(self):
print(self.name, self.age, self.phone_no)
print(self.address.get_door_no(),
sel... | class Customer:
def __init__(self, name, age, phone_no, address):
self.name = name
self.age = age
self.phone_no = phone_no
self.address = address
def view_details(self):
print(self.name, self.age, self.phone_no)
print(self.address.get_door_no(), self.address.get... |
#!/usr/bin/env python3
# https://abc054.contest.atcoder.jp/tasks/abc054_a
a, b = map(int, input().split())
if a == b: print('Draw')
elif a == 1: print('Alice')
elif b == 1: print('Bob')
elif a > b: print('Alice')
else: print('Bob')
| (a, b) = map(int, input().split())
if a == b:
print('Draw')
elif a == 1:
print('Alice')
elif b == 1:
print('Bob')
elif a > b:
print('Alice')
else:
print('Bob') |
class NoQueueError(Exception):
pass
class JobError(RuntimeError):
pass
class TimeoutError(JobError):
pass
class CrashError(JobError):
pass | class Noqueueerror(Exception):
pass
class Joberror(RuntimeError):
pass
class Timeouterror(JobError):
pass
class Crasherror(JobError):
pass |
# Encoding and Decoding in Python 3.x
a = 'Harshit'
# initialize byte object.
c = b'Harshit'
# using encode() to encode string
d = a.encode('ASCII')
if (d == c):
print("Encoding successful.")
else:
print("Encoding unsuccessful. :( ")
# Similarly, decode() is the inverse process.
# decode() will convert byte... | a = 'Harshit'
c = b'Harshit'
d = a.encode('ASCII')
if d == c:
print('Encoding successful.')
else:
print('Encoding unsuccessful. :( ') |
'''
Verify correct field and URL verification behavior
for not and nocase modifiers.
'''
# @file
#
# Copyright 2021, Verizon Media
# SPDX-License-Identifier: Apache-2.0
#
Test.Summary = '''
Verify correct field and URL verification behavior for
equals, absent, present, contains, prefix, and suffix
with not, nocase, a... | """
Verify correct field and URL verification behavior
for not and nocase modifiers.
"""
Test.Summary = '\nVerify correct field and URL verification behavior for\nequals, absent, present, contains, prefix, and suffix\nwith not, nocase, and both not and nocase modifiers\n'
r = Test.AddTestRun("Verify 'not' and 'nocase' ... |
# ------------------------------
# 1027. Longest Arithmetic Sequence
#
# Description:
# Given an array A of integers, return the length of the longest arithmetic subsequence in A.
# Recall that a subsequence of A is a list A[i_1], A[i_2], ..., A[i_k] with 0 <= i_1 < i_2 <
# ... < i_k <= A.length - 1, and that a sequ... | class Solution:
def longest_arith_seq_length(self, A: List[int]) -> int:
dp = {}
for i in range(len(A)):
for j in range(i + 1, len(A)):
dp[j, A[j] - A[i]] = dp.get((i, A[j] - A[i]), 1) + 1
return max(dp.values())
if __name__ == '__main__':
test = solution() |
products = {}
command = input()
while command != "statistics":
command = input()
while command != "statistics":
tokens = command.split(": ")
product = tokens[0]
quantity = int(tokens[1])
if product not in products:
products[product] = 0
products[product] += quantity
print("Products in s... | products = {}
command = input()
while command != 'statistics':
command = input()
while command != 'statistics':
tokens = command.split(': ')
product = tokens[0]
quantity = int(tokens[1])
if product not in products:
products[product] = 0
products[product] += quantity
print('Products in st... |
DEBUG = False
ALLOWED_HOSTS = ['*']
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'db1',
'USER': 'alex',
'PASSWORD': 'asdewqr1',
'HOST': 'localhost', # Set to empty string for localhost.
'PORT': '', # Set to empty string for default.
}
... | debug = False
allowed_hosts = ['*']
databases = {'default': {'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'db1', 'USER': 'alex', 'PASSWORD': 'asdewqr1', 'HOST': 'localhost', 'PORT': ''}} |
class Dummy:
def __str__(self) -> str:
return "dummy"
d1 = Dummy()
print(d1)
| class Dummy:
def __str__(self) -> str:
return 'dummy'
d1 = dummy()
print(d1) |
_use_time = True
try:
_start_time = datetime.utcnow().timestamp()
except Exception:
_use_time = False | _use_time = True
try:
_start_time = datetime.utcnow().timestamp()
except Exception:
_use_time = False |
# -*- coding: utf-8 -*-
extensions = ['sphinx.ext.viewcode']
master_doc = 'index'
exclude_patterns = ['_build']
viewcode_follow_imported_members = False
| extensions = ['sphinx.ext.viewcode']
master_doc = 'index'
exclude_patterns = ['_build']
viewcode_follow_imported_members = False |
'''
Anti-palindrome strings
You are given a string containing only lowercase alphabets. You can swap two adjacent characters any number of times (including 0).
A string is called anti-palindrome if it is not a palindrome. If it is possible to make a string anti-palindrome, then find the lexicographically smallest an... | """
Anti-palindrome strings
You are given a string containing only lowercase alphabets. You can swap two adjacent characters any number of times (including 0).
A string is called anti-palindrome if it is not a palindrome. If it is possible to make a string anti-palindrome, then find the lexicographically smallest an... |
def bom_populate(bom):
bom.components.new(
name="s1",
description="HPE ML30 INTEL, 4U Tower, 8 HD's fit inside, 1 gbit dual",
cost=378,
rackspace_u=0,
cru=0,
sru=0,
hru=0,
mru=0,
su_perc=50,
cu_perc=50,
power=150,
)
... | def bom_populate(bom):
bom.components.new(name='s1', description="HPE ML30 INTEL, 4U Tower, 8 HD's fit inside, 1 gbit dual", cost=378, rackspace_u=0, cru=0, sru=0, hru=0, mru=0, su_perc=50, cu_perc=50, power=150)
bom.components.new(name='s2', description="HPE ML110 INTEL, 4U Tower, 8 HD's fit inside, 1 gbit dua... |
class Model:
def to_dict(self):
return NotImplementedError
class User(Model):
def to_dict(self):
return {}
class UserID(Model):
def to_dict(self):
return {}
class UserAuth(Model):
def to_dict(self):
return {}
| class Model:
def to_dict(self):
return NotImplementedError
class User(Model):
def to_dict(self):
return {}
class Userid(Model):
def to_dict(self):
return {}
class Userauth(Model):
def to_dict(self):
return {} |
# @file dsc_processor_plugin
# Plugin for for parsing DSCs
##
# Copyright (c) Microsoft Corporation
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
class IDscProcessorPlugin(object):
##
# does the transform on the DSC
#
# @param dsc - the in-memory model of the DSC
# @param thebuilder - UefiB... | class Idscprocessorplugin(object):
def do_transform(self, dsc, thebuilder):
return 0
def get_level(self, thebuilder):
return 0 |
def q2(stop_value):
first, second = 0, 1
i = 0
while first < stop_value:
print(f"{i}th term is: {first}")
first, second = first + second, first
i += 1
if __name__ == "__main__":
n = 20
q2(n)
| def q2(stop_value):
(first, second) = (0, 1)
i = 0
while first < stop_value:
print(f'{i}th term is: {first}')
(first, second) = (first + second, first)
i += 1
if __name__ == '__main__':
n = 20
q2(n) |
def titulo():
print('~' * 80)
print('{:^80}'.format('Sistema Interativo PyHelp'))
print('~' * 80)
def leia_comando():
comando = str(input(
'> Insira o comando que deseja obter ajuda: ("fim" para encerrar) ')).lower().strip()
return comando
def imprimir_manual(_comando):
try:
... | def titulo():
print('~' * 80)
print('{:^80}'.format('Sistema Interativo PyHelp'))
print('~' * 80)
def leia_comando():
comando = str(input('> Insira o comando que deseja obter ajuda: ("fim" para encerrar) ')).lower().strip()
return comando
def imprimir_manual(_comando):
try:
print()
... |
# Mu Lung Dojo Bulletin Board (2091006) | Mu Lung Temple (250000100)
dojo = 925020000
response = sm.sendAskYesNo("Would you like to go to Mu Lung Dojo?")
if response:
sm.setReturnField()
sm.setReturnPortal(0)
sm.warp(dojo) | dojo = 925020000
response = sm.sendAskYesNo('Would you like to go to Mu Lung Dojo?')
if response:
sm.setReturnField()
sm.setReturnPortal(0)
sm.warp(dojo) |
# --------------
# Code starts here
class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1 + class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new... | class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1 + class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_class)
courses = {'Math': 65, 'English... |
badge_icon = 'app.icns'
icon_locations = {
'LBRY.app': (115, 164),
'Applications': (387, 164)
}
background='dmg_background.png'
default_view='icon-view'
symlinks = { 'Applications': '/Applications' }
window_rect=((200, 200), (500, 320))
files = [ 'LBRY.app' ]
icon_size=128
| badge_icon = 'app.icns'
icon_locations = {'LBRY.app': (115, 164), 'Applications': (387, 164)}
background = 'dmg_background.png'
default_view = 'icon-view'
symlinks = {'Applications': '/Applications'}
window_rect = ((200, 200), (500, 320))
files = ['LBRY.app']
icon_size = 128 |
#
# PySNMP MIB module TPT-TPA-HARDWARE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPT-TPA-HARDWARE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:26:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, value_size_constraint, constraints_intersection, single_value_constraint) ... |
class Solution:
def criticalConnections(self, n: int, connections: List[List[int]]) -> List[List[int]]:
INF = 1000000
lows = [INF] * n
ranks = [INF] * n
graph = collections.defaultdict(list)
for u, v in connections:
graph[u].append(v)
graph[v].append(u... | class Solution:
def critical_connections(self, n: int, connections: List[List[int]]) -> List[List[int]]:
inf = 1000000
lows = [INF] * n
ranks = [INF] * n
graph = collections.defaultdict(list)
for (u, v) in connections:
graph[u].append(v)
graph[v].appe... |
l = [83, 85, 78, 123, 77, 52, 57, 53, 45, 102, 52, 110, 33, 125]
flag = ""
for c in l:
flag += chr(c)
print(flag)
| l = [83, 85, 78, 123, 77, 52, 57, 53, 45, 102, 52, 110, 33, 125]
flag = ''
for c in l:
flag += chr(c)
print(flag) |
l,S1,final=[],[],[]
S=input('Enter the numbers: ')
S1=S.split()
for i in S1:
l.append(int(i))
final=str("['"+str(l)+"']")
print(final)
| (l, s1, final) = ([], [], [])
s = input('Enter the numbers: ')
s1 = S.split()
for i in S1:
l.append(int(i))
final = str("['" + str(l) + "']")
print(final) |
# Permutation
def permutation_rec(a):
if len(a) == 0:
return []
if len(a) == 1:
return [a]
l = []
for i in range(len(a)):
x = a[:i] + a[i+1:]
for j in permutation_rec(x):
str2 = a[i] + j
l.append(str2)
return l
count = 0
for r in permutati... | def permutation_rec(a):
if len(a) == 0:
return []
if len(a) == 1:
return [a]
l = []
for i in range(len(a)):
x = a[:i] + a[i + 1:]
for j in permutation_rec(x):
str2 = a[i] + j
l.append(str2)
return l
count = 0
for r in permutation_rec('chip'):
... |
# almostIncreasingSequence or "too big or too small"
# is there one exception to the list being sorted? (with no repeats)
# including being already sorted
# (User's) Problem
# We Have:
# list of int
# We Need:
# Is there one exception to the list being sorted? yes/no
# We Must:
# return boolean: true false... | def almost_increasing_sequence(input_list):
if input_list == sorted(list(set(input_list))):
return True
for i in range(len(input_list) - 1):
if input_list[i] >= input_list[i + 1]:
if i == 0:
input_list.pop(i)
elif i == len(input_list) - 1:
... |
#
# PySNMP MIB module XEDIA-DHCP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XEDIA-DHCP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:36:09 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_size_constraint, constraints_union, constraints_intersection, value_range_constraint) ... |
class CustomError(Exception):
def __init__(self, *args):
if args:
self.topic = args[0]
else:
self.topic = None
def __str__(self):
if self.topic:
return 'Custom Error:, {0}'.format(self.topic)
class MessageHandler(object):
def __init__(self, event... | class Customerror(Exception):
def __init__(self, *args):
if args:
self.topic = args[0]
else:
self.topic = None
def __str__(self):
if self.topic:
return 'Custom Error:, {0}'.format(self.topic)
class Messagehandler(object):
def __init__(self, eve... |
class Solution:
# @return a string
def longestCommonPrefix(self, strs):
n = len(strs)
if n == 0:
return ''
if n == 1:
return strs[0]
prefix = ''
m = min([len(s) for s in strs])
for i in range(m):
first = strs[0]
com... | class Solution:
def longest_common_prefix(self, strs):
n = len(strs)
if n == 0:
return ''
if n == 1:
return strs[0]
prefix = ''
m = min([len(s) for s in strs])
for i in range(m):
first = strs[0]
common = True
... |
def parseSolutions(solutions, orderList):
parsedSolutions = []
for solution in solutions:
solutionItems = solution.items()
schedule = []
finishTimes = []
for item in solutionItems:
if "enter" in item[0]:
parsedItem = item[0].split("-")
order = orderList.orderFromID(int(parsedItem[0]))
schedule.... | def parse_solutions(solutions, orderList):
parsed_solutions = []
for solution in solutions:
solution_items = solution.items()
schedule = []
finish_times = []
for item in solutionItems:
if 'enter' in item[0]:
parsed_item = item[0].split('-')
... |
# Copyright 2014-2019 Ivan Yelizariev <https://it-projects.info/team/yelizariev>
# Copyright 2015 Bassirou Ndaw <https://github.com/bassn>
# Copyright 2015 Alexis de Lattre <https://github.com/alexis-via>
# Copyright 2016-2017 Stanislav Krotov <https://it-projects.info/team/ufaks>
# Copyright 2017 Ilmir Karamov <https:... | {'name': 'POS: Prepaid credits', 'summary': 'Comfortable sales for your regular customers. Debt payment method for POS', 'category': 'Point Of Sale', 'images': ['images/debt_notebook.png'], 'version': '12.0.5.3.2', 'author': 'IT-Projects LLC, Ivan Yelizariev', 'support': 'apps@itpp.dev', 'website': 'https://apps.odoo.c... |
description = 'BOA Translations stages'
pvprefix = 'SQ:BOA:mcu2:'
devices = dict(
translation_300mm_a = device('nicos_ess.devices.epics.motor.EpicsMotor',
description = 'Translation 1',
motorpv = pvprefix + 'TVA',
errormsgpv = pvprefix + 'TVA-MsgTxt',
),
translation_300mm_b = devic... | description = 'BOA Translations stages'
pvprefix = 'SQ:BOA:mcu2:'
devices = dict(translation_300mm_a=device('nicos_ess.devices.epics.motor.EpicsMotor', description='Translation 1', motorpv=pvprefix + 'TVA', errormsgpv=pvprefix + 'TVA-MsgTxt'), translation_300mm_b=device('nicos_ess.devices.epics.motor.EpicsMotor', descr... |
def frac(num1,num2):
if num1 == 0 or num2 ==0:
return 0
else:
sum1 = num1 / num2
sum1 = str(sum1)
sum1 = sum1.split(".")
final = "0."+ sum1[1][0]
final = float(final)
return final
print(frac(4,1)) | def frac(num1, num2):
if num1 == 0 or num2 == 0:
return 0
else:
sum1 = num1 / num2
sum1 = str(sum1)
sum1 = sum1.split('.')
final = '0.' + sum1[1][0]
final = float(final)
return final
print(frac(4, 1)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.