content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#
# PySNMP MIB module IPFIX-EXPORTER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/IPFIX-EXPORTER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:55:56 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (integer, octet_string, object_identifier) = mibBuilder.importSymbols('ASN1', 'Integer', 'OctetString', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, value_range_constraint, value_size_constraint, single_value_constraint) ... |
# Advent of Code 2020, Day 6
with open("../input06", "r") as infile:
lines = infile.readlines()
# check if a line is blank
def blank(l):
b = True
for c in l: b = b and (c == ' ' or c == '\n')
return b
group = []
groups = []
for l in lines:
if blank(l):
groups.append(group)
group = []
else: ... | with open('../input06', 'r') as infile:
lines = infile.readlines()
def blank(l):
b = True
for c in l:
b = b and (c == ' ' or c == '\n')
return b
group = []
groups = []
for l in lines:
if blank(l):
groups.append(group)
group = []
else:
group.append(l[:-1])
groups.... |
class Products:
def __init__(self, product_name, displayed_price, product_number):
self.product_name = product_name
self.displayed_price = displayed_price
self.product_number = product_number
| class Products:
def __init__(self, product_name, displayed_price, product_number):
self.product_name = product_name
self.displayed_price = displayed_price
self.product_number = product_number |
def for_underscore():
for row in range(4):
for col in range(6):
if row==3 and col>0 and col<5 :
print("*",end=" ")
else:
print(" ",end=" ")
print()
def while_underscore():
row=0
while row<4:
col=0
while col<6... | def for_underscore():
for row in range(4):
for col in range(6):
if row == 3 and col > 0 and (col < 5):
print('*', end=' ')
else:
print(' ', end=' ')
print()
def while_underscore():
row = 0
while row < 4:
col = 0
while c... |
def asTemplate(f):
def wrapped(*args, **props):
def execute():
return f(*args, **props)
return execute
return wrapped
def renderProps(**props):
result = [f' {key}="{value}"' if isinstance(value, str) else f' {key}={str(value)}' for key, value in props.items()]
retur... | def as_template(f):
def wrapped(*args, **props):
def execute():
return f(*args, **props)
return execute
return wrapped
def render_props(**props):
result = [f' {key}="{value}"' if isinstance(value, str) else f' {key}={str(value)}' for (key, value) in props.items()]
return '... |
def render_template(gadget):
RN = "\r\n"
p = Payload()
p.header = "__METHOD__ __ENDPOINT__?cb=__RANDOM__ HTTP/__HTTP_VERSION__" + RN
p.header += gadget + RN
p.header += "Host: __HOST__" + RN
p.header += "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/... | def render_template(gadget):
rn = '\r\n'
p = payload()
p.header = '__METHOD__ __ENDPOINT__?cb=__RANDOM__ HTTP/__HTTP_VERSION__' + RN
p.header += gadget + RN
p.header += 'Host: __HOST__' + RN
p.header += 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)... |
# Count inversions in a sequence of numbers
def count_inversion(sequence):
if (len(sequence) < 1 or len(sequence) > 199):
return "Error1"
for element in sequence:
if (element < -99 or element > 199):
return "Error2"
sequencel = list(sequence);
count = 0;
... | def count_inversion(sequence):
if len(sequence) < 1 or len(sequence) > 199:
return 'Error1'
for element in sequence:
if element < -99 or element > 199:
return 'Error2'
sequencel = list(sequence)
count = 0
fake = 0
for i in reversed(range(len(sequencel))):
for ... |
def grade(a):
if a >= 90:
print("A")
else:
if a >= 85:
print("B+")
else:
if a >= 80:
print("B")
else:
if a >= 75:
print("C+")
else:
if a >= 70:
print("C")
else:
if a >= 65:
print("D+")
... | def grade(a):
if a >= 90:
print('A')
elif a >= 85:
print('B+')
elif a >= 80:
print('B')
elif a >= 75:
print('C+')
elif a >= 70:
print('C')
elif a >= 65:
print('D+')
elif a >= 60:
print('D')
else:
print('F')
a = 'Error : Valu... |
class DDH2Exception(Exception):
def __init__(self, response):
self.status_code = response.status_code
self.text = response.text
def __repr__(self):
return 'DDH2Exception [{}]: {}'.format(self.status_code, self.text)
def __str__(self):
return self.text | class Ddh2Exception(Exception):
def __init__(self, response):
self.status_code = response.status_code
self.text = response.text
def __repr__(self):
return 'DDH2Exception [{}]: {}'.format(self.status_code, self.text)
def __str__(self):
return self.text |
class Queue:
def __init__(self):
self.array = []
self.length = 0
# adding the data to the end of the array
def enqueue(self, data):
self.array.append(data)
self.length += 1
return
# popping the data to the start of the array
def dequeue(self):
poped ... | class Queue:
def __init__(self):
self.array = []
self.length = 0
def enqueue(self, data):
self.array.append(data)
self.length += 1
return
def dequeue(self):
poped = self.array[0]
self.array.pop(0)
self.length -= 1
return poped
d... |
def minimax(arr):
arr.sort()
max = 0
min = 0
for i in range(len(arr)):
if i!=0:
max += arr[i]
if i!=4:
min += arr[i]
print(min,max)
if __name__=="__main__":
arr = list(map(int, input().rstrip().split()))
minimax(arr)
| def minimax(arr):
arr.sort()
max = 0
min = 0
for i in range(len(arr)):
if i != 0:
max += arr[i]
if i != 4:
min += arr[i]
print(min, max)
if __name__ == '__main__':
arr = list(map(int, input().rstrip().split()))
minimax(arr) |
# You need to print the value from 0 to 100
# whenever the number divisible by 3, then it should print as "fuzz"
# If the number is divisible 5, it should display as "buzz
# If the number id divided by 15, the result should be "fuzz_buzz"
# Simple method
for i in range(101):
if i % 15 == 0:
print("fuzz_buz... | for i in range(101):
if i % 15 == 0:
print('fuzz_buzz')
elif i % 5 == 0:
print('buzz')
elif i % 3 == 0:
print('fizz')
else:
print(i)
answer = ('fizz_buzz' if i % 15 == 0 else 'buzz' if i % 5 == 0 else 'fizz' if i % 3 == 0 else i for i in range(101)) |
#==============================================================================
#
# Copyright (c) 2019 Smells Like Donkey Software Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redist... | def decode_bid(bid):
suit = bid[-1:]
if suit in ('C', 'H', 'D', 'S', 'N'):
bid = bid[:-1]
else:
suit = None
return (bid, suit)
def decode_card(card):
if card[0] == '3':
return (3, card[1])
if card[0] == '5':
return (5, card[1])
if card[0] == '7':
retu... |
#!/usr/bin/env python3
def getMinimumCost(k, c):
min_cost = 0
temp = 0
previous = 0
if k >= len(c):
return sum(c)
c = sorted(c)
for x in reversed(c):
if temp == k:
temp = 0
previous += 1
min_cost += (previous + 1) * x
temp += 1
ret... | def get_minimum_cost(k, c):
min_cost = 0
temp = 0
previous = 0
if k >= len(c):
return sum(c)
c = sorted(c)
for x in reversed(c):
if temp == k:
temp = 0
previous += 1
min_cost += (previous + 1) * x
temp += 1
return min_cost
print(get_min... |
POSTGRES_URL="****"
POSTGRES_USER="****"
POSTGRES_PW="****"
POSTGRES_DB="****"
| postgres_url = '****'
postgres_user = '****'
postgres_pw = '****'
postgres_db = '****' |
#
# PySNMP MIB module ASCEND-MIBATMIF-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIBATMIF-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:26:28 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default... | (configuration,) = mibBuilder.importSymbols('ASCEND-MIB', 'configuration')
(object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_inters... |
#!/usr/bin/env pypy
n = int(input())
F = [1] * -~n
for i in range(2, n + 1):
for j in range(i, n + 1, i):
F[j] += 1
print(sum(e * v for e, v in enumerate(F))) | n = int(input())
f = [1] * -~n
for i in range(2, n + 1):
for j in range(i, n + 1, i):
F[j] += 1
print(sum((e * v for (e, v) in enumerate(F)))) |
# Large sum
x = 371072875339021027987979982208375902465101357402504637693767749000971264812489697007805041701826053874324986199524741059474233309513058123726617309629919422133635741615725224305633018110724061549082502306758820753934617117198031042104751377806324667689261670696623633820136378418383684178734361726757281... | x = 3710728753390210279879799822083759024651013574025046376937677490009712648124896970078050417018260538743249861995247410594742333095130581237266173096299194221336357416157252243056330181107240615490825023067588207539346171171980310421047513778063246676892616706966236338201363784183836841787343617267572811287981284997... |
# -*- coding: utf-8 -*-
class GraphDSLSemantics(object):
def digit(self, ast):
return ast
def symbol(self, ast):
return ast
def characters(self, ast):
return ast
def identifier(self, ast):
return ast
def string(self, ast):
return ast[1]
def natural(... | class Graphdslsemantics(object):
def digit(self, ast):
return ast
def symbol(self, ast):
return ast
def characters(self, ast):
return ast
def identifier(self, ast):
return ast
def string(self, ast):
return ast[1]
def natural(self, ast):
retur... |
n = int(input())
nums = list(input())
sum = 0
for i in range(0, n):
sum += int(nums[i])
print(sum) | n = int(input())
nums = list(input())
sum = 0
for i in range(0, n):
sum += int(nums[i])
print(sum) |
test_secret = "seB388LNHgxcuvAcg1pOV20_VR7uJWNGAznE0fOqKxg=".encode('ascii')
test_data = {
'valid':
'{"tx_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb", "case_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb","collection":'
'{"exercise_sid":"hfjdskf"},"metadata":{"user_id":"789473423","ru_ref":"12345678901A"... | test_secret = 'seB388LNHgxcuvAcg1pOV20_VR7uJWNGAznE0fOqKxg='.encode('ascii')
test_data = {'valid': '{"tx_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb", "case_id":"0f534ffc-9442-414c-b39f-a756b4adc6cb","collection":{"exercise_sid":"hfjdskf"},"metadata":{"user_id":"789473423","ru_ref":"12345678901A"}}', 'invalid': '{"cats":... |
'''
Create a script that reads something and show the type and all informations about it.
'''
something = input('Type something: ')
print(f'The type of this value is \033[34m{type(something)}\033[m')
print(f'Has only spaces? \033[34m{something.isspace()}\033[m')
print(f'Is numeric? \033[34m{something.isnumeric()}\... | """
Create a script that reads something and show the type and all informations about it.
"""
something = input('Type something: ')
print(f'The type of this value is \x1b[34m{type(something)}\x1b[m')
print(f'Has only spaces? \x1b[34m{something.isspace()}\x1b[m')
print(f'Is numeric? \x1b[34m{something.isnumeric()}\x... |
#
# This file contains the Python code from Program 8.12 of
# "Data Structures and Algorithms
# with Object-Oriented Design Patterns in Python"
# by Bruno R. Preiss.
#
# Copyright (c) 2003 by Bruno R. Preiss, P.Eng. All rights reserved.
#
# http://www.brpreiss.com/books/opus7/programs/pgm08_12.txt
#
class ChainedScatt... | class Chainedscattertable(HashTable):
def __init__(self, length):
super(ChainedScatterTable, self).__init__()
self._array = array(length)
for i in xrange(len(self._array)):
self._array[i] = self.Entry(None, self.NULL)
def __len__(self):
return len(self._array)
... |
font = CurrentFont()
min = 0
max = 0
for glyph in font:
if glyph.bounds != None:
if glyph.bounds[1] < min:
min = glyph.bounds[1]
if glyph.bounds[3] > max:
max = glyph.bounds[3]
print(min,max)
font.info.openTypeOS2TypoAscender = font.info.ascender
font.info.ope... | font = current_font()
min = 0
max = 0
for glyph in font:
if glyph.bounds != None:
if glyph.bounds[1] < min:
min = glyph.bounds[1]
if glyph.bounds[3] > max:
max = glyph.bounds[3]
print(min, max)
font.info.openTypeOS2TypoAscender = font.info.ascender
font.info.openTypeOS2TypoDe... |
class AtomicappBuilderException(Exception):
def __init__(self, cause):
super(AtomicappBuilderException, self).__init__(cause)
self.cause = cause
def to_str(self):
ret = str(self.cause)
if hasattr(self.cause, 'output'):
ret += ' Subprocess output: {0}'.format(self.cau... | class Atomicappbuilderexception(Exception):
def __init__(self, cause):
super(AtomicappBuilderException, self).__init__(cause)
self.cause = cause
def to_str(self):
ret = str(self.cause)
if hasattr(self.cause, 'output'):
ret += ' Subprocess output: {0}'.format(self.ca... |
class Employee:
#the self paremeter is a reference
#to the current instance of the class - w3schools/python
def __init__(self,name,age):
self.name = name
self.age = age
def compute_wage(self,hours, rate):
return hours * rate
| class Employee:
def __init__(self, name, age):
self.name = name
self.age = age
def compute_wage(self, hours, rate):
return hours * rate |
value = float(input())
print('NOTAS:')
for cell in [100, 50, 20, 10, 5, 2]:
print('{} nota(s) de R$ {},00'.format(int(value/cell), cell))
value = value % cell
print('MOEDAS:')
for coin in [1, 0.5, 0.25, 0.10, 0.05, 0.01]:
print('{} moeda(s) de R$ {:.2f}'.format(int(value/coin), coin).replace('.',','))
v... | value = float(input())
print('NOTAS:')
for cell in [100, 50, 20, 10, 5, 2]:
print('{} nota(s) de R$ {},00'.format(int(value / cell), cell))
value = value % cell
print('MOEDAS:')
for coin in [1, 0.5, 0.25, 0.1, 0.05, 0.01]:
print('{} moeda(s) de R$ {:.2f}'.format(int(value / coin), coin).replace('.', ','))
... |
# -----------------------------------------------------------
# Copyright (c) 2021. Danil Smirnov
# The football team recruits girls from 10 to 15 years old inclusive.
# Write a program that asks for the age and gender of an applicant
# using the gender designation m (for male) and f (for female)
# to... | class Applicant:
def __init__(self, name: str=None, age: int=None, gender: str=None):
self.name = name
self.age = age
self.gender = gender
self.can_join = self.check_membership(age, gender)
def check_membership(self, age: int, gender: str) -> bool:
return self.check_age... |
text_list = list(input())
length_matrix = int(input())
matrix = []
player_position = []
for i in range(length_matrix):
row = list(input())
matrix.append(row)
for j in range(length_matrix):
if row[j] == 'P':
player_position = [i, j]
directions = {
'up': (-1, 0),
'right': (0, 1),
... | text_list = list(input())
length_matrix = int(input())
matrix = []
player_position = []
for i in range(length_matrix):
row = list(input())
matrix.append(row)
for j in range(length_matrix):
if row[j] == 'P':
player_position = [i, j]
directions = {'up': (-1, 0), 'right': (0, 1), 'down': (1... |
class Layer(object):
def __init__(self):
self.input_shape = None
self.x =None
self.z = None
def initialize(self,folder):
pass
def train(self, inputs, train=True):
pass
def forward(self, inputs):
pass
def backward(self,delta_in,arg)... | class Layer(object):
def __init__(self):
self.input_shape = None
self.x = None
self.z = None
def initialize(self, folder):
pass
def train(self, inputs, train=True):
pass
def forward(self, inputs):
pass
def backward(self, delta_in, arg):
pa... |
# https://www.hackerrank.com/challenges/three-month-preparation-kit-queue-using-two-stacks/problem
class Queue:
def __init__(self, s1=[], s2=[]):
self.s1 = s1
self.s2 = s2
def isEmpty(self):
if not self.s1 and not self.s2: return True
return False
def size(self):
r... | class Queue:
def __init__(self, s1=[], s2=[]):
self.s1 = s1
self.s2 = s2
def is_empty(self):
if not self.s1 and (not self.s2):
return True
return False
def size(self):
return len(self.s1) + len(self.s2)
def enqueue(self, val):
self.s1.appen... |
# Copyright (C) 2018 Intel Corporation
#
# SPDX-License-Identifier: MIT
default_app_config = 'cvat.apps.annotation.apps.AnnotationConfig'
| default_app_config = 'cvat.apps.annotation.apps.AnnotationConfig' |
{
"targets": [
{
"target_name": "irf",
"sources": [
"irf/node.cpp",
"irf/randomForest.h",
"irf/randomForest.cpp",
"irf/MurmurHash3.h",
"irf/MurmurHash3.cpp"
],
'cflags': [ '<!@(pkg-config --cflags libsparsehash)' ],
'conditions': [
[ 'O... | {'targets': [{'target_name': 'irf', 'sources': ['irf/node.cpp', 'irf/randomForest.h', 'irf/randomForest.cpp', 'irf/MurmurHash3.h', 'irf/MurmurHash3.cpp'], 'cflags': ['<!@(pkg-config --cflags libsparsehash)'], 'conditions': [['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {'cflags_cc!': ['-fno-rtti', ... |
# SLICE
list = ['start', 'second', 'third', 'fourth', 'fifth']
list_fra = list[2]
print(list)
print(list_fra)
print(list[1:3])
print(list[-3:-1])
print(list[-3:])
print(list[:-3])
| list = ['start', 'second', 'third', 'fourth', 'fifth']
list_fra = list[2]
print(list)
print(list_fra)
print(list[1:3])
print(list[-3:-1])
print(list[-3:])
print(list[:-3]) |
class Solution:
def helper(self, n: int, k: int, first: int, curr: list, output: list) -> None:
if len(curr)==k:
output.append(curr[:])
else:
for i in range(first, n+1):
curr.append(i)
self.helper(n, k, i+1, curr, output)
curr.p... | class Solution:
def helper(self, n: int, k: int, first: int, curr: list, output: list) -> None:
if len(curr) == k:
output.append(curr[:])
else:
for i in range(first, n + 1):
curr.append(i)
self.helper(n, k, i + 1, curr, output)
... |
file1 = open('windows/contest.ppm','r')
Lines = file1.readlines()
count = 0
for line in Lines:
a, b, c = line.split()
count += 6
A = int(a)
B = int(b)
C = int(c)
while A/10 >= 1 :
count += 1
A /= 10
while B/10 >= 1 :
count += 1
B /= 10
while ... | file1 = open('windows/contest.ppm', 'r')
lines = file1.readlines()
count = 0
for line in Lines:
(a, b, c) = line.split()
count += 6
a = int(a)
b = int(b)
c = int(c)
while A / 10 >= 1:
count += 1
a /= 10
while B / 10 >= 1:
count += 1
b /= 10
while C / 10 >=... |
MONGODB_SETTINGS = {
'db': 'rsframgia',
'collection': 'viblo_posts',
'host': 'mongodb+srv://nhomanhemcututu:chubichthuy@cluster0.vnbw3.mongodb.net/rsframgia?authSource=admin&replicaSet=atlas-mi89bw-shard-0&w=majority&readPreference=primary&appname=MongoDB%20Compass&retryWrites=true&ssl=true'
}
PATH_DICTIONA... | mongodb_settings = {'db': 'rsframgia', 'collection': 'viblo_posts', 'host': 'mongodb+srv://nhomanhemcututu:chubichthuy@cluster0.vnbw3.mongodb.net/rsframgia?authSource=admin&replicaSet=atlas-mi89bw-shard-0&w=majority&readPreference=primary&appname=MongoDB%20Compass&retryWrites=true&ssl=true'}
path_dictionary = 'models/i... |
# Anders Poirel
# https://leetcode.com/problems/valid-parentheses
# Runtime: 28 ms, faster than 71.23% of Python3 online submissions for Valid Parentheses.
# Memory Usage: 12.8 MB, less than 100.00% of Python3 online submissions for Valid Parentheses.
class Solution:
def isValid(self, s: str) -> bool:
st... | class Solution:
def is_valid(self, s: str) -> bool:
stack = []
for i in range(len(s)):
if s[i] in ['{', '[', '(']:
stack.append(s[i])
else:
if len(stack) == 0:
return False
res = stack.pop()
... |
#2. Suppose the cover price of a book is **$24.95, but bookstores get a **40% discount. Shipping costs **$3 for the
# first copy and **75 cents for each additional copy. What is the total wholesale cost for **60 copies?
cover_price = 24.95
bkstore_dis = cover_price - (cover_price * 40)/100
ship_cost = 3 #only for t... | cover_price = 24.95
bkstore_dis = cover_price - cover_price * 40 / 100
ship_cost = 3
ship_cost_normal = 0.75
copies = 60
ship_calc = ship_cost_normal * (copies - 1) + ship_cost
books_purchase = bkstore_dis * copies
whole_sale = books_purchase + ship_calc
print('The total wholesale cost ${:.2f}'.format(whole_sale)) |
#
# Author: Luke Hindman
# Date: Mon Nov 6 16:13:43 MST 2017
# Description: Example of how to write to a file with Exception Handling
#
# Write a List of strings to a file
#
# Parameter
# outputFile - A String with the name of the file to write to
# dataList - A List of strings to write to the file
#
# Return ... | def write_list_to_file(outputFile, dataList):
try:
destination = open(outputFile, 'w')
destination.writelines(dataList)
destination.close()
except IOError:
print('Unable to write to output file' + outputFile)
my_file = 'names.txt'
name_list = ['Robin\n', 'Lily\n', 'Nora\n', 'Patr... |
power = {'BUSES': {'Area': 1.33155,
'Bus/Area': 1.33155,
'Bus/Gate Leakage': 0.00662954,
'Bus/Peak Dynamic': 0.0,
'Bus/Runtime Dynamic': 0.0,
'Bus/Subthreshold Leakage': 0.0691322,
'Bus/Subthreshold Leakage with power gating': 0.0259246,
'Gate... | power = {'BUSES': {'Area': 1.33155, 'Bus/Area': 1.33155, 'Bus/Gate Leakage': 0.00662954, 'Bus/Peak Dynamic': 0.0, 'Bus/Runtime Dynamic': 0.0, 'Bus/Subthreshold Leakage': 0.0691322, 'Bus/Subthreshold Leakage with power gating': 0.0259246, 'Gate Leakage': 0.00662954, 'Peak Dynamic': 0.0, 'Runtime Dynamic': 0.0, 'Subthres... |
# This file contains default error messages to be used.
notFound = {
"status": "error",
"type": "404 Not found",
"message": "Not found error"
}
serverError = {
"status": "error",
"type": "500 Server error",
"message": "Unknown internal server error"
}
badRequest = {
"status": "error",
... | not_found = {'status': 'error', 'type': '404 Not found', 'message': 'Not found error'}
server_error = {'status': 'error', 'type': '500 Server error', 'message': 'Unknown internal server error'}
bad_request = {'status': 'error', 'type': '400 Bad request', 'message': 'Bad request, please check your syntax and try again'} |
# -*- coding: utf-8 -*-
def main():
d = list(map(int, input().split()))
j = list(map(int, input().split()))
gold_amount = 0
for di, ji in zip(d, j):
gold_amount += max(di, ji)
print(gold_amount)
if __name__ == '__main__':
main()
| def main():
d = list(map(int, input().split()))
j = list(map(int, input().split()))
gold_amount = 0
for (di, ji) in zip(d, j):
gold_amount += max(di, ji)
print(gold_amount)
if __name__ == '__main__':
main() |
'''
For Admins:
This Template class is to help developers add additional cloud platforms to the software
'''
'''
class [Platform_NAME](object):
def __init__(self):
## For attributes use convention [NAME]_[FUNCTION]_[PARAM]
## The below attributes are strongly recomended to have within ... | """
For Admins:
This Template class is to help developers add additional cloud platforms to the software
"""
"\nclass [Platform_NAME](object):\n def __init__(self):\n ## For attributes use convention [NAME]_[FUNCTION]_[PARAM]\n ## The below attributes are strongly recomended to have within new plat... |
# https://leetcode.com/problems/determine-if-string-halves-are-alike/
def halves_are_alike(s):
vowels = {
'a': True,
'e': True,
'i': True,
'o': True,
'u': True,
'A': True,
'E': True,
'I': True,
'O': True,
'U': True,
}
... | def halves_are_alike(s):
vowels = {'a': True, 'e': True, 'i': True, 'o': True, 'u': True, 'A': True, 'E': True, 'I': True, 'O': True, 'U': True}
middle_index = len(s) // 2
(a, b) = (s[:middle_index], s[middle_index:])
(a_counter, b_counter) = (0, 0)
for char in a:
if char in vowels:
... |
def findReplaceString(s, indexes, sources, targets):
dupe_s = s[:]
for i in range(len(indexes)):
curr = s[indexes[i]]
if curr == sources[i][0]:
print(curr)
dupe_s = dupe_s.replace(sources[i], targets[i])
print(dupe_s)
return dupe_s | def find_replace_string(s, indexes, sources, targets):
dupe_s = s[:]
for i in range(len(indexes)):
curr = s[indexes[i]]
if curr == sources[i][0]:
print(curr)
dupe_s = dupe_s.replace(sources[i], targets[i])
print(dupe_s)
return dupe_s |
#
# Copyright (C) 2020 The Android Open Source Project
#
# 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 la... | layout = bool_scalar('layout', False)
i1 = input('op1', 'TENSOR_FLOAT32', '{1, 3, 3, 2}')
f1 = parameter('op2', 'TENSOR_FLOAT32', '{2, 2, 2, 4}', [0.0] * (2 * 2 * 2 * 4))
b1 = parameter('op3', 'TENSOR_FLOAT32', '{4}', [0.0] * 4)
o1 = output('op4', 'TENSOR_FLOAT32', '{1, 2, 2, 4}')
model().Operation('DEPTHWISE_CONV_2D',... |
class twitter_nlp_toolkit:
def __init__(self):
print("twitter_nlp_toolkit initialized")
| class Twitter_Nlp_Toolkit:
def __init__(self):
print('twitter_nlp_toolkit initialized') |
#difference between a given number and 17, if the number is greater than 17 return double the absolute difference.
x = int(input('Enter the number:'))
y = 17
n = y-x
if x > 17:
print(abs(n)*2)
else:
print(n) | x = int(input('Enter the number:'))
y = 17
n = y - x
if x > 17:
print(abs(n) * 2)
else:
print(n) |
def compare(physical_inventory, digital_inventory):
if physical_inventory == digital_inventory:
return {}
discrepencies = {}
for item, quantity in digital_inventory.items():
if item not in physical_inventory:
discrepencies[item] = {"physical":None,"digital":quantity}
for item, quantity in physical_inventory.... | def compare(physical_inventory, digital_inventory):
if physical_inventory == digital_inventory:
return {}
discrepencies = {}
for (item, quantity) in digital_inventory.items():
if item not in physical_inventory:
discrepencies[item] = {'physical': None, 'digital': quantity}
for... |
print(type(1))
print(type(1.1))
print(type('texto'))
print(type(False))
print(type(True))
| print(type(1))
print(type(1.1))
print(type('texto'))
print(type(False))
print(type(True)) |
app_host = '127.0.0.1'
app_port = 9090
app_desc = 'Local Server'
app_title = 'API Template'
app_key = 'AWEREG#Q$^#!%^QEH$##%'
admin_id = 'admin'
admin_pw = 'w4b35ya253vu5e6n'
db_type = 'mysql+pymysql'
db_host = 'localhost'
db_port = '33066'
db_name = 'hrms'
db_user = 'root'
db_pass = 'fnxm1qazXSW@' | app_host = '127.0.0.1'
app_port = 9090
app_desc = 'Local Server'
app_title = 'API Template'
app_key = 'AWEREG#Q$^#!%^QEH$##%'
admin_id = 'admin'
admin_pw = 'w4b35ya253vu5e6n'
db_type = 'mysql+pymysql'
db_host = 'localhost'
db_port = '33066'
db_name = 'hrms'
db_user = 'root'
db_pass = 'fnxm1qazXSW@' |
s = float(input('digite o salario do funcionario? R$'))
if s <= 1250.0:
c1 = (s * 15 / 100) + s
print('agora o funcionario vai ter o reajuste de 15%\nentao o salario dele que era R${:.2f}, passa a ser de R${:.2f}'.format(s, c1))
else:
c2 = (s * 10 / 100) + s
print('agora o fucionario vai ter o reajuste... | s = float(input('digite o salario do funcionario? R$'))
if s <= 1250.0:
c1 = s * 15 / 100 + s
print('agora o funcionario vai ter o reajuste de 15%\nentao o salario dele que era R${:.2f}, passa a ser de R${:.2f}'.format(s, c1))
else:
c2 = s * 10 / 100 + s
print('agora o fucionario vai ter o reajuste de 1... |
def name(firstname,lastname):
return f"My name is {firstname} {lastname}"
print(name("Atherv", "Patil"))
| def name(firstname, lastname):
return f'My name is {firstname} {lastname}'
print(name('Atherv', 'Patil')) |
# -*- coding: utf-8 -*-
def view_grid(grid_space):
for row in range(len(grid_space)):
for column in range(len(grid_space[0])):
print (grid_space[row][column],end = ' '),
if column == 2 or column == 5:
print('|', end=' ')
if row == 2 or row == 5:... | def view_grid(grid_space):
for row in range(len(grid_space)):
for column in range(len(grid_space[0])):
(print(grid_space[row][column], end=' '),)
if column == 2 or column == 5:
print('|', end=' ')
if row == 2 or row == 5:
print('')
prin... |
n = int(input())
sl = {}
for i in range(n):
s = input()
if not(s in sl):
sl[s] = 0
else:
sl[s] += 1
ans = []
s_max = max(sl.values())
for key in sl:
if sl[key] == s_max:
ans.append(key)
ans.sort()
for a in ans:
print(a)
| n = int(input())
sl = {}
for i in range(n):
s = input()
if not s in sl:
sl[s] = 0
else:
sl[s] += 1
ans = []
s_max = max(sl.values())
for key in sl:
if sl[key] == s_max:
ans.append(key)
ans.sort()
for a in ans:
print(a) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__title__ = 'lasotuvi'
__version__ = '1.0.1'
__author__ = 'doanguyen'
__author_email__ = 'dungnv2410 at gmail.com'
__license__ = 'MIT License'
| __title__ = 'lasotuvi'
__version__ = '1.0.1'
__author__ = 'doanguyen'
__author_email__ = 'dungnv2410 at gmail.com'
__license__ = 'MIT License' |
#Robot in a grid. Imagine a robot sitting in the upper left corner of a grid
#with r rows and c columns. The robot can only move in two directions,
#right and down, but certain cells are "off limits" such that the robot
#cannot step on them. Design an algorithm to find a path for the robot
#from the top left to the bot... | def has_path(n, m, clear):
if n < 0 or n >= len(clear) or m < 0 or (m >= len(clear[0])):
return False
if n == 0 and m == 0 and clear[n][m]:
return True
return clear[n, m] and (has_path(n, m - 1, clear) or has_path(n - 1, m, clear)) |
'''
Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root).
'''
# RECURSION
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val ... | """
Given the root of a binary tree, return the bottom-up level order traversal of its nodes' values. (i.e., from left to right, level by level from leaf to root).
"""
class Solution(object):
def driver(self, node, res, level):
if not node:
return res
if len(res) == level:
... |
# Print out numbers from 1 to 100 (including 100).
# But, instead of printing multiples of 3, print "Fizz"
# Instead of printing multiples of 5, print "Buzz"
# Instead of printing multiples of both 3 and 5, print "FizzBuzz".
for number in range(1, 101):
if number % 3 == 0 and number % 5 == 0:
print("FizzBu... | for number in range(1, 101):
if number % 3 == 0 and number % 5 == 0:
print('FizzBuzz')
elif number % 3 == 0:
print('Fizz')
elif number % 5 == 0:
print('Buzz')
else:
print(number)
counter = 1
while counter < 101:
if counter % 3 == 0 and counter % 5 == 0:
print(... |
# Stackmaps don't get emitted for code that's dead even if it exists in IR:
class C(object):
pass
c = C()
if 1 == 0:
c.x = 1
| class C(object):
pass
c = c()
if 1 == 0:
c.x = 1 |
class FlipFlop:
GATE_LVL = False
def __init__(self, clock, input, name="FlipFlop"):
self.clock = clock
self.input = input
self.output = None
self.outputp = None
self.output_star = None
self.name = name
self.build()
def logic(self):
pass
... | class Flipflop:
gate_lvl = False
def __init__(self, clock, input, name='FlipFlop'):
self.clock = clock
self.input = input
self.output = None
self.outputp = None
self.output_star = None
self.name = name
self.build()
def logic(self):
pass
... |
def SelectionSort(array):
# Traverse through all array elements
for i in range(len(array)):
# Find the minimum element in remaining
# unsorted array
min_idx = i
for j in range(i+1, len(array)):
if array[min_idx] > array[j]:
min_idx = j
# Swap the found minimum element with
# the first eleme... | def selection_sort(array):
for i in range(len(array)):
min_idx = i
for j in range(i + 1, len(array)):
if array[min_idx] > array[j]:
min_idx = j
(array[i], array[min_idx]) = (array[min_idx], array[i])
return array
array = [24, 6, 2, 9, 0, 7]
print(selection_sor... |
def yes_no_bool(val):
if val.lower() == 'yes':
return True
elif val.lower() == 'no':
return False
else:
raise ValueError(
'Cannot translate "{}" to bool'.format(val))
| def yes_no_bool(val):
if val.lower() == 'yes':
return True
elif val.lower() == 'no':
return False
else:
raise value_error('Cannot translate "{}" to bool'.format(val)) |
# Calculate distance of 1056 feet in yard and miles.
# 1 mile = 1760 yards and 1 yard = 3 feet.
feet = 1056
yard = feet / 3
print("1056 feet is",yard,"yards")
mile = yard / 1760
print("1056 feet is",mile,"miles") | feet = 1056
yard = feet / 3
print('1056 feet is', yard, 'yards')
mile = yard / 1760
print('1056 feet is', mile, 'miles') |
# -----
model_path_asr= 'models/asr/'
processor_path_asr='models/asr/'
device_asr = 'cuda'
min_len_sec=100
max_len_sec=150
# -----
model_path_punctuation='models/v1_4lang_q.pt'
step_punctuation=30
# -----
model_path_summarization= 'models/sum/'
tokenizer_path_summarization='models/sum/'
max_length_sum=50
step_sum=450
d... | model_path_asr = 'models/asr/'
processor_path_asr = 'models/asr/'
device_asr = 'cuda'
min_len_sec = 100
max_len_sec = 150
model_path_punctuation = 'models/v1_4lang_q.pt'
step_punctuation = 30
model_path_summarization = 'models/sum/'
tokenizer_path_summarization = 'models/sum/'
max_length_sum = 50
step_sum = 450
device_... |
# detection params
detector_path = 'retina_r50/'
box_score_thresh = 0.8
img_target_size = 480
img_max_size = 640
nms_thresh = 0.4
| detector_path = 'retina_r50/'
box_score_thresh = 0.8
img_target_size = 480
img_max_size = 640
nms_thresh = 0.4 |
def main():
n = int(input())
player_hp = [11 + i for i in range(n)]
i = 0
out = 0
out_indexes = []
while out < len(player_hp) - 1:
if player_hp[i] == 0:
i += 1
if i == len(player_hp):
i = 0
continue
hp = player_hp[target(play... | def main():
n = int(input())
player_hp = [11 + i for i in range(n)]
i = 0
out = 0
out_indexes = []
while out < len(player_hp) - 1:
if player_hp[i] == 0:
i += 1
if i == len(player_hp):
i = 0
continue
hp = player_hp[target(player_... |
#TODOS LOS METODOS QUE EXISTEN PARA HACER COMENTARIOS EN PYTHON
#ESTE ES UN EJEMPLO DE COMENTARIO
print('COMETARIOS EN EL CODIGO')
"ESTE ES OTRO EJEMPLO DE COMO HACER COMENTARIOS"
'''HOLA
ESTO ES EJEMPLO DE COMO HACER
COMENTARIOS MULTILINEA
'''
| print('COMETARIOS EN EL CODIGO')
'ESTE ES OTRO EJEMPLO DE COMO HACER COMENTARIOS'
'HOLA\nESTO ES EJEMPLO DE COMO HACER\nCOMENTARIOS MULTILINEA\n' |
#-*-coding:utf-8-*-
# Create dummy secrey key so we can use sessions
SECRET_KEY = '123456790'
# Create in-memory database
DATABASE_FILE = '../hhlyDevops_db.sqlite'
SQLALCHEMY_DATABASE_URI = 'sqlite:///' + DATABASE_FILE
SQLALCHEMY_ECHO = True
SQLALCHEMY_TRACK_MODIFICATIONS = True
SQLALCHEMY_COMMIT_ON_TEARDOWN = True
#... | secret_key = '123456790'
database_file = '../hhlyDevops_db.sqlite'
sqlalchemy_database_uri = 'sqlite:///' + DATABASE_FILE
sqlalchemy_echo = True
sqlalchemy_track_modifications = True
sqlalchemy_commit_on_teardown = True
bootstrap_use_minified = True
bootstrap_serve_local = True
bootstrap_cdn_force_ssl = True
bootstrap_... |
num1 = 10
print("Global variable num1=",num1)
def func(num2):
print("In function num2 = " ,num2)
num3 = 30
print("In function num3 = " ,num3)
func(20)
print("num1 again=",num1)
print("num3 outside function =",num3) # it will throw error since is local variable.
| num1 = 10
print('Global variable num1=', num1)
def func(num2):
print('In function num2 = ', num2)
num3 = 30
print('In function num3 = ', num3)
func(20)
print('num1 again=', num1)
print('num3 outside function =', num3) |
class Solution:
def removeElement(self, nums: List[int], val: int) -> int:
size = len(nums)
if (size == 0):
return 0
j = 0
k = size - 1
while (j < k) :
while (j < k and nums[j] != val):
j += 1
while (j < k and nums[k] == va... | class Solution:
def remove_element(self, nums: List[int], val: int) -> int:
size = len(nums)
if size == 0:
return 0
j = 0
k = size - 1
while j < k:
while j < k and nums[j] != val:
j += 1
while j < k and nums[k] == val:
... |
controlNum = list(map(int, input().split()))
controlArr = list(map(int, input().split()))
tvChannelCost = []
for i in range(10):
tvChannelCost.extend(list(map(int, input().split())))
origin, destination = input().split()
origin = int(origin)
destination = int(destination)
results = []
# check can go directly to ... | control_num = list(map(int, input().split()))
control_arr = list(map(int, input().split()))
tv_channel_cost = []
for i in range(10):
tvChannelCost.extend(list(map(int, input().split())))
(origin, destination) = input().split()
origin = int(origin)
destination = int(destination)
results = []
if destination > 9:
... |
size(200, 200)
path = BezierPath()
path.rect(50, 50, 100, 100)
path.reverse()
path.rect(75, 75, 50, 50)
drawPath(path)
| size(200, 200)
path = bezier_path()
path.rect(50, 50, 100, 100)
path.reverse()
path.rect(75, 75, 50, 50)
draw_path(path) |
class vowels:
__VOWELS = ["A", "a", "E", "e",
"I", "i", "O", "o",
"U", "u", "Y", "y"]
def __init__(self, text):
self.text = text
self.start = 0
@staticmethod
def is_vowel(char):
return char in vowels.__VOWELS
def __iter__(self):
return s... | class Vowels:
__vowels = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u', 'Y', 'y']
def __init__(self, text):
self.text = text
self.start = 0
@staticmethod
def is_vowel(char):
return char in vowels.__VOWELS
def __iter__(self):
return self
def __next__(self):... |
print(len("Python"))
print(len("programming"))
print(len(" "))
print("Maciej" + "Zurek")
print("Maciej " + "Zurek")
print("Maciej" + " Zurek")
print("Maciej" + " " + "Zurek")
print("a" "b" "c")
print("---" * 10)
| print(len('Python'))
print(len('programming'))
print(len(' '))
print('Maciej' + 'Zurek')
print('Maciej ' + 'Zurek')
print('Maciej' + ' Zurek')
print('Maciej' + ' ' + 'Zurek')
print('abc')
print('---' * 10) |
# Find the IP address in the following line using a regex group and the
# re.search function. Print the IP address using the match object group
# method, as well as the index of where the grouping starts and ends.
log = '208.115.111.73 - - [01/Apr/2013:06:30:26 -0700] "GET /nanowiki/index.php/1_November_2007_-_Day_1 HT... | log = '208.115.111.73 - - [01/Apr/2013:06:30:26 -0700] "GET /nanowiki/index.php/1_November_2007_-_Day_1 HTTP/1.1" 404 36 "-" "Mozilla/5.0 (compatible; Ezooms/1.0; ezooms.bot@gmail.com)"' |
__author__ = 'ivan.arar@gmail.com'
class Paging(object):
def __init__(self, paging_data):
self.paging_data = paging_data
def has_next(self):
if int(self.paging_data['page']) == int(self.paging_data['pages']):
return False
else:
return True
def has_previou... | __author__ = 'ivan.arar@gmail.com'
class Paging(object):
def __init__(self, paging_data):
self.paging_data = paging_data
def has_next(self):
if int(self.paging_data['page']) == int(self.paging_data['pages']):
return False
else:
return True
def has_previous... |
f = open("01.txt", "r")
past = 150 # using this as base case since first number on file is 150 (prevent dec or inc count from chaning)
dec = 0
inc = 0
for i in f.read().splitlines():
if i > past:
inc += 1
elif i < past:
dec += 1
past = i
print(inc)
| f = open('01.txt', 'r')
past = 150
dec = 0
inc = 0
for i in f.read().splitlines():
if i > past:
inc += 1
elif i < past:
dec += 1
past = i
print(inc) |
mapping = {
"files": [
("site-example.conf", "/etc/nginx/sites-available/site-example.conf")
],
"templates": [
("index.html.tmpl", "/var/www/html/index.html")
]
}
| mapping = {'files': [('site-example.conf', '/etc/nginx/sites-available/site-example.conf')], 'templates': [('index.html.tmpl', '/var/www/html/index.html')]} |
#----------------------------------------------------------------------------------------------------------
#
# AUTOMATICALLY GENERATED FILE TO BE USED BY W_HOTBOX
#
# NAME: Toggle Adjust Points
# COLOR: #3a97bd
#
#---------------------------------------------------------------------------------------------------------... | ns = nuke.selectedNodes()
for n in ns:
n.knob('toggleAdjustKnobs').execute() |
#!/usr/bin/env python3
# ## Algorithm:
#
# - Initialize an empty set to store the already visited elements
# - Iterate through the list
# - If the current element is in the set, return True
# - Otherwise, add the element to the set
#
# ## Time Complexity:
#
# - O(n) to run through the entire list
# - O(1) to add an... | class Solution:
def contains_duplicate(self, nums: List[int]) -> bool:
seen = set()
for x in nums:
if x in seen:
return True
else:
seen.add(x)
return False |
#==============================================================================================
#Multiples of 3 and 5
#===============================================================================================
#Problem 1
#If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and... | rezultat = [i for i in range(1000) if i % 3 == 0 or i % 5 == 0]
print(sum(rezultat)) |
# Do not edit this file directly.
# It was auto-generated by: code/programs/reflexivity/reflexive_refresh
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_file")
def pthreadpool():
http_archive(
name = "pthreadpool",
bu... | load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_file')
def pthreadpool():
http_archive(name='pthreadpool', build_file='//bazel/deps/pthreadpool:build.BUILD', sha256='7a523b439a996e2f4376169279409059101f2f71eed4fcc915971368990504a0', st... |
#
# PySNMP MIB module HPICF-SAVI-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HPICF-SAVI-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:33:53 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_union, constraints_intersection, single_value_constraint, value_size_constraint, value_range_constraint) ... |
__title__ = 'db_cache'
__description__ = 'DB Cache'
__url__ = 'https://github.com/dskrypa/db_cache'
__version__ = '2020.09.19-1'
__author__ = 'Doug Skrypa'
__author_email__ = 'dskrypa@gmail.com'
__copyright__ = 'Copyright 2020 Doug Skrypa'
| __title__ = 'db_cache'
__description__ = 'DB Cache'
__url__ = 'https://github.com/dskrypa/db_cache'
__version__ = '2020.09.19-1'
__author__ = 'Doug Skrypa'
__author_email__ = 'dskrypa@gmail.com'
__copyright__ = 'Copyright 2020 Doug Skrypa' |
'''
Created on 29 Oct 2009
@author: charanpal
An abstract class which reads graphs from files.
'''
class GraphReader(object):
def __init__(self):
pass
def readFromFile(self, fileName):
pass
| """
Created on 29 Oct 2009
@author: charanpal
An abstract class which reads graphs from files.
"""
class Graphreader(object):
def __init__(self):
pass
def read_from_file(self, fileName):
pass |
class FPS:
sum_e=(911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497)
sum_ie=(86583718, 372528824, 373294451, 645684063, 112220581, 69... | class Fps:
sum_e = (911660635, 509520358, 369330050, 332049552, 983190778, 123842337, 238493703, 975955924, 603855026, 856644456, 131300601, 842657263, 730768835, 942482514, 806263778, 151565301, 510815449, 503497456, 743006876, 741047443, 56250497)
sum_ie = (86583718, 372528824, 373294451, 645684063, 112220581... |
def build_shopkeeper_dialog(scene, buyer, seller):
class ItemDisplay(gui.BorderedControl):
def __init__(self, item, depreciate=True, **kwargs):
gui.BorderedControl.__init__(self, **kwargs)
self.item = item
self.depreciate = depreciate
self._initComponents()
... | def build_shopkeeper_dialog(scene, buyer, seller):
class Itemdisplay(gui.BorderedControl):
def __init__(self, item, depreciate=True, **kwargs):
gui.BorderedControl.__init__(self, **kwargs)
self.item = item
self.depreciate = depreciate
self._initComponents()
... |
input_file = 'input.txt'
def process_input():
with open(input_file) as f:
content = f.readlines()
# stripping whitespace
stripped = [x.strip() for x in content]
return stripped
def build_rules(raw):
# converts the line-by-line representation
# into a dictionary, keyed by the bag (e.g. "mirrored bla... | input_file = 'input.txt'
def process_input():
with open(input_file) as f:
content = f.readlines()
stripped = [x.strip() for x in content]
return stripped
def build_rules(raw):
rules = {}
for line in raw:
spl = line.split(' bags contain')
current = spl[0]
buffer = []... |
# Enter your code here. Read input from STDIN. Print output to STDOUT
n_input = input()
int_input = input().split()
print(all([int(i) > 0 for i in int_input]) and any([j == j[::-1] for j in int_input]))
| n_input = input()
int_input = input().split()
print(all([int(i) > 0 for i in int_input]) and any([j == j[::-1] for j in int_input])) |
# Class Method
class sample:
x = 10
@classmethod
def modify(cls):
cls.x += 1
s1 = Sample()
s2 = Sample()
print(s1.x, s2.x)
s1.modify()
print(s1.x, s2.x)
s1.x += 1
print(s1.x, s2.x)
| class Sample:
x = 10
@classmethod
def modify(cls):
cls.x += 1
s1 = sample()
s2 = sample()
print(s1.x, s2.x)
s1.modify()
print(s1.x, s2.x)
s1.x += 1
print(s1.x, s2.x) |
# Settings for finals
# Foreign language classes for finals logic
FOREIGN_LANGUAGES = {
'ARABIC': ['100A', '100B', '1A', '1B', '20A', '20B'],
'ARMENI': ['101A', '101B', '1A', '1B'],
'BANGLA': ['101A', '101B', '1A', '1B'],
'BERMESE': ['1A', '1B'],
'BOSCRSR': ['117A', '117B', '27A', '27B'],
'BULGA... | foreign_languages = {'ARABIC': ['100A', '100B', '1A', '1B', '20A', '20B'], 'ARMENI': ['101A', '101B', '1A', '1B'], 'BANGLA': ['101A', '101B', '1A', '1B'], 'BERMESE': ['1A', '1B'], 'BOSCRSR': ['117A', '117B', '27A', '27B'], 'BULGARI': ['118A', '118B', '28A', '28B'], 'CATALAN': ['101', '102'], 'CELTIC': ['16', '85', '86'... |
#%%
file = open("../dataset/novel.txt")
# %%
characters = []
file2 = open("../dataset/character.txt")
for line in file2:
if line != '\n':
line = line.strip('\n')
characters.append(line)
# %%
relationship = [[0 for column in range(len(characters))] for row in range(len(characters))]
lines = file.re... | file = open('../dataset/novel.txt')
characters = []
file2 = open('../dataset/character.txt')
for line in file2:
if line != '\n':
line = line.strip('\n')
characters.append(line)
relationship = [[0 for column in range(len(characters))] for row in range(len(characters))]
lines = file.readlines()
for li... |
with open("sample.txt",'r+') as f:
for line in f:
for letter in line:
print(letter)
| with open('sample.txt', 'r+') as f:
for line in f:
for letter in line:
print(letter) |
class Solution:
def numUniqueEmails(self, emails):
_dict = {}
for email in emails:
at_idx = email.index('@')
if email[:at_idx].count('+') == 0:
if email[:at_idx].count('.') == 0:
new_mail_address = email
else:
... | class Solution:
def num_unique_emails(self, emails):
_dict = {}
for email in emails:
at_idx = email.index('@')
if email[:at_idx].count('+') == 0:
if email[:at_idx].count('.') == 0:
new_mail_address = email
else:
... |
search_fruit = 'apple'
fruit_box = ['banana', 'mango', 'apple', 'pineapple']
for fruit in fruit_box:
if fruit == search_fruit:
print('Found fruit : {}'.format(search_fruit))
break
else:
print('{} fruit not found'.format(search_fruit))
| search_fruit = 'apple'
fruit_box = ['banana', 'mango', 'apple', 'pineapple']
for fruit in fruit_box:
if fruit == search_fruit:
print('Found fruit : {}'.format(search_fruit))
break
else:
print('{} fruit not found'.format(search_fruit)) |
apps = ["admin", "AjaxSpreadsheet", "AppointmentManager", "ArXivInterface", "BingApi", "BitcoinExample", "CarSales", "CeleryIntegrationExample", "CookbookExample", "CssDesigner", "CustomerRelationshipManagement", "DnaAnalysisNeedlemanWunsh", "eCardsOnMap", "EmailContactForm", "EStoreExample", "FacebookClone", "Facebook... | apps = ['admin', 'AjaxSpreadsheet', 'AppointmentManager', 'ArXivInterface', 'BingApi', 'BitcoinExample', 'CarSales', 'CeleryIntegrationExample', 'CookbookExample', 'CssDesigner', 'CustomerRelationshipManagement', 'DnaAnalysisNeedlemanWunsh', 'eCardsOnMap', 'EmailContactForm', 'EStoreExample', 'FacebookClone', 'Facebook... |
# Approach 1
class Solution:
def maxProfit(self, prices: List[int]) -> int:
i = 0
maxprofit = 0
v = prices[0]
p = prices[0]
while i < len(prices) - 1:
while i < len(prices) - 1 and prices[i] > prices[i + 1]:
i += 1
v = prices[i]
... | class Solution:
def max_profit(self, prices: List[int]) -> int:
i = 0
maxprofit = 0
v = prices[0]
p = prices[0]
while i < len(prices) - 1:
while i < len(prices) - 1 and prices[i] > prices[i + 1]:
i += 1
v = prices[i]
i += 1... |
class Parameters:
course_number_per_program = {"min":3,"max":6}
remote_learning_start_year = 2018
professor_number = 3000
student_enrollment_year = {"start":2015,"end":2016}
student_number = 20000
before_remote_learning_drop_off = {"rate":10,"remote":20}
after_remote_learning_drop_off = {"ra... | class Parameters:
course_number_per_program = {'min': 3, 'max': 6}
remote_learning_start_year = 2018
professor_number = 3000
student_enrollment_year = {'start': 2015, 'end': 2016}
student_number = 20000
before_remote_learning_drop_off = {'rate': 10, 'remote': 20}
after_remote_learning_drop_o... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.