content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Copyright (c) 2020 vesoft inc. All rights reserved.
#
# This source code is licensed under Apache 2.0 License,
# attached with Common Clause Condition 1.0, found in the LICENSES directory.
def __bytes2ul(b):
return int.from_bytes(b, byteorder='little', signed=False)
def mmh2(bstr, seed=0xc70f6907, signed=True)... | def __bytes2ul(b):
return int.from_bytes(b, byteorder='little', signed=False)
def mmh2(bstr, seed=3339675911, signed=True):
mask = 2 ** 64 - 1
size = len(bstr)
m = 14313749767032793493
r = 47
h = seed ^ size * m & MASK
end = size & 4294967288
for pos in range(0, end, 8):
k = __b... |
def init(n,m):
state_initial = [n] + [1] * m
state_current = state_initial
state_final = [n] * (m + 1)
return state_initial, state_current, state_final
def valid_transition(currentState, tower_i, tower_j):
k = 0
t = 0
if tower_i == tower_j: # same tower not allowed
return False
... | def init(n, m):
state_initial = [n] + [1] * m
state_current = state_initial
state_final = [n] * (m + 1)
return (state_initial, state_current, state_final)
def valid_transition(currentState, tower_i, tower_j):
k = 0
t = 0
if tower_i == tower_j:
return False
for i in range(1, len(... |
class Vector:
'''Vector class modeling Vectors'''
def __init__(self,initialise_param):
'''constructor:-create list of num length'''
if isinstance(initialise_param,(Vector,list)):
self._coords=[i for i in initialise_param]
elif isinstance(initialise_param,(int)):
... | class Vector:
"""Vector class modeling Vectors"""
def __init__(self, initialise_param):
"""constructor:-create list of num length"""
if isinstance(initialise_param, (Vector, list)):
self._coords = [i for i in initialise_param]
elif isinstance(initialise_param, int):
... |
def createList():
fruitsList = ["apple", "banana", "cherry"]
print("Fruit List : ", fruitsList)
# Iterate the list of fruits
for i in fruitsList:
print("Value : ", i)
# Add to fruits list
fruitsList.append("kiwi")
fruitsList.append("Grape")
fruitsList.append("Orange")
... | def create_list():
fruits_list = ['apple', 'banana', 'cherry']
print('Fruit List : ', fruitsList)
for i in fruitsList:
print('Value : ', i)
fruitsList.append('kiwi')
fruitsList.append('Grape')
fruitsList.append('Orange')
print('After adding furits now list ...')
for fruit in frui... |
class SlopeGradient:
def __init__(self, rightSteps, downSteps):
self.rightSteps = rightSteps
self.downSteps = downSteps
| class Slopegradient:
def __init__(self, rightSteps, downSteps):
self.rightSteps = rightSteps
self.downSteps = downSteps |
S = input()
is_no = False
for s in S:
if S.count(s) != 2:
is_no = True
break
if is_no:
print("No")
else:
print("Yes")
| s = input()
is_no = False
for s in S:
if S.count(s) != 2:
is_no = True
break
if is_no:
print('No')
else:
print('Yes') |
class WeekSchedule():
def __init__(self, dates=[], codes=[]):
self.weeknum = 0
self.dates = dates
self.codes = codes | class Weekschedule:
def __init__(self, dates=[], codes=[]):
self.weeknum = 0
self.dates = dates
self.codes = codes |
a=10
print(type(a))
a='Python'
print(type(a))
a=False
print(type(a)) | a = 10
print(type(a))
a = 'Python'
print(type(a))
a = False
print(type(a)) |
''' Code for training and evaluating Self-Explaining Neural Networks.
Copyright (C) 2018 David Alvarez-Melis <dalvmel@mit.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of ... | """ Code for training and evaluating Self-Explaining Neural Networks.
Copyright (C) 2018 David Alvarez-Melis <dalvmel@mit.edu>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of ... |
load("@io_bazel_rules_docker//container:container.bzl", "container_pull")
def image_deps():
container_pull(
name = "python3.7",
digest = "sha256:57c7d7161fdaa79b61f107b8a480c50657d64dca37295d67db2f675abe38b45a",
registry = "index.docker.io",
repository = "library/python",
ta... | load('@io_bazel_rules_docker//container:container.bzl', 'container_pull')
def image_deps():
container_pull(name='python3.7', digest='sha256:57c7d7161fdaa79b61f107b8a480c50657d64dca37295d67db2f675abe38b45a', registry='index.docker.io', repository='library/python', tag='3.7.8') |
#!/usr/bin/python
ADMIN_SCHEMA_FOLDER = "admin/schemas/"
ADMIN_SCHEMA_CHAR_SEPARATOR = "_"
ADD_COIN_METHOD = "addcoin"
GET_COIN_METHOD = "getcoin"
REMOVE_COIN_METHOD = "removecoin"
UPDATE_COIN_METHOD = "updatecoin"
| admin_schema_folder = 'admin/schemas/'
admin_schema_char_separator = '_'
add_coin_method = 'addcoin'
get_coin_method = 'getcoin'
remove_coin_method = 'removecoin'
update_coin_method = 'updatecoin' |
exp_name = 'glean_ffhq_16x'
scale = 16
# model settings
model = dict(
type='GLEAN',
generator=dict(
type='GLEANStyleGANv2',
in_size=64,
out_size=1024,
style_channels=512,
pretrained=dict(
ckpt_path='http://download.openmmlab.com/mmgen/stylegan2/'
... | exp_name = 'glean_ffhq_16x'
scale = 16
model = dict(type='GLEAN', generator=dict(type='GLEANStyleGANv2', in_size=64, out_size=1024, style_channels=512, pretrained=dict(ckpt_path='http://download.openmmlab.com/mmgen/stylegan2/official_weights/stylegan2-ffhq-config-f-official_20210327_171224-bce9310c.pth', prefix='genera... |
#1 Create countries dictionary
countries = __________________
#2 Print out the capital of egypt
print(__________________) | countries = __________________
print(__________________) |
# -*- coding:utf-8 -*-
__author__ = [
'wufang'
]
| __author__ = ['wufang'] |
a = int(input())
b = int(input())
def rectangle_area(a, b):
return '{:.0f}'.format(a * b)
print(rectangle_area(a, b))
| a = int(input())
b = int(input())
def rectangle_area(a, b):
return '{:.0f}'.format(a * b)
print(rectangle_area(a, b)) |
class Solution:
def minSteps(self, n: int) -> int:
res, m = 0, 2
while n > 1:
while n % m == 0:
res += m
n //= m
m += 1
return res | class Solution:
def min_steps(self, n: int) -> int:
(res, m) = (0, 2)
while n > 1:
while n % m == 0:
res += m
n //= m
m += 1
return res |
# Example, do not modify!
print(5 / 8)
# Put code below here
5 / 8
print( 7 + 10 )
# Just testing division
print(5 / 8)
# Addition works too.
print(7 + 10)
# Addition and subtraction
print(5 + 5)
print(5 - 5)
# Multiplication and division
print(3 * 5)
print(10 / 2)
# Exponentiation
print(4 ** 2)
# Modulo
print(... | print(5 / 8)
5 / 8
print(7 + 10)
print(5 / 8)
print(7 + 10)
print(5 + 5)
print(5 - 5)
print(3 * 5)
print(10 / 2)
print(4 ** 2)
print(18 % 7)
print(100 * 1.1 ** 7)
savings = 100
print(savings)
savings = 100
factor = 1.1
result = savings * factor ** 7
print(result)
desc = 'compound interest'
profitable = True
savings = 1... |
# -*- coding: utf-8 -*-
name = 'smsapi-client'
version = '2.3.0'
lib_info = '%s/%s' % (name, version) | name = 'smsapi-client'
version = '2.3.0'
lib_info = '%s/%s' % (name, version) |
f = open('day6.txt', 'r')
data = f.read()
groups = data.split('\n\n')
answer = 0
for group in groups:
people = group.split('\n')
group_set = set(people[0])
for person in people:
group_set = group_set & set(person)
answer += len(group_set)
print(answer)
| f = open('day6.txt', 'r')
data = f.read()
groups = data.split('\n\n')
answer = 0
for group in groups:
people = group.split('\n')
group_set = set(people[0])
for person in people:
group_set = group_set & set(person)
answer += len(group_set)
print(answer) |
#!/bin/python3
def day12(lines):
registers = {'a': 0, 'b': 0, 'c': 1, 'd': 0}
i = 0
k = 0
while i < len(lines):
if k > 0:
i += 1
k -= 1
continue
line = lines[i].strip('\n').split(' ')
print('[%d, %d, %d, %d], %s' % (registers['a'],
... | def day12(lines):
registers = {'a': 0, 'b': 0, 'c': 1, 'd': 0}
i = 0
k = 0
while i < len(lines):
if k > 0:
i += 1
k -= 1
continue
line = lines[i].strip('\n').split(' ')
print('[%d, %d, %d, %d], %s' % (registers['a'], registers['b'], registers['... |
mutables_test_text_001 = '''
def function(
param,
):
pass
'''
mutables_test_text_002 = '''
def function(
param=0,
):
pass
'''
mutables_test_text_003 = '''
def function(
param={},
):
pass
'''
mutables_test_text_004 = '''
def function(
param=[],
):
pass
'''
mutables_test_text_005 = '''
def... | mutables_test_text_001 = '\ndef function(\n param,\n):\n pass\n'
mutables_test_text_002 = '\ndef function(\n param=0,\n):\n pass\n'
mutables_test_text_003 = '\ndef function(\n param={},\n):\n pass\n'
mutables_test_text_004 = '\ndef function(\n param=[],\n):\n pass\n'
mutables_test_text_005 = '\n... |
#
# PySNMP MIB module CISCO-ENTITY-FRU-CONTROL-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-ENTITY-FRU-CONTROL-CAPABILITY
# Produced by pysmi-0.3.4 at Wed May 1 11:57:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Usi... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, value_range_constraint, value_size_constraint, constraints_intersection) ... |
# validated: 2018-01-14 DV a68a0c3ebf0b libraries/driver/include/ctre/phoenix/MotorControl/Faults.h
__all__ = ['FaultsBase']
class FaultsBase:
fields = []
def __init__(self, bits = 0):
mask = 1
for field in self.fields:
setattr(self, field, bool(bits & mask))
mask <<... | __all__ = ['FaultsBase']
class Faultsbase:
fields = []
def __init__(self, bits=0):
mask = 1
for field in self.fields:
setattr(self, field, bool(bits & mask))
mask <<= 1
def to_bitfield(self):
retval = 0
mask = 1
for field in self.fields:
... |
# Databricks notebook source
HLRIOWYITKFDP
GOQFOEKSZNF
BQRYZYCEYRHRVDKCQSN
BELVHHTEWWKFYTNTWJIIYUQTBHUMOCJNDBBIPBOVCDIKTUPVXZRIUC
AUVGECGGHDZPJPMFEZWDFYYDXYGEMHXRHYXXGEMXTCZOPGPGSRCIQNPHCUONPPCBOWTFOZEYCXCQKKUNDSXSBAKSMWIPUKICUWX
HDCWKJXOZHPPXWBBPLIGLXMBATYPTDTCAACKEEWURDREVIIUPRJXDFNDLSHBZEBMWQOMYFWARMGERQAXVLFREGTYUX... | HLRIOWYITKFDP
GOQFOEKSZNF
BQRYZYCEYRHRVDKCQSN
BELVHHTEWWKFYTNTWJIIYUQTBHUMOCJNDBBIPBOVCDIKTUPVXZRIUC
AUVGECGGHDZPJPMFEZWDFYYDXYGEMHXRHYXXGEMXTCZOPGPGSRCIQNPHCUONPPCBOWTFOZEYCXCQKKUNDSXSBAKSMWIPUKICUWX
HDCWKJXOZHPPXWBBPLIGLXMBATYPTDTCAACKEEWURDREVIIUPRJXDFNDLSHBZEBMWQOMYFWARMGERQAXVLFREGTYUXPABORSDUP
XPSNALKIEEH
TNRJVKV... |
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
# Function to print the list
def printList(self):
node = self
output = ''
while node is not None:
output += str(node.val)
output += " "
node =... | class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
def print_list(self):
node = self
output = ''
while node is not None:
output += str(node.val)
output += ' '
node = node.next
print(output)
@stat... |
# My Script:
hrs=input('Enter Hours: ')
hrs=float(hrs)
rph=input('Enter your rate per hour: ')
rph=float(rph)
pay=hrs*rph
print('Pay:', pay)
| hrs = input('Enter Hours: ')
hrs = float(hrs)
rph = input('Enter your rate per hour: ')
rph = float(rph)
pay = hrs * rph
print('Pay:', pay) |
#!/usr/bin/python
def twosum(list, target):
for i in list:
for j in list:
if i != j and i + j == target:
return True
return False
with open('xmas.txt') as fh:
lines = fh.readlines()
nums = [int(l.strip()) for l in lines]
idx = 25
while(True):
last25 = nums[idx-25... | def twosum(list, target):
for i in list:
for j in list:
if i != j and i + j == target:
return True
return False
with open('xmas.txt') as fh:
lines = fh.readlines()
nums = [int(l.strip()) for l in lines]
idx = 25
while True:
last25 = nums[idx - 25:idx]
if twosum(la... |
class Solution:
# Max to Min distance pair, O(n^2) time, O(1) space
def maxDistance(self, colors: List[int]) -> int:
for dist in range(len(colors)-1, 0, -1):
for i in range(len(colors)-dist):
if colors[i] != colors[i+dist]:
return dist
# Max dist from... | class Solution:
def max_distance(self, colors: List[int]) -> int:
for dist in range(len(colors) - 1, 0, -1):
for i in range(len(colors) - dist):
if colors[i] != colors[i + dist]:
return dist
def max_distance(self, A: List[int]) -> int:
(i, j) = (... |
#Functions
def userFunction(): #Putting Function
print("Hello, User :)")
print("Have a nice day!")
#Calling Function
userFunction()
| def user_function():
print('Hello, User :)')
print('Have a nice day!')
user_function() |
num_of_lines = int(input())
def cold_compress(cum, rs):
N = len(cum)
# exit
if (rs == ""):
output_string = ""
for s in cum:
output_string += str(s) + " "
return output_string
# iteration
if (N >= 2 and cum[N-1] == rs[0]):
cnt = cum[N-2]
cnt += 1
... | num_of_lines = int(input())
def cold_compress(cum, rs):
n = len(cum)
if rs == '':
output_string = ''
for s in cum:
output_string += str(s) + ' '
return output_string
if N >= 2 and cum[N - 1] == rs[0]:
cnt = cum[N - 2]
cnt += 1
cum[N - 2] = cnt
... |
# arr = [2, 3, -4, -9, -1, -7, 1, -5, -6]
arr = [0, 0, 0, 0]
def next_p(arr, l, x):
print("px0", x)
while x <= l - 1 and arr[x] < 0:
x += 1
print("px1", x)
print("px2", x)
return x
def next_n(arr, l, x):
print("nx0", x)
while x <= l - 1 and arr[x] >= 0:
x += 1
... | arr = [0, 0, 0, 0]
def next_p(arr, l, x):
print('px0', x)
while x <= l - 1 and arr[x] < 0:
x += 1
print('px1', x)
print('px2', x)
return x
def next_n(arr, l, x):
print('nx0', x)
while x <= l - 1 and arr[x] >= 0:
x += 1
print('nx1', x)
print('nx2', x)
ret... |
# -*- coding: utf-8 -*-
# OPENID URLS
URL_WELL_KNOWN = "realms/{realm-name}/.well-known/openid-configuration"
URL_TOKEN = "realms/{realm-name}/protocol/openid-connect/token"
URL_USERINFO = "realms/{realm-name}/protocol/openid-connect/userinfo"
URL_LOGOUT = "realms/{realm-name}/protocol/openid-connect/logout"
URL_CERTS... | url_well_known = 'realms/{realm-name}/.well-known/openid-configuration'
url_token = 'realms/{realm-name}/protocol/openid-connect/token'
url_userinfo = 'realms/{realm-name}/protocol/openid-connect/userinfo'
url_logout = 'realms/{realm-name}/protocol/openid-connect/logout'
url_certs = 'realms/{realm-name}/protocol/openid... |
#DEFAULT ARGS
print('Default Args : ')
def sample(a, b = 0, c = 1) :
print(a, b, c)
sample(10)
sample(10, 20)
sample(10, 20, 30)
#VARIABLE NUMBER OF ARGS
print('VARIABLE NUMBER OF ARGS : ')
def add(a, b, *t) :
s = a + b
for x in t :
s = s + x
return s
print(add(1, 2, 3, 4))
#KEY - WORD ARGS
print('KEY - WORD... | print('Default Args : ')
def sample(a, b=0, c=1):
print(a, b, c)
sample(10)
sample(10, 20)
sample(10, 20, 30)
print('VARIABLE NUMBER OF ARGS : ')
def add(a, b, *t):
s = a + b
for x in t:
s = s + x
return s
print(add(1, 2, 3, 4))
print('KEY - WORD ARGS : ')
def sample2(j, k, l):
print(j, k... |
string = 'b a '
newstring = string[-1::-1]
length = 0
print(newstring)
for i in range(0, len(newstring)):
if newstring[i] == ' ':
if i == 0:
continue
if newstring[i-1] == ' ':
continue
break
length += 1
print(length) | string = 'b a '
newstring = string[-1::-1]
length = 0
print(newstring)
for i in range(0, len(newstring)):
if newstring[i] == ' ':
if i == 0:
continue
if newstring[i - 1] == ' ':
continue
break
length += 1
print(length) |
NEPS_URL = 'https://neps.academy'
ENGLISH_BUTTON = '/html/body/div/div/div/div[2]/div/div/a/div[2]/div'
LOGIN_PAGE_BUTTON = '//*[@id="app"]/div/div/div/div[1]/div/header/div/div/div[3]/div/div/nav/ul/li[6]/button'
EMAIL_INPUT = '/html/body/div/div/div/div[3]/div/div/div/form/div[1]/div/div[1]/div/input'
PASSWORD_INPUT ... | neps_url = 'https://neps.academy'
english_button = '/html/body/div/div/div/div[2]/div/div/a/div[2]/div'
login_page_button = '//*[@id="app"]/div/div/div/div[1]/div/header/div/div/div[3]/div/div/nav/ul/li[6]/button'
email_input = '/html/body/div/div/div/div[3]/div/div/div/form/div[1]/div/div[1]/div/input'
password_input ... |
password = input()
alpha = False
upalpha = False
digit = False
for i in password:
if i.isspace():
print("NOPE")
break
if i.isdigit():
digit = True
if i.isalpha():
if i.isupper():
upalpha = True
if i.islower():
alpha = True
else:
if alpha an... | password = input()
alpha = False
upalpha = False
digit = False
for i in password:
if i.isspace():
print('NOPE')
break
if i.isdigit():
digit = True
if i.isalpha():
if i.isupper():
upalpha = True
if i.islower():
alpha = True
else:
if alpha an... |
#!/usr/bin/env python3
class IndexCreator:
def __init__(self):
self._index = 0
def generate(self):
r = self._index
self._index += 1
return r
def clear(self):
self._index = 0
if __name__ == "__main__":
i = IndexCreator()
print(i.generate(), i.genera... | class Indexcreator:
def __init__(self):
self._index = 0
def generate(self):
r = self._index
self._index += 1
return r
def clear(self):
self._index = 0
if __name__ == '__main__':
i = index_creator()
print(i.generate(), i.generate(), i.generate(), i.generate(... |
#Drinklist by Danzibob Credits to him!
drink_list = [{
'name': 'Vesper',
'ingredients': {
'gin': 60,
'vodka': 15.0,
'vermouth': 7.5
},
},
{
'name': 'Bacardi',
'ingredients': {
'whiteRum': 45.0,
'lij': 20,
... | drink_list = [{'name': 'Vesper', 'ingredients': {'gin': 60, 'vodka': 15.0, 'vermouth': 7.5}}, {'name': 'Bacardi', 'ingredients': {'whiteRum': 45.0, 'lij': 20, 'grenadine': 10}}, {'name': 'Kryptonite', 'ingredients': {'vodka': 8.0, 'whiskey': 7.0, 'lej': 6.0, 'oj': 5.0, 'grenadine': 4.0, 'cj': 3.0, 'rum': 2.0, 'vermouth... |
'''
Thanks to "Primo" for the amazing code found in this .py.
'''
# legendre symbol (a|m)
# note: returns m-1 if a is a non-residue, instead of -1
def legendre(a, m):
return pow(a, (m-1) >> 1, m)
# strong probable prime
def is_sprp(n, b=2):
d = n-1
s = 0
while d & 1 == 0:
s... | """
Thanks to "Primo" for the amazing code found in this .py.
"""
def legendre(a, m):
return pow(a, m - 1 >> 1, m)
def is_sprp(n, b=2):
d = n - 1
s = 0
while d & 1 == 0:
s += 1
d >>= 1
x = pow(b, d, n)
if x == 1 or x == n - 1:
return True
for r in range(1, s):
... |
a = "Hello World"
b = a[3]
c = a[-2]
d = a[5::]
e = a[:5]
print(b)
print(c)
print(d)
print(e)
| a = 'Hello World'
b = a[3]
c = a[-2]
d = a[5:]
e = a[:5]
print(b)
print(c)
print(d)
print(e) |
overlapped_classes = ["Alarm clock",
"Backpack",
"Banana",
"Band Aid",
"Basket",
"Bath towel",
"Beer bottle",
"Bench",
"Bicycle",
"Binder (closed)",
"Bottle cap",
"Bread loaf",
"Broom",
"Bucket",
"Butcher's knife",
"Can opener",
"Candle",
"Cellphone",
"Chair",
"Clothes hamper",
"Combination lock",
"Computer mouse",
"De... | overlapped_classes = ['Alarm clock', 'Backpack', 'Banana', 'Band Aid', 'Basket', 'Bath towel', 'Beer bottle', 'Bench', 'Bicycle', 'Binder (closed)', 'Bottle cap', 'Bread loaf', 'Broom', 'Bucket', "Butcher's knife", 'Can opener', 'Candle', 'Cellphone', 'Chair', 'Clothes hamper', 'Combination lock', 'Computer mouse', 'De... |
indexes = range(5)
same_indexes = range(0, 5)
print("indexes are:")
for i in indexes:
print(i)
print("same_indexes are:")
for i in same_indexes:
print(i)
special_indexes = range(5, 9)
print("special_indexes are:")
for i in special_indexes:
print(i) | indexes = range(5)
same_indexes = range(0, 5)
print('indexes are:')
for i in indexes:
print(i)
print('same_indexes are:')
for i in same_indexes:
print(i)
special_indexes = range(5, 9)
print('special_indexes are:')
for i in special_indexes:
print(i) |
print('\nCalculate the midpoint of a line :')
x1 = float(input('The value of x (the first endpoint) '))
y1 = float(input('The value of y (the first endpoint) '))
x2 = float(input('The value of x (the first endpoint) '))
y2 = float(input('The value of y (the first endpoint) '))
x_m_point = (x1 + x2)/2
y_m_point = (y1... | print('\nCalculate the midpoint of a line :')
x1 = float(input('The value of x (the first endpoint) '))
y1 = float(input('The value of y (the first endpoint) '))
x2 = float(input('The value of x (the first endpoint) '))
y2 = float(input('The value of y (the first endpoint) '))
x_m_point = (x1 + x2) / 2
y_m_point = (y1 ... |
ts = [
# example tests
14,
16,
23,
# small numbers
5,
4,
3,
2,
1,
# random bit bigger numbers
10,
20,
31,
32,
33,
46,
# perfect squares
25,
36,
49,
# random incrementally larger numbers
73,
89,
106,
132,
182,
258,
299,... | ts = [14, 16, 23, 5, 4, 3, 2, 1, 10, 20, 31, 32, 33, 46, 25, 36, 49, 73, 89, 106, 132, 182, 258, 299, 324, 359, 489, 512, 581, 713, 834, 952, 986, 996, 997, 998, 999]
for (i, n) in enumerate(ts):
with open('T%02d.in' % i, 'w') as f:
f.write('%d\n' % n) |
n=int(input())
while n:
n-=1
print(pow(*map(int,input().split()),10**9+7))
| n = int(input())
while n:
n -= 1
print(pow(*map(int, input().split()), 10 ** 9 + 7)) |
# Wrapper class to make dealing with logs easier
class ChannelLog():
__channel = ""
__logs = []
unread = False
mentioned_in = False
# the index of where to start printing the messages
__index = 0
def __init__(self, channel, logs):
self.__channel = channel
self.__logs = list... | class Channellog:
__channel = ''
__logs = []
unread = False
mentioned_in = False
__index = 0
def __init__(self, channel, logs):
self.__channel = channel
self.__logs = list(logs)
def get_server(self):
return self.__channel.server
def get_channel(self):
r... |
l= int(input("Enter the size of array \n"))
a=input("Enter the integer inputs\n").split()
c=0
a[0]=int(a[0])
for i in range(1,l):
a[i]=int(a[i])
while a[i]<a[i-1]:
c+=1
a[i]+=1
print(c)
| l = int(input('Enter the size of array \n'))
a = input('Enter the integer inputs\n').split()
c = 0
a[0] = int(a[0])
for i in range(1, l):
a[i] = int(a[i])
while a[i] < a[i - 1]:
c += 1
a[i] += 1
print(c) |
1 == 2
segfault()
class Dupe(object):
pass
class Dupe(Dupe):
pass
| 1 == 2
segfault()
class Dupe(object):
pass
class Dupe(Dupe):
pass |
# General Errors
NO_ERROR = 0
USER_EXIT = 1
ERR_SUDO_PERMS = 100
ERR_FOUND = 101
ERR_PYTHON_PKG = 154
# Warnings
WARN_FILE_PERMS = 115
WARN_LOG_ERRS = 126
WARN_LOG_WARNS = 127
WARN_LARGE_FILES = 151
# Installation Errors
ERR_BITS = 102
ERR_OS_VER = 103
ERR_OS = 104
ERR_FINDING_OS = 105
ERR_FREE_SPACE = 106
ERR_PKG_MA... | no_error = 0
user_exit = 1
err_sudo_perms = 100
err_found = 101
err_python_pkg = 154
warn_file_perms = 115
warn_log_errs = 126
warn_log_warns = 127
warn_large_files = 151
err_bits = 102
err_os_ver = 103
err_os = 104
err_finding_os = 105
err_free_space = 106
err_pkg_manager = 107
err_omsconfig = 108
err_omi = 109
err_sc... |
"{variable_name:format_description}"
print('{a:<10}|{a:^10}|{a:>10}'.format(a='test'))
print('{a:~<10}|{a:~^10}|{a:~>10}'.format(a='test'))
person = {"first":"Joran","last":"Beasley"}
print("{p[first]} {p[last]}".format(p=person))
data = range(100)
print("{d[0]}...{d[99]}".format(d=data))
print("normal:{num:d}".forma... | """{variable_name:format_description}"""
print('{a:<10}|{a:^10}|{a:>10}'.format(a='test'))
print('{a:~<10}|{a:~^10}|{a:~>10}'.format(a='test'))
person = {'first': 'Joran', 'last': 'Beasley'}
print('{p[first]} {p[last]}'.format(p=person))
data = range(100)
print('{d[0]}...{d[99]}'.format(d=data))
print('normal:{num:d}'.... |
def solution(A,B,K):
count = 0
for i in range(A,B):
if(i%K==0):
count += 1
#print(count)
return count
solution(6,11,2) | def solution(A, B, K):
count = 0
for i in range(A, B):
if i % K == 0:
count += 1
return count
solution(6, 11, 2) |
# -*- coding: utf-8 -*-
class Solution:
def getLucky(self, s: str, k: int) -> int:
result = ''.join(str(ord(c) - ord('a') + 1) for c in s)
for _ in range(k):
result = sum(int(digit) for digit in str(result))
return result
if __name__ == '__main__':
solution = Solution()
... | class Solution:
def get_lucky(self, s: str, k: int) -> int:
result = ''.join((str(ord(c) - ord('a') + 1) for c in s))
for _ in range(k):
result = sum((int(digit) for digit in str(result)))
return result
if __name__ == '__main__':
solution = solution()
assert 36 == soluti... |
def calc_average(case):
sum = 0
count = int(case[0])
for i in range(1, count + 1):
sum += int(case[i])
return sum / count
def count_average(case, average):
count = 0
count_num = int(case[0])
for i in range(1, count_num + 1):
if average < int(case[i]):
count += 1... | def calc_average(case):
sum = 0
count = int(case[0])
for i in range(1, count + 1):
sum += int(case[i])
return sum / count
def count_average(case, average):
count = 0
count_num = int(case[0])
for i in range(1, count_num + 1):
if average < int(case[i]):
count += 1
... |
def decorator(func):
def wrapper():
print("Decoring")
func()
print("Done!")
return wrapper
@decorator
def say_hi():
print("Hi!")
if __name__ == "__main__":
say_hi()
| def decorator(func):
def wrapper():
print('Decoring')
func()
print('Done!')
return wrapper
@decorator
def say_hi():
print('Hi!')
if __name__ == '__main__':
say_hi() |
s = pd.Series(
data=np.random.randn(NUMBER),
index=pd.date_range('2000-01-01', freq='D', periods=NUMBER))
result = s['2000-02-14':'2000-02']
| s = pd.Series(data=np.random.randn(NUMBER), index=pd.date_range('2000-01-01', freq='D', periods=NUMBER))
result = s['2000-02-14':'2000-02'] |
# https://edabit.com/challenge/Yx2a9B57vXRuPevGh
# Create a function that takes length and width and finds the perimeter of a rectangle.
def find_perimeter(x: int, y: int) -> int:
perimeter = (x * 2) + (y * 2)
return perimeter
print(find_perimeter(20, 10))
| def find_perimeter(x: int, y: int) -> int:
perimeter = x * 2 + y * 2
return perimeter
print(find_perimeter(20, 10)) |
# -*- coding: utf-8 -*-
# This file is generated from NI Switch Executive API metadata version 21.0.0d1
config = {
'api_version': '21.0.0d1',
'c_function_prefix': 'niSE_',
'close_function': 'CloseSession',
'context_manager_name': {
},
'custom_types': [
],
'driver_name': 'NI Switch Execut... | config = {'api_version': '21.0.0d1', 'c_function_prefix': 'niSE_', 'close_function': 'CloseSession', 'context_manager_name': {}, 'custom_types': [], 'driver_name': 'NI Switch Executive', 'driver_registry': 'Switch Executive', 'extra_errors_used': ['InvalidRepeatedCapabilityError'], 'init_function': 'OpenSession', 'libr... |
class DomainServiceBase:
def __init__(self, repository):
self.repository = repository
def update(self, obj, updated_data={}):
self.repository.update(obj, updated_data)
def delete(self, obj):
self.repository.delete(obj)
def create(self, obj):
obj = self.repository.creat... | class Domainservicebase:
def __init__(self, repository):
self.repository = repository
def update(self, obj, updated_data={}):
self.repository.update(obj, updated_data)
def delete(self, obj):
self.repository.delete(obj)
def create(self, obj):
obj = self.repository.crea... |
# score_manager.py
#Score Manager
ENEMY_SCORE = 300
RUPEE_SCORE = 500
scores = {
"ENEMY": ENEMY_SCORE,
"RUPEE": RUPEE_SCORE,
}
my_scores = {
"ENEMY": 300,
"MONEY": 1000,
"LASER": 1000,
"HP": 200,
"DEFENSE": 100
}
def calculate_score(score_type):
return my_scores[score_type]
| enemy_score = 300
rupee_score = 500
scores = {'ENEMY': ENEMY_SCORE, 'RUPEE': RUPEE_SCORE}
my_scores = {'ENEMY': 300, 'MONEY': 1000, 'LASER': 1000, 'HP': 200, 'DEFENSE': 100}
def calculate_score(score_type):
return my_scores[score_type] |
'''
Created on Mar 1, 2016
@author: kashefy
'''
class Phase:
TRAIN = 'Train'
TEST = 'Test'
| """
Created on Mar 1, 2016
@author: kashefy
"""
class Phase:
train = 'Train'
test = 'Test' |
class Node:
#Initialize node oject
def __init__(self, data):
self.data = data #assign data
self.next = None #declare next as null
class LinkedList:
#Initialize head
def __init__(self):
self.head = None
#### Insert in the beginning
def push(self, content):
... | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
def push(self, content):
new_node = node(content)
new_node.next = self.head
self.head = new_node
def insert_after(self, prev... |
class Solution:
# @param {character[][]} matrix
# @return {integer}
def maximalSquare(self, matrix):
if not matrix:
return 0
max_square = 0
self.visited = []
for line in matrix:
row = []
for c in line:
row.append(0)
... | class Solution:
def maximal_square(self, matrix):
if not matrix:
return 0
max_square = 0
self.visited = []
for line in matrix:
row = []
for c in line:
row.append(0)
self.visited.append(row)
self.visited[0] = [in... |
#! /usr/bin/python3.7
# soh cah toa
def sin():
o = float(input('What is the oppisite?: '))
h = float(input("What is the hypotnuse?: "))
s = o / h
print("sin = {}".format(s))
def cos():
a = float(input('What is the ajacent?: '))
h = float(input("What is the hypotnuse?: "))
c = a / h
print('cos = {}'.format(c))... | def sin():
o = float(input('What is the oppisite?: '))
h = float(input('What is the hypotnuse?: '))
s = o / h
print('sin = {}'.format(s))
def cos():
a = float(input('What is the ajacent?: '))
h = float(input('What is the hypotnuse?: '))
c = a / h
print('cos = {}'.format(c))
def tan():
... |
# Scale Settings
# For 005.mp4
SCALE_WIDTH = 25
SCALE_HEIGHT = 50
# SCALE_WIDTH = 100
# SCALE_HEIGHT = 100
# Video Settings
DETECT_AFTER_N = 50
# NMS Settings
NMS_CONFIDENCE = 0.1
NMS_THRESHOLD = 0.1
# Detection Settings
DETECTION_CONFIDENCE = 0.9
# Tracker Settings
MAX_DISAPPEARED = 50 | scale_width = 25
scale_height = 50
detect_after_n = 50
nms_confidence = 0.1
nms_threshold = 0.1
detection_confidence = 0.9
max_disappeared = 50 |
a=int(input("Enter the first number:"))
b=int(input("Enter the second number:"))
c=int(input("Enter the third number:"))
if a<b in c>a:
min=a
elif a<b in c>b:
min=b
else:
min=c
print(min)
| a = int(input('Enter the first number:'))
b = int(input('Enter the second number:'))
c = int(input('Enter the third number:'))
if a < b in c > a:
min = a
elif a < b in c > b:
min = b
else:
min = c
print(min) |
def cycles_until_reseen(bins):
configs = set()
curr = bins
while tuple(curr) not in configs:
configs.add(tuple(curr))
min_idx = 0
for i in range(1, len(curr)):
if curr[i] > curr[min_idx]:
min_idx = i
redistribute = curr[min_idx]
curr[min_i... | def cycles_until_reseen(bins):
configs = set()
curr = bins
while tuple(curr) not in configs:
configs.add(tuple(curr))
min_idx = 0
for i in range(1, len(curr)):
if curr[i] > curr[min_idx]:
min_idx = i
redistribute = curr[min_idx]
curr[min_id... |
n = int(input())
count_2 = 0
count_5 = 0
for i in range(2,n+1):
num = i
while(1):
if num%2 == 0:
count_2 += 1
num //= 2
elif num%5 == 0:
count_5 += 1
num //= 5
else: break
print(min(count_2,count_5)) | n = int(input())
count_2 = 0
count_5 = 0
for i in range(2, n + 1):
num = i
while 1:
if num % 2 == 0:
count_2 += 1
num //= 2
elif num % 5 == 0:
count_5 += 1
num //= 5
else:
break
print(min(count_2, count_5)) |
if 1:
N = int(input())
Q = int(input())
queries = []
for i in range(Q):
queries.append([int(x) for x in input().split()])
else:
N = 100000
queries = [
[2, 1, 2],
[4, 1, 2]
] * 10000
queries.append([4, 1, 2])
Q = len(queries)
isTransposed = False
xs = list(ra... | if 1:
n = int(input())
q = int(input())
queries = []
for i in range(Q):
queries.append([int(x) for x in input().split()])
else:
n = 100000
queries = [[2, 1, 2], [4, 1, 2]] * 10000
queries.append([4, 1, 2])
q = len(queries)
is_transposed = False
xs = list(range(N + 1))
ys = list(r... |
# Location of the data.
reference_data_path = '/p/cscratch/acme/data/obs_for_acme_diags/'
test_data_path = '/p/cscratch/acme/data/test_model_data_for_acme_diags/'
# Name of the test model data, used to find the climo files.
test_name = '20161118.beta0.FC5COSP.ne30_ne30.edison'
# An optional, shorter name to be used ins... | reference_data_path = '/p/cscratch/acme/data/obs_for_acme_diags/'
test_data_path = '/p/cscratch/acme/data/test_model_data_for_acme_diags/'
test_name = '20161118.beta0.FC5COSP.ne30_ne30.edison'
short_test_name = 'beta0.FC5COSP.ne30'
sets = ['lat_lon']
results_dir = 'era_tas_land'
backend = 'mpl'
diff_title = 'Model - Ob... |
file_name=str(input("Input the Filename:"))
if(file_name.split('.')[1]=='c'):
print('The extension of the file is C')
if(file_name.split('.')[1]=='cpp'):
print('The extension of the file is C++')
if(file_name.split('.')[1]=='java'):
print('The extension of the file is Java')
if(file_name.split('.')[1]=='py'):
p... | file_name = str(input('Input the Filename:'))
if file_name.split('.')[1] == 'c':
print('The extension of the file is C')
if file_name.split('.')[1] == 'cpp':
print('The extension of the file is C++')
if file_name.split('.')[1] == 'java':
print('The extension of the file is Java')
if file_name.split('.')[1] ... |
#
# PySNMP MIB module INTELCORPORATION-MULTI-FLEX-SERVER-DRIVE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/INTELCORPORATION-MULTI-FLEX-SERVER-DRIVE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:54:55 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by u... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, single_value_constraint, constraints_intersection, value_size_constraint, value_range_constraint) ... |
def delUser(cur,con,loginid):
try:
query = "DELETE FROM USER WHERE Login_id='%s'" % (loginid)
#print(query)
cur.execute(query)
con.commit()
print("Deleted from Database")
except Exception as e:
con.rollback()
print("Failed to delete from database")
... | def del_user(cur, con, loginid):
try:
query = "DELETE FROM USER WHERE Login_id='%s'" % loginid
cur.execute(query)
con.commit()
print('Deleted from Database')
except Exception as e:
con.rollback()
print('Failed to delete from database')
print('>>>>>>>>>>>>>... |
# program to generate the combinations of n distinct objects taken from the elements of a given list.
def combination(n, n_list):
if n<=0:
yield []
return
for i in range(len(n_list)):
c_num = n_list[i:i+1]
for a_num in combination(n-1, n_list[i+1:]):
yield c_num + a_n... | def combination(n, n_list):
if n <= 0:
yield []
return
for i in range(len(n_list)):
c_num = n_list[i:i + 1]
for a_num in combination(n - 1, n_list[i + 1:]):
yield (c_num + a_num)
n_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
print('Original list:')
print(n_list)
n = 2
result =... |
def install(job):
service = job.service
# create user if it doesn't exists
username = service.model.dbobj.name
password = service.model.data.password
email = service.model.data.email
provider = service.model.data.provider
username = "%s@%s" % (username, provider) if provider else username... | def install(job):
service = job.service
username = service.model.dbobj.name
password = service.model.data.password
email = service.model.data.email
provider = service.model.data.provider
username = '%s@%s' % (username, provider) if provider else username
password = password if not provider e... |
if condition1:
...
elif condition2:
...
elif condition3:
...
elif condition4:
...
elif condition5:
...
elif condition6:
...
else:
...
| if condition1:
...
elif condition2:
...
elif condition3:
...
elif condition4:
...
elif condition5:
...
elif condition6:
...
else:
... |
# Python - 3.6.0
test.assert_equals(relatively_prime(8, [1, 2, 3, 4, 5, 6, 7]), [1, 3, 5, 7])
test.assert_equals(relatively_prime(15, [72, 27, 32, 61, 77, 11, 40]), [32, 61, 77, 11])
test.assert_equals(relatively_prime(210, [15, 100, 2222222, 6, 4, 12369, 99]), [])
| test.assert_equals(relatively_prime(8, [1, 2, 3, 4, 5, 6, 7]), [1, 3, 5, 7])
test.assert_equals(relatively_prime(15, [72, 27, 32, 61, 77, 11, 40]), [32, 61, 77, 11])
test.assert_equals(relatively_prime(210, [15, 100, 2222222, 6, 4, 12369, 99]), []) |
def save_file(contents):
with open("path_to_save_the_file.wav", 'wb') as f:
f.write(contents)
return "path_to_save_the_file.wav"
| def save_file(contents):
with open('path_to_save_the_file.wav', 'wb') as f:
f.write(contents)
return 'path_to_save_the_file.wav' |
expected_output = {
"main": {
"chassis": {
"ASR1002-X": {
"descr": "Cisco ASR1002-X Chassis",
"name": "Chassis",
"pid": "ASR1002-X",
"sn": "FOX1111P1M1",
"vid": "V07",
}
}
},
"slot": {
... | expected_output = {'main': {'chassis': {'ASR1002-X': {'descr': 'Cisco ASR1002-X Chassis', 'name': 'Chassis', 'pid': 'ASR1002-X', 'sn': 'FOX1111P1M1', 'vid': 'V07'}}}, 'slot': {'0': {'lc': {'ASR1002-X': {'descr': 'Cisco ASR1002-X SPA Interface Processor', 'name': 'module 0', 'pid': 'ASR1002-X', 'sn': '', 'subslot': {'0'... |
A = 1
connection= {
A : ['B'],
'B' : ['A', 'B', 'D'],
'C' : ['A'],
'D' : ['E','A'],
'E' : ['B']
}
for f in connection:
print(connection['B'])
print(connection[id])
| a = 1
connection = {A: ['B'], 'B': ['A', 'B', 'D'], 'C': ['A'], 'D': ['E', 'A'], 'E': ['B']}
for f in connection:
print(connection['B'])
print(connection[id]) |
# emacs: -*- mode: python-mode; py-indent-offset: 2; tab-width: 2; indent-tabs-mode: nil -*-
# ex: set sts=2 ts=2 sw=2 et:
__all__ = ['classify', 'cluster', 'decode', 'meta', 'network', 'reduce', 'stats']
| __all__ = ['classify', 'cluster', 'decode', 'meta', 'network', 'reduce', 'stats'] |
def f1(x, *args):
pass
f1(42, 'spam')
| def f1(x, *args):
pass
f1(42, 'spam') |
{
'includes': [
'./common.gypi'
],
'target_defaults': {
'defines' : [
'PNG_PREFIX',
'PNGPREFIX_H',
'PNG_USE_READ_MACROS',
],
# 'include_dirs': [
# '<(DEPTH)/third_party/pdfium',
# '<(DEPTH)/third_party/pdfium/third_party/freetype/include',
# ],
'conditions': [
... | {'includes': ['./common.gypi'], 'target_defaults': {'defines': ['PNG_PREFIX', 'PNGPREFIX_H', 'PNG_USE_READ_MACROS'], 'conditions': [['OS=="linux"', {'conditions': [['target_arch=="x64"', {'defines': ['_FX_CPU_=_FX_X64_'], 'cflags': ['-fPIC']}], ['target_arch=="ia32"', {'defines': ['_FX_CPU_=_FX_X86_']}]]}]], 'msvs_disa... |
def normalizer(x, norm):
if norm == 'l2':
norm_val = sum(xi ** 2 for xi in x) ** .5
elif norm == 'l1':
norm_val = sum(abs(xi) for xi in x)
elif norm == 'max':
norm_val = max(abs(xi) for xi in x)
return [xi / norm_val for xi in x]
def standard_scaler(x, mean_, var_, with_mean, ... | def normalizer(x, norm):
if norm == 'l2':
norm_val = sum((xi ** 2 for xi in x)) ** 0.5
elif norm == 'l1':
norm_val = sum((abs(xi) for xi in x))
elif norm == 'max':
norm_val = max((abs(xi) for xi in x))
return [xi / norm_val for xi in x]
def standard_scaler(x, mean_, var_, with_m... |
print('Enter any integer: ')
n = str(input().strip())
num_places = len(n)
for i in range(num_places) :
x = num_places - i
if x >= 10 :
suffix = "Billion "
elif x <= 9 and x >= 7 :
suffix = "Million "
elif x == 6 :
suffix = "Hundred "
elif x == 5 :
suffix = "Thousan... | print('Enter any integer: ')
n = str(input().strip())
num_places = len(n)
for i in range(num_places):
x = num_places - i
if x >= 10:
suffix = 'Billion '
elif x <= 9 and x >= 7:
suffix = 'Million '
elif x == 6:
suffix = 'Hundred '
elif x == 5:
suffix = 'Thousand '
... |
def search(arr, d, y):
for m in range(0, d):
if (arr[m] == y):
return m;
return -1;
arr = [4, 8, 26, 30, 13];
p = 30;
k = len(arr);
result = search(arr, k, p)
if (result == -1):
print("Element is not present in array")
else:
print("Element is present at index", result... | def search(arr, d, y):
for m in range(0, d):
if arr[m] == y:
return m
return -1
arr = [4, 8, 26, 30, 13]
p = 30
k = len(arr)
result = search(arr, k, p)
if result == -1:
print('Element is not present in array')
else:
print('Element is present at index', result) |
# Turns an RPN expression to normal mathematical notation
_VARIABLES = {
"0": "0",
"1": "1",
"P": "pi",
"a": "x0",
"b": "x1",
"c": "x2",
"d": "x3",
"e": "x4",
"f": "x5",
"g": "x6",
"h": "x7",
"i": "x8",
"j": "x9",
"k": "x10",
"l": "x11",
"m": "x12",
"... | _variables = {'0': '0', '1': '1', 'P': 'pi', 'a': 'x0', 'b': 'x1', 'c': 'x2', 'd': 'x3', 'e': 'x4', 'f': 'x5', 'g': 'x6', 'h': 'x7', 'i': 'x8', 'j': 'x9', 'k': 'x10', 'l': 'x11', 'm': 'x12', 'n': 'x13'}
_ops_unary = {'>': '({}+1)', '<': '({}-1)', '~': '(-{})', '\\': '({})**(-1)', 'L': 'log({})', 'E': 'exp({})', 'S': 's... |
#converts the pixel bytes to binary
def decToBin(dec):
secret_bin = []
for i in dec:
secret_bin.append(f'{i:08b}')
return secret_bin
#gets the last 2 LSB of each byte
def get2LSB(secret_bin):
last2 = []
for i in secret_bin:
for j in i[6:8]:
last2.append(j... | def dec_to_bin(dec):
secret_bin = []
for i in dec:
secret_bin.append(f'{i:08b}')
return secret_bin
def get2_lsb(secret_bin):
last2 = []
for i in secret_bin:
for j in i[6:8]:
last2.append(j)
return last2
def filter2_lsb(listdict, last2):
piclsb = []
replace_n... |
# Do not edit this file directly.
# It was auto-generated by: code/programs/reflexivity/reflexive_refresh
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def buildfarm():
http_archive(
name="buildfarm" ,
build_file="//bazel/deps/buildfarm:build.BUILD" ,
sha256="de2a18... | load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
def buildfarm():
http_archive(name='buildfarm', build_file='//bazel/deps/buildfarm:build.BUILD', sha256='de2a18bbe1e6770be0cd54e93630fb1ee7bce937bff708eed16329033fbfe32b', strip_prefix='bazel-buildfarm-355f816acf3531e9e37d860acf9ebbb89c9041c2', u... |
class ReporterInterface(object):
def notify_before_console_output(self):
pass
def notify_after_console_output(self):
pass
def report_session_start(self, session):
pass
def report_session_end(self, session):
pass
def report_file_start(self, filename):
pass... | class Reporterinterface(object):
def notify_before_console_output(self):
pass
def notify_after_console_output(self):
pass
def report_session_start(self, session):
pass
def report_session_end(self, session):
pass
def report_file_start(self, filename):
pass... |
def read_as_strings(filename):
f = open(filename, "r")
res = f.read().split("\n")
return res
def read_as_ints(filename):
f = open(filename, "r")
res = map(int, f.read().split("\n"))
return list(res)
| def read_as_strings(filename):
f = open(filename, 'r')
res = f.read().split('\n')
return res
def read_as_ints(filename):
f = open(filename, 'r')
res = map(int, f.read().split('\n'))
return list(res) |
n = int(input("Qual o tamanho do vetor?"))
x = [int(input()) for x in range(n)]
for i in range(0, n, 2):
print(x[i])
| n = int(input('Qual o tamanho do vetor?'))
x = [int(input()) for x in range(n)]
for i in range(0, n, 2):
print(x[i]) |
# function for merge sort
def merge_sort(arr):
if len(arr) > 1:
# mid element of array
mid = len(arr) // 2
# Dividing the array and calling merge sort on array
left = arr[:mid]
# into 2 halves
right = arr[mid:]
# merge sort for array first
merge_so... | def merge_sort(arr):
if len(arr) > 1:
mid = len(arr) // 2
left = arr[:mid]
right = arr[mid:]
merge_sort(left)
merge_sort(right)
merge_array(arr, left, right)
def merge_array(arr, left, right):
i = j = k = 0
while i < len(left) and j < len(right):
if l... |
def test_fake_hash(fake_hash):
assert fake_hash(b'rainstorms') == b"HASH(brainstorms)"
| def test_fake_hash(fake_hash):
assert fake_hash(b'rainstorms') == b'HASH(brainstorms)' |
supported_browsers = (
"system_default",
"chrome",
"chromium",
"chromium-browser",
"google-chrome",
"safari",
"firefox",
"opera",
"mozilla",
"netscape",
"galeon",
"epiphany",
"skipstone",
"kfmclient",
"konqueror",
"kfm",
"mosaic",
"grail",
"lin... | supported_browsers = ('system_default', 'chrome', 'chromium', 'chromium-browser', 'google-chrome', 'safari', 'firefox', 'opera', 'mozilla', 'netscape', 'galeon', 'epiphany', 'skipstone', 'kfmclient', 'konqueror', 'kfm', 'mosaic', 'grail', 'links', 'elinks', 'lynx', 'w3m', 'windows-default', 'macosx')
supported_image_ex... |
class BasePermission:
def __init__(self, user):
self.user = user
def has_permission(self, action):
raise NotImplementedError
class AllowAny:
def has_permission(self, action):
return True
class IsAuthenticated(BasePermission):
def has_permission(self, action):
return ... | class Basepermission:
def __init__(self, user):
self.user = user
def has_permission(self, action):
raise NotImplementedError
class Allowany:
def has_permission(self, action):
return True
class Isauthenticated(BasePermission):
def has_permission(self, action):
return... |
#counter part of inheritance
#inheritance means by this program- a bookself is a book
#composition is -
class Bookself:
def __init__(self, *books):
self.books=books
def __str__(self):
return f"Bookself with {len(self.books)} books."
class Book:
def __init__(self... | class Bookself:
def __init__(self, *books):
self.books = books
def __str__(self):
return f'Bookself with {len(self.books)} books.'
class Book:
def __init__(self, name):
self.name = name
def __str__(self):
return f'Book {self.name}'
book = book('Harry potter')
book2 =... |
def fake_get_value_from_db():
return 5
def check_outdated():
total = fake_get_value_from_db()
return total > 10
def task_put_more_stuff_in_db():
def put_stuff(): pass
return {'actions': [put_stuff],
'uptodate': [check_outdated],
}
| def fake_get_value_from_db():
return 5
def check_outdated():
total = fake_get_value_from_db()
return total > 10
def task_put_more_stuff_in_db():
def put_stuff():
pass
return {'actions': [put_stuff], 'uptodate': [check_outdated]} |
'''
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0... | """
Given an array of integers, return indices of the two numbers such that they add up to a specific target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
Example:
Given nums = [2, 7, 11, 15], target = 9,
Because nums[0] + nums[1] = 2 + 7 = 9,
return [0... |
# coding:utf-8
unconfirmed_users = ['liuhanyu', 'luoliuzhou', 'wangyue', 'xiaolizi']
confirmed_users = []
while unconfirmed_users:
user = unconfirmed_users.pop()
confirmed_users.append(user)
print(confirmed_users)
print(unconfirmed_users) | unconfirmed_users = ['liuhanyu', 'luoliuzhou', 'wangyue', 'xiaolizi']
confirmed_users = []
while unconfirmed_users:
user = unconfirmed_users.pop()
confirmed_users.append(user)
print(confirmed_users)
print(unconfirmed_users) |
num = int(input("Enter a number: "))
if ((num % 2 == 0) and (num % 3 == 0) and (num % 5 == 0)):
print("Divisible")
else:
print("Not Divisible")
| num = int(input('Enter a number: '))
if num % 2 == 0 and num % 3 == 0 and (num % 5 == 0):
print('Divisible')
else:
print('Not Divisible') |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.