content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
# Copyright (c) 2018 PrimeVR
# Distributed under the MIT software license, see the accompanying
# file LICENSE or http://www.opensource.org/licenses/mit-license.php
def united_bitcoin_qualification(span):
ubtc_start = 494000
ubtc_end = 502315
if not span['defunded']:
return None
if (span['defun... | def united_bitcoin_qualification(span):
ubtc_start = 494000
ubtc_end = 502315
if not span['defunded']:
return None
if span['defunded']['block'] < ubtc_end and span['defunded']['block'] > ubtc_start:
return span['defunded']['value']
return None
united_bitcoin = {'id': 'united-bitcoin'... |
class Protocol:
def __init__(self, data):
self.iniciator = data.get('iniciator', {})
self.responder = data.get('responder', {})
| class Protocol:
def __init__(self, data):
self.iniciator = data.get('iniciator', {})
self.responder = data.get('responder', {}) |
N = int(input())
t_list = [int(input()) for _ in range(N)]
if N == 1:
print(t_list[0])
exit()
ans = float("inf")
for bit in range(2 ** N):
one = 0
zero = 0
for j in range(N):
if 1 & bit >> j:
one += t_list[j]
else:
zero += t_list[j]
ans = min(ans, max(one... | n = int(input())
t_list = [int(input()) for _ in range(N)]
if N == 1:
print(t_list[0])
exit()
ans = float('inf')
for bit in range(2 ** N):
one = 0
zero = 0
for j in range(N):
if 1 & bit >> j:
one += t_list[j]
else:
zero += t_list[j]
ans = min(ans, max(one,... |
# This controls how frequently the whole batch is iterated over vs only
# {QUICK_EVAL_PERCENT} of the data
QUICK_EVAL_FREQUENCY = 0
QUICK_EVAL_PERCENT = 0.05
QUICK_EVAL_TRAIN_PERCENT = 0.025
def train(
device,
model,
manifold,
dimension,
data,
optimizer,
loss_pa... | quick_eval_frequency = 0
quick_eval_percent = 0.05
quick_eval_train_percent = 0.025
def train(device, model, manifold, dimension, data, optimizer, loss_params, n_epochs, eval_every, sample_neighbors_every, lr_scheduler, shared_params, thread_number, feature_manifold, conformal_loss_params, tensorboard_watch={}, eval_d... |
class MyClass:
def __init__(self, value): self.__value = value
def __int__(self): return int(self.__value)
c = MyClass(1.23)
print(int(c))
| class Myclass:
def __init__(self, value):
self.__value = value
def __int__(self):
return int(self.__value)
c = my_class(1.23)
print(int(c)) |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"component_save_data_fixture": "tst.components.ipynb",
"column_transformer_data_fixture": "tst.compose.ipynb",
"multi_split_data_fixture": "tst.compose.ipynb",
"test_pipeline_find_l... | __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'component_save_data_fixture': 'tst.components.ipynb', 'column_transformer_data_fixture': 'tst.compose.ipynb', 'multi_split_data_fixture': 'tst.compose.ipynb', 'test_pipeline_find_last_fitted_model_seq_others': 'tst.compose.ipynb', 'test_pipeline_fi... |
def solution():
data = open(r'inputs\day13.in').readlines()
print('Part 1 result: ' + str(part1(data)))
print('Part 2 result: ' + str(part2(data)))
def part1(data):
# build out the grid and instructions from our data
grid, fold_instructions = build_grid_and_instructions(data)
# run the first f... | def solution():
data = open('inputs\\day13.in').readlines()
print('Part 1 result: ' + str(part1(data)))
print('Part 2 result: ' + str(part2(data)))
def part1(data):
(grid, fold_instructions) = build_grid_and_instructions(data)
grid = fold(grid, fold_instructions[0])
return len(grid)
def part2(... |
cappacity = 0
lines = int(input())
for i in range(0, lines):
water = int(input())
if cappacity + water > 255:
print("Insufficient capacity!")
continue
else:
cappacity += water
print(cappacity) | cappacity = 0
lines = int(input())
for i in range(0, lines):
water = int(input())
if cappacity + water > 255:
print('Insufficient capacity!')
continue
else:
cappacity += water
print(cappacity) |
# Write your code here
def query(arr, x, l, r, k):
for i in range(l-1,r):
if arr[i] == x:
k -= 1
if k == 0:
print(i+1)
return
print(-1)
return
def update(arr, ind, value):
arr[ind-1] = value
n,x = map(int, input().split())
arr ... | def query(arr, x, l, r, k):
for i in range(l - 1, r):
if arr[i] == x:
k -= 1
if k == 0:
print(i + 1)
return
print(-1)
return
def update(arr, ind, value):
arr[ind - 1] = value
(n, x) = map(int, input().split())
arr = list(map(int, input().split()))
q =... |
def foo(a, b):
a = a + b
print(a, b)
def bar(x):
x += 1
print(x+1)
x = x + 1
return x
def multi(
a,
b,
c=12):
pass
if a is None:
print(123)
if a == b and \
True:
print(bla)
class A:
def bar(self, aa):
print(aa)
| def foo(a, b):
a = a + b
print(a, b)
def bar(x):
x += 1
print(x + 1)
x = x + 1
return x
def multi(a, b, c=12):
pass
if a is None:
print(123)
if a == b and True:
print(bla)
class A:
def bar(self, aa):
print(aa) |
def part_one(data_input: list) -> int:
frequency = 0
for line in data_input:
frequency += int(line)
return frequency
def part_two(data_input: list) -> int:
change_after_iteration = sum(data_input)
if not change_after_iteration:
return change_after_iteration
best_n_repetition =... | def part_one(data_input: list) -> int:
frequency = 0
for line in data_input:
frequency += int(line)
return frequency
def part_two(data_input: list) -> int:
change_after_iteration = sum(data_input)
if not change_after_iteration:
return change_after_iteration
best_n_repetition = f... |
'''
This is the 5th problem on Day 3 based on if else and if statements
In this problem, we are going to build a love calculator which shall calculate compatibility between 2 people
if score < 10 or score > 90, we have to print Your score is this, you go together like coke and mentos
if score >=40 and score <= 50 we h... | """
This is the 5th problem on Day 3 based on if else and if statements
In this problem, we are going to build a love calculator which shall calculate compatibility between 2 people
if score < 10 or score > 90, we have to print Your score is this, you go together like coke and mentos
if score >=40 and score <= 50 we h... |
# learn about boolean
#a=True
#b=False
a=not True
b=not False
print(a)
print(b) | a = not True
b = not False
print(a)
print(b) |
def affiche_table(liste):
...
def construit_table(largeur, hauteur):
tab = [[],[]]
for nb in range(largeur):
tab[0].append(nb+1)
for nb in range(hauteur):
tab[1].append(nb+1)
for line in hauteur:
tab.append([])
return tab
| def affiche_table(liste):
...
def construit_table(largeur, hauteur):
tab = [[], []]
for nb in range(largeur):
tab[0].append(nb + 1)
for nb in range(hauteur):
tab[1].append(nb + 1)
for line in hauteur:
tab.append([])
return tab |
name = "Gary"
number = len(name) * 3
print("Hello {}, your lucky number is {}".format(name, number))
| name = 'Gary'
number = len(name) * 3
print('Hello {}, your lucky number is {}'.format(name, number)) |
# DP
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]
b = [[0] * N for _ in range(2)]
b[0][0] = A[0][0]
for i in range(1, N):
b[0][i] = b[0][i - 1] + A[0][i]
b[1][0] = b[0][0] + A[1][0]
for i in range(1, N):
b[1][i] = max(b[1][i - 1], b[0][i]) + A[1][i]
print(b[1][N - 1])
| n = int(input())
a = [list(map(int, input().split())) for _ in range(2)]
b = [[0] * N for _ in range(2)]
b[0][0] = A[0][0]
for i in range(1, N):
b[0][i] = b[0][i - 1] + A[0][i]
b[1][0] = b[0][0] + A[1][0]
for i in range(1, N):
b[1][i] = max(b[1][i - 1], b[0][i]) + A[1][i]
print(b[1][N - 1]) |
class Solution:
def missingNumber(self, nums: List[int]) -> int:
ideal_sum = 0
actual_sum = 0
for i in range(0, len(nums)):
ideal_sum += i
actual_sum += nums[i]
ideal_sum += len(nums)
return ideal_sum - actual_sum | class Solution:
def missing_number(self, nums: List[int]) -> int:
ideal_sum = 0
actual_sum = 0
for i in range(0, len(nums)):
ideal_sum += i
actual_sum += nums[i]
ideal_sum += len(nums)
return ideal_sum - actual_sum |
class TokenType:
ID = 'ID'
STRING = 'STRING'
NUMBER = 'NUMBER'
REGEX = 'REGEX'
COMMA = 'COMMA'
L_BRACKET = 'LEFT BRACKET'
R_BRACKET = 'RIGHT BRACKET'
COLON = 'COLON'
SEMICOLON = 'SEMICOLON'
NEW_LINE = 'NEW LINE'
TAB = 'TAB'
class Token:
def __init__(self, token_type, lex... | class Tokentype:
id = 'ID'
string = 'STRING'
number = 'NUMBER'
regex = 'REGEX'
comma = 'COMMA'
l_bracket = 'LEFT BRACKET'
r_bracket = 'RIGHT BRACKET'
colon = 'COLON'
semicolon = 'SEMICOLON'
new_line = 'NEW LINE'
tab = 'TAB'
class Token:
def __init__(self, token_type, le... |
array = list(input().split(","))
def find_single(array):
for item in array:
if array.count(item) == 1:
return item
print(find_single(array))
| array = list(input().split(','))
def find_single(array):
for item in array:
if array.count(item) == 1:
return item
print(find_single(array)) |
n = int(input())
height = list(map(int,input().strip(" ").split()))
distinct = set(height)
average = sum(distinct)/len(distinct)
print(average)
| n = int(input())
height = list(map(int, input().strip(' ').split()))
distinct = set(height)
average = sum(distinct) / len(distinct)
print(average) |
# Write your solution for 1.4 here!
def is_prime(x):
a=0
for i in range(2,x):
if x%i==0:
a+=1
if a==1:
return(False)
print("False")
else:
return(True)
print("True")
is_prime(13)
is_prime(4)
| def is_prime(x):
a = 0
for i in range(2, x):
if x % i == 0:
a += 1
if a == 1:
return False
print('False')
else:
return True
print('True')
is_prime(13)
is_prime(4) |
def runner_cli(augury, args):
assert args.cmd == 'runner'
paths = {
'status': set_status,
'config': get_config,
'artifacts': add_artifacts,
}
paths[args.runner_cmd](augury, args)
def set_status(augury, args):
if args.status:
print(augury.set_runner_status(args.stat... | def runner_cli(augury, args):
assert args.cmd == 'runner'
paths = {'status': set_status, 'config': get_config, 'artifacts': add_artifacts}
paths[args.runner_cmd](augury, args)
def set_status(augury, args):
if args.status:
print(augury.set_runner_status(args.status))
else:
print(augu... |
locit_settings = {
'scaling': 'none'
}
coral_settings = {
'scaling': 'none' # needs to be none with separate test set!
}
pwmstl_settings = {
'mu': 0.1,
'rho': 1.0,
'beta1': 10.0,
'beta2': 10.0,
'kernel': 'linear',
'max_alpha': 10.0,
'tau_lambda': 1.0
} | locit_settings = {'scaling': 'none'}
coral_settings = {'scaling': 'none'}
pwmstl_settings = {'mu': 0.1, 'rho': 1.0, 'beta1': 10.0, 'beta2': 10.0, 'kernel': 'linear', 'max_alpha': 10.0, 'tau_lambda': 1.0} |
#
# Copyright 2022 Duncan Rose
#
# 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 or agreed to in writing... | fill = 8080
class Spacereq:
def __init__(self, minx, desx, maxx, miny, desy, maxy):
self._xmax = _fill_or(maxx)
self._xmin = _fill_or(minx)
self._xpref = _fill_or(desx)
self._ymax = _fill_or(maxy)
self._ymin = _fill_or(miny)
self._ypref = _fill_or(desy)
def __r... |
errors = {
'NotFound': {
'status': 404,
},
'BadRequest': {
'status': 400,
},
'MethodNotAllowed': {
'status': 405,
}
} | errors = {'NotFound': {'status': 404}, 'BadRequest': {'status': 400}, 'MethodNotAllowed': {'status': 405}} |
# Copyright (c) 2019-2020 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publi... | install = ['libva', 'libva-utils', 'gmmlib', 'ffmpeg', 'metrics-calc-lite', 'media-driver', 'mediasdk']
test_script_path = infra_path / 'driver_tests'
test_env = {'MFX_HOME': '/opt/intel/mediasdk', 'LD_LIBRARY_PATH': '/opt/intel/mediasdk/lib64', 'LIBVA_DRIVERS_PATH': '/opt/intel/msdk_driver/lib64', 'LIBVA_DRIVER_NAME':... |
# This is my first Python Project using Project Euler.
# Find the sum of all the multiples of 3 or 5 below 1000.
# The easy and efficient way
# (1 + 2 + 3 + .... n) = 1/2 n(n+1)
print(0.5*((333*1002)+(199*1000)-(66*1005)))
# The second way
# I am defining a function to sum up all of the multiples of 3 and 5... | print(0.5 * (333 * 1002 + 199 * 1000 - 66 * 1005))
def sum():
number = range(1, 1000)
def multiple_of_3():
for x in Number:
y = x / 3
print(y)
if type(y) == int:
print(x)
else:
pass
multiple_of_3()
sum()
a = range(1000)
count = 0
for ... |
'''
File: __init__.py
Project: src
File Created: Sunday, 28th February 2021 3:03:13 am
Author: Sparsh Dutta (sparsh.dtt@gmail.com)
-----
Last Modified: Sunday, 28th February 2021 3:03:13 am
Modified By: Sparsh Dutta (sparsh.dtt@gmail.com>)
-----
Copyright 2021 Sparsh Dutta
'''
| """
File: __init__.py
Project: src
File Created: Sunday, 28th February 2021 3:03:13 am
Author: Sparsh Dutta (sparsh.dtt@gmail.com)
-----
Last Modified: Sunday, 28th February 2021 3:03:13 am
Modified By: Sparsh Dutta (sparsh.dtt@gmail.com>)
-----
Copyright 2021 Sparsh Dutta
""" |
jpg1 = 0
jpg2 = 0
img1 = 0
img2 = 0
def setup():
global jpg1, jpg2
background(100)
smooth()
size(1200, 700)
noStroke()
jpg1 = loadImage ('br1.jpg')
jpg2 = loadImage ('bread1.gif')
def draw():
global jpg1, jpg2
if ( frameCount == 1):
image... | jpg1 = 0
jpg2 = 0
img1 = 0
img2 = 0
def setup():
global jpg1, jpg2
background(100)
smooth()
size(1200, 700)
no_stroke()
jpg1 = load_image('br1.jpg')
jpg2 = load_image('bread1.gif')
def draw():
global jpg1, jpg2
if frameCount == 1:
image(jpg1, 0, 0)
val1 = int(random(0, ... |
def slices(series, length):
if len(series) <= 0 or length <= 0:
raise ValueError("invalid arguments.")
if length > len(series):
raise ValueError(f"Cannot get {length} digit series from a {len(series)} digit string.")
resultList = []
diff = len(series) - length +1
for i in range (... | def slices(series, length):
if len(series) <= 0 or length <= 0:
raise value_error('invalid arguments.')
if length > len(series):
raise value_error(f'Cannot get {length} digit series from a {len(series)} digit string.')
result_list = []
diff = len(series) - length + 1
for i in range(d... |
# parsetab.py
# This file is automatically generated. Do not edit.
# pylint: disable=W,C,R
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'AND ASSIGN COMMA DEF DIFF DIVIDE ELIF ELSE EQ FALSE FLOAT FOR GET GT ID IF IN INTEGER LBRACE LBRACKET LET LPAREN LT MINUS MINUSMINUS MULTIPLY NOT OR PLUS PLUSPLUS RBRAC... | _tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'AND ASSIGN COMMA DEF DIFF DIVIDE ELIF ELSE EQ FALSE FLOAT FOR GET GT ID IF IN INTEGER LBRACE LBRACKET LET LPAREN LT MINUS MINUSMINUS MULTIPLY NOT OR PLUS PLUSPLUS RBRACE RBRACKET RPAREN SEMI STRING TRUE WHILEcode : code sent\n\t\t\t\t| sent\n\t\t\t\t| emptysent ... |
# To create a variable
character_name = "Jin"
character_age = "99"
print(character_name + " is " + character_age + " years old.")
# reassigning the variable
character_name = "mochi"
print(character_name + " is " + character_age + " years old.")
print("jin\nacademy")
print(len(character_name))
# to create a new line ... | character_name = 'Jin'
character_age = '99'
print(character_name + ' is ' + character_age + ' years old.')
character_name = 'mochi'
print(character_name + ' is ' + character_age + ' years old.')
print('jin\nacademy')
print(len(character_name))
my_character = 'mochi'
print(my_character[3])
print(my_character.index('h'))... |
def gimme5():
return 5
def gimme3():
return 3
| def gimme5():
return 5
def gimme3():
return 3 |
def sqrt_approx(num):
i = 0
minsq = 0
maxsq = 0
while i <= num:
if i * i <= num:
minsq = i
if i * i >= num:
maxsq = i
break
i = i + 1
return minsq, maxsq
for i in range(0, 26):
print(i, sqrt_approx(i))
| def sqrt_approx(num):
i = 0
minsq = 0
maxsq = 0
while i <= num:
if i * i <= num:
minsq = i
if i * i >= num:
maxsq = i
break
i = i + 1
return (minsq, maxsq)
for i in range(0, 26):
print(i, sqrt_approx(i)) |
#
# PySNMP MIB module Wellfleet-IPEX-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Wellfleet-IPEX-MIB
# Produced by pysmi-0.3.4 at Wed May 1 15:40:34 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, value_size_constraint, single_value_constraint, constraints_intersection, constraints_union) ... |
## lists7.py
def main():
pals = ['Bob','Rob','Fred','Amy','Sarah']
pals2 = pals ## both variables refer to SAME LIST
pals.remove('Fred')
print(pals2) ### crude
pals3 = []
for p in pals:
pals3.append(p)
print(pals3) ### crude dump
del pals[0] ### dele... | def main():
pals = ['Bob', 'Rob', 'Fred', 'Amy', 'Sarah']
pals2 = pals
pals.remove('Fred')
print(pals2)
pals3 = []
for p in pals:
pals3.append(p)
print(pals3)
del pals[0]
print(pals)
main() |
class fcf(object):
nr_cortes = None
coef_vf = None
termo_i = None
estagio = None
def __init__(self, estagio):
self.nr_cortes = 0
self.coef_vf = []
self.termo_i = []
self.estagio = estagio
def add_corte(self, coeficientes, constante, volume, nr_estagios):
... | class Fcf(object):
nr_cortes = None
coef_vf = None
termo_i = None
estagio = None
def __init__(self, estagio):
self.nr_cortes = 0
self.coef_vf = []
self.termo_i = []
self.estagio = estagio
def add_corte(self, coeficientes, constante, volume, nr_estagios):
... |
def Neighbors(row: int, col: int, data: list) -> list:
adjacents = []
for i in range(row - 1, row + 2):
for j in range(col - 1, col + 2):
if i == row and j == col or i < 0 or i >= len(data) or j < 0 or j >= len(data[0]):
continue
adjacents.append((i, j))
retur... | def neighbors(row: int, col: int, data: list) -> list:
adjacents = []
for i in range(row - 1, row + 2):
for j in range(col - 1, col + 2):
if i == row and j == col or i < 0 or i >= len(data) or (j < 0) or (j >= len(data[0])):
continue
adjacents.append((i, j))
r... |
# Decorator for triggers
# A trigger is an event that we can watch.
# We expect it to return True if the event has happened and False if not.
# If it has 'required_arg_types', then the trigger will request those arguments in the console
# and will be passed them at runtime.
class Trigger():
def __init__(self, name, de... | class Trigger:
def __init__(self, name, description, required_arg_types=[], generated_arg_types=[]):
self.trigger = True
self.tname = name
self.tdesc = description
self.treqs = required_arg_types
self.tgen = generated_arg_types
def __call__(self, f):
f.trigger =... |
# Convert 1024 to binary
print(bin(1024))
print(hex(1024))
# 2 palce round of 5.23222
print(round(5.23222,2))
# check if every letter in str is lowercase
s='hello how are you Mary,are you feeling okay'
print(s.islower())
# how many time w showup
s = 'twywywtwywbwhsjhwuwshshwuwwwjdjdid'
print(s.count('w'))
#... | print(bin(1024))
print(hex(1024))
print(round(5.23222, 2))
s = 'hello how are you Mary,are you feeling okay'
print(s.islower())
s = 'twywywtwywbwhsjhwuwshshwuwwwjdjdid'
print(s.count('w'))
set1 = {2, 3, 1, 5, 6, 8}
set2 = {3, 1, 7, 5, 6, 8}
print(set1.difference(set2))
print(set1.union(set2))
a = {x: x ** 3 for x in ra... |
# Stats for each item in the game
# 0-attack, 1-defense, 2-price, 3-type, 4-Pclass, 5-HP, 6-count, 7-lvl
Items = {'sword': list((10, 0, 10, 'weapon', 'swordsman', 0, 0, 1)),
'bronze sword': list((15, 0, 15, 'weapon', 'swordsman', 0, 0, 5)),
'iron sword': list((20, 0, 20, 'weapon', 'swordsman', 0, 0, 1... | items = {'sword': list((10, 0, 10, 'weapon', 'swordsman', 0, 0, 1)), 'bronze sword': list((15, 0, 15, 'weapon', 'swordsman', 0, 0, 5)), 'iron sword': list((20, 0, 20, 'weapon', 'swordsman', 0, 0, 10)), 'steel sword': list((25, 0, 25, 'weapon', 'swordsman', 0, 0, 15)), 'long sword': list((30, 0, 30, 'weapon', 'swordsman... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def isSubtree(self, s: TreeNode, t: TreeNode) -> bool:
def rec(s,t):
if s is No... | class Solution:
def is_subtree(self, s: TreeNode, t: TreeNode) -> bool:
def rec(s, t):
if s is None and t is None:
return True
if s is None or t is None:
return False
return s.val == t.val and rec(s.left, t.left) and rec(s.right, t.right)... |
def f(a, b, c):
return (a, b, c)
___assertEqual(f(*[0, 1, 2]), (0, 1, 2))
___assertEqual(f(*"abc"), ('a', 'b', 'c'))
___assertEqual(f(*range(3)), (0, 1, 2))
| def f(a, b, c):
return (a, b, c)
___assert_equal(f(*[0, 1, 2]), (0, 1, 2))
___assert_equal(f(*'abc'), ('a', 'b', 'c'))
___assert_equal(f(*range(3)), (0, 1, 2)) |
def is_leap(year):
leap = False
# Write your logic here
if year%4 == 0 and year%100 != 0:
leap = True
elif year%400 == 0:
leap = True
return leap
year = int(input("Enter the year"))
print(is_leap(year))
| def is_leap(year):
leap = False
if year % 4 == 0 and year % 100 != 0:
leap = True
elif year % 400 == 0:
leap = True
return leap
year = int(input('Enter the year'))
print(is_leap(year)) |
floor_lenght = float(input())
tile_wight = float(input())
tile_lenght = float(input())
bench_wight = float(input())
bench_lenght = float(input())
speed = 0.2
bench_area = bench_lenght * bench_wight
tile_area = (tile_wight * tile_lenght)
floor_area = floor_lenght * floor_lenght - bench_area
print("%.2f" % (floor_area... | floor_lenght = float(input())
tile_wight = float(input())
tile_lenght = float(input())
bench_wight = float(input())
bench_lenght = float(input())
speed = 0.2
bench_area = bench_lenght * bench_wight
tile_area = tile_wight * tile_lenght
floor_area = floor_lenght * floor_lenght - bench_area
print('%.2f' % (floor_area / ti... |
print("give me two numbers, and I'll divide them.")
print("enter 'q' to quit.")
while True:
first_number = input("\nFirst Number:")
if first_number == 'q':
break
second_number = input("\nSecond Number:")
if second_number == 'q':
break
try:
answer = int(first_number)/int(secon... | print("give me two numbers, and I'll divide them.")
print("enter 'q' to quit.")
while True:
first_number = input('\nFirst Number:')
if first_number == 'q':
break
second_number = input('\nSecond Number:')
if second_number == 'q':
break
try:
answer = int(first_number) / int(sec... |
def convert_adjacent_matrix_to_adjacent_list(graph: list, vertices: list) -> dict:
result_graph = {}
for v in vertices:
result_graph[v] = []
rows, cols = len(graph), len(graph[0])
for i in range(rows):
for j in range(cols):
if graph[i][j] == 1:
result_graph[v... | def convert_adjacent_matrix_to_adjacent_list(graph: list, vertices: list) -> dict:
result_graph = {}
for v in vertices:
result_graph[v] = []
(rows, cols) = (len(graph), len(graph[0]))
for i in range(rows):
for j in range(cols):
if graph[i][j] == 1:
result_grap... |
ANDHRA_TRACK_DIR = '/Users/jalend15/PycharmProjects/electoral_rolls/andhra/andhra_pdfs'
ANDHRA_PDF_ENGLISH_DIR = '/Users/jalend15/PycharmProjects/electoral_rolls/andhra/andhra_pdfs/english'
ANDHRA_PDF_TELUGU_DIR = '/Users/jalend15/PycharmProjects/electoral_rolls/andhra/andhra_pdfs/telugu' | andhra_track_dir = '/Users/jalend15/PycharmProjects/electoral_rolls/andhra/andhra_pdfs'
andhra_pdf_english_dir = '/Users/jalend15/PycharmProjects/electoral_rolls/andhra/andhra_pdfs/english'
andhra_pdf_telugu_dir = '/Users/jalend15/PycharmProjects/electoral_rolls/andhra/andhra_pdfs/telugu' |
class shapes:
Count_Cylinder=0
Count_Cone=0
def __init__(self,rad,height):
self.rad=rad
self.height=height
def disp(self):
return self.rad+","+self.height
class Cone(shapes):
def __init__(self,rad,height):
shapes.__init__(self,rad,height)
self.slen=pow((pow(self.rad,2)+pow(self.height,2)),0.5)
self.Vo... | class Shapes:
count__cylinder = 0
count__cone = 0
def __init__(self, rad, height):
self.rad = rad
self.height = height
def disp(self):
return self.rad + ',' + self.height
class Cone(shapes):
def __init__(self, rad, height):
shapes.__init__(self, rad, height)
... |
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def verticalTraversal(self, root):
result = collections.defaultdict(list)
stack = [(root, 0)]
while stack... | class Solution(object):
def vertical_traversal(self, root):
result = collections.defaultdict(list)
stack = [(root, 0)]
while stack:
new_stack = []
cur_result = collections.defaultdict(list)
for (node, level) in stack:
cur_result[level].app... |
def metodoBloqueioMovimento(x, y, mapaAtual, direcao, item_select):
if x > -1 and x < 750 and y >-1 and y < 560:
if mapaAtual == 1:
if direcao == 'direita':
if y < 330 and y > 200:
if (x+10>350 or x+10<270):
return True
... | def metodo_bloqueio_movimento(x, y, mapaAtual, direcao, item_select):
if x > -1 and x < 750 and (y > -1) and (y < 560):
if mapaAtual == 1:
if direcao == 'direita':
if y < 330 and y > 200:
if x + 10 > 350 or x + 10 < 270:
return True
... |
def fun(n):
if n%2==0:
return '.'
return '*'
l=[[fun(j) for j in range(5)] for i in range(5)]
print(l) | def fun(n):
if n % 2 == 0:
return '.'
return '*'
l = [[fun(j) for j in range(5)] for i in range(5)]
print(l) |
class Work:
__id = None
__artist = None
__artist_name = None
__name = None
__created = None
__description = None
__tags = []
__forks = 0
__likes = 0
__allow_download = False
__allow_sketch = False
__allow_fork = False
__address = None
def set_address(self, addres... | class Work:
__id = None
__artist = None
__artist_name = None
__name = None
__created = None
__description = None
__tags = []
__forks = 0
__likes = 0
__allow_download = False
__allow_sketch = False
__allow_fork = False
__address = None
def set_address(self, addres... |
#
# @lc app=leetcode id=938 lang=python3
#
# [938] Range Sum of BST
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def rangeSumBST(self... | class Solution:
def range_sum_bst(self, root: TreeNode, L: int, R: int) -> int:
self.ans = 0
self.finder(root, L, R)
return self.ans
def finder(self, root, l, r):
if not root:
return
if l <= root.val <= r:
self.ans += root.val
if root.val... |
protists_chlorophyta = ["volvox", "actinastrum", "hydrodictyon", "spirogyra"]
print("The first three items in the list are:")
for protist in protists_chlorophyta[:3]:
print(protist.title())
protists_chlorophyta = ["volvox", "actinastrum", "hydrodictyon", "spirogyra"]
print("The items in the middle of the list are:... | protists_chlorophyta = ['volvox', 'actinastrum', 'hydrodictyon', 'spirogyra']
print('The first three items in the list are:')
for protist in protists_chlorophyta[:3]:
print(protist.title())
protists_chlorophyta = ['volvox', 'actinastrum', 'hydrodictyon', 'spirogyra']
print('The items in the middle of the list are:'... |
#This program demonstrates creation of bank account using OOP
#Reference: https://www.udemy.com/the-python-mega-course/learn/v4/t/lecture/5170352?start=0
class Account:
def __init__(self, filepath): #filepath stands for a value that is taken from balance.txt
self.fp=filepath #this makes filepath an in... | class Account:
def __init__(self, filepath):
self.fp = filepath
with open(filepath, 'r') as file:
self.balance = int(file.read())
def withdraw(self, amount):
self.balance -= amount
def deposit(self, amount):
self.balance += amount
def commit(self):
... |
def fuel(mass):
try:
mass_int = int(mass)
return max(int(mass_int / 3) - 2, 0)
except ValueError:
return 0
def fuel_recursive(mass):
try:
mass_int = int(mass)
fuel_mass = fuel(mass_int)
fuel_total = fuel_mass
while fuel_mass > 0:
fuel_ma... | def fuel(mass):
try:
mass_int = int(mass)
return max(int(mass_int / 3) - 2, 0)
except ValueError:
return 0
def fuel_recursive(mass):
try:
mass_int = int(mass)
fuel_mass = fuel(mass_int)
fuel_total = fuel_mass
while fuel_mass > 0:
fuel_mass... |
# The test
# For (3,4,5) representing (a,b,c)
# For (3,4,5) a + b + c = 12 is true
# a < b < c is true for (3,4,5)
# a2 + b2 = c2 is true for (3,4,5)
# For (3,4,5) a + b + c = 12
# Ultimately, fink the product abc.
# - Iterate through (a,b) until a^2 + b^2 = c^2
# - Test if a < b < c
# - Test if a + b + c = 1000
# (... | sum_of_triplets = 1000
def main():
a = 1
while True:
(a, b, c) = platonic_sequence(a)
k = 0
while k * (a + b + c) < sum_of_triplets:
k += 1
if k * (a + b + c) == sum_of_triplets and a < b < c:
print('Primitive Triplet: ', a, b, c)
... |
ntos = {
1: 'one',
2: 'two',
3: 'three',
4: 'four',
5: 'five',
6: 'six',
7: 'seven',
8: 'eight',
9: 'nine',
10: 'ten',
11: 'eleven',
12: 'twelve',
13: 'thirteen',
14: 'fourteen',
15: 'fifteen',
16: 'sixteen',
17: 'seventeen',
18: 'eighteen',
19... | ntos = {1: 'one', 2: 'two', 3: 'three', 4: 'four', 5: 'five', 6: 'six', 7: 'seven', 8: 'eight', 9: 'nine', 10: 'ten', 11: 'eleven', 12: 'twelve', 13: 'thirteen', 14: 'fourteen', 15: 'fifteen', 16: 'sixteen', 17: 'seventeen', 18: 'eighteen', 19: 'nineteen', 20: 'twenty', 30: 'thirty'}
for i in range(1, 10):
ntos[20 ... |
# A python module for example purposes
myName = "mymod module for examples"
def add(a,b):
return a + b
def multiply(a,b):
return a * b
| my_name = 'mymod module for examples'
def add(a, b):
return a + b
def multiply(a, b):
return a * b |
#Setting Directory
morsealpha={
"A" : ".-",
"B" : "-...",
"C" : "-.-.",
"D" : "-..",
"E" : ".",
"F" : "..-.",
"G" : "--.",
"H" : "....",
"I" : "..",
"J" : ".---",
"K" : "-.-",
"L" : ".-..",
"M" : "--",
"N" :... | morsealpha = {'A': '.-', 'B': '-...', 'C': '-.-.', 'D': '-..', 'E': '.', 'F': '..-.', 'G': '--.', 'H': '....', 'I': '..', 'J': '.---', 'K': '-.-', 'L': '.-..', 'M': '--', 'N': '-.', 'O': '---', 'P': '.--.', 'Q': '--.-', 'R': '.-.', 'S': '...', 'T': '-', 'U': '..-', 'V': '...-', 'W': '.--', 'X': '-..-', 'Y': '-.--', 'Z'... |
nome = input("Digite seu nome: ")
s = input("Digite seu sexo(M/N): ").upper()
while s != 'M' != 'F':
s = input("Digite seu sexo novamente: ").upper()
| nome = input('Digite seu nome: ')
s = input('Digite seu sexo(M/N): ').upper()
while s != 'M' != 'F':
s = input('Digite seu sexo novamente: ').upper() |
# THIS FILE IS AUTO-GENERATED. PLEASE DO NOT MODIFY# version file for ldap3
# generated on 2020-09-07 08:48:35.409733
# on system uname_result(system='Windows', node='ELITE10GC', release='10', version='10.0.19041', machine='AMD64', processor='Intel64 Family 6 Model 58 Stepping 9, GenuineIntel')
# with Python 3.8.5 - ('... | __version__ = '2.8.1'
__author__ = 'Giovanni Cannata'
__email__ = 'cannatag@gmail.com'
__url__ = 'https://github.com/cannatag/ldap3'
__description__ = 'A strictly RFC 4510 conforming LDAP V3 pure Python client library'
__status__ = '5 - Production/Stable'
__license__ = 'LGPL v3' |
def parse_bool(val, default):
if not val:
return default
if type(val) == bool:
return val
if type(val) == str:
if val.lower() in ["1", "true"]:
return True
if val.lower() in ["0", "false"]:
return False
raise ValueError(f"{val} can not be interpret... | def parse_bool(val, default):
if not val:
return default
if type(val) == bool:
return val
if type(val) == str:
if val.lower() in ['1', 'true']:
return True
if val.lower() in ['0', 'false']:
return False
raise value_error(f'{val} can not be interpre... |
def ficha(nome='<desconhecido>', gol=0):
print(f'O jogador {nome} fez {gol} gol(s) no campeonato.')
#programa principal
n = str(input('Digite o nome do jogador: '))
g = str(input('Quantos gols no campeonato: '))
if g.isnumeric():
g = int(g)
else:
g = 0
if n.strip() == '':
ficha(gol=g)
else:
ficha(n... | def ficha(nome='<desconhecido>', gol=0):
print(f'O jogador {nome} fez {gol} gol(s) no campeonato.')
n = str(input('Digite o nome do jogador: '))
g = str(input('Quantos gols no campeonato: '))
if g.isnumeric():
g = int(g)
else:
g = 0
if n.strip() == '':
ficha(gol=g)
else:
ficha(n, g) |
count=0
while count<5 :
print(count, "is less than 5")
count= count +1
else :
print(count, "is greater than 5")
| count = 0
while count < 5:
print(count, 'is less than 5')
count = count + 1
else:
print(count, 'is greater than 5') |
def merge(x, y):
if len(x) == 0:
return y
if len(y) == 0:
return x
if x[0] <= y[0]:
return [x[0]] + merge(x[1:], y)
else:
return [y[0]] + merge(x, y[1:])
#Solution without slice and concat, which are O(n) in python
def merge2(x, y):
if len(x) == 0:
retu... | def merge(x, y):
if len(x) == 0:
return y
if len(y) == 0:
return x
if x[0] <= y[0]:
return [x[0]] + merge(x[1:], y)
else:
return [y[0]] + merge(x, y[1:])
def merge2(x, y):
if len(x) == 0:
return y
if len(y) == 0:
return x
last = y.pop() if x[-... |
try:
user_number = int(input("Enter a number: "))
res = 10/user_number
except ValueError:
print("You did not enter a number!")
except ZeroDivisionError:
print("Enter a number different from zero (0)!")
| try:
user_number = int(input('Enter a number: '))
res = 10 / user_number
except ValueError:
print('You did not enter a number!')
except ZeroDivisionError:
print('Enter a number different from zero (0)!') |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = "nebula"
class RabbitmqCtx(object):
_instance = None
def __init__(self):
self._amqp_url = "amqp://guest:guest@localhost:5672/"
@property
def amqp_url(self):
return self._amqp_url
@amqp_url.setter
def amqp_url(self, ... | __author__ = 'nebula'
class Rabbitmqctx(object):
_instance = None
def __init__(self):
self._amqp_url = 'amqp://guest:guest@localhost:5672/'
@property
def amqp_url(self):
return self._amqp_url
@amqp_url.setter
def amqp_url(self, amqp_url):
self._amqp_url = amqp_url
... |
# Truth and guesses should be lists of (commit_id, classification_id)
def score(truth, guesses):
truth = dict(truth)
correct_matches = 0
incorrect_matches = 0
for commit_id, classification_id in guesses:
assert(commit_id in truth)
if truth[commit_id] == classification_id:
correct_matches += 1
... | def score(truth, guesses):
truth = dict(truth)
correct_matches = 0
incorrect_matches = 0
for (commit_id, classification_id) in guesses:
assert commit_id in truth
if truth[commit_id] == classification_id:
correct_matches += 1
else:
incorrect_matches += 1
... |
class A(object):
def __init__(self):
pass
def _internal_use(self):
pass
def __method_name(self):
pass
| class A(object):
def __init__(self):
pass
def _internal_use(self):
pass
def __method_name(self):
pass |
#https://leetcode.com/explore/learn/card/queue-stack/239/conclusion/1393/
# According to Trial 68 ms and 14.5 mb
# 95.45% time and 21.71% space
class Solution:
def floodFill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]:
stack = [(sr,sc)]
visited = {}
val... | class Solution:
def flood_fill(self, image: List[List[int]], sr: int, sc: int, newColor: int) -> List[List[int]]:
stack = [(sr, sc)]
visited = {}
valid_path_val = image[sr][sc]
while stack:
(row, col) = stack.pop()
if image[row][col] == valid_path_val and (no... |
# Copyright (c) 2009 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
{
'variables': {
'feature_defines': [
'ENABLE_CHANNEL_MESSAGING=1',
'ENABLE_DATABASE=1',
'ENABLE_DATAGRID=1',
'ENABLE_DASHB... | {'variables': {'feature_defines': ['ENABLE_CHANNEL_MESSAGING=1', 'ENABLE_DATABASE=1', 'ENABLE_DATAGRID=1', 'ENABLE_DASHBOARD_SUPPORT=0', 'ENABLE_JAVASCRIPT_DEBUGGER=0', 'ENABLE_JSC_MULTIPLE_THREADS=0', 'ENABLE_ICONDATABASE=0', 'ENABLE_XSLT=1', 'ENABLE_XPATH=1', 'ENABLE_SVG=1', 'ENABLE_SVG_ANIMATION=1', 'ENABLE_SVG_AS_I... |
l, h = [int(input()), int(input())]
t = [ord(c.lower()) - 97 if c.isalpha() else 26 for c in input()]
for _ in range(h):
row = input()
print("".join(row[j * l:(j + 1) * l] for j in t))
| (l, h) = [int(input()), int(input())]
t = [ord(c.lower()) - 97 if c.isalpha() else 26 for c in input()]
for _ in range(h):
row = input()
print(''.join((row[j * l:(j + 1) * l] for j in t))) |
# Worker: Microsoft
GET_ANOMALY = {
"type": "get",
"endpoint": "/getAnomaly",
"call_message": "{type} {endpoint}",
"error_message": "{type} {endpoint} {response_code}"
} | get_anomaly = {'type': 'get', 'endpoint': '/getAnomaly', 'call_message': '{type} {endpoint}', 'error_message': '{type} {endpoint} {response_code}'} |
n=int(input())
res=[]
grade=[]
for i in range(n):
name=input()
mark=float(input())
res.append([name,mark])
grade.append(mark)
grade=sorted(set(grade)) #sorted and remove the duplicates
m=grade[1]
name=[]
for val in res:
if m==val[1]:
name.append(val[0])
name.sort()
... | n = int(input())
res = []
grade = []
for i in range(n):
name = input()
mark = float(input())
res.append([name, mark])
grade.append(mark)
grade = sorted(set(grade))
m = grade[1]
name = []
for val in res:
if m == val[1]:
name.append(val[0])
name.sort()
for nm in name:
print(nm) |
def adapt_routes_object(object):
lat_north = object['routes'][0]['bounds']['northeast']['lat']
long_east = object['routes'][0]['bounds']['northeast']['long']
lat_south = object['routes'][0]['bounds']['southwest']['lat']
long_west = object['routes'][0]['bounds']['southwest']['long']
| def adapt_routes_object(object):
lat_north = object['routes'][0]['bounds']['northeast']['lat']
long_east = object['routes'][0]['bounds']['northeast']['long']
lat_south = object['routes'][0]['bounds']['southwest']['lat']
long_west = object['routes'][0]['bounds']['southwest']['long'] |
def get_aggregation(**kwargs):
field_name = ''
for k, v in kwargs.items():
field_name = v.replace('.keyword', '')+'_'+k
return {
field_name : {
k: {
'field': v
}
}
}
| def get_aggregation(**kwargs):
field_name = ''
for (k, v) in kwargs.items():
field_name = v.replace('.keyword', '') + '_' + k
return {field_name: {k: {'field': v}}} |
short = {}
def printShort1(word, i):
words = word.split()
words[i] = "[" + words[i][0] + "]" + words[i][1:]
print(" ".join(words))
def printShort2(cmd, i):
print(cmd[:i] + "[" + cmd[i] + "]" + cmd[i + 1:])
for i in range(ord('a'), ord('z') + 1):
short[chr(i)] = False
n = int(input())
cmds = []
f... | short = {}
def print_short1(word, i):
words = word.split()
words[i] = '[' + words[i][0] + ']' + words[i][1:]
print(' '.join(words))
def print_short2(cmd, i):
print(cmd[:i] + '[' + cmd[i] + ']' + cmd[i + 1:])
for i in range(ord('a'), ord('z') + 1):
short[chr(i)] = False
n = int(input())
cmds = []
f... |
#!/usr/bin/env python
# coding: utf-8
# # Day 4 Assignment
# In[1]:
num1 = 1042000
num2 = 702648265
for num in range(num1, num2 + 1):
order = len(str(num))
total = 0
temp = num
while temp > 0:
digit = temp % 10
total += digit ** order
temp //= 10
if num == total:
... | num1 = 1042000
num2 = 702648265
for num in range(num1, num2 + 1):
order = len(str(num))
total = 0
temp = num
while temp > 0:
digit = temp % 10
total += digit ** order
temp //= 10
if num == total:
print(num)
break |
#THIS IS TO PLACTICE CLASS AND METHODS
##CREATE A BANK CLASS AND METHODTS TO DEPOSIT AND WITHDRAW MONEY FROM THE
##ACCOUNT, IF THE ACCOUNT DOES NOT HAVE ENOUGH FUND, PREVENT WITHDRAWAL
class Bank_Account():
#bank account has owner and balance attributes
def __init__(self, owner, balance =0):
sel... | class Bank_Account:
def __init__(self, owner, balance=0):
self.owner = owner
self.balance = balance
def __str__(self):
return f'Account owner is: {self.owner}\n Balance : {self.balance}'
def deposit(self, deposit):
self.balance += deposit
print('Deposit accepted an... |
class ReverseOrderIterator():
def __init__(self, n):
self.n = n
def __iter__(self):
return self
def __next__(self):
list = []
for element in range(self.n, -1, -1):
list.append(element)
return list
def next(self):
return... | class Reverseorderiterator:
def __init__(self, n):
self.n = n
def __iter__(self):
return self
def __next__(self):
list = []
for element in range(self.n, -1, -1):
list.append(element)
return list
def next(self):
return self.__next__()
iter =... |
''' setting api config '''
''' base config class '''
class Config(object):
DEBUG=False
SECRET_KEY="secret"
''' testing class configurations '''
class Testing(Config):
DEBUG=True
TESTING=True
''' dev class configurations '''
class Development(Config):
DEBUG=True
''' staging configurations '''
c... | """ setting api config """
' base config class '
class Config(object):
debug = False
secret_key = 'secret'
' testing class configurations '
class Testing(Config):
debug = True
testing = True
' dev class configurations '
class Development(Config):
debug = True
' staging configurations '
class St... |
expected_output = {
'application': 'TEMPERATURE',
'temperature_sensors': {
'CPU board': {
'id': 0,
'history': {
'11/10/2019 05:35:04': 51,
'11/10/2019 05:45:04': 51,
'11/10/2019 06:35:04': 49,
'11/10/2019 06:40:... | expected_output = {'application': 'TEMPERATURE', 'temperature_sensors': {'CPU board': {'id': 0, 'history': {'11/10/2019 05:35:04': 51, '11/10/2019 05:45:04': 51, '11/10/2019 06:35:04': 49, '11/10/2019 06:40:04': 49}}, 'FANIO Board': {'id': 1, 'history': {'11/10/2019 05:35:04': 48, '11/10/2019 05:45:04': 48, '11/10/2019... |
a = float(input())
b = float(input())
media = ((a*3.5) + (b*7.5)) / 11
print('MEDIA = {:.5f}'.format(media)) | a = float(input())
b = float(input())
media = (a * 3.5 + b * 7.5) / 11
print('MEDIA = {:.5f}'.format(media)) |
class Node():
def __init__(self, x, y, r):
self.x = x
self.y = y
self.r = r
self.next = None
self.prev = None
pass
@classmethod
def from_np(cls, index, pos):
return cls(pos[index][0], pos[index][1], pos[index][2])
def __str__(self):
retu... | class Node:
def __init__(self, x, y, r):
self.x = x
self.y = y
self.r = r
self.next = None
self.prev = None
pass
@classmethod
def from_np(cls, index, pos):
return cls(pos[index][0], pos[index][1], pos[index][2])
def __str__(self):
return... |
def decrypt_fun(input_string,k):
st=""
for i in range(len(input_string)):
if input_string.islower():
shift=97 #ord(97)=a
else:
shift=65 #ord(65)=A
s=(((ord(input_string[i]))-(ord(k[i])))%26)+shift #here we need to subtract the ord(key) rest is same as ... | def decrypt_fun(input_string, k):
st = ''
for i in range(len(input_string)):
if input_string.islower():
shift = 97
else:
shift = 65
s = (ord(input_string[i]) - ord(k[i])) % 26 + shift
st += chr(s)
return st
def key(length):
t = list(input('Enter t... |
N, K, M = map(int, input().split())
P = list(map(int, input().split()))
E = list(map(int, input().split()))
A = list(map(int, input().split()))
H = list(map(int, input().split()))
P.sort()
E.sort()
A.sort()
H.sort()
result = 0
for x in zip(P, E, A, H):
y = sorted(x)
result += pow(y[-1] - y[0], K, M)
resul... | (n, k, m) = map(int, input().split())
p = list(map(int, input().split()))
e = list(map(int, input().split()))
a = list(map(int, input().split()))
h = list(map(int, input().split()))
P.sort()
E.sort()
A.sort()
H.sort()
result = 0
for x in zip(P, E, A, H):
y = sorted(x)
result += pow(y[-1] - y[0], K, M)
resul... |
#!/usr/bin/env python
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "Lic... | mshr_urls = []
MSHR_URLS.append('ftp://ftp.ncdc.noaa.gov/pub/data/homr/docs/MSHR_Enhanced_Table.txt')
MSHR_URLS.append('http://www.ncdc.noaa.gov/homr/file/mshr_enhanced.txt.zip')
mshr_field_index_name = 0
mshr_field_index_start = 1
mshr_field_index_end = 2
mshr_field_index_type = 3
mshr_fields = {}
MSHR_FIELDS['SOURCE_... |
(a, b) = map(str, input().split(" "))
a = len(a)
b = len(b)
if a<b:
g = a
else:
g = b
l = []
for i in range(1,g+1):
if a%i==0 and b%i==0:
l.append(str(i))
if (len(l) == 1) and ('1' in l):
print("yes")
else:
print("no")
| (a, b) = map(str, input().split(' '))
a = len(a)
b = len(b)
if a < b:
g = a
else:
g = b
l = []
for i in range(1, g + 1):
if a % i == 0 and b % i == 0:
l.append(str(i))
if len(l) == 1 and '1' in l:
print('yes')
else:
print('no') |
# Enumerate instead of parsing so we pick up errors if a host is added/changed
ver_lookup = {
"postgresql-96-c7": ("9.6", "centos"),
"postgresql-10-c7": ("10", "centos"),
"postgresql-11-c7": ("11", "centos"),
"postgresql-12-c7": ("12", "centos"),
"postgresql-96-u1804": ("9.6", "ubuntu"),
"postg... | ver_lookup = {'postgresql-96-c7': ('9.6', 'centos'), 'postgresql-10-c7': ('10', 'centos'), 'postgresql-11-c7': ('11', 'centos'), 'postgresql-12-c7': ('12', 'centos'), 'postgresql-96-u1804': ('9.6', 'ubuntu'), 'postgresql-10-u1804': ('10', 'ubuntu'), 'postgresql-11-u1804': ('11', 'ubuntu'), 'postgresql-12-u1804': ('12',... |
#%%
payments = 0
interest = (1 + rpi + 0.03) ** (1 / 12)
for i in range(0, 30*12):
repayment = (monthly_income(i) - base_monthly_income(i)) * 0.09
temp = debt * interest - repayment
if temp < 0:
payments = payments + debt * interest
debt = 0
break
debt = temp
payments = ... | payments = 0
interest = (1 + rpi + 0.03) ** (1 / 12)
for i in range(0, 30 * 12):
repayment = (monthly_income(i) - base_monthly_income(i)) * 0.09
temp = debt * interest - repayment
if temp < 0:
payments = payments + debt * interest
debt = 0
break
debt = temp
payments = payment... |
print("Welcome To even / odd Check: ")
num = int(input("Enter Number: "))
if num % 2 != 0:
print("This is Odd Number")
else:
print("This is an Even Number")
| print('Welcome To even / odd Check: ')
num = int(input('Enter Number: '))
if num % 2 != 0:
print('This is Odd Number')
else:
print('This is an Even Number') |
class Solution:
def maxSubArray(self, nums: [int]) -> int:
max_ending = max_current = nums[0]
for i in nums[1:]:
max_ending = max(i, max_ending + i)
max_current = max(max_current, max_ending)
return max_current
| class Solution:
def max_sub_array(self, nums: [int]) -> int:
max_ending = max_current = nums[0]
for i in nums[1:]:
max_ending = max(i, max_ending + i)
max_current = max(max_current, max_ending)
return max_current |
#
# PySNMP MIB module DATASMART-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/DATASMART-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:21:38 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 201... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, value_size_constraint, constraints_union) ... |
# List of base-map providers
class Providers:
MAPBOX = "mapbox"
GOOGLE_MAPS = "google_maps"
| class Providers:
mapbox = 'mapbox'
google_maps = 'google_maps' |
class Person:
def __init__(self, name):
self.name = name
def greet(self):
print(f"Hello, I'm {self.name}")
class Child(Person):
def __init__(self, name, school):
super().__init__(name)
self.school = school
def learn(self):
print(f"I'm learning a lot at {self.s... | class Person:
def __init__(self, name):
self.name = name
def greet(self):
print(f"Hello, I'm {self.name}")
class Child(Person):
def __init__(self, name, school):
super().__init__(name)
self.school = school
def learn(self):
print(f"I'm learning a lot at {self.... |
__author__ = 'Yifei'
HEADER_OFFSET = 0
INDEX_OFFSET = 4
LENGTH_OFFSET = 5
CHECKSUM_OFFSET = 6
PACKET_CONSTANT_OFFSET = 7
OPERAND_OFFSET = 7
PAYLOAD_OFFSET = 8
MAX_PAYLOAD_LENGTH = 255
MIN_PACKET_LENGTH = 4 + 1 + 1 + 1
PROTOSBN1_HEADER_BYTES = [0x53, 0x42, 0x4e, 0x31]
| __author__ = 'Yifei'
header_offset = 0
index_offset = 4
length_offset = 5
checksum_offset = 6
packet_constant_offset = 7
operand_offset = 7
payload_offset = 8
max_payload_length = 255
min_packet_length = 4 + 1 + 1 + 1
protosbn1_header_bytes = [83, 66, 78, 49] |
#code=input("Enter customer code:")
while True:
print("")
code=input("Enter customer code:")
bill_float = 0
bill = float(bill_float)
if code == "r":
begin_int=input("Enter beginning meter reading:")
begin = float(begin_int)
end_int=input("Enter ending meter reading:")
... | while True:
print('')
code = input('Enter customer code:')
bill_float = 0
bill = float(bill_float)
if code == 'r':
begin_int = input('Enter beginning meter reading:')
begin = float(begin_int)
end_int = input('Enter ending meter reading:')
end = float(end_int)
... |
class ExperimentorException(Exception):
pass
class ModelDefinitionException(ExperimentorException):
pass
class ExperimentDefinitionException(ExperimentorException):
pass
class DuplicatedParameter(ExperimentorException):
pass | class Experimentorexception(Exception):
pass
class Modeldefinitionexception(ExperimentorException):
pass
class Experimentdefinitionexception(ExperimentorException):
pass
class Duplicatedparameter(ExperimentorException):
pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.