content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
class Constants:
LOGGER_NAME = "log4sdc-common"
LOGGER_LOG_LEVEL_ENV_VAR = "LOG_LEVEL"
LOGGER_DEFAULT_LOG_LEVEL = "WARN"
def __setattr__(self, attr, value):
if hasattr(self, attr):
raise Exception("Attempting to alter read-only value")
self.__dict__[attr] = value
| class Constants:
logger_name = 'log4sdc-common'
logger_log_level_env_var = 'LOG_LEVEL'
logger_default_log_level = 'WARN'
def __setattr__(self, attr, value):
if hasattr(self, attr):
raise exception('Attempting to alter read-only value')
self.__dict__[attr] = value |
class Solution:
def leap_year(self, year):
return ((year % 400 == 0) or (year % 100 != 0 and year % 4 == 0))
def date_to_int(self, year, month, day):
month_length = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = day - 1
while month != 0:
month -= ... | class Solution:
def leap_year(self, year):
return year % 400 == 0 or (year % 100 != 0 and year % 4 == 0)
def date_to_int(self, year, month, day):
month_length = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
ans = day - 1
while month != 0:
month -= 1
... |
N,B,H,W =map(int,input().split())
ans = 9876543210
for i in range(H):
p = int(input())
L = list(map(int,input().split()))
for i in L:
if i >=N:
if p*N <= B and p*N < ans:
ans = p*N
if ans == 9876543210:
print("stay home")
else:
print(ans) | (n, b, h, w) = map(int, input().split())
ans = 9876543210
for i in range(H):
p = int(input())
l = list(map(int, input().split()))
for i in L:
if i >= N:
if p * N <= B and p * N < ans:
ans = p * N
if ans == 9876543210:
print('stay home')
else:
print(ans) |
# decorator function
def mymypy(types):
def wrap(func):
def inner(*args):
for t, a in zip(types, args):
if not isinstance(a, t):
raise TypeError(f'Argument: {a} is not type {t}')
return func(*args)
return inner
return wrap
# --- testi... | def mymypy(types):
def wrap(func):
def inner(*args):
for (t, a) in zip(types, args):
if not isinstance(a, t):
raise type_error(f'Argument: {a} is not type {t}')
return func(*args)
return inner
return wrap
@mymypy([float, int])
def mu... |
# Data directories
train_data_path = "./finished_files/chunked/train_*.json"
eval_data_path = "./finished_files/val.json"
decode_data_path = "./finished_files/test.json"
vocab_path = "./finished_files/vocab"
log_root = "./log"
# Hyperparameters
hidden_dim = 256
emb_dim = 128
batch_size = 8
max_enc_steps = 400
max_dec_... | train_data_path = './finished_files/chunked/train_*.json'
eval_data_path = './finished_files/val.json'
decode_data_path = './finished_files/test.json'
vocab_path = './finished_files/vocab'
log_root = './log'
hidden_dim = 256
emb_dim = 128
batch_size = 8
max_enc_steps = 400
max_dec_steps = 100
beam_size = 4
min_dec_step... |
class BaseProfileVisualizer:
def __init__(self, framework=None, visualizer=None):
self.framework = framework
self.visualizer = visualizer
self.profiles = []
def set_profiles(self, profiles):
""""""
if len(profiles) <= 1:
self.profiles = [profiles]
els... | class Baseprofilevisualizer:
def __init__(self, framework=None, visualizer=None):
self.framework = framework
self.visualizer = visualizer
self.profiles = []
def set_profiles(self, profiles):
""""""
if len(profiles) <= 1:
self.profiles = [profiles]
el... |
# Give yourself a nice cheer -
# print out Go Whateveryournameis!
print( )
# Did you get an error?
# Remember that you need to wrap something around text...
| print() |
def select_tower(tower_selected, tower):
if tower_selected:
move_disk(tower_selected, tower)
return None
else:
return tower
def move_disk(from_tower, to_tower):
disk = from_tower.pop()
if not disk:
return False
if can_move(disk, to_tower):
to_tower.append(d... | def select_tower(tower_selected, tower):
if tower_selected:
move_disk(tower_selected, tower)
return None
else:
return tower
def move_disk(from_tower, to_tower):
disk = from_tower.pop()
if not disk:
return False
if can_move(disk, to_tower):
to_tower.append(dis... |
def dedupe_and_sort(sequence, first=None, last=None):
"""
De-dupe and partially sort a sequence.
The `first` argument should contain all the items that might appear in
`sequence` and for which the order (relative to each other) is important.
The `last` argument is the same, but matching items will... | def dedupe_and_sort(sequence, first=None, last=None):
"""
De-dupe and partially sort a sequence.
The `first` argument should contain all the items that might appear in
`sequence` and for which the order (relative to each other) is important.
The `last` argument is the same, but matching items will... |
class OTRSException(Exception):
pass
class HTTPMethodNotSupportedError(OTRSException):
pass
class OTRSBadResponse(OTRSException):
pass
class AuthError(OTRSException):
pass
class AccessDeniedError(OTRSException):
pass
class InvalidParameterError(OTRSException):
pass
class ArgumentMiss... | class Otrsexception(Exception):
pass
class Httpmethodnotsupportederror(OTRSException):
pass
class Otrsbadresponse(OTRSException):
pass
class Autherror(OTRSException):
pass
class Accessdeniederror(OTRSException):
pass
class Invalidparametererror(OTRSException):
pass
class Argumentmissingerr... |
# cmdline: -O
# test optimisation output
print(__debug__)
assert 0
| print(__debug__)
assert 0 |
HOST = 'nhc2.local'
USER = 'username'
PASS = 'password'
# For hobby API 8884
PORT = 8883 | host = 'nhc2.local'
user = 'username'
pass = 'password'
port = 8883 |
"""Bind all submodules needed for eventuals."""
load("@com_github_3rdparty_eventuals//bazel:submodule_repository.bzl", "submodule_repository")
def submodules(external):
"""Creates repositories for each submodule.
Args:
external: whether or not we're invoking this function as though
thou... | """Bind all submodules needed for eventuals."""
load('@com_github_3rdparty_eventuals//bazel:submodule_repository.bzl', 'submodule_repository')
def submodules(external):
"""Creates repositories for each submodule.
Args:
external: whether or not we're invoking this function as though
thoug... |
# Copyright 2021 Sony Corporation.
#
# 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 wri... | incompatible_arcs = {('100', '7'): ['Ampere', 'Fermi'], ('102', '7'): ['Ampere', 'Fermi'], ('102', '8'): ['Ampere', 'Fermi'], ('110', '8'): ['Fermi']}
gpu_compute_capability_to_arc = {8: 'Ampere', (7, 5): 'Turing', (7, 0): 'Volta', (7, 2): 'Volta', 6: 'Pascal', 5: 'Maxwell', 3: 'Kepler', 2: 'Fermi'} |
api_key = ''
api_secret = ''
# number of seconds before bittrex request timesout
timeout = 5 | api_key = ''
api_secret = ''
timeout = 5 |
expected_output = {
'vrf':
{'default':
{'address_family':
{'ipv4':
{'instance':
{'1':
{'areas':
{'0.0.0.0':
{'database':
... | expected_output = {'vrf': {'default': {'address_family': {'ipv4': {'instance': {'1': {'areas': {'0.0.0.0': {'database': {'lsa_types': {10: {'lsa_type': 10, 'lsas': {'10.1.0.0 192.168.4.1': {'adv_router': '192.168.4.1', 'lsa_id': '10.1.0.0', 'ospfv2': {'body': {'opaque': {}}, 'header': {'adv_router': '192.168.4.1', 'age... |
# Right justify a string to column 70 of the screen
def rightjustify(sig):
full_line = ""
num_chars = len(sig)
blank = 70 - num_chars
full_line += " "*blank + sig
pass
print(full_line)
rightjustify("monty")
| def rightjustify(sig):
full_line = ''
num_chars = len(sig)
blank = 70 - num_chars
full_line += ' ' * blank + sig
pass
print(full_line)
rightjustify('monty') |
def decimal_to_binary(n):
if n > 1: decimal_to_binary(n//2)
print(n % 2, end = '')
try: decimal_to_binary(int(input("Enter an Integer to Covert into Binary: ")))
except ValueError: print("Input is not an integer.")
print()
| def decimal_to_binary(n):
if n > 1:
decimal_to_binary(n // 2)
print(n % 2, end='')
try:
decimal_to_binary(int(input('Enter an Integer to Covert into Binary: ')))
except ValueError:
print('Input is not an integer.')
print() |
'''
Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)
A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid.
Return the number of land squares in the grid for which we cannot walk off the boundary of the grid in any number ... | """
Given a 2D array A, each cell is 0 (representing sea) or 1 (representing land)
A move consists of walking from one land square 4-directionally to another land square, or off the boundary of the grid.
Return the number of land squares in the grid for which we cannot walk off the boundary of the grid in any number ... |
#!/usr/bin/env python3
"""This file contains the health check functions used on a service bundle.
"""
| """This file contains the health check functions used on a service bundle.
""" |
n = input()
my_set = set()
for item in input().split():
my_set.add(item)
m = input()
for item in input().split():
if item in my_set:
print(1)
else:
print(0) | n = input()
my_set = set()
for item in input().split():
my_set.add(item)
m = input()
for item in input().split():
if item in my_set:
print(1)
else:
print(0) |
class Observable:
def __init__(self):
self._observers = []
def register(self, observer):
if observer not in self._observers:
self._observers.append(observer)
def unregister(self, observer):
if observer in self._observers:
self._observers.remove(observer)
... | class Observable:
def __init__(self):
self._observers = []
def register(self, observer):
if observer not in self._observers:
self._observers.append(observer)
def unregister(self, observer):
if observer in self._observers:
self._observers.remove(observer)
... |
class Solution:
def lengthOfLongestSubstring(self, s):
dicts = {}
maxlength = start = 0
for i,value in enumerate(s):
if value in dicts:
sums = dicts[value] + 1
if sums > start:
start = sums
num = i - start + 1
... | class Solution:
def length_of_longest_substring(self, s):
dicts = {}
maxlength = start = 0
for (i, value) in enumerate(s):
if value in dicts:
sums = dicts[value] + 1
if sums > start:
start = sums
num = i - start + 1... |
# -*- coding: utf-8
# http://stackoverflow.com/questions/2082152/case-insensitive-dictionary
class CaseInsensitiveDict(dict):
def __setitem__(self, key, value):
super(Caseinsensitivedict, self).__setitem__(key.lower(), value)
def __getitem__(self, key):
return super(Caseinsensitivedict, self)... | class Caseinsensitivedict(dict):
def __setitem__(self, key, value):
super(Caseinsensitivedict, self).__setitem__(key.lower(), value)
def __getitem__(self, key):
return super(Caseinsensitivedict, self).__getitem__(key.lower()) |
student_name = input()
count = 0
count_fail = 0
grades = []
grade = float(input())
while count < 12:
if grade < 4:
count_fail += 1
if count_fail > 1:
print(f"{student_name} has been excluded at {count} grade")
exit()
grades.append(grade)
else:
grades.appe... | student_name = input()
count = 0
count_fail = 0
grades = []
grade = float(input())
while count < 12:
if grade < 4:
count_fail += 1
if count_fail > 1:
print(f'{student_name} has been excluded at {count} grade')
exit()
grades.append(grade)
else:
grades.appen... |
#
# PySNMP MIB module PDN-MPE-HEALTH-AND-STATUS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PDN-MPE-HEALTH-AND-STATUS-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:39:22 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ve... | (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, single_value_constraint, constraints_intersection, value_size_constraint) ... |
class Eval(object):
def __init__(self, param):
self.__str = param.get('value')
self.__length = param.get('length',100000)
self.__counter = 0
def next(self):
self.__counter += 1
if self.__counter > self.__length:
raise StopIteration
value = self.__str
return {'value': value}
def length(self):
r... | class Eval(object):
def __init__(self, param):
self.__str = param.get('value')
self.__length = param.get('length', 100000)
self.__counter = 0
def next(self):
self.__counter += 1
if self.__counter > self.__length:
raise StopIteration
value = self.__st... |
n=int(input())
a=""
for i in range(1,n+1):
a+=str(i)
print(a)
| n = int(input())
a = ''
for i in range(1, n + 1):
a += str(i)
print(a) |
"""
Problem Statement:
Given a non-empty array of integers,
every element appears twice except for one.
Find that single one.
Note:
Your algorithm should have a linear runtime complexity.
Could you implement it without using extra memory?
"""
def single_number(integers):
unique = 0
for integer in integers:... | """
Problem Statement:
Given a non-empty array of integers,
every element appears twice except for one.
Find that single one.
Note:
Your algorithm should have a linear runtime complexity.
Could you implement it without using extra memory?
"""
def single_number(integers):
unique = 0
for integer in integers:
... |
#define the main
def main():
i = 0 #declare an integer i
x = 119.0 #declare a float x
for i in range(120): #loop i from 0 to 119
if ((i%2)==0): #if i is even
x += 3. #add 3
else: #if i is odd
x -= 5. #subtract 5 from x
s = "%3.2e" % x #make a string containing x
print(s)
if __... | def main():
i = 0
x = 119.0
for i in range(120):
if i % 2 == 0:
x += 3.0
else:
x -= 5.0
s = '%3.2e' % x
print(s)
if __name__ == '__main__':
main() |
#class memorySetting():
global packet_db
packet_db = {}
# Schema
# Key for access is MAC Address/IP Address
# * Initially had mac address (assuming unique) as the only key
# - CTF problems sometime cause a scenario of same mac with different IP address so segregated this
# * Otherwise each key holds
# - Mac Vend... | global packet_db
packet_db = {}
global lan_hosts
lan_hosts = {}
global destination_hosts
destination_hosts = {}
global tor_nodes
tor_nodes = []
global possible_tor_traffic
possible_tor_traffic = []
global malicious_traffic
possible_mal_traffic = []
global signatures
signatures = {} |
# -*- coding: Latin-1 -*-
# pycrc -- parametrisable CRC calculation utility and C source code generator
#
# Copyright (c) 2006-2011 Thomas Pircher <tehpeh@gmx.net>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software... | """
CRC routines for pycrc.
If you want to study the Python implementation of the CRC routines, then you are
looking at the right place.
Examples
========
This is an example use of the different algorithms:
>>> from crc_algorithms import Crc
>>>
>>> crc = Crc(width = 16, poly = 0x8005,
... reflect_in = Tr... |
sm = [[1, 2, 3],
[8, 9, 4],
[7, 6, 5]]
sm2 = [[1, 2, 3, 4],
[12, 13, 14, 5],
[11, 16, 15, 6],
[10, 9, 8, 7]]
def snail(snail_map):
ans = []
c = 0
nMtx = snail_map
l = len(snail_map)
for i in snail_map[0]:
ans.append(i)
for i in range(l):
if... | sm = [[1, 2, 3], [8, 9, 4], [7, 6, 5]]
sm2 = [[1, 2, 3, 4], [12, 13, 14, 5], [11, 16, 15, 6], [10, 9, 8, 7]]
def snail(snail_map):
ans = []
c = 0
n_mtx = snail_map
l = len(snail_map)
for i in snail_map[0]:
ans.append(i)
for i in range(l):
if i > 0 and i < l - 1:
ans.... |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright (c) 2019, Gianluca Fiore
#
###############################################################################
__author__ = "Gianluca Fiore"
class Node(object):
def __init__(sel... | __author__ = 'Gianluca Fiore'
class Node(object):
def __init__(self, data=None, next_node=None, prev_node=None):
self.data = data
self.next_node = next_node
self.prev_node = prev_node
def get_data(self):
return self.data
def set_data(self, val):
self.data = val
c... |
class A(object):
val = 1
class B(A):
pass
class C(A):
pass
print(A.val, B.val, C.val)
B.val = 2
print (A.val, B.val, C.val)
A.val = 3
print (A.val, B.val, C.val)
"""
Explanation:
In Python,{{{{ class variables are internally handled as dictionaries}}}}.
If a variable name is not found in the dictionary of the curr... | class A(object):
val = 1
class B(A):
pass
class C(A):
pass
print(A.val, B.val, C.val)
B.val = 2
print(A.val, B.val, C.val)
A.val = 3
print(A.val, B.val, C.val)
'\nExplanation:\nIn Python,{{{{ class variables are internally handled as dictionaries}}}}. \nIf a variable name is not found in the dictionary of... |
##This program finds all the numbers between 1500 and 2700 that are
##divisible by 5 and 7.
n = range(1500, 2700)
newlist = []
for i in n:
if (i%7==0) and (i%5==0):
newlist.append(str(i))
print(newlist)
| n = range(1500, 2700)
newlist = []
for i in n:
if i % 7 == 0 and i % 5 == 0:
newlist.append(str(i))
print(newlist) |
class Solution(object):
def firstUniqChar(self, s):
"""
:type s: str
:rtype: int
"""
d={}
for i,x in enumerate(s):
if x in d:
continue
elif s[i:].count(x)==1:
return i
else:
d[x]=1
... | class Solution(object):
def first_uniq_char(self, s):
"""
:type s: str
:rtype: int
"""
d = {}
for (i, x) in enumerate(s):
if x in d:
continue
elif s[i:].count(x) == 1:
return i
else:
... |
def test_augassign():
r: i32
s: i32
r = 0
r += 4
s = 5
r *= s
r -= 2
s = 10
r /= s
a: str
a = ""
a += "test"
| def test_augassign():
r: i32
s: i32
r = 0
r += 4
s = 5
r *= s
r -= 2
s = 10
r /= s
a: str
a = ''
a += 'test' |
'''
Descripttion:
version:
Author: HuSharp
Date: 2021-02-09 11:34:48
LastEditors: HuSharp
LastEditTime: 2021-02-09 11:42:18
@Email: 8211180515@csu.edu.cn
'''
def count(s, val):
'''cnt the val 's nums in s
>>> count([1,2,3,4,1], 1)
2
'''
total = 0
for element in s:
if element == val:
... | """
Descripttion:
version:
Author: HuSharp
Date: 2021-02-09 11:34:48
LastEditors: HuSharp
LastEditTime: 2021-02-09 11:42:18
@Email: 8211180515@csu.edu.cn
"""
def count(s, val):
"""cnt the val 's nums in s
>>> count([1,2,3,4,1], 1)
2
"""
total = 0
for element in s:
if element == val:
... |
__title__ = 'krnl'
__url__ = 'https://github.com/cens6r/krnl.py/'
__author__ = 'Cens6r'
__email__ = 'cens6r@no-email-yet'
__license__ = 'MIT License'
__version__ = '1.0.0'
__description__ = 'Utilize the KRNL Api easily from python'
| __title__ = 'krnl'
__url__ = 'https://github.com/cens6r/krnl.py/'
__author__ = 'Cens6r'
__email__ = 'cens6r@no-email-yet'
__license__ = 'MIT License'
__version__ = '1.0.0'
__description__ = 'Utilize the KRNL Api easily from python' |
class Solution(object):
def minTimeToVisitAllPoints(self, points):
"""
:type points: List[List[int]]
:rtype: int
"""
t = 0
for i in range(len(points) - 1):
t += self._time(points[i], points[i + 1])
return t
def _time(self, pa, pb):
t1 ... | class Solution(object):
def min_time_to_visit_all_points(self, points):
"""
:type points: List[List[int]]
:rtype: int
"""
t = 0
for i in range(len(points) - 1):
t += self._time(points[i], points[i + 1])
return t
def _time(self, pa, pb):
... |
class DiffLineState:
INSERT = 0
DELETE = 1
UNCHANGED = 2
class DiffLine():
def __init__(self):
self.text = None
self.state = DiffLineState.UNCHANGED
class DiffChange():
def __init__(self):
self.oldStartLine = None
self.newStartLine = None
self.description = ... | class Difflinestate:
insert = 0
delete = 1
unchanged = 2
class Diffline:
def __init__(self):
self.text = None
self.state = DiffLineState.UNCHANGED
class Diffchange:
def __init__(self):
self.oldStartLine = None
self.newStartLine = None
self.description = No... |
def binary_search(sorted_list, key):
if type(key) is not int:
raise TypeError('Argument invalid. Must be int.')
left = 0
right = len(sorted_list) - 1
while left != right:
# import pdb; pdb.set_trace()
if (left + right) % 2:
if sorted_list[int((left + right) / 2)] == k... | def binary_search(sorted_list, key):
if type(key) is not int:
raise type_error('Argument invalid. Must be int.')
left = 0
right = len(sorted_list) - 1
while left != right:
if (left + right) % 2:
if sorted_list[int((left + right) / 2)] == key:
return int((left ... |
# -*- coding: utf-8 -*-
log_file = "autogreeter.log" # Fill this out for a logging. P.S It's a must!
slack_token = "" # token for slack bot
welcomemessagedm = "" # what the bot should dm the person
welcomemessagechannel = "" # what should the bot post on a channel, leave empty to not post
| log_file = 'autogreeter.log'
slack_token = ''
welcomemessagedm = ''
welcomemessagechannel = '' |
table = [
'Feature | This Lib | Classical Singleton | [herpe] | [ugrif] | [xytis] | [aworx] | [fwolt] | [zyf38] | [cheno] | [cppma]',
'supports instance replacement for testing | X | - | - | - | - | - | - | - | X | X',
'2-phase initialization avoidable| X | - | - | - | - | - | - | - | - | -',
'control ... | table = ['Feature | This Lib | Classical Singleton | [herpe] | [ugrif] | [xytis] | [aworx] | [fwolt] | [zyf38] | [cheno] | [cppma]', 'supports instance replacement for testing | X | - | - | - | - | - | - | - | X | X', '2-phase initialization avoidable| X | - | - | - | - | - | - | - | - | -', 'control over construction ... |
# -*- coding: utf-8 -*-
"""
Created on Wed Sep 16 15:37:04 2020
@author: CHANGE WITH YOUR NAME
This is a blablabla..
"""
print(3+4)
print(3, 4, 3+4)
print("3 4 3+4")
print()
print("The answer is 3+4")
| """
Created on Wed Sep 16 15:37:04 2020
@author: CHANGE WITH YOUR NAME
This is a blablabla..
"""
print(3 + 4)
print(3, 4, 3 + 4)
print('3 4 3+4')
print()
print('The answer is 3+4') |
def cross(u, v):
"""
return the cross product of 2 vectors.
"""
dim = len(u)
s = []
for i in range(0, dim):
if i == 0:
j,k = 1,2
s.append(u[j]*v[k] - u[k]*v[j])
elif i == 1:
j,k = 2,0
s.append(u[j]*v[k] - u[k]*v[j])
else:
j,k = 0,1
... | def cross(u, v):
"""
return the cross product of 2 vectors.
"""
dim = len(u)
s = []
for i in range(0, dim):
if i == 0:
(j, k) = (1, 2)
s.append(u[j] * v[k] - u[k] * v[j])
elif i == 1:
(j, k) = (2, 0)
s.append(u[j] * v[k] - u[k] * v[j])
... |
"""
instance.py contains the basic classes of the items in a study plan card,
like university, faculty, major, and course. This was made to 'objectify' the
data fetched from the courses.json file
"""
class University:
"""Wrapper for University item"""
def __init__(self, name=None, faculties=[], aliases=[]):
... | """
instance.py contains the basic classes of the items in a study plan card,
like university, faculty, major, and course. This was made to 'objectify' the
data fetched from the courses.json file
"""
class University:
"""Wrapper for University item"""
def __init__(self, name=None, faculties=[], aliases=[]):
... |
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def deleteDuplicates(self, head: ListNode) -> ListNode:
if not head:
return head
dummy_head = ListNode()
dummy_head.nex... | class Listnode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def delete_duplicates(self, head: ListNode) -> ListNode:
if not head:
return head
dummy_head = list_node()
dummy_head.next = head
prev = dummy_head... |
# -*- coding: utf-8 -*-
"""Top-level package for cui_okinawa."""
__author__ = """anosillus"""
__email__ = "anosillus@gmail.com"
__version__ = "0.1.0"
| """Top-level package for cui_okinawa."""
__author__ = 'anosillus'
__email__ = 'anosillus@gmail.com'
__version__ = '0.1.0' |
class Node:
def __init__(self, value=""):
self.value = value
self.next = None
class LinkedList():
def __init__(self):
self.head = None
self.values=[]
def insert(self, value):
self.values.append(value)
node = Node(value)
if self.head:
n... | class Node:
def __init__(self, value=''):
self.value = value
self.next = None
class Linkedlist:
def __init__(self):
self.head = None
self.values = []
def insert(self, value):
self.values.append(value)
node = node(value)
if self.head:
no... |
#
# PySNMP MIB module NetWare-Host-Ext-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NetWare-Host-Ext-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 20:16:26 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, constraints_intersection, single_value_constraint, constraints_union, value_range_constraint) ... |
""" Mime type data
"""
MIME_TYPES = {
'png': "image/png",
'svg': "image/svg+xml",
'eps': "application/postscript",
'dw': "text/plain",
}
| """ Mime type data
"""
mime_types = {'png': 'image/png', 'svg': 'image/svg+xml', 'eps': 'application/postscript', 'dw': 'text/plain'} |
# config.py
def can_build(env, platform):
return True
def configure(env):
pass
def get_doc_path():
return "doc_classes"
def get_doc_classes():
return [
"MySQL",
]
| def can_build(env, platform):
return True
def configure(env):
pass
def get_doc_path():
return 'doc_classes'
def get_doc_classes():
return ['MySQL'] |
# generated from genmsg/cmake/pkg-genmsg.context.in
messages_str = "/home/nvidia/catkin_ws/src/my_pkg3/msg/MABX.msg;/home/nvidia/catkin_ws/src/my_pkg3/msg/a.msg"
services_str = ""
pkg_name = "my_pkg3"
dependencies_str = "std_msgs"
langs = ""
dep_include_paths_str = "my_pkg3;/home/nvidia/catkin_ws/src/my_pkg3/msg;std_m... | messages_str = '/home/nvidia/catkin_ws/src/my_pkg3/msg/MABX.msg;/home/nvidia/catkin_ws/src/my_pkg3/msg/a.msg'
services_str = ''
pkg_name = 'my_pkg3'
dependencies_str = 'std_msgs'
langs = ''
dep_include_paths_str = 'my_pkg3;/home/nvidia/catkin_ws/src/my_pkg3/msg;std_msgs;/opt/ros/kinetic/share/std_msgs/cmake/../msg'
pyt... |
# greet.py| prints hello world to the console
message = 'Hello World'
print(message)
| message = 'Hello World'
print(message) |
"""
PASSENGERS
"""
numPassengers = 30585
passenger_arriving = (
(6, 7, 5, 12, 5, 4, 3, 0, 3, 0, 0, 1, 0, 12, 9, 9, 3, 5, 2, 3, 2, 3, 0, 1, 2, 0), # 0
(8, 12, 2, 2, 8, 3, 3, 1, 2, 2, 1, 0, 0, 14, 10, 7, 6, 5, 4, 4, 3, 6, 3, 2, 2, 0), # 1
(7, 11, 10, 8, 6, 2, 4, 4, 5, 1, 2, 1, 0, 10, 7, 6, 9, 7, 5, 3, 4, 4, 4, 0,... | """
PASSENGERS
"""
num_passengers = 30585
passenger_arriving = ((6, 7, 5, 12, 5, 4, 3, 0, 3, 0, 0, 1, 0, 12, 9, 9, 3, 5, 2, 3, 2, 3, 0, 1, 2, 0), (8, 12, 2, 2, 8, 3, 3, 1, 2, 2, 1, 0, 0, 14, 10, 7, 6, 5, 4, 4, 3, 6, 3, 2, 2, 0), (7, 11, 10, 8, 6, 2, 4, 4, 5, 1, 2, 1, 0, 10, 7, 6, 9, 7, 5, 3, 4, 4, 4, 0, 1, 0), (7, 6, 1... |
#!/usr/bin/env python
class HashImpl(object):
def __init__(self):
self._tree = {}
def insert(self, word):
if word:
t = self._tree
for a in list(word):
if a in t:
t = t[a]
else:
t[a] = {}
... | class Hashimpl(object):
def __init__(self):
self._tree = {}
def insert(self, word):
if word:
t = self._tree
for a in list(word):
if a in t:
t = t[a]
else:
t[a] = {}
t = t[a]
... |
mqtt_broker = "192.168.10.254"
mqtt_client_id = b"esp_kitchen_servo_switch"
mqtt_topic = b"kitchen/light1"
mqtt_user = "homeassistant"
mqtt_password = "internetofthings"
| mqtt_broker = '192.168.10.254'
mqtt_client_id = b'esp_kitchen_servo_switch'
mqtt_topic = b'kitchen/light1'
mqtt_user = 'homeassistant'
mqtt_password = 'internetofthings' |
# Define Class/ Properties
class IO: # Class
supportedSrcs=["console","file"] #attributes
def read(src): #attributes
if src not in IO.supportedSrcs:
print("Not supported")
else:
print("Read from", src)
# Use class
print(IO.supportedSrcs)
IO.read("file")
IO.read("i... | class Io:
supported_srcs = ['console', 'file']
def read(src):
if src not in IO.supportedSrcs:
print('Not supported')
else:
print('Read from', src)
print(IO.supportedSrcs)
IO.read('file')
IO.read('internet') |
n = int(input())
time = []
for i in range(n):
time.append(hour+minute)
hour, minute = input().split()
count_max = 1
count = 1
for i in range(1,n):
if time[i] == time[i-1]:
count += 1
else:
count = 1
if count > count_max:
count_max = count
print(count_max) | n = int(input())
time = []
for i in range(n):
time.append(hour + minute)
(hour, minute) = input().split()
count_max = 1
count = 1
for i in range(1, n):
if time[i] == time[i - 1]:
count += 1
else:
count = 1
if count > count_max:
count_max = count
print(count_max) |
class Project:
def __init__(self, name, status="development", inherit=True, view_status="public", description="default"):
self.name = name
self.status = status
self.inherit = inherit
self.view_status = view_status
self.description = description
def __eq__(self, other):
... | class Project:
def __init__(self, name, status='development', inherit=True, view_status='public', description='default'):
self.name = name
self.status = status
self.inherit = inherit
self.view_status = view_status
self.description = description
def __eq__(self, other):
... |
custom_values = {"name": "pinto", "default_code": "p001", "default_value": 100}
new_values = {}
for key, value in custom_values.items():
if 'default_' in key:
new_key = key[8::]
new_values[new_key] = value
else:
new_values[key] = value
print(new_values)
| custom_values = {'name': 'pinto', 'default_code': 'p001', 'default_value': 100}
new_values = {}
for (key, value) in custom_values.items():
if 'default_' in key:
new_key = key[8:]
new_values[new_key] = value
else:
new_values[key] = value
print(new_values) |
class BoardPrecinct():
precinct_map = (
'Upload a PDF file that represent the boundaries of this precinct.'
)
| class Boardprecinct:
precinct_map = 'Upload a PDF file that represent the boundaries of this precinct.' |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
' a test module '
__author__ = 'Ahrli Tao'
IP_URL = 'http://127.0.0.1:6868/proxies/random'
def get_proxies():
url = IP_URL
response = requests.get(url=url)
if response is None:
time.sleep(1)
get_proxies()
proxies_ip = response.text
pro... | """ a test module """
__author__ = 'Ahrli Tao'
ip_url = 'http://127.0.0.1:6868/proxies/random'
def get_proxies():
url = IP_URL
response = requests.get(url=url)
if response is None:
time.sleep(1)
get_proxies()
proxies_ip = response.text
proxies = {proxies_ip.split(':')[0]: proxies_ip... |
class LinkedList:
def __init__(self, value):
self.value = value
self.next = None
# O(n) time | O(n) space - where n is the number of nodes in the Linked List
def linkedListPalindrome(head):
isPalindromeResults = isPalindrome(head, head)
return isPalindromeResults.outerNodesA... | class Linkedlist:
def __init__(self, value):
self.value = value
self.next = None
def linked_list_palindrome(head):
is_palindrome_results = is_palindrome(head, head)
return isPalindromeResults.outerNodesAreEqual
def is_palindrome(leftNode, rightNode):
if rightNode is None:
retu... |
_base_ = './htc_r50_fpn_1x_coco.py'
model = dict(
backbone=dict(
depth=101,
init_cfg=dict(type='Pretrained',
checkpoint='torchvision://resnet101')))
# learning policy
lr_config = dict(step=[16, 19])
runner = dict(type='EpochBasedRunner', max_epochs=20)
| _base_ = './htc_r50_fpn_1x_coco.py'
model = dict(backbone=dict(depth=101, init_cfg=dict(type='Pretrained', checkpoint='torchvision://resnet101')))
lr_config = dict(step=[16, 19])
runner = dict(type='EpochBasedRunner', max_epochs=20) |
"""Songs that people need to play back.
"""
class Song:
def get_note_time(self):
""" returns a list of [[note, time], ...]
"""
def load(self, fname):
""" load a song from the given name.
"""
raise NotImplementedError("need to load stuff from s... | """Songs that people need to play back.
"""
class Song:
def get_note_time(self):
""" returns a list of [[note, time], ...]
"""
def load(self, fname):
""" load a song from the given name.
"""
raise not_implemented_error('need to load stuff from some file format. .py ... |
"""
ChatterBot constants
"""
'''
The maximum length of characters that the text of a statement can contain.
This should be enforced on a per-model basis by the data model for each
storage adapter.
'''
STATEMENT_TEXT_MAX_LENGTH = 400
| """
ChatterBot constants
"""
'\nThe maximum length of characters that the text of a statement can contain.\nThis should be enforced on a per-model basis by the data model for each\nstorage adapter.\n'
statement_text_max_length = 400 |
# https://www.hackerrank.com/challenges/triple-sum/problem?isFullScreen=true
def triplets(a, b, c):
a = list(sorted(set(a)))
b = list(sorted(set(b)))
c = list(sorted(set(c)))
ai = 0
bi = 0
ci = 0
ans = 0
while bi < len(b):
while ai < len(a) and a[ai] <= b[bi]:
... | def triplets(a, b, c):
a = list(sorted(set(a)))
b = list(sorted(set(b)))
c = list(sorted(set(c)))
ai = 0
bi = 0
ci = 0
ans = 0
while bi < len(b):
while ai < len(a) and a[ai] <= b[bi]:
ai += 1
while ci < len(c) and c[ci] <= b[bi]:
ci += 1
an... |
def parse(a):
a = a.split("\n")
a = [x+", " for x in a]
a = [''.join(a[i:i+6])+"\n" for i in range(0, len(a), 6)]
print(''.join(a))
| def parse(a):
a = a.split('\n')
a = [x + ', ' for x in a]
a = [''.join(a[i:i + 6]) + '\n' for i in range(0, len(a), 6)]
print(''.join(a)) |
def string_handler(words: str) -> str:
length = len(words)
pos = length // 2
left = words[:pos]
right = words[pos + 1 if length % 2 else pos::][::-1]
return "yes" if left == right else "no"
def main():
while True:
try:
data = input()
print(string_handler(data))
... | def string_handler(words: str) -> str:
length = len(words)
pos = length // 2
left = words[:pos]
right = words[pos + 1 if length % 2 else pos:][::-1]
return 'yes' if left == right else 'no'
def main():
while True:
try:
data = input()
print(string_handler(data))
... |
#!/usr/bin/env python
#title :busy_load.py
#description :Get the busiest or the most loaded disk from a trace
#author :Vincentius Martin
#date :20150203
#version :0.1
#usage :
#notes :
#python_version :2.7.5+
#precondition :ordered
#===================... | def cut(tracefile, lowerb, upperb, devno=-1):
out = open('out/' + tracefile + '-cut.trace', 'w')
lowerb = 60000 * lowerb
upperb = 60000 * upperb
with open('in/' + tracefile) as f:
for line in f:
tok = map(str.lstrip, line.split(' '))
if devno != -1 and int(tok[1]) != devn... |
def count_variants(event_log,return_variants=False):
current_case = ""
current_variant = ""
caseIDColName = "Case ID"
activityColName = "Activity"
variants = set()
for index, row in event_log.iterrows():
activity = row[activityColName]
if row[caseIDColName] != current_case:
... | def count_variants(event_log, return_variants=False):
current_case = ''
current_variant = ''
case_id_col_name = 'Case ID'
activity_col_name = 'Activity'
variants = set()
for (index, row) in event_log.iterrows():
activity = row[activityColName]
if row[caseIDColName] != current_cas... |
#
# PySNMP MIB module TIARA-QOS-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIARA-QOS-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:09:15 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, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constraint, value_range_constraint, value_size_constraint, constraints_union, constraints_intersection) ... |
'''
builtin functions
'''
def main():
o = ord('x')
TestError( o == 120 )
#n = float('1.1')
#TestError( n==1.1 )
#n = float('NaN')
#TestError( isNaN(n)==True )
#r = round( 1.1234, 2)
#print(r)
#TestError( str(r) == '1.12' )
#r = round( 100.001, 2)
#TestError( r == 100 )
#i = int( 100.1 )
#TestError( ... | """
builtin functions
"""
def main():
o = ord('x')
test_error(o == 120) |
#
# PySNMP MIB module ASCEND-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ASCEND-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:09:57 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:... | (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, single_value_constraint, value_range_constraint, value_size_constraint, constraints_union) ... |
def solution(A):
B = []
best_dif = 100000000000
sum = 0
for i in A:
sum += i
sum_left = 0
sum_right = sum
for i in A[:-1]:
sum_left += i
sum_right -= i
dif = abs(sum_left - sum_right)
if dif < best_dif:
best_dif = dif
return best_dif
| def solution(A):
b = []
best_dif = 100000000000
sum = 0
for i in A:
sum += i
sum_left = 0
sum_right = sum
for i in A[:-1]:
sum_left += i
sum_right -= i
dif = abs(sum_left - sum_right)
if dif < best_dif:
best_dif = dif
return best_dif |
def long_usage_messenger():
return """
PDB.py
optional arguments:
-h, --help show this help message and exit
-rftf text_file_with_PDB.tsv, --renumber_from_text_file text_file_with_PDB.tsv
This option will download and renumber specified files
usage $ python3 PDB.py -rftf text_file_with_PDB_in_it.tsv -mm... | def long_usage_messenger():
return '\nPDB.py\noptional arguments:\n-h, --help show this help message and exit\n\n-rftf text_file_with_PDB.tsv, --renumber_from_text_file text_file_with_PDB.tsv\nThis option will download and renumber specified files\nusage $ python3 PDB.py -rftf text_file_with_PDB_in_it.ts... |
my_list = [1, 2.0, "three", 4]
my_tup = (1, 2.0, "three", 4)
my_set = {1, 2.0, "three", 4}
my_str = "1, 2.0, three, 4"
# Subscripting ordered datatypes
print(my_list[0]) # indexing
print(my_tup[0:2]) # slicing
print(my_str[-8:]) # negative index and slice
# Adding elements
my_list.append(5.0)
print("my_l... | my_list = [1, 2.0, 'three', 4]
my_tup = (1, 2.0, 'three', 4)
my_set = {1, 2.0, 'three', 4}
my_str = '1, 2.0, three, 4'
print(my_list[0])
print(my_tup[0:2])
print(my_str[-8:])
my_list.append(5.0)
print('my_list with new element:', my_list)
my_set.add(2.0)
print("my_set didn't change:", my_set) |
'''
nimpy module created for working with nimrod using python
Main dependencies are:
numpy
scipy
h5py
struct
os
argparse
subprocess
This module was developed for simulations run at WiPAL in
the physics department at UW-Madison. The main nimrod build
used to test features was nimuw 3.4.10, a... | """
nimpy module created for working with nimrod using python
Main dependencies are:
numpy
scipy
h5py
struct
os
argparse
subprocess
This module was developed for simulations run at WiPAL in
the physics department at UW-Madison. The main nimrod build
used to test features was nimuw 3.4.10, a... |
TASKS = []
class Context:
def __init__(self, sources, target):
self.sources = sources
self.target = target
@property
def source(self):
return self.sources[0]
class Task:
def __init__(self, matcher, handler, phony=False):
self.matcher = matcher
self.handler = ... | tasks = []
class Context:
def __init__(self, sources, target):
self.sources = sources
self.target = target
@property
def source(self):
return self.sources[0]
class Task:
def __init__(self, matcher, handler, phony=False):
self.matcher = matcher
self.handler = ... |
def reversort(lst):
n = len(lst)
cnt = 0
for i in range(n - 1):
j = min(range(i, n), key=lambda j: lst[j])
cnt += j - i + 1
lst[i : j + 1] = lst[i : j + 1][::-1]
return cnt
t = int(input())
for i in range(t):
input()
(*lst,) = map(int, input().split())
cnt = reverso... | def reversort(lst):
n = len(lst)
cnt = 0
for i in range(n - 1):
j = min(range(i, n), key=lambda j: lst[j])
cnt += j - i + 1
lst[i:j + 1] = lst[i:j + 1][::-1]
return cnt
t = int(input())
for i in range(t):
input()
(*lst,) = map(int, input().split())
cnt = reversort(lst... |
greater = 0
one = int(input())
two = int(input())
three = int(input())
while inp := input():
current = int(inp)
last_sum = one + two + three
current_sum = two + three + current
if current_sum > last_sum:
greater += 1
one = two
two = three
three = current
print(greater)
| greater = 0
one = int(input())
two = int(input())
three = int(input())
while (inp := input()):
current = int(inp)
last_sum = one + two + three
current_sum = two + three + current
if current_sum > last_sum:
greater += 1
one = two
two = three
three = current
print(greater) |
# Copyright (c) 2015 The WebRTC project authors. All Rights Reserved.
#
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file in the root of the source
# tree. An additional intellectual property rights grant can be found
# in the file PATENTS. All contributing project au... | {'includes': ['../build/common.gypi'], 'conditions': [['OS=="ios"', {'targets': [{'target_name': 'rtc_api_objc', 'type': 'static_library', 'dependencies': ['<(webrtc_root)/base/base.gyp:rtc_base_objc', '../../talk/libjingle.gyp:libjingle_peerconnection'], 'sources': ['objc/RTCIceCandidate+Private.h', 'objc/RTCIceCandid... |
class EmptyInputException(Exception):
def __init__(self, *args, **kwargs):
super().__init__('Input path must be non-empty')
class InvalidInputException(Exception):
def __init__(self, *args, **kwargs):
super().__init__('Input path is invalid')
class InvalidURLException(Exception):
def ... | class Emptyinputexception(Exception):
def __init__(self, *args, **kwargs):
super().__init__('Input path must be non-empty')
class Invalidinputexception(Exception):
def __init__(self, *args, **kwargs):
super().__init__('Input path is invalid')
class Invalidurlexception(Exception):
def __... |
def convert_bytes(byte):
units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB'
'YiB', 'BiB', 'NiB', 'DiB', 'CiB']
for x in units:
if divmod(byte, 1024)[0] == 0:
break
else:
byte /= 1024
return ('%.2lf%s' % (byte, x))
| def convert_bytes(byte):
units = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiBYiB', 'BiB', 'NiB', 'DiB', 'CiB']
for x in units:
if divmod(byte, 1024)[0] == 0:
break
else:
byte /= 1024
return '%.2lf%s' % (byte, x) |
def test_function(some_value):
"""This is just a test function to show the issues
with PyCharm text."""
if some_value <= 10:
print('{} is below 10'.format(some_value))
else:
print('{} at least 10'.format(some_value))
test_function(4)
test_function(12) | def test_function(some_value):
"""This is just a test function to show the issues
with PyCharm text."""
if some_value <= 10:
print('{} is below 10'.format(some_value))
else:
print('{} at least 10'.format(some_value))
test_function(4)
test_function(12) |
def read_sender_input():
try:
input_data = input()
return classify_input(input_data)
except EOFError:
return None,None
def classify_input(input_data):
attribute = input_data.split(' ')
if ValidInput(attribute):
temperature = float(attribute... | def read_sender_input():
try:
input_data = input()
return classify_input(input_data)
except EOFError:
return (None, None)
def classify_input(input_data):
attribute = input_data.split(' ')
if valid_input(attribute):
temperature = float(attribute[0])
charge_rate = ... |
def configure(conf):
conf.recurse('armv7a.py', once=False)
conf.env.VALID_ARCHITECTURES = ['armv7s'] + conf.env.VALID_ARCHITECTURES
conf.env.append_unique('DEFINES', ['_ARM_V7S'])
| def configure(conf):
conf.recurse('armv7a.py', once=False)
conf.env.VALID_ARCHITECTURES = ['armv7s'] + conf.env.VALID_ARCHITECTURES
conf.env.append_unique('DEFINES', ['_ARM_V7S']) |
# Definition for singly-linked list with a random pointer.
# class RandomListNode(object):
# def __init__(self, x):
# self.label = x
# self.next = None
# self.random = None
class Solution(object):
def copyRandomList(self, head):
"""
:type head: RandomListNode
:r... | class Solution(object):
def copy_random_list(self, head):
"""
:type head: RandomListNode
:rtype: RandomListNode
"""
if not head:
return None
p = head
np = random_list_node(head.label)
p.link = np
if p.random:
if p.rando... |
"""
Custom exceptions
"""
class ImproperlyConfigured(Exception):
"""Raised when demosys is configured incorrectly"""
pass
| """
Custom exceptions
"""
class Improperlyconfigured(Exception):
"""Raised when demosys is configured incorrectly"""
pass |
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# write your code in Python 3.6
n = len(A)
left = [0]*n
# max left slice
for i in range(1, n-1):
left[i] = max(0, left[i-1] + A[i])
right = [0]*n
# max righ... | def solution(A):
n = len(A)
left = [0] * n
for i in range(1, n - 1):
left[i] = max(0, left[i - 1] + A[i])
right = [0] * n
for i in range(n - 2, 1, -1):
right[i] = max(0, right[i + 1] + A[i])
double_slice = -10000
for i in range(1, n - 1):
double_slice = max(doubleSlic... |
######################################################################
# Author: Dr. Patrick Shepherd TODO: Change this to your names
# Username: shepherdp TODO: Change this to your usernames
#
# Assignment: T5: Buggy Fruit
# Purpose: A flawed birthday program
########################################... | def happy_birthday(i, x):
"""Happy birthday function"""
for i in range(x):
print('Happy Birthday to you!')
print('Happy Birthday, dear ' + i + '.')
print('Happy Birthday to you!')
happy_birthday('Felix', 4) |
waf_checker = [ " '",
" AND 1",
" /**/AND/**/1",
" AND 1=1",
" AND 1 LIKE 1",
" ' AND '1'='1",
"<img src=x onerror=alert('XSS')>",
"<img onfoo=f()>",
"<script>alert('intrusion')</script>"
... | waf_checker = [" '", ' AND 1', ' /**/AND/**/1', ' AND 1=1', ' AND 1 LIKE 1', " ' AND '1'='1", "<img src=x onerror=alert('XSS')>", '<img onfoo=f()>', "<script>alert('intrusion')</script>"]
sql_injection = {'error_based': ["'", "')", "';", '"', '")', '";', '`', '`)', '`;', '\\', '%27', '%%2727', '%25%27', '%60', '%5C'], ... |
class SearchList(list):
def find(self, name):
items = []
for child in self:
if child.__class__ == self.__class__:
items += child.find(name)
else:
if child == name:
items.append(child)
if len(items) == 1:
... | class Searchlist(list):
def find(self, name):
items = []
for child in self:
if child.__class__ == self.__class__:
items += child.find(name)
elif child == name:
items.append(child)
if len(items) == 1:
return items[0]
... |
#
# PySNMP MIB module ALCATEL-IND1-STACK-MANAGER-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALCATEL-IND1-STACK-MANAGER-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:19:30 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python ... | (softent_ind1_stack_mgr,) = mibBuilder.importSymbols('ALCATEL-IND1-BASE', 'softentIND1StackMgr')
(integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(single_value_constra... |
class Solution:
def maxArea(self, height):
left, right, mx = 0, len(height) - 1, 0
while left < right:
mx = max(mx, (right - left) * min(height[left], height[right]))
if height[left] < height[right]:
left += 1
else:
right -= 1
... | class Solution:
def max_area(self, height):
(left, right, mx) = (0, len(height) - 1, 0)
while left < right:
mx = max(mx, (right - left) * min(height[left], height[right]))
if height[left] < height[right]:
left += 1
else:
right -= 1... |
'''input
-1000000000 1000000000
Zero
-1 0
Zero
1 3
Positive
-3 -1
Negative
-4 -1
Positive
-1 1
Zero
0 1
Zero
'''
# -*- coding: utf-8 -*-
# AtCoder Grand Contest
# Problem A
if __name__ == '__main__':
a, b = list(map(int, input().split()))
if a * b <= 0:
print('Zero')
elif (a >= 1) or ((b... | """input
-1000000000 1000000000
Zero
-1 0
Zero
1 3
Positive
-3 -1
Negative
-4 -1
Positive
-1 1
Zero
0 1
Zero
"""
if __name__ == '__main__':
(a, b) = list(map(int, input().split()))
if a * b <= 0:
print('Zero')
elif a >= 1 or (b <= -1 and (b - a + 1) % 2 == 0):
print('Positive')
el... |
"""
Module: 'gc' on esp32_LoBo 3.2.9
"""
# MCU: (sysname='esp32_LoBo', nodename='esp32_LoBo', release='3.2.9', version='ESP32_LoBo_v3.2.9 on 2018-04-12', machine='ESP32 board with ESP32')
# Stubber: 1.1.2
def collect():
pass
def disable():
pass
def enable():
pass
def isenabled():
pass
def mem_alloc(... | """
Module: 'gc' on esp32_LoBo 3.2.9
"""
def collect():
pass
def disable():
pass
def enable():
pass
def isenabled():
pass
def mem_alloc():
pass
def mem_free():
pass
def threshold():
pass |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.