content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def asarray(a, dtype=None, order=None):
"""Convert the input to an array.
Parameters
----------
a : array_like
Input data, in any form that can be converted to an array. This
includes lists, lists of tuples, tuples, tuples of tuples, tuples
of lists and ndarrays.
dtype : d... | def asarray(a, dtype=None, order=None):
"""Convert the input to an array.
Parameters
----------
a : array_like
Input data, in any form that can be converted to an array. This
includes lists, lists of tuples, tuples, tuples of tuples, tuples
of lists and ndarrays.
dtype : da... |
[b'z' if foldnuls and not word else
b'y' if foldspaces and word == 0x20202020 else
(chars2[word // 614125] +
chars2[word // 85 % 7225] +
chars[word % 85])
]
| [b'z' if foldnuls and (not word) else b'y' if foldspaces and word == 538976288 else chars2[word // 614125] + chars2[word // 85 % 7225] + chars[word % 85]] |
inputs = {"sentence": "a very well-made, funny and entertaining picture."}
archive = (
"https://storage.googleapis.com/allennlp-public-models/"
"basic_stanford_sentiment_treebank-2020.06.09.tar.gz"
)
predictor = Predictor.from_path(archive)
interpreter = SimpleGradient(predictor)
interpretation = interpreter.sa... | inputs = {'sentence': 'a very well-made, funny and entertaining picture.'}
archive = 'https://storage.googleapis.com/allennlp-public-models/basic_stanford_sentiment_treebank-2020.06.09.tar.gz'
predictor = Predictor.from_path(archive)
interpreter = simple_gradient(predictor)
interpretation = interpreter.saliency_interpr... |
# -*- coding: utf-8 -*-
"""
Created on Fri Dec 6 15:17:07 2019
@author: bdobson
"""
"""Constants
"""
M3_S_TO_ML_D = 86.4
MM_KM2_TO_ML = 1e-3 * 1e6 * 1e3 * 1e-6
PCT_TO_PROP = 1e-2
PROP_TO_PCT = 100
L_TO_ML = 1e-6
FLOAT_ACCURACY = 1e-10 | """
Created on Fri Dec 6 15:17:07 2019
@author: bdobson
"""
'Constants\n'
m3_s_to_ml_d = 86.4
mm_km2_to_ml = 0.001 * 1000000.0 * 1000.0 * 1e-06
pct_to_prop = 0.01
prop_to_pct = 100
l_to_ml = 1e-06
float_accuracy = 1e-10 |
# File: adldap_view.py
#
# Copyright (c) 2021-2022 Splunk 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 applic... | def get_ctx_result(result):
ctx_result = {}
param = result.get_param()
summary = result.get_summary()
data = result.get_data()
ctx_result['param'] = param
if data:
ctx_result['data'] = data[0]
if summary:
ctx_result['summary'] = summary
return ctx_result
def display_attr... |
while True:
try:
p = input()
d = 0
for i in range(len(p)):
if(p[i]=='('):
d += 1
elif(p[i]==')'):
d -= 1
if(d < 0):
break
if(d != 0):
print('incorrect')
else:
print('co... | while True:
try:
p = input()
d = 0
for i in range(len(p)):
if p[i] == '(':
d += 1
elif p[i] == ')':
d -= 1
if d < 0:
break
if d != 0:
print('incorrect')
else:
print('co... |
f = open('69_sample.txt')
# read 1st line
data = f.readline()
print (data)
# read second line
data = f.readline()
print (data)
f.close()
| f = open('69_sample.txt')
data = f.readline()
print(data)
data = f.readline()
print(data)
f.close() |
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def trace(self, node, nodelist):
if node is None:
return
for n in node.children:
self.trace(n, nodelist)
nodelist.append(node.v... | class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
class Solution(object):
def trace(self, node, nodelist):
if node is None:
return
for n in node.children:
self.trace(n, nodelist)
nodelist.append(node.... |
bot = {'owner': '',
'client_id': '',
'version': '',
'prefix': '|',
'pstart': 'python3 ./main.py',
'game': '',
'token': '',
'invite_url': '',
'update_name': '',
'release_details': './data/misc/releaseplaceholder.txt',
'checkin_details': './data/misc/c... | bot = {'owner': '', 'client_id': '', 'version': '', 'prefix': '|', 'pstart': 'python3 ./main.py', 'game': '', 'token': '', 'invite_url': '', 'update_name': '', 'release_details': './data/misc/releaseplaceholder.txt', 'checkin_details': './data/misc/checkin.txt', 'checkin_channel': '', 'update_details': './data/misc/upd... |
"""
Module to contain the configuration information loaded from the config file.
DO NOT MODIFY THIS FILE!
Use yaml files in configurations directory to change the settings.
"""
# Optional settings (set defaults)
show_labels = False
show_sensory = False
show_individual = False
display_legend = True
combination_strate... | """
Module to contain the configuration information loaded from the config file.
DO NOT MODIFY THIS FILE!
Use yaml files in configurations directory to change the settings.
"""
show_labels = False
show_sensory = False
show_individual = False
display_legend = True
combination_strategy = 'avg'
confidence_threshold = 0
... |
"""
This module provide solution for first task.
"""
def change_sub_strings(text, pattern, new_string):
"""
Function for changing all entrance of pattern to new_string.
:param text: str
String for changing.
:param pattern: str
String which should be removed. Any suffix of this string... | """
This module provide solution for first task.
"""
def change_sub_strings(text, pattern, new_string):
"""
Function for changing all entrance of pattern to new_string.
:param text: str
String for changing.
:param pattern: str
String which should be removed. Any suffix of this string ... |
ENTRY_POINT = 'fizz_buzz'
FIX = """
Update doc string to remove requirement for print.
"""
#[PROMPT]
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
0
>>> fizz_buzz(78)
2
>>> fizz_buzz(79)
... | entry_point = 'fizz_buzz'
fix = '\nUpdate doc string to remove requirement for print.\n'
def fizz_buzz(n: int):
"""Return the number of times the digit 7 appears in integers less than n which are divisible by 11 or 13.
>>> fizz_buzz(50)
0
>>> fizz_buzz(78)
2
>>> fizz_buzz(79)
3
"""
... |
def type2diabetes(filepath):
"""
1. Takes a text file as the only parameter and returns means and std of the phenotype typeII diabetes
2. Search for data labels on the text file and read text file to csv file starting from the
rows of labels present
3. Replace missing data '--' with NaN and drop mis... | def type2diabetes(filepath):
"""
1. Takes a text file as the only parameter and returns means and std of the phenotype typeII diabetes
2. Search for data labels on the text file and read text file to csv file starting from the
rows of labels present
3. Replace missing data '--' with NaN and drop mis... |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 12 10:49:34 2020
@author: ravi
"""
def recordBreaker(arr):
peak = 0
cmax = float("-inf")
if len(arr)==0:
return 0
if len(arr)==1:
return 1
for i in range(len(arr)):
if i==0:
if arr[i]>arr[i+1]... | """
Created on Sun Jul 12 10:49:34 2020
@author: ravi
"""
def record_breaker(arr):
peak = 0
cmax = float('-inf')
if len(arr) == 0:
return 0
if len(arr) == 1:
return 1
for i in range(len(arr)):
if i == 0:
if arr[i] > arr[i + 1]:
if arr[i] > cmax:
... |
N = int(input())
for i in range(N):
line = input()
print("I am Toorg!") | n = int(input())
for i in range(N):
line = input()
print('I am Toorg!') |
def divide(n1, n2):#dessa forma levantamos o erro sem parar o cod
if n2 == 0:#se n2 for igual a zero
raise ValueError("n2 nao pode ser 0 ")
return n1 / n2
try:
print(divide(n1=2,n2=1))
except ValueError as error:
print('Voce esta tentando dividir por zero')
print('log:', error) | def divide(n1, n2):
if n2 == 0:
raise value_error('n2 nao pode ser 0 ')
return n1 / n2
try:
print(divide(n1=2, n2=1))
except ValueError as error:
print('Voce esta tentando dividir por zero')
print('log:', error) |
# 566. Reshape the Matrix
# Runtime: 109 ms, faster than 30.83% of Python3 online submissions for Reshape the Matrix.
# Memory Usage: 14.7 MB, less than 87.88% of Python3 online submissions for Reshape the Matrix.
class Solution:
# Using Queue
def matrixReshape(self, mat: list[list[int]], r: int, c: int) ->... | class Solution:
def matrix_reshape(self, mat: list[list[int]], r: int, c: int) -> list[list[int]]:
if len(mat) == 0 or r * c != len(mat) * len(mat[0]):
return mat
nums = []
for i in range(len(mat)):
for j in range(len(mat[0])):
nums.append(mat[i][j])
... |
def n_primos (x):
numero =2
quantidadeDePrimos=0
while numero<=x:
divisor = 2
divisores=0
while divisor<numero:
if numero%divisor==0:
divisores+=1
divisor+=1
if divisores==0:
quantidadeDePrimos+=1
numero+=1
return... | def n_primos(x):
numero = 2
quantidade_de_primos = 0
while numero <= x:
divisor = 2
divisores = 0
while divisor < numero:
if numero % divisor == 0:
divisores += 1
divisor += 1
if divisores == 0:
quantidade_de_primos += 1
... |
#Now let's make things a little more challenging.
#
#Last exercise, you wrote a function called word_count that
#counted the number of words in a string essentially by
#counting the spaces. However, if there were multiple spaces
#in a row, it would incorrectly add additional words. For
#example, it would have counted t... | def word_count(my_string):
word_count = 1
try:
string_len = len(my_string)
i = 0
while string_len > 0:
try:
if my_string[i] == ' ' and (not my_string[i + 1] == ' '):
word_count += 1
i += 1
string_len -= 1
... |
def sortByHeight(a):
trees = []
peoples = []
for i in range(len(a)):
if (a[i] != -1):
peoples.append(a[i])
else:
trees.append(i)
peoples = sorted(peoples)
for i in range(len(trees)):
peoples.insert(trees[i], -1)
return peoples | def sort_by_height(a):
trees = []
peoples = []
for i in range(len(a)):
if a[i] != -1:
peoples.append(a[i])
else:
trees.append(i)
peoples = sorted(peoples)
for i in range(len(trees)):
peoples.insert(trees[i], -1)
return peoples |
class Helper(object):
defaultText = """Eddie knowledge - what your opponents don't want you to know.\n\nCommands:
.help
.changes
.fd <CHAR> [<MOVENAME>]
.fds <CHAR> [<MOVENAME>]
.atklevel <LEVEL>
.alias <ALIAS>
.addalias <ALIAS> | <VALUE>
.removealias <ALIAS>
.charnames... | class Helper(object):
default_text = "Eddie knowledge - what your opponents don't want you to know.\n\nCommands:\n .help\n .changes\n .fd <CHAR> [<MOVENAME>]\n .fds <CHAR> [<MOVENAME>]\n .atklevel <LEVEL>\n .alias <ALIAS>\n .addalias <ALIAS> | <VALUE>\n .removealias <ALIAS>\n .charnames\n... |
nome = str(input('qual o seu nome '))
print('Prazer em te conhecer {:-^20}! \n'.format(nome))
n = int(input(' Bem vindo a Tabuada, digite um numero para ver o resultado: '))
multiplicando = 0
cont = 0
while cont <= 10:
print(n * multiplicando)
multiplicando = multiplicando + 1
cont = cont + 1
| nome = str(input('qual o seu nome '))
print('Prazer em te conhecer {:-^20}! \n'.format(nome))
n = int(input(' Bem vindo a Tabuada, digite um numero para ver o resultado: '))
multiplicando = 0
cont = 0
while cont <= 10:
print(n * multiplicando)
multiplicando = multiplicando + 1
cont = cont + 1 |
"""
@FileName: __init__.py.py
@Description: Implement __init__.py
@Author: Ryuk
@CreateDate: 2021/06/27
@LastEditTime: 2021/06/27
@LastEditors: Please set LastEditors
@Version: v0.1
""" | """
@FileName: __init__.py.py
@Description: Implement __init__.py
@Author: Ryuk
@CreateDate: 2021/06/27
@LastEditTime: 2021/06/27
@LastEditors: Please set LastEditors
@Version: v0.1
""" |
__all__ = ["RefMixin"]
class RefMixin:
def __init__(self, loop, ref=True):
self.loop = loop
self.ref = ref
self._ref_increased = False
def _increase_ref(self):
if self.ref:
self._ref_increased = True
self.loop.increase_ref()
def _decrease_ref(self)... | __all__ = ['RefMixin']
class Refmixin:
def __init__(self, loop, ref=True):
self.loop = loop
self.ref = ref
self._ref_increased = False
def _increase_ref(self):
if self.ref:
self._ref_increased = True
self.loop.increase_ref()
def _decrease_ref(self)... |
#!/usr/bin/env python3
max_seat = 0
with open('input.txt') as infile:
for line in infile:
row = 0
col = 0
for c in line:
if c == 'B':
row = 2*row + 1
if c == 'F':
row *= 2
if c == 'R':
col = 2*col + 1
... | max_seat = 0
with open('input.txt') as infile:
for line in infile:
row = 0
col = 0
for c in line:
if c == 'B':
row = 2 * row + 1
if c == 'F':
row *= 2
if c == 'R':
col = 2 * col + 1
if c == 'L':
... |
class Solution:
def closedIsland(self, grid: List[List[int]]) -> int:
m = len(grid)
n = len(grid[0])
vis = [[0]*n for i in range(m)]
res = 0
def bfs(i,j):
vis[i][j] = 1
q = [(i,j)]
valid = 1
while len(q)> 0... | class Solution:
def closed_island(self, grid: List[List[int]]) -> int:
m = len(grid)
n = len(grid[0])
vis = [[0] * n for i in range(m)]
res = 0
def bfs(i, j):
vis[i][j] = 1
q = [(i, j)]
valid = 1
while len(q) > 0:
... |
UK = "curb accessorise accessorised accessorises accessorising acclimatisation acclimatise acclimatised acclimatises acclimatising accoutrements aeon aeons aerogramme aerogrammes aeroplane aeroplanes aesthete aesthetes aesthetic aesthetically aesthetics aetiology ageing aggrandisement agonise agonised agonises agonisin... | uk = 'curb accessorise accessorised accessorises accessorising acclimatisation acclimatise acclimatised acclimatises acclimatising accoutrements aeon aeons aerogramme aerogrammes aeroplane aeroplanes aesthete aesthetes aesthetic aesthetically aesthetics aetiology ageing aggrandisement agonise agonised agonises agonisin... |
s = [[int(i) for i in input().split(' ')] for j in range(3)]
n = [s[i][j] for i in range(3) for j in range(3)]
all_n = [[8,1,6,3,5,7,4,9,2],[6,1,8,7,5,3,2,9,4],[4,9,2,3,5,7,8,1,6],[2,9,4,7,5,3,6,1,8],[8,3,4,1,5,9,6,7,2],[4,3,8,9,5,1,2,7,6],[6,7,2,1,5,9,8,3,4],[2,7,6,9,5,1,4,3,8]]
allsum=[]
for l in all_n:
summ=... | s = [[int(i) for i in input().split(' ')] for j in range(3)]
n = [s[i][j] for i in range(3) for j in range(3)]
all_n = [[8, 1, 6, 3, 5, 7, 4, 9, 2], [6, 1, 8, 7, 5, 3, 2, 9, 4], [4, 9, 2, 3, 5, 7, 8, 1, 6], [2, 9, 4, 7, 5, 3, 6, 1, 8], [8, 3, 4, 1, 5, 9, 6, 7, 2], [4, 3, 8, 9, 5, 1, 2, 7, 6], [6, 7, 2, 1, 5, 9, 8, 3, 4... |
BUILTIN_ENGINES = {"spark": "feaflow.engine.spark.SparkEngine"}
BUILTIN_SOURCES = {
"query": "feaflow.source.query.QuerySource",
"pandas": "feaflow.source.pandas.PandasDataFrameSource",
}
BUILTIN_COMPUTES = {"sql": "feaflow.compute.sql.SqlCompute"}
BUILTIN_SINKS = {
"table": "feaflow.sink.table.TableSink... | builtin_engines = {'spark': 'feaflow.engine.spark.SparkEngine'}
builtin_sources = {'query': 'feaflow.source.query.QuerySource', 'pandas': 'feaflow.source.pandas.PandasDataFrameSource'}
builtin_computes = {'sql': 'feaflow.compute.sql.SqlCompute'}
builtin_sinks = {'table': 'feaflow.sink.table.TableSink', 'redis': 'feaflo... |
"""
This module contains everything that calls command line calls.
"""
class Command(object):
base_cmd = ['transmission-remote']
args = []
def run_command(self):
return subprocess.check_output(self.base_cmd + self.args, stderr=subprocess.STDOUT)
class ListCommand(Command):
args = ['-l']
c... | """
This module contains everything that calls command line calls.
"""
class Command(object):
base_cmd = ['transmission-remote']
args = []
def run_command(self):
return subprocess.check_output(self.base_cmd + self.args, stderr=subprocess.STDOUT)
class Listcommand(Command):
args = ['-l']
clas... |
APP_ID = '390093838084850'
DOMAIN = 'https://ef1ac6ba.ngrok.io'
COMMENTS_CALLBACK = DOMAIN + \
'/webhook_handler/'
MESSENGER_CALLBACK = DOMAIN + \
'/webhook_handler/'
VERIFY_TOKEN = '19990402'
APP_SECRET = 'e3d24fecd0c82e3c558d9cca9c6edad7'
| app_id = '390093838084850'
domain = 'https://ef1ac6ba.ngrok.io'
comments_callback = DOMAIN + '/webhook_handler/'
messenger_callback = DOMAIN + '/webhook_handler/'
verify_token = '19990402'
app_secret = 'e3d24fecd0c82e3c558d9cca9c6edad7' |
# Copyright 2017 Ryan D. Williams
#
# 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 writ... | """Module containing helper functions for common tasks related to interacting
with the FeedLogs DB
Functions:
add_nulls_to_vals - replace values that evaluate to false with None
build_ins_query - builds an insert query
"""
def add_nulls_to_vals(columns, vals):
"""Takes a list of columns to be inserted/upd... |
bind = '0.0.0.0:5000'
workers = 1
backlog = 2048
worker_class = "sync"
debug = True
proc_name = 'gunicorn.proc'
pidfile = '/tmp/gunicorn.pid'
logfile = '/var/log/gunicorn/debug.log'
loglevel = 'error' | bind = '0.0.0.0:5000'
workers = 1
backlog = 2048
worker_class = 'sync'
debug = True
proc_name = 'gunicorn.proc'
pidfile = '/tmp/gunicorn.pid'
logfile = '/var/log/gunicorn/debug.log'
loglevel = 'error' |
def fizzbuzz(i):
''' int -> str
If i is divisible by 3, return "Fizz".
If i is divisible by 5, return "Buzz".
If i is divisible by 3 and 5, return "FizzBuzz".'''
if i % 3 == 0 and i % 5 == 0:
return ("FizzBuzz")
elif i % 3 == 0:
return ("Fizz")
elif i % 5 == 0:
retur... | def fizzbuzz(i):
""" int -> str
If i is divisible by 3, return "Fizz".
If i is divisible by 5, return "Buzz".
If i is divisible by 3 and 5, return "FizzBuzz"."""
if i % 3 == 0 and i % 5 == 0:
return 'FizzBuzz'
elif i % 3 == 0:
return 'Fizz'
elif i % 5 == 0:
return 'Bu... |
# Configuration file for the Sphinx documentation builder.
# -- Project information
project = 'ChemW'
copyright = '2022, Andrew Philip Freiburger'
author = 'Andrew Philip Freiburger'
release = '1'
version = '0.3.1' | project = 'ChemW'
copyright = '2022, Andrew Philip Freiburger'
author = 'Andrew Philip Freiburger'
release = '1'
version = '0.3.1' |
"""
Quoridor Online
Quentin Deschamps, 2020
"""
class Game:
"""Create a game"""
def __init__(self, game_id, nb_players):
self.game_id = game_id
self.nb_players = nb_players
self.connected = [False] * nb_players
self.names = [''] * nb_players
self.run = False
sel... | """
Quoridor Online
Quentin Deschamps, 2020
"""
class Game:
"""Create a game"""
def __init__(self, game_id, nb_players):
self.game_id = game_id
self.nb_players = nb_players
self.connected = [False] * nb_players
self.names = [''] * nb_players
self.run = False
sel... |
"""
>>> bus1 = HountedBus(['Alice', 'Bill'])
>>> bus1.passengers
['Alice', 'Bill']
>>> bus1.pick('Charlie')
>>> bus1.drop('Alice')
>>> bus1.passengers
['Bill', 'Charlie']
>>> bus2 = HountedBus()
>>> bus2.pick('Carrie')
>>> bus2.passengers
['Carrie']
>>> bus3 = HountedBus()
>>> bus3.passengers
['Carrie']
>>> bus3.pick('... | """
>>> bus1 = HountedBus(['Alice', 'Bill'])
>>> bus1.passengers
['Alice', 'Bill']
>>> bus1.pick('Charlie')
>>> bus1.drop('Alice')
>>> bus1.passengers
['Bill', 'Charlie']
>>> bus2 = HountedBus()
>>> bus2.pick('Carrie')
>>> bus2.passengers
['Carrie']
>>> bus3 = HountedBus()
>>> bus3.passengers
['Carrie']
>>> bus3.pick('... |
"""
File: caesar.py
Name: Isabelle
------------------------------
This program demonstrates the idea of caesar cipher.
Users will be asked to input a number to produce shifted
ALPHABET as the cipher table. After that, any strings typed
in will be encrypted.
"""
# This constant shows the original order of alphabetic s... | """
File: caesar.py
Name: Isabelle
------------------------------
This program demonstrates the idea of caesar cipher.
Users will be asked to input a number to produce shifted
ALPHABET as the cipher table. After that, any strings typed
in will be encrypted.
"""
alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def main():
"... |
#URL: https://www.hackerrank.com/challenges/two-characters/problem
def alternate(l, s):
chars = list(set(s))
n = len(chars)
maxlen = 0
#print(chars)
for i in range(n):
for j in range(i+1,n):
ch1 = chars[i]
ch2 = chars[j]
tempans = ""
ansl = 0
... | def alternate(l, s):
chars = list(set(s))
n = len(chars)
maxlen = 0
for i in range(n):
for j in range(i + 1, n):
ch1 = chars[i]
ch2 = chars[j]
tempans = ''
ansl = 0
f = True
for ch in s:
if ch == ch1:
... |
def arithmetic_arranger(problems, answer=False):
# check to see if the list is too long
num_problems = len(problems)
answers_list = []
top_operand = []
operator = []
bottom_operand = []
# calculate answers, create a list of answers
# check to see if there are too many problems... | def arithmetic_arranger(problems, answer=False):
num_problems = len(problems)
answers_list = []
top_operand = []
operator = []
bottom_operand = []
if num_problems > 5:
return 'Error: Too many problems.'
for problem in problems:
problem_list = problem.split()
if len(pr... |
#
# PySNMP MIB module OUTBOUNDTELNET-PRIVATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/OUTBOUNDTELNET-PRIVATE-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:35:45 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version ... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_intersection, value_size_constraint, constraints_union) ... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: FBOutput
class PassMask(object):
_img = 1
_id = 2
_category = 4
_mask = 8
_depth = 16
_normals = 32
_flow = 64
| class Passmask(object):
_img = 1
_id = 2
_category = 4
_mask = 8
_depth = 16
_normals = 32
_flow = 64 |
class Config():
def __init__(self):
self.api_token = None
self.module_name = None
self.port = None
self.enable_2fa = None
self.creds = None
self.seen = set()
self.verbose = False
| class Config:
def __init__(self):
self.api_token = None
self.module_name = None
self.port = None
self.enable_2fa = None
self.creds = None
self.seen = set()
self.verbose = False |
board=[" "]*9
def draw_board(board):
print("|----|----|----|")
print("| | | |")
print("| "+board[0]+"| "+board[1]+" | "+board[2]+" |")
print("| | | |")
print("|----|----|----|")
print("| | | |")
print("| "+board[3]+"| "+board[4]+" | "+board[5]+" |")
pr... | board = [' '] * 9
def draw_board(board):
print('|----|----|----|')
print('| | | |')
print('| ' + board[0] + '| ' + board[1] + ' | ' + board[2] + ' |')
print('| | | |')
print('|----|----|----|')
print('| | | |')
print('| ' + board[3] + '| ' + board[4] + ' | ... |
"""
Script testing 3.4.1 control from OWASP ASVS 4.0:
'Verify that cookie-based session tokens have the 'Secure' attribute set.'
The script will raise an alert if 'Secure' attribute is not present.
"""
def scan(ps, msg, src):
#find "Set-Cookie" header
headerCookie = str(msg.getResponseHeader().getHeader("Set-... | """
Script testing 3.4.1 control from OWASP ASVS 4.0:
'Verify that cookie-based session tokens have the 'Secure' attribute set.'
The script will raise an alert if 'Secure' attribute is not present.
"""
def scan(ps, msg, src):
header_cookie = str(msg.getResponseHeader().getHeader('Set-Cookie'))
alert_risk =... |
__example_payload__ = "AND 1=1"
__type__ = "putting the payload in-between a comment with obfuscation in it"
def tamper(payload, **kwargs):
return "/*!00000{}*/".format(payload)
| __example_payload__ = 'AND 1=1'
__type__ = 'putting the payload in-between a comment with obfuscation in it'
def tamper(payload, **kwargs):
return '/*!00000{}*/'.format(payload) |
class Employee:
raise_amount = 1.04
employee_Amount = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@companyemail'
Employee.employee_Amount += 1
def fullname(self):
... | class Employee:
raise_amount = 1.04
employee__amount = 0
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = first + '.' + last + '@companyemail'
Employee.employee_Amount += 1
def fullname(self):
return '... |
class Editor(object):
def __init__(self):
self.color = '0 143 192'
self.visgroupshown = 1
self.visgroupautoshown = 1
def __str__(self):
out_str = 'editor\n\t\t{\n'
out_str += f'\t\t\t\"color\" \"{self.color}\"\n'
out_str += f'\t\t\t\"visgroupshown\" \"{self.visgr... | class Editor(object):
def __init__(self):
self.color = '0 143 192'
self.visgroupshown = 1
self.visgroupautoshown = 1
def __str__(self):
out_str = 'editor\n\t\t{\n'
out_str += f'\t\t\t"color" "{self.color}"\n'
out_str += f'\t\t\t"visgroupshown" "{self.visgroupsho... |
class SharpSpringException(Exception):
pass
| class Sharpspringexception(Exception):
pass |
t = int(input())
for _ in range(t):
n = int(input())
s = input()
dic = {}
for i in s:
if i not in dic:
dic[i] = 1
else:
dic[i] += 1
is_yes = True
for key in dic:
if(dic[key] % 2 == 1):
is_yes = False
break
if(i... | t = int(input())
for _ in range(t):
n = int(input())
s = input()
dic = {}
for i in s:
if i not in dic:
dic[i] = 1
else:
dic[i] += 1
is_yes = True
for key in dic:
if dic[key] % 2 == 1:
is_yes = False
break
if is_yes:
... |
# Space: O(l)
# Time: O(m * n * l)
class Solution:
def exist(self, board, word) -> bool:
column_length = len(board)
row_length = len(board[0])
word_length = len(word)
def dfs(x, y, index):
if index >= word_length: return True
if (not 0 <= x < row_length) o... | class Solution:
def exist(self, board, word) -> bool:
column_length = len(board)
row_length = len(board[0])
word_length = len(word)
def dfs(x, y, index):
if index >= word_length:
return True
if not 0 <= x < row_length or not 0 <= y < column_l... |
class User:
def __init__(self, login, password):
self._login = login
self._password = password
@property
def login(self):
return self._login
@property
def password(self):
return self._password
class Operation:
def __init__(self, a, func, b):
self._a = ... | class User:
def __init__(self, login, password):
self._login = login
self._password = password
@property
def login(self):
return self._login
@property
def password(self):
return self._password
class Operation:
def __init__(self, a, func, b):
self._a =... |
internCache = {} # XXX: upper bound on size somehow
def intern(klass, vm, method, frame):
string = frame.get_local(0)
value = string._values['value']
if value in internCache:
return internCache[value]
internCache[value] = string
return string
| intern_cache = {}
def intern(klass, vm, method, frame):
string = frame.get_local(0)
value = string._values['value']
if value in internCache:
return internCache[value]
internCache[value] = string
return string |
for _ in range(int(input())):
s = input().split()
for i in range(2, len(s)):
print(s[i], end=' ')
print(s[0]+' '+s[1])
| for _ in range(int(input())):
s = input().split()
for i in range(2, len(s)):
print(s[i], end=' ')
print(s[0] + ' ' + s[1]) |
"""
return every upper case character from a text
"""
def only_upper(string):
text = ""
for char in string:
if char.isupper():
text += char
return text
if __name__ == "__main__":
# get cipher from file if unavailable
cipher = input("paste the text here: ")
... | """
return every upper case character from a text
"""
def only_upper(string):
text = ''
for char in string:
if char.isupper():
text += char
return text
if __name__ == '__main__':
cipher = input('paste the text here: ')
if cipher == '':
file_location = input('file locatio... |
# https://stepik.org/lesson/5047/step/5?unit=1086
# Sample Input 1:
# 8
# 2
# 14
# Sample Output 1:
# 14
# 2
# 8
# Sample Input 2:
# 23
# 23
# 21
# Sample Output 2:
# 23
# 21
# 23
max, min, other = a, b, c = int(input()), int(input()), int(input())
if b > max: max, min = b, a
if c > max: max, min, other = c, a, b
if ... | (max, min, other) = (a, b, c) = (int(input()), int(input()), int(input()))
if b > max:
(max, min) = (b, a)
if c > max:
(max, min, other) = (c, a, b)
if min > other:
(min, other) = (other, min)
print(max, min, other, sep='\n') |
p=int(input("Enter the size of list : "))
l=p
x=[]
while(l):
x.append(input("Enter elements : "))
l=l-1
print(x)
while(True) :
option= int(input("Do you want to :\n1.Pop\n2Remove\n3.Exit\n4.Insert\n5.Append\n6.Search\n7.Sort\n8.Reverse\n9.DecSort ?\n"))
if(option == 1):
#POP
n=int(in... | p = int(input('Enter the size of list : '))
l = p
x = []
while l:
x.append(input('Enter elements : '))
l = l - 1
print(x)
while True:
option = int(input('Do you want to :\n1.Pop\n2Remove\n3.Exit\n4.Insert\n5.Append\n6.Search\n7.Sort\n8.Reverse\n9.DecSort ?\n'))
if option == 1:
n = int(input('Ent... |
'''
Python Code Snippets - stevepython.wordpress.com
149-Convert KMH to MPH
Source:
https://www.pythonforbeginners.com/code-snippets-source-code/
python-code-convert-kmh-to-mph/
'''
kmh = int(input("Enter km/h: "))
mph = 0.6214 * kmh
print ("Speed:", kmh, "KM/H = ", mph, "MPH")
| """
Python Code Snippets - stevepython.wordpress.com
149-Convert KMH to MPH
Source:
https://www.pythonforbeginners.com/code-snippets-source-code/
python-code-convert-kmh-to-mph/
"""
kmh = int(input('Enter km/h: '))
mph = 0.6214 * kmh
print('Speed:', kmh, 'KM/H = ', mph, 'MPH') |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
opticalIsomers = 2
energy = {
'CBS-QB3': GaussianLog('TS07.log'),
'CCSD(T)-F12/cc-pVTZ-F12': MolproLog('TS07_f12.out'),
#'CCSD(T)-F12/cc-pVTZ-F12': -382.96546696009017
}
frequencies = GaussianLog('TS07freq.log')
rotors = [HinderedRotor(scanLog=Sca... | optical_isomers = 2
energy = {'CBS-QB3': gaussian_log('TS07.log'), 'CCSD(T)-F12/cc-pVTZ-F12': molpro_log('TS07_f12.out')}
frequencies = gaussian_log('TS07freq.log')
rotors = [hindered_rotor(scanLog=scan_log('scan_0.log'), pivots=[2, 4], top=[4, 5, 6, 7], symmetry=3), hindered_rotor(scanLog=scan_log('scan_1.log'), pivot... |
class AdditionalInfoMeta(object):
"""Attributes that can enhance the discoverability of a resource."""
KEY = 'additionalInformation'
VALUES_KEYS = (
'categories',
'copyrightHolder',
'description',
'inLanguage',
'links',
'tags',
'updateFrequency',
... | class Additionalinfometa(object):
"""Attributes that can enhance the discoverability of a resource."""
key = 'additionalInformation'
values_keys = ('categories', 'copyrightHolder', 'description', 'inLanguage', 'links', 'tags', 'updateFrequency', 'structuredMarkup', 'poseidonHash', 'providerKey', 'workExampl... |
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]
for i in range(read_line(int)):
N = read_line(int)
print(min(read_list(int)) * (N-1))
| def read_list(t):
return [t(x) for x in input().split()]
def read_line(t):
return t(input())
def read_lines(t, N):
return [t(input()) for _ in range(N)]
for i in range(read_line(int)):
n = read_line(int)
print(min(read_list(int)) * (N - 1)) |
#assert True == True
def mean(num_list):
try:
mean = sum(num_list)/float(len(num_list))
if isinstance(mean, complex):
return NotImplemented
return mean
except ZeroDivisionError as detail:
msg = "\nCannot compute the mean value of an empty list."
raise ZeroDiv... | def mean(num_list):
try:
mean = sum(num_list) / float(len(num_list))
if isinstance(mean, complex):
return NotImplemented
return mean
except ZeroDivisionError as detail:
msg = '\nCannot compute the mean value of an empty list.'
raise zero_division_error(detail.... |
def solution(clothes):
style = dict()
for i in clothes:
if i[1] not in style:
style[i[1]]=1
else :
style[i[1]]+=1
print(style)
answer =1
for i in style.values():
answer*=(i+1)
return answer-1 | def solution(clothes):
style = dict()
for i in clothes:
if i[1] not in style:
style[i[1]] = 1
else:
style[i[1]] += 1
print(style)
answer = 1
for i in style.values():
answer *= i + 1
return answer - 1 |
# tunnels at level = 0
#https://www.openstreetmap.org/way/167952621
assert_has_feature(
18, 41903, 101298, "roads",
{"kind": "highway", "highway": "motorway", "id": 167952621,
"name": "Presidio Pkwy.", "is_tunnel": True, "sort_key": 331})
# http://www.openstreetmap.org/way/89912879
assert_has_feature(
... | assert_has_feature(18, 41903, 101298, 'roads', {'kind': 'highway', 'highway': 'motorway', 'id': 167952621, 'name': 'Presidio Pkwy.', 'is_tunnel': True, 'sort_key': 331})
assert_has_feature(16, 19829, 24234, 'roads', {'kind': 'major_road', 'highway': 'trunk', 'id': 89912879, 'name': 'Sullivan Square Underpass', 'is_tunn... |
'''
Kattis - rijeci
from fibo(0) = 0, fibo(1) = 1, output the x-1th and xth fibo numbers, x <= 45
Simply use a for loop.
Time: O(x), Space: O(1)
'''
x = int(input())
a = 1
b = 0
for i in range(x):
a, b = b, a+b
print(a, b) | """
Kattis - rijeci
from fibo(0) = 0, fibo(1) = 1, output the x-1th and xth fibo numbers, x <= 45
Simply use a for loop.
Time: O(x), Space: O(1)
"""
x = int(input())
a = 1
b = 0
for i in range(x):
(a, b) = (b, a + b)
print(a, b) |
"""This module contains class Task for represent single task entity,
class TaskStatus"""
class TaskStatus:
OPENED = 'opened'
SOLVED = 'solved'
ACTIVATED = 'activated'
FAILED = 'failed'
class RelatedTaskType:
"""
This class defines constants which using in related tasks
"""
BLOCKER = ... | """This module contains class Task for represent single task entity,
class TaskStatus"""
class Taskstatus:
opened = 'opened'
solved = 'solved'
activated = 'activated'
failed = 'failed'
class Relatedtasktype:
"""
This class defines constants which using in related tasks
"""
blocker = 'b... |
# 1st solution
# O(1) time | O(1) space
class Solution:
def bitwiseComplement(self, n: int) -> int:
k = 1
while k < n:
k = (k << 1) | 1
return k - n | class Solution:
def bitwise_complement(self, n: int) -> int:
k = 1
while k < n:
k = k << 1 | 1
return k - n |
# -*- coding: utf-8 -*-
"""
The MIT License (MIT)
Copyright (c) 2019 Lorenzo
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, ... | """
The MIT License (MIT)
Copyright (c) 2019 Lorenzo
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publ... |
"""
https://leetcode.com/problems/find-smallest-letter-greater-than-target/
Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target.
Letters also wrap around. For example, if the target is ... | """
https://leetcode.com/problems/find-smallest-letter-greater-than-target/
Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list that is larger than the given target.
Letters also wrap around. For example, if the target is ... |
"""88. Lowest Common Ancestor of a Binary Tree
Assume two nodes are exist in tree."""
"""
Definition of TreeNode:
class TreeNode:
def __init__(self, val):
self.val = val
self.left, self.right = None, None
"""
class Solution:
"""
@param: root: The root of the binary search tree.
@param:... | """88. Lowest Common Ancestor of a Binary Tree
Assume two nodes are exist in tree."""
'\nDefinition of TreeNode:\nclass TreeNode:\n def __init__(self, val):\n self.val = val\n self.left, self.right = None, None\n'
class Solution:
"""
@param: root: The root of the binary search tree.
@param... |
"""
Configuration for defining the datastore.
"""
MAX_KEY_LEN = 32 # characters
MAX_VALUE_SIZE = 16 * 1024 # 16 Kbytes
MAX_LOCAL_STORAGE_SIZE = 1 * 1024 * 1024 * 1024 # 1 GB
LOCAL_STORAGE_PREPEND_PATH = "/tmp" # this will be prepended to the file path provided
| """
Configuration for defining the datastore.
"""
max_key_len = 32
max_value_size = 16 * 1024
max_local_storage_size = 1 * 1024 * 1024 * 1024
local_storage_prepend_path = '/tmp' |
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November',
'December']
for n in range(1, 12, 1):
n = int(input())
print(months[n - 1])
break | months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
for n in range(1, 12, 1):
n = int(input())
print(months[n - 1])
break |
def add_mod(x: int, y: int, modulo: int = 32) -> int:
"""
Modular addition
:param x:
:param y:
:param modulo:
:return:
"""
return (x + y) & ((1 << modulo) - 1)
def left_circ_shift(x: int, shift: int, n_bits: int) -> int:
"""
Does a left binary circular shift on the number x of ... | def add_mod(x: int, y: int, modulo: int=32) -> int:
"""
Modular addition
:param x:
:param y:
:param modulo:
:return:
"""
return x + y & (1 << modulo) - 1
def left_circ_shift(x: int, shift: int, n_bits: int) -> int:
"""
Does a left binary circular shift on the number x of n_bits ... |
# Utility class used for string processing
def HasText(line, values):
retval = False
found = 0
for data in values:
if data in line:
found += 1
if found == len(values):
retval = True
return retval
def TextAfter(line, values):
retval = ""
if HasText... | def has_text(line, values):
retval = False
found = 0
for data in values:
if data in line:
found += 1
if found == len(values):
retval = True
return retval
def text_after(line, values):
retval = ''
if has_text(line, values):
loc = 0
for data in valu... |
# razbi n, ki je 5000 mestno stevilo na 100 50 mestnih stevilk in najdi prvih 10 stevk vsote teh 100-tih stevil
sez = [37107287533902102798797998220837590246510135740250,46376937677490009712648124896970078050417018260538,74324986199524741059474233309513058123726617309629,91942213363574161572522430563301811072406154908... | sez = [37107287533902102798797998220837590246510135740250, 46376937677490009712648124896970078050417018260538, 74324986199524741059474233309513058123726617309629, 91942213363574161572522430563301811072406154908250, 23067588207539346171171980310421047513778063246676, 89261670696623633820136378418383684178734361726757, 2... |
"""
Represents the domain of a variable, i.e. the possible values that each
variable may assign.
"""
class Domain:
# ==================================================================
# Constructors
# ==================================================================
def __init__ ( self, valu... | """
Represents the domain of a variable, i.e. the possible values that each
variable may assign.
"""
class Domain:
def __init__(self, value_or_values):
self.values = []
if type(value_or_values) is int:
self.values.append(value_or_values)
else:
self.values = ... |
"""
approximations using histograms
"""
class Interval:
def __init__(self, low, up):
if low > up:
raise Exception("Cannot create interval: low must be smaller or equal than up")
self.low = low
self.up = up
def __len__(self):
return self.up - self.low
def conta... | """
approximations using histograms
"""
class Interval:
def __init__(self, low, up):
if low > up:
raise exception('Cannot create interval: low must be smaller or equal than up')
self.low = low
self.up = up
def __len__(self):
return self.up - self.low
def conta... |
async def run(plugin, ctx, channel):
plugin.db.configs.update(ctx.guild.id, "message_logging", True)
plugin.db.configs.update(ctx.guild.id, "message_log_channel", f"{channel.id}")
await ctx.send(plugin.t(ctx.guild, "enabled_module_channel", _emote="YES", module="Message Logging", channel=channel.mention)... | async def run(plugin, ctx, channel):
plugin.db.configs.update(ctx.guild.id, 'message_logging', True)
plugin.db.configs.update(ctx.guild.id, 'message_log_channel', f'{channel.id}')
await ctx.send(plugin.t(ctx.guild, 'enabled_module_channel', _emote='YES', module='Message Logging', channel=channel.mention)) |
# Copyright 2014 Hewlett-Packard Development Company, L.P.
#
# 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 applicabl... | """Exception Class for proliantutils module."""
class Proliantutilsexception(Exception):
"""Parent class for all Proliantutils exceptions."""
pass
class Invalidinputerror(Exception):
message = 'Invalid Input: %(reason)s'
class Iloerror(ProliantUtilsException):
"""Base Exception.
This exception i... |
def exist(board, word):
"""
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell,
where "adjacent" cells are those horizontally or vertically neighboring.
The same letter cell may not be used more than once.
:pa... | def exist(board, word):
"""
Given a 2D board and a word, find if the word exists in the grid.
The word can be constructed from letters of sequentially adjacent cell,
where "adjacent" cells are those horizontally or vertically neighboring.
The same letter cell may not be used more than once.
:pa... |
class TwoSum:
def __init__(self):
"""
Initialize your data structure here.
"""
self.numberCount = defaultdict(int)
def add(self, number: int) -> None:
"""
Add the number to an internal data structure..
"""
self.numberCount[number] += 1
def f... | class Twosum:
def __init__(self):
"""
Initialize your data structure here.
"""
self.numberCount = defaultdict(int)
def add(self, number: int) -> None:
"""
Add the number to an internal data structure..
"""
self.numberCount[number] += 1
def f... |
### --- ### --- ### --- ###
#! While structure:
#` 1. The while statement starts with the while keyword, followed bu a test condition, and ends with a colon (:).
#` 2. The loop body contains the code that gets repeated at each step of the loop. Each line is indented four spaces.
#$ Example:
n = 10
while n < 20:
... | n = 10
while n < 20:
print(n)
n = n + 1
while n <= 10:
print(n) |
class Solution:
def maxScore(self, s: str) -> int:
"""String.
Running time: O(n) where n == len(s).
"""
res = 0
ones = 0
for i in s:
if i == '1':
ones += 1
z, o = 0, 0
for i in s[:-1]:
if i == '0':
... | class Solution:
def max_score(self, s: str) -> int:
"""String.
Running time: O(n) where n == len(s).
"""
res = 0
ones = 0
for i in s:
if i == '1':
ones += 1
(z, o) = (0, 0)
for i in s[:-1]:
if i == '0':
... |
class EndpointSolver(object):
def __init__(self, env, charms):
self.env = env
self.charms = charms
# Relation endpoint match logic
def solve(self, ep_a, ep_b):
service_a, charm_a, endpoints_a = self._parse_endpoints(ep_a)
service_b, charm_b, endpoints_b = self._parse_endpo... | class Endpointsolver(object):
def __init__(self, env, charms):
self.env = env
self.charms = charms
def solve(self, ep_a, ep_b):
(service_a, charm_a, endpoints_a) = self._parse_endpoints(ep_a)
(service_b, charm_b, endpoints_b) = self._parse_endpoints(ep_b)
pairs = self._... |
# -*- encoding: utf-8 -*-
def _single_action_str(self):
return '/'.join(list(iter(self)))
def _multi_action_str(_):
cmd_actions = [
str(arg) for arg in [
RUN_OPT_NAME,
STOP_OPT_NAME,
ENABLE_OPTS_NAME,
ENABLE_OPTS_NAME,
]
]
return ', '.j... | def _single_action_str(self):
return '/'.join(list(iter(self)))
def _multi_action_str(_):
cmd_actions = [str(arg) for arg in [RUN_OPT_NAME, STOP_OPT_NAME, ENABLE_OPTS_NAME, ENABLE_OPTS_NAME]]
return ', '.join(cmd_actions)
frozenset_single_action_opts = type('frozenset_argv_action_opts', (frozenset,), {'__s... |
rosha = bet_log[-1]
bet_log = []
| rosha = bet_log[-1]
bet_log = [] |
#
# PySNMP MIB module CISCO-LWAPP-REAP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCO-LWAPP-REAP-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 17:49:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (defau... | (octet_string, integer, object_identifier) = mibBuilder.importSymbols('ASN1', 'OctetString', 'Integer', 'ObjectIdentifier')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, constraints_union, value_size_constraint, single_value_constraint, constraints_intersection) ... |
number = 15
while True:
number += 1
last_digit = str(number)[-1:]
if last_digit != '6':
continue
small = int(number / 10)
large = int('6' + str(small))
if large % number == 0:
print('--')
print(str(number) + ' || ' + str(small) + ' : ' + str(large))
print... | number = 15
while True:
number += 1
last_digit = str(number)[-1:]
if last_digit != '6':
continue
small = int(number / 10)
large = int('6' + str(small))
if large % number == 0:
print('--')
print(str(number) + ' || ' + str(small) + ' : ' + str(large))
print('Divisio... |
fake_users_db = {
"typo11": {
"username": "typo11",
"full_name": "Tammy Cacablanka",
"email": "tammy@localhost.com",
"disabled": False,
"hashed_password": "$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW"
},
"typo12": {
"username": "typo12",
... | fake_users_db = {'typo11': {'username': 'typo11', 'full_name': 'Tammy Cacablanka', 'email': 'tammy@localhost.com', 'disabled': False, 'hashed_password': '$2b$12$EixZaYVK1fsbw1ZfbX3OXePaWxn96p36WQoeG6Lruj3vjPGga31lW'}, 'typo12': {'username': 'typo12', 'full_name': 'Sammy Cacablanka', 'email': 'master@localhost.com', 'di... |
"""
DSC20 WI22 HW05
Name: William Trang
PID: A16679845
"""
# begin helper methods
def ceil(x):
"""
Simulation to math.ceil
No doctest needed
"""
if int(x) != x:
return int(x) + 1
return int(x)
def log(x):
"""
Simulation to math.log with base e
No doctests needed
"""
... | """
DSC20 WI22 HW05
Name: William Trang
PID: A16679845
"""
def ceil(x):
"""
Simulation to math.ceil
No doctest needed
"""
if int(x) != x:
return int(x) + 1
return int(x)
def log(x):
"""
Simulation to math.log with base e
No doctests needed
"""
n = 10000000000.0
... |
# Aidan Conlon - 27 March 2019
# This is the solution to Problem 6
# Write a program that takes a user input string and outputs every second word.
UserInput = input("Please enter a string of text:") # Print to screen the comment and take a value entered by the user.
for i, word in enumerate(UserInput.split()): ... | user_input = input('Please enter a string of text:')
for (i, word) in enumerate(UserInput.split()):
if i % 2 == 0:
print('%s' % word, sep=' ', end=' ')
quit() |
# THIS IS STATIC
WEEKDAYS = {
0: "Monday",
1: "Tuesday",
2: "Wednesday",
3: "Thursday",
4: "Friday",
5: "Saturday",
6: "Sunday"
}
CLASS_MAP = {
1: "Art",
2: "Geography",
3: "Science"
}
ENTRIES = {
"Monday": {
1: {
"class_name": CLASS_MAP[1],
... | weekdays = {0: 'Monday', 1: 'Tuesday', 2: 'Wednesday', 3: 'Thursday', 4: 'Friday', 5: 'Saturday', 6: 'Sunday'}
class_map = {1: 'Art', 2: 'Geography', 3: 'Science'}
entries = {'Monday': {1: {'class_name': CLASS_MAP[1], 'meeting_time': [9, 10], 'meeting_link': 'zoommtg://port-ac-uk.zoom.us/join?action=join&confno=5453452... |
# -*- coding: utf-8 -*-
def test_search_all(slack_time):
assert slack_time.search.all
def test_search_files(slack_time):
assert slack_time.search.files
def test_search_messages(slack_time):
assert slack_time.search.messages
| def test_search_all(slack_time):
assert slack_time.search.all
def test_search_files(slack_time):
assert slack_time.search.files
def test_search_messages(slack_time):
assert slack_time.search.messages |
class SegmentTreeNode:
def __init__(self, start, end, max):
self.start, self.end, self.max = start, end, max
self.left, self.right = None, None
class Solution:
"""
@param root: The root of segment tree.
@param index: index.
@param value: value
@return: nothing
"""
def mo... | class Segmenttreenode:
def __init__(self, start, end, max):
(self.start, self.end, self.max) = (start, end, max)
(self.left, self.right) = (None, None)
class Solution:
"""
@param root: The root of segment tree.
@param index: index.
@param value: value
@return: nothing
"""
... |
class RssItem:
"""A class used to represent an RSS post"""
def __init__(self, title, description, link, pub_date):
self.title = title
self.description = description
self.link = link
self.pub_date = pub_date | class Rssitem:
"""A class used to represent an RSS post"""
def __init__(self, title, description, link, pub_date):
self.title = title
self.description = description
self.link = link
self.pub_date = pub_date |
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Pre-caching steps used internally by the IDL compiler
#
# Design doc: http://www.chromium.org/developers/design-documents/idl-build
{
'includes': [
... | {'includes': ['scripts.gypi', '../bindings.gypi', '../templates/templates.gypi'], 'targets': [{'target_name': 'cached_lex_yacc_tables', 'type': 'none', 'actions': [{'action_name': 'cache_lex_yacc_tables', 'inputs': ['<@(idl_lexer_parser_files)'], 'outputs': ['<(bindings_scripts_output_dir)/lextab.py', '<(bindings_scrip... |
# automatically generated by the FlatBuffers compiler, do not modify
# namespace: enums
class DateGenerationRule(object):
Backward = 0
CDS = 1
Forward = 2
OldCDS = 3
ThirdWednesday = 4
Twentieth = 5
TwentiethIMM = 6
Zero = 7
| class Dategenerationrule(object):
backward = 0
cds = 1
forward = 2
old_cds = 3
third_wednesday = 4
twentieth = 5
twentieth_imm = 6
zero = 7 |
n=int(input("Enter a number:"))
print("The number is",n)
sum=0
while(n>0 or sum>9):
if(n==0):
n=sum
sum=0
sum=sum+n%10
n=n//10
print(f"sum of the digits is:", sum)
if(sum==1):
print("it is a magic number")
else:
print("It is not a magic number")
| n = int(input('Enter a number:'))
print('The number is', n)
sum = 0
while n > 0 or sum > 9:
if n == 0:
n = sum
sum = 0
sum = sum + n % 10
n = n // 10
print(f'sum of the digits is:', sum)
if sum == 1:
print('it is a magic number')
else:
print('It is not a magic number') |
# https://docs.python.org/3/library/exceptions.html
class person:
def __init__(self, age, name):
if type(age)!=int:
raise Exception("Invaild Age: {}".format(age))
if age<0:
raise Exception("Invaild Age: {}".format(age))
if type(name)!=str:
raise Exception... | class Person:
def __init__(self, age, name):
if type(age) != int:
raise exception('Invaild Age: {}'.format(age))
if age < 0:
raise exception('Invaild Age: {}'.format(age))
if type(name) != str:
raise exception('Name not string: {}'.format(name))
s... |
#Exercise!
#Display the image below to the right hand side where the 0 is going to be ' ',
# and the 1 is going to be '*'. This will reveal an image!
picture = [
[0,0,0,1,0,0,0],
[0,0,1,1,1,0,0],
[0,1,1,1,1,1,0],
[1,1,1,1,1,1,1],
[0,0,0,1,0,0,0],
[0,0,0,1,0,0,0]
]
#version 1
# for y_list in picture:
# ... | picture = [[0, 0, 0, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 1, 1, 1, 1, 1, 0], [1, 1, 1, 1, 1, 1, 1], [0, 0, 0, 1, 0, 0, 0], [0, 0, 0, 1, 0, 0, 0]]
fill = '*'
space = ' '
empty = ''
for row in picture:
for pixel in row:
if pixel:
print(fill, end=empty)
else:
print(space, end... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.