content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def main():
with open('part1.in') as f:
content = f.readlines()
roots = []
leafs = []
for line in content:
line = [x.strip(',') for x in line.split()]
if len(line) > 2:
roots.append(line[0])
leafs.extend(line[3:])
print(set(roots) - set(leafs... | def main():
with open('part1.in') as f:
content = f.readlines()
roots = []
leafs = []
for line in content:
line = [x.strip(',') for x in line.split()]
if len(line) > 2:
roots.append(line[0])
leafs.extend(line[3:])
print(set(roots) - set(leafs))
if __na... |
__all__ = ['register', 'registry']
registry = {}
def register(name: str):
def inner(f):
registry[name] = f
return f
return inner
| __all__ = ['register', 'registry']
registry = {}
def register(name: str):
def inner(f):
registry[name] = f
return f
return inner |
def checksum(data):
s = 0
n = len(data) % 2
for i in range(0, len(data)-n, 2):
s+= ord(data[i]) + (ord(data[i+1]) << 8)
if n:
s+= ord(data[i+1])
while (s >> 16):
s = (s & 0xFFFF) + (s >> 16)
s = ~s & 0xffff
return s
| def checksum(data):
s = 0
n = len(data) % 2
for i in range(0, len(data) - n, 2):
s += ord(data[i]) + (ord(data[i + 1]) << 8)
if n:
s += ord(data[i + 1])
while s >> 16:
s = (s & 65535) + (s >> 16)
s = ~s & 65535
return s |
class SubrectangleQueries:
def __init__(self, rectangle):
self.rect = rectangle
def updateSubrectangle(self, row1, col1, row2, col2, newValue):
rect = self.rect
rows, cols = range(row1, row2 + 1), range(col1, col2 + 1)
for i in rows:
r = rect[i]
for j in ... | class Subrectanglequeries:
def __init__(self, rectangle):
self.rect = rectangle
def update_subrectangle(self, row1, col1, row2, col2, newValue):
rect = self.rect
(rows, cols) = (range(row1, row2 + 1), range(col1, col2 + 1))
for i in rows:
r = rect[i]
for... |
# https://www.codewars.com/kata/5514e5b77e6b2f38e0000ca9/train/python
def up_array(arr):
if not arr or max(arr) > 9 or min(arr) < 0:
return None
isEnd = False
i = len(arr) - 1
while(i >= 0 and not(isEnd)):
if arr[i] != 9:
arr[i] += 1
isEnd = True
... | def up_array(arr):
if not arr or max(arr) > 9 or min(arr) < 0:
return None
is_end = False
i = len(arr) - 1
while i >= 0 and (not isEnd):
if arr[i] != 9:
arr[i] += 1
is_end = True
else:
arr[i] = 0
if i == 0:
arr.inser... |
ExternalRegion = True
InternalRegion = False
DirectionLeft = 0
DirectionRight = 1
DirectionAnalog = 2
class ConnectionProperty(object):
def __init__(self):
super().__init__()
self.internal = UnitConnectionProperty()
self.internal.region_type = InternalRegion
self.external = Un... | external_region = True
internal_region = False
direction_left = 0
direction_right = 1
direction_analog = 2
class Connectionproperty(object):
def __init__(self):
super().__init__()
self.internal = unit_connection_property()
self.internal.region_type = InternalRegion
self.external = ... |
a = [1,10,3,4,15]
# print(max(a))
s=0
for i in a:
if i>s:
s=i
print(s)
# a.sort(reverse=True)
# print(a[0])
| a = [1, 10, 3, 4, 15]
s = 0
for i in a:
if i > s:
s = i
print(s) |
def Solution(r, c):
im = { 'result': 'IMPOSSIBLE' }
po = { 'result': 'POSSIBLE' }
path = []
for i in range(0, r - 1, 2):
for j in range(0, c - 2):
path.append((i, j))
path.append((i + 1, j + 2))
po['path'] = path
return po
def print_path(path):
pass
for... | def solution(r, c):
im = {'result': 'IMPOSSIBLE'}
po = {'result': 'POSSIBLE'}
path = []
for i in range(0, r - 1, 2):
for j in range(0, c - 2):
path.append((i, j))
path.append((i + 1, j + 2))
po['path'] = path
return po
def print_path(path):
pass
for tc in ran... |
def formatter(inp:dict, width, height, init=None):
res = [[init for i in range(width)] for j in range(height)]
for key in inp :
res[key[1]][key[0]] = inp[key]
for i in range(len(res)):
for j in range(len(res[0])):
print(res[i][j],end="")
print()
print("-------------... | def formatter(inp: dict, width, height, init=None):
res = [[init for i in range(width)] for j in range(height)]
for key in inp:
res[key[1]][key[0]] = inp[key]
for i in range(len(res)):
for j in range(len(res[0])):
print(res[i][j], end='')
print()
print('--------------... |
BTC_USD = 'BTC_USD'
ETH_USD = 'ETH_USD'
LTC_USD = 'LTC_USD'
ETH_BTC = 'ETH_BTC'
BCH_BTC = 'BCH_BTC'
LTC_BTC = 'LTC_BTC'
OPEN = 'open'
O = 'open'
HIGH = 'high'
H = 'high'
LOW = 'low'
L = 'low'
CLOSE = 'close'
C = 'close'
PRICE = 'price'
P = 'price'
TIME = 'time'
T = 'time'
INTERVAL = 'interval'
I = 'interval'
def fix_... | btc_usd = 'BTC_USD'
eth_usd = 'ETH_USD'
ltc_usd = 'LTC_USD'
eth_btc = 'ETH_BTC'
bch_btc = 'BCH_BTC'
ltc_btc = 'LTC_BTC'
open = 'open'
o = 'open'
high = 'high'
h = 'high'
low = 'low'
l = 'low'
close = 'close'
c = 'close'
price = 'price'
p = 'price'
time = 'time'
t = 'time'
interval = 'interval'
i = 'interval'
def fix_s... |
# Basic eucledian algorithm to find the greatest common divisor of 2 numbers
def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
print(gcd(10, 15))
| def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
print(gcd(10, 15)) |
bit_length_e = 256
def get_bit(bit_array,bit_location):
#will return 1 if the bit in location is 1
#and will return 0 if the bit is 0
return (bit_array>>bit_location)&0x1
def montgomery_product(a,b,n):
S = 0
for i in range(bit_length_e):
if get_bit(S + get_bit(a,i)*b,0) == 0:
... | bit_length_e = 256
def get_bit(bit_array, bit_location):
return bit_array >> bit_location & 1
def montgomery_product(a, b, n):
s = 0
for i in range(bit_length_e):
if get_bit(S + get_bit(a, i) * b, 0) == 0:
s = S + get_bit(a, i) * b
else:
s = S + get_bit(a, i) * b + ... |
class Solution:
def frequencySort(self, s: str) -> str:
f_map = {}
for c in s:
if c in f_map:
f_map[c] += 1
else:
f_map[c] = 1
t = sorted(f_map.items(), key=operator.itemgetter(1), reverse=True)
r = ''
... | class Solution:
def frequency_sort(self, s: str) -> str:
f_map = {}
for c in s:
if c in f_map:
f_map[c] += 1
else:
f_map[c] = 1
t = sorted(f_map.items(), key=operator.itemgetter(1), reverse=True)
r = ''
for (c, fq) in t... |
def generate_and_save_images(model, epoch, test_input):
'''Image generation plot function'''
predictions = model(test_input, training=False)
fig = plt.figure(figsize=(22,22))
for i in range(predictions.shape[0]):
plt.subplot(8, 4, i+1)
plt.imshow(((np.array(predictions[i]) * 127.5) + 127.5).astype... | def generate_and_save_images(model, epoch, test_input):
"""Image generation plot function"""
predictions = model(test_input, training=False)
fig = plt.figure(figsize=(22, 22))
for i in range(predictions.shape[0]):
plt.subplot(8, 4, i + 1)
plt.imshow((np.array(predictions[i]) * 127.5 + 12... |
class Solution:
def reformatDate(self, date: str) -> str:
d, m, y = date.split()
if m == 'Jan':
m = 1
elif m == 'Feb':
m = 2
elif m == 'Mar':
m = 3
elif m == 'Apr':
m=4
elif m=='May':
m=5
elif m=='Jun... | class Solution:
def reformat_date(self, date: str) -> str:
(d, m, y) = date.split()
if m == 'Jan':
m = 1
elif m == 'Feb':
m = 2
elif m == 'Mar':
m = 3
elif m == 'Apr':
m = 4
elif m == 'May':
m = 5
el... |
def factorial(n):
if n==0 or n==1:
return 1
else:
n=n*factorial(n-1)
return n
fact=factorial(5)
print(fact) | def factorial(n):
if n == 0 or n == 1:
return 1
else:
n = n * factorial(n - 1)
return n
fact = factorial(5)
print(fact) |
# https://www.reddit.com/r/dailyprogrammer/comments/6jr76h/20170627_challenge_321_easy_talking_clock/
# This is the challenge if ever to refer back to it.
#Check
p = 12
l = 0
'''Checks and outputs 24 hour time'''
def twelve_hour_time_fix(x, n):
if type(x) == int and type(n) == int:
if x == 0:
return("BAWK BAWK ... | p = 12
l = 0
'Checks and outputs 24 hour time'
def twelve_hour_time_fix(x, n):
if type(x) == int and type(n) == int:
if x == 0:
return 'BAWK BAWK STOP IT'
elif n == 0 and x <= 12:
return "it's " + x + ' oh clock'
elif n > 0 and n < 10 and (x <= 12):
retur... |
nice = 0
for word in open('input.txt'):
vowels = 0
bad = 0
doubled = 0
for i in range(len(word)):
if word[i:i+2] in ('ab', 'cd', 'pq', 'xy'):
bad += 1
if word[i] in 'aeiou':
vowels += 1
if i < len(word)-1 and word[i] == word[i+1]:
doubled += 1... | nice = 0
for word in open('input.txt'):
vowels = 0
bad = 0
doubled = 0
for i in range(len(word)):
if word[i:i + 2] in ('ab', 'cd', 'pq', 'xy'):
bad += 1
if word[i] in 'aeiou':
vowels += 1
if i < len(word) - 1 and word[i] == word[i + 1]:
doubled... |
print("Body Mass Index Calculator 2.0!")
height = float(input("Enter your height in m: "))
weight = float(input("Enter your weight in Kg: "))
bmi = weight / (height ** 2)
if bmi < 18.5:
print(f"Your BMI is {bmi:.1f}. You are underweight!")
elif bmi < 25:
print(f"Your BMI is {bmi:.1f}. You have a normal weight!"... | print('Body Mass Index Calculator 2.0!')
height = float(input('Enter your height in m: '))
weight = float(input('Enter your weight in Kg: '))
bmi = weight / height ** 2
if bmi < 18.5:
print(f'Your BMI is {bmi:.1f}. You are underweight!')
elif bmi < 25:
print(f'Your BMI is {bmi:.1f}. You have a normal weight!')
... |
A, B, C, K = map(int, input().split())
if A >= K:
print(K)
elif (A+B) >= K:
print(A)
else:
tmp = K-(A+B)
print(A-tmp)
| (a, b, c, k) = map(int, input().split())
if A >= K:
print(K)
elif A + B >= K:
print(A)
else:
tmp = K - (A + B)
print(A - tmp) |
def is_question(parsed_frag):
likelihood = 0
begins_with_verb = False
beings_with_wh_word = False
# the fragment starts with a verb
# now we need to check if this is a WH or auxilary verb
print(parsed_frag[0].pos_)
if parsed_frag[0].pos_ == 'VERB':
begins_with_verb = True
#... | def is_question(parsed_frag):
likelihood = 0
begins_with_verb = False
beings_with_wh_word = False
print(parsed_frag[0].pos_)
if parsed_frag[0].pos_ == 'VERB':
begins_with_verb = True
if parsed_frag[0].lemma_ == 'be':
return True
print(parsed_frag[0].tag_)
if parse... |
class HeyMovieError(AssertionError):
pass
class InvalidParameter(HeyMovieError):
status_code = 400
content = 'The given parameter is invalid'
docs = {status_code: content}
class ResourceStateConflict(HeyMovieError):
status_code = 409
docs = {status_code: 'The is a problem with the state of a... | class Heymovieerror(AssertionError):
pass
class Invalidparameter(HeyMovieError):
status_code = 400
content = 'The given parameter is invalid'
docs = {status_code: content}
class Resourcestateconflict(HeyMovieError):
status_code = 409
docs = {status_code: 'The is a problem with the state of a r... |
#9.27 10:30AM
def cyclic_sort(nums):
# TODO: Write your code here
# for i in range(len(nums)):
# nums[i] = i+1
pointer = 0
while pointer < len(nums):
currValue = nums[pointer] -1
if nums[pointer] != nums[currValue]:
nums[pointer], nums[currValue] = nums[currValue], nums[pointer]
else:
... | def cyclic_sort(nums):
pointer = 0
while pointer < len(nums):
curr_value = nums[pointer] - 1
if nums[pointer] != nums[currValue]:
(nums[pointer], nums[currValue]) = (nums[currValue], nums[pointer])
else:
pointer += 1
return nums |
class Stairs:
def designs(self, maxHeight, minWidth, totalHeight, totalWidth):
c = 0
for r in xrange(1, maxHeight+1):
if totalHeight%r == 0:
n = totalHeight / r
if n > 1 and totalWidth%(n-1) == 0 and totalWidth / (n-1) >= minWidth:
c +=... | class Stairs:
def designs(self, maxHeight, minWidth, totalHeight, totalWidth):
c = 0
for r in xrange(1, maxHeight + 1):
if totalHeight % r == 0:
n = totalHeight / r
if n > 1 and totalWidth % (n - 1) == 0 and (totalWidth / (n - 1) >= minWidth):
... |
#simle declaretion
my_list=list()
list1=[11,22,33,44]
print("list1 =",list1)
#create list with string & integer
list2=[1,"hello",3]
print(list2)
#create a 2d list
list2d=[list1,list2]
print(list2d)
| my_list = list()
list1 = [11, 22, 33, 44]
print('list1 =', list1)
list2 = [1, 'hello', 3]
print(list2)
list2d = [list1, list2]
print(list2d) |
config = {}
config["am"] = 400
config["pm"] = 2000
config["flip_horizontal"] = False
config["flip_vertical"] = False
config["metering_mode"] = "matrix"
config["base_path"] = "/media/pi/UNTITLED/image"
config["usb_path"] = "/media/pi/UNTITLED/usbimage"
config["height"] = 1536
config["width"] = 2048
config["quality"] =... | config = {}
config['am'] = 400
config['pm'] = 2000
config['flip_horizontal'] = False
config['flip_vertical'] = False
config['metering_mode'] = 'matrix'
config['base_path'] = '/media/pi/UNTITLED/image'
config['usb_path'] = '/media/pi/UNTITLED/usbimage'
config['height'] = 1536
config['width'] = 2048
config['quality'] = 3... |
#sequential
a=40
b=20
c=a-b
print("Subtraction is : ",c)
#selection statements
#simple if statements
n = 10
if n % 2 == 0:
print("n is an even number")
#if-else statements
n = 5
if n % 2 == 0:
print("n is even")
else:
print("n is odd") #5 is odd
l = 10
u = 12
x = 17
if l > u:
if l > x:
... | a = 40
b = 20
c = a - b
print('Subtraction is : ', c)
n = 10
if n % 2 == 0:
print('n is an even number')
n = 5
if n % 2 == 0:
print('n is even')
else:
print('n is odd')
l = 10
u = 12
x = 17
if l > u:
if l > x:
print('l value is big')
else:
print('x value is big')
elif u > x:
prin... |
class model1:
def __getattr__(self,x):
getter = 'var_'+x
if getter in self.__dict__:
return self.__dict__[getter]()
else:
return self.__dict__[x]
def chain(self,other):
for k,v in other.__dict__.items():
self.__dict__[k]=v
return self
if __name__=="__main__":
x = model1()
x.var_a = lambda: 20
x... | class Model1:
def __getattr__(self, x):
getter = 'var_' + x
if getter in self.__dict__:
return self.__dict__[getter]()
else:
return self.__dict__[x]
def chain(self, other):
for (k, v) in other.__dict__.items():
self.__dict__[k] = v
re... |
'''
Configuration file
'''
API_KEY_PATH = '/home/chris/Desktop/work/programming/python/backtest/secrets/apikey.txt' | """
Configuration file
"""
api_key_path = '/home/chris/Desktop/work/programming/python/backtest/secrets/apikey.txt' |
def rank_tokens(valid_size,valid_examples, reverse_dictionary, top_k,sim):
for i in xrange(valid_size):
valid_word = reverse_dictionary[valid_examples[i]]
nearest = (-sim[i, :]).argsort()[1:top_k + 1]
log_str = "Nearest to %s:" % valid_word
word_list = []
for k in xrange(top_... | def rank_tokens(valid_size, valid_examples, reverse_dictionary, top_k, sim):
for i in xrange(valid_size):
valid_word = reverse_dictionary[valid_examples[i]]
nearest = (-sim[i, :]).argsort()[1:top_k + 1]
log_str = 'Nearest to %s:' % valid_word
word_list = []
for k in xrange(to... |
def get_nth_sevenish(n):
if n < 1:
raise Exception("Invalid value for 'n'")
power = 0
sevenish_nums = list()
while len(sevenish_nums) < n:
num = 7 ** power
new_sevenish_nums = [num]
for old in sevenish_nums:
if len(sevenish_nums) + len(new_sevenish_nums) == n... | def get_nth_sevenish(n):
if n < 1:
raise exception("Invalid value for 'n'")
power = 0
sevenish_nums = list()
while len(sevenish_nums) < n:
num = 7 ** power
new_sevenish_nums = [num]
for old in sevenish_nums:
if len(sevenish_nums) + len(new_sevenish_nums) == n:... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
def getfile(pathlist):
for filename in pathlist:
try:
fileobj = open(filename, 'r')
except:
continue
return fileobj
def getlist():
fileobj = getfile(["../data/tld.txt", "data/tld.txt"])
data = set()
for line in fileobj:
line = line.strip('\n')
if len(line)... | def getfile(pathlist):
for filename in pathlist:
try:
fileobj = open(filename, 'r')
except:
continue
return fileobj
def getlist():
fileobj = getfile(['../data/tld.txt', 'data/tld.txt'])
data = set()
for line in fileobj:
line = line.strip('\n')
... |
#
# PySNMP MIB module CISCO-AAA-SERVER-CAPABILITY (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-AAA-SERVER-CAPABILITY
# Produced by pysmi-0.3.4 at Mon Apr 29 17:32:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python versio... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, constraints_union, single_value_constraint, value_range_constraint) ... |
class Solution:
def winnerSquareGame(self, n: int) -> bool:
dp = [False] * (n + 1)
for i in range(1, n + 1):
dp[i] = any(not dp[i - r * r] for r in range(1, int(i ** 0.5) + 1))
return dp[-1]
# TESTS
for n, expected in [
(1, True),
(2, False),
(3, True),
(4, True... | class Solution:
def winner_square_game(self, n: int) -> bool:
dp = [False] * (n + 1)
for i in range(1, n + 1):
dp[i] = any((not dp[i - r * r] for r in range(1, int(i ** 0.5) + 1)))
return dp[-1]
for (n, expected) in [(1, True), (2, False), (3, True), (4, True), (5, False), (6, T... |
class Content:
def __init__(self, content_type: str, content_id: str):
self.type = content_type
self.id = content_id
| class Content:
def __init__(self, content_type: str, content_id: str):
self.type = content_type
self.id = content_id |
ALPHABET = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
PORTUGUESE_FREQUENCY = [.1463, .0104, .0388, .0499, .1257, .0102, .0130, .0128,
.0618, .0040, .0002, .0278, .0474, .0505, .1073, .0252,
... | alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
portuguese_frequency = [0.1463, 0.0104, 0.0388, 0.0499, 0.1257, 0.0102, 0.013, 0.0128, 0.0618, 0.004, 0.0002, 0.0278, 0.0474, 0.0505, 0.1073, 0.0252, 0.012, 0.0653, 0.0781, 0.043... |
def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Specified in Code table 3.1'},
{'abbr': 1,
'code': 1,
'title': 'Predetermined grid definition Defined by originating centre'},
{'abbr': None,
'code': 255,
'title': 'A grid definition doe... | def load(h):
return ({'abbr': 0, 'code': 0, 'title': 'Specified in Code table 3.1'}, {'abbr': 1, 'code': 1, 'title': 'Predetermined grid definition Defined by originating centre'}, {'abbr': None, 'code': 255, 'title': 'A grid definition does not apply to this product'}) |
###############################################
# #
# Created by Youssef Sully #
# Beginner python #
# classes 1 INSTANCE variables 1 #
# #
################################... | class Studenttype1:
pass
student_1 = student_type1()
student_1.f_name = 'Youssef'
student_1.l_name = 'Sully'
student_1.courses = ['CompSci', 'Telecom']
student_1.email = 'youssef.sully@aol.com'
student_2 = student_type1()
student_2.f_name = 'Sully'
student_2.l_name = 'Youssef'
student_2.courses = ['Telecom', 'CompS... |
__version__='0.1'
install_python_version='bigger than 3.5'
def hello():
print('hello')
| __version__ = '0.1'
install_python_version = 'bigger than 3.5'
def hello():
print('hello') |
# divide arr: sorted arr with len of 0,
# find smallest num in unsorted array,
# insert it into sorted subarray with swap
# Best: O(n^2) time | O(1)space
# Average: O(n^2) time | O(1)space
# Worst: O(n^2) time | O(1)space
def selectionSort(array):
currentIdx = 0 # sorted subarray with len 0
while currentIdx < len... | def selection_sort(array):
current_idx = 0
while currentIdx < len(array) - 1:
smallest_idx = currentIdx
for i in range(currentIdx + 1, len(array)):
if array[smallestIdx] > array[i]:
smallest_idx = i
swap(currentIdx, smallestIdx, array)
current_idx += 1... |
class PriestSpells(object):
def __init__(self):
self.heal_r1 = dict(heal=100, mana=100, cast_time=1.5, heal_coef=.1, mana_coef=1, haste_coef=1)
self.heal_r2 = dict(heal=275, mana=200, cast_time=1.5, heal_coef=.15, mana_coef=1, haste_coef=1)
self.heal_r3 = dict(heal=450, mana=290, cast_ti... | class Priestspells(object):
def __init__(self):
self.heal_r1 = dict(heal=100, mana=100, cast_time=1.5, heal_coef=0.1, mana_coef=1, haste_coef=1)
self.heal_r2 = dict(heal=275, mana=200, cast_time=1.5, heal_coef=0.15, mana_coef=1, haste_coef=1)
self.heal_r3 = dict(heal=450, mana=290, cast_tim... |
confounder_monotonicities_1_some = {'anemia': 'none',
'cardiac':'none',
'lung': 'none',
'diabetes': 'none',
'gestat10':'none',
'herpes':'none',
... | confounder_monotonicities_1_some = {'anemia': 'none', 'cardiac': 'none', 'lung': 'none', 'diabetes': 'none', 'gestat10': 'none', 'herpes': 'none', 'hydra': 'none', 'hemo': 'none', 'chyper': 'none', 'phyper': 'none', 'eclamp': 'none', 'incervix': 'none', 'pre4000': 'none', 'preterm': 'none', 'renal': 'none', 'rh': 'none... |
def nearest_two_power(n):
two_in_power = 2
power = 1
while two_in_power <= n:
two_in_power *= 2
power += 1
return power
n = int(input())
pow_two = nearest_two_power(n-1)
input_list = list(range(0, n))
l = []
output_list = []
for d in range(0, pow_two+1):
out_break = 0
for i in ... | def nearest_two_power(n):
two_in_power = 2
power = 1
while two_in_power <= n:
two_in_power *= 2
power += 1
return power
n = int(input())
pow_two = nearest_two_power(n - 1)
input_list = list(range(0, n))
l = []
output_list = []
for d in range(0, pow_two + 1):
out_break = 0
for i i... |
class EPICSErrorLoggingService():
... | class Epicserrorloggingservice:
... |
def foo():
while True:
try:
break
finally:
pass
print('b') | def foo():
while True:
try:
break
finally:
pass
print('b') |
class Solution:
def stringMatching(self, words: List[str]) -> List[str]:
ans = []
for idx, s in enumerate(words):
flag = False
for idy, ss in enumerate(words):
if idx != idy and s in ss:
flag = True
break
... | class Solution:
def string_matching(self, words: List[str]) -> List[str]:
ans = []
for (idx, s) in enumerate(words):
flag = False
for (idy, ss) in enumerate(words):
if idx != idy and s in ss:
flag = True
break
... |
a = float(input('Enter a value a: '))
b = float(input('Enter a value b: '))
c = float(input('Enter a value c: '))
d = float(input('Enter a value d: '))
# Find maximum of a and b
if a > b:
m1 = a
else:
m1 = b
# Find maximum of c and d
if c > d:
m2 = c
else:
m2 = d
# Print largest of all four values
if... | a = float(input('Enter a value a: '))
b = float(input('Enter a value b: '))
c = float(input('Enter a value c: '))
d = float(input('Enter a value d: '))
if a > b:
m1 = a
else:
m1 = b
if c > d:
m2 = c
else:
m2 = d
if m1 > m2:
print('The maximum value is:', m1)
else:
print('The maximum value is:', ... |
ROOT_LOG_CONF = {
'version': 1,
'root': {
'level': 'DEBUG',
'handlers': ['file'],
},
'handlers': {
'file': {
'class': 'logging.handlers.RotatingFileHandler',
'level': 'DEBUG',
'formatter': 'detailed',
'filename': '/var/log/apollo.lo... | root_log_conf = {'version': 1, 'root': {'level': 'DEBUG', 'handlers': ['file']}, 'handlers': {'file': {'class': 'logging.handlers.RotatingFileHandler', 'level': 'DEBUG', 'formatter': 'detailed', 'filename': '/var/log/apollo.log', 'mode': 'a', 'maxBytes': 10000000, 'backupCount': 3}}, 'formatters': {'detailed': {'format... |
load(":import_external.bzl", import_external = "import_external")
def dependencies():
import_external(
name = "org_specs2_classycle",
artifact = "org.specs2:classycle:1.4.3",
artifact_sha256 = "9b8cc4f88a5fa8c0e9437ff72f472f9f8e2a7509d94261df6196d5570935d697",
srcjar_sha256 = "23e4f... | load(':import_external.bzl', import_external='import_external')
def dependencies():
import_external(name='org_specs2_classycle', artifact='org.specs2:classycle:1.4.3', artifact_sha256='9b8cc4f88a5fa8c0e9437ff72f472f9f8e2a7509d94261df6196d5570935d697', srcjar_sha256='23e4f4afe7f91b882974fa7fa06164c2db1b1d97a1d974cd... |
# Ask the user to type in his age
print("How old are you?", end=' ')
# Store the input in the variable age
age = input()
# age = int(input())
print(">>>> age=", repr(age))
# ask the user his length
print("How tall are you?", end=' ')
# store the input in height
height = input()
# ask the user for his weight
print("How ... | print('How old are you?', end=' ')
age = input()
print('>>>> age=', repr(age))
print('How tall are you?', end=' ')
height = input()
print('How much do you weigh?', end=' ')
weight = input()
num = input('Enter your lucky number: ')
name = input('Enter your name :')
print(f"So, you're {age} old. {height} tall and {weight... |
class Solution:
def maxSubarraySumCircular(self, A: List[int]) -> int:
def kadane(A):
best = float("-inf")
current = 0
for n in A:
current += n
if current < n:
current = n
if current > best:
... | class Solution:
def max_subarray_sum_circular(self, A: List[int]) -> int:
def kadane(A):
best = float('-inf')
current = 0
for n in A:
current += n
if current < n:
current = n
if current > best:
... |
# 1. Perform a task
# 1. Return a value
# all functions returns none by default
def greet(name):
print(f"Hello {name}!")
greet("NISB Members")
def get_greeting(name):
return f"Hello! {name}!"
message = get_greeting("This is the content of the content.txt file")
print(message)
file = open("content.txt", ... | def greet(name):
print(f'Hello {name}!')
greet('NISB Members')
def get_greeting(name):
return f'Hello! {name}!'
message = get_greeting('This is the content of the content.txt file')
print(message)
file = open('content.txt', 'w')
file.write(message) |
def lossy_fuse(list_1, list_2):
''' Return a new list containing all the elements of list 1 except the
last followed by all the elements of list 2 except the first '''
temp = []
for i in range(0, len(list_1) - 1):
temp.append(list_1[i])
for j in range(1, len(list_2)):
temp.ap... | def lossy_fuse(list_1, list_2):
""" Return a new list containing all the elements of list 1 except the
last followed by all the elements of list 2 except the first """
temp = []
for i in range(0, len(list_1) - 1):
temp.append(list_1[i])
for j in range(1, len(list_2)):
temp.append(li... |
class Solution:
def __init__(self):
self.current = None
def inOrder(self, node):
if node == None:
return
self.inOrder(node.left)
# set nodes left node as null and current nodes right node as node
self.current.left = None
self.current.right = node
... | class Solution:
def __init__(self):
self.current = None
def in_order(self, node):
if node == None:
return
self.inOrder(node.left)
self.current.left = None
self.current.right = node
self.current = node
self.inOrder(node.right)
def increas... |
description = 'Mephisto instrument'
group = 'basic'
includes = [
'blende1',
'reactor',
'system',
]
| description = 'Mephisto instrument'
group = 'basic'
includes = ['blende1', 'reactor', 'system'] |
def dp_iterative(nums):
if not nums: return 0
if len(nums) == 1: return nums[0]
def helper(nums, start, end):
dp = [0] * (len(nums) + 2)
print(f'nums={nums}, start={start}, end={end}')
for i in range(end, start - 1, -1):
print(i)
dp[i] = max(dp[i + 1], nums[i... | def dp_iterative(nums):
if not nums:
return 0
if len(nums) == 1:
return nums[0]
def helper(nums, start, end):
dp = [0] * (len(nums) + 2)
print(f'nums={nums}, start={start}, end={end}')
for i in range(end, start - 1, -1):
print(i)
dp[i] = max(d... |
my_list = ['p', 'y', 't', 'h', 'o', 'n', 'h',
'a', 'c', 'k', 'a', 't', 'h', 'o', 'n']
print('p' in my_list)
print('a' in my_list)
print('c' in my_list)
# length of list
print(len(my_list))
# reversing a list
my_list.reverse()
print(my_list)
# sorting a list
my_list.sort()
print(my_list)
# counting no.of ... | my_list = ['p', 'y', 't', 'h', 'o', 'n', 'h', 'a', 'c', 'k', 'a', 't', 'h', 'o', 'n']
print('p' in my_list)
print('a' in my_list)
print('c' in my_list)
print(len(my_list))
my_list.reverse()
print(my_list)
my_list.sort()
print(my_list)
print(my_list.count('n'))
print(my_list.index('h')) |
a=int(input('liczba a='))
b=int(input('liczba b='))
while b != a:
if a < b:
b = b - a
else:
a = a - b
print(a) | a = int(input('liczba a='))
b = int(input('liczba b='))
while b != a:
if a < b:
b = b - a
else:
a = a - b
print(a) |
class Node:
def __init__(self, key, data, parent=None, left=None, right=None):
self.key = key
self.data = data
self.parent = parent
self.left = left
self.right = right
class SplayTree:
def __init__(self):
self.root = None
def zig(self, p):
x = p.le... | class Node:
def __init__(self, key, data, parent=None, left=None, right=None):
self.key = key
self.data = data
self.parent = parent
self.left = left
self.right = right
class Splaytree:
def __init__(self):
self.root = None
def zig(self, p):
x = p.le... |
people_file = open("/home/thiago/Documentos/arquivo.txt", "r")
for people in people_file.readlines():
print(people)
people_file.close() | people_file = open('/home/thiago/Documentos/arquivo.txt', 'r')
for people in people_file.readlines():
print(people)
people_file.close() |
annotations = {
"no_target": {
"@context": "http://www.w3.org/ns/anno.jsonld",
"type": "Annotation",
"motivation": "classifying",
"body": [
{
"type": "Classifying",
"value": "Vincent van Gogh",
"vocabulary": "DBpedia",
... | annotations = {'no_target': {'@context': 'http://www.w3.org/ns/anno.jsonld', 'type': 'Annotation', 'motivation': 'classifying', 'body': [{'type': 'Classifying', 'value': 'Vincent van Gogh', 'vocabulary': 'DBpedia', 'id': 'http://dbpedia.org/resource/Vincent_van_Gogh', 'purpose': 'classifying'}]}, 'vincent': {'@context'... |
client_id="client-id"
client_secret="client-secret"
password="password"
username="username"
user_agent="ClicksOnLinksBot 0.1"
| client_id = 'client-id'
client_secret = 'client-secret'
password = 'password'
username = 'username'
user_agent = 'ClicksOnLinksBot 0.1' |
# -*- coding: utf-8 -*-
class MissingRequiredParameterError(Exception):
pass
class InvalidParameterError(Exception):
pass
class InvalidTypeParameterError(Exception):
pass
| class Missingrequiredparametererror(Exception):
pass
class Invalidparametererror(Exception):
pass
class Invalidtypeparametererror(Exception):
pass |
sheeps = []
class Pen:
def crowd(self, sheep):
sheeps.append(sheep)
def list(self):
for sheep in sheeps:
print(sheep.name)
class Sheep:
def __init__(self, name):
self.name = name
def sayName(self):
print("Hello, " + self.name)
pen = Pen()
dory = Sheep("Dory... | sheeps = []
class Pen:
def crowd(self, sheep):
sheeps.append(sheep)
def list(self):
for sheep in sheeps:
print(sheep.name)
class Sheep:
def __init__(self, name):
self.name = name
def say_name(self):
print('Hello, ' + self.name)
pen = pen()
dory = sheep('... |
t = int(input())
while t:
N = int(input())
c = 0
for i in range(N):
S, J = map(int, input().split())
if J-S >5:
c += 1
print(c)
t = t-1 | t = int(input())
while t:
n = int(input())
c = 0
for i in range(N):
(s, j) = map(int, input().split())
if J - S > 5:
c += 1
print(c)
t = t - 1 |
# 4. Ask the user to enter a list containing numbers between 1 and 12. Then replace all of the
# entries in the list that are greater than 10 with 10.
L = input('Enter a list of numbers between 1 and 12: ')
L = L.split()
for i in range(len(L)):
L[i] = int(L[i])
if L[i] > 10:
L[i] = 10
# L = [int(i) i... | l = input('Enter a list of numbers between 1 and 12: ')
l = L.split()
for i in range(len(L)):
L[i] = int(L[i])
if L[i] > 10:
L[i] = 10
print(L) |
# Without recursion
def gcd(a, b):
res = 1
for i in range(1, min(a, b) + 1):
if a % i == 0 and b % i == 0:
res = i
return res
# print(gcd(8, 16))
# with recursion
def gcd_recur(a, b):
assert type(a) is int and type(b) is int, "Invalid Input"
if a < 0:
a = -a
if ... | def gcd(a, b):
res = 1
for i in range(1, min(a, b) + 1):
if a % i == 0 and b % i == 0:
res = i
return res
def gcd_recur(a, b):
assert type(a) is int and type(b) is int, 'Invalid Input'
if a < 0:
a = -a
if b < 0:
b = -b
if b == 0:
return a
retu... |
def list_of_api():
return {
'config_url': '/v2/config',
'health_url': '/v2/health',
'notify_url': '/v2/notify',
'subscriptions_url': '/v2/subscriptions',
'entities_url': '/v2/entities',
'types_url': '/v2/types',
'attributes_url': '... | def list_of_api():
return {'config_url': '/v2/config', 'health_url': '/v2/health', 'notify_url': '/v2/notify', 'subscriptions_url': '/v2/subscriptions', 'entities_url': '/v2/entities', 'types_url': '/v2/types', 'attributes_url': '/v2/attrs'} |
# AUTOGENERATED! DO NOT EDIT! File to edit: src/to_HML_demo.ipynb (unless otherwise specified).
__all__ = ['ToHMLDemo']
# Cell
class ToHMLDemo:
def __init__(self):
pass | __all__ = ['ToHMLDemo']
class Tohmldemo:
def __init__(self):
pass |
# Authentication Steps, paramaters, and responses are defined at https://developer.spotify.com/web-api/authorization-guide/
# Visit this url to see all the steps, parameters, and expected response.
# Client Keys
CLIENT_ID = "9e486c3d8ed34b8f997e0930cfcadcc2"
CLIENT_SECRET = "521a89a3084a426a9798ab511338e2b2"
# Spoti... | client_id = '9e486c3d8ed34b8f997e0930cfcadcc2'
client_secret = '521a89a3084a426a9798ab511338e2b2'
spotify_auth_url = 'https://accounts.spotify.com/authorize'
spotify_token_url = 'https://accounts.spotify.com/api/token'
spotify_api_base_url = 'https://api.spotify.com'
api_version = 'v1'
spotify_api_url = '{}/{}'.format(... |
def cache_gem5(data):
s = ""
s += "from __future__ import print_function\n"
s += "from __future__ import absolute_import\n"
s += "import m5\n"
s += "from m5.objects import *\n"
# import the caches which we made
s += "from nvcc4jupyter.gem5.examples.caches import *\n"
# import the ... | def cache_gem5(data):
s = ''
s += 'from __future__ import print_function\n'
s += 'from __future__ import absolute_import\n'
s += 'import m5\n'
s += 'from m5.objects import *\n'
s += 'from nvcc4jupyter.gem5.examples.caches import *\n'
s += 'from nvcc4jupyter.gem5.examples import SimpleOpts\n'... |
def delete_nth(d, n):
d.rotate(-n)
d.popleft()
d.rotate(n)
| def delete_nth(d, n):
d.rotate(-n)
d.popleft()
d.rotate(n) |
case = int(input())
for j in range(case):
n, m = map(int,input().split())
imp = list(map(int,input().split()))
queue = [0 for i in range(n)]
queue[m] = 1
count = 0
while True:
if imp[0] == max(imp):
count += 1
if queue[0] == 1:
print(count)
... | case = int(input())
for j in range(case):
(n, m) = map(int, input().split())
imp = list(map(int, input().split()))
queue = [0 for i in range(n)]
queue[m] = 1
count = 0
while True:
if imp[0] == max(imp):
count += 1
if queue[0] == 1:
print(count)
... |
lower=1
upper=1000
for num in range(lower, upper +1):
order=len(str(num))
sum = 0
temp =num
while temp>0:
digit =temp %10
sum+= digit**order
temp //=10
if num ==sum:
print (sum) | lower = 1
upper = 1000
for num in range(lower, upper + 1):
order = len(str(num))
sum = 0
temp = num
while temp > 0:
digit = temp % 10
sum += digit ** order
temp //= 10
if num == sum:
print(sum) |
###############################################################################
# Copyright (c) 2017-2020 Koren Lev (Cisco Systems), #
# Yaron Yogev (Cisco Systems), Ilia Abashin (Cisco Systems) and others #
# #
... | event_payload_network_add = {'_context_request_id': 'req-d8593c49-8424-459b-9ac1-1fd8667310eb', '_context_project_domain': None, '_context_tenant_id': '75c0eb79ff4a42b0ae4973c8375ddf40', '_context_project_name': 'calipso-project', '_context_show_deleted': False, '_context_timestamp': '2016-09-30 17:45:01.738932', '_con... |
mean_bands = {
'AOI_2_Vegas': [66.203843139322203, 64.793622432296814, 63.816469071277851, 67.365390860065887, 68.80479517013778,
70.498218756846072, 67.712760288609388, 69.555316792809833],
'AOI_3_Paris': [38.639393682336831, 37.012744344218845, 38.301689254170853, 40.9502977658262, 38.3958... | mean_bands = {'AOI_2_Vegas': [66.2038431393222, 64.79362243229681, 63.81646907127785, 67.36539086006589, 68.80479517013778, 70.49821875684607, 67.71276028860939, 69.55531679280983], 'AOI_3_Paris': [38.63939368233683, 37.012744344218845, 38.30168925417085, 40.9502977658262, 38.39583795027569, 42.296092196170676, 54.3344... |
def dfs(graph, start, destination):
return _dfs(graph, start, destination, [start])
def _dfs(graph, current_node, destination, visited):
if current_node == destination:
yield visited
for adjacent in graph[current_node]:
if adjacent not in visited:
yield from _dfs(graph, ad... | def dfs(graph, start, destination):
return _dfs(graph, start, destination, [start])
def _dfs(graph, current_node, destination, visited):
if current_node == destination:
yield visited
for adjacent in graph[current_node]:
if adjacent not in visited:
yield from _dfs(graph, adjacent... |
'''THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OT... | """THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE
DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OT... |
# For reproducibility
seed = 990
# metric options
metrics = ['FID', 'PRD']
# the experiment, epoch and threshold to be used for generated images
gan_trial_num = 16
gan_epoch_num = 99
gan_batch = 1
gan_label_threshold = 0.3
# real data specification
dataset = 'PEGASUS_denoised'
split = 'train'
ppp = 50
image_size = '... | seed = 990
metrics = ['FID', 'PRD']
gan_trial_num = 16
gan_epoch_num = 99
gan_batch = 1
gan_label_threshold = 0.3
dataset = 'PEGASUS_denoised'
split = 'train'
ppp = 50
image_size = '128x128x64'
patches_dataset = str(ppp) + '_ppp_' + image_size
save_column_names = ['seed', 'dataset', 'split', 'gan_label_threshold', 'gan... |
n = [int(i) for i in input('Enter Your List : ').split()]
sum = []
li = []
if len(n) < 3:
print("Array Input Length Must More Than 2")
else:
for i in n:
for j in n:
if i < j:
for k in n:
if j < k:
if i + j + k ... | n = [int(i) for i in input('Enter Your List : ').split()]
sum = []
li = []
if len(n) < 3:
print('Array Input Length Must More Than 2')
else:
for i in n:
for j in n:
if i < j:
for k in n:
if j < k:
if i + j + k == 0 and [i, j, k] not... |
def format_timedelta(delta):
days = delta.astype('timedelta64[D]').astype(int)
hours = delta.astype('timedelta64[h]').astype(int) - 24*days
minutes = delta.astype('timedelta64[m]').astype(int) - 60*(24*days+hours)
seconds = delta.astype('timedelta64[s]').astype(int) - 60*(60*(24*days+hours)+minutes)
... | def format_timedelta(delta):
days = delta.astype('timedelta64[D]').astype(int)
hours = delta.astype('timedelta64[h]').astype(int) - 24 * days
minutes = delta.astype('timedelta64[m]').astype(int) - 60 * (24 * days + hours)
seconds = delta.astype('timedelta64[s]').astype(int) - 60 * (60 * (24 * days + hou... |
coordinates_FFFF01 = ((130, 121),
(131, 121), (131, 122), (132, 122), (136, 127), (136, 129), (137, 126), (137, 130), (138, 124), (138, 127), (138, 128), (138, 130), (139, 125), (139, 127), (139, 130), (140, 125), (140, 127), (140, 128), (140, 130), (141, 126), )
coordinates_FEFF00 = ((107, 127),
(107, 128), (108,... | coordinates_ffff01 = ((130, 121), (131, 121), (131, 122), (132, 122), (136, 127), (136, 129), (137, 126), (137, 130), (138, 124), (138, 127), (138, 128), (138, 130), (139, 125), (139, 127), (139, 130), (140, 125), (140, 127), (140, 128), (140, 130), (141, 126))
coordinates_feff00 = ((107, 127), (107, 128), (108, 126), ... |
def fattoriale(n):
if n==0:
return 1
return n*fattoriale(n-1)
print(" 12! ", fattoriale(12))
print(" 18! ", fattoriale(18))
print(" 33! ", fattoriale(33))
| def fattoriale(n):
if n == 0:
return 1
return n * fattoriale(n - 1)
print(' 12! ', fattoriale(12))
print(' 18! ', fattoriale(18))
print(' 33! ', fattoriale(33)) |
a_, b_ = input().split()
a = float(a_)
b = float(b_)
porc = ((b * 100)/a) - 100
print("%.2f%%" % porc)
| (a_, b_) = input().split()
a = float(a_)
b = float(b_)
porc = b * 100 / a - 100
print('%.2f%%' % porc) |
if __name__ == '__main__':
for i in range(1, 5):
print (i , ": Hello, world!!", i)
| if __name__ == '__main__':
for i in range(1, 5):
print(i, ': Hello, world!!', i) |
class single:
def singlesize(size,count):
print("\n" + "_"+ size.upper() +"_" + "\n" + str(int(count/12)) + " total stacks of (12)" + "\n" + "Remainder stack size: " + str(int(count%12)) +"\n")
| class Single:
def singlesize(size, count):
print('\n' + '_' + size.upper() + '_' + '\n' + str(int(count / 12)) + ' total stacks of (12)' + '\n' + 'Remainder stack size: ' + str(int(count % 12)) + '\n') |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__version__ = "2020.3.5"
| __version__ = '2020.3.5' |
#Creating class Node
class node():
def __init__(self, value):
self.value = value
self.next = None
#Creating reverse function
def reverse(head):
current = head
next_node = None
previous = None
#Traversing list
while(current):
#Pointing to next nodes
next_node = ... | class Node:
def __init__(self, value):
self.value = value
self.next = None
def reverse(head):
current = head
next_node = None
previous = None
while current:
next_node = current.next
current.next = previous
previous = current
current = next_node
r... |
class Amostras:
def __init__(self, nomeProjeto, identificacao, numFemeas, CCT, CA, T):
self.nomeProjeto = nomeProjeto
self.identificacao = identificacao
self.numFemeas = numFemeas
self.CCT = float(CCT)
self.CA = float(CA)
self.T = float(T) | class Amostras:
def __init__(self, nomeProjeto, identificacao, numFemeas, CCT, CA, T):
self.nomeProjeto = nomeProjeto
self.identificacao = identificacao
self.numFemeas = numFemeas
self.CCT = float(CCT)
self.CA = float(CA)
self.T = float(T) |
# ------------------------------
# 106. Construct Binary Tree from Inorder and Postorder Traversal
#
# Description:
# Given inorder and postorder traversal of a tree, construct the binary tree.
#
# Note:
# You may assume that duplicates do not exist in the tree.
#
# For example, given
#
# inorder = [9,3,15,20,7]
# ... | class Solution:
def build_tree(self, inorder: List[int], postorder: List[int]) -> TreeNode:
def helper(in_l, in_r):
nonlocal post_idx
if in_l == in_r:
return None
root_val = postorder[post_idx]
root = tree_node(rootVal)
index = in... |
#-----------------------------------------------------------------------------
# Copyright (c) 2013, PyInstaller Development Team.
#
# Distributed under the terms of the GNU General Public License with exception
# for distributing bootloader.
#
# The full license is in the file COPYING.txt, distributed with this softwa... | attrs = [('HTML_4_STRICT_INLINE', 0), ('HTML_4_TRANSITIONAL_INLINE', 0), ('HTML_FORBIDDEN_END', 0), ('HTML_OPT_END', 0), ('HTML_BOOLEAN_ATTRS', 0), ('HTML_CHARACTER_ENTITIES', 0), ('HTML_NAME_ALLOWED', 0), ('HTML_DTD', 0), ('HTMLDOMImplementation', 0), ('htmlImplementation', 0), ('utf8_to_code', 0), ('ConvertChar', 0),... |
def soma():
valor1 = float(input("Digite valor 1: "))
valor2 = float(input("Digite valor 2: "))
soma = valor1 + valor2
return soma
def subtracao():
a = float(input("Primeiro numero: "))
b = float(input("Segundo numero: "))
subtracao = a - b
return subtracao
def multiplicacao():
a = float(input("Primei... | def soma():
valor1 = float(input('Digite valor 1: '))
valor2 = float(input('Digite valor 2: '))
soma = valor1 + valor2
return soma
def subtracao():
a = float(input('Primeiro numero: '))
b = float(input('Segundo numero: '))
subtracao = a - b
return subtracao
def multiplicacao():
a =... |
BOARD_SIZE = 5
WALL_NUM = 3
NN_DIM = 128
NUM_BLOCK = 5
BATCH_SIZE = 512
NUM_EPOCHS = 5
HISTORY_LEN = 5
TAU_THRES = 100
TURN_LIMIT = 60 | board_size = 5
wall_num = 3
nn_dim = 128
num_block = 5
batch_size = 512
num_epochs = 5
history_len = 5
tau_thres = 100
turn_limit = 60 |
with open("text_file.txt", mode="r") as in_file:
words = []
for line in in_file.readlines():
words += line.strip().split(" ")
unique_words = set(words)
with open("unique_words.txt", mode="w") as out_file:
for item in sorted(unique_words):
out_file.write(item)
out... | with open('text_file.txt', mode='r') as in_file:
words = []
for line in in_file.readlines():
words += line.strip().split(' ')
unique_words = set(words)
with open('unique_words.txt', mode='w') as out_file:
for item in sorted(unique_words):
out_file.write(item)
out_... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Jorge Samper Gonzalez'
__email__ = 'jsampergonzalez@gmail.com'
__version__ = '1.0.0'
__all__ = ["interpreter_parse", "syntax_highlighter"]
| __author__ = 'Jorge Samper Gonzalez'
__email__ = 'jsampergonzalez@gmail.com'
__version__ = '1.0.0'
__all__ = ['interpreter_parse', 'syntax_highlighter'] |
class Server(object):
def __init__(self, server):
self.id = server['server_id']
self.name = server['name']
self.default_channel = server['default_channel_id']
self.created = server['created']
@property
def _id(self):
return self.id
@property
def _name(self):... | class Server(object):
def __init__(self, server):
self.id = server['server_id']
self.name = server['name']
self.default_channel = server['default_channel_id']
self.created = server['created']
@property
def _id(self):
return self.id
@property
def _name(self)... |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"resize_slices": "00_dataprep.ipynb",
"apply_trans": "00_dataprep.ipynb",
"MRImage": "00_dataprep.ipynb",
"MRImageSegment": "00_dataprep.ipynb",
"loadnii": "00_dataprep.ipy... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'resize_slices': '00_dataprep.ipynb', 'apply_trans': '00_dataprep.ipynb', 'MRImage': '00_dataprep.ipynb', 'MRImageSegment': '00_dataprep.ipynb', 'loadnii': '00_dataprep.ipynb', 'open_mri': '00_dataprep.ipynb', 'open_mri_mask': '00_dataprep.ipynb', '... |
# https://www.interviewbit.com/problems/random-attendance/
class Solution:
# @param A : integer
# @param B : list of integers
# @return a list of integers
def solve(self, A, B):
return [self.find_position(A, x) for x in B]
def find_position(self, A, x):
position, x = 1, x - 1
... | class Solution:
def solve(self, A, B):
return [self.find_position(A, x) for x in B]
def find_position(self, A, x):
(position, x) = (1, x - 1)
while x > 0:
count = self.count(A, position)
if count <= x:
position += 1
x -= count
... |
def nonunique(alist):
for item in alist:
if (alist.count(item)==1):
alist.remove(item)
return alist
| def nonunique(alist):
for item in alist:
if alist.count(item) == 1:
alist.remove(item)
return alist |
class RecoveryError(Exception):
def __init__(self, message):
self.message = message
class UnableToRecoverPassword(RecoveryError):
pass
| class Recoveryerror(Exception):
def __init__(self, message):
self.message = message
class Unabletorecoverpassword(RecoveryError):
pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.