content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def main():
n=int(input())
a=list(map(int, input().split()))
mp=(None,None)
d=0
for i in range(0, n-1, 2):
if a[i+1] - a[i] > d:
mp=(i,i+1)
a[mp[0]], a[mp[1]] = a[mp[1]], a[mp[0]]
print(sum(a[::2]))
if __name__ == '__main__':
t=int(input())
for _ in range... | def main():
n = int(input())
a = list(map(int, input().split()))
mp = (None, None)
d = 0
for i in range(0, n - 1, 2):
if a[i + 1] - a[i] > d:
mp = (i, i + 1)
(a[mp[0]], a[mp[1]]) = (a[mp[1]], a[mp[0]])
print(sum(a[::2]))
if __name__ == '__main__':
t = int(input())
... |
x = int(input('Enter an integer:'))
y = int(input('Enter an integer:'))
if x ^ y!=0:
print(x,' and ', y, ' are different')
else:
print(x,' and ', y, ' are same') | x = int(input('Enter an integer:'))
y = int(input('Enter an integer:'))
if x ^ y != 0:
print(x, ' and ', y, ' are different')
else:
print(x, ' and ', y, ' are same') |
#!/usr/bin/env python
#######################################
# Installation module for AttackSurfaceMapper
#######################################
DESCRIPTION="This module will install/update Attack Surface Mapper (ASM) by Andreas Georgiou - A tool that aim to automate the recon process"
AUTHOR="Andrew Schwartz"
IN... | description = 'This module will install/update Attack Surface Mapper (ASM) by Andreas Georgiou - A tool that aim to automate the recon process'
author = 'Andrew Schwartz'
install_type = 'GIT'
repository_location = 'https://github.com/superhedgy/AttackSurfaceMapper.git'
install_location = 'ASM'
debian = 'python3,pip'
af... |
def k_to_c(k):
c = (k - 273.15)
return c
k = 268.0
c = k_to_c(k)
print("kelvin of" + str(k) + "is" + str(c) + "in kelvin" )
| def k_to_c(k):
c = k - 273.15
return c
k = 268.0
c = k_to_c(k)
print('kelvin of' + str(k) + 'is' + str(c) + 'in kelvin') |
# Autogenerated file for Reflected light
# Add missing from ... import const
_JD_SERVICE_CLASS_REFLECTED_LIGHT = const(0x126c4cb2)
_JD_REFLECTED_LIGHT_VARIANT_INFRARED_DIGITAL = const(0x1)
_JD_REFLECTED_LIGHT_VARIANT_INFRARED_ANALOG = const(0x2)
_JD_REFLECTED_LIGHT_REG_BRIGHTNESS = const(JD_REG_READING)
_JD_REFLECTED_L... | _jd_service_class_reflected_light = const(309087410)
_jd_reflected_light_variant_infrared_digital = const(1)
_jd_reflected_light_variant_infrared_analog = const(2)
_jd_reflected_light_reg_brightness = const(JD_REG_READING)
_jd_reflected_light_reg_variant = const(JD_REG_VARIANT)
_jd_reflected_light_ev_dark = const(JD_EV... |
#!/bin/python3
# Designer Door Mat
# https://www.hackerrank.com/challenges/designer-door-mat/problem
n, m = map(int, input().split())
init = ".|."
for i in range(n // 2):
print(init.center(m, "-"))
init = ".|." + init + ".|."
print("WELCOME".center(m, "-"))
for i in range(n // 2):
linit = list(init)
... | (n, m) = map(int, input().split())
init = '.|.'
for i in range(n // 2):
print(init.center(m, '-'))
init = '.|.' + init + '.|.'
print('WELCOME'.center(m, '-'))
for i in range(n // 2):
linit = list(init)
init = ''.join(linit[3:len(linit) - 3])
print(init.center(m, '-')) |
# albus.exceptions
class AlbusError(Exception):
def __init__(self, message, inner=None, detail=None):
self.message = message
self.inner = inner
self.detail = detail
| class Albuserror(Exception):
def __init__(self, message, inner=None, detail=None):
self.message = message
self.inner = inner
self.detail = detail |
# Created by MechAviv
# Nyen Damage Skin | (2438086)
if sm.addDamageSkin(2438086):
sm.chat("'Nyen Damage Skin' Damage Skin has been added to your account's damage skin collection.")
sm.consumeItem() | if sm.addDamageSkin(2438086):
sm.chat("'Nyen Damage Skin' Damage Skin has been added to your account's damage skin collection.")
sm.consumeItem() |
# -*- coding: utf-8 -*-
#
# Copyright 2016 Civic Knowledge. All Rights Reserved
# This software may be modified and distributed under the terms of the BSD license.
# See the LICENSE file for details.
def get_root():
return ['do some magic?','or don\'t']
def get_measure_root(id):
return "got id {} ({}) ... | def get_root():
return ['do some magic?', "or don't"]
def get_measure_root(id):
return 'got id {} ({}) '.format(id, type(id)) |
#
# PySNMP MIB module CHANNEL-CHANGE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CHANNEL-CHANGE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:31:02 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, ... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
x1 = 2
y1 = 2
x2 = 6
y2 = 10
m2 = (y2 - y1) / (x2 - x1)
print(f'Slope = {m2:.2f}') # 9
| x1 = 2
y1 = 2
x2 = 6
y2 = 10
m2 = (y2 - y1) / (x2 - x1)
print(f'Slope = {m2:.2f}') |
def read_delimited_lines(file_handle, delimiter='|',
omit_delimiter=False, read_size=4):
delimited_line = ""
data = file_handle.read(read_size)
while data:
delimiter_index = data.find(delimiter)
if delimiter_index < 0:
delimited_line += data
... | def read_delimited_lines(file_handle, delimiter='|', omit_delimiter=False, read_size=4):
delimited_line = ''
data = file_handle.read(read_size)
while data:
delimiter_index = data.find(delimiter)
if delimiter_index < 0:
delimited_line += data
else:
delimited_li... |
# -*- coding: utf-8 -*-
# this file is released under public domain and you can use without limitations
#########################################################################
## Customize your APP title, subtitle and menus here
#########################################################################
response.logo... | response.logo = a(b(span('M'), 'eta', span('B'), 'ase'), xml('™ '), _class='navbar-brand', _href=url('default', 'index'), _id='web2py-logo')
response.title = request.application.replace('_', ' ').title()
response.subtitle = ''
response.meta.author = 'Ryan Marquardt <ryan.marquardt@gmail.com>'
response.meta.d... |
def cluster_it(common_pos,no_sup,low_sup):
topla=[]
for x in common_pos:
if x in no_sup+low_sup:
continue
else:
topla.append(x)
topla.sort()
cluster={}
r_cluster={}
c_num=1
cluster['c_'+str(c_num)]=[]
for i in range (0,len(topla)-1):
po... | def cluster_it(common_pos, no_sup, low_sup):
topla = []
for x in common_pos:
if x in no_sup + low_sup:
continue
else:
topla.append(x)
topla.sort()
cluster = {}
r_cluster = {}
c_num = 1
cluster['c_' + str(c_num)] = []
for i in range(0, len(topla) - ... |
#
# PySNMP MIB module HIST-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HIST-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:31:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:1... | (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, constraints_union, single_value_constraint, value_range_constraint) ... |
# ** CONTROL FLOW **
# IF, ELIF AND ELSE
age = 21
if age >= 21:
print("You can drive alone")
elif age < 16:
print("You are not allow to drive")
else:
print("You can drive with supervision")
# FOR LOOPS
# Iterate a List
print("\nIterate a List:")
my_list = [1, 2, 3, 4, 5]
for item in my_list:
print(... | age = 21
if age >= 21:
print('You can drive alone')
elif age < 16:
print('You are not allow to drive')
else:
print('You can drive with supervision')
print('\nIterate a List:')
my_list = [1, 2, 3, 4, 5]
for item in my_list:
print(item)
print('\nIterate a Dictionary:')
my_dict = {'One': 1, 'Two': 2, 'Thre... |
###################################
# SOLUTION
###################################
def no_boring_zeros(n):
j = n
if j <= 0:
j = -j
x = list(range(0,100))
z = []
for k in x:
if j/(10**k) != int(j/(10**k)):
z.append((j/(10**k))*10)
if n < 0:
return -max(z)
... | def no_boring_zeros(n):
j = n
if j <= 0:
j = -j
x = list(range(0, 100))
z = []
for k in x:
if j / 10 ** k != int(j / 10 ** k):
z.append(j / 10 ** k * 10)
if n < 0:
return -max(z)
if n == 0:
return 0
else:
return max(z) |
x = [ 100, 100, 100, 100, 100 ]
y = 100
s = 50
speed = [ 1, 2, 3, 4, 5 ]
def setup():
size(640, 360, P2D)
def draw():
global x, y, s, speed
background(127)
for i in range(0, len(x)):
ellipse(x[i], y + (i * s), s, s)
x[i] += speed[i]
if x[i] > width or x[i... | x = [100, 100, 100, 100, 100]
y = 100
s = 50
speed = [1, 2, 3, 4, 5]
def setup():
size(640, 360, P2D)
def draw():
global x, y, s, speed
background(127)
for i in range(0, len(x)):
ellipse(x[i], y + i * s, s, s)
x[i] += speed[i]
if x[i] > width or x[i] < 0:
speed[i] *... |
def mph2fps(mph):
return mph*5280/3600
def myhello():
print("Konchi_wa")
| def mph2fps(mph):
return mph * 5280 / 3600
def myhello():
print('Konchi_wa') |
aux=0
aux2=0
while True:
string=list(map(str,input().split()))
if string[0]=="ABEND":break
elif string[0]=='SALIDA':
aux+=int(string[1])
aux2+=1
else:
aux-=int(string[1])
aux2-=1
print(aux)
print(aux2)
| aux = 0
aux2 = 0
while True:
string = list(map(str, input().split()))
if string[0] == 'ABEND':
break
elif string[0] == 'SALIDA':
aux += int(string[1])
aux2 += 1
else:
aux -= int(string[1])
aux2 -= 1
print(aux)
print(aux2) |
class Solution:
def canMakeArithmeticProgression(self, arr: List[int]) -> bool:
arr.sort()
l1 = arr[0:(len(arr)-1)]
l2 = arr[1:]
diffs = [abs(i-j) for i,j in zip(l1, l2)]
if len(set(diffs)) == 1:
return True
return False
| class Solution:
def can_make_arithmetic_progression(self, arr: List[int]) -> bool:
arr.sort()
l1 = arr[0:len(arr) - 1]
l2 = arr[1:]
diffs = [abs(i - j) for (i, j) in zip(l1, l2)]
if len(set(diffs)) == 1:
return True
return False |
class LanguageUtility:
LANGUAGES = {
"C": ("h",),
"Clojure": ("clj",),
"C++": ("cpp", "hpp", "h++",),
"Crystal": ("cr",),
"C#": ("cs", "csharp",),
"CSS": (),
"D": (),
"Go": ("golang",),
"HTML": ("htm",),
"Java": (),
"JavaScript"... | class Languageutility:
languages = {'C': ('h',), 'Clojure': ('clj',), 'C++': ('cpp', 'hpp', 'h++'), 'Crystal': ('cr',), 'C#': ('cs', 'csharp'), 'CSS': (), 'D': (), 'Go': ('golang',), 'HTML': ('htm',), 'Java': (), 'JavaScript': ('ecma', 'ecmascript', 'es', 'js'), 'Julia': (), 'Less': (), 'Lua': (), 'Nim': (), 'PHP':... |
# Recursion
# Base Case: n < 2, return lst
# Otherwise:
# Divide list into 2, Sort each of them, Merge!
def merge(left, right):
# Compare first element
# Take the smaller of the 2
# Repeat until no more elements
results = []
while left and right:
if left[0] < right[0]:
results.a... | def merge(left, right):
results = []
while left and right:
if left[0] < right[0]:
results.append(left.pop(0))
else:
results.append(right.pop(0))
results.extend(right)
results.extend(left)
return results
def merge_sort(lst):
if len(lst) < 2:
return... |
__about__ = "Maximum no in a binary tree."
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right= None
class Tree:
@staticmethod
def insert(root = None,data = None):
if root is None and data is not None:
root = Node(data)
| __about__ = 'Maximum no in a binary tree.'
class Node:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
class Tree:
@staticmethod
def insert(root=None, data=None):
if root is None and data is not None:
root = node(data) |
E, F, C = map(int, input().split())
bottles = E + F
drank = 0
while bottles >= C:
# while he still has enough empty bottles to purchase more
bottles -= C - 1 # used F empty bottles to buy 1
drank += 1
print(drank) | (e, f, c) = map(int, input().split())
bottles = E + F
drank = 0
while bottles >= C:
bottles -= C - 1
drank += 1
print(drank) |
NOTES = {
'C3': 130.8,
'CS3': 138.6,
'DF3': 138.6,
'D3': 146.8,
'DS3': 155.6,
'EF3': 155.6,
'E3': 164.8,
'F3': 174.6,
'FS3': 185.0,
'GF3': 185.0,
'G3': 196.0,
'GS3': 207.7,
'AF3': 207.7,
'A3': 220.0,
'AS3': 233.1,
'BF3': 233.1,
'B3': 246.9,
'C4': ... | notes = {'C3': 130.8, 'CS3': 138.6, 'DF3': 138.6, 'D3': 146.8, 'DS3': 155.6, 'EF3': 155.6, 'E3': 164.8, 'F3': 174.6, 'FS3': 185.0, 'GF3': 185.0, 'G3': 196.0, 'GS3': 207.7, 'AF3': 207.7, 'A3': 220.0, 'AS3': 233.1, 'BF3': 233.1, 'B3': 246.9, 'C4': 261.6, 'CS4': 277.2, 'DF4': 277.2, 'D4': 293.7, 'DS4': 311.1, 'EF4': 311.1... |
# -*- coding: utf-8 -*-
class HelloWorldController:
__defaultName = None
def __init__(self):
self.__defaultName = "Pip User"
def configure(self, config):
self.__defaultName = config.get_as_string_with_default("default_name", self.__defaultName)
def greeting(self, name):
retur... | class Helloworldcontroller:
__default_name = None
def __init__(self):
self.__defaultName = 'Pip User'
def configure(self, config):
self.__defaultName = config.get_as_string_with_default('default_name', self.__defaultName)
def greeting(self, name):
return f'Hello, {(name if nam... |
edge_array = [0,100,-1,-30,130,-150,-1,-1,-1,10,10,-120,-10,160,-180,0,10,-180,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,120,-120,-100,30,-200,30,30,-200,20,30,-200,30,220,-230,40,20,-220,0,50,-30,-200,30,-30,30,30,-200,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,60,-160,-10,130,-190,0,40,-2... | edge_array = [0, 100, -1, -30, 130, -150, -1, -1, -1, 10, 10, -120, -10, 160, -180, 0, 10, -180, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 120, -120, -100, 30, -200, 30, 30, -200, 20, 30, -200, 30, 220, -230, 40, 20, -220, 0, 50, -30, -200, 30, -30, 30, 30, -200, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1... |
class LoginResponse:
def __init__(
self, access_token: str,
fresh_token: str,
token_type: str = "bearer"
):
self.access_token = access_token
self.fresh_token = fresh_token
self.token_type = token_type
def json(self):
return dict(
access_... | class Loginresponse:
def __init__(self, access_token: str, fresh_token: str, token_type: str='bearer'):
self.access_token = access_token
self.fresh_token = fresh_token
self.token_type = token_type
def json(self):
return dict(access_token=self.access_token, fresh_token=self.fres... |
# Iterating Through Dictionaries
contacts = {"Daisy Johnson": "2468 Park Ave", "Leo Fitz": "1258 Monkey Dr"}
# iterate through each key
for name in contacts:
print(name)
# or, use keys() method
for name in contacts.keys():
print(name)
# using each key to print each value
for name in contacts:
# prints e... | contacts = {'Daisy Johnson': '2468 Park Ave', 'Leo Fitz': '1258 Monkey Dr'}
for name in contacts:
print(name)
for name in contacts.keys():
print(name)
for name in contacts:
print(contacts[name])
for address in contacts.values():
print(address)
for (name, address) in contacts.items():
print(name + ',... |
to_do_list = ["0"] * 10
while True:
command = input().split("-", maxsplit=1)
if "End" in command:
break
to_do_list.insert(int(command[0]), command[1])
while "0" in to_do_list:
to_do_list.remove("0")
print(to_do_list) | to_do_list = ['0'] * 10
while True:
command = input().split('-', maxsplit=1)
if 'End' in command:
break
to_do_list.insert(int(command[0]), command[1])
while '0' in to_do_list:
to_do_list.remove('0')
print(to_do_list) |
N = int(input())
data = open("{}.txt".format(N), 'r')
data = data.readline()
data = [int(i) for i in data.split()]
def parr(array):
for i in array:
print('{:4d}'.format(i), end=" ")
def insertionsort(x):
for i in range(1, len(x)):
j = i - 1; key = x[i]
while(x[j] > key and j>= 0):
x[j+1] = x[j]
j = j-1
... | n = int(input())
data = open('{}.txt'.format(N), 'r')
data = data.readline()
data = [int(i) for i in data.split()]
def parr(array):
for i in array:
print('{:4d}'.format(i), end=' ')
def insertionsort(x):
for i in range(1, len(x)):
j = i - 1
key = x[i]
while x[j] > key and j >= ... |
def resolve():
n = int(input())
for i in range(1, n + 1):
if i % 3 == 0 or "3" in str(i):
print(" {}".format(i), end="")
print()
| def resolve():
n = int(input())
for i in range(1, n + 1):
if i % 3 == 0 or '3' in str(i):
print(' {}'.format(i), end='')
print() |
'''
Make a 3x3 matrix and fill with numbers
at the end show the matrix in a right format
'''
cr = [[],[],[]]
for c in range(0,3):
cr[0].append(int(input(f'First line [1, {c+1}]: ')))
for c in range(0,3):
cr[1].append(int(input(f'Second line [2, {c+1}]: ')))
for c in range(0,3):
cr[2].append(int(input(f'Thir... | """
Make a 3x3 matrix and fill with numbers
at the end show the matrix in a right format
"""
cr = [[], [], []]
for c in range(0, 3):
cr[0].append(int(input(f'First line [1, {c + 1}]: ')))
for c in range(0, 3):
cr[1].append(int(input(f'Second line [2, {c + 1}]: ')))
for c in range(0, 3):
cr[2].append(int(inp... |
n = int(input())
for i in range(n):
x = int(input())
print(len(bin(x)) - 2)
| n = int(input())
for i in range(n):
x = int(input())
print(len(bin(x)) - 2) |
'''
The class derived from more than 1 base called as a Multiple Inheritence.
Programmer_name : BALAVIGNESH.M
Implemented_Date : 11-11-2018
'''
class OS:
SecurityOS = "Linux"
DeveloperlikeOS = "Mac OS"
Most_Personal_usage_OS = "Windows"
class KernerlType:
SecurityOS_Kernel = "MonoLit... | """
The class derived from more than 1 base called as a Multiple Inheritence.
Programmer_name : BALAVIGNESH.M
Implemented_Date : 11-11-2018
"""
class Os:
security_os = 'Linux'
developerlike_os = 'Mac OS'
most__personal_usage_os = 'Windows'
class Kernerltype:
security_os__kernel = 'MonoLi... |
class RecentCounter:
def __init__(self):
self.queue = []
def ping(self, t: int) -> int:
self.queue.append(t)
if len(self.queue) > 3001:
self.queue.pop(0)
start = 0
for idx, item in enumerate(self.queue):
if item >= t-3000:
... | class Recentcounter:
def __init__(self):
self.queue = []
def ping(self, t: int) -> int:
self.queue.append(t)
if len(self.queue) > 3001:
self.queue.pop(0)
start = 0
for (idx, item) in enumerate(self.queue):
if item >= t - 3000:
sta... |
#!/bin/python3
n,k = input().strip().split(' ')
n,k = [int(n),int(k)]
height = list(map(int, input().strip().split(' ')))
max_height = max(height)
if max_height - k >= 1:
print (max_height-k)
else:
print (0)
| (n, k) = input().strip().split(' ')
(n, k) = [int(n), int(k)]
height = list(map(int, input().strip().split(' ')))
max_height = max(height)
if max_height - k >= 1:
print(max_height - k)
else:
print(0) |
#!/usr/local/bin/python3
s1 = "floor"
s2 = "brake"
print(s1)
for i in range(len(s1)):
if s1[i] != s2[i]:
print(s2[:i+1] + s1[i+1:])
| s1 = 'floor'
s2 = 'brake'
print(s1)
for i in range(len(s1)):
if s1[i] != s2[i]:
print(s2[:i + 1] + s1[i + 1:]) |
def solve() -> None:
# person whose strength is i can only carry parcels whose weight is less than or equal to i.
# check in descending order of degree of freedom of remained parcels.
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
# for i in range(1, 6... | def solve() -> None:
a = [0] + list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
if a[5] > b[5]:
print('No')
return
b[5] -= a[5]
a[5] = 0
if a[4] <= b[4]:
b[4] -= a[4]
a[4] = 0
else:
a[4] -= b[4]
b[4] = 0
if a[4]... |
class WayPoint:
code = None
state = None
location = None
coordinate = None
def __init__(self, code=None, state=None, location=None, coordinate=None):
self.code = code
self.state = state
self.location = location
self.coordinate = coordinate
if self.code is No... | class Waypoint:
code = None
state = None
location = None
coordinate = None
def __init__(self, code=None, state=None, location=None, coordinate=None):
self.code = code
self.state = state
self.location = location
self.coordinate = coordinate
if self.code is Non... |
class Solution:
def constructFromPrePost(self, pre: List[int], post: List[int]) -> TreeNode:
if not pre:
return None
if len(pre) == 1:
return TreeNode(pre[0])
lroot = post.index(pre[1])
l = self.constructFromPrePost(pre[1:lroot+2], post[:lroot+1])
r = ... | class Solution:
def construct_from_pre_post(self, pre: List[int], post: List[int]) -> TreeNode:
if not pre:
return None
if len(pre) == 1:
return tree_node(pre[0])
lroot = post.index(pre[1])
l = self.constructFromPrePost(pre[1:lroot + 2], post[:lroot + 1])
... |
BIGINT = "BIGINT"
NUMERIC = "NUMERIC"
NUMBER = "NUMBER"
BIT = "BIT"
SMALLINT = "SMALLINT"
DECIMAL = "DECIMAL"
SMALLMONEY = "SMALLMONEY"
INT = "INT"
TINYINT = "TINYINT"
MONEY = "MONEY"
FLOAT = "FLOAT"
REAL = "REAL"
DATE = "DATE"
DATETIMEOFFSET = "DATETIMEOFFSET"
DATETIME2 = "DATETIME2"
SMALLDATETIME = "SMALLDATETIME"
DA... | bigint = 'BIGINT'
numeric = 'NUMERIC'
number = 'NUMBER'
bit = 'BIT'
smallint = 'SMALLINT'
decimal = 'DECIMAL'
smallmoney = 'SMALLMONEY'
int = 'INT'
tinyint = 'TINYINT'
money = 'MONEY'
float = 'FLOAT'
real = 'REAL'
date = 'DATE'
datetimeoffset = 'DATETIMEOFFSET'
datetime2 = 'DATETIME2'
smalldatetime = 'SMALLDATETIME'
da... |
xCoordinate = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30]
def setup():
size(500,500)
smooth()
noStroke()
myInit()
def myInit():
println ("New coordinates : ")
for i in range(len(xCoordinate)):
xCoordinate [i] = 250 + random ( -100 ,100)
prin... | x_coordinate = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30]
def setup():
size(500, 500)
smooth()
no_stroke()
my_init()
def my_init():
println('New coordinates : ')
for i in range(len(xCoordinate)):
xCoordinate[i] = 250 ... |
#
# PySNMP MIB module HUAWEI-MGMD-STD-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HUAWEI-MGMD-STD-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:46:50 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')
(single_value_constraint, value_size_constraint, constraints_intersection, constraints_union, value_range_constraint) ... |
def test_get_cpu_times(device):
result = device.cpu_times()
assert result is not None
def test_get_cpu_percent(device):
percent = device.cpu_percent(interval=1)
assert percent is not None
assert percent != 0
def test_get_cpu_count(device):
assert device.cpu_count() == 2
| def test_get_cpu_times(device):
result = device.cpu_times()
assert result is not None
def test_get_cpu_percent(device):
percent = device.cpu_percent(interval=1)
assert percent is not None
assert percent != 0
def test_get_cpu_count(device):
assert device.cpu_count() == 2 |
# Normal way
def userEntity(item) -> dict:
return {
"fname":item["fname"],
"lname":item["lname"],
"email":item["email"],
}
def usersEntity(entity) -> list:
return [userEntity(item) for item in entity] | def user_entity(item) -> dict:
return {'fname': item['fname'], 'lname': item['lname'], 'email': item['email']}
def users_entity(entity) -> list:
return [user_entity(item) for item in entity] |
# Copyright (c) 2013-2018 LG Electronics, Inc.
#
# 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 t... | {'variables': {'sysroot%': ''}, 'targets': [{'target_name': 'webos-sysbus', 'include_dirs': ['<!@(pkg-config --cflags-only-I glib-2.0 | sed s/-I//g)'], 'sources': ['src/node_ls2.cpp', 'src/node_ls2_base.cpp', 'src/node_ls2_call.cpp', 'src/node_ls2_error_wrapper.cpp', 'src/node_ls2_handle.cpp', 'src/node_ls2_message.cpp... |
def bool_func(i, w, a):
if i == 0:
if w == 0:
return True
else:
return False
# in case not choosing a[i-1]
if bool_func(i-1, w, a):
return True
# in case choosing a[i-1]
if bool_func(i-1, w-a[i-1], a): return True
# return False if both cas... | def bool_func(i, w, a):
if i == 0:
if w == 0:
return True
else:
return False
if bool_func(i - 1, w, a):
return True
if bool_func(i - 1, w - a[i - 1], a):
return True
return False
def main():
(n, w) = map(int, input().split())
a = list(map(... |
def mid(word: str | list | tuple) -> str:
return "" if len(word) % 2 == 0 else word[round(len(word) // 2)]
def tests() -> None:
print(mid("hello")) # "l"
print(mid("12345")) # "3"
print(mid("hello2")) # ""
print(mid("abc")) # "b"
# It also works with lists!
print(mid(["a", "b", "c", "d... | def mid(word: str | list | tuple) -> str:
return '' if len(word) % 2 == 0 else word[round(len(word) // 2)]
def tests() -> None:
print(mid('hello'))
print(mid('12345'))
print(mid('hello2'))
print(mid('abc'))
print(mid(['a', 'b', 'c', 'd', 'e']))
print(mid(('1', '2', '3', '4', '5')))
if __nam... |
def A():
q = int(input())
for i in range(q):
n , a , b = map(int , input().split())
if(2*a<b):
print(n*a)
continue
else:
print(n//2*b+(n%2)*a)
A()
| def a():
q = int(input())
for i in range(q):
(n, a, b) = map(int, input().split())
if 2 * a < b:
print(n * a)
continue
else:
print(n // 2 * b + n % 2 * a)
a() |
class AdministrationWarning(Warning):
pass
class TemporaryDirectoryDeletionWarning(Warning):
pass | class Administrationwarning(Warning):
pass
class Temporarydirectorydeletionwarning(Warning):
pass |
#input
# 13
# 19443 576
# 6001842 911503
# 4067 1248
# 6121885 186
# -410349 4955307
# 5375848 874
# 2770998 256
# 18765 1284
# 5813 1630
# 8212240 77
# 293304 -4580549
# 7956897 3420372
# 6775023 846
n = int(input())
for k in range(0, n):
num = None
for i in input().split():
if not(num):
... | n = int(input())
for k in range(0, n):
num = None
for i in input().split():
if not num:
num = float(i)
continue
num /= float(i)
print(round(num), ' ', end='') |
with open("instructions.txt") as f:
content = f.readlines()
instrL = []
for line in content:
if ";" in line:
instr = line.split(";")[0]
instr = instr.replace(" ", "")
instr = instr.replace("()", "")
instr = instr.replace("void", "")
nr = line.split("/")[2]
... | with open('instructions.txt') as f:
content = f.readlines()
instr_l = []
for line in content:
if ';' in line:
instr = line.split(';')[0]
instr = instr.replace(' ', '')
instr = instr.replace('()', '')
instr = instr.replace('void', '')
nr = l... |
# this is an example trial file
# each line in this file is one command
# there are two type of commands, phase commands and robot commands
#all comamands share the same format:
# name_of_command(time_to_run_command, <some number of arguments>)
# time_to_run_command is the numver of seconds afte rth trial starts
# ... | phase(0, '1')
skee(3, 9)
phase(60, '2')
phase(60, '3') |
def mittelwert(liste):
return sum(liste)/len(liste)
def mittelwert2(*liste):
return sum(liste)/len(liste)
print(mittelwert([3, 4, 5]))
print(mittelwert2(3, 4, 5))
def ausgabe(Liste, ende="\n"):
for element in Liste:
print(element, end=ende)
def ausgabe2(Liste, **kwargs):
ende... | def mittelwert(liste):
return sum(liste) / len(liste)
def mittelwert2(*liste):
return sum(liste) / len(liste)
print(mittelwert([3, 4, 5]))
print(mittelwert2(3, 4, 5))
def ausgabe(Liste, ende='\n'):
for element in Liste:
print(element, end=ende)
def ausgabe2(Liste, **kwargs):
ende = '\n' if 'e... |
# Copyright 2021 The BladeDISC Authors. All rights reserved.
# 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 ... | class Unionset:
def __init__(self, num_elems: int):
self._num_elems = num_elems
self._num_sets = num_elems
self._group_id = dict([(g, g) for g in range(0, num_elems)])
def same_group(self, x: int, y: int):
pid_x = self.find(x)
pid_y = self.find(x)
if pid_x == pi... |
'''
Runtime: 56 ms, faster than 75.06% of Python3 online submissions for Longest Substring Without Repeating Characters.
Memory Usage: 12.8 MB, less than 100.00% of Python3 online submissions for Longest Substring Without Repeating Characters.
'''
'''
Given a string, find the length of the longest substring with... | """
Runtime: 56 ms, faster than 75.06% of Python3 online submissions for Longest Substring Without Repeating Characters.
Memory Usage: 12.8 MB, less than 100.00% of Python3 online submissions for Longest Substring Without Repeating Characters.
"""
'\nGiven a string, find the length of the longest substring without repe... |
n, m, k = map(int, input().split())
if k < n:
print(k + 1, 1)
else:
k -= n
r = n - k // (m - 1)
if r & 1:
print(r, m - k % (m - 1))
else:
print(r, k % (m - 1) + 2)
| (n, m, k) = map(int, input().split())
if k < n:
print(k + 1, 1)
else:
k -= n
r = n - k // (m - 1)
if r & 1:
print(r, m - k % (m - 1))
else:
print(r, k % (m - 1) + 2) |
TASK_NAME = 'ReviewTask'
JS_ASSETS = ['']
JS_ASSETS_OUTPUT = 'scripts/vulyk-declarations-review.js'
JS_ASSETS_FILTERS = 'yui_js'
CSS_ASSETS = ['']
CSS_ASSETS_OUTPUT = 'styles/vulyk-declarations-review.css'
CSS_ASSETS_FILTERS = 'yui_css'
| task_name = 'ReviewTask'
js_assets = ['']
js_assets_output = 'scripts/vulyk-declarations-review.js'
js_assets_filters = 'yui_js'
css_assets = ['']
css_assets_output = 'styles/vulyk-declarations-review.css'
css_assets_filters = 'yui_css' |
#!/usr/bin/python3
# -*-coding:utf-8-*-
__author__ = "Bannings"
class Solution:
def decodeString(self, s: str) -> str:
ans, stack, num = "", [], 0
for char in s:
if char.isdigit():
num = num * 10 + int(char)
elif char == "[":
stack.append((nu... | __author__ = 'Bannings'
class Solution:
def decode_string(self, s: str) -> str:
(ans, stack, num) = ('', [], 0)
for char in s:
if char.isdigit():
num = num * 10 + int(char)
elif char == '[':
stack.append((num, ans))
(num, ans)... |
'''
Given a target A on an infinite number line, i.e. -infinity to +infinity.
You are currently at position 0 and you need to reach the target by moving according to the below rule:
In ith move you can take i steps forward or backward.
Find the minimum number of moves required to reach the target.
'''
class Solutio... | """
Given a target A on an infinite number line, i.e. -infinity to +infinity.
You are currently at position 0 and you need to reach the target by moving according to the below rule:
In ith move you can take i steps forward or backward.
Find the minimum number of moves required to reach the target.
"""
class Solution... |
def format_name(first_name,last_name):
if first_name == "" and last_name == "":
return "You didn't provide valid inputs"
first_name = first_name.title()
last_name = last_name.title()
return first_name + " " + last_name
name = format_name(input("Enter your first name : "),input("Enter your last... | def format_name(first_name, last_name):
if first_name == '' and last_name == '':
return "You didn't provide valid inputs"
first_name = first_name.title()
last_name = last_name.title()
return first_name + ' ' + last_name
name = format_name(input('Enter your first name : '), input('Enter your last... |
class AnalistaContable():
def sueldo(self, horas, precio, comisiones):
print("el sueldo del analista contable es:", (horas*precio)- comisiones)
def Datos(self, nombre, apellido, edad):
print("el nombre del analista contable es: ", nombre ," ", apellido, "\n su edad es: ", edad)
... | class Analistacontable:
def sueldo(self, horas, precio, comisiones):
print('el sueldo del analista contable es:', horas * precio - comisiones)
def datos(self, nombre, apellido, edad):
print('el nombre del analista contable es: ', nombre, ' ', apellido, '\n su edad es: ', edad)
def labores... |
class Person:
def __init__(self, first_name: str, last_name: str, age: int) -> None:
self.first_name = first_name
self.last_name = last_name
self.age = age
def __repr__(self) -> str:
return f"{self.first_name} {self.last_name}, {self.age} y.o."
| class Person:
def __init__(self, first_name: str, last_name: str, age: int) -> None:
self.first_name = first_name
self.last_name = last_name
self.age = age
def __repr__(self) -> str:
return f'{self.first_name} {self.last_name}, {self.age} y.o.' |
asdasdasd
asdasdasdsa
asdasd
| asdasdasd
asdasdasdsa
asdasd |
class CastLibraryTable: #------------------------------
def __init__(self, castlibs):
self.by_nr = {}
self.by_assoc_id = {}
for cl in castlibs:
self.by_nr[cl.nr] = cl
if cl.assoc_id>0:
self.by_assoc_id[cl.assoc_id] = cl
def iter_by_nr(self):
... | class Castlibrarytable:
def __init__(self, castlibs):
self.by_nr = {}
self.by_assoc_id = {}
for cl in castlibs:
self.by_nr[cl.nr] = cl
if cl.assoc_id > 0:
self.by_assoc_id[cl.assoc_id] = cl
def iter_by_nr(self):
return self.by_nr.itervalu... |
class TimeRecord:
def __init__(self,ID,startHour,endHour,projectID,recordTypeID,description,statusID,minutes,oneNoteLink,km):
self.ID = ID
self.StartHour = startHour
self.EndHour = endHour
self.ProjectID = projectID
self.RecordTypeID = recordTypeID
self.Description =... | class Timerecord:
def __init__(self, ID, startHour, endHour, projectID, recordTypeID, description, statusID, minutes, oneNoteLink, km):
self.ID = ID
self.StartHour = startHour
self.EndHour = endHour
self.ProjectID = projectID
self.RecordTypeID = recordTypeID
self.Des... |
class Multi(object):
ITEMS = (1, 3), (5, 8)
def __getitem__(self, i):
return self.ITEMS[i[0]][i[1]]
def __setitem__(self, i, x):
self.ITEMS[i[0]][i[1]] = x
def __len__(self):
return 2, 2
| class Multi(object):
items = ((1, 3), (5, 8))
def __getitem__(self, i):
return self.ITEMS[i[0]][i[1]]
def __setitem__(self, i, x):
self.ITEMS[i[0]][i[1]] = x
def __len__(self):
return (2, 2) |
#!/usr/bin/env python3
def read_val():
return int(input())
def count_three_addend_decompositions(n):
# https://www.wolframalpha.com/input/?i=sum_k%3D0%5En+(n+-+k+%2B+1)
return (n + 1) * (n + 2) // 2
for _ in range(read_val()):
print(count_three_addend_decompositions(read_val()))
| def read_val():
return int(input())
def count_three_addend_decompositions(n):
return (n + 1) * (n + 2) // 2
for _ in range(read_val()):
print(count_three_addend_decompositions(read_val())) |
ALLOWLIST_ACTIONS = [
"ip_allow_list.enable",
"ip_allow_list.disable",
"ip_allow_list.enable_for_installed_apps",
"ip_allow_list.disable_for_installed_apps",
"ip_allow_list_entry.create",
"ip_allow_list_entry.update",
"ip_allow_list_entry.destroy",
]
def rule(event):
return (
e... | allowlist_actions = ['ip_allow_list.enable', 'ip_allow_list.disable', 'ip_allow_list.enable_for_installed_apps', 'ip_allow_list.disable_for_installed_apps', 'ip_allow_list_entry.create', 'ip_allow_list_entry.update', 'ip_allow_list_entry.destroy']
def rule(event):
return event.get('action').startswith('ip_allow_li... |
# https://leetcode-cn.com/problems/lru-cache/
class LRUCache:
def __init__(self, capacity: int):
self.c = capacity
self.l = []
self.d = {}
def get(self, key: int) -> int:
if key in self.d:
self.l.pop(self.l.index(key))
self.l.append(key)
ret... | class Lrucache:
def __init__(self, capacity: int):
self.c = capacity
self.l = []
self.d = {}
def get(self, key: int) -> int:
if key in self.d:
self.l.pop(self.l.index(key))
self.l.append(key)
return self.d[key]
else:
retur... |
cost = 14.99
taxperc = 23
tax = taxperc / 100.00
salepr = cost * (1.0 + tax)
print("sale price:", salepr) | cost = 14.99
taxperc = 23
tax = taxperc / 100.0
salepr = cost * (1.0 + tax)
print('sale price:', salepr) |
{
"targets": [
{
"target_name": "fortuna",
"sources": [ "src/main.cpp", "src/libfortuna.cpp",
"src/libfortuna/blf.c", "src/libfortuna/fortuna.c", "src/libfortuna/internal.c", "src/libfortuna/md5.c",
"src/libfortuna/px.c", "src/libfortuna/random.c", "s... | {'targets': [{'target_name': 'fortuna', 'sources': ['src/main.cpp', 'src/libfortuna.cpp', 'src/libfortuna/blf.c', 'src/libfortuna/fortuna.c', 'src/libfortuna/internal.c', 'src/libfortuna/md5.c', 'src/libfortuna/px.c', 'src/libfortuna/random.c', 'src/libfortuna/rijndael.c', 'src/libfortuna/sha1.c', 'src/libfortuna/sha2.... |
a=list()
with open('db.txt', 'r') as file:
for i in file:
a.append(i.strip())
b=input()
interval=len(a)
shift=0
while interval>=1:
t=interval%2
interval//=2
i=interval+t
print('1 - ', a[i+shift-1], ' | 2 - ', b)
r=input()
while r!='1' and r!='2':
r=input()
if r=='1':
shift+=i
else:
if not t:
inte... | a = list()
with open('db.txt', 'r') as file:
for i in file:
a.append(i.strip())
b = input()
interval = len(a)
shift = 0
while interval >= 1:
t = interval % 2
interval //= 2
i = interval + t
print('1 - ', a[i + shift - 1], ' | 2 - ', b)
r = input()
while r != '1' and r != '2':
... |
# Training and prediction
prediction_window = 7 # How many days in single prediction
# Window optimization
n_optimizer_predictions = 100 # Num of predictions to make during window optimization
smallest_possible_training_window = 25 ... | prediction_window = 7
n_optimizer_predictions = 100
smallest_possible_training_window = 25
largest_possible_training_window = 2025
training_window_test_increase = 25
n_reservoir = 200
spectral_radius = 1.5
sparsity = 0.2
noise = 0.03
input_scaling = 1.0
n_generations = 10
n_population = 100
mutation_rate = 0.5
crossove... |
# Given an array a that contains only numbers in the range from 1 to a.length, find the first duplicate number for which the second occurrence has the minimal index. In other words, if there are more than 1 duplicated numbers, return the number for which the second occurrence has a smaller index than the second occurr... | def first_duplicate(a):
new = set()
for i in range(len(a)):
if a[i] in new:
return a[i]
else:
new.add(a[i])
return -1
a = [2, 1, 3, 5, 3, 2]
print(first_duplicate(a)) |
testcase = int(input())
for i in range(testcase+1):
if i == 0:
continue
strlist = input()
strlen = len(strlist)
j = 0
decodestr = "Case {}: ".format(i)
while j < strlen:
ch = strlist[j]
if ch == '\n':
break
else:
cnt = 0
k = j + 1
while(k < strlen and strlist[k].isdigit()):
cnt *= 10
c... | testcase = int(input())
for i in range(testcase + 1):
if i == 0:
continue
strlist = input()
strlen = len(strlist)
j = 0
decodestr = 'Case {}: '.format(i)
while j < strlen:
ch = strlist[j]
if ch == '\n':
break
else:
cnt = 0
k = j... |
# -*- coding: utf-8 -*-
#: Following the versioning system at http://semver.org/
#: See also docs/contributing.rst, section ``Versioning``
#: MAJOR: incremented for incompatible API changes
MAJOR = 1
#: MINOR: incremented for adding functionality in a backwards-compatible manner
MINOR = 0
#: PATCH: incremented for bac... | major = 1
minor = 0
patch = 0
__version__ = '{0:d}.{1:d}.{2:d}'.format(MAJOR, MINOR, PATCH) |
def logical_calc(array,op):
while len(array) > 1:
inp1 = array.pop(0)
inp2 = array.pop(0)
if op == "AND":
array.insert(0,a(inp1,inp2))
elif op == "OR":
array.insert(0,o(inp1,inp2))
elif op == "XOR":
array.insert(0,x(inp1,i... | def logical_calc(array, op):
while len(array) > 1:
inp1 = array.pop(0)
inp2 = array.pop(0)
if op == 'AND':
array.insert(0, a(inp1, inp2))
elif op == 'OR':
array.insert(0, o(inp1, inp2))
elif op == 'XOR':
array.insert(0, x(inp1, inp2))
r... |
def add_native_methods(clazz):
def getTotalSwapSpaceSize____(a0):
raise NotImplementedError()
def getFreeSwapSpaceSize____(a0):
raise NotImplementedError()
def getProcessCpuTime____(a0):
raise NotImplementedError()
def getFreePhysicalMemorySize____(a0):
raise NotImplem... | def add_native_methods(clazz):
def get_total_swap_space_size____(a0):
raise not_implemented_error()
def get_free_swap_space_size____(a0):
raise not_implemented_error()
def get_process_cpu_time____(a0):
raise not_implemented_error()
def get_free_physical_memory_size____(a0):
... |
#You Source Code Very Good
print("Good")
for i in range(1,20+1):
print("It works Great!")
| print('Good')
for i in range(1, 20 + 1):
print('It works Great!') |
#!/usr/bin/env python
class FLVError(Exception):
pass
class F4VError(Exception):
pass
class AMFError(Exception):
pass
__all__ = ["FLVError", "F4VError", "AMFError"]
| class Flverror(Exception):
pass
class F4Verror(Exception):
pass
class Amferror(Exception):
pass
__all__ = ['FLVError', 'F4VError', 'AMFError'] |
def check_cnpj(value):
if value == '99999999999999':
is_valid = False
else:
# Checks if is in pattern NNNNNNNNNNNNNN
is_valid_len = len(value) == 14
is_valid_num = all(char.isnumeric() for char in value)
is_valid = is_valid_len and is_valid_num
return not is_valid
de... | def check_cnpj(value):
if value == '99999999999999':
is_valid = False
else:
is_valid_len = len(value) == 14
is_valid_num = all((char.isnumeric() for char in value))
is_valid = is_valid_len and is_valid_num
return not is_valid
def check_cpf(value):
if value == '0000000000... |
# 1st solution
class Solution:
def findLadders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]:
if endWord not in wordList:
return []
wordSet = set(wordList) # faster checks against dictionary
layer = {}
layer[beginWord] = [[beginWord]] # ... | class Solution:
def find_ladders(self, beginWord: str, endWord: str, wordList: List[str]) -> List[List[str]]:
if endWord not in wordList:
return []
word_set = set(wordList)
layer = {}
layer[beginWord] = [[beginWord]]
while layer:
newlayer = collection... |
#!/usr/bin/env python3
# https://abc099.contest.atcoder.jp/tasks/abc099_b
a, b = map(int, input().split())
d = b - a
k = d * (d - 1) // 2
print(k - a)
| (a, b) = map(int, input().split())
d = b - a
k = d * (d - 1) // 2
print(k - a) |
class StringUtilities(str):
def longest_word(self):
word_list = self.split()
longest_word_length = 0
for word in word_list:
word = StringUtilities.remove_symbols(word)
if len(word) > longest_word_length:
longest_word_length = len(word)
... | class Stringutilities(str):
def longest_word(self):
word_list = self.split()
longest_word_length = 0
for word in word_list:
word = StringUtilities.remove_symbols(word)
if len(word) > longest_word_length:
longest_word_length = len(word)
return ... |
def result(G_ab,kmeans,kmeans_cluster_centers_mag,of_idx,of_min_x,of_min_y,n_clusters,knn,dataset):
dist = np.ones(n_clusters)*100
valid = np.ones(n_clusters)
for i in range(0,n_clusters):
# get pixel coordinates of VP point plane cantidate
y_idx,x_idx = np.unravel_index(np.argmax(G_ab[:,:,i], axis=None)... | def result(G_ab, kmeans, kmeans_cluster_centers_mag, of_idx, of_min_x, of_min_y, n_clusters, knn, dataset):
dist = np.ones(n_clusters) * 100
valid = np.ones(n_clusters)
for i in range(0, n_clusters):
(y_idx, x_idx) = np.unravel_index(np.argmax(G_ab[:, :, i], axis=None), G_ab[:, :, i].shape)
... |
#!/usr/bin/env python
# coding=utf-8
def ClassSchedule(DB, pam):
json_data = {
"code": 0,
"msg": ""
}
if pam == "":
json_data["code"] = "0"
json_data["msg"] = "false"
return json_data
classid = pam["Pam"]
# &Schedule.WID, &Schedule.Chapter, &Schedule.CourseN... | def class_schedule(DB, pam):
json_data = {'code': 0, 'msg': ''}
if pam == '':
json_data['code'] = '0'
json_data['msg'] = 'false'
return json_data
classid = pam['Pam']
sql_str = 'select * from (SELECT T3.*,T4.ID as tid,T4.`start` as tstart,t4.`end` as tend from(select t1.*,t2.User... |
def decor(func):
def wrap():
print("============")
func()
print("============")
return wrap
def print_text():
print("Hello world!")
decorated = decor(print_text)
decorated()
| def decor(func):
def wrap():
print('============')
func()
print('============')
return wrap
def print_text():
print('Hello world!')
decorated = decor(print_text)
decorated() |
for i in range(100, 1000):
base9 = ''
base10 = i
# Convert to base 9
for j in range(0,3):
r = base10 % 9
base10 = (base10 - r) / 9
base9 = str(int(r)) + base9
# compare base 10 to reversed base9
if str(i) == str(base9)[::-1]:
print('Found... | for i in range(100, 1000):
base9 = ''
base10 = i
for j in range(0, 3):
r = base10 % 9
base10 = (base10 - r) / 9
base9 = str(int(r)) + base9
if str(i) == str(base9)[::-1]:
print('Found: ' + str(i) + '^10 == ' + str(base9) + '^9')
break |
#
# PySNMP MIB module EQLCONTROLLER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/EQLCONTROLLER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:05:16 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Ma... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, value_range_constraint, single_value_constraint, constraints_union, constraints_intersection) ... |
#!/bin/python
num = int(input())
possibilities = 0
while num >= 0:
if num % 4 == 0:
possibilities += 1
num -= 5
print(possibilities)
| num = int(input())
possibilities = 0
while num >= 0:
if num % 4 == 0:
possibilities += 1
num -= 5
print(possibilities) |
class Mouse(object):
def __init__(self, browser):
self.browser = browser
def left_click(
self,
element=None,
by_id=None,
by_xpath=None,
by_link=None,
by_partial_link=None,
by_name=None,
by_tag=None,
by_css=None,
by_class=No... | class Mouse(object):
def __init__(self, browser):
self.browser = browser
def left_click(self, element=None, by_id=None, by_xpath=None, by_link=None, by_partial_link=None, by_name=None, by_tag=None, by_css=None, by_class=None):
self.left_click_by_offset(element, 0, 0, by_id=by_id, by_xpath=by_x... |
# Theory: Kwargs
# With *args you can create more flexible functions that accept
# a varying number of positional arguments. You may now wonder
# how to do the same with named arguments. Fortunately, in
# Python, you can work with keyword arguments in a similar way.
# Multiple keyword arguments
# Let's get acquianted... | def capital(**kwargs):
for (key, value) in kwargs.items():
print(value, 'is the capital city of', key)
capital(Canada='Ottawa', Estonia='Tallinn', Venezuela='Caracas', Finland='Helsinki')
def func(positional_args, defaults, *args, **kwargs):
pass
def say_bye(**names):
for name in names:
pr... |
#!/usr/bin/env python3
# Copyright 2009-2017 BHG http://bw.org/
x = 42
y = 73
# Compares the vallue of x and y
if x < y:
print('x < y: x is {} and y is {}'.format(x, y))
elif x > y:
print("x is greater than y")
else:
print("x and y are equal")
if x > y:
print('x > y: x is {} and y is {}'.format(x, y)... | x = 42
y = 73
if x < y:
print('x < y: x is {} and y is {}'.format(x, y))
elif x > y:
print('x is greater than y')
else:
print('x and y are equal')
if x > y:
print('x > y: x is {} and y is {}'.format(x, y))
print('Inside Condition')
x = 10
print(x) |
__title__ = 'Generative FSL for Covid Prediction'
__version__ = '1.0.0'
__author__ = 'Suvarna Kadam'
__license__ = 'MIT'
__copyright__ = 'Copyright 2021'
| __title__ = 'Generative FSL for Covid Prediction'
__version__ = '1.0.0'
__author__ = 'Suvarna Kadam'
__license__ = 'MIT'
__copyright__ = 'Copyright 2021' |
print('Temperature conversion program')
print(' press 1 for convert from celcius to another \n press 2 for convert from faremhit to another \n press 3 for convert from kelvin to another')
choice = int(input('enter your choice number : '))
if choice >3:
print('invalid choice optino...please enter from 1 to 3... | print('Temperature conversion program')
print(' press 1 for convert from celcius to another \n press 2 for convert from faremhit to another \n press 3 for convert from kelvin to another')
choice = int(input('enter your choice number : '))
if choice > 3:
print('invalid choice optino...please enter from 1 to 3')
if c... |
a=int(input('enter a :'))
b=int(input('enter a :'))
c=int(input('enter a :'))
def largest_num(x,y,z):
if x>y and x>z:
print(x)
elif y>x and y>z:
print(y)
else:
print(z)
print('largest :',end="")
largest_num(a,b,c) | a = int(input('enter a :'))
b = int(input('enter a :'))
c = int(input('enter a :'))
def largest_num(x, y, z):
if x > y and x > z:
print(x)
elif y > x and y > z:
print(y)
else:
print(z)
print('largest :', end='')
largest_num(a, b, c) |
# List in Python
# from typing import Tuple
name = ["Anirban", "Rangan", "Miko", "UK NK", "Lucifer"]
print(name)
# mixed List
mixing1 = ["ISHITA ROY", 143, 0.99, 'E']
print(mixing1)
print(mixing1[2])
# list shorting
num1 = [2, 5, 78, 3, 88, 23, 1, 94, 33, 21, 5, 3, 67, 27]
print(num1)
num2 = num1.copy()
num1.sort()
pr... | name = ['Anirban', 'Rangan', 'Miko', 'UK NK', 'Lucifer']
print(name)
mixing1 = ['ISHITA ROY', 143, 0.99, 'E']
print(mixing1)
print(mixing1[2])
num1 = [2, 5, 78, 3, 88, 23, 1, 94, 33, 21, 5, 3, 67, 27]
print(num1)
num2 = num1.copy()
num1.sort()
print(num1)
num1.reverse()
num1.remove(33)
num1.pop()
num1.append(101)
num1.... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.