content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Morse:
DOT = '.'
DASH = '-'
characters = {
(DOT, DASH): 'A',
(DASH, DOT, DOT, DOT): 'B',
(DASH, DOT, DASH, DOT): 'C',
(DASH, DOT, DOT): 'D',
(DOT,): 'E',
(DOT, DOT, DASH, DOT): 'F',
(DASH, DASH, DOT): 'G',
(DOT, DOT, DOT, DOT): 'H',
... | class Morse:
dot = '.'
dash = '-'
characters = {(DOT, DASH): 'A', (DASH, DOT, DOT, DOT): 'B', (DASH, DOT, DASH, DOT): 'C', (DASH, DOT, DOT): 'D', (DOT,): 'E', (DOT, DOT, DASH, DOT): 'F', (DASH, DASH, DOT): 'G', (DOT, DOT, DOT, DOT): 'H', (DOT, DOT): 'I', (DOT, DASH, DASH, DASH): 'J', (DASH, DOT, DASH): 'K',... |
# ScalePairs.py
# Chromatic definitions of different scale types
# Guide:
# C:1, Db:2, D:3, Eb:4, E:5, F:6, Gb:7, G:8, Ab:9, A:10, Bb:11, B:12
scalePairs = []
# Copied from NodeBeat's "NodeBeat Classic"
scalePairs += [("KosBeat\nClassic", [1, 3, 6, 8, 10])]
scalePairs += [("Major", [1, 3, 5, 6, 8, 10, 12])]
scalePair... | scale_pairs = []
scale_pairs += [('KosBeat\nClassic', [1, 3, 6, 8, 10])]
scale_pairs += [('Major', [1, 3, 5, 6, 8, 10, 12])]
scale_pairs += [('Major\nPentatonic', [1, 3, 5, 8, 10])]
scale_pairs += [('Minor\nPentatonic', [1, 4, 6, 8, 11])]
scale_pairs += [('Natural\nMinor', [1, 3, 4, 6, 8, 9, 11])]
scale_pairs += [('Har... |
#
# PySNMP MIB module TIMETRA-SAS-FILTER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIMETRA-SAS-FILTER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:21:39 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ... |
# Singleton (from guido)
class Singleton(object):
def __new__(cls, *args, **kwds):
it = cls.__dict__.get("__it__")
if it is not None:
return it
cls.__it__ = it = object.__new__(cls)
it.init(*args, **kwds)
return it
def init(self, *args, **kwds):
pass
... | class Singleton(object):
def __new__(cls, *args, **kwds):
it = cls.__dict__.get('__it__')
if it is not None:
return it
cls.__it__ = it = object.__new__(cls)
it.init(*args, **kwds)
return it
def init(self, *args, **kwds):
pass |
class Node:
def __init__(self, type_, arity: int, value=None):
self.type = type_
self.arity = arity
self.value = value
self.children = []
def __repr__(self):
return "<Node {t} {v} {c}>".format(t=self.type, v=self.value, c=self.children)
def _pprint(self, level):
... | class Node:
def __init__(self, type_, arity: int, value=None):
self.type = type_
self.arity = arity
self.value = value
self.children = []
def __repr__(self):
return '<Node {t} {v} {c}>'.format(t=self.type, v=self.value, c=self.children)
def _pprint(self, level):
... |
#!/usr/bin/python3
def readfile(filename):
'''
:param
filename:
input is a text file for input
:return:
Equations:
lines with potential equations on them
num_line:
number of equation lines
'''
# open file
with open(filename, mode='r') as f:
line_l... | def readfile(filename):
"""
:param
filename:
input is a text file for input
:return:
Equations:
lines with potential equations on them
num_line:
number of equation lines
"""
with open(filename, mode='r') as f:
line_list = []
while True:
... |
# Configuration file for ipython-notebook.
c = get_config()
# ------------------------------------------------------------------------------
# NotebookApp configuration
# ------------------------------------------------------------------------------
c.GitHubConfig.access_token = ''
c.JupyterApp.answer_yes = True
c.L... | c = get_config()
c.GitHubConfig.access_token = ''
c.JupyterApp.answer_yes = True
c.LabApp.user_settings_dir = '/data/user-settings'
c.LabApp.workspaces_dir = '/data/workspaces'
c.NotebookApp.allow_origin = '*'
c.NotebookApp.allow_password_change = False
c.NotebookApp.allow_remote_access = True
c.NotebookApp.allow_root ... |
#
# PySNMP MIB module JUNIPER-WX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/JUNIPER-WX-GLOBAL-REG
# Produced by pysmi-0.3.4 at Mon Apr 29 19:50:41 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, M... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, constraints_union, constraints_intersection, value_size_constraint) ... |
def f(n):
if n <=0:
return 1
res = 0
for i in range(n):
res += f(i) * f(n-i-1)
return res | def f(n):
if n <= 0:
return 1
res = 0
for i in range(n):
res += f(i) * f(n - i - 1)
return res |
#
# PySNMP MIB module TPLINK-CLUSTER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TPLINK-CLUSTER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:24:19 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ... |
x = 1 # int
print(type(x))
x = 1.1 # float
print(type(x))
x = 1 + 2j # complex number
print(type(x))
print(10 + 3)
print(10 - 3)
print(10 * 3)
print(10 / 3)
print(10 // 3)
print(10 % 3)
print(10 ** 3)
x = 10
x = x + 3
x += 3
print(x)
| x = 1
print(type(x))
x = 1.1
print(type(x))
x = 1 + 2j
print(type(x))
print(10 + 3)
print(10 - 3)
print(10 * 3)
print(10 / 3)
print(10 // 3)
print(10 % 3)
print(10 ** 3)
x = 10
x = x + 3
x += 3
print(x) |
__title__ = 'mudrex'
__version__ = '0.1.2'
__summary__ = 'Send external webhook signals to Mudrex platform.'
__uri__ = 'https://github.com/surajiyer/mudrex'
__author__ = 'Suraj Iyer'
__email__ = 'me@surajiyer.com'
__license__ = 'MIT' | __title__ = 'mudrex'
__version__ = '0.1.2'
__summary__ = 'Send external webhook signals to Mudrex platform.'
__uri__ = 'https://github.com/surajiyer/mudrex'
__author__ = 'Suraj Iyer'
__email__ = 'me@surajiyer.com'
__license__ = 'MIT' |
c = 0
while c < 10:
print(c)
c = c + 1
print('FIM') | c = 0
while c < 10:
print(c)
c = c + 1
print('FIM') |
class Request:
def __init__(self, start, end):
self.start = start
self.end = end
def __str__(self):
return f'Request:{self.start},{self.end}'
def Is_compatible(self, request):
return request.start > self.end or request.end < self.start
'''This Algorithm give 0... | class Request:
def __init__(self, start, end):
self.start = start
self.end = end
def __str__(self):
return f'Request:{self.start},{self.end}'
def is_compatible(self, request):
return request.start > self.end or request.end < self.start
'This Algorithm give 0(n2) running ti... |
S = input()
S = S.replace('BC', 'D')
cnt_a = 0
ans = 0
for i in range(len(S)):
if S[i] == 'A':
cnt_a += 1
elif S[i] == 'D':
ans += cnt_a
else:
cnt_a = 0
print(ans)
| s = input()
s = S.replace('BC', 'D')
cnt_a = 0
ans = 0
for i in range(len(S)):
if S[i] == 'A':
cnt_a += 1
elif S[i] == 'D':
ans += cnt_a
else:
cnt_a = 0
print(ans) |
#zip
my_list = [1,2,3]
your_list = [100,200,300]
their_list = [1000,2000,3000]
print(list(zip(my_list, your_list, their_list))[0][2])
print(list(zip(my_list, your_list, their_list))) | my_list = [1, 2, 3]
your_list = [100, 200, 300]
their_list = [1000, 2000, 3000]
print(list(zip(my_list, your_list, their_list))[0][2])
print(list(zip(my_list, your_list, their_list))) |
# https://leetcode.com/problems/minimum-falling-path-sum-ii/
# Given a square grid of integers arr, a falling path with non-zero shifts is a
# choice of exactly one element from each row of arr, such that no two elements
# chosen in adjacent rows are in the same column.
# Return the minimum sum of a falling path with... | class Solution:
def min_falling_path_sum(self, arr: List[List[int]]) -> int:
n = len(arr)
if n == 1:
return arr[0][0]
dp = [[0 for _ in range(n)] for _ in range(n)]
for j in range(n):
dp[0][j] = arr[0][j]
for i in range(1, n):
(min_1st, mi... |
# Configuration
# [Yoshikawa Taichi]
# version 1.3 (Jan. 28, 2020)
class Configuration():
'''
Configuration
'''
def __init__(self):
# ----- k-means components -----
## cluster numbers
self.centers = 3
## upper limit of iterations
self.upper_limit_... | class Configuration:
"""
Configuration
"""
def __init__(self):
self.centers = 3
self.upper_limit_iter = 1000
self.similarity_index = 'euclidean-distance'
self.dataset_url = 'https://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data'
self.datase... |
################### PEAK FINDING ###################
# 1D peak finding COMPLEXITY --> O(theta)(log n)
def peak_1D(l):
if len(l) == 1: # if a singleton list then simply returns the element
return l[0]
elif not len(l): # if a null list then returns None
... | def peak_1_d(l):
if len(l) == 1:
return l[0]
elif not len(l):
return None
else:
mid = len(l) // 2
if l[mid - 1] > l[mid]:
return peak_1_d(l[:mid])
elif l[mid + 1] > l[mid]:
return peak_1_d(l[mid + 1:])
else:
return l[mid]
d... |
# problem : https://leetcode.com/problems/binary-tree-postorder-traversal/
# time complexity : O(N)
# data structure : stack
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def postord... | class Solution:
def postorder_traversal(self, root: TreeNode) -> List[int]:
ans = []
s = [(root, 0)]
while len(s) > 0:
(node, appear_cnt) = s.pop()
if node is None:
continue
if appearCnt == 0:
s.append((node, 1))
... |
#
# PySNMP MIB module GARP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/GARP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:04:38 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, 09:23:1... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_intersection, constraints_union) ... |
class IIDError:
INTERNAL_ERROR = 'internal-error'
UNKNOWN_ERROR = 'unknown-error'
ERROR_CODES = {
400: 'invalid-argument',
401: 'authentication-error',
403: 'authentication-error',
500: INTERNAL_ERROR,
503: 'server-unavailable'
}
| class Iiderror:
internal_error = 'internal-error'
unknown_error = 'unknown-error'
error_codes = {400: 'invalid-argument', 401: 'authentication-error', 403: 'authentication-error', 500: INTERNAL_ERROR, 503: 'server-unavailable'} |
a, b, n = (int(i) for i in raw_input().split())
if n == 1: print(a)
elif n == 2: print(b)
else:
for x in range(2, n):
tn = a + b*b
a = b
b = tn
print(tn)
| (a, b, n) = (int(i) for i in raw_input().split())
if n == 1:
print(a)
elif n == 2:
print(b)
else:
for x in range(2, n):
tn = a + b * b
a = b
b = tn
print(tn) |
# Name : Exercise7-2.py
# Author : Ryan Carr
# Date : 02/03/19
# Purpose : Open a file, calculate average spam confidence
# Display result to user
# Text files are stored in the data folder one level up
filename = input('Enter a filename: ')
if filename == 'mbox-short.txt':
filename = '../data/mbo... | filename = input('Enter a filename: ')
if filename == 'mbox-short.txt':
filename = '../data/mbox-short.txt'
elif filename == 'mbox.txt':
filename = '../data/mbox.txt'
fh = open(filename, 'r')
count = 0
total = 0.0
for line in fh:
if not line.startswith('X-DSPAM-Confidence:'):
continue
position =... |
#
# PySNMP MIB module CISCO-BITS-CLOCK-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-BITS-CLOCK-CAPABILITY
# Produced by pysmi-0.3.4 at Mon Apr 29 17:34:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, constraints_intersection, value_size_constraint) ... |
# https://www.acmicpc.net/problem/16167
class Node:
def __init__(self, node, cost):
self.node = node
self.cost = cost
def __lt__(self, other):
return self.cost < other.cost
def bfs():
queue = __import__('collections').deque()
queue.append(1)
cnt = 1
while queue:
... | class Node:
def __init__(self, node, cost):
self.node = node
self.cost = cost
def __lt__(self, other):
return self.cost < other.cost
def bfs():
queue = __import__('collections').deque()
queue.append(1)
cnt = 1
while queue:
size = len(queue)
cnt += 1
... |
LEVEL_MAP = [
' ',
' ',
' XX ',
' XX XXX XX XX ',
' XX P XX ',
' XXXX XX XX ',
' XXXX XX ... | level_map = [' ', ' ', ' XX ', ' XX XXX XX XX ', ' XX P XX ', ' XXXX XX XX ', ' XXXX XX ... |
{
'targets': [
{
'target_name': 'example1',
'sources': ['manifest.c'],
'libraries': [
'../../target/release/libnapi_example1.a',
],
'include_dirs': [
'../napi/include'
]
}
]
}
| {'targets': [{'target_name': 'example1', 'sources': ['manifest.c'], 'libraries': ['../../target/release/libnapi_example1.a'], 'include_dirs': ['../napi/include']}]} |
#!/usr/bin/python3
Rectangle = __import__('1-rectangle').Rectangle
my_rectangle = Rectangle(4)
print("{} - {}".format(my_rectangle.width, my_rectangle.height))
| rectangle = __import__('1-rectangle').Rectangle
my_rectangle = rectangle(4)
print('{} - {}'.format(my_rectangle.width, my_rectangle.height)) |
# Problem 1 - Paying Debt off in a Year
def calculateBalance(balance, annualInterestRate, monthlyPaymentRate):
'''
Input:
balance: integer or float - the outstanding balance on the credit card
annualInterestRate: float - annual interest rate as a decimal
monthlyPaymentRate: float - mi... | def calculate_balance(balance, annualInterestRate, monthlyPaymentRate):
"""
Input:
balance: integer or float - the outstanding balance on the credit card
annualInterestRate: float - annual interest rate as a decimal
monthlyPaymentRate: float - minimum monthly payment rate as a decimal
... |
# ControlRequest
RESPONSE_sendControlRequestTrue = (
'CMD M601 Received.\r\nControl Success V2.1.\r\nok\r\n'
)
RESPONSE_sendControlRequestFalse = (
'CMD M601 Received.\r\nControl failed.\r\nok\r\n'
)
# ControlRelease
RESPONSE_sendControlRelease = (
'CMD 602 Received.\r\nok\r\n'
)
# InfoRequest
RESPONSE_s... | response_send_control_request_true = 'CMD M601 Received.\r\nControl Success V2.1.\r\nok\r\n'
response_send_control_request_false = 'CMD M601 Received.\r\nControl failed.\r\nok\r\n'
response_send_control_release = 'CMD 602 Received.\r\nok\r\n'
response_send_info_request = 'CMD M115 Received.\r\nMachine Type: Flashforge ... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# JTSK-350112
# complex.py
# Shun-Lung Chang
# sh.chang@jacobs-university.de
class Complex(object):
def __init__(self, real, imag):
self._real = real
self._imag = imag
def __add__(self, other):
if type(self) != type(other):
... | class Complex(object):
def __init__(self, real, imag):
self._real = real
self._imag = imag
def __add__(self, other):
if type(self) != type(other):
raise raise_type_error('Type of {0} is not same as Type of {1}'.format(type(self), type(other)))
return complex(self._r... |
def gc_genome_skew(dna):
gc_skew=[]
gc_diff=0
for i in range(len(dna)):
gc_skew.append(gc_diff)
if dna[i]=='C':
gc_diff-=1
if dna[i]=='G':
gc_diff+=1
oric_list=[]
min_value = min(gc_skew)
for i in range(len(gc_skew)):
if(gc_s... | def gc_genome_skew(dna):
gc_skew = []
gc_diff = 0
for i in range(len(dna)):
gc_skew.append(gc_diff)
if dna[i] == 'C':
gc_diff -= 1
if dna[i] == 'G':
gc_diff += 1
oric_list = []
min_value = min(gc_skew)
for i in range(len(gc_skew)):
if gc_sk... |
fibonacci_cache= {}
def fibonacci(n):
# If we have cached the value, then return it
if n in fibonacci_cache:
return fibonacci_cache[n]
# Compute the Nth term
if n == 1:
value = 1
elif n == 2:
value = 1
elif n >2:
value = fibonacci(n-1) + fibonacci(n-2)
#Cache the value and return it
f... | fibonacci_cache = {}
def fibonacci(n):
if n in fibonacci_cache:
return fibonacci_cache[n]
if n == 1:
value = 1
elif n == 2:
value = 1
elif n > 2:
value = fibonacci(n - 1) + fibonacci(n - 2)
fibonacci_cache[n] = value
return value
for n in range(1, 101):
print... |
x = [0.0, 3.0, 5.0, 2.5, 3.7] #an array is a list of numbers
print(type(x))
#removing the third element
x.pop(2) #it pops off the (index)
print(x)
#removes the 2.5 element
x.remove(2.5)
print(x)
#add an element to the end
x.append(1.2)
print(x)
#get a copy
y = x.copy() #produces a 'deep' ... | x = [0.0, 3.0, 5.0, 2.5, 3.7]
print(type(x))
x.pop(2)
print(x)
x.remove(2.5)
print(x)
x.append(1.2)
print(x)
y = x.copy()
print(y)
print(y.count(0.0))
print(y.index(3.7))
y[0] = 5.9
print(y)
y.sort()
print(y)
y.reverse()
print(y)
y.clear()
print(y) |
def imc(a,p):
return p / (a**2)
peso = float(input("Digite seu peso: "))
altura = float(input("Digite sua altura: "))
imc = imc(altura, peso)
if(imc < 17):
print("Muito abaixo do peso\n")
elif(imc >= 17 and imc <= 18.49):
print("Abaixo do peso\n")
elif(imc >= 18.5 and imc < 25):
print("Peso normal\n")
... | def imc(a, p):
return p / a ** 2
peso = float(input('Digite seu peso: '))
altura = float(input('Digite sua altura: '))
imc = imc(altura, peso)
if imc < 17:
print('Muito abaixo do peso\n')
elif imc >= 17 and imc <= 18.49:
print('Abaixo do peso\n')
elif imc >= 18.5 and imc < 25:
print('Peso normal\n')
eli... |
# DO NOT EDIT -- GENERATED BY CMake -- Change the CMakeLists.txt file if needed
bigtable_client_unit_tests = [
"admin_client_test.cc",
"app_profile_config_test.cc",
"bigtable_version_test.cc",
"cell_test.cc",
"client_options_test.cc",
"cluster_config_test.cc",
"column_family_test.cc",
"c... | bigtable_client_unit_tests = ['admin_client_test.cc', 'app_profile_config_test.cc', 'bigtable_version_test.cc', 'cell_test.cc', 'client_options_test.cc', 'cluster_config_test.cc', 'column_family_test.cc', 'completion_queue_test.cc', 'data_client_test.cc', 'filters_test.cc', 'force_sanitizer_failures_test.cc', 'grpc_err... |
# Assign functions to a variable
def add(a, b):
return a + b
plus = add
value = plus(1, 2)
print(value) # 3
# Lambda
value = (lambda a, b: a + b)(1, 2)
print(value) # 3
addition = lambda a, b: a + b
value = addition(1, 2)
print(value) # 3
authors = [
'Octavia Butler',
'Isaac Asimov',
'Neal Stephens... | def add(a, b):
return a + b
plus = add
value = plus(1, 2)
print(value)
value = (lambda a, b: a + b)(1, 2)
print(value)
addition = lambda a, b: a + b
value = addition(1, 2)
print(value)
authors = ['Octavia Butler', 'Isaac Asimov', 'Neal Stephenson', 'Margaret Atwood', 'Usula K Le Guin', 'Ray Bradbury']
sorted_author... |
# my_script
print(f"My __name__ is: {__name__}")
def i_am_main():
print("I'm main!")
def i_am_imported():
print("I'm iported!")
if __name__ == "__main__":
i_am_main()
else:
i_am_imported()
| print(f'My __name__ is: {__name__}')
def i_am_main():
print("I'm main!")
def i_am_imported():
print("I'm iported!")
if __name__ == '__main__':
i_am_main()
else:
i_am_imported() |
#!/usr/bin/env python
'''
* Author : Hutter Valentin
* Date : 08.05.2019
* Description : Hector agent monitoring
* Help : ANSI color from https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python
'''
class colors:
HEADER = '\033[95m'
BLUE = '\033[94m'
CBLUE = '\33[34m'... | """
* Author : Hutter Valentin
* Date : 08.05.2019
* Description : Hector agent monitoring
* Help : ANSI color from https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-terminal-in-python
"""
class Colors:
header = '\x1b[95m'
blue = '\x1b[94m'
cblue = '\x1b[34m'
green = '\x1b[92m... |
print("analise estatistico de grupos")
somaid =0
feminino =0
masculino =0
while True:
print("_"*20)
idade = int(input("Informe sua idade:"))
sexo = str(input("informe seu sexo:[M/F]")).upper()
print("-"*20)
if idade >= 18:
somaid = somaid + 1
if sexo == "M":
masculino = masculi... | print('analise estatistico de grupos')
somaid = 0
feminino = 0
masculino = 0
while True:
print('_' * 20)
idade = int(input('Informe sua idade:'))
sexo = str(input('informe seu sexo:[M/F]')).upper()
print('-' * 20)
if idade >= 18:
somaid = somaid + 1
if sexo == 'M':
masculino = ma... |
def test_get_symbols(xtb_client):
symbols = list(xtb_client.get_all_symbols())
assert len(symbols) > 0
def test_get_balance(xtb_client):
balance = xtb_client.get_balance()
assert balance.get('balance') is not None
def test_ping(xtb_client):
response = xtb_client.ping()
assert response
| def test_get_symbols(xtb_client):
symbols = list(xtb_client.get_all_symbols())
assert len(symbols) > 0
def test_get_balance(xtb_client):
balance = xtb_client.get_balance()
assert balance.get('balance') is not None
def test_ping(xtb_client):
response = xtb_client.ping()
assert response |
#Solution code for exercise 1
#We make a loop to make the element by element product of two lists, we then compare to numpy
def list_product(list1,list2):
new_list=list1
if(len(list1)==len(list2)):
try:
for i,row in enumerate(list1):
for j,el in enumerate(row):
... | def list_product(list1, list2):
new_list = list1
if len(list1) == len(list2):
try:
for (i, row) in enumerate(list1):
for (j, el) in enumerate(row):
new_list[i][j] = list1[i][j] * list2[i][j]
except:
print('Both arrays should have the sa... |
#Verificar si un numero es cuadrado
#sin usar metodo sqrt
def findSqrt (num):
l=0
r=num-1
while l<=r:
mid = l+(r-l)//2
if mid*mid == num:
return True
if mid*mid < num:
l=mid+1
if mid*mid > num:
r=mid-1
return False
print(findSqrt(14)) | def find_sqrt(num):
l = 0
r = num - 1
while l <= r:
mid = l + (r - l) // 2
if mid * mid == num:
return True
if mid * mid < num:
l = mid + 1
if mid * mid > num:
r = mid - 1
return False
print(find_sqrt(14)) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def isValidBST(self, root: TreeNode) -> bool:
self.prev = None
def valid(node):
if node:
if n... | class Solution:
def is_valid_bst(self, root: TreeNode) -> bool:
self.prev = None
def valid(node):
if node:
if not valid(node.left):
return False
if self.prev and self.prev.val >= node.val:
return False
... |
class Solution:
def lengthOfLastWord(self, s: str) -> int:
s = s.strip()
wordList = s.split(' ')
try:
lastWord = wordList[-1]
return len(lastWord)
except IndexError:
return 0
sol = Solution()
print(sol.lengthOfLastWord("hello world"))
| class Solution:
def length_of_last_word(self, s: str) -> int:
s = s.strip()
word_list = s.split(' ')
try:
last_word = wordList[-1]
return len(lastWord)
except IndexError:
return 0
sol = solution()
print(sol.lengthOfLastWord('hello world')) |
class A:
def method(self):
print('This belongs to class A')
class B(A):
def method(self):
print('This belongs to class B')
pass
class C(A):
def method(self):
print('This belongs to class C')
pass
class D(B,C):
def method(self):
p... | class A:
def method(self):
print('This belongs to class A')
class B(A):
def method(self):
print('This belongs to class B')
pass
class C(A):
def method(self):
print('This belongs to class C')
pass
class D(B, C):
def method(self):
print('This belongs to class... |
def astr(jour, mois):
if (mois == 3 and (jour >= 21 and jour <= 31)) or (mois == 4 and (jour >= 1 and jour <= 20)):
return "Belier"
elif (mois == 4 and (jour >= 21 and jour <= 30) or (mois == 5 and (jour >= 1 and jour <= 21))):
return "Taureau"
elif (mois == 5 and (jour >= 22 and jo... | def astr(jour, mois):
if mois == 3 and (jour >= 21 and jour <= 31) or (mois == 4 and (jour >= 1 and jour <= 20)):
return 'Belier'
elif mois == 4 and (jour >= 21 and jour <= 30) or (mois == 5 and (jour >= 1 and jour <= 21)):
return 'Taureau'
elif mois == 5 and (jour >= 22 and jour <= 31) or (... |
class Solution:
def flipAndInvertImage(self, image: List[List[int]]) -> List[List[int]]:
image_width = len(image)
for idx, row in enumerate(image):
image[idx] = []
for element in row:
image[idx] = [1 - element] + image[idx]
return image | class Solution:
def flip_and_invert_image(self, image: List[List[int]]) -> List[List[int]]:
image_width = len(image)
for (idx, row) in enumerate(image):
image[idx] = []
for element in row:
image[idx] = [1 - element] + image[idx]
return image |
N = int(input())
odds = [i for i in range(1, N+1) if i % 2 != 0]
result = []
for odd in odds:
z = []
for i in range(1, odd+1):
if odd % i == 0:
z.append(i)
if len(z) == 8:
result.append(z)
print(len(result))
| n = int(input())
odds = [i for i in range(1, N + 1) if i % 2 != 0]
result = []
for odd in odds:
z = []
for i in range(1, odd + 1):
if odd % i == 0:
z.append(i)
if len(z) == 8:
result.append(z)
print(len(result)) |
# 11 - Given 2 (integer) lists, calculate if they're equal element by element and print it on the terminal.
equal = True
L1 = [67, 82, 100, 28, 22, 68]
L2 = [18, 27, 33, 13, 83, 61]
n = len(L1)
for i in range(0, n):
if L1[i] != L2[i]:
equal = False
if equal:
print("Lists are equal.")
else:
print("Lists a... | equal = True
l1 = [67, 82, 100, 28, 22, 68]
l2 = [18, 27, 33, 13, 83, 61]
n = len(L1)
for i in range(0, n):
if L1[i] != L2[i]:
equal = False
if equal:
print('Lists are equal.')
else:
print("Lists aren't equal.") |
# pylint: disable=invalid-name
VERSION = '1.0'
default_app_config = 'django_walletpass.apps.DjangoWalletpassConfig'
| version = '1.0'
default_app_config = 'django_walletpass.apps.DjangoWalletpassConfig' |
#
# Example file for working with conditional statements
# (For Python 3.x, be sure to use the ExampleSnippets3.txt file)
def main():
x, y = 10, 100
if x < y :
str = "x is less than y"
elif x > y:
str = "y is less than x";
else:
str = "x is equal to y"
print(str)
st =... | def main():
(x, y) = (10, 100)
if x < y:
str = 'x is less than y'
elif x > y:
str = 'y is less than x'
else:
str = 'x is equal to y'
print(str)
st = 'x is less than y' if x < y else 'x is greater than or equal to y'
print(st)
if __name__ == '__main__':
main() |
# Trie Node
class TrieNode:
def __init__(self, letter):
self.letter = letter
self.children = {}
self.is_end_of_word = False
class Trie:
def __init__(self):
self.root = TrieNode("*") # Root node
# -----------------------------------------------------------------------... | class Trienode:
def __init__(self, letter):
self.letter = letter
self.children = {}
self.is_end_of_word = False
class Trie:
def __init__(self):
self.root = trie_node('*')
def add(self, word):
curr_node = self.root
for letter in word:
if letter ... |
#
# PySNMP MIB module AT-DHCPSN-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-DHCPSN-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:29:42 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint, constraints_union) ... |
# From dashcore-lib
class SimplifiedMNList:
pass
class SimplifiedMNListDiff:
pass
class MerkleBlock:
pass
class BlockHeader:
pass
| class Simplifiedmnlist:
pass
class Simplifiedmnlistdiff:
pass
class Merkleblock:
pass
class Blockheader:
pass |
# SPDX-License-Identifier: BSD-3-Clause
__all__ = (
'guid',
'GPT_PART_TYPES',
'UEFI_CORE_PART_TYPES' , 'WINDOWS_PART_TYPES' , 'HPUX_PART_TYPES' ,
'LINUX_PART_TYPES' , 'FREEBSD_PART_TYPES' , 'DARWIN_PART_TYPES' ,
'SOLARIS_PART_TYPES' , 'NETBSD_PART_TYPES' , 'CHROMEOS_PART_TYPES' ,
'COREOS_... | __all__ = ('guid', 'GPT_PART_TYPES', 'UEFI_CORE_PART_TYPES', 'WINDOWS_PART_TYPES', 'HPUX_PART_TYPES', 'LINUX_PART_TYPES', 'FREEBSD_PART_TYPES', 'DARWIN_PART_TYPES', 'SOLARIS_PART_TYPES', 'NETBSD_PART_TYPES', 'CHROMEOS_PART_TYPES', 'COREOS_PART_TYPES', 'HAIKU_PART_TYPES', 'MIDNIGHT_PART_TYPES', 'CEPH_PART_TYPES', 'OPENB... |
def echo(user , lang , sys) :
print('User:', user, 'Language:', lang, 'Platform:', sys)
echo('Mike' , 'Python' , 'Window')
echo(lang = 'Python' , sys = 'Mac OS' , user = 'Anne')
def mirror(user = 'Carole' , lang = 'Python') :
print('\nUser:' , user , 'Language:' , lang)
mirror()
mirror(lang = 'Java')
mirro... | def echo(user, lang, sys):
print('User:', user, 'Language:', lang, 'Platform:', sys)
echo('Mike', 'Python', 'Window')
echo(lang='Python', sys='Mac OS', user='Anne')
def mirror(user='Carole', lang='Python'):
print('\nUser:', user, 'Language:', lang)
mirror()
mirror(lang='Java')
mirror(user='Tony')
mirror('Susan... |
numbers = []
while True:
num = input('Enter a number: ')
if num == 'done':
break
try:
num = int(num)
numbers.append(num)
except ValueError:
print('Invalid input')
largest = max(numbers)
smallest = min(numbers)
print(f'Maximum is {largest}')
print(f'Minimum is {smallest}')... | numbers = []
while True:
num = input('Enter a number: ')
if num == 'done':
break
try:
num = int(num)
numbers.append(num)
except ValueError:
print('Invalid input')
largest = max(numbers)
smallest = min(numbers)
print(f'Maximum is {largest}')
print(f'Minimum is {smallest}') |
def reverseLeftWords(s: str, n: int) -> str:
return s[n:] + s[:n]
def reverseLeftWords(s: str, n: int) -> str:
str_list = []
length = len(s)
for i in range(n, n + length):
str_list.append(s[i % length])
return ''.join(str_list)
| def reverse_left_words(s: str, n: int) -> str:
return s[n:] + s[:n]
def reverse_left_words(s: str, n: int) -> str:
str_list = []
length = len(s)
for i in range(n, n + length):
str_list.append(s[i % length])
return ''.join(str_list) |
# O(log n)
def recursiveBinarySearch(vector, left_index, right_index, wanted):
if left_index <= right_index:
pivot = round(left_index + (right_index - left_index) / 2)
if (vector[pivot] == wanted): return pivot
elif vector[pivot] < wanted:
return recursiveBinarySearch(vector, pivot+1, right_index... | def recursive_binary_search(vector, left_index, right_index, wanted):
if left_index <= right_index:
pivot = round(left_index + (right_index - left_index) / 2)
if vector[pivot] == wanted:
return pivot
elif vector[pivot] < wanted:
return recursive_binary_search(vector, ... |
with open('assets/day09.txt', 'r') as file:
lines = [line for line in file.read().splitlines()]
depths = [[9] + [int(d) for d in line] + [9] for line in lines]
depths = [[9] * len(depths[0])] + depths + [[9] * len(depths[0])]
minimums = []
for y in range(1, len(depths) - 1):
for x in range(1, len(depths[y]) ... | with open('assets/day09.txt', 'r') as file:
lines = [line for line in file.read().splitlines()]
depths = [[9] + [int(d) for d in line] + [9] for line in lines]
depths = [[9] * len(depths[0])] + depths + [[9] * len(depths[0])]
minimums = []
for y in range(1, len(depths) - 1):
for x in range(1, len(depths[y]) - 1... |
# Copyright 2020 Joshua Laniado and Todd O. Yeates.
__author__ = "Joshua Laniado and Todd O. Yeates"
__copyright__ = "Copyright 2020, Nanohedra"
__version__ = "1.0"
# SYMMETRY COMBINATION MATERIAL TABLE (T.O.Y and J.L, 2020)
sym_comb_dict = {
1: [1, 'C2', 1, ['r:<0,0,1,a>', 't:<0,0,b>'], 2, '<0,0,0>', 'C2', 1, ['r... | __author__ = 'Joshua Laniado and Todd O. Yeates'
__copyright__ = 'Copyright 2020, Nanohedra'
__version__ = '1.0'
sym_comb_dict = {1: [1, 'C2', 1, ['r:<0,0,1,a>', 't:<0,0,b>'], 2, '<0,0,0>', 'C2', 1, ['r:<0,0,1,c>', 't:<0,0,d>'], 1, '<0,0,0>', 'D2', 'D2', 0, 'N/A', 4, 2], 2: [2, 'C2', 1, ['r:<0,0,1,a>', 't:<0,0,b>'], 1,... |
n, k = map(int, input().split())
y = sorted(map(int, input().split()))
sol = 0
for i in y:
if k <= (5-i):
sol += 1
print(sol//3)
| (n, k) = map(int, input().split())
y = sorted(map(int, input().split()))
sol = 0
for i in y:
if k <= 5 - i:
sol += 1
print(sol // 3) |
# Enter your code here. Read input from STDIN. Print output to STDOUT
#with name and number input, divide both and enter into dict
phonebook = {}
number = int(input())
for _ in range(0, number):
item = str(input()).split(" ")
name = item[0]
phonenumber = int(item[1])
phonebook[name] = phonenumber
#... | phonebook = {}
number = int(input())
for _ in range(0, number):
item = str(input()).split(' ')
name = item[0]
phonenumber = int(item[1])
phonebook[name] = phonenumber
for i in range(0, number):
name = input()
if name in phonebook:
print(name + '=' + str(phonebook[name]))
else:
... |
{
"targets":[
{
"target_name":"pcap_addon",
"sources":[
"./src/winpcap/pcap_addon.cc",
"./src/winpcap/pcapObjFactory.cc",
"./src/winpcap/commLib.cc"],
"include_dirs": [
"<!(node -e \"require('nan')\")",
... | {'targets': [{'target_name': 'pcap_addon', 'sources': ['./src/winpcap/pcap_addon.cc', './src/winpcap/pcapObjFactory.cc', './src/winpcap/commLib.cc'], 'include_dirs': ['<!(node -e "require(\'nan\')")', 'lib/winpcap/include', 'lib/winpcap/include/pcap', 'src/winpcap/include'], 'defines': ['HAVE_REMOTE'], 'conditions': [[... |
# coding: utf-8
# file generated by setuptools_scm
# don't change, don't track in version control
version = '1.9.0'
version_tuple = (1, 9, 0)
| version = '1.9.0'
version_tuple = (1, 9, 0) |
LINKING_PROPERTY = "Transaction/generated/LinkedTransactionId"
INPUT_TXN_FILTER = "type in 'Buy','Purchase','Sell','FwdFxSell', 'FwdFxBuy','FxBuy','FxSell','StockIn'"
ENTITY_PROPERTY = "Portfolio/test/Entity"
BROKER_PROPERTY = "Portfolio/test/Broker"
COUNTRY_PROPERTY = "Instrument/test/Country"
PROPERTIES_REQUIRED = [... | linking_property = 'Transaction/generated/LinkedTransactionId'
input_txn_filter = "type in 'Buy','Purchase','Sell','FwdFxSell', 'FwdFxBuy','FxBuy','FxSell','StockIn'"
entity_property = 'Portfolio/test/Entity'
broker_property = 'Portfolio/test/Broker'
country_property = 'Instrument/test/Country'
properties_required = [E... |
class Solution:
def reformatNumber(self, number: str) -> str:
number = number.replace(' ','')
number = number.replace('-','')
output = ''
count = len(number)
remain = count % 3
print(remain)
if remain == 0:
last = number[len(numbe... | class Solution:
def reformat_number(self, number: str) -> str:
number = number.replace(' ', '')
number = number.replace('-', '')
output = ''
count = len(number)
remain = count % 3
print(remain)
if remain == 0:
last = number[len(number) - 3:]
... |
numero = int(input('digite um numero: '))
u = numero // 1 % 10
d = numero // 10 % 10
c = numero // 100 % 10
m = numero // 1000 % 10
print('analisando numero {}'.format(numero))
print('unidades: {}'.format(u))
print('dezenas: {}'.format(d))
print('centenas: {}'.format(c))
print('milhares: {}'.format(m))
| numero = int(input('digite um numero: '))
u = numero // 1 % 10
d = numero // 10 % 10
c = numero // 100 % 10
m = numero // 1000 % 10
print('analisando numero {}'.format(numero))
print('unidades: {}'.format(u))
print('dezenas: {}'.format(d))
print('centenas: {}'.format(c))
print('milhares: {}'.format(m)) |
SOURCE = "http://tabinstore.fr"
HEADER = "User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"
MAX_IMG_SIZE = 71680 # In Bytes
| source = 'http://tabinstore.fr'
header = 'User-Agent: Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11'
max_img_size = 71680 |
li = []
inp = input()
li = inp.split(' ' , 5)
print(1-int(li[0]),' ',1-int(li[1]),' ',2-int(li[2]),' ',2-int(li[3]),' ',2-int(li[4]),' ',8-int(li[5]), end = '')
| li = []
inp = input()
li = inp.split(' ', 5)
print(1 - int(li[0]), ' ', 1 - int(li[1]), ' ', 2 - int(li[2]), ' ', 2 - int(li[3]), ' ', 2 - int(li[4]), ' ', 8 - int(li[5]), end='') |
x,y = 8, 4
if x > y:
print("x es mayor que y")
print("x es el doble de y")
if x > y:
print("x es mayor que y")
else:
print("x es menor o igual que y")
if x < y:
print("x es menor que y")
elif x == y:
print("x es igual a y")
else:
print("x es mayor que y") | (x, y) = (8, 4)
if x > y:
print('x es mayor que y')
print('x es el doble de y')
if x > y:
print('x es mayor que y')
else:
print('x es menor o igual que y')
if x < y:
print('x es menor que y')
elif x == y:
print('x es igual a y')
else:
print('x es mayor que y') |
set_name(0x8012EA14, "GameOnlyTestRoutine__Fv", SN_NOWARN)
set_name(0x8012EA1C, "vecleny__Fii", SN_NOWARN)
set_name(0x8012EA40, "veclenx__Fii", SN_NOWARN)
set_name(0x8012EA6C, "GetDamageAmt__FiPiT1", SN_NOWARN)
set_name(0x8012F0DC, "CheckBlock__Fiiii", SN_NOWARN)
set_name(0x8012F22C, "FindClosest__Fiii", SN_NOWARN)
set... | set_name(2148723220, 'GameOnlyTestRoutine__Fv', SN_NOWARN)
set_name(2148723228, 'vecleny__Fii', SN_NOWARN)
set_name(2148723264, 'veclenx__Fii', SN_NOWARN)
set_name(2148723308, 'GetDamageAmt__FiPiT1', SN_NOWARN)
set_name(2148724956, 'CheckBlock__Fiiii', SN_NOWARN)
set_name(2148725292, 'FindClosest__Fiii', SN_NOWARN)
set... |
#Printing stars in 'W' shape!
'''
* * *
* * * *
** **
* *
'''
i=0
j=3
for row in range(4):
for col in range(7):
if(col==0 or col==6) or (col==4 and row==1) or (col==5 and row==2):
print('*',end='')
elif row==i and col==j:
print('*', end='')
i+=1
... | """
* * *
* * * *
** **
* *
"""
i = 0
j = 3
for row in range(4):
for col in range(7):
if (col == 0 or col == 6) or (col == 4 and row == 1) or (col == 5 and row == 2):
print('*', end='')
elif row == i and col == j:
print('*', end='')
i += 1
j -=... |
def get():
return [
'const',
'var',
'import',
'require',
'using',
'load',
'from',
'as'
] | def get():
return ['const', 'var', 'import', 'require', 'using', 'load', 'from', 'as'] |
def inlookuptable(value: str, lookuptable: str):
with open(lookuptable, "r") as lookuptablestream:
for table in lookuptablestream:
if table.strip("\n") == value:
return True
return False
| def inlookuptable(value: str, lookuptable: str):
with open(lookuptable, 'r') as lookuptablestream:
for table in lookuptablestream:
if table.strip('\n') == value:
return True
return False |
# Labels for Nodes and Relationships
BOT_LABEL = "Bot"
USER_LABEL = "User"
TWEET_LABEL = "Tweet"
WROTE_LABEL = "WROTE"
RETWEET_LABEL = "RETWEETED"
QUOTE_LABEL = "QUOTED"
REPLY_LABEL = "REPLIED"
FOLLOW_LABEL = "FOLLOWS"
QUERY = "match (b:Bot) - [r] - (t:Tweet) - [r2] - (t2:Tweet)" \
"call apoc.cypher.run('with `t` as ... | bot_label = 'Bot'
user_label = 'User'
tweet_label = 'Tweet'
wrote_label = 'WROTE'
retweet_label = 'RETWEETED'
quote_label = 'QUOTED'
reply_label = 'REPLIED'
follow_label = 'FOLLOWS'
query = "match (b:Bot) - [r] - (t:Tweet) - [r2] - (t2:Tweet)call apoc.cypher.run('with `t` as t match (u:User) -[]-(t) return u, t limit 5... |
def my_first_module_func():
print('you are using my first created module')
def console_log(message):
print(message)
| def my_first_module_func():
print('you are using my first created module')
def console_log(message):
print(message) |
def cuadrado1(num1):
return num1**2
cuadrado2 = lambda num1: num1 ** 2
print(cuadrado1(5))
print(cuadrado2(5)) | def cuadrado1(num1):
return num1 ** 2
cuadrado2 = lambda num1: num1 ** 2
print(cuadrado1(5))
print(cuadrado2(5)) |
MODE_5X11 = 0b00000011
class I2cConstants:
def __init__(self):
self.I2C_ADDR = 0x60
self.CMD_SET_MODE = 0x00
self.CMD_SET_BRIGHTNESS = 0x19
self.MODE_5X11 = 0b00000011
class IS31FL3730:
def __init__(self, smbus, font):
self.bus = smbus
self.font = font
s... | mode_5_x11 = 3
class I2Cconstants:
def __init__(self):
self.I2C_ADDR = 96
self.CMD_SET_MODE = 0
self.CMD_SET_BRIGHTNESS = 25
self.MODE_5X11 = 3
class Is31Fl3730:
def __init__(self, smbus, font):
self.bus = smbus
self.font = font
self.i2cConstants = i2c... |
#Imagine you are building a compiler. Before running any code, the compiler must check that the parentheses in the program are balanced. Every opening bracket must have a corresponding closing bracket. We can approximate this using strings.
#Given a string containing just the characters '(', ')', '{', '}', '[' and ']'... | class Solution:
def close_para(self, s):
if s == '(':
return (')', False)
elif s == '{':
return ('}', False)
elif s == '[':
return (']', False)
else:
return (s, True)
def append_stack(self, c, paraStack):
paraStack.append(... |
if type(Query.target) is IfStatement:
parent = Query.target.parent
parent.beginModification('If to while')
condition = Query.target.condition
thenBranch = Query.target.thenBranch
Query.target.replaceChild(condition, Node.createNewNode('Expression', None))
Query.target.replaceChild(thenBranch, Node.createNewNode... | if type(Query.target) is IfStatement:
parent = Query.target.parent
parent.beginModification('If to while')
condition = Query.target.condition
then_branch = Query.target.thenBranch
Query.target.replaceChild(condition, Node.createNewNode('Expression', None))
Query.target.replaceChild(thenBranch, N... |
# -*- coding:utf-8 -*-
class CocoException(Exception):
pass
class CoCoRuntimeError(RuntimeError):
pass | class Cocoexception(Exception):
pass
class Cocoruntimeerror(RuntimeError):
pass |
sampleJson = {
"id": 3,
"pin": "700014",
"cgst": 3241.53,
"date": "2021-04-16",
"igst": 0,
"name": "Subhajit Paul",
"sgst": 3241.53,
"type": "S",
"email": 'nulestu@gmail.com',
"gstin": 'KKHUU654343KL8',
"phone": 9165799976,
"mobile": "7059403006",
"ref_no": "GKUS/30/2... | sample_json = {'id': 3, 'pin': '700014', 'cgst': 3241.53, 'date': '2021-04-16', 'igst': 0, 'name': 'Subhajit Paul', 'sgst': 3241.53, 'type': 'S', 'email': 'nulestu@gmail.com', 'gstin': 'KKHUU654343KL8', 'phone': 9165799976, 'mobile': '7059403006', 'ref_no': 'GKUS/30/21', 'address': '7 Dr Suresh Sarkar road Kolkata', 'p... |
def dot(data, compile_to=None):
notation_list = data.split('.')
compiling = ""
compiling += notation_list[0]
beginning_string = compile_to.split('{1}')[0]
compiling = beginning_string + compiling
dot_split = compile_to.replace(beginning_string + '{1}', '').split('{.}')
if any(len(x) > 1 for... | def dot(data, compile_to=None):
notation_list = data.split('.')
compiling = ''
compiling += notation_list[0]
beginning_string = compile_to.split('{1}')[0]
compiling = beginning_string + compiling
dot_split = compile_to.replace(beginning_string + '{1}', '').split('{.}')
if any((len(x) > 1 for... |
expected_output = {
"tag": {
"test": {
"system_id": {
"R2_xr": {
"type": {
"L1L2": {
"area_address": ["49.0001"],
"circuit_id": "R1_xe.01",
"format": "P... | expected_output = {'tag': {'test': {'system_id': {'R2_xr': {'type': {'L1L2': {'area_address': ['49.0001'], 'circuit_id': 'R1_xe.01', 'format': 'Phase V', 'interface': 'GigabitEthernet2.115', 'ip_address': ['10.12.115.2*'], 'ipv6_address': ['FE80::F816:3EFF:FE67:2452'], 'nsf': 'capable', 'priority': 64, 'state': 'up', '... |
class CliArgs(object):
def __init__(self):
self.search = []
self.all = False
self.slim = False
self.include = False
self.order = False
self.reverse = False
self.json = False
self.version = False
| class Cliargs(object):
def __init__(self):
self.search = []
self.all = False
self.slim = False
self.include = False
self.order = False
self.reverse = False
self.json = False
self.version = False |
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
# Find the sum of all the multiples of 3 or 5 below 1000.
# https://projecteuler.net/problem=1
# 1, 5, 10, 15, 20, ...
# 3, 6, 9, 12, 15, 18, 21, ...
limit = 1000
print( sum( set(range(... | limit = 1000
print(sum(set(range(5, limit, 5)).union(set(range(3, limit, 3))))) |
# Resources for an MPMCT with n controls
def mpmct_depth(n):
return 28*n - 60
def mpmct_t_c(n):
return 12*n - 20
def mpmct_t_d(n):
return 4*(n-2)
def mpmct_h_c(n):
return 4*n - 6
def mpmct_cnot_c(n):
return 24*n - 40
| def mpmct_depth(n):
return 28 * n - 60
def mpmct_t_c(n):
return 12 * n - 20
def mpmct_t_d(n):
return 4 * (n - 2)
def mpmct_h_c(n):
return 4 * n - 6
def mpmct_cnot_c(n):
return 24 * n - 40 |
class Equip():
def __init__(self, name, attribute, action):
self.name = name
self.attribute = attribute
self.action = action
class Item():
def __init__(self, name, attribute, buff):
self.name = name
self.attribute = attribute
self.buff = buff
class Attribute(dic... | class Equip:
def __init__(self, name, attribute, action):
self.name = name
self.attribute = attribute
self.action = action
class Item:
def __init__(self, name, attribute, buff):
self.name = name
self.attribute = attribute
self.buff = buff
class Attribute(dict)... |
H, W, N = map(int, input().split())
berry = [tuple(int(x) for x in input().split()) for _ in range(N)]
ans = []
for i in range(1, W+1):
up = 0
for x, y in berry:
if i * y == H * x:
break
elif i * y > H * x:
up += 1
else:
if up * 2 == N:
ans.append(... | (h, w, n) = map(int, input().split())
berry = [tuple((int(x) for x in input().split())) for _ in range(N)]
ans = []
for i in range(1, W + 1):
up = 0
for (x, y) in berry:
if i * y == H * x:
break
elif i * y > H * x:
up += 1
else:
if up * 2 == N:
ans... |
__author__ = 'lg'
a = raw_input()
if a > 0:
print('positive number')
elif a < 0:
print('negative number')
else:
print('the number is zero') | __author__ = 'lg'
a = raw_input()
if a > 0:
print('positive number')
elif a < 0:
print('negative number')
else:
print('the number is zero') |
# Advent of Code - Day 7 - Part One
def parse(input):
return [int(n) for n in input[0].split(",")]
def result(input):
positions = parse(input)
fuel_cost_options = []
for i in range(min(positions), max(positions) + 1):
movements = [abs(n - i) for n in positions]
fuel_cost_options.appe... | def parse(input):
return [int(n) for n in input[0].split(',')]
def result(input):
positions = parse(input)
fuel_cost_options = []
for i in range(min(positions), max(positions) + 1):
movements = [abs(n - i) for n in positions]
fuel_cost_options.append(sum(movements))
return min(fuel_... |
'''
6. Write a Python program to create a histogram from a given list of integers.
'''
def histogram(values):
for n in values:
output = ''
x = n
while(x > 0):
output += '*'
x = x - 1
print(output)
histogram([1,2,3,4,5,6]) | """
6. Write a Python program to create a histogram from a given list of integers.
"""
def histogram(values):
for n in values:
output = ''
x = n
while x > 0:
output += '*'
x = x - 1
print(output)
histogram([1, 2, 3, 4, 5, 6]) |
print("#######################################")
print("## AVERAGE STUDENT HEIGHT CALCULATOR ##")
print("#######################################")
#test heights: 123 149 175 183 166 179 125
student_heights = input(" Input a list of student heights:\n>> ").split()
for n in range(0, len(student_heights)):
student_hei... | print('#######################################')
print('## AVERAGE STUDENT HEIGHT CALCULATOR ##')
print('#######################################')
student_heights = input(' Input a list of student heights:\n>> ').split()
for n in range(0, len(student_heights)):
student_heights[n] = int(student_heights[n])
total =... |
i = 1
while True:
print(i)
i += 1
if i > 10:
break
| i = 1
while True:
print(i)
i += 1
if i > 10:
break |
# Copyright (c) Facebook, Inc. and its affiliates. (http://www.facebook.com)
c = (a, b)
d = {e: 1, f: 2}
fun(a, b, *c, **d)
# EXPECTED:
[
...,
BUILD_TUPLE(2),
...,
BUILD_TUPLE_UNPACK_WITH_CALL(2),
...,
CALL_FUNCTION_EX(1),
...,
]
| c = (a, b)
d = {e: 1, f: 2}
fun(a, b, *c, **d)
[..., build_tuple(2), ..., build_tuple_unpack_with_call(2), ..., call_function_ex(1), ...] |
#A program that counts the number of characters up to the first $ in a text file.
file = open("poem.txt","r")
data = file.readlines()
for index in range(len(data)):
for secondIndex in range(len(data[index])):
if data[index][secondIndex] == "$":
break
print( "Total number of chara... | file = open('poem.txt', 'r')
data = file.readlines()
for index in range(len(data)):
for second_index in range(len(data[index])):
if data[index][secondIndex] == '$':
break
print('Total number of characters up to the first $ are = ', index + secondIndex)
file.close() |
def metade(valor = 0, format = False):
resp = valor/2
return resp if format is False else money(resp)
def dobro(valor = 0, format = False):
resp = valor*2
return resp if format is False else money(resp)
def dez_porcento(valor = 0, format = False):
resp = valor + (valor*10)/100
return resp i... | def metade(valor=0, format=False):
resp = valor / 2
return resp if format is False else money(resp)
def dobro(valor=0, format=False):
resp = valor * 2
return resp if format is False else money(resp)
def dez_porcento(valor=0, format=False):
resp = valor + valor * 10 / 100
return resp if format ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.