content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class BinarySearch:
def __init__(self):
pass
def search(self, array, item):
# return self.recursively_search(array, item, 0, len(array)-1)
return self.interactive_search(array, item, 0, len(array)-1)
def recursively_search(self, array, item, left, right):
if(left > right):
... | class Binarysearch:
def __init__(self):
pass
def search(self, array, item):
return self.interactive_search(array, item, 0, len(array) - 1)
def recursively_search(self, array, item, left, right):
if left > right:
return -1
mid = int((left + right) / 2)
i... |
class Solution:
def makeGood(self, s: str) -> str:
ans = []
for ch in s:
if ans and ans[-1].lower() == ch.lower() and ans[-1] != ch:
ans.pop()
else:
ans.append(ch)
return ''.join(ans)
| class Solution:
def make_good(self, s: str) -> str:
ans = []
for ch in s:
if ans and ans[-1].lower() == ch.lower() and (ans[-1] != ch):
ans.pop()
else:
ans.append(ch)
return ''.join(ans) |
#-----------------------------------------------------------------------------
# Runtime: 28ms
# Memory Usage:
# Link:
#-----------------------------------------------------------------------------
class Solution:
def spiralOrder(self, matrix: [[int]]) -> [int]:
row_length = len(matrix)
if row_le... | class Solution:
def spiral_order(self, matrix: [[int]]) -> [int]:
row_length = len(matrix)
if row_length <= 0:
return matrix
col_length = len(matrix[0])
matrix_length = col_length * row_length
result = []
level = 0
while True:
first_co... |
def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Reserved'},
{'abbr': 'surf',
'code': 1,
'title': 'Surface',
'units': 'of the Earth, which includes sea surface'},
{'abbr': 'bcld', 'code': 2, 'title': 'Cloud base level'},
{'abbr': 'tcld'... | def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Reserved'}, {'abbr': 'surf', 'code': 1, 'title': 'Surface', 'units': 'of the Earth, which includes sea surface'}, {'abbr': 'bcld', 'code': 2, 'title': 'Cloud base level'}, {'abbr': 'tcld', 'code': 3, 'title': 'Cloud top level'}, {'abbr': 'isot', 'code': 4, 'titl... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def __init__(self):
... | class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def __init__(self):
self.preorder_i = 0
def build_tree(self, preorder, inorder) -> TreeNode:
return self.rec(preorder, inorder, 0, len(preorder) - 1)
def re... |
inpt1 = int(input('enter base: '))
inpt2 = int(input('enter height: '))
inpt3 = int(input('enter hypotenus: '))
def get_area(base, height):
return 0.5 * base * height
def get_per(base, height, hypo):
return base + height + hypo
print("area of the triangle is: ")
print(get_area(inpt1, inpt2))
print()
print('t... | inpt1 = int(input('enter base: '))
inpt2 = int(input('enter height: '))
inpt3 = int(input('enter hypotenus: '))
def get_area(base, height):
return 0.5 * base * height
def get_per(base, height, hypo):
return base + height + hypo
print('area of the triangle is: ')
print(get_area(inpt1, inpt2))
print()
print('th... |
def __getattr__():
pass
class C1:
def __str__(self):
return ''
def foo(self):
'''
>>> class Good():
... def __str__(self):
... return 1
'''
pass
class C2:
if True:
def __str__(self):
return ''
class C... | def __getattr__():
pass
class C1:
def __str__(self):
return ''
def foo(self):
"""
>>> class Good():
... def __str__(self):
... return 1
"""
pass
class C2:
if True:
def __str__(self):
return ''
class... |
class Config(object):
DEBUG = False
TESTING = False
SECRET_KEY = 'AAABBBBAAAA'
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
class ProductionConfig(Config):
DATABASE_URI = 'mysql://user@localhost/foo'
class DevelopmentConfig(Config):
DEBUG = True
class TestingConfig(Config):
TESTING... | class Config(object):
debug = False
testing = False
secret_key = 'AAABBBBAAAA'
sqlalchemy_database_uri = 'sqlite:////tmp/test.db'
class Productionconfig(Config):
database_uri = 'mysql://user@localhost/foo'
class Developmentconfig(Config):
debug = True
class Testingconfig(Config):
testing ... |
#!/usr/bin/python3
'''
Finds the coincidence index for the piece of text
Does not format the text so make sure to pass in a formatted one
'''
def findCoincidenceIndex(text: str, shift: int):
shiftedText = text[:-(shift)]
text = text[shift:]
shiftedLen = len(shiftedText)
similarCount = 0
for i in ra... | """
Finds the coincidence index for the piece of text
Does not format the text so make sure to pass in a formatted one
"""
def find_coincidence_index(text: str, shift: int):
shifted_text = text[:-shift]
text = text[shift:]
shifted_len = len(shiftedText)
similar_count = 0
for i in range(shiftedLen):... |
# Default
domainFile = "domains.txt"
assets = "./assets/"
targets = assets + "targets/"
subdomains = assets + "subdomains/"
domains = assets + "domains/"
takeover = assets + "takeover/"
dto = assets = "dto/"
# Target Information
targetFields = {
"Domain" : "",
"Analysis" : {
"Subdomain" : "",
"... | domain_file = 'domains.txt'
assets = './assets/'
targets = assets + 'targets/'
subdomains = assets + 'subdomains/'
domains = assets + 'domains/'
takeover = assets + 'takeover/'
dto = assets = 'dto/'
target_fields = {'Domain': '', 'Analysis': {'Subdomain': '', 'Ping': '', 'Dns': ''}} |
"""
Recipes available to data with tags ['GSAOI', 'IMAGE']
Default is "reduce_nostack".
"""
recipe_tags = {'GSAOI', 'IMAGE'}
def reduce_nostack(p):
"""
This recipe reduce GSAOI up to but NOT including alignment and stacking.
It will attempt to do flat correction if a processed calibration is
available.... | """
Recipes available to data with tags ['GSAOI', 'IMAGE']
Default is "reduce_nostack".
"""
recipe_tags = {'GSAOI', 'IMAGE'}
def reduce_nostack(p):
"""
This recipe reduce GSAOI up to but NOT including alignment and stacking.
It will attempt to do flat correction if a processed calibration is
available.... |
"""Error classes for authentise_services"""
class ResourceError(Exception):
"""arbitrary error whenever a call to a authentise resource doesnt go according to plan"""
pass
class ResourceStillProcessing(Exception):
"""most authentise resources have a status property to tell the user what state its in
... | """Error classes for authentise_services"""
class Resourceerror(Exception):
"""arbitrary error whenever a call to a authentise resource doesnt go according to plan"""
pass
class Resourcestillprocessing(Exception):
"""most authentise resources have a status property to tell the user what state its in
... |
count = int(input())
matrix = []
for i in range(count):
matrix.append(list(map(int, input().split())))
# matrix = [list(map(int, input().split())) for i in range(n)]
roads = 0
for row in range(len(matrix)):
for col in range(row, len(matrix)):
roads += matrix[row][col]
print(roads)
| count = int(input())
matrix = []
for i in range(count):
matrix.append(list(map(int, input().split())))
roads = 0
for row in range(len(matrix)):
for col in range(row, len(matrix)):
roads += matrix[row][col]
print(roads) |
# BUILD FILE SYNTAX: SKYLARK
SE_VERSION = '3.9.1'
ASSEMBLY_VERSION = '3.9.1.0'
| se_version = '3.9.1'
assembly_version = '3.9.1.0' |
#
# PySNMP MIB module STN-SESSION-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/STN-SESSION-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:11:40 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, single_value_constraint, value_range_constraint, value_size_constraint) ... |
msg = "No Smoking here"
print(len(msg))
msg.count('o')
msg.count('s',3,5)
msg.count('n')
msg.count('N')
msg.count('O',7)
msg.count('o',7)
msg.count('o',1,7)
msg.count('o',7,15) | msg = 'No Smoking here'
print(len(msg))
msg.count('o')
msg.count('s', 3, 5)
msg.count('n')
msg.count('N')
msg.count('O', 7)
msg.count('o', 7)
msg.count('o', 1, 7)
msg.count('o', 7, 15) |
definition = [
{
"project_name" : "Project1",
"end_points": [
{
"local_development": "http://localhost:8066/",
"local_team_development": "http://192.168.5.217:8066/"
}
],
"api_end_point_partial_path": "api/"
}
]
| definition = [{'project_name': 'Project1', 'end_points': [{'local_development': 'http://localhost:8066/', 'local_team_development': 'http://192.168.5.217:8066/'}], 'api_end_point_partial_path': 'api/'}] |
print('----- range(3) -----')
print(range(3))
for x in range(3): print(x)
print('----- range(3, 10) -----')
print(range(3, 10))
for x in range(3, 10): print(x)
print('----- range(-3) -----')
print(range(-3))
for x in range(-3): print(x)
print('----- range(0,-3) -----')
print(range(0,-3))
for x in range(0,-3): print(x)
... | print('----- range(3) -----')
print(range(3))
for x in range(3):
print(x)
print('----- range(3, 10) -----')
print(range(3, 10))
for x in range(3, 10):
print(x)
print('----- range(-3) -----')
print(range(-3))
for x in range(-3):
print(x)
print('----- range(0,-3) -----')
print(range(0, -3))
for x in range(0, ... |
# leetcode
class Solution:
def reverse(self, x: int) -> int:
str_x = str(x)
if str_x[:1] == "-":
isNeg = True
str_x = str_x[1:]
else:
isNeg = False
str_x = str_x[::-1]
new_x = int(str_x)
if isNeg:
... | class Solution:
def reverse(self, x: int) -> int:
str_x = str(x)
if str_x[:1] == '-':
is_neg = True
str_x = str_x[1:]
else:
is_neg = False
str_x = str_x[::-1]
new_x = int(str_x)
if isNeg:
new_x *= -1
if new_x < ... |
# -*- coding: utf-8 -*-
class UnknownServiceEnvironmentNotConfiguredError(Exception):
"""
Raised when unknown service-environment is not configured for plugin.
"""
pass
| class Unknownserviceenvironmentnotconfigurederror(Exception):
"""
Raised when unknown service-environment is not configured for plugin.
"""
pass |
n = input()
# Reading first list
list1 = list(map(int, input().split()))
# Reading second list then to set
set1 = set(list(map(int, input().split())))
set2 = set(list(map(int, input().split())))
count = 0
# Looping through elements in
for el in list1:
# checking the element existence Set
if el in set1:
... | n = input()
list1 = list(map(int, input().split()))
set1 = set(list(map(int, input().split())))
set2 = set(list(map(int, input().split())))
count = 0
for el in list1:
if el in set1:
count += 1
elif el in set2:
count -= 1
print(count) |
pairs = {1: "apple",
"orange": [2,3,5],
True:False,
None:"True",
}
print(pairs.get("orange"))
print(pairs.get(7))
print(pairs.get(12345, "not in dictionary")) | pairs = {1: 'apple', 'orange': [2, 3, 5], True: False, None: 'True'}
print(pairs.get('orange'))
print(pairs.get(7))
print(pairs.get(12345, 'not in dictionary')) |
main = [{'category': 'Transfer Limits',
'field': [{'name': 'tx_transfer_min',
'title': 'Minimum amount a user can transfer per transaction',
'note': 'Default is set to zero.'},
{'name': 'tx_transfer_max_day',
'title': 'Maximum total... | main = [{'category': 'Transfer Limits', 'field': [{'name': 'tx_transfer_min', 'title': 'Minimum amount a user can transfer per transaction', 'note': 'Default is set to zero.'}, {'name': 'tx_transfer_max_day', 'title': 'Maximum total amount a user can transfer per day', 'note': 'Default is set to unlimited.'}, {'name': ... |
# Author: Luke Hindman
# Date: Tue Oct 24 13:10:06 MDT 2017
# Description: In-class example for user input and lists
# Create an empty grocery list
groceryList = []
# Shopping list loop
done = False
while done == False:
# Prompt the user for an item to add to the list
item = input("Please enter an item or ... | grocery_list = []
done = False
while done == False:
item = input('Please enter an item or done when finished: ')
if item.lower() == 'done':
done = True
else:
groceryList.append(item)
for g in groceryList:
print("Don't forget the " + g + '!') |
space = [[1 for _ in range(21)] for _ in range(21)]
for x in range(1,21):
for y in range(1,21):
space[x][y] = space[x-1][y] + space[x][y-1]
print(space[20][20])
| space = [[1 for _ in range(21)] for _ in range(21)]
for x in range(1, 21):
for y in range(1, 21):
space[x][y] = space[x - 1][y] + space[x][y - 1]
print(space[20][20]) |
#4.6
def computepay(h,r):
# ( 40 hours * normal rate ) + (( overtime hours ) * time-and-a-half rate)
if(h>40):
p = ( 40 * r ) + (( h - 40 ) * 1.5 * r)
return p
else:
p = h * r
return p
hours = float(input("Enter Hours: "))
rate = float(input("Enter Rate per hour: "))
pay = ... | def computepay(h, r):
if h > 40:
p = 40 * r + (h - 40) * 1.5 * r
return p
else:
p = h * r
return p
hours = float(input('Enter Hours: '))
rate = float(input('Enter Rate per hour: '))
pay = computepay(hours, rate)
print('Pay', pay) |
class CellCountMissingCellsException(Exception):
pass
class UnknownAtlasValue(Exception):
pass
def atlas_value_to_structure_id(atlas_value, structures_reference_df):
line = structures_reference_df[
structures_reference_df["id"] == atlas_value
]
if len(line) == 0:
raise UnknownAtl... | class Cellcountmissingcellsexception(Exception):
pass
class Unknownatlasvalue(Exception):
pass
def atlas_value_to_structure_id(atlas_value, structures_reference_df):
line = structures_reference_df[structures_reference_df['id'] == atlas_value]
if len(line) == 0:
raise unknown_atlas_value(atlas_... |
x = 'abc'
x = "abc"
x = r'abc'
x = 'abc' \
'def'
x = ('abc'
'def')
x = 'ab"c'
x = "ab'c"
x = '''ab'c'''
| x = 'abc'
x = 'abc'
x = 'abc'
x = 'abcdef'
x = 'abcdef'
x = 'ab"c'
x = "ab'c"
x = "ab'c" |
class DefaultConfig (object) :
root_raw_train_data = 'path to be filled' # downloaded training data root
root_raw_eval_data = 'path to be filled' # downloaded evaluation/testing data root
root_dataset_file = './dataset/' # preprocessed dataset root
root_train_volume = './dataset/train/' # preprocessed... | class Defaultconfig(object):
root_raw_train_data = 'path to be filled'
root_raw_eval_data = 'path to be filled'
root_dataset_file = './dataset/'
root_train_volume = './dataset/train/'
root_eval_volume = './dataset/eval/'
root_exp_file = './exp/'
root_submit_file = './submit/'
root_pred_d... |
def main():
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for e in a:
if e%2 == 0:
count2 += 1
if e%4 == 0:
count4 += 1
if n == 3 and count4:
print("Yes")
return
if count2 == n:
print("Yes")
r... | def main():
n = int(input())
a = list(map(int, input().split()))
count2 = 0
count4 = 0
for e in a:
if e % 2 == 0:
count2 += 1
if e % 4 == 0:
count4 += 1
if n == 3 and count4:
print('Yes')
return
if count2 == n:
print('Yes')
... |
class Solution:
def canPartition(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
total_sum = sum(nums)
if total_sum % 2 == 1:
return False
half_sum = total_sum//2
dp = [[0 for col in range(half_sum+1)] for row in range(len(nums))]
... | class Solution:
def can_partition(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
total_sum = sum(nums)
if total_sum % 2 == 1:
return False
half_sum = total_sum // 2
dp = [[0 for col in range(half_sum + 1)] for row in range(len(num... |
class Node:
def __init__(self, game, parent, action):
self.game = game
self.parent = parent
self.action = action
self.player = game.get_current_player()
self.score = game.get_score()
self.children = []
self.visits = 0
def is_leaf(self):
... | class Node:
def __init__(self, game, parent, action):
self.game = game
self.parent = parent
self.action = action
self.player = game.get_current_player()
self.score = game.get_score()
self.children = []
self.visits = 0
def is_leaf(self):
return no... |
def product(x, y):
ret = list()
for _x in x:
for _y in y:
ret.append((_x, _y))
return ret
print(product([1, 2, 3], ["a", "b"]))
| def product(x, y):
ret = list()
for _x in x:
for _y in y:
ret.append((_x, _y))
return ret
print(product([1, 2, 3], ['a', 'b'])) |
# configuration
class Config:
DEBUG = True
# db
SQLALCHEMY_DATABASE_URI = 'mysql://root:root@localhost/djangoapp'
SQLALCHEMY_TRACK_MODIFICATIONS = False
| class Config:
debug = True
sqlalchemy_database_uri = 'mysql://root:root@localhost/djangoapp'
sqlalchemy_track_modifications = False |
class VaultConfig(object):
def __init__(self):
self.method = None
self.address = None
self.username = None
self.namespace = None
self.studio = None
self.mount_point = None
self.connect = False
| class Vaultconfig(object):
def __init__(self):
self.method = None
self.address = None
self.username = None
self.namespace = None
self.studio = None
self.mount_point = None
self.connect = False |
# -*- coding: utf-8 -*-
# Copyright: (c) 2020, Garfield Lee Freeman (@shinmog)
class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = r'''
'''
FACTS = r'''
notes:
- As this is a facts module, check mode is not supported.
options:
search_type:
descripti... | class Moduledocfragment(object):
documentation = '\n'
facts = "\nnotes:\n - As this is a facts module, check mode is not supported.\noptions:\n search_type:\n description:\n - How to interpret the value given for the primary param.\n choices:\n - exact\n - su... |
#!/usr/bin/env python3
class Canvas(object):
def __init__(self, width, height):
self.width = width
self.height = height
self._area = []
for _ in range(height):
self._area.append([c for c in ' ' * width])
def _inside_canvas(self, x, y):
return 0 < x <= self.... | class Canvas(object):
def __init__(self, width, height):
self.width = width
self.height = height
self._area = []
for _ in range(height):
self._area.append([c for c in ' ' * width])
def _inside_canvas(self, x, y):
return 0 < x <= self.width and 0 < y <= self.... |
'''
Praveen Manimaran
CIS 41A Spring 2020
Exercise A
'''
height = 2.9
width = 7.1
height = height// 2
width = width// 2
area = height*width
print("height: ",height)
print("width: ",width)
print("area: ",area) | """
Praveen Manimaran
CIS 41A Spring 2020
Exercise A
"""
height = 2.9
width = 7.1
height = height // 2
width = width // 2
area = height * width
print('height: ', height)
print('width: ', width)
print('area: ', area) |
#!/usr/bin/env python
# -*- coding:utf-8 -*-
class Solution:
def longestPalindrome(self,s):
dp = [[False for _ in range(len(s))] for _ in range(len(s))]
l,r = 0,0
for head in range(len(s)-2,0,-1):
for tail in range(head,len(s)):
if s[head] == s[tail] and (tail-he... | class Solution:
def longest_palindrome(self, s):
dp = [[False for _ in range(len(s))] for _ in range(len(s))]
(l, r) = (0, 0)
for head in range(len(s) - 2, 0, -1):
for tail in range(head, len(s)):
if s[head] == s[tail] and (tail - head < 3 or dp[head + 1][tail - ... |
#!/usr/bin/env python3
def part1():
data = open('day8_input.txt').read().splitlines()
one = 2 # 2 segments light up to display 1
four = 4
seven = 3
eight = 7
output = [i.rpartition('|')[2].strip() for i in data]
counter = 0
for i in range(len(output)):
strings = output[i... | def part1():
data = open('day8_input.txt').read().splitlines()
one = 2
four = 4
seven = 3
eight = 7
output = [i.rpartition('|')[2].strip() for i in data]
counter = 0
for i in range(len(output)):
strings = output[i].split()
for string in strings:
length = len(s... |
valores = input().split()
x, y = valores
x = float(x)
y = float(y)
if(x == 0.0 and y == 0.0):
print('Origem')
if(x == 0.0 and y != 0.0):
print('Eixo Y')
if(x != 0.0 and y == 0.0):
print('Eixo X')
if(x > 0 and y > 0):
print('Q1')
if(x < 0 and y > 0):
print('Q2')
if(x < 0 and y < 0):
pr... | valores = input().split()
(x, y) = valores
x = float(x)
y = float(y)
if x == 0.0 and y == 0.0:
print('Origem')
if x == 0.0 and y != 0.0:
print('Eixo Y')
if x != 0.0 and y == 0.0:
print('Eixo X')
if x > 0 and y > 0:
print('Q1')
if x < 0 and y > 0:
print('Q2')
if x < 0 and y < 0:
print('Q3')
if x ... |
#! python3
# Configuration file for cf-py-importer
globalSettings = {
# FQDN or IP address of the CyberFlood Controller. Do NOT prefix with https://
"cfControllerAddress": "your.cyberflood.controller",
"userName": "your@login",
"userPassword": "yourPassword"
}
| global_settings = {'cfControllerAddress': 'your.cyberflood.controller', 'userName': 'your@login', 'userPassword': 'yourPassword'} |
#OPCODE_Init = b"0"
OPCODE_ActivateLayer0 = b"1"
OPCODE_ActivateLayer1 = b"2"
OPCODE_ActivateLayer2 = b"3"
OPCODE_ActivateLayer3 = b"4"
OPCODE_NextAI = b"5"
OPCODE_NewTournament = b"6"
OPCODE_Exit = b"7" | opcode__activate_layer0 = b'1'
opcode__activate_layer1 = b'2'
opcode__activate_layer2 = b'3'
opcode__activate_layer3 = b'4'
opcode__next_ai = b'5'
opcode__new_tournament = b'6'
opcode__exit = b'7' |
class InvalidProtocolMessage(Exception):
"""Invalid protocol message function name"""
class InvalidHandshake(Exception):
"""Handshake message from peer is invalid"""
class InvalidAck(Exception):
"""Handshake message from peer is invalid"""
class IncompatibleProtocolVersion(Exception):
"""Protocol ... | class Invalidprotocolmessage(Exception):
"""Invalid protocol message function name"""
class Invalidhandshake(Exception):
"""Handshake message from peer is invalid"""
class Invalidack(Exception):
"""Handshake message from peer is invalid"""
class Incompatibleprotocolversion(Exception):
"""Protocol ver... |
"""
Florian Guillot & Julien Donche: Project 7
Topic modeling and keywords extractions for Holi.io
Jedha Full Stack, dsmf-paris-13
08-2021
FILE NAME :
topic_text.py
OBJECTIVE :
This function use a pretrained topic_modeling model to associate topics to a text
INPUTS:
- 'model' : a topic modeling model that w... | """
Florian Guillot & Julien Donche: Project 7
Topic modeling and keywords extractions for Holi.io
Jedha Full Stack, dsmf-paris-13
08-2021
FILE NAME :
topic_text.py
OBJECTIVE :
This function use a pretrained topic_modeling model to associate topics to a text
INPUTS:
- 'model' : a topic modeling model that w... |
greek_alp = {
"Alpha" : "Alp",
"Beta" : "Bet",
"Gamma" : "Gam",
"Delta" : "Del",
"Epsilon" : "Eps",
"Zeta" : "Zet",
"Eta" : "Eta",
"Theta" : "The",
"Iota" : "Iot",
"Kappa" : "Kap",
"Lambda" : "Lam",
"Mu" : "Mu ",
"Nu" : "Nu ",
"Xi" : "Xi ",
"Omicron" : "Omi",
"Pi" : "Pi ",
"Rho" : "Rho",
"Sigma" : "Si... | greek_alp = {'Alpha': 'Alp', 'Beta': 'Bet', 'Gamma': 'Gam', 'Delta': 'Del', 'Epsilon': 'Eps', 'Zeta': 'Zet', 'Eta': 'Eta', 'Theta': 'The', 'Iota': 'Iot', 'Kappa': 'Kap', 'Lambda': 'Lam', 'Mu': 'Mu ', 'Nu': 'Nu ', 'Xi': 'Xi ', 'Omicron': 'Omi', 'Pi': 'Pi ', 'Rho': 'Rho', 'Sigma': 'Sig', 'Tau': 'Tau', 'Upsilon': 'Ups', '... |
data = ["React", "Angular", "Svelte", "Vue"]
# or
data = [
{"value": "React", "label": "React"},
{"value": "Angular", "label": "Angular"},
{"value": "Svelte", "label": "Svelte"},
{"value": "Vue", "label": "Vue"},
]
| data = ['React', 'Angular', 'Svelte', 'Vue']
data = [{'value': 'React', 'label': 'React'}, {'value': 'Angular', 'label': 'Angular'}, {'value': 'Svelte', 'label': 'Svelte'}, {'value': 'Vue', 'label': 'Vue'}] |
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long
"""Reduce integer values in coords attributes comma separated list of html 3.2 map area elements."""
ENCODING = "utf-8"
ENCODING_ERRORS_POLICY = "ignore"
def apply_scaling(reduction_factor:int, text_line: str):
"""Apply the scaling if... | """Reduce integer values in coords attributes comma separated list of html 3.2 map area elements."""
encoding = 'utf-8'
encoding_errors_policy = 'ignore'
def apply_scaling(reduction_factor: int, text_line: str):
"""Apply the scaling if coords attribute present in line."""
coords_token_start = ' coords="'
c... |
FONT = "Arial"
FONT_SIZE_TINY = 8
FONT_SIZE_SMALL = 11
FONT_SIZE_REGULAR = 14
FONT_SIZE_LARGE = 16
FONT_SIZE_EXTRA_LARGE = 20
FONT_WEIGHT_LIGHT = 100
FONT_WEIGHT_REGULAR = 600
FONT_WEIGHT_BOLD = 900
| font = 'Arial'
font_size_tiny = 8
font_size_small = 11
font_size_regular = 14
font_size_large = 16
font_size_extra_large = 20
font_weight_light = 100
font_weight_regular = 600
font_weight_bold = 900 |
# Copyright (c) 2021 Qianyun, Inc. All rights reserved.
class ValidationError(Exception):
"""The validation exception"""
message = "ValidationError"
def __init__(self, message=None):
self.message = message or self.message
super(ValidationError, self).__init__(self.message)
class FusionC... | class Validationerror(Exception):
"""The validation exception"""
message = 'ValidationError'
def __init__(self, message=None):
self.message = message or self.message
super(ValidationError, self).__init__(self.message)
class Fusioncomputeclienterror(Exception):
def __init__(self, messa... |
person = ('Nana', 25, 'piza')
# unpack mikonim person ro
# chandta ro ba ham takhsis midim
name, age, food = person
print(name)
print(age)
print(food)
person2 = ["ali", 26, "eli"]
name, age, food = person2
print(name)
print(age)
print(food)
# dictionary order nadare o nmishe tekrari dasht
dic = {'banana', 'bluebe... | person = ('Nana', 25, 'piza')
(name, age, food) = person
print(name)
print(age)
print(food)
person2 = ['ali', 26, 'eli']
(name, age, food) = person2
print(name)
print(age)
print(food)
dic = {'banana', 'blueberry'}
dic.add('kiwi')
print(dic)
lis = [1, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 8, 6]
no_duplicate = set(lis)
print(no_... |
# -*- coding: utf-8 -*-
def main():
n = int(input())
a_score, b_score = 0, 0
for i in range(n):
ai, bi = map(int, input().split())
if ai > bi:
a_score += ai + bi
elif ai < bi:
b_score += ai + bi
else:
a_score += ai
b_score +... | def main():
n = int(input())
(a_score, b_score) = (0, 0)
for i in range(n):
(ai, bi) = map(int, input().split())
if ai > bi:
a_score += ai + bi
elif ai < bi:
b_score += ai + bi
else:
a_score += ai
b_score += bi
print(a_score... |
UPWARDS = 1
UPDOWN = -1
FARAWAY = 1.0e39
SKYBOX_DISTANCE = 1.0e6
| upwards = 1
updown = -1
faraway = 1e+39
skybox_distance = 1000000.0 |
class Solution:
def checkStraightLine(self, coordinates: [[int]]) -> bool:
(x1, y1), (x2, y2) = coordinates[:2]
for i in range(2, len(coordinates)):
x, y = coordinates[i]
if (y2 - y1) * (x1 - x) != (y1 - y) * (x2 - x1):
return False
return True
| class Solution:
def check_straight_line(self, coordinates: [[int]]) -> bool:
((x1, y1), (x2, y2)) = coordinates[:2]
for i in range(2, len(coordinates)):
(x, y) = coordinates[i]
if (y2 - y1) * (x1 - x) != (y1 - y) * (x2 - x1):
return False
return True |
#coding: utf-8
LEFT = 'left'
X = 'x'
RIGHT = 'right'
WIDTH = 'width'
MAX_WIDTH = 'max_width'
MIN_WIDTH = 'min_width'
INNER_WIDTH = 'inner_width'
CENTER = 'center'
TOP = 'top'
Y = 'y'
BOTTOM = 'bottom'
HEIGHT = 'height'
MAX_HEIGHT = 'max_height'
MIN_HEIGHT = 'min_height'
INNER_HEIGHT = 'inner_height'
MIDDLE = 'middle'
G... | left = 'left'
x = 'x'
right = 'right'
width = 'width'
max_width = 'max_width'
min_width = 'min_width'
inner_width = 'inner_width'
center = 'center'
top = 'top'
y = 'y'
bottom = 'bottom'
height = 'height'
max_height = 'max_height'
min_height = 'min_height'
inner_height = 'inner_height'
middle = 'middle'
grid_size = 'gri... |
#!/usr/bin/python
#
"""
Virtual superclass for all devices
Homepage and documentation: http://dev.moorescloud.com/
Copyright (c) 2013, Mark Pesce.
License: MIT (see LICENSE for details)
"""
__author__ = 'Mark Pesce'
__version__ = '0.1a'
__license__ = 'MIT'
class Device:
def __init__(self, dev):
self.dev = dev
... | """
Virtual superclass for all devices
Homepage and documentation: http://dev.moorescloud.com/
Copyright (c) 2013, Mark Pesce.
License: MIT (see LICENSE for details)
"""
__author__ = 'Mark Pesce'
__version__ = '0.1a'
__license__ = 'MIT'
class Device:
def __init__(self, dev):
self.dev = dev
retur... |
class Solution:
def validPalindrome(self, s: str) -> bool:
l, r = 0, len(s) - 1
while l < r:
if s[l] != s[r]:
return self._validPalindrome(s, l + 1, r) or self._validPalindrome(s, l, r - 1)
l += 1
r -= 1
return True
... | class Solution:
def valid_palindrome(self, s: str) -> bool:
(l, r) = (0, len(s) - 1)
while l < r:
if s[l] != s[r]:
return self._validPalindrome(s, l + 1, r) or self._validPalindrome(s, l, r - 1)
l += 1
r -= 1
return True
def _valid_pa... |
# 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
class Solution:
def isValidBST(self, root: Optional[TreeNode]) -> bool:
ary = []
self.traverse(root, ary)
... | class Solution:
def is_valid_bst(self, root: Optional[TreeNode]) -> bool:
ary = []
self.traverse(root, ary)
return self.is_valid(ary)
def traverse(self, root, ary):
if root.left is not None:
self.traverse(root.left, ary)
ary.append(root.val)
if root.... |
# -*- coding: utf-8 -*-
"""
This module provides the utilities used by the requester.
"""
def make_host(headers, dst_ip):
if "Host" in headers:
return headers["Host"]
elif "host" in headers:
return headers["host"]
else:
return dst_ip
def make_request_url(host, port, uri):
if... | """
This module provides the utilities used by the requester.
"""
def make_host(headers, dst_ip):
if 'Host' in headers:
return headers['Host']
elif 'host' in headers:
return headers['host']
else:
return dst_ip
def make_request_url(host, port, uri):
if 'http://' in host or 'http... |
def solution(N, P):
ans = []
for c in P:
ans.append('S' if c == 'E' else 'E')
return ''.join(ans)
def main():
T = int(input())
for t in range(T):
N, P = int(input()), input()
answer = solution(N, P)
print('Case #' + str(t+1) + ': ' + answer)
if __name__ == '__main... | def solution(N, P):
ans = []
for c in P:
ans.append('S' if c == 'E' else 'E')
return ''.join(ans)
def main():
t = int(input())
for t in range(T):
(n, p) = (int(input()), input())
answer = solution(N, P)
print('Case #' + str(t + 1) + ': ' + answer)
if __name__ == '__m... |
# https://codeforces.com/problemset/problem/1220/A
n, s = int(input()), input()
ones = s.count('n')
zeros = (n-(ones*3))//4
print(f"{'1 '*ones}{'0 '*zeros}") | (n, s) = (int(input()), input())
ones = s.count('n')
zeros = (n - ones * 3) // 4
print(f"{'1 ' * ones}{'0 ' * zeros}") |
# Reverse Nodes in k-Group: https://leetcode.com/problems/reverse-nodes-in-k-group/
# Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
# k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k the... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def reverse_k_group(self, head: ListNode, k: int) -> ListNode:
count = 0
cur = head
while count < k and cur:
cur = cur.next
count += 1
... |
def test_get_building_block_id(case_data):
"""
Test :meth:`.BondInfo.get_building_block_id`.
Parameters
----------
case_data : :class:`.CaseData`
A test case. Holds the bond info to test and the building
block id it should be holding.
Returns
-------
None : :class:`None... | def test_get_building_block_id(case_data):
"""
Test :meth:`.BondInfo.get_building_block_id`.
Parameters
----------
case_data : :class:`.CaseData`
A test case. Holds the bond info to test and the building
block id it should be holding.
Returns
-------
None : :class:`None... |
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
h = {}
for i in s:
h[i] = h.get(i, 0) + 1
for j in t:
if h.get(j, 0) == 0:
return False
else:
h[j] -= 1
for k in h:
if h[k] >= 1:
... | class Solution:
def is_anagram(self, s: str, t: str) -> bool:
h = {}
for i in s:
h[i] = h.get(i, 0) + 1
for j in t:
if h.get(j, 0) == 0:
return False
else:
h[j] -= 1
for k in h:
if h[k] >= 1:
... |
#!/usr/bin/env python
# descriptors from http://www.winning-homebrew.com/beer-flavor-descriptors.html
aroma_basic = [
'malty', 'grainy', 'sweet',
'corn', 'hay', 'straw',
'cracker', 'bicuity',
'caramel', 'toast', 'roast',
'coffee', 'espresso', 'burnt',
'alcohol', 'tobacco', 'gunpowder',
'lea... | aroma_basic = ['malty', 'grainy', 'sweet', 'corn', 'hay', 'straw', 'cracker', 'bicuity', 'caramel', 'toast', 'roast', 'coffee', 'espresso', 'burnt', 'alcohol', 'tobacco', 'gunpowder', 'leather', 'pine', 'grass', 'dank', 'piney', 'floral', 'perfume']
aroma_dark_fruit = ['raisins', 'currant', 'plum', 'dates', 'prunes', '... |
def get_fact(i):
if i==1:
return 1
else:
return i*get_fact(i-1)
t=int(input())
for i in range(t):
x=int(input())
print(get_fact(x)) | def get_fact(i):
if i == 1:
return 1
else:
return i * get_fact(i - 1)
t = int(input())
for i in range(t):
x = int(input())
print(get_fact(x)) |
# /Users/dvs/Dropbox/Code/graphql-py/graphql/parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.5'
_lr_method = 'LALR'
_lr_signature = 'CDC982EBD105CCA216971D7DA325FA06'
_lr_action_items = {'BRACE_L':([0,8,10,11,21,23,24,25,26,27,28,29,30,31,32,33,36,37,50,51,52,58,59,61,67,68,70,... | _tabversion = '3.5'
_lr_method = 'LALR'
_lr_signature = 'CDC982EBD105CCA216971D7DA325FA06'
_lr_action_items = {'BRACE_L': ([0, 8, 10, 11, 21, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 36, 37, 50, 51, 52, 58, 59, 61, 67, 68, 70, 71, 73, 80, 81, 82, 83, 87, 90, 91, 92, 96, 98, 99, 103, 107, 108, 109, 110, 111, 112, 113... |
a = list(map(int, input().split()))
if sum(a) < 22:
print("win")
else:
print("bust")
| a = list(map(int, input().split()))
if sum(a) < 22:
print('win')
else:
print('bust') |
# for holding settings for use later
class IndividualSetting:
settingkey = ""
settingvalue = ""
| class Individualsetting:
settingkey = ''
settingvalue = '' |
#!/usr/bin/env python3
class Evaluate:
def __init__(self):
self.formula = []
self.result = ''
self.error = False
def eval(self, expression):
if (self.percent(expression)):
return self.result
if (self.sum(expression)):
return self.result
... | class Evaluate:
def __init__(self):
self.formula = []
self.result = ''
self.error = False
def eval(self, expression):
if self.percent(expression):
return self.result
if self.sum(expression):
return self.result
if self.substract(expression... |
#!/usr/bin/python3
#https://practice.geeksforgeeks.org/problems/bit-difference/0
def sol(a, b):
"""
Take an XOR, so 1 will be set whereever there is bit diff.
Keep doing AND with the number to check if the last bit is set
"""
c = a^b
count=0
while c:
if c&1:
count+=1
... | def sol(a, b):
"""
Take an XOR, so 1 will be set whereever there is bit diff.
Keep doing AND with the number to check if the last bit is set
"""
c = a ^ b
count = 0
while c:
if c & 1:
count += 1
c = c >> 1
return count |
# https://leetcode.com/explore/learn/card/n-ary-tree/130/traversal/925/
# N-ary Tree Preorder Traversal
#
# Given an n-ary tree, return the preorder traversal of its nodes'
# values.
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = ch... | class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def preorder(self, root):
"""
:type root: Node
:rtype: List[int]
"""
return self.my_preorder(root)
def my_preorder(self, root):
... |
def covert(df, drop, rename, inflow_source):
print(df)
result = df.copy()
outflow = []
inflow = []
for _, row in df.iterrows():
if row.get(inflow_source) >= 0:
inflow.append(row.get(inflow_source))
outflow.append(0)
else:
inflow.append(0)
... | def covert(df, drop, rename, inflow_source):
print(df)
result = df.copy()
outflow = []
inflow = []
for (_, row) in df.iterrows():
if row.get(inflow_source) >= 0:
inflow.append(row.get(inflow_source))
outflow.append(0)
else:
inflow.append(0)
... |
#-*-python-*-
def guild_python_workspace():
native.new_http_archive(
name = "org_pyyaml",
build_file = "//third-party:pyyaml.BUILD",
urls = [
"https://pypi.python.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz",
],
... | def guild_python_workspace():
native.new_http_archive(name='org_pyyaml', build_file='//third-party:pyyaml.BUILD', urls=['https://pypi.python.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz'], strip_prefix='PyYAML-3.12', sha256='592766c6303207a20efc445587778322d7f73... |
#
# PySNMP MIB module ENGENIUS-CLIENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENGENIUS-CLIENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:02:54 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint, constraints_union) ... |
# Habibu-R-ahman
# 7th Jan, 2021
a = float(input())
salary = money = percentage = None
if a <= 400:
salary = a * 1.15
percentage = 15
elif a <= 800:
salary = a * 1.12
percentage = 12
elif a <= 1200:
salary = a * 1.10
percentage = 10
elif a <= 2000:
salary = a * 1.07
percentage = 7
else... | a = float(input())
salary = money = percentage = None
if a <= 400:
salary = a * 1.15
percentage = 15
elif a <= 800:
salary = a * 1.12
percentage = 12
elif a <= 1200:
salary = a * 1.1
percentage = 10
elif a <= 2000:
salary = a * 1.07
percentage = 7
else:
salary = a * 1.04
percenta... |
# -*- coding: utf-8 -*-
"""Top-level package for Generador Ficheros Agencia Tributaria."""
__author__ = """Pau Rosello Van Schoor"""
__email__ = 'paurosello@gmail.com'
__version__ = '0.1.1'
| """Top-level package for Generador Ficheros Agencia Tributaria."""
__author__ = 'Pau Rosello Van Schoor'
__email__ = 'paurosello@gmail.com'
__version__ = '0.1.1' |
def arbitage(plen):
lst1=list(permutations(lst,plen))
for j in [[0]+list(i)+[0] for i in lst1]:
val=1
length=len(j)
print([x+1 for x in j])
index=0
for k in j:
if index+1>=length:
break
print("index:{}, index+1:{},val:{}".format(j[i... | def arbitage(plen):
lst1 = list(permutations(lst, plen))
for j in [[0] + list(i) + [0] for i in lst1]:
val = 1
length = len(j)
print([x + 1 for x in j])
index = 0
for k in j:
if index + 1 >= length:
break
print('index:{}, index+1:{}... |
class Http:
def __init__(self, session):
self.session = session
async def download(self, url: str):
async with self.session.get(url, timeout=10) as res:
if res.status == 200:
return await res.read()
else:
return None
async def get_hea... | class Http:
def __init__(self, session):
self.session = session
async def download(self, url: str):
async with self.session.get(url, timeout=10) as res:
if res.status == 200:
return await res.read()
else:
return None
async def get_he... |
"""
LeetCode Problem: 78. Subsets
Link: https://leetcode.com/problems/subsets/
Language: Python
Written by: Mostofa Adib Shakib
Time Complexity: O(n*2^n)
Space Complexity: O(n*2^n)
"""
# Solution 1
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def recursiveHelper(index, ... | """
LeetCode Problem: 78. Subsets
Link: https://leetcode.com/problems/subsets/
Language: Python
Written by: Mostofa Adib Shakib
Time Complexity: O(n*2^n)
Space Complexity: O(n*2^n)
"""
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def recursive_helper(index, current):
... |
# Pretty lame athlete model
LT = 160
REST_HR = 50
MAX_HR = 175
| lt = 160
rest_hr = 50
max_hr = 175 |
class Solution(object):
def findNthDigit(self, n):
"""
:type n: int
:rtype: int
"""
index = 1
result = 0
digit_num = 9 * 10 ** (index - 1)
while n > digit_num * index:
n -= digit_num * index
result += digit_num
ind... | class Solution(object):
def find_nth_digit(self, n):
"""
:type n: int
:rtype: int
"""
index = 1
result = 0
digit_num = 9 * 10 ** (index - 1)
while n > digit_num * index:
n -= digit_num * index
result += digit_num
in... |
class User:
def __init__(self, id, first_name, last_name, email, account_creation_date):
self.id = id
self.first_name = first_name
self.last_name = last_name
self.email = email
self.account_creation_date = account_creation_date | class User:
def __init__(self, id, first_name, last_name, email, account_creation_date):
self.id = id
self.first_name = first_name
self.last_name = last_name
self.email = email
self.account_creation_date = account_creation_date |
# Copyright (C) 2007 Samuel Abels
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distri... | class Workflowinfo(object):
"""
This class represents a workflow definition.
"""
def __init__(self, handle, **kwargs):
"""
Constructor.
"""
assert not (kwargs.has_key('xml') and kwargs.has_key('file'))
self.id = None
self.handle = handle
self.name... |
frase = 'Curso em video Python'
print(frase[5::2])
print('''jfafj aj fjaljsfkjasj fkasjfkaj sfjsajfljslkjjf
a fsjdfjs flasjfkldjfdjsfjasjfjaskjfsjfk sdkf
sjfsd fskjfs asfjlkds fjsf sdjflksjfslfs
s fslfjklsdjfsjfjlsjfklsjkfksldfk dsjfsdf''')
| frase = 'Curso em video Python'
print(frase[5::2])
print('jfafj aj fjaljsfkjasj fkasjfkaj sfjsajfljslkjjf\na fsjdfjs flasjfkldjfdjsfjasjfjaskjfsjfk sdkf \nsjfsd fskjfs asfjlkds fjsf sdjflksjfslfs\ns fslfjklsdjfsjfjlsjfklsjkfksldfk dsjfsdf') |
BRANCHES = {
'AdditiveExpression' : {
"!" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"(" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"+" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
... | branches = {'AdditiveExpression': {'!': ['MultiplicativeExpression', '_Add_Sub_MultiplicativeExpression_Star'], '(': ['MultiplicativeExpression', '_Add_Sub_MultiplicativeExpression_Star'], '+': ['MultiplicativeExpression', '_Add_Sub_MultiplicativeExpression_Star'], '-': ['MultiplicativeExpression', '_Add_Sub_Multiplica... |
class Solution:
def minSteps(self, s: str, t: str) -> int:
res = 0
dic = {}
for _ in s:
if _ in dic:
dic[_] += 1
else:
dic[_] = 1
for _ in t:
if _ in dic:
dic[_] -= 1
if not dic[_]:
... | class Solution:
def min_steps(self, s: str, t: str) -> int:
res = 0
dic = {}
for _ in s:
if _ in dic:
dic[_] += 1
else:
dic[_] = 1
for _ in t:
if _ in dic:
dic[_] -= 1
if not dic[_]:
... |
# * Daily Coding Problem August 25 2020
# * [Easy] -- Google
# * In linear algebra, a Toeplitz matrix is one in which the elements on
# * any given diagonal from top left to bottom right are identical.
# * Write a program to determine whether a given input is a Toeplitz matrix.
def checkDiagonal(mat, i, j):
r... | def check_diagonal(mat, i, j):
res = mat[i][j]
i += 1
j += 1
rows = len(mat)
cols = len(mat[0])
while i < rows and j < cols:
if mat[i][j] != res:
return False
i += 1
j += 1
return True
def is_toeplitz(mat):
rows = len(mat)
cols = len(mat[0])
f... |
# Initialize sum
sum = 0
# Add 0.01, 0.02, ..., 0.99, 1 to sum
i = 0.01
while i <= 1.0:
sum += i
i = i + 0.01
# Display result
print("The sum is", sum) | sum = 0
i = 0.01
while i <= 1.0:
sum += i
i = i + 0.01
print('The sum is', sum) |
"""
1. For $V>-75$ mV, the derivative is negative.
2. For $V<-75$ mV, the derivative is positive.
3. For $V=-75$ mV, the derivative is equal to $0$ is and a stable point.
""" | """
1. For $V>-75$ mV, the derivative is negative.
2. For $V<-75$ mV, the derivative is positive.
3. For $V=-75$ mV, the derivative is equal to $0$ is and a stable point.
""" |
print('-' * 15)
medida = float(input('Digite uma distancia em metros:'))
centimetros = medida * 100
milimetros = medida * 1000
print('A media de {} corresponde a {:.0f} e {:.0f}'.format(medida, centimetros, milimetros)) | print('-' * 15)
medida = float(input('Digite uma distancia em metros:'))
centimetros = medida * 100
milimetros = medida * 1000
print('A media de {} corresponde a {:.0f} e {:.0f}'.format(medida, centimetros, milimetros)) |
def exponentiation(base, exponent):
if isinstance(base, str) or isinstance(exponent, str):
return "Trying to use strings in calculator"
solution = float(base) ** exponent
return solution
| def exponentiation(base, exponent):
if isinstance(base, str) or isinstance(exponent, str):
return 'Trying to use strings in calculator'
solution = float(base) ** exponent
return solution |
#!/usr/bin/env python
# -*- coding: utf-8
"""
Taxonomy Resolver
:copyright: (c) 2020-2021.
:license: Apache 2.0, see LICENSE for more details.
"""
ncbi_ranks = [
"class",
"cohort",
"family",
"forma",
"genus",
"infraclass",
"infraorder",
"kingdom",
"order",
"parvorder",
"ph... | """
Taxonomy Resolver
:copyright: (c) 2020-2021.
:license: Apache 2.0, see LICENSE for more details.
"""
ncbi_ranks = ['class', 'cohort', 'family', 'forma', 'genus', 'infraclass', 'infraorder', 'kingdom', 'order', 'parvorder', 'phylum', 'section', 'series', 'species group', 'species subgroup', 'species', 'subclass', '... |
# Curbrock's Revenge (5501)
SABITRAMA = 1061005 # NPC ID
CURBROCKS_HIDEOUT_VER3 = 600050020 # MAP ID
CURBROCKS_ESCAPE_ROUTE_VER3 = 600050050 # MAP ID 3
sm.setSpeakerID(SABITRAMA)
if sm.getFieldID() == CURBROCKS_ESCAPE_ROUTE_VER3:
sm.sendSayOkay("Please leave before reaccepting this quest again.")
else:
sm.s... | sabitrama = 1061005
curbrocks_hideout_ver3 = 600050020
curbrocks_escape_route_ver3 = 600050050
sm.setSpeakerID(SABITRAMA)
if sm.getFieldID() == CURBROCKS_ESCAPE_ROUTE_VER3:
sm.sendSayOkay('Please leave before reaccepting this quest again.')
else:
sm.sendNext('The rumors are true. Curbrock has returned, and the ... |
#
# PySNMP MIB module CISCOSB-SECSD-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-SECSD-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:06:01 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ... |
#
# @lc app=leetcode id=680 lang=python3
#
# [680] Valid Palindrome II
#
# @lc code=start
class Solution:
def validPalindrome(self, s: str) -> bool:
l, r = 0, len(s) - 1
while l < r:
if s[l] != s[r]:
pre, las = s[l:r], s[l + 1:r + 1]
return pre[::-1] == p... | class Solution:
def valid_palindrome(self, s: str) -> bool:
(l, r) = (0, len(s) - 1)
while l < r:
if s[l] != s[r]:
(pre, las) = (s[l:r], s[l + 1:r + 1])
return pre[::-1] == pre or las[::-1] == las
else:
l += 1
r... |
# Space/Time O(n), O(nLogn)
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
# Sort intervals
intervals.sort(key=lambda x:x[0])
# start merged list and go through intervals
merged = [intervals[0]]
for si, ei in inter... | class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
intervals.sort(key=lambda x: x[0])
merged = [intervals[0]]
for (si, ei) in intervals:
(sm, em) = merged[-1]
if si <= em:
merged[-1] = (sm, max(em, ei))
else:
... |
start_range = int(input())
stop_range = int(input())
for x in range(start_range, stop_range + 1):
print(f"{(chr(x))}", end=" ") | start_range = int(input())
stop_range = int(input())
for x in range(start_range, stop_range + 1):
print(f'{chr(x)}', end=' ') |
def brackets(sequence: str) -> bool:
brackets_dict = {"]": "[", ")": "(", "}": "{", ">": "<"}
stack = []
for symbol in sequence:
if symbol in "[({<":
stack.append(symbol)
elif symbol in "])}>":
if brackets_dict[symbol] != stack.pop():
return False
... | def brackets(sequence: str) -> bool:
brackets_dict = {']': '[', ')': '(', '}': '{', '>': '<'}
stack = []
for symbol in sequence:
if symbol in '[({<':
stack.append(symbol)
elif symbol in '])}>':
if brackets_dict[symbol] != stack.pop():
return False
... |
def merge(left, right):
m = []
i,j = 0,0
k = 0
while i < len(left) and j < len(right):
# print(left,right,left[i], right[j])
if left[i] <= right[j]:
m.append(left[i])
i+=1
else:
m.append(right[j])
j +=1
if i < len(le... | def merge(left, right):
m = []
(i, j) = (0, 0)
k = 0
while i < len(left) and j < len(right):
if left[i] <= right[j]:
m.append(left[i])
i += 1
else:
m.append(right[j])
j += 1
if i < len(left):
m.extend(left[i:])
if j < len(ri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.