content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def print_formatted(number):
# your code goes here
if number in range (1,100):
l = len(bin(number)[2:])
for i in range (1,n+1):
decimal = str(i).rjust(l)
octal = str(oct(i)[2:]).rjust(l)
hexadecimal = hex(i)[2:].rjust(l)
binary = bin(i)[2:].rjust(l... | def print_formatted(number):
if number in range(1, 100):
l = len(bin(number)[2:])
for i in range(1, n + 1):
decimal = str(i).rjust(l)
octal = str(oct(i)[2:]).rjust(l)
hexadecimal = hex(i)[2:].rjust(l)
binary = bin(i)[2:].rjust(l)
print(deci... |
def get_city_year(p0, perc, delta, p):
years = 1
curr = p0 + p0 * (0.01 * perc) + delta
if curr <= p0: # remember == would imply stagnation
return -1
else:
while curr < p:
curr = curr + curr * (0.01 * perc) + delta
years += 1
return years
print(get_cit... | def get_city_year(p0, perc, delta, p):
years = 1
curr = p0 + p0 * (0.01 * perc) + delta
if curr <= p0:
return -1
else:
while curr < p:
curr = curr + curr * (0.01 * perc) + delta
years += 1
return years
print(get_city_year(1000, 2, -50, 5000))
print(get_cit... |
#First Example - uncomment lines or change values to test the code
phone_balance = 7.62
bank_balance = 104.39
#phone_balance = 12.34
#bank_balance = 25
if phone_balance < 10:
phone_balance += 10
bank_balance -= 10
print(phone_balance)
print(bank_balance)
#Second Example
#change the number to experiment!
numbe... | phone_balance = 7.62
bank_balance = 104.39
if phone_balance < 10:
phone_balance += 10
bank_balance -= 10
print(phone_balance)
print(bank_balance)
number = 145346334
if number % 2 == 0:
print('The number ' + str(number) + ' is even.')
else:
print('The number ' + str(number) + ' is odd.')
age = 35
free_up... |
print('pypypy')
print('pypypy111')
print('pycharm1111')
print('pycharm222')
print('pypypy222')
print('pycharm3333')
print('pypypy333')
hheheheh
# zuishuaidezishi
ssshhhhhhh
| print('pypypy')
print('pypypy111')
print('pycharm1111')
print('pycharm222')
print('pypypy222')
print('pycharm3333')
print('pypypy333')
hheheheh
ssshhhhhhh |
# Design
# a
# stack
# that
# supports
# push, pop, top, and retrieving
# the
# minimum
# element in constant
# time.
#
# Implement
# the
# MinStack
#
#
# class:
#
#
# MinStack()
# initializes
# the
# stack
# object.
# void
# push(int
# val) pushes
# the
# element
# val
# onto
# the
# stack.
# void
# pop()
# removes
# ... | class Minstack:
def __init__(self):
self.stack = []
def push(self, val: int) -> None:
self.stack.append(val)
def pop(self) -> None:
if len(self.stack) > 0:
self.stack.pop()
def top(self) -> int:
if len(self.stack) > 0:
return self.stack[-1]
... |
def baseline_opt_default_args(prob_type):
defaults = {}
defaults['simpleVar'] = 100
defaults['simpleIneq'] = 50
defaults['simpleEq'] = 50
defaults['simpleEx'] = 10000
defaults['nonconvexVar'] = 100
defaults['nonconvexIneq'] = 50
defaults['nonconvexEq'] = 50
defaults['nonconvexEx'] = ... | def baseline_opt_default_args(prob_type):
defaults = {}
defaults['simpleVar'] = 100
defaults['simpleIneq'] = 50
defaults['simpleEq'] = 50
defaults['simpleEx'] = 10000
defaults['nonconvexVar'] = 100
defaults['nonconvexIneq'] = 50
defaults['nonconvexEq'] = 50
defaults['nonconvexEx'] = ... |
class S1C1():
@staticmethod
def ret_true():
return True
@staticmethod
def hex_to_base64(hx):
return "x"
| class S1C1:
@staticmethod
def ret_true():
return True
@staticmethod
def hex_to_base64(hx):
return 'x' |
s = input()
answer = len(s)
k = s.count('a')
for i in range(len(s)):
cnt = 0
for j in range(k):
if s[(i+j)%len(s)] == 'b':
cnt+=1
if cnt < answer:
answer = cnt
print(answer) | s = input()
answer = len(s)
k = s.count('a')
for i in range(len(s)):
cnt = 0
for j in range(k):
if s[(i + j) % len(s)] == 'b':
cnt += 1
if cnt < answer:
answer = cnt
print(answer) |
def math():
i_put = input()
if len(i_put) <= 140:
print('TWEET')
else:
print('MUTE')
if __name__ == '__main__':
math()
| def math():
i_put = input()
if len(i_put) <= 140:
print('TWEET')
else:
print('MUTE')
if __name__ == '__main__':
math() |
'''
A better way to implement the fibonacci series
T(n) = 2n + 2
'''
def fibonacci(n):
# Taking 1st two fibonacci nubers as 0 and 1
FibArray = [0, 1]
while len(FibArray) < n + 1:
FibArray.append(0)
if n <= 1:
return n
else:
if FibArray[n... | """
A better way to implement the fibonacci series
T(n) = 2n + 2
"""
def fibonacci(n):
fib_array = [0, 1]
while len(FibArray) < n + 1:
FibArray.append(0)
if n <= 1:
return n
else:
if FibArray[n - 1] == 0:
FibArray[n - 1] = fibonacci(n - 1)
if FibArray[n - 2... |
eval_cfgs = [
dict(
metrics=dict(type='OPE'),
dataset=dict(type='OTB100'),
hypers=dict(
epoch=list(range(31, 51, 2)),
window=dict(
weight=[0.200, 0.300, 0.400]
)
)
),
] | eval_cfgs = [dict(metrics=dict(type='OPE'), dataset=dict(type='OTB100'), hypers=dict(epoch=list(range(31, 51, 2)), window=dict(weight=[0.2, 0.3, 0.4])))] |
class Solution:
# Enumerate shortest length (Accepted), O(n*l) time, O(l) space (n = len(strs), l = len(shortest str))
def longestCommonPrefix(self, strs: List[str]) -> str:
min_len = min(len(s) for s in strs)
res = ""
for i in range(min_len):
c = strs[0][i]
for s... | class Solution:
def longest_common_prefix(self, strs: List[str]) -> str:
min_len = min((len(s) for s in strs))
res = ''
for i in range(min_len):
c = strs[0][i]
for s in strs:
if s[i] != c:
return res
res += c
re... |
n = int(input("Please enter the size of the table: "))
# print the first row (header)
print(" ", end = "")
for i in range(1, n + 1):
print(" ", i, end = "")
print() # new line
# print the actual table
for row in range(1, n + 1):
# print row number at the beginning of each row
print(" ", row, end =... | n = int(input('Please enter the size of the table: '))
print(' ', end='')
for i in range(1, n + 1):
print(' ', i, end='')
print()
for row in range(1, n + 1):
print(' ', row, end='')
for col in range(1, n + 1):
if col % row == 0:
print(' X', end='')
else:
print(... |
# Copyright 2018 The Fuchsia Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# DO NOT MANUALLY EDIT!
# Generated by //scripts/sdk/bazel/generate.py.
load("@io_bazel_rules_dart//dart/build_rules/internal:pub.bzl", "pub_repository")
d... | load('@io_bazel_rules_dart//dart/build_rules/internal:pub.bzl', 'pub_repository')
def setup_dart():
pub_repository(name='vendor_meta', output='.', package='meta', version='1.1.6', pub_deps=[])
pub_repository(name='vendor_logging', output='.', package='logging', version='0.11.3+2', pub_deps=[])
pub_reposito... |
def split(list):
n = len(list)
if n == 1:
return list, []
middle = int(n/2)
return list[0:middle], list[middle:n]
def merge_sort(list):
if len(list) == 0:
return list
a, b = split(list)
if a == list:
return a
else:
new_a = merge_sort(a)
... | def split(list):
n = len(list)
if n == 1:
return (list, [])
middle = int(n / 2)
return (list[0:middle], list[middle:n])
def merge_sort(list):
if len(list) == 0:
return list
(a, b) = split(list)
if a == list:
return a
else:
new_a = merge_sort(a)
ne... |
# 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
# We would need to create an map out of in-order array to access index easily
class Solution:
# Faster solution
def bu... | class Solution:
def build_tree(self, preorder: List[int], inorder: List[int]) -> TreeNode:
def helper(in_left=0, in_right=len(inorder)):
nonlocal pre_idx
if in_right <= in_left:
return None
node_val = preorder[pre_idx]
node = tree_node(node_v... |
a = 3
b = 4
z = a + b
print(z)
| a = 3
b = 4
z = a + b
print(z) |
expected = 'Jana III Sobieskiego'
a = ' Jana III Sobieskiego '
b = 'ul Jana III SobIESkiego'
c = '\tul. Jana trzeciego Sobieskiego'
d = 'ulicaJana III Sobieskiego'
e = 'UL. JA\tNA 3 SOBIES\tKIEGO'
f = 'UL. jana III SOBiesKIEGO'
g = 'ULICA JANA III SOBIESKIEGO '
h = 'ULICA. JANA III SOBIeskieGO'
i = ' Jana 3 Sobieski... | expected = 'Jana III Sobieskiego'
a = ' Jana III Sobieskiego '
b = 'ul Jana III SobIESkiego'
c = '\tul. Jana trzeciego Sobieskiego'
d = 'ulicaJana III Sobieskiego'
e = 'UL. JA\tNA 3 SOBIES\tKIEGO'
f = 'UL. jana III SOBiesKIEGO'
g = 'ULICA JANA III SOBIESKIEGO '
h = 'ULICA. JANA III SOBIeskieGO'
i = ' Jana 3 Sobieskie... |
#
# PySNMP MIB module CISCO-CALL-TRACKER-TCP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-CALL-TRACKER-TCP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:34:55 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, value_size_constraint, constraints_intersection, single_value_constraint) ... |
def test_index(client):
res = client.get("/")
json_data = res.get_json()
assert json_data["msg"] == "Don't panic"
assert res.status_code == 200
| def test_index(client):
res = client.get('/')
json_data = res.get_json()
assert json_data['msg'] == "Don't panic"
assert res.status_code == 200 |
#!/usr/bin/env python
numbers = [1,2,3,4,5,8,3,2,3,1,1,1]
def bubblesort(numbers):
# Keep a boolean to determine if we switched
switched = True
# One round of sorting
while switched:
switched = False
indexA = 0
indexB = 1
while indexB < len(numbers):
num... | numbers = [1, 2, 3, 4, 5, 8, 3, 2, 3, 1, 1, 1]
def bubblesort(numbers):
switched = True
while switched:
switched = False
index_a = 0
index_b = 1
while indexB < len(numbers):
number_a = numbers[indexA]
number_b = numbers[indexB]
if numberA > nu... |
class Solution:
def transpose(self, A: List[List[int]]) -> List[List[int]]:
output=[]
rows=len(A)
cols=len(A[0])
output=[[0]*rows for i in range(cols)]
for i in range(0,len(A)):
for j in range(0,len(A[0])):
output[j][i]=A[i][j]
return outp... | class Solution:
def transpose(self, A: List[List[int]]) -> List[List[int]]:
output = []
rows = len(A)
cols = len(A[0])
output = [[0] * rows for i in range(cols)]
for i in range(0, len(A)):
for j in range(0, len(A[0])):
output[j][i] = A[i][j]
... |
def Settings( **kwargs ):
return {
'flags': [
'-O3', '-std=gnu11', '-fms-extensions',
'-Wno-microsoft-anon-tag',
'-Iinclude/', '-Ilib/', '-pthread',
'-Wall', '-Werror', '-pedantic']
}
| def settings(**kwargs):
return {'flags': ['-O3', '-std=gnu11', '-fms-extensions', '-Wno-microsoft-anon-tag', '-Iinclude/', '-Ilib/', '-pthread', '-Wall', '-Werror', '-pedantic']} |
schema = {
# Schema definition, of the CLARA items.
'main_scale': {
'type': 'string',
'minlength': 1,
'maxlength': 20,
'required': True
},
'itembank_id': {
'type': 'string',
'minlength': 1,
'maxlength': 4,
'required': True
},
'prese... | schema = {'main_scale': {'type': 'string', 'minlength': 1, 'maxlength': 20, 'required': True}, 'itembank_id': {'type': 'string', 'minlength': 1, 'maxlength': 4, 'required': True}, 'presenting_order': {'type': 'integer', 'required': True}, 'clara_item': {'type': 'string', 'minlength': 1, 'maxlength': 255, 'required': Tr... |
n,d = map(int,raw_input().split())
c = map(int,raw_input().split(' '))
gc = 0
for i in range(len(c)):
if c[i]+d in c and c[i]+2*d in c:
gc+=1
print (gc) | (n, d) = map(int, raw_input().split())
c = map(int, raw_input().split(' '))
gc = 0
for i in range(len(c)):
if c[i] + d in c and c[i] + 2 * d in c:
gc += 1
print(gc) |
{
"targets": [
{
"target_name": "glace",
"sources": [
"target/glace.cc",
],
"include_dirs": [
"target/deps/include",
],
"libraries": [],
"library_dirs": [
"/usr/local/lib"
... | {'targets': [{'target_name': 'glace', 'sources': ['target/glace.cc'], 'include_dirs': ['target/deps/include'], 'libraries': [], 'library_dirs': ['/usr/local/lib']}]} |
OUT_FORMAT_CONVERSION = {
"t": "",
"b": "b",
"u": "bu",
}
| out_format_conversion = {'t': '', 'b': 'b', 'u': 'bu'} |
Scale.default = Scale.egyptian
Root.default = 0
Clock.bpm = 110
~p1 >> play('m', dur=PDur(3,16), sample=[0,2,3])
~p2 >> play('V', dur=1, pan=[-1,1], sample=var([0,2],[24,8]))
~p3 >> play('n', dur=var([.5,.25,.125,2/3],[24,4,2,2]))
p_all.lpf = 0
p_all.rate = .5
~s1 >> space(P[0,3,5,1]+(0,3), dur=4, chop=6, slide=0, e... | Scale.default = Scale.egyptian
Root.default = 0
Clock.bpm = 110
~p1 >> play('m', dur=p_dur(3, 16), sample=[0, 2, 3])
~p2 >> play('V', dur=1, pan=[-1, 1], sample=var([0, 2], [24, 8]))
~p3 >> play('n', dur=var([0.5, 0.25, 0.125, 2 / 3], [24, 4, 2, 2]))
p_all.lpf = 0
p_all.rate = 0.5
~s1 >> space(P[0, 3, 5, 1] + (0, 3), d... |
params = {
# file to load wav from
'file': 'C:/Users/qweis/Documents/GitHub/unknown-pleasures/wavs/famous.wav',
# output file for images
'save_loc': 'covers/frame.png',
# save location for video
'vid_save': 'time_test.mp4',
# number of spacers between each data point
'spacers': 5,
# ... | params = {'file': 'C:/Users/qweis/Documents/GitHub/unknown-pleasures/wavs/famous.wav', 'save_loc': 'covers/frame.png', 'vid_save': 'time_test.mp4', 'spacers': 5, 'offset': 10, 'data_line': 40, 'n_lines': 80, 'noise_frac': 1, 'min_ticks': 5, 'random_noise_range': 1, 'connecting_line_range': 6, 'fps': 30, 'line_width': 3... |
# The Twitter API keys needed to send tweets
# Two applications for the same account are needed,
# since two streamers can't be run on the same account
# main account. needs all privileges
CONSUMER_KEY = "enter your consumer key here"
CONSUMER_SECRET = "enter your secret consumer key here"
ACCESS_TOKEN = "enter your ... | consumer_key = 'enter your consumer key here'
consumer_secret = 'enter your secret consumer key here'
access_token = 'enter your access token here'
access_token_secret = 'enter your secret access token here'
mine_consumer_key = 'enter your consumer key here'
mine_consumer_secret = 'enter your secret consumer key here'
... |
CATEGORIES = {
"all",
"arts",
"automotive",
"baby",
"beauty",
"books",
"boys",
"computers",
"electronics",
"girls",
"health",
"kitchen",
"industrial",
"mens",
"pets",
"sports",
"games",
"travel",
"womens",
}
CATEGORIES_CHOICES = [
("all",... | categories = {'all', 'arts', 'automotive', 'baby', 'beauty', 'books', 'boys', 'computers', 'electronics', 'girls', 'health', 'kitchen', 'industrial', 'mens', 'pets', 'sports', 'games', 'travel', 'womens'}
categories_choices = [('all', 'All'), ('arts', 'Arts'), ('automotive', 'Automotive'), ('baby', 'Baby'), ('beauty', ... |
mensaje = "Registre el nombre del estudiante "
estudiantes = []
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(m... | mensaje = 'Registre el nombre del estudiante '
estudiantes = []
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(mensaje)
estudiantes.append(estudiante)
estudiante = input(m... |
# from https://www.ngdc.noaa.gov/geomag/WMM/data/WMM2020/WMM2020_Report.pdf
EQUATOR_RADIUS = 6378137
FLATTENING = 1 / 298.257223563
EE2 = FLATTENING * (2 - FLATTENING) # eecentricity squared
N_MAX = 12 # degree of expansion
| equator_radius = 6378137
flattening = 1 / 298.257223563
ee2 = FLATTENING * (2 - FLATTENING)
n_max = 12 |
# -*- coding: utf-8 -*-
def suma(num1, num2):
sm = num1 + num2
return sm
print(suma(2,3))
| def suma(num1, num2):
sm = num1 + num2
return sm
print(suma(2, 3)) |
myVariable = 0
def when_started1():
global myVariable
fork_motor_group.spin_to_position(1100, DEGREES, wait=False)
drivetrain.turn_for(RIGHT, 22, DEGREES, wait=True)
# Get goalpost with 2 rings into our zone (22 points)
drivetrain.drive_for(FORWARD, 1200, MM, wait=True)
drivetrain.set... | my_variable = 0
def when_started1():
global myVariable
fork_motor_group.spin_to_position(1100, DEGREES, wait=False)
drivetrain.turn_for(RIGHT, 22, DEGREES, wait=True)
drivetrain.drive_for(FORWARD, 1200, MM, wait=True)
drivetrain.set_drive_velocity(100, PERCENT)
drivetrain.set_turn_velocity(100,... |
def search(f, k, ma):
la = 0
r = ma
while r - la > 1:
d = (la + r) // 2
t = f(d)
if t >= k:
r = d
else:
la = d
return r
a, b, c, x, k = map(int, input().split())
def f(t):
if t > b:
rp = t
elif a <= t and t * (1 + c / 100) >... | def search(f, k, ma):
la = 0
r = ma
while r - la > 1:
d = (la + r) // 2
t = f(d)
if t >= k:
r = d
else:
la = d
return r
(a, b, c, x, k) = map(int, input().split())
def f(t):
if t > b:
rp = t
elif a <= t and t * (1 + c / 100) > b + ... |
#!/usr/bin/env python
class H2O:
def __init__(self):
pass
def hydrogen(self, releaseHydrogen: 'Callable[[], None]') -> None:
# releaseHydrogen() outputs "H". Do not change or remove this line.
releaseHydrogen()
def oxygen(self, releaseOxygen: 'Callable[[], None]') -> No... | class H2O:
def __init__(self):
pass
def hydrogen(self, releaseHydrogen: 'Callable[[], None]') -> None:
release_hydrogen()
def oxygen(self, releaseOxygen: 'Callable[[], None]') -> None:
release_oxygen() |
def longestValidParentheses(s: str) -> int:
result = 0
if not s:
return result
n = len(s)
stack = [-1]
for i in range(n):
if s[i] == "(":
stack.append(i)
else:
stack.pop()
if not stack:
stack.append(i)
else:
... | def longest_valid_parentheses(s: str) -> int:
result = 0
if not s:
return result
n = len(s)
stack = [-1]
for i in range(n):
if s[i] == '(':
stack.append(i)
else:
stack.pop()
if not stack:
stack.append(i)
else:
... |
#!/usr/bin/python3
class FctCheck:
def __init__(self):
pass
def ding_dong(self):
print('')
def _check_me(self, arg):
return True if arg is not None else False
| class Fctcheck:
def __init__(self):
pass
def ding_dong(self):
print('')
def _check_me(self, arg):
return True if arg is not None else False |
def greet(name):
print(f'Good Day, {name}')
name = input('Enter your name: ')
greet(name) | def greet(name):
print(f'Good Day, {name}')
name = input('Enter your name: ')
greet(name) |
def ver1(sum):
if sum == 1501500:
print("Correct!")
return
else:
print("Incorrect")
return
def hint1():
print("Remember to increment the loop in 3s. Also make sure that the last element is 3001, as it will not be included.")
return
def ver2(product):
if product == 430... | def ver1(sum):
if sum == 1501500:
print('Correct!')
return
else:
print('Incorrect')
return
def hint1():
print('Remember to increment the loop in 3s. Also make sure that the last element is 3001, as it will not be included.')
return
def ver2(product):
if product == 4... |
mat = [[x for x in range(4)],
[x for x in range(4,8)],
[x for x in range(8,12)],
[x for x in range(12,16)]]
print(mat)
d = 4
for k in range(0,d):
print("d: ",end=" ")
row , col = range(0,k + 1), range(k,-1,-1)
for i,j in zip(row,col):
print(mat[i][j],end =" ")
... | mat = [[x for x in range(4)], [x for x in range(4, 8)], [x for x in range(8, 12)], [x for x in range(12, 16)]]
print(mat)
d = 4
for k in range(0, d):
print('d: ', end=' ')
(row, col) = (range(0, k + 1), range(k, -1, -1))
for (i, j) in zip(row, col):
print(mat[i][j], end=' ')
print('')
for k in r... |
# class LLNode:
# def __init__(self, val, next=None):
# self.val = val
# self.next = next
class Solution:
def solve(self, node):
count = 0
currentNode = node
while currentNode:
count += 1
currentNode = currentNode.next
return cou... | class Solution:
def solve(self, node):
count = 0
current_node = node
while currentNode:
count += 1
current_node = currentNode.next
return count |
class FastaParser(object):
def __init__(self, in_file):
self.in_file = in_file
try: (".fasta" in in_file) == True
except ValueError:
raise Exception("%s is not a .fasta file." % (in_file))
try: os.path.exists(in_file) == True
except IOError:
raise Exception("%s can not be found." % (in_file))
| class Fastaparser(object):
def __init__(self, in_file):
self.in_file = in_file
try:
('.fasta' in in_file) == True
except ValueError:
raise exception('%s is not a .fasta file.' % in_file)
try:
os.path.exists(in_file) == True
except IOError:... |
class Shape:
def __init__(self):
self.__matrix = [[1]]
self.color = ''
self.xy = [0, 0]
def set_matrix(self, new_matrix):
self.__matrix = new_matrix[:]
def is_colored_block(self, x, y):
return self.__matrix[y][x] == 1
def is_shape(self, x, y):
x -= self... | class Shape:
def __init__(self):
self.__matrix = [[1]]
self.color = ''
self.xy = [0, 0]
def set_matrix(self, new_matrix):
self.__matrix = new_matrix[:]
def is_colored_block(self, x, y):
return self.__matrix[y][x] == 1
def is_shape(self, x, y):
x -= sel... |
# fizzbuzz in python
for i in range(1, 101):
printed = False
if i % 3 == 0:
printed = True
print('Fizz', end='')
if i % 5 == 0:
printed = True
print('Buzz', end='')
if not printed:
print(i, end='')
print()
| for i in range(1, 101):
printed = False
if i % 3 == 0:
printed = True
print('Fizz', end='')
if i % 5 == 0:
printed = True
print('Buzz', end='')
if not printed:
print(i, end='')
print() |
# noinspection PyUnusedLocal
def fizz_buzz(number):
if (number % 3 == 0 or '3' in str(number)) and (number % 5 == 0 or '5' in str(number)):
delux = deluxe(number)
if delux:
return "fizz buzz " + delux
return "fizz buzz"
if number % 3 == 0 or '3' in str(number):
... | def fizz_buzz(number):
if (number % 3 == 0 or '3' in str(number)) and (number % 5 == 0 or '5' in str(number)):
delux = deluxe(number)
if delux:
return 'fizz buzz ' + delux
return 'fizz buzz'
if number % 3 == 0 or '3' in str(number):
delux = deluxe(number)
if d... |
# @file Validate Binary Search Tree
# @brief Given a binary tree, check if it is a valid binary search tree (BST).
# https://leetcode.com/problems/validate-binary-search-tree
'''
Assume a BST is defined as follows:
Left subtree of a node contains only nodes with keys lesser than node's key.
Right subtree of a node c... | """
Assume a BST is defined as follows:
Left subtree of a node contains only nodes with keys lesser than node's key.
Right subtree of a node contains only nodes with keys greater than node's key.
Both the left and right subtrees must also be binary search trees.
"""
def is_valid_bst(self, root, min_val=float('-inf'), ... |
class BatchTaskCreateOutDTO(object):
def __init__(self):
self.taskID = None
def getTaskID(self):
return self.taskID
def setTaskID(self, taskID):
self.taskID = taskID
| class Batchtaskcreateoutdto(object):
def __init__(self):
self.taskID = None
def get_task_id(self):
return self.taskID
def set_task_id(self, taskID):
self.taskID = taskID |
def resolve_path2d(seq1, seq2, path):
'''
Given path dictionary, resolve the aligned sequence pair
(which means it supports only DP2d)
#! NOTE: path[(i, j)] = ('prev_step', (prev_x, prev_y))
@param:
seq1 & seq2: sequences used to generate the path dictionary in method DP2d()
#! seq1: x
... | def resolve_path2d(seq1, seq2, path):
"""
Given path dictionary, resolve the aligned sequence pair
(which means it supports only DP2d)
#! NOTE: path[(i, j)] = ('prev_step', (prev_x, prev_y))
@param:
seq1 & seq2: sequences used to generate the path dictionary in method DP2d()
#! seq1: x
... |
#
# PySNMP MIB module TRAPEZE-NETWORKS-SYSTEM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TRAPEZE-NETWORKS-SYSTEM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:27:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_intersection, single_value_constraint, constraints_union, value_size_constraint) ... |
# model
model = dict(type='ResNet', depth=18, num_classes=10, maxpool=False)
loss = dict(type='CrossEntropyLoss')
# dataset
root = '/path/to/your/dataset'
mean = (0.4914, 0.4822, 0.4465)
std = (0.2023, 0.1994, 0.2010)
batch_size = 512
num_workers = 4
data = dict(
train=dict(
ds_dict=dict(
type=... | model = dict(type='ResNet', depth=18, num_classes=10, maxpool=False)
loss = dict(type='CrossEntropyLoss')
root = '/path/to/your/dataset'
mean = (0.4914, 0.4822, 0.4465)
std = (0.2023, 0.1994, 0.201)
batch_size = 512
num_workers = 4
data = dict(train=dict(ds_dict=dict(type='CIFAR10', root=root, train=True), trans_dict=d... |
# d.update((['two', 'II'], ['four', 4]))
d = {'one': 1, 'two': 2, 'three': 3}
print(d.update((['two', 'II'], ['four', 4])))
print(d)
| d = {'one': 1, 'two': 2, 'three': 3}
print(d.update((['two', 'II'], ['four', 4])))
print(d) |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param head, a ListNode
# @return a list node
def detectCycle(self, head):
if head is None or head.next is None:
return None
sl... | class Solution:
def detect_cycle(self, head):
if head is None or head.next is None:
return None
slow = head
fast = head
while fast is not None and fast.next is not None:
slow = slow.next
fast = fast.next.next
if fast == slow:
... |
BASE_URL = 'https://storyweaver.org.in/api/v1/illustrations-search'
DEFAULT_PAGE_NUM = 1
DEFAULT_PER_PAGE = 10
MAX_PAGE_NUM = 1164
DATA_FOLDER_PATH = '\\Documents\\Github\\Storyweaver\\static\\data\\'
MODEL_FOLDER_PATH = '\\Documents\\Github\\Storyweaver\\model\\'
DETECTED_OBJECT_OUTPUT_PATH = '\\Documents\\Github\\Sto... | base_url = 'https://storyweaver.org.in/api/v1/illustrations-search'
default_page_num = 1
default_per_page = 10
max_page_num = 1164
data_folder_path = '\\Documents\\Github\\Storyweaver\\static\\data\\'
model_folder_path = '\\Documents\\Github\\Storyweaver\\model\\'
detected_object_output_path = '\\Documents\\Github\\Sto... |
class JobService:
def update_status(self):
pass
| class Jobservice:
def update_status(self):
pass |
try:
name, surname = input().split()
print(f"Welcome to our party, {name} {surname}")
except ValueError:
print("You need to enter exactly 2 words. Try again!")
| try:
(name, surname) = input().split()
print(f'Welcome to our party, {name} {surname}')
except ValueError:
print('You need to enter exactly 2 words. Try again!') |
class Status:
def __init__(self, x, y):
self.x = x
self.y = y
self.active = False
def max_y(self):
# Het maximale ei gehalte is
# 1 stapje = 0.30mm
# max = 3 meter
max_mm = 3 * 1000
max_steps = max_mm / 0.30
return max_steps
def set_y(self, y):
self.y = y
f = open('/boot/y.txt', 'w')
f.writ... | class Status:
def __init__(self, x, y):
self.x = x
self.y = y
self.active = False
def max_y(self):
max_mm = 3 * 1000
max_steps = max_mm / 0.3
return max_steps
def set_y(self, y):
self.y = y
f = open('/boot/y.txt', 'w')
f.write(str(y)... |
def MAIN(Number):
if Number > 0:
return Number
return 0
if __name__ == "__main__":
print(
"Hello, World")
MAIN(0)
| def main(Number):
if Number > 0:
return Number
return 0
if __name__ == '__main__':
print('Hello, World')
main(0) |
returnedDate = [ int( x ) for x in input( ).split( ' ' ) ]
dueDate = [ int( x ) for x in input( ).split( ' ' ) ]
fine = 0
if returnedDate[ 2 ] > dueDate[ 2 ]:
fine = 10000
elif returnedDate[ 2 ] < dueDate[ 2 ]:
fine = 0
elif returnedDate[ 2 ] == dueDate[ 2 ] and returnedDate[ 1 ] > dueDate[ 1 ]:
fine = 50... | returned_date = [int(x) for x in input().split(' ')]
due_date = [int(x) for x in input().split(' ')]
fine = 0
if returnedDate[2] > dueDate[2]:
fine = 10000
elif returnedDate[2] < dueDate[2]:
fine = 0
elif returnedDate[2] == dueDate[2] and returnedDate[1] > dueDate[1]:
fine = 500 * (returnedDate[1] - dueDate... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2021 by DeepLn
# Distributed under the MIT software license, see the accompanying
KLINE_INTERVAL = [
"1m",
"3m",
"5m",
"15m",
"30m",
"1h",
"2h",
"4h",
"6h",
"8h",
"12h"... | kline_interval = ['1m', '3m', '5m', '15m', '30m', '1h', '2h', '4h', '6h', '8h', '12h', '1d', '3d', '1w', '1m']
depth = [5, 10, 20, 50, 100, 500, 1000]
contract_type = ['PERPETUAL', 'CURRENT_MONTH', 'NEXT_MONTH', 'CURRENT_QUARTER', 'NEXT_QUARTER']
period = ['5m', '15m', '30m', '1h', '2h', '4h', '6h', '12h', '1d']
income... |
# -*- coding: utf-8 -*-
# Author: XuMing <shibing624@126.com>
# Data: 17/10/15
# Brief:
with open("1.txt", "r", encoding="utf-8") as f:
for i in f:
parts = i.strip().split("\t")
print(parts[22])
| with open('1.txt', 'r', encoding='utf-8') as f:
for i in f:
parts = i.strip().split('\t')
print(parts[22]) |
donor_dict = \
{
1: 3,
2: 6,
3: 9,
4: 12,
5: 11,
6: 8,
7: 5,
8: 2,
9: 1,
10: 4,
11: 7,
12: 10,
}
cell_dict = {
'CD68': {
'legend': "Macrophage (CD68+)",
'full': "Macrophage (CD68+)",
'sho... | donor_dict = {1: 3, 2: 6, 3: 9, 4: 12, 5: 11, 6: 8, 7: 5, 8: 2, 9: 1, 10: 4, 11: 7, 12: 10}
cell_dict = {'CD68': {'legend': 'Macrophage (CD68+)', 'full': 'Macrophage (CD68+)', 'short': 'Macrophage', 'group': 'Immune Cells', 'color': 'gold', 'marker': 'circle', 'size': 15.89, 'histogram_location': [3, 1]}, 'CD31': {'leg... |
# File type implements the Context Manager Protocol
# can therefore use a file in a with as statement
with open('myfile.txt', 'r') as f:
lines = f.readlines()
for line in lines:
print(line, end='')
print('Done')
| with open('myfile.txt', 'r') as f:
lines = f.readlines()
for line in lines:
print(line, end='')
print('Done') |
class Solution:
def numberOfSubarrays(self, nums: 'List[int]', k: int) -> int:
odds = []
x = 0
for i, num in enumerate(nums):
if num % 2 == 1:
odds.append(x)
x = 0
else:
x += 1
odds.append(x)
res = 0
... | class Solution:
def number_of_subarrays(self, nums: 'List[int]', k: int) -> int:
odds = []
x = 0
for (i, num) in enumerate(nums):
if num % 2 == 1:
odds.append(x)
x = 0
else:
x += 1
odds.append(x)
res = 0... |
# the following file holds meta information about the sunpy package
sunpy_releases = {'0.9': '2018/04/22', '0.8': '2017/08/17', '0.7': '2016/05/24', '0.6': '2015/07/21',
'0.5': '2014/06/13', '0.4': '2014/02/14', '0.3': '2013/08/30',
'0.2': '2012/11/26', '0.1': '2011/09/28'}
repo_pa... | sunpy_releases = {'0.9': '2018/04/22', '0.8': '2017/08/17', '0.7': '2016/05/24', '0.6': '2015/07/21', '0.5': '2014/06/13', '0.4': '2014/02/14', '0.3': '2013/08/30', '0.2': '2012/11/26', '0.1': '2011/09/28'}
repo_path = '/Users/sdchris1/Developer/repositories/sunpy/' |
def parse(filename: str):
with open(filename) as file:
fileLines = file.read().split('\n')
width, height = len(fileLines[0]), len(fileLines)
eastHerd, southHerd = set(), set()
for y, line in enumerate(fileLines):
for x, char in enumerate(line):
if char ==... | def parse(filename: str):
with open(filename) as file:
file_lines = file.read().split('\n')
(width, height) = (len(fileLines[0]), len(fileLines))
(east_herd, south_herd) = (set(), set())
for (y, line) in enumerate(fileLines):
for (x, char) in enumerate(line):
... |
USES_BASE64 = True
REDIRECT = None
AUTHOR = 'BrocaProgs'
APPNAME = 'PyQt_Socius'
| uses_base64 = True
redirect = None
author = 'BrocaProgs'
appname = 'PyQt_Socius' |
#!/usr/bin/env python
# encoding: utf-8
def run(whatweb, pluginname):
whatweb.recog_from_content(pluginname, "dedecms")
whatweb.recog_from_file(pluginname, "templets/default/style/dedecms.css", "DedeCMS")
| def run(whatweb, pluginname):
whatweb.recog_from_content(pluginname, 'dedecms')
whatweb.recog_from_file(pluginname, 'templets/default/style/dedecms.css', 'DedeCMS') |
# Python function to print leaders in array
def printLeaders(l, size):
m=[]
max_element = l[size-1]
m.append(max_element)
for i in range(size-2, -1, -1):
if max_element <= l[i]:
m.append(l[i])
max_element = l[i]
for k in range(len(m)-1... | def print_leaders(l, size):
m = []
max_element = l[size - 1]
m.append(max_element)
for i in range(size - 2, -1, -1):
if max_element <= l[i]:
m.append(l[i])
max_element = l[i]
for k in range(len(m) - 1, -1, -1):
print(m[k], end=' ')
arr = [16, 17, 4, 3, 5, 2]
p... |
class Parser:
def __init__(self):
pass
def parse(self, record):
raise NotImplementedError('the parse method should be implemented by subclasses')
class Success(Parser):
def __init__(self):
super().__init__()
def parse(self, record):
return [('', record)]
class Pre... | class Parser:
def __init__(self):
pass
def parse(self, record):
raise not_implemented_error('the parse method should be implemented by subclasses')
class Success(Parser):
def __init__(self):
super().__init__()
def parse(self, record):
return [('', record)]
class Pre... |
a < b < c
x in y
x not in y
x is y
x is not y
x < y
x > y
x >= y
x <= y
x == y
x != y
| a < b < c
x in y
x not in y
x is y
x is not y
x < y
x > y
x >= y
x <= y
x == y
x != y |
# url -> https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/11/ALDS1_11_A
N = int(input().rstrip())
def generateGraph(N):
graph = [[0]*N for _ in range(N)]
for _ in range(N):
U, A, *B = map(int, input().rstrip().split())
for i in range(A):
graph[U-1][B[i]-1] = 1
... | n = int(input().rstrip())
def generate_graph(N):
graph = [[0] * N for _ in range(N)]
for _ in range(N):
(u, a, *b) = map(int, input().rstrip().split())
for i in range(A):
graph[U - 1][B[i] - 1] = 1
return graph
result = generate_graph(N)
for i in range(len(result)):
print(*r... |
# Copyright 2016 Anselm Binninger, Thomas Maier, Ralph Schaumann
#
# 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
#
# Unless required by appl... | __author__ = 'Anselm Binninger, Thomas Maier, Ralph Schaumann'
message_code_announce = 500
message_code_notify = 501
message_code_notification = 502
message_code_validation = 503
message_code_peer_request = 510
message_code_peer_response = 511
message_code_peer_update = 512
message_code_peer_init = 513
message_code_gos... |
#! Metanit.com - Python: Chapter 2, lesson 3 "Operations with Numbers".
y = 0x0a # hexadecimal system, 11
a = 0o11 # octal system, 9
x = 0b101 # binary system, 5
z = x + y
# Awesome string formatters.
print("{0} in binary {0:08b}; in hex {0:02x} in octal {0:02o}".format(z))
# {:n} - 'n' indicates h... | y = 10
a = 9
x = 5
z = x + y
print('{0} in binary {0:08b}; in hex {0:02x} in octal {0:02o}'.format(z))
number = 3 + 4 * 5 ** 2 + 7
print(number)
number = (3 + 4) * (5 ** 2 + 7)
print(number)
number = 12
number += 5
print(number)
number -= 3
print(number)
number *= 4
print(number)
number //= 9
print(number)
number **= 4... |
# Python - 3.6.0
test.assert_equals(string_to_number('1234'), 1234)
test.assert_equals(string_to_number('605'), 605)
test.assert_equals(string_to_number('1405'), 1405)
test.assert_equals(string_to_number('1234'), 1234)
| test.assert_equals(string_to_number('1234'), 1234)
test.assert_equals(string_to_number('605'), 605)
test.assert_equals(string_to_number('1405'), 1405)
test.assert_equals(string_to_number('1234'), 1234) |
def get_formatted(first_name, last_name):
full_name = first_name + ' ' + last_name
return full_name.title()
while True:
print('Please tell me your name:')
# print('Press "q" to quit')
f_name = input('Fist Name: ')
l_name = input('Last Name: ')
formatted_name = get_formatted(f_name, l_name)... | def get_formatted(first_name, last_name):
full_name = first_name + ' ' + last_name
return full_name.title()
while True:
print('Please tell me your name:')
f_name = input('Fist Name: ')
l_name = input('Last Name: ')
formatted_name = get_formatted(f_name, l_name)
print('Hello, ' + formatted_na... |
find_sum_of_squearse = lambda x, y: x**2 + y**2
print(find_sum_of_squearse(3, 5))
words = ["hello", "monkey", "python"]
wordsSort = max(words, key = lambda x: x.count("1"))
print(wordsSort) | find_sum_of_squearse = lambda x, y: x ** 2 + y ** 2
print(find_sum_of_squearse(3, 5))
words = ['hello', 'monkey', 'python']
words_sort = max(words, key=lambda x: x.count('1'))
print(wordsSort) |
class KomodoRPC:
node_addr = '127.0.0.1'
rpc_port = 7777
req_method = 'POST'
rpc_username = ''
rpc_password = ''
req_auth = {
'user': rpc_username,
'pass': rpc_password
}
req_url = 'http://{0}:{1}/'.format(str(node_addr), str(rpc_port))
req_headers = {
... | class Komodorpc:
node_addr = '127.0.0.1'
rpc_port = 7777
req_method = 'POST'
rpc_username = ''
rpc_password = ''
req_auth = {'user': rpc_username, 'pass': rpc_password}
req_url = 'http://{0}:{1}/'.format(str(node_addr), str(rpc_port))
req_headers = {'content-type': 'text/plain;'}
jso... |
def josephus(n, k):
q = [i for i in range(1, n + 1)]
j = 0
while len(q) > 1:
j = (j + k - 1) % len(q)
q.pop(j)
return q[0]
print(josephus(41, 3)) | def josephus(n, k):
q = [i for i in range(1, n + 1)]
j = 0
while len(q) > 1:
j = (j + k - 1) % len(q)
q.pop(j)
return q[0]
print(josephus(41, 3)) |
# Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
#
# Example 1:
#
# Input: "Let's take LeetCode contest"
# Output: "s'teL ekat edoCteeL tsetnoc"
#
#
#
# Note:
# In the string, each word is separated by single spac... | class Solution:
def reverse_words(self, s: str) -> str:
if not s or s == ' ' or len(s) is 1:
return s
result = ''
tmp = ''
for c in s:
if c == ' ':
result += tmp[::-1] + ' '
tmp = ''
else:
tmp += c
... |
#python program to print strings and type
str1 = "Hi my name is Matthew. I am String"
str2 = 'Hi my name is Precious. I am also String'
#displaying string str1 and its type
print(str1)
print(type(str1))
#displaying string str1 and its type
print(str2)
print(type(str2))
| str1 = 'Hi my name is Matthew. I am String'
str2 = 'Hi my name is Precious. I am also String'
print(str1)
print(type(str1))
print(str2)
print(type(str2)) |
# Define a String
str = "python"
# Convert String in Upper Case and assign to variable strupper
strupper = str.upper();
# Print both the original and the converted fields
print(str+ " is converted to the Upper Case as "+ strupper);
| str = 'python'
strupper = str.upper()
print(str + ' is converted to the Upper Case as ' + strupper) |
Search_Amish={
'Amish+Romance':['http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+Romance&page=1','http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+Romance&page=2','http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+Romance&page=3','http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+... | search__amish = {'Amish+Romance': ['http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+Romance&page=1', 'http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+Romance&page=2', 'http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3AAmish+Romance&page=3', 'http://www.amazon.com/s/ref=sr_pg_5?rh=i%3Aaps%2Ck%3A... |
def find(searchList, elem):
endList = []
for indElem in range(0,len(elem)):
resultList = []
for ind in range(0, len(searchList)):
if searchList[ind] == elem[indElem]:
resultList.append(ind)
endList.extend([resultList])
retur... | def find(searchList, elem):
end_list = []
for ind_elem in range(0, len(elem)):
result_list = []
for ind in range(0, len(searchList)):
if searchList[ind] == elem[indElem]:
resultList.append(ind)
endList.extend([resultList])
return endList |
#!/usr/bin/env python
# vim: ai ts=4 sts=4 et sw=4
title = "AJAX Helper"
host = "localhost"
port = 8001
| title = 'AJAX Helper'
host = 'localhost'
port = 8001 |
Names = ["John","Steve","Brian","Jim","Alex","Paul","Micheal","Bruce","Alfred","Buzz","Eric","Gary"]
Nombre = [i for i in range(1,1000000)]
def affiche(names):
for name in names:
yield name
def nextSquare():
i = 1;
# An Infinite loop to generate squares
while True:
yield i*i
i... | names = ['John', 'Steve', 'Brian', 'Jim', 'Alex', 'Paul', 'Micheal', 'Bruce', 'Alfred', 'Buzz', 'Eric', 'Gary']
nombre = [i for i in range(1, 1000000)]
def affiche(names):
for name in names:
yield name
def next_square():
i = 1
while True:
yield (i * i)
i += 1
def main():
test ... |
#
# #
def palindrom(word):
try:
word = word[::-1]
except TypeError:
print("I execute myself only if an exception happens")
print("You can't type only strings")
else:
print("I just execute myself only if no exceptions happens")
print(word)
finally:
print(... | def palindrom(word):
try:
word = word[::-1]
except TypeError:
print('I execute myself only if an exception happens')
print("You can't type only strings")
else:
print('I just execute myself only if no exceptions happens')
print(word)
finally:
print('I alway... |
def normal_function(func):
print(func(10))
normal_function(lambda value: 10 + value)
def normal_function2(func, *args):
for argument in args:
print(func(argument))
normal_function2(lambda value: value / 5, 10, 15, 20, 25, 30, 35, 40, 45, 50)
def normal_function3(func, *args):
for argument in ar... | def normal_function(func):
print(func(10))
normal_function(lambda value: 10 + value)
def normal_function2(func, *args):
for argument in args:
print(func(argument))
normal_function2(lambda value: value / 5, 10, 15, 20, 25, 30, 35, 40, 45, 50)
def normal_function3(func, *args):
for argument in args:... |
# Theory: Class instances
# By now, you already know what classes are and how they're
# created and used in Python, Now let's get into the details about
# class instances.
# A class instance is an object of the class. If, for example, there
# was a class River, we could create such instances as Volga,
# Seine, and Ni... | class River:
all_rivers = []
def __init__(self, name, length):
self.name = name
self.length = length
River.all_rivers.append(self)
volga = river('Volga', 3530)
seine = river('Seine', 776)
nile = river('Nile', 6852)
for river in River.all_rivers:
print(river.name)
class River:
a... |
#From https://notepad-plus-plus.org/community/topic/14501/has-a-plugin-like-sublime-plugin-brackethighlighter/7
try:
BH__dict
except NameError:
BH__dict = dict()
BH__dict['indic_for_box_at_caret'] = 10 # pick a free indicator number
def indicatorOptionsSet(indicator_number, indicator_style, rgb_c... | try:
BH__dict
except NameError:
bh__dict = dict()
BH__dict['indic_for_box_at_caret'] = 10
def indicator_options_set(indicator_number, indicator_style, rgb_color_tup, alpha, outline_alpha, draw_under_text, which_editor=editor):
which_editor.indicSetStyle(indicator_number, indicator_style)
... |
class Solution:
def evalRPN(self, tokens: List[str]) -> int:
num_stack = []
for token in tokens:
if token in "+-*/":
num2, num1 = num_stack.pop(), num_stack.pop()
if token == "+":
num_stack.append(num1 + num2)
el... | class Solution:
def eval_rpn(self, tokens: List[str]) -> int:
num_stack = []
for token in tokens:
if token in '+-*/':
(num2, num1) = (num_stack.pop(), num_stack.pop())
if token == '+':
num_stack.append(num1 + num2)
elif... |
#
# @lc app=leetcode id=221 lang=python3
#
# [221] Maximal Square
#
# @lc code=start
class Solution:
def maximalSquare(self, matrix: List[List[str]]) -> int:
for i in range(len(matrix)):
for j in range(len(matrix[0])):
matrix[i][j] = int(matrix[i][j])
if i and ... | class Solution:
def maximal_square(self, matrix: List[List[str]]) -> int:
for i in range(len(matrix)):
for j in range(len(matrix[0])):
matrix[i][j] = int(matrix[i][j])
if i and j and matrix[i][j]:
matrix[i][j] = min(matrix[i - 1][j - 1], matri... |
seq_to_protein = dict(
AUG="Methionine",
UUU="Phenylalanine",
UUC="Phenylalanine",
UUA="Leucine",
UUG="Leucine",
UCU="Serine",
UCC="Serine",
UCA="Serine",
UCG="Serine",
UAU="Tyrosine",
UAC="Tyrosine",
UGU="Cysteine",
UGC="Cysteine",
UGG="Tryptophan",
UAA="STOP... | seq_to_protein = dict(AUG='Methionine', UUU='Phenylalanine', UUC='Phenylalanine', UUA='Leucine', UUG='Leucine', UCU='Serine', UCC='Serine', UCA='Serine', UCG='Serine', UAU='Tyrosine', UAC='Tyrosine', UGU='Cysteine', UGC='Cysteine', UGG='Tryptophan', UAA='STOP', UAG='STOP', UGA='STOP')
def get_sequences(strand: str):
... |
poly = [2, 8]
const = 5
out = [const]
for index in range(len(poly)):
out.append(poly[index] / (index + 1))
print(out) | poly = [2, 8]
const = 5
out = [const]
for index in range(len(poly)):
out.append(poly[index] / (index + 1))
print(out) |
token = '1111:example'
# @ShowJsonBot
chat_ids = [12345]
games = [
'monopoly',
]
| token = '1111:example'
chat_ids = [12345]
games = ['monopoly'] |
#
# Write a query that returns all the species in the zoo, and how many animals of
# each species there are, sorted with the most populous species at the top.
#
# The result should have two columns: species and number.
#
# The animals table has columns (name, species, birthdate) for each individual.
#
QUERY ... | query = 'select species, count(species) number from animals group by species order by number desc' |
while True:
numero=int(input(""))
if(numero==2002):
print("Accceso Permitido")
break
else:
print("Senha Invalida") | while True:
numero = int(input(''))
if numero == 2002:
print('Accceso Permitido')
break
else:
print('Senha Invalida') |
x = 25
epsilon = 0.01
#step = epsilon ** 2
numGuesses = 0
low = 0
high = max(1, x)
ans = (high + low) / 2
while abs(ans**2 - x) >= epsilon:
print(f"low = {low}, high ={high} , ans = {ans}")
numGuesses += 1
if ans**2 < x :
low = ans
else:
high = ans
ans = (high + low) / 2
print(numG... | x = 25
epsilon = 0.01
num_guesses = 0
low = 0
high = max(1, x)
ans = (high + low) / 2
while abs(ans ** 2 - x) >= epsilon:
print(f'low = {low}, high ={high} , ans = {ans}')
num_guesses += 1
if ans ** 2 < x:
low = ans
else:
high = ans
ans = (high + low) / 2
print(numGuesses)
print(f' {... |
# The optimized implementation
def fib(n):
if (n == 1 or n == 2):
return 1
prev = 1
curr = 1
for i in range(2, n):
sums = prev + curr
prev = curr
curr = sums
return curr
print(fib(50))
| def fib(n):
if n == 1 or n == 2:
return 1
prev = 1
curr = 1
for i in range(2, n):
sums = prev + curr
prev = curr
curr = sums
return curr
print(fib(50)) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.