content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def is_even_with_return(i):
print('with return')
remainder = i % 2
return remainder == 0
print(is_even_with_return(132))
def is_even(i):
return i % 2 == 0
print("All numbers between 0 and 20: even or not")
for i in range(20):
if is_even(i):
print(i, "even")
else:
print(i, "odd... | def is_even_with_return(i):
print('with return')
remainder = i % 2
return remainder == 0
print(is_even_with_return(132))
def is_even(i):
return i % 2 == 0
print('All numbers between 0 and 20: even or not')
for i in range(20):
if is_even(i):
print(i, 'even')
else:
print(i, 'odd')... |
class Solution:
def firstBadVersion(self, n):
if n == 1:
return 1
l, r = 2, n
while l <= r:
mid = (l + r) // 2
if isBadVersion(mid) and not isBadVersion(mid - 1):
return mid
elif isBadVersion(mid):
r = mid - 1... | class Solution:
def first_bad_version(self, n):
if n == 1:
return 1
(l, r) = (2, n)
while l <= r:
mid = (l + r) // 2
if is_bad_version(mid) and (not is_bad_version(mid - 1)):
return mid
elif is_bad_version(mid):
... |
class Obstacle:
def __init__(self, clearance):
self.x = 10
self.y = 10
self.clearance = clearance
self.robot_radius = 0.354 / 2
self.clearance = self.robot_radius + self.clearance
self.dynamic_Obstacle = False
# self.rect1_corner1_x = 3
# self.rect1... | class Obstacle:
def __init__(self, clearance):
self.x = 10
self.y = 10
self.clearance = clearance
self.robot_radius = 0.354 / 2
self.clearance = self.robot_radius + self.clearance
self.dynamic_Obstacle = False
self.rect1_corner1_x = 0
self.rect1_corne... |
def f(*, b):
return b
def f(a, *, b):
return a + b
def f(a, *, b, c):
return a + b + c
def f(a, *, b=c):
return a + b
def f(a, *, b=c, c):
return a + b + c
def f(a, *, b=c, c=d):
return a + b + c
def f(a, *, b=c, c, d=e):
return a + b + c + d
def f(a=None, *, b=None):
return a + b... | def f(*, b):
return b
def f(a, *, b):
return a + b
def f(a, *, b, c):
return a + b + c
def f(a, *, b=c):
return a + b
def f(a, *, b=c, c):
return a + b + c
def f(a, *, b=c, c=d):
return a + b + c
def f(a, *, b=c, c, d=e):
return a + b + c + d
def f(a=None, *, b=None):
return a + b |
# Sort the entries of medals: medals_sorted
medals_sorted = medals.sort_index(level=0)
# Print the number of Bronze medals won by Germany
print(medals_sorted.loc[('bronze','Germany')])
# Print data about silver medals
print(medals_sorted.loc['silver'])
# Create alias for pd.IndexSlice: idx
idx = pd.IndexSl... | medals_sorted = medals.sort_index(level=0)
print(medals_sorted.loc['bronze', 'Germany'])
print(medals_sorted.loc['silver'])
idx = pd.IndexSlice
print(medals_sorted.loc[idx[:, 'United Kingdom'], :]) |
class WebSocketDefine:
Uri = "wss://sdstream.binance.com/stream"
# testnet new spec
# Uri = "wss://sdstream.binancefuture.com/stream"
class RestApiDefine:
Url = "https://dapi.binance.com"
# testnet
# Url = "https://testnet.binancefuture.com"
| class Websocketdefine:
uri = 'wss://sdstream.binance.com/stream'
class Restapidefine:
url = 'https://dapi.binance.com' |
s = input()
y, m, d = map(int, s.split('/'))
f = False
(
Heisei,
TBD,
)= (
'Heisei',
'TBD',
)
if y < 2019:
print(Heisei)
elif y == 2019:
if(m < 4):
print(Heisei)
elif m == 4:
if(d <= 30):
print(Heisei)
else :
print(TBD)
else :
print... | s = input()
(y, m, d) = map(int, s.split('/'))
f = False
(heisei, tbd) = ('Heisei', 'TBD')
if y < 2019:
print(Heisei)
elif y == 2019:
if m < 4:
print(Heisei)
elif m == 4:
if d <= 30:
print(Heisei)
else:
print(TBD)
else:
print(TBD)
else:
print(T... |
rfm69SpiBus = 0
rfm69NSS = 5 # GPIO5 == pin 7
rfm69D0 = 9 # GPIO9 == pin 12
rfm69RST = 8 # GPIO8 == pin 11
am2302 = 22 # GPIO22 == pin 29
voltADC = 26 # GPIO26 == pin 31 | rfm69_spi_bus = 0
rfm69_nss = 5
rfm69_d0 = 9
rfm69_rst = 8
am2302 = 22
volt_adc = 26 |
# Hack 3: create your own math function
# Function is superfactorial: superfactorial is product of all factorials until n.
# OOP method
class superFactorial():
def __init__(self,n):
self.n = n
def factorial(self,y):
y = self.n if y is None else y
product = 1
for x in range(1,y... | class Superfactorial:
def __init__(self, n):
self.n = n
def factorial(self, y):
y = self.n if y is None else y
product = 1
for x in range(1, y + 1):
product *= x
return product
def __call__(self):
product = 1
for x in range(1, self.n + 1... |
# -*- Mode:Python;indent-tabs-mode:nil; -*-
#
# File: psaExceptions.py
# Created: 05/09/2014
# Author: BSC
#
# Description:
# Custom execption class to manage error in the PSC
#
class psaExceptions( object ):
class confRetrievalFailed( Exception ):
pass
| class Psaexceptions(object):
class Confretrievalfailed(Exception):
pass |
# multiply a list by a number
def mul(row, num):
return [x * num for x in row]
# subtract one row from another
def sub(row_left, row_right):
return [a - b for (a, b) in zip(row_left, row_right)]
# calculate the row echelon form of the matrix
def echelonify(rw, i, m):
for j, row in enum... | def mul(row, num):
return [x * num for x in row]
def sub(row_left, row_right):
return [a - b for (a, b) in zip(row_left, row_right)]
def echelonify(rw, i, m):
for (j, row) in enumerate(m[i + 1:]):
j += 1
if rw[i] != 0:
m[j + i] = sub(row, mul(rw, row[i] / rw[i]))
return rw
... |
ans = 0
a=input()
for _ in range(int(input())):
s=input()
for start in range(10):
for j in range(len(a)):
if a[j] != s[(start+j)%10]:
break
else:
ans+=1
break
print(ans) | ans = 0
a = input()
for _ in range(int(input())):
s = input()
for start in range(10):
for j in range(len(a)):
if a[j] != s[(start + j) % 10]:
break
else:
ans += 1
break
print(ans) |
# Easy
# Runtime: 32 ms, faster than 73.01% of Python3 online submissions for Count and Say.
# Memory Usage: 12.9 MB, less than 100.00% of Python3 online submissions for Count and Say.
class Solution:
def countAndSay(self, n: int) -> str:
def count_and_say(n):
if n == 1:
return ... | class Solution:
def count_and_say(self, n: int) -> str:
def count_and_say(n):
if n == 1:
return '1'
cur_s = ''
idx = 0
cur_sum = 0
s = count_and_say(n - 1)
for (i, ch) in enumerate(s):
if ch != s[idx]:
... |
class PlannerEventHandler(object):
pass
def ProblemNotImplemented(self):
return False
def StartedPlanning(self):
return True
def SubmittedPipeline(self, pipeline):
return True
def RunningPipeline(self, pipeline):
return True
def CompletedPipeline(self, pipeli... | class Plannereventhandler(object):
pass
def problem_not_implemented(self):
return False
def started_planning(self):
return True
def submitted_pipeline(self, pipeline):
return True
def running_pipeline(self, pipeline):
return True
def completed_pipeline(self, ... |
def minSubArrayLen(target, nums):
length = list()
for i in range(len(nums)):
remain = target - nums[i]
if remain <= 0:
length.append(1)
continue
for j in range(i+1, len(nums)):
remain = remain - nums[j]
if remain <= 0:
len... | def min_sub_array_len(target, nums):
length = list()
for i in range(len(nums)):
remain = target - nums[i]
if remain <= 0:
length.append(1)
continue
for j in range(i + 1, len(nums)):
remain = remain - nums[j]
if remain <= 0:
... |
# -*- coding: UTF-8 -*-
class Shared(object):
'''
Class used for /hana/shared attributes.
Attributes and methods are passed to other LVM Classes.
'''
name = 'shared'
vg_physical_extent_size = '-s 1M'
vg_data_alignment = '--dataalignment 1M'
vg_args = vg_physical_extent... | class Shared(object):
"""
Class used for /hana/shared attributes.
Attributes and methods are passed to other LVM Classes.
"""
name = 'shared'
vg_physical_extent_size = '-s 1M'
vg_data_alignment = '--dataalignment 1M'
vg_args = vg_physical_extent_size + ' ' + vg_data_alignment
lv_size = '-l 10... |
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
shortest = min(strs, key=len)
longest_common = ""
for idx, char in enumerate(shortest):
for word in strs:
if word[idx] != char:
return longest_common
longest_co... | class Solution:
def longest_common_prefix(self, strs: List[str]) -> str:
shortest = min(strs, key=len)
longest_common = ''
for (idx, char) in enumerate(shortest):
for word in strs:
if word[idx] != char:
return longest_common
longes... |
class Solution:
def uniqueOccurrences(self, arr: List[int]) -> bool:
dict = {}
for i in arr :
if i in dict :
dict[i] += 1
else :
dict[i] = 1
count = 0
s = set(dict.values())
ns = len(s)
nl = len(... | class Solution:
def unique_occurrences(self, arr: List[int]) -> bool:
dict = {}
for i in arr:
if i in dict:
dict[i] += 1
else:
dict[i] = 1
count = 0
s = set(dict.values())
ns = len(s)
nl = len(dict.values())
... |
test = { 'name': 'q1d',
'points': 1,
'suites': [ { 'cases': [ {'code': ">>> species_by_island.labels == ('species', 'Biscoe', 'Dream', 'Torgersen')\nTrue", 'hidden': False, 'locked': False},
{'code': ">>> np.all(species_by_island.column('Biscoe') == np.array([44, 0, 11... | test = {'name': 'q1d', 'points': 1, 'suites': [{'cases': [{'code': ">>> species_by_island.labels == ('species', 'Biscoe', 'Dream', 'Torgersen')\nTrue", 'hidden': False, 'locked': False}, {'code': ">>> np.all(species_by_island.column('Biscoe') == np.array([44, 0, 119]))\nTrue", 'hidden': False, 'locked': False}], 'score... |
# objects here will be mixed into the dynamically created asset type classes
# based on name.
# This lets us extend certain asset types without having to give up the generic
# dynamic meta implementation
class Attachment(object):
def set_blob(self, blob):
return self._v1_v1meta.set_attachment_... | class Attachment(object):
def set_blob(self, blob):
return self._v1_v1meta.set_attachment_blob(self, blob)
def get_blob(self):
return self._v1_v1meta.get_attachment_blob(self)
file_data = property(get_blob, set_blob)
special_classes = locals() |
LOG_EPOCH = 'epoch'
LOG_TRAIN_LOSS = 'train_loss'
LOG_TRAIN_ACC = 'train_acc'
LOG_VAL_LOSS = 'val_loss'
LOG_VAL_ACC = 'val_acc'
LOG_FIELDS = [LOG_EPOCH, LOG_TRAIN_LOSS, LOG_TRAIN_ACC, LOG_VAL_LOSS, LOG_VAL_ACC]
LOG_COLOR_HEADER = '\033[95m'
LOG_COLOR_OKBLUE = '\033[94m'
LOG_COLOR_OKCYAN = '\033[96m'
LOG_COLOR_OKGREEN =... | log_epoch = 'epoch'
log_train_loss = 'train_loss'
log_train_acc = 'train_acc'
log_val_loss = 'val_loss'
log_val_acc = 'val_acc'
log_fields = [LOG_EPOCH, LOG_TRAIN_LOSS, LOG_TRAIN_ACC, LOG_VAL_LOSS, LOG_VAL_ACC]
log_color_header = '\x1b[95m'
log_color_okblue = '\x1b[94m'
log_color_okcyan = '\x1b[96m'
log_color_okgreen =... |
def load(h):
return ({'abbr': 1, 'code': 1, 'title': 'PRES Pressure [hPa]'},
{'abbr': 2, 'code': 2, 'title': 'psnm Pressure reduced to MSL [hPa]'},
{'abbr': 3, 'code': 3, 'title': 'tsps Pressure tendency [Pa/s]'},
{'abbr': 4, 'code': 4, 'title': 'var4 undefined'},
{'a... | def load(h):
return ({'abbr': 1, 'code': 1, 'title': 'PRES Pressure [hPa]'}, {'abbr': 2, 'code': 2, 'title': 'psnm Pressure reduced to MSL [hPa]'}, {'abbr': 3, 'code': 3, 'title': 'tsps Pressure tendency [Pa/s]'}, {'abbr': 4, 'code': 4, 'title': 'var4 undefined'}, {'abbr': 5, 'code': 5, 'title': 'var5 undefined'}, ... |
class Settings:
params = ()
def __init__(self, params):
self.params = params
| class Settings:
params = ()
def __init__(self, params):
self.params = params |
urlChatAdd = '/chat/add'
urlUserAdd = '/chat/adduser'
urlGetUsers = '/chat/getusers/'
urlGetChats = '/chat/chats'
urlPost = '/chat/post'
urlHist = '/chat/hist'
urlAuth = '/chat/auth'
| url_chat_add = '/chat/add'
url_user_add = '/chat/adduser'
url_get_users = '/chat/getusers/'
url_get_chats = '/chat/chats'
url_post = '/chat/post'
url_hist = '/chat/hist'
url_auth = '/chat/auth' |
# 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 applicable law or agreed to in writing, software
# distributed under the Li... | names = {'Cisco': 'cwom'}
mappings = {'cwom': {'1.0': '5.8.3.1', '1.1': '5.9.1', '1.1.3': '5.9.3', '1.2.0': '6.0.3', '1.2.1': '6.0.6', '1.2.2': '6.0.9', '1.2.3': '6.0.11.1', '2.0.0': '6.1.1', '2.0.1': '6.1.6', '2.0.2': '6.1.8', '2.0.3': '6.1.12', '2.1.0': '6.2.2', '2.1.1': '6.2.7.1', '2.1.2': '6.2.10', '2.2': '6.3.2', ... |
try:
with open('../../../assets/img_cogwheel_argb.bin','rb') as f:
cogwheel_img_data = f.read()
except:
try:
with open('images/img_cogwheel_rgb565.bin','rb') as f:
cogwheel_img_data = f.read()
except:
print("Could not find binary img_cogwheel file")
# create the cogwheel image data
cogwheel_im... | try:
with open('../../../assets/img_cogwheel_argb.bin', 'rb') as f:
cogwheel_img_data = f.read()
except:
try:
with open('images/img_cogwheel_rgb565.bin', 'rb') as f:
cogwheel_img_data = f.read()
except:
print('Could not find binary img_cogwheel file')
cogwheel_img_dsc = l... |
int1 = int(input('informe o inteiro 1 '))
int2 = int(input('informe o inteiro 2 '))
real = float(input('informe o real '))
print('a %2.f' %((int1*2)*(int2/2)))
print('b %2.f' %((int1*3)+(real)))
print('c %2.f' %(real**3))
| int1 = int(input('informe o inteiro 1 '))
int2 = int(input('informe o inteiro 2 '))
real = float(input('informe o real '))
print('a %2.f' % (int1 * 2 * (int2 / 2)))
print('b %2.f' % (int1 * 3 + real))
print('c %2.f' % real ** 3) |
data = (
'ruk', # 0x00
'rut', # 0x01
'rup', # 0x02
'ruh', # 0x03
'rweo', # 0x04
'rweog', # 0x05
'rweogg', # 0x06
'rweogs', # 0x07
'rweon', # 0x08
'rweonj', # 0x09
'rweonh', # 0x0a
'rweod', # 0x0b
'rweol', # 0x0c
'rweolg', # 0x0d
'rweolm', # 0x0e
'rweolb', ... | data = ('ruk', 'rut', 'rup', 'ruh', 'rweo', 'rweog', 'rweogg', 'rweogs', 'rweon', 'rweonj', 'rweonh', 'rweod', 'rweol', 'rweolg', 'rweolm', 'rweolb', 'rweols', 'rweolt', 'rweolp', 'rweolh', 'rweom', 'rweob', 'rweobs', 'rweos', 'rweoss', 'rweong', 'rweoj', 'rweoc', 'rweok', 'rweot', 'rweop', 'rweoh', 'rwe', 'rweg', 'rwe... |
class PHPWriter:
def __init__(self, constants):
self.constants = constants
def write(self, out):
out.write("<?php\n")
out.write("/* This file was generated by generate_constants. */\n\n")
for enum in self.constants.enum_values.values():
out.write("\n")
f... | class Phpwriter:
def __init__(self, constants):
self.constants = constants
def write(self, out):
out.write('<?php\n')
out.write('/* This file was generated by generate_constants. */\n\n')
for enum in self.constants.enum_values.values():
out.write('\n')
f... |
Amount = float
BenefitName = str
Email = str
Donor = Email
PaymentId = str
def isnotemptyinstance(value, type):
if not isinstance(value, type):
return False # None returns false
if isinstance(value, str):
return (len(value.strip()) != 0)
elif isinstance(value, int):
return (value... | amount = float
benefit_name = str
email = str
donor = Email
payment_id = str
def isnotemptyinstance(value, type):
if not isinstance(value, type):
return False
if isinstance(value, str):
return len(value.strip()) != 0
elif isinstance(value, int):
return value != 0
elif isinstance... |
# model settings
model = dict(
type='ImageClassifier',
backbone=dict(
type='SVT',
arch='base',
in_channels=3,
out_indices=(3, ),
qkv_bias=True,
norm_cfg=dict(type='LN'),
norm_after_stage=[False, False, False, True],
drop_rate=0.0,
attn_drop... | model = dict(type='ImageClassifier', backbone=dict(type='SVT', arch='base', in_channels=3, out_indices=(3,), qkv_bias=True, norm_cfg=dict(type='LN'), norm_after_stage=[False, False, False, True], drop_rate=0.0, attn_drop_rate=0.0, drop_path_rate=0.3), neck=dict(type='GlobalAveragePooling'), head=dict(type='LinearClsHea... |
nome = input('Digite seu nome: ')
def saudar(x):
print(f'Bem-vindo, {x}!')
saudar(nome) | nome = input('Digite seu nome: ')
def saudar(x):
print(f'Bem-vindo, {x}!')
saudar(nome) |
class Solution:
def sortedSquares(self, nums: List[int]) -> List[int]:
sq_nums = []
for num in nums:
sq_nums.append(num ** 2)
sq_nums.sort()
return sq_nums
| class Solution:
def sorted_squares(self, nums: List[int]) -> List[int]:
sq_nums = []
for num in nums:
sq_nums.append(num ** 2)
sq_nums.sort()
return sq_nums |
class Stack(object):
def __init__(self):
self.items = []
self.min_value = None
def push(self, item):
if not self.min_value or self.min_value > item:
self.min_value = item
self.items.append(item)
def pop(self):
self.items.pop()
def get_min_val... | class Stack(object):
def __init__(self):
self.items = []
self.min_value = None
def push(self, item):
if not self.min_value or self.min_value > item:
self.min_value = item
self.items.append(item)
def pop(self):
self.items.pop()
def get_min_value(sel... |
_base_ = [
'../../_base_/models/resnet50.py',
'../../_base_/datasets/imagenet.py',
'../../_base_/schedules/sgd_steplr-100e.py',
'../../_base_/default_runtime.py',
]
# model settings
model = dict(backbone=dict(norm_cfg=dict(type='SyncBN')))
# dataset settings
data = dict(
imgs_per_gpu=64, # total ... | _base_ = ['../../_base_/models/resnet50.py', '../../_base_/datasets/imagenet.py', '../../_base_/schedules/sgd_steplr-100e.py', '../../_base_/default_runtime.py']
model = dict(backbone=dict(norm_cfg=dict(type='SyncBN')))
data = dict(imgs_per_gpu=64, train=dict(data_source=dict(ann_file='data/imagenet/meta/train_1percent... |
def test_add_to_basket(browser):
link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/'
browser.get(link)
assert browser.find_element_by_class_name('btn-add-to-basket').is_displayed(), f'Basket button not found'
| def test_add_to_basket(browser):
link = 'http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/'
browser.get(link)
assert browser.find_element_by_class_name('btn-add-to-basket').is_displayed(), f'Basket button not found' |
class TaskAnswer:
# list of tuple: (vertice_source, vertice_destination, moved_value)
_steps = []
def get_steps(self) -> list:
return self._steps
def add_step(self, source: int, destination: int, value: float):
step = (source, destination, value)
self._steps.append(step)
... | class Taskanswer:
_steps = []
def get_steps(self) -> list:
return self._steps
def add_step(self, source: int, destination: int, value: float):
step = (source, destination, value)
self._steps.append(step)
def print(self):
for step in self._steps:
(source, de... |
class Solution:
def getDescentPeriods(self, prices: List[int]) -> int:
curr = result = 1
for i in range(1, len(prices)):
if prices[i] + 1 == prices[i-1]:
curr += 1
else:
curr = 1
result += curr
return result | class Solution:
def get_descent_periods(self, prices: List[int]) -> int:
curr = result = 1
for i in range(1, len(prices)):
if prices[i] + 1 == prices[i - 1]:
curr += 1
else:
curr = 1
result += curr
return result |
print("####################################################")
print("#FILENAME:\t\ta1p1.py\t\t\t #")
print("#ASSIGNMENT:\t\tHomework Assignment 1 Pt. 1#")
print("#COURSE/SECTION:\tCIS 3389.251\t\t #")
print("#DUE DATE:\t\tWednesday, 12.February 2020#")
print("####################################################\n\... | print('####################################################')
print('#FILENAME:\t\ta1p1.py\t\t\t #')
print('#ASSIGNMENT:\t\tHomework Assignment 1 Pt. 1#')
print('#COURSE/SECTION:\tCIS 3389.251\t\t #')
print('#DUE DATE:\t\tWednesday, 12.February 2020#')
print('####################################################\n\n... |
#!/usr/local/bin/python3
# Python Challenge - 1
# http://www.pythonchallenge.com/pc/def/map.html
# Keyword: ocr
def main():
'''
Hint:
K -> M
O -> Q
E -> G
Everybody thinks twice before solving this.
'''
cipher_text = ('g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcp'
... | def main():
"""
Hint:
K -> M
O -> Q
E -> G
Everybody thinks twice before solving this.
"""
cipher_text = "g fmnc wms bgblr rpylqjyrc gr zw fylb. rfyrq ufyr amknsrcpq ypc dmp. bmgle gr gl zw fylb gq glcddgagclr ylb rfyr'q ufw rfgq rcvr gq qm jmle. sqgle qrpgle.kyicrpylq() gq pcamkkclbcb. ... |
def rotate(str, d, mag):
if (d=="L"):
return str[mag:] + str[0:mag]
elif (d=="R"):
return str[len(str)-mag:] + str[0: len(str)-mag]
def checkAnagram(str1, str2):
if(sorted(str1)==sorted(str2)):
return True
else:
return False
def subString(s, n, ans):
for i in r... | def rotate(str, d, mag):
if d == 'L':
return str[mag:] + str[0:mag]
elif d == 'R':
return str[len(str) - mag:] + str[0:len(str) - mag]
def check_anagram(str1, str2):
if sorted(str1) == sorted(str2):
return True
else:
return False
def sub_string(s, n, ans):
for i in ... |
number = int(input("Pick a number? "))
for i in range(5):
number = number + number
print(number)
| number = int(input('Pick a number? '))
for i in range(5):
number = number + number
print(number) |
# --------------------------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------... | maximum_secret_length = 20
maximum_container_app_name_length = 40
short_polling_interval_secs = 3
long_polling_interval_secs = 10
log_analytics_rp = 'Microsoft.OperationalInsights'
container_apps_rp = 'Microsoft.App'
max_env_per_location = 2
microsoft_secret_setting_name = 'microsoft-provider-authentication-secret'
fac... |
# Author=====>>>Nipun Garg<<<=====
# Problem Statement - Given number of jobs and number of applicants
# And for each applicant given that wether each applicant is
# eligible to get the job or not in the form of matrix
# Return 1 if a person can get the job
def dfs(graph, applicant, visited, result,nApplicants,nJob... | def dfs(graph, applicant, visited, result, nApplicants, nJobs):
for i in range(0, nJobs):
if graph[applicant][i] == 1 and (not visited[i]):
visited[i] = 1
if result[i] < 0 or dfs(graph, result[i], visited, result, nApplicants, nJobs):
result[i] = applicant
... |
# 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 tree2str(self, t: TreeNode) -> str:
if t is None:
return ""
... | class Solution:
def tree2str(self, t: TreeNode) -> str:
if t is None:
return ''
if t.left is None and t.right is None:
return str(t.val) + ''
if t.right is None:
return str(t.val) + '(' + str(self.tree2str(t.left)) + ')'
return str(t.val) + '(' + ... |
# get distinct characters and their count in a String
string = input("Enter String: ")
c = 0
for i in range(65, 91):
c = 0
for j in range(0, len(string)):
if(string[j] == chr(i)):
c += 1
if c > 0:
print("", chr(i), " is ", c, " times.")
c = 0
for i in range(97, 123):
c = 0... | string = input('Enter String: ')
c = 0
for i in range(65, 91):
c = 0
for j in range(0, len(string)):
if string[j] == chr(i):
c += 1
if c > 0:
print('', chr(i), ' is ', c, ' times.')
c = 0
for i in range(97, 123):
c = 0
for j in range(0, len(string)):
if string[j] ... |
class SearchPath:
def __init__(self, path=None):
if path is None:
self._path = []
else:
self._path = path
def branch_off(self, label, p):
path = self._path + [(label, p)]
return SearchPath(path)
@property
def labels(self):
return [label f... | class Searchpath:
def __init__(self, path=None):
if path is None:
self._path = []
else:
self._path = path
def branch_off(self, label, p):
path = self._path + [(label, p)]
return search_path(path)
@property
def labels(self):
return [label... |
class Bot:
'''
state - state of the game
returns a move
'''
def move(self, state, symbol):
raise NotImplementedError('Abstractaaa')
def get_name(self):
raise NotImplementedError('Abstractaaa')
| class Bot:
"""
state - state of the game
returns a move
"""
def move(self, state, symbol):
raise not_implemented_error('Abstractaaa')
def get_name(self):
raise not_implemented_error('Abstractaaa') |
__author__ = 'shukkkur'
'''
https://codeforces.com/problemset/problem/581/A
A. Vasya the Hipster
'''
red, blue = map(int, input().split())
total = red + blue
a = min(red, blue)
total -= 2 * a
b = total // 2
print(a, b)
| __author__ = 'shukkkur'
'\nhttps://codeforces.com/problemset/problem/581/A\nA. Vasya the Hipster\n'
(red, blue) = map(int, input().split())
total = red + blue
a = min(red, blue)
total -= 2 * a
b = total // 2
print(a, b) |
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def dnsmasq_dependencies():
http_archive(
name = "dnsmasq",
urls = ["http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.78.tar.xz"],
sha256 = "89949f438c74b0c7543f06689c319484bd126cc4b1f8c745c742ab397681252b",
build_fi... | load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
def dnsmasq_dependencies():
http_archive(name='dnsmasq', urls=['http://www.thekelleys.org.uk/dnsmasq/dnsmasq-2.78.tar.xz'], sha256='89949f438c74b0c7543f06689c319484bd126cc4b1f8c745c742ab397681252b', build_file='//dnsmasq:BUILD.import') |
file = open("input")
lines = file.readlines()
pattern_len = len(lines[0])
def part1(lines, right, down):
count = 0
pattern_len = len(lines[0])
x = 0
y = 0
while y < len(lines) - down:
x += right
y += down
if lines[y][x % (pattern_len - 1)] == "#":
... | file = open('input')
lines = file.readlines()
pattern_len = len(lines[0])
def part1(lines, right, down):
count = 0
pattern_len = len(lines[0])
x = 0
y = 0
while y < len(lines) - down:
x += right
y += down
if lines[y][x % (pattern_len - 1)] == '#':
count += 1
... |
# input the length of array
n = int(input())
# input the elements of array
ar = [int(x) for x in input().strip().split(' ')]
c = [0]*100
for a in ar :
c[a] += 1
s = ''
# print the sorted list as a single line of space-separated elements
for x in range(0,100) :
for i in range(0,c[x]) :
s += ' ' + ... | n = int(input())
ar = [int(x) for x in input().strip().split(' ')]
c = [0] * 100
for a in ar:
c[a] += 1
s = ''
for x in range(0, 100):
for i in range(0, c[x]):
s += ' ' + str(x)
print(s[1:]) |
full_dict = {
'daterecieved': 'entry daterecieved',
'poploadslip' : 'entry poploadslip',
'count' : 'entry 1' ,
'tm9_ticket' : 'entry tm9_ticket',
'disposition_fmanum' : 'entry disposition_fmanum',
'owner' : 'entry ownerName',
'... | full_dict = {'daterecieved': 'entry daterecieved', 'poploadslip': 'entry poploadslip', 'count': 'entry 1', 'tm9_ticket': 'entry tm9_ticket', 'disposition_fmanum': 'entry disposition_fmanum', 'owner': 'entry ownerName', 'haulingcontractor': 'entry hauled by', 'numpcsreceived': 'entry num of pieces', 'blocknum': 'entry B... |
# HEAD
# Python Functions - *args
# DESCRIPTION
# Describes
# capturing all arguments as *args (tuple)
#
# RESOURCES
#
# Arguments (any number during invocation) can also be
# caught as a sequence of arguments - tuple using *args
# Order does matter for unnamed arguments list and makes for
# inde... | def print_unnamed_args(*args):
print('3. printUnnamedArgs', args)
for x in enumerate(args):
print(x)
print_unnamed_args([1, 2, 3], [4, 5, 6]) |
class Luhn:
def __init__(self, card_num: str):
self._reversed_card_num = card_num.replace(' ', '')[::-1]
self._even_digits = self._reversed_card_num[1::2]
self._odd_digits = self._reversed_card_num[::2]
def valid(self) -> bool:
if str.isnumeric(self._reversed_card_num) and len(s... | class Luhn:
def __init__(self, card_num: str):
self._reversed_card_num = card_num.replace(' ', '')[::-1]
self._even_digits = self._reversed_card_num[1::2]
self._odd_digits = self._reversed_card_num[::2]
def valid(self) -> bool:
if str.isnumeric(self._reversed_card_num) and len(... |
# Copyright 2019-present, GraphQL Foundation
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
def title(s):
'''Capitalize the first character of s.'''
return s[0].capitalize() + s[1:]
def camel(s):
'''Lowercase the first charac... | def title(s):
"""Capitalize the first character of s."""
return s[0].capitalize() + s[1:]
def camel(s):
"""Lowercase the first character of s."""
return s[0].lower() + s[1:]
def snake(s):
"""Convert from title or camelCase to snake_case."""
if len(s) < 2:
return s.lower()
out = s[0... |
class Solution:
def binary_to_decimal(self, n):
return int(n, 2)
def grayCode(self, A):
num_till_now = [0, 1]
if A == 1:
return num_till_now
results = []
for i in range(1, A):
rev = num_till_now.copy()
rev.reverse()
num_ti... | class Solution:
def binary_to_decimal(self, n):
return int(n, 2)
def gray_code(self, A):
num_till_now = [0, 1]
if A == 1:
return num_till_now
results = []
for i in range(1, A):
rev = num_till_now.copy()
rev.reverse()
num_t... |
def include_in_html(content_to_include, input_includename, html_filepath):
with open(html_filepath, "r") as f:
line_list = f.readlines()
res = []
includename = None
initial_spaces = 0
for line in line_list:
line = line.strip("\n")
if line.strip(" ")[:14] == "<!-- #includ... | def include_in_html(content_to_include, input_includename, html_filepath):
with open(html_filepath, 'r') as f:
line_list = f.readlines()
res = []
includename = None
initial_spaces = 0
for line in line_list:
line = line.strip('\n')
if line.strip(' ')[:14] == '<!-- #include ' o... |
# Copyright 2017 The Bazel Authors. All rights reserved.
#
# 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 applicable la... | """Defaults for rules_typescript repository not meant to be used downstream"""
load('@build_bazel_rules_typescript//:defs.bzl', _karma_web_test='karma_web_test', _karma_web_test_suite='karma_web_test_suite', _ts_library='ts_library', _ts_web_test='ts_web_test', _ts_web_test_suite='ts_web_test_suite')
internal_ts_librar... |
class Simple(object):
def __init__(self, x):
self.x = x
self.y = 6
def get_x(self):
return self.x
class WithCollection(object):
def __init__(self):
self.l = list()
self.d = dict()
def get_l(self):
return self.l | class Simple(object):
def __init__(self, x):
self.x = x
self.y = 6
def get_x(self):
return self.x
class Withcollection(object):
def __init__(self):
self.l = list()
self.d = dict()
def get_l(self):
return self.l |
s = open('input.txt','r').read()
s = [k for k in s.split("\n")]
aller = {}
count = {}
for line in s:
allergens = line.split("contains ")[1].split(", ")
allergens[-1] = allergens[-1][:-1]
ing = line.split(" (")[0].split(" ")
for i in ing:
count[i] = 1 if i not in count else count[i] + 1
fo... | s = open('input.txt', 'r').read()
s = [k for k in s.split('\n')]
aller = {}
count = {}
for line in s:
allergens = line.split('contains ')[1].split(', ')
allergens[-1] = allergens[-1][:-1]
ing = line.split(' (')[0].split(' ')
for i in ing:
count[i] = 1 if i not in count else count[i] + 1
for ... |
t = int(input())
for i in range(t):
n = input()
rev_n = int(n[::-1])
print(rev_n) | t = int(input())
for i in range(t):
n = input()
rev_n = int(n[::-1])
print(rev_n) |
courses={}
while True:
command=input()
if command!="end":
command=command.split(" : ")
doesCourseExist=False
for j in courses:
if j==command[0]:
doesCourseExist=True
break
if doesCourseExist==False:
courses[comm... | courses = {}
while True:
command = input()
if command != 'end':
command = command.split(' : ')
does_course_exist = False
for j in courses:
if j == command[0]:
does_course_exist = True
break
if doesCourseExist == False:
cours... |
def main():
object_a_mass = float(input("Object A mass: "))
object_b_mass = float(input("Object B mass: "))
distance = float(input("Distance between both: "))
G = 6.67408 * (10**11)
print(G*(object_a_mass*object_b_mass)/ (distance ** 2))
if __name__ == '__main__':
main()
| def main():
object_a_mass = float(input('Object A mass: '))
object_b_mass = float(input('Object B mass: '))
distance = float(input('Distance between both: '))
g = 6.67408 * 10 ** 11
print(G * (object_a_mass * object_b_mass) / distance ** 2)
if __name__ == '__main__':
main() |
PB_PACKAGE = __package__
NODE_TAG = 'p_baker_node'
MATERIAL_TAG = 'p_baker_material'
MATERIAL_TAG_VERTEX = 'p_baker_material_vertex'
NODE_INPUTS = [
'Color',
'Subsurface',
'Subsurface Color',
'Metallic',
'Specular',
'Specular Tint',
'Roughness',
'Anisotropic',
'Anisotropic Rotation... | pb_package = __package__
node_tag = 'p_baker_node'
material_tag = 'p_baker_material'
material_tag_vertex = 'p_baker_material_vertex'
node_inputs = ['Color', 'Subsurface', 'Subsurface Color', 'Metallic', 'Specular', 'Specular Tint', 'Roughness', 'Anisotropic', 'Anisotropic Rotation', 'Sheen', 'Sheen Tint', 'Clearcoat', ... |
def nrange(start, stop, step=1):
while start < stop:
yield start
start += step
@profile
def ncall():
for i in nrange(1,1000000):
pass
if __name__ == "__main__":
ncall()
| def nrange(start, stop, step=1):
while start < stop:
yield start
start += step
@profile
def ncall():
for i in nrange(1, 1000000):
pass
if __name__ == '__main__':
ncall() |
string = "abcdefgabc"
string_list = []
for letter in string:
string_list.append(letter)
print(string_list)
string_list_no_duplicate = set(string_list)
string_list_no_duplicate = list(string_list_no_duplicate)
string_list_no_duplicate.sort()
print(string_list_no_duplicate)
for letters in string_list_no_duplicate... | string = 'abcdefgabc'
string_list = []
for letter in string:
string_list.append(letter)
print(string_list)
string_list_no_duplicate = set(string_list)
string_list_no_duplicate = list(string_list_no_duplicate)
string_list_no_duplicate.sort()
print(string_list_no_duplicate)
for letters in string_list_no_duplicate:
... |
def load(task_id, file_id, cmds):
global responses
code = reverse_upload(task_id, file_id)
name = cmds
if agent.get_Encryption_key() == "":
dynfs[name] = code
else:
dynfs[name] = encrypt_code(code)
response = {
'task_id': task_id,
"user_output": "Modul... | def load(task_id, file_id, cmds):
global responses
code = reverse_upload(task_id, file_id)
name = cmds
if agent.get_Encryption_key() == '':
dynfs[name] = code
else:
dynfs[name] = encrypt_code(code)
response = {'task_id': task_id, 'user_output': 'Module successfully added', 'comma... |
for _ in range(int(input())):
n = int(input())
r = [int(i) for i in input().split()]
o = max(r)
if r.count(o)==len(r):
print(-1)
continue
kq = -1
for i in range(1,len(r)):
if r[i]==o and (r[i]>r[i-1]):
kq = i+1
for i in range(len(r)-1):
if r[i]==o and(r[i]>r[i+1]):
kq = i+1
print(kq)
| for _ in range(int(input())):
n = int(input())
r = [int(i) for i in input().split()]
o = max(r)
if r.count(o) == len(r):
print(-1)
continue
kq = -1
for i in range(1, len(r)):
if r[i] == o and r[i] > r[i - 1]:
kq = i + 1
for i in range(len(r) - 1):
... |
WIDTH = 128
HEIGHT = 128
# Must be more than ALIEN_SIZE, used to pad alien rows and columns
ALIEN_BLOCK_SIZE = 8
# Alien constants are global as their spacing is used to separate them
ALIENS_PER_ROW = int(WIDTH / ALIEN_BLOCK_SIZE) - 6
ALIEN_ROWS = int(HEIGHT / (2 * ALIEN_BLOCK_SIZE))
# How often to move the aliens i... | width = 128
height = 128
alien_block_size = 8
aliens_per_row = int(WIDTH / ALIEN_BLOCK_SIZE) - 6
alien_rows = int(HEIGHT / (2 * ALIEN_BLOCK_SIZE))
alien_start_time = 4
alien_time_step = 0.2
alien_minimum_time = 1
alien_start_fire_probability = 0.01
alien_fire_probability_step = 0.005
alien_maximum_fire_probability = 0.... |
fp = open('abcd.txt', 'r')
line_offset = []
offset = 0
for line in fp:
line_offset.append(offset)
offset += len(line)
print(line_offset)
for each in line_offset:
fp.seek(each)
print(fp.readline()[:-1])
| fp = open('abcd.txt', 'r')
line_offset = []
offset = 0
for line in fp:
line_offset.append(offset)
offset += len(line)
print(line_offset)
for each in line_offset:
fp.seek(each)
print(fp.readline()[:-1]) |
# ----------------------------------------------------------------------------
# Copyright 2019-2022 Diligent Graphics LLC
#
# 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.a... | cxx_registered_struct = {'Version', 'RenderTargetBlendDesc', 'BlendStateDesc', 'StencilOpDesc', 'DepthStencilStateDesc', 'RasterizerStateDesc', 'InputLayoutDesc', 'LayoutElement', 'SampleDesc', 'ShaderResourceVariableDesc', 'PipelineResourceDesc', 'PipelineResourceSignatureDesc', 'SamplerDesc', 'ImmutableSamplerDesc', ... |
#
# PySNMP MIB module Cajun-ROOT (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Cajun-ROOT
# Produced by pysmi-0.3.4 at Mon Apr 29 17:08:17 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... | (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) ... |
# Add 5 to number
add5 = lambda n : n + 5
print(add5(2))
print(add5(7))
print()
# Square number
sqr = lambda n : n * n
print(sqr(2))
print(sqr(7))
print()
# Next integer
nextInt = lambda n : int(n) + 1
print(nextInt(2.7))
print(nextInt(7.2))
print()
# Previous integer of half
prevInt = lambda n : int(n // 2)
print(p... | add5 = lambda n: n + 5
print(add5(2))
print(add5(7))
print()
sqr = lambda n: n * n
print(sqr(2))
print(sqr(7))
print()
next_int = lambda n: int(n) + 1
print(next_int(2.7))
print(next_int(7.2))
print()
prev_int = lambda n: int(n // 2)
print(prev_int(2.7))
print(prev_int(7.2))
print()
div = lambda dvsr: lambda dvdn: dvdn... |
state = '10011111011011001'
disk_length = 35651584
def mutate(a):
b = ''.join(['1' if x == '0' else '0' for x in reversed(a)])
return a + '0' + b
def checksum(a):
result = ''
i = 0
while i < len(a) - 1:
if a[i] == a[i+1]:
result += '1'
else:
result += '0'
... | state = '10011111011011001'
disk_length = 35651584
def mutate(a):
b = ''.join(['1' if x == '0' else '0' for x in reversed(a)])
return a + '0' + b
def checksum(a):
result = ''
i = 0
while i < len(a) - 1:
if a[i] == a[i + 1]:
result += '1'
else:
result += '0'
... |
x = 1
while x < 10:
y = 1
while y < 10:
print("%4d" % (x*y), end="")
y += 1
print()
x += 1
| x = 1
while x < 10:
y = 1
while y < 10:
print('%4d' % (x * y), end='')
y += 1
print()
x += 1 |
def saisie_liste():
cest_un_nombre=True
premier_nombre = input("Entrer un nombre : ")
somme=int(premier_nombre)
min=int(premier_nombre)
max=int(premier_nombre)
nombre_int = 0
n=0
moyenne = 0
while cest_un_nombre==True:
n += 1
nombre=input("Entrer un nombre : ")
... | def saisie_liste():
cest_un_nombre = True
premier_nombre = input('Entrer un nombre : ')
somme = int(premier_nombre)
min = int(premier_nombre)
max = int(premier_nombre)
nombre_int = 0
n = 0
moyenne = 0
while cest_un_nombre == True:
n += 1
nombre = input('Entrer un nomb... |
AF_INET = 2
AF_INET6 = 10
IPPROTO_IP = 0
IPPROTO_TCP = 6
IPPROTO_UDP = 17
IP_ADD_MEMBERSHIP = 3
SOCK_DGRAM = 2
SOCK_RAW = 3
SOCK_STREAM = 1
SOL_SOCKET = 4095
SO_REUSEADDR = 4
def getaddrinfo():
pass
def socket():
pass
| af_inet = 2
af_inet6 = 10
ipproto_ip = 0
ipproto_tcp = 6
ipproto_udp = 17
ip_add_membership = 3
sock_dgram = 2
sock_raw = 3
sock_stream = 1
sol_socket = 4095
so_reuseaddr = 4
def getaddrinfo():
pass
def socket():
pass |
fixed_rows = []
with open('runs/expert/baseline_pass_full_doc_rerank', 'r') as fi:
for line in fi:
line = line.strip().split()
if line:
fixed_score = -float(line[4])
line[4] = str(fixed_score)
fixed_rows.append('\t'.join(line))
with open('runs/expert/baseline_pass_full_doc_rerank', 'w') as fo:
for row ... | fixed_rows = []
with open('runs/expert/baseline_pass_full_doc_rerank', 'r') as fi:
for line in fi:
line = line.strip().split()
if line:
fixed_score = -float(line[4])
line[4] = str(fixed_score)
fixed_rows.append('\t'.join(line))
with open('runs/expert/baseline_pass... |
def insertion_sort(l):
for i in range(1, len(l)):
j = i-1
key = l[i]
while (l[j] > key) and (j >= 0):
l[j+1] = l[j]
j -= 1
l[j+1] = key
numbers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
insertion_sort(numbers)
print(numbers)
| def insertion_sort(l):
for i in range(1, len(l)):
j = i - 1
key = l[i]
while l[j] > key and j >= 0:
l[j + 1] = l[j]
j -= 1
l[j + 1] = key
numbers = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1]
insertion_sort(numbers)
print(numbers) |
# Question: https://projecteuler.net/problem=120
# The coefficients of a^(odd) cancel out, so there might be a pattern ...
# n | X_n = (a-1)^n + (a+1)^n | mod a^2
#-----|----------------------------|--------
# 1 | 2a | 2a
# 2 | 2a^2 + 2 | 2
# 3 | 2... | n = 1000
result = (N - 1) * N * (N + 1) // 3 - N * (N + 2) // 4
print(result) |
n = int(input().strip())
for i in range(0,n):
for y in range(0,n):
if(y<n-i-1):
print(' ', end='')
elif(y>=n-i-1 and y!=n-1):
print('#',end='')
else:
print('#')
| n = int(input().strip())
for i in range(0, n):
for y in range(0, n):
if y < n - i - 1:
print(' ', end='')
elif y >= n - i - 1 and y != n - 1:
print('#', end='')
else:
print('#') |
class Node:
def __init__(self, value):
self.value = value
self.next = None
class Stack:
def __init__(self):
self.top = None
def push(self, value):
node = Node(value)
if self.top:
node.next = self.top
self.top = node
else:
... | class Node:
def __init__(self, value):
self.value = value
self.next = None
class Stack:
def __init__(self):
self.top = None
def push(self, value):
node = node(value)
if self.top:
node.next = self.top
self.top = node
else:
... |
class Node:
def __init__(self, condition, body):
self.condition = condition
self.body = body
def visit(self, context):
rvalue = None
while self.condition.visit(context):
rvalue = self.body.visit(context)
return rvalue
| class Node:
def __init__(self, condition, body):
self.condition = condition
self.body = body
def visit(self, context):
rvalue = None
while self.condition.visit(context):
rvalue = self.body.visit(context)
return rvalue |
__all__ = [
'arch_blocks',
'get_mask',
'get_param_groups',
'logger',
'losses',
'lr_schedulers',
'optimizers_L1L2',
'tensorflow_logger',
] | __all__ = ['arch_blocks', 'get_mask', 'get_param_groups', 'logger', 'losses', 'lr_schedulers', 'optimizers_L1L2', 'tensorflow_logger'] |
class Solution:
def solve(self, courses):
n = len(courses)
def helper(start):
visited[start] = 1
for v in courses[start]:
if visited[v]==1:
return True
elif visited[v]==0:
if helper(v):
... | class Solution:
def solve(self, courses):
n = len(courses)
def helper(start):
visited[start] = 1
for v in courses[start]:
if visited[v] == 1:
return True
elif visited[v] == 0:
if helper(v):
... |
chipper = input('Input Message: ')
plain = ''
for alphabet in chipper:
temp = ord(alphabet)-1
plain += chr(temp)
print(plain)
| chipper = input('Input Message: ')
plain = ''
for alphabet in chipper:
temp = ord(alphabet) - 1
plain += chr(temp)
print(plain) |
def dec1(def1):
def exec():
print("Executing now")
def1()
print("Executed")
return exec
@dec1
def who_is_sandy():
print("Sandy is good programmer")
#who_is_sandy = dec1(who_is_sandy) #Decorative function is dec1 another term is @dec1
who_is_sandy()
| def dec1(def1):
def exec():
print('Executing now')
def1()
print('Executed')
return exec
@dec1
def who_is_sandy():
print('Sandy is good programmer')
who_is_sandy() |
# container with most water
# https://leetcode.com/problems/container-with-most-water/
# the function maxArea -> take in a list of integers and return an integer
# 3 variables to keep track of the current max area, left and right pointers
# left pointer initialized to the first elements of the list
# right pointer init... | class Solution:
def max_area(self, height: list[int]) -> int:
current_max_area = 0
left = 0
right = len(height) - 1
while left < right:
area = (right - left) * min(height[left], height[right])
if area > current_max_area:
current_max_area = are... |
print("------------------------------------")
print("********* Woorden switchen *********")
print("------------------------------------")
# Input temperatuur in Celsius
woord1 = input("Woord 1: ")
woord2 = input("Woord 2: ")
# Output
print()
print("Woord 1: " + woord1.upper())
print("Woord 2: " + woord2.upper())
prin... | print('------------------------------------')
print('********* Woorden switchen *********')
print('------------------------------------')
woord1 = input('Woord 1: ')
woord2 = input('Woord 2: ')
print()
print('Woord 1: ' + woord1.upper())
print('Woord 2: ' + woord2.upper())
print()
(woord1, woord2) = (woord2, woord1)
pr... |
# * =======================
# *
# * Author: Matthew Moccaro
# * File: Network_Programming.py
# * Type: Python Source File
# *
# * Creation Date: 1/2/19
# *
# * Description: Python
# * source file for the
# * network programming
# * project.
# *
# * ======================
print("Network Programming For Python")
| print('Network Programming For Python') |
__author__ = 'mstipanov'
class ApiRequestErrorDetails(object):
messageId = ""
text = ""
variables = ""
additionalDescription = ""
def __init__(self, text=""):
self.text = text
def __str__(self):
return "ApiRequestErrorDetails: {" \
"messageId = \"" + str(self.m... | __author__ = 'mstipanov'
class Apirequesterrordetails(object):
message_id = ''
text = ''
variables = ''
additional_description = ''
def __init__(self, text=''):
self.text = text
def __str__(self):
return 'ApiRequestErrorDetails: {messageId = "' + str(self.messageId) + '", text... |
# -*- coding: utf-8 -*-
# Jupyter Extension points
def _jupyter_nbextension_paths():
return [
dict(
section="notebook",
# the path is relative to the `my_fancy_module` directory
src="resources/nbextension",
# directory in the `nbextension/` namespace
... | def _jupyter_nbextension_paths():
return [dict(section='notebook', src='resources/nbextension', dest='nbsafety', require='nbsafety/index')]
def load_jupyter_server_extension(nbapp):
pass |
class BatteryAndInverter:
name = "battery and inverter"
params = [
{
"key": "capacity_dc_kwh",
"label": "",
"units": "kwh",
"private": False,
"value": 4000,
"confidence": 0,
"notes": "",
"source": "FAKE"
... | class Batteryandinverter:
name = 'battery and inverter'
params = [{'key': 'capacity_dc_kwh', 'label': '', 'units': 'kwh', 'private': False, 'value': 4000, 'confidence': 0, 'notes': '', 'source': 'FAKE'}, {'key': 'capacity_dc_kw', 'label': '', 'units': 'kw', 'private': False, 'value': 4000, 'confidence': 0, 'not... |
# Generate a mask for the upper triangle
mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
# Set up the matplotlib figure
f, ax = plt.subplots(figsize=(20, 18))
# Draw the heatmap with the mask and correct aspect ratio
sns.heatmap(corr, mask=mask, cmap="YlGnBu", vmax=.30, cente... | mask = np.zeros_like(corr, dtype=np.bool)
mask[np.triu_indices_from(mask)] = True
(f, ax) = plt.subplots(figsize=(20, 18))
sns.heatmap(corr, mask=mask, cmap='YlGnBu', vmax=0.3, center=0, square=True, linewidths=0.5, cbar_kws={'shrink': 0.5}) |
# -*- coding: utf-8 -*-
#
# 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 applicable law or agreed to in writing, softwa... | class Lbaastobigip(object):
def __init__(self, benchmark, benchmark_filter):
self.benchmark_name = None
self.benchmark = None
self.benchmark_filter = None
self.benchmark_projects = None
self.subject_name = None
self.subject = None
self.subject_filter = None
... |
# Declaring the gotopt2 dependencies
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@bazel_bats//:deps.bzl", "bazel_bats_dependencies")
# Include this into any dependencies that want to compile gotopt2 from source.
... | load('@bazel_gazelle//:deps.bzl', 'gazelle_dependencies', 'go_repository')
load('@bazel_tools//tools/build_defs/repo:git.bzl', 'git_repository')
load('@bazel_bats//:deps.bzl', 'bazel_bats_dependencies')
def gotopt2_dependencies():
go_repository(name='com_github_golang_glog', commit='23def4e6c14b', importpath='gith... |
A = []
B = []
for i in range (10):
A.append(int(input()))
U = int(input())
for j in range (len(A)):
if A[j] == U:
B.append(j)
print(B)
| a = []
b = []
for i in range(10):
A.append(int(input()))
u = int(input())
for j in range(len(A)):
if A[j] == U:
B.append(j)
print(B) |
def differentSymbolsNaive(s):
diffArray = []
for i in range(len(list(s))):
if list(s)[i] not in diffArray:
diffArray.append(list(s)[i])
return len(diffArray) | def different_symbols_naive(s):
diff_array = []
for i in range(len(list(s))):
if list(s)[i] not in diffArray:
diffArray.append(list(s)[i])
return len(diffArray) |
s = input()
s = s.upper()
c = 0
for i in ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
for j in s:
if(i!=j):
c = 0
else:
c = 1
break
if(c==0):
break
if c==1:
print("Pangram exists")
else:
print("Pangram doesn't exists")
| s = input()
s = s.upper()
c = 0
for i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
for j in s:
if i != j:
c = 0
else:
c = 1
break
if c == 0:
break
if c == 1:
print('Pangram exists')
else:
print("Pangram doesn't exists") |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.