content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class solve_day(object):
with open('inputs/day07.txt', 'r') as f:
data = f.readlines()
# method for NOT operation
def n(self, value):
return 65535 + ~value + 1
def part1(self):
wires = {}
for d in self.data:
d = d.strip()
# print(f'input: \t\... | class Solve_Day(object):
with open('inputs/day07.txt', 'r') as f:
data = f.readlines()
def n(self, value):
return 65535 + ~value + 1
def part1(self):
wires = {}
for d in self.data:
d = d.strip()
try:
operator = [x for x in ['AND', 'OR... |
# Function which adds two numbers
def compute(num1, num2):
return (num1 + num2)
| def compute(num1, num2):
return num1 + num2 |
def majuscule(chaine):
whitelist = "abcdefghijklmnopqrstuvwxyz"
chrs = [chr(ord(c) - 32) if c in whitelist else c for c in chaine]
return "".join(chrs)
print(majuscule("axel coezard"))
def val2ascii(entier):
ch = ""
for i in range(entier):
ch = chr(ord(ch) + 1)
print(ch)
val2ascii(355... | def majuscule(chaine):
whitelist = 'abcdefghijklmnopqrstuvwxyz'
chrs = [chr(ord(c) - 32) if c in whitelist else c for c in chaine]
return ''.join(chrs)
print(majuscule('axel coezard'))
def val2ascii(entier):
ch = ''
for i in range(entier):
ch = chr(ord(ch) + 1)
print(ch)
val2ascii(355) |
class Node(object):
def __init__(self,data):
self.data = data
self.prev = None
self.next = None
class DoubleLinkedList(object):
def __init__(self):
self.head = None
self.tail = None
def prepend(self,data):
node = Node(data)
if not self.head:
... | class Node(object):
def __init__(self, data):
self.data = data
self.prev = None
self.next = None
class Doublelinkedlist(object):
def __init__(self):
self.head = None
self.tail = None
def prepend(self, data):
node = node(data)
if not self.head:
... |
# Copyright [2019] [Christopher Syben, Markus Michen]
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law ... | learning_rate = 1e-05
batch_size_train = 50
num_training_samples = 800
max_train_steps = NUM_TRAINING_SAMPLES // BATCH_SIZE_TRAIN + 1
batch_size_validation = 50
num_validation_samples = 150
max_validation_steps = NUM_VALIDATION_SAMPLES // BATCH_SIZE_VALIDATION
num_test_samples = 1
max_test_steps = NUM_TEST_SAMPLES
max_... |
BOOLEAN_OPTION_TYPE = ['false', 'true']
# Extracted from the documentation of clang-format version 13
# https://releases.llvm.org/13.0.0/tools/clang/docs/ClangFormatStyleOptions.html
ALL_TUNEABLE_OPTIONS = {
'AccessModifierOffset': ['0', '-1', '-2', '-3', '-4'],
'AlignAfterOpenBracket': ['DontAlign', 'Align', ... | boolean_option_type = ['false', 'true']
all_tuneable_options = {'AccessModifierOffset': ['0', '-1', '-2', '-3', '-4'], 'AlignAfterOpenBracket': ['DontAlign', 'Align', 'AlwaysBreak'], 'AlignArrayOfStructures': ['None', 'Left', 'Right'], 'AlignConsecutiveAssignments': ['None', 'Consecutive', 'AcrossEmptyLines', 'AcrossCo... |
{
'variables': {
'node_shared_openssl%': 'true'
},
'targets': [
{
'target_name': 'ed25519',
'sources': [
'src/ed25519/keypair.c',
'src/ed25519/sign.c',
'src/ed25519/open.c',
'src/ed25519/crypto... | {'variables': {'node_shared_openssl%': 'true'}, 'targets': [{'target_name': 'ed25519', 'sources': ['src/ed25519/keypair.c', 'src/ed25519/sign.c', 'src/ed25519/open.c', 'src/ed25519/crypto_verify_32.c', 'src/ed25519/ge_double_scalarmult.c', 'src/ed25519/ge_frombytes.c', 'src/ed25519/ge_scalarmult_base.c', 'src/ed25519/g... |
def issorted(str1, str2):
if len(str1) != len(str2):
return False
bool_b1 = [0] * 256
bool_b2 = [0] * 256
for i in range(len(str1)):
bool_b1[ord(str1[i])] += 1
bool_b2[ord(str2[i])] += 1
if bool_b1 == bool_b2:
return True
else:
return False
#... | def issorted(str1, str2):
if len(str1) != len(str2):
return False
bool_b1 = [0] * 256
bool_b2 = [0] * 256
for i in range(len(str1)):
bool_b1[ord(str1[i])] += 1
bool_b2[ord(str2[i])] += 1
if bool_b1 == bool_b2:
return True
else:
return False
print(issorted(... |
class Event:
def __init__(self, name, payload):
self.name = name
self.payload = payload
| class Event:
def __init__(self, name, payload):
self.name = name
self.payload = payload |
class Solution:
def numDecodings(self, s):
if not s:
return 0
second_last, last = 0, 1
for i, ch in enumerate(s):
ways = 0
curr = int(ch)
# current number is not 0
if curr:
# there is at least one way to decode
... | class Solution:
def num_decodings(self, s):
if not s:
return 0
(second_last, last) = (0, 1)
for (i, ch) in enumerate(s):
ways = 0
curr = int(ch)
if curr:
ways = last
if i:
prev = int(s[i - 1]... |
def Divide(a,b):
try:
return (a/b)
except ZeroDivisionError:
print("\nHey!Dont be insane!\n")
def Rem(a,b):
try:
return (a%b)
except ZeroDivisionError:
print("\nHey!Dont be insane!\n")
print("Enter Operand1:\n")
oper1=float(input())
print("Enter Operand2:\n")
oper2=float(input... | def divide(a, b):
try:
return a / b
except ZeroDivisionError:
print('\nHey!Dont be insane!\n')
def rem(a, b):
try:
return a % b
except ZeroDivisionError:
print('\nHey!Dont be insane!\n')
print('Enter Operand1:\n')
oper1 = float(input())
print('Enter Operand2:\n')
oper2 =... |
#global Variable
x = 100
def fun(x):
#local scope of variable
x = 3 + 2
return x
local = fun(x)
print(local)
print(x) | x = 100
def fun(x):
x = 3 + 2
return x
local = fun(x)
print(local)
print(x) |
sqrt = lambda n: n ** .5
sqrt_5 = sqrt(5)
phi = (1 + sqrt_5) / 2
psi = (1 - sqrt_5) / 2
fibonacci = lambda n: int(round((phi ** n - psi ** n) / sqrt_5))
for n in range(-12, 12):
print(fibonacci(n))
| sqrt = lambda n: n ** 0.5
sqrt_5 = sqrt(5)
phi = (1 + sqrt_5) / 2
psi = (1 - sqrt_5) / 2
fibonacci = lambda n: int(round((phi ** n - psi ** n) / sqrt_5))
for n in range(-12, 12):
print(fibonacci(n)) |
def originalSystemPrettyPrint():
var = "Original System \n\ny1' = 7 y3 + 4.5 y5 + -19.5 y1^2 -9.5 y1 y2 + -10 y1 y5 + -9.75 y1 y3 -9.75 y1 y4\n" + \
"y2' = 9 y4 + 4.5 y5 + -6 y2^2 -9.5 y1 y2 + -10 y3 y2 + -4 y5 y2 -1.75 y2 y4\n" + \
"y3' = 9.75 y1^2 -3.5 y3 + -9.75 y1 y3 + -19.5 y3^2 -10 y3 y2\n... | def original_system_pretty_print():
var = "Original System \n\ny1' = 7 y3 + 4.5 y5 + -19.5 y1^2 -9.5 y1 y2 + -10 y1 y5 + -9.75 y1 y3 -9.75 y1 y4\n" + "y2' = 9 y4 + 4.5 y5 + -6 y2^2 -9.5 y1 y2 + -10 y3 y2 + -4 y5 y2 -1.75 y2 y4\n" + "y3' = 9.75 y1^2 -3.5 y3 + -9.75 y1 y3 + -19.5 y3^2 -10 y3 y2\n" + "y4' = 8 y2^2 -4.... |
class DataQueue:
def __init__(self):
self.data = []
def Add(self, unitData):
self.Enqueue(unitData)
self.Dequeue()
def Enqueue(self, unitData):
self.data.append(unitData)
def Dequeue(self):
self.data.pop(0) | class Dataqueue:
def __init__(self):
self.data = []
def add(self, unitData):
self.Enqueue(unitData)
self.Dequeue()
def enqueue(self, unitData):
self.data.append(unitData)
def dequeue(self):
self.data.pop(0) |
#!/usr/bin/python3
def print_matrix_integer(matrix=[[]]):
if not matrix:
print()
else:
for row in range(len(matrix)):
for item in range(len(matrix[row])):
if item != len(matrix[row]) - 1:
endspace = ' '
else:
end... | def print_matrix_integer(matrix=[[]]):
if not matrix:
print()
else:
for row in range(len(matrix)):
for item in range(len(matrix[row])):
if item != len(matrix[row]) - 1:
endspace = ' '
else:
endspace = ''
... |
value = int(input())
def dumb_fib(n):
if n < 3:
return 1
else:
return dumb_fib(n - 1) + dumb_fib(n - 2)
print(dumb_fib(value + 1))
| value = int(input())
def dumb_fib(n):
if n < 3:
return 1
else:
return dumb_fib(n - 1) + dumb_fib(n - 2)
print(dumb_fib(value + 1)) |
lst = [8, 3, 9, 6, 4, 7, 5, 2, 1]
def main():
test(lst)
def test(lst):
line_one = []
reverse_line_two = lst
shifted_num = []
reverse_line_two = reverse_line_two[::-1]
limit = len(reverse_line_two)
for i in range(limit):
line_one.append(i + 1)
line_one.pop(0)
left = reverse_... | lst = [8, 3, 9, 6, 4, 7, 5, 2, 1]
def main():
test(lst)
def test(lst):
line_one = []
reverse_line_two = lst
shifted_num = []
reverse_line_two = reverse_line_two[::-1]
limit = len(reverse_line_two)
for i in range(limit):
line_one.append(i + 1)
line_one.pop(0)
left = reverse_... |
def age_predict():
name = input("What is your name?\n")
print("Hello " + name + " it is nice to meet you!")
x = True
while x:
age = input("How old are you " + name + "?\n")
if age.isnumeric():
x = False
else:
print("Please try again.")
age_date = ((100... | def age_predict():
name = input('What is your name?\n')
print('Hello ' + name + ' it is nice to meet you!')
x = True
while x:
age = input('How old are you ' + name + '?\n')
if age.isnumeric():
x = False
else:
print('Please try again.')
age_date = 100 -... |
def get_eben(n: list):
if sum(n) % 2 == 0:
return int("".join(map(str, n)))
num = n
s = sum(num)
while s % 2 != 0:
s
def main():
t = int(input())
for _ in range(t):
length = int(input())
n = map(int, input().split())
print(get_eben(n... | def get_eben(n: list):
if sum(n) % 2 == 0:
return int(''.join(map(str, n)))
num = n
s = sum(num)
while s % 2 != 0:
s
def main():
t = int(input())
for _ in range(t):
length = int(input())
n = map(int, input().split())
print(get_eben(n))
if __name__ == '__m... |
# encoding: utf-8
class Enum(object):
@classmethod
def get_keys(cls):
return filter(lambda x: not x.startswith('_'), cls.__dict__.keys())
@classmethod
def items(cls):
return map(lambda x: (x, getattr(cls, x)), cls.get_keys())
@classmethod
def get_values(cls):
return map... | class Enum(object):
@classmethod
def get_keys(cls):
return filter(lambda x: not x.startswith('_'), cls.__dict__.keys())
@classmethod
def items(cls):
return map(lambda x: (x, getattr(cls, x)), cls.get_keys())
@classmethod
def get_values(cls):
return map(lambda x: getatt... |
def euro(b, m, c):
czas = dict()
mecze = dict()
baza = dict()
wynik = ['', float('inf')]
for baz in b:
baza[baz[0]] = baz[1]
for mecz in m:
if mecz[0] not in mecze.keys():
mecze[mecz[0]] = [mecz[2]]
else:
mecze[mecz[0]].append(mecz[2])
if... | def euro(b, m, c):
czas = dict()
mecze = dict()
baza = dict()
wynik = ['', float('inf')]
for baz in b:
baza[baz[0]] = baz[1]
for mecz in m:
if mecz[0] not in mecze.keys():
mecze[mecz[0]] = [mecz[2]]
else:
mecze[mecz[0]].append(mecz[2])
if m... |
dataset_type = 'CocoDataset'
data_root = '/work/u5216579/ctr/data/PCB_v3/'#'/home/u5216579/vf/data/coco/' #'data/coco/'
img_norm_cfg = dict(
#mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
mean=[38.720, 51.155, 40.22], std=[53.275, 52.273, 46.819], to_rgb=True)
train_pipeline = [
... | dataset_type = 'CocoDataset'
data_root = '/work/u5216579/ctr/data/PCB_v3/'
img_norm_cfg = dict(mean=[38.72, 51.155, 40.22], std=[53.275, 52.273, 46.819], to_rgb=True)
train_pipeline = [dict(type='LoadImageFromFile'), dict(type='LoadAnnotations', with_bbox=True), dict(type='Resize', img_scale=(512, 512), keep_ratio=True... |
def get_nd_par(ref_len, read_type, basecaller):
if read_type:
if read_type == "dRNA":
return drna_nd_par(ref_len, basecaller)
else:
return cdna_nd_par(ref_len, read_type)
else:
return dna_nd_par(ref_len, basecaller)
def seg_par(ref_len, changepoint):
if ref_... | def get_nd_par(ref_len, read_type, basecaller):
if read_type:
if read_type == 'dRNA':
return drna_nd_par(ref_len, basecaller)
else:
return cdna_nd_par(ref_len, read_type)
else:
return dna_nd_par(ref_len, basecaller)
def seg_par(ref_len, changepoint):
if ref_l... |
if __name__ == "__main__":
T = int(input().strip())
correct = 1 << 32
for _ in range(T):
num = int(input().strip())
print(~num + correct)
| if __name__ == '__main__':
t = int(input().strip())
correct = 1 << 32
for _ in range(T):
num = int(input().strip())
print(~num + correct) |
def format_user(userdata, format):
result = ""
u = userdata["name"]
if format == "greeting":
result = "{}, {} {}".format(u["title"], u["first"], u["last"])
elif format == "short":
result = "{}{}".format(u["title"], u["last"])
elif format == "country":
result = userdata["nat"]... | def format_user(userdata, format):
result = ''
u = userdata['name']
if format == 'greeting':
result = '{}, {} {}'.format(u['title'], u['first'], u['last'])
elif format == 'short':
result = '{}{}'.format(u['title'], u['last'])
elif format == 'country':
result = userdata['nat']... |
t = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
print(t[3])
print(t[-99:-7])
print(t[-99:-5])
print(t[::])
| t = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
print(t[3])
print(t[-99:-7])
print(t[-99:-5])
print(t[:]) |
SCHEMA = {
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"DEB_REPO_SCHEMA": {
"type": "object",
"required": [
"name",
"uri",
"suite",
"section"
],
"properties": {
... | schema = {'$schema': 'http://json-schema.org/draft-04/schema#', 'definitions': {'DEB_REPO_SCHEMA': {'type': 'object', 'required': ['name', 'uri', 'suite', 'section'], 'properties': {'name': {'type': 'string'}, 'type': {'type': 'string', 'enum': ['deb']}, 'uri': {'type': 'string'}, 'priority': {'anyOf': [{'type': 'integ... |
# -*- coding: utf-8 -*-
# Author: Rodrigo E. Principe
# Email: fitoprincipe82 at gmail
# Make a prediction with weights
# one vector has n elements
# p = (element1*weight1) + (element2*weight2) + (elementn*weightn) + bias
# if p >= 0; 1; 0
def predict(vector, bias, weights):
pairs = zip(vector, weights) # [[eleme... | def predict(vector, bias, weights):
pairs = zip(vector, weights)
for (element, weight) in pairs:
bias += element * weight
return 1.0 if bias >= 0.0 else 0.0
def train_weights(train, l_rate, n_epoch, bias=0):
first_vector = train[0][0]
weights = [random() for i in range(len(first_vector))]
... |
{
"variables": {
"buffer_impl" : "<!(node -pe 'v=process.versions.node.split(\".\");v[0] > 0 || v[0] == 0 && v[1] >= 11 ? \"POS_0_11\" : \"PRE_0_11\"')",
"callback_style" : "<!(node -pe 'v=process.versions.v8.split(\".\");v[0] > 3 || v[0] == 3 && v[1] >= 20 ? \"POS_3_20\" : \"PRE_3_20\"')"
},
"targets": [... | {'variables': {'buffer_impl': '<!(node -pe \'v=process.versions.node.split(".");v[0] > 0 || v[0] == 0 && v[1] >= 11 ? "POS_0_11" : "PRE_0_11"\')', 'callback_style': '<!(node -pe \'v=process.versions.v8.split(".");v[0] > 3 || v[0] == 3 && v[1] >= 20 ? "POS_3_20" : "PRE_3_20"\')'}, 'targets': [{'target_name': 'openvg', '... |
#method 'find' finds index positon of specified string
#index position starts with 0
my_fruit = "My favorite fruit is apple".find('apple')
print(my_fruit) | my_fruit = 'My favorite fruit is apple'.find('apple')
print(my_fruit) |
# File: Slicing_in_Python.py
# Description: How to slice strings in Python
# Environment: PyCharm and Anaconda environment
#
# MIT License
# Copyright (c) 2018 Valentyn N Sichkar
# github.com/sichkar-valentyn
#
# Reference to:
# [1] Valentyn N Sichkar. Slicing in Python // GitHub platform [Electronic resource]. URL: ht... | dna = 'ATTCGGAGCT'
print(dna[1])
print(dna[1:4])
print(dna[:4])
print(dna[4:])
print(dna[-4:])
print(dna[1:-1])
print(dna[1:-1:2])
print(dna[::-1]) |
class Hund:
def __init__(self, alder, vekt):
self._alder = alder
self._vekt = vekt
self._metthet = 10
def hentAlder(self):
return self._alder
def hentVekt(self):
return self._vekt
def spring(self):
self._metthet -= 1
if self._metthet < 5:
... | class Hund:
def __init__(self, alder, vekt):
self._alder = alder
self._vekt = vekt
self._metthet = 10
def hent_alder(self):
return self._alder
def hent_vekt(self):
return self._vekt
def spring(self):
self._metthet -= 1
if self._metthet < 5:
... |
#
# PySNMP MIB module LLDP-EXT-DOT1-PE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/LLDP-EXT-DOT1-PE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 19:57:50 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, value_range_constraint, constraints_intersection, value_size_constraint, single_value_constraint) ... |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
output = ListNode(None)
outputPointer = output
carry = 0
... | class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
output = list_node(None)
output_pointer = output
carry = 0
(pointer1, pointer2) = (l1, l2)
while pointer1 or pointer2:
if pointer1 and pointer2:
new = pointer1.val ... |
class Trackable(object):
def __init__(self, name):
self.name = name
print('CREATE {}'.format(name))
def __del__(self):
print('DELETE {}'.format(self.name))
| class Trackable(object):
def __init__(self, name):
self.name = name
print('CREATE {}'.format(name))
def __del__(self):
print('DELETE {}'.format(self.name)) |
CURRENCY_ALGO = "ALGO"
EXCHANGE_ALGORAND_BLOCKCHAIN = "algorand_blockchain"
TRANSACTION_TYPE_PAYMENT = "pay"
TRANSACTION_TYPE_ASSET_TRANSFER = "axfer"
TRANSACTION_TYPE_APP_CALL = "appl"
APPLICATION_ID_TINYMAN_v10 = 350338509
APPLICATION_ID_TINYMAN_v11 = 552635992
APPLICATION_ID_YIELDLY = 233725848
APPLI... | currency_algo = 'ALGO'
exchange_algorand_blockchain = 'algorand_blockchain'
transaction_type_payment = 'pay'
transaction_type_asset_transfer = 'axfer'
transaction_type_app_call = 'appl'
application_id_tinyman_v10 = 350338509
application_id_tinyman_v11 = 552635992
application_id_yieldly = 233725848
application_id_yieldl... |
XK_emspace = 0xaa1
XK_enspace = 0xaa2
XK_em3space = 0xaa3
XK_em4space = 0xaa4
XK_digitspace = 0xaa5
XK_punctspace = 0xaa6
XK_thinspace = 0xaa7
XK_hairspace = 0xaa8
XK_emdash = 0xaa9
XK_endash = 0xaaa
XK_signifblank = 0xaac
XK_ellipsis = 0xaae
XK_doubbaselinedot = 0xaaf
XK_onethird = 0xab0
XK_twothirds = 0xab1
XK_onefif... | xk_emspace = 2721
xk_enspace = 2722
xk_em3space = 2723
xk_em4space = 2724
xk_digitspace = 2725
xk_punctspace = 2726
xk_thinspace = 2727
xk_hairspace = 2728
xk_emdash = 2729
xk_endash = 2730
xk_signifblank = 2732
xk_ellipsis = 2734
xk_doubbaselinedot = 2735
xk_onethird = 2736
xk_twothirds = 2737
xk_onefifth = 2738
xk_tw... |
firstname = str(input("Enter your first name: "))
lastname = str(input("Enter your last name: "))
print("Initials: " + firstname[0] + "." + lastname[0] + ".")
| firstname = str(input('Enter your first name: '))
lastname = str(input('Enter your last name: '))
print('Initials: ' + firstname[0] + '.' + lastname[0] + '.') |
POST_JSON_RESPONSES = {
'/auth/realms/test/protocol/openid-connect/token': {
'access_token': '54604e3b-4d6a-419d-9173-4b1af0530bfb',
'token_type': 'bearer',
'expires_in': 42695,
'scope': 'read write'},
'/v2/observations': {
'dimensionDeclarations': [
{
... | post_json_responses = {'/auth/realms/test/protocol/openid-connect/token': {'access_token': '54604e3b-4d6a-419d-9173-4b1af0530bfb', 'token_type': 'bearer', 'expires_in': 42695, 'scope': 'read write'}, '/v2/observations': {'dimensionDeclarations': [{'name': 'study', 'dimensionType': 'attribute', 'sortIndex': None, 'value... |
def ends_with_punctuation(string):
if string is None:
return False
for punctuation in ['.', '!', '?']:
if string.rstrip().endswith(punctuation):
return True
return False
| def ends_with_punctuation(string):
if string is None:
return False
for punctuation in ['.', '!', '?']:
if string.rstrip().endswith(punctuation):
return True
return False |
# PREDSTORM L1 input parameters file
# ----------------------------------
# If True, show interpolated data points on the DSCOVR input plot
showinterpolated = True
# Time interval for both the observed and predicted windDelta T (hours), start with 24 hours here (covers 1 night of aurora)
deltat = 24
# Time range of ... | showinterpolated = True
deltat = 24
trainstart = '2006-01-01 00:00'
trainend = '2010-01-01 00:00' |
size = int(input())
matrix = []
for _ in range(size):
matrix.append([int(x) for x in input().split()])
primary_diagonal_sum = 0
secondary_diagonal_sum = 0
for i in range(len(matrix)):
primary_diagonal_sum += matrix[i][i]
secondary_diagonal_sum += matrix[i][size - i - 1]
total = abs(primary_diagonal_sum... | size = int(input())
matrix = []
for _ in range(size):
matrix.append([int(x) for x in input().split()])
primary_diagonal_sum = 0
secondary_diagonal_sum = 0
for i in range(len(matrix)):
primary_diagonal_sum += matrix[i][i]
secondary_diagonal_sum += matrix[i][size - i - 1]
total = abs(primary_diagonal_sum - se... |
class BlockLinkedList:
def __init__(self):
self.size = 0
self.header = None
self.trailer = None
def addbh(self, block):
if self.size == 0:
self.trailer = block
else:
block.set_next(self.header)
self.header.set_previous(block)
self.header = block
self.size += 1
def addbt(self, block):
i... | class Blocklinkedlist:
def __init__(self):
self.size = 0
self.header = None
self.trailer = None
def addbh(self, block):
if self.size == 0:
self.trailer = block
else:
block.set_next(self.header)
self.header.set_previous(block)
... |
# -*- coding:utf-8 -*-
# package information.
INFO = dict(
name = "exputils",
description = "Utilities for experiment analysis",
author = "Yohsuke T. Fukai",
author_email = "ysk@yfukai.net",
license = "MIT License",
url = "",
classifiers = [
"Programming Language :: Python ::... | info = dict(name='exputils', description='Utilities for experiment analysis', author='Yohsuke T. Fukai', author_email='ysk@yfukai.net', license='MIT License', url='', classifiers=['Programming Language :: Python :: 3.6', 'License :: OSI Approved :: MIT License']) |
# Given a linked list, determine if it has a cycle in it.
#
# To represent a cycle in the given linked list, we use an integer pos which
# represents the position (0-indexed) in the linked list where tail connects to.
# If pos is -1, then there is no cycle in the linked list.
#
# Input: head = [3,2,0,-4], pos = 1
# Out... | class Listnode:
def __init__(self, val):
self.val = val
self.next = None
class Solution:
def is_cycle(self, head):
pointer1 = head
pointer2 = head.next
while pointer1 != pointer2:
if pointer2 is None or pointer2.next is None:
return False
... |
# %% [492. Construct the Rectangle](https://leetcode.com/problems/construct-the-rectangle/)
class Solution:
def constructRectangle(self, area: int) -> List[int]:
w = int(area ** 0.5)
while area % w:
w -= 1
return area // w, w
| class Solution:
def construct_rectangle(self, area: int) -> List[int]:
w = int(area ** 0.5)
while area % w:
w -= 1
return (area // w, w) |
# config.py
class Config(object):
embed_size = 300
in_channels = 1
num_channels = 100
kernel_size = [3,4,5]
output_size = 4
max_epochs = 10
lr = 0.25
batch_size = 64
max_sen_len = 20
dropout_keep = 0.6 | class Config(object):
embed_size = 300
in_channels = 1
num_channels = 100
kernel_size = [3, 4, 5]
output_size = 4
max_epochs = 10
lr = 0.25
batch_size = 64
max_sen_len = 20
dropout_keep = 0.6 |
class Color:
def __init__(self, r, g, b, alpha=255):
self.r = r
self.g = g
self.b = b
self.alpha = alpha
if self.r < 0 or self.g < 0 or self.b < 0 or self.alpha < 0:
raise ValueError("color values can't be below 0")
if self.r > 255 or self.g > 255 or self... | class Color:
def __init__(self, r, g, b, alpha=255):
self.r = r
self.g = g
self.b = b
self.alpha = alpha
if self.r < 0 or self.g < 0 or self.b < 0 or (self.alpha < 0):
raise value_error("color values can't be below 0")
if self.r > 255 or self.g > 255 or s... |
def ConverterTempo(tempo, unidade):
if unidade == "m":
return tempo*60
if unidade == "s":
return tempo
def ConverteMetros(quantidade, unidade):
if unidade == "M":
return quantidade*100
if unidade == "m":
return quantidade | def converter_tempo(tempo, unidade):
if unidade == 'm':
return tempo * 60
if unidade == 's':
return tempo
def converte_metros(quantidade, unidade):
if unidade == 'M':
return quantidade * 100
if unidade == 'm':
return quantidade |
class TokenType(object):
END = ""
ILLEGAL = "ILLEGAL"
# Operators
PLUS = "+"
MINUS = "-"
SLASH = "/"
AT = "@"
# Identifiers
NUMBER = "NUMBER"
MODIFIER = "MODIFIER"
# keywords
NOW = "NOW"
class Token(object):
def __init__(self, tok_type, tok_literal):
self.to... | class Tokentype(object):
end = ''
illegal = 'ILLEGAL'
plus = '+'
minus = '-'
slash = '/'
at = '@'
number = 'NUMBER'
modifier = 'MODIFIER'
now = 'NOW'
class Token(object):
def __init__(self, tok_type, tok_literal):
self.token_type = tok_type
self.token_literal = ... |
def sort(L):
n = len(L)
# Build Heap
for i in range(n-1, -1, -1):
L = heapify(L, i, n)
for i in range(n-1, 0, -1):
L[i], L[0] = L[0], L[i]
n -= 1
heapify(L, 0, n)
return L
def heapify(L, _v, n): # v is index to be passed
v = _v + 1
largest = v
if 2*v <=... | def sort(L):
n = len(L)
for i in range(n - 1, -1, -1):
l = heapify(L, i, n)
for i in range(n - 1, 0, -1):
(L[i], L[0]) = (L[0], L[i])
n -= 1
heapify(L, 0, n)
return L
def heapify(L, _v, n):
v = _v + 1
largest = v
if 2 * v <= n:
if L[2 * v - 1] > L[v -... |
####################################################
#
# Components applicable to all types of items
#
####################################################
# what type of item is this entity
# this is primarily used in iterable statements as a filter
class TypeOfItem:
def __init__(self, label=''):
self... | class Typeofitem:
def __init__(self, label=''):
self.label = label
class Actionlist:
def __init__(self, action_list=''):
self.actions = action_list
class Name:
def __init__(self, label=''):
self.label = label
class Description:
def __init__(self, label=''):
self.la... |
def get_ages() -> list[int]:
with open('input.txt') as f:
line, = f.readlines()
return list(map(int, line.split(',')))
def step_day(ages: list[int]):
for i, age in enumerate(ages[:]):
age, *newborn = tick(age)
ages[i] = age
ages.extend(newborn)
def tick(age: int) -> list[... | def get_ages() -> list[int]:
with open('input.txt') as f:
(line,) = f.readlines()
return list(map(int, line.split(',')))
def step_day(ages: list[int]):
for (i, age) in enumerate(ages[:]):
(age, *newborn) = tick(age)
ages[i] = age
ages.extend(newborn)
def tick(age: int) -> l... |
'''
Given an array of integers A sorted in non-decreasing order,
return an array of the squares of each number, also in sorted non-decreasing order.
Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Example 2:
Input: [-7,-3,2,3,11]
Output: [4,9,9,49,121]
Note:
1 <= A.length <= 10000
-10000 <= A[i] <= 1... | """
Given an array of integers A sorted in non-decreasing order,
return an array of the squares of each number, also in sorted non-decreasing order.
Example 1:
Input: [-4,-1,0,3,10]
Output: [0,1,9,16,100]
Example 2:
Input: [-7,-3,2,3,11]
Output: [4,9,9,49,121]
Note:
1 <= A.length <= 10000
-10000 <= A[i] <= 1... |
tuple1 = ("apple", "banana", "cherry")
tuple2 = (1, 5, 7, 9, 3)
tuple3 = (True, False, False)
print(tuple1)
print(tuple2)
print(tuple3)
| tuple1 = ('apple', 'banana', 'cherry')
tuple2 = (1, 5, 7, 9, 3)
tuple3 = (True, False, False)
print(tuple1)
print(tuple2)
print(tuple3) |
class Node:
def __init__(self,data):
self.data = data
self.previous = None
self.next = None
class removeDuplicates:
def __init__(self):
self.head = None
self.tail = None
def remove_duplicates(self):
if (self.head == None):
return
else:
... | class Node:
def __init__(self, data):
self.data = data
self.previous = None
self.next = None
class Removeduplicates:
def __init__(self):
self.head = None
self.tail = None
def remove_duplicates(self):
if self.head == None:
return
else:
... |
class Parameter:
def __init__(self, name: str, klass: str, data_member, required=True, array=False):
self._name = name
self._klass = klass
self._data_member = data_member
self._required = required
self._array = array
def __eq__(self, other):
return True if \
... | class Parameter:
def __init__(self, name: str, klass: str, data_member, required=True, array=False):
self._name = name
self._klass = klass
self._data_member = data_member
self._required = required
self._array = array
def __eq__(self, other):
return True if self.... |
fname = input('Enter the name of the file: ')
if(len(fname) < 1) : fname = 'clown.txt'
hand = open(fname)
di = dict()
for line in hand:
line = line.rstrip()
wds = line.split()
for w in wds:
##if not there, the count is zero
##if it is there, just add + 1
di[w] = di.get(w, 0) + 1
... | fname = input('Enter the name of the file: ')
if len(fname) < 1:
fname = 'clown.txt'
hand = open(fname)
di = dict()
for line in hand:
line = line.rstrip()
wds = line.split()
for w in wds:
di[w] = di.get(w, 0) + 1
"\n if w in di:\n di[w] = di[w] + 1\n print('*... |
def distinct(iterable, keyfunc=None):
seen = set()
for item in iterable:
key = item if keyfunc is None else keyfunc(item)
if key not in seen:
seen.add(key)
yield item | def distinct(iterable, keyfunc=None):
seen = set()
for item in iterable:
key = item if keyfunc is None else keyfunc(item)
if key not in seen:
seen.add(key)
yield item |
'''
URL: https://leetcode.com/problems/binary-tree-level-order-traversal/
Difficulty: Medium
Description: Binary Tree Level Order Traversal
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],
... | """
URL: https://leetcode.com/problems/binary-tree-level-order-traversal/
Difficulty: Medium
Description: Binary Tree Level Order Traversal
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],
... |
def read_file():
content = open("C:/Users/DIPANSH KHANDELWAL/Desktop/Python Codes/PythonFiles/read_file/read_file.txt")
text = content.read()
print (text)
content.close()
read_file()
| def read_file():
content = open('C:/Users/DIPANSH KHANDELWAL/Desktop/Python Codes/PythonFiles/read_file/read_file.txt')
text = content.read()
print(text)
content.close()
read_file() |
NAME='syslog'
CFLAGS = []
LDFLAGS = []
LIBS = []
GCC_LIST = ['syslog_plugin']
| name = 'syslog'
cflags = []
ldflags = []
libs = []
gcc_list = ['syslog_plugin'] |
#lambda is used to create an anonymous function (function with no name)
# It is an inline function that does not contain a return statement
a = lambda x: x*2
for i in range(1,6):
print(a(i)) | a = lambda x: x * 2
for i in range(1, 6):
print(a(i)) |
def solve(a, b):
return a + b
def driver():
a, b = list(map(int, input().split(' ')))
result = solve(a, b)
print(solve(a, b))
return result
def main():
return driver()
if __name__ == '__main__':
main()
| def solve(a, b):
return a + b
def driver():
(a, b) = list(map(int, input().split(' ')))
result = solve(a, b)
print(solve(a, b))
return result
def main():
return driver()
if __name__ == '__main__':
main() |
# Program to convert Miles to Kilometers
# Taking miles input from the user
miles = float(input("Enter value in miles: "))
# conversion factor
convFac = 0.621371
# calculate kilometers
kilometers = miles / convFac
print("%0.2f miles is equal to %0.2f kilometers" % (miles, kilometers))
| miles = float(input('Enter value in miles: '))
conv_fac = 0.621371
kilometers = miles / convFac
print('%0.2f miles is equal to %0.2f kilometers' % (miles, kilometers)) |
def venda_mensal(*args):
telaCaixa = args[0]
telaMensal = args[1]
cursor = args[2]
QtWidgets = args[3]
data1 = telaMensal.data_mensal.text()
cursor.execute("select sum(qt_pizzas), sum(qt_esfihas), sum(qt_bebidas), sum(qt_outros), sum(total) from caixa where extract(year_month from data2) = %s ... | def venda_mensal(*args):
tela_caixa = args[0]
tela_mensal = args[1]
cursor = args[2]
qt_widgets = args[3]
data1 = telaMensal.data_mensal.text()
cursor.execute('select sum(qt_pizzas), sum(qt_esfihas), sum(qt_bebidas), sum(qt_outros), sum(total) from caixa where extract(year_month from data2) = %s... |
class ApiException(Exception):
pass
class ResourceNotFound(ApiException):
pass
class InternalServerException(ApiException):
pass
class UserNotFound(ApiException):
pass
class Ratelimited(ApiException):
pass
class InvalidMetric(ApiException):
pass
class Authenti... | class Apiexception(Exception):
pass
class Resourcenotfound(ApiException):
pass
class Internalserverexception(ApiException):
pass
class Usernotfound(ApiException):
pass
class Ratelimited(ApiException):
pass
class Invalidmetric(ApiException):
pass
class Authenticationexception(ApiException):... |
class Solution:
def findDisappearedNumbers(self, nums: List[int]) -> List[int]:
arr = [0 for _ in range(len(nums))]
for num in nums:
arr[num - 1] += 1
ans = []
for i in range(len(arr)):
if arr[i] == 0:
ans.append(i + ... | class Solution:
def find_disappeared_numbers(self, nums: List[int]) -> List[int]:
arr = [0 for _ in range(len(nums))]
for num in nums:
arr[num - 1] += 1
ans = []
for i in range(len(arr)):
if arr[i] == 0:
ans.append(i + 1)
return ans |
s = "abdcd"
count = 0
for vowelsItem in s:
if vowelsItem in "aeiou":
count += 1
print("Number of vowels: " + str(count)) | s = 'abdcd'
count = 0
for vowels_item in s:
if vowelsItem in 'aeiou':
count += 1
print('Number of vowels: ' + str(count)) |
# Python3 implementation to
# find first element
# occurring k times
# function to find the
# first element occurring
# k number of times
def firstElement(arr, n, k):
# dictionary to count
# occurrences of
# each element
count_map = {};
for i in range(0, n):
... | def first_element(arr, n, k):
count_map = {}
for i in range(0, n):
if arr[i] in count_map.keys():
count_map[arr[i]] += 1
else:
count_map[arr[i]] = 1
i += 1
for i in range(0, n):
if count_map[arr[i]] == k:
return arr[i]
i += 1
if __n... |
rooms = int(input())
free_chairs = 0
game_on = True
for current_room in range(1, rooms + 1):
command = input().split()
chairs = len(command[0])
visitors = int(command[1])
if chairs > visitors:
free_chairs += chairs - visitors
elif chairs < visitors:
needed_chairs_in_room = visito... | rooms = int(input())
free_chairs = 0
game_on = True
for current_room in range(1, rooms + 1):
command = input().split()
chairs = len(command[0])
visitors = int(command[1])
if chairs > visitors:
free_chairs += chairs - visitors
elif chairs < visitors:
needed_chairs_in_room = visitors -... |
def main():
students = []
number_students = int(input())
while number_students > 0:
student = input()
students.append(student)
number_students -= 1
number_days = int(input())
all_missing_students = []
while number_days > 0:
curr_num_students = int(input())
... | def main():
students = []
number_students = int(input())
while number_students > 0:
student = input()
students.append(student)
number_students -= 1
number_days = int(input())
all_missing_students = []
while number_days > 0:
curr_num_students = int(input())
... |
def AAsInPeptideListCount(PeptidesListFileLocation):
PeptidesListFile = open(PeptidesListFileLocation, 'r')
Lines = PeptidesListFile.readlines()
PeptidesListFile.close
AminoAcidsCount = {'A':0, 'C':0, 'D':0, 'E':0,
'F':0, 'G':0, 'H':0, 'I':0,
'K':0, '... | def a_as_in_peptide_list_count(PeptidesListFileLocation):
peptides_list_file = open(PeptidesListFileLocation, 'r')
lines = PeptidesListFile.readlines()
PeptidesListFile.close
amino_acids_count = {'A': 0, 'C': 0, 'D': 0, 'E': 0, 'F': 0, 'G': 0, 'H': 0, 'I': 0, 'K': 0, 'L': 0, 'M': 0, 'N': 0, 'P': 0, 'Q':... |
a = 25
b = 0o31
c = 0x19
print(a)
print(b)
print(c)
| a = 25
b = 25
c = 25
print(a)
print(b)
print(c) |
class MaxSparseList:
def __init__(self, firstMember, limit: int,
weight: callable = lambda x: x[0],
value: callable = lambda x: x[1]):
self.weight = weight
self.value = value
self.data = [firstMember]
self.limit = limit
return
def append... | class Maxsparselist:
def __init__(self, firstMember, limit: int, weight: callable=lambda x: x[0], value: callable=lambda x: x[1]):
self.weight = weight
self.value = value
self.data = [firstMember]
self.limit = limit
return
def append(self, newMember):
w = self.w... |
class RGBColor:
def __init__(self, r, g, b):
self.r = r
self.g = g
self.b = b
def __str__(self):
return "rgb({},{},{})".format(self.r, self.g, self.b)
def as_hex(self):
return HexColor("#%02x%02x%02x" % (self.r, self.g, self.b))
def as_cmyk(self):
k = m... | class Rgbcolor:
def __init__(self, r, g, b):
self.r = r
self.g = g
self.b = b
def __str__(self):
return 'rgb({},{},{})'.format(self.r, self.g, self.b)
def as_hex(self):
return hex_color('#%02x%02x%02x' % (self.r, self.g, self.b))
def as_cmyk(self):
k =... |
class HightonConstants:
# is used for requests
GET = 'GET'
POST = 'POST'
PUT = 'PUT'
DELETE = 'DELETE'
HIGHRISE_URL = 'highrisehq.com'
# Company
COMPANIES = 'companies'
COMPANY = 'company'
COMPANY_NAME = 'company-name'
COMPANY_ID = 'company-id'
# Case
KASES = 'kases... | class Hightonconstants:
get = 'GET'
post = 'POST'
put = 'PUT'
delete = 'DELETE'
highrise_url = 'highrisehq.com'
companies = 'companies'
company = 'company'
company_name = 'company-name'
company_id = 'company-id'
kases = 'kases'
deals = 'deals'
task = 'task'
tasks = 't... |
class BraviaProtocol:
# def __init__():
# def makeQuery(self, parameters):
# queries = [];
# while parameters:
# if parameters[0] in self.protocol.keys():
# queries.append(self.protocol[parameters[0]] + "?")
# parameters = parameters[1:]
# retu... | class Braviaprotocol:
def parse_events(self, events):
has_changed = True
return has_changed |
class Value():
def __init__(self):
self._value = None
def __set__(self, obj, value):
self._value = value
def __get__(self, obj, obj_type):
return self._value - obj.commission * self._value | class Value:
def __init__(self):
self._value = None
def __set__(self, obj, value):
self._value = value
def __get__(self, obj, obj_type):
return self._value - obj.commission * self._value |
# Given nums = [2, 7, 11, 15], target = 9,
# Because nums[0] + nums[1] = 2 + 7 = 9,
# return [0, 1].
# brute force - time complexity O(n^2)
def two_sum(list, target):
for f_index, f_value in enumerate(list):
for s_index, s_value in enumerate(list[f_index+1:]):
if (f_value + s_value) == target:... | def two_sum(list, target):
for (f_index, f_value) in enumerate(list):
for (s_index, s_value) in enumerate(list[f_index + 1:]):
if f_value + s_value == target:
return [f_index, list.index(s_value)]
return None |
SECRET_KEY = 'XXX'
DEBUG=False
# API-specific
API_500PX_KEY = 'XXX'
API_500PX_SECRET = 'XXX'
API_RIJKS = 'XXX'
FLICKR_KEY = 'XXX'
FLICKR_SECRET = 'XXX'
# Database-specific
SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format('cctest',
'cctest',
... | secret_key = 'XXX'
debug = False
api_500_px_key = 'XXX'
api_500_px_secret = 'XXX'
api_rijks = 'XXX'
flickr_key = 'XXX'
flickr_secret = 'XXX'
sqlalchemy_database_uri = 'postgresql://{}:{}@{}:{}/{}'.format('cctest', 'cctest', 'localhost', '5432', 'openledgertest')
sqlalchemy_track_modifications = False
debug_tb_enabled =... |
_runs_on_key = "runs-on"
def execute(obj: dict) -> None:
default_runner = obj.get(_runs_on_key)
if not default_runner:
return
for job in obj.get("jobs", {}).values():
if _runs_on_key not in job:
job[_runs_on_key] = default_runner
# Clean up the left-overs
obj.pop(_run... | _runs_on_key = 'runs-on'
def execute(obj: dict) -> None:
default_runner = obj.get(_runs_on_key)
if not default_runner:
return
for job in obj.get('jobs', {}).values():
if _runs_on_key not in job:
job[_runs_on_key] = default_runner
obj.pop(_runs_on_key) |
# **args
def save_user(**user):
print(user['name'])
#**user retorna um dict
save_user(id=1, name='admin') | def save_user(**user):
print(user['name'])
save_user(id=1, name='admin') |
# keys TabbinPoint
OFFSET_DX = 'OFFSET_DX' # DOUBLE
OFFSET_DY = 'OFFSET_DY' # DOUBLE
OFFSET_DZ = 'OFFSET_DZ' ... | offset_dx = 'OFFSET_DX'
offset_dy = 'OFFSET_DY'
offset_dz = 'OFFSET_DZ'
offset_dlength = 'OFFSET_DLENGTH'
offset_lintensity = 'OFFSET_LINTENSITY'
offset_ifilter_obsolete = 'OFFSET_IFILTER_OBSOLETE'
offset_isymsetting_obsolete = 'OFFSET_ISYMSETTING_OBSOLETE'
offset_iswsmode_obsolete = 'OFFSET_ISWSMODE_OBSOLETE'
offset_i... |
# Tests Python 3.5+'s ops
# BINARY_MATRIX_MULTIPLY and INPLACE_MATRIX_MULTIPLY
# code taken from pycdc tests/35_matrix_mult_oper.pyc.src
m = [1, 2] @ [3, 4]
m @= [5, 6]
| m = [1, 2] @ [3, 4]
m @= [5, 6] |
apple=map(int,input().split())
high=int(input())+30
sum=0
for i in apple:
if i<=high:sum+=1
print(sum) | apple = map(int, input().split())
high = int(input()) + 30
sum = 0
for i in apple:
if i <= high:
sum += 1
print(sum) |
# -*- coding: utf-8 -*-
SYSTEM = "O"
USER = "I"
TYPE_CHAT = (
(SYSTEM, u'Gozokia'),
(USER, u'User'),
)
| system = 'O'
user = 'I'
type_chat = ((SYSTEM, u'Gozokia'), (USER, u'User')) |
class FluidSettings:
type = None
| class Fluidsettings:
type = None |
class AtbashCipher:
def encrypt(self, string):
lst = []
for elem in string.lower():
if elem.isalpha():
lst+=chr(219-ord(elem))
else:
lst+=[elem]
return ''.join(lst).lower()
def decrypt(self, string):
return self.encrypt(str... | class Atbashcipher:
def encrypt(self, string):
lst = []
for elem in string.lower():
if elem.isalpha():
lst += chr(219 - ord(elem))
else:
lst += [elem]
return ''.join(lst).lower()
def decrypt(self, string):
return self.encr... |
def forward(t):
t.penup()
t.forward(3)
def no_draw_forward(t):
t.pendown()
t.forward(3)
axiom = 'A'
n = 5
subs = {
'A': 'ABA',
'B': 'BBB'
}
graphics = {
'A': lambda t: forward(t),
'B': lambda t: no_draw_forward(t)
}
| def forward(t):
t.penup()
t.forward(3)
def no_draw_forward(t):
t.pendown()
t.forward(3)
axiom = 'A'
n = 5
subs = {'A': 'ABA', 'B': 'BBB'}
graphics = {'A': lambda t: forward(t), 'B': lambda t: no_draw_forward(t)} |
_base_ = "./FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_Pbr_01_ape.py"
OUTPUT_DIR = "output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_lmPbr_SO/benchvise"
DATASETS = dict(TRAIN=("lm_pbr_benchvise_train",), TEST=("lm_real_benchvise_test",))
# bbnc7
# objects benchvise Avg(1)
# ad_2 10.77 10... | _base_ = './FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_Pbr_01_ape.py'
output_dir = 'output/deepim/lmPbrSO/FlowNet512_1.5AugCosyAAEGray_Aggressive_Flat_lmPbr_SO/benchvise'
datasets = dict(TRAIN=('lm_pbr_benchvise_train',), TEST=('lm_real_benchvise_test',)) |
class ChannelLengthException(Exception):
'''channel searched is more than 16 characters
use with the command line functions
'''
pass
class ChannelCharactersException(Exception):
'''
it should not contain characters that cannot be used in a channel
'''
pass
class ChannelQuote... | class Channellengthexception(Exception):
"""channel searched is more than 16 characters
use with the command line functions
"""
pass
class Channelcharactersexception(Exception):
"""
it should not contain characters that cannot be used in a channel
"""
pass
class Channelquotes... |
# Algorithm: Longest monotonic subsequence
# Overall Time Complexity: O(n^2).
# Space Complexity: O(n).
# Author: https://www.linkedin.com/in/kilar.
def monotonic_subsequence(arr):
Dict = {}
maximum = 0
for i in range(len(arr)):
Dict[i] = [arr[i]]
for j in range(i + 1, len(arr)):
... | def monotonic_subsequence(arr):
dict = {}
maximum = 0
for i in range(len(arr)):
Dict[i] = [arr[i]]
for j in range(i + 1, len(arr)):
if arr[j] >= Dict[i][-1]:
Dict[i].append(arr[j])
for m in Dict:
temp = maximum
maximum = max(maximum... |
# p43.py
str1 = input().split()
str1.reverse()
def exp():
s = str1.pop()
if s[0] == '+':
return exp() + exp()
elif s[0] == '-':
return exp() - exp()
elif s[0] == '*':
return exp() * exp()
elif s[0] == '/':
return exp() / exp()
else:
retur... | str1 = input().split()
str1.reverse()
def exp():
s = str1.pop()
if s[0] == '+':
return exp() + exp()
elif s[0] == '-':
return exp() - exp()
elif s[0] == '*':
return exp() * exp()
elif s[0] == '/':
return exp() / exp()
else:
return float(s)
print(int(exp()... |
#!/usr/bin/env python3
# calculate path of lowest risk
# use Dijkstra algorithm
risk = []
with open('input', 'r') as data:
lines = data.readlines()
for line in lines:
risk.append([int(l) for l in line.strip()])
# prepare nodes
# we might get up with x <-> y again...
graph = []
for y in range... | risk = []
with open('input', 'r') as data:
lines = data.readlines()
for line in lines:
risk.append([int(l) for l in line.strip()])
graph = []
for y in range(len(risk)):
graph.append([{'visited': False, 'risk': 10000000} for x in range(len(risk[y]))])
def visit_neighbors(position, graph):
x = po... |
stack = []
stack.append("Moby Dick")
stack.append("The Great Gatsby")
stack.append("Hamlet")
stack.pop()
stack.append("The Iliad")
stack.append("Pride and Prejudice")
stack.pop()
stack.append("To Kill a Mockingbird")
stack.append("Gulliver's Travels")
stack.append("Don Quixote")
stack.pop()
stack.pop()
stack.pop()
stac... | stack = []
stack.append('Moby Dick')
stack.append('The Great Gatsby')
stack.append('Hamlet')
stack.pop()
stack.append('The Iliad')
stack.append('Pride and Prejudice')
stack.pop()
stack.append('To Kill a Mockingbird')
stack.append("Gulliver's Travels")
stack.append('Don Quixote')
stack.pop()
stack.pop()
stack.pop()
stac... |
MOCK_PLAYER = {
"_id": 1234,
"uuid": "2ad3kfei9ikmd",
"displayname": "TestPlayer123",
"knownAliases": ["1234", "test", "TestPlayer123"],
"firstLogin": 123456,
"lastLogin": 150996,
"achievementsOneTime": ["MVP", "MVP2", "BedwarsMVP"],
"achievementPoints": 300,
"achievements": {"bedwar... | mock_player = {'_id': 1234, 'uuid': '2ad3kfei9ikmd', 'displayname': 'TestPlayer123', 'knownAliases': ['1234', 'test', 'TestPlayer123'], 'firstLogin': 123456, 'lastLogin': 150996, 'achievementsOneTime': ['MVP', 'MVP2', 'BedwarsMVP'], 'achievementPoints': 300, 'achievements': {'bedwars_level': 5, 'general_challenger': 7,... |
class Solution:
def XXX(self, root: TreeNode) -> int:
self.maxleftlength = 0
self.maxrightlength = 0
return self.dp(root)
def dp(self,root):
if(root is None):
return 0
self.maxleftlength = self.dp(root.left)
self.maxrightlength = self.d... | class Solution:
def xxx(self, root: TreeNode) -> int:
self.maxleftlength = 0
self.maxrightlength = 0
return self.dp(root)
def dp(self, root):
if root is None:
return 0
self.maxleftlength = self.dp(root.left)
self.maxrightlength = self.dp(root.right)
... |
{'application':{'type':'Application',
'name':'GuiPyBlog',
'backgrounds': [
{'type':'Background',
'name':'bgTextRouter',
'title':'TextRouter 0.60',
'size':(650, 426),
'statusBar':1,
'icon':'tr.ico',
'style':['resizeable'],
'menubar': {'ty... | {'application': {'type': 'Application', 'name': 'GuiPyBlog', 'backgrounds': [{'type': 'Background', 'name': 'bgTextRouter', 'title': 'TextRouter 0.60', 'size': (650, 426), 'statusBar': 1, 'icon': 'tr.ico', 'style': ['resizeable'], 'menubar': {'type': 'MenuBar', 'menus': [{'type': 'Menu', 'name': 'menuFile', 'label': '&... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.