content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Maximum Erasure Value
'''
You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.
Return the maximum score you can get by erasing exactly one subarray.
An array b is called to be a suba... | """
You are given an array of positive integers nums and want to erase a subarray containing unique elements. The score you get by erasing the subarray is equal to the sum of its elements.
Return the maximum score you can get by erasing exactly one subarray.
An array b is called to be a subarray of a if it forms a c... |
# --------------------------------------------------------------
class ModelSimilarity:
'''
Uses a model (e.g. Word2Vec model) to calculate the similarity between two terms.
'''
def __init__( self, model ):
self.model = model
def similarity( self, ranking_i, ranking_j ):
sim = 0.0
pairs = 0
for term_i ... | class Modelsimilarity:
"""
Uses a model (e.g. Word2Vec model) to calculate the similarity between two terms.
"""
def __init__(self, model):
self.model = model
def similarity(self, ranking_i, ranking_j):
sim = 0.0
pairs = 0
for term_i in ranking_i:
for term_j ... |
xs1 = ys[42:
5:
-1]
xs2 = ys[:
2:
3]
xs3 = ys[::
3]
| xs1 = ys[42:5:-1]
xs2 = ys[:2:3]
xs3 = ys[::3] |
class Stack:
topNode = None
class Node:
def __init__(self, value):
self.value = value
self.nextNode = None
def __repr__(self):
return "[{}]".format(self.value)
def __init__(self, iterable):
if len(iterable) != 0:
for k... | class Stack:
top_node = None
class Node:
def __init__(self, value):
self.value = value
self.nextNode = None
def __repr__(self):
return '[{}]'.format(self.value)
def __init__(self, iterable):
if len(iterable) != 0:
for k in iterable:... |
'''
'''
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License");... | """
"""
Test.Summary = 'Testing ATS active timeout'
Test.SkipUnless(Condition.HasCurlFeature('http2'))
ts = Test.MakeATSProcess('ts', select_ports=True, enable_tls=True)
server = Test.MakeOriginServer('server', delay=8)
request_header = {'headers': 'GET /file HTTP/1.1\r\nHost: *\r\n\r\n', 'timestamp': '5678', 'body': '... |
class take_skip:
def __init__(self, step, count):
self.step = step
self.count = count
self.start = 0
self.end = step * count
def __iter__(self):
return self
def __next__(self):
index = self.start
if index >= self.end:
raise StopIteration
... | class Take_Skip:
def __init__(self, step, count):
self.step = step
self.count = count
self.start = 0
self.end = step * count
def __iter__(self):
return self
def __next__(self):
index = self.start
if index >= self.end:
raise StopIteration... |
class Solution:
def longestCommonPrefix(self, strs: List[str]) -> str:
if len(strs) == 0:
return ''
def getCommonPrefix(s1, s2):
result = []
for i in range(min(len(s1), len(s2))):
if s1[i] == s2[i]:
result.append(s1[i])
... | class Solution:
def longest_common_prefix(self, strs: List[str]) -> str:
if len(strs) == 0:
return ''
def get_common_prefix(s1, s2):
result = []
for i in range(min(len(s1), len(s2))):
if s1[i] == s2[i]:
result.append(s1[i])
... |
n = int(input())
a = list(map(int, input().split()))
xor = a[0]
for x in a[1:]:
xor ^= x
ans = print(*[xor ^ x for x in a]) | n = int(input())
a = list(map(int, input().split()))
xor = a[0]
for x in a[1:]:
xor ^= x
ans = print(*[xor ^ x for x in a]) |
class DictTrafo(object):
def __init__(self, trafo_dict=None, prefix=None):
if trafo_dict is None:
trafo_dict = {}
self.trafo_dict = trafo_dict
if type(prefix) is str:
self.prefix = (prefix,)
elif type(prefix) is tuple:
self.prefix = prefix
... | class Dicttrafo(object):
def __init__(self, trafo_dict=None, prefix=None):
if trafo_dict is None:
trafo_dict = {}
self.trafo_dict = trafo_dict
if type(prefix) is str:
self.prefix = (prefix,)
elif type(prefix) is tuple:
self.prefix = prefix
... |
filename = 'full_text_small.txt'
def file_write(filename):
with open(filename, 'r') as f:
n = 0
for line in f:
n += 1
if n <= 5:
print(line)
return(line)
file_write(filename)
| filename = 'full_text_small.txt'
def file_write(filename):
with open(filename, 'r') as f:
n = 0
for line in f:
n += 1
if n <= 5:
print(line)
return line
file_write(filename) |
a = 1
b = 0
c = a & b
d = a | b
e = a ^ b
print(c+d+e)
my_list = [[1,2,3,4] for i in range(2)]
print(my_list[1][0])
x =2
x = x==x
print(x)
my_list = [1,2,3]
for v in range(len(my_list)):
my_list.insert(1, my_list[v])
print(my_list) | a = 1
b = 0
c = a & b
d = a | b
e = a ^ b
print(c + d + e)
my_list = [[1, 2, 3, 4] for i in range(2)]
print(my_list[1][0])
x = 2
x = x == x
print(x)
my_list = [1, 2, 3]
for v in range(len(my_list)):
my_list.insert(1, my_list[v])
print(my_list) |
n = int(input())
ans = 0
for i in range(n):
l, c = map(int, input().split())
if l > c:
ans += c
else:
continue
print(ans) | n = int(input())
ans = 0
for i in range(n):
(l, c) = map(int, input().split())
if l > c:
ans += c
else:
continue
print(ans) |
_base_ = [
'../_base_/models/faster_rcnn_r50_fpn_moco.py',
'../_base_/datasets/vocdataset_voc0712.py',
'../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py'
]
optimizer = dict(type='SGD', lr=0.02/16, momentum=0.9, weight_decay=0.0001) | _base_ = ['../_base_/models/faster_rcnn_r50_fpn_moco.py', '../_base_/datasets/vocdataset_voc0712.py', '../_base_/schedules/schedule_1x.py', '../_base_/default_runtime.py']
optimizer = dict(type='SGD', lr=0.02 / 16, momentum=0.9, weight_decay=0.0001) |
_base_ = ['./mswin_par_small_patch4_512x512_160k_ade20k_pretrain_224x224_1K.py']
model = dict(
decode_head=dict(
mode='seq',
))
data = dict(samples_per_gpu=10)
| _base_ = ['./mswin_par_small_patch4_512x512_160k_ade20k_pretrain_224x224_1K.py']
model = dict(decode_head=dict(mode='seq'))
data = dict(samples_per_gpu=10) |
def merge_sort(arr):
n = len(arr)
if (n >= 2):
A = merge_sort(arr[:int(n/2)])
B = merge_sort(arr[int(n/2):])
i = 0
j = 0
for k in range(0, n):
if i < int(n/2) and (j == len(B) or A[i] <= B[j]):
arr[k] = A[i]
i = i + 1
... | def merge_sort(arr):
n = len(arr)
if n >= 2:
a = merge_sort(arr[:int(n / 2)])
b = merge_sort(arr[int(n / 2):])
i = 0
j = 0
for k in range(0, n):
if i < int(n / 2) and (j == len(B) or A[i] <= B[j]):
arr[k] = A[i]
i = i + 1
... |
# --------------
# Code starts here
class_1 = ['Geoffrey Hinton','Andrew Ng','Sebastian Raschka','Yoshua Bengio']
class_2 = ['Hilary Mason','Carla Gentry','Corinna Cortes']
new_class = class_1 + class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_class)
... | class_1 = ['Geoffrey Hinton', 'Andrew Ng', 'Sebastian Raschka', 'Yoshua Bengio']
class_2 = ['Hilary Mason', 'Carla Gentry', 'Corinna Cortes']
new_class = class_1 + class_2
print(new_class)
new_class.append('Peter Warden')
print(new_class)
new_class.remove('Carla Gentry')
print(new_class)
courses = {'Math': 65, 'English... |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( x , y , z ) :
if ( not ( y / x ) ) :
return y if ( not ( y / z ) ) else z
return x if ( not ( x / z... | def f_gold(x, y, z):
if not y / x:
return y if not y / z else z
return x if not x / z else z
if __name__ == '__main__':
param = [(48, 63, 56), (11, 55, 84), (50, 89, 96), (21, 71, 74), (94, 39, 42), (22, 44, 86), (3, 41, 68), (67, 62, 94), (59, 2, 83), (50, 11, 1)]
n_success = 0
for (i, para... |
config = {
'lr': (1.5395901937079718e-05, 4.252664987376195e-05, 9.011700881717918e-05, 0.00026653695086486183),
'target_stepsize': 0.07688144983085089,
'feedback_wd': 5.751527315358352e-07,
'beta1': 0.9,
'beta2': 0.999,
'epsilon': (7.952762675272583e-06, 3.573159556208438e-06, 1.0425400798717413e-08, 2.023264400953111... | config = {'lr': (1.5395901937079718e-05, 4.252664987376195e-05, 9.011700881717918e-05, 0.00026653695086486183), 'target_stepsize': 0.07688144983085089, 'feedback_wd': 5.751527315358352e-07, 'beta1': 0.9, 'beta2': 0.999, 'epsilon': (7.952762675272583e-06, 3.573159556208438e-06, 1.0425400798717413e-08, 2.0232644009531115... |
# constants related to the matchers
# all the types of matches
MATCH_TYPE_NONE = 0
MATCH_TYPE_RESET = 1
MATCH_TYPE_NMI = 2
MATCH_TYPE_WAIT_START = 3
MATCH_TYPE_WAIT_END = 4
MATCH_TYPE_BITS = 6 # number of bits required to represent the above (max 8)
NUM_MATCHERS = 32 # how many match engines are there?
MATCHER_BITS ... | match_type_none = 0
match_type_reset = 1
match_type_nmi = 2
match_type_wait_start = 3
match_type_wait_end = 4
match_type_bits = 6
num_matchers = 32
matcher_bits = 5 |
def get_initial(name, force_uppercase=True):
if force_uppercase:
initial = name[0:1].upper()
else:
initial = name[0:1].lower()
return initial
first_name = input('Enter your first name: ')
# initial = get_initial(first_name)
initial = get_initial(force_uppercase=False, name=first_name)
prin... | def get_initial(name, force_uppercase=True):
if force_uppercase:
initial = name[0:1].upper()
else:
initial = name[0:1].lower()
return initial
first_name = input('Enter your first name: ')
initial = get_initial(force_uppercase=False, name=first_name)
print('Your initial is: ' + initial) |
INPUT_PATH = "./input.txt"
input_file = open(INPUT_PATH, "r")
lines = input_file.readlines()
input_file.close()
divided_input = [[[set(x) for x in x.split()] for x in line.split(" | ")] for line in lines]
# Part 1
print("Part 1: ", sum([len([x for x in entry[1] if len(x) in [2, 3, 4, 7]]) for entry in divided_input... | input_path = './input.txt'
input_file = open(INPUT_PATH, 'r')
lines = input_file.readlines()
input_file.close()
divided_input = [[[set(x) for x in x.split()] for x in line.split(' | ')] for line in lines]
print('Part 1: ', sum([len([x for x in entry[1] if len(x) in [2, 3, 4, 7]]) for entry in divided_input]))
total_sum... |
#Python Lists
mylist = [ "banana", "abacate", "manga"]
print(mylist) | mylist = ['banana', 'abacate', 'manga']
print(mylist) |
# working on final project to combine all the learnt concepts into 1
# problem statement.
#The CTO wants to monitor all the computer usage by all engineers. Using Python ,
# write an automation script that will produce a report when each user logged in and out,
# and how long each user used the computers.
# writing ... | def get_event_date(event):
return event.date
def get_event_date(event):
return event.date
def get_event_date(event):
return event.date
def current_users(events):
events.sort(key=get_event_date)
machines = {}
for event in events:
if event.machine not in machines:
machines[e... |
class RockartExamplesException(Exception):
pass
class RockartExamplesIndexError(RockartExamplesException, IndexError):
pass
class RockartExamplesValueError(RockartExamplesException, ValueError):
pass
| class Rockartexamplesexception(Exception):
pass
class Rockartexamplesindexerror(RockartExamplesException, IndexError):
pass
class Rockartexamplesvalueerror(RockartExamplesException, ValueError):
pass |
print("Kinjal Raykarmakar\nSec: CSE2H\tRoll: 29\n")
row = int(input("Enter the number of rows: "))
for i in range(1, row+1):
for j in range(i):
print("*", end=" ")
print()
for i in range(row+1, 0, -1):
for j in range(i):
print("*", end=" ")
print() | print('Kinjal Raykarmakar\nSec: CSE2H\tRoll: 29\n')
row = int(input('Enter the number of rows: '))
for i in range(1, row + 1):
for j in range(i):
print('*', end=' ')
print()
for i in range(row + 1, 0, -1):
for j in range(i):
print('*', end=' ')
print() |
#!/usr/bin/env python3
for hour_offset in range(0, 24, 6):
train = open('data/train_b{:02}.csv'.format(hour_offset), 'w', newline='')
test = open('data/test_b{:02}.csv'.format(hour_offset), 'w', newline='')
data = open('data/data.txt')
t = int(next(data))
n, m = tuple(map(int, next(data).split()))... | for hour_offset in range(0, 24, 6):
train = open('data/train_b{:02}.csv'.format(hour_offset), 'w', newline='')
test = open('data/test_b{:02}.csv'.format(hour_offset), 'w', newline='')
data = open('data/data.txt')
t = int(next(data))
(n, m) = tuple(map(int, next(data).split()))
for (line_num, lin... |
p = [1,2,3,4,5,6,7,8,9]
del p[1:3]
print(p[:])
p.remove(8)
print(p[:])
print(p.pop())
p.clear()
print(p[:])
l=[1,3,4,5,6,7]
l.remove(3)
print(l[:])
l.sort()
print(l[:])
l.reverse()
print(l[:])
l.clear()
print(l[:])
| p = [1, 2, 3, 4, 5, 6, 7, 8, 9]
del p[1:3]
print(p[:])
p.remove(8)
print(p[:])
print(p.pop())
p.clear()
print(p[:])
l = [1, 3, 4, 5, 6, 7]
l.remove(3)
print(l[:])
l.sort()
print(l[:])
l.reverse()
print(l[:])
l.clear()
print(l[:]) |
# -*- coding: utf-8 -*-
CSRF_ENABLED = True
SECRET_KEY = "208h3oiushefo9823liukhso8dyfhsdklihf"
debug = False
| csrf_enabled = True
secret_key = '208h3oiushefo9823liukhso8dyfhsdklihf'
debug = False |
def getLate():
v = Late(**{})
return v
class Late():
value = 'late'
| def get_late():
v = late(**{})
return v
class Late:
value = 'late' |
formatter = "{} {} {} {}"
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format(
"I had this thing.",
"That you could type up right."... | formatter = '{} {} {} {}'
print(formatter.format(1, 2, 3, 4))
print(formatter.format('one', 'two', 'three', 'four'))
print(formatter.format(True, False, False, True))
print(formatter.format(formatter, formatter, formatter, formatter))
print(formatter.format('I had this thing.', 'That you could type up right.', "But it ... |
# Copyright 2014 PDFium authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Original code from V8, original license was:
# Copyright 2014 the V8 project authors. All rights reserved.
# Use of this source code is governed by a BSD-style ... | {'targets': [{'target_name': 'gtest', 'toolsets': ['host', 'target'], 'type': 'static_library', 'sources': ['gtest/include/gtest/gtest-death-test.h', 'gtest/include/gtest/gtest-message.h', 'gtest/include/gtest/gtest-param-test.h', 'gtest/include/gtest/gtest-printers.h', 'gtest/include/gtest/gtest-spi.h', 'gtest/include... |
activate_mse = 1
activate_adaptation_imp = 1
activate_adaptation_d1 = 1
weight_d2 = 1.0
weight_mse = 1.0
refinement = 1
n_epochs_refinement = 10
lambda_regul = [0.01]
lambda_regul_s = [0.01]
threshold_value = [0.95]
compute_variance = False
random_seed = [1985] if not compute_variance else [1985, 2184, 51, 12, 465]
... | activate_mse = 1
activate_adaptation_imp = 1
activate_adaptation_d1 = 1
weight_d2 = 1.0
weight_mse = 1.0
refinement = 1
n_epochs_refinement = 10
lambda_regul = [0.01]
lambda_regul_s = [0.01]
threshold_value = [0.95]
compute_variance = False
random_seed = [1985] if not compute_variance else [1985, 2184, 51, 12, 465]
cl... |
# flopy version file automatically created using...pre-commit.py
# created on...March 20, 2018 17:03:11
major = 3
minor = 2
micro = 9
build = 60
commit = 2731
__version__ = '{:d}.{:d}.{:d}'.format(major, minor, micro)
__build__ = '{:d}.{:d}.{:d}.{:d}'.format(major, minor, micro, build)
__git_commit__ = '{:d}'.format(... | major = 3
minor = 2
micro = 9
build = 60
commit = 2731
__version__ = '{:d}.{:d}.{:d}'.format(major, minor, micro)
__build__ = '{:d}.{:d}.{:d}.{:d}'.format(major, minor, micro, build)
__git_commit__ = '{:d}'.format(commit) |
#!/usr/bin/env python3
def main():
with open("dnsservers.txt", "r") as dnsfile:
for svr in dnsfile:
svr = svr.rstrip('\n') # remove newline char if exists
# would exists on all but last line
# IF the string svr ends with 'org'
if svr.endswith('org'):
... | def main():
with open('dnsservers.txt', 'r') as dnsfile:
for svr in dnsfile:
svr = svr.rstrip('\n')
if svr.endswith('org'):
with open('org-domain.txt', 'a') as srvfile:
srvfile.write(svr + '\n')
elif svr.endswith('com'):
... |
a, b = map(int, input('').split(' '))
n = int(input(''))
ans = 0
for i in range(n):
shop = [int(i) for i in input('').split(' ') if abs(int(i)) == a or b]
if shop.count(a) > shop.count(-a) and shop.count(b) > shop.count(-b):
ans += 1
print(ans) | (a, b) = map(int, input('').split(' '))
n = int(input(''))
ans = 0
for i in range(n):
shop = [int(i) for i in input('').split(' ') if abs(int(i)) == a or b]
if shop.count(a) > shop.count(-a) and shop.count(b) > shop.count(-b):
ans += 1
print(ans) |
# Break Statement :
greetings = ["Hello","World","!!!"]
for x in greetings:
print(x)
if (x == "World"):
break #Breaks the loop when condition matches
print()
for x in range (0,22,2):
if (x == 10):
continue #Skips the current iteration when condition matches
print(x)... | greetings = ['Hello', 'World', '!!!']
for x in greetings:
print(x)
if x == 'World':
break
print()
for x in range(0, 22, 2):
if x == 10:
continue
print(x)
input('Press Enter key to exit ') |
HOST = '127.0.0.1'
USERNAME = 'guest'
PASSWORD = 'guest'
URI = 'amqp://guest:guest@127.0.0.1:5672/%2F'
HTTP_URL = 'http://127.0.0.1:15672'
| host = '127.0.0.1'
username = 'guest'
password = 'guest'
uri = 'amqp://guest:guest@127.0.0.1:5672/%2F'
http_url = 'http://127.0.0.1:15672' |
load("@bazel_skylib//lib:paths.bzl", "paths")
def _add_data_impl(ctx):
(_, extension) = paths.split_extension(ctx.executable.executable.path)
executable = ctx.actions.declare_file(
ctx.label.name + extension,
)
ctx.actions.symlink(
output = executable,
target_file = ctx.executab... | load('@bazel_skylib//lib:paths.bzl', 'paths')
def _add_data_impl(ctx):
(_, extension) = paths.split_extension(ctx.executable.executable.path)
executable = ctx.actions.declare_file(ctx.label.name + extension)
ctx.actions.symlink(output=executable, target_file=ctx.executable.executable, is_executable=True)
... |
#What will this script produce?
#A: 3
a = 1
a = 2
a = 3
print(a)
| a = 1
a = 2
a = 3
print(a) |
#addintersert3.py
def addInterest(balances, rate):
for i in range(len(balances)):
balances[i] = balances[i] * (1 + rate)
def main():
amounts = [1000, 105, 3500, 739]
rate = 0.05
addInterest(amounts, rate)
print(amounts)
main() | def add_interest(balances, rate):
for i in range(len(balances)):
balances[i] = balances[i] * (1 + rate)
def main():
amounts = [1000, 105, 3500, 739]
rate = 0.05
add_interest(amounts, rate)
print(amounts)
main() |
# INTERNAL_ONLY_PROPERTIES defines the properties in the config that, while settable, should
# not be documented for external users. These will generally be used for internal test or only
# given to customers when they have been briefed on the side effects of using them.
INTERNAL_ONLY_PROPERTIES = {
"__module__",
... | internal_only_properties = {'__module__', '__doc__', 'create_transaction', 'SESSION_COOKIE_NAME', 'SESSION_COOKIE_HTTPONLY', 'SESSION_COOKIE_SAMESITE', 'DATABASE_SECRET_KEY', 'V22_NAMESPACE_BLACKLIST', 'MAXIMUM_CNR_LAYER_SIZE', 'OCI_NAMESPACE_WHITELIST', 'FEATURE_GENERAL_OCI_SUPPORT', 'FEATURE_HELM_OCI_SUPPORT', 'FEATU... |
# example file for submodule imports
def divide_me_by_2(x):
return x/2
| def divide_me_by_2(x):
return x / 2 |
class Solution:
def connect(self, root):
nodes = [[root], []]
x = 0
while (nodes[0] and nodes[0][0]) or (nodes[1] and nodes[1][0]):
for i in range(len(nodes[x])):
nodes[x][i].next = None if i == len(nodes[x]) - 1 else nodes[x][i+1]
nodes[(1 + x) % ... | class Solution:
def connect(self, root):
nodes = [[root], []]
x = 0
while nodes[0] and nodes[0][0] or (nodes[1] and nodes[1][0]):
for i in range(len(nodes[x])):
nodes[x][i].next = None if i == len(nodes[x]) - 1 else nodes[x][i + 1]
nodes[(1 + x) %... |
CELERY_TIMEZONE = 'Europe/Rome'
# The backend used to store task results
CELERY_RESULT_BACKEND = 'rpc://'
# If set to True, result messages will be persistent. This means the messages will not be lost after a broker restart
CELERY_RESULT_PERSISTENT = True
CELERY_ACCEPT_CONTENT=['json', 'pickle']
CELERY_TASK_SERIALI... | celery_timezone = 'Europe/Rome'
celery_result_backend = 'rpc://'
celery_result_persistent = True
celery_accept_content = ['json', 'pickle']
celery_task_serializer = 'json'
celery_result_serializer = 'json'
broker_url = 'amqp://guest:guest@localhost:5672//'
broker_heartbeat = 10.0
broker_heartbeat_checkrate = 2.0
celery... |
# colorcodingfor rows(...)
def colornumber(color):
if color == 'd':
return 0
elif color == 'e':
return 1
elif color == 'f':
return 2
elif color == 'g':
return 3
elif color == 'h':
return 4
elif color == 'i':
return 5
elif color ==... | def colornumber(color):
if color == 'd':
return 0
elif color == 'e':
return 1
elif color == 'f':
return 2
elif color == 'g':
return 3
elif color == 'h':
return 4
elif color == 'i':
return 5
elif color == 'j':
return 6
elif color == ... |
[
{
'date': '2018-01-01',
'description': "New Year's Day",
'locale': 'en-US',
'notes': '',
'region': '',
'type': 'NF'
},
{
'date': '2018-01-15',
'description': 'Birthday of Martin Luther King, Jr.',
'locale': 'en-US',
'notes': '... | [{'date': '2018-01-01', 'description': "New Year's Day", 'locale': 'en-US', 'notes': '', 'region': '', 'type': 'NF'}, {'date': '2018-01-15', 'description': 'Birthday of Martin Luther King, Jr.', 'locale': 'en-US', 'notes': '', 'region': '', 'type': 'NV'}, {'date': '2018-02-19', 'description': "Washington's Birthday", '... |
# A function to get the desired metrics while working with multiple model training procedures
def print_classification_metrics(y_train, train_pred, y_test, test_pred, return_performance=True):
dict_performance = {'Training Accuracy: ': accuracy_score(y_train, train_pred),
'Training f1-score:... | def print_classification_metrics(y_train, train_pred, y_test, test_pred, return_performance=True):
dict_performance = {'Training Accuracy: ': accuracy_score(y_train, train_pred), 'Training f1-score: ': f1_score(y_train, train_pred), 'Accuracy: ': accuracy_score(y_test, test_pred), 'Precision: ': precision_score(y_t... |
#!/usr/bin/env python
def part_one(values: list[int]) -> int:
count = sum(values[index] < values[index + 1] for index in range(len(values) - 1))
return count
def part_two(values: list[int]) -> int:
summed_list = list(sum(three) for three in zip(values, values[1:], values[2:]))
count = sum(summed_list... | def part_one(values: list[int]) -> int:
count = sum((values[index] < values[index + 1] for index in range(len(values) - 1)))
return count
def part_two(values: list[int]) -> int:
summed_list = list((sum(three) for three in zip(values, values[1:], values[2:])))
count = sum((summed_list[index] < summed_li... |
# Usage: gunicorn ProductCatalog.wsgi --bind 0.0.0.0:$PORT --config deploy/gunicorn.conf.py
# Max number of pending connections.
backlog = 1024
# Number of workers spawned for request handling.
workers = 1
# Standard type of workers.
worker_class = 'sync'
# Kill worker if it does not notify the master process in this ... | backlog = 1024
workers = 1
worker_class = 'sync'
timeout = 30
logfile = '/var/log/productcatalog-gunicorn.log'
loglevel = 'info' |
# NOTE: This objects are used directly in the external-notification-data and vulnerability-service
# on the frontend, so be careful with changing their existing keys.
PRIORITY_LEVELS = {
"Unknown": {
"title": "Unknown",
"value": "Unknown",
"index": 5,
"level": "info",
"color"... | priority_levels = {'Unknown': {'title': 'Unknown', 'value': 'Unknown', 'index': 5, 'level': 'info', 'color': '#9B9B9B', 'score': 0, 'description': 'Unknown is either a security problem that has not been assigned to a priority' + ' yet or a priority that our system did not recognize', 'banner_required': False}, 'Negligi... |
class solution:
def findNumbers(self, nums=[]):
even = 0
for num in nums:
numString = str(num)
if len(numString) % 2 == 0:
even += 1
return even
if __name__ == "__main__":
sol = solution()
_ = [int(n) for n in input().split()]
print(sol.fin... | class Solution:
def find_numbers(self, nums=[]):
even = 0
for num in nums:
num_string = str(num)
if len(numString) % 2 == 0:
even += 1
return even
if __name__ == '__main__':
sol = solution()
_ = [int(n) for n in input().split()]
print(sol.... |
pressure_arr = [80, 90, 100, 150, 120, 110, 160, 110, 100]
sum = 0
for pressure in pressure_arr:
sum = pressure + sum
length = len(pressure_arr)
mean = sum / length
print("The mean is", mean)
| pressure_arr = [80, 90, 100, 150, 120, 110, 160, 110, 100]
sum = 0
for pressure in pressure_arr:
sum = pressure + sum
length = len(pressure_arr)
mean = sum / length
print('The mean is', mean) |
n = int(input())
families = map(int, input().split())
families = sorted(families)
for i in range(len(families)):
if(i!=len(families)-1):
if(families[i]!=families[i - 1] and families[i]!=families[i + 1]):
print(families[i])
break
else:
print(families[i])
| n = int(input())
families = map(int, input().split())
families = sorted(families)
for i in range(len(families)):
if i != len(families) - 1:
if families[i] != families[i - 1] and families[i] != families[i + 1]:
print(families[i])
break
else:
print(families[i]) |
class Solution:
def expand(self, S: str) -> List[str]:
return sorted(self.dfs(S, ['']))
def dfs(self, s, prev):
if not s:
return prev
n = len(s)
cur = ''
found = False
result = []
for i in range(n):
if s[i].is... | class Solution:
def expand(self, S: str) -> List[str]:
return sorted(self.dfs(S, ['']))
def dfs(self, s, prev):
if not s:
return prev
n = len(s)
cur = ''
found = False
result = []
for i in range(n):
if s[i].isalpha():
... |
def translate(data, char, replacement):
result = data.replace(char, replacement)
print(result)
return result
def includes(data, string):
if string in data:
return True
return False
def start(data, string):
counter = 0
is_it = False
for char in string:
if char == data[cou... | def translate(data, char, replacement):
result = data.replace(char, replacement)
print(result)
return result
def includes(data, string):
if string in data:
return True
return False
def start(data, string):
counter = 0
is_it = False
for char in string:
if char == data[co... |
L = 25
with open('input') as f:
nums = list(map(int, f.read().split()))
# Part 1
for i in range(L, len(nums)):
pre = nums[i - L:i]
n = nums[i]
d = {}
for p in pre:
if p in d and p != d[p]:
break
d[n - p] = p
else:
print(n)
break
# Part 2
i = 0
j = 2... | l = 25
with open('input') as f:
nums = list(map(int, f.read().split()))
for i in range(L, len(nums)):
pre = nums[i - L:i]
n = nums[i]
d = {}
for p in pre:
if p in d and p != d[p]:
break
d[n - p] = p
else:
print(n)
break
i = 0
j = 2
while j < len(nums):... |
class UnexpectedMode(ValueError):
def __init__(self, mode: str) -> None:
super().__init__(
f"Unexpected mode - found '{mode}' but must be 'image' or 'mesh'"
)
| class Unexpectedmode(ValueError):
def __init__(self, mode: str) -> None:
super().__init__(f"Unexpected mode - found '{mode}' but must be 'image' or 'mesh'") |
# Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project au... | {'includes': ['../../../../../../common_settings.gypi'], 'targets': [{'target_name': 'iLBC', 'type': '<(library)', 'dependencies': ['../../../../../../common_audio/signal_processing_library/main/source/spl.gyp:spl'], 'include_dirs': ['../interface'], 'direct_dependent_settings': {'include_dirs': ['../interface']}, 'sou... |
# generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/lzh/racecar_ws/devel/include;/home/lzh/racecar_ws/src/navigation-melodic-devel/dwa_local_planner/include".split(';') if "/home/lzh/racecar_ws/devel/include;/home/lzh/racecar_ws/src/navigation-mel... | catkin_package_prefix = ''
project_pkg_config_include_dirs = '/home/lzh/racecar_ws/devel/include;/home/lzh/racecar_ws/src/navigation-melodic-devel/dwa_local_planner/include'.split(';') if '/home/lzh/racecar_ws/devel/include;/home/lzh/racecar_ws/src/navigation-melodic-devel/dwa_local_planner/include' != '' else []
proje... |
nome = input("Digite seu nome ").strip().lower()
confirmacao = 'silva' in nome
print(f"Seu nome tem silva {confirmacao}") | nome = input('Digite seu nome ').strip().lower()
confirmacao = 'silva' in nome
print(f'Seu nome tem silva {confirmacao}') |
# *****************************
# Environment specific settings
# *****************************
# DO NOT use "DEBUG = True" in production environments
DEBUG = True
# DO NOT use Unsecure Secrets in production environments
# Generate a safe one with:
# python -c "import os; print repr(os.urandom(24));"
... | debug = True
secret_key = 'This is an UNSECURE Secret. CHANGE THIS for production environments.'
sqlalchemy_database_uri = 'sqlite:///../app.sqlite'
sqlalchemy_track_modifications = False |
# coding: utf-8
# # Functions (1) - Creating Functions
# In this lesson we're going to learn about functions in Python. Functions are an important tool when programming and their use can be very complex. It's not the aim of this course to teach you how to implement functional programming, instead, this lesson will g... | def test_function():
print('This is a function')
test_function()
len('abcdefg')
def test_function2(item1, item2):
print('The first item is: ' + str(item1) + ', the second item is: ' + str(item2))
test_function2('abc', 20)
test_function2('howdy', 'partner')
def alternate_list(item1, item2, repeats):
altern... |
stack = []
stack.append('a')
stack.append('b')
stack.append('c')
print('Initial stack')
print(stack)
print('\nElements poped from stack:')
print(stack.pop())
print(stack.pop())
print(stack.pop())
print('\nStack after elements are poped:')
print(stack)
| stack = []
stack.append('a')
stack.append('b')
stack.append('c')
print('Initial stack')
print(stack)
print('\nElements poped from stack:')
print(stack.pop())
print(stack.pop())
print(stack.pop())
print('\nStack after elements are poped:')
print(stack) |
def findLongestSubSeq(str):
n = len(str)
dp = [[0 for k in range(n+1)] for l in range(n+1)]
for i in range(1, n+1):
for j in range(1, n+1):
# If characters match and indices are not same
if (str[i-1] == str[j-1] and i != j):
dp[i][j] = 1 + dp[i-1][j-1]
# If characters do not match
else:... | def find_longest_sub_seq(str):
n = len(str)
dp = [[0 for k in range(n + 1)] for l in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, n + 1):
if str[i - 1] == str[j - 1] and i != j:
dp[i][j] = 1 + dp[i - 1][j - 1]
else:
dp[i][j] = max(... |
@singleton
class Database:
def __init__(self):
print('Loading database')
| @singleton
class Database:
def __init__(self):
print('Loading database') |
#!/usr/bin/env python3
def get_case_data():
return [int(i) for i in input().split()]
# Using recursive implementation
def get_gcd(a, b):
return get_gcd(b, a % b) if b != 0 else a
def print_number_or_ok_if_equals(number, guess):
print("OK" if number == guess else number)
number_of_cases = int(input())
for case in... | def get_case_data():
return [int(i) for i in input().split()]
def get_gcd(a, b):
return get_gcd(b, a % b) if b != 0 else a
def print_number_or_ok_if_equals(number, guess):
print('OK' if number == guess else number)
number_of_cases = int(input())
for case in range(number_of_cases):
(first_integer, seco... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def verticalTraversal(self, root: TreeNode) -> List[List[int]]:
res = defaultdict(list)
q = ... | class Solution:
def vertical_traversal(self, root: TreeNode) -> List[List[int]]:
res = defaultdict(list)
q = [(root, 0)]
min_col = max_col = 0
while q:
q.sort(key=lambda x: (x[1], x[0].val))
min_col = min(min_col, q[0][1])
max_col = max(max_col, q... |
# -*- coding: utf-8 -*-
def main():
s = input()
mod = ''
for i in range(3):
if s[i] == '1':
mod += '9'
elif s[i] == '9':
mod += '1'
print(mod)
if __name__ == '__main__':
main()
| def main():
s = input()
mod = ''
for i in range(3):
if s[i] == '1':
mod += '9'
elif s[i] == '9':
mod += '1'
print(mod)
if __name__ == '__main__':
main() |
class Node:
def __init__(self,data):
self.data=data
self.next=None
arr=[5,8,20]
brr=[4,11,15]
#inserting elements in first list
list1=Node(arr[0])
root1=list1
for i in arr[1::]:
temp=Node(i)
list1.next=temp
list1=list1.next
#inserting elements in second list
lis... | class Node:
def __init__(self, data):
self.data = data
self.next = None
arr = [5, 8, 20]
brr = [4, 11, 15]
list1 = node(arr[0])
root1 = list1
for i in arr[1:]:
temp = node(i)
list1.next = temp
list1 = list1.next
list2 = node(brr[0])
root2 = list2
for i in brr[1:]:
temp = node(i)
... |
# Write your solution for 1.4 here!
def is_prime(x):
if x > 1:
for i in range(2,x):
if (x % i) == 0:
print(x,"is not a prime number")
print(i,"times",x//i,"is",x)
else:
print(x,"is not a prime number")
is_prime(5)
| def is_prime(x):
if x > 1:
for i in range(2, x):
if x % i == 0:
print(x, 'is not a prime number')
print(i, 'times', x // i, 'is', x)
else:
print(x, 'is not a prime number')
is_prime(5) |
if __name__ == "__main__":
print((lambda x,r : [r:=r+1 for i in x.split('\n\n') if all(map(lambda x : x in i,['byr','iyr','eyr','hgt','hcl','ecl','pid']))][-1])(open("i").read(),0))
def main_debug(inp): # 204
inp = inp.split('\n\n')
rep = 0
for i in inp:
if all(map(lambda x : x in i,['byr','iyr... | if __name__ == '__main__':
print((lambda x, r: [(r := (r + 1)) for i in x.split('\n\n') if all(map(lambda x: x in i, ['byr', 'iyr', 'eyr', 'hgt', 'hcl', 'ecl', 'pid']))][-1])(open('i').read(), 0))
def main_debug(inp):
inp = inp.split('\n\n')
rep = 0
for i in inp:
if all(map(lambda x: x in i, ['... |
def flatten(iterable, result=None):
if result == None:
result = []
for it in iterable:
if type(it) in (list, set, tuple):
flatten(it, result)
else:
result.append(it)
return [i for i in result if i is not None]
| def flatten(iterable, result=None):
if result == None:
result = []
for it in iterable:
if type(it) in (list, set, tuple):
flatten(it, result)
else:
result.append(it)
return [i for i in result if i is not None] |
def palindromo(palavra: str) -> bool:
if len(palavra) <= 1:
return True
primeira_letra = palavra[0]
ultima_letra = palavra[-1]
if primeira_letra != ultima_letra:
return False
return palindromo(palavra[1:-1])
nome_do_arquivo = input('Digite o nome do entrada de entrada: ')
with open... | def palindromo(palavra: str) -> bool:
if len(palavra) <= 1:
return True
primeira_letra = palavra[0]
ultima_letra = palavra[-1]
if primeira_letra != ultima_letra:
return False
return palindromo(palavra[1:-1])
nome_do_arquivo = input('Digite o nome do entrada de entrada: ')
with open(n... |
def main():
isNumber = False
while not isNumber:
try:
size = int(input('Height: '))
if size > 0 and size <= 8:
isNumber = True
break
except ValueError:
isNumber = False
build(size, size)
def build(size, counter):
sp... | def main():
is_number = False
while not isNumber:
try:
size = int(input('Height: '))
if size > 0 and size <= 8:
is_number = True
break
except ValueError:
is_number = False
build(size, size)
def build(size, counter):
spa... |
#URLs
ROOTURL = 'https://www.reuters.com/companies/'
FXRATESURL = 'https://www.reuters.com/markets/currencies'
#ADDURLs
INCSTAT_ANN_URL = '/financials/income-statement-annual/'
INCSTAT_QRT_URL = '/financials/income-statement-quarterly/'
BS_ANN_URL = '/financials/balance-sheet-annual/'
BS_QRT_URL = '/financials/balance... | rooturl = 'https://www.reuters.com/companies/'
fxratesurl = 'https://www.reuters.com/markets/currencies'
incstat_ann_url = '/financials/income-statement-annual/'
incstat_qrt_url = '/financials/income-statement-quarterly/'
bs_ann_url = '/financials/balance-sheet-annual/'
bs_qrt_url = '/financials/balance-sheet-quarterly... |
DEFAULT_PORT = 9000
DEFAULT_SECURE_PORT = 9440
DBMS_MIN_REVISION_WITH_TEMPORARY_TABLES = 50264
DBMS_MIN_REVISION_WITH_TOTAL_ROWS_IN_PROGRESS = 51554
DBMS_MIN_REVISION_WITH_BLOCK_INFO = 51903
# Legacy above.
DBMS_MIN_REVISION_WITH_CLIENT_INFO = 54032
DBMS_MIN_REVISION_WITH_SERVER_TIMEZONE = 54058
DBMS_MIN_REVISION_WIT... | default_port = 9000
default_secure_port = 9440
dbms_min_revision_with_temporary_tables = 50264
dbms_min_revision_with_total_rows_in_progress = 51554
dbms_min_revision_with_block_info = 51903
dbms_min_revision_with_client_info = 54032
dbms_min_revision_with_server_timezone = 54058
dbms_min_revision_with_quota_key_in_cli... |
input_file = open("input.txt", "r")
entriesArray = input_file.read().split("\n")
depth_measure_increase = 0
for i in range(3, len(entriesArray), 1):
first_window = int(entriesArray[i-1]) + int(entriesArray[i-2]) + int(entriesArray[i-3])
second_window = int(entriesArray[i]) + int(entriesArray[i-1]) + int(entrie... | input_file = open('input.txt', 'r')
entries_array = input_file.read().split('\n')
depth_measure_increase = 0
for i in range(3, len(entriesArray), 1):
first_window = int(entriesArray[i - 1]) + int(entriesArray[i - 2]) + int(entriesArray[i - 3])
second_window = int(entriesArray[i]) + int(entriesArray[i - 1]) + in... |
def multiplicationTable(size):
return [[j*i for j in range(1, size+1)] for i in range(1, size+1)]
x = multiplicationTable(5)
print(x)
print()
for i in x:
print(i)
| def multiplication_table(size):
return [[j * i for j in range(1, size + 1)] for i in range(1, size + 1)]
x = multiplication_table(5)
print(x)
print()
for i in x:
print(i) |
def getFrequencyDictForText(sentence):
fullTermsDict = multidict.MultiDict()
tmpDict = {}
# making dictionary for counting word frequencies
for text in sentence.split(" "):
# remove irrelevant words
if re.match("a|the|an|the|to|in|for|of|or|by|with|is|on|that|but|from|than|be", text):
... | def get_frequency_dict_for_text(sentence):
full_terms_dict = multidict.MultiDict()
tmp_dict = {}
for text in sentence.split(' '):
if re.match('a|the|an|the|to|in|for|of|or|by|with|is|on|that|but|from|than|be', text):
continue
val = tmpDict.get(text, 0)
tmpDict[text.lower(... |
class BoxaugError(Exception):
pass
| class Boxaugerror(Exception):
pass |
# short hand if
a=23
b=4
if a > b: print("a is greater than b")
# short hand if
print("a is greater ") if a > b else print("b is greater ")
#pass statements
b=300
if b > a:
pass
| a = 23
b = 4
if a > b:
print('a is greater than b')
print('a is greater ') if a > b else print('b is greater ')
b = 300
if b > a:
pass |
if args.algo in ['a2c', 'acktr']:
values, action_log_probs, dist_entropy, conv_list = actor_critic.evaluate_actions(Variable(rollouts.states[:-1].view(-1, *obs_shape)), Variable(rollouts.actions.view(-1, action_shape)))
# pre-process
values = values.view(args.num_steps, num_processes_total, 1)
action_lo... | if args.algo in ['a2c', 'acktr']:
(values, action_log_probs, dist_entropy, conv_list) = actor_critic.evaluate_actions(variable(rollouts.states[:-1].view(-1, *obs_shape)), variable(rollouts.actions.view(-1, action_shape)))
values = values.view(args.num_steps, num_processes_total, 1)
action_log_probs = action... |
'''
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Example 1:
Input: [2,2,3,4]
Output: 3
Explanation:
Valid combinations are:
2,3,4 (using the first 2)
2,3,4 (using the second 2)... | """
Given an array consists of non-negative integers, your task is to count the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle.
Example 1:
Input: [2,2,3,4]
Output: 3
Explanation:
Valid combinations are:
2,3,4 (using the first 2)
2,3,4 (using the second 2)... |
a = [0x77, 0x60, 0x76, 0x66, 0x72, 0x77, 0x7D, 0x73, 0x60, 0x3D, 0x64, 0x60, 0x39, 0x52, 0x66, 0x3B, 0x73, 0x7A, 0x23, 0x7D, 0x73, 0x4A, 0x70, 0x78, 0x6A, 0x46, 0x69, 0x2B, 0x76, 0x68, 0x41, 0x77, 0x41, 0x42, 0x49, 0x4A, 0x4A, 0x42, 0x40, 0x48, 0x5A, 0x5A, 0x45, 0x41, 0x59, 0x03, 0x5A, 0x4A, 0x51, 0x5C, 0x4F]
flag = ''... | a = [119, 96, 118, 102, 114, 119, 125, 115, 96, 61, 100, 96, 57, 82, 102, 59, 115, 122, 35, 125, 115, 74, 112, 120, 106, 70, 105, 43, 118, 104, 65, 119, 65, 66, 73, 74, 74, 66, 64, 72, 90, 90, 69, 65, 89, 3, 90, 74, 81, 92, 79]
flag = ''
for i in range(len(a)):
flag += chr(a[i] ^ i)
print(flag) |
# This code is provoded by MDS DSCI 531/532
def mds_special():
font = "Arial"
axisColor = "#000000"
gridColor = "#DEDDDD"
return {
"config": {
"title": {
"fontSize": 24,
"font": font,
"anchor": "star... | def mds_special():
font = 'Arial'
axis_color = '#000000'
grid_color = '#DEDDDD'
return {'config': {'title': {'fontSize': 24, 'font': font, 'anchor': 'start', 'fontColor': '#000000'}, 'view': {'height': 300, 'width': 400}, 'axisX': {'domain': True, 'gridColor': gridColor, 'domainWidth': 1, 'grid': False,... |
# Writing a method
class Shape:
def __init__(self, name, sides, colour=None):
self.name = name
self.sides = sides
self.colour = colour
def get_info(self):
return '{} {} with {} sides'.format(self.colour,
self.name,
... | class Shape:
def __init__(self, name, sides, colour=None):
self.name = name
self.sides = sides
self.colour = colour
def get_info(self):
return '{} {} with {} sides'.format(self.colour, self.name, self.sides)
s = shape('square', 4, 'green')
print(s.get_info())
class Shape:
... |
class Solution:
def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
degree = [0] * n
for u, v in edges:
degree[v] = 1
return [i for i, d in enumerate(degree) if d == 0]
| class Solution:
def find_smallest_set_of_vertices(self, n: int, edges: List[List[int]]) -> List[int]:
degree = [0] * n
for (u, v) in edges:
degree[v] = 1
return [i for (i, d) in enumerate(degree) if d == 0] |
#!/usr/bin/env python
DEBUG = True
SECRET_KEY = 'super-ultra-secret-key'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': ':memory:',
}
}
INSTALLED_APPS = [
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.staticfiles',
'django_ta... | debug = True
secret_key = 'super-ultra-secret-key'
databases = {'default': {'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:'}}
installed_apps = ['django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.staticfiles', 'django_tables2', 'django_tables2_column_shifter', 'django_tables2_column_shifter... |
# classical (x, y) position vectors
class Pos:
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, other):
return(Pos(self.x + other.x, self.y + other.y))
def __eq__(self, other):
return(
(self.x == other.x) and
(self.y == other.y))
def __mul__(self, factor):
return(Pos(factor * sel... | class Pos:
def __init__(self, x, y):
self.x = x
self.y = y
def __add__(self, other):
return pos(self.x + other.x, self.y + other.y)
def __eq__(self, other):
return self.x == other.x and self.y == other.y
def __mul__(self, factor):
return pos(factor * self.x, f... |
# model settings
model = dict(
type='Recognizer3D',
backbone=dict(
type='C3D',
# pretrained= # noqa: E251
# 'https://download.openmmlab.com/mmaction/recognition/c3d/c3d_sports1m_pretrain_20201016-dcc47ddc.pth', # noqa: E501
pretrained= # noqa: E251
'./work_dirs/fatigue... | model = dict(type='Recognizer3D', backbone=dict(type='C3D', pretrained='./work_dirs/fatigue_c3d/c3d_sports1m_pretrain_20201016-dcc47ddc.pth', style='pytorch', conv_cfg=dict(type='Conv3d'), norm_cfg=None, act_cfg=dict(type='ReLU'), dropout_ratio=0.5, init_std=0.005), cls_head=dict(type='I3DHead', num_classes=2, in_chann... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
if root is None:
return... | class Solution:
def lowest_common_ancestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
if root is None:
return None
stack = deque([root])
parent = {root: None}
while stack:
node = stack.pop()
if node.left:
... |
def variance_of_sample_proportion(a,b,c,d,e,f,g,h,j,k):
try:
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)
f = int(f)
g = int(g)
h = int(h)
j = int(j)
k = int(k)
sample = [a,b,c,d,e,f,g,h,j,k]
# Count how many ... | def variance_of_sample_proportion(a, b, c, d, e, f, g, h, j, k):
try:
a = int(a)
b = int(b)
c = int(c)
d = int(d)
e = int(e)
f = int(f)
g = int(g)
h = int(h)
j = int(j)
k = int(k)
sample = [a, b, c, d, e, f, g, h, j, k]
... |
class Stack:
def __init__(self):
self.stack = []
self.current_minimum = float('inf')
def push(self, item):
if not self.stack:
self.stack.append(item)
self.current_minimum = item
else:
if item >= self.current_minimum:
self.stack... | class Stack:
def __init__(self):
self.stack = []
self.current_minimum = float('inf')
def push(self, item):
if not self.stack:
self.stack.append(item)
self.current_minimum = item
elif item >= self.current_minimum:
self.stack.append(item)
... |
# -*- coding: utf-8 -*-
# Return the contents of a file
def load_file(filename):
with open(filename, "r") as f:
return f.read()
# Write contents to a file
def write_file(filename, content):
with open(filename, "w+") as f:
f.write(content)
# Append contents to a file
def append_file(filename, content):
... | def load_file(filename):
with open(filename, 'r') as f:
return f.read()
def write_file(filename, content):
with open(filename, 'w+') as f:
f.write(content)
def append_file(filename, content):
with open(filename, 'a+') as f:
f.write(content) |
def main():
t: tuple[i32, str]
t = (1, 2)
main() | def main():
t: tuple[i32, str]
t = (1, 2)
main() |
# Config
SIZES = {
'basic': 299
}
NUM_CHANNELS = 3
NUM_CLASSES = 2
GENERATOR_BATCH_SIZE = 32
TOTAL_EPOCHS = 50
STEPS_PER_EPOCH = 100
VALIDATION_STEPS = 50
BASE_DIR = 'C:\\Users\\guilo\\mba-tcc\\data\\' | sizes = {'basic': 299}
num_channels = 3
num_classes = 2
generator_batch_size = 32
total_epochs = 50
steps_per_epoch = 100
validation_steps = 50
base_dir = 'C:\\Users\\guilo\\mba-tcc\\data\\' |
def test_split():
assert split(10) == 2
def test_string():
city = "String"
assert type(city) == str
def test_float():
price = 3.45
assert type(price) == float
def test_int():
high_score = 1
assert type(high_score) == int
def test_boolean():
is_having_fun = True
assert type(is... | def test_split():
assert split(10) == 2
def test_string():
city = 'String'
assert type(city) == str
def test_float():
price = 3.45
assert type(price) == float
def test_int():
high_score = 1
assert type(high_score) == int
def test_boolean():
is_having_fun = True
assert type(is_hav... |
A = 'A'
B = 'B'
RULE_ACTION = {
1: 'Suck',
2: 'Right',
3: 'Left',
4: 'NoOp'
}
rules = {
(A, 'Dirty'): 1,
(B, 'Dirty'): 1,
(A, 'Clean'): 2,
(B, 'Clean'): 3,
(A, B, 'Clean'): 4
}
# Ex. rule (if location == A && Dirty then 1)
Environment = {
A: 'Dirty',
B: 'Dirty',
'Curre... | a = 'A'
b = 'B'
rule_action = {1: 'Suck', 2: 'Right', 3: 'Left', 4: 'NoOp'}
rules = {(A, 'Dirty'): 1, (B, 'Dirty'): 1, (A, 'Clean'): 2, (B, 'Clean'): 3, (A, B, 'Clean'): 4}
environment = {A: 'Dirty', B: 'Dirty', 'Current': A}
def interpret_input(input):
return input
def rule_match(state, rules):
rule = rules.... |
def convert(s):
s_split = s.split(' ')
return s_split
def niceprint(s):
for i, elm in enumerate(s):
print('Element #', i + 1, ' = ', elm, sep='')
return None
c1 = 10
c2 = 's'
| def convert(s):
s_split = s.split(' ')
return s_split
def niceprint(s):
for (i, elm) in enumerate(s):
print('Element #', i + 1, ' = ', elm, sep='')
return None
c1 = 10
c2 = 's' |
#
# PySNMP MIB module ASCEND-MIBIPSECSPD-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBIPSECSPD-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:11:32 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (d... | (configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration')
(octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constr... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.