content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class BST:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
@staticmethod
def array2BST(array):
'''
array:sorted array
'''
n = len(array)
if n == 0: return None
m = n//2
left,... | class Bst:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
@staticmethod
def array2_bst(array):
"""
array:sorted array
"""
n = len(array)
if n == 0:
return None
m = n //... |
TANGO_PALLETE = [
'2e2e34343636',
'cccc00000000',
'4e4e9a9a0606',
'c4c4a0a00000',
'34346565a4a4',
'757550507b7b',
'060698989a9a',
'd3d3d7d7cfcf',
'555557575353',
'efef29292929',
'8a8ae2e23434',
'fcfce9e94f4f',
'72729f9fcfcf',
'adad7f7fa8a8',
'34... | tango_pallete = ['2e2e34343636', 'cccc00000000', '4e4e9a9a0606', 'c4c4a0a00000', '34346565a4a4', '757550507b7b', '060698989a9a', 'd3d3d7d7cfcf', '555557575353', 'efef29292929', '8a8ae2e23434', 'fcfce9e94f4f', '72729f9fcfcf', 'adad7f7fa8a8', '3434e2e2e2e2', 'eeeeeeeeecec']
def parse_tango_color(c):
r = int(c[:4][:2... |
def gen():
i = 0
while 1:
yield i
i += 1
g = gen()
try:
g.pend_throw
except AttributeError:
print("SKIP")
raise SystemExit
print(next(g))
print(next(g))
g.pend_throw(ValueError())
v = None
try:
v = next(g)
except Exception as e:
print("raised", repr(e))
print("ret was:"... | def gen():
i = 0
while 1:
yield i
i += 1
g = gen()
try:
g.pend_throw
except AttributeError:
print('SKIP')
raise SystemExit
print(next(g))
print(next(g))
g.pend_throw(value_error())
v = None
try:
v = next(g)
except Exception as e:
print('raised', repr(e))
print('ret was:', v)
... |
_base_ = [
'../../../_base_/datasets/imagenet/swin_sz224_4xbs256.py',
'../../../_base_/default_runtime.py',
]
# model settings
model = dict(
type='MixUpClassification',
pretrained=None,
alpha=0.2,
mix_mode="cutmix",
mix_args=dict(
attentivemix=dict(grid_size=32, top_k=None, beta=8),... | _base_ = ['../../../_base_/datasets/imagenet/swin_sz224_4xbs256.py', '../../../_base_/default_runtime.py']
model = dict(type='MixUpClassification', pretrained=None, alpha=0.2, mix_mode='cutmix', mix_args=dict(attentivemix=dict(grid_size=32, top_k=None, beta=8), automix=dict(mask_adjust=0, lam_margin=0), fmix=dict(decay... |
# Level: Hard
def isMatch(s: str, p: str) -> bool:
if not p:
return not s
n_s = len(s)
n_p = len(p)
j = 0
i = -1
while i < n_s-1:
i = i+ 1
if j >= n_p:
return False
if p[j] == '*':
while s[i]==s[i-1]:
i += 1
j... | def is_match(s: str, p: str) -> bool:
if not p:
return not s
n_s = len(s)
n_p = len(p)
j = 0
i = -1
while i < n_s - 1:
i = i + 1
if j >= n_p:
return False
if p[j] == '*':
while s[i] == s[i - 1]:
i += 1
j += 1
... |
# Take number, and convert integer to string
# Calculate and return number of digits
def get_num_digits(num):
# Convert int to str
num_str = str(num)
# Calculate number of digits
digits = len(num_str)
return digits
# Define main function
def main():
# Prompt user for an int... | def get_num_digits(num):
num_str = str(num)
digits = len(num_str)
return digits
def main():
number = int(input('Enter an integer: '))
num_digits = get_num_digits(number)
print(f'The number of digits in number {number} is {num_digits}.')
main() |
#Atoi stands for ASCII to Integer Conversion
def atoi(string):
res = 0
# Iterate through all characters of
# input and update result
for i in range(len(string)):
res = res * 10 + (ord(string[i]) - ord('0'))
return res
#Adjustment contains rule of three for calculating an integer given an... | def atoi(string):
res = 0
for i in range(len(string)):
res = res * 10 + (ord(string[i]) - ord('0'))
return res
def adjustment(a, b):
return a * b / 100 |
def bypass_incompatible_branch(job):
return (job.settings.bypass_incompatible_branch or
job.author_bypass.get('bypass_incompatible_branch', False))
def bypass_peer_approval(job):
return (job.settings.bypass_peer_approval or
job.author_bypass.get('bypass_peer_approval', False))
def b... | def bypass_incompatible_branch(job):
return job.settings.bypass_incompatible_branch or job.author_bypass.get('bypass_incompatible_branch', False)
def bypass_peer_approval(job):
return job.settings.bypass_peer_approval or job.author_bypass.get('bypass_peer_approval', False)
def bypass_leader_approval(job):
... |
class Heap:
def __init__(self):
self.items = dict() # key - (value, index)
self.indexes = [] # index - key // to know indexes
# Usefull functions
def swap(self, i, j):
x = self.indexes[i] # key of 1 item
y = self.indexes[j] # key of 2 item
# swa... | class Heap:
def __init__(self):
self.items = dict()
self.indexes = []
def swap(self, i, j):
x = self.indexes[i]
y = self.indexes[j]
self.indexes[i] = y
self.indexes[j] = x
temp = self.items[x][1]
self.items.update({x: (self.items[x][0], self.item... |
'''
All the reserved, individual words used in MAlice.
'''
A = "a"
ALICE = "Alice"
AND = "and"
ATE = "ate"
BECAME = "became"
BECAUSE = "because"
BUT = "but"
CLOSED = "closed"
COMMA = ","
CONTAINED = "contained"
DOT = "."
DRANK = "drank"
EITHER = "either"
ENOUGH = "enough"
EVENTUALLY = "eventually"
FOUND = "found"
H... | """
All the reserved, individual words used in MAlice.
"""
a = 'a'
alice = 'Alice'
and = 'and'
ate = 'ate'
became = 'became'
because = 'because'
but = 'but'
closed = 'closed'
comma = ','
contained = 'contained'
dot = '.'
drank = 'drank'
either = 'either'
enough = 'enough'
eventually = 'eventually'
found = 'found'
ha... |
def migrate():
print('migrating to version 2')
| def migrate():
print('migrating to version 2') |
test = { 'name': 'q2b3',
'points': 5,
'suites': [ { 'cases': [ { 'code': '>>> '
'histories_2b[2].model.count_params()\n'
'119260',
'hidden': False,
... | test = {'name': 'q2b3', 'points': 5, 'suites': [{'cases': [{'code': '>>> histories_2b[2].model.count_params()\n119260', 'hidden': False, 'locked': False}, {'code': ">>> histories_2b[2].model.layers[1].activation.__name__\n'sigmoid'", 'hidden': False, 'locked': False}, {'code': '>>> histories_2b[2].model.layers[1].units... |
def solve(n, red , blue):
rcount = bcount = 0
for i in range(n):
if int(red[i]) > int(blue[i]):
rcount = rcount +1
elif int(red[i]) < int(blue[i]):
bcount = bcount + 1
print( 'RED' if rcount>bcount else ('BLUE' if bcount>rcount else 'EQUAL'))
if __name__ == "__ma... | def solve(n, red, blue):
rcount = bcount = 0
for i in range(n):
if int(red[i]) > int(blue[i]):
rcount = rcount + 1
elif int(red[i]) < int(blue[i]):
bcount = bcount + 1
print('RED' if rcount > bcount else 'BLUE' if bcount > rcount else 'EQUAL')
if __name__ == '__main__... |
class a:
def __init__(self,da):
self.da = da
return
def go(self):
dd()
return None
def dd():
print('ok')
return None
aa = a(1)
aa.go() | class A:
def __init__(self, da):
self.da = da
return
def go(self):
dd()
return None
def dd():
print('ok')
return None
aa = a(1)
aa.go() |
'''
Created on Dec 27, 2019
@author: duane
'''
DOLLAR = ord('$')
LBRACE = ord('{')
RBRACE = ord('}')
LPAREN = ord('(')
RPAREN = ord(')')
class IStrFindResult(object):
OK = 0
NOTFOUND = 1
SYNTAX = 2
def __init__(self):
self.result = IStrFindResult.SYNTAX
self.lhs = 0
self.rh... | """
Created on Dec 27, 2019
@author: duane
"""
dollar = ord('$')
lbrace = ord('{')
rbrace = ord('}')
lparen = ord('(')
rparen = ord(')')
class Istrfindresult(object):
ok = 0
notfound = 1
syntax = 2
def __init__(self):
self.result = IStrFindResult.SYNTAX
self.lhs = 0
self.rhs ... |
P, R = input().split()
if P == '0': print('C')
elif R == '0': print('B')
else: print('A') | (p, r) = input().split()
if P == '0':
print('C')
elif R == '0':
print('B')
else:
print('A') |
dosyaadi = input("Enter file name: ")
dosyaadi = str(dosyaadi + ".txt")
with open(dosyaadi, 'r') as file :
dosyaicerigi = file.read()
silinecek = str(input("Enter the text that you wish to delete: "))
dosyaicerigi = dosyaicerigi.replace(silinecek, '')
with open(dosyaadi, 'w') as file:
file.write(dosyai... | dosyaadi = input('Enter file name: ')
dosyaadi = str(dosyaadi + '.txt')
with open(dosyaadi, 'r') as file:
dosyaicerigi = file.read()
silinecek = str(input('Enter the text that you wish to delete: '))
dosyaicerigi = dosyaicerigi.replace(silinecek, '')
with open(dosyaadi, 'w') as file:
file.write(dosyaicerigi)
... |
'''
DNA++ (c) DNA++ 2017
All rights reserved.
@author: neilswainston
'''
| """
DNA++ (c) DNA++ 2017
All rights reserved.
@author: neilswainston
""" |
class Solution:
def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
if root:
root.left,root.right = self.invertTree(root.right),self.invertTree(root.left)
return root
return None | class Solution:
def invert_tree(self, root: Optional[TreeNode]) -> Optional[TreeNode]:
if root:
(root.left, root.right) = (self.invertTree(root.right), self.invertTree(root.left))
return root
return None |
def assert_not_none(actual_result, message=""):
if not message:
message = f"{actual_result} resulted with None"
assert actual_result, message
def assert_equal(actual_result, expected_result, message=""):
if not message:
message = f"{actual_result} is not equal to expected " \
... | def assert_not_none(actual_result, message=''):
if not message:
message = f'{actual_result} resulted with None'
assert actual_result, message
def assert_equal(actual_result, expected_result, message=''):
if not message:
message = f'{actual_result} is not equal to expected result {expected_r... |
# 2019 advent day 3
MOVES = {
'R': (lambda x: (x[0], x[1] + 1)),
'L': (lambda x: (x[0], x[1] - 1)),
'U': (lambda x: (x[0] + 1, x[1])),
'D': (lambda x: (x[0] - 1, x[1])),
}
def build_route(directions: list) -> list:
current_location = (0, 0)
route = []
for d in directions:
directio... | moves = {'R': lambda x: (x[0], x[1] + 1), 'L': lambda x: (x[0], x[1] - 1), 'U': lambda x: (x[0] + 1, x[1]), 'D': lambda x: (x[0] - 1, x[1])}
def build_route(directions: list) -> list:
current_location = (0, 0)
route = []
for d in directions:
(direction, amount) = (d[0], int(d[1:]))
for _ in... |
budget = float(input())
nights = int(input())
price_night = float(input())
percent_extra = int(input())
if nights > 7:
price_night = price_night - (price_night * 0.05)
sum = nights * price_night
total_sum = sum + (budget * percent_extra / 100)
if total_sum <= budget:
print(f"Ivanovi will be left ... | budget = float(input())
nights = int(input())
price_night = float(input())
percent_extra = int(input())
if nights > 7:
price_night = price_night - price_night * 0.05
sum = nights * price_night
total_sum = sum + budget * percent_extra / 100
if total_sum <= budget:
print(f'Ivanovi will be left with {budget - tota... |
class Skidoo(object):
''' a mapping which claims to contain all keys, each with a value
of 23; item setting and deletion are no-ops; you can also call
an instance with arbitrary positional args, result is 23. '''
__metaclass__ = MetaInterfaceChecker
__implements__ = IMinimalMapping, ICallabl... | class Skidoo(object):
""" a mapping which claims to contain all keys, each with a value
of 23; item setting and deletion are no-ops; you can also call
an instance with arbitrary positional args, result is 23. """
__metaclass__ = MetaInterfaceChecker
__implements__ = (IMinimalMapping, ICallab... |
#!/usr/bin/env python
# coding: UTF-8
#
# @package Actor
# @author Ariadne Pinheiro
# @date 26/08/2020
#
# Actor class, which is the base class for Disease objects.
#
##
class Actor:
# Holds the value of the next "free" id.
__ID = 0
##
# Construct a new Actor object.
# - Sets the initial values of... | class Actor:
__id = 0
def __init__(self):
self.__locX = 0
self.__locY = 0
self.__world = None
self.__actorID = Actor.__ID
Actor.__ID += 1
self.__itCounter = 0
def get_id(self):
return self.__actorID
def iteration(self):
return self.__itC... |
NAMES_SAML2_PROTOCOL = "urn:oasis:names:tc:SAML:2.0:protocol"
NAMES_SAML2_ASSERTION = "urn:oasis:names:tc:SAML:2.0:assertion"
NAMEID_FORMAT_UNSPECIFIED = "urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified"
BINDINGS_HTTP_POST = "urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
DATE_TIME_FORMAT = "%Y-%m-%dT%H:%M:%SZ"
... | names_saml2_protocol = 'urn:oasis:names:tc:SAML:2.0:protocol'
names_saml2_assertion = 'urn:oasis:names:tc:SAML:2.0:assertion'
nameid_format_unspecified = 'urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified'
bindings_http_post = 'urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST'
date_time_format = '%Y-%m-%dT%H:%M:%SZ'
... |
groupSize = input()
groups = list(map(int,input().split(' ')))
tmpArray1 = set()
tmpArray2 = set()
for i in groups:
if i in tmpArray1:
tmpArray2.discard(i)
else:
tmpArray1.add(i)
tmpArray2.add(i)
for i in tmpArray2:
print(i)
| group_size = input()
groups = list(map(int, input().split(' ')))
tmp_array1 = set()
tmp_array2 = set()
for i in groups:
if i in tmpArray1:
tmpArray2.discard(i)
else:
tmpArray1.add(i)
tmpArray2.add(i)
for i in tmpArray2:
print(i) |
class Calculations:
def __init__(self, first, second):
self.first = first
self.second = second
def add(self):
print(self.first + self.second)
def subtract(self):
print(self.first - self.second)
def multiply(self):
print(self.first * self.second)
... | class Calculations:
def __init__(self, first, second):
self.first = first
self.second = second
def add(self):
print(self.first + self.second)
def subtract(self):
print(self.first - self.second)
def multiply(self):
print(self.first * self.second)
def divid... |
n, k = map(int, input().split())
w = list(map(int, input().split()))
r = sum(map(lambda x: (x+k-1)//k, w))
print((r+1)//2)
| (n, k) = map(int, input().split())
w = list(map(int, input().split()))
r = sum(map(lambda x: (x + k - 1) // k, w))
print((r + 1) // 2) |
# -*- coding: utf-8 -*-
def main():
a = input()
# See:
# https://www.slideshare.net/chokudai/abc007
if a == 'a':
print('-1')
else:
print('a')
if __name__ == '__main__':
main()
| def main():
a = input()
if a == 'a':
print('-1')
else:
print('a')
if __name__ == '__main__':
main() |
# input
N, M = map(int, input().split())
Ds = [*map(int, input().split())]
# compute
dp = [False] * (N+1)
for ni in range(N+1):
if ni == 0:
dp[ni] = True
for D in Ds:
if ni >= D:
dp[ni] = dp[ni] or dp[ni-D]
# output
print("Yes" if dp[-1] else "No")
| (n, m) = map(int, input().split())
ds = [*map(int, input().split())]
dp = [False] * (N + 1)
for ni in range(N + 1):
if ni == 0:
dp[ni] = True
for d in Ds:
if ni >= D:
dp[ni] = dp[ni] or dp[ni - D]
print('Yes' if dp[-1] else 'No') |
# sorting
n=int(input())
array=list(map(int,input().split()))
i=0
count=[]
counter=0
while i<len(array):
min=i
start=i+1
while(start<len(array)):
if array[start]<array[min]:
min=start
start+=1
if i!=min:
array[i],array[min]=array[min],array[i]
count.append(i)
... | n = int(input())
array = list(map(int, input().split()))
i = 0
count = []
counter = 0
while i < len(array):
min = i
start = i + 1
while start < len(array):
if array[start] < array[min]:
min = start
start += 1
if i != min:
(array[i], array[min]) = (array[min], array[i]... |
#Basics
a = "hello"
a += " I'm a dog"
print(a)
print(len(a))
print(a[1:]) #Output: ello I'm a dog
print(a[:5]) #Output: hello(index 5 is not included)
print(a[2:5])#Output: llo(index 2 is included)
print(a[::2])#Step size
#string is immutable so you can't assign a[1]= b
x = a.upper()
print(x)
x = a.capitalize()
prin... | a = 'hello'
a += " I'm a dog"
print(a)
print(len(a))
print(a[1:])
print(a[:5])
print(a[2:5])
print(a[::2])
x = a.upper()
print(x)
x = a.capitalize()
print(x)
x = a.split('e')
print(x)
x = a.split()
print(x)
x = a.strip()
print(x)
x = a.replace('l', 'xxx')
print(x)
x = 'Insert another string here: {}'.format('insert me!... |
def is_even(i: int) -> bool:
if i == 1:
return False
elif i == 2:
return True
elif i == 3:
return False
elif i == 4:
return True
elif i == 5:
...
# Never do that! Use one of these instead...
is_even = lambda i : i % 2 == 0
is_even = lambda i : not i & 1
is_o... | def is_even(i: int) -> bool:
if i == 1:
return False
elif i == 2:
return True
elif i == 3:
return False
elif i == 4:
return True
elif i == 5:
...
is_even = lambda i: i % 2 == 0
is_even = lambda i: not i & 1
is_odd = lambda i: not is_even(i) |
__title__ = 'har2case'
__description__ = 'Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner.'
__url__ = 'https://github.com/HttpRunner/har2case'
__version__ = '0.2.0'
__author__ = 'debugtalk'
__author_email__ = 'mail@debugtalk.com'
__license__ = 'Apache-2.0'
__copyright__ = 'Copyright 2017 debugtalk' | __title__ = 'har2case'
__description__ = 'Convert HAR(HTTP Archive) to YAML/JSON testcases for HttpRunner.'
__url__ = 'https://github.com/HttpRunner/har2case'
__version__ = '0.2.0'
__author__ = 'debugtalk'
__author_email__ = 'mail@debugtalk.com'
__license__ = 'Apache-2.0'
__copyright__ = 'Copyright 2017 debugtalk' |
def pictureInserter(og,address,list):
j=0
for i in og:
file1 = open(address+'/'+i, "a")
x="\ncover::https://image.tmdb.org/t/p/original/"+list[j]
file1.writelines(x)
file1.close()
j=j+1
| def picture_inserter(og, address, list):
j = 0
for i in og:
file1 = open(address + '/' + i, 'a')
x = '\ncover::https://image.tmdb.org/t/p/original/' + list[j]
file1.writelines(x)
file1.close()
j = j + 1 |
class Solution:
def removeOuterParentheses(self, s: str) -> str:
ans = []
ct = 0
for ch in s:
if ch == '(':
ct += 1
if ct != 1:
ans.append(ch)
else:
ct -= 1
if ct != 0:
... | class Solution:
def remove_outer_parentheses(self, s: str) -> str:
ans = []
ct = 0
for ch in s:
if ch == '(':
ct += 1
if ct != 1:
ans.append(ch)
else:
ct -= 1
if ct != 0:
... |
#######################################################################################################################
# Given a string, find the length of the longest substring which has no repeating characters.
#
# Input: String="aabccbb"
# Output: 3
# Explanation: The longest substring without any repeating charact... | def longest_substring_no_repeating_char(input_str: str) -> int:
window_start = 0
is_present = [None for i in range(26)]
max_window = 0
for i in range(len(input_str)):
char_ord = ord(input_str[i]) - 97
if is_present[char_ord] is not None:
window_start = max(window_start, is_pr... |
# ------------------------------
# Binary Tree Level Order Traversal
#
# Description:
# Given a binary tree, return the level order traversal of its nodes' values. (ie, from
# left to right, level by level).
#
# For example:
# Given binary tree [3,9,20,null,null,15,7],
# 3
# / \
# 9 20
# / \
# 15 ... | class Solution:
def level_order(self, root: TreeNode) -> List[List[int]]:
if not root:
return []
res = []
queue = [root]
while queue:
temp = []
children = []
for node in queue:
temp.append(node.val)
if n... |
def take_beer(fridge, number=1):
if "beer" not in fridge:
raise Exception("No beer at all:(")
if number > fridge["beer"]:
raise Exception("Not enough beer:(")
fridge["beer"] -= number
if __name__ == "__main__":
fridge = {
"beer": 2,
"milk": 1,
"meat": 3,
}... | def take_beer(fridge, number=1):
if 'beer' not in fridge:
raise exception('No beer at all:(')
if number > fridge['beer']:
raise exception('Not enough beer:(')
fridge['beer'] -= number
if __name__ == '__main__':
fridge = {'beer': 2, 'milk': 1, 'meat': 3}
print('I wanna drink 1 bottle ... |
camera_width = 640
camera_height = 480
film_back_width = 1.417
film_back_height = 0.945
x_center = 320
y_center = 240
P_1 = (-0.023, -0.261, 2.376)
p_11 = P_1[0]
p_12 = P_1[1]
p_13 = P_1[2]
P_2 = (0.659, -0.071, 2.082)
p_21 = P_2[0]
p_22 = P_2[1]
p_23 = P_2[2]
p_1_prime = (52, 163)
x_1 = p_1_prime[0]
y_1 = p_1_pr... | camera_width = 640
camera_height = 480
film_back_width = 1.417
film_back_height = 0.945
x_center = 320
y_center = 240
p_1 = (-0.023, -0.261, 2.376)
p_11 = P_1[0]
p_12 = P_1[1]
p_13 = P_1[2]
p_2 = (0.659, -0.071, 2.082)
p_21 = P_2[0]
p_22 = P_2[1]
p_23 = P_2[2]
p_1_prime = (52, 163)
x_1 = p_1_prime[0]
y_1 = p_1_prime[1]... |
def main():
val=int(input("input a num"))
if val<10:
print("A")
elif val<20:
print("B")
elif val<30:
print("C")
else:
print("D")
main()
| def main():
val = int(input('input a num'))
if val < 10:
print('A')
elif val < 20:
print('B')
elif val < 30:
print('C')
else:
print('D')
main() |
__all__ = ['cross_validation',
'metrics',
'datasets',
'recommender']
| __all__ = ['cross_validation', 'metrics', 'datasets', 'recommender'] |
def is_leap(year):
leap=False
if year%400==0:
leap=True
elif year%4==0 and year%100!=0:
leap=True
else:
leap=False
return leap
year = int(input())
| def is_leap(year):
leap = False
if year % 400 == 0:
leap = True
elif year % 4 == 0 and year % 100 != 0:
leap = True
else:
leap = False
return leap
year = int(input()) |
print("Press q to quit")
quit = False
while quit is False:
in_val = input("Please enter a positive integer.\n > ")
if in_val is 'q':
quit = True
elif int(in_val) % 3 == 0 and int(in_val) % 5 == 0:
print("FizzBuzz")
elif int(in_val) % 5 == 0:
print("Buzz")
elif int(in_val) % ... | print('Press q to quit')
quit = False
while quit is False:
in_val = input('Please enter a positive integer.\n > ')
if in_val is 'q':
quit = True
elif int(in_val) % 3 == 0 and int(in_val) % 5 == 0:
print('FizzBuzz')
elif int(in_val) % 5 == 0:
print('Buzz')
elif int(in_val) % 3... |
# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------
class DashboardInfo:
MODEL_ID_KEY = "id" # To match Model schema
MODEL_INFO_FILENAME = "model_info.json"
RAI_INSIGHTS_MODEL_... | class Dashboardinfo:
model_id_key = 'id'
model_info_filename = 'model_info.json'
rai_insights_model_id_key = 'model_id'
rai_insights_run_id_key = 'rai_insights_parent_run_id'
rai_insights_parent_filename = 'rai_insights.json'
class Propertykeyvalues:
rai_insights_type_key = '_azureml.responsibl... |
#4 lines: Fibonacci, tuple assignment
parents, babies = (1, 1)
while babies < 100:
print ('This generation has {0} babies'.format(babies))
parents, babies = (babies, parents + babies) | (parents, babies) = (1, 1)
while babies < 100:
print('This generation has {0} babies'.format(babies))
(parents, babies) = (babies, parents + babies) |
# model settings
norm_cfg = dict(type='BN', requires_grad=True)
model = dict(
type='EncoderDecoder',
pretrained='pretrain/vit_base_patch16_224.pth',
backbone=dict(
type='VisionTransformer',
img_size=(224, 224),
patch_size=16,
in_channels=3,
embed_dim=768,
dept... | norm_cfg = dict(type='BN', requires_grad=True)
model = dict(type='EncoderDecoder', pretrained='pretrain/vit_base_patch16_224.pth', backbone=dict(type='VisionTransformer', img_size=(224, 224), patch_size=16, in_channels=3, embed_dim=768, depth=12, num_heads=12, mlp_ratio=4, qkv_bias=True, drop_rate=0.0, attn_drop_rate=0... |
# Copyright (C) 2019 Intel Corporation. All rights reserved.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
load("@bazel_tools//tools/build_defs/cc:action_names.bzl", "ACTION_NAMES")
load(
"@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl",
"feature",
"flag_group",
"flag_set",
"tool_p... | load('@bazel_tools//tools/build_defs/cc:action_names.bzl', 'ACTION_NAMES')
load('@bazel_tools//tools/cpp:cc_toolchain_config_lib.bzl', 'feature', 'flag_group', 'flag_set', 'tool_path')
all_compile_actions = [ACTION_NAMES.c_compile, ACTION_NAMES.cpp_compile]
all_link_actions = [ACTION_NAMES.cpp_link_executable, ACTION_N... |
train_data_path = "../data/no_cycle/train.data"
dev_data_path = "../data/no_cycle/dev.data"
test_data_path = "../data/no_cycle/test.data"
word_idx_file_path = "../data/word.idx"
word_embedding_dim = 100
train_batch_size = 32
dev_batch_size = 500
test_batch_size = 500
l2_lambda = 0.000001
learning_rate = 0.001
epoch... | train_data_path = '../data/no_cycle/train.data'
dev_data_path = '../data/no_cycle/dev.data'
test_data_path = '../data/no_cycle/test.data'
word_idx_file_path = '../data/word.idx'
word_embedding_dim = 100
train_batch_size = 32
dev_batch_size = 500
test_batch_size = 500
l2_lambda = 1e-06
learning_rate = 0.001
epochs = 100... |
class Input(object):
def __init__(self, type, data):
self.__type = type
self.__data = deepcopy(data)
def __repr__(self):
return repr(self.__data)
def __str__(self):
return str(self.__type) + str(self.__data)
| class Input(object):
def __init__(self, type, data):
self.__type = type
self.__data = deepcopy(data)
def __repr__(self):
return repr(self.__data)
def __str__(self):
return str(self.__type) + str(self.__data) |
class Player:
def __init__(self, nickname, vapor_id, player_id, ip):
self.nickname = nickname
self.vapor_id = vapor_id
self.player_id = player_id
self.ip = ip
self.not_joined = True
self.loads_map = True
self.joined_after_change_map = True
class Players:
... | class Player:
def __init__(self, nickname, vapor_id, player_id, ip):
self.nickname = nickname
self.vapor_id = vapor_id
self.player_id = player_id
self.ip = ip
self.not_joined = True
self.loads_map = True
self.joined_after_change_map = True
class Players:
... |
#
# PySNMP MIB module DABING-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file://..\DABING-MIB.mib
# Produced by pysmi-0.3.4 at Tue Mar 22 12:53:47 2022
# On host ? platform ? version ? by user ?
# Using Python version 3.8.2 (tags/v3.8.2:7b3ab59, Feb 25 2020, 22:45:29) [MSC v.1916 32 bit (Intel)]
#
OctetString, Objec... | (octet_string, object_identifier, integer) = mibBuilder.importSymbols('ASN1', 'OctetString', 'ObjectIdentifier', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, constraints_union, value_range_constraint, single_value_constraint, value_size_constraint) ... |
class TreeNode:
def __init__(self, name, data, parent=None):
self.name = name
self.parent = parent
self.data = data
self.childs = {}
def add_child(self, name, data):
self.childs.update({name:(type(self))(name, data, self)})
def rm_branch(self, name, ansistors_n: lis... | class Treenode:
def __init__(self, name, data, parent=None):
self.name = name
self.parent = parent
self.data = data
self.childs = {}
def add_child(self, name, data):
self.childs.update({name: type(self)(name, data, self)})
def rm_branch(self, name, ansistors_n: lis... |
api_key = "9N7hvPP9yFrjBnELpBdthluBjiOWzJZw"
mongo_url = 'mongodb://localhost:27017'
mongo_db = 'CarPopularity'
mongo_collections = ['CarSalesByYear', 'PopularCarsByRegion']
years_data = ['2019', '2018', '2017', '2016', '2015']
test_mode = True | api_key = '9N7hvPP9yFrjBnELpBdthluBjiOWzJZw'
mongo_url = 'mongodb://localhost:27017'
mongo_db = 'CarPopularity'
mongo_collections = ['CarSalesByYear', 'PopularCarsByRegion']
years_data = ['2019', '2018', '2017', '2016', '2015']
test_mode = True |
#
# PySNMP MIB module MWORKS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MWORKS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:16:04 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_union, value_size_constraint, constraints_intersection) ... |
# == 1 ==
bar = [1, 2]
def foo(bar):
bar = sum(bar)
return bar
print(foo(bar))
# == 2 ==
bar = [1, 2]
def foo(bar):
bar[0] = 1
return sum(bar)
print(foo(bar))
# == 3 ==
bar = [1, 2]
def foo():
bar = sum(bar)
return bar
print(foo())
# == 4 ==
bar = [1, 2]
def foo(bar):
bar =... | bar = [1, 2]
def foo(bar):
bar = sum(bar)
return bar
print(foo(bar))
bar = [1, 2]
def foo(bar):
bar[0] = 1
return sum(bar)
print(foo(bar))
bar = [1, 2]
def foo():
bar = sum(bar)
return bar
print(foo())
bar = [1, 2]
def foo(bar):
bar = [1, 2, 3]
return sum(bar)
print(foo(bar), bar)
ba... |
n = int(input())
row = 0
for i in range(100):
if 2 ** i <= n <= 2 ** (i + 1) - 1:
row = i
break
def seki(k, n):
for _ in range(n):
k = 4 * k + 2
return k
k = 0
if row % 2 != 0:
k = 2
cri = seki(k, row // 2)
if n < cri:
print("Aoki")
else:
print("Ta... | n = int(input())
row = 0
for i in range(100):
if 2 ** i <= n <= 2 ** (i + 1) - 1:
row = i
break
def seki(k, n):
for _ in range(n):
k = 4 * k + 2
return k
k = 0
if row % 2 != 0:
k = 2
cri = seki(k, row // 2)
if n < cri:
print('Aoki')
else:
print('Takah... |
bino = int(input())
cino = int(input())
if (bino+cino)%2==0:
print("Bino")
else:
print("Cino")
| bino = int(input())
cino = int(input())
if (bino + cino) % 2 == 0:
print('Bino')
else:
print('Cino') |
print(b)
print(c)
print(d)
print(e)
print(f)
print(g) | print(b)
print(c)
print(d)
print(e)
print(f)
print(g) |
print("hiiiiiiiiiiiiiiiix")
def sayhi():
print("2nd pkg said hi")
| print('hiiiiiiiiiiiiiiiix')
def sayhi():
print('2nd pkg said hi') |
base = int(input('Digite o valor da base: '))
expoente = 0
while expoente <= 0:
expoente = int(input('Digite o valor do expoente: '))
if expoente <= 0:
print('O expoente tem que ser positivo')
potencia = 1
for c in range(1, expoente + 1):
potencia *= base
print(f'{base}^ {expoente} = {potencia}'... | base = int(input('Digite o valor da base: '))
expoente = 0
while expoente <= 0:
expoente = int(input('Digite o valor do expoente: '))
if expoente <= 0:
print('O expoente tem que ser positivo')
potencia = 1
for c in range(1, expoente + 1):
potencia *= base
print(f'{base}^ {expoente} = {potencia}') |
# 084
# Ask the user to type in their postcode.Display the first two
# letters in uppercase.
# very simple
print(input('Enter your postcode: ')[0:2].upper()) | print(input('Enter your postcode: ')[0:2].upper()) |
MAP = 1
SPEED = 1.5
VELOCITYRESET = 6
WIDTH = 1280
HEIGHT = 720
X = WIDTH / 2 - 50
Y = HEIGHT / 2 - 50
MOUSER = 325
TICKRATES = 120
nfc = False
raspberry = False | map = 1
speed = 1.5
velocityreset = 6
width = 1280
height = 720
x = WIDTH / 2 - 50
y = HEIGHT / 2 - 50
mouser = 325
tickrates = 120
nfc = False
raspberry = False |
def main():
n = 111
gen = (n * 7 for x in range(10))
if 777 in gen:
print("Yes!")
if __name__ == '__main__':
main()
| def main():
n = 111
gen = (n * 7 for x in range(10))
if 777 in gen:
print('Yes!')
if __name__ == '__main__':
main() |
class BaseStorageManager(object):
def __init__(self, adpter):
self.adapter = adpter
def put(self, options):
try:
return self.adapter.put(options)
except Exception:
raise Exception('Failed to write data to storage')
def get(self, options):
try:
... | class Basestoragemanager(object):
def __init__(self, adpter):
self.adapter = adpter
def put(self, options):
try:
return self.adapter.put(options)
except Exception:
raise exception('Failed to write data to storage')
def get(self, options):
try:
... |
def keychain_value_iter(d, key_chain=None, allowed_values=None):
key_chain = [] if key_chain is None else list(key_chain).copy()
if not isinstance(d, dict):
if allowed_values is not None:
assert isinstance(d, allowed_values), 'Value needs to be of type {}!'.format(
allowed_v... | def keychain_value_iter(d, key_chain=None, allowed_values=None):
key_chain = [] if key_chain is None else list(key_chain).copy()
if not isinstance(d, dict):
if allowed_values is not None:
assert isinstance(d, allowed_values), 'Value needs to be of type {}!'.format(allowed_values)
yie... |
#!/usr/bin/python
# -*- coding: utf-8 -*-
def getstatus(code):
if code == "1000":
value = "Success!"
elif code == "1001":
value = "Unknown Message Received"
elif code == "1002":
value = "Connection to Fishbowl Server was lost"
elif code == "1003":
value = "Some Requests ... | def getstatus(code):
if code == '1000':
value = 'Success!'
elif code == '1001':
value = 'Unknown Message Received'
elif code == '1002':
value = 'Connection to Fishbowl Server was lost'
elif code == '1003':
value = "Some Requests had errors -- now isn't that helpful..."
... |
ans = dict()
pairs = dict()
def create_tree(p):
if p in ans:
return ans[p]
else:
try:
res = 0
if p in pairs:
for ch in pairs[p]:
res += create_tree(ch) + 1
ans[p] = res
return res
except:
pass... | ans = dict()
pairs = dict()
def create_tree(p):
if p in ans:
return ans[p]
else:
try:
res = 0
if p in pairs:
for ch in pairs[p]:
res += create_tree(ch) + 1
ans[p] = res
return res
except:
pas... |
def italicize(s):
b = False
res = ''
for e in s:
if e == '"':
if b:
res += '{\\i}' + e
else:
res += e + '{i}'
b=not b
else:
res += e
return res
def main():
F=open('test_in.txt','r')
X=F.read()
F... | def italicize(s):
b = False
res = ''
for e in s:
if e == '"':
if b:
res += '{\\i}' + e
else:
res += e + '{i}'
b = not b
else:
res += e
return res
def main():
f = open('test_in.txt', 'r')
x = F.read()... |
#!venv/bin/python3
cs = [int(c) for c in open("inputs/23.in", "r").readline().strip()]
def f(cs, ts):
p,cc = {n: cs[(i+1)%len(cs)] for i,n in enumerate(cs)},cs[-1]
for _ in range(ts):
cc,dc = p[cc],p[cc]-1 if p[cc]-1 > 0 else max(p.keys())
hc,p[cc] = [p[cc], p[p[cc]], p[p[p[cc]]]],p[p[p[p[cc]]... | cs = [int(c) for c in open('inputs/23.in', 'r').readline().strip()]
def f(cs, ts):
(p, cc) = ({n: cs[(i + 1) % len(cs)] for (i, n) in enumerate(cs)}, cs[-1])
for _ in range(ts):
(cc, dc) = (p[cc], p[cc] - 1 if p[cc] - 1 > 0 else max(p.keys()))
(hc, p[cc]) = ([p[cc], p[p[cc]], p[p[p[cc]]]], p[p[... |
entrada = input("palabra")
listaDeLetras = []
for i in entrada:
listaDeLetras.append(i)
| entrada = input('palabra')
lista_de_letras = []
for i in entrada:
listaDeLetras.append(i) |
class Machine():
def __init__(self):
self.pointer = 0
self.accum = 0
self.visited = []
def run(self,program):
salir = False
while (salir == False):
if (self.pointer in self.visited):
return False
if (self.pointer >= len(progr... | class Machine:
def __init__(self):
self.pointer = 0
self.accum = 0
self.visited = []
def run(self, program):
salir = False
while salir == False:
if self.pointer in self.visited:
return False
if self.pointer >= len(program):
... |
class PayabbhiError(Exception):
def __init__(self, description=None, http_status=None,
field=None):
self.description = description
self.http_status = http_status
self.field = field
self._message = self.error_message()
super(PayabbhiError, self).__init__(self... | class Payabbhierror(Exception):
def __init__(self, description=None, http_status=None, field=None):
self.description = description
self.http_status = http_status
self.field = field
self._message = self.error_message()
super(PayabbhiError, self).__init__(self._message)
d... |
class OrderedStream:
def __init__(self, n: int):
self.data = [None]*n
self.ptr = 0
def insert(self, id: int, value: str) -> List[str]:
id -= 1
self.data[id] = value
if id > self.ptr: return []
while self.ptr < len(self.data) and self.data[self.ptr]: ... | class Orderedstream:
def __init__(self, n: int):
self.data = [None] * n
self.ptr = 0
def insert(self, id: int, value: str) -> List[str]:
id -= 1
self.data[id] = value
if id > self.ptr:
return []
while self.ptr < len(self.data) and self.data[self.ptr]... |
# convert2.py
# A program to convert Celsius temps to Fahrenheit.
# This version issues heat and cold warnings.
def main():
celsius = float(input("What is the Celsius temperature? "))
fahrenheit = 9 / 5 * celsius + 32
print("The temperature is", fahrenheit, "degrees fahrenheit.")
if fahrenhei... | def main():
celsius = float(input('What is the Celsius temperature? '))
fahrenheit = 9 / 5 * celsius + 32
print('The temperature is', fahrenheit, 'degrees fahrenheit.')
if fahrenheit >= 90:
print("It's really hot out there, be careful!")
if fahrenheit <= 30:
print('Brrrrr. Be sure to... |
class LevenshteinDistance:
def solve(self, str_a, str_b):
a, b = str_a, str_b
dist = {(x,y):0 for x in range(len(a)) for y in range(len(b))}
for x in range(len(a)): dist[(x,-1)] = x+1
for y in range(len(b)): dist[(-1,y)] = y+1
dist[(-1,-1)] = 0
for i in range(len(a)):... | class Levenshteindistance:
def solve(self, str_a, str_b):
(a, b) = (str_a, str_b)
dist = {(x, y): 0 for x in range(len(a)) for y in range(len(b))}
for x in range(len(a)):
dist[x, -1] = x + 1
for y in range(len(b)):
dist[-1, y] = y + 1
dist[-1, -1] = 0... |
# -*- coding: utf-8 -*-
BROKER_URL = 'amqp://guest@localhost//'
CELERY_ACCEPT_CONTENT = ['json'],
CELERY_RESULT_BACKEND = 'amqp://guest@localhost//'
CELERY_RESULT_SERIALIZER = 'json'
CELERY_TASK_SERIALIZER = 'json'
CELERY_TIMEZONE = 'Asia/Shanghai'
CELERY_ENABLE_UTC = False
| broker_url = 'amqp://guest@localhost//'
celery_accept_content = (['json'],)
celery_result_backend = 'amqp://guest@localhost//'
celery_result_serializer = 'json'
celery_task_serializer = 'json'
celery_timezone = 'Asia/Shanghai'
celery_enable_utc = False |
'''
Created on 2011-6-22
@author: dholer
'''
| """
Created on 2011-6-22
@author: dholer
""" |
total = 0
for n in range(1000, 1000000):
suma = 0
for i in str(n):
suma += int(i)**5
if (n == suma):
total += n
print(total) | total = 0
for n in range(1000, 1000000):
suma = 0
for i in str(n):
suma += int(i) ** 5
if n == suma:
total += n
print(total) |
class Solution:
@staticmethod
def naive(board,word):
rows,cols,n = len(board),len(board[0]),len(word)
visited = set()
def dfs(i,j,k):
idf = str(i)+','+str(j)
if i<0 or j<0 or i>cols-1 or j>rows-1 or \
board[j][i]!=word[k] or idf in visited:
... | class Solution:
@staticmethod
def naive(board, word):
(rows, cols, n) = (len(board), len(board[0]), len(word))
visited = set()
def dfs(i, j, k):
idf = str(i) + ',' + str(j)
if i < 0 or j < 0 or i > cols - 1 or (j > rows - 1) or (board[j][i] != word[k]) or (idf i... |
# ----------------------------------------------------------------------
# CISCO-VLAN-MEMBERSHIP-MIB
# Compiled MIB
# Do not modify this file directly
# Run ./noc mib make-cmib instead
# ----------------------------------------------------------------------
# Copyright (C) 2007-2020 The NOC Project
# See LICENSE for de... | name = 'CISCO-VLAN-MEMBERSHIP-MIB'
last_updated = '2007-12-14'
compiled = '2020-01-19'
mib = {'CISCO-VLAN-MEMBERSHIP-MIB::ciscoVlanMembershipMIB': '1.3.6.1.4.1.9.9.68', 'CISCO-VLAN-MEMBERSHIP-MIB::ciscoVlanMembershipMIBObjects': '1.3.6.1.4.1.9.9.68.1', 'CISCO-VLAN-MEMBERSHIP-MIB::vmVmps': '1.3.6.1.4.1.9.9.68.1.1', 'CIS... |
# module for adapting templates on the fly if components are reused
# check that all reused components are defined consistently -> else: exception
def check_consistency(components):
for j1 in components:
for j2 in components: # compare all components
if j1 == j2 and j1.__dict__ != j2.__dict__: # same n... | def check_consistency(components):
for j1 in components:
for j2 in components:
if j1 == j2 and j1.__dict__ != j2.__dict__:
raise value_error('Inconsistent definition of reused component {}.'.format(j1))
def reuses(component, arcs):
times = set()
for k in range(component.... |
def findDecision(obj): #obj[0]: Passanger, obj[1]: Time, obj[2]: Coupon, obj[3]: Gender, obj[4]: Age, obj[5]: Education, obj[6]: Occupation, obj[7]: Bar, obj[8]: Coffeehouse, obj[9]: Restaurant20to50, obj[10]: Direction_same, obj[11]: Distance
# {"feature": "Age", "instances": 51, "metric_value": 0.9662, "depth": 1}
... | def find_decision(obj):
if obj[4] > 0:
if obj[6] > 1:
if obj[7] <= 1.0:
if obj[5] > 0:
if obj[0] <= 2:
if obj[1] <= 2:
if obj[9] > 0.0:
if obj[8] <= 2.0:
... |
# -*- coding: utf-8 -*-
PIXIVUTIL_VERSION = '20191220-beta1'
PIXIVUTIL_LINK = 'https://github.com/Nandaka/PixivUtil2/releases'
PIXIVUTIL_DONATE = 'https://bit.ly/PixivUtilDonation'
# Log Settings
PIXIVUTIL_LOG_FILE = 'pixivutil.log'
PIXIVUTIL_LOG_SIZE = 10485760
PIXIVUTIL_LOG_COUNT = 10
PIXIVUTIL_LOG_FORMAT = "%(asct... | pixivutil_version = '20191220-beta1'
pixivutil_link = 'https://github.com/Nandaka/PixivUtil2/releases'
pixivutil_donate = 'https://bit.ly/PixivUtilDonation'
pixivutil_log_file = 'pixivutil.log'
pixivutil_log_size = 10485760
pixivutil_log_count = 10
pixivutil_log_format = '%(asctime)s - %(name)s - %(levelname)s - %(mess... |
class Solution:
def destCity(self, paths: List[List[str]]) -> str:
bads = set()
cities = set()
for u, v in paths:
cities.add(u)
cities.add(v)
bads.add(u)
ans = cities - bads
return list(ans)[0]
| class Solution:
def dest_city(self, paths: List[List[str]]) -> str:
bads = set()
cities = set()
for (u, v) in paths:
cities.add(u)
cities.add(v)
bads.add(u)
ans = cities - bads
return list(ans)[0] |
#!/usr/bin/env python3
# The format of your own localizable method.
# This is an example of '"string".localized'
SUFFIX = '.localized'
KEY = r'"(?:\\.|[^"\\])*"'
LOCALIZABLE_RE = r'%s%s' % (KEY, SUFFIX)
# Specify the path of localizable files in project.
LOCALIZABLE_FILE_PATH = ''
LOCALIZABLE_FILE_NAMES = ['Localizab... | suffix = '.localized'
key = '"(?:\\\\.|[^"\\\\])*"'
localizable_re = '%s%s' % (KEY, SUFFIX)
localizable_file_path = ''
localizable_file_names = ['Localizable']
localizable_file_types = ['strings']
search_types = ['swift', 'm', 'json']
source_file_exclusive_paths = ['Assets.xcassets', 'Carthage', 'ThirdParty', 'Pods', '... |
def task_pos_args():
def show_params(param1, pos):
print('param1 is: {0}'.format(param1))
for index, pos_arg in enumerate(pos):
print('positional-{0}: {1}'.format(index, pos_arg))
return {'actions':[(show_params,)],
'params':[{'name':'param1',
'shor... | def task_pos_args():
def show_params(param1, pos):
print('param1 is: {0}'.format(param1))
for (index, pos_arg) in enumerate(pos):
print('positional-{0}: {1}'.format(index, pos_arg))
return {'actions': [(show_params,)], 'params': [{'name': 'param1', 'short': 'p', 'default': 'default ... |
# Lets create a linked list that has the following elements
'''
1. FE
2. SE
3. TE
4. BE
'''
# Creating a Node class to create individual Nodes
class Node:
def __init__(self,data):
self.__data = data
self.__next = None
def get_data(self):
return self.__data
... | """
1. FE
2. SE
3. TE
4. BE
"""
class Node:
def __init__(self, data):
self.__data = data
self.__next = None
def get_data(self):
return self.__data
def set_data(self, data):
self.__data = data
def get_next(self):
return self.__next
def set_next(self, next... |
ten_things = "Apples Oranges cows Telephone Light Sugar"
print ("Wait there are not 10 things in that list. Let's fix")
stuff = ten_things.split(' ')
more_stuff = {"Day", "Night", "Song", "Firebee",
"Corn", "Banana", "Girl", "Boy"}
while len(stuff) !=10:
next_one = more_stuff.pop()
print("Adding: ", next_one)
... | ten_things = 'Apples Oranges cows Telephone Light Sugar'
print("Wait there are not 10 things in that list. Let's fix")
stuff = ten_things.split(' ')
more_stuff = {'Day', 'Night', 'Song', 'Firebee', 'Corn', 'Banana', 'Girl', 'Boy'}
while len(stuff) != 10:
next_one = more_stuff.pop()
print('Adding: ', next_one)
... |
_base_ = './pspnet_r50-d8_512x512_80k_loveda.py'
model = dict(
backbone=dict(
depth=18,
init_cfg=dict(
type='Pretrained', checkpoint='open-mmlab://resnet18_v1c')),
decode_head=dict(
in_channels=512,
channels=128,
),
auxiliary_head=dict(in_channels=256, channel... | _base_ = './pspnet_r50-d8_512x512_80k_loveda.py'
model = dict(backbone=dict(depth=18, init_cfg=dict(type='Pretrained', checkpoint='open-mmlab://resnet18_v1c')), decode_head=dict(in_channels=512, channels=128), auxiliary_head=dict(in_channels=256, channels=64)) |
# Easy
# https://leetcode.com/problems/palindrome-number/
# Time Complexity: O(log(x) to base 10)
# Space Complexity: O(1)
class Solution:
def isPalindrome(self, x: int) -> bool:
temp = x
rev = 0
while temp > 0:
rev = rev * 10 + temp % 10
temp //= 10
return re... | class Solution:
def is_palindrome(self, x: int) -> bool:
temp = x
rev = 0
while temp > 0:
rev = rev * 10 + temp % 10
temp //= 10
return rev == x |
# Use zip() to create a new variable called names_and_dogs_names that combines owners and dogs_names lists into a zip object.
# Then, create a new variable named list_of_names_and_dogs_names by calling the list() function on names_and_dogs_names.
# Print list_of_names_and_dogs_names.
owners = ["Jenny", "Alexus", "Sa... | owners = ['Jenny', 'Alexus', 'Sam', 'Grace']
dogs_names = ['Elphonse', 'Dr. Doggy DDS', 'Carter', 'Ralph']
names_and_dogs_names = zip(owners, dogs_names)
list_of_names_and_dogs_names = list(names_and_dogs_names)
print(list_of_names_and_dogs_names) |
r, c, m = map(int, input().split())
n = int(input())
op = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]
board = [[0 for _ in range(c)] for _ in range(r)]
for ra, rb, ca, cb in op:
for j in range(ra, rb + 1):
for k in range(ca, cb + 1):
board[j][k] += 1
cnt = 0
for i in ra... | (r, c, m) = map(int, input().split())
n = int(input())
op = [list(map(lambda x: int(x) - 1, input().split())) for _ in range(n)]
board = [[0 for _ in range(c)] for _ in range(r)]
for (ra, rb, ca, cb) in op:
for j in range(ra, rb + 1):
for k in range(ca, cb + 1):
board[j][k] += 1
cnt = 0
for i in... |
# Convert a Number to a String!
# We need a function that can transform a number into a string.
# What ways of achieving this do you know?
def number_to_string(num: int) -> str:
str_num = str(num)
return str_num
print(number_to_string(123))
print(type(number_to_string(123))) | def number_to_string(num: int) -> str:
str_num = str(num)
return str_num
print(number_to_string(123))
print(type(number_to_string(123))) |
floatVar = 1.0
listVar = [3, "hello"]
dictVar = {
"myField": "value"
}
aotVar = [dictVar, dictVar]
intVar = 1 | float_var = 1.0
list_var = [3, 'hello']
dict_var = {'myField': 'value'}
aot_var = [dictVar, dictVar]
int_var = 1 |
# Python3 program to print
# given matrix in spiral form
def spiralPrint(m, n, a):
start_row_index = 0
start_col_index = 0
l = 0
''' start_row_index - starting row index
m - ending row index
start_col_index - starting column index
n - ending column index
i - iterator '''
while (start... | def spiral_print(m, n, a):
start_row_index = 0
start_col_index = 0
l = 0
' start_row_index - starting row index \n\t\tm - ending row index \n\t\tstart_col_index - starting column index \n\t\tn - ending column index \n\t\ti - iterator '
while start_row_index < m and start_col_index < n:
for i... |
# configs for the model training
class model_training_configs:
VALIDATION_ERRORS_DIRECTORY = 'results/validation_errors/'
INFO_FREQ = 1
# configs for the model testing
class model_testing_configs:
RNN_FORECASTS_DIRECTORY = 'results/rnn_forecasts/'
RNN_ERRORS_DIRECTORY = 'results/errors'
PROCESSED_R... | class Model_Training_Configs:
validation_errors_directory = 'results/validation_errors/'
info_freq = 1
class Model_Testing_Configs:
rnn_forecasts_directory = 'results/rnn_forecasts/'
rnn_errors_directory = 'results/errors'
processed_rnn_forecasts_directory = '/results/processed_rnn_forecasts/'
cla... |
workdays = float(input())
daily_tips = float(input())
exchange_rate = float(input())
salary = workdays * daily_tips
annual_income = salary * 12 + salary * 2.5
net_income = annual_income - annual_income * 25 / 100
result = net_income / 365 * exchange_rate
print('%.2f' % result)
| workdays = float(input())
daily_tips = float(input())
exchange_rate = float(input())
salary = workdays * daily_tips
annual_income = salary * 12 + salary * 2.5
net_income = annual_income - annual_income * 25 / 100
result = net_income / 365 * exchange_rate
print('%.2f' % result) |
def main():
# Pass a string to show_mammal_info...
show_mammal_info('I am a string')
# The show_mammal_info function accepts an object
# as an argument, and calls its show_species
# and make_sound methods.
def show_mammal_info(creature):
creature.show_species()
creature.make_sound()
# Call th... | def main():
show_mammal_info('I am a string')
def show_mammal_info(creature):
creature.show_species()
creature.make_sound()
main() |
COLOR_BLUE = '\033[0;34m'
COLOR_GREEN = '\033[0;32m'
COLOR_CYAN = '\033[0;36m'
COLOR_RED = '\033[0;31m'
COLOR_PURPLE = '\033[0;35m'
COLOR_BROWN = '\033[0;33m'
COLOR_YELLOW = '\033[1;33m'
COLOR_GRAY = '\033[1;30m'
COLOR_RESET = '\033[0m'
FG_COLORS = [
# COLOR_BLUE,
COLOR_GREEN,
# COLOR_CYAN,
# COLOR_R... | color_blue = '\x1b[0;34m'
color_green = '\x1b[0;32m'
color_cyan = '\x1b[0;36m'
color_red = '\x1b[0;31m'
color_purple = '\x1b[0;35m'
color_brown = '\x1b[0;33m'
color_yellow = '\x1b[1;33m'
color_gray = '\x1b[1;30m'
color_reset = '\x1b[0m'
fg_colors = [COLOR_GREEN]
def next_color(color):
assert color in FG_COLORS
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.