content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
comultiset_init = lib.comultiset_init_TAG
insert = lib.cms_insert_TAG
remove = lib.cms_remove_TAG
count = lib.cms_count_TAG
get_s = lib.cms_get_size_TAG
clear = lib.cms_clear_TAG
get_min = lib.cms_min_TAG
get_max = lib.cms_min_TAG
upper_bound = lib.cms_upper_bound_TAG
rupper_bound = lib.cms_rupper_bound_TAG
get_k = ... | comultiset_init = lib.comultiset_init_TAG
insert = lib.cms_insert_TAG
remove = lib.cms_remove_TAG
count = lib.cms_count_TAG
get_s = lib.cms_get_size_TAG
clear = lib.cms_clear_TAG
get_min = lib.cms_min_TAG
get_max = lib.cms_min_TAG
upper_bound = lib.cms_upper_bound_TAG
rupper_bound = lib.cms_rupper_bound_TAG
get_k = lib... |
class queries(object):
#can I decompose these query parts into lists and concatenate them prior to passing to the cursor?
#need to standardize field names in order to use the same query across eyars
#ffiec_median_family_income vs HUD_median_family_income
#no sequencenumber prior to 2012
def __init__(self):
s... | class Queries(object):
def __init__(self):
self.SQL_Count = "SELECT COUNT(msaofproperty) FROM hmdapub{year} WHERE msaofproperty = '{MSA}' "
self.SQL_Query = "SELECT {columns} FROM hmdapub{year} WHERE msaofproperty = '{MSA}' "
def table_3_1_conditions(self):
return " and purchasertype !... |
class Action:
def __init__(self, resultState, actionName):
self.resultState = resultState
self.actionName = actionName
def __str__(self):
return "{}: {}".format(self.actionName, self.resultState)
def GetNextStates(current):
nextStates = []
small = current[0]
large = cur... | class Action:
def __init__(self, resultState, actionName):
self.resultState = resultState
self.actionName = actionName
def __str__(self):
return '{}: {}'.format(self.actionName, self.resultState)
def get_next_states(current):
next_states = []
small = current[0]
large = cur... |
def make_ngram(n, token):
return [tuple(token[i:i+n]) for i in range(len(token)-n+1)]
if __name__ == '__main__':
sentence = "I am an NLPer"
print(make_ngram(2, sentence.split()))
print(make_ngram(2, list(sentence)))
| def make_ngram(n, token):
return [tuple(token[i:i + n]) for i in range(len(token) - n + 1)]
if __name__ == '__main__':
sentence = 'I am an NLPer'
print(make_ngram(2, sentence.split()))
print(make_ngram(2, list(sentence))) |
#!/usr/bin/python3
with open('input.txt') as f:
input = f.read().splitlines()
def valid(passport):
if 'byr' not in passport:
return False
if int(passport['byr']) < 1920 or int(passport['byr']) > 2002:
return False
if 'iyr' not in passport:
return False
if int(passport['iyr']) < 2010 or int(pass... | with open('input.txt') as f:
input = f.read().splitlines()
def valid(passport):
if 'byr' not in passport:
return False
if int(passport['byr']) < 1920 or int(passport['byr']) > 2002:
return False
if 'iyr' not in passport:
return False
if int(passport['iyr']) < 2010 or int(pas... |
#!/usr/bin/env python3
# Mission: Report default class members.
# File: KA9001.py
for ss, member in enumerate(sorted(dir(object())),1):
print(ss, member)
| for (ss, member) in enumerate(sorted(dir(object())), 1):
print(ss, member) |
def generate():
# grab global references to the output frame and lock variables
global jpg_buffer, lock
while True:
# wait until the lock is acquired
with lock:
rpi_name, jpg_buffer = imagehub.recv_jpg()
if jpg_buffer is None:
continue
... | def generate():
global jpg_buffer, lock
while True:
with lock:
(rpi_name, jpg_buffer) = imagehub.recv_jpg()
if jpg_buffer is None:
continue
image = cv2.imdecode(np.frombuffer(jpg_buffer, dtype='uint8'), -1)
imagehub.send_reply(b'OK')
... |
a=list(map(int,input().split()))
c=0
lo=0
h=1
while(lo<h and lo<len(a)):
if(sum(a[lo:h])==0 and h<=len(a)):
print(a[lo:h])
c=c+1
break
elif(h==len(a)):
lo=lo+1
h=lo+1
else:
h=h+1
if(c>0):
print("YES")
else:
... | a = list(map(int, input().split()))
c = 0
lo = 0
h = 1
while lo < h and lo < len(a):
if sum(a[lo:h]) == 0 and h <= len(a):
print(a[lo:h])
c = c + 1
break
elif h == len(a):
lo = lo + 1
h = lo + 1
else:
h = h + 1
if c > 0:
print('YES')
else:
print('NO') |
def sort_by_self(elem):
return elem[1]
if __name__ == "__main__":
# sorted(iterable[, key][, reverse])
# iterable - sequence (string, tuple, list) or collection (set, dictionary, frozen set) or any iterator
# reverse (Optional) - If true, the sorted list is reversed (or sorted in Descending order)
... | def sort_by_self(elem):
return elem[1]
if __name__ == '__main__':
py_list = ['c', 'a', 'd', 'e', 'b']
print('sorted(pyList): {}'.format(sorted(pyList)))
print('pyList: {}'.format(pyList))
int_string = '51423'
print('int_string: {}'.format(sorted(int_string)))
int_string_seqs = [1, '299', 3, ... |
# counter = 0
#
# print('2 to ' + str(counter) + 'is = to: ' + str(2 ** counter))
#
#
# counter = 2
#
# print('2 to ' + str(counter) + 'is = to: ' + str(2 ** counter))
#
def run():
LIMIT = 1000000
counter = 0
potency = 2 ** counter
while potency < LIMIT:
print('2 to ' + str(counter) + ' is =... | def run():
limit = 1000000
counter = 0
potency = 2 ** counter
while potency < LIMIT:
print('2 to ' + str(counter) + ' is = to: ' + str(potency))
counter += 1
potency = 2 ** counter
if __name__ == '__main__':
run() |
class Solution:
# @param num, a list of integer
# @return a list of lists of integers
def permuteUnique(self, num):
return map(list, list(set(itertools.permutations(num))))
| class Solution:
def permute_unique(self, num):
return map(list, list(set(itertools.permutations(num)))) |
with open('commitHistory.csv','r') as mpr_csv:
with open('cleanCommitHistory.csv', "w") as mpr_txt:
for line in mpr_csv:
l = line.split('\n')[0]
if l != '':
mpr_txt.write(l + '\n')
| with open('commitHistory.csv', 'r') as mpr_csv:
with open('cleanCommitHistory.csv', 'w') as mpr_txt:
for line in mpr_csv:
l = line.split('\n')[0]
if l != '':
mpr_txt.write(l + '\n') |
begin_unit
comment|'# Copyright (c) Intel Corporation.'
nl|'\n'
comment|'#'
nl|'\n'
comment|'# Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl|'\n'
comment|'# not use this file except in compliance with the License. You may obtain'
nl|'\n'
comment|'# a copy of the License at'
nl|'\n... | begin_unit
comment | '# Copyright (c) Intel Corporation.'
nl | '\n'
comment | '#'
nl | '\n'
comment | '# Licensed under the Apache License, Version 2.0 (the "License"); you may'
nl | '\n'
comment | '# not use this file except in compliance with the License. You may obtain'
nl | '\n'
comment | '# a copy of the ... |
NAME = 'hemath'
YOB = 1999
ID_NUM = 17783
print(NAME)
# access class constants from superclass to subclass
class C1:
a_constant = 0.167355
class C2(C1):
def this_constant(self):
print(self.a_constant)
an_object = C2()
an_object.this_constant()
| name = 'hemath'
yob = 1999
id_num = 17783
print(NAME)
class C1:
a_constant = 0.167355
class C2(C1):
def this_constant(self):
print(self.a_constant)
an_object = c2()
an_object.this_constant() |
num = input()
n = len(num)
pref = [0] * n
prefSum = 0
for i in range(len(num)):
prefSum += ord(num[i]) - ord('0')
pref[i] = prefSum
ans = ""
sum1 = 0
for i in range(n - 1, -1, -1):
sum1 += pref[i]
ans += chr(ord('0') + int(sum1 % 10))
sum1 = int(sum1 / 10)
if (sum1 != 0):
for i in str(sum1):
... | num = input()
n = len(num)
pref = [0] * n
pref_sum = 0
for i in range(len(num)):
pref_sum += ord(num[i]) - ord('0')
pref[i] = prefSum
ans = ''
sum1 = 0
for i in range(n - 1, -1, -1):
sum1 += pref[i]
ans += chr(ord('0') + int(sum1 % 10))
sum1 = int(sum1 / 10)
if sum1 != 0:
for i in str(sum1):
... |
level_choice={
"beginner": "Beginner",
"intermediate":"Intermediate",
"advance":"Advance"
}
programming_choice={
"py":"Python"
}
time_choice={
"1":"1 week",
"2":"2 week",
"3":"3 week"
} | level_choice = {'beginner': 'Beginner', 'intermediate': 'Intermediate', 'advance': 'Advance'}
programming_choice = {'py': 'Python'}
time_choice = {'1': '1 week', '2': '2 week', '3': '3 week'} |
#!/usr/bin/env python
# Copyright 2016 The Fuchsia Authors
#
# 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 ... | baby_names = ['Emma', 'Olivia', 'Noah', 'Liam', 'Sophia', 'Mason', 'Ava', 'Jacob', 'William', 'Isabella', 'Ethan', 'Mia', 'James', 'Alexander', 'Michael', 'Benjamin', 'Elijah', 'Daniel', 'Aiden', 'Logan', 'Matthew', 'Abigail', 'Lucas', 'Jackson', 'Emily', 'David', 'Oliver', 'Jayden', 'Joseph', 'Charlotte', 'Gabriel', '... |
def test_get_classes_full_unique_crns(class_info, test_data):
(classes_full, err) = class_info.get_classes_full()
assert err is None
assert len(classes_full) > 0
crns = []
for row in classes_full:
for section in row['sections']:
if section and section['crn']:
c... | def test_get_classes_full_unique_crns(class_info, test_data):
(classes_full, err) = class_info.get_classes_full()
assert err is None
assert len(classes_full) > 0
crns = []
for row in classes_full:
for section in row['sections']:
if section and section['crn']:
crns... |
def insertionSort(lista):
for indice in range(1,len(lista)):
valoreCorrente = lista[indice]
posizione = indice
while posizione>0 and lista[posizione-1]>valoreCorrente:
lista[posizione]=lista[posizione-1]
posizione = posizione-1
lista[posizione]=valoreCorrente
miaLista... | def insertion_sort(lista):
for indice in range(1, len(lista)):
valore_corrente = lista[indice]
posizione = indice
while posizione > 0 and lista[posizione - 1] > valoreCorrente:
lista[posizione] = lista[posizione - 1]
posizione = posizione - 1
lista[posizione] ... |
# this is a VGGNet demo.
def vgg_net(input_shape,num_classes):
# from VGG
model = Sequential()
# Conv1,2
model.add(Conv2D(
kernel_size=(3, 3),
activation="relu",
filters=64,
strides=(1,1),
input_shape=input_shape
))
model.add(Conv2D(
kernel_s... | def vgg_net(input_shape, num_classes):
model = sequential()
model.add(conv2_d(kernel_size=(3, 3), activation='relu', filters=64, strides=(1, 1), input_shape=input_shape))
model.add(conv2_d(kernel_size=(3, 3), activation='relu', filters=64, strides=(1, 1)))
model.add(max_pooling2_d((2, 2), strides=(2, 2)... |
def sum(a, b):
return int(a) + int(b)
def sub(a, b):
return int(a) - int(b)
| def sum(a, b):
return int(a) + int(b)
def sub(a, b):
return int(a) - int(b) |
def cache(func):
def wrapper(n):
cache_key = n
if cache_key not in wrapper.log:
wrapper.log[cache_key] = func(n)
return wrapper.log[cache_key]
wrapper.log = {}
return wrapper
@cache
def fibonacci(n):
if n < 2:
return n
else:
return fibonacci(n -... | def cache(func):
def wrapper(n):
cache_key = n
if cache_key not in wrapper.log:
wrapper.log[cache_key] = func(n)
return wrapper.log[cache_key]
wrapper.log = {}
return wrapper
@cache
def fibonacci(n):
if n < 2:
return n
else:
return fibonacci(n - ... |
class Maksukortti:
def __init__(self, saldo):
self.saldo = saldo
def lataa_rahaa(self, lisays):
self.saldo += lisays
def ota_rahaa(self, maara):
if self.saldo < maara:
return False
self.saldo = self.saldo - maara
return True
def __str__(self):
... | class Maksukortti:
def __init__(self, saldo):
self.saldo = saldo
def lataa_rahaa(self, lisays):
self.saldo += lisays
def ota_rahaa(self, maara):
if self.saldo < maara:
return False
self.saldo = self.saldo - maara
return True
def __str__(self):
... |
# https://www.codechef.com/problems/PROC18A
for _ in range(int(input())):
n,k=map(int,input().split())
a,m=list(map(int,input().split())),0
for z in range(n-k+1): m=max(m,sum(a[z:z+k]))
print(m) | for _ in range(int(input())):
(n, k) = map(int, input().split())
(a, m) = (list(map(int, input().split())), 0)
for z in range(n - k + 1):
m = max(m, sum(a[z:z + k]))
print(m) |
a = int(input())
b = int(input())
max_count = int(input())
flag = False
counter = 0
for A in range(35, 55):
for B in range(64, 96):
for x in range(1, a + 1):
for y in range(1, b + 1):
counter += 1
if counter > max_count:
flag = True
... | a = int(input())
b = int(input())
max_count = int(input())
flag = False
counter = 0
for a in range(35, 55):
for b in range(64, 96):
for x in range(1, a + 1):
for y in range(1, b + 1):
counter += 1
if counter > max_count:
flag = True
... |
file=open("user1.txt","w")
user=input("enter user name")
passward=input("enter passward")
file.write(user)
file.write("\n")
file.write(passward)
file.write("\n")
print("data inserted")
file.close()
| file = open('user1.txt', 'w')
user = input('enter user name')
passward = input('enter passward')
file.write(user)
file.write('\n')
file.write(passward)
file.write('\n')
print('data inserted')
file.close() |
def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Mass density (concentration) kg.m-3'},
{'abbr': 1,
'code': 1,
'title': 'Total column (integrated mass density) kg.m-2'},
{'abbr': 2,
'code': 2,
'title': 'Volume mixing ratio (mole fracti... | def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Mass density (concentration) kg.m-3'}, {'abbr': 1, 'code': 1, 'title': 'Total column (integrated mass density) kg.m-2'}, {'abbr': 2, 'code': 2, 'title': 'Volume mixing ratio (mole fraction in air) mole.mole-1'}, {'abbr': 3, 'code': 3, 'title': 'Mass mixing ratio... |
number = int(input())
if number != 0:
if number < 100 or number > 200:
print('invalid') | number = int(input())
if number != 0:
if number < 100 or number > 200:
print('invalid') |
# ------------------------- DESAFIO 006 -------------------------
# Criar um programa para mostrar o dobro, o triplo e a raiz quadrada de um nomedo digitado
num = int(input('Digite um Numero: '))
dob = num * 2
trip = num * 3
sqr = num ** (1/2)
print('Abaixo seguem os numeros conforme a ordem: \n Numero / Dobro / Tri... | num = int(input('Digite um Numero: '))
dob = num * 2
trip = num * 3
sqr = num ** (1 / 2)
print('Abaixo seguem os numeros conforme a ordem: \n Numero / Dobro / Triplo / Raiz Quadrada \n {:^6} / {:^5} / {:^6} / {:^13.2f}'.format(num, dob, trip, sqr)) |
class Solution:
def kLengthApart(self, nums: List[int], k: int) -> bool:
if k == 0:
return True
n = len(nums)
curr = 0
next = 1
while curr < n and next < n:
if nums[next] == 1:
if nums[curr] == 1 and next - curr <= k:
return False
curr = next
next += ... | class Solution:
def k_length_apart(self, nums: List[int], k: int) -> bool:
if k == 0:
return True
n = len(nums)
curr = 0
next = 1
while curr < n and next < n:
if nums[next] == 1:
if nums[curr] == 1 and next - curr <= k:
... |
# Suma Recursiva
# -*- coding: utf-8 -*-
# =======VARIABLES GLOBALES========
# ===========FUNCIONES=============
def menu():
pass
def suma(num):
pass
# =======CUERPO PRINCIPAL==========
if __name__ == "__main__":
acum = 0
print('-----------------SUMA RECURSIVA--------------------')
while(True... | def menu():
pass
def suma(num):
pass
if __name__ == '__main__':
acum = 0
print('-----------------SUMA RECURSIVA--------------------')
while True:
num = int(raw_input('Ingresa un numero: '))
acum += num
print('Resultado Acumulado:{}'.format(acum)) |
class Urls:
PAGE_LOGIN = "https://www.shudder.com/login"
API_LOGIN = "https://www.shudder.com/auth/login"
API_MY_LIST = "https://www.shudder.com/api/my-list"
API_SEARCH = "https://www.shudder.com/api/search/videos"
API_REVIEWS = "https://www.shudder.com/api/reviews/"
| class Urls:
page_login = 'https://www.shudder.com/login'
api_login = 'https://www.shudder.com/auth/login'
api_my_list = 'https://www.shudder.com/api/my-list'
api_search = 'https://www.shudder.com/api/search/videos'
api_reviews = 'https://www.shudder.com/api/reviews/' |
# Aquarium (230000000) => Free Market
sm.setReturnField()
sm.setReturnPortal()
sm.warp(910000000, 36)
| sm.setReturnField()
sm.setReturnPortal()
sm.warp(910000000, 36) |
#!/usr/bin/env python3.6
x = 123456789
x = 123456
x = .1
x = 1.
x = 1E+1
x = 1E-1
x = 1.000_000_01
x = 123456789.123456789
x = 123456789.123456789E123456789
x = 123456789E123456789
x = 123456789J
x = 123456789.123456789J
x = 0XB1ACC
x = 0B1011
x = 0O777
x = 0.000000006
x = 10000
x = 133333
# output
#!/usr/bin/env p... | x = 123456789
x = 123456
x = 0.1
x = 1.0
x = 10.0
x = 0.1
x = 1.00000001
x = 123456789.12345679
x = 1e309
x = 1e309
x = 123456789j
x = 123456789.12345679j
x = 727756
x = 11
x = 511
x = 6e-09
x = 10000
x = 133333
x = 123456789
x = 123456
x = 0.1
x = 1.0
x = 10.0
x = 0.1
x = 1.00000001
x = 123456789.12345679
x = 1e309
x ... |
class BaseNode:
def __init__(self):
self.next_node = None
def set_next(self, node):
self.next_node = node
def run(self, input_obj):
raise NotImplementedError
def set_nodes(node_list):
max_len = len(node_list)
for index, node in enumerate(node_list):
next_index = in... | class Basenode:
def __init__(self):
self.next_node = None
def set_next(self, node):
self.next_node = node
def run(self, input_obj):
raise NotImplementedError
def set_nodes(node_list):
max_len = len(node_list)
for (index, node) in enumerate(node_list):
next_index =... |
list=[2,5,9,6]
def revers(arr):
new_array=arr[::-1]
return new_array
print(revers(list))
# def revers(arr):
# new_array=[]
# for i in range(len(arr)-1,-1,-1):
# print(i)
# new_array.append(arr[i])
# print(new_array)
# revers(list)
# def revers(arr):
# new_array=[0 for i in a... | list = [2, 5, 9, 6]
def revers(arr):
new_array = arr[::-1]
return new_array
print(revers(list)) |
RUN_TEST = False
TEST_SOLUTION = 2
TEST_INPUT_FILE = 'test_input_day_19.txt'
INPUT_FILE = 'input_day_19.txt'
ARGS = []
def main_part1(input_file, ):
with open(input_file) as file:
rules, msgs = file.read().replace('"', '').split('\n\n')
rules, msgs = rules.split('\n'), msgs.split('\n')
rule_dict ... | run_test = False
test_solution = 2
test_input_file = 'test_input_day_19.txt'
input_file = 'input_day_19.txt'
args = []
def main_part1(input_file):
with open(input_file) as file:
(rules, msgs) = file.read().replace('"', '').split('\n\n')
(rules, msgs) = (rules.split('\n'), msgs.split('\n'))
rule_dic... |
class Config(object):
DEBUG = True
class ProductionConfig(Config):
DEBUG = False
class DevelopmentConfig(Config):
DEBUG = True
class TestingConfig(Config):
DEBUG = True | class Config(object):
debug = True
class Productionconfig(Config):
debug = False
class Developmentconfig(Config):
debug = True
class Testingconfig(Config):
debug = True |
# CodeWars Find_The_Distance_Between_Two_Points
def distance(x1, y1, x2, y2):
result = ((x2 - x1)**2 + (y2 - y1)**2)**0.5
return round(result, 2)
| def distance(x1, y1, x2, y2):
result = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
return round(result, 2) |
__all__ = [
'CombinedLengthError',
]
class CombinedLengthError(ValueError):
sequence: tuple[str, ...]
def __init__(self, sequence: tuple[str, ...]) -> None:
super().__init__(f'A sound sequence to be combined must contain at least 2 elements'
f' (got {len(sequence)}{f": {r... | __all__ = ['CombinedLengthError']
class Combinedlengtherror(ValueError):
sequence: tuple[str, ...]
def __init__(self, sequence: tuple[str, ...]) -> None:
super().__init__(f"A sound sequence to be combined must contain at least 2 elements (got {len(sequence)}{(f': {repr(sequence[0])}' if sequence else ... |
times = int(input())
for i in range(times):
n = int(input())
if n ==0:
print("NULL")
elif n >0:
if n % 2 == 1:
print("ODD POSITIVE")
else:
print("EVEN POSITIVE")
elif n<0:
if n % 2 == 1:
print("ODD NEGATIVE")
else:
p... | times = int(input())
for i in range(times):
n = int(input())
if n == 0:
print('NULL')
elif n > 0:
if n % 2 == 1:
print('ODD POSITIVE')
else:
print('EVEN POSITIVE')
elif n < 0:
if n % 2 == 1:
print('ODD NEGATIVE')
else:
... |
'''
Problem description:
The goal of this exercise is to convert a string to a new string where each character
in the new string is "(" if that character appears only once in the original string, or ")"
if that character appears more than once in the original string. Ignore capitalization when
determining if a char... | """
Problem description:
The goal of this exercise is to convert a string to a new string where each character
in the new string is "(" if that character appears only once in the original string, or ")"
if that character appears more than once in the original string. Ignore capitalization when
determining if a char... |
if int(input()):
print(0)
else:
print(1)
| if int(input()):
print(0)
else:
print(1) |
def spec_white(resid, exog):
'''
White's Two-Moment Specification Test
Parameters
----------
resid : array_like
OLS residuals
exog : array_like
OLS design matrix
Returns
-------
stat : float
test statistic
pval : float
chi-square p-value for test... | def spec_white(resid, exog):
"""
White's Two-Moment Specification Test
Parameters
----------
resid : array_like
OLS residuals
exog : array_like
OLS design matrix
Returns
-------
stat : float
test statistic
pval : float
chi-square p-value for test... |
lista_numeros = []
quantidade = 5
while quantidade > 0:
lista_numeros.append(int(input("")))
quantidade -= 1
valores_pares = 0
valores_impares = 0
valores_positivos = 0
valores_negativos = 0
for numero in lista_numeros:
if numero % 2 == 0:
valores_pares += 1
if numero % 2 != 0:
valor... | lista_numeros = []
quantidade = 5
while quantidade > 0:
lista_numeros.append(int(input('')))
quantidade -= 1
valores_pares = 0
valores_impares = 0
valores_positivos = 0
valores_negativos = 0
for numero in lista_numeros:
if numero % 2 == 0:
valores_pares += 1
if numero % 2 != 0:
valores_i... |
GET = 'GET'
PUT = 'PUT'
DEL = 'DEL'
ILLEGAL = 'ILLEGAL'
| get = 'GET'
put = 'PUT'
del = 'DEL'
illegal = 'ILLEGAL' |
# config.py
class Config(object):
embed_size = 300
num_channels = 100
kernel_size = [3,4,5]
output_size = 4
max_epochs = 15
lr = 0.3
batch_size = 64
max_sen_len = 30
dropout_keep = 0.8 | class Config(object):
embed_size = 300
num_channels = 100
kernel_size = [3, 4, 5]
output_size = 4
max_epochs = 15
lr = 0.3
batch_size = 64
max_sen_len = 30
dropout_keep = 0.8 |
#Find dynamically resolved IAT locations and apply labels from input file
#@author https://AGDCServices.com
#@category AGDCservices
#@keybinding
#@menupath
#@toolbar
#@toolbar
'''
Script will search program for all dynamically resolved
imports and label them with the appropriate API name pulled
from a provi... | """
Script will search program for all dynamically resolved
imports and label them with the appropriate API name pulled
from a provided labeled IAT dump file. Only resolved imports
stored in global variables will be identified. This script will
not label every resolved global variable, but only those that
are used in... |
class Value:
def __init__(self):
self.value = None
def __get__(self, instance, instance_type):
return self.value
def __set__(self, instance, amount):
self.value = amount * (1 - instance.commission)
class Account:
amount = Value()
def __init__(sel... | class Value:
def __init__(self):
self.value = None
def __get__(self, instance, instance_type):
return self.value
def __set__(self, instance, amount):
self.value = amount * (1 - instance.commission)
class Account:
amount = value()
def __init__(self, commission):
s... |
def test_get_priorities(testrail_client, mocked_response, priority_data, priority):
mocked_response(data_json=[priority_data])
api_priorities = testrail_client.priorities.get_priorities()
assert len(api_priorities) == 1
assert api_priorities[0] == priority
| def test_get_priorities(testrail_client, mocked_response, priority_data, priority):
mocked_response(data_json=[priority_data])
api_priorities = testrail_client.priorities.get_priorities()
assert len(api_priorities) == 1
assert api_priorities[0] == priority |
def SteamID264ID(SID):
SIDSplit = SID.split(':')
SID = int(SIDSplit[2]) * 2
if SIDSplit[1] == '1':
SID += 1
SID += 76561197960265728
return SID
| def steam_id264_id(SID):
sid_split = SID.split(':')
sid = int(SIDSplit[2]) * 2
if SIDSplit[1] == '1':
sid += 1
sid += 76561197960265728
return SID |
def get_max_dot_product(a, b):
a.sort()
b.sort()
return sum( [ a[i] * b[i] for i in range(len(a)) ] )
def main():
a = [1, 3, -5]
b = [-2, 4, 1]
print(get_max_dot_product(a, b))
if __name__ == '__main__':
main()
| def get_max_dot_product(a, b):
a.sort()
b.sort()
return sum([a[i] * b[i] for i in range(len(a))])
def main():
a = [1, 3, -5]
b = [-2, 4, 1]
print(get_max_dot_product(a, b))
if __name__ == '__main__':
main() |
#user input from terminal
name = input("What is your name: ") #to input a number you need to cast it
age = int(input("How old are you: "))
height = float(input("How height are you:"))
age += 1
print("Hello "+name)
print("Next year you will be "+str(age))
print("You are "+str(height)+"cm tall") | name = input('What is your name: ')
age = int(input('How old are you: '))
height = float(input('How height are you:'))
age += 1
print('Hello ' + name)
print('Next year you will be ' + str(age))
print('You are ' + str(height) + 'cm tall') |
def index_of_min(arr):
index = 0
min_num = arr[0]
for i in range(len(arr)):
if arr[i] < min_num:
index = i
min_num = arr[i]
return index
if __name__ == '__main__':
res = index_of_min([9, 8, 7, 6, -1, 5, 4, -5, 2, 1])
print(res) | def index_of_min(arr):
index = 0
min_num = arr[0]
for i in range(len(arr)):
if arr[i] < min_num:
index = i
min_num = arr[i]
return index
if __name__ == '__main__':
res = index_of_min([9, 8, 7, 6, -1, 5, 4, -5, 2, 1])
print(res) |
print("Please enter your age")
var1 = int(input())
var2 = 18
if var1<var2:
print("Sorry,You are not eligible for driving.")
if var1>120:
print("Sorry, Human lifespan exceeded.\n Enter proper age.")
else:
print("You are eligible for Driving.") | print('Please enter your age')
var1 = int(input())
var2 = 18
if var1 < var2:
print('Sorry,You are not eligible for driving.')
if var1 > 120:
print('Sorry, Human lifespan exceeded.\n Enter proper age.')
else:
print('You are eligible for Driving.') |
# File: fib_memo.py
# Fibonacci with memoization
M = {} # dict of already computed values
def F(n): # n is int, >= 0
if n in M:
return M[n]
if n == 0 or n == 1:
ret = n
else:
ret = F(n - 1) + F(n - 2)
M[n] = ret
return ret
# test code:
if __nam... | m = {}
def f(n):
if n in M:
return M[n]
if n == 0 or n == 1:
ret = n
else:
ret = f(n - 1) + f(n - 2)
M[n] = ret
return ret
if __name__ == '__main__':
print('F(0):', f(0))
print('F(1):', f(1))
print('F(2):', f(2))
print('F(5):', f(5))
print('F(10):', f(10)... |
def match(command):
return('./psh.phar' in command.script or
'administration:watch in command.output')
def get_new_command(command):
return './psh.phar administration:watch'.format(command.script);
enabled_by_default = True
| def match(command):
return './psh.phar' in command.script or 'administration:watch in command.output'
def get_new_command(command):
return './psh.phar administration:watch'.format(command.script)
enabled_by_default = True |
class Solution:
def transpose(self, matrix):
n = len(matrix)
for i in xrange(n):
for j in xrange(i + 1, n):
matrix[i][j], matrix[j][i] = matrix[j][i], matrix[i][j]
def mirror_vertical(self, matrix):
n = len(matrix)
for i in xrange(n):
... | class Solution:
def transpose(self, matrix):
n = len(matrix)
for i in xrange(n):
for j in xrange(i + 1, n):
(matrix[i][j], matrix[j][i]) = (matrix[j][i], matrix[i][j])
def mirror_vertical(self, matrix):
n = len(matrix)
for i in xrange(n):
... |
class SemiPerfectSquare:
def check(self, N):
l, u = int(N**.33), int(N**.5)
for b in xrange(l, u+1):
for a in xrange(1, b):
if a * b * b == N:
return 'Yes'
return 'No'
| class Semiperfectsquare:
def check(self, N):
(l, u) = (int(N ** 0.33), int(N ** 0.5))
for b in xrange(l, u + 1):
for a in xrange(1, b):
if a * b * b == N:
return 'Yes'
return 'No' |
x = 2
print(x)
x += 3
print(x)
x = "telor"
print(x)
x += "ceplok"
print(x)
| x = 2
print(x)
x += 3
print(x)
x = 'telor'
print(x)
x += 'ceplok'
print(x) |
#file : InMoov2.FingerStarter with voice control.py
# this will run with versions of MRL 1.0.107
# a very minimal script for InMoov
# although this script is very short you can still
# do voice control of a finger box
# for any command which you say - you will be required to say a confirmation
# e.g. you say -> open f... | right_port = 'COM7'
i01 = Runtime.createAndStart('i01', 'InMoov')
i01.startEar()
i01.startMouth()
i01.mouth.setGoogleURI('http://thehackettfamily.org/Voice_api/api2.php?voice=Ryan&txt=')
i01.startRightHand(rightPort)
i01.rightHand.index.setMinMax(0, 180)
i01.rightHand.index.map(0, 180, 35, 140)
ear = i01.ear
ear.addCom... |
# A Tuple is a collection which is ordered and unchangeable. Allows duplicate members.
# Create a tuple
fruits = ('Apples', 'Oranges', 'Grapes')
#fruits2 = tuple(('Banana', 'Mango'))
# Single value needs comma
fruits2 = ('Apples',)
# Delete tuple
#del fruits2
# get length
print(len(fruits))
# A Set is a collectio... | fruits = ('Apples', 'Oranges', 'Grapes')
fruits2 = ('Apples',)
print(len(fruits))
fruit_set = {'Apples', 'Mangos', 'Oranges'}
print('Apples' in fruit_set)
fruit_set.add('Grapes')
fruit_set.remove('Grapes')
fruit_set.clear()
print(fruit_set) |
''' Nome: Luiz Lima Cezario
Exercio para mostrar qunatos notas e quais notas
devem ser sacadas de um caixa eletronico a depender do valor inserido'''
def CedDiv(valor:int, div:int):
res = int(valor/div)
newvalor = valor - div*res
return res , newvalor
def Principal():
valor = int(input(''))
ced100 , v... | """ Nome: Luiz Lima Cezario
Exercio para mostrar qunatos notas e quais notas
devem ser sacadas de um caixa eletronico a depender do valor inserido"""
def ced_div(valor: int, div: int):
res = int(valor / div)
newvalor = valor - div * res
return (res, newvalor)
def principal():
valor = int(input('')... |
def add_time(start, duration, day = None):
# can remove later on, this is for testing. This parameter will be given in the function
start_hm = start.split(":")
start_hr = int(start_hm[0])
start_hm = start_hm[1].split(" ")
start_min = int(start_hm[0])
start_ampm = start_hm[1]
# c... | def add_time(start, duration, day=None):
start_hm = start.split(':')
start_hr = int(start_hm[0])
start_hm = start_hm[1].split(' ')
start_min = int(start_hm[0])
start_ampm = start_hm[1]
if start_ampm == 'PM':
start_hr = start_hr + 12
duration_hm = duration.split(':')
duration_hr =... |
# Tuple elegant syntax to swap variables
c = 3
d = 4
c, d = d, c
assert (c, d) == (4, 3)
assert (c) == 4
assert (c,) != 4
assert (c, d) != (3, 4)
# Common method is to use a tmp variable
a = 1
b = 2
tmp = a
a = b
b = tmp
assert (a, b) == (2, 1)
# Example: Split an email address
name, domain = "office@goo... | c = 3
d = 4
(c, d) = (d, c)
assert (c, d) == (4, 3)
assert c == 4
assert (c,) != 4
assert (c, d) != (3, 4)
a = 1
b = 2
tmp = a
a = b
b = tmp
assert (a, b) == (2, 1)
(name, domain) = 'office@google.com'.split('@')
assert (name, domain) == ('office', 'google.com')
assert domain == 'google.com' |
NUMPAD = [
[1,2,3],
[4,5,6],
[7,8,9],
]
NUMPAD2 = [
[' ',' ','1',' ',' '],
[' ','2','3','4',' '],
['5','6','7','8','9'],
[' ','A','B','C',' '],
[' ',' ','D',' ',' ']
]
def get_bathroom_code(instructions, numpad, start):
size = len(numpad)
x,y = start
code = []
for line in instructions:
... | numpad = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
numpad2 = [[' ', ' ', '1', ' ', ' '], [' ', '2', '3', '4', ' '], ['5', '6', '7', '8', '9'], [' ', 'A', 'B', 'C', ' '], [' ', ' ', 'D', ' ', ' ']]
def get_bathroom_code(instructions, numpad, start):
size = len(numpad)
(x, y) = start
code = []
for line in instru... |
n = int(input())
if n & 1:
print(0)
exit(0)
n //= 2
ans = 0
while n:
ans += (n // 5)
n //= 5
print(ans)
| n = int(input())
if n & 1:
print(0)
exit(0)
n //= 2
ans = 0
while n:
ans += n // 5
n //= 5
print(ans) |
class PersistentNumber:
def getPersistence(self, n):
def p(x):
return reduce(lambda a, e: a * int(e), str(x), 1)
i = 0
while n > 9:
i += 1
n = p(n)
return i
| class Persistentnumber:
def get_persistence(self, n):
def p(x):
return reduce(lambda a, e: a * int(e), str(x), 1)
i = 0
while n > 9:
i += 1
n = p(n)
return i |
class BaseDBError(Exception):
pass
class QueryError(BaseDBError):
pass
| class Basedberror(Exception):
pass
class Queryerror(BaseDBError):
pass |
TITLE = "Exporter hub"
ACCOUNT = "Export control account"
ACCOUNT_HOME = "Account home"
SWITCH_ORG = "Switch organisation <!--from -->"
SIGNATURE_GUIDANCE = "Guidance on LITE document digital signatures"
class Navigation:
YOUR_ACCOUNT = "Manage your organisation and personal details"
class Tiles:
APPLY_FOR_... | title = 'Exporter hub'
account = 'Export control account'
account_home = 'Account home'
switch_org = 'Switch organisation <!--from -->'
signature_guidance = 'Guidance on LITE document digital signatures'
class Navigation:
your_account = 'Manage your organisation and personal details'
class Tiles:
apply_for_li... |
n, b, d = map(int, input().split())
a = list(map(int, input().split()))
t = 0
c = 0
for i in range(n):
if a[i] <= b:
t += a[i]
if t > d:
t = 0
c += 1
print(c) | (n, b, d) = map(int, input().split())
a = list(map(int, input().split()))
t = 0
c = 0
for i in range(n):
if a[i] <= b:
t += a[i]
if t > d:
t = 0
c += 1
print(c) |
def multiple_of_3_and_5(n):
sum = 0
for i in range(n):
sum += i if i % 3 == 0 or i % 5 == 0 else 0
return sum
raise NotImplementedError()
if __name__ == "__main__":
n = int(input())
print(multiple_of_3_and_5(n)) | def multiple_of_3_and_5(n):
sum = 0
for i in range(n):
sum += i if i % 3 == 0 or i % 5 == 0 else 0
return sum
raise not_implemented_error()
if __name__ == '__main__':
n = int(input())
print(multiple_of_3_and_5(n)) |
class int:
def __init__(self, jsobject):
self.jsobject = jsobject
def __not__(self):
jsobject = self.jsobject
if jscode('jsobject == 0'):
return True
return False
def __abs__(self):
if self < 0:
return -self
return self
def __ne... | class Int:
def __init__(self, jsobject):
self.jsobject = jsobject
def __not__(self):
jsobject = self.jsobject
if jscode('jsobject == 0'):
return True
return False
def __abs__(self):
if self < 0:
return -self
return self
def __ne... |
def manager_check(user):
return user.isManager()
def privileged_check(user):
return user.isManager() or user.isOfficer()
def officer_check(user):
return user.isOfficer()
| def manager_check(user):
return user.isManager()
def privileged_check(user):
return user.isManager() or user.isOfficer()
def officer_check(user):
return user.isOfficer() |
Sun = pd.read_csv('data/sun.csv')
Sun.set_index('YEAR', inplace=True)
N=250
sun_forecast02 = forecast(Sun['SUNACTIVITY'], 0.2, N)
sun_forecast04 = forecast(Sun['SUNACTIVITY'], 0.4, N)
sun_forecast06 = forecast(Sun['SUNACTIVITY'], 0.6, N)
ax = Sun.iloc[N:].plot(y=['SUNACTIVITY'], lw=2)
ax.plot(Sun.index[N:], sun_for... | sun = pd.read_csv('data/sun.csv')
Sun.set_index('YEAR', inplace=True)
n = 250
sun_forecast02 = forecast(Sun['SUNACTIVITY'], 0.2, N)
sun_forecast04 = forecast(Sun['SUNACTIVITY'], 0.4, N)
sun_forecast06 = forecast(Sun['SUNACTIVITY'], 0.6, N)
ax = Sun.iloc[N:].plot(y=['SUNACTIVITY'], lw=2)
ax.plot(Sun.index[N:], sun_forec... |
statement_one = (2 + 2 + 2 >= 6) and (-1 * -1 < 0)
statement_two = (4 * 2 <= 8) and (7 - 1 == 6)
credits = 120
gpa = 3.4
if credits >= 120 and gpa >= 2.0:
print("You meet the requirements to graduate!") | statement_one = 2 + 2 + 2 >= 6 and -1 * -1 < 0
statement_two = 4 * 2 <= 8 and 7 - 1 == 6
credits = 120
gpa = 3.4
if credits >= 120 and gpa >= 2.0:
print('You meet the requirements to graduate!') |
def grade(key, submission):
if submission == "a_waterfall_is_just_a_stream_on_its_side":
return True, "Nice job! If waterfalls are streams on their side, what about rain?"
else:
return False, "That doesn't sound right. Streamline your thinking."
| def grade(key, submission):
if submission == 'a_waterfall_is_just_a_stream_on_its_side':
return (True, 'Nice job! If waterfalls are streams on their side, what about rain?')
else:
return (False, "That doesn't sound right. Streamline your thinking.") |
# Python3 program to swap elements
# at given positions
# Swap function
def swapPositions(list, pos1, pos2):
list[pos1], list[pos2] = list[pos2], list[pos1]
return list
# Driver function
List = [23, 65, 19, 90]
pos1, pos2 = 1, 3
print(swapPositions(List, pos1-1, pos2-1))
| def swap_positions(list, pos1, pos2):
(list[pos1], list[pos2]) = (list[pos2], list[pos1])
return list
list = [23, 65, 19, 90]
(pos1, pos2) = (1, 3)
print(swap_positions(List, pos1 - 1, pos2 - 1)) |
#
# PySNMP MIB module POWERHUB-CORE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/POWERHUB-CORE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:32:47 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, value_range_constraint, constraints_union, single_value_constraint) ... |
print("Kinjal Raykarmakar\nSec: CSE2H\tRoll: 29\n")
l = [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
l.sort(key= lambda x: x[1])
print(l) | print('Kinjal Raykarmakar\nSec: CSE2H\tRoll: 29\n')
l = [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
l.sort(key=lambda x: x[1])
print(l) |
baseurl = "https://raw.githubusercontent.com/serchaofan/laogu-scripts/master/scripts/shell"
url = {
"sysinfo": f"{baseurl}/info/sysinfo.sh",
"loadinfo": f"{baseurl}/info/loadinfo.sh"
} | baseurl = 'https://raw.githubusercontent.com/serchaofan/laogu-scripts/master/scripts/shell'
url = {'sysinfo': f'{baseurl}/info/sysinfo.sh', 'loadinfo': f'{baseurl}/info/loadinfo.sh'} |
#
# PySNMP MIB module XXX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/XXX-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:38:11 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:23:15)... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, constraints_union, value_range_constraint, value_size_constraint, constraints_intersection) ... |
class Solution:
def sortedSquares(self, nums: List[int]) -> List[int]:
left_pointer = 0
right_pointer = len(nums) - 1
sorted_array = [0 for x in range(len(nums))]
insert_position = len(nums) - 1
while left_pointer <= right_pointer:
right_item = nums[right_pointer]... | class Solution:
def sorted_squares(self, nums: List[int]) -> List[int]:
left_pointer = 0
right_pointer = len(nums) - 1
sorted_array = [0 for x in range(len(nums))]
insert_position = len(nums) - 1
while left_pointer <= right_pointer:
right_item = nums[right_pointe... |
# -*- coding: utf-8 -*-
class UserAdminMixin(object):
def save_model(self, request, obj, form, change):
if hasattr(obj, 'creator_id') and not change:
obj.creator_id = request.user.id
if hasattr(obj, 'last_modifier_id'):
obj.last_modifier_id = request.user.id
super(U... | class Useradminmixin(object):
def save_model(self, request, obj, form, change):
if hasattr(obj, 'creator_id') and (not change):
obj.creator_id = request.user.id
if hasattr(obj, 'last_modifier_id'):
obj.last_modifier_id = request.user.id
super(UserAdminMixin, self).sa... |
# Min XOR value
# https://www.interviewbit.com/problems/min-xor-value/
#
# Given an array of N integers, find the pair of integers in the array which have minimum XOR value. Report the minimum XOR value.
#
# Examples :
# Input
# 0 2 5 7
# Output
# 2 (0 XOR 2)
# Input
# 0 4 7 9
# Output
# 3 (4 XOR 7)
#
# Constraints:
# ... | class Solution:
def find_min_xor(self, A):
A.sort()
return min(map(lambda i: A[i] ^ A[i + 1], range(len(A) - 1))) |
#IFs, elifs and multiple ifs
alien_colors = ['red', 'green', 'blue', 'yellow']
if ('green' in alien_colors):
print("You just earned 5 freaking points for saving the humanity")
if ('black' in alien_colors):
print("You just earned 5 freaking points for saving the humanity")
else:
print('oopsie dasiy. You did ... | alien_colors = ['red', 'green', 'blue', 'yellow']
if 'green' in alien_colors:
print('You just earned 5 freaking points for saving the humanity')
if 'black' in alien_colors:
print('You just earned 5 freaking points for saving the humanity')
else:
print('oopsie dasiy. You did not manage to kill the real alien... |
# A school has decided to create three new math groups and
# equip three classrooms for them with new desks. Your task is to
# calculate the minimum number of desks to be purchased. To do
# so, you'll need the following information:
#
# The number of students in each of the three groups is
# known: your program will re... | (a, b, c) = (int(input()), int(input()), int(input()))
first_desk = a // 2 + a % 2
second_desk = b // 2 + b % 2
third_desk = c // 2 + c % 2
print(int(first_desk + second_desk + third_desk))
first_desk = int(input()) // 2 + a % 2
second_desk = int(input()) // 2 + b % 2
third_desk = int(input()) // 2 + c % 2
print(int(fi... |
def core_type(a):
if (type(a) is float):
return 'num'
if (type(a) is int):
return 'num'
elif (type(a) is bool):
return 'bool'
elif (type(a) is str):
return 'string'
elif (type(a) is list):
return 'list'
else:
return 'unknown'
| def core_type(a):
if type(a) is float:
return 'num'
if type(a) is int:
return 'num'
elif type(a) is bool:
return 'bool'
elif type(a) is str:
return 'string'
elif type(a) is list:
return 'list'
else:
return 'unknown' |
class CloudmeshCloud(object):
def __init__(self, filename=None):
if filename is None:
filename = "cloudmehs.yaml"
self.config = ConfigDict(filename)
def get(self, cloud):
if cloud in config["cloudmesh"]["clouds"]:
return config["cloudmesh"]["clouds"][cloud]
| class Cloudmeshcloud(object):
def __init__(self, filename=None):
if filename is None:
filename = 'cloudmehs.yaml'
self.config = config_dict(filename)
def get(self, cloud):
if cloud in config['cloudmesh']['clouds']:
return config['cloudmesh']['clouds'][cloud] |
# define interface to create object
# let subclass to decide which object to create
# defere instantiation to subclasses
# also called as vitual constructor
singleton_meta | singleton_meta |
coordinates_E0E1E1 = ((123, 107),
(123, 109), (123, 112), (123, 114), (123, 115), (124, 107), (124, 109), (124, 113), (125, 107), (125, 109), (126, 99), (126, 100), (126, 106), (126, 108), (127, 69), (127, 70), (127, 78), (127, 98), (127, 100), (127, 106), (127, 108), (128, 68), (128, 71), (128, 72), (128, 74), (128,... | coordinates_e0_e1_e1 = ((123, 107), (123, 109), (123, 112), (123, 114), (123, 115), (124, 107), (124, 109), (124, 113), (125, 107), (125, 109), (126, 99), (126, 100), (126, 106), (126, 108), (127, 69), (127, 70), (127, 78), (127, 98), (127, 100), (127, 106), (127, 108), (128, 68), (128, 71), (128, 72), (128, 74), (128,... |
''' A lazy factory '''
class Fib:
def __init__(self):
self.prev = 0
self.curr = 1
def __iter__(self):
return self
def __next__(self):
retval = self.curr
self.curr += self.prev
self.prev = retval
return retval
| """ A lazy factory """
class Fib:
def __init__(self):
self.prev = 0
self.curr = 1
def __iter__(self):
return self
def __next__(self):
retval = self.curr
self.curr += self.prev
self.prev = retval
return retval |
noop_entries = [
{
"env-title": "atari-alien",
"env-variant": "No-op start",
"score": 40804.9,
},
{
"env-title": "atari-amidar",
"env-variant": "No-op start",
"score": 8659.2,
},
{
"env-title": "atari-assault",
"env-variant": "No-op sta... | noop_entries = [{'env-title': 'atari-alien', 'env-variant': 'No-op start', 'score': 40804.9}, {'env-title': 'atari-amidar', 'env-variant': 'No-op start', 'score': 8659.2}, {'env-title': 'atari-assault', 'env-variant': 'No-op start', 'score': 24559.4}, {'env-title': 'atari-asterix', 'env-variant': 'No-op start', 'score'... |
# Definition for a point
# class Point:
# def __init__(self, a=0, b=0):
# self.x = a
# self.y = b
class Solution:
def one_line(self, pnt_i, pnt_j, pnt_k):
if pnt_i.x == pnt_j.x and pnt_j.x == pnt_k.x:
return True;
if pnt_i.y == pnt_j.y and pnt_j.y == pnt_k.y:
... | class Solution:
def one_line(self, pnt_i, pnt_j, pnt_k):
if pnt_i.x == pnt_j.x and pnt_j.x == pnt_k.x:
return True
if pnt_i.y == pnt_j.y and pnt_j.y == pnt_k.y:
return True
return (pnt_j.y - pnt_i.y) * (pnt_k.x - pnt_j.x) == (pnt_j.x - pnt_i.x) * (pnt_k.y - pnt_j.y)
... |
students = int(input())
lectures = int(input())
course_bonus = int(input())
scores_bonus = []
attendance_list = []
for at in range(students): # "at" is the attendances
student_attendances = input()
total_bonus = int(student_attendances) / lectures * (5 + course_bonus)
scores_bonus.append(total_bonus)
... | students = int(input())
lectures = int(input())
course_bonus = int(input())
scores_bonus = []
attendance_list = []
for at in range(students):
student_attendances = input()
total_bonus = int(student_attendances) / lectures * (5 + course_bonus)
scores_bonus.append(total_bonus)
attendance_list.append(stude... |
name0_1_0_0_0_1_0 = None
name0_1_0_0_0_1_1 = None
name0_1_0_0_0_1_2 = None
name0_1_0_0_0_1_3 = None
name0_1_0_0_0_1_4 = None | name0_1_0_0_0_1_0 = None
name0_1_0_0_0_1_1 = None
name0_1_0_0_0_1_2 = None
name0_1_0_0_0_1_3 = None
name0_1_0_0_0_1_4 = None |
available_toppings = ['mushrooms', 'green peppers', 'extra cheese', 'olives', 'pineapple', 'pepperoni']
requested_toppings = ['mushrooms', 'french fries', 'extra cheese']
for requested_topping in requested_toppings:
if requested_topping in available_toppings:
print ('adding ' + requested_topping + '.')
... | available_toppings = ['mushrooms', 'green peppers', 'extra cheese', 'olives', 'pineapple', 'pepperoni']
requested_toppings = ['mushrooms', 'french fries', 'extra cheese']
for requested_topping in requested_toppings:
if requested_topping in available_toppings:
print('adding ' + requested_topping + '.')
e... |
# from __future__ import print_function
# allows the following print() to work if using python 2
# print("Hello", "planet", "earth")
def average(*args: int) -> float:
print(type(args))
print("args is {}".format(args)) # (3, 4, 5, 1)
print(*args) # 3 4 5 1
mean = 0
for arg in args:
mean +... | def average(*args: int) -> float:
print(type(args))
print('args is {}'.format(args))
print(*args)
mean = 0
for arg in args:
mean += arg
return mean / len(args)
def print_tuple(*args) -> tuple:
return args
def average_length(*args: str) -> float:
mean = 0
for arg in args:
... |
# thomas (Desnord)
# objetivo: verificar em uma matriz quando um indice for divisor do outro e
# quantas vezes isso ocorre
# entrada: dimensao da matriz
# saida: linhas da matriz e o valor do contador
x = int(input()) # le a dimensao da matriz
m = list(range(x)) # cria uma vetor com a dimensao especificada
cont = ... | x = int(input())
m = list(range(x))
cont = 0
for i in range(x):
for j in range(x):
if (i + 1) % (j + 1) == 0 or (j + 1) % (i + 1) == 0:
m[j] = '*'
cont += 1
else:
m[j] = '-'
print(''.join(map(str, m)))
print(cont) |
class MockResponse:
def __init__(self, json, status):
self._json = json
self.status = status
async def json(self):
return self._json
async def __aexit__(self, exc_type, exc, tb):
pass
async def __aenter__(self):
return self
| class Mockresponse:
def __init__(self, json, status):
self._json = json
self.status = status
async def json(self):
return self._json
async def __aexit__(self, exc_type, exc, tb):
pass
async def __aenter__(self):
return self |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.