content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# -*- coding: utf-8 -*-
# Copyright 2021 Cohesity Inc.
class TenantProxy(object):
"""Implementation of the 'TenantProxy' model.
Specifies the data for tenant proxy which has been deployed in tenant's
enviroment.
Attributes:
constituent_id (long|int): Specifies the constituent id of the prox... | class Tenantproxy(object):
"""Implementation of the 'TenantProxy' model.
Specifies the data for tenant proxy which has been deployed in tenant's
enviroment.
Attributes:
constituent_id (long|int): Specifies the constituent id of the proxy.
ip_address (string): Specifies the ip address o... |
# generated from catkin/cmake/template/order_packages.context.py.in
source_root_dir = '/home/sim2real/ep_ws/src'
whitelisted_packages = ''.split(';') if '' != '' else []
blacklisted_packages = ''.split(';') if '' != '' else []
underlay_workspaces = '/home/sim2real/carto_ws/devel_isolated/cartographer_rviz;/home/sim2rea... | source_root_dir = '/home/sim2real/ep_ws/src'
whitelisted_packages = ''.split(';') if '' != '' else []
blacklisted_packages = ''.split(';') if '' != '' else []
underlay_workspaces = '/home/sim2real/carto_ws/devel_isolated/cartographer_rviz;/home/sim2real/carto_ws/install_isolated;/home/sim2real/ep_ws/devel;/opt/ros/noet... |
#
# PySNMP MIB module CISCOSB-RMON (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-RMON
# Produced by pysmi-0.3.4 at Wed May 1 12:23:18 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,... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, single_value_constraint, value_size_constraint, value_range_constraint) ... |
#!/usr/bin/env/ python3
"""SoloLearn > Code Coach > Hovercraft"""
sales = int(input('How many did you sell? ')) * 3
expense = 21
if sales > expense:
print('Profit')
elif sales < expense:
print('Loss')
else:
print('Broke Even')
| """SoloLearn > Code Coach > Hovercraft"""
sales = int(input('How many did you sell? ')) * 3
expense = 21
if sales > expense:
print('Profit')
elif sales < expense:
print('Loss')
else:
print('Broke Even') |
class SearchResult(object):
"""Class representing a return object for a search query.
Attributes:
path: An array representing the path from a start node to the end node, empty if there is no path.
path_len: The length of the path represented by path, 0 if path is empty.
ele_gain: The cu... | class Searchresult(object):
"""Class representing a return object for a search query.
Attributes:
path: An array representing the path from a start node to the end node, empty if there is no path.
path_len: The length of the path represented by path, 0 if path is empty.
ele_gain: The cu... |
class Stats:
writes: int
reads: int
accesses: int
def __init__(self) -> None:
self.reset()
def reset(self) -> None:
self.writes = 0
self.reads = 0
self.accesses = 0
def add_reads(self, count: int = 1) -> None:
self.reads += count
self.accesses +... | class Stats:
writes: int
reads: int
accesses: int
def __init__(self) -> None:
self.reset()
def reset(self) -> None:
self.writes = 0
self.reads = 0
self.accesses = 0
def add_reads(self, count: int=1) -> None:
self.reads += count
self.accesses += ... |
colors = ['black', 'white']
sizes = ['S', 'M', 'L']
tshirts = [
(color, size)
for color in colors
for size in sizes
]
print(f"Cartesian products from {colors} and {sizes}: {tshirts}")
| colors = ['black', 'white']
sizes = ['S', 'M', 'L']
tshirts = [(color, size) for color in colors for size in sizes]
print(f'Cartesian products from {colors} and {sizes}: {tshirts}') |
class Eventseverity(basestring):
"""
EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFORMATIONAL|DEBUG
Possible values:
<ul>
<li> "emergency" - System is unusable,
<li> "alert" - Action must be taken immediately,
<li> "critical" - Critical condition,
<li> "error" ... | class Eventseverity(basestring):
"""
EMERGENCY|ALERT|CRITICAL|ERROR|WARNING|NOTICE|INFORMATIONAL|DEBUG
Possible values:
<ul>
<li> "emergency" - System is unusable,
<li> "alert" - Action must be taken immediately,
<li> "critical" - Critical condition,
<li> "error" ... |
MAX_SENTENCE = 30
MAX_ALL = 50
MAX_SENT_LENGTH=MAX_SENTENCE
MAX_SENTS=MAX_ALL
max_entity_num = 10
num = 100
num1 = 200
num2 = 100
npratio=4
| max_sentence = 30
max_all = 50
max_sent_length = MAX_SENTENCE
max_sents = MAX_ALL
max_entity_num = 10
num = 100
num1 = 200
num2 = 100
npratio = 4 |
"""
File defining the classes Normalize and Standardize used respectively to normalize and standardize the data set.
"""
class Normalize(object):
"""
Data pre-processing class to normalize data so the values are in the range [new_min, new_max].
"""
def __init__(self, min_, max_, new_min=0, new_max=1)... | """
File defining the classes Normalize and Standardize used respectively to normalize and standardize the data set.
"""
class Normalize(object):
"""
Data pre-processing class to normalize data so the values are in the range [new_min, new_max].
"""
def __init__(self, min_, max_, new_min=0, new_max=1):... |
n=1
def f(x):
print(n)
f(0) | n = 1
def f(x):
print(n)
f(0) |
# creates a list and prints it
days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
# traversing without an index
for day in days:
print(day)
# traversing with an index
for i in range(len(days)):
print(f"Day {i} is {days[i]}")
days[1] = "Lunes"
print("Day[1] is now ... | days = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
for day in days:
print(day)
for i in range(len(days)):
print(f'Day {i} is {days[i]}')
days[1] = 'Lunes'
print('Day[1] is now ', days[1])
for day in days:
print(day) |
# -*- coding: utf-8 -*-
# Memory addresses
ADDRESS_R15 = 0x400f
ADDRESS_ADC_POWER = 0x4062
ADDRESS_ADC_BATTERY = 0x4063
ADDRESS_LEVELA = 0x4064
ADDRESS_LEVELB = 0x4065
ADDRESS_PUSH_BUTTON = 0x4068
ADDRESS_COMMAND_1 = 0x4070
ADDRESS_COMMAND_2 = 0x4071
ADDRESS_MA_MIN_VALUE = 0x4086
ADDRESS_MA_MAX_VALUE = 0x4087
ADDRESS_... | address_r15 = 16399
address_adc_power = 16482
address_adc_battery = 16483
address_levela = 16484
address_levelb = 16485
address_push_button = 16488
address_command_1 = 16496
address_command_2 = 16497
address_ma_min_value = 16518
address_ma_max_value = 16519
address_current_mode = 16507
address_lcd_write_parameter_1 = 1... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 11:34:33 2019
@author: manninan
""" | """
Created on Thu Jun 13 11:34:33 2019
@author: manninan
""" |
r"""
.. include::../README.md
:start-line: 1
"""
| """
.. include::../README.md
:start-line: 1
""" |
# http://www.codewars.com/kata/55f73f66d160f1f1db000059/
def combine_names(first_name, last_name):
return "{0} {1}".format(first_name, last_name)
| def combine_names(first_name, last_name):
return '{0} {1}'.format(first_name, last_name) |
class DefaultPreferences(type):
"""The type for Default Preferences that cannot be modified"""
def __setattr__(cls, key, value):
if key == "defaults":
raise AttributeError("Cannot override defaults")
else:
return type.__setattr__(cls, key, value)
def __delattr__(c... | class Defaultpreferences(type):
"""The type for Default Preferences that cannot be modified"""
def __setattr__(cls, key, value):
if key == 'defaults':
raise attribute_error('Cannot override defaults')
else:
return type.__setattr__(cls, key, value)
def __delattr__(cl... |
# ------------------------------------------
#
# Program created by Maksim Kumundzhiev
#
#
# email: kumundzhievmaxim@gmail.com
# github: https://github.com/KumundzhievMaxim
# -------------------------------------------
BATCH_SIZE = 10
IMG_SIZE = (160, 160)
MODEL_PATH = 'checkpoints/model'
| batch_size = 10
img_size = (160, 160)
model_path = 'checkpoints/model' |
#1
num = int(input("Enter a number : "))
largest_divisor = 0
#2
for i in range(2, num):
#3
if num % i == 0:
#4
largest_divisor = i
#5
print("Largest divisor of {} is {}".format(num,largest_divisor))
| num = int(input('Enter a number : '))
largest_divisor = 0
for i in range(2, num):
if num % i == 0:
largest_divisor = i
print('Largest divisor of {} is {}'.format(num, largest_divisor)) |
class ObjectProperties:
def __init__(self, object_id, extra_data=None, ticket_type=None, quantity=None):
if extra_data:
self.extraData = extra_data
self.objectId = object_id
if ticket_type:
self.ticketType = ticket_type
if quantity:
self.quantity =... | class Objectproperties:
def __init__(self, object_id, extra_data=None, ticket_type=None, quantity=None):
if extra_data:
self.extraData = extra_data
self.objectId = object_id
if ticket_type:
self.ticketType = ticket_type
if quantity:
self.quantity ... |
class Solution:
def lengthOfLongestSubstring(self, s: str) -> int:
if len(s) == 0:
return 0
m = 1
for _ in range(len(s)):
i = 0
S = set()
for x in range(_, len(s)):
if s[x] not in S:
S.add(s... | class Solution:
def length_of_longest_substring(self, s: str) -> int:
if len(s) == 0:
return 0
m = 1
for _ in range(len(s)):
i = 0
s = set()
for x in range(_, len(s)):
if s[x] not in S:
S.add(s[x])
... |
lookup = [
(10, "x"),
(9, "ix"),
(5, "v"),
(4, "iv"),
(1, "i"),
]
def to_roman(integer):
#
"""
"""
for decimal, roman in lookup:
if decimal <= integer:
return roman + to_roman(integer - decimal)
return ""
def main():
print(to_roman(1))
print(to_ro... | lookup = [(10, 'x'), (9, 'ix'), (5, 'v'), (4, 'iv'), (1, 'i')]
def to_roman(integer):
"""
"""
for (decimal, roman) in lookup:
if decimal <= integer:
return roman + to_roman(integer - decimal)
return ''
def main():
print(to_roman(1))
print(to_roman(2))
print(to_roman(4))... |
class Stack:
def __init__(self):
self.items = []
def is_empty(self): # test to see whether the stack is empty.
return self.items == []
def push(self, item): # adds a new item to the top of the stack.
self.items.append(item)
def pop(self): # removes the top item from the sta... | class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[len(self.items) - 1]
def size(self):
... |
class Book:
def __init__(self, title, author, location):
self.title = title
self.author = author
self.location = location
self.page = 0
def turn_page(self, page):
self.page = page
| class Book:
def __init__(self, title, author, location):
self.title = title
self.author = author
self.location = location
self.page = 0
def turn_page(self, page):
self.page = page |
class Entity(object):
'''
An entity has:
- energy
- position(x,y)
- size(length, width)
An entity may have a parent entity
An entity may have child entities
'''
def __init__(
self,
p,
parent=None,
children=None):
... | class Entity(object):
"""
An entity has:
- energy
- position(x,y)
- size(length, width)
An entity may have a parent entity
An entity may have child entities
"""
def __init__(self, p, parent=None, children=None):
self.p = p
self.energy = p.getfloat('ENTITY', 'en... |
"""
https://leetcode.com/problems/longest-substring-without-repeating-characters/
Given a string, find the length of the longest substring without repeating characters.
"""
class Solution:
def lengthOfLongestSubstring(self, s):
longest = 0
longest_substr = ""
for ch in s:
if... | """
https://leetcode.com/problems/longest-substring-without-repeating-characters/
Given a string, find the length of the longest substring without repeating characters.
"""
class Solution:
def length_of_longest_substring(self, s):
longest = 0
longest_substr = ''
for ch in s:
... |
N = int(input())
A = list(map(int, input().split()))
d = {}
for i in range(N - 1):
if A[i] in d:
d[A[i]].append(i + 2)
else:
d[A[i]] = [i + 2]
for i in range(1, N + 1):
if i in d:
print(len(d[i]))
else:
print(0)
| n = int(input())
a = list(map(int, input().split()))
d = {}
for i in range(N - 1):
if A[i] in d:
d[A[i]].append(i + 2)
else:
d[A[i]] = [i + 2]
for i in range(1, N + 1):
if i in d:
print(len(d[i]))
else:
print(0) |
GENERIC = [
'Half of US adults have had family jailed',
'Judge stopped me winning election',
'Stock markets stabilise after earlier sell-off'
]
NON_GENERIC = [
'Leicester helicopter rotor controls failed',
'Pizza Express founder Peter Boizot dies aged 89',
'Senior Tory suggests vote could be d... | generic = ['Half of US adults have had family jailed', 'Judge stopped me winning election', 'Stock markets stabilise after earlier sell-off']
non_generic = ['Leicester helicopter rotor controls failed', 'Pizza Express founder Peter Boizot dies aged 89', 'Senior Tory suggests vote could be delayed'] |
class Solution:
def uniqueLetterString(self, S: str) -> int:
idxes = {ch : (-1, -1) for ch in string.ascii_uppercase}
ans = 0
for idx, ch in enumerate(S):
i, j = idxes[ch]
ans += (j - i) * (idx - j)
idxes[ch] = j, idx
for i, j in idxes.values():
... | class Solution:
def unique_letter_string(self, S: str) -> int:
idxes = {ch: (-1, -1) for ch in string.ascii_uppercase}
ans = 0
for (idx, ch) in enumerate(S):
(i, j) = idxes[ch]
ans += (j - i) * (idx - j)
idxes[ch] = (j, idx)
for (i, j) in idxes.va... |
class Image_Anotation:
def __init__(self, id, image, path_image):
self.id = id
self.FOV = [0.30,0.60]
self.image = image
self.list_roi=[]
self.list_compose_ROI=[]
self.id_roi=0
self.path_image = path_image
def set_image(self, image):
self.imag... | class Image_Anotation:
def __init__(self, id, image, path_image):
self.id = id
self.FOV = [0.3, 0.6]
self.image = image
self.list_roi = []
self.list_compose_ROI = []
self.id_roi = 0
self.path_image = path_image
def set_image(self, image):
self.im... |
NEO_HOST = "seed3.neo.org"
MAINNET_HTTP_RPC_PORT = 10332
MAINNET_HTTPS_RPC_PORT = 10331
TESTNET_HTTP_RPC_PORT = 20332
TESTNET_HTTPS_RPC_PORT = 20331
| neo_host = 'seed3.neo.org'
mainnet_http_rpc_port = 10332
mainnet_https_rpc_port = 10331
testnet_http_rpc_port = 20332
testnet_https_rpc_port = 20331 |
# first.n.squares.manual.method.py
def get_squares_gen(n):
for x in range(n):
yield x ** 2
squares = get_squares_gen(3)
print(squares.__next__()) # prints: 0
print(squares.__next__()) # prints: 1
print(squares.__next__()) # prints: 4
# the following raises StopIteration, the generator is exhausted,
# a... | def get_squares_gen(n):
for x in range(n):
yield (x ** 2)
squares = get_squares_gen(3)
print(squares.__next__())
print(squares.__next__())
print(squares.__next__())
print(squares.__next__()) |
class binary_tree:
def __init__(self):
pass
class Node(binary_tree):
__field_0 : int
__field_1 : binary_tree
__field_2 : binary_tree
def __init__(self, arg_0 : int , arg_1 : binary_tree , arg_2 : binary_tree ):
self.__field_0 = arg_0
self.__field_1 = arg_1
self.__fi... | class Binary_Tree:
def __init__(self):
pass
class Node(binary_tree):
__field_0: int
__field_1: binary_tree
__field_2: binary_tree
def __init__(self, arg_0: int, arg_1: binary_tree, arg_2: binary_tree):
self.__field_0 = arg_0
self.__field_1 = arg_1
self.__field_2 = ... |
def main():
_ = input()
string = input()
if _ == 0 or _ == 1:
return 0
if _ == 2:
if string[0] == string[1]:
return 1
return 0
last = string[0]
cnt = 0
for i in range(1, len(string)):
if string[i] == last:
cnt += 1
last = str... | def main():
_ = input()
string = input()
if _ == 0 or _ == 1:
return 0
if _ == 2:
if string[0] == string[1]:
return 1
return 0
last = string[0]
cnt = 0
for i in range(1, len(string)):
if string[i] == last:
cnt += 1
last = string... |
num = int(input("Enter a number: "))
sum = 0; size = 0; temp = num; temp2 = num
while(temp2!=0):
size += 1
temp2 = int(temp2/10)
while(temp!=0):
remainder = temp%10
sum += remainder**size
temp = int(temp/10)
if(sum == num):
print("It's an armstrong number")
else:
print("It's not an arms... | num = int(input('Enter a number: '))
sum = 0
size = 0
temp = num
temp2 = num
while temp2 != 0:
size += 1
temp2 = int(temp2 / 10)
while temp != 0:
remainder = temp % 10
sum += remainder ** size
temp = int(temp / 10)
if sum == num:
print("It's an armstrong number")
else:
print("It's not an arm... |
#!/usr/bin/env python3
"""This is a simple python3 calculator for demonstration purposes
some to-do's but we'll get to that"""
__author__ = "Sebastian Meier zu Biesen"
__copyright__ = "2000-2019 by MzB Solutions"
__email__ = "smzb@mitos-kalandiel.me"
class Calculator(object):
@property
def isDebug(self):
... | """This is a simple python3 calculator for demonstration purposes
some to-do's but we'll get to that"""
__author__ = 'Sebastian Meier zu Biesen'
__copyright__ = '2000-2019 by MzB Solutions'
__email__ = 'smzb@mitos-kalandiel.me'
class Calculator(object):
@property
def is_debug(self):
return self._isDeb... |
data_size_plus_header = 1000001
train_dir = 'train'
subset_train_dir = 'sub_train.txt'
fullfile = open(train_dir, 'r')
subfile = open(subset_train_dir,'w')
for i in range(data_size_plus_header):
subfile.write(fullfile.readline())
fullfile.close()
subfile.close()
| data_size_plus_header = 1000001
train_dir = 'train'
subset_train_dir = 'sub_train.txt'
fullfile = open(train_dir, 'r')
subfile = open(subset_train_dir, 'w')
for i in range(data_size_plus_header):
subfile.write(fullfile.readline())
fullfile.close()
subfile.close() |
long_number = "73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358... | long_number = '73167176531330624919225119674426574742355349194934969835203127745063262395783180169848018694788518438586156078911294949545950173795833195285320880551112540698747158523863050715693290963295227443043557668966489504452445231617318564030987111217223831136222989342338030813533627661428280644448664523874930358... |
class Game:
def __init__(self,span=[0,100],sub_fun="Square"):
self.span=span
self.func_dict = {
"Square":lambda x: pow(x,2),
"Odd":lambda x: 1 + (x-1)*2,
"Even":lambda x: x*2,
"Identity":lambda x: x,
"Logarithm":lambda x: pow(10,x-1)
... | class Game:
def __init__(self, span=[0, 100], sub_fun='Square'):
self.span = span
self.func_dict = {'Square': lambda x: pow(x, 2), 'Odd': lambda x: 1 + (x - 1) * 2, 'Even': lambda x: x * 2, 'Identity': lambda x: x, 'Logarithm': lambda x: pow(10, x - 1)}
self.sub_fun = self.func_dict[sub_fun... |
# -*- coding: utf-8 -*-
# @Time : 2021/01/05 22:53:23
# @Author : ddvv
# @Site : https://ddvvmmzz.github.io
# @File : about.py
# @Software: Visual Studio Code
__all__ = [
"__author__",
"__copyright__",
"__email__",
"__license__",
"__summary__",
"__title__",
"__uri__",
"__ver... | __all__ = ['__author__', '__copyright__', '__email__', '__license__', '__summary__', '__title__', '__uri__', '__version__']
__title__ = 'python_mmdt'
__summary__ = 'Python wrapper for the mmdt library'
__uri__ = 'https://github.com/a232319779/python_mmdt'
__version__ = '0.2.3'
__author__ = 'ddvv'
__email__ = 'dadavivi5... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
def main():
A,B,M = map(int,input().split())
A_prise = list(map(int,input().split()))
B_prise = list(map(int,input().split()))
Most_low_prise = min(A_prise)+min(B_prise)
for i in range(M):
x,y,c = map(int,input().split())
Post_coupon_ori... | def main():
(a, b, m) = map(int, input().split())
a_prise = list(map(int, input().split()))
b_prise = list(map(int, input().split()))
most_low_prise = min(A_prise) + min(B_prise)
for i in range(M):
(x, y, c) = map(int, input().split())
post_coupon_orientation_prise = A_prise[x - 1] +... |
#!/usr/bin/env python3
# 2018-10-13 (cc) <paul4hough@gmail.com>
'''
pips:
- testinfra
- molecule
- tox
'''
class test_role_ans_dev (object):
''' test_role_ans_dev useless class
'''
assert packages.installed(
yaml.array( pkgs[common],
pkgs[os][common],
... | """
pips:
- testinfra
- molecule
- tox
"""
class Test_Role_Ans_Dev(object):
""" test_role_ans_dev useless class
"""
assert packages.installed(yaml.array(pkgs[common], pkgs[os][common], pkgs[os][major]))
assert pips.installed()
assert validate.python('https://github.com/python/stuff') |
"""1122. Relative Sort Array"""
class Solution(object):
def relativeSortArray(self, arr1, arr2):
"""
:type arr1: List[int]
:type arr2: List[int]
:rtype: List[int]
"""
####
pos = {num:i for i, num in enumerate(arr2)}
return sorted(arr1, key=lambda x: p... | """1122. Relative Sort Array"""
class Solution(object):
def relative_sort_array(self, arr1, arr2):
"""
:type arr1: List[int]
:type arr2: List[int]
:rtype: List[int]
"""
pos = {num: i for (i, num) in enumerate(arr2)}
return sorted(arr1, key=lambda x: pos.get(... |
"""About this package."""
__all__ = [
"__title__",
"__summary__",
"__uri__",
"__version__",
"__author__",
"__email__",
"__license__",
"__copyright__",
]
__title__ = "argo-events"
__summary__ = "Community Maintained Python client for Argo Events"
__uri__ = "https://github.com/argoproj-l... | """About this package."""
__all__ = ['__title__', '__summary__', '__uri__', '__version__', '__author__', '__email__', '__license__', '__copyright__']
__title__ = 'argo-events'
__summary__ = 'Community Maintained Python client for Argo Events'
__uri__ = 'https://github.com/argoproj-labs/argo-events-client-python'
__vers... |
#
# @lc app=leetcode id=657 lang=python3
#
# [657] Robot Return to Origin
#
# https://leetcode.com/problems/robot-return-to-origin/description/
#
# algorithms
# Easy (73.67%)
# Likes: 1228
# Dislikes: 692
# Total Accepted: 274.1K
# Total Submissions: 371K
# Testcase Example: '"UD"'
#
# There is a robot starting ... | class Solution:
def judge_circle(self, moves: str) -> bool:
start = [0, 0]
for move in moves:
if move == 'U':
(start[0], start[1]) = (start[0] + 0, start[1] + 1)
elif move == 'R':
(start[0], start[1]) = (start[0] + 1, start[1] + 0)
... |
# get_incrementer.py
"""Helper function to create counter strings with a set length throughout."""
__version__ = '0.2'
__author__ = 'Rob Dupre (KU)'
def get_incrementer(num, num_digits):
if num >= 10**num_digits:
print('NUMBER IS LARGER THAN THE MAX POSSIBLE BASED ON num_digits')
return -1
els... | """Helper function to create counter strings with a set length throughout."""
__version__ = '0.2'
__author__ = 'Rob Dupre (KU)'
def get_incrementer(num, num_digits):
if num >= 10 ** num_digits:
print('NUMBER IS LARGER THAN THE MAX POSSIBLE BASED ON num_digits')
return -1
elif num > 9999999:
... |
def test_open_home_page(driver, request):
url = 'opencart/'
return driver.get("".join([request.config.getoption("--address"), url]))
element = driver.find_elements_by_xpath("//base[contains(@href, 'http://192.168.56.103/opencart/]")
assert element == 'http://192.168.56.103/opencart/'
assert driver.f... | def test_open_home_page(driver, request):
url = 'opencart/'
return driver.get(''.join([request.config.getoption('--address'), url]))
element = driver.find_elements_by_xpath("//base[contains(@href, 'http://192.168.56.103/opencart/]")
assert element == 'http://192.168.56.103/opencart/'
assert driver.f... |
"""Tests for compiler options processing functions."""
load("@bazel_skylib//lib:unittest.bzl", "asserts", "unittest")
load("//test:utils.bzl", "stringify_dict")
# buildifier: disable=bzl-visibility
load("//xcodeproj/internal:opts.bzl", "testable")
process_compiler_opts = testable.process_compiler_opts
def _process_... | """Tests for compiler options processing functions."""
load('@bazel_skylib//lib:unittest.bzl', 'asserts', 'unittest')
load('//test:utils.bzl', 'stringify_dict')
load('//xcodeproj/internal:opts.bzl', 'testable')
process_compiler_opts = testable.process_compiler_opts
def _process_compiler_opts_test_impl(ctx):
env = ... |
TOMASULO_DEFAULT_PARAMETERS = {
"num_register": 32,
"num_rob": 128,
"num_cdb": 1,
"cdb_buffer_size": 0,
"nop_latency": 1,
"nop_unit_pipelined": 1,
"integer_adder_latency": 1,
"integer_adder_rs": 5,
"integer_adder_pipelined": 0,
"float_adder_latency": 3,
"float_adder_rs": 3... | tomasulo_default_parameters = {'num_register': 32, 'num_rob': 128, 'num_cdb': 1, 'cdb_buffer_size': 0, 'nop_latency': 1, 'nop_unit_pipelined': 1, 'integer_adder_latency': 1, 'integer_adder_rs': 5, 'integer_adder_pipelined': 0, 'float_adder_latency': 3, 'float_adder_rs': 3, 'float_adder_pipelined': 1, 'float_multiplier_... |
# Definition for singly-linked list.
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def addTwoNumbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
ret = NodeLis... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
class Solution(object):
def add_two_numbers(self, l1, l2):
"""
:type l1: ListNode
:type l2: ListNode
:rtype: ListNode
"""
ret = node_list(0)
val = 0
las... |
# answer = 5
# print("please guess number between 1 and 10: ")
# guess = int(input())
#
# if guess < answer:
# print("Please guess higher")
# elif guess > answer:
# print ( "Please guess lower")
# else:
# print("You got it first time")
answer = 5
print ("Please guess number between 1 and 10: ")
guess = in... | answer = 5
print('Please guess number between 1 and 10: ')
guess = int(input())
if guess != answer:
if guess < answer:
print('Please guess higher')
guess = int(input())
if guess == answer:
print('Well done, you guessed it')
else:
print('Sorry, you have not guessed correctly')
els... |
# -*- coding: utf-8 -*-
# Copyright 2019 Cohesity Inc.
class VserverNetworkInterface(object):
"""Implementation of the 'Vserver Network Interface.' model.
Specifies information about a logical network interface on a
NetApp Vserver. The interface's IP address is the mount point for a
specific data pr... | class Vservernetworkinterface(object):
"""Implementation of the 'Vserver Network Interface.' model.
Specifies information about a logical network interface on a
NetApp Vserver. The interface's IP address is the mount point for a
specific data protocol, such as NFS or CIFS.
Attributes:
data... |
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def isPalindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
if not head or not head.next:
... | class Solution(object):
def is_palindrome(self, head):
"""
:type head: ListNode
:rtype: bool
"""
if not head or not head.next:
return True
(slow, fast) = (head, head)
while fast and fast.next:
(slow, fast) = (slow.next, fast.next.next)... |
print("linear search")
si=int(input("\nEnter the size:"))
data=list()
for i in range(0,si):
n=int(input())
data.append(n)
cot=0
print("\nEnter the number you want to search:")
val=int(input())
for i in range(0,len(data)):
if(data[i]==val):
break;
else:
cot=co... | print('linear search')
si = int(input('\nEnter the size:'))
data = list()
for i in range(0, si):
n = int(input())
data.append(n)
cot = 0
print('\nEnter the number you want to search:')
val = int(input())
for i in range(0, len(data)):
if data[i] == val:
break
else:
cot = cot + 1
print(cot... |
#Pio_prefs
prefsdict = {
###modify or add preferences below
#below are the database preferences.
"sqluser" : "user",
"sqldb" : "database",
"sqlhost" : "127.0.0.1",
#authorization must come from same address - extra security
#valid values yes/no
"staticip" : "no",
#below is to do logging of qrystmts.... | prefsdict = {'sqluser': 'user', 'sqldb': 'database', 'sqlhost': '127.0.0.1', 'staticip': 'no', 'piolog': 'yes', 'showpobj': 'no', 'showpinp': 'no', 'showppref': 'no', 'pobjerror': 'bottom', 'pobjautherrorfile': 'Pio_login.html', 'pobjautherror': 'top', 'piosiderrorfile': 'none', 'piosiderror': 'bottom', 'loginerror': '... |
# Time: O(n)
# Space: O(h)
# Definition for a binary tree node.
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
# iterative stack solution
class Solution(object):
def maxAncestorDiff(self, root):
"""
:type root: TreeNode
... | class Treenode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def max_ancestor_diff(self, root):
"""
:type root: TreeNode
:rtype: int
"""
result = 0
stack = [(root, 0, float('inf')... |
"""
Declarations for the .NET SDK Downloads URLs and version
These are the URLs to download the .NET SDKs for each of the supported operating systems. These URLs are accessible from: https://dotnet.microsoft.com/download/dotnet-core.
"""
DOTNET_SDK_VERSION = "3.1.100"
DOTNET_SDK = {
"windows": {
"url": "ht... | """
Declarations for the .NET SDK Downloads URLs and version
These are the URLs to download the .NET SDKs for each of the supported operating systems. These URLs are accessible from: https://dotnet.microsoft.com/download/dotnet-core.
"""
dotnet_sdk_version = '3.1.100'
dotnet_sdk = {'windows': {'url': 'https://download... |
'''
Module for basic averaging of system states across multiple trials.
Used in plotting.
@author: Joe Schaul <joe.schaul@gmail.com>
'''
class TrialState(object):
def __init__(self, trial_id, times, systemStates, uniqueStates, stateCounterForStateX):
self.trial_id = trial_id
self.times... | """
Module for basic averaging of system states across multiple trials.
Used in plotting.
@author: Joe Schaul <joe.schaul@gmail.com>
"""
class Trialstate(object):
def __init__(self, trial_id, times, systemStates, uniqueStates, stateCounterForStateX):
self.trial_id = trial_id
self.times = times
... |
trees = []
with open("input.txt", "r") as f:
for line in f.readlines():
trees.append(line[:-1])
# curr pos
x, y = 0, 0
count = 0
while True:
x += 3
y += 1
if y >= len(trees):
break
if trees[y][x % len(trees[y])] == '#':
count += 1
print(count) | trees = []
with open('input.txt', 'r') as f:
for line in f.readlines():
trees.append(line[:-1])
(x, y) = (0, 0)
count = 0
while True:
x += 3
y += 1
if y >= len(trees):
break
if trees[y][x % len(trees[y])] == '#':
count += 1
print(count) |
#35011
#a3_p10.py
#Miruthula Ramesh
#mramesh@jacobs-university.de
n = int(input("Enter the width"))
w = int(input("Enter the length"))
c = input("Enter a character")
space=" "
def print_frame(n, w):
for i in range(n):
if i == 0 or i == n-1:
print(w*c)
else:
pr... | n = int(input('Enter the width'))
w = int(input('Enter the length'))
c = input('Enter a character')
space = ' '
def print_frame(n, w):
for i in range(n):
if i == 0 or i == n - 1:
print(w * c)
else:
print(c + space * (w - 2) + c)
print_frame(n, w) |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 18 10:36:17 2019
@author: tuyenta
"""
s = "7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896... | """
Created on Tue Jun 18 10:36:17 2019
@author: tuyenta
"""
s = '7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622... |
a = int(input())
sum = 0
while True:
if ( a == 0):
print (int(sum))
break
if ( a <= 2):
print (-1)
break
if (a%5 != 0):
a = a - 3
sum = sum + 1
else:
sum = sum + int(a/5)
a = 0
| a = int(input())
sum = 0
while True:
if a == 0:
print(int(sum))
break
if a <= 2:
print(-1)
break
if a % 5 != 0:
a = a - 3
sum = sum + 1
else:
sum = sum + int(a / 5)
a = 0 |
"""IntegerHeap.py
Priority queues of integer keys based on van Emde Boas trees.
Only the keys are stored; caller is responsible for keeping
track of any data associated with the keys in a separate dictionary.
We use a version of vEB trees in which all accesses to subtrees
are performed indirectly through a hash table... | """IntegerHeap.py
Priority queues of integer keys based on van Emde Boas trees.
Only the keys are stored; caller is responsible for keeping
track of any data associated with the keys in a separate dictionary.
We use a version of vEB trees in which all accesses to subtrees
are performed indirectly through a hash table... |
def add_num(x, y):
return x + y
def sub_num(x, y):
return x - y
class MathFunctions(object):
pass
| def add_num(x, y):
return x + y
def sub_num(x, y):
return x - y
class Mathfunctions(object):
pass |
if __name__ == '__main__':
N = int(input())
main_list=[]
for iterate in range(N):
entered_string=input().split()
if entered_string[0] == 'insert':
main_list.insert(int(entered_string[1]),int(entered_string[2]))
elif entered_string[0] == 'print':
print(main_lis... | if __name__ == '__main__':
n = int(input())
main_list = []
for iterate in range(N):
entered_string = input().split()
if entered_string[0] == 'insert':
main_list.insert(int(entered_string[1]), int(entered_string[2]))
elif entered_string[0] == 'print':
print(mai... |
with open('input.txt', 'r') as file:
input = file.readlines()
input = [ step.split() for step in input ]
input = [ {step[0]: int(step[1])} for step in input ]
def part1():
x = 0
y = 0
for step in input:
x += step.get('forward', 0)
y += step.get('down', 0)
y -= step.get('up', 0)... | with open('input.txt', 'r') as file:
input = file.readlines()
input = [step.split() for step in input]
input = [{step[0]: int(step[1])} for step in input]
def part1():
x = 0
y = 0
for step in input:
x += step.get('forward', 0)
y += step.get('down', 0)
y -= step.get('up', 0)
... |
def f(x):
if x:
x = 1
else:
x = 'zero'
y = x
return y
f(1)
| def f(x):
if x:
x = 1
else:
x = 'zero'
y = x
return y
f(1) |
class Pattern_Twenty_Six:
'''Pattern twenty_six
***
* *
*
* ***
* *
* *
***
'''
def __init__(self, strings='*'):
if not isinstance(strings, str):
strings = str(strings)
for i in range(7):
if i i... | class Pattern_Twenty_Six:
"""Pattern twenty_six
***
* *
*
* ***
* *
* *
***
"""
def __init__(self, strings='*'):
if not isinstance(strings, str):
strings = str(strings)
for i in range(7):
if i in... |
def debug_transformer(func):
def wrapper():
print(f'Function `{func.__name__}` called')
func()
print(f'Function `{func.__name__}` finished')
return wrapper
@debug_transformer
def walkout():
print('Bye Felicia')
walkout() | def debug_transformer(func):
def wrapper():
print(f'Function `{func.__name__}` called')
func()
print(f'Function `{func.__name__}` finished')
return wrapper
@debug_transformer
def walkout():
print('Bye Felicia')
walkout() |
def preprocess(text):
text=text.replace('\n', '\n\r')
return text
def getLetter():
return open("./input/letter.txt", "r").read()
| def preprocess(text):
text = text.replace('\n', '\n\r')
return text
def get_letter():
return open('./input/letter.txt', 'r').read() |
MainWindow.clearData()
MainWindow.openPreWindow()
box = CAD.Box()
box.setName('Box_1')
box.setLocation(0,0,0)
box.setPara(10,10,10)
box.create()
cylinder = CAD.Cylinder()
cylinder.setName('Cylinder_2')
cylinder.setLocation(0,0,0)
cylinder.setRadius(5)
cylinder.setLength(10)
cylinder.setAxis(0,0,1)
cylinder... | MainWindow.clearData()
MainWindow.openPreWindow()
box = CAD.Box()
box.setName('Box_1')
box.setLocation(0, 0, 0)
box.setPara(10, 10, 10)
box.create()
cylinder = CAD.Cylinder()
cylinder.setName('Cylinder_2')
cylinder.setLocation(0, 0, 0)
cylinder.setRadius(5)
cylinder.setLength(10)
cylinder.setAxis(0, 0, 1)
cylinder.crea... |
class Parrot():
def __init__(self, squawk, is_alive=True):
self.squawk = squawk
self.is_alive = is_alive
african_grey = Parrot('Polly want a Cracker?')
norwegian_blue = Parrot('', is_alive=False)
def squawk(self):
if self.is_alive:
return self.squawk
else:
... | class Parrot:
def __init__(self, squawk, is_alive=True):
self.squawk = squawk
self.is_alive = is_alive
african_grey = parrot('Polly want a Cracker?')
norwegian_blue = parrot('', is_alive=False)
def squawk(self):
if self.is_alive:
return self.squawk
else:
return None
african... |
def solution(S, K):
# write your code in Python 3.6
day_dict = {0:'Mon', 1:'Tue', 2:'Wed', 3:'Thu', 4:'Fri', 5:'Sat', 6:'Sun'}
return day_dict[list(day_dict.values()).index(S)+K]
S='Wed'
K=2
print(solution(S,K))
| def solution(S, K):
day_dict = {0: 'Mon', 1: 'Tue', 2: 'Wed', 3: 'Thu', 4: 'Fri', 5: 'Sat', 6: 'Sun'}
return day_dict[list(day_dict.values()).index(S) + K]
s = 'Wed'
k = 2
print(solution(S, K)) |
produtos = {1: 4.0, 2: 4.5, 3: 5.0, 4: 2.0, 5: 1.5}
produto, quantidade = [int(num) for num in input().split()]
total = produtos[produto] * quantidade
print('Total: R$ {:.2f}'.format(total))
| produtos = {1: 4.0, 2: 4.5, 3: 5.0, 4: 2.0, 5: 1.5}
(produto, quantidade) = [int(num) for num in input().split()]
total = produtos[produto] * quantidade
print('Total: R$ {:.2f}'.format(total)) |
# Code Listing #3
"""
Prime number iterator class
"""
class Prime(object):
""" A prime number iterator for first 'n' primes """
def __init__(self, n):
self.n = n
self.count = 0
self.value = 0
def __iter__(self):
return self
def __next__(self):
""" Return ne... | """
Prime number iterator class
"""
class Prime(object):
""" A prime number iterator for first 'n' primes """
def __init__(self, n):
self.n = n
self.count = 0
self.value = 0
def __iter__(self):
return self
def __next__(self):
""" Return next item in iterator... |
def merge_dicts(*dicts):
"""
Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.
"""
result = {}
for d in dicts:
result.update(d)
return result
def evaluate_term(term, **kwargs):
return term.evaluate(**kwargs)... | def merge_dicts(*dicts):
"""
Given any number of dicts, shallow copy and merge into a new dict,
precedence goes to key value pairs in latter dicts.
"""
result = {}
for d in dicts:
result.update(d)
return result
def evaluate_term(term, **kwargs):
return term.evaluate(**kwargs) if... |
arr=[int(x) for x in input().split()]
sum=0
for i in range(1,(arr[2]+1)):
sum+=arr[0]*i
if sum<=arr[1]:
print(0)
else:
print(sum-arr[1])
| arr = [int(x) for x in input().split()]
sum = 0
for i in range(1, arr[2] + 1):
sum += arr[0] * i
if sum <= arr[1]:
print(0)
else:
print(sum - arr[1]) |
# Binary search of an item in a (sorted) list
def binary_search(alist, item):
first = 0
last = len(alist) - 1
found = False
while first <= last and not found:
middle = (first + last) // 2
if alist[middle] == item:
found = True
else:
if item < alist[midd... | def binary_search(alist, item):
first = 0
last = len(alist) - 1
found = False
while first <= last and (not found):
middle = (first + last) // 2
if alist[middle] == item:
found = True
elif item < alist[middle]:
last = middle - 1
else:
fi... |
"""
Experiments with infix operator dispatch
>>> kadd = KnowsAdd()
>>> kadd + 1
(<KnowsAdd object>, 1)
>>> kadd * 1
"""
class KnowsAdd:
def __add__(self, other):
return self, other
def __repr__(self):
return '<{} object>'.format(type(self).__name__)
| """
Experiments with infix operator dispatch
>>> kadd = KnowsAdd()
>>> kadd + 1
(<KnowsAdd object>, 1)
>>> kadd * 1
"""
class Knowsadd:
def __add__(self, other):
return (self, other)
def __repr__(self):
return '<{} object>'.format(type(self).__name__) |
def resolve():
'''
code here
'''
N = int(input())
A_list = [int(item) for item in input().split()]
hp = sum(A_list) #leaf
is_slove = True
res = 1 # root
prev = 1
prev_add_num = 0
delete_cnt = 0
if hp > 2**N:
is_slove = False
elif A_list[0] == 1:
i... | def resolve():
"""
code here
"""
n = int(input())
a_list = [int(item) for item in input().split()]
hp = sum(A_list)
is_slove = True
res = 1
prev = 1
prev_add_num = 0
delete_cnt = 0
if hp > 2 ** N:
is_slove = False
elif A_list[0] == 1:
if len(A_list) >=... |
class Solution:
def reverseWords(self, s: str) -> str:
s = s.split(" ")
s = [i for i in s if i != ""]
return " ".join(s[::-1]) | class Solution:
def reverse_words(self, s: str) -> str:
s = s.split(' ')
s = [i for i in s if i != '']
return ' '.join(s[::-1]) |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
# if root.left and root.right:
# if v <= root.left.val or v >= root.right.val: return False
# elif ... | class Solution:
def is_valid_bst(self, root: TreeNode) -> bool:
self.prev = None
return self.recur(root)
def recur(self, root):
if not root:
return True
left = self.recur(root.left)
if self.prev and self.prev.val >= root.val:
return False
... |
class hparams:
sample_rate = 16000
n_fft = 1024
#fft_bins = n_fft // 2 + 1
num_mels = 80
hop_length = 256
win_length = 1024
fmin = 90
fmax = 7600
min_level_db = -100
ref_level_db = 20
seq_len_factor = 64
bits = 12
seq_len = seq_len_factor * hop_length
d... | class Hparams:
sample_rate = 16000
n_fft = 1024
num_mels = 80
hop_length = 256
win_length = 1024
fmin = 90
fmax = 7600
min_level_db = -100
ref_level_db = 20
seq_len_factor = 64
bits = 12
seq_len = seq_len_factor * hop_length
dim_neck = 32
dim_emb = 256
dim_pre... |
# Material
buttonType = ['Arrow button', 'Radio button', 'Switch button', 'Option']
requestLUT = [
{
'name' : 'Radio',
'on' : 'OSD_ImgFolder/radio_on.png',
'off' : 'OSD_ImgFolder/radio_off.png',
'default' : 'off',
'hint_path' : 'OSD_ImgFolder/L4 off.png',
'hint': 0
},
{
'nam... | button_type = ['Arrow button', 'Radio button', 'Switch button', 'Option']
request_lut = [{'name': 'Radio', 'on': 'OSD_ImgFolder/radio_on.png', 'off': 'OSD_ImgFolder/radio_off.png', 'default': 'off', 'hint_path': 'OSD_ImgFolder/L4 off.png', 'hint': 0}, {'name': 'Switch', 'on': 'OSD_ImgFolder/switch_on.png', 'off': 'OSD_... |
"""8. String to Integer (atoi)
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a
challenge, please do not see below and ask yourself what are the
possible input cases.
Notes: It is intended for this problem to be specified vaguely
(ie, no given input sp... | """8. String to Integer (atoi)
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a
challenge, please do not see below and ask yourself what are the
possible input cases.
Notes: It is intended for this problem to be specified vaguely
(ie, no given input sp... |
database = "database"
user = "postgres"
password = "password"
host = "localhost"
port = "5432"
| database = 'database'
user = 'postgres'
password = 'password'
host = 'localhost'
port = '5432' |
def mul(a, b):
return a * b
mul(3, 4)
#12
def mul5(a):
return mul(5,a)
mul5(2)
#10
def mul(a):
def helper(b):
return a * b
return helper
mul(5)(2)
#10
def fun1(a):
x = a * 3
def fun2(b):
nonlocal x
return b + x
return fun2
test_fun = fun1(4)
test_fun(7)
#19
| def mul(a, b):
return a * b
mul(3, 4)
def mul5(a):
return mul(5, a)
mul5(2)
def mul(a):
def helper(b):
return a * b
return helper
mul(5)(2)
def fun1(a):
x = a * 3
def fun2(b):
nonlocal x
return b + x
return fun2
test_fun = fun1(4)
test_fun(7) |
seagate_sense_codes = {0: {0: {0: {0: 'No error.', 'L1': 'No Sense', 'L2': 'No Sense'},
31: {0: 'No Specific FRU code.',
'L1': 'No Sense',
'L2': 'Logical unit transitioning to another power condition'}},
... | seagate_sense_codes = {0: {0: {0: {0: 'No error.', 'L1': 'No Sense', 'L2': 'No Sense'}, 31: {0: 'No Specific FRU code.', 'L1': 'No Sense', 'L2': 'Logical unit transitioning to another power condition'}}, 94: {0: {0: 'No Specific FRU code.', 'L1': 'No Sense', 'L2': 'Drive is in power save mode for unknown reasons'}, 1: ... |
"""
try:
from .NotReceived import NotReceived
from .errors import *
from .classreader import *
from .checkpoint import Checkpoint
except Exception as e:
from NotReceived import NotReceived
from errors import *
from classreader import *
from checkpoint import Checkpoint
"""
"""
import sys
print(sys.path)""" | """
try:
from .NotReceived import NotReceived
from .errors import *
from .classreader import *
from .checkpoint import Checkpoint
except Exception as e:
from NotReceived import NotReceived
from errors import *
from classreader import *
from checkpoint import Checkpoint
"""
'\nimport sys\nprint(sys.path)' |
frase = str(input('Digite a frase: ')).strip().upper()
palavras = frase.split()
juntarPalavras = ''.join(palavras)
trocar = juntarPalavras[::-1]
print(trocar) | frase = str(input('Digite a frase: ')).strip().upper()
palavras = frase.split()
juntar_palavras = ''.join(palavras)
trocar = juntarPalavras[::-1]
print(trocar) |
def log_normal_pdf(sample, mean, logvar, raxis=1):
log2pi = tf.math.log(2. * np.pi)
return tf.reduce_sum(
-.5 * ((sample - mean) ** 2. * tf.exp(-logvar) + logvar + log2pi),
axis=raxis)
def compute_loss(model, x):
mean, logvar = model.encode(x)
z = model.reparameterize(mean, logvar)
x_logit = mod... | def log_normal_pdf(sample, mean, logvar, raxis=1):
log2pi = tf.math.log(2.0 * np.pi)
return tf.reduce_sum(-0.5 * ((sample - mean) ** 2.0 * tf.exp(-logvar) + logvar + log2pi), axis=raxis)
def compute_loss(model, x):
(mean, logvar) = model.encode(x)
z = model.reparameterize(mean, logvar)
x_logit = mo... |
my_name = "Jan"
my_age = 23
print(f"Age: { my_age }, Name: { my_name }")
| my_name = 'Jan'
my_age = 23
print(f'Age: {my_age}, Name: {my_name}') |
__all__ = ("ComparsionMixin", "LazyLoadMixin")
class ComparsionMixin(object):
"""
Mixin to help compare two instances
"""
def __eq__(self, other):
"""
Compare two items
"""
if not issubclass(type(other), self.__class__):
return False
if (self.bod... | __all__ = ('ComparsionMixin', 'LazyLoadMixin')
class Comparsionmixin(object):
"""
Mixin to help compare two instances
"""
def __eq__(self, other):
"""
Compare two items
"""
if not issubclass(type(other), self.__class__):
return False
if self.body == ... |
# Yunfan Ye 10423172
def Fibonacci(n):
if n == 1:
return 1
elif n == 2:
return 1
else:
return Fibonacci(n - 1) + Fibonacci(n - 2)
# arr = [1,2,3,4,5,6,7,8,9,10]
# for i in arr:
# print(Fibonacci(i))
| def fibonacci(n):
if n == 1:
return 1
elif n == 2:
return 1
else:
return fibonacci(n - 1) + fibonacci(n - 2) |
class UrlPath:
@staticmethod
def combine(*args):
result = ''
for path in args:
result += path if path.endswith('/') else '{}/'.format(path)
#result = result[:-1]
return result | class Urlpath:
@staticmethod
def combine(*args):
result = ''
for path in args:
result += path if path.endswith('/') else '{}/'.format(path)
return result |
class Error():
def __init__(self):
print("An error has occured !")
class TypeError(Error):
def __init__(self):
print("This is Type Error\nThere is a type mismatch.. ! Please fix it.") | class Error:
def __init__(self):
print('An error has occured !')
class Typeerror(Error):
def __init__(self):
print('This is Type Error\nThere is a type mismatch.. ! Please fix it.') |
class Node(object):
def __init__(self, value, next=None, prev=None):
self.value = value
self.next = next
self.prev = prev
class LinkedList(object):
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def push(self, value):
new_node... | class Node(object):
def __init__(self, value, next=None, prev=None):
self.value = value
self.next = next
self.prev = prev
class Linkedlist(object):
def __init__(self):
self.head = None
self.tail = None
self.length = 0
def push(self, value):
new_nod... |
def params_create_rels_unwind_from_objects(relationships, property_identifier=None):
"""
Format Relationship properties into a one level dictionary matching the query generated in
`query_create_rels_from_list`. This is necessary because you cannot access nested dictionairies
in the UNWIND query.
UN... | def params_create_rels_unwind_from_objects(relationships, property_identifier=None):
"""
Format Relationship properties into a one level dictionary matching the query generated in
`query_create_rels_from_list`. This is necessary because you cannot access nested dictionairies
in the UNWIND query.
UN... |
# Check if the value is in the list?
words = ['apple', 'banana', 'peach', '42']
if 'apple' in words:
print('found apple')
if 'a' in words:
print('found a')
else:
print('NOT found a')
if 42 in words:
print('found 42')
else:
print('NOT found 42')
# found apple
# NOT found a
# NOT found 42 | words = ['apple', 'banana', 'peach', '42']
if 'apple' in words:
print('found apple')
if 'a' in words:
print('found a')
else:
print('NOT found a')
if 42 in words:
print('found 42')
else:
print('NOT found 42') |
__author__ = 'renderle'
class OpenWeatherParser:
def __init__(self, data):
self.data = data
def getValueFor(self, idx):
return self.data['list'][idx]
def getTemperature(self):
earlymorningValue = self.getValueFor(0)['main']['temp_max']
morningValue = self.getValueFor(1)['... | __author__ = 'renderle'
class Openweatherparser:
def __init__(self, data):
self.data = data
def get_value_for(self, idx):
return self.data['list'][idx]
def get_temperature(self):
earlymorning_value = self.getValueFor(0)['main']['temp_max']
morning_value = self.getValueFor... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.