content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
#
# PySNMP MIB module RBTWS-RF-DETECT-TC (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RBTWS-RF-DETECT-TC
# Produced by pysmi-0.3.4 at Mon Apr 29 20:45:14 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint")
rbtwsMibs, = mibBuilder.importSymbols("RBTWS-ROOT-MIB", "rbtwsMibs")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
IpAddress, Gauge32, TimeTicks, MibIdentifier, Bits, Counter32, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity, Counter64, Integer32, Unsigned32, iso, ModuleIdentity, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Gauge32", "TimeTicks", "MibIdentifier", "Bits", "Counter32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity", "Counter64", "Integer32", "Unsigned32", "iso", "ModuleIdentity", "NotificationType")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
rbtwsRFDetectTc = ModuleIdentity((1, 3, 6, 1, 4, 1, 52, 4, 15, 1, 4, 11))
rbtwsRFDetectTc.setRevisions(('2007-04-18 00:02', '2007-03-28 00:01',))
if mibBuilder.loadTexts: rbtwsRFDetectTc.setLastUpdated('200704191855Z')
if mibBuilder.loadTexts: rbtwsRFDetectTc.setOrganization('Enterasys Networks')
class RbtwsRFDetectClassificationReason(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
namedValues = NamedValues(("other", 1), ("default-classification", 2), ("rogue-list", 3), ("ap-in-modo", 4), ("neighbor-list", 5), ("ssid-masquerade", 6), ("seen-in-network", 7), ("ad-hoc", 8), ("ssid-list", 9), ("pass-fingerprint", 10), ("fail-fingerprint", 11))
class RbtwsRFDetectClassification(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6))
namedValues = NamedValues(("other", 1), ("not-classified", 2), ("member", 3), ("neighbor", 4), ("suspect", 5), ("rogue", 6))
class RbtwsRFDetectNetworkingMode(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("ad-hoc", 1), ("infrastructure", 2))
mibBuilder.exportSymbols("RBTWS-RF-DETECT-TC", RbtwsRFDetectClassification=RbtwsRFDetectClassification, rbtwsRFDetectTc=rbtwsRFDetectTc, PYSNMP_MODULE_ID=rbtwsRFDetectTc, RbtwsRFDetectNetworkingMode=RbtwsRFDetectNetworkingMode, RbtwsRFDetectClassificationReason=RbtwsRFDetectClassificationReason)
| (object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_size_constraint, value_range_constraint, constraints_union, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueSizeConstraint', 'ValueRangeConstraint', 'ConstraintsUnion', 'SingleValueConstraint')
(rbtws_mibs,) = mibBuilder.importSymbols('RBTWS-ROOT-MIB', 'rbtwsMibs')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(ip_address, gauge32, time_ticks, mib_identifier, bits, counter32, mib_scalar, mib_table, mib_table_row, mib_table_column, object_identity, counter64, integer32, unsigned32, iso, module_identity, notification_type) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Gauge32', 'TimeTicks', 'MibIdentifier', 'Bits', 'Counter32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'ObjectIdentity', 'Counter64', 'Integer32', 'Unsigned32', 'iso', 'ModuleIdentity', 'NotificationType')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
rbtws_rf_detect_tc = module_identity((1, 3, 6, 1, 4, 1, 52, 4, 15, 1, 4, 11))
rbtwsRFDetectTc.setRevisions(('2007-04-18 00:02', '2007-03-28 00:01'))
if mibBuilder.loadTexts:
rbtwsRFDetectTc.setLastUpdated('200704191855Z')
if mibBuilder.loadTexts:
rbtwsRFDetectTc.setOrganization('Enterasys Networks')
class Rbtwsrfdetectclassificationreason(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11))
named_values = named_values(('other', 1), ('default-classification', 2), ('rogue-list', 3), ('ap-in-modo', 4), ('neighbor-list', 5), ('ssid-masquerade', 6), ('seen-in-network', 7), ('ad-hoc', 8), ('ssid-list', 9), ('pass-fingerprint', 10), ('fail-fingerprint', 11))
class Rbtwsrfdetectclassification(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6))
named_values = named_values(('other', 1), ('not-classified', 2), ('member', 3), ('neighbor', 4), ('suspect', 5), ('rogue', 6))
class Rbtwsrfdetectnetworkingmode(TextualConvention, Integer32):
status = 'current'
subtype_spec = Integer32.subtypeSpec + constraints_union(single_value_constraint(1, 2))
named_values = named_values(('ad-hoc', 1), ('infrastructure', 2))
mibBuilder.exportSymbols('RBTWS-RF-DETECT-TC', RbtwsRFDetectClassification=RbtwsRFDetectClassification, rbtwsRFDetectTc=rbtwsRFDetectTc, PYSNMP_MODULE_ID=rbtwsRFDetectTc, RbtwsRFDetectNetworkingMode=RbtwsRFDetectNetworkingMode, RbtwsRFDetectClassificationReason=RbtwsRFDetectClassificationReason) |
# Collaborators (including web sites where you got help: (enter none if you didn't need help)
# none
# A note on style: Dictionaries can be defined before or after functions.
board = {'1': ' ' , '2': ' ' , '3': ' ' ,'4': ' ' , '5': ' ' , '6': ' ' ,'7': ' ' , '8': ' ' , '9': ' ' }
def gameboard(board):
print(board['1'] + '|' + board['2'] + '|' + board['3'])
print('-+-+-')
print(board['4'] + '|' + board['5'] + '|' + board['6'])
print('-+-+-')
print(board['7'] + '|' + board['8'] + '|' + board['9'])
def main():
num = 0
global player
player = 'X'
for i in range(10):
gameboard(board)
print("It is player " + player + "'s turn. " + player + ", what do you want to move? Use the keys: 1, 2, 3, 4, 5, 6, 7, 8, 9 to pick a spot on the board: ")
move = input()
if board[move] == ' ':
board[move] = player
num += 1
else:
print("That spot is already filled. pick another move")
continue
if num >= 1:
if board['1'] == board['2'] == board['3'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['4'] == board['5'] == board['6'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['7'] == board['8'] == board['9'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['1'] == board['4'] == board['7'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['2'] == board['5'] == board['8'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['3'] == board['6'] == board['9'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['1'] == board['5'] == board['9'] != ' ':
gameboard(board)
print(player + " won.")
break
elif board['3'] == board['5'] == board['7'] != ' ':
gameboard(board)
print(player + " won.")
break
if player =='X':
player = 'O'
else:
player = 'X'
if num == 9:
gameboard(board)
print("It's a Tie!!")
break
try:
main()
except:
print("bad input")
if player == 'X':
player = 'X'
else:
player = 'O'
main()
| board = {'1': ' ', '2': ' ', '3': ' ', '4': ' ', '5': ' ', '6': ' ', '7': ' ', '8': ' ', '9': ' '}
def gameboard(board):
print(board['1'] + '|' + board['2'] + '|' + board['3'])
print('-+-+-')
print(board['4'] + '|' + board['5'] + '|' + board['6'])
print('-+-+-')
print(board['7'] + '|' + board['8'] + '|' + board['9'])
def main():
num = 0
global player
player = 'X'
for i in range(10):
gameboard(board)
print('It is player ' + player + "'s turn. " + player + ', what do you want to move? Use the keys: 1, 2, 3, 4, 5, 6, 7, 8, 9 to pick a spot on the board: ')
move = input()
if board[move] == ' ':
board[move] = player
num += 1
else:
print('That spot is already filled. pick another move')
continue
if num >= 1:
if board['1'] == board['2'] == board['3'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['4'] == board['5'] == board['6'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['7'] == board['8'] == board['9'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['1'] == board['4'] == board['7'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['2'] == board['5'] == board['8'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['3'] == board['6'] == board['9'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['1'] == board['5'] == board['9'] != ' ':
gameboard(board)
print(player + ' won.')
break
elif board['3'] == board['5'] == board['7'] != ' ':
gameboard(board)
print(player + ' won.')
break
if player == 'X':
player = 'O'
else:
player = 'X'
if num == 9:
gameboard(board)
print("It's a Tie!!")
break
try:
main()
except:
print('bad input')
if player == 'X':
player = 'X'
else:
player = 'O'
main() |
{
"cells": [
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Financial Analysis\n",
"Total Months:86\n",
"Total Amount:38382578\n",
"-2315.1176470588234\n",
"Feb-2012 1926159\n",
"Sep-2013 -2196167\n"
]
}
],
"source": [
"#import file\n",
"import os\n",
"import csv\n",
"\n",
"#declare the csv path\n",
"csvpath = os.path.join('Resources','budget_data.csv')\n",
"\n",
"#declare the variables \n",
"total_months = 0\n",
"total_revenue =0\n",
"changes =[]\n",
"date_count = []\n",
"greatest_increase = 0\n",
"greatest_increase_month = 0\n",
"greatest_decrease = 0\n",
"greatest_decrease_month = 0\n",
"\n",
"# Open the csv\n",
"with open(csvpath, newline = '') as csvfile:\n",
" csvreader = csv.reader(csvfile, delimiter = ',')\n",
" next(csvreader, None)\n",
" row = next(csvreader)\n",
" \n",
" # calculate the total number of months and total revenue\n",
" previous_profit = int(row[1])\n",
" total_months = total_months + 1\n",
" total_revenue = total_revenue + int(row[1])\n",
" greatest_increase = int(row[1])\n",
" greatest_increase_month = row[0]\n",
"\n",
" for row in csvreader:\n",
" \n",
" total_months = total_months + 1\n",
" total_revenue = total_revenue + int(row[1])\n",
"\n",
" # calculate change from month-to-month\n",
" change = int(row[1]) - previous_profit\n",
" changes.append(change)\n",
" previous_profit = int(row[1])\n",
" date_count.append(row[0])\n",
" \n",
" #calculate the greatest increase\n",
" if int(row[1]) > greatest_increase:\n",
" greatest_increase = int(row[1])\n",
" greatest_increase_month = row[0]\n",
" \n",
" #calculate the greatest decrease\n",
" if int(row[1]) < greatest_decrease:\n",
" greatest_decrease = int(row[1])\n",
" greatest_decrease_month = row[0] \n",
" \n",
" # calculate the average and date\n",
" average_change = sum(changes)/len(changes)\n",
"\n",
" high = max(changes)\n",
" low = min(changes)\n",
"\n",
" # print values\n",
" print(\"Financial Analysis\")\n",
" print(\"Total Months:\" + str(total_months))\n",
" print(\"Total Amount:\" + str(total_revenue))\n",
" print(average_change)\n",
" print(greatest_increase_month, max(changes))\n",
" print(greatest_decrease_month, min(changes))\n",
"\n",
"\n",
" # write output files\n",
" PyBank = open(\"output.txt\",\"w+\")\n",
" PyBank.write(\"Financial Analysis\") \n",
" PyBank.write('\\n' +\"Total Months\" + str(total_months)) \n",
" PyBank.write('\\n' +\"Total Amount\" + str(total_revenue)) \n",
" PyBank.write('\\n' +\"Average\" + str(average_change)) \n",
" PyBank.write('\\n' +greatest_increase_month) \n",
" PyBank.write('\\n' +str(high))\n",
" PyBank.write('\\n' +greatest_decrease_month) \n",
" PyBank.write('\\n' +str(low)) "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3.9.1 64-bit ('3.9')",
"language": "python",
"name": "python391jvsc74a57bd07812ea015bdcee6f23a998adcdd2ef97c151c0c241b7b7070987d9313e41299d"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.1"
},
"metadata": {
"interpreter": {
"hash": "7812ea015bdcee6f23a998adcdd2ef97c151c0c241b7b7070987d9313e41299d"
}
}
},
"nbformat": 4,
"nbformat_minor": 4
}
| {'cells': [{'cell_type': 'code', 'execution_count': 4, 'metadata': {}, 'outputs': [{'name': 'stdout', 'output_type': 'stream', 'text': ['Financial Analysis\n', 'Total Months:86\n', 'Total Amount:38382578\n', '-2315.1176470588234\n', 'Feb-2012 1926159\n', 'Sep-2013 -2196167\n']}], 'source': ['#import file\n', 'import os\n', 'import csv\n', '\n', '#declare the csv path\n', "csvpath = os.path.join('Resources','budget_data.csv')\n", '\n', '#declare the variables \n', 'total_months = 0\n', 'total_revenue =0\n', 'changes =[]\n', 'date_count = []\n', 'greatest_increase = 0\n', 'greatest_increase_month = 0\n', 'greatest_decrease = 0\n', 'greatest_decrease_month = 0\n', '\n', '# Open the csv\n', "with open(csvpath, newline = '') as csvfile:\n", " csvreader = csv.reader(csvfile, delimiter = ',')\n", ' next(csvreader, None)\n', ' row = next(csvreader)\n', ' \n', ' # calculate the total number of months and total revenue\n', ' previous_profit = int(row[1])\n', ' total_months = total_months + 1\n', ' total_revenue = total_revenue + int(row[1])\n', ' greatest_increase = int(row[1])\n', ' greatest_increase_month = row[0]\n', '\n', ' for row in csvreader:\n', ' \n', ' total_months = total_months + 1\n', ' total_revenue = total_revenue + int(row[1])\n', '\n', ' # calculate change from month-to-month\n', ' change = int(row[1]) - previous_profit\n', ' changes.append(change)\n', ' previous_profit = int(row[1])\n', ' date_count.append(row[0])\n', ' \n', ' #calculate the greatest increase\n', ' if int(row[1]) > greatest_increase:\n', ' greatest_increase = int(row[1])\n', ' greatest_increase_month = row[0]\n', ' \n', ' #calculate the greatest decrease\n', ' if int(row[1]) < greatest_decrease:\n', ' greatest_decrease = int(row[1])\n', ' greatest_decrease_month = row[0] \n', ' \n', ' # calculate the average and date\n', ' average_change = sum(changes)/len(changes)\n', '\n', ' high = max(changes)\n', ' low = min(changes)\n', '\n', ' # print values\n', ' print("Financial Analysis")\n', ' print("Total Months:" + str(total_months))\n', ' print("Total Amount:" + str(total_revenue))\n', ' print(average_change)\n', ' print(greatest_increase_month, max(changes))\n', ' print(greatest_decrease_month, min(changes))\n', '\n', '\n', ' # write output files\n', ' PyBank = open("output.txt","w+")\n', ' PyBank.write("Financial Analysis") \n', ' PyBank.write(\'\\n\' +"Total Months" + str(total_months)) \n', ' PyBank.write(\'\\n\' +"Total Amount" + str(total_revenue)) \n', ' PyBank.write(\'\\n\' +"Average" + str(average_change)) \n', " PyBank.write('\\n' +greatest_increase_month) \n", " PyBank.write('\\n' +str(high))\n", " PyBank.write('\\n' +greatest_decrease_month) \n", " PyBank.write('\\n' +str(low)) "]}, {'cell_type': 'code', 'execution_count': null, 'metadata': {}, 'outputs': [], 'source': []}], 'metadata': {'kernelspec': {'display_name': "Python 3.9.1 64-bit ('3.9')", 'language': 'python', 'name': 'python391jvsc74a57bd07812ea015bdcee6f23a998adcdd2ef97c151c0c241b7b7070987d9313e41299d'}, 'language_info': {'codemirror_mode': {'name': 'ipython', 'version': 3}, 'file_extension': '.py', 'mimetype': 'text/x-python', 'name': 'python', 'nbconvert_exporter': 'python', 'pygments_lexer': 'ipython3', 'version': '3.9.1'}, 'metadata': {'interpreter': {'hash': '7812ea015bdcee6f23a998adcdd2ef97c151c0c241b7b7070987d9313e41299d'}}}, 'nbformat': 4, 'nbformat_minor': 4} |
# Puzzle Input
with open('Day13_Input.txt') as puzzle_input:
bus_info = puzzle_input.read().split('\n')
# Get the departure time and the IDs
departure = int(bus_info[0])
bus_id = bus_info[1].split(',')
# Remove the x's
while 'x' in bus_id:
bus_id.remove('x')
# Convert the IDs to integers
bus_id = list(map(int, bus_id))
# Calculate the waiting times
waiting_times = []
for ID in bus_id: # The negative part is the time the bus departs before we can leave
waiting_times += [-(departure % ID) + ID] # the positive part changes it to after we left
# See which bus gave us the minimum waiting time
min_index = waiting_times.index(min(waiting_times))
# Show the result
print(waiting_times[min_index] * bus_id[min_index])
| with open('Day13_Input.txt') as puzzle_input:
bus_info = puzzle_input.read().split('\n')
departure = int(bus_info[0])
bus_id = bus_info[1].split(',')
while 'x' in bus_id:
bus_id.remove('x')
bus_id = list(map(int, bus_id))
waiting_times = []
for id in bus_id:
waiting_times += [-(departure % ID) + ID]
min_index = waiting_times.index(min(waiting_times))
print(waiting_times[min_index] * bus_id[min_index]) |
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"PseudoData": "00_pseudodata.ipynb",
"paper_sig": "00_pseudodata.ipynb",
"paper_bkg": "00_pseudodata.ipynb",
"ModelWrapper": "01_model_wrapper.ipynb",
"DataSet": "02_data.ipynb",
"WeightedDataLoader": "02_data.ipynb",
"DataPair": "02_data.ipynb",
"get_paper_data": "02_data.ipynb",
"AbsCallback": "03_callback.ipynb",
"LossTracker": "03_callback.ipynb",
"EarlyStopping": "03_callback.ipynb",
"SaveBest": "03_callback.ipynb",
"PredHandler": "03_callback.ipynb",
"PaperSystMod": "03_callback.ipynb",
"GradClip": "03_callback.ipynb",
"to_device": "04_utils.ipynb",
"device": "04_utils.ipynb",
"to_np": "04_utils.ipynb",
"init_net": "04_utils.ipynb",
"plt_style": "05_plotting.ipynb",
"plt_sz": "05_plotting.ipynb",
"plt_cat_pal": "05_plotting.ipynb",
"plt_tk_sz": "05_plotting.ipynb",
"plt_lbl_sz": "05_plotting.ipynb",
"plt_title_sz": "05_plotting.ipynb",
"plt_leg_sz": "05_plotting.ipynb",
"plot_preds": "05_plotting.ipynb",
"plot_likelihood": "05_plotting.ipynb",
"bin_preds": "06_inference.ipynb",
"get_shape": "06_inference.ipynb",
"get_paper_syst_shapes": "06_inference.ipynb",
"get_likelihood_width": "06_inference.ipynb",
"interp_shape": "06_inference.ipynb",
"calc_nll": "06_inference.ipynb",
"jacobian": "06_inference.ipynb",
"calc_grad_hesse": "06_inference.ipynb",
"calc_profile": "06_inference.ipynb",
"VariableSoftmax": "07_inferno_exact.ipynb",
"AbsInferno": "07_inferno_exact.ipynb",
"PaperInferno": "07_inferno_exact.ipynb",
"InfernoPred": "07_inferno_exact.ipynb",
"AbsApproxInferno": "08_inferno_interp.ipynb",
"ApproxPaperInferno": "08_inferno_interp.ipynb"}
modules = ["pseudodata.py",
"model_wrapper.py",
"data.py",
"callback.py",
"utils.py",
"plotting.py",
"inference.py",
"inferno.py"]
doc_url = "https://GilesStrong.github.io/pytorch_inferno/"
git_url = "https://github.com/GilesStrong/pytorch_inferno/tree/master/"
def custom_doc_links(name): return None
| __all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'PseudoData': '00_pseudodata.ipynb', 'paper_sig': '00_pseudodata.ipynb', 'paper_bkg': '00_pseudodata.ipynb', 'ModelWrapper': '01_model_wrapper.ipynb', 'DataSet': '02_data.ipynb', 'WeightedDataLoader': '02_data.ipynb', 'DataPair': '02_data.ipynb', 'get_paper_data': '02_data.ipynb', 'AbsCallback': '03_callback.ipynb', 'LossTracker': '03_callback.ipynb', 'EarlyStopping': '03_callback.ipynb', 'SaveBest': '03_callback.ipynb', 'PredHandler': '03_callback.ipynb', 'PaperSystMod': '03_callback.ipynb', 'GradClip': '03_callback.ipynb', 'to_device': '04_utils.ipynb', 'device': '04_utils.ipynb', 'to_np': '04_utils.ipynb', 'init_net': '04_utils.ipynb', 'plt_style': '05_plotting.ipynb', 'plt_sz': '05_plotting.ipynb', 'plt_cat_pal': '05_plotting.ipynb', 'plt_tk_sz': '05_plotting.ipynb', 'plt_lbl_sz': '05_plotting.ipynb', 'plt_title_sz': '05_plotting.ipynb', 'plt_leg_sz': '05_plotting.ipynb', 'plot_preds': '05_plotting.ipynb', 'plot_likelihood': '05_plotting.ipynb', 'bin_preds': '06_inference.ipynb', 'get_shape': '06_inference.ipynb', 'get_paper_syst_shapes': '06_inference.ipynb', 'get_likelihood_width': '06_inference.ipynb', 'interp_shape': '06_inference.ipynb', 'calc_nll': '06_inference.ipynb', 'jacobian': '06_inference.ipynb', 'calc_grad_hesse': '06_inference.ipynb', 'calc_profile': '06_inference.ipynb', 'VariableSoftmax': '07_inferno_exact.ipynb', 'AbsInferno': '07_inferno_exact.ipynb', 'PaperInferno': '07_inferno_exact.ipynb', 'InfernoPred': '07_inferno_exact.ipynb', 'AbsApproxInferno': '08_inferno_interp.ipynb', 'ApproxPaperInferno': '08_inferno_interp.ipynb'}
modules = ['pseudodata.py', 'model_wrapper.py', 'data.py', 'callback.py', 'utils.py', 'plotting.py', 'inference.py', 'inferno.py']
doc_url = 'https://GilesStrong.github.io/pytorch_inferno/'
git_url = 'https://github.com/GilesStrong/pytorch_inferno/tree/master/'
def custom_doc_links(name):
return None |
def min(x, y):
return x > y and x or y
def gcd(x, y):
res = -1
for i in range(1, min(x, y) + 1):
if x % i == 0 and y % i == 0:
if res < i: res = i
return res
N, M = map(int, input().split())
print(gcd(N, M))
print(gcd(N, M) * (N // gcd(N, M)) * (M // gcd(N, M)))
| def min(x, y):
return x > y and x or y
def gcd(x, y):
res = -1
for i in range(1, min(x, y) + 1):
if x % i == 0 and y % i == 0:
if res < i:
res = i
return res
(n, m) = map(int, input().split())
print(gcd(N, M))
print(gcd(N, M) * (N // gcd(N, M)) * (M // gcd(N, M))) |
# Python - 3.6.0
fruitList = {
1: 'kiwi',
2: 'pear',
3: 'kiwi',
4: 'banana',
5: 'melon',
6: 'banana',
7: 'melon',
8: 'pineapple',
9: 'apple',
10: 'pineapple',
11: 'cucumber',
12: 'pineapple',
13: 'cucumber',
14: 'orange',
15: 'grape',
16: 'orange',
17: 'grape',
18: 'apple',
19: 'grape',
20: 'cherry',
21: 'pear',
22: 'cherry',
23: 'pear',
24: 'kiwi',
25: 'banana',
26: 'kiwi',
27: 'apple',
28: 'melon',
29: 'banana',
30: 'melon',
31: 'pineapple',
32: 'melon',
33: 'pineapple',
34: 'cucumber',
35: 'orange',
36: 'apple',
37: 'orange',
38: 'grape',
39: 'orange',
40: 'grape',
41: 'cherry',
42: 'pear',
43: 'cherry',
44: 'pear',
45: 'apple',
46: 'pear',
47: 'kiwi',
48: 'banana',
49: 'kiwi',
50: 'banana',
51: 'melon',
52: 'pineapple',
53: 'melon',
54: 'apple',
55: 'cucumber',
56: 'pineapple',
57: 'cucumber',
58: 'orange',
59: 'cucumber',
60: 'orange',
61: 'grape',
62: 'cherry',
63: 'apple',
64: 'cherry',
65: 'pear',
66: 'cherry',
67: 'pear',
68: 'kiwi',
69: 'pear',
70: 'kiwi',
71: 'banana',
72: 'apple',
73: 'banana',
74: 'melon',
75: 'pineapple',
76: 'melon',
77: 'pineapple',
78: 'cucumber',
79: 'pineapple',
80: 'cucumber',
81: 'apple',
82: 'grape',
83: 'orange',
84: 'grape',
85: 'cherry',
86: 'grape',
87: 'cherry',
88: 'pear',
89: 'cherry',
90: 'apple',
91: 'kiwi',
92: 'banana',
93: 'kiwi',
94: 'banana',
95: 'melon',
96: 'banana',
97: 'melon',
98: 'pineapple',
99: 'apple',
100: 'pineapple'
}
def subtract_sum(number):
while number > 0:
number -= sum([int(i) for i in str(number)])
if number in fruitList:
return fruitList[number]
return ''
| fruit_list = {1: 'kiwi', 2: 'pear', 3: 'kiwi', 4: 'banana', 5: 'melon', 6: 'banana', 7: 'melon', 8: 'pineapple', 9: 'apple', 10: 'pineapple', 11: 'cucumber', 12: 'pineapple', 13: 'cucumber', 14: 'orange', 15: 'grape', 16: 'orange', 17: 'grape', 18: 'apple', 19: 'grape', 20: 'cherry', 21: 'pear', 22: 'cherry', 23: 'pear', 24: 'kiwi', 25: 'banana', 26: 'kiwi', 27: 'apple', 28: 'melon', 29: 'banana', 30: 'melon', 31: 'pineapple', 32: 'melon', 33: 'pineapple', 34: 'cucumber', 35: 'orange', 36: 'apple', 37: 'orange', 38: 'grape', 39: 'orange', 40: 'grape', 41: 'cherry', 42: 'pear', 43: 'cherry', 44: 'pear', 45: 'apple', 46: 'pear', 47: 'kiwi', 48: 'banana', 49: 'kiwi', 50: 'banana', 51: 'melon', 52: 'pineapple', 53: 'melon', 54: 'apple', 55: 'cucumber', 56: 'pineapple', 57: 'cucumber', 58: 'orange', 59: 'cucumber', 60: 'orange', 61: 'grape', 62: 'cherry', 63: 'apple', 64: 'cherry', 65: 'pear', 66: 'cherry', 67: 'pear', 68: 'kiwi', 69: 'pear', 70: 'kiwi', 71: 'banana', 72: 'apple', 73: 'banana', 74: 'melon', 75: 'pineapple', 76: 'melon', 77: 'pineapple', 78: 'cucumber', 79: 'pineapple', 80: 'cucumber', 81: 'apple', 82: 'grape', 83: 'orange', 84: 'grape', 85: 'cherry', 86: 'grape', 87: 'cherry', 88: 'pear', 89: 'cherry', 90: 'apple', 91: 'kiwi', 92: 'banana', 93: 'kiwi', 94: 'banana', 95: 'melon', 96: 'banana', 97: 'melon', 98: 'pineapple', 99: 'apple', 100: 'pineapple'}
def subtract_sum(number):
while number > 0:
number -= sum([int(i) for i in str(number)])
if number in fruitList:
return fruitList[number]
return '' |
__all__ = [
'base_controller',
'imaging',
'telephony',
'data_tools',
'security_and_networking',
'geolocation',
'e_commerce',
'www',
] | __all__ = ['base_controller', 'imaging', 'telephony', 'data_tools', 'security_and_networking', 'geolocation', 'e_commerce', 'www'] |
f = open('test16.txt', 'rt')
rows = f.readlines()
for row in rows:
print(row)
f.close()
# while True:
# row = f.readline()
# print(row)
# if not row:
# break
# f.close() | f = open('test16.txt', 'rt')
rows = f.readlines()
for row in rows:
print(row)
f.close() |
flagArray = [0 for i in range(32)]
flag = ""
flagArray[0] = 'd'
flagArray[29] = '9'
flagArray[4] = 'r'
flagArray[2] = '5'
flagArray[23] = 'r'
flagArray[3] = 'c'
flagArray[17] = '4'
flagArray[1] = '3'
flagArray[7] = 'b'
flagArray[10] = '_'
flagArray[5] = '4'
flagArray[9] = '3'
flagArray[11] = 't'
flagArray[15] = 'c'
flagArray[8] = 'l'
flagArray[12] = 'H'
flagArray[20] = 'c'
flagArray[14] = '_'
flagArray[6] = 'm'
flagArray[24] = '5'
flagArray[18] = 'r'
flagArray[13] = '3'
flagArray[19] = '4'
flagArray[21] = 'T'
flagArray[16] = 'H'
flagArray[27] = '5'
flagArray[30] = '2'
flagArray[25] = '_'
flagArray[22] = '3'
flagArray[28] = '0'
flagArray[26] = '7'
flagArray[31] = 'e'
for i in range(0, len(flagArray)):
flag = flag + str(flagArray[i])
print(flag) | flag_array = [0 for i in range(32)]
flag = ''
flagArray[0] = 'd'
flagArray[29] = '9'
flagArray[4] = 'r'
flagArray[2] = '5'
flagArray[23] = 'r'
flagArray[3] = 'c'
flagArray[17] = '4'
flagArray[1] = '3'
flagArray[7] = 'b'
flagArray[10] = '_'
flagArray[5] = '4'
flagArray[9] = '3'
flagArray[11] = 't'
flagArray[15] = 'c'
flagArray[8] = 'l'
flagArray[12] = 'H'
flagArray[20] = 'c'
flagArray[14] = '_'
flagArray[6] = 'm'
flagArray[24] = '5'
flagArray[18] = 'r'
flagArray[13] = '3'
flagArray[19] = '4'
flagArray[21] = 'T'
flagArray[16] = 'H'
flagArray[27] = '5'
flagArray[30] = '2'
flagArray[25] = '_'
flagArray[22] = '3'
flagArray[28] = '0'
flagArray[26] = '7'
flagArray[31] = 'e'
for i in range(0, len(flagArray)):
flag = flag + str(flagArray[i])
print(flag) |
print("Enter a selection from the below menu. Press '0' to exit.")
menu_items = ["Bake a loaf of bread", "Bake a pound cake", "Prepare Roast Chicken", "Make Curry", \
"Put a rack of ribs in the smoker", "Buy dinner out", "Have ice cream", "Sandwiches - again"]
select = None
while True:
for i in range(len(menu_items)):
print(f"{i+1}:\t{menu_items[i]}")
select = int(input("\nMake a selection: "))
if select == 0:
print("Shutting down!\n")
break
if select > len(menu_items):
print("I don't have that many options today!\n")
continue
select -= 1
print(f"\nYou selected: {menu_items[select]}\n") | print("Enter a selection from the below menu. Press '0' to exit.")
menu_items = ['Bake a loaf of bread', 'Bake a pound cake', 'Prepare Roast Chicken', 'Make Curry', 'Put a rack of ribs in the smoker', 'Buy dinner out', 'Have ice cream', 'Sandwiches - again']
select = None
while True:
for i in range(len(menu_items)):
print(f'{i + 1}:\t{menu_items[i]}')
select = int(input('\nMake a selection: '))
if select == 0:
print('Shutting down!\n')
break
if select > len(menu_items):
print("I don't have that many options today!\n")
continue
select -= 1
print(f'\nYou selected: {menu_items[select]}\n') |
def primes(n):
out = list()
sieve = [True] * (n+1)
for p in range(2, n+1):
if sieve[p]:
out.append(p)
for i in range(p, n+1, p):
sieve[i] = False
return out
def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
r = int(n**0.5)
f = 5
while f <= r:
if n % f == 0 or n % (f + 2) == 0:
return False
f += 6
return True
| def primes(n):
out = list()
sieve = [True] * (n + 1)
for p in range(2, n + 1):
if sieve[p]:
out.append(p)
for i in range(p, n + 1, p):
sieve[i] = False
return out
def is_prime(n):
if n <= 1:
return False
if n <= 3:
return True
if n % 2 == 0 or n % 3 == 0:
return False
r = int(n ** 0.5)
f = 5
while f <= r:
if n % f == 0 or n % (f + 2) == 0:
return False
f += 6
return True |
class Solution:
def maxArea(self, height: List[int]) -> int:
area = 0
left_pivot = 0
right_pivot = len(height)-1
while left_pivot != right_pivot:
current_area = abs(right_pivot-left_pivot) * min(height[left_pivot], height[right_pivot])
# update the area
if current_area > area:
area = current_area
#update the pivots
if height[left_pivot] < height[right_pivot]:
left_pivot += 1
else:
right_pivot -= 1
return area
| class Solution:
def max_area(self, height: List[int]) -> int:
area = 0
left_pivot = 0
right_pivot = len(height) - 1
while left_pivot != right_pivot:
current_area = abs(right_pivot - left_pivot) * min(height[left_pivot], height[right_pivot])
if current_area > area:
area = current_area
if height[left_pivot] < height[right_pivot]:
left_pivot += 1
else:
right_pivot -= 1
return area |
print("------------------")
print("------------------")
print("------------------")
print("------------------")
print("------------------")
num1 = 10
num2 = 20
| print('------------------')
print('------------------')
print('------------------')
print('------------------')
print('------------------')
num1 = 10
num2 = 20 |
#exceptions
def spam(divided_by):
try:
return 42 / divided_by
except:
print('Invalid argument.')
print(spam(2))
print(spam(0))
print(spam(1))
| def spam(divided_by):
try:
return 42 / divided_by
except:
print('Invalid argument.')
print(spam(2))
print(spam(0))
print(spam(1)) |
# Slackbot API Information
slack_bot_token = "xoxb-2650828670406-2670419769553-qxTzP6Sbh9tlqfYIA52wh1bZ"
bot_id = "xoxb-2650828670406-2670419769553-qxTzP6Sbh9tlqfYIA52wh1bZ"
# AIML FIles
directory = "/aiml"
learn_file = "std-startup.xml"
respond = "load aiml b" | slack_bot_token = 'xoxb-2650828670406-2670419769553-qxTzP6Sbh9tlqfYIA52wh1bZ'
bot_id = 'xoxb-2650828670406-2670419769553-qxTzP6Sbh9tlqfYIA52wh1bZ'
directory = '/aiml'
learn_file = 'std-startup.xml'
respond = 'load aiml b' |
#-*- coding: UTF-8 -*-
def log_info(msg):
print ('bn info:'+msg);
return;
def log_error(msg):
print ('bn error:'+msg);
return;
def log_debug(msg):
print ('bn debug:'+msg);
return; | def log_info(msg):
print('bn info:' + msg)
return
def log_error(msg):
print('bn error:' + msg)
return
def log_debug(msg):
print('bn debug:' + msg)
return |
def fighter():
i01.moveHead(160,87)
i01.moveArm("left",31,75,152,10)
i01.moveArm("right",3,94,33,16)
i01.moveHand("left",161,151,133,127,107,83)
i01.moveHand("right",99,130,152,154,145,180)
i01.moveTorso(90,90,90) | def fighter():
i01.moveHead(160, 87)
i01.moveArm('left', 31, 75, 152, 10)
i01.moveArm('right', 3, 94, 33, 16)
i01.moveHand('left', 161, 151, 133, 127, 107, 83)
i01.moveHand('right', 99, 130, 152, 154, 145, 180)
i01.moveTorso(90, 90, 90) |
# -*- coding: utf-8 -*-
__name__ = "bayrell-common"
__version__ = "0.0.2"
__description__ = "Bayrell Common Library"
__license__ = "Apache License Version 2.0"
__author__ = "Ildar Bikmamatov"
__email__ = "support@bayrell.org"
__copyright__ = "Copyright 2016-2018"
__url__ = "https://github.com/bayrell/common_py3"
| __name__ = 'bayrell-common'
__version__ = '0.0.2'
__description__ = 'Bayrell Common Library'
__license__ = 'Apache License Version 2.0'
__author__ = 'Ildar Bikmamatov'
__email__ = 'support@bayrell.org'
__copyright__ = 'Copyright 2016-2018'
__url__ = 'https://github.com/bayrell/common_py3' |
description = 'Verify the application shows the correct error message when creating a project without name'
pages = ['common',
'index']
def setup(data):
common.access_golem(data.env.url, data.env.admin)
def test(data):
click(index.create_project_button)
click(index.create_button)
index.verify_error_message('Project name is too short')
| description = 'Verify the application shows the correct error message when creating a project without name'
pages = ['common', 'index']
def setup(data):
common.access_golem(data.env.url, data.env.admin)
def test(data):
click(index.create_project_button)
click(index.create_button)
index.verify_error_message('Project name is too short') |
expected_output = {
'group':{
1:{
'state':'Ready',
'core_interfaces':{
'Bundle-Ether2':{
'state':'up'
},
'TenGigE0/1/0/6/1':{
'state':'up'
}
},
'access_interfaces':{
'Bundle-Ether1':{
'state':'up'
}
}
}
}
}
| expected_output = {'group': {1: {'state': 'Ready', 'core_interfaces': {'Bundle-Ether2': {'state': 'up'}, 'TenGigE0/1/0/6/1': {'state': 'up'}}, 'access_interfaces': {'Bundle-Ether1': {'state': 'up'}}}}} |
class Band:
def __init__(self, musicians={}):
self._musicians = musicians
def add_musician(self, musician):
if musician is None:
raise ValueError("Missing required musician instance!")
if musician.get_email() in self._musicians.keys():
raise ValueError("Email already exists!")
self._musicians[musician.get_email()] = musician
print(self)
def add_instrument(self, musician_email, instrument):
if musician_email not in self._musicians.keys():
raise ValueError("Musician does not exist!")
self._musicians[musician_email].add_instrument(instrument)
print(self)
def remove_instrument(self, name, manufacturer, model, musician_email):
if musician_email not in self._musicians.keys():
raise ValueError("Musician does not exist!")
musician = self._musicians[musician_email]
for inst in musician.get_instruments():
if inst.get_name() == name and inst.get_manufacturer() == manufacturer \
and inst.get_model() == model:
musician.get_instruments().remove(inst)
break
print(self)
def __str__(self):
band = "The band's musicians & instruments:\n"
for musician in self._musicians.values():
band += musician.__str__()
band += "\n"
return band
@property
def musicians(self):
return self._musicians
| class Band:
def __init__(self, musicians={}):
self._musicians = musicians
def add_musician(self, musician):
if musician is None:
raise value_error('Missing required musician instance!')
if musician.get_email() in self._musicians.keys():
raise value_error('Email already exists!')
self._musicians[musician.get_email()] = musician
print(self)
def add_instrument(self, musician_email, instrument):
if musician_email not in self._musicians.keys():
raise value_error('Musician does not exist!')
self._musicians[musician_email].add_instrument(instrument)
print(self)
def remove_instrument(self, name, manufacturer, model, musician_email):
if musician_email not in self._musicians.keys():
raise value_error('Musician does not exist!')
musician = self._musicians[musician_email]
for inst in musician.get_instruments():
if inst.get_name() == name and inst.get_manufacturer() == manufacturer and (inst.get_model() == model):
musician.get_instruments().remove(inst)
break
print(self)
def __str__(self):
band = "The band's musicians & instruments:\n"
for musician in self._musicians.values():
band += musician.__str__()
band += '\n'
return band
@property
def musicians(self):
return self._musicians |
class TestStackiPalletInfo:
def test_no_pallet_name(self, run_ansible_module):
result = run_ansible_module("stacki_pallet_info")
assert result.status == "SUCCESS"
assert result.data["changed"] is False
def test_pallet_name(self, run_ansible_module):
pallet_name = "stacki"
result = run_ansible_module("stacki_pallet_info", name=pallet_name)
assert result.status == "SUCCESS"
assert result.data["changed"] is False
assert len(result.data["pallets"]) == 1
assert result.data["pallets"][0]["name"] == pallet_name
def test_invalid_pallet_name(self, run_ansible_module):
pallet_name = "fake_pallet_name"
result = run_ansible_module("stacki_pallet_info", name=pallet_name)
assert "FAIL" in result.status
assert result.data["changed"] is False
assert "error" in result.data["msg"]
assert "not a valid pallet" in result.data["msg"] | class Teststackipalletinfo:
def test_no_pallet_name(self, run_ansible_module):
result = run_ansible_module('stacki_pallet_info')
assert result.status == 'SUCCESS'
assert result.data['changed'] is False
def test_pallet_name(self, run_ansible_module):
pallet_name = 'stacki'
result = run_ansible_module('stacki_pallet_info', name=pallet_name)
assert result.status == 'SUCCESS'
assert result.data['changed'] is False
assert len(result.data['pallets']) == 1
assert result.data['pallets'][0]['name'] == pallet_name
def test_invalid_pallet_name(self, run_ansible_module):
pallet_name = 'fake_pallet_name'
result = run_ansible_module('stacki_pallet_info', name=pallet_name)
assert 'FAIL' in result.status
assert result.data['changed'] is False
assert 'error' in result.data['msg']
assert 'not a valid pallet' in result.data['msg'] |
'''(Record and Move on Technique [E]): Given a sorted array A and a target T,
find the target. If the target is not in the array, find the number closest to the target.
For example, if A = [2,3,5,8,9,11] and T = 7, return 8.'''
def record(arr, mid, res, T):
if res == -1 or abs(arr[mid] - T) < abs(arr[res] - T):
return mid
return res
def closestElement(arr, T):
low = 0
high = len(arr) - 1
res = -1
while low <= high:
mid = low + (high - low) // 2
res = record(arr, mid, res, T)
if arr[mid] > T:
high = mid - 1
elif arr[mid] < T:
low = mid + 1
else:
return mid
return res
print(closestElement([2,3,5,8,9,11], 7))
# Output: 3
# Time: O(logn) Space: O(1)
| """(Record and Move on Technique [E]): Given a sorted array A and a target T,
find the target. If the target is not in the array, find the number closest to the target.
For example, if A = [2,3,5,8,9,11] and T = 7, return 8."""
def record(arr, mid, res, T):
if res == -1 or abs(arr[mid] - T) < abs(arr[res] - T):
return mid
return res
def closest_element(arr, T):
low = 0
high = len(arr) - 1
res = -1
while low <= high:
mid = low + (high - low) // 2
res = record(arr, mid, res, T)
if arr[mid] > T:
high = mid - 1
elif arr[mid] < T:
low = mid + 1
else:
return mid
return res
print(closest_element([2, 3, 5, 8, 9, 11], 7)) |
f1 = open("../train_pre_1")
f2 = open("../test_pre_1")
out1 = open("../train_pre_1b","w")
out2 = open("../test_pre_1b","w")
t = open("../train_gbdt_out")
v = open("../test_gbdt_out")
add = []
for i in xrange(30,49):
add.append("C" + str(i))
line = f1.readline()
print >> out1, line[:-1] + "," + ",".join(add)
line = f2.readline()
print >> out2, line[:-1] + "," + ",".join(add)
for i in xrange(40428967):
line = f1.readline()[:-1]
a = t.readline()[:-1]
ll = a.split(" ")[1:]
for j in xrange(19):
line += "," + add[j] + "_" + ll[j]
print >> out1,line
for i in xrange(4577464):
line = f2.readline()[:-1]
a = v.readline()[:-1]
ll = a.split(" ")[1:]
for j in xrange(19):
line += "," + add[j] + "_" + ll[j]
print >> out2,line
f1.close()
f2.close()
out1.close()
out2.close()
t.close()
v.close()
| f1 = open('../train_pre_1')
f2 = open('../test_pre_1')
out1 = open('../train_pre_1b', 'w')
out2 = open('../test_pre_1b', 'w')
t = open('../train_gbdt_out')
v = open('../test_gbdt_out')
add = []
for i in xrange(30, 49):
add.append('C' + str(i))
line = f1.readline()
(print >> out1, line[:-1] + ',' + ','.join(add))
line = f2.readline()
(print >> out2, line[:-1] + ',' + ','.join(add))
for i in xrange(40428967):
line = f1.readline()[:-1]
a = t.readline()[:-1]
ll = a.split(' ')[1:]
for j in xrange(19):
line += ',' + add[j] + '_' + ll[j]
(print >> out1, line)
for i in xrange(4577464):
line = f2.readline()[:-1]
a = v.readline()[:-1]
ll = a.split(' ')[1:]
for j in xrange(19):
line += ',' + add[j] + '_' + ll[j]
(print >> out2, line)
f1.close()
f2.close()
out1.close()
out2.close()
t.close()
v.close() |
class Solution:
def readBinaryWatch(self, num: int) -> List[str]:
return [str(h)+':'+'0'*(m<10)+str(m) for h in range(12) for m in range(60) if (bin(m)+bin(h)).count('1') ==
num]
| class Solution:
def read_binary_watch(self, num: int) -> List[str]:
return [str(h) + ':' + '0' * (m < 10) + str(m) for h in range(12) for m in range(60) if (bin(m) + bin(h)).count('1') == num] |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( a ) :
return ( 4 * a )
#TOFILL
if __name__ == '__main__':
param = [
(98,),
(9,),
(18,),
(38,),
(84,),
(8,),
(39,),
(6,),
(60,),
(47,)
]
n_success = 0
for i, parameters_set in enumerate(param):
if f_filled(*parameters_set) == f_gold(*parameters_set):
n_success+=1
print("#Results: %i, %i" % (n_success, len(param))) | def f_gold(a):
return 4 * a
if __name__ == '__main__':
param = [(98,), (9,), (18,), (38,), (84,), (8,), (39,), (6,), (60,), (47,)]
n_success = 0
for (i, parameters_set) in enumerate(param):
if f_filled(*parameters_set) == f_gold(*parameters_set):
n_success += 1
print('#Results: %i, %i' % (n_success, len(param))) |
selRoi = 0
top_left= [20,40]
bottom_right = [60,120]
#For cars2.avi
top_left= [40,50]
bottom_right = [60,80]
top_left2= [110,40]
bottom_right2 = [150,120]
first_time = 1
video_path = 'cars2.avi' | sel_roi = 0
top_left = [20, 40]
bottom_right = [60, 120]
top_left = [40, 50]
bottom_right = [60, 80]
top_left2 = [110, 40]
bottom_right2 = [150, 120]
first_time = 1
video_path = 'cars2.avi' |
class Animal:
def __init__(self):
self.age = 1
def eat(self):
print("eat")
class Mammal(Animal):
def walk(self):
print("walk")
m = Mammal()
print(isinstance(m, Mammal))
print(isinstance(m, Animal))
print(isinstance(Mammal, object))
o = object()
print(issubclass(Mammal, Animal))
print(issubclass(Mammal, object))
| class Animal:
def __init__(self):
self.age = 1
def eat(self):
print('eat')
class Mammal(Animal):
def walk(self):
print('walk')
m = mammal()
print(isinstance(m, Mammal))
print(isinstance(m, Animal))
print(isinstance(Mammal, object))
o = object()
print(issubclass(Mammal, Animal))
print(issubclass(Mammal, object)) |
inventory_dict = {
"core": [
"PrettyName",
"Present",
"Functional"
],
"fan": [
"PrettyName",
"Present",
"MeetsMinimumShipLevel",
"Functional"
],
"fan_wc": [
"PrettyName",
"Present",
"MeetsMinimumShipLevel"
],
"fru": [
"PrettyName",
"Present",
"PartNumber",
"SerialNumber",
"Manufacturer",
"BuildDate",
"Model",
"Version",
"FieldReplaceable",
"Cached",
"Functional"
],
"gpu": [
"PrettyName",
"Present",
"FieldReplaceable",
"Functional"
]
}
| inventory_dict = {'core': ['PrettyName', 'Present', 'Functional'], 'fan': ['PrettyName', 'Present', 'MeetsMinimumShipLevel', 'Functional'], 'fan_wc': ['PrettyName', 'Present', 'MeetsMinimumShipLevel'], 'fru': ['PrettyName', 'Present', 'PartNumber', 'SerialNumber', 'Manufacturer', 'BuildDate', 'Model', 'Version', 'FieldReplaceable', 'Cached', 'Functional'], 'gpu': ['PrettyName', 'Present', 'FieldReplaceable', 'Functional']} |
SEAL_CHECKER = 9300535
SEAL_OF_TIME = 2159367
if not sm.hasQuest(25672):
sm.createQuestWithQRValue(25672, "1")
sm.showFieldEffect("lightning/screenMsg/6", 0) | seal_checker = 9300535
seal_of_time = 2159367
if not sm.hasQuest(25672):
sm.createQuestWithQRValue(25672, '1')
sm.showFieldEffect('lightning/screenMsg/6', 0) |
class Solution:
def minJumps(self, arr: List[int]) -> int:
if len(arr) == 1:
return 0
d = collections.defaultdict(list)
for index, element in enumerate(arr):
d[element].append(index)
queue = collections.deque([(0, 0)])
s = set()
s.add(0)
while len(queue):
currIndex, jumps = queue.popleft()
for nextIndex in [currIndex + 1, currIndex - 1] + d[arr[currIndex]][::-1]:
if nextIndex < len(arr) and nextIndex > -1 and nextIndex != currIndex and nextIndex not in s:
if nextIndex == len(arr) - 1:
return jumps + 1
s.add(nextIndex)
queue.append((nextIndex, jumps + 1))
return -1
| class Solution:
def min_jumps(self, arr: List[int]) -> int:
if len(arr) == 1:
return 0
d = collections.defaultdict(list)
for (index, element) in enumerate(arr):
d[element].append(index)
queue = collections.deque([(0, 0)])
s = set()
s.add(0)
while len(queue):
(curr_index, jumps) = queue.popleft()
for next_index in [currIndex + 1, currIndex - 1] + d[arr[currIndex]][::-1]:
if nextIndex < len(arr) and nextIndex > -1 and (nextIndex != currIndex) and (nextIndex not in s):
if nextIndex == len(arr) - 1:
return jumps + 1
s.add(nextIndex)
queue.append((nextIndex, jumps + 1))
return -1 |
_base_ = './model_r3d18.py'
model = dict(
backbone=dict(type='R2Plus1D'),
)
| _base_ = './model_r3d18.py'
model = dict(backbone=dict(type='R2Plus1D')) |
'''input
ABCD
No
BACD
Yes
'''
# -*- coding: utf-8 -*-
# CODE FESTIVAL 2017 qual C
# Problem A
if __name__ == '__main__':
s = input()
if 'AC' in s:
print('Yes')
else:
print('No')
| """input
ABCD
No
BACD
Yes
"""
if __name__ == '__main__':
s = input()
if 'AC' in s:
print('Yes')
else:
print('No') |
ss = input()
out = ss[0]
for i in range(1, len(ss)):
if ss[i] != ss[i-1]: out += ss[i]
print(out)
| ss = input()
out = ss[0]
for i in range(1, len(ss)):
if ss[i] != ss[i - 1]:
out += ss[i]
print(out) |
def onStart():
parent().par.Showshortcut = True
def onCreate():
onStart()
| def on_start():
parent().par.Showshortcut = True
def on_create():
on_start() |
#Edited by Joseph Hutchens
def test():
print("Sucessfully Complete")
return 1
test()
| def test():
print('Sucessfully Complete')
return 1
test() |
__all__ = [
'ValidationError',
'MethodMissingError',
]
class ValidationError(Exception):
pass
class MethodMissingError(Exception):
pass
| __all__ = ['ValidationError', 'MethodMissingError']
class Validationerror(Exception):
pass
class Methodmissingerror(Exception):
pass |
def main():
while True:
text = input("Enter a number: ")
if not text:
print("Later...")
break
num = int(text)
num_class = "small" if num < 100 else "huge!"
print(f"The number is {num_class}")
| def main():
while True:
text = input('Enter a number: ')
if not text:
print('Later...')
break
num = int(text)
num_class = 'small' if num < 100 else 'huge!'
print(f'The number is {num_class}') |
def main():
# problem1()
# problem2()
# problem3()
problem4()
# Create a function that has two variables.
# One called greeting and another called myName.
# Print out greeting and myName two different ways without using the following examples
def problem1():
greeting = "Hello world"
myName = "Chey"
print("%s my name is %s." %(greeting,myName))
# print(f"{greeting} my name is {myName}.")
# Create a function that asks the user for a secret password.
# Create a loop that quits with the user's quit word.
# If the user doesn't enter that word, ask them to guess again.
def problem2():
secretPassword = input("Enter secret password ")
while (True):
password = input("Enter password ")
if password == secretPassword:
break
else:
print("Try Again!!")
# Create a function that prints 0 to 100 three times in a row (vertically).
def problem3():
for firstLoop in range(3):
for secondLoop in range(101):
print(secondLoop)
def problem4():
randomNum = random.randint(0,5)
userInput = ""
while(userInput != str(randomNum)):
userInput = input("Guess the number")
if __name__ == '__main__':
main() | def main():
problem4()
def problem1():
greeting = 'Hello world'
my_name = 'Chey'
print('%s my name is %s.' % (greeting, myName))
def problem2():
secret_password = input('Enter secret password ')
while True:
password = input('Enter password ')
if password == secretPassword:
break
else:
print('Try Again!!')
def problem3():
for first_loop in range(3):
for second_loop in range(101):
print(secondLoop)
def problem4():
random_num = random.randint(0, 5)
user_input = ''
while userInput != str(randomNum):
user_input = input('Guess the number')
if __name__ == '__main__':
main() |
# 037
# Ask the user to enter their name and display each letter in
# their name on a separate line
name = input('Enter ya name: ')
for i in range(len(name)):
print(name[i])
| name = input('Enter ya name: ')
for i in range(len(name)):
print(name[i]) |
# Dictionary Keys, Items and Values
mice = {'harold': 'tiny mouse', 'rose': 'nipple mouse', 'willy wonka': 'dead mouse'}
# Looping over a dictionary
for m in mice.values(): # All values of the dictionary
print(m)
print()
for m in mice.keys(): # All keys of the dictionary
print(m)
print()
for m in mice.items(): # All items of the dictionary
print(m)
print()
# Or get all info from the dictionary
for key, value in mice.items():
print(value + ' ' + key + ' represent!')
# Checkin a dictionary for a specific value
print()
print('harold' in mice.keys()) # True
print('harold' in mice.values()) # False
| mice = {'harold': 'tiny mouse', 'rose': 'nipple mouse', 'willy wonka': 'dead mouse'}
for m in mice.values():
print(m)
print()
for m in mice.keys():
print(m)
print()
for m in mice.items():
print(m)
print()
for (key, value) in mice.items():
print(value + ' ' + key + ' represent!')
print()
print('harold' in mice.keys())
print('harold' in mice.values()) |
def make_greeting(name, formality):
return (
"Greetings and felicitations, {}!".format(name)
if formality
else "Hello, {}!".format(name)
)
| def make_greeting(name, formality):
return 'Greetings and felicitations, {}!'.format(name) if formality else 'Hello, {}!'.format(name) |
class MockMetaMachine(object):
def __init__(self, meta_business_unit_id_set, tag_id_set, platform, type, serial_number="YO"):
self.meta_business_unit_id_set = set(meta_business_unit_id_set)
self._tag_id_set = set(tag_id_set)
self.platform = platform
self.type = type
self.serial_number = serial_number
self.has_deb_packages = platform == "LINUX"
def get_probe_filtering_values(self):
return self.platform, self.type, self.meta_business_unit_id_set, self._tag_id_set
@property
def cached_probe_filtering_values(self):
return self.get_probe_filtering_values()
| class Mockmetamachine(object):
def __init__(self, meta_business_unit_id_set, tag_id_set, platform, type, serial_number='YO'):
self.meta_business_unit_id_set = set(meta_business_unit_id_set)
self._tag_id_set = set(tag_id_set)
self.platform = platform
self.type = type
self.serial_number = serial_number
self.has_deb_packages = platform == 'LINUX'
def get_probe_filtering_values(self):
return (self.platform, self.type, self.meta_business_unit_id_set, self._tag_id_set)
@property
def cached_probe_filtering_values(self):
return self.get_probe_filtering_values() |
__all__ = ('CMD_STATUS', 'CMD_STATUS_NAME', 'CMD_BLOCKED', 'CMD_READY',
'CMD_ASSIGNED', 'CMD_RUNNING', 'CMD_FINISHING', 'CMD_DONE',
'CMD_ERROR', 'CMD_CANCELED', 'CMD_TIMEOUT',
'isFinalStatus', 'isRunningStatus')
CMD_STATUS = (CMD_BLOCKED,
CMD_READY,
CMD_ASSIGNED,
CMD_RUNNING,
CMD_FINISHING,
CMD_DONE,
CMD_TIMEOUT,
CMD_ERROR,
CMD_CANCELED) = range(9)
CMD_STATUS_NAME = ('BLOCKED',
'READY',
'ASSIGNED',
'RUNNING',
'FINISHING',
'DONE',
'TIMEOUT',
'ERROR',
'CANCELED')
CMD_STATUS_SHORT_NAMES = ("B", "I", "A", "R", "F", "D", "T", "E", "C")
def isFinalStatus(status):
return status in (CMD_DONE, CMD_ERROR, CMD_CANCELED, CMD_TIMEOUT)
def isRunningStatus(status):
return status in (CMD_RUNNING, CMD_FINISHING, CMD_ASSIGNED)
| __all__ = ('CMD_STATUS', 'CMD_STATUS_NAME', 'CMD_BLOCKED', 'CMD_READY', 'CMD_ASSIGNED', 'CMD_RUNNING', 'CMD_FINISHING', 'CMD_DONE', 'CMD_ERROR', 'CMD_CANCELED', 'CMD_TIMEOUT', 'isFinalStatus', 'isRunningStatus')
cmd_status = (cmd_blocked, cmd_ready, cmd_assigned, cmd_running, cmd_finishing, cmd_done, cmd_timeout, cmd_error, cmd_canceled) = range(9)
cmd_status_name = ('BLOCKED', 'READY', 'ASSIGNED', 'RUNNING', 'FINISHING', 'DONE', 'TIMEOUT', 'ERROR', 'CANCELED')
cmd_status_short_names = ('B', 'I', 'A', 'R', 'F', 'D', 'T', 'E', 'C')
def is_final_status(status):
return status in (CMD_DONE, CMD_ERROR, CMD_CANCELED, CMD_TIMEOUT)
def is_running_status(status):
return status in (CMD_RUNNING, CMD_FINISHING, CMD_ASSIGNED) |
uri = "postgres://user:password@host/database" # Postgresql url connection string
token = "" # Discord bot token
POLL_ROLE_PING = None # Role ID to ping for polls, leave as None to not ping
THREAD_INACTIVE_HOURS = 12 # How many hours of inactivity are required for a
ADD_USERS_IDS = [] # List of user ids to add to a thread on joi
| uri = 'postgres://user:password@host/database'
token = ''
poll_role_ping = None
thread_inactive_hours = 12
add_users_ids = [] |
# copyright 2008-2009 WebDriver committers
# Copyright 2008-2009 Google Inc.
#
# Licensed under the Apache License Version 2.0 = uthe "License")
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http //www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing software
# distributed under the License is distributed on an "AS IS" BASIS
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
class Keys(object):
NULL = u'\ue000'
CANCEL = u'\ue001' # ^break
HELP = u'\ue002'
BACK_SPACE = u'\ue003'
TAB = u'\ue004'
CLEAR = u'\ue005'
RETURN = u'\ue006'
ENTER = u'\ue007'
SHIFT = u'\ue008'
LEFT_SHIFT = u'\ue008' # alias
CONTROL = u'\ue009'
LEFT_CONTROL = u'\ue009' # alias
ALT = u'\ue00a'
LEFT_ALT = u'\ue00a' # alias
PAUSE = u'\ue00b'
ESCAPE = u'\ue00c'
SPACE = u'\ue00d'
PAGE_UP = u'\ue00e'
PAGE_DOWN = u'\ue00f'
END = u'\ue010'
HOME = u'\ue011'
LEFT = u'\ue012'
ARROW_LEFT = u'\ue012' # alias
UP = u'\ue013'
ARROW_UP = u'\ue013' # alias
RIGHT = u'\ue014'
ARROW_RIGHT = u'\ue014' # alias
DOWN = u'\ue015'
ARROW_DOWN = u'\ue015' # alias
INSERT = u'\ue016'
DELETE = u'\ue017'
SEMICOLON = u'\ue018'
EQUALS = u'\ue019'
NUMPAD0 = u'\ue01a' # numbe pad keys
NUMPAD1 = u'\ue01b'
NUMPAD2 = u'\ue01c'
NUMPAD3 = u'\ue01d'
NUMPAD4 = u'\ue01e'
NUMPAD5 = u'\ue01f'
NUMPAD6 = u'\ue020'
NUMPAD7 = u'\ue021'
NUMPAD8 = u'\ue022'
NUMPAD9 = u'\ue023'
MULTIPLY = u'\ue024'
ADD = u'\ue025'
SEPARATOR = u'\ue026'
SUBTRACT = u'\ue027'
DECIMAL = u'\ue028'
DIVIDE = u'\ue029'
F1 = u'\ue031' # function keys
F2 = u'\ue032'
F3 = u'\ue033'
F4 = u'\ue034'
F5 = u'\ue035'
F6 = u'\ue036'
F7 = u'\ue037'
F8 = u'\ue038'
F9 = u'\ue039'
F10 = u'\ue03a'
F11 = u'\ue03b'
F12 = u'\ue03c'
META = u'\ue03d'
COMMAND = u'\ue03d'
| class Keys(object):
null = u'\ue000'
cancel = u'\ue001'
help = u'\ue002'
back_space = u'\ue003'
tab = u'\ue004'
clear = u'\ue005'
return = u'\ue006'
enter = u'\ue007'
shift = u'\ue008'
left_shift = u'\ue008'
control = u'\ue009'
left_control = u'\ue009'
alt = u'\ue00a'
left_alt = u'\ue00a'
pause = u'\ue00b'
escape = u'\ue00c'
space = u'\ue00d'
page_up = u'\ue00e'
page_down = u'\ue00f'
end = u'\ue010'
home = u'\ue011'
left = u'\ue012'
arrow_left = u'\ue012'
up = u'\ue013'
arrow_up = u'\ue013'
right = u'\ue014'
arrow_right = u'\ue014'
down = u'\ue015'
arrow_down = u'\ue015'
insert = u'\ue016'
delete = u'\ue017'
semicolon = u'\ue018'
equals = u'\ue019'
numpad0 = u'\ue01a'
numpad1 = u'\ue01b'
numpad2 = u'\ue01c'
numpad3 = u'\ue01d'
numpad4 = u'\ue01e'
numpad5 = u'\ue01f'
numpad6 = u'\ue020'
numpad7 = u'\ue021'
numpad8 = u'\ue022'
numpad9 = u'\ue023'
multiply = u'\ue024'
add = u'\ue025'
separator = u'\ue026'
subtract = u'\ue027'
decimal = u'\ue028'
divide = u'\ue029'
f1 = u'\ue031'
f2 = u'\ue032'
f3 = u'\ue033'
f4 = u'\ue034'
f5 = u'\ue035'
f6 = u'\ue036'
f7 = u'\ue037'
f8 = u'\ue038'
f9 = u'\ue039'
f10 = u'\ue03a'
f11 = u'\ue03b'
f12 = u'\ue03c'
meta = u'\ue03d'
command = u'\ue03d' |
def my_cleaner(dryrun):
if dryrun:
print('dryrun, dont really execute')
return
print('execute cleaner...')
def task_sample():
return {
"actions" : None,
"clean" : [my_cleaner],
}
| def my_cleaner(dryrun):
if dryrun:
print('dryrun, dont really execute')
return
print('execute cleaner...')
def task_sample():
return {'actions': None, 'clean': [my_cleaner]} |
def NumFunc(myList1=[],myList2=[],*args):
list3 = list(set(myList1).intersection(myList2))
return list3
myList1 = [1,2,3,4,5,6]
myList2 = [3, 5, 7, 9]
NumFunc(myList1,myList2) | def num_func(myList1=[], myList2=[], *args):
list3 = list(set(myList1).intersection(myList2))
return list3
my_list1 = [1, 2, 3, 4, 5, 6]
my_list2 = [3, 5, 7, 9]
num_func(myList1, myList2) |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution:
def mergeKLists(self, lists: List[ListNode]) -> ListNode:
ans = list()
for node in lists:
val = node
while (val != None):
ans.append(val.val)
val = val.next
ans = sorted(ans)
sub = None
point = None
for x in ans:
if sub == None:
sub = ListNode(x)
point = sub
else:
point.next = ListNode(x)
point = point.next
return sub
# home = None
# point = None
# val = None
# while True:
# val = None
# for i in range(len(lists)):
# if lists[i] == None:
# continue
# if val == None:
# val = i
# continue
# if lists[i].val < lists[val].val:
# val = i
# if val == None:
# break
# if home == None:
# home = lists[val]
# point = home
# lists[val] = lists[val].next
# else:
# point.next = lists[val]
# point = point.next
# lists[val] = lists[val].next
# return home
| class Solution:
def merge_k_lists(self, lists: List[ListNode]) -> ListNode:
ans = list()
for node in lists:
val = node
while val != None:
ans.append(val.val)
val = val.next
ans = sorted(ans)
sub = None
point = None
for x in ans:
if sub == None:
sub = list_node(x)
point = sub
else:
point.next = list_node(x)
point = point.next
return sub |
# Copyright (C) 2021 <FacuFalcone - CaidevOficial>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
def bag(sizeBag: int, kilos: list, values: list, index: int):
# Base Case 1
if index == 0 or sizeBag == 0:
return 0
# Base Case 2
elif kilos[index-1] > sizeBag:
return bag(sizeBag, kilos, values, index-1)
return max(values[index-1]+bag(sizeBag-kilos[index-1], kilos, values, index-1), bag(sizeBag, kilos, values, index-1))
if __name__ == "__main__":
values = [60, 100, 120]
kilos = [10, 20, 30]
sizeBag = 50
index = len(values)
result = bag(sizeBag, kilos, values, index)
print(result)
| def bag(sizeBag: int, kilos: list, values: list, index: int):
if index == 0 or sizeBag == 0:
return 0
elif kilos[index - 1] > sizeBag:
return bag(sizeBag, kilos, values, index - 1)
return max(values[index - 1] + bag(sizeBag - kilos[index - 1], kilos, values, index - 1), bag(sizeBag, kilos, values, index - 1))
if __name__ == '__main__':
values = [60, 100, 120]
kilos = [10, 20, 30]
size_bag = 50
index = len(values)
result = bag(sizeBag, kilos, values, index)
print(result) |
#Replace all ______ with rjust, ljust or center.
THICKNESS = int(input()) #This must be an odd number
c = 'H'
# Top Cone
for i in range(THICKNESS):
print((c*i).rjust(THICKNESS-1)+c+(c*i).ljust(THICKNESS-1))
# Top Pillars
for i in range(THICKNESS+1):
print((c*THICKNESS).center(THICKNESS*2)+(c*THICKNESS).center(THICKNESS*6))
# Middle Belt
for i in range((THICKNESS+1)//2):
print((c*THICKNESS*5).center(THICKNESS*6))
# Bottom Pillars
for i in range(THICKNESS+1):
print((c*THICKNESS).center(THICKNESS*2)+(c*THICKNESS).center(THICKNESS*6))
# Bottom Cone
for i in range(THICKNESS):
print(((c*(THICKNESS-i-1)).rjust(THICKNESS)+c+(c*(THICKNESS-i-1)).ljust(THICKNESS)).rjust(THICKNESS*6)) | thickness = int(input())
c = 'H'
for i in range(THICKNESS):
print((c * i).rjust(THICKNESS - 1) + c + (c * i).ljust(THICKNESS - 1))
for i in range(THICKNESS + 1):
print((c * THICKNESS).center(THICKNESS * 2) + (c * THICKNESS).center(THICKNESS * 6))
for i in range((THICKNESS + 1) // 2):
print((c * THICKNESS * 5).center(THICKNESS * 6))
for i in range(THICKNESS + 1):
print((c * THICKNESS).center(THICKNESS * 2) + (c * THICKNESS).center(THICKNESS * 6))
for i in range(THICKNESS):
print(((c * (THICKNESS - i - 1)).rjust(THICKNESS) + c + (c * (THICKNESS - i - 1)).ljust(THICKNESS)).rjust(THICKNESS * 6)) |
cellsize = 200
cells = {}
recording = False
class Cell:
def __init__(self, x, y, ix, iy):
self.x, self.y = x, y
self.ix, self.iy = ix, iy # positional indices
self.xdiv = 1.0
self.ydiv = 1.0
self.left = None
self.up = None
def left_inter(self):
if self.left:
return self.f(frameCount)[0] + self.left.left_inter()
else:
return self.f(frameCount)[0]
def up_inter(self):
if self.up:
return self.f(frameCount)[1] + self.up.up_inter()
else:
return self.f(frameCount)[1]
def f(self, fc):
return cos(fc/self.xdiv), sin(fc/self.ydiv)
def draw_me(self):
pushStyle()
pushMatrix()
translate(self.x, self.y)
fill(0, 0, 1)
noStroke()
circle(0, 0, 5)
# calculate interference from previous cells
# average out based on position
ix = self.left_inter() / self.ix
iy = self.up_inter() / self.iy
fill(0, 1, 1, 0.5)
circle(ix*cellsize*0.3, iy*cellsize*0.3, 2)
popMatrix()
popStyle()
def __repr__(self):
return "{}, {}".format(self.x, self.y)
def setup():
size(800, 800)
colorMode(HSB, 360, 1, 1, 1)
background(0, 0, 0)
for x in range(4):
for y in range(4):
cells[x,y] = Cell(x*cellsize+cellsize/2, y*cellsize+cellsize/2, x+1, y+1)
cells[x,y].xdiv, cells[x,y].ydiv = 100.0, 100.0
# set up neighbour properties
for y in range(4):
for x in range(4):
if x != 0:
cells[x,y].left = cells[x-1,y]
if y != 0:
cells[x,y].up = cells[x,y-1]
cells[0,0].xdiv, cells[0,0].ydiv = 100.0, 100.0
# set up vertical seeds
for i in range(1,4):
cells[0,i].xdiv, cells[0,i].ydiv = random(50, 100), random(30, 50)
# set up horizontal seeds
for i in range(1,4):
cells[i,0].xdiv, cells[i,0].ydiv = random(30, 50), random(50, 100)
def draw():
noStroke()
fill(0, 0, 0, 0.04)
square(0, 0, height)
for k in cells:
cells[k].draw_me()
if recording and frameCount < 1500:
saveFrame("frames/#####.png")
else:
noLoop()
print("Done.")
| cellsize = 200
cells = {}
recording = False
class Cell:
def __init__(self, x, y, ix, iy):
(self.x, self.y) = (x, y)
(self.ix, self.iy) = (ix, iy)
self.xdiv = 1.0
self.ydiv = 1.0
self.left = None
self.up = None
def left_inter(self):
if self.left:
return self.f(frameCount)[0] + self.left.left_inter()
else:
return self.f(frameCount)[0]
def up_inter(self):
if self.up:
return self.f(frameCount)[1] + self.up.up_inter()
else:
return self.f(frameCount)[1]
def f(self, fc):
return (cos(fc / self.xdiv), sin(fc / self.ydiv))
def draw_me(self):
push_style()
push_matrix()
translate(self.x, self.y)
fill(0, 0, 1)
no_stroke()
circle(0, 0, 5)
ix = self.left_inter() / self.ix
iy = self.up_inter() / self.iy
fill(0, 1, 1, 0.5)
circle(ix * cellsize * 0.3, iy * cellsize * 0.3, 2)
pop_matrix()
pop_style()
def __repr__(self):
return '{}, {}'.format(self.x, self.y)
def setup():
size(800, 800)
color_mode(HSB, 360, 1, 1, 1)
background(0, 0, 0)
for x in range(4):
for y in range(4):
cells[x, y] = cell(x * cellsize + cellsize / 2, y * cellsize + cellsize / 2, x + 1, y + 1)
(cells[x, y].xdiv, cells[x, y].ydiv) = (100.0, 100.0)
for y in range(4):
for x in range(4):
if x != 0:
cells[x, y].left = cells[x - 1, y]
if y != 0:
cells[x, y].up = cells[x, y - 1]
(cells[0, 0].xdiv, cells[0, 0].ydiv) = (100.0, 100.0)
for i in range(1, 4):
(cells[0, i].xdiv, cells[0, i].ydiv) = (random(50, 100), random(30, 50))
for i in range(1, 4):
(cells[i, 0].xdiv, cells[i, 0].ydiv) = (random(30, 50), random(50, 100))
def draw():
no_stroke()
fill(0, 0, 0, 0.04)
square(0, 0, height)
for k in cells:
cells[k].draw_me()
if recording and frameCount < 1500:
save_frame('frames/#####.png')
else:
no_loop()
print('Done.') |
HUOBI_URL_PRO = "https://api.huobi.sg"
HUOBI_URL_VN = "https://api.huobi.sg"
HUOBI_URL_SO = "https://api.huobi.sg"
HUOBI_WEBSOCKET_URI_PRO = "wss://api.huobi.sg"
HUOBI_WEBSOCKET_URI_VN = "wss://api.huobi.sg"
HUOBI_WEBSOCKET_URI_SO = "wss://api.huobi.sg"
class WebSocketDefine:
Uri = HUOBI_WEBSOCKET_URI_PRO
class RestApiDefine:
Url = HUOBI_URL_PRO
class HttpMethod:
GET = "GET"
GET_SIGN = "GET_SIGN"
POST = "POST"
POST_SIGN = "POST_SIGN"
class ApiVersion:
VERSION_V1 = "v1"
VERSION_V2 = "v2"
def get_default_server_url(user_configed_url):
if user_configed_url and len(user_configed_url):
return user_configed_url
else:
return RestApiDefine.Url
| huobi_url_pro = 'https://api.huobi.sg'
huobi_url_vn = 'https://api.huobi.sg'
huobi_url_so = 'https://api.huobi.sg'
huobi_websocket_uri_pro = 'wss://api.huobi.sg'
huobi_websocket_uri_vn = 'wss://api.huobi.sg'
huobi_websocket_uri_so = 'wss://api.huobi.sg'
class Websocketdefine:
uri = HUOBI_WEBSOCKET_URI_PRO
class Restapidefine:
url = HUOBI_URL_PRO
class Httpmethod:
get = 'GET'
get_sign = 'GET_SIGN'
post = 'POST'
post_sign = 'POST_SIGN'
class Apiversion:
version_v1 = 'v1'
version_v2 = 'v2'
def get_default_server_url(user_configed_url):
if user_configed_url and len(user_configed_url):
return user_configed_url
else:
return RestApiDefine.Url |
def index(array,index):
try:
return array[index]
except:
return array
def append(array,value):
try:
array.append(value)
except:
pass
return array
def remove(array,index):
try:
del array[index]
except:
pass
return array
def dedupe(array):
try:
return list(dict.fromkeys(array))
except:
return array
| def index(array, index):
try:
return array[index]
except:
return array
def append(array, value):
try:
array.append(value)
except:
pass
return array
def remove(array, index):
try:
del array[index]
except:
pass
return array
def dedupe(array):
try:
return list(dict.fromkeys(array))
except:
return array |
class Entity():
def __init__(self, entityID, type, attributeMap):
self.__entityID = entityID
self.__type = type
self.__attributeMap = attributeMap
@property
def entityID(self):
return self.__entityID
@entityID.setter
def entityID(self, entityID):
self.__entityID = entityID
@property
def type(self):
return self.__type
@type.setter
def type(self, type):
self.__type = type
@property
def attributeMap(self):
return self.__attributeMap
@attributeMap.setter
def attributeMap(self, attributeMap):
self.__attributeMap = attributeMap
| class Entity:
def __init__(self, entityID, type, attributeMap):
self.__entityID = entityID
self.__type = type
self.__attributeMap = attributeMap
@property
def entity_id(self):
return self.__entityID
@entityID.setter
def entity_id(self, entityID):
self.__entityID = entityID
@property
def type(self):
return self.__type
@type.setter
def type(self, type):
self.__type = type
@property
def attribute_map(self):
return self.__attributeMap
@attributeMap.setter
def attribute_map(self, attributeMap):
self.__attributeMap = attributeMap |
#
# from src/3dgraph.c
#
# a part of main to tdGraph
#
_MAX_VALUE = float("inf")
class parametersTDGraph:
def __init__(self, m, n, t, u, minX, minY, minZ, maxX, maxY, maxZ):
self.m = m
self.n = n
self.t = t
self.u = u
self.minX = minX
self.minY = minY
self.minZ = minZ
self.maxX = maxX
self.maxY = maxY
self.maxZ = maxZ
def tdGraph(plotter, aFunction, parameters):
P = parameters
lowerHorizon = [ _MAX_VALUE for _ in range(P.m + 4 * P.n + 1) ]
upperHorizon = [ -_MAX_VALUE for _ in range(P.m + 4 * P.n + 1) ]
for i in range(P.n + 1):
flagA = False
z = P.minZ + (P.maxZ - P.minZ) / P.n * i
for j in range(P.m + 1):
flagB = False
idx = j + 2 * (P.n - i)
x = P.minX + (P.maxX - P.minX) / P.m * j
y = P.t * (aFunction(x, z) - P.minY) / (P.maxY - P.minY) + P.u * i
if y < lowerHorizon[idx]:
lowerHorizon[idx], flagB = y, True
if y > upperHorizon[idx]:
upperHorizon[idx], flagB = y, True
if flagB and flagA:
plotter.draw(2 * idx, 2 * y)
else:
plotter.move(2 * idx, 2 * y)
flagA = flagB
| _max_value = float('inf')
class Parameterstdgraph:
def __init__(self, m, n, t, u, minX, minY, minZ, maxX, maxY, maxZ):
self.m = m
self.n = n
self.t = t
self.u = u
self.minX = minX
self.minY = minY
self.minZ = minZ
self.maxX = maxX
self.maxY = maxY
self.maxZ = maxZ
def td_graph(plotter, aFunction, parameters):
p = parameters
lower_horizon = [_MAX_VALUE for _ in range(P.m + 4 * P.n + 1)]
upper_horizon = [-_MAX_VALUE for _ in range(P.m + 4 * P.n + 1)]
for i in range(P.n + 1):
flag_a = False
z = P.minZ + (P.maxZ - P.minZ) / P.n * i
for j in range(P.m + 1):
flag_b = False
idx = j + 2 * (P.n - i)
x = P.minX + (P.maxX - P.minX) / P.m * j
y = P.t * (a_function(x, z) - P.minY) / (P.maxY - P.minY) + P.u * i
if y < lowerHorizon[idx]:
(lowerHorizon[idx], flag_b) = (y, True)
if y > upperHorizon[idx]:
(upperHorizon[idx], flag_b) = (y, True)
if flagB and flagA:
plotter.draw(2 * idx, 2 * y)
else:
plotter.move(2 * idx, 2 * y)
flag_a = flagB |
class CreateSingleEventRequest:
def __init__(self, chart_key, event_key=None, table_booking_config=None, social_distancing_ruleset_key=None):
if chart_key:
self.chartKey = chart_key
if event_key:
self.eventKey = event_key
if table_booking_config is not None:
self.tableBookingConfig = table_booking_config.to_json()
if social_distancing_ruleset_key is not None:
self.socialDistancingRulesetKey = social_distancing_ruleset_key
| class Createsingleeventrequest:
def __init__(self, chart_key, event_key=None, table_booking_config=None, social_distancing_ruleset_key=None):
if chart_key:
self.chartKey = chart_key
if event_key:
self.eventKey = event_key
if table_booking_config is not None:
self.tableBookingConfig = table_booking_config.to_json()
if social_distancing_ruleset_key is not None:
self.socialDistancingRulesetKey = social_distancing_ruleset_key |
#
# PySNMP MIB module PYSNMP-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/PYSNMP-MIB
# Produced by pysmi-0.3.4 at Wed May 1 14:43:00 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ConstraintsIntersection, ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, Bits, NotificationType, enterprises, IpAddress, Counter64, MibIdentifier, ObjectIdentity, ModuleIdentity, Counter32, iso, TimeTicks, Unsigned32, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "Bits", "NotificationType", "enterprises", "IpAddress", "Counter64", "MibIdentifier", "ObjectIdentity", "ModuleIdentity", "Counter32", "iso", "TimeTicks", "Unsigned32", "Integer32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
pysnmp = ModuleIdentity((1, 3, 6, 1, 4, 1, 20408))
pysnmp.setRevisions(('2017-04-14 00:00', '2005-05-14 00:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: pysnmp.setRevisionsDescriptions(('Updated addresses', 'Initial revision',))
if mibBuilder.loadTexts: pysnmp.setLastUpdated('201704140000Z')
if mibBuilder.loadTexts: pysnmp.setOrganization('The PySNMP Project')
if mibBuilder.loadTexts: pysnmp.setContactInfo('E-mail: Ilya Etingof <etingof@gmail.com> GitHub: https://github.com/etingof/pysnmp')
if mibBuilder.loadTexts: pysnmp.setDescription('PySNMP top-level MIB tree infrastructure')
pysnmpObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 1))
pysnmpExamples = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 2))
pysnmpEnumerations = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3))
pysnmpModuleIDs = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 1))
pysnmpAgentOIDs = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 2))
pysnmpDomains = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 3, 3))
pysnmpExperimental = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 9999))
pysnmpNotificationPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 4))
pysnmpNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 4, 0))
pysnmpNotificationObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 4, 1))
pysnmpConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 5))
pysnmpCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 5, 1))
pysnmpGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 20408, 5, 2))
mibBuilder.exportSymbols("PYSNMP-MIB", pysnmpNotifications=pysnmpNotifications, pysnmpObjects=pysnmpObjects, pysnmpGroups=pysnmpGroups, pysnmp=pysnmp, pysnmpNotificationObjects=pysnmpNotificationObjects, pysnmpExamples=pysnmpExamples, pysnmpCompliances=pysnmpCompliances, PYSNMP_MODULE_ID=pysnmp, pysnmpNotificationPrefix=pysnmpNotificationPrefix, pysnmpEnumerations=pysnmpEnumerations, pysnmpModuleIDs=pysnmpModuleIDs, pysnmpAgentOIDs=pysnmpAgentOIDs, pysnmpConformance=pysnmpConformance, pysnmpExperimental=pysnmpExperimental, pysnmpDomains=pysnmpDomains)
| (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(constraints_intersection, value_range_constraint, constraints_union, value_size_constraint, single_value_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ConstraintsIntersection', 'ValueRangeConstraint', 'ConstraintsUnion', 'ValueSizeConstraint', 'SingleValueConstraint')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(mib_scalar, mib_table, mib_table_row, mib_table_column, gauge32, bits, notification_type, enterprises, ip_address, counter64, mib_identifier, object_identity, module_identity, counter32, iso, time_ticks, unsigned32, integer32) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Gauge32', 'Bits', 'NotificationType', 'enterprises', 'IpAddress', 'Counter64', 'MibIdentifier', 'ObjectIdentity', 'ModuleIdentity', 'Counter32', 'iso', 'TimeTicks', 'Unsigned32', 'Integer32')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
pysnmp = module_identity((1, 3, 6, 1, 4, 1, 20408))
pysnmp.setRevisions(('2017-04-14 00:00', '2005-05-14 00:00'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
pysnmp.setRevisionsDescriptions(('Updated addresses', 'Initial revision'))
if mibBuilder.loadTexts:
pysnmp.setLastUpdated('201704140000Z')
if mibBuilder.loadTexts:
pysnmp.setOrganization('The PySNMP Project')
if mibBuilder.loadTexts:
pysnmp.setContactInfo('E-mail: Ilya Etingof <etingof@gmail.com> GitHub: https://github.com/etingof/pysnmp')
if mibBuilder.loadTexts:
pysnmp.setDescription('PySNMP top-level MIB tree infrastructure')
pysnmp_objects = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 1))
pysnmp_examples = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 2))
pysnmp_enumerations = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 3))
pysnmp_module_i_ds = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 3, 1))
pysnmp_agent_oi_ds = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 3, 2))
pysnmp_domains = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 3, 3))
pysnmp_experimental = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 9999))
pysnmp_notification_prefix = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 4))
pysnmp_notifications = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 4, 0))
pysnmp_notification_objects = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 4, 1))
pysnmp_conformance = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 5))
pysnmp_compliances = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 5, 1))
pysnmp_groups = mib_identifier((1, 3, 6, 1, 4, 1, 20408, 5, 2))
mibBuilder.exportSymbols('PYSNMP-MIB', pysnmpNotifications=pysnmpNotifications, pysnmpObjects=pysnmpObjects, pysnmpGroups=pysnmpGroups, pysnmp=pysnmp, pysnmpNotificationObjects=pysnmpNotificationObjects, pysnmpExamples=pysnmpExamples, pysnmpCompliances=pysnmpCompliances, PYSNMP_MODULE_ID=pysnmp, pysnmpNotificationPrefix=pysnmpNotificationPrefix, pysnmpEnumerations=pysnmpEnumerations, pysnmpModuleIDs=pysnmpModuleIDs, pysnmpAgentOIDs=pysnmpAgentOIDs, pysnmpConformance=pysnmpConformance, pysnmpExperimental=pysnmpExperimental, pysnmpDomains=pysnmpDomains) |
def uniform_cost_search(graph, start, goal):
path = []
explored_nodes = list()
if start == goal:
return path, explored_nodes
path.append(start)
path_cost = 0
frontier = [(path_cost, path)]
while len(frontier) > 0:
path_cost_till_now, path_till_now = pop_frontier(frontier)
current_node = path_till_now[-1]
explored_nodes.append(current_node)
if current_node == goal:
return path_till_now, explored_nodes
neighbours = graph[current_node]
neighbours_list_int = [int(n) for n in neighbours]
neighbours_list_int.sort(reverse=False)
neighbours_list_str = [str(n) for n in neighbours_list_int]
for neighbour in neighbours_list_str:
path_to_neighbour = path_till_now.copy()
path_to_neighbour.append(neighbour)
extra_cost = 1
neighbour_cost = extra_cost + path_cost_till_now
new_element = (neighbour_cost, path_to_neighbour)
is_there, indexx, neighbour_old_cost, _ = get_frontier_params_new(neighbour, frontier)
if (neighbour not in explored_nodes) and not is_there:
frontier.append(new_element)
elif is_there:
if neighbour_old_cost > neighbour_cost:
frontier.pop(indexx)
frontier.append(new_element)
return None, None
| def uniform_cost_search(graph, start, goal):
path = []
explored_nodes = list()
if start == goal:
return (path, explored_nodes)
path.append(start)
path_cost = 0
frontier = [(path_cost, path)]
while len(frontier) > 0:
(path_cost_till_now, path_till_now) = pop_frontier(frontier)
current_node = path_till_now[-1]
explored_nodes.append(current_node)
if current_node == goal:
return (path_till_now, explored_nodes)
neighbours = graph[current_node]
neighbours_list_int = [int(n) for n in neighbours]
neighbours_list_int.sort(reverse=False)
neighbours_list_str = [str(n) for n in neighbours_list_int]
for neighbour in neighbours_list_str:
path_to_neighbour = path_till_now.copy()
path_to_neighbour.append(neighbour)
extra_cost = 1
neighbour_cost = extra_cost + path_cost_till_now
new_element = (neighbour_cost, path_to_neighbour)
(is_there, indexx, neighbour_old_cost, _) = get_frontier_params_new(neighbour, frontier)
if neighbour not in explored_nodes and (not is_there):
frontier.append(new_element)
elif is_there:
if neighbour_old_cost > neighbour_cost:
frontier.pop(indexx)
frontier.append(new_element)
return (None, None) |
def fibonacci(n):
seznam = []
(a, b) = (0, 1)
for i in range(n):
(a, b) = (b, a+b)
seznam.append(a)
return [a, seznam]
def stevke(stevilo):
n = 1
while n > 0: #nevem kako naj bolje napisem
if fibonacci(n)[0] > 10 ** (stevilo -1):
return fibonacci(n)[1].index(fibonacci(n)[0]) + 1
n = n + 1
print(stevke(1000)) | def fibonacci(n):
seznam = []
(a, b) = (0, 1)
for i in range(n):
(a, b) = (b, a + b)
seznam.append(a)
return [a, seznam]
def stevke(stevilo):
n = 1
while n > 0:
if fibonacci(n)[0] > 10 ** (stevilo - 1):
return fibonacci(n)[1].index(fibonacci(n)[0]) + 1
n = n + 1
print(stevke(1000)) |
spam = 42 # global variable
def printSpam():
print('Spam = ' + str(spam))
def eggs():
spam = 42 # local variable
return spam
print('example xyz')
def Spam():
eggs = 99
bacon()
print(eggs)
def bacon():
ham = 101
eggs = 0
def assignSpam(var):
global spam
spam = var
Spam()
printSpam()
assignSpam(25)
printSpam() | spam = 42
def print_spam():
print('Spam = ' + str(spam))
def eggs():
spam = 42
return spam
print('example xyz')
def spam():
eggs = 99
bacon()
print(eggs)
def bacon():
ham = 101
eggs = 0
def assign_spam(var):
global spam
spam = var
spam()
print_spam()
assign_spam(25)
print_spam() |
n = int(input().strip())
ar = list(map(int, input().strip().split(' ')))
print (ar.count(max(ar)))
#https://www.hackerrank.com/challenges/birthday-cake-candles/problem | n = int(input().strip())
ar = list(map(int, input().strip().split(' ')))
print(ar.count(max(ar))) |
class Project:
def __init__(self, id=None, name=None, description=None):
self.id = id
self.name = name
self.description = description
def __repr__(self):
return "%s: %s, %s" % (self.id, self.name, self.description)
def __eq__(self, other):
return self.id == other.id and self.name == other.name
def __lt__(self, other):
return int(self.id) < int(other.id)
| class Project:
def __init__(self, id=None, name=None, description=None):
self.id = id
self.name = name
self.description = description
def __repr__(self):
return '%s: %s, %s' % (self.id, self.name, self.description)
def __eq__(self, other):
return self.id == other.id and self.name == other.name
def __lt__(self, other):
return int(self.id) < int(other.id) |
class Service:
def __init__(self, name):
self.name = name
self.methods = {}
def rpc(self, func_name):
def decorator(func):
self._save_method(func_name, func)
return func
if isinstance(func_name, str):
return decorator
func = func_name
func_name = func.__name__
return decorator(func)
def _save_method(self, method: str, func):
self.methods[method] = func.__name__
def get_methods(self, obj):
methods = {}
for method, func_name in self.methods.items():
func = getattr(obj, func_name)
methods[method] = func
return methods
| class Service:
def __init__(self, name):
self.name = name
self.methods = {}
def rpc(self, func_name):
def decorator(func):
self._save_method(func_name, func)
return func
if isinstance(func_name, str):
return decorator
func = func_name
func_name = func.__name__
return decorator(func)
def _save_method(self, method: str, func):
self.methods[method] = func.__name__
def get_methods(self, obj):
methods = {}
for (method, func_name) in self.methods.items():
func = getattr(obj, func_name)
methods[method] = func
return methods |
def prime_factors(strs):
result = []
float=2
while float:
if strs%float==0:
strs = strs / float
result.append(float)
else:
float = float+1
if float>strs:
break
return result
| def prime_factors(strs):
result = []
float = 2
while float:
if strs % float == 0:
strs = strs / float
result.append(float)
else:
float = float + 1
if float > strs:
break
return result |
'''
Steven Kyritsis CS100
2021F Section 031 HW 10,
November 12, 2021
'''
#3
def shareoneletter(wordlist):
d={}
for w in wordlist:
d[w]=[]
for i in wordlist:
match=False
for c in w:
if c in i:
match=True
if match and i not in d[w]:
d[w].append(i)
return d
print(shareoneletter(['I', 'say', 'what', 'I', 'mean', 'and', 'I', 'mean', 'what', 'I', 'say']))
| """
Steven Kyritsis CS100
2021F Section 031 HW 10,
November 12, 2021
"""
def shareoneletter(wordlist):
d = {}
for w in wordlist:
d[w] = []
for i in wordlist:
match = False
for c in w:
if c in i:
match = True
if match and i not in d[w]:
d[w].append(i)
return d
print(shareoneletter(['I', 'say', 'what', 'I', 'mean', 'and', 'I', 'mean', 'what', 'I', 'say'])) |
# A server used to store and retrieve arbitrary data.
# This is used by: ./dispatcher.js
def main(request, response):
response.headers.set(b'Access-Control-Allow-Origin', b'*')
response.headers.set(b'Access-Control-Allow-Methods', b'OPTIONS, GET, POST')
response.headers.set(b'Access-Control-Allow-Headers', b'Content-Type')
response.headers.set(b'Cache-Control', b'no-cache, no-store, must-revalidate')
if request.method == u'OPTIONS': # CORS preflight
return b''
uuid = request.GET[b'uuid']
stash = request.server.stash;
with stash.lock:
queue = stash.take(uuid)
if queue is None:
queue = []
if request.method == u'POST':
queue.append(request.body)
ret = b'done'
else:
if len(queue) == 0:
ret = b'not ready'
else:
ret = queue.pop(0)
stash.put(uuid, queue)
return ret;
| def main(request, response):
response.headers.set(b'Access-Control-Allow-Origin', b'*')
response.headers.set(b'Access-Control-Allow-Methods', b'OPTIONS, GET, POST')
response.headers.set(b'Access-Control-Allow-Headers', b'Content-Type')
response.headers.set(b'Cache-Control', b'no-cache, no-store, must-revalidate')
if request.method == u'OPTIONS':
return b''
uuid = request.GET[b'uuid']
stash = request.server.stash
with stash.lock:
queue = stash.take(uuid)
if queue is None:
queue = []
if request.method == u'POST':
queue.append(request.body)
ret = b'done'
elif len(queue) == 0:
ret = b'not ready'
else:
ret = queue.pop(0)
stash.put(uuid, queue)
return ret |
clarify_boosted = {
'abita cove': ["cooked cod"],
'the red city': ["baked potatoes", "carrots", "iron ingot"],
'claybound': ["cooked salmon"]
}
aliases = {
'Quartz': 'Quartz Crystal',
'Potatoes': 'Baked Potatoes',
'Nether Wart': 'Nether Wart Block'
}
| clarify_boosted = {'abita cove': ['cooked cod'], 'the red city': ['baked potatoes', 'carrots', 'iron ingot'], 'claybound': ['cooked salmon']}
aliases = {'Quartz': 'Quartz Crystal', 'Potatoes': 'Baked Potatoes', 'Nether Wart': 'Nether Wart Block'} |
while True:
linha = input("Digite qualquer coisa ou \"fim\" para terminar: ")
if linha == "fim":
break
print(linha)
print("Fim!")
| while True:
linha = input('Digite qualquer coisa ou "fim" para terminar: ')
if linha == 'fim':
break
print(linha)
print('Fim!') |
phrase = input('Enter a phrase: ')
for c in phrase:
if c in 'aeoiuAEOIU':
print(c) | phrase = input('Enter a phrase: ')
for c in phrase:
if c in 'aeoiuAEOIU':
print(c) |
# author Mahmud Ahsan
# --------------------
# msmath module under mspack package
# --------------------
def sum(x, y):
return x + y
def subtract(x, y):
return x - y
def multiplication(x, y):
return x * y
def division(x, y):
return x / y | def sum(x, y):
return x + y
def subtract(x, y):
return x - y
def multiplication(x, y):
return x * y
def division(x, y):
return x / y |
rows=input()
rows=int(rows)
k=0
matrixList=[]; evenMatrix=[]
while rows!=0:
matrix=input()
matrix=matrix.split(", "); matrix=[int(e) for e in matrix]
e=0; elements=len(matrix)
matrixList.append([])
while e < elements:
matrixList[k].append(matrix[0])
del matrix[0]
e += 1
rows-=1; k+=1
for k in matrixList:
evenMatrix.append([])
for j in k:
if j%2==0:
evenMatrix[len(evenMatrix)-1].append(j)
print(evenMatrix) | rows = input()
rows = int(rows)
k = 0
matrix_list = []
even_matrix = []
while rows != 0:
matrix = input()
matrix = matrix.split(', ')
matrix = [int(e) for e in matrix]
e = 0
elements = len(matrix)
matrixList.append([])
while e < elements:
matrixList[k].append(matrix[0])
del matrix[0]
e += 1
rows -= 1
k += 1
for k in matrixList:
evenMatrix.append([])
for j in k:
if j % 2 == 0:
evenMatrix[len(evenMatrix) - 1].append(j)
print(evenMatrix) |
def profitable_gamble(prob, prize, pay):
if prob * prize > pay:
return True
return False
print(profitable_gamble(4,8,12)) | def profitable_gamble(prob, prize, pay):
if prob * prize > pay:
return True
return False
print(profitable_gamble(4, 8, 12)) |
#addition.py
def add(a,b):
return a+b
a=int(input("Enter the a value"))
b= int(input("Enter the b value"))
c=add(a,b)
print(c) | def add(a, b):
return a + b
a = int(input('Enter the a value'))
b = int(input('Enter the b value'))
c = add(a, b)
print(c) |
class Block:
def __init__(self):
self.statements = []
def add_statement(self, statement):
self.statements.append(statement)
| class Block:
def __init__(self):
self.statements = []
def add_statement(self, statement):
self.statements.append(statement) |
# TODO: Just change this to CSS
colors = {
"text" : "#aaaaaa",
"background" : "#222221",
"plot_background" : "#222221",
"plot_gridlines" : "#777776",
"page_background" : "#222221"
} | colors = {'text': '#aaaaaa', 'background': '#222221', 'plot_background': '#222221', 'plot_gridlines': '#777776', 'page_background': '#222221'} |
clang_env = {
"ASAN_SYMBOLIZER_PATH": "/usr/local/bin/llvm-symbolizer",
"CC": "/usr/local/bin/clang",
"GCOV": "/dev/null",
"LD_LIBRARY_PATH": "/usr/local/lib",
"MSAN_SYMBOLIZER_PATH": "/usr/local/bin/llvm-symbolizer",
"TSAN_SYMBOLIZER_PATH": "/usr/local/bin/llvm-symbolizer",
"UBSAN_SYMBOLIZER_PATH": "/usr/local/bin/llvm-symbolizer",
}
| clang_env = {'ASAN_SYMBOLIZER_PATH': '/usr/local/bin/llvm-symbolizer', 'CC': '/usr/local/bin/clang', 'GCOV': '/dev/null', 'LD_LIBRARY_PATH': '/usr/local/lib', 'MSAN_SYMBOLIZER_PATH': '/usr/local/bin/llvm-symbolizer', 'TSAN_SYMBOLIZER_PATH': '/usr/local/bin/llvm-symbolizer', 'UBSAN_SYMBOLIZER_PATH': '/usr/local/bin/llvm-symbolizer'} |
# Task 03. Special Numbers
num = int(input())
digits = [x for x in range(1,num+1)]
is_special = False
for digit in digits:
digit_iter = [int(x) for x in str(digit)]
if sum(digit_iter) == 5 or sum(digit_iter) == 7 or sum(digit_iter) == 11:
is_special = True
else:
is_special = False
print(f'{digit} -> {is_special}')
| num = int(input())
digits = [x for x in range(1, num + 1)]
is_special = False
for digit in digits:
digit_iter = [int(x) for x in str(digit)]
if sum(digit_iter) == 5 or sum(digit_iter) == 7 or sum(digit_iter) == 11:
is_special = True
else:
is_special = False
print(f'{digit} -> {is_special}') |
__version__ = '0.11.2'
# import importlib
# import logging
# from pathlib import Path
# importlib.reload(logging)
# logpath = Path.home() / 'p4reduction.log'
# logging.basicConfig(filename=str(logpath), filemode='w',
# format='%(asctime)s %(levelname)s: %(message)s',
# datefmt='%Y-%m-%d %H:%M:%S')
| __version__ = '0.11.2' |
def binario(n):
num = []
while(n>1):
if(n==2 or n==3):
resto = n % 2
n //= 2
num.append(resto)
num.append(n)
else:
resto = n % 2
n //= 2
num.append(resto)
return num
n = int(input('digite um numero: '))
num = []
bin = 0
if(n > 1):
num = binario(n)
i = len(num)-1
while(i>-1):
bin+= num[i]*10**i
i-=1
else:
bin = n
print('numero: {} em binario = {}'.format(n,bin)) | def binario(n):
num = []
while n > 1:
if n == 2 or n == 3:
resto = n % 2
n //= 2
num.append(resto)
num.append(n)
else:
resto = n % 2
n //= 2
num.append(resto)
return num
n = int(input('digite um numero: '))
num = []
bin = 0
if n > 1:
num = binario(n)
i = len(num) - 1
while i > -1:
bin += num[i] * 10 ** i
i -= 1
else:
bin = n
print('numero: {} em binario = {}'.format(n, bin)) |
#
#
# Package libApp in directory source
#
#
print("Loaded libApp")
#
# This file can be left empty, but its presence informs the import mechanism
#
| print('Loaded libApp') |
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright: (c) 2015, Corwin Brown <corwin@corwinbrown.com>
# Copyright: (c) 2017, Dag Wieers (@dagwieers) <dag@wieers.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = r'''
---
module: win_uri
version_added: '2.1'
short_description: Interacts with webservices
description:
- Interacts with FTP, HTTP and HTTPS web services.
- Supports Digest, Basic and WSSE HTTP authentication mechanisms.
- For non-Windows targets, use the M(uri) module instead.
options:
url:
description:
- Supports FTP, HTTP or HTTPS URLs in the form of (ftp|http|https)://host.domain:port/path.
type: str
required: yes
method:
description:
- The HTTP Method of the request or response.
type: str
default: GET
content_type:
description:
- Sets the "Content-Type" header.
type: str
body:
description:
- The body of the HTTP request/response to the web service.
type: raw
dest:
description:
- Output the response body to a file.
type: path
version_added: '2.3'
creates:
description:
- A filename, when it already exists, this step will be skipped.
type: path
version_added: '2.4'
removes:
description:
- A filename, when it does not exist, this step will be skipped.
type: path
version_added: '2.4'
return_content:
description:
- Whether or not to return the body of the response as a "content" key in
the dictionary result. If the reported Content-type is
"application/json", then the JSON is additionally loaded into a key
called C(json) in the dictionary results.
type: bool
default: no
version_added: '2.4'
status_code:
description:
- A valid, numeric, HTTP status code that signifies success of the request.
- Can also be comma separated list of status codes.
type: list
default: [ 200 ]
version_added: '2.4'
url_username:
description:
- The username to use for authentication.
- Was originally called I(user) but was changed to I(url_username) in
Ansible 2.9.
version_added: "2.4"
url_password:
description:
- The password for I(url_username).
- Was originally called I(password) but was changed to I(url_password) in
Ansible 2.9.
version_added: "2.4"
follow_redirects:
version_added: "2.4"
maximum_redirection:
version_added: "2.4"
client_cert:
version_added: "2.4"
client_cert_password:
version_added: "2.5"
use_proxy:
version_added: "2.9"
proxy_url:
version_added: "2.9"
proxy_username:
version_added: "2.9"
proxy_password:
version_added: "2.9"
extends_documentation_fragment:
- url_windows
seealso:
- module: uri
- module: win_get_url
author:
- Corwin Brown (@blakfeld)
- Dag Wieers (@dagwieers)
'''
EXAMPLES = r'''
- name: Perform a GET and Store Output
win_uri:
url: http://example.com/endpoint
register: http_output
# Set a HOST header to hit an internal webserver:
- name: Hit a Specific Host on the Server
win_uri:
url: http://example.com/
method: GET
headers:
host: www.somesite.com
- name: Perform a HEAD on an Endpoint
win_uri:
url: http://www.example.com/
method: HEAD
- name: POST a Body to an Endpoint
win_uri:
url: http://www.somesite.com/
method: POST
body: "{ 'some': 'json' }"
'''
RETURN = r'''
elapsed:
description: The number of seconds that elapsed while performing the download.
returned: always
type: float
sample: 23.2
url:
description: The Target URL.
returned: always
type: str
sample: https://www.ansible.com
status_code:
description: The HTTP Status Code of the response.
returned: success
type: int
sample: 200
status_description:
description: A summary of the status.
returned: success
type: str
sample: OK
content:
description: The raw content of the HTTP response.
returned: success and return_content is True
type: str
sample: '{"foo": "bar"}'
content_length:
description: The byte size of the response.
returned: success
type: int
sample: 54447
json:
description: The json structure returned under content as a dictionary.
returned: success and Content-Type is "application/json" or "application/javascript" and return_content is True
type: dict
sample: {"this-is-dependent": "on the actual return content"}
'''
| ansible_metadata = {'metadata_version': '1.1', 'status': ['preview'], 'supported_by': 'community'}
documentation = '\n---\nmodule: win_uri\nversion_added: \'2.1\'\nshort_description: Interacts with webservices\ndescription:\n- Interacts with FTP, HTTP and HTTPS web services.\n- Supports Digest, Basic and WSSE HTTP authentication mechanisms.\n- For non-Windows targets, use the M(uri) module instead.\noptions:\n url:\n description:\n - Supports FTP, HTTP or HTTPS URLs in the form of (ftp|http|https)://host.domain:port/path.\n type: str\n required: yes\n method:\n description:\n - The HTTP Method of the request or response.\n type: str\n default: GET\n content_type:\n description:\n - Sets the "Content-Type" header.\n type: str\n body:\n description:\n - The body of the HTTP request/response to the web service.\n type: raw\n dest:\n description:\n - Output the response body to a file.\n type: path\n version_added: \'2.3\'\n creates:\n description:\n - A filename, when it already exists, this step will be skipped.\n type: path\n version_added: \'2.4\'\n removes:\n description:\n - A filename, when it does not exist, this step will be skipped.\n type: path\n version_added: \'2.4\'\n return_content:\n description:\n - Whether or not to return the body of the response as a "content" key in\n the dictionary result. If the reported Content-type is\n "application/json", then the JSON is additionally loaded into a key\n called C(json) in the dictionary results.\n type: bool\n default: no\n version_added: \'2.4\'\n status_code:\n description:\n - A valid, numeric, HTTP status code that signifies success of the request.\n - Can also be comma separated list of status codes.\n type: list\n default: [ 200 ]\n version_added: \'2.4\'\n url_username:\n description:\n - The username to use for authentication.\n - Was originally called I(user) but was changed to I(url_username) in\n Ansible 2.9.\n version_added: "2.4"\n url_password:\n description:\n - The password for I(url_username).\n - Was originally called I(password) but was changed to I(url_password) in\n Ansible 2.9.\n version_added: "2.4"\n follow_redirects:\n version_added: "2.4"\n maximum_redirection:\n version_added: "2.4"\n client_cert:\n version_added: "2.4"\n client_cert_password:\n version_added: "2.5"\n use_proxy:\n version_added: "2.9"\n proxy_url:\n version_added: "2.9"\n proxy_username:\n version_added: "2.9"\n proxy_password:\n version_added: "2.9"\nextends_documentation_fragment:\n- url_windows\nseealso:\n- module: uri\n- module: win_get_url\nauthor:\n- Corwin Brown (@blakfeld)\n- Dag Wieers (@dagwieers)\n'
examples = '\n- name: Perform a GET and Store Output\n win_uri:\n url: http://example.com/endpoint\n register: http_output\n\n# Set a HOST header to hit an internal webserver:\n- name: Hit a Specific Host on the Server\n win_uri:\n url: http://example.com/\n method: GET\n headers:\n host: www.somesite.com\n\n- name: Perform a HEAD on an Endpoint\n win_uri:\n url: http://www.example.com/\n method: HEAD\n\n- name: POST a Body to an Endpoint\n win_uri:\n url: http://www.somesite.com/\n method: POST\n body: "{ \'some\': \'json\' }"\n'
return = '\nelapsed:\n description: The number of seconds that elapsed while performing the download.\n returned: always\n type: float\n sample: 23.2\nurl:\n description: The Target URL.\n returned: always\n type: str\n sample: https://www.ansible.com\nstatus_code:\n description: The HTTP Status Code of the response.\n returned: success\n type: int\n sample: 200\nstatus_description:\n description: A summary of the status.\n returned: success\n type: str\n sample: OK\ncontent:\n description: The raw content of the HTTP response.\n returned: success and return_content is True\n type: str\n sample: \'{"foo": "bar"}\'\ncontent_length:\n description: The byte size of the response.\n returned: success\n type: int\n sample: 54447\njson:\n description: The json structure returned under content as a dictionary.\n returned: success and Content-Type is "application/json" or "application/javascript" and return_content is True\n type: dict\n sample: {"this-is-dependent": "on the actual return content"}\n' |
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email@example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '', # Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Detroit'
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Make this unique, and don't share it with anybody.
SECRET_KEY = 't76+zh&*@(p*l3y50$f^el8q79o7gytx)64@uwt280hf=+)x1('
| debug = True
template_debug = DEBUG
admins = ()
managers = ADMINS
databases = {'default': {'ENGINE': 'django.db.backends.', 'NAME': '', 'USER': '', 'PASSWORD': '', 'HOST': '', 'PORT': ''}}
time_zone = 'America/Detroit'
media_root = ''
media_url = ''
static_root = ''
static_url = '/static/'
secret_key = 't76+zh&*@(p*l3y50$f^el8q79o7gytx)64@uwt280hf=+)x1(' |
VERSION = "3.6.dev1"
SERIES = '.'.join(VERSION.split('.')[:2])
| version = '3.6.dev1'
series = '.'.join(VERSION.split('.')[:2]) |
cookie = {
'ipb_member_id': '',
'ipb_pass_hash': '',
'igneous': '',
} | cookie = {'ipb_member_id': '', 'ipb_pass_hash': '', 'igneous': ''} |
class UserTarget:
@staticmethod
def get_response():
return "Response by UserTarget"
| class Usertarget:
@staticmethod
def get_response():
return 'Response by UserTarget' |
class ATM:
def __init__(self, balance, bank_name):
self.balance = balance
self.bank_name = bank_name
self.withdrawals_list = []
def calcul(self,request):
self.withdrawals_list.append(request)
self.balance -= request
notes =[100,50,10,5]
for note in notes :
while request >= note :
request-=note
print("give ", str(note))
if request < 5:
print("give " + str(request))
request = 0
return self.balance
def withdraw(self, request):
print("the name of bank is :",self.bank_name)
print("the balance is",self.balance)
if request > self.balance:
print("Can't give you all this money !!")
elif request < 0:
print("More than zero plz!")
else:
self.calcul(request)
def show_withdrawals(self):
for withdrawal in self.withdrawals_list:
print(withdrawal)
balance1=500
balance2=1000
atm1=ATM(balance1,"smart_bank")
atm2=ATM(balance2,"baraka_bank")
atm1.withdraw(700)
atm1.withdraw(300)
print("the rest of balance for smart bank are",atm1.balance)
atm2.withdraw(500)
print("the rest of balance for baraka bank are",atm2.balance)
atm2.withdraw(257)
print("the rest of balance for baraka bank are",atm2.balance)
atm2.show_withdrawals()
| class Atm:
def __init__(self, balance, bank_name):
self.balance = balance
self.bank_name = bank_name
self.withdrawals_list = []
def calcul(self, request):
self.withdrawals_list.append(request)
self.balance -= request
notes = [100, 50, 10, 5]
for note in notes:
while request >= note:
request -= note
print('give ', str(note))
if request < 5:
print('give ' + str(request))
request = 0
return self.balance
def withdraw(self, request):
print('the name of bank is :', self.bank_name)
print('the balance is', self.balance)
if request > self.balance:
print("Can't give you all this money !!")
elif request < 0:
print('More than zero plz!')
else:
self.calcul(request)
def show_withdrawals(self):
for withdrawal in self.withdrawals_list:
print(withdrawal)
balance1 = 500
balance2 = 1000
atm1 = atm(balance1, 'smart_bank')
atm2 = atm(balance2, 'baraka_bank')
atm1.withdraw(700)
atm1.withdraw(300)
print('the rest of balance for smart bank are', atm1.balance)
atm2.withdraw(500)
print('the rest of balance for baraka bank are', atm2.balance)
atm2.withdraw(257)
print('the rest of balance for baraka bank are', atm2.balance)
atm2.show_withdrawals() |
#
# @lc app=leetcode id=53 lang=python3
#
# [53] Maximum Subarray
#
class Solution:
def maxSubArray(self, nums: List[int]) -> int:
if all([x < 0 for x in nums]):
return max(nums)
running_sum = 0
ans = 0
for x in nums:
running_sum += x
if running_sum < 0:
running_sum = 0
continue
if ans < running_sum:
ans = running_sum
return ans
| class Solution:
def max_sub_array(self, nums: List[int]) -> int:
if all([x < 0 for x in nums]):
return max(nums)
running_sum = 0
ans = 0
for x in nums:
running_sum += x
if running_sum < 0:
running_sum = 0
continue
if ans < running_sum:
ans = running_sum
return ans |
# flake8: NOQA: E501
# This proves that the given key (which is an account) exists on the trie rooted at this state
# root. It was obtained by querying geth via the LES protocol
state_root = b'Gu\xd8\x85\xf5/\x83:e\xf5\x9e0\x0b\xce\x86J\xcc\xe4.0\xc8#\xdaW\xb3\xbd\xd0).\x91\x17\xe8'
key = b'\x9b\xbf\xc3\x08Z\xd0\xd47\x84\xe6\xe4S4ndG|\xac\xa3\x0f^7\xd5nv\x14\x9e\x98\x84\xe7\xc2\x97'
proof = ([b'\x01\xb2\xcf/\xa7&\xef{\xec9c%\xed\xeb\x9b)\xe9n\xb5\xd5\x0e\x8c\xa9A\xc1:-{<2$)', b'\xa2\xbab\xe5J\x88\xa1\x8b\x90y\xa5yW\xd7G\x13\x16\xec\xb3\xb6\x87S9okV\xa3\rlC\xbfU', b'\xd6\x06\x92\x9e\x0b\xd310|\xbeV\x9d\xb4r\xdf0\xa5Q\xfb\xec\xb9I\x8c\x96r\x81\xeb\xefX7_l', b'\xa8\x88\xed@\x04\x7f\xa6\xbe&\x89&\x89T\t+\xac\xb8w\x8a\xebn\x16\x0c\xe1n\xb4?\xad\x14\xfdF\xff', b'\xc9\t\xd0\xaa\xb0:P\xdc\xea\xedX%\x04\x9a\xbe\x1f\x16\x0cf\xbc\x04P#@\xfd\xd60\xad\xecK\x8b\x08', b'x\xff\xb2\x9ajO\xbc\x1bjR\x80$I\xe6\x95\xf6Tow\x82\xf9\x01\xa8V\xa9\xaa4\xa6`\x88\xf9\x10', b'I\x1cQc\x8a\xeda\xf8\xd1D\x01GT)\xc9\x02O\xef\x8d\xcc\\\xf9\xe6}\x8a~\xcc\x98~\xd5\xd6\xb6', b"U'\xa2\xa0 \xe4\xb1\xb6\xc3\xcd4C_\x9c]\xb3P\xa8w\xef\x8c\xde\xc2\x02^v\xcd\x12\xed%\x89\xa5", b'(\xa6x\xfa\xbe\xc3\x9a\xae\xaa\xe9\xbcv#u\\\xdfo\x14\x9a3\xbc\x89c\xc1\xfe\xdf[{|\x02P\x03', b'\xcf5\x07\x8f3\xa9\x1f\x19Q\xbb\x11\x8a\xb0\x97\xbe\x93\xb2\xd5~\xe2\xe06\x07\xc37\x08vg\x80 BD', b'U\x8e/\x95&\n\xc5\xf1\xd4\xc3\xb9\xa84Rd\xaa\x80\xfe8\xf1\xcf G\xcc\xe3\x99\x01\x07\xceH\x9a`', b'W\x1f\xb5\x1c\xec\xf7\x0b\x86\x15\r\xf9\xf9\x94\xcd|\xe6B\x9f\xa8l\x8d]D\xf7\xba\xee:\xc0\\\x11\xb8\x08', b'\xf5i\xee)\xc4\xd24\xfc\x8f\xba\xc0vS\x1dU>\xccz\xd18\n\xa2+\n\xcf\xe2i*\xee\x18\xe8\xc1', b'\x9dmSX\x1e\xee\xf7`\x1d\x0cO\xfcF\xe4\xbd\x0cE2\x10H6\xf0\x93|\xd5z\xe7=\xebbJ\xd6', b'u\x08\x92\x08\xa5Nl\x938\x03\xa3\xe2O\xe8\xfe\xb1\xc4\x87\x8c\xb8q\x9eb\x89b\x96\x98\xd7\xf22\xb9\xa2', b'\xa6V\xb5?\xcc\xd2\xc8*ME\xe7\xcf\xf8\xad\xf8\xdb\xe7\xf8\xf6D\xd5<\x1c\x95F\x13\x0e\x06rz\xe5m', b''], [b"\xb3\x03\xa9\xc11\x87mQ\xa1I2D4jg\xfe\xd0%k\xf2\r]\xb0\x0e\xeb'\x17\xedx\xc9Uj", b'L/\r$7-\xa5\xdf x\x9c\xbc\xc4\x99\x1e\xc5\xd8\xb5\xaf\xd1\xd1\xae\xe6L\xeco\xc4\xe2RUe\r', b'\xbeSp\xf5\xef\x02\xcd\x83\xb2\x0b\xa06\xfd\xca\xbb\xed_\xf2}\xf7\xea\xb3\x84\x17\xed\xcc\x19mF\x13(\xf3', b"\xfb$IYR\x9f\x04p\x01\x1d}\x88\x0b\xed'\x8e%\x9b\xc9\xeaN_\xab\xf9\xc9\x9d\xac\xa9\xb3\t\x1eq", b'\xaab\xeb\x14\xc2\xf6}%\xaa+0\xb5\xc1\x0f< \xc5ma\xb1c\xeb\xdd\xca\xc0\x90\xe2L\x8b\xe9\xfe/', b'\x91l\x9d\xa2\x84\xbf\xc1\x05\xe2S\x0e\xc9`\xc0^}Q!\xc4ml-\xec\xf4R$\xf6\x8a\xd3\xc6\xf1j', b'\xf3\x13\xde\xe0L\xdb\x96E`Q\xdf\xa1\x13\x01b5\xe4k\xde\xde\xbf\xb10\xaf\xe61Z\xdbZ\xd47\xf4', b'\t\x81\xb0\xea*\xec\xd0\xc3\x16\xee\xed~\xdc\x98e\x90\xf2~p\xbbSY\x19\xcfl\xc4)\x01\xc2\xd9\xc91', b'-\xda%\x8a\xc5jA-\xe5 lIp\xbe\xb3h\x98\x0f\x80q\xed\xab\x89KN\xdd\xa6\xcb;\x98\xb08', b'\x13\x97\x12f\xa31\xfa}\xf1\xfe\x19\xfa\x0b\xe6\x89\x9a\xcb\xf5\xed\xf3Q\x98O=\xa3\xb0e/\xd9\x9fy\x08', b'f\xba%\xfb\xbfE\x1d]\xb3\x05\xe4$\xa5\xd2G\xecc\xe5#\x0f,\x91\x8bN9a\x8a\xd1L\x16l\xa5', b'#p\x15\x8bU\x04\x88/K|4a\xfc\x0e.Zm^{\x15uk\x8d\xe4_\xfe\xee\xae\xb99\xd1\x8e', b'C \x9f\xb3y\xf3d.\x8b\t\x1cF\x9eL\x08\x07y\x08\xb9\xe1\xffM\x87\xfd\xd6\xfd\xdb\x8f\x94\x9e\x88\xc2', b'\x17X\x1f/\x8b\x82\xf5\xe4\x02\x84}\xbe\x9bz` \x94\'"_\x9c\xff\x06\t>\x8a\xd7oK\xf9\xf5w', b'6Q\x8db\xd8\\\x84_Rin\x18\x1f\x17\x89\x7f@\xd6\xbb%>\xafa\'\x80A\xa7\xd8}d\x07"', b'\xccgm\xf7\x05\xc8\xe4G\xf4\xb3\x18\xc7\\.\x0b\xa25]\xdc\x80w\xda\xc9;\xde\x9b\x03\xa0LS\xce\x8c', b''], [b'\xe4\xd3\x15\xe0\xaa\x0f\xf9\xd0\xa6\xc2\xc8B_\xaf"0\x8c\xea;\x91\xe4E\x04\xec\x901yZ\xd6>\xadc', b'wM\xce\x16JS:\xe96\x98\x12|\xa0\xc9~G\xbb\xc7u8\xc8\x93\x9b\x05\x92yh\xaa\xda\x94NK', b'\x89\xc7\xa2\xbd\xe1\xda\x06$|\xde\x03\xd9RS\x90\x84\xe7\x05\x0cc\xdfy\xb0\xfb@\x065\xdb8\xa9\xef\x1f', b'@\x11>\xe8\xb8\x19\xb7\xc7@\x92m$\x93 \x08\xc5\x15\xbd\x97\xb0;\xf5\x05q;\xb5\xc69\xd3E\xc4\x0e', b'\xd5_ol\x05o\x8e\xf0V\xd2\xa0n\xe7CxR\xc9\x92HTQhkc\x10K\xad\xfdU\xe9\x97\x8f', b'v\x7f\xc5KB\xdaYS\xa1\xbf \xda\xe2\x99\x84\xef,\x92\xdd\xc9\xb8\x9eo\xfcv(\x95\xff\x94t\xbc5', b"\xcbQ\x962!$\x1f\xdc\xdb\xfe\xef'\xc8\xc8O\xec\xa2\xae\xd3P\x88\xbf\xbd!\xea\x0e\xb0\x89\xe9\xdd\xf3w", b'H\xb8\x1b\xc3&\x86|!o\x003/\xc7K\xc9+,K\xe1y\xf2\x86\xa9*H\x05W\xcd\xf8\x8b\xb5\n', b'\x06\xc5\xa1\x83\xe4\xb4\xdc\xbf\xc0\x8c4Q\x93\x14W\xaf\xbb\xe9f\x82\xa2\x8d\xa3m\xda\xed\xc0W\x88UA\xd9', b'\x9czV\x7f$\xa8\xb9\xf3\xc1W0\x19\xac\xc5\xaap\x03?*\xe6\xd6\xee<\x0b\xafr\xf6ji\xd9\x87\xed', b'\xc7\x1d\xca\x95\xab~\xd3|\xa6\x9f\xba\x9e\xd5KxI\x95Y\xadx\xb8\xda\xa7!\xba\x93\xbbB,\x97n\xe4', b'\xd7"\x13\xca=\xa9|e\x11\x8f%\xb2^\x1b\xa6\xff\x93Z\x8b(\xca\xab\x12\xed\x8b3\x0f\xe0\xa7U\xa9\xe1', b'\xc2\xb4\x98\xb7\x08\x18#i7\x81\x85\xfd\xc3\xc6k\x12\x86\x99\xa55\x0c8\xd3\xbc\x9d\xc8\xe0\xd3\xcd=\xc6x', b'\xad\xf0\xea&\xf4\x8f=5\xe1\xb5b\xc1}\xba\xa1\n \xa4\xb7J2\x1f\xd7\xc9\x1d\xa4\xc2\xaf\xb7O\xb2\x12', b'\xd5~\x94\x99~Vy,4\xedMJ\x1a\xda3\xe7\x90\x91\xd4\xafw\xba\xbf\x89`\x0e\x99s\x93E\xdf%', b'\x82\xd2O\x16\xca{\x15\x87\xef-\x8a\xea\xb9\xcd\xfc\x82\x84\x99\xdco\xc1\x1eg\xf3-\x07\xf8\xa3\xed\xffx\x85', b''], [b"\xc5\xa5\xd38zu\xfc\xe9\xe2j\x97\xf0\x81T$\xee5\x94AC\xb1\x85\x0c\xef\x10\xcb`Z\xfcT'\xcb", b'ZU\xe4?lj\x05\xf8\xbc\xa7\xf1\xe4\xdb\x08M\x06\xad\xbf\xb3s\xfa\xcaS\xb9{U\xd2n\x981+|', b'l\x0cL\xfb\\(g\xb47\xc2<\xcb\x14\xf3\xa9l\x01#\xdb"|\xdc\xfd\xa0#\xa2\x89\xcfx\x97\xb4\x8e', b'\x0b\xe7$\x1d\xa2\x1c\\\xa5)t\xd6\x82\xec\xed\x02]\xdd\xefz\xa3C`\x1b\xda\x81\t\xb3\x14\xdf5\xbb\xcb', b'\xe7%b2\xd4\xc6\x98\x90\xd8:B\xa4\x9e\n\xc6\xa1\x01\xac\x94\xbdr\xca\xdd\x8a\xa8\xe8\xc6F\xed\x04\xe9\x14', b'\xa7\xac\xc0S\xcbo\x98\xebJ)\xb1\x8b{\xda,\x98\xf2M\xca,\xcd\xc4%\x94\xe4\xdc<\xf5o}\x90\x1d', b'[\xd9}F\xe2\n\x84\xbc\xa0\x81\x0f\xb9\x0b]\x0c\x10%\x9d\r\x00RZgbV*2b\xd1z\xb5\xd3', b'\xac\xcag\xdb\xc3y\x91\x82\xddu\xad\x85%g\x82\xa0\r\xf4\x99^=\x14h\xee\xac\x81/o\xe6\xe4\xec\x0c', b'8\xeb\xed\x80}2\xd9.\x0e\xeb\x92\xa7\xae\xeb\x8d\x9b>8<\x9d\xc4\x05\xf2W;F\xce!\t\x15\xb2\xe3', b'*\xed\xbfJ\x80\x9f7\xd1\xcd\xeft\x89.e\x02M\r\x85D-\x9bL\x8d\xac*3h\xf3\x9f\xde\xe0F', b'd\xf9\xdf\xfb\xfa`\x97:\x11\xc4\x89u_\xe9&\xd0LX;r\x12\x86\\,}\x7f:\xbc\xf9\x9a\xd2\xe9', b'\x94\x80\xd4\xb8\xe4\xa6\xd4\x9cS\xcc\xc7*xo]2y~\xd6\x18a\xfb\xafP\x19\x87\xe7:\xb1r\x96\xdc', b'\x1c\xdar\xc1\x18\x1f\x0b\xf3\xe2\xf0\xf1<\x05\x88\xa4\x01J,\xc2\xa1\xbd`L\x8b\x95\xa6\xbdze4&\xc1', b'>0\x01SdF=\x8c\xa7\x1d4\x1elOt\xcd;,|\xf0l\xe9O\x83\xf3\xc0rm\xb6\x82\xaa\x08', b'\xd0\xef\x12\xc5<\\\x00\x82$\x98\x8d\xb6\xa7l\xd6w\xa3\x00<D\x15\xf7\xd6\xc9\xd0\xfb\xd3\x9f\xed,\x9e\xf7', b'\xa6->\xb1\x80jz\xc3\x8a,5\xb8\xf8\xbf\xb4^\x880\x824A\xfa\xbf\x0e\x1f\x9b /\x02\xadhx', b''], [b"\xc1\x17\xa1{\x135'>\xce\x8a\xe8;\x84V\x8c\xfer\xdaZS\xc7v\xd7\x18\xfb\xe3\xbf\xff\x92\x87@D", b'\x06\xb9c\xad\x8d2\xc0WU\xaf"w\xe5>\x1a\xfd\x02\xf1\xdd\x91$h/\x02)\xc6\xd3\xbc\x17\xc42\xe8', b'\xc4\xa2\xb3*k\xa8\xc8\x124\x86\xa0\x9b\xad\xfa\xb9$5?\xc6\x0c]\x98Kb\xd13\xdb:\x85\xed\xe1[', b'%\xa4>aM\x08\xbet\x1b\xc8\xb5\xf2c.9o!\x03G\x99_\n\xef\x93OA^\xabC\x91\xce\x97', b'\xc9T\xc1\xf6\xc8\xbe\xd8h\x86\xfey\x82Evg\xe1zP\x9ct\x98(\x01\xf5\xfc\xf8\xbe\xf6\x1d\xc0\x15\x8e', b'\xd3\xf1\xe6T\xd7"\xba\xdeipC\xe5\xe1\x04\x0e?o\x84\xcb\x1aE\x18\xd0\xa36\x0eC\xc7D>\x12 ', b'\xe0\x06\x0c\xaf\xec\xe3op*j\xcd\x84\xef\x9b\x82a{,\x1c\x98\xba-\x10\xf9\x7f+\xb6\x8a/q,\xeb', b"\x8a'\xeb\x1a\xe8i\x91S\xf3;\xa8[f-\xb02\x01?\xac\xe4Ds\xd8E\xa0\x87\x8a\xec]\x9b?\x9e", b'\xcf\x0cM\xbd\x92\xbbaS\x9d\xd0:\x7f\xfe\xd5\x08\xac\xe4\xb5\x81ga\xc2>\\\x89\x95\x08\xd6C\xf9\xe6\xb7', b'\x9bh\xd3\xb0x\xf0\xfa5\xa6vV\x96_\x16\x9dx\x95B2\xa9\xcem\xc8\xb9\xaf\xb9\xff\n\xae\xc7\x14\x13', b'H\x03\x82\xd6\xbd\x00Z\r\xa03YQ\xa4\xfa\xcdl\xea8g{L\x16\x18\xca\xdb\xb75~\xff\x1b]&', b'A?l1\xbf\x04\xc3Qs\x9b\x08c\xc3|\xf5D6\xa2\x82\xf8\xd3\xf4@\xab\xa0oDx\xc4\xffY*', b'\x0c\xd7U\x880\xa0\xd3\xad\xdd\xda\xdb\x01\xac\x99ya:\xeb\xab8K%\xaf\xc4\xf1G\xd3*\xb7\xae\x01*', b'\xb8s\xab\x0e\xf4\x90\xdb\xce\x0b)l\xb3\x7f\xf1p\xc6&\x0eh\xfb\xc8\xd7\x88`\xcd\xdc\x97-l\xb6L\x82', b'x\xf2\x15\x85\xe9\x01\xd8\xdc\xc5\xbc\xb7\xda\xcd$\xf0\xae\xc9\x01\xcdHZ\xb8)\x97\x11\xff\xcc7\xa5\x98\xb4\xb6', b'\xf3\xb6\xdd\xe9\xb1\x93\x08A\xda\xa39\xfe$\x8dO\n$ Mn"-\'\xa5$F5\xae\xcd>\xa2\x0c', b''], [b'\x82\x8b\x9d\x85\x0b/\x83\xacmb\x07\x89h\xa5\x86R\x8e\xf4\xd9_\x00\t\xeb\xb3>\\@\x11\xecOp\x7f', b'', b'', b'"\xee\xd9\x89<\xc3_\xca\xe9\xed\xc2v\r,\x9e\x10\x1c\x07\xe8E\xbd\x10\x9a\x16_:hk\xb9Om\xf2', b'', b'', b'\x11]i\xb3t6\xabKF\xc0\xa9\x81z&\xdf\x02\xcaRQ\x82\x92\xac\xf1\xf9~\x94\x94tM9\xbe\x1a', b'\xd0dY\xbc\xbe\xe5\xa8\x93\xc8e\xbd\x15\xf8\xb6b\x9a+\xbeh\xeb\x9d\x85\x1f(\xee\xd5\xb2 \xf2\xea\xa1\xf2', b'', b'`\xa8\xcd0:I\xdd\xd7\xa1\xc9W\r\x00\xa6\x1b\x0cM\xbb8\xb0Z\x8b\xe2\x87\x16\x0f\x99U\xf7\xdf\xc4U', b'', b'\xbcR\x17x\x12Y\xf1r\xb9c\xf5\x17#\xcd\xdb\xd5\x1c0\xd2\xda~\x99a\x96\xd5k\xef\x94\x0f\xd0$\xcb', b'!\x16\xaee\xb5H7X\xd5\tA\xb5{\x98\x8f\x12\x0bX\x85K\x184\x04\xcf\x80\x17\xf81V\xbc\xed\x9c', b'\x00\x08C^\xb5\xcfb\xb3\x13\xf0\x95S\x8eyQ\xe8\xdf\x9bI\xfe\xa2\x9c\x91@_\x16\x9d\x82w,u\x86', b'6&\x99Z\xae\xe6r\xab\xec\xb3X\x87\\\x02\x99>\xfa\xebP:\xd5\xd2t\xe2p\xc7\xe2\xe0\x0e\x95\xf9D', b'\xcf\x7f\x99\x9a\x1c\x18\xa6\x9av\xe6\xa2\xd5\xb3E\x8aJ\x18\xa7\x8c\xc0\x07\xda\xe9\x0bi\r\t\x0f\x9b\x06\xf8S', b''], [b'\x07\x83C\xd1X\xdf\xddJ\xd4\xf2\x7f3+\n\x95\xb2\x89\xd2"\x9d\xc5S\xfb\xfc\x9ed\x8d\xd2\xd2\xe5\x99B', b'', b'', b'', b'', b'-m2\x00\xef\x95\xcd\xfe\xf8\x9e\x0b\xbf\xae\xd8\xb4\xd2\xa1*\xfde\xaa\xb1\x8a\xdd\x1d\x07\x03\xc7,<\xe8\xe7', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b''], [b'8Z\xd0\xd47\x84\xe6\xe4S4ndG|\xac\xa3\x0f^7\xd5nv\x14\x9e\x98\x84\xe7\xc2\x97', b'\xf8D\x01\x80\xa0U\xbd\x1daQ\x97{bg,!\xc2uK\xbe\xeb;\x82x\xb2\xe0\xc3\x8e\xdc\xd9I\x84n\xe3b\x8b\xf1\xa0\x1e\x0b*\xd9p\xb3e\xa2\x17\xc4\x0b\xcf5\x82\xcb\xb4\xfc\xc1d-z]\xd7\xa8*\xe1\xe2x\xe0\x10\x12>'])
| state_root = b'Gu\xd8\x85\xf5/\x83:e\xf5\x9e0\x0b\xce\x86J\xcc\xe4.0\xc8#\xdaW\xb3\xbd\xd0).\x91\x17\xe8'
key = b'\x9b\xbf\xc3\x08Z\xd0\xd47\x84\xe6\xe4S4ndG|\xac\xa3\x0f^7\xd5nv\x14\x9e\x98\x84\xe7\xc2\x97'
proof = ([b'\x01\xb2\xcf/\xa7&\xef{\xec9c%\xed\xeb\x9b)\xe9n\xb5\xd5\x0e\x8c\xa9A\xc1:-{<2$)', b'\xa2\xbab\xe5J\x88\xa1\x8b\x90y\xa5yW\xd7G\x13\x16\xec\xb3\xb6\x87S9okV\xa3\rlC\xbfU', b'\xd6\x06\x92\x9e\x0b\xd310|\xbeV\x9d\xb4r\xdf0\xa5Q\xfb\xec\xb9I\x8c\x96r\x81\xeb\xefX7_l', b'\xa8\x88\xed@\x04\x7f\xa6\xbe&\x89&\x89T\t+\xac\xb8w\x8a\xebn\x16\x0c\xe1n\xb4?\xad\x14\xfdF\xff', b'\xc9\t\xd0\xaa\xb0:P\xdc\xea\xedX%\x04\x9a\xbe\x1f\x16\x0cf\xbc\x04P#@\xfd\xd60\xad\xecK\x8b\x08', b'x\xff\xb2\x9ajO\xbc\x1bjR\x80$I\xe6\x95\xf6Tow\x82\xf9\x01\xa8V\xa9\xaa4\xa6`\x88\xf9\x10', b'I\x1cQc\x8a\xeda\xf8\xd1D\x01GT)\xc9\x02O\xef\x8d\xcc\\\xf9\xe6}\x8a~\xcc\x98~\xd5\xd6\xb6', b"U'\xa2\xa0 \xe4\xb1\xb6\xc3\xcd4C_\x9c]\xb3P\xa8w\xef\x8c\xde\xc2\x02^v\xcd\x12\xed%\x89\xa5", b'(\xa6x\xfa\xbe\xc3\x9a\xae\xaa\xe9\xbcv#u\\\xdfo\x14\x9a3\xbc\x89c\xc1\xfe\xdf[{|\x02P\x03', b'\xcf5\x07\x8f3\xa9\x1f\x19Q\xbb\x11\x8a\xb0\x97\xbe\x93\xb2\xd5~\xe2\xe06\x07\xc37\x08vg\x80 BD', b'U\x8e/\x95&\n\xc5\xf1\xd4\xc3\xb9\xa84Rd\xaa\x80\xfe8\xf1\xcf G\xcc\xe3\x99\x01\x07\xceH\x9a`', b'W\x1f\xb5\x1c\xec\xf7\x0b\x86\x15\r\xf9\xf9\x94\xcd|\xe6B\x9f\xa8l\x8d]D\xf7\xba\xee:\xc0\\\x11\xb8\x08', b'\xf5i\xee)\xc4\xd24\xfc\x8f\xba\xc0vS\x1dU>\xccz\xd18\n\xa2+\n\xcf\xe2i*\xee\x18\xe8\xc1', b'\x9dmSX\x1e\xee\xf7`\x1d\x0cO\xfcF\xe4\xbd\x0cE2\x10H6\xf0\x93|\xd5z\xe7=\xebbJ\xd6', b'u\x08\x92\x08\xa5Nl\x938\x03\xa3\xe2O\xe8\xfe\xb1\xc4\x87\x8c\xb8q\x9eb\x89b\x96\x98\xd7\xf22\xb9\xa2', b'\xa6V\xb5?\xcc\xd2\xc8*ME\xe7\xcf\xf8\xad\xf8\xdb\xe7\xf8\xf6D\xd5<\x1c\x95F\x13\x0e\x06rz\xe5m', b''], [b"\xb3\x03\xa9\xc11\x87mQ\xa1I2D4jg\xfe\xd0%k\xf2\r]\xb0\x0e\xeb'\x17\xedx\xc9Uj", b'L/\r$7-\xa5\xdf x\x9c\xbc\xc4\x99\x1e\xc5\xd8\xb5\xaf\xd1\xd1\xae\xe6L\xeco\xc4\xe2RUe\r', b'\xbeSp\xf5\xef\x02\xcd\x83\xb2\x0b\xa06\xfd\xca\xbb\xed_\xf2}\xf7\xea\xb3\x84\x17\xed\xcc\x19mF\x13(\xf3', b"\xfb$IYR\x9f\x04p\x01\x1d}\x88\x0b\xed'\x8e%\x9b\xc9\xeaN_\xab\xf9\xc9\x9d\xac\xa9\xb3\t\x1eq", b'\xaab\xeb\x14\xc2\xf6}%\xaa+0\xb5\xc1\x0f< \xc5ma\xb1c\xeb\xdd\xca\xc0\x90\xe2L\x8b\xe9\xfe/', b'\x91l\x9d\xa2\x84\xbf\xc1\x05\xe2S\x0e\xc9`\xc0^}Q!\xc4ml-\xec\xf4R$\xf6\x8a\xd3\xc6\xf1j', b'\xf3\x13\xde\xe0L\xdb\x96E`Q\xdf\xa1\x13\x01b5\xe4k\xde\xde\xbf\xb10\xaf\xe61Z\xdbZ\xd47\xf4', b'\t\x81\xb0\xea*\xec\xd0\xc3\x16\xee\xed~\xdc\x98e\x90\xf2~p\xbbSY\x19\xcfl\xc4)\x01\xc2\xd9\xc91', b'-\xda%\x8a\xc5jA-\xe5 lIp\xbe\xb3h\x98\x0f\x80q\xed\xab\x89KN\xdd\xa6\xcb;\x98\xb08', b'\x13\x97\x12f\xa31\xfa}\xf1\xfe\x19\xfa\x0b\xe6\x89\x9a\xcb\xf5\xed\xf3Q\x98O=\xa3\xb0e/\xd9\x9fy\x08', b'f\xba%\xfb\xbfE\x1d]\xb3\x05\xe4$\xa5\xd2G\xecc\xe5#\x0f,\x91\x8bN9a\x8a\xd1L\x16l\xa5', b'#p\x15\x8bU\x04\x88/K|4a\xfc\x0e.Zm^{\x15uk\x8d\xe4_\xfe\xee\xae\xb99\xd1\x8e', b'C \x9f\xb3y\xf3d.\x8b\t\x1cF\x9eL\x08\x07y\x08\xb9\xe1\xffM\x87\xfd\xd6\xfd\xdb\x8f\x94\x9e\x88\xc2', b'\x17X\x1f/\x8b\x82\xf5\xe4\x02\x84}\xbe\x9bz` \x94\'"_\x9c\xff\x06\t>\x8a\xd7oK\xf9\xf5w', b'6Q\x8db\xd8\\\x84_Rin\x18\x1f\x17\x89\x7f@\xd6\xbb%>\xafa\'\x80A\xa7\xd8}d\x07"', b'\xccgm\xf7\x05\xc8\xe4G\xf4\xb3\x18\xc7\\.\x0b\xa25]\xdc\x80w\xda\xc9;\xde\x9b\x03\xa0LS\xce\x8c', b''], [b'\xe4\xd3\x15\xe0\xaa\x0f\xf9\xd0\xa6\xc2\xc8B_\xaf"0\x8c\xea;\x91\xe4E\x04\xec\x901yZ\xd6>\xadc', b'wM\xce\x16JS:\xe96\x98\x12|\xa0\xc9~G\xbb\xc7u8\xc8\x93\x9b\x05\x92yh\xaa\xda\x94NK', b'\x89\xc7\xa2\xbd\xe1\xda\x06$|\xde\x03\xd9RS\x90\x84\xe7\x05\x0cc\xdfy\xb0\xfb@\x065\xdb8\xa9\xef\x1f', b'@\x11>\xe8\xb8\x19\xb7\xc7@\x92m$\x93 \x08\xc5\x15\xbd\x97\xb0;\xf5\x05q;\xb5\xc69\xd3E\xc4\x0e', b'\xd5_ol\x05o\x8e\xf0V\xd2\xa0n\xe7CxR\xc9\x92HTQhkc\x10K\xad\xfdU\xe9\x97\x8f', b'v\x7f\xc5KB\xdaYS\xa1\xbf \xda\xe2\x99\x84\xef,\x92\xdd\xc9\xb8\x9eo\xfcv(\x95\xff\x94t\xbc5', b"\xcbQ\x962!$\x1f\xdc\xdb\xfe\xef'\xc8\xc8O\xec\xa2\xae\xd3P\x88\xbf\xbd!\xea\x0e\xb0\x89\xe9\xdd\xf3w", b'H\xb8\x1b\xc3&\x86|!o\x003/\xc7K\xc9+,K\xe1y\xf2\x86\xa9*H\x05W\xcd\xf8\x8b\xb5\n', b'\x06\xc5\xa1\x83\xe4\xb4\xdc\xbf\xc0\x8c4Q\x93\x14W\xaf\xbb\xe9f\x82\xa2\x8d\xa3m\xda\xed\xc0W\x88UA\xd9', b'\x9czV\x7f$\xa8\xb9\xf3\xc1W0\x19\xac\xc5\xaap\x03?*\xe6\xd6\xee<\x0b\xafr\xf6ji\xd9\x87\xed', b'\xc7\x1d\xca\x95\xab~\xd3|\xa6\x9f\xba\x9e\xd5KxI\x95Y\xadx\xb8\xda\xa7!\xba\x93\xbbB,\x97n\xe4', b'\xd7"\x13\xca=\xa9|e\x11\x8f%\xb2^\x1b\xa6\xff\x93Z\x8b(\xca\xab\x12\xed\x8b3\x0f\xe0\xa7U\xa9\xe1', b'\xc2\xb4\x98\xb7\x08\x18#i7\x81\x85\xfd\xc3\xc6k\x12\x86\x99\xa55\x0c8\xd3\xbc\x9d\xc8\xe0\xd3\xcd=\xc6x', b'\xad\xf0\xea&\xf4\x8f=5\xe1\xb5b\xc1}\xba\xa1\n \xa4\xb7J2\x1f\xd7\xc9\x1d\xa4\xc2\xaf\xb7O\xb2\x12', b'\xd5~\x94\x99~Vy,4\xedMJ\x1a\xda3\xe7\x90\x91\xd4\xafw\xba\xbf\x89`\x0e\x99s\x93E\xdf%', b'\x82\xd2O\x16\xca{\x15\x87\xef-\x8a\xea\xb9\xcd\xfc\x82\x84\x99\xdco\xc1\x1eg\xf3-\x07\xf8\xa3\xed\xffx\x85', b''], [b"\xc5\xa5\xd38zu\xfc\xe9\xe2j\x97\xf0\x81T$\xee5\x94AC\xb1\x85\x0c\xef\x10\xcb`Z\xfcT'\xcb", b'ZU\xe4?lj\x05\xf8\xbc\xa7\xf1\xe4\xdb\x08M\x06\xad\xbf\xb3s\xfa\xcaS\xb9{U\xd2n\x981+|', b'l\x0cL\xfb\\(g\xb47\xc2<\xcb\x14\xf3\xa9l\x01#\xdb"|\xdc\xfd\xa0#\xa2\x89\xcfx\x97\xb4\x8e', b'\x0b\xe7$\x1d\xa2\x1c\\\xa5)t\xd6\x82\xec\xed\x02]\xdd\xefz\xa3C`\x1b\xda\x81\t\xb3\x14\xdf5\xbb\xcb', b'\xe7%b2\xd4\xc6\x98\x90\xd8:B\xa4\x9e\n\xc6\xa1\x01\xac\x94\xbdr\xca\xdd\x8a\xa8\xe8\xc6F\xed\x04\xe9\x14', b'\xa7\xac\xc0S\xcbo\x98\xebJ)\xb1\x8b{\xda,\x98\xf2M\xca,\xcd\xc4%\x94\xe4\xdc<\xf5o}\x90\x1d', b'[\xd9}F\xe2\n\x84\xbc\xa0\x81\x0f\xb9\x0b]\x0c\x10%\x9d\r\x00RZgbV*2b\xd1z\xb5\xd3', b'\xac\xcag\xdb\xc3y\x91\x82\xddu\xad\x85%g\x82\xa0\r\xf4\x99^=\x14h\xee\xac\x81/o\xe6\xe4\xec\x0c', b'8\xeb\xed\x80}2\xd9.\x0e\xeb\x92\xa7\xae\xeb\x8d\x9b>8<\x9d\xc4\x05\xf2W;F\xce!\t\x15\xb2\xe3', b'*\xed\xbfJ\x80\x9f7\xd1\xcd\xeft\x89.e\x02M\r\x85D-\x9bL\x8d\xac*3h\xf3\x9f\xde\xe0F', b'd\xf9\xdf\xfb\xfa`\x97:\x11\xc4\x89u_\xe9&\xd0LX;r\x12\x86\\,}\x7f:\xbc\xf9\x9a\xd2\xe9', b'\x94\x80\xd4\xb8\xe4\xa6\xd4\x9cS\xcc\xc7*xo]2y~\xd6\x18a\xfb\xafP\x19\x87\xe7:\xb1r\x96\xdc', b'\x1c\xdar\xc1\x18\x1f\x0b\xf3\xe2\xf0\xf1<\x05\x88\xa4\x01J,\xc2\xa1\xbd`L\x8b\x95\xa6\xbdze4&\xc1', b'>0\x01SdF=\x8c\xa7\x1d4\x1elOt\xcd;,|\xf0l\xe9O\x83\xf3\xc0rm\xb6\x82\xaa\x08', b'\xd0\xef\x12\xc5<\\\x00\x82$\x98\x8d\xb6\xa7l\xd6w\xa3\x00<D\x15\xf7\xd6\xc9\xd0\xfb\xd3\x9f\xed,\x9e\xf7', b'\xa6->\xb1\x80jz\xc3\x8a,5\xb8\xf8\xbf\xb4^\x880\x824A\xfa\xbf\x0e\x1f\x9b /\x02\xadhx', b''], [b"\xc1\x17\xa1{\x135'>\xce\x8a\xe8;\x84V\x8c\xfer\xdaZS\xc7v\xd7\x18\xfb\xe3\xbf\xff\x92\x87@D", b'\x06\xb9c\xad\x8d2\xc0WU\xaf"w\xe5>\x1a\xfd\x02\xf1\xdd\x91$h/\x02)\xc6\xd3\xbc\x17\xc42\xe8', b'\xc4\xa2\xb3*k\xa8\xc8\x124\x86\xa0\x9b\xad\xfa\xb9$5?\xc6\x0c]\x98Kb\xd13\xdb:\x85\xed\xe1[', b'%\xa4>aM\x08\xbet\x1b\xc8\xb5\xf2c.9o!\x03G\x99_\n\xef\x93OA^\xabC\x91\xce\x97', b'\xc9T\xc1\xf6\xc8\xbe\xd8h\x86\xfey\x82Evg\xe1zP\x9ct\x98(\x01\xf5\xfc\xf8\xbe\xf6\x1d\xc0\x15\x8e', b'\xd3\xf1\xe6T\xd7"\xba\xdeipC\xe5\xe1\x04\x0e?o\x84\xcb\x1aE\x18\xd0\xa36\x0eC\xc7D>\x12 ', b'\xe0\x06\x0c\xaf\xec\xe3op*j\xcd\x84\xef\x9b\x82a{,\x1c\x98\xba-\x10\xf9\x7f+\xb6\x8a/q,\xeb', b"\x8a'\xeb\x1a\xe8i\x91S\xf3;\xa8[f-\xb02\x01?\xac\xe4Ds\xd8E\xa0\x87\x8a\xec]\x9b?\x9e", b'\xcf\x0cM\xbd\x92\xbbaS\x9d\xd0:\x7f\xfe\xd5\x08\xac\xe4\xb5\x81ga\xc2>\\\x89\x95\x08\xd6C\xf9\xe6\xb7', b'\x9bh\xd3\xb0x\xf0\xfa5\xa6vV\x96_\x16\x9dx\x95B2\xa9\xcem\xc8\xb9\xaf\xb9\xff\n\xae\xc7\x14\x13', b'H\x03\x82\xd6\xbd\x00Z\r\xa03YQ\xa4\xfa\xcdl\xea8g{L\x16\x18\xca\xdb\xb75~\xff\x1b]&', b'A?l1\xbf\x04\xc3Qs\x9b\x08c\xc3|\xf5D6\xa2\x82\xf8\xd3\xf4@\xab\xa0oDx\xc4\xffY*', b'\x0c\xd7U\x880\xa0\xd3\xad\xdd\xda\xdb\x01\xac\x99ya:\xeb\xab8K%\xaf\xc4\xf1G\xd3*\xb7\xae\x01*', b'\xb8s\xab\x0e\xf4\x90\xdb\xce\x0b)l\xb3\x7f\xf1p\xc6&\x0eh\xfb\xc8\xd7\x88`\xcd\xdc\x97-l\xb6L\x82', b'x\xf2\x15\x85\xe9\x01\xd8\xdc\xc5\xbc\xb7\xda\xcd$\xf0\xae\xc9\x01\xcdHZ\xb8)\x97\x11\xff\xcc7\xa5\x98\xb4\xb6', b'\xf3\xb6\xdd\xe9\xb1\x93\x08A\xda\xa39\xfe$\x8dO\n$ Mn"-\'\xa5$F5\xae\xcd>\xa2\x0c', b''], [b'\x82\x8b\x9d\x85\x0b/\x83\xacmb\x07\x89h\xa5\x86R\x8e\xf4\xd9_\x00\t\xeb\xb3>\\@\x11\xecOp\x7f', b'', b'', b'"\xee\xd9\x89<\xc3_\xca\xe9\xed\xc2v\r,\x9e\x10\x1c\x07\xe8E\xbd\x10\x9a\x16_:hk\xb9Om\xf2', b'', b'', b'\x11]i\xb3t6\xabKF\xc0\xa9\x81z&\xdf\x02\xcaRQ\x82\x92\xac\xf1\xf9~\x94\x94tM9\xbe\x1a', b'\xd0dY\xbc\xbe\xe5\xa8\x93\xc8e\xbd\x15\xf8\xb6b\x9a+\xbeh\xeb\x9d\x85\x1f(\xee\xd5\xb2 \xf2\xea\xa1\xf2', b'', b'`\xa8\xcd0:I\xdd\xd7\xa1\xc9W\r\x00\xa6\x1b\x0cM\xbb8\xb0Z\x8b\xe2\x87\x16\x0f\x99U\xf7\xdf\xc4U', b'', b'\xbcR\x17x\x12Y\xf1r\xb9c\xf5\x17#\xcd\xdb\xd5\x1c0\xd2\xda~\x99a\x96\xd5k\xef\x94\x0f\xd0$\xcb', b'!\x16\xaee\xb5H7X\xd5\tA\xb5{\x98\x8f\x12\x0bX\x85K\x184\x04\xcf\x80\x17\xf81V\xbc\xed\x9c', b'\x00\x08C^\xb5\xcfb\xb3\x13\xf0\x95S\x8eyQ\xe8\xdf\x9bI\xfe\xa2\x9c\x91@_\x16\x9d\x82w,u\x86', b'6&\x99Z\xae\xe6r\xab\xec\xb3X\x87\\\x02\x99>\xfa\xebP:\xd5\xd2t\xe2p\xc7\xe2\xe0\x0e\x95\xf9D', b'\xcf\x7f\x99\x9a\x1c\x18\xa6\x9av\xe6\xa2\xd5\xb3E\x8aJ\x18\xa7\x8c\xc0\x07\xda\xe9\x0bi\r\t\x0f\x9b\x06\xf8S', b''], [b'\x07\x83C\xd1X\xdf\xddJ\xd4\xf2\x7f3+\n\x95\xb2\x89\xd2"\x9d\xc5S\xfb\xfc\x9ed\x8d\xd2\xd2\xe5\x99B', b'', b'', b'', b'', b'-m2\x00\xef\x95\xcd\xfe\xf8\x9e\x0b\xbf\xae\xd8\xb4\xd2\xa1*\xfde\xaa\xb1\x8a\xdd\x1d\x07\x03\xc7,<\xe8\xe7', b'', b'', b'', b'', b'', b'', b'', b'', b'', b'', b''], [b'8Z\xd0\xd47\x84\xe6\xe4S4ndG|\xac\xa3\x0f^7\xd5nv\x14\x9e\x98\x84\xe7\xc2\x97', b'\xf8D\x01\x80\xa0U\xbd\x1daQ\x97{bg,!\xc2uK\xbe\xeb;\x82x\xb2\xe0\xc3\x8e\xdc\xd9I\x84n\xe3b\x8b\xf1\xa0\x1e\x0b*\xd9p\xb3e\xa2\x17\xc4\x0b\xcf5\x82\xcb\xb4\xfc\xc1d-z]\xd7\xa8*\xe1\xe2x\xe0\x10\x12>']) |
# Minizip library
unz = StaticLibrary( 'unz', sources = ['ioapi.c', 'mztools.c', 'unzip.c', 'zip.c'] )
# minizip
minizip = Executable( 'minizip', libs = [ unz, 'z' ], sources = ['minizip.c'] )
# miniunz
miniunz = Executable( 'miniunz', libs = [ unz, 'z' ], sources = ['miniunz.c'] )
# Platform specific settings
if platform == 'MacOS':
project.define( 'unix' )
elif platform == 'iOS':
project.define( 'unix' )
elif platform == 'Windows':
unz.files( 'iowin32.c' ) | unz = static_library('unz', sources=['ioapi.c', 'mztools.c', 'unzip.c', 'zip.c'])
minizip = executable('minizip', libs=[unz, 'z'], sources=['minizip.c'])
miniunz = executable('miniunz', libs=[unz, 'z'], sources=['miniunz.c'])
if platform == 'MacOS':
project.define('unix')
elif platform == 'iOS':
project.define('unix')
elif platform == 'Windows':
unz.files('iowin32.c') |
_base_ = [
'./coco_resize.py'
]
data = dict(
train=dict(classes=('person',)),
val=dict(classes=('person',)),
test=dict(classes=('person',))
)
| _base_ = ['./coco_resize.py']
data = dict(train=dict(classes=('person',)), val=dict(classes=('person',)), test=dict(classes=('person',))) |
class DFS:
def __init__(self):
self.visited_node_counter = 0
def visitor(self):
self.visited_node_counter += 1
def visit(self, node):
node.accept_visitor(self.visitor)
for child in node.children: self.visit(child)
class Node:
def __init__(self):
self.children = []
def add_child(self, node):
self.children.append(node)
def accept_visitor(self, visitor):
visitor()
root = Node()
for i in xrange(0, firstLevelNodes):
root.add_child(Node())
for child in root.children:
for i in xrange(0, secondLevelNodes): child.add_child(Node())
dfs = DFS()
dfs.visit(root)
result = dfs.visited_node_counter
| class Dfs:
def __init__(self):
self.visited_node_counter = 0
def visitor(self):
self.visited_node_counter += 1
def visit(self, node):
node.accept_visitor(self.visitor)
for child in node.children:
self.visit(child)
class Node:
def __init__(self):
self.children = []
def add_child(self, node):
self.children.append(node)
def accept_visitor(self, visitor):
visitor()
root = node()
for i in xrange(0, firstLevelNodes):
root.add_child(node())
for child in root.children:
for i in xrange(0, secondLevelNodes):
child.add_child(node())
dfs = dfs()
dfs.visit(root)
result = dfs.visited_node_counter |
n=int(input())
l=[1 for i in range(n)]
for i in range(1,n):
for x in range(n):
if x==0:
continue
else:
l[x]=l[x]+l[x-1]
print(l[-1])
| n = int(input())
l = [1 for i in range(n)]
for i in range(1, n):
for x in range(n):
if x == 0:
continue
else:
l[x] = l[x] + l[x - 1]
print(l[-1]) |
android = 70 # percents of people using nova poshta on android
ios = 30 # percents of people using nova poshta on ios
people_count = 5000000
ios_people = people_count/ 100 * ios
print (ios_people, " people using nova poshta on ios.") | android = 70
ios = 30
people_count = 5000000
ios_people = people_count / 100 * ios
print(ios_people, ' people using nova poshta on ios.') |
class Profile:
'''
Example
my = Profile('Rob')
my.company = 'CPF'
my.hobby = ['Reading','Sleeping','Eating']
print(my.name)
my.show_email()
my.show_myart()
my.show_hobby()
'''
def __init__(self,name):
self.name = name
self.company = ''
self.hobby = []
self.art = '''
|\ _,,,---,,_
ZZZzz /,`.-'`' -. ;-;;,_
|,4- ) )-,_. ,\ ( `'-'
'---''(_/--' `-'\_)
CAT'''
self.art2 = '''
~~~~
~~
_||____
/\ /\ /\ /\\\\\\\\
//\\/\\/\\ __ /__\\\\\\\\ _,
//\\/\\/\\ __/ \_ |__|_|_|__| \__,
|| || || '-o---o-' | |/|\| /| /\ \
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'''
def show_email(self):
if self.company != '':
print('{}@{}.com'.format(self.name.lower(),self.company))
else:
print('{}@gmail.com'.format(self.name.lower()))
def show_myart(self):
print(self.art)
def show_myart2(self):
print(self.art2)
def show_hobby(self):
if len(self.hobby) != 0:
print('------my hobby-------')
for i,h in enumerate(self.hobby,start = 1):
print(i,h)
print('---------------------')
else:
print('No hobby')
if __name__ == '__main__':
my = Profile('Rob')
my.company = 'CPF'
my.hobby = ['Reading','Sleeping','Eating']
print(my.name)
my.show_email()
my.show_myart()
my.show_myart2()
my.show_hobby()
#help(my)
| class Profile:
"""
Example
my = Profile('Rob')
my.company = 'CPF'
my.hobby = ['Reading','Sleeping','Eating']
print(my.name)
my.show_email()
my.show_myart()
my.show_hobby()
"""
def __init__(self, name):
self.name = name
self.company = ''
self.hobby = []
self.art = "\n\t\t |\\ _,,,---,,_\n\tZZZzz /,`.-'`' -. ;-;;,_\n\t |,4- ) )-,_. ,\\ ( `'-'\n\t '---''(_/--' `-'\\_)\n\n\t\tCAT"
self.art2 = "\n\t\t ~~~~\n ~~\n _||____\n /\\ /\\ /\\ /\\\\\\\\\n//\\/\\/\\ __ /__\\\\\\\\ _,\n//\\/\\/\\ __/ \\_ |__|_|_|__| \\__,\n || || || '-o---o-' | |/|\\| /| /\\ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n "
def show_email(self):
if self.company != '':
print('{}@{}.com'.format(self.name.lower(), self.company))
else:
print('{}@gmail.com'.format(self.name.lower()))
def show_myart(self):
print(self.art)
def show_myart2(self):
print(self.art2)
def show_hobby(self):
if len(self.hobby) != 0:
print('------my hobby-------')
for (i, h) in enumerate(self.hobby, start=1):
print(i, h)
print('---------------------')
else:
print('No hobby')
if __name__ == '__main__':
my = profile('Rob')
my.company = 'CPF'
my.hobby = ['Reading', 'Sleeping', 'Eating']
print(my.name)
my.show_email()
my.show_myart()
my.show_myart2()
my.show_hobby() |
def format_duration(seconds):
years = int(seconds/(365*24*60*60))
days = int((seconds-(years*365*24*60*60))/(24*60*60))
hours = int((seconds-(years*365*24*60*60)-(days*24*60*60)) / (60*60))
mins = int((seconds-(years*365*24*60*60)-(days*24*60*60) - hours*60*60)/60)
sec = (seconds -(years*365*24*60*60)-(days*24*60*60)- hours*60*60 - mins*60)
total = [years, days, hours, mins, sec]
x = ""
if years == 1:
x += "1 year, "
elif years > 1:
x += str(years) + " years, "
if days == 1:
x += "1 day, "
elif days >1:
x += str(days) + " days, "
if hours == 1:
x += "1 hour, "
elif hours >1:
x += str(hours) + " hours, "
if sec == 0 and mins > 0:
x = x[:-2]
x += " and "
if mins == 1:
x += "1 minute, "
elif mins >1:
x += str(mins) + " minutes, "
if sec == 1:
x = x[:-2]
x += " and 1 second"
elif sec > 1:
x = x[:-2]
x += " and " + str(sec) + " seconds"
if seconds == 0:
x = "now"
if x[0] == ",":
x = x[1:]
if x[0] == " ":
x = x[1:]
if x[-1] == " ":
x = x[:-1]
if x[-1] == ",":
x = x[:-1]
if x[0] == "a":
x = x[4:]
return x
print(format_duration(100000))
| def format_duration(seconds):
years = int(seconds / (365 * 24 * 60 * 60))
days = int((seconds - years * 365 * 24 * 60 * 60) / (24 * 60 * 60))
hours = int((seconds - years * 365 * 24 * 60 * 60 - days * 24 * 60 * 60) / (60 * 60))
mins = int((seconds - years * 365 * 24 * 60 * 60 - days * 24 * 60 * 60 - hours * 60 * 60) / 60)
sec = seconds - years * 365 * 24 * 60 * 60 - days * 24 * 60 * 60 - hours * 60 * 60 - mins * 60
total = [years, days, hours, mins, sec]
x = ''
if years == 1:
x += '1 year, '
elif years > 1:
x += str(years) + ' years, '
if days == 1:
x += '1 day, '
elif days > 1:
x += str(days) + ' days, '
if hours == 1:
x += '1 hour, '
elif hours > 1:
x += str(hours) + ' hours, '
if sec == 0 and mins > 0:
x = x[:-2]
x += ' and '
if mins == 1:
x += '1 minute, '
elif mins > 1:
x += str(mins) + ' minutes, '
if sec == 1:
x = x[:-2]
x += ' and 1 second'
elif sec > 1:
x = x[:-2]
x += ' and ' + str(sec) + ' seconds'
if seconds == 0:
x = 'now'
if x[0] == ',':
x = x[1:]
if x[0] == ' ':
x = x[1:]
if x[-1] == ' ':
x = x[:-1]
if x[-1] == ',':
x = x[:-1]
if x[0] == 'a':
x = x[4:]
return x
print(format_duration(100000)) |
# "range(1,11)" just provides us a list of numbers 1-10 (the last number isn't included).
# The list in this case would look like this: [1,2,3,4,5,6,7,8,9,10].
# For loop
## This takes each number inside "range", and saves it as a variable "i". It does whatever is in the loop with that variable, then moves to the next number.
## In this case, the first time it goes through the loop, i is 1 (the first item in the list provided by range).
## Then it will print it, since that's the only thing inside the loop. When it's done with that, it will move to the next number: 2 and do the same thing.
## And so on and so on until it reaches 10. It will print 10 and exit the loop.
for i in range(1,11):
print(i)
# While loop
## While loops will go on forever until whatever condition you provide turns false.
## If the condition is false at the start, the loop is never entered.
do_loop = True
while do_loop:
user_input = input("Should I do the loop again? ")
if user_input == 'no':
do_loop = False
print("Ok, exiting loop")
| for i in range(1, 11):
print(i)
do_loop = True
while do_loop:
user_input = input('Should I do the loop again? ')
if user_input == 'no':
do_loop = False
print('Ok, exiting loop') |
math_str = input("please input a number: ")
math = int(math_str)
math6 = 6
if math == math6:
print("Yes, it is 6!")
elif math < math6:
print("That's less than 6!")
else:
print("That's more than 6!")
| math_str = input('please input a number: ')
math = int(math_str)
math6 = 6
if math == math6:
print('Yes, it is 6!')
elif math < math6:
print("That's less than 6!")
else:
print("That's more than 6!") |
a = arr = [[False for i in range(100)] for j in range(100)]
ans = 0
sl = 0
block= []
def findLargestRectangle(blockNumber):
global sl
global block
block = blockNumber
for i in block: sl += i
for i in range(1,9):
find(i, 1)
return ans
def find(r,n):
global ans
global a
# calc result
if (((n - 1) * 4) % r == 0):
l = (n - 1) * 4 // r
check = True
for i in range(l):
for j in range(r):
if (not a[i][j]):
check = False
break
if (not check): break
if (check and ans < (n-1)*4):
ans = (n-1)*4
# condition end
if (n > sl): return
#fill - backtracking
for i in range(80):
for j in range(r):
if (not a[i][j]):
if (block[0] > 0):
if (not a[i + 1][j] and not a[i + 2][j] and not a[i + 3][j]):
a[i][j] = True
a[i + 1][j] = True
a[i + 2][j] = True
a[i + 3][j] = True
block[0]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 2][j] = False
a[i + 3][j] = False
block[0]+=1
if (j + 3 < r and not a[i][j + 1] and not a[i][j + 2] and not a[i][j + 3]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i][j + 3] = True
block[0]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i][j + 3] = False
block[0]+=1
if (block[1] > 0):
if (j + 1 < r and not a[i][j + 1] and not a[i + 1][j] and not a[i + 1][j + 1]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
block[1]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
block[1]+=1
if (block[2] > 0):
if (j + 2 < r and not a[i][j + 1] and not a[i][j + 2] and not a[i + 1][j + 2]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i + 1][j + 2] = True
block[2]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i + 1][j + 2] = False
block[2]+=1
if (j + 1 < r and not a[i][j + 1] and not a[i + 1][j] and not a[i + 2][j]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j] = True
a[i + 2][j] = True
block[2]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j] = False
a[i + 2][j] = False
block[2]+=1
if (j + 2 < r and not a[i + 1][j] and not a[i + 1][j + 1] and not a[i + 1][j + 2]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
a[i + 1][j + 2] = True
block[2]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
a[i + 1][j + 2] = False
block[2]+=1
if (j > 0):
if (not a[i + 1][j] and not a[i + 2][j] and not a[i + 2][j - 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 2][j] = True
a[i + 2][j - 1] = True
block[2]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 2][j] = False
a[i + 2][j - 1] = False
block[2]+=1
if (block[3] > 0):
if (j + 2 < r and not a[i][j + 1] and not a[i + 1][j + 1] and not a[i + 1][j + 2]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j + 1] = True
a[i + 1][j + 2] = True
block[3]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j + 1] = False
a[i + 1][j + 2] = False
block[3]+=1
if (j > 0):
if (not a[i + 1][j] and not a[i + 1][j - 1] and not a[i + 2][j - 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 2][j - 1] = True
block[3]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 2][j - 1] = False
block[3]+=1
if (block[4] > 0):
if (j + 1 < r and j > 0):
if(not a[i][j + 1] and not a[i + 1][j] and not a[i + 1][j - 1]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
block[4]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
block[4]+=1
if (j + 1 < r):
if (not a[i + 1][j] and not a[i + 1][j + 1] and not a[i + 2][j + 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
a[i + 2][j + 1] = True
block[4]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
a[i + 2][j + 1] = False
block[4]+=1
if (block[5] > 0):
if (j + 2 < r and not a[i][j + 1] and not a[i][j + 2] and not a[i + 1][j]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i + 1][j] = True
block[5]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i + 1][j] = False
block[5]+=1
if (j + 1 < r and not a[i][j + 1] and not a[i + 1][j + 1] and not a[i + 2][j + 1]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j + 1] = True
a[i + 2][j + 1] = True
block[5]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j + 1] = False
a[i + 2][j + 1] = False
block[5]+=1
if (j > 1):
if(not a[i + 1][j] and not a[i + 1][j - 1] and not a[i + 1][j - 2]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 1][j - 2] = True
block[5]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 1][j - 2] = False
block[5]+=1
if (j + 1 < r):
if (not a[i + 1][j] and not a[i + 2][j] and not a[i + 2][j + 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 2][j] = True
a[i + 2][j + 1] = True
block[5]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 2][j] = False
a[i + 2][j + 1] = False
block[5]+=1
if (block[6] > 0):
if (j + 2 < r and not a[i][j + 1] and not a[i][j + 2] and not a[i + 1][j + 1]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i + 1][j + 1] = True
block[6]-=1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i + 1][j + 1] = False
block[6]+=1
if (j + 1 < r and not a[i + 1][j] and not a[i + 1][j + 1] and not a[i + 2][j]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
a[i + 2][j] = True
block[6]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
a[i + 2][j] = False
block[6]+=1
if (j > 0):
if (not a[i + 1][j] and not a[i + 1][j - 1] and not a[i + 2][j]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 2][j] = True
block[6]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 2][j] = False
block[6]+=1
if (j + 1 < r and j > 0):
if(not a[i + 1][j] and not a[i + 1][j + 1] and not a[i + 1][j - 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 1][j + 1] = True
block[6]-=1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 1][j + 1] = False
block[6]+=1
return
print(findLargestRectangle([0,0,1,1,0,1,0]))
| a = arr = [[False for i in range(100)] for j in range(100)]
ans = 0
sl = 0
block = []
def find_largest_rectangle(blockNumber):
global sl
global block
block = blockNumber
for i in block:
sl += i
for i in range(1, 9):
find(i, 1)
return ans
def find(r, n):
global ans
global a
if (n - 1) * 4 % r == 0:
l = (n - 1) * 4 // r
check = True
for i in range(l):
for j in range(r):
if not a[i][j]:
check = False
break
if not check:
break
if check and ans < (n - 1) * 4:
ans = (n - 1) * 4
if n > sl:
return
for i in range(80):
for j in range(r):
if not a[i][j]:
if block[0] > 0:
if not a[i + 1][j] and (not a[i + 2][j]) and (not a[i + 3][j]):
a[i][j] = True
a[i + 1][j] = True
a[i + 2][j] = True
a[i + 3][j] = True
block[0] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 2][j] = False
a[i + 3][j] = False
block[0] += 1
if j + 3 < r and (not a[i][j + 1]) and (not a[i][j + 2]) and (not a[i][j + 3]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i][j + 3] = True
block[0] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i][j + 3] = False
block[0] += 1
if block[1] > 0:
if j + 1 < r and (not a[i][j + 1]) and (not a[i + 1][j]) and (not a[i + 1][j + 1]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
block[1] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
block[1] += 1
if block[2] > 0:
if j + 2 < r and (not a[i][j + 1]) and (not a[i][j + 2]) and (not a[i + 1][j + 2]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i + 1][j + 2] = True
block[2] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i + 1][j + 2] = False
block[2] += 1
if j + 1 < r and (not a[i][j + 1]) and (not a[i + 1][j]) and (not a[i + 2][j]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j] = True
a[i + 2][j] = True
block[2] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j] = False
a[i + 2][j] = False
block[2] += 1
if j + 2 < r and (not a[i + 1][j]) and (not a[i + 1][j + 1]) and (not a[i + 1][j + 2]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
a[i + 1][j + 2] = True
block[2] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
a[i + 1][j + 2] = False
block[2] += 1
if j > 0:
if not a[i + 1][j] and (not a[i + 2][j]) and (not a[i + 2][j - 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 2][j] = True
a[i + 2][j - 1] = True
block[2] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 2][j] = False
a[i + 2][j - 1] = False
block[2] += 1
if block[3] > 0:
if j + 2 < r and (not a[i][j + 1]) and (not a[i + 1][j + 1]) and (not a[i + 1][j + 2]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j + 1] = True
a[i + 1][j + 2] = True
block[3] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j + 1] = False
a[i + 1][j + 2] = False
block[3] += 1
if j > 0:
if not a[i + 1][j] and (not a[i + 1][j - 1]) and (not a[i + 2][j - 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 2][j - 1] = True
block[3] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 2][j - 1] = False
block[3] += 1
if block[4] > 0:
if j + 1 < r and j > 0:
if not a[i][j + 1] and (not a[i + 1][j]) and (not a[i + 1][j - 1]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
block[4] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
block[4] += 1
if j + 1 < r:
if not a[i + 1][j] and (not a[i + 1][j + 1]) and (not a[i + 2][j + 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
a[i + 2][j + 1] = True
block[4] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
a[i + 2][j + 1] = False
block[4] += 1
if block[5] > 0:
if j + 2 < r and (not a[i][j + 1]) and (not a[i][j + 2]) and (not a[i + 1][j]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i + 1][j] = True
block[5] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i + 1][j] = False
block[5] += 1
if j + 1 < r and (not a[i][j + 1]) and (not a[i + 1][j + 1]) and (not a[i + 2][j + 1]):
a[i][j] = True
a[i][j + 1] = True
a[i + 1][j + 1] = True
a[i + 2][j + 1] = True
block[5] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i + 1][j + 1] = False
a[i + 2][j + 1] = False
block[5] += 1
if j > 1:
if not a[i + 1][j] and (not a[i + 1][j - 1]) and (not a[i + 1][j - 2]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 1][j - 2] = True
block[5] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 1][j - 2] = False
block[5] += 1
if j + 1 < r:
if not a[i + 1][j] and (not a[i + 2][j]) and (not a[i + 2][j + 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 2][j] = True
a[i + 2][j + 1] = True
block[5] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 2][j] = False
a[i + 2][j + 1] = False
block[5] += 1
if block[6] > 0:
if j + 2 < r and (not a[i][j + 1]) and (not a[i][j + 2]) and (not a[i + 1][j + 1]):
a[i][j] = True
a[i][j + 1] = True
a[i][j + 2] = True
a[i + 1][j + 1] = True
block[6] -= 1
find(r, n + 1)
a[i][j] = False
a[i][j + 1] = False
a[i][j + 2] = False
a[i + 1][j + 1] = False
block[6] += 1
if j + 1 < r and (not a[i + 1][j]) and (not a[i + 1][j + 1]) and (not a[i + 2][j]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j + 1] = True
a[i + 2][j] = True
block[6] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j + 1] = False
a[i + 2][j] = False
block[6] += 1
if j > 0:
if not a[i + 1][j] and (not a[i + 1][j - 1]) and (not a[i + 2][j]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 2][j] = True
block[6] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 2][j] = False
block[6] += 1
if j + 1 < r and j > 0:
if not a[i + 1][j] and (not a[i + 1][j + 1]) and (not a[i + 1][j - 1]):
a[i][j] = True
a[i + 1][j] = True
a[i + 1][j - 1] = True
a[i + 1][j + 1] = True
block[6] -= 1
find(r, n + 1)
a[i][j] = False
a[i + 1][j] = False
a[i + 1][j - 1] = False
a[i + 1][j + 1] = False
block[6] += 1
return
print(find_largest_rectangle([0, 0, 1, 1, 0, 1, 0])) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.