content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class DisconnectedError(RuntimeError):
def __init__(self):
msg = 'Must self.connect before continuing.'
RuntimeError.__init__(self, msg)
class OperationFailed(RuntimeError):
def __init__(self, op, report):
message = '{0}: {1}:{2}'.format(op, report._diagnostics, report.errors)
... | class Disconnectederror(RuntimeError):
def __init__(self):
msg = 'Must self.connect before continuing.'
RuntimeError.__init__(self, msg)
class Operationfailed(RuntimeError):
def __init__(self, op, report):
message = '{0}: {1}:{2}'.format(op, report._diagnostics, report.errors)
... |
# given an int, return the reverse of itself.
# inp: 1234
# return: 4321
# perform operation on |x| and return along with the sign of x. using built in function abs()
def reverse_int(x):
rev = 0
x_remaining=abs(x)
while x_remaining:
rev = 10*rev + x_remaining%10
x_remaining //=10
return -rev if x < 0 else r... | def reverse_int(x):
rev = 0
x_remaining = abs(x)
while x_remaining:
rev = 10 * rev + x_remaining % 10
x_remaining //= 10
return -rev if x < 0 else rev
print(reverse_int(-1234)) |
# Generated by make-pins.py, do NOT edit!
PINS_AF = (
('LED1', (0, 'LPI2C2_SCL'), (1, 'FLEXPWM1_PWMA1'), (2, 'LPUART2_TX'), (3, 'SAI1_TX_DATA2'), (5, 'GPIO1_PIN24'), ),
('LED2', (0, 'LPI2C2_SDA'), (1, 'FLEXPWM1_PWMB1'), (2, 'LPUART2_RX'), (3, 'SAI1_TX_DATA3'), (5, 'GPIO1_PIN25'), ),
('LED3', (1, 'FLEXPWM1_PWMA2')... | pins_af = (('LED1', (0, 'LPI2C2_SCL'), (1, 'FLEXPWM1_PWMA1'), (2, 'LPUART2_TX'), (3, 'SAI1_TX_DATA2'), (5, 'GPIO1_PIN24')), ('LED2', (0, 'LPI2C2_SDA'), (1, 'FLEXPWM1_PWMB1'), (2, 'LPUART2_RX'), (3, 'SAI1_TX_DATA3'), (5, 'GPIO1_PIN25')), ('LED3', (1, 'FLEXPWM1_PWMA2'), (2, 'LPUART4_TX'), (5, 'GPIO1_PIN26'), (6, 'GPT2_CA... |
"""Top-level package for telomemore."""
__author__ = """William Rosenbaum"""
__email__ = 'william.rosenbaum88@gmail.com'
__version__ = '0.0.1'
| """Top-level package for telomemore."""
__author__ = 'William Rosenbaum'
__email__ = 'william.rosenbaum88@gmail.com'
__version__ = '0.0.1' |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def numbertoampm(hour: int, minute: int) -> tuple:
"""
Convert time in hh:mm format to AM/PM.
"""
if hour < 12 or hour == 24:
period = 'AM'
else:
period = 'PM'
hour = hour % 12
if hour == 0:
hour = 12
return (hour, m... | def numbertoampm(hour: int, minute: int) -> tuple:
"""
Convert time in hh:mm format to AM/PM.
"""
if hour < 12 or hour == 24:
period = 'AM'
else:
period = 'PM'
hour = hour % 12
if hour == 0:
hour = 12
return (hour, minute, period)
def ampmtonumber(time: str) -> t... |
"""Default configuration settings"""
DEBUG = True
TESTING = False
LOGGER_NAME = 'api-server'
LOG_FILENAME = 'api-server.log'
| """Default configuration settings"""
debug = True
testing = False
logger_name = 'api-server'
log_filename = 'api-server.log' |
def add_native_methods(clazz):
def cmmLoadProfile__byte____long____(a0, a1):
raise NotImplementedError()
def cmmFreeProfile__long__(a0):
raise NotImplementedError()
def cmmGetProfileSize__long__int____(a0, a1):
raise NotImplementedError()
def cmmGetProfileData__long__byte____(... | def add_native_methods(clazz):
def cmm_load_profile__byte____long____(a0, a1):
raise not_implemented_error()
def cmm_free_profile__long__(a0):
raise not_implemented_error()
def cmm_get_profile_size__long__int____(a0, a1):
raise not_implemented_error()
def cmm_get_profile_data... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
# # Reversed Second Half == First Half (Accepted), O(n) time, O(1) space
# def isPalindrome(self, head: ListNode) -> bool:
# if not head ... | class Solution:
def is_palindrome(self, head: ListNode) -> bool:
rev = None
slow = fast = head
while fast and fast.next:
fast = fast.next.next
(rev, rev.next, slow) = (slow, rev, slow.next)
if fast:
slow = slow.next
while rev and rev.val =... |
yolo_config = {
# Basic
'img_size': (416, 416, 3),
'anchors': [12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401],
'strides': [8, 16, 32],
'xyscale': [1.2, 1.1, 1.05],
# Training
'iou_loss_thresh': 0.5,
'batch_size': 8,
'num_gpu': 1, # 2,
# Inference
... | yolo_config = {'img_size': (416, 416, 3), 'anchors': [12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401], 'strides': [8, 16, 32], 'xyscale': [1.2, 1.1, 1.05], 'iou_loss_thresh': 0.5, 'batch_size': 8, 'num_gpu': 1, 'max_boxes': 100, 'iou_threshold': 0.413, 'score_threshold': 0.3} |
ordered_counties = [18, 44, 45, 30, 39, 14, 13, 6, 12, 15, 21, 46, 5, 50, 19, 48, 4, 33, 23, 29, 27, 24, 43, 47, 11, 10, 37, 35, 31, 32, 41, 25, 20, 38, 36, 16, 7, 9, 8, 28, 2, 34, 17, 3, 1, 26, 49, 40, 42, 22]
county_lean = {}
with open('raw_data.txt') as file:
data = file.read().split('\n')
for county in data:
c... | ordered_counties = [18, 44, 45, 30, 39, 14, 13, 6, 12, 15, 21, 46, 5, 50, 19, 48, 4, 33, 23, 29, 27, 24, 43, 47, 11, 10, 37, 35, 31, 32, 41, 25, 20, 38, 36, 16, 7, 9, 8, 28, 2, 34, 17, 3, 1, 26, 49, 40, 42, 22]
county_lean = {}
with open('raw_data.txt') as file:
data = file.read().split('\n')
for county in data... |
# Copyright Contributors to the Pyro-Cov project.
# SPDX-License-Identifier: Apache-2.0
class ShardedFastaWriter:
"""
Writer that splits into multiple fasta files to avoid nextclade file size
limit.
"""
def __init__(self, filepattern, max_count=5000):
assert filepattern.count("*") == 1
... | class Shardedfastawriter:
"""
Writer that splits into multiple fasta files to avoid nextclade file size
limit.
"""
def __init__(self, filepattern, max_count=5000):
assert filepattern.count('*') == 1
self.filepattern = filepattern
self.max_count = max_count
self._file... |
"""Train/Validation/Test dataset split
The dataset needs to be split into train/val/test sets to properly validate the hypothesis.
To make sure the split is always consistent, it is hardcoded here.
All other scripts reference this file for the split ids.
"""
all_ids = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, ... | """Train/Validation/Test dataset split
The dataset needs to be split into train/val/test sets to properly validate the hypothesis.
To make sure the split is always consistent, it is hardcoded here.
All other scripts reference this file for the split ids.
"""
all_ids = [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14, 15, 1... |
load("@bazel_gazelle//:deps.bzl", "go_repository")
def pull_monitor_dependencies():
go_repository(
name = "com_github_hashicorp_errwrap",
commit = "8a6fb523712970c966eefc6b39ed2c5e74880354", # 1.0.0
importpath = "github.com/hashicorp/errwrap",
)
go_repository(
name = "com_... | load('@bazel_gazelle//:deps.bzl', 'go_repository')
def pull_monitor_dependencies():
go_repository(name='com_github_hashicorp_errwrap', commit='8a6fb523712970c966eefc6b39ed2c5e74880354', importpath='github.com/hashicorp/errwrap')
go_repository(name='com_github_hashicorp_go_multierror', commit='886a7fbe3eb1c874d... |
class Stack():
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items == []
def peek(self):
if not self.is_empty():
return self.... | class Stack:
def __init__(self):
self.items = []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def is_empty(self):
return self.items == []
def peek(self):
if not self.is_empty():
return self.items[-1]
... |
class checker():
# Similarity Checker V.0.0.8 | Made by Jekkow
def __init__(self, Set_Difference = 1, Length_Difference = 2, Minimum_Percentage = 0.75):
# Set Variables
self.Set_Difference = Set_Difference # Public Variable
self.Length_Difference = Length_Difference # Public Variab... | class Checker:
def __init__(self, Set_Difference=1, Length_Difference=2, Minimum_Percentage=0.75):
self.Set_Difference = Set_Difference
self.Length_Difference = Length_Difference
self.Minimum_Percentage = Minimum_Percentage
self.__Results = []
self.__Set_Dictionary = {}
... |
def fact (n):
if n==0:
return 1
return n*fact(n-1)
result=fact(int(input("Enter the number")))
print(result)
| def fact(n):
if n == 0:
return 1
return n * fact(n - 1)
result = fact(int(input('Enter the number')))
print(result) |
# -*- coding: utf-8 -*-
# Copyright 2021 Cohesity Inc.
class RoleNetworkInterfaceEnum(object):
"""Implementation of the 'Role_NetworkInterface' enum.
Specifies the role of this interface.
Attributes:
KPRIMARY: TODO: type description here.
KSECONDARY: TODO: type description here.
"""... | class Rolenetworkinterfaceenum(object):
"""Implementation of the 'Role_NetworkInterface' enum.
Specifies the role of this interface.
Attributes:
KPRIMARY: TODO: type description here.
KSECONDARY: TODO: type description here.
"""
kprimary = 'kPrimary'
ksecondary = 'kSecondary' |
n = int(input())
if n > 10:
print("High Five")
elif n > 0:
for i in range(n):
print("Ra!")
else:
print("shh")
| n = int(input())
if n > 10:
print('High Five')
elif n > 0:
for i in range(n):
print('Ra!')
else:
print('shh') |
# -*- coding: utf-8 -*-
# Copyright (c) 2021, Silvio Peroni <essepuntato@gmail.com>
#
# Permission to use, copy, modify, and/or distribute this software for any purpose
# with or without fee is hereby granted, provided that the above copyright notice
# and this permission notice appear in all copies.
#
# THE SOFTWARE I... | def test_f(s1, s2, s3, expected):
result = f(s1, s2, s3)
if sorted(expected) == sorted(result):
return True
else:
return False
def f(s1, s2, s3):
l_s1 = len(s1)
l_s2 = len(s2)
l_s3 = len(s3)
if l_s1 <= l_s2 and l_s1 <= l_s3:
return (s2, s3)
elif l_s2 <= l_s1 and ... |
arguments = ["self", "info", "args"]
helpstring = "host <nick>"
minlevel = 1
def main(connection, info, args) :
"""Specifies the hostname of the nick given"""
connection.msg(info["channel"], '%s: "%s"' % (info["sender"], connection.hostnames[args[1]]))
| arguments = ['self', 'info', 'args']
helpstring = 'host <nick>'
minlevel = 1
def main(connection, info, args):
"""Specifies the hostname of the nick given"""
connection.msg(info['channel'], '%s: "%s"' % (info['sender'], connection.hostnames[args[1]])) |
salario = int(input ('Salario: '))
imposto = 27.
while imposto > 0.:
imposto = input('Imposto ou (0) para sair:')
#Comando abaixo indica se a variavel imposto for vazia
if not imposto:
imposto: 27.
elif imposto == 's':
break
else:
imposto = float(imposto)
print( "Valor r... | salario = int(input('Salario: '))
imposto = 27.0
while imposto > 0.0:
imposto = input('Imposto ou (0) para sair:')
if not imposto:
imposto: 27.0
elif imposto == 's':
break
else:
imposto = float(imposto)
print('Valor real: {0}'.format(salario - salario * (imposto * 0.01))) |
class IComponent(IDisposable):
""" Provides functionality required by all components. """
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
Site = property(... | class Icomponent(IDisposable):
""" Provides functionality required by all components. """
def __init__(self, *args):
""" x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """
pass
site = property(lambda s... |
"""Non-flag command line arguments"""
def validate(args):
if isinstance(args, str):
args = [args]
return args
| """Non-flag command line arguments"""
def validate(args):
if isinstance(args, str):
args = [args]
return args |
"""
Profile ../profile-datasets-py/us76_43lev_allgas/004.py
file automaticaly created by prof_gen.py script
"""
self["ID"] = "../profile-datasets-py/us76_43lev_allgas/004.py"
self["Q"] = numpy.array([ 1.32999800e+00, 1.99999600e+00, 2.69999300e+00,
3.29998900e+00, 3.99998400e+00, 4.49998... | """
Profile ../profile-datasets-py/us76_43lev_allgas/004.py
file automaticaly created by prof_gen.py script
"""
self['ID'] = '../profile-datasets-py/us76_43lev_allgas/004.py'
self['Q'] = numpy.array([1.329998, 1.999996, 2.699993, 3.299989, 3.999984, 4.49998, 4.849976, 4.949975, 4.999975, 4.999975, 4.999975,... |
nums = [1, 2, 3, 4]
print("Before Remove: ", nums)
nums.remove(3)
print("After Remove: ", nums)
print(nums.pop())
print("After Pop", nums)
nums.extend([3, 4])
print("After Extend: ", nums)
nums.insert(0, 1)
print("After insert: ", nums)
nums.append([])
print("After append: ", nums)
| nums = [1, 2, 3, 4]
print('Before Remove: ', nums)
nums.remove(3)
print('After Remove: ', nums)
print(nums.pop())
print('After Pop', nums)
nums.extend([3, 4])
print('After Extend: ', nums)
nums.insert(0, 1)
print('After insert: ', nums)
nums.append([])
print('After append: ', nums) |
#
# PySNMP MIB module CISCO-DS3-EXT-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-DS3-EXT-CAPABILITY
# Produced by pysmi-0.3.4 at Mon Apr 29 17:38:48 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, value_size_constraint, single_value_constraint, value_range_constraint) ... |
class Cycle(object):
def __init__(self, graph):
self.cycle = None
if self.has_parallel_edges(graph):
return
self.marked = [False for _ in range(graph.v)]
self.edge_to = [0 for _ in range(graph.v)]
for v in range(graph.v):
if not self.marked[v]:
... | class Cycle(object):
def __init__(self, graph):
self.cycle = None
if self.has_parallel_edges(graph):
return
self.marked = [False for _ in range(graph.v)]
self.edge_to = [0 for _ in range(graph.v)]
for v in range(graph.v):
if not self.marked[v]:
... |
def main():
for n in range(1, 11):
print(n)
if __name__ == '__main__':
main()
| def main():
for n in range(1, 11):
print(n)
if __name__ == '__main__':
main() |
# def print_pattern():
# for i in range(1, 4):
# for j in range(i, i+1):
# print("*"*j)
def print_pattern():
for i, j in zip(range(2, -1, -1), range(1, 6, 2)):
print(" "*i + "*"*j)
if __name__ == "__main__":
print_pattern()
# *
# ***
#***** | def print_pattern():
for (i, j) in zip(range(2, -1, -1), range(1, 6, 2)):
print(' ' * i + '*' * j)
if __name__ == '__main__':
print_pattern() |
mimeDict = {'.bin': 'application/octet-stream',
'.bmp': 'image/bmp',
'.c': 'text/x-c',
'.css': 'text/css',
'.dmg': 'application/vnd.apple.installer+xml,',
'.f4v': 'video/x-f4v',
'.flv': 'video/x-flv',
'.h261': 'video/h261',
'.h263': 'video/h263',
'.h264': 'video/h264',
'.ico': 'image/x-ico... | mime_dict = {'.bin': 'application/octet-stream', '.bmp': 'image/bmp', '.c': 'text/x-c', '.css': 'text/css', '.dmg': 'application/vnd.apple.installer+xml,', '.f4v': 'video/x-f4v', '.flv': 'video/x-flv', '.h261': 'video/h261', '.h263': 'video/h263', '.h264': 'video/h264', '.ico': 'image/x-icon', '.jar': 'application/java... |
#
# @lc app=leetcode id=171 lang=python3
#
# [171] Excel Sheet Column Number
#
# @lc code=start
class Solution:
def titleToNumber(self, s: str) -> int:
number = 0
for c in s:
number = number*26 + ord(c) - ord('A') + 1
return number
# @lc code=end
# Accepted
# 1000/1000 cases... | class Solution:
def title_to_number(self, s: str) -> int:
number = 0
for c in s:
number = number * 26 + ord(c) - ord('A') + 1
return number |
response = natural_language_understanding.analyze(
html="Space/SpaceX and NASA Launch Is First Step to Renewed Human Spaceflight - The New York Times.html",
features=Features(
categories=CategoriesOptions(limit=4),
concepts=ConceptsOptions(limit=10)),
clean=False
... | response = natural_language_understanding.analyze(html='Space/SpaceX and NASA Launch Is First Step to Renewed Human Spaceflight - The New York Times.html', features=features(categories=categories_options(limit=4), concepts=concepts_options(limit=10)), clean=False).get_result() |
mylist = ["Firefox","Chrome","Safari","Microsoft Edges","Brave"]
print("Unsorted List: ",mylist)
mylist.sort()
print("Sorted List in Increasing Order: ",mylist)
mylist.sort(reverse=True)
print("Sorted List in Decreasing Order: ",mylist) | mylist = ['Firefox', 'Chrome', 'Safari', 'Microsoft Edges', 'Brave']
print('Unsorted List: ', mylist)
mylist.sort()
print('Sorted List in Increasing Order: ', mylist)
mylist.sort(reverse=True)
print('Sorted List in Decreasing Order: ', mylist) |
"""
This is a program intend to convert numeric scores into grades.
The program can identify valid and legal inputs (scores range in 0 to 100) and remind users to input valid inputs.
Written by Qi Zhao
"""
def validScores(yourMsg):
#get the valid input scores
try:
scores = float(yourMsg)
except V... | """
This is a program intend to convert numeric scores into grades.
The program can identify valid and legal inputs (scores range in 0 to 100) and remind users to input valid inputs.
Written by Qi Zhao
"""
def valid_scores(yourMsg):
try:
scores = float(yourMsg)
except ValueError:
print(f'{your... |
"""This package contains classes, functions, objects and packages contributed
by Cheetah users. They are not used by Cheetah itself. There is no
guarantee that this directory will be included in Cheetah releases, that
these objects will remain here forever, or that they will remain
backward-compatible.
""... | """This package contains classes, functions, objects and packages contributed
by Cheetah users. They are not used by Cheetah itself. There is no
guarantee that this directory will be included in Cheetah releases, that
these objects will remain here forever, or that they will remain
backward-compatible.
""... |
L_TYPE = {
0: 'Not Licensed',
1: 'Full Driver License',
2: 'Intermediate Driver License',
6: 'No Driver Present/Unknown if Driver Present',
7: 'Learner\'s Permit',
8: 'Terporary License',
9: 'Unkown License Type'
}
| l_type = {0: 'Not Licensed', 1: 'Full Driver License', 2: 'Intermediate Driver License', 6: 'No Driver Present/Unknown if Driver Present', 7: "Learner's Permit", 8: 'Terporary License', 9: 'Unkown License Type'} |
def generate_field():
field = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'],
['.', '.', '.', '.', '.', '.', '.', '.', ... | def generate_field():
field = [['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'], ['.', '.', '.', '.', '.', '.', '.', '.', '.', '.', '.'... |
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 20 15:14:11 2018
@author: behzad
"""
L = 0.05 # this is the length in m
A = 0.22 # area in m2
k= 0.78 #N conductivity W/mK
R_cond = L/(k*A) # resistance on C/W
h_i= 10 # w/m^2 K
R_conv_i = 1/(h_i*A)
h_0= 40 # w/m^2 K
R_conv_o = 1/(h_0*A)
name1= "Manuel"
# mu... | """
Created on Thu Sep 20 15:14:11 2018
@author: behzad
"""
l = 0.05
a = 0.22
k = 0.78
r_cond = L / (k * A)
h_i = 10
r_conv_i = 1 / (h_i * A)
h_0 = 40
r_conv_o = 1 / (h_0 * A)
name1 = 'Manuel'
3 * name1
sentence = 'my name is ' + name1
sentene2 = 'three of us are ' + 3 * name1
sentence3 = 'The result is ' + str(1)
pri... |
# flake8: noqa
# In[]:
# Controls for webapp
COUNTIES = {
"001": "Albany",
"003": "Allegany",
"005": "Bronx",
"007": "Broome",
"009": "Cattaraugus",
"011": "Cayuga",
"013": "Chautauqua",
"015": "Chemung",
"017": "Chenango",
"019": "Clinton",
"021": "Columbia",
"023": "Co... | counties = {'001': 'Albany', '003': 'Allegany', '005': 'Bronx', '007': 'Broome', '009': 'Cattaraugus', '011': 'Cayuga', '013': 'Chautauqua', '015': 'Chemung', '017': 'Chenango', '019': 'Clinton', '021': 'Columbia', '023': 'Cortland', '025': 'Delaware', '027': 'Dutchess', '029': 'Erie', '031': 'Essex', '033': 'Franklin'... |
# one of many possible solutions
weights = [-2, 5]
b = -.6
plot_decision(perceptron, X, y, weights=weights, b=b) | weights = [-2, 5]
b = -0.6
plot_decision(perceptron, X, y, weights=weights, b=b) |
def emailConfirmationTemplate(userName, confirmationLink):
return f"""
<html>
<body>
<p>Hi {userName}!<br>
Thanks for creating an account with LUSE! We're thrilled to get you started
investing. Please follow the link below to confirm your ... | def email_confirmation_template(userName, confirmationLink):
return f'''\n <html>\n <body>\n <p>Hi {userName}!<br>\n Thanks for creating an account with LUSE! We're thrilled to get you started \n investing. Please follow the link below to confir... |
'''
huygens
=======
My personal Python library of commonly used functions
D. C. Groothuizen Dijkema - December, 2019
'''
__all__=[]
| """
huygens
=======
My personal Python library of commonly used functions
D. C. Groothuizen Dijkema - December, 2019
"""
__all__ = [] |
V = int(input())
def m_to_edge(mat):
for i in range(len(mat)):
for j in range(i, len(mat)):
if mat[i][j] == 1:
print(i + 1, j + 1, sep=" ")
return 0
matrix = [list(map(int, input().split())) for _ in range(V)]
m_to_edge(matrix)
| v = int(input())
def m_to_edge(mat):
for i in range(len(mat)):
for j in range(i, len(mat)):
if mat[i][j] == 1:
print(i + 1, j + 1, sep=' ')
return 0
matrix = [list(map(int, input().split())) for _ in range(V)]
m_to_edge(matrix) |
"""
[01/07/13] Challenge #116 [Easy] Permutation of a string
https://www.reddit.com/r/dailyprogrammer/comments/164zvs/010713_challenge_116_easy_permutation_of_a_string/
# [](#EasyIcon) *(Easy)*: Permutation of a string
Write a function that prints all of the permutatons of the unique characters of a given string. For... | """
[01/07/13] Challenge #116 [Easy] Permutation of a string
https://www.reddit.com/r/dailyprogrammer/comments/164zvs/010713_challenge_116_easy_permutation_of_a_string/
# [](#EasyIcon) *(Easy)*: Permutation of a string
Write a function that prints all of the permutatons of the unique characters of a given string. For... |
#
# Copyright (c) 2018 cTuning foundation.
# See CK COPYRIGHT.txt for copyright details.
#
# See CK LICENSE for licensing details.
# See CK COPYRIGHT for copyright details.
#
def evaluate(results_dir, annotations_dir):
# TODO: run `ck-tensorflow:program:kitti-eval-tool`
raise Exception('KITTI evaluation is not imp... | def evaluate(results_dir, annotations_dir):
raise exception('KITTI evaluation is not implemented yet (TBD)') |
def bubbleSortdesc(arr):
n = len(arr)
# Traverse through all array elements
for i in range(n):
# Last i elements are already in place
for j in range(0, n-i-1):
# traverse the array from 0 to n-i-1
# Swap if the element found is greater
# than the next e... | def bubble_sortdesc(arr):
n = len(arr)
for i in range(n):
for j in range(0, n - i - 1):
if arr[j] < arr[j + 1]:
(arr[j], arr[j + 1]) = (arr[j + 1], arr[j])
arr = []
elem = int(input('Number of elements you want:'))
for i in range(0, elem):
arr.append(int(input('Enter numb... |
class Solution:
def numTilings(self, n: int) -> int:
dp, dpa = [1, 2] + [0] * n, [1] * n
for i in range(2, n):
dp[i] = (dp[i - 1] + dp[i - 2] + dpa[i - 1] * 2) % 1000000007
dpa[i] = (dp[i - 2] + dpa[i - 1]) % 1000000007
return dp[n - 1]
| class Solution:
def num_tilings(self, n: int) -> int:
(dp, dpa) = ([1, 2] + [0] * n, [1] * n)
for i in range(2, n):
dp[i] = (dp[i - 1] + dp[i - 2] + dpa[i - 1] * 2) % 1000000007
dpa[i] = (dp[i - 2] + dpa[i - 1]) % 1000000007
return dp[n - 1] |
# https://leetcode.com/problems/keyboard-row/
KEYS = {
**{k:1 for k in 'QWERTYUIOP'},
**{k:2 for k in 'ASDFGHJKL'},
**{k:3 for k in 'ZXCVBNM'}
}
class Solution(object):
def findWords(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
return [word f... | keys = {**{k: 1 for k in 'QWERTYUIOP'}, **{k: 2 for k in 'ASDFGHJKL'}, **{k: 3 for k in 'ZXCVBNM'}}
class Solution(object):
def find_words(self, words):
"""
:type words: List[str]
:rtype: List[str]
"""
return [word for word in words if len({KEYS[k] for k in word.upper()}) =... |
"""folders.py
Variables to store the folder names
"""
RAW = "results/raw/"
# QC
QC = "results/qc/"
# mappings
MAP_INDEX = "results/index/"
MAP_RAW = "results/map/raw/"
MAP_SPLIT = "results/map/split/"
MAP_FILT = "results/map/filt/"
# mpileup - SNP calling - popoolation
MPILEUP_RAW = "results/mpileup/raw/"
MPILEUP_F... | """folders.py
Variables to store the folder names
"""
raw = 'results/raw/'
qc = 'results/qc/'
map_index = 'results/index/'
map_raw = 'results/map/raw/'
map_split = 'results/map/split/'
map_filt = 'results/map/filt/'
mpileup_raw = 'results/mpileup/raw/'
mpileup_filt = 'results/mpileup/filt/'
mpileup_sub = 'results/mpile... |
class Allergen:
""" Array of allergens drawn from the controlled list of allergens.
For an Allergen Alert there will also be at least one allergen present on the problem statement.
Attributes:
_label (string): name for the allergen
_notation (string): a unique identifier for the allergen
... | class Allergen:
""" Array of allergens drawn from the controlled list of allergens.
For an Allergen Alert there will also be at least one allergen present on the problem statement.
Attributes:
_label (string): name for the allergen
_notation (string): a unique identifier for the allergen
... |
def octal_to_quinary(octal_number):
'''Convert octal number to quinary number
You can covert octal_number to binary by converting the given octal_number to decimal and then obtained decimal to quinary
For an instance, lets take an octal number to be 123
Step 1: Covert octal num... | def octal_to_quinary(octal_number):
"""Convert octal number to quinary number
You can covert octal_number to binary by converting the given octal_number to decimal and then obtained decimal to quinary
For an instance, lets take an octal number to be 123
Step 1: Covert octal num... |
# -*- coding: utf-8 -*-
# @Time : 2019/10/18 13:31
# @Author :
# @Site :
# @File : config.py
# @Software: PyCharm
class DBConfig:
@staticmethod
def get_db_config(db_type):
if db_type == 'dev':
return Development()
class Development:
host = 'localhost'
user = 'root'
pa... | class Dbconfig:
@staticmethod
def get_db_config(db_type):
if db_type == 'dev':
return development()
class Development:
host = 'localhost'
user = 'root'
password = 'admin123'
port = 3306
db = 'test'
mincached = 2
maxconnections = 5
charset = 'utf8' |
# -*- encoding: utf-8 -*-
DBUS_NAME = "org.freedesktop.DBus"
SERVICE_NAME = "org.bluez"
DBUS_OM_INTERFACE = DBUS_NAME + ".ObjectManager"
INTROSPECTABLE_INTERFACE = DBUS_NAME + ".Introspectable"
BLUEZ_MANAGER_INTERFACE = SERVICE_NAME + ".BluezManager1"
AGENT_MANAGER_INTERFACE = SERVICE_NAME + ".AgentManager1"
PROFIL... | dbus_name = 'org.freedesktop.DBus'
service_name = 'org.bluez'
dbus_om_interface = DBUS_NAME + '.ObjectManager'
introspectable_interface = DBUS_NAME + '.Introspectable'
bluez_manager_interface = SERVICE_NAME + '.BluezManager1'
agent_manager_interface = SERVICE_NAME + '.AgentManager1'
profile_manager_interface = SERVICE_... |
class Material(object):
def __init__(self, diffuse_color, mirror=0.05, softness=0.03):
self.diffuse_color = diffuse_color
self.mirror = mirror
self.softness = softness
| class Material(object):
def __init__(self, diffuse_color, mirror=0.05, softness=0.03):
self.diffuse_color = diffuse_color
self.mirror = mirror
self.softness = softness |
x = int(input())
y = int(input())
menor = min(x, y)
maior = max(x, y)
soma = 0
for i in range(menor, maior + 1):
if i % 13 != 0:
soma += i
print(soma)
| x = int(input())
y = int(input())
menor = min(x, y)
maior = max(x, y)
soma = 0
for i in range(menor, maior + 1):
if i % 13 != 0:
soma += i
print(soma) |
"""
15 / 15 test cases passed.
Runtime: 36 ms
Memory Usage: 15.3 MB
"""
class Solution:
def nextGreaterElement(self, nums1: List[int], nums2: List[int]) -> List[int]:
stk, dct = [], {}
for num in nums2:
while stk and stk[-1] < num:
dct[stk.pop()] = num
stk.app... | """
15 / 15 test cases passed.
Runtime: 36 ms
Memory Usage: 15.3 MB
"""
class Solution:
def next_greater_element(self, nums1: List[int], nums2: List[int]) -> List[int]:
(stk, dct) = ([], {})
for num in nums2:
while stk and stk[-1] < num:
dct[stk.pop()] = num
... |
class Literal():
def __init__(self, literal):
self.literal = literal
def optimizacion(self):
return self.literal | class Literal:
def __init__(self, literal):
self.literal = literal
def optimizacion(self):
return self.literal |
#!/usr/bin/env python
# Copyright (c) 2016 Hewlett Packard Enterprise Development Company, L.P.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | class Trigger(object):
"""A trigger generate events when a particular graph state is reached."""
def __init__(self, node_check, prob_check, event_builder):
"""Create a new trigger.
:type node_check:
(monasca_analytics.source.markov_chain.base.StateNode) -> bool
:param node_... |
# reverseArrayOfStrings.py
def reverseArrayOfStrings(arr):
# initialization, pointer is for another implementation
rev_str, res, beg, end, pointer = "", [], 0, 0, 0
# print (rev_str, res,beg, end)
# traverse through array from the end
for i in range(len(arr)-1, -1, -1):
print (arr[i])
... | def reverse_array_of_strings(arr):
(rev_str, res, beg, end, pointer) = ('', [], 0, 0, 0)
for i in range(len(arr) - 1, -1, -1):
print(arr[i])
for j in range(len(arr[i]) - 1, -1, -1):
print(arr[i][j])
rev_str += arr[i][j]
print(rev_str)
for item in arr:
end ... |
def pionek(w, p, c):
plansza = []
dlug_rzedu = int(len(p) / w)
ruchy = 0
for i in range(w):
plansza.append(p[i * dlug_rzedu : (i+ 1) * dlug_rzedu])
wystapienia = []
for j in range(len(plansza)):
for k in range(len(plansza[j])):
if int(plansza[j][k]) == c:
... | def pionek(w, p, c):
plansza = []
dlug_rzedu = int(len(p) / w)
ruchy = 0
for i in range(w):
plansza.append(p[i * dlug_rzedu:(i + 1) * dlug_rzedu])
wystapienia = []
for j in range(len(plansza)):
for k in range(len(plansza[j])):
if int(plansza[j][k]) == c:
... |
# config.py
class Config(object):
"""
Common configurations
"""
# Put any configurations here that are common across all environments
class DevelopmentConfig(Config):
"""
Development configurations
"""
DEBUG = True
DEVELOPMENT = True
SQLALCHEMY_ECHO = True
PORT = 80
cl... | class Config(object):
"""
Common configurations
"""
class Developmentconfig(Config):
"""
Development configurations
"""
debug = True
development = True
sqlalchemy_echo = True
port = 80
class Productionconfig(Config):
"""
Production configurations
"""
debug = Fal... |
class ASGIWebSubException(Exception):
...
class HubNotFoundException(ASGIWebSubException):
...
class TopicNotFoundException(ASGIWebSubException):
...
class SubscriptionException(ASGIWebSubException):
...
| class Asgiwebsubexception(Exception):
...
class Hubnotfoundexception(ASGIWebSubException):
...
class Topicnotfoundexception(ASGIWebSubException):
...
class Subscriptionexception(ASGIWebSubException):
... |
"""
This script was used to select 20 MEN-data set pairs as test set for
a sandbox (to explore incrementality)
"""
menfile = "../data/MEN_dataset_natural_form_full"
wordlist = []
pairs = []
with open(menfile, "r") as f:
for line in f:
words = line.rstrip().split()[:2]
pairs.append(words)
wordlist.extend(words)... | """
This script was used to select 20 MEN-data set pairs as test set for
a sandbox (to explore incrementality)
"""
menfile = '../data/MEN_dataset_natural_form_full'
wordlist = []
pairs = []
with open(menfile, 'r') as f:
for line in f:
words = line.rstrip().split()[:2]
pairs.append(words)
wor... |
""" Python > Basic Data Types > Find Second Largest
To print second largest element in given input (2 -2 2 2 :o/p=-2)
"""
input()
print('enter element in one line')
arr=set(map(int,input().split()))
lists=list(arr)
print(lists)
print(arr)
try:
print(arr[-1])
print(arr[-2])
except:
print('TypeError: set is just a... | """ Python > Basic Data Types > Find Second Largest
To print second largest element in given input (2 -2 2 2 :o/p=-2)
"""
input()
print('enter element in one line')
arr = set(map(int, input().split()))
lists = list(arr)
print(lists)
print(arr)
try:
print(arr[-1])
print(arr[-2])
except:
print('TypeError: se... |
i = 4
d = 4.0
s = 'HackerRank '
#Input Format
#The first line contains an integer that you must sum with .
#The second line contains a double that you must sum with .
#The third line contains a string that you must concatenate with .
#Output Format
#Print the sum of both integers on the first line, the ... | i = 4
d = 4.0
s = 'HackerRank '
input_int = int(input())
input_double = float(input())
input_string = str(input())
print(i + input_int)
print(d + input_double)
print(s + ' ' + input_string) |
#
# This software is Copyright (c) 2015 University of Oxford
#
# This work is made avaiable to you under the terms of the Apache
# License, Version 2.0; you may not use this source code except in
# compliance with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#... | config_file_locations = ['/etc/munki-staging/munki-staging.cfg', 'munki-staging.cfg']
date_format = '%d/%m/%y'
repo_path = '/Volumes/Munki'
makecatalogs = '/usr/local/munki/makecatalogs'
default_dev_list = 'Development'
default_to_dev_list = 'To Development'
default_munki_dev_catalog = 'development'
default_test_list =... |
##############################################################################
#
# Author: Avoin.Systems
# Copyright 2017 Avoin.Systems
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Softwar... | {'name': 'Robust Mails', 'version': '13.0.1.2.0', 'license': 'AGPL-3', 'summary': '\n Adds fields on outgoing email server that allows you to better control the\n outgoing email headers and Reply-To addresses.\n ', 'data': ['data/ir_config_parameter_data.xml', 'views/ir_mail_server_views.xml'], 'author': 'Avoi... |
# zip() in Python
# https://www.geeksforgeeks.org/zip-in-python/
# 1. zip() in Python
name = ["Manjeet", "Nikhil","Shambhavi", "Astha"];
roll_no = [4,1,3,2]
marks = [40,50,60,70]
mapped = zip(name,roll_no,marks)
print(mapped)
# <zip object at 0x7f7aaebc28c8>
mapped = set(mapped)
print("The zipped result... | name = ['Manjeet', 'Nikhil', 'Shambhavi', 'Astha']
roll_no = [4, 1, 3, 2]
marks = [40, 50, 60, 70]
mapped = zip(name, roll_no, marks)
print(mapped)
mapped = set(mapped)
print('The zipped results is: ', end='')
print(mapped)
print('\n')
name = ['Manjeet', 'Nikhil', 'Shambhavi', 'Astha']
roll_no = [4, 1, 3, 2]
marks = [4... |
sub = "tet"
string = "tested"
if sub in string:
print("Yes") | sub = 'tet'
string = 'tested'
if sub in string:
print('Yes') |
class Queue:
def __init__(self):
self.storage = []
def enqueue(self, value):
self.storage.append(value)
def dequeue(self):
if self.size() > 0:
return self.storage.pop(0)
else:
return None
def size(self):
return len(self.storage)
class ... | class Queue:
def __init__(self):
self.storage = []
def enqueue(self, value):
self.storage.append(value)
def dequeue(self):
if self.size() > 0:
return self.storage.pop(0)
else:
return None
def size(self):
return len(self.storage)
class ... |
def binary_search(arr:list, low:int, high:int, x:int) -> list:
if high >= low:
mid = (high + low) // 2
if arr[mid] == x:
return mid
elif arr[mid] > x:
return binary_search(arr, low, mid - 1, x)
else:
return binary_search(arr, mid + 1, high, x)
... | def binary_search(arr: list, low: int, high: int, x: int) -> list:
if high >= low:
mid = (high + low) // 2
if arr[mid] == x:
return mid
elif arr[mid] > x:
return binary_search(arr, low, mid - 1, x)
else:
return binary_search(arr, mid + 1, high, x)
... |
n, k = map(int, input().split())
v = list(map(int, input().split()))
prefMap = {}
prefMap[0] = 1
prefSum = 0
countK = 0
for i in range(n):
prefSum += v[i]
if (prefSum - k) in prefMap:
countK += prefMap[prefSum - k]
if prefSum in prefMap:
prefMap[prefSum] += 1
else:
prefMap[... | (n, k) = map(int, input().split())
v = list(map(int, input().split()))
pref_map = {}
prefMap[0] = 1
pref_sum = 0
count_k = 0
for i in range(n):
pref_sum += v[i]
if prefSum - k in prefMap:
count_k += prefMap[prefSum - k]
if prefSum in prefMap:
prefMap[prefSum] += 1
else:
prefMap[p... |
class Product:
def GetProduct(self):
self.__id = input("Enter Id : ")
self.__name = input("Enter Name : ")
self.__rate = int(input("Enter Rate : "))
self.__stock = int(input("Enter Stock : "))
def PutProduct(self):
print(self.__id, self.__name, self.__rate, self.__stock)... | class Product:
def get_product(self):
self.__id = input('Enter Id : ')
self.__name = input('Enter Name : ')
self.__rate = int(input('Enter Rate : '))
self.__stock = int(input('Enter Stock : '))
def put_product(self):
print(self.__id, self.__name, self.__rate, self.__sto... |
#
# This function calculates n!
# Factorial function not works in less than 0
#
def factorial(n):
result = 1
for i in range(2, n+1):
result *= i
return result
def factorial_recur(n):
if n == 0:
return 1
return n * factorial(n-1)
| def factorial(n):
result = 1
for i in range(2, n + 1):
result *= i
return result
def factorial_recur(n):
if n == 0:
return 1
return n * factorial(n - 1) |
bicycles = ['trek', 'cannondale', 'redline', 'specialized']
# print(bicycles)
# # or specific
# print(bicycles[0].title())
# # get the last item with special syntax
# print(bicycles[-1])
message = f"My first bike was a {bicycles[-2].title()}"
print(message) | bicycles = ['trek', 'cannondale', 'redline', 'specialized']
message = f'My first bike was a {bicycles[-2].title()}'
print(message) |
def movezeros(nums):
i = 0
for j in range(len(nums)):
if nums[j] != 0:
nums[i], nums[j] = nums[j], nums[i]
i += 1
return nums
print(movezeros([0,1,0,3,12,14]))
# two pointer i and j
# I will increase i if and only if swaping nums[j] and nums[i] and will only swap when nums[j... | def movezeros(nums):
i = 0
for j in range(len(nums)):
if nums[j] != 0:
(nums[i], nums[j]) = (nums[j], nums[i])
i += 1
return nums
print(movezeros([0, 1, 0, 3, 12, 14])) |
def test_one():
w1 = input()
w2 = input()
display = input()
first_letter = None
second_letter = None
for i in range(len(display)):
if display[i] == '_':
if first_letter is None:
first_letter = i
else:
second_letter = i
... | def test_one():
w1 = input()
w2 = input()
display = input()
first_letter = None
second_letter = None
for i in range(len(display)):
if display[i] == '_':
if first_letter is None:
first_letter = i
else:
second_letter = i
... |
# Given an index k, return the kth row of the Pascal's triangle.
#
# For example, given k = 3,
# Return [1,3,3,1].
#
# Note:
# Could you optimize your algorithm to use only O(k) extra space?
class Solution:
def getRow(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
... | class Solution:
def get_row(self, rowIndex):
"""
:type rowIndex: int
:rtype: List[int]
"""
row = [1]
for _ in range(rowIndex):
row = [x + y for (x, y) in zip([0] + row, row + [0])]
return row |
A = int(input())
if A - 7 <= 7:
print(-1)
else:
print(A - 7)
| a = int(input())
if A - 7 <= 7:
print(-1)
else:
print(A - 7) |
"""
abstract baseBackend class
"""
class baseBackend():
def __init__(self):
pass
def load_model(self):
raise NotImplementedError("baseBackend:load")
def predict(self):
raise NotImplementedError("baseBackend:predict") | """
abstract baseBackend class
"""
class Basebackend:
def __init__(self):
pass
def load_model(self):
raise not_implemented_error('baseBackend:load')
def predict(self):
raise not_implemented_error('baseBackend:predict') |
#!/usr/bin/env python3
def show_banner(value: str, times: int):
print(value * times)
def show_strings_demo1():
first_name = "Mohd"
last_name = 'Azim'
person_description = """
My Name is
Mohd Azim
"""
show_banner('=', 50)
... | def show_banner(value: str, times: int):
print(value * times)
def show_strings_demo1():
first_name = 'Mohd'
last_name = 'Azim'
person_description = '\n My Name is \n Mohd Azim\n '
show_banner('=', 50)
print('Strings Demo 1')
... |
def somatorio(a=0,b=0,c=0):
s = a + b + c
return s
def funcao():
n1 = 4
print(f"n1 dentro vale {n1}")
def somar(a=0,b=0,c=0):
soma = a + b +c
print(f"a soma vaale {soma}")
def contador(i,y,x):
"""
essa funcao tem caracteristica de mostrar o usuario uma forma de contagem dos umeros ... | def somatorio(a=0, b=0, c=0):
s = a + b + c
return s
def funcao():
n1 = 4
print(f'n1 dentro vale {n1}')
def somar(a=0, b=0, c=0):
soma = a + b + c
print(f'a soma vaale {soma}')
def contador(i, y, x):
"""
essa funcao tem caracteristica de mostrar o usuario uma forma de contagem dos ume... |
# here create parent class
class Person :
def __init__(self,_name,_age) :
self.name = _name;
self.age = _age;
# here create child function with overwrite init
class Student(Person) :
def __init__(self,_id,_year,_p) :
Person.__init__(self,_p.name,_p.age);
self.student_id = _id;
... | class Person:
def __init__(self, _name, _age):
self.name = _name
self.age = _age
class Student(Person):
def __init__(self, _id, _year, _p):
Person.__init__(self, _p.name, _p.age)
self.student_id = _id
self.addmassion_year = _year
def show_details(self):
pr... |
class StackWithMax:
def __init__(self):
self.stack = []
def push(self, element):
if self.stack and self.getMax() > element:
self.stack.append((element, self.getMax()))
else:
self.stack.append((element, element))
def pop(self):
self.stack.pop()
... | class Stackwithmax:
def __init__(self):
self.stack = []
def push(self, element):
if self.stack and self.getMax() > element:
self.stack.append((element, self.getMax()))
else:
self.stack.append((element, element))
def pop(self):
self.stack.pop()
... |
# -*- coding: utf-8 -*-
"""
Created on Thu Apr 25 17:54:53 2019
@author: Falble
"""
def rotate_letter(letter, n):
"""Rotates a letter by n places. Does not change other chars.
letter: single-letter string
n: int
Returns: single-letter string
"""
if letter.isupper():
star... | """
Created on Thu Apr 25 17:54:53 2019
@author: Falble
"""
def rotate_letter(letter, n):
"""Rotates a letter by n places. Does not change other chars.
letter: single-letter string
n: int
Returns: single-letter string
"""
if letter.isupper():
start = ord('A')
elif letter.islower()... |
class ReplList(list):
def __init__(self, *args, **kwargs):
list.__init__(self, *args, **kwargs)
def __repr__(self):
return ', '.join(map(repr, self))
class Repl(dict):
def __init__(self, *args, **kwargs):
dict.__init__(self)
def fill(**kwargs):
for k, v in kwa... | class Repllist(list):
def __init__(self, *args, **kwargs):
list.__init__(self, *args, **kwargs)
def __repr__(self):
return ', '.join(map(repr, self))
class Repl(dict):
def __init__(self, *args, **kwargs):
dict.__init__(self)
def fill(**kwargs):
for (k, v) in ... |
ONE_HUNDRED: int = 100
SEGMENT_MATCH_OPERATOR = "segmentMatch"
IN_OPERATOR = "in"
EQUAL_OPERATOR = "equal"
GT_OPERATOR = "gt"
STARTS_WITH_OPERATOR = "starts_with"
ENDS_WITH_OPERATOR = "ends_with"
CONTAINS_OPERATOR = "contains"
EQUAL_SENSITIVE_OPERATOR = "equal_sensitive"
| one_hundred: int = 100
segment_match_operator = 'segmentMatch'
in_operator = 'in'
equal_operator = 'equal'
gt_operator = 'gt'
starts_with_operator = 'starts_with'
ends_with_operator = 'ends_with'
contains_operator = 'contains'
equal_sensitive_operator = 'equal_sensitive' |
# Done by Carlos Amaral (2020/09/26)
emotions = ("happy", "sad", "fear", "surprise")
print("The length of the tuple is:", len(emotions))
print("The last emotion cotained in the tuple is: ", emotions[3])
| emotions = ('happy', 'sad', 'fear', 'surprise')
print('The length of the tuple is:', len(emotions))
print('The last emotion cotained in the tuple is: ', emotions[3]) |
def df_to_apex_data_single_gene(filtered_gene_df, actual):
series = [
{
'name': data_type,
'dataType': actual.loc[data_type]['Data type'],
'data': [
{
'x': val[0], # sample ID
'y': val[1], # color scale val
... | def df_to_apex_data_single_gene(filtered_gene_df, actual):
series = [{'name': data_type, 'dataType': actual.loc[data_type]['Data type'], 'data': [{'x': val[0], 'y': val[1], 'value': actual[val[0]][data_type], 'gene': actual.loc[data_type]['Gene symbol']} for val in vals.items()]} for (data_type, vals) in filtered_g... |
def ans(x):
r=0
w=1
while x//w:
r+=(x//w)*(w-w//2)
w*=2
return r
a,b=map(int,input().split())
print(ans(b)-ans(a-1)) | def ans(x):
r = 0
w = 1
while x // w:
r += x // w * (w - w // 2)
w *= 2
return r
(a, b) = map(int, input().split())
print(ans(b) - ans(a - 1)) |
"Wrap stardoc to set our repo-wide defaults"
load("@io_bazel_stardoc//stardoc:stardoc.bzl", _stardoc = "stardoc")
_PKG = "@build_bazel_rules_nodejs//tools/stardoc"
def stardoc(**kwargs):
_stardoc(
aspect_template = _PKG + ":templates/aspect.vm",
header_template = _PKG + ":templates/header.vm",
... | """Wrap stardoc to set our repo-wide defaults"""
load('@io_bazel_stardoc//stardoc:stardoc.bzl', _stardoc='stardoc')
_pkg = '@build_bazel_rules_nodejs//tools/stardoc'
def stardoc(**kwargs):
_stardoc(aspect_template=_PKG + ':templates/aspect.vm', header_template=_PKG + ':templates/header.vm', func_template=_PKG + ':... |
class YamlReaderError(Exception):
pass
class ConfigurationError(Exception):
pass
class RasterFileError(Exception):
pass
class MeteoDataError(Exception):
pass
class CategoryError(Exception):
pass
class RuntimeError(Exception):
pass
| class Yamlreadererror(Exception):
pass
class Configurationerror(Exception):
pass
class Rasterfileerror(Exception):
pass
class Meteodataerror(Exception):
pass
class Categoryerror(Exception):
pass
class Runtimeerror(Exception):
pass |
class EqualityAssertionError(AssertionError):
def __init__(self, equal, actual, expected):
template = "Expected {0} {1} {2}"
equal_str = "to equal" if equal else "not to equal"
message = template.format(str(actual), equal_str, str(expected))
super(EqualityAssertionError, self).__init... | class Equalityassertionerror(AssertionError):
def __init__(self, equal, actual, expected):
template = 'Expected {0} {1} {2}'
equal_str = 'to equal' if equal else 'not to equal'
message = template.format(str(actual), equal_str, str(expected))
super(EqualityAssertionError, self).__ini... |
"""
Q394
Decode String
Medium
Stack; DFS.
Given an encoded string, return its decoded string.
The encoding rule is: k[encoded_string], where the encoded_string
inside the square brackets is being repeated exactly k times.
Note that k is guaranteed to be a positive integer.
You may assume that the input string is ... | """
Q394
Decode String
Medium
Stack; DFS.
Given an encoded string, return its decoded string.
The encoding rule is: k[encoded_string], where the encoded_string
inside the square brackets is being repeated exactly k times.
Note that k is guaranteed to be a positive integer.
You may assume that the input string is ... |
# LEETCODE 152: Maximum Product Subarray
#
# https://leetcode.com/problems/maximum-subarray/
#
# Given an integer array nums, find the contiguous subarray within an array
# (containing at least one number) which has the largest product.
#
# Example 1:
#
# Input: [2,3,-2,4]
# Output: 6
# Explanation: [2,3] has the larg... | def max_product(nums):
product = 0
count = len(nums)
if count == 0:
return product
product = nums[0]
maximum = nums[0]
minimum = nums[0]
for i in range(1, count):
mx = maximum
mn = minimum
maximum = max(max(nums[i], mx * nums[i]), mn * nums[i])
minimum... |
class Solution:
def selfDividingNumbers(self, left, right):
"""
:type left: int
:type right: int
:rtype: List[int]
"""
res = []
for num in range(left, right + 1):
if self.isDividing(num):
res.append(num)
return res
... | class Solution:
def self_dividing_numbers(self, left, right):
"""
:type left: int
:type right: int
:rtype: List[int]
"""
res = []
for num in range(left, right + 1):
if self.isDividing(num):
res.append(num)
return res
d... |
def ok(cs, ds, l, r, k):
cs_max = 0
for i in range(l, r + 1):
cs_max = max(cs_max, cs[i])
ds_max = 0
for i in range(l, r + 1):
ds_max = max(ds_max, ds[i])
if abs(cs_max - ds_max) <= k:
return True
return False
def Solution(cs, ds, n, k):
lr = 0
for i in range(n)... | def ok(cs, ds, l, r, k):
cs_max = 0
for i in range(l, r + 1):
cs_max = max(cs_max, cs[i])
ds_max = 0
for i in range(l, r + 1):
ds_max = max(ds_max, ds[i])
if abs(cs_max - ds_max) <= k:
return True
return False
def solution(cs, ds, n, k):
lr = 0
for i in range(n):... |
cli_args = {
'actor-model': {'help': 'Path to actor model .cfg file'},
'critic-model': {'help': 'Path to critic model .cfg file'},
'gradient-steps': {
'help': 'Number of iterations per train step',
'type': int,
'hp_type': 'int',
},
'tau': {
'help': 'Value used for syn... | cli_args = {'actor-model': {'help': 'Path to actor model .cfg file'}, 'critic-model': {'help': 'Path to critic model .cfg file'}, 'gradient-steps': {'help': 'Number of iterations per train step', 'type': int, 'hp_type': 'int'}, 'tau': {'help': 'Value used for syncing target model weights', 'type': float, 'default': 0.0... |
""" Configurable hooks in the build system. Can be used by various platforms
to customize the build process.
"""
################################################################################
# Hooks for the various parts of the build process
# Internal mapping of hooks per tool
_HOOKS = {}
# Internal mapping of r... | """ Configurable hooks in the build system. Can be used by various platforms
to customize the build process.
"""
_hooks = {}
_running_hooks = {}
_hook_types = ['binary', 'compile', 'link', 'assemble']
_hook_steps = ['pre', 'replace', 'post']
def hook_tool(function):
"""Decorate a function as a tool that may be hoo... |
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 3 08:44:30 2020
@author: Simon
"""
"""
Author: Simon Schalk S1910632012
Title: Schaltjahr
Discription: Ueberpuefung ob ein beliebiges Jahr ein Schaltjahr ist.
Last Change: 03.01.2020
"""
#Funktion zur Schaltjahr-Berechnung
def Scha... | """
Created on Fri Jan 3 08:44:30 2020
@author: Simon
"""
'\nAuthor: Simon Schalk S1910632012\nTitle: Schaltjahr\nDiscription: Ueberpuefung ob ein beliebiges Jahr ein Schaltjahr ist.\nLast Change: 03.01.2020\n'
def schaltjahr(j):
"""j = int(input("Zu ueberpruefendes Jahr: "))"""
if j ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.