content
stringlengths 7
1.05M
| fixed_cases
stringlengths 1
1.28M
|
---|---|
sort = lambda array: [sublist for sublist in sorted(array, key=lambda x: x[1])]
if __name__ == "__main__":
print(sort([
("English", 88),
("Social", 82),
("Science", 90),
("Math", 97)
]))
| sort = lambda array: [sublist for sublist in sorted(array, key=lambda x: x[1])]
if __name__ == '__main__':
print(sort([('English', 88), ('Social', 82), ('Science', 90), ('Math', 97)])) |
class Solution:
def decompressRLElist(self, nums: List[int]) -> List[int]:
de = []
for i in range(0, len(nums), 2):
pair = []
pair.append(nums[i])
pair.append(nums[i + 1])
arr = [nums[i + 1]] * nums[i]
de += arr
return de
| class Solution:
def decompress_rl_elist(self, nums: List[int]) -> List[int]:
de = []
for i in range(0, len(nums), 2):
pair = []
pair.append(nums[i])
pair.append(nums[i + 1])
arr = [nums[i + 1]] * nums[i]
de += arr
return de |
class SubCommand:
def __init__(self, command, description="", arguments=[], mutually_exclusive_arguments=[]):
self._command = command
self._description = description
self._arguments = arguments
self._mutually_exclusive_arguments = mutually_exclusive_arguments
def getCommand(self):
return self._command
def get_description(self):
return self._description
def getArguments(self):
return self._arguments
def getMutuallyExclusiveArguments(self):
return self._mutually_exclusive_arguments | class Subcommand:
def __init__(self, command, description='', arguments=[], mutually_exclusive_arguments=[]):
self._command = command
self._description = description
self._arguments = arguments
self._mutually_exclusive_arguments = mutually_exclusive_arguments
def get_command(self):
return self._command
def get_description(self):
return self._description
def get_arguments(self):
return self._arguments
def get_mutually_exclusive_arguments(self):
return self._mutually_exclusive_arguments |
def read_file(filepath):
with open(filepath,'r') as i:
inst = [int(x) for x in i.read().replace(')','-1,').replace('(','1,').strip('\n').strip(',').split(',')]
return inst
def calculate(inst,floor=0):
for i,f in enumerate(inst):
floor += f
if floor < 0: break
return sum(inst), i+1
def main(filepath):
pt1, pt2 = calculate(read_file(filepath))
return pt1, pt2
print(main('1.txt'))
| def read_file(filepath):
with open(filepath, 'r') as i:
inst = [int(x) for x in i.read().replace(')', '-1,').replace('(', '1,').strip('\n').strip(',').split(',')]
return inst
def calculate(inst, floor=0):
for (i, f) in enumerate(inst):
floor += f
if floor < 0:
break
return (sum(inst), i + 1)
def main(filepath):
(pt1, pt2) = calculate(read_file(filepath))
return (pt1, pt2)
print(main('1.txt')) |
def test_check_left_panel(app):
app.login(username="admin", password="admin")
app.main_page.get_menu_items_list()
app.main_page.check_all_admin_panel_items()
| def test_check_left_panel(app):
app.login(username='admin', password='admin')
app.main_page.get_menu_items_list()
app.main_page.check_all_admin_panel_items() |
#
# PySNMP MIB module ALVARION-SMI (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ALVARION-SMI
# Produced by pysmi-0.3.4 at Mon Apr 29 17:06:07 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)
#
Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueSizeConstraint")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
IpAddress, Unsigned32, ObjectIdentity, TimeTicks, MibIdentifier, Integer32, ModuleIdentity, Bits, MibScalar, MibTable, MibTableRow, MibTableColumn, enterprises, Gauge32, NotificationType, Counter32, Counter64, iso = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Unsigned32", "ObjectIdentity", "TimeTicks", "MibIdentifier", "Integer32", "ModuleIdentity", "Bits", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "enterprises", "Gauge32", "NotificationType", "Counter32", "Counter64", "iso")
TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString")
alvarionWireless = ModuleIdentity((1, 3, 6, 1, 4, 1, 12394, 1, 10))
if mibBuilder.loadTexts: alvarionWireless.setLastUpdated('200710310000Z')
if mibBuilder.loadTexts: alvarionWireless.setOrganization('Alvarion Ltd.')
alvarionProducts = ObjectIdentity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 1))
if mibBuilder.loadTexts: alvarionProducts.setStatus('current')
alvarionExperiment = ObjectIdentity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 3))
if mibBuilder.loadTexts: alvarionExperiment.setStatus('current')
alvarionModules = ObjectIdentity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 4))
if mibBuilder.loadTexts: alvarionModules.setStatus('current')
alvarionMgmtV2 = ObjectIdentity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 5))
if mibBuilder.loadTexts: alvarionMgmtV2.setStatus('current')
variation = ObjectIdentity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 7))
if mibBuilder.loadTexts: variation.setStatus('current')
mibBuilder.exportSymbols("ALVARION-SMI", variation=variation, PYSNMP_MODULE_ID=alvarionWireless, alvarionProducts=alvarionProducts, alvarionWireless=alvarionWireless, alvarionModules=alvarionModules, alvarionMgmtV2=alvarionMgmtV2, alvarionExperiment=alvarionExperiment)
| (integer, object_identifier, octet_string) = mibBuilder.importSymbols('ASN1', 'Integer', 'ObjectIdentifier', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_range_constraint, single_value_constraint, constraints_intersection, constraints_union, value_size_constraint) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueRangeConstraint', 'SingleValueConstraint', 'ConstraintsIntersection', 'ConstraintsUnion', 'ValueSizeConstraint')
(notification_group, module_compliance) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance')
(ip_address, unsigned32, object_identity, time_ticks, mib_identifier, integer32, module_identity, bits, mib_scalar, mib_table, mib_table_row, mib_table_column, enterprises, gauge32, notification_type, counter32, counter64, iso) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Unsigned32', 'ObjectIdentity', 'TimeTicks', 'MibIdentifier', 'Integer32', 'ModuleIdentity', 'Bits', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'enterprises', 'Gauge32', 'NotificationType', 'Counter32', 'Counter64', 'iso')
(textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'TextualConvention', 'DisplayString')
alvarion_wireless = module_identity((1, 3, 6, 1, 4, 1, 12394, 1, 10))
if mibBuilder.loadTexts:
alvarionWireless.setLastUpdated('200710310000Z')
if mibBuilder.loadTexts:
alvarionWireless.setOrganization('Alvarion Ltd.')
alvarion_products = object_identity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 1))
if mibBuilder.loadTexts:
alvarionProducts.setStatus('current')
alvarion_experiment = object_identity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 3))
if mibBuilder.loadTexts:
alvarionExperiment.setStatus('current')
alvarion_modules = object_identity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 4))
if mibBuilder.loadTexts:
alvarionModules.setStatus('current')
alvarion_mgmt_v2 = object_identity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 5))
if mibBuilder.loadTexts:
alvarionMgmtV2.setStatus('current')
variation = object_identity((1, 3, 6, 1, 4, 1, 12394, 1, 10, 7))
if mibBuilder.loadTexts:
variation.setStatus('current')
mibBuilder.exportSymbols('ALVARION-SMI', variation=variation, PYSNMP_MODULE_ID=alvarionWireless, alvarionProducts=alvarionProducts, alvarionWireless=alvarionWireless, alvarionModules=alvarionModules, alvarionMgmtV2=alvarionMgmtV2, alvarionExperiment=alvarionExperiment) |
_QUEUED_JOBS_KEY = 'projects:global:jobs:queued'
_ARCHIVED_JOBS_KEY = 'projects:global:jobs:archived'
def list_jobs(redis):
return {job_id.decode() for job_id in redis.smembers(_QUEUED_JOBS_KEY)}
def remove_jobs(redis, job_id_project_mapping):
for job_id, project_name in job_id_project_mapping.items():
redis.srem(_QUEUED_JOBS_KEY, job_id)
redis.srem('project:{}:jobs:queued'.format(project_name), job_id)
def job_project_names(redis, list_of_job_ids):
return {job_id: _job_project_name(redis, job_id) for job_id in list_of_job_ids}
def _job_project_name(redis, job_id):
project_name = redis.get('jobs:{}:project'.format(job_id))
if project_name:
return project_name.decode()
def add_jobs_to_archive(redis, list_of_job_ids):
for job_id in list_of_job_ids:
redis.sadd(_ARCHIVED_JOBS_KEY, job_id)
def list_archived_jobs(redis):
return {job_id.decode() for job_id in redis.smembers(_ARCHIVED_JOBS_KEY)} | _queued_jobs_key = 'projects:global:jobs:queued'
_archived_jobs_key = 'projects:global:jobs:archived'
def list_jobs(redis):
return {job_id.decode() for job_id in redis.smembers(_QUEUED_JOBS_KEY)}
def remove_jobs(redis, job_id_project_mapping):
for (job_id, project_name) in job_id_project_mapping.items():
redis.srem(_QUEUED_JOBS_KEY, job_id)
redis.srem('project:{}:jobs:queued'.format(project_name), job_id)
def job_project_names(redis, list_of_job_ids):
return {job_id: _job_project_name(redis, job_id) for job_id in list_of_job_ids}
def _job_project_name(redis, job_id):
project_name = redis.get('jobs:{}:project'.format(job_id))
if project_name:
return project_name.decode()
def add_jobs_to_archive(redis, list_of_job_ids):
for job_id in list_of_job_ids:
redis.sadd(_ARCHIVED_JOBS_KEY, job_id)
def list_archived_jobs(redis):
return {job_id.decode() for job_id in redis.smembers(_ARCHIVED_JOBS_KEY)} |
#!/usr/bin/env python3
a = []
b = []
s = input()
while s != "end":
n = int(s)
if n % 2 == 1:
a.append(n)
else:
print(n)
s = input()
i = 0
while i < len(a):
print(a[i])
i = i + 1
| a = []
b = []
s = input()
while s != 'end':
n = int(s)
if n % 2 == 1:
a.append(n)
else:
print(n)
s = input()
i = 0
while i < len(a):
print(a[i])
i = i + 1 |
class InvalidBitstringError(BaseException):
pass
class InvalidQuantumKeyError(BaseException):
pass
| class Invalidbitstringerror(BaseException):
pass
class Invalidquantumkeyerror(BaseException):
pass |
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
if len(nums) < 3:
return []
ans = []
nums.sort()
for i in range(0, len(nums)-2):
if nums[i] > 0:
break
if i > 0 and nums[i-1] == nums[i]:
continue
left, right = i+1, len(nums)-1
while right > left:
s = nums[left] + nums[right] + nums[i]
if s == 0:
ans.append([nums[i], nums[left], nums[right]])
left += 1
right -= 1
while right > left and nums[left] == nums[left-1]:
left += 1
while right > left and nums[right] == nums[right+1]:
right -= 1
elif s < 0:
left += 1
else:
right -= 1
return ans
| class Solution:
def three_sum(self, nums: List[int]) -> List[List[int]]:
if len(nums) < 3:
return []
ans = []
nums.sort()
for i in range(0, len(nums) - 2):
if nums[i] > 0:
break
if i > 0 and nums[i - 1] == nums[i]:
continue
(left, right) = (i + 1, len(nums) - 1)
while right > left:
s = nums[left] + nums[right] + nums[i]
if s == 0:
ans.append([nums[i], nums[left], nums[right]])
left += 1
right -= 1
while right > left and nums[left] == nums[left - 1]:
left += 1
while right > left and nums[right] == nums[right + 1]:
right -= 1
elif s < 0:
left += 1
else:
right -= 1
return ans |
def sum_all(ls):
sum = 0
if(len(ls) != 2):
print("Invalid input")
else:
ls.sort()
start = ls[0]
end = ls[1]
if(start == end):
sum = 2 * start
else:
for i in range(start, end+1):
sum += i
return sum
| def sum_all(ls):
sum = 0
if len(ls) != 2:
print('Invalid input')
else:
ls.sort()
start = ls[0]
end = ls[1]
if start == end:
sum = 2 * start
else:
for i in range(start, end + 1):
sum += i
return sum |
# Primitive reimplementation of the buildflag_header scripts used in the gn build
def _buildflag_header_impl(ctx):
content = "// Generated by build/buildflag_header.bzl\n"
content += '// From "' + ctx.attr.name + '"\n'
content += "\n#ifndef %s_h\n" % ctx.attr.name
content += "#define %s_h\n\n" % ctx.attr.name
content += '#include "build/buildflag.h"\n\n'
for key in ctx.attr.flags:
content += "#define BUILDFLAG_INTERNAL_%s() (%s)\n" % (key, ctx.attr.flags[key])
content += "\n#endif // %s_h\n" % ctx.attr.name
ctx.actions.write(output = ctx.outputs.header, content = content)
buildflag_header = rule(
implementation = _buildflag_header_impl,
attrs = {
"flags": attr.string_dict(mandatory = True),
"header": attr.string(mandatory = True),
"header_dir": attr.string(),
},
outputs = {"header": "%{header_dir}%{header}"},
output_to_genfiles = True,
)
| def _buildflag_header_impl(ctx):
content = '// Generated by build/buildflag_header.bzl\n'
content += '// From "' + ctx.attr.name + '"\n'
content += '\n#ifndef %s_h\n' % ctx.attr.name
content += '#define %s_h\n\n' % ctx.attr.name
content += '#include "build/buildflag.h"\n\n'
for key in ctx.attr.flags:
content += '#define BUILDFLAG_INTERNAL_%s() (%s)\n' % (key, ctx.attr.flags[key])
content += '\n#endif // %s_h\n' % ctx.attr.name
ctx.actions.write(output=ctx.outputs.header, content=content)
buildflag_header = rule(implementation=_buildflag_header_impl, attrs={'flags': attr.string_dict(mandatory=True), 'header': attr.string(mandatory=True), 'header_dir': attr.string()}, outputs={'header': '%{header_dir}%{header}'}, output_to_genfiles=True) |
# Space: O(n)
# Time: O(n)
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def convertBST(self, root):
if (root is None) or (root.left is None and root.right is None): return root
def inorder_traversal(root):
if root is None: return []
res = []
left = inorder_traversal(root.left)
res.append(root.val)
right = inorder_traversal(root.right)
return left + res + right
def update_BST(adict, root):
queue = [root]
while queue:
cur = queue.pop(0)
# print(cur.val)
cur.val = adict[cur.val]
if cur.left:
queue.append(cur.left)
if cur.right:
queue.append(cur.right)
return root
inorder_traversal_res = inorder_traversal(root)
cache = {}
for i in range(len(inorder_traversal_res)):
cache[inorder_traversal_res[i]] = sum(inorder_traversal_res[i:])
return update_BST(cache, root)
| class Solution:
def convert_bst(self, root):
if root is None or (root.left is None and root.right is None):
return root
def inorder_traversal(root):
if root is None:
return []
res = []
left = inorder_traversal(root.left)
res.append(root.val)
right = inorder_traversal(root.right)
return left + res + right
def update_bst(adict, root):
queue = [root]
while queue:
cur = queue.pop(0)
cur.val = adict[cur.val]
if cur.left:
queue.append(cur.left)
if cur.right:
queue.append(cur.right)
return root
inorder_traversal_res = inorder_traversal(root)
cache = {}
for i in range(len(inorder_traversal_res)):
cache[inorder_traversal_res[i]] = sum(inorder_traversal_res[i:])
return update_bst(cache, root) |
# parsetab.py
# This file is automatically generated. Do not edit.
# pylint: disable=W,C,R
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'statement_listleftPLUSMINUSleftMULTIPLYDIVIDEAND ATOM BANG BOOL COLON COMMA DIVIDE ELIF ELSE END EQUAL EXIT FUN GT ID IF IMPORT LBRACE LBRACKET LPAREN LT MAC MINUS MULTIPLY NOT NULL NUMBER OR PLACEHOLDER PLUS RBRACE RBRACKET RETURN RPAREN SEMICOLON STRING WHILEstatement_list : statement statement_list\n | emptyempty :statement : IMPORT STRING SEMICOLONstatement : assignment SEMICOLONstatement : conditionalstatement : expr SEMICOLONstatement : macro_defstatement : macro_callassignment : l_value EQUAL r_valuestatement : looploop : WHILE LPAREN expr RPAREN LBRACE statement_list RBRACEstatement : fun_deffun_def : FUN ID LPAREN id_list RPAREN LBRACE statement_list RBRACEstatement : RETURN expr SEMICOLONid_list : IDid_list : ID COMMA id_listid_list : emptyconditional : IF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elif conditional_elseconditional_elif : ELIF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elifconditional_elif : emptyconditional_else : ELSE LBRACE statement_list RBRACEconditional_else : emptyr_value : exprl_value : IDl_value : ID fieldsl_value : PLACEHOLDERl_value : PLACEHOLDER fieldsfields : LBRACKET expr RBRACKETfields : LBRACKET expr RBRACKET fieldsexpr : alg_opexpr : STRINGexpr : NUMBERexpr : BOOLexpr : NULLexpr : func_callexpr : IDexpr : LPAREN expr RPARENexpr : anonymous_fun func_call : ID LPAREN arg_list RPARENarg_list : emptyarg_list : exprarg_list : expr COMMA arg_listalg_op : expr PLUS expr\n | expr MINUS expr\n | expr MULTIPLY expr\n | expr DIVIDE exprexpr : LBRACKET arg_list RBRACKETexpr : LBRACE record_list RBRACEexpr : LPAREN statement_list RPARENrecord_list : ID COLON exprrecord_list : ID COLON expr COMMA record_listrecord_list : emptyexpr : expr LBRACKET expr RBRACKETexpr : comp_opexpr : PLACEHOLDERcomp_op : expr EQUAL EQUAL exprcomp_op : expr BANG EQUAL exprcomp_op : expr GT exprcomp_op : expr GT EQUAL exprcomp_op : expr LT exprcomp_op : expr LT EQUAL exprexpr : log_oplog_op : expr AND exprlog_op : expr OR exprlog_op : NOT exprmacro_def : MAC macro_def_arg_list LBRACE statement_list RBRACEmacro_def_arg_list : ATOM macro_def_arg_list_recmacro_def_arg_list_rec : PLACEHOLDER macro_def_arg_list_recmacro_def_arg_list_rec : ATOM macro_def_arg_list_recmacro_def_arg_list_rec : emptymacro_call : ATOM macro_arg_list SEMICOLONmacro_arg_list : ATOM macro_arg_listmacro_arg_list : expr macro_arg_listmacro_arg_list : emptyanonymous_fun : LPAREN id_list RPAREN LBRACE statement_list RBRACE'
_lr_action_items = {'IMPORT':([0,2,7,9,10,11,12,16,36,37,78,92,106,112,123,137,141,142,148,149,150,152,154,155,156,158,160,164,165,167,168,],[4,4,-6,-8,-9,-11,-13,4,-5,-7,-4,-15,4,-72,4,4,-67,4,4,-3,-12,-3,-21,-14,-19,-23,4,-22,4,-3,-20,]),'RETURN':([0,2,7,9,10,11,12,16,36,37,78,92,106,112,123,137,141,142,148,149,150,152,154,155,156,158,160,164,165,167,168,],[13,13,-6,-8,-9,-11,-13,13,-5,-7,-4,-15,13,-72,13,13,-67,13,13,-3,-12,-3,-21,-14,-19,-23,13,-22,13,-3,-20,]),'$end':([0,1,2,3,7,9,10,11,12,34,36,37,78,92,112,141,149,150,152,154,155,156,158,164,167,168,],[-3,0,-3,-2,-6,-8,-9,-11,-13,-1,-5,-7,-4,-15,-72,-67,-3,-12,-3,-21,-14,-19,-23,-22,-3,-20,]),'IF':([0,2,7,9,10,11,12,16,36,37,78,92,106,112,123,137,141,142,148,149,150,152,154,155,156,158,160,164,165,167,168,],[15,15,-6,-8,-9,-11,-13,15,-5,-7,-4,-15,15,-72,15,15,-67,15,15,-3,-12,-3,-21,-14,-19,-23,15,-22,15,-3,-20,]),'STRING':([0,2,4,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[5,5,35,-32,-6,-8,-9,-11,-13,5,5,-31,-33,-34,-35,-36,-39,5,-55,-63,5,5,-5,-7,5,5,5,5,5,5,5,5,5,-37,-56,5,5,5,5,5,5,5,-66,-4,-44,-45,-46,-47,5,5,-59,5,-61,5,-64,-65,-15,-38,-50,-49,5,-48,5,5,-72,5,-54,-57,-58,-60,-62,5,-40,5,-67,5,-76,5,-3,-12,-3,-21,-14,-19,-23,5,5,-22,5,-3,-20,]),'NUMBER':([0,2,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[19,19,-32,-6,-8,-9,-11,-13,19,19,-31,-33,-34,-35,-36,-39,19,-55,-63,19,19,-5,-7,19,19,19,19,19,19,19,19,19,-37,-56,19,19,19,19,19,19,19,-66,-4,-44,-45,-46,-47,19,19,-59,19,-61,19,-64,-65,-15,-38,-50,-49,19,-48,19,19,-72,19,-54,-57,-58,-60,-62,19,-40,19,-67,19,-76,19,-3,-12,-3,-21,-14,-19,-23,19,19,-22,19,-3,-20,]),'BOOL':([0,2,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[20,20,-32,-6,-8,-9,-11,-13,20,20,-31,-33,-34,-35,-36,-39,20,-55,-63,20,20,-5,-7,20,20,20,20,20,20,20,20,20,-37,-56,20,20,20,20,20,20,20,-66,-4,-44,-45,-46,-47,20,20,-59,20,-61,20,-64,-65,-15,-38,-50,-49,20,-48,20,20,-72,20,-54,-57,-58,-60,-62,20,-40,20,-67,20,-76,20,-3,-12,-3,-21,-14,-19,-23,20,20,-22,20,-3,-20,]),'NULL':([0,2,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[21,21,-32,-6,-8,-9,-11,-13,21,21,-31,-33,-34,-35,-36,-39,21,-55,-63,21,21,-5,-7,21,21,21,21,21,21,21,21,21,-37,-56,21,21,21,21,21,21,21,-66,-4,-44,-45,-46,-47,21,21,-59,21,-61,21,-64,-65,-15,-38,-50,-49,21,-48,21,21,-72,21,-54,-57,-58,-60,-62,21,-40,21,-67,21,-76,21,-3,-12,-3,-21,-14,-19,-23,21,21,-22,21,-3,-20,]),'ID':([0,2,5,7,9,10,11,12,13,16,17,18,19,20,21,22,24,25,26,28,30,32,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,99,100,101,104,105,106,112,114,116,117,118,119,120,121,123,128,137,139,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[23,23,-32,-6,-8,-9,-11,-13,50,57,60,-31,-33,-34,-35,-36,-39,50,-55,-63,50,76,50,-5,-7,50,50,50,50,50,50,50,50,50,-37,-56,50,50,50,50,50,50,50,-66,-4,-44,-45,-46,-47,50,50,-59,50,-61,50,-64,-65,-15,-38,-50,124,-49,50,-48,50,23,-72,50,124,-54,-57,-58,-60,-62,23,-40,23,60,-67,23,-76,23,-3,-12,-3,-21,-14,-19,-23,50,23,-22,23,-3,-20,]),'LPAREN':([0,2,5,7,9,10,11,12,13,15,16,18,19,20,21,22,23,24,25,26,28,30,31,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,57,63,64,71,73,75,76,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,153,154,155,156,158,159,160,164,165,167,168,],[16,16,-32,-6,-8,-9,-11,-13,16,53,16,-31,-33,-34,-35,-36,63,-39,16,-55,-63,16,75,16,-5,-7,16,16,16,16,16,16,16,16,16,63,-56,16,16,63,16,16,16,16,16,116,-66,-4,-44,-45,-46,-47,16,16,-59,16,-61,16,-64,-65,-15,-38,-50,-49,16,-48,16,16,-72,16,-54,-57,-58,-60,-62,16,-40,16,-67,16,-76,16,-3,-12,-3,159,-21,-14,-19,-23,16,16,-22,16,-3,-20,]),'LBRACKET':([0,2,5,7,8,9,10,11,12,13,16,18,19,20,21,22,23,24,25,26,27,28,30,33,36,37,38,39,40,41,42,45,46,47,48,49,50,51,52,53,54,57,63,64,67,71,73,75,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,94,95,96,97,100,101,103,104,105,106,112,114,115,117,118,119,120,121,123,127,128,129,134,137,141,142,145,148,149,150,152,154,155,156,158,159,160,161,164,165,167,168,],[25,25,-32,-6,38,-8,-9,-11,-13,25,25,-31,-33,-34,-35,-36,64,-39,25,-55,64,-63,25,25,-5,-7,25,25,25,25,25,25,25,25,25,38,-37,-56,25,25,38,64,25,25,38,25,114,25,38,-4,38,-44,-45,-46,-47,25,25,38,25,38,25,38,38,-15,38,38,-38,-50,-49,25,38,-48,25,25,-72,25,38,-54,38,38,38,38,25,38,-40,64,38,25,-67,25,-76,25,-3,-12,-3,-21,-14,-19,-23,25,25,38,-22,25,-3,-20,]),'LBRACE':([0,2,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,69,70,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,98,100,101,104,105,106,107,108,109,110,112,114,117,118,119,120,121,122,123,128,132,133,135,137,141,142,143,145,148,149,150,152,154,155,156,157,158,159,160,163,164,165,167,168,],[17,17,-32,-6,-8,-9,-11,-13,17,17,-31,-33,-34,-35,-36,-39,17,-55,-63,17,17,-5,-7,17,17,17,17,17,17,17,17,17,-37,-56,17,17,17,17,106,-3,17,17,17,-66,-4,-44,-45,-46,-47,17,17,-59,17,-61,17,-64,-65,-15,-38,-50,123,-49,17,-48,17,17,-3,-68,-3,-71,-72,17,-54,-57,-58,-60,-62,137,17,-40,-70,-69,142,17,-67,17,148,-76,17,-3,-12,-3,-21,-14,-19,160,-23,17,17,165,-22,17,-3,-20,]),'PLACEHOLDER':([0,2,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,70,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,107,109,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[27,27,-32,-6,-8,-9,-11,-13,51,27,-31,-33,-34,-35,-36,-39,51,-55,-63,51,51,-5,-7,51,51,51,51,51,51,51,51,51,-37,-56,51,51,51,51,109,51,51,51,-66,-4,-44,-45,-46,-47,51,51,-59,51,-61,51,-64,-65,-15,-38,-50,-49,51,-48,51,27,109,109,-72,51,-54,-57,-58,-60,-62,27,-40,27,-67,27,-76,27,-3,-12,-3,-21,-14,-19,-23,51,27,-22,27,-3,-20,]),'MAC':([0,2,7,9,10,11,12,16,36,37,78,92,106,112,123,137,141,142,148,149,150,152,154,155,156,158,160,164,165,167,168,],[29,29,-6,-8,-9,-11,-13,29,-5,-7,-4,-15,29,-72,29,29,-67,29,29,-3,-12,-3,-21,-14,-19,-23,29,-22,29,-3,-20,]),'ATOM':([0,2,5,7,9,10,11,12,16,18,19,20,21,22,24,26,28,29,30,36,37,50,51,70,71,73,77,78,80,81,82,83,86,88,90,91,92,96,97,100,104,106,107,109,112,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,160,164,165,167,168,],[30,30,-32,-6,-8,-9,-11,-13,30,-31,-33,-34,-35,-36,-39,-55,-63,70,71,-5,-7,-37,-56,107,71,71,-66,-4,-44,-45,-46,-47,-59,-61,-64,-65,-15,-38,-50,-49,-48,30,107,107,-72,-54,-57,-58,-60,-62,30,-40,30,-67,30,-76,30,-3,-12,-3,-21,-14,-19,-23,30,-22,30,-3,-20,]),'WHILE':([0,2,7,9,10,11,12,16,36,37,78,92,106,112,123,137,141,142,148,149,150,152,154,155,156,158,160,164,165,167,168,],[31,31,-6,-8,-9,-11,-13,31,-5,-7,-4,-15,31,-72,31,31,-67,31,31,-3,-12,-3,-21,-14,-19,-23,31,-22,31,-3,-20,]),'FUN':([0,2,7,9,10,11,12,16,36,37,78,92,106,112,123,137,141,142,148,149,150,152,154,155,156,158,160,164,165,167,168,],[32,32,-6,-8,-9,-11,-13,32,-5,-7,-4,-15,32,-72,32,32,-67,32,32,-3,-12,-3,-21,-14,-19,-23,32,-22,32,-3,-20,]),'NOT':([0,2,5,7,9,10,11,12,13,16,18,19,20,21,22,24,25,26,28,30,33,36,37,38,39,40,41,42,45,46,47,48,50,51,52,53,63,64,71,73,75,77,78,80,81,82,83,84,85,86,87,88,89,90,91,92,96,97,100,101,104,105,106,112,114,117,118,119,120,121,123,128,137,141,142,145,148,149,150,152,154,155,156,158,159,160,164,165,167,168,],[33,33,-32,-6,-8,-9,-11,-13,33,33,-31,-33,-34,-35,-36,-39,33,-55,-63,33,33,-5,-7,33,33,33,33,33,33,33,33,33,-37,-56,33,33,33,33,33,33,33,-66,-4,-44,-45,-46,-47,33,33,-59,33,-61,33,-64,-65,-15,-38,-50,-49,33,-48,33,33,-72,33,-54,-57,-58,-60,-62,33,-40,33,-67,33,-76,33,-3,-12,-3,-21,-14,-19,-23,33,33,-22,33,-3,-20,]),'RPAREN':([2,3,5,7,9,10,11,12,16,18,19,20,21,22,24,26,27,28,34,36,37,50,51,54,55,56,57,58,63,66,67,77,78,80,81,82,83,86,88,90,91,92,95,96,97,99,100,102,104,105,112,115,116,117,118,119,120,121,124,125,126,128,130,136,141,145,149,150,152,154,155,156,158,161,164,167,168,],[-3,-2,-32,-6,-8,-9,-11,-13,-3,-31,-33,-34,-35,-36,-39,-55,-56,-63,-1,-5,-7,-37,-56,96,97,98,-16,-2,-3,-41,-42,-66,-4,-44,-45,-46,-47,-59,-61,-64,-65,-15,122,-38,-50,-3,-49,128,-48,-3,-72,135,-3,-54,-57,-58,-60,-62,-16,-17,-18,-40,-43,143,-67,-76,-3,-12,-3,-21,-14,-19,-23,163,-22,-3,-20,]),'RBRACE':([2,3,5,7,9,10,11,12,17,18,19,20,21,22,24,26,28,34,36,37,50,51,59,61,77,78,80,81,82,83,86,88,90,91,92,96,97,100,104,106,112,117,118,119,120,121,123,127,128,131,137,138,139,141,142,144,145,146,147,148,149,150,151,152,154,155,156,158,160,162,164,165,166,167,168,],[-3,-2,-32,-6,-8,-9,-11,-13,-3,-31,-33,-34,-35,-36,-39,-55,-63,-1,-5,-7,-37,-56,100,-53,-66,-4,-44,-45,-46,-47,-59,-61,-64,-65,-15,-38,-50,-49,-48,-3,-72,-54,-57,-58,-60,-62,-3,-51,-40,141,-3,145,-3,-67,-3,149,-76,-52,150,-3,-3,-12,155,-3,-21,-14,-19,-23,-3,164,-22,-3,167,-3,-20,]),'SEMICOLON':([5,6,8,18,19,20,21,22,23,24,26,27,28,30,35,49,50,51,54,57,71,72,73,74,77,80,81,82,83,86,88,90,91,93,94,96,97,100,104,111,113,117,118,119,120,121,128,145,],[-32,36,37,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,-3,78,92,-37,-56,37,-37,-3,112,-3,-75,-66,-44,-45,-46,-47,-59,-61,-64,-65,-10,-24,-38,-50,-49,-48,-73,-74,-54,-57,-58,-60,-62,-40,-76,]),'PLUS':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,39,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,39,-37,-56,39,-37,39,39,39,39,-44,-45,-46,-47,39,39,39,39,39,39,-38,-50,-49,39,-48,39,-54,39,39,39,39,39,-40,39,-76,39,]),'MINUS':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,40,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,40,-37,-56,40,-37,40,40,40,40,-44,-45,-46,-47,40,40,40,40,40,40,-38,-50,-49,40,-48,40,-54,40,40,40,40,40,-40,40,-76,40,]),'MULTIPLY':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,41,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,41,-37,-56,41,-37,41,41,41,41,41,41,-46,-47,41,41,41,41,41,41,-38,-50,-49,41,-48,41,-54,41,41,41,41,41,-40,41,-76,41,]),'DIVIDE':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,42,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,42,-37,-56,42,-37,42,42,42,42,42,42,-46,-47,42,42,42,42,42,42,-38,-50,-49,42,-48,42,-54,42,42,42,42,42,-40,42,-76,42,]),'EQUAL':([5,8,14,18,19,20,21,22,23,24,26,27,28,43,44,45,46,49,50,51,54,57,62,67,68,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,129,134,140,145,161,],[-32,43,52,-31,-33,-34,-35,-36,-25,-39,-55,-27,-63,84,85,87,89,43,-37,-56,43,-25,-26,43,-28,43,43,43,-44,-45,-46,-47,43,43,43,43,43,43,-38,-50,-49,43,-48,43,-54,43,43,43,43,43,-40,-29,43,-30,-76,43,]),'BANG':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,44,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,44,-37,-56,44,-37,44,44,44,44,-44,-45,-46,-47,44,44,44,44,44,44,-38,-50,-49,44,-48,44,-54,44,44,44,44,44,-40,44,-76,44,]),'GT':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,45,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,45,-37,-56,45,-37,45,45,45,45,-44,-45,-46,-47,45,45,45,45,45,45,-38,-50,-49,45,-48,45,-54,45,45,45,45,45,-40,45,-76,45,]),'LT':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,46,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,46,-37,-56,46,-37,46,46,46,46,-44,-45,-46,-47,46,46,46,46,46,46,-38,-50,-49,46,-48,46,-54,46,46,46,46,46,-40,46,-76,46,]),'AND':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,47,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,47,-37,-56,47,-37,47,47,47,47,-44,-45,-46,-47,47,47,47,47,47,47,-38,-50,-49,47,-48,47,-54,47,47,47,47,47,-40,47,-76,47,]),'OR':([5,8,18,19,20,21,22,23,24,26,27,28,49,50,51,54,57,67,73,77,79,80,81,82,83,86,88,90,91,94,95,96,97,100,103,104,115,117,118,119,120,121,127,128,134,145,161,],[-32,48,-31,-33,-34,-35,-36,-37,-39,-55,-56,-63,48,-37,-56,48,-37,48,48,48,48,-44,-45,-46,-47,48,48,48,48,48,48,-38,-50,-49,48,-48,48,-54,48,48,48,48,48,-40,48,-76,48,]),'COMMA':([5,18,19,20,21,22,24,26,28,50,51,57,67,77,80,81,82,83,86,88,90,91,96,97,100,104,117,118,119,120,121,124,127,128,134,145,],[-32,-31,-33,-34,-35,-36,-39,-55,-63,-37,-56,99,105,-66,-44,-45,-46,-47,-59,-61,-64,-65,-38,-50,-49,-48,-54,-57,-58,-60,-62,99,139,-40,105,-76,]),'RBRACKET':([5,18,19,20,21,22,24,25,26,28,50,51,65,66,67,77,79,80,81,82,83,86,88,90,91,96,97,100,103,104,105,114,117,118,119,120,121,128,130,134,145,],[-32,-31,-33,-34,-35,-36,-39,-3,-55,-63,-37,-56,104,-41,-42,-66,117,-44,-45,-46,-47,-59,-61,-64,-65,-38,-50,-49,129,-48,-3,-3,-54,-57,-58,-60,-62,-40,-43,117,-76,]),'COLON':([60,],[101,]),'ELIF':([149,167,],[153,153,]),'ELSE':([149,152,154,167,168,],[-3,157,-21,-3,-20,]),}
_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'statement_list':([0,2,16,106,123,137,142,148,160,165,],[1,34,55,131,138,144,147,151,162,166,]),'statement':([0,2,16,106,123,137,142,148,160,165,],[2,2,2,2,2,2,2,2,2,2,]),'empty':([0,2,16,17,25,30,63,70,71,73,99,105,106,107,109,114,116,123,137,139,142,148,149,152,160,165,167,],[3,3,58,61,66,74,66,110,74,74,126,66,3,110,110,66,126,3,3,61,3,3,154,158,3,3,154,]),'assignment':([0,2,16,106,123,137,142,148,160,165,],[6,6,6,6,6,6,6,6,6,6,]),'conditional':([0,2,16,106,123,137,142,148,160,165,],[7,7,7,7,7,7,7,7,7,7,]),'expr':([0,2,13,16,25,30,33,38,39,40,41,42,45,46,47,48,52,53,63,64,71,73,75,84,85,87,89,101,105,106,114,123,137,142,148,159,160,165,],[8,8,49,54,67,73,77,79,80,81,82,83,86,88,90,91,94,95,67,103,73,73,115,118,119,120,121,127,67,8,134,8,8,8,8,161,8,8,]),'macro_def':([0,2,16,106,123,137,142,148,160,165,],[9,9,9,9,9,9,9,9,9,9,]),'macro_call':([0,2,16,106,123,137,142,148,160,165,],[10,10,10,10,10,10,10,10,10,10,]),'loop':([0,2,16,106,123,137,142,148,160,165,],[11,11,11,11,11,11,11,11,11,11,]),'fun_def':([0,2,16,106,123,137,142,148,160,165,],[12,12,12,12,12,12,12,12,12,12,]),'l_value':([0,2,16,106,123,137,142,148,160,165,],[14,14,14,14,14,14,14,14,14,14,]),'alg_op':([0,2,13,16,25,30,33,38,39,40,41,42,45,46,47,48,52,53,63,64,71,73,75,84,85,87,89,101,105,106,114,123,137,142,148,159,160,165,],[18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,]),'func_call':([0,2,13,16,25,30,33,38,39,40,41,42,45,46,47,48,52,53,63,64,71,73,75,84,85,87,89,101,105,106,114,123,137,142,148,159,160,165,],[22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,]),'anonymous_fun':([0,2,13,16,25,30,33,38,39,40,41,42,45,46,47,48,52,53,63,64,71,73,75,84,85,87,89,101,105,106,114,123,137,142,148,159,160,165,],[24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,]),'comp_op':([0,2,13,16,25,30,33,38,39,40,41,42,45,46,47,48,52,53,63,64,71,73,75,84,85,87,89,101,105,106,114,123,137,142,148,159,160,165,],[26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,]),'log_op':([0,2,13,16,25,30,33,38,39,40,41,42,45,46,47,48,52,53,63,64,71,73,75,84,85,87,89,101,105,106,114,123,137,142,148,159,160,165,],[28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,]),'id_list':([16,99,116,],[56,125,136,]),'record_list':([17,139,],[59,146,]),'fields':([23,27,57,129,],[62,68,62,140,]),'arg_list':([25,63,105,114,],[65,102,130,65,]),'macro_def_arg_list':([29,],[69,]),'macro_arg_list':([30,71,73,],[72,111,113,]),'r_value':([52,],[93,]),'macro_def_arg_list_rec':([70,107,109,],[108,132,133,]),'conditional_elif':([149,167,],[152,168,]),'conditional_else':([152,],[156,]),}
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> statement_list","S'",1,None,None,None),
('statement_list -> statement statement_list','statement_list',2,'p_statement_list','parse.py',20),
('statement_list -> empty','statement_list',1,'p_statement_list','parse.py',21),
('empty -> <empty>','empty',0,'p_empty','parse.py',30),
('statement -> IMPORT STRING SEMICOLON','statement',3,'p_statement_import','parse.py',34),
('statement -> assignment SEMICOLON','statement',2,'p_statement_assignment','parse.py',38),
('statement -> conditional','statement',1,'p_statement_conditional','parse.py',42),
('statement -> expr SEMICOLON','statement',2,'p_statement_expr','parse.py',46),
('statement -> macro_def','statement',1,'p_statement_macro_def','parse.py',50),
('statement -> macro_call','statement',1,'p_statement_macro_call','parse.py',54),
('assignment -> l_value EQUAL r_value','assignment',3,'p_assignment','parse.py',58),
('statement -> loop','statement',1,'p_statement_loop','parse.py',62),
('loop -> WHILE LPAREN expr RPAREN LBRACE statement_list RBRACE','loop',7,'p_loop','parse.py',66),
('statement -> fun_def','statement',1,'p_statement_fun_def','parse.py',70),
('fun_def -> FUN ID LPAREN id_list RPAREN LBRACE statement_list RBRACE','fun_def',8,'p_fun_def','parse.py',74),
('statement -> RETURN expr SEMICOLON','statement',3,'p_statement_return','parse.py',78),
('id_list -> ID','id_list',1,'p_id_list_single','parse.py',82),
('id_list -> ID COMMA id_list','id_list',3,'p_id_list_multi','parse.py',86),
('id_list -> empty','id_list',1,'p_id_list_empty','parse.py',90),
('conditional -> IF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elif conditional_else','conditional',9,'p_conditional_full','parse.py',94),
('conditional_elif -> ELIF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elif','conditional_elif',8,'p_conditional_elif','parse.py',99),
('conditional_elif -> empty','conditional_elif',1,'p_conditional_elif_empty','parse.py',103),
('conditional_else -> ELSE LBRACE statement_list RBRACE','conditional_else',4,'p_conditional_else','parse.py',107),
('conditional_else -> empty','conditional_else',1,'p_conditional_else_empty','parse.py',111),
('r_value -> expr','r_value',1,'p_r_value','parse.py',115),
('l_value -> ID','l_value',1,'p_l_value_id','parse.py',119),
('l_value -> ID fields','l_value',2,'p_l_value_record','parse.py',123),
('l_value -> PLACEHOLDER','l_value',1,'p_l_value_placeholder','parse.py',127),
('l_value -> PLACEHOLDER fields','l_value',2,'p_l_value_placeholder_record','parse.py',131),
('fields -> LBRACKET expr RBRACKET','fields',3,'p_fields_single','parse.py',134),
('fields -> LBRACKET expr RBRACKET fields','fields',4,'p_fields_multi','parse.py',138),
('expr -> alg_op','expr',1,'p_expr','parse.py',142),
('expr -> STRING','expr',1,'p_expr_string','parse.py',146),
('expr -> NUMBER','expr',1,'p_expr_number','parse.py',150),
('expr -> BOOL','expr',1,'p_expr_bool','parse.py',154),
('expr -> NULL','expr',1,'p_expr_null','parse.py',158),
('expr -> func_call','expr',1,'p_expr_func_call','parse.py',162),
('expr -> ID','expr',1,'p_expr_id','parse.py',166),
('expr -> LPAREN expr RPAREN','expr',3,'p_expr_parens','parse.py',170),
('expr -> anonymous_fun','expr',1,'p_expr_anonymous_fun','parse.py',174),
('func_call -> ID LPAREN arg_list RPAREN','func_call',4,'p_func_call','parse.py',178),
('arg_list -> empty','arg_list',1,'p_arg_list_empty','parse.py',182),
('arg_list -> expr','arg_list',1,'p_arg_list_single','parse.py',186),
('arg_list -> expr COMMA arg_list','arg_list',3,'p_arg_list_multi','parse.py',190),
('alg_op -> expr PLUS expr','alg_op',3,'p_alg_op','parse.py',197),
('alg_op -> expr MINUS expr','alg_op',3,'p_alg_op','parse.py',198),
('alg_op -> expr MULTIPLY expr','alg_op',3,'p_alg_op','parse.py',199),
('alg_op -> expr DIVIDE expr','alg_op',3,'p_alg_op','parse.py',200),
('expr -> LBRACKET arg_list RBRACKET','expr',3,'p_expr_list','parse.py',211),
('expr -> LBRACE record_list RBRACE','expr',3,'p_expr_object','parse.py',215),
('expr -> LPAREN statement_list RPAREN','expr',3,'p_expr_sequence','parse.py',219),
('record_list -> ID COLON expr','record_list',3,'p_record_list_single','parse.py',223),
('record_list -> ID COLON expr COMMA record_list','record_list',5,'p_record_list_multi','parse.py',227),
('record_list -> empty','record_list',1,'p_record_list_empty','parse.py',231),
('expr -> expr LBRACKET expr RBRACKET','expr',4,'p_expr_access','parse.py',235),
('expr -> comp_op','expr',1,'p_expr_comp_op','parse.py',239),
('expr -> PLACEHOLDER','expr',1,'p_expr_placeholder','parse.py',243),
('comp_op -> expr EQUAL EQUAL expr','comp_op',4,'p_comp_op_eq','parse.py',247),
('comp_op -> expr BANG EQUAL expr','comp_op',4,'p_comp_op_neq','parse.py',251),
('comp_op -> expr GT expr','comp_op',3,'p_comp_op_gt','parse.py',255),
('comp_op -> expr GT EQUAL expr','comp_op',4,'p_comp_op_gte','parse.py',259),
('comp_op -> expr LT expr','comp_op',3,'p_comp_op_lt','parse.py',263),
('comp_op -> expr LT EQUAL expr','comp_op',4,'p_comp_op_lte','parse.py',267),
('expr -> log_op','expr',1,'p_expr_log_op','parse.py',271),
('log_op -> expr AND expr','log_op',3,'p_log_op_and','parse.py',275),
('log_op -> expr OR expr','log_op',3,'p_log_op_or','parse.py',279),
('log_op -> NOT expr','log_op',2,'p_log_op_not','parse.py',283),
('macro_def -> MAC macro_def_arg_list LBRACE statement_list RBRACE','macro_def',5,'p_macro_def','parse.py',287),
('macro_def_arg_list -> ATOM macro_def_arg_list_rec','macro_def_arg_list',2,'p_macro_def_arg_list_start_atom','parse.py',291),
('macro_def_arg_list_rec -> PLACEHOLDER macro_def_arg_list_rec','macro_def_arg_list_rec',2,'p_macro_def_arg_list_rec_placeholder','parse.py',295),
('macro_def_arg_list_rec -> ATOM macro_def_arg_list_rec','macro_def_arg_list_rec',2,'p_macro_def_arg_list_rec_atom','parse.py',299),
('macro_def_arg_list_rec -> empty','macro_def_arg_list_rec',1,'p_macro_def_arg_list_rec_empty','parse.py',303),
('macro_call -> ATOM macro_arg_list SEMICOLON','macro_call',3,'p_macro_call_atom_start','parse.py',307),
('macro_arg_list -> ATOM macro_arg_list','macro_arg_list',2,'p_macro_call_arg_list_atom','parse.py',311),
('macro_arg_list -> expr macro_arg_list','macro_arg_list',2,'p_macro_call_arg_list_expr','parse.py',315),
('macro_arg_list -> empty','macro_arg_list',1,'p_macro_call_arg_list_empty','parse.py',319),
('anonymous_fun -> LPAREN id_list RPAREN LBRACE statement_list RBRACE','anonymous_fun',6,'p_anonymous_fun','parse.py',323),
]
| _tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'statement_listleftPLUSMINUSleftMULTIPLYDIVIDEAND ATOM BANG BOOL COLON COMMA DIVIDE ELIF ELSE END EQUAL EXIT FUN GT ID IF IMPORT LBRACE LBRACKET LPAREN LT MAC MINUS MULTIPLY NOT NULL NUMBER OR PLACEHOLDER PLUS RBRACE RBRACKET RETURN RPAREN SEMICOLON STRING WHILEstatement_list : statement statement_list\n | emptyempty :statement : IMPORT STRING SEMICOLONstatement : assignment SEMICOLONstatement : conditionalstatement : expr SEMICOLONstatement : macro_defstatement : macro_callassignment : l_value EQUAL r_valuestatement : looploop : WHILE LPAREN expr RPAREN LBRACE statement_list RBRACEstatement : fun_deffun_def : FUN ID LPAREN id_list RPAREN LBRACE statement_list RBRACEstatement : RETURN expr SEMICOLONid_list : IDid_list : ID COMMA id_listid_list : emptyconditional : IF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elif conditional_elseconditional_elif : ELIF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elifconditional_elif : emptyconditional_else : ELSE LBRACE statement_list RBRACEconditional_else : emptyr_value : exprl_value : IDl_value : ID fieldsl_value : PLACEHOLDERl_value : PLACEHOLDER fieldsfields : LBRACKET expr RBRACKETfields : LBRACKET expr RBRACKET fieldsexpr : alg_opexpr : STRINGexpr : NUMBERexpr : BOOLexpr : NULLexpr : func_callexpr : IDexpr : LPAREN expr RPARENexpr : anonymous_fun func_call : ID LPAREN arg_list RPARENarg_list : emptyarg_list : exprarg_list : expr COMMA arg_listalg_op : expr PLUS expr\n | expr MINUS expr\n | expr MULTIPLY expr\n | expr DIVIDE exprexpr : LBRACKET arg_list RBRACKETexpr : LBRACE record_list RBRACEexpr : LPAREN statement_list RPARENrecord_list : ID COLON exprrecord_list : ID COLON expr COMMA record_listrecord_list : emptyexpr : expr LBRACKET expr RBRACKETexpr : comp_opexpr : PLACEHOLDERcomp_op : expr EQUAL EQUAL exprcomp_op : expr BANG EQUAL exprcomp_op : expr GT exprcomp_op : expr GT EQUAL exprcomp_op : expr LT exprcomp_op : expr LT EQUAL exprexpr : log_oplog_op : expr AND exprlog_op : expr OR exprlog_op : NOT exprmacro_def : MAC macro_def_arg_list LBRACE statement_list RBRACEmacro_def_arg_list : ATOM macro_def_arg_list_recmacro_def_arg_list_rec : PLACEHOLDER macro_def_arg_list_recmacro_def_arg_list_rec : ATOM macro_def_arg_list_recmacro_def_arg_list_rec : emptymacro_call : ATOM macro_arg_list SEMICOLONmacro_arg_list : ATOM macro_arg_listmacro_arg_list : expr macro_arg_listmacro_arg_list : emptyanonymous_fun : LPAREN id_list RPAREN LBRACE statement_list RBRACE'
_lr_action_items = {'IMPORT': ([0, 2, 7, 9, 10, 11, 12, 16, 36, 37, 78, 92, 106, 112, 123, 137, 141, 142, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [4, 4, -6, -8, -9, -11, -13, 4, -5, -7, -4, -15, 4, -72, 4, 4, -67, 4, 4, -3, -12, -3, -21, -14, -19, -23, 4, -22, 4, -3, -20]), 'RETURN': ([0, 2, 7, 9, 10, 11, 12, 16, 36, 37, 78, 92, 106, 112, 123, 137, 141, 142, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [13, 13, -6, -8, -9, -11, -13, 13, -5, -7, -4, -15, 13, -72, 13, 13, -67, 13, 13, -3, -12, -3, -21, -14, -19, -23, 13, -22, 13, -3, -20]), '$end': ([0, 1, 2, 3, 7, 9, 10, 11, 12, 34, 36, 37, 78, 92, 112, 141, 149, 150, 152, 154, 155, 156, 158, 164, 167, 168], [-3, 0, -3, -2, -6, -8, -9, -11, -13, -1, -5, -7, -4, -15, -72, -67, -3, -12, -3, -21, -14, -19, -23, -22, -3, -20]), 'IF': ([0, 2, 7, 9, 10, 11, 12, 16, 36, 37, 78, 92, 106, 112, 123, 137, 141, 142, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [15, 15, -6, -8, -9, -11, -13, 15, -5, -7, -4, -15, 15, -72, 15, 15, -67, 15, 15, -3, -12, -3, -21, -14, -19, -23, 15, -22, 15, -3, -20]), 'STRING': ([0, 2, 4, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [5, 5, 35, -32, -6, -8, -9, -11, -13, 5, 5, -31, -33, -34, -35, -36, -39, 5, -55, -63, 5, 5, -5, -7, 5, 5, 5, 5, 5, 5, 5, 5, 5, -37, -56, 5, 5, 5, 5, 5, 5, 5, -66, -4, -44, -45, -46, -47, 5, 5, -59, 5, -61, 5, -64, -65, -15, -38, -50, -49, 5, -48, 5, 5, -72, 5, -54, -57, -58, -60, -62, 5, -40, 5, -67, 5, -76, 5, -3, -12, -3, -21, -14, -19, -23, 5, 5, -22, 5, -3, -20]), 'NUMBER': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [19, 19, -32, -6, -8, -9, -11, -13, 19, 19, -31, -33, -34, -35, -36, -39, 19, -55, -63, 19, 19, -5, -7, 19, 19, 19, 19, 19, 19, 19, 19, 19, -37, -56, 19, 19, 19, 19, 19, 19, 19, -66, -4, -44, -45, -46, -47, 19, 19, -59, 19, -61, 19, -64, -65, -15, -38, -50, -49, 19, -48, 19, 19, -72, 19, -54, -57, -58, -60, -62, 19, -40, 19, -67, 19, -76, 19, -3, -12, -3, -21, -14, -19, -23, 19, 19, -22, 19, -3, -20]), 'BOOL': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [20, 20, -32, -6, -8, -9, -11, -13, 20, 20, -31, -33, -34, -35, -36, -39, 20, -55, -63, 20, 20, -5, -7, 20, 20, 20, 20, 20, 20, 20, 20, 20, -37, -56, 20, 20, 20, 20, 20, 20, 20, -66, -4, -44, -45, -46, -47, 20, 20, -59, 20, -61, 20, -64, -65, -15, -38, -50, -49, 20, -48, 20, 20, -72, 20, -54, -57, -58, -60, -62, 20, -40, 20, -67, 20, -76, 20, -3, -12, -3, -21, -14, -19, -23, 20, 20, -22, 20, -3, -20]), 'NULL': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [21, 21, -32, -6, -8, -9, -11, -13, 21, 21, -31, -33, -34, -35, -36, -39, 21, -55, -63, 21, 21, -5, -7, 21, 21, 21, 21, 21, 21, 21, 21, 21, -37, -56, 21, 21, 21, 21, 21, 21, 21, -66, -4, -44, -45, -46, -47, 21, 21, -59, 21, -61, 21, -64, -65, -15, -38, -50, -49, 21, -48, 21, 21, -72, 21, -54, -57, -58, -60, -62, 21, -40, 21, -67, 21, -76, 21, -3, -12, -3, -21, -14, -19, -23, 21, 21, -22, 21, -3, -20]), 'ID': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 32, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 99, 100, 101, 104, 105, 106, 112, 114, 116, 117, 118, 119, 120, 121, 123, 128, 137, 139, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [23, 23, -32, -6, -8, -9, -11, -13, 50, 57, 60, -31, -33, -34, -35, -36, -39, 50, -55, -63, 50, 76, 50, -5, -7, 50, 50, 50, 50, 50, 50, 50, 50, 50, -37, -56, 50, 50, 50, 50, 50, 50, 50, -66, -4, -44, -45, -46, -47, 50, 50, -59, 50, -61, 50, -64, -65, -15, -38, -50, 124, -49, 50, -48, 50, 23, -72, 50, 124, -54, -57, -58, -60, -62, 23, -40, 23, 60, -67, 23, -76, 23, -3, -12, -3, -21, -14, -19, -23, 50, 23, -22, 23, -3, -20]), 'LPAREN': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 15, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 30, 31, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 57, 63, 64, 71, 73, 75, 76, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 153, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [16, 16, -32, -6, -8, -9, -11, -13, 16, 53, 16, -31, -33, -34, -35, -36, 63, -39, 16, -55, -63, 16, 75, 16, -5, -7, 16, 16, 16, 16, 16, 16, 16, 16, 16, 63, -56, 16, 16, 63, 16, 16, 16, 16, 16, 116, -66, -4, -44, -45, -46, -47, 16, 16, -59, 16, -61, 16, -64, -65, -15, -38, -50, -49, 16, -48, 16, 16, -72, 16, -54, -57, -58, -60, -62, 16, -40, 16, -67, 16, -76, 16, -3, -12, -3, 159, -21, -14, -19, -23, 16, 16, -22, 16, -3, -20]), 'LBRACKET': ([0, 2, 5, 7, 8, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 57, 63, 64, 67, 71, 73, 75, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 94, 95, 96, 97, 100, 101, 103, 104, 105, 106, 112, 114, 115, 117, 118, 119, 120, 121, 123, 127, 128, 129, 134, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 161, 164, 165, 167, 168], [25, 25, -32, -6, 38, -8, -9, -11, -13, 25, 25, -31, -33, -34, -35, -36, 64, -39, 25, -55, 64, -63, 25, 25, -5, -7, 25, 25, 25, 25, 25, 25, 25, 25, 25, 38, -37, -56, 25, 25, 38, 64, 25, 25, 38, 25, 114, 25, 38, -4, 38, -44, -45, -46, -47, 25, 25, 38, 25, 38, 25, 38, 38, -15, 38, 38, -38, -50, -49, 25, 38, -48, 25, 25, -72, 25, 38, -54, 38, 38, 38, 38, 25, 38, -40, 64, 38, 25, -67, 25, -76, 25, -3, -12, -3, -21, -14, -19, -23, 25, 25, 38, -22, 25, -3, -20]), 'LBRACE': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 69, 70, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 98, 100, 101, 104, 105, 106, 107, 108, 109, 110, 112, 114, 117, 118, 119, 120, 121, 122, 123, 128, 132, 133, 135, 137, 141, 142, 143, 145, 148, 149, 150, 152, 154, 155, 156, 157, 158, 159, 160, 163, 164, 165, 167, 168], [17, 17, -32, -6, -8, -9, -11, -13, 17, 17, -31, -33, -34, -35, -36, -39, 17, -55, -63, 17, 17, -5, -7, 17, 17, 17, 17, 17, 17, 17, 17, 17, -37, -56, 17, 17, 17, 17, 106, -3, 17, 17, 17, -66, -4, -44, -45, -46, -47, 17, 17, -59, 17, -61, 17, -64, -65, -15, -38, -50, 123, -49, 17, -48, 17, 17, -3, -68, -3, -71, -72, 17, -54, -57, -58, -60, -62, 137, 17, -40, -70, -69, 142, 17, -67, 17, 148, -76, 17, -3, -12, -3, -21, -14, -19, 160, -23, 17, 17, 165, -22, 17, -3, -20]), 'PLACEHOLDER': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 70, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 107, 109, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [27, 27, -32, -6, -8, -9, -11, -13, 51, 27, -31, -33, -34, -35, -36, -39, 51, -55, -63, 51, 51, -5, -7, 51, 51, 51, 51, 51, 51, 51, 51, 51, -37, -56, 51, 51, 51, 51, 109, 51, 51, 51, -66, -4, -44, -45, -46, -47, 51, 51, -59, 51, -61, 51, -64, -65, -15, -38, -50, -49, 51, -48, 51, 27, 109, 109, -72, 51, -54, -57, -58, -60, -62, 27, -40, 27, -67, 27, -76, 27, -3, -12, -3, -21, -14, -19, -23, 51, 27, -22, 27, -3, -20]), 'MAC': ([0, 2, 7, 9, 10, 11, 12, 16, 36, 37, 78, 92, 106, 112, 123, 137, 141, 142, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [29, 29, -6, -8, -9, -11, -13, 29, -5, -7, -4, -15, 29, -72, 29, 29, -67, 29, 29, -3, -12, -3, -21, -14, -19, -23, 29, -22, 29, -3, -20]), 'ATOM': ([0, 2, 5, 7, 9, 10, 11, 12, 16, 18, 19, 20, 21, 22, 24, 26, 28, 29, 30, 36, 37, 50, 51, 70, 71, 73, 77, 78, 80, 81, 82, 83, 86, 88, 90, 91, 92, 96, 97, 100, 104, 106, 107, 109, 112, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [30, 30, -32, -6, -8, -9, -11, -13, 30, -31, -33, -34, -35, -36, -39, -55, -63, 70, 71, -5, -7, -37, -56, 107, 71, 71, -66, -4, -44, -45, -46, -47, -59, -61, -64, -65, -15, -38, -50, -49, -48, 30, 107, 107, -72, -54, -57, -58, -60, -62, 30, -40, 30, -67, 30, -76, 30, -3, -12, -3, -21, -14, -19, -23, 30, -22, 30, -3, -20]), 'WHILE': ([0, 2, 7, 9, 10, 11, 12, 16, 36, 37, 78, 92, 106, 112, 123, 137, 141, 142, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [31, 31, -6, -8, -9, -11, -13, 31, -5, -7, -4, -15, 31, -72, 31, 31, -67, 31, 31, -3, -12, -3, -21, -14, -19, -23, 31, -22, 31, -3, -20]), 'FUN': ([0, 2, 7, 9, 10, 11, 12, 16, 36, 37, 78, 92, 106, 112, 123, 137, 141, 142, 148, 149, 150, 152, 154, 155, 156, 158, 160, 164, 165, 167, 168], [32, 32, -6, -8, -9, -11, -13, 32, -5, -7, -4, -15, 32, -72, 32, 32, -67, 32, 32, -3, -12, -3, -21, -14, -19, -23, 32, -22, 32, -3, -20]), 'NOT': ([0, 2, 5, 7, 9, 10, 11, 12, 13, 16, 18, 19, 20, 21, 22, 24, 25, 26, 28, 30, 33, 36, 37, 38, 39, 40, 41, 42, 45, 46, 47, 48, 50, 51, 52, 53, 63, 64, 71, 73, 75, 77, 78, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 96, 97, 100, 101, 104, 105, 106, 112, 114, 117, 118, 119, 120, 121, 123, 128, 137, 141, 142, 145, 148, 149, 150, 152, 154, 155, 156, 158, 159, 160, 164, 165, 167, 168], [33, 33, -32, -6, -8, -9, -11, -13, 33, 33, -31, -33, -34, -35, -36, -39, 33, -55, -63, 33, 33, -5, -7, 33, 33, 33, 33, 33, 33, 33, 33, 33, -37, -56, 33, 33, 33, 33, 33, 33, 33, -66, -4, -44, -45, -46, -47, 33, 33, -59, 33, -61, 33, -64, -65, -15, -38, -50, -49, 33, -48, 33, 33, -72, 33, -54, -57, -58, -60, -62, 33, -40, 33, -67, 33, -76, 33, -3, -12, -3, -21, -14, -19, -23, 33, 33, -22, 33, -3, -20]), 'RPAREN': ([2, 3, 5, 7, 9, 10, 11, 12, 16, 18, 19, 20, 21, 22, 24, 26, 27, 28, 34, 36, 37, 50, 51, 54, 55, 56, 57, 58, 63, 66, 67, 77, 78, 80, 81, 82, 83, 86, 88, 90, 91, 92, 95, 96, 97, 99, 100, 102, 104, 105, 112, 115, 116, 117, 118, 119, 120, 121, 124, 125, 126, 128, 130, 136, 141, 145, 149, 150, 152, 154, 155, 156, 158, 161, 164, 167, 168], [-3, -2, -32, -6, -8, -9, -11, -13, -3, -31, -33, -34, -35, -36, -39, -55, -56, -63, -1, -5, -7, -37, -56, 96, 97, 98, -16, -2, -3, -41, -42, -66, -4, -44, -45, -46, -47, -59, -61, -64, -65, -15, 122, -38, -50, -3, -49, 128, -48, -3, -72, 135, -3, -54, -57, -58, -60, -62, -16, -17, -18, -40, -43, 143, -67, -76, -3, -12, -3, -21, -14, -19, -23, 163, -22, -3, -20]), 'RBRACE': ([2, 3, 5, 7, 9, 10, 11, 12, 17, 18, 19, 20, 21, 22, 24, 26, 28, 34, 36, 37, 50, 51, 59, 61, 77, 78, 80, 81, 82, 83, 86, 88, 90, 91, 92, 96, 97, 100, 104, 106, 112, 117, 118, 119, 120, 121, 123, 127, 128, 131, 137, 138, 139, 141, 142, 144, 145, 146, 147, 148, 149, 150, 151, 152, 154, 155, 156, 158, 160, 162, 164, 165, 166, 167, 168], [-3, -2, -32, -6, -8, -9, -11, -13, -3, -31, -33, -34, -35, -36, -39, -55, -63, -1, -5, -7, -37, -56, 100, -53, -66, -4, -44, -45, -46, -47, -59, -61, -64, -65, -15, -38, -50, -49, -48, -3, -72, -54, -57, -58, -60, -62, -3, -51, -40, 141, -3, 145, -3, -67, -3, 149, -76, -52, 150, -3, -3, -12, 155, -3, -21, -14, -19, -23, -3, 164, -22, -3, 167, -3, -20]), 'SEMICOLON': ([5, 6, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 30, 35, 49, 50, 51, 54, 57, 71, 72, 73, 74, 77, 80, 81, 82, 83, 86, 88, 90, 91, 93, 94, 96, 97, 100, 104, 111, 113, 117, 118, 119, 120, 121, 128, 145], [-32, 36, 37, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, -3, 78, 92, -37, -56, 37, -37, -3, 112, -3, -75, -66, -44, -45, -46, -47, -59, -61, -64, -65, -10, -24, -38, -50, -49, -48, -73, -74, -54, -57, -58, -60, -62, -40, -76]), 'PLUS': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 39, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 39, -37, -56, 39, -37, 39, 39, 39, 39, -44, -45, -46, -47, 39, 39, 39, 39, 39, 39, -38, -50, -49, 39, -48, 39, -54, 39, 39, 39, 39, 39, -40, 39, -76, 39]), 'MINUS': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 40, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 40, -37, -56, 40, -37, 40, 40, 40, 40, -44, -45, -46, -47, 40, 40, 40, 40, 40, 40, -38, -50, -49, 40, -48, 40, -54, 40, 40, 40, 40, 40, -40, 40, -76, 40]), 'MULTIPLY': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 41, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 41, -37, -56, 41, -37, 41, 41, 41, 41, 41, 41, -46, -47, 41, 41, 41, 41, 41, 41, -38, -50, -49, 41, -48, 41, -54, 41, 41, 41, 41, 41, -40, 41, -76, 41]), 'DIVIDE': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 42, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 42, -37, -56, 42, -37, 42, 42, 42, 42, 42, 42, -46, -47, 42, 42, 42, 42, 42, 42, -38, -50, -49, 42, -48, 42, -54, 42, 42, 42, 42, 42, -40, 42, -76, 42]), 'EQUAL': ([5, 8, 14, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 43, 44, 45, 46, 49, 50, 51, 54, 57, 62, 67, 68, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 129, 134, 140, 145, 161], [-32, 43, 52, -31, -33, -34, -35, -36, -25, -39, -55, -27, -63, 84, 85, 87, 89, 43, -37, -56, 43, -25, -26, 43, -28, 43, 43, 43, -44, -45, -46, -47, 43, 43, 43, 43, 43, 43, -38, -50, -49, 43, -48, 43, -54, 43, 43, 43, 43, 43, -40, -29, 43, -30, -76, 43]), 'BANG': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 44, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 44, -37, -56, 44, -37, 44, 44, 44, 44, -44, -45, -46, -47, 44, 44, 44, 44, 44, 44, -38, -50, -49, 44, -48, 44, -54, 44, 44, 44, 44, 44, -40, 44, -76, 44]), 'GT': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 45, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 45, -37, -56, 45, -37, 45, 45, 45, 45, -44, -45, -46, -47, 45, 45, 45, 45, 45, 45, -38, -50, -49, 45, -48, 45, -54, 45, 45, 45, 45, 45, -40, 45, -76, 45]), 'LT': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 46, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 46, -37, -56, 46, -37, 46, 46, 46, 46, -44, -45, -46, -47, 46, 46, 46, 46, 46, 46, -38, -50, -49, 46, -48, 46, -54, 46, 46, 46, 46, 46, -40, 46, -76, 46]), 'AND': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 47, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 47, -37, -56, 47, -37, 47, 47, 47, 47, -44, -45, -46, -47, 47, 47, 47, 47, 47, 47, -38, -50, -49, 47, -48, 47, -54, 47, 47, 47, 47, 47, -40, 47, -76, 47]), 'OR': ([5, 8, 18, 19, 20, 21, 22, 23, 24, 26, 27, 28, 49, 50, 51, 54, 57, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 96, 97, 100, 103, 104, 115, 117, 118, 119, 120, 121, 127, 128, 134, 145, 161], [-32, 48, -31, -33, -34, -35, -36, -37, -39, -55, -56, -63, 48, -37, -56, 48, -37, 48, 48, 48, 48, -44, -45, -46, -47, 48, 48, 48, 48, 48, 48, -38, -50, -49, 48, -48, 48, -54, 48, 48, 48, 48, 48, -40, 48, -76, 48]), 'COMMA': ([5, 18, 19, 20, 21, 22, 24, 26, 28, 50, 51, 57, 67, 77, 80, 81, 82, 83, 86, 88, 90, 91, 96, 97, 100, 104, 117, 118, 119, 120, 121, 124, 127, 128, 134, 145], [-32, -31, -33, -34, -35, -36, -39, -55, -63, -37, -56, 99, 105, -66, -44, -45, -46, -47, -59, -61, -64, -65, -38, -50, -49, -48, -54, -57, -58, -60, -62, 99, 139, -40, 105, -76]), 'RBRACKET': ([5, 18, 19, 20, 21, 22, 24, 25, 26, 28, 50, 51, 65, 66, 67, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 96, 97, 100, 103, 104, 105, 114, 117, 118, 119, 120, 121, 128, 130, 134, 145], [-32, -31, -33, -34, -35, -36, -39, -3, -55, -63, -37, -56, 104, -41, -42, -66, 117, -44, -45, -46, -47, -59, -61, -64, -65, -38, -50, -49, 129, -48, -3, -3, -54, -57, -58, -60, -62, -40, -43, 117, -76]), 'COLON': ([60], [101]), 'ELIF': ([149, 167], [153, 153]), 'ELSE': ([149, 152, 154, 167, 168], [-3, 157, -21, -3, -20])}
_lr_action = {}
for (_k, _v) in _lr_action_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_action:
_lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'statement_list': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [1, 34, 55, 131, 138, 144, 147, 151, 162, 166]), 'statement': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2]), 'empty': ([0, 2, 16, 17, 25, 30, 63, 70, 71, 73, 99, 105, 106, 107, 109, 114, 116, 123, 137, 139, 142, 148, 149, 152, 160, 165, 167], [3, 3, 58, 61, 66, 74, 66, 110, 74, 74, 126, 66, 3, 110, 110, 66, 126, 3, 3, 61, 3, 3, 154, 158, 3, 3, 154]), 'assignment': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6]), 'conditional': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7]), 'expr': ([0, 2, 13, 16, 25, 30, 33, 38, 39, 40, 41, 42, 45, 46, 47, 48, 52, 53, 63, 64, 71, 73, 75, 84, 85, 87, 89, 101, 105, 106, 114, 123, 137, 142, 148, 159, 160, 165], [8, 8, 49, 54, 67, 73, 77, 79, 80, 81, 82, 83, 86, 88, 90, 91, 94, 95, 67, 103, 73, 73, 115, 118, 119, 120, 121, 127, 67, 8, 134, 8, 8, 8, 8, 161, 8, 8]), 'macro_def': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [9, 9, 9, 9, 9, 9, 9, 9, 9, 9]), 'macro_call': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [10, 10, 10, 10, 10, 10, 10, 10, 10, 10]), 'loop': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [11, 11, 11, 11, 11, 11, 11, 11, 11, 11]), 'fun_def': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [12, 12, 12, 12, 12, 12, 12, 12, 12, 12]), 'l_value': ([0, 2, 16, 106, 123, 137, 142, 148, 160, 165], [14, 14, 14, 14, 14, 14, 14, 14, 14, 14]), 'alg_op': ([0, 2, 13, 16, 25, 30, 33, 38, 39, 40, 41, 42, 45, 46, 47, 48, 52, 53, 63, 64, 71, 73, 75, 84, 85, 87, 89, 101, 105, 106, 114, 123, 137, 142, 148, 159, 160, 165], [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18]), 'func_call': ([0, 2, 13, 16, 25, 30, 33, 38, 39, 40, 41, 42, 45, 46, 47, 48, 52, 53, 63, 64, 71, 73, 75, 84, 85, 87, 89, 101, 105, 106, 114, 123, 137, 142, 148, 159, 160, 165], [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22]), 'anonymous_fun': ([0, 2, 13, 16, 25, 30, 33, 38, 39, 40, 41, 42, 45, 46, 47, 48, 52, 53, 63, 64, 71, 73, 75, 84, 85, 87, 89, 101, 105, 106, 114, 123, 137, 142, 148, 159, 160, 165], [24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24]), 'comp_op': ([0, 2, 13, 16, 25, 30, 33, 38, 39, 40, 41, 42, 45, 46, 47, 48, 52, 53, 63, 64, 71, 73, 75, 84, 85, 87, 89, 101, 105, 106, 114, 123, 137, 142, 148, 159, 160, 165], [26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26]), 'log_op': ([0, 2, 13, 16, 25, 30, 33, 38, 39, 40, 41, 42, 45, 46, 47, 48, 52, 53, 63, 64, 71, 73, 75, 84, 85, 87, 89, 101, 105, 106, 114, 123, 137, 142, 148, 159, 160, 165], [28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28]), 'id_list': ([16, 99, 116], [56, 125, 136]), 'record_list': ([17, 139], [59, 146]), 'fields': ([23, 27, 57, 129], [62, 68, 62, 140]), 'arg_list': ([25, 63, 105, 114], [65, 102, 130, 65]), 'macro_def_arg_list': ([29], [69]), 'macro_arg_list': ([30, 71, 73], [72, 111, 113]), 'r_value': ([52], [93]), 'macro_def_arg_list_rec': ([70, 107, 109], [108, 132, 133]), 'conditional_elif': ([149, 167], [152, 168]), 'conditional_else': ([152], [156])}
_lr_goto = {}
for (_k, _v) in _lr_goto_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_goto:
_lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [("S' -> statement_list", "S'", 1, None, None, None), ('statement_list -> statement statement_list', 'statement_list', 2, 'p_statement_list', 'parse.py', 20), ('statement_list -> empty', 'statement_list', 1, 'p_statement_list', 'parse.py', 21), ('empty -> <empty>', 'empty', 0, 'p_empty', 'parse.py', 30), ('statement -> IMPORT STRING SEMICOLON', 'statement', 3, 'p_statement_import', 'parse.py', 34), ('statement -> assignment SEMICOLON', 'statement', 2, 'p_statement_assignment', 'parse.py', 38), ('statement -> conditional', 'statement', 1, 'p_statement_conditional', 'parse.py', 42), ('statement -> expr SEMICOLON', 'statement', 2, 'p_statement_expr', 'parse.py', 46), ('statement -> macro_def', 'statement', 1, 'p_statement_macro_def', 'parse.py', 50), ('statement -> macro_call', 'statement', 1, 'p_statement_macro_call', 'parse.py', 54), ('assignment -> l_value EQUAL r_value', 'assignment', 3, 'p_assignment', 'parse.py', 58), ('statement -> loop', 'statement', 1, 'p_statement_loop', 'parse.py', 62), ('loop -> WHILE LPAREN expr RPAREN LBRACE statement_list RBRACE', 'loop', 7, 'p_loop', 'parse.py', 66), ('statement -> fun_def', 'statement', 1, 'p_statement_fun_def', 'parse.py', 70), ('fun_def -> FUN ID LPAREN id_list RPAREN LBRACE statement_list RBRACE', 'fun_def', 8, 'p_fun_def', 'parse.py', 74), ('statement -> RETURN expr SEMICOLON', 'statement', 3, 'p_statement_return', 'parse.py', 78), ('id_list -> ID', 'id_list', 1, 'p_id_list_single', 'parse.py', 82), ('id_list -> ID COMMA id_list', 'id_list', 3, 'p_id_list_multi', 'parse.py', 86), ('id_list -> empty', 'id_list', 1, 'p_id_list_empty', 'parse.py', 90), ('conditional -> IF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elif conditional_else', 'conditional', 9, 'p_conditional_full', 'parse.py', 94), ('conditional_elif -> ELIF LPAREN expr RPAREN LBRACE statement_list RBRACE conditional_elif', 'conditional_elif', 8, 'p_conditional_elif', 'parse.py', 99), ('conditional_elif -> empty', 'conditional_elif', 1, 'p_conditional_elif_empty', 'parse.py', 103), ('conditional_else -> ELSE LBRACE statement_list RBRACE', 'conditional_else', 4, 'p_conditional_else', 'parse.py', 107), ('conditional_else -> empty', 'conditional_else', 1, 'p_conditional_else_empty', 'parse.py', 111), ('r_value -> expr', 'r_value', 1, 'p_r_value', 'parse.py', 115), ('l_value -> ID', 'l_value', 1, 'p_l_value_id', 'parse.py', 119), ('l_value -> ID fields', 'l_value', 2, 'p_l_value_record', 'parse.py', 123), ('l_value -> PLACEHOLDER', 'l_value', 1, 'p_l_value_placeholder', 'parse.py', 127), ('l_value -> PLACEHOLDER fields', 'l_value', 2, 'p_l_value_placeholder_record', 'parse.py', 131), ('fields -> LBRACKET expr RBRACKET', 'fields', 3, 'p_fields_single', 'parse.py', 134), ('fields -> LBRACKET expr RBRACKET fields', 'fields', 4, 'p_fields_multi', 'parse.py', 138), ('expr -> alg_op', 'expr', 1, 'p_expr', 'parse.py', 142), ('expr -> STRING', 'expr', 1, 'p_expr_string', 'parse.py', 146), ('expr -> NUMBER', 'expr', 1, 'p_expr_number', 'parse.py', 150), ('expr -> BOOL', 'expr', 1, 'p_expr_bool', 'parse.py', 154), ('expr -> NULL', 'expr', 1, 'p_expr_null', 'parse.py', 158), ('expr -> func_call', 'expr', 1, 'p_expr_func_call', 'parse.py', 162), ('expr -> ID', 'expr', 1, 'p_expr_id', 'parse.py', 166), ('expr -> LPAREN expr RPAREN', 'expr', 3, 'p_expr_parens', 'parse.py', 170), ('expr -> anonymous_fun', 'expr', 1, 'p_expr_anonymous_fun', 'parse.py', 174), ('func_call -> ID LPAREN arg_list RPAREN', 'func_call', 4, 'p_func_call', 'parse.py', 178), ('arg_list -> empty', 'arg_list', 1, 'p_arg_list_empty', 'parse.py', 182), ('arg_list -> expr', 'arg_list', 1, 'p_arg_list_single', 'parse.py', 186), ('arg_list -> expr COMMA arg_list', 'arg_list', 3, 'p_arg_list_multi', 'parse.py', 190), ('alg_op -> expr PLUS expr', 'alg_op', 3, 'p_alg_op', 'parse.py', 197), ('alg_op -> expr MINUS expr', 'alg_op', 3, 'p_alg_op', 'parse.py', 198), ('alg_op -> expr MULTIPLY expr', 'alg_op', 3, 'p_alg_op', 'parse.py', 199), ('alg_op -> expr DIVIDE expr', 'alg_op', 3, 'p_alg_op', 'parse.py', 200), ('expr -> LBRACKET arg_list RBRACKET', 'expr', 3, 'p_expr_list', 'parse.py', 211), ('expr -> LBRACE record_list RBRACE', 'expr', 3, 'p_expr_object', 'parse.py', 215), ('expr -> LPAREN statement_list RPAREN', 'expr', 3, 'p_expr_sequence', 'parse.py', 219), ('record_list -> ID COLON expr', 'record_list', 3, 'p_record_list_single', 'parse.py', 223), ('record_list -> ID COLON expr COMMA record_list', 'record_list', 5, 'p_record_list_multi', 'parse.py', 227), ('record_list -> empty', 'record_list', 1, 'p_record_list_empty', 'parse.py', 231), ('expr -> expr LBRACKET expr RBRACKET', 'expr', 4, 'p_expr_access', 'parse.py', 235), ('expr -> comp_op', 'expr', 1, 'p_expr_comp_op', 'parse.py', 239), ('expr -> PLACEHOLDER', 'expr', 1, 'p_expr_placeholder', 'parse.py', 243), ('comp_op -> expr EQUAL EQUAL expr', 'comp_op', 4, 'p_comp_op_eq', 'parse.py', 247), ('comp_op -> expr BANG EQUAL expr', 'comp_op', 4, 'p_comp_op_neq', 'parse.py', 251), ('comp_op -> expr GT expr', 'comp_op', 3, 'p_comp_op_gt', 'parse.py', 255), ('comp_op -> expr GT EQUAL expr', 'comp_op', 4, 'p_comp_op_gte', 'parse.py', 259), ('comp_op -> expr LT expr', 'comp_op', 3, 'p_comp_op_lt', 'parse.py', 263), ('comp_op -> expr LT EQUAL expr', 'comp_op', 4, 'p_comp_op_lte', 'parse.py', 267), ('expr -> log_op', 'expr', 1, 'p_expr_log_op', 'parse.py', 271), ('log_op -> expr AND expr', 'log_op', 3, 'p_log_op_and', 'parse.py', 275), ('log_op -> expr OR expr', 'log_op', 3, 'p_log_op_or', 'parse.py', 279), ('log_op -> NOT expr', 'log_op', 2, 'p_log_op_not', 'parse.py', 283), ('macro_def -> MAC macro_def_arg_list LBRACE statement_list RBRACE', 'macro_def', 5, 'p_macro_def', 'parse.py', 287), ('macro_def_arg_list -> ATOM macro_def_arg_list_rec', 'macro_def_arg_list', 2, 'p_macro_def_arg_list_start_atom', 'parse.py', 291), ('macro_def_arg_list_rec -> PLACEHOLDER macro_def_arg_list_rec', 'macro_def_arg_list_rec', 2, 'p_macro_def_arg_list_rec_placeholder', 'parse.py', 295), ('macro_def_arg_list_rec -> ATOM macro_def_arg_list_rec', 'macro_def_arg_list_rec', 2, 'p_macro_def_arg_list_rec_atom', 'parse.py', 299), ('macro_def_arg_list_rec -> empty', 'macro_def_arg_list_rec', 1, 'p_macro_def_arg_list_rec_empty', 'parse.py', 303), ('macro_call -> ATOM macro_arg_list SEMICOLON', 'macro_call', 3, 'p_macro_call_atom_start', 'parse.py', 307), ('macro_arg_list -> ATOM macro_arg_list', 'macro_arg_list', 2, 'p_macro_call_arg_list_atom', 'parse.py', 311), ('macro_arg_list -> expr macro_arg_list', 'macro_arg_list', 2, 'p_macro_call_arg_list_expr', 'parse.py', 315), ('macro_arg_list -> empty', 'macro_arg_list', 1, 'p_macro_call_arg_list_empty', 'parse.py', 319), ('anonymous_fun -> LPAREN id_list RPAREN LBRACE statement_list RBRACE', 'anonymous_fun', 6, 'p_anonymous_fun', 'parse.py', 323)] |
#!/usr/bin/env python3
NUMBER_OF_MARKS = 5
def avg(numbers):
return sum(numbers) / len(numbers)
def valid_mark(mark):
return 0 <= mark <= 100
def read_marks(number_of_marks):
marks_read = []
for count in range(number_of_marks):
while True:
mark = int(input(f'Enter mark #{count + 1}: '))
if valid_mark(mark):
break
else:
print('Mark out of range. Try again.')
marks_read.append(mark)
return marks_read
def letter_grade(mark):
if mark > 70:
return 'A'
elif mark > 60:
return 'B'
elif mark > 50:
return 'C'
elif mark > 40:
return 'D'
else:
return 'F'
def print_results(marks):
print()
print(f'Maximum Mark: {max(marks)}')
print(f'Minimum Mark: {min(marks)}')
print(f'Average Mark: {avg(marks):.2f}')
print()
print(f'Grade: {letter_grade(avg(marks))}')
if __name__ == '__main__':
mark_list = read_marks(NUMBER_OF_MARKS)
print_results(mark_list)
| number_of_marks = 5
def avg(numbers):
return sum(numbers) / len(numbers)
def valid_mark(mark):
return 0 <= mark <= 100
def read_marks(number_of_marks):
marks_read = []
for count in range(number_of_marks):
while True:
mark = int(input(f'Enter mark #{count + 1}: '))
if valid_mark(mark):
break
else:
print('Mark out of range. Try again.')
marks_read.append(mark)
return marks_read
def letter_grade(mark):
if mark > 70:
return 'A'
elif mark > 60:
return 'B'
elif mark > 50:
return 'C'
elif mark > 40:
return 'D'
else:
return 'F'
def print_results(marks):
print()
print(f'Maximum Mark: {max(marks)}')
print(f'Minimum Mark: {min(marks)}')
print(f'Average Mark: {avg(marks):.2f}')
print()
print(f'Grade: {letter_grade(avg(marks))}')
if __name__ == '__main__':
mark_list = read_marks(NUMBER_OF_MARKS)
print_results(mark_list) |
class Vertex:
'''This class will create Vertex of Graph, include methods
add neighbours(v) and rem_neighbor(v)'''
def __init__(self, n): # To initiate instance Graph Vertex
self.name = n
self.neighbors = list()
self.color = 'black'
def add_neighbor(self, v): # To add neighbour in graph
if v not in self.neighbors:
self.neighbors.append(v)
self.neighbors.sort()
def rem_neighbor(self, v): # To remove neighbor in graph
if v in self.neighbors:
self.neighbors.remove(v)
class Graph:
'''This Graph Class will implement Graph using adjacency list include
methods add vertex, add edge and dfs triversal that print Vertax label using
adjacency list '''
vertices = {} # create directory
def add_vertex(self, vertex): # To add vertex
if isinstance(vertex, Vertex) and vertex.name not in self.vertices:
self.vertices[vertex.name] = vertex
return True
else:
return False
def add_edge(self, src, dst): # To add Edges
if src in self.vertices and dst in self.vertices:
for key, value in self.vertices.items():
if key == src:
value.add_neighbor(dst)
if key == dst:
value.add_neighbor(src)
return True
else:
return False
def rem_edge(self, src, dst): # To remove Edges
if src in self.vertices and dst in self.vertices:
self.vertices[src].rem_neighbor(dst)
self.vertices[dst].rem_neighbor(src)
print("Edges removed from {} to {}".format(src, dst))
return True
else:
return False
def dfs(self, vertex): # dfs Triversal
vertex.color = 'blue'
for v in vertex.neighbors:
if self.vertices[v].color == 'black':
self.dfs(self.vertices[v])
vertex.color = 'blue'
if vertex.color == 'blue':
for key in sorted(list(self.vertices.keys())):
print(key + str(self.vertices[key].neighbors))
| class Vertex:
"""This class will create Vertex of Graph, include methods
add neighbours(v) and rem_neighbor(v)"""
def __init__(self, n):
self.name = n
self.neighbors = list()
self.color = 'black'
def add_neighbor(self, v):
if v not in self.neighbors:
self.neighbors.append(v)
self.neighbors.sort()
def rem_neighbor(self, v):
if v in self.neighbors:
self.neighbors.remove(v)
class Graph:
"""This Graph Class will implement Graph using adjacency list include
methods add vertex, add edge and dfs triversal that print Vertax label using
adjacency list """
vertices = {}
def add_vertex(self, vertex):
if isinstance(vertex, Vertex) and vertex.name not in self.vertices:
self.vertices[vertex.name] = vertex
return True
else:
return False
def add_edge(self, src, dst):
if src in self.vertices and dst in self.vertices:
for (key, value) in self.vertices.items():
if key == src:
value.add_neighbor(dst)
if key == dst:
value.add_neighbor(src)
return True
else:
return False
def rem_edge(self, src, dst):
if src in self.vertices and dst in self.vertices:
self.vertices[src].rem_neighbor(dst)
self.vertices[dst].rem_neighbor(src)
print('Edges removed from {} to {}'.format(src, dst))
return True
else:
return False
def dfs(self, vertex):
vertex.color = 'blue'
for v in vertex.neighbors:
if self.vertices[v].color == 'black':
self.dfs(self.vertices[v])
vertex.color = 'blue'
if vertex.color == 'blue':
for key in sorted(list(self.vertices.keys())):
print(key + str(self.vertices[key].neighbors)) |
input = [1, 1, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 4, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 3, 1, 1, 2, 1, 2, 1, 3, 3, 4, 1, 4, 1, 1, 3, 1, 1, 5, 1, 1, 1, 1, 4, 1, 1, 5, 1, 1, 1, 4, 1, 5, 1, 1, 1, 3, 1, 1, 5, 3, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 2, 4, 1, 1, 1, 1, 4, 1, 2, 2, 1, 1, 1, 3, 1, 2, 5, 1, 4, 1, 1, 1, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 5, 1, 1, 1, 4, 1, 1, 5, 1, 1, 5, 3, 3, 5, 3, 1, 1,
1, 4, 1, 1, 1, 1, 1, 1, 5, 3, 1, 2, 1, 1, 1, 4, 1, 3, 1, 5, 1, 1, 2, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4, 3, 2, 1, 2, 4, 1, 3, 1, 5, 1, 2, 1, 4, 1, 1, 1, 1, 1, 3, 1, 4, 1, 1, 1, 1, 3, 1, 3, 3, 1, 4, 3, 4, 1, 1, 1, 1, 5, 1, 3, 3, 2, 5, 3, 1, 1, 3, 1, 3, 1, 1, 1, 1, 4, 1, 1, 1, 1, 3, 1, 5, 1, 1, 1, 4, 4, 1, 1, 5, 5, 2, 4, 5, 1, 1, 1, 1, 5, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1]
new_num = 8
reset_num = 6
def getFishCounts(input):
fishes = [0] * (new_num + 1)
for i in input:
fishes[i] += 1
return fishes
def simDay(fishes):
newFishes = [0] * (new_num + 1)
# Move counters down
for i in range(0, new_num):
newFishes[i] = fishes[i + 1]
# Move the zeros back to 7
newFishes[reset_num] += fishes[0]
# Create new fishes
newFishes[8] = fishes[0]
return newFishes
def runSim(input, days):
fishes = getFishCounts(input)
for d in range(days):
fishes = simDay(fishes)
# print(f'Day: {d}: ', fishes)
return sum(fishes)
if __name__ == '__main__':
# test = runSim([3, 4, 3, 1, 2], 80)
# print(test)
isPart1 = False
if isPart1:
total = runSim(input, 80)
print('The answer is:', total)
else:
total = runSim(input, 256)
print('The answer is:', total)
# else:
# total = findWorstVents(filename, False)
# print('The answer is:', total)
| input = [1, 1, 1, 1, 1, 1, 1, 4, 1, 2, 1, 1, 4, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 3, 1, 1, 2, 1, 2, 1, 3, 3, 4, 1, 4, 1, 1, 3, 1, 1, 5, 1, 1, 1, 1, 4, 1, 1, 5, 1, 1, 1, 4, 1, 5, 1, 1, 1, 3, 1, 1, 5, 3, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 2, 4, 1, 1, 1, 1, 4, 1, 2, 2, 1, 1, 1, 3, 1, 2, 5, 1, 4, 1, 1, 1, 3, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 5, 1, 1, 1, 4, 1, 1, 5, 1, 1, 5, 3, 3, 5, 3, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 5, 3, 1, 2, 1, 1, 1, 4, 1, 3, 1, 5, 1, 1, 2, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 4, 3, 2, 1, 2, 4, 1, 3, 1, 5, 1, 2, 1, 4, 1, 1, 1, 1, 1, 3, 1, 4, 1, 1, 1, 1, 3, 1, 3, 3, 1, 4, 3, 4, 1, 1, 1, 1, 5, 1, 3, 3, 2, 5, 3, 1, 1, 3, 1, 3, 1, 1, 1, 1, 4, 1, 1, 1, 1, 3, 1, 5, 1, 1, 1, 4, 4, 1, 1, 5, 5, 2, 4, 5, 1, 1, 1, 1, 5, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 5, 1, 1, 1, 1, 1, 1, 3, 1, 1, 2, 1, 1]
new_num = 8
reset_num = 6
def get_fish_counts(input):
fishes = [0] * (new_num + 1)
for i in input:
fishes[i] += 1
return fishes
def sim_day(fishes):
new_fishes = [0] * (new_num + 1)
for i in range(0, new_num):
newFishes[i] = fishes[i + 1]
newFishes[reset_num] += fishes[0]
newFishes[8] = fishes[0]
return newFishes
def run_sim(input, days):
fishes = get_fish_counts(input)
for d in range(days):
fishes = sim_day(fishes)
return sum(fishes)
if __name__ == '__main__':
is_part1 = False
if isPart1:
total = run_sim(input, 80)
print('The answer is:', total)
else:
total = run_sim(input, 256)
print('The answer is:', total) |
def none_check(value):
if value is None:
return False
else:
return True
def is_empty(any_type_value):
if any_type_value:
return False
else:
return True
| def none_check(value):
if value is None:
return False
else:
return True
def is_empty(any_type_value):
if any_type_value:
return False
else:
return True |
# Link class
class Link:
## Constructor ##
def __init__(self, text = "None", url = "None", status_code = 000): # Not the keyword 'None' so it will still print something
# Dictionary of URL-related content
self.text = text
self.url = url
self.status_code = status_code
# Trims the inside of a string (removing extra whitespace between words)
def trim_inner(self, text):
return " ".join( [string.strip() for string in text.split()] ) # Separate the indiv. words and trim them individually
## OVERLOADS ##
# String representation of the 'Link' class
def __str__(self):
# Format: status code, hyperlinked text, then url (CSV)
text = self.trim_inner(self.text) # Trim internal whitespace;
if not text: # If the string is blank,
text = "N/A" # Give it some text
return f"{self.status_code}, {text}, {self.url}"
# Relational Operators, compared by status code for sorting
# > (less than)
def __lt__(self, other):
return self.status_code < other.status_code
# >= (less than or equal to)
def __le__(self, other):
return self.status_code <= other.status_code
# == (is equal to)
def __eq__(self, other):
return self.staus_code == other.status_code
# != (is not equal to)
def __ne__(self, other):
return self.status_code != other.status_code
# < (greater than)
def __gt__(self, other):
return self.status_code > other.status_code
# <= (greater than or equal to)
def __ge__(self, other):
return self.status_code >= other.status_code
# End of Link class
| class Link:
def __init__(self, text='None', url='None', status_code=0):
self.text = text
self.url = url
self.status_code = status_code
def trim_inner(self, text):
return ' '.join([string.strip() for string in text.split()])
def __str__(self):
text = self.trim_inner(self.text)
if not text:
text = 'N/A'
return f'{self.status_code}, {text}, {self.url}'
def __lt__(self, other):
return self.status_code < other.status_code
def __le__(self, other):
return self.status_code <= other.status_code
def __eq__(self, other):
return self.staus_code == other.status_code
def __ne__(self, other):
return self.status_code != other.status_code
def __gt__(self, other):
return self.status_code > other.status_code
def __ge__(self, other):
return self.status_code >= other.status_code |
template_open = '{{#ctx.payload.aggregations.result.hits.hits.0._source}}'
template_close = template_open.replace('{{#','{{/')
kibana_url = (
"{{ctx.metadata.kibana_url}}/app/kibana#/discover?"
"_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,"
"index:'metricbeat-*',key:query,negate:!f,type:custom,value:''),"
"query:(bool:(must:!((regexp:(kubernetes.pod.name:'{{ctx.metadata.regex}}')),"
"(match:(metricset.name:'state_pod')),"
"(match:(kubernetes.namespace:{{ctx.metadata.namespace}}))))))),"
"index:'metricbeat-*',"
"interval:auto,query:(language:lucene,query:''),"
"regexp:(language:lucene,query:'kubernetes.pod.name:test-nginx-%5B%5E-%5D%20-%5B%5E-%5D%20'),"
"sort:!('@timestamp',desc),time:(from:now%2FM,mode:quick,to:now%2FM))"
"&_g=(refreshInterval:(display:Off,pause:!f,value:0),"
"time:(from:now-15m,mode:quick,to:now))"
)
watch_url = "{{ctx.metadata.kibana_url}}/app/management/insightsAndAlerting/watcher/watches/watch/{{ctx.metadata.name}}/status"
slack_alert_template = "{template_open}*<{kibana_url}|{{{{ctx.metadata.name}}}}>* has `{{{{ctx.payload.aggregations.pods.value}}}}` not ready pod(s) <{watch_url}|[ack]>{{{{#ctx.metadata.docs}}}} <{{{{.}}}}|[docs]>{{{{/ctx.metadata.docs}}}}{template_close}".format(**locals())
email_alert_template = "{template_open}<a href=\"{kibana_url}\">{{{{ctx.metadata.name}}}}</a> has {{{{ctx.payload.aggregations.pods.value}}}} not ready pod(s) <a href=\"{watch_url}\">[ack]</a>{{{{#ctx.metadata.docs}}}} <a href=\"{{{{.}}}}\">[docs]</a>{{{{/ctx.metadata.docs}}}}{template_close}".format(**locals())
k8s_template = {
"metadata": {
"name": "",
"namespace": "",
"regex": "",
"kibana_url": "",
"kibana_dashboard": "",
"docs": "",
"xpack" : {
"type" : "json"
},
},
"trigger": {
"schedule": {
"interval": ""
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"metricbeat-*"
],
"rest_total_hits_as_int": True,
"body": {
"aggs": {
"result": {
"top_hits": {
"size": 1
}
},
"pods": {
"cardinality": {
"field": "kubernetes.pod.name"
}
},
"not_ready": {
"terms": {
"field": "kubernetes.pod.name",
"min_doc_count": 12,
"size": 100
}
}
},
"query": {
"bool": {
"must_not": [],
"must": [],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-{{ctx.metadata.window}}"
}
}
}
]
}
}
}
}
}
},
"condition": {},
"actions": {
"email_admin": {
"throttle_period_in_millis": 300000,
"email": {
"profile": "standard",
"subject": "{{#ctx.payload.aggregations.result.hits.hits.0._source}}{{ctx.metadata.name}} has {{ctx.payload.aggregations.pods.value}} not ready pod(s){{/ctx.payload.aggregations.result.hits.hits.0._source}}",
"body": {
"html": email_alert_template
}
}
},
"notify-slack": {
"throttle_period_in_millis": 300000,
"slack": {
"message": {
"text": slack_alert_template
}
}
}
}
}
metricbeat_template = {
"metadata": {
"window": "300s",
"subject": "No metricbeat data has been recieved in the last 5 minutes!"
},
"trigger": {
"schedule": {
"interval": "60s"
}
},
"input": {
"search": {
"request": {
"search_type": "query_then_fetch",
"indices": [
"metricbeat-*"
],
"rest_total_hits_as_int": True,
"body": {
"query": {
"bool": {
"must": [
{
"match": {
"metricset.name": "state_pod"
}
}
],
"filter": [
{
"range": {
"@timestamp": {
"gte": "now-{{ctx.metadata.window}}"
}
}
}
]
}
}
}
}
}
},
"condition": {
"compare": {
"ctx.payload.hits.total": {
"eq": 0
}
}
},
"actions": {
"email_admin": {
"throttle_period_in_millis": 300000,
"email": {
"profile": "standard",
"subject": "{{ctx.metadata.subject}}",
"body": {
"text": "{{ctx.metadata.message}}"
}
}
},
"notify-slack": {
"throttle_period_in_millis": 300000,
"slack": {
"message": {
"text": "{{ctx.metadata.message}}"
}
}
}
}
}
| template_open = '{{#ctx.payload.aggregations.result.hits.hits.0._source}}'
template_close = template_open.replace('{{#', '{{/')
kibana_url = "{{ctx.metadata.kibana_url}}/app/kibana#/discover?_a=(columns:!(_source),filters:!(('$state':(store:appState),meta:(alias:!n,disabled:!f,index:'metricbeat-*',key:query,negate:!f,type:custom,value:''),query:(bool:(must:!((regexp:(kubernetes.pod.name:'{{ctx.metadata.regex}}')),(match:(metricset.name:'state_pod')),(match:(kubernetes.namespace:{{ctx.metadata.namespace}}))))))),index:'metricbeat-*',interval:auto,query:(language:lucene,query:''),regexp:(language:lucene,query:'kubernetes.pod.name:test-nginx-%5B%5E-%5D%20-%5B%5E-%5D%20'),sort:!('@timestamp',desc),time:(from:now%2FM,mode:quick,to:now%2FM))&_g=(refreshInterval:(display:Off,pause:!f,value:0),time:(from:now-15m,mode:quick,to:now))"
watch_url = '{{ctx.metadata.kibana_url}}/app/management/insightsAndAlerting/watcher/watches/watch/{{ctx.metadata.name}}/status'
slack_alert_template = '{template_open}*<{kibana_url}|{{{{ctx.metadata.name}}}}>* has `{{{{ctx.payload.aggregations.pods.value}}}}` not ready pod(s) <{watch_url}|[ack]>{{{{#ctx.metadata.docs}}}} <{{{{.}}}}|[docs]>{{{{/ctx.metadata.docs}}}}{template_close}'.format(**locals())
email_alert_template = '{template_open}<a href="{kibana_url}">{{{{ctx.metadata.name}}}}</a> has {{{{ctx.payload.aggregations.pods.value}}}} not ready pod(s) <a href="{watch_url}">[ack]</a>{{{{#ctx.metadata.docs}}}} <a href="{{{{.}}}}">[docs]</a>{{{{/ctx.metadata.docs}}}}{template_close}'.format(**locals())
k8s_template = {'metadata': {'name': '', 'namespace': '', 'regex': '', 'kibana_url': '', 'kibana_dashboard': '', 'docs': '', 'xpack': {'type': 'json'}}, 'trigger': {'schedule': {'interval': ''}}, 'input': {'search': {'request': {'search_type': 'query_then_fetch', 'indices': ['metricbeat-*'], 'rest_total_hits_as_int': True, 'body': {'aggs': {'result': {'top_hits': {'size': 1}}, 'pods': {'cardinality': {'field': 'kubernetes.pod.name'}}, 'not_ready': {'terms': {'field': 'kubernetes.pod.name', 'min_doc_count': 12, 'size': 100}}}, 'query': {'bool': {'must_not': [], 'must': [], 'filter': [{'range': {'@timestamp': {'gte': 'now-{{ctx.metadata.window}}'}}}]}}}}}}, 'condition': {}, 'actions': {'email_admin': {'throttle_period_in_millis': 300000, 'email': {'profile': 'standard', 'subject': '{{#ctx.payload.aggregations.result.hits.hits.0._source}}{{ctx.metadata.name}} has {{ctx.payload.aggregations.pods.value}} not ready pod(s){{/ctx.payload.aggregations.result.hits.hits.0._source}}', 'body': {'html': email_alert_template}}}, 'notify-slack': {'throttle_period_in_millis': 300000, 'slack': {'message': {'text': slack_alert_template}}}}}
metricbeat_template = {'metadata': {'window': '300s', 'subject': 'No metricbeat data has been recieved in the last 5 minutes!'}, 'trigger': {'schedule': {'interval': '60s'}}, 'input': {'search': {'request': {'search_type': 'query_then_fetch', 'indices': ['metricbeat-*'], 'rest_total_hits_as_int': True, 'body': {'query': {'bool': {'must': [{'match': {'metricset.name': 'state_pod'}}], 'filter': [{'range': {'@timestamp': {'gte': 'now-{{ctx.metadata.window}}'}}}]}}}}}}, 'condition': {'compare': {'ctx.payload.hits.total': {'eq': 0}}}, 'actions': {'email_admin': {'throttle_period_in_millis': 300000, 'email': {'profile': 'standard', 'subject': '{{ctx.metadata.subject}}', 'body': {'text': '{{ctx.metadata.message}}'}}}, 'notify-slack': {'throttle_period_in_millis': 300000, 'slack': {'message': {'text': '{{ctx.metadata.message}}'}}}}} |
c = get_config()
#Export all the notebooks in the current directory to the sphinx_howto format.
c.NbConvertApp.notebooks = ['*.ipynb']
c.NbConvertApp.export_format = 'latex'
c.NbConvertApp.postprocessor_class = 'PDF'
c.Exporter.template_file = 'custom_article.tplx'
| c = get_config()
c.NbConvertApp.notebooks = ['*.ipynb']
c.NbConvertApp.export_format = 'latex'
c.NbConvertApp.postprocessor_class = 'PDF'
c.Exporter.template_file = 'custom_article.tplx' |
class Solution:
def twoSum(self, nums: List[int], target: int) -> List[List[int]]:
complement = {}
out = []
for i,n in enumerate(nums):
complement[target-n] = i
for i,n in enumerate(nums):
idx = complement.get(n, None)
if idx != None and idx != i:
out.append([nums[idx], nums[i]])
return out
def threeSum(self, nums: List[int]) -> List[List[int]]:
if len(nums) < 3:
return []
nums.sort()
out = []
if set(nums) == {0}:
return [[0,0,0]]
i = 0
while len(nums) >= 3:
l_twosum = self.twoSum(nums[1:], -nums[0])
if l_twosum != None:
for l in l_twosum:
l.append(nums[0])
out.append(l)
nums.pop(0)
for i,l in enumerate(out):
out[i] = sorted(l)
out = list(map(list, set(map(tuple, out))))
return out
| class Solution:
def two_sum(self, nums: List[int], target: int) -> List[List[int]]:
complement = {}
out = []
for (i, n) in enumerate(nums):
complement[target - n] = i
for (i, n) in enumerate(nums):
idx = complement.get(n, None)
if idx != None and idx != i:
out.append([nums[idx], nums[i]])
return out
def three_sum(self, nums: List[int]) -> List[List[int]]:
if len(nums) < 3:
return []
nums.sort()
out = []
if set(nums) == {0}:
return [[0, 0, 0]]
i = 0
while len(nums) >= 3:
l_twosum = self.twoSum(nums[1:], -nums[0])
if l_twosum != None:
for l in l_twosum:
l.append(nums[0])
out.append(l)
nums.pop(0)
for (i, l) in enumerate(out):
out[i] = sorted(l)
out = list(map(list, set(map(tuple, out))))
return out |
#To solve Rat in a maze problem using backtracking
#initializing the size of the maze and soution matrix
N = 4
solution_maze = [ [ 0 for j in range(N) ] for i in range(N) ]
def is_safe(maze, x, y ):
'''A utility function to check if x, y is valid
return true if it is valid move,
return false otherwise
'''
if x >= 0 and x < N and y >= 0 and y < N and maze[x][y] == 1:
return True
return False
def check_if_solution_exists(maze):
if solve_maze(maze) == False:
print("Solution doesn't exist");
return False
# recursive function to solve rat in a maze problem
def solve_maze(maze, x=0,y=0):
'''
This function will make several recursive calls
until we reach to some finding, if we reach to destination
following asafe path, then it prints the solution and return true,
will return false otherwise.
'''
# if (x, y is goal) return True
if x == N - 1 and y == N - 1:
solution_maze[x][y] = 1
print("solution:", solution_maze)
return True
# check if the move is valid
if is_safe(maze, x, y) == True:
# mark x, y as part of solution path
# for(0,0) it sets up 1 in solution maze
solution_maze[x][y] = 1
# Move forward in x direction (recursive call)
if solve_maze(maze, x + 1, y) == True:
return True
# Move down in y direction if moving in x direction is not fruitful
#(recursive call)
if solve_maze(maze, x, y + 1) == True:
return True
#no option for rat to move, backtrack
solution_maze[x][y] = 0
return False
# Driver program to test above function
if __name__ == "__main__":
maze = [ [1, 0, 0, 0],
[1, 1, 0, 1],
[1, 0, 0, 0],
[1, 1, 1, 1] ]
check_if_solution_exists(maze)
| n = 4
solution_maze = [[0 for j in range(N)] for i in range(N)]
def is_safe(maze, x, y):
"""A utility function to check if x, y is valid
return true if it is valid move,
return false otherwise
"""
if x >= 0 and x < N and (y >= 0) and (y < N) and (maze[x][y] == 1):
return True
return False
def check_if_solution_exists(maze):
if solve_maze(maze) == False:
print("Solution doesn't exist")
return False
def solve_maze(maze, x=0, y=0):
"""
This function will make several recursive calls
until we reach to some finding, if we reach to destination
following asafe path, then it prints the solution and return true,
will return false otherwise.
"""
if x == N - 1 and y == N - 1:
solution_maze[x][y] = 1
print('solution:', solution_maze)
return True
if is_safe(maze, x, y) == True:
solution_maze[x][y] = 1
if solve_maze(maze, x + 1, y) == True:
return True
if solve_maze(maze, x, y + 1) == True:
return True
solution_maze[x][y] = 0
return False
if __name__ == '__main__':
maze = [[1, 0, 0, 0], [1, 1, 0, 1], [1, 0, 0, 0], [1, 1, 1, 1]]
check_if_solution_exists(maze) |
# called concatenation sometimes..
str1 = 'abra, '
str2 = 'cadabra. '
str3 = 'i wanna reach out and grab ya.'
combo = str1 + str1 + str2 + str3
# you probably don't remember the song.
print(combo)
# you can also do it this way
print('I heat up', '\n', "I can't cool down", '\n', 'my life is spinning', '\n', 'round and round')
# notice the change in single and double quotes. hopefully the change makes sense.
print('not sure why the space for lines 2,3,4 above.', '\n', "i guess there's more to learn... :)")
| str1 = 'abra, '
str2 = 'cadabra. '
str3 = 'i wanna reach out and grab ya.'
combo = str1 + str1 + str2 + str3
print(combo)
print('I heat up', '\n', "I can't cool down", '\n', 'my life is spinning', '\n', 'round and round')
print('not sure why the space for lines 2,3,4 above.', '\n', "i guess there's more to learn... :)") |
# Licensed under the LGPL: https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html
# For details: https://github.com/PyCQA/astroid/blob/main/LICENSE
# Copyright (c) https://github.com/PyCQA/astroid/blob/main/CONTRIBUTORS.txt
__version__ = "2.11.2"
version = __version__
| __version__ = '2.11.2'
version = __version__ |
def combination(n, r):
r = min(n - r, r)
result = 1
for i in range(n, n - r, -1):
result *= i
for i in range(1, r + 1):
result //= i
return result
N, A, B = map(int, input().split())
v_list = list(map(int, input().split()))
v_list.sort(reverse=True)
mean_max = sum(v_list[:A]) / A
comb = 0
if v_list[0] != v_list[A - 1]:
x = v_list.count(v_list[A - 1])
y = v_list[:A].count(v_list[A - 1])
comb = combination(x, y)
else:
x = v_list.count(v_list[A - 1])
for i in range(A, B + 1):
if v_list[i - 1] == v_list[0]:
comb += combination(x, i)
print("{:.10f}".format(mean_max))
print(comb)
| def combination(n, r):
r = min(n - r, r)
result = 1
for i in range(n, n - r, -1):
result *= i
for i in range(1, r + 1):
result //= i
return result
(n, a, b) = map(int, input().split())
v_list = list(map(int, input().split()))
v_list.sort(reverse=True)
mean_max = sum(v_list[:A]) / A
comb = 0
if v_list[0] != v_list[A - 1]:
x = v_list.count(v_list[A - 1])
y = v_list[:A].count(v_list[A - 1])
comb = combination(x, y)
else:
x = v_list.count(v_list[A - 1])
for i in range(A, B + 1):
if v_list[i - 1] == v_list[0]:
comb += combination(x, i)
print('{:.10f}'.format(mean_max))
print(comb) |
variable1 = input('Variable 1:')
variable2 = input('Variable 2:')
variable1, variable2 = variable2, variable1
print(f"Variable 1: {variable1}")
print(f"Variable 2: {variable2}") | variable1 = input('Variable 1:')
variable2 = input('Variable 2:')
(variable1, variable2) = (variable2, variable1)
print(f'Variable 1: {variable1}')
print(f'Variable 2: {variable2}') |
# Copyright 2014 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or 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.
#
# Build configuration for ctmalloc. This is not a part of the original
# library.
{
'targets': [
{
'target_name': 'ctmalloc_lib',
'type': 'static_library',
'sources': [
'wtf/AsanHooks.cpp',
'wtf/AsanHooks.h',
'wtf/Assertions.h',
'wtf/Atomics.h',
'wtf/BitwiseOperations.h',
'wtf/ByteSwap.h',
'wtf/Compiler.h',
'wtf/config.h',
'wtf/CPU.h',
'wtf/malloc.cpp',
'wtf/PageAllocator.cpp',
'wtf/PageAllocator.h',
'wtf/PartitionAlloc.cpp',
'wtf/PartitionAlloc.h',
'wtf/ProcessID.h',
'wtf/SpinLock.h',
'wtf/WTFExport.h',
],
'defines': [
'CTMALLOC_NDEBUG',
],
'include_dirs': [
'<(src)/third_party/ctmalloc',
],
'all_dependent_settings': {
'defines': [
# We disable debug features of the CtMalloc heap as they are redundant
# given SyzyASan's extensive debug features.
'CTMALLOC_NDEBUG',
],
'include_dirs': [
'<(src)/third_party/ctmalloc',
],
},
},
],
}
| {'targets': [{'target_name': 'ctmalloc_lib', 'type': 'static_library', 'sources': ['wtf/AsanHooks.cpp', 'wtf/AsanHooks.h', 'wtf/Assertions.h', 'wtf/Atomics.h', 'wtf/BitwiseOperations.h', 'wtf/ByteSwap.h', 'wtf/Compiler.h', 'wtf/config.h', 'wtf/CPU.h', 'wtf/malloc.cpp', 'wtf/PageAllocator.cpp', 'wtf/PageAllocator.h', 'wtf/PartitionAlloc.cpp', 'wtf/PartitionAlloc.h', 'wtf/ProcessID.h', 'wtf/SpinLock.h', 'wtf/WTFExport.h'], 'defines': ['CTMALLOC_NDEBUG'], 'include_dirs': ['<(src)/third_party/ctmalloc'], 'all_dependent_settings': {'defines': ['CTMALLOC_NDEBUG'], 'include_dirs': ['<(src)/third_party/ctmalloc']}}]} |
def main():
# Manage input file
input = open(r"C:\Users\lawht\Desktop\Github\ROSALIND\Bioinformatics Stronghold\Complementing a Stand of DNA\Complementing a Stand of DNA\rosalind_revc.txt","r")
DNA_string = input.readline(); # take first line of input file for counting
# Take in input file of DNA string and print out its reverse complement
print(reverse_complement(DNA_string))
input.close()
# Given: A DNA string s of length at most 1000 bp.
# Return: The reverse complement sc of s.
def reverse_complement(s):
sc = "";
for n in reversed(s):
if n == "A":
sc = sc + "T"
elif n == "T":
sc = sc + "A"
elif n == "C":
sc = sc + "G"
elif n == "G":
sc = sc + "C"
else:
continue
return sc
# Manually call main() on the file load
if __name__ == "__main__":
main() | def main():
input = open('C:\\Users\\lawht\\Desktop\\Github\\ROSALIND\\Bioinformatics Stronghold\\Complementing a Stand of DNA\\Complementing a Stand of DNA\\rosalind_revc.txt', 'r')
dna_string = input.readline()
print(reverse_complement(DNA_string))
input.close()
def reverse_complement(s):
sc = ''
for n in reversed(s):
if n == 'A':
sc = sc + 'T'
elif n == 'T':
sc = sc + 'A'
elif n == 'C':
sc = sc + 'G'
elif n == 'G':
sc = sc + 'C'
else:
continue
return sc
if __name__ == '__main__':
main() |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
def part_1(program):
i = 0
while i < len(program):
opcode, a, b, dest = program[i:i+4]
i += 4
assert opcode in {1, 2, 99}, f'Unexpected opcode: {opcode}'
if opcode == 1:
val = program[a] + program[b]
elif opcode == 2:
val = program[a] * program[b]
elif opcode == 99:
return program
program[dest] = val
def part_2(program, goal):
for noun in range(99):
for verb in range(99):
p = program[:]
p[1] = noun
p[2] = verb
p = part_1(p)
if p[0] == goal:
return noun, verb
if __name__ == '__main__':
with open('input.txt') as f:
program = f.readline()
program = [int(i) for i in program.split(',')]
p_1 = program[:]
p_1[1] = 12
p_1[2] = 2
p = part_1(p_1)
print(f'part 1: {p[0]}')
noun, verb = part_2(program, 19690720)
print(f'part 2: noun={noun}\n\tverb={verb}')
| def part_1(program):
i = 0
while i < len(program):
(opcode, a, b, dest) = program[i:i + 4]
i += 4
assert opcode in {1, 2, 99}, f'Unexpected opcode: {opcode}'
if opcode == 1:
val = program[a] + program[b]
elif opcode == 2:
val = program[a] * program[b]
elif opcode == 99:
return program
program[dest] = val
def part_2(program, goal):
for noun in range(99):
for verb in range(99):
p = program[:]
p[1] = noun
p[2] = verb
p = part_1(p)
if p[0] == goal:
return (noun, verb)
if __name__ == '__main__':
with open('input.txt') as f:
program = f.readline()
program = [int(i) for i in program.split(',')]
p_1 = program[:]
p_1[1] = 12
p_1[2] = 2
p = part_1(p_1)
print(f'part 1: {p[0]}')
(noun, verb) = part_2(program, 19690720)
print(f'part 2: noun={noun}\n\tverb={verb}') |
# Copyright 2021 Duan-JM, Sun Aries
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, 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.
# Note: passing both BUILD_SHARED_LIBS=ON and BUILD_STATIC_LIBS=ON to cmake
# still only builds the shared libraries, so we have to choose one or the
# other. We build shared libraries by default, but this variable can be used
# to switch to static libraries.
OPENCV_SHARED_LIBS = False
OPENCV_TAG = "4.5.0"
OPENCV_SO_VERSION = "4.5" # OPENCV_SO_VERSION need to match OPENCV_TAG
# Note: this determines the order in which the libraries are passed to the
# linker, so if library A depends on library B, library B must come _after_.
# Hence core is at the bottom.
OPENCV_MODULES = [
"calib3d",
"features2d",
"flann",
"highgui",
"video",
"videoio",
"imgcodecs",
"imgproc",
"core",
]
OPENCV_THIRD_PARTY_DEPS = [
"liblibjpeg-turbo.a",
"liblibpng.a",
"liblibprotobuf.a",
"libquirc.a",
"libtegra_hal.a",
"libzlib.a",
"libade.a",
"liblibopenjp2.a"
]
| opencv_shared_libs = False
opencv_tag = '4.5.0'
opencv_so_version = '4.5'
opencv_modules = ['calib3d', 'features2d', 'flann', 'highgui', 'video', 'videoio', 'imgcodecs', 'imgproc', 'core']
opencv_third_party_deps = ['liblibjpeg-turbo.a', 'liblibpng.a', 'liblibprotobuf.a', 'libquirc.a', 'libtegra_hal.a', 'libzlib.a', 'libade.a', 'liblibopenjp2.a'] |
fd = open('f',"r")
buffer = fd.read(2)
print("first 2 chars in f:",buffer)
fd.close()
| fd = open('f', 'r')
buffer = fd.read(2)
print('first 2 chars in f:', buffer)
fd.close() |
# from http://www.voidspace.org.uk/python/weblog/arch_d7_2007_03_17.shtml#e664
def ReadOnlyProxy(obj):
class _ReadOnlyProxy(object):
def __getattr__(self, name):
return getattr(obj, name)
def __setattr__(self, name, value):
raise AttributeError("Attributes can't be set on this object")
for name in dir(obj):
if not (name[:2] == '__' == name[-2:]):
continue
if name in ('__new__', '__init__', '__class__', '__bases__'):
continue
if not callable(getattr(obj, name)):
continue
def get_proxy_method(name):
def proxy_method(self, *args, **keywargs):
return getattr(obj, name)(*args, **keywargs)
return proxy_method
setattr(_ReadOnlyProxy, name, get_proxy_method(name))
return _ReadOnlyProxy() | def read_only_proxy(obj):
class _Readonlyproxy(object):
def __getattr__(self, name):
return getattr(obj, name)
def __setattr__(self, name, value):
raise attribute_error("Attributes can't be set on this object")
for name in dir(obj):
if not name[:2] == '__' == name[-2:]:
continue
if name in ('__new__', '__init__', '__class__', '__bases__'):
continue
if not callable(getattr(obj, name)):
continue
def get_proxy_method(name):
def proxy_method(self, *args, **keywargs):
return getattr(obj, name)(*args, **keywargs)
return proxy_method
setattr(_ReadOnlyProxy, name, get_proxy_method(name))
return __read_only_proxy() |
settings = {"velocity_min": 1,
"velocity_max": 3,
"x_boundary": 800,
"y_boundary": 800,
"small_particle_radius": 5,
"big_particle_radius": 10,
"number_of_particles": 500,
"density_min": 2,
"density_max": 20
} | settings = {'velocity_min': 1, 'velocity_max': 3, 'x_boundary': 800, 'y_boundary': 800, 'small_particle_radius': 5, 'big_particle_radius': 10, 'number_of_particles': 500, 'density_min': 2, 'density_max': 20} |
'''8. Write a Python program to count occurrences of a substring in a string.'''
def count_word_in_string(string1, substring2):
return string1.count(substring2)
print(count_word_in_string('The quick brown fox jumps over the lazy dog that is chasing the fox.', "fox")) | """8. Write a Python program to count occurrences of a substring in a string."""
def count_word_in_string(string1, substring2):
return string1.count(substring2)
print(count_word_in_string('The quick brown fox jumps over the lazy dog that is chasing the fox.', 'fox')) |
def read_data():
rules = dict()
your_ticket = None
nearby_tickets = []
state = 0
with open('in') as f:
for line in map(lambda x: x.strip(), f.readlines()):
if line == '':
state += 1
continue
if line == 'your ticket:':
continue
if line == 'nearby tickets:':
continue
if state == 0:
parts = line.split(':')
ranges = parts[1].split('or')
rules[parts[0]] = []
for r in ranges:
nums = r.split('-')
rules[parts[0]].append((int(nums[0]), int(nums[1])))
if state == 1:
your_ticket = list(map(int, line.split(',')))
if state == 2:
nearby_tickets.append(list(map(int, line.split(','))))
return rules, your_ticket, nearby_tickets
def part_one(rules, tickets):
error_rate = 0
invalid_tickets = []
for i, ticket in enumerate(tickets):
for val in ticket:
valid_val = False
for rule in rules.keys():
valid = False
for m, M in rules[rule]:
if val >= m and val <= M:
valid = True
break
if valid:
valid_val = True
break
if not valid_val:
error_rate += val
invalid_tickets.append(i)
return invalid_tickets, error_rate
def part_two(rules, your_ticket, tickets):
possible_values = [set(rules.keys()) for i in range(len(rules.keys()))]
for ticket in tickets:
for i, val in enumerate(ticket):
for rule in rules.keys():
valid = False
for m, M in rules[rule]:
if val >= m and val <= M:
valid = True
break
if not valid and rule in possible_values[i]:
possible_values[i].remove(rule)
while True:
to_filter = False
for v in map(len, possible_values):
if v > 1:
to_filter = True
if not to_filter:
break
for i in range(len(possible_values)):
if len(possible_values[i]) == 1:
for j in range(len(possible_values)):
if i != j:
possible_values[j] -= possible_values[i]
res = 1
for i in range(len(possible_values)):
if 'departure' in list(possible_values[i])[0]:
res *= your_ticket[i]
return res
def main():
rules, your_ticket, nearby_tickets = read_data()
invalid_tickets, error_rate = part_one(rules, nearby_tickets)
p_two = part_two(rules, your_ticket, [t for i, t in enumerate(nearby_tickets) if i not in invalid_tickets])
print(f'Part One: {error_rate}')
print(f'Part Two: {p_two}')
if __name__ == '__main__':
main()
| def read_data():
rules = dict()
your_ticket = None
nearby_tickets = []
state = 0
with open('in') as f:
for line in map(lambda x: x.strip(), f.readlines()):
if line == '':
state += 1
continue
if line == 'your ticket:':
continue
if line == 'nearby tickets:':
continue
if state == 0:
parts = line.split(':')
ranges = parts[1].split('or')
rules[parts[0]] = []
for r in ranges:
nums = r.split('-')
rules[parts[0]].append((int(nums[0]), int(nums[1])))
if state == 1:
your_ticket = list(map(int, line.split(',')))
if state == 2:
nearby_tickets.append(list(map(int, line.split(','))))
return (rules, your_ticket, nearby_tickets)
def part_one(rules, tickets):
error_rate = 0
invalid_tickets = []
for (i, ticket) in enumerate(tickets):
for val in ticket:
valid_val = False
for rule in rules.keys():
valid = False
for (m, m) in rules[rule]:
if val >= m and val <= M:
valid = True
break
if valid:
valid_val = True
break
if not valid_val:
error_rate += val
invalid_tickets.append(i)
return (invalid_tickets, error_rate)
def part_two(rules, your_ticket, tickets):
possible_values = [set(rules.keys()) for i in range(len(rules.keys()))]
for ticket in tickets:
for (i, val) in enumerate(ticket):
for rule in rules.keys():
valid = False
for (m, m) in rules[rule]:
if val >= m and val <= M:
valid = True
break
if not valid and rule in possible_values[i]:
possible_values[i].remove(rule)
while True:
to_filter = False
for v in map(len, possible_values):
if v > 1:
to_filter = True
if not to_filter:
break
for i in range(len(possible_values)):
if len(possible_values[i]) == 1:
for j in range(len(possible_values)):
if i != j:
possible_values[j] -= possible_values[i]
res = 1
for i in range(len(possible_values)):
if 'departure' in list(possible_values[i])[0]:
res *= your_ticket[i]
return res
def main():
(rules, your_ticket, nearby_tickets) = read_data()
(invalid_tickets, error_rate) = part_one(rules, nearby_tickets)
p_two = part_two(rules, your_ticket, [t for (i, t) in enumerate(nearby_tickets) if i not in invalid_tickets])
print(f'Part One: {error_rate}')
print(f'Part Two: {p_two}')
if __name__ == '__main__':
main() |
mapping = {
"settings": {
"index": {
"max_result_window": 15000,
"analysis": {
"analyzer": {
"default": {
"type": "custom",
"tokenizer": "whitespace",
"filter": ["english_stemmer", "lowercase"]
},
"autocomplete": {
"type": "custom",
"tokenizer": "whitespace",
"filter": ["lowercase", "autocomplete_filter"]
},
"symbols": {
"type": "custom",
"tokenizer": "whitespace",
"filter": ["lowercase"]
}
},
"filter": {
"english_stemmer": {
"type": "stemmer",
"language": "english"
},
"autocomplete_filter": {
"type": "edge_ngram",
"min_gram": "1",
"max_gram": "20"
}
}
},
"number_of_replicas": "1", #temporarily
"number_of_shards": "5"
}
},
"mappings": { # having a raw field means it can be a facet or sorted by
"searchable_item": {
"properties": {
"name": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
},
"autocomplete": {
"type": "string",
"analyzer": "autocomplete"
}
}
},
"category": {
"type": "string",
"analyzer": "symbols"
},
"href": {
"type": "string",
"analyzer": "symbols"
},
"description": {
"type": "string"
},
"first_name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"last_name": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"institution": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"position": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"country": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"state": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"colleague_loci": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"number_annotations": {
"type": "integer"
},
"feature_type": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"name_description": {
"type": "string"
},
"summary": {
"type": "string"
},
"phenotypes": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"cellular_component": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"biological_process": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"molecular_function": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"ec_number": {
"type": "string",
"analyzer": "symbols"
},
"protein": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"tc_number": {
"type": "string",
"analyzer": "symbols"
},
"secondary_sgdid": {
"type": "string",
"analyzer": "symbols"
},
"sequence_history": {
"type": "string",
"analyzer": "symbols"
},
"gene_history": {
"type": "string",
"analyzer": "symbols"
},
"bioentity_id": {
"type": "string",
"analyzer": "symbols"
},
"keys": {
"type": "string",
"analyzer": "symbols"
},
"status": {
"type": "string",
"analyzer": "symbols",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"observable": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"qualifier": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"references": {
"type": "string",
"analyzer": "symbols",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"phenotype_loci": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"chemical": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"mutant_type": {
"type": "string",
"fields": {
"symbol": {
"type": "string",
"analyzer": "symbols"
},
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"synonyms": {
"type": "string"
},
"go_id": {
"type": "string",
"analyzer": "symbols"
},
"go_loci": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"author": {
"type": "string",
"analyzer": "symbols",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"journal": {
"type": "string",
"analyzer": "symbols",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"year": {
"type": "string",
"analyzer": "symbols",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"reference_loci": {
"type": "string",
"analyzer": "symbols",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
},
"aliases": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"format": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"keyword": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"file_size": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"readme_url": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"topic": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"data": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
},
"is_quick_flag": {
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
},
"symbol": {
"type": "string",
"analyzer": "symbols"
}
}
}
}
}
}
}
| mapping = {'settings': {'index': {'max_result_window': 15000, 'analysis': {'analyzer': {'default': {'type': 'custom', 'tokenizer': 'whitespace', 'filter': ['english_stemmer', 'lowercase']}, 'autocomplete': {'type': 'custom', 'tokenizer': 'whitespace', 'filter': ['lowercase', 'autocomplete_filter']}, 'symbols': {'type': 'custom', 'tokenizer': 'whitespace', 'filter': ['lowercase']}}, 'filter': {'english_stemmer': {'type': 'stemmer', 'language': 'english'}, 'autocomplete_filter': {'type': 'edge_ngram', 'min_gram': '1', 'max_gram': '20'}}}, 'number_of_replicas': '1', 'number_of_shards': '5'}}, 'mappings': {'searchable_item': {'properties': {'name': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}, 'autocomplete': {'type': 'string', 'analyzer': 'autocomplete'}}}, 'category': {'type': 'string', 'analyzer': 'symbols'}, 'href': {'type': 'string', 'analyzer': 'symbols'}, 'description': {'type': 'string'}, 'first_name': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'last_name': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'institution': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'position': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'country': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'state': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'colleague_loci': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'number_annotations': {'type': 'integer'}, 'feature_type': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'name_description': {'type': 'string'}, 'summary': {'type': 'string'}, 'phenotypes': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'cellular_component': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'biological_process': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'molecular_function': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'ec_number': {'type': 'string', 'analyzer': 'symbols'}, 'protein': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'tc_number': {'type': 'string', 'analyzer': 'symbols'}, 'secondary_sgdid': {'type': 'string', 'analyzer': 'symbols'}, 'sequence_history': {'type': 'string', 'analyzer': 'symbols'}, 'gene_history': {'type': 'string', 'analyzer': 'symbols'}, 'bioentity_id': {'type': 'string', 'analyzer': 'symbols'}, 'keys': {'type': 'string', 'analyzer': 'symbols'}, 'status': {'type': 'string', 'analyzer': 'symbols', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'observable': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'qualifier': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'references': {'type': 'string', 'analyzer': 'symbols', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'phenotype_loci': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'chemical': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'mutant_type': {'type': 'string', 'fields': {'symbol': {'type': 'string', 'analyzer': 'symbols'}, 'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'synonyms': {'type': 'string'}, 'go_id': {'type': 'string', 'analyzer': 'symbols'}, 'go_loci': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'author': {'type': 'string', 'analyzer': 'symbols', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'journal': {'type': 'string', 'analyzer': 'symbols', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'year': {'type': 'string', 'analyzer': 'symbols', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'reference_loci': {'type': 'string', 'analyzer': 'symbols', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}}}, 'aliases': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'format': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'keyword': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'file_size': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'readme_url': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'topic': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'data': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}, 'is_quick_flag': {'type': 'string', 'fields': {'raw': {'type': 'string', 'index': 'not_analyzed'}, 'symbol': {'type': 'string', 'analyzer': 'symbols'}}}}}}} |
'''
https://www.hackerrank.com/challenges/strings-xor/submissions/code/102872134
Given two strings consisting of digits 0 and 1 only, find the XOR of the two strings.
'''
def strings_xor(s, t):
res = ""
for i in range(len(s)):
if s[i] != t[i]:
res += '1'
else:
res += '0'
return res
s = input()
t = input()
print(strings_xor(s, t))
| """
https://www.hackerrank.com/challenges/strings-xor/submissions/code/102872134
Given two strings consisting of digits 0 and 1 only, find the XOR of the two strings.
"""
def strings_xor(s, t):
res = ''
for i in range(len(s)):
if s[i] != t[i]:
res += '1'
else:
res += '0'
return res
s = input()
t = input()
print(strings_xor(s, t)) |
__description__ = "Gearman RPC broker"
__config__ = {
"gearmand.listen_address": dict(
description = "IP address to bind to",
default = "127.0.0.1",
),
"gearmand.user": dict(
display_name = "Gearmand user",
description = "User to run the gearmand procses as",
default = "nobody",
),
"gearmand.pidfile": dict(
display_name = "Gearmand pid file",
description = "Path to the PID file for gearmand",
default = "/var/run/gearmand/gearmand.pid",
),
}
| __description__ = 'Gearman RPC broker'
__config__ = {'gearmand.listen_address': dict(description='IP address to bind to', default='127.0.0.1'), 'gearmand.user': dict(display_name='Gearmand user', description='User to run the gearmand procses as', default='nobody'), 'gearmand.pidfile': dict(display_name='Gearmand pid file', description='Path to the PID file for gearmand', default='/var/run/gearmand/gearmand.pid')} |
bot_token = ''
waiting_timeout = 5 # Seconds
admin_id = ""
channel_id = ""
bitly_access_token = ""
vars_file = ""
| bot_token = ''
waiting_timeout = 5
admin_id = ''
channel_id = ''
bitly_access_token = ''
vars_file = '' |
# parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.5'
_lr_method = 'LALR'
_lr_signature = '5E2BB3531AA676A6BB1D06733251B2F3'
_lr_action_items = {'COS':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[1,1,1,1,1,1,1,1,1,1,-26,1,-32,1,1,1,1,1,-18,-19,1,-52,1,1,-27,-35,-24,1,-28,-37,1,-25,-34,-36,1,-30,-31,-39,1,1,1,-23,-38,-21,1,-29,1,1,-22,1,1,1,1,-47,-40,1,1,1,-7,-42,-49,1,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'COT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[5,5,5,5,5,5,5,5,5,5,-26,5,-32,5,5,5,5,5,-18,-19,5,-52,5,5,-27,-35,-24,5,-28,-37,5,-25,-34,-36,5,-30,-31,-39,5,5,5,-23,-38,-21,5,-29,5,5,-22,5,5,5,5,-47,-40,5,5,5,-7,-42,-49,5,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'DEGREE':([12,14,22,23,27,32,33,34,36,37,39,40,42,44,45,46,50,51,52,54,57,62,63,67,68,69,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[-26,-32,-18,-19,-52,-27,62,-24,-28,69,-25,72,75,-30,-31,78,-23,83,-21,-29,-22,-47,-40,-7,-42,-49,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-28,-33,]),'SUM':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[3,3,3,3,3,3,3,3,3,3,-26,3,-32,3,3,3,3,3,-18,-19,3,-52,3,3,-27,-35,-24,3,-28,-37,3,-25,-34,-36,3,-30,-31,-39,3,3,3,-23,-38,-21,3,-29,3,3,-22,3,3,3,3,-47,-40,3,3,3,-7,-42,-49,3,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'MINUS':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,21,22,23,26,27,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[4,4,4,4,4,4,4,4,4,4,-26,4,-32,4,4,4,4,4,-27,-18,-19,4,-52,4,4,61,-27,61,61,64,-28,61,4,61,61,61,61,64,61,61,61,64,64,4,61,61,61,4,-29,4,4,-22,4,4,4,4,-47,-40,4,4,4,61,-42,-49,64,-45,-46,-20,-41,-48,61,-44,-51,61,61,61,-43,-50,61,61,-14,61,-11,-13,-12,-12,61,-33,]),'LOG':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[2,2,2,2,2,2,2,2,2,2,-26,2,-32,2,2,2,2,2,-18,-19,2,-52,2,2,-27,-35,-24,2,-28,-37,2,-25,-34,-36,2,-30,-31,-39,2,2,2,-23,-38,-21,2,-29,2,2,-22,2,2,2,2,-47,-40,2,2,2,-7,-42,-49,2,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'RAD':([12,14,22,23,27,32,33,34,36,37,39,40,42,44,45,46,50,51,52,54,57,62,63,67,68,69,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[-26,-32,-18,-19,-52,-27,63,-24,-28,68,-25,71,74,-30,-31,77,-23,82,-21,-29,-22,-47,-40,-7,-42,-49,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-28,-33,]),'POWER':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[6,6,6,6,6,6,6,6,6,6,-26,6,-32,6,6,6,6,6,-18,-19,6,-52,6,6,-27,-35,-24,6,-28,-37,6,-25,-34,-36,6,-30,-31,-39,6,6,6,-23,-38,-21,6,-29,6,6,-22,6,6,6,6,-47,-40,6,6,6,-7,-42,-49,6,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'LN':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[7,7,7,7,7,7,7,7,7,7,-26,7,-32,7,7,7,7,7,-18,-19,7,-52,7,7,-27,-35,-24,7,-28,-37,7,-25,-34,-36,7,-30,-31,-39,7,7,7,-23,-38,-21,7,-29,7,7,-22,7,7,7,7,-47,-40,7,7,7,-7,-42,-49,7,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'SIN':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[8,8,8,8,8,8,8,8,8,8,-26,8,-32,8,8,8,8,8,-18,-19,8,-52,8,8,-27,-35,-24,8,-28,-37,8,-25,-34,-36,8,-30,-31,-39,8,8,8,-23,-38,-21,8,-29,8,8,-22,8,8,8,8,-47,-40,8,8,8,-7,-42,-49,8,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'OPAR':([0,1,2,3,4,5,6,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[9,9,9,9,9,9,38,9,9,9,9,-26,9,-32,9,9,9,9,9,-18,-19,9,-52,9,9,-27,-35,-24,9,-28,-37,9,-25,-34,-36,9,-30,-31,-39,9,9,9,-23,-38,-21,9,-29,9,9,-22,9,9,9,9,-47,-40,9,9,9,-7,-42,-49,9,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'SEC':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[29,29,29,29,29,29,29,29,29,29,-26,29,-32,29,29,29,29,29,-18,-19,29,-52,29,29,-27,-35,-24,29,-28,-37,29,-25,-34,-36,29,-30,-31,-39,29,29,29,-23,-38,-21,29,-29,29,29,-22,29,29,29,29,-47,-40,29,29,29,-7,-42,-49,29,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'TAN':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[11,11,11,11,11,11,11,11,11,11,-26,11,-32,11,11,11,11,11,-18,-19,11,-52,11,11,-27,-35,-24,11,-28,-37,11,-25,-34,-36,11,-30,-31,-39,11,11,11,-23,-38,-21,11,-29,11,11,-22,11,11,11,11,-47,-40,11,11,11,-7,-42,-49,11,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'PI':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[12,12,12,12,12,12,12,12,12,12,-26,12,-32,12,12,12,12,12,-18,-19,12,-52,12,12,-27,-35,-24,12,-28,-37,12,-25,-34,-36,12,-30,-31,-39,12,12,12,-23,-38,-21,12,-29,12,12,-22,12,12,12,12,-47,-40,12,12,12,-7,-42,-49,12,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'QUOTIENT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[13,13,13,13,13,13,13,13,13,13,-26,13,-32,13,13,13,13,13,-18,-19,13,-52,13,13,-27,-35,-24,13,-28,-37,13,-25,-34,-36,13,-30,-31,-39,13,13,13,-23,-38,-21,13,-29,13,13,-22,13,13,13,13,-47,-40,13,13,13,-7,-42,-49,13,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'PLUS':([12,14,21,22,23,27,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,54,57,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-27,-18,-19,-52,59,-27,59,59,59,-28,59,59,59,59,59,59,59,59,59,59,59,59,59,59,-29,-22,-47,-40,-29,-22,59,-42,-49,59,-45,-46,-20,-41,-48,59,-44,-51,59,59,59,-43,-50,59,59,-14,59,-11,-13,-12,-12,59,-33,]),'SQUARE':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,21,22,23,26,27,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[15,15,15,15,15,15,15,15,15,15,-26,15,-32,15,15,15,15,15,-27,-18,-19,15,-52,15,15,54,-27,54,54,65,-28,54,15,54,54,54,54,65,54,54,54,65,65,15,54,54,54,15,-29,15,15,-22,15,15,15,15,-47,-40,15,15,15,54,-42,-49,65,-45,-46,-20,-41,-48,54,-44,-51,54,54,54,-43,-50,54,54,-14,54,-11,-13,-12,-12,54,-33,]),'XOR':([12,14,21,22,23,27,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,54,57,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-27,-18,-19,-52,55,-27,55,55,55,-28,55,55,55,55,55,55,55,55,55,55,55,55,55,55,-29,-22,-47,-40,-29,-22,55,-42,-49,55,-45,-46,-20,-41,-48,55,-44,-51,55,55,55,-43,-50,55,55,-14,55,-11,-13,-12,-12,55,-33,]),'DIVIDE':([12,14,21,22,23,27,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,54,57,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-27,-18,-19,-52,56,-27,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,-29,-22,-47,-40,-29,-22,56,-42,-49,56,-45,-46,-20,-41,-48,56,-44,-51,56,56,56,-43,-50,56,56,-14,56,56,-13,56,56,56,-33,]),'SQROOT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[16,16,16,16,16,16,16,16,16,16,-26,16,-32,16,16,16,16,16,-18,-19,16,-52,16,16,-27,-35,-24,16,-28,-37,16,-25,-34,-36,16,-30,-31,-39,16,16,16,-23,-38,-21,16,-29,16,16,-22,16,16,16,16,-47,-40,16,16,16,-7,-42,-49,16,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'CPAR':([12,14,22,23,27,32,33,34,36,37,39,40,41,42,44,45,46,50,51,52,54,57,62,63,67,68,69,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-18,-19,-52,-27,-35,-24,-28,-37,-25,-34,73,-36,-30,-31,-39,-23,-38,-21,-29,-22,-47,-40,-7,-42,-49,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-28,93,-33,]),'EQUALS':([21,],[49,]),'TIMES':([12,14,21,22,23,27,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,54,57,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-27,-18,-19,-52,60,-27,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,60,-29,-22,-47,-40,-29,-22,60,-42,-49,60,-45,-46,-20,-41,-48,60,-44,-51,60,60,60,-43,-50,60,60,-14,60,60,-13,60,60,60,-33,]),'COSEC':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[17,17,17,17,17,17,17,17,17,17,-26,17,-32,17,17,17,17,17,-18,-19,17,-52,17,17,-27,-35,-24,17,-28,-37,17,-25,-34,-36,17,-30,-31,-39,17,17,17,-23,-38,-21,17,-29,17,17,-22,17,17,17,17,-47,-40,17,17,17,-7,-42,-49,17,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'DIFFERENCE':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[18,18,18,18,18,18,18,18,18,18,-26,18,-32,18,18,18,18,18,-18,-19,18,-52,18,18,-27,-35,-24,18,-28,-37,18,-25,-34,-36,18,-30,-31,-39,18,18,18,-23,-38,-21,18,-29,18,18,-22,18,18,18,18,-47,-40,18,18,18,-7,-42,-49,18,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'AND':([12,14,21,22,23,27,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,54,57,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-27,-18,-19,-52,53,-27,53,53,53,-28,53,53,53,53,53,53,53,53,53,53,53,53,53,53,-29,-22,-47,-40,-29,-22,53,-42,-49,53,-45,-46,-20,-41,-48,53,-44,-51,53,53,53,-43,-50,53,53,-14,53,-11,-13,-12,-12,53,-33,]),'QUIT':([0,],[19,]),'PRODUCT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[20,20,20,20,20,20,20,20,20,20,-26,20,-32,20,20,20,20,20,-18,-19,20,-52,20,20,-27,-35,-24,20,-28,-37,20,-25,-34,-36,20,-30,-31,-39,20,20,20,-23,-38,-21,20,-29,20,20,-22,20,20,20,20,-47,-40,20,20,20,-7,-42,-49,20,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'NAME':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[21,32,32,32,32,32,32,32,32,32,-26,32,-32,32,32,32,32,32,-18,-19,32,-52,32,32,-27,-35,-24,32,-28,-37,32,-25,-34,-36,32,-30,-31,-39,32,32,32,-23,-38,-21,32,-29,32,32,-22,32,32,32,32,-47,-40,32,32,32,-7,-42,-49,32,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'INT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[22,22,22,22,22,22,22,22,22,22,-26,22,-32,22,22,22,22,22,-18,-19,22,-52,22,22,-27,-35,-24,22,-28,-37,22,-25,-34,-36,22,-30,-31,-39,22,22,22,-23,-38,-21,22,-29,22,22,-22,22,22,22,22,-47,-40,22,22,22,-7,-42,-49,22,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'FLOAT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[23,23,23,23,23,23,23,23,23,23,-26,23,-32,23,23,23,23,23,-18,-19,23,-52,23,23,-27,-35,-24,23,-28,-37,23,-25,-34,-36,23,-30,-31,-39,23,23,23,-23,-38,-21,23,-29,23,23,-22,23,23,23,23,-47,-40,23,23,23,-7,-42,-49,23,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'BREAK':([0,],[25,]),'FACTORIAL':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,21,22,23,26,27,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[26,26,26,26,26,26,26,26,26,26,-26,26,-32,26,26,26,26,26,-27,-18,-19,26,-52,26,26,57,-27,57,57,66,-28,57,26,57,57,57,57,66,57,57,57,66,66,26,57,57,57,26,-29,26,26,-22,26,26,26,26,-47,-40,26,26,26,57,-42,-49,66,-45,-46,-20,-41,-48,57,-44,-51,57,57,57,-43,-50,57,57,-14,57,-11,-13,-12,-12,57,-33,]),'REGISTERS':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[27,27,27,27,27,27,27,27,27,27,-26,27,-32,27,27,27,27,27,-18,-19,27,-52,27,27,-27,-35,-24,27,-28,-37,27,-25,-34,-36,27,-30,-31,-39,27,27,27,-23,-38,-21,27,-29,27,27,-22,27,27,27,27,-47,-40,27,27,27,-7,-42,-49,27,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'EXIT':([0,],[28,]),'NOT':([0,1,2,3,4,5,7,8,9,11,12,13,14,15,16,17,18,20,22,23,26,27,29,30,32,33,34,35,36,37,38,39,40,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,82,83,84,85,86,87,88,89,90,91,93,],[30,30,30,30,30,30,30,30,30,30,-26,30,-32,30,30,30,30,30,-18,-19,30,-52,30,30,-27,-35,-24,30,-28,-37,30,-25,-34,-36,30,-30,-31,-39,30,30,30,-23,-38,-21,30,-29,30,30,-22,30,30,30,30,-47,-40,30,30,30,-7,-42,-49,30,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-43,-50,-16,-17,-14,-15,-11,-13,-12,-12,-33,]),'$end':([10,12,14,19,21,22,23,24,25,27,28,31,32,33,34,36,37,39,40,42,44,45,46,50,51,52,54,57,62,63,67,68,69,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,93,],[-2,-26,-32,-6,-27,-18,-19,0,-4,-52,-5,-3,-27,-35,-24,-28,-37,-25,-34,-36,-30,-31,-39,-23,-38,-21,-29,-22,-47,-40,-7,-42,-49,-45,-46,-20,-41,-48,-10,-44,-51,-8,-9,-1,-43,-50,-16,-17,-14,-15,-11,-13,-12,-28,-33,]),'OR':([12,14,21,22,23,27,31,32,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,54,57,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,],[-26,-32,-27,-18,-19,-52,58,-27,58,58,58,-28,58,58,58,58,58,58,58,58,58,58,58,58,58,58,-29,-22,-47,-40,-29,-22,58,-42,-49,58,-45,-46,-20,-41,-48,58,-44,-51,58,58,58,-43,-50,58,58,-14,58,-11,-13,-12,-12,58,-33,]),}
_lr_action = {}
for _k, _v in _lr_action_items.items():
for _x,_y in zip(_v[0],_v[1]):
if not _x in _lr_action: _lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'function1':([0,1,2,3,4,5,7,8,9,11,13,15,16,17,18,20,26,29,30,35,38,43,47,48,49,53,55,56,58,59,60,61,64,65,66,70,],[14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,]),'expression':([0,1,2,3,4,5,7,8,9,11,13,15,16,17,18,20,26,29,30,35,38,43,47,48,49,53,55,56,58,59,60,61,64,65,66,70,],[31,33,34,35,36,37,39,40,41,42,43,44,45,46,47,48,50,51,52,67,70,76,79,80,81,84,85,86,87,88,89,90,91,44,50,92,]),'assign':([0,],[24,]),'statement':([0,],[10,]),}
_lr_goto = {}
for _k, _v in _lr_goto_items.items():
for _x, _y in zip(_v[0], _v[1]):
if not _x in _lr_goto: _lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [
("S' -> assign","S'",1,None,None,None),
('assign -> NAME EQUALS expression','assign',3,'p_statement_assign','calc1.py',13),
('assign -> statement','assign',1,'p_statement_assign','calc1.py',14),
('statement -> expression','statement',1,'p_statement_expr','calc1.py',22),
('statement -> BREAK','statement',1,'p_statement_expr','calc1.py',23),
('statement -> EXIT','statement',1,'p_statement_expr','calc1.py',24),
('statement -> QUIT','statement',1,'p_statement_expr','calc1.py',25),
('expression -> SUM expression expression','expression',3,'p_exprr','calc1.py',34),
('expression -> DIFFERENCE expression expression','expression',3,'p_exprr','calc1.py',35),
('expression -> PRODUCT expression expression','expression',3,'p_exprr','calc1.py',36),
('expression -> QUOTIENT expression expression','expression',3,'p_exprr','calc1.py',37),
('expression -> expression PLUS expression','expression',3,'p_expression_binop','calc1.py',50),
('expression -> expression MINUS expression','expression',3,'p_expression_binop','calc1.py',51),
('expression -> expression TIMES expression','expression',3,'p_expression_binop','calc1.py',52),
('expression -> expression DIVIDE expression','expression',3,'p_expression_binop','calc1.py',53),
('expression -> expression OR expression','expression',3,'p_expression_binop','calc1.py',54),
('expression -> expression AND expression','expression',3,'p_expression_binop','calc1.py',55),
('expression -> expression XOR expression','expression',3,'p_expression_binop','calc1.py',56),
('expression -> INT','expression',1,'p_factor','calc1.py',80),
('expression -> FLOAT','expression',1,'p_factor','calc1.py',81),
('expression -> OPAR expression CPAR','expression',3,'p_paran','calc1.py',85),
('expression -> NOT expression','expression',2,'p_logical_not','calc1.py',89),
('expression -> expression FACTORIAL','expression',2,'p_factorial_exp','calc1.py',93),
('expression -> FACTORIAL expression','expression',2,'p_factorial_exp','calc1.py',94),
('expression -> LOG expression','expression',2,'p_logarithms','calc1.py',108),
('expression -> LN expression','expression',2,'p_logarithms','calc1.py',109),
('expression -> PI','expression',1,'p_pival','calc1.py',126),
('expression -> NAME','expression',1,'p_pival','calc1.py',127),
('expression -> MINUS expression','expression',2,'p_uniminus','calc1.py',134),
('expression -> expression SQUARE','expression',2,'p_square_fun','calc1.py',138),
('expression -> SQUARE expression','expression',2,'p_square_fun','calc1.py',139),
('expression -> SQROOT expression','expression',2,'p_square_root','calc1.py',147),
('expression -> function1','expression',1,'p_math_fun','calc1.py',151),
('expression -> POWER OPAR expression expression CPAR','expression',5,'p_math_pow','calc1.py',155),
('function1 -> SIN expression','function1',2,'p_trig_func1','calc1.py',161),
('function1 -> COS expression','function1',2,'p_trig_func1','calc1.py',162),
('function1 -> TAN expression','function1',2,'p_trig_func1','calc1.py',163),
('function1 -> COT expression','function1',2,'p_trig_func1','calc1.py',164),
('function1 -> SEC expression','function1',2,'p_trig_func1','calc1.py',165),
('function1 -> COSEC expression','function1',2,'p_trig_func1','calc1.py',166),
('function1 -> COS expression RAD','function1',3,'p_trig_func1','calc1.py',167),
('function1 -> TAN expression RAD','function1',3,'p_trig_func1','calc1.py',168),
('function1 -> COT expression RAD','function1',3,'p_trig_func1','calc1.py',169),
('function1 -> SEC expression RAD','function1',3,'p_trig_func1','calc1.py',170),
('function1 -> COSEC expression RAD','function1',3,'p_trig_func1','calc1.py',171),
('function1 -> SIN expression RAD','function1',3,'p_trig_func1','calc1.py',172),
('function1 -> SIN expression DEGREE','function1',3,'p_func1','calc1.py',190),
('function1 -> COS expression DEGREE','function1',3,'p_func1','calc1.py',191),
('function1 -> TAN expression DEGREE','function1',3,'p_func1','calc1.py',192),
('function1 -> COT expression DEGREE','function1',3,'p_func1','calc1.py',193),
('function1 -> SEC expression DEGREE','function1',3,'p_func1','calc1.py',194),
('function1 -> COSEC expression DEGREE','function1',3,'p_func1','calc1.py',195),
('expression -> REGISTERS','expression',1,'p_registers','calc1.py',211),
]
| _tabversion = '3.5'
_lr_method = 'LALR'
_lr_signature = '5E2BB3531AA676A6BB1D06733251B2F3'
_lr_action_items = {'COS': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -26, 1, -32, 1, 1, 1, 1, 1, -18, -19, 1, -52, 1, 1, -27, -35, -24, 1, -28, -37, 1, -25, -34, -36, 1, -30, -31, -39, 1, 1, 1, -23, -38, -21, 1, -29, 1, 1, -22, 1, 1, 1, 1, -47, -40, 1, 1, 1, -7, -42, -49, 1, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'COT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [5, 5, 5, 5, 5, 5, 5, 5, 5, 5, -26, 5, -32, 5, 5, 5, 5, 5, -18, -19, 5, -52, 5, 5, -27, -35, -24, 5, -28, -37, 5, -25, -34, -36, 5, -30, -31, -39, 5, 5, 5, -23, -38, -21, 5, -29, 5, 5, -22, 5, 5, 5, 5, -47, -40, 5, 5, 5, -7, -42, -49, 5, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'DEGREE': ([12, 14, 22, 23, 27, 32, 33, 34, 36, 37, 39, 40, 42, 44, 45, 46, 50, 51, 52, 54, 57, 62, 63, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [-26, -32, -18, -19, -52, -27, 62, -24, -28, 69, -25, 72, 75, -30, -31, 78, -23, 83, -21, -29, -22, -47, -40, -7, -42, -49, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -28, -33]), 'SUM': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, -26, 3, -32, 3, 3, 3, 3, 3, -18, -19, 3, -52, 3, 3, -27, -35, -24, 3, -28, -37, 3, -25, -34, -36, 3, -30, -31, -39, 3, 3, 3, -23, -38, -21, 3, -29, 3, 3, -22, 3, 3, 3, 3, -47, -40, 3, 3, 3, -7, -42, -49, 3, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'MINUS': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [4, 4, 4, 4, 4, 4, 4, 4, 4, 4, -26, 4, -32, 4, 4, 4, 4, 4, -27, -18, -19, 4, -52, 4, 4, 61, -27, 61, 61, 64, -28, 61, 4, 61, 61, 61, 61, 64, 61, 61, 61, 64, 64, 4, 61, 61, 61, 4, -29, 4, 4, -22, 4, 4, 4, 4, -47, -40, 4, 4, 4, 61, -42, -49, 64, -45, -46, -20, -41, -48, 61, -44, -51, 61, 61, 61, -43, -50, 61, 61, -14, 61, -11, -13, -12, -12, 61, -33]), 'LOG': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [2, 2, 2, 2, 2, 2, 2, 2, 2, 2, -26, 2, -32, 2, 2, 2, 2, 2, -18, -19, 2, -52, 2, 2, -27, -35, -24, 2, -28, -37, 2, -25, -34, -36, 2, -30, -31, -39, 2, 2, 2, -23, -38, -21, 2, -29, 2, 2, -22, 2, 2, 2, 2, -47, -40, 2, 2, 2, -7, -42, -49, 2, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'RAD': ([12, 14, 22, 23, 27, 32, 33, 34, 36, 37, 39, 40, 42, 44, 45, 46, 50, 51, 52, 54, 57, 62, 63, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [-26, -32, -18, -19, -52, -27, 63, -24, -28, 68, -25, 71, 74, -30, -31, 77, -23, 82, -21, -29, -22, -47, -40, -7, -42, -49, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -28, -33]), 'POWER': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -26, 6, -32, 6, 6, 6, 6, 6, -18, -19, 6, -52, 6, 6, -27, -35, -24, 6, -28, -37, 6, -25, -34, -36, 6, -30, -31, -39, 6, 6, 6, -23, -38, -21, 6, -29, 6, 6, -22, 6, 6, 6, 6, -47, -40, 6, 6, 6, -7, -42, -49, 6, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'LN': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, -26, 7, -32, 7, 7, 7, 7, 7, -18, -19, 7, -52, 7, 7, -27, -35, -24, 7, -28, -37, 7, -25, -34, -36, 7, -30, -31, -39, 7, 7, 7, -23, -38, -21, 7, -29, 7, 7, -22, 7, 7, 7, 7, -47, -40, 7, 7, 7, -7, -42, -49, 7, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'SIN': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [8, 8, 8, 8, 8, 8, 8, 8, 8, 8, -26, 8, -32, 8, 8, 8, 8, 8, -18, -19, 8, -52, 8, 8, -27, -35, -24, 8, -28, -37, 8, -25, -34, -36, 8, -30, -31, -39, 8, 8, 8, -23, -38, -21, 8, -29, 8, 8, -22, 8, 8, 8, 8, -47, -40, 8, 8, 8, -7, -42, -49, 8, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'OPAR': ([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [9, 9, 9, 9, 9, 9, 38, 9, 9, 9, 9, -26, 9, -32, 9, 9, 9, 9, 9, -18, -19, 9, -52, 9, 9, -27, -35, -24, 9, -28, -37, 9, -25, -34, -36, 9, -30, -31, -39, 9, 9, 9, -23, -38, -21, 9, -29, 9, 9, -22, 9, 9, 9, 9, -47, -40, 9, 9, 9, -7, -42, -49, 9, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'SEC': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [29, 29, 29, 29, 29, 29, 29, 29, 29, 29, -26, 29, -32, 29, 29, 29, 29, 29, -18, -19, 29, -52, 29, 29, -27, -35, -24, 29, -28, -37, 29, -25, -34, -36, 29, -30, -31, -39, 29, 29, 29, -23, -38, -21, 29, -29, 29, 29, -22, 29, 29, 29, 29, -47, -40, 29, 29, 29, -7, -42, -49, 29, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'TAN': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [11, 11, 11, 11, 11, 11, 11, 11, 11, 11, -26, 11, -32, 11, 11, 11, 11, 11, -18, -19, 11, -52, 11, 11, -27, -35, -24, 11, -28, -37, 11, -25, -34, -36, 11, -30, -31, -39, 11, 11, 11, -23, -38, -21, 11, -29, 11, 11, -22, 11, 11, 11, 11, -47, -40, 11, 11, 11, -7, -42, -49, 11, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'PI': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [12, 12, 12, 12, 12, 12, 12, 12, 12, 12, -26, 12, -32, 12, 12, 12, 12, 12, -18, -19, 12, -52, 12, 12, -27, -35, -24, 12, -28, -37, 12, -25, -34, -36, 12, -30, -31, -39, 12, 12, 12, -23, -38, -21, 12, -29, 12, 12, -22, 12, 12, 12, 12, -47, -40, 12, 12, 12, -7, -42, -49, 12, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'QUOTIENT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [13, 13, 13, 13, 13, 13, 13, 13, 13, 13, -26, 13, -32, 13, 13, 13, 13, 13, -18, -19, 13, -52, 13, 13, -27, -35, -24, 13, -28, -37, 13, -25, -34, -36, 13, -30, -31, -39, 13, 13, 13, -23, -38, -21, 13, -29, 13, 13, -22, 13, 13, 13, 13, -47, -40, 13, 13, 13, -7, -42, -49, 13, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'PLUS': ([12, 14, 21, 22, 23, 27, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 57, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -27, -18, -19, -52, 59, -27, 59, 59, 59, -28, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, -29, -22, -47, -40, -29, -22, 59, -42, -49, 59, -45, -46, -20, -41, -48, 59, -44, -51, 59, 59, 59, -43, -50, 59, 59, -14, 59, -11, -13, -12, -12, 59, -33]), 'SQUARE': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [15, 15, 15, 15, 15, 15, 15, 15, 15, 15, -26, 15, -32, 15, 15, 15, 15, 15, -27, -18, -19, 15, -52, 15, 15, 54, -27, 54, 54, 65, -28, 54, 15, 54, 54, 54, 54, 65, 54, 54, 54, 65, 65, 15, 54, 54, 54, 15, -29, 15, 15, -22, 15, 15, 15, 15, -47, -40, 15, 15, 15, 54, -42, -49, 65, -45, -46, -20, -41, -48, 54, -44, -51, 54, 54, 54, -43, -50, 54, 54, -14, 54, -11, -13, -12, -12, 54, -33]), 'XOR': ([12, 14, 21, 22, 23, 27, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 57, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -27, -18, -19, -52, 55, -27, 55, 55, 55, -28, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, 55, -29, -22, -47, -40, -29, -22, 55, -42, -49, 55, -45, -46, -20, -41, -48, 55, -44, -51, 55, 55, 55, -43, -50, 55, 55, -14, 55, -11, -13, -12, -12, 55, -33]), 'DIVIDE': ([12, 14, 21, 22, 23, 27, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 57, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -27, -18, -19, -52, 56, -27, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, -29, -22, -47, -40, -29, -22, 56, -42, -49, 56, -45, -46, -20, -41, -48, 56, -44, -51, 56, 56, 56, -43, -50, 56, 56, -14, 56, 56, -13, 56, 56, 56, -33]), 'SQROOT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [16, 16, 16, 16, 16, 16, 16, 16, 16, 16, -26, 16, -32, 16, 16, 16, 16, 16, -18, -19, 16, -52, 16, 16, -27, -35, -24, 16, -28, -37, 16, -25, -34, -36, 16, -30, -31, -39, 16, 16, 16, -23, -38, -21, 16, -29, 16, 16, -22, 16, 16, 16, 16, -47, -40, 16, 16, 16, -7, -42, -49, 16, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'CPAR': ([12, 14, 22, 23, 27, 32, 33, 34, 36, 37, 39, 40, 41, 42, 44, 45, 46, 50, 51, 52, 54, 57, 62, 63, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -18, -19, -52, -27, -35, -24, -28, -37, -25, -34, 73, -36, -30, -31, -39, -23, -38, -21, -29, -22, -47, -40, -7, -42, -49, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -28, 93, -33]), 'EQUALS': ([21], [49]), 'TIMES': ([12, 14, 21, 22, 23, 27, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 57, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -27, -18, -19, -52, 60, -27, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, -29, -22, -47, -40, -29, -22, 60, -42, -49, 60, -45, -46, -20, -41, -48, 60, -44, -51, 60, 60, 60, -43, -50, 60, 60, -14, 60, 60, -13, 60, 60, 60, -33]), 'COSEC': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [17, 17, 17, 17, 17, 17, 17, 17, 17, 17, -26, 17, -32, 17, 17, 17, 17, 17, -18, -19, 17, -52, 17, 17, -27, -35, -24, 17, -28, -37, 17, -25, -34, -36, 17, -30, -31, -39, 17, 17, 17, -23, -38, -21, 17, -29, 17, 17, -22, 17, 17, 17, 17, -47, -40, 17, 17, 17, -7, -42, -49, 17, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'DIFFERENCE': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [18, 18, 18, 18, 18, 18, 18, 18, 18, 18, -26, 18, -32, 18, 18, 18, 18, 18, -18, -19, 18, -52, 18, 18, -27, -35, -24, 18, -28, -37, 18, -25, -34, -36, 18, -30, -31, -39, 18, 18, 18, -23, -38, -21, 18, -29, 18, 18, -22, 18, 18, 18, 18, -47, -40, 18, 18, 18, -7, -42, -49, 18, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'AND': ([12, 14, 21, 22, 23, 27, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 57, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -27, -18, -19, -52, 53, -27, 53, 53, 53, -28, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, 53, -29, -22, -47, -40, -29, -22, 53, -42, -49, 53, -45, -46, -20, -41, -48, 53, -44, -51, 53, 53, 53, -43, -50, 53, 53, -14, 53, -11, -13, -12, -12, 53, -33]), 'QUIT': ([0], [19]), 'PRODUCT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [20, 20, 20, 20, 20, 20, 20, 20, 20, 20, -26, 20, -32, 20, 20, 20, 20, 20, -18, -19, 20, -52, 20, 20, -27, -35, -24, 20, -28, -37, 20, -25, -34, -36, 20, -30, -31, -39, 20, 20, 20, -23, -38, -21, 20, -29, 20, 20, -22, 20, 20, 20, 20, -47, -40, 20, 20, 20, -7, -42, -49, 20, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'NAME': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [21, 32, 32, 32, 32, 32, 32, 32, 32, 32, -26, 32, -32, 32, 32, 32, 32, 32, -18, -19, 32, -52, 32, 32, -27, -35, -24, 32, -28, -37, 32, -25, -34, -36, 32, -30, -31, -39, 32, 32, 32, -23, -38, -21, 32, -29, 32, 32, -22, 32, 32, 32, 32, -47, -40, 32, 32, 32, -7, -42, -49, 32, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'INT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [22, 22, 22, 22, 22, 22, 22, 22, 22, 22, -26, 22, -32, 22, 22, 22, 22, 22, -18, -19, 22, -52, 22, 22, -27, -35, -24, 22, -28, -37, 22, -25, -34, -36, 22, -30, -31, -39, 22, 22, 22, -23, -38, -21, 22, -29, 22, 22, -22, 22, 22, 22, 22, -47, -40, 22, 22, 22, -7, -42, -49, 22, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'FLOAT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [23, 23, 23, 23, 23, 23, 23, 23, 23, 23, -26, 23, -32, 23, 23, 23, 23, 23, -18, -19, 23, -52, 23, 23, -27, -35, -24, 23, -28, -37, 23, -25, -34, -36, 23, -30, -31, -39, 23, 23, 23, -23, -38, -21, 23, -29, 23, 23, -22, 23, 23, 23, 23, -47, -40, 23, 23, 23, -7, -42, -49, 23, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'BREAK': ([0], [25]), 'FACTORIAL': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22, 23, 26, 27, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [26, 26, 26, 26, 26, 26, 26, 26, 26, 26, -26, 26, -32, 26, 26, 26, 26, 26, -27, -18, -19, 26, -52, 26, 26, 57, -27, 57, 57, 66, -28, 57, 26, 57, 57, 57, 57, 66, 57, 57, 57, 66, 66, 26, 57, 57, 57, 26, -29, 26, 26, -22, 26, 26, 26, 26, -47, -40, 26, 26, 26, 57, -42, -49, 66, -45, -46, -20, -41, -48, 57, -44, -51, 57, 57, 57, -43, -50, 57, 57, -14, 57, -11, -13, -12, -12, 57, -33]), 'REGISTERS': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [27, 27, 27, 27, 27, 27, 27, 27, 27, 27, -26, 27, -32, 27, 27, 27, 27, 27, -18, -19, 27, -52, 27, 27, -27, -35, -24, 27, -28, -37, 27, -25, -34, -36, 27, -30, -31, -39, 27, 27, 27, -23, -38, -21, 27, -29, 27, 27, -22, 27, 27, 27, 27, -47, -40, 27, 27, 27, -7, -42, -49, 27, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), 'EXIT': ([0], [28]), 'NOT': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 12, 13, 14, 15, 16, 17, 18, 20, 22, 23, 26, 27, 29, 30, 32, 33, 34, 35, 36, 37, 38, 39, 40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [30, 30, 30, 30, 30, 30, 30, 30, 30, 30, -26, 30, -32, 30, 30, 30, 30, 30, -18, -19, 30, -52, 30, 30, -27, -35, -24, 30, -28, -37, 30, -25, -34, -36, 30, -30, -31, -39, 30, 30, 30, -23, -38, -21, 30, -29, 30, 30, -22, 30, 30, 30, 30, -47, -40, 30, 30, 30, -7, -42, -49, 30, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -43, -50, -16, -17, -14, -15, -11, -13, -12, -12, -33]), '$end': ([10, 12, 14, 19, 21, 22, 23, 24, 25, 27, 28, 31, 32, 33, 34, 36, 37, 39, 40, 42, 44, 45, 46, 50, 51, 52, 54, 57, 62, 63, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 93], [-2, -26, -32, -6, -27, -18, -19, 0, -4, -52, -5, -3, -27, -35, -24, -28, -37, -25, -34, -36, -30, -31, -39, -23, -38, -21, -29, -22, -47, -40, -7, -42, -49, -45, -46, -20, -41, -48, -10, -44, -51, -8, -9, -1, -43, -50, -16, -17, -14, -15, -11, -13, -12, -28, -33]), 'OR': ([12, 14, 21, 22, 23, 27, 31, 32, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 54, 57, 62, 63, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93], [-26, -32, -27, -18, -19, -52, 58, -27, 58, 58, 58, -28, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, 58, -29, -22, -47, -40, -29, -22, 58, -42, -49, 58, -45, -46, -20, -41, -48, 58, -44, -51, 58, 58, 58, -43, -50, 58, 58, -14, 58, -11, -13, -12, -12, 58, -33])}
_lr_action = {}
for (_k, _v) in _lr_action_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_action:
_lr_action[_x] = {}
_lr_action[_x][_k] = _y
del _lr_action_items
_lr_goto_items = {'function1': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 13, 15, 16, 17, 18, 20, 26, 29, 30, 35, 38, 43, 47, 48, 49, 53, 55, 56, 58, 59, 60, 61, 64, 65, 66, 70], [14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14]), 'expression': ([0, 1, 2, 3, 4, 5, 7, 8, 9, 11, 13, 15, 16, 17, 18, 20, 26, 29, 30, 35, 38, 43, 47, 48, 49, 53, 55, 56, 58, 59, 60, 61, 64, 65, 66, 70], [31, 33, 34, 35, 36, 37, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 67, 70, 76, 79, 80, 81, 84, 85, 86, 87, 88, 89, 90, 91, 44, 50, 92]), 'assign': ([0], [24]), 'statement': ([0], [10])}
_lr_goto = {}
for (_k, _v) in _lr_goto_items.items():
for (_x, _y) in zip(_v[0], _v[1]):
if not _x in _lr_goto:
_lr_goto[_x] = {}
_lr_goto[_x][_k] = _y
del _lr_goto_items
_lr_productions = [("S' -> assign", "S'", 1, None, None, None), ('assign -> NAME EQUALS expression', 'assign', 3, 'p_statement_assign', 'calc1.py', 13), ('assign -> statement', 'assign', 1, 'p_statement_assign', 'calc1.py', 14), ('statement -> expression', 'statement', 1, 'p_statement_expr', 'calc1.py', 22), ('statement -> BREAK', 'statement', 1, 'p_statement_expr', 'calc1.py', 23), ('statement -> EXIT', 'statement', 1, 'p_statement_expr', 'calc1.py', 24), ('statement -> QUIT', 'statement', 1, 'p_statement_expr', 'calc1.py', 25), ('expression -> SUM expression expression', 'expression', 3, 'p_exprr', 'calc1.py', 34), ('expression -> DIFFERENCE expression expression', 'expression', 3, 'p_exprr', 'calc1.py', 35), ('expression -> PRODUCT expression expression', 'expression', 3, 'p_exprr', 'calc1.py', 36), ('expression -> QUOTIENT expression expression', 'expression', 3, 'p_exprr', 'calc1.py', 37), ('expression -> expression PLUS expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 50), ('expression -> expression MINUS expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 51), ('expression -> expression TIMES expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 52), ('expression -> expression DIVIDE expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 53), ('expression -> expression OR expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 54), ('expression -> expression AND expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 55), ('expression -> expression XOR expression', 'expression', 3, 'p_expression_binop', 'calc1.py', 56), ('expression -> INT', 'expression', 1, 'p_factor', 'calc1.py', 80), ('expression -> FLOAT', 'expression', 1, 'p_factor', 'calc1.py', 81), ('expression -> OPAR expression CPAR', 'expression', 3, 'p_paran', 'calc1.py', 85), ('expression -> NOT expression', 'expression', 2, 'p_logical_not', 'calc1.py', 89), ('expression -> expression FACTORIAL', 'expression', 2, 'p_factorial_exp', 'calc1.py', 93), ('expression -> FACTORIAL expression', 'expression', 2, 'p_factorial_exp', 'calc1.py', 94), ('expression -> LOG expression', 'expression', 2, 'p_logarithms', 'calc1.py', 108), ('expression -> LN expression', 'expression', 2, 'p_logarithms', 'calc1.py', 109), ('expression -> PI', 'expression', 1, 'p_pival', 'calc1.py', 126), ('expression -> NAME', 'expression', 1, 'p_pival', 'calc1.py', 127), ('expression -> MINUS expression', 'expression', 2, 'p_uniminus', 'calc1.py', 134), ('expression -> expression SQUARE', 'expression', 2, 'p_square_fun', 'calc1.py', 138), ('expression -> SQUARE expression', 'expression', 2, 'p_square_fun', 'calc1.py', 139), ('expression -> SQROOT expression', 'expression', 2, 'p_square_root', 'calc1.py', 147), ('expression -> function1', 'expression', 1, 'p_math_fun', 'calc1.py', 151), ('expression -> POWER OPAR expression expression CPAR', 'expression', 5, 'p_math_pow', 'calc1.py', 155), ('function1 -> SIN expression', 'function1', 2, 'p_trig_func1', 'calc1.py', 161), ('function1 -> COS expression', 'function1', 2, 'p_trig_func1', 'calc1.py', 162), ('function1 -> TAN expression', 'function1', 2, 'p_trig_func1', 'calc1.py', 163), ('function1 -> COT expression', 'function1', 2, 'p_trig_func1', 'calc1.py', 164), ('function1 -> SEC expression', 'function1', 2, 'p_trig_func1', 'calc1.py', 165), ('function1 -> COSEC expression', 'function1', 2, 'p_trig_func1', 'calc1.py', 166), ('function1 -> COS expression RAD', 'function1', 3, 'p_trig_func1', 'calc1.py', 167), ('function1 -> TAN expression RAD', 'function1', 3, 'p_trig_func1', 'calc1.py', 168), ('function1 -> COT expression RAD', 'function1', 3, 'p_trig_func1', 'calc1.py', 169), ('function1 -> SEC expression RAD', 'function1', 3, 'p_trig_func1', 'calc1.py', 170), ('function1 -> COSEC expression RAD', 'function1', 3, 'p_trig_func1', 'calc1.py', 171), ('function1 -> SIN expression RAD', 'function1', 3, 'p_trig_func1', 'calc1.py', 172), ('function1 -> SIN expression DEGREE', 'function1', 3, 'p_func1', 'calc1.py', 190), ('function1 -> COS expression DEGREE', 'function1', 3, 'p_func1', 'calc1.py', 191), ('function1 -> TAN expression DEGREE', 'function1', 3, 'p_func1', 'calc1.py', 192), ('function1 -> COT expression DEGREE', 'function1', 3, 'p_func1', 'calc1.py', 193), ('function1 -> SEC expression DEGREE', 'function1', 3, 'p_func1', 'calc1.py', 194), ('function1 -> COSEC expression DEGREE', 'function1', 3, 'p_func1', 'calc1.py', 195), ('expression -> REGISTERS', 'expression', 1, 'p_registers', 'calc1.py', 211)] |
# The following is a list of gene-plan combinations which should
# not be run
BLACKLIST = [
('8C58', 'performance'), # performance.xml make specific references to 52DC
('7DDA', 'performance') # performance.xml make specific references to 52DC
]
IGNORE = {
'history' : ['uuid', 'creationTool', 'creationDate'],
'genome' : ['uuid', 'creationTool', 'creationDate'],
# the following two ignored because they contain line numbers
'attempt' : ['description'],
'compared' : ['description']
}
| blacklist = [('8C58', 'performance'), ('7DDA', 'performance')]
ignore = {'history': ['uuid', 'creationTool', 'creationDate'], 'genome': ['uuid', 'creationTool', 'creationDate'], 'attempt': ['description'], 'compared': ['description']} |
track = dict(
author_username='alexisbcook',
course_name='Data Cleaning',
course_url='https://www.kaggle.com/learn/data-cleaning',
course_forum_url='https://www.kaggle.com/learn-forum/172650'
)
lessons = [ {'topic': topic_name} for topic_name in
['Handling missing values', #1
'Scaling and normalization', #2
'Parsing dates', #3
'Character encodings', #4
'Inconsistent data entry'] #5
]
notebooks = [
dict(
filename='tut1.ipynb',
lesson_idx=0,
type='tutorial',
dataset_sources=['maxhorowitz/nflplaybyplay2009to2016'],
),
dict(
filename='ex1.ipynb',
lesson_idx=0,
type='exercise',
dataset_sources=['aparnashastry/building-permit-applications-data'],
scriptid=10824396
),
dict(
filename='tut2.ipynb',
lesson_idx=1,
type='tutorial',
),
dict(
filename='ex2.ipynb',
lesson_idx=1,
type='exercise',
dataset_sources=['kemical/kickstarter-projects'],
scriptid=10824404
),
dict(
filename='tut3.ipynb',
lesson_idx=2,
type='tutorial',
dataset_sources=['nasa/landslide-events']
),
dict(
filename='ex3.ipynb',
lesson_idx=2,
type='exercise',
dataset_sources=['usgs/earthquake-database', 'smithsonian/volcanic-eruptions'],
scriptid=10824403
),
dict(
filename='tut4.ipynb',
lesson_idx=3,
type='tutorial',
dataset_sources=['kemical/kickstarter-projects']
),
dict(
filename='ex4.ipynb',
lesson_idx=3,
type='exercise',
dataset_sources=['kwullum/fatal-police-shootings-in-the-us'],
scriptid=10824401
),
dict(
filename='tut5.ipynb',
lesson_idx=4,
type='tutorial',
dataset_sources=['alexisbcook/pakistan-intellectual-capital']
),
dict(
filename='ex5.ipynb',
lesson_idx=4,
type='exercise',
dataset_sources=['alexisbcook/pakistan-intellectual-capital'],
scriptid=10824407
),
] | track = dict(author_username='alexisbcook', course_name='Data Cleaning', course_url='https://www.kaggle.com/learn/data-cleaning', course_forum_url='https://www.kaggle.com/learn-forum/172650')
lessons = [{'topic': topic_name} for topic_name in ['Handling missing values', 'Scaling and normalization', 'Parsing dates', 'Character encodings', 'Inconsistent data entry']]
notebooks = [dict(filename='tut1.ipynb', lesson_idx=0, type='tutorial', dataset_sources=['maxhorowitz/nflplaybyplay2009to2016']), dict(filename='ex1.ipynb', lesson_idx=0, type='exercise', dataset_sources=['aparnashastry/building-permit-applications-data'], scriptid=10824396), dict(filename='tut2.ipynb', lesson_idx=1, type='tutorial'), dict(filename='ex2.ipynb', lesson_idx=1, type='exercise', dataset_sources=['kemical/kickstarter-projects'], scriptid=10824404), dict(filename='tut3.ipynb', lesson_idx=2, type='tutorial', dataset_sources=['nasa/landslide-events']), dict(filename='ex3.ipynb', lesson_idx=2, type='exercise', dataset_sources=['usgs/earthquake-database', 'smithsonian/volcanic-eruptions'], scriptid=10824403), dict(filename='tut4.ipynb', lesson_idx=3, type='tutorial', dataset_sources=['kemical/kickstarter-projects']), dict(filename='ex4.ipynb', lesson_idx=3, type='exercise', dataset_sources=['kwullum/fatal-police-shootings-in-the-us'], scriptid=10824401), dict(filename='tut5.ipynb', lesson_idx=4, type='tutorial', dataset_sources=['alexisbcook/pakistan-intellectual-capital']), dict(filename='ex5.ipynb', lesson_idx=4, type='exercise', dataset_sources=['alexisbcook/pakistan-intellectual-capital'], scriptid=10824407)] |
# !usr/bin/python
# -*- coding: UTF-8 -*-
class Image:
def __init__(self, name, path, url):
self.name = name
self.path = path
self.url = url
@property
def full_path(self):
return self.path + self.name
def __str__(self):
return self.name
def __repr__(self):
return f' {{ Name: {self.name}, \nPath: {self.path}, \nURL:{self.url} }}'
| class Image:
def __init__(self, name, path, url):
self.name = name
self.path = path
self.url = url
@property
def full_path(self):
return self.path + self.name
def __str__(self):
return self.name
def __repr__(self):
return f' {{ Name: {self.name}, \nPath: {self.path}, \nURL:{self.url} }}' |
def metade(preco,sit):
if sit==True:
return (f'R${preco/2}')
else:
return preco/2
def dobro(preco,sit):
if sit==True:
return (f'R${preco * 2}')
else:
return preco * 2
def aumentar(preco,r,sit):
if sit==True:
return (f'R${preco * (100 + r)/100}')
else:
return preco * (100 + r) / 100
def diminuir(preco,r,sit):
if sit==True:
return(f'R${preco * (100 - r)/100}')
else:
return preco * (100-r)/100
def moeda(preco):
return (f'R${preco}')
def resumo(p=0, r=10, q=5):
print('-'*30)
print('RESUMO DO VALOR'.center(30))
print('-' * 30)
print(f'Preco analisado: \t{moeda(p):>10}')
print(f'Dobro do preco: \t{dobro(p, True):>10}')
print(f'Metade do preco: \t{metade(p, True):>10}')
print(f'{r}% de aumento: \t{aumentar(p, r, True):>10}')
print(f'{q}% de reducao: \t{diminuir(p, q, True):>10}') | def metade(preco, sit):
if sit == True:
return f'R${preco / 2}'
else:
return preco / 2
def dobro(preco, sit):
if sit == True:
return f'R${preco * 2}'
else:
return preco * 2
def aumentar(preco, r, sit):
if sit == True:
return f'R${preco * (100 + r) / 100}'
else:
return preco * (100 + r) / 100
def diminuir(preco, r, sit):
if sit == True:
return f'R${preco * (100 - r) / 100}'
else:
return preco * (100 - r) / 100
def moeda(preco):
return f'R${preco}'
def resumo(p=0, r=10, q=5):
print('-' * 30)
print('RESUMO DO VALOR'.center(30))
print('-' * 30)
print(f'Preco analisado: \t{moeda(p):>10}')
print(f'Dobro do preco: \t{dobro(p, True):>10}')
print(f'Metade do preco: \t{metade(p, True):>10}')
print(f'{r}% de aumento: \t{aumentar(p, r, True):>10}')
print(f'{q}% de reducao: \t{diminuir(p, q, True):>10}') |
word=input("enter any word:")
d={}
for x in word:
d[x]=d.get(x,0)+1
for k,v in d.items():
print(k,"occured",v,"times") | word = input('enter any word:')
d = {}
for x in word:
d[x] = d.get(x, 0) + 1
for (k, v) in d.items():
print(k, 'occured', v, 'times') |
#!/usr/bin/env python3
average = 0
score = int(input('Enter first score: '))
score += int(input('Enter second score: '))
score += int(input('Enter third score: '))
average = score / 3.0
average = round(average, 2)
print(f'Total Score: {score}')
print(f'Average Score: {average}')
| average = 0
score = int(input('Enter first score: '))
score += int(input('Enter second score: '))
score += int(input('Enter third score: '))
average = score / 3.0
average = round(average, 2)
print(f'Total Score: {score}')
print(f'Average Score: {average}') |
# Copyright 2022 Huawei Technologies Co., Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, 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.
# ============================================================================
'''
calculate AUC
'''
def calc_auc(raw_arr):
'''
calculate AUC
:param raw_arr:
:return:
'''
arr = sorted(raw_arr, key=lambda d: d[0], reverse=True)
pos, neg = 0., 0.
for record in arr:
if abs(record[1] - 1.) < 0.000001:
pos += 1
else:
neg += 1
fp, tp = 0., 0.
xy_arr = []
for record in arr:
if abs(record[1] - 1.) < 0.000001:
tp += 1
else:
fp += 1
xy_arr.append([fp / neg, tp / pos])
auc = 0.
prev_x = 0.
prev_y = 0.
for x, y in xy_arr:
if x != prev_x:
auc += ((x - prev_x) * (y + prev_y) / 2.)
prev_x = x
prev_y = y
return auc
| """
calculate AUC
"""
def calc_auc(raw_arr):
"""
calculate AUC
:param raw_arr:
:return:
"""
arr = sorted(raw_arr, key=lambda d: d[0], reverse=True)
(pos, neg) = (0.0, 0.0)
for record in arr:
if abs(record[1] - 1.0) < 1e-06:
pos += 1
else:
neg += 1
(fp, tp) = (0.0, 0.0)
xy_arr = []
for record in arr:
if abs(record[1] - 1.0) < 1e-06:
tp += 1
else:
fp += 1
xy_arr.append([fp / neg, tp / pos])
auc = 0.0
prev_x = 0.0
prev_y = 0.0
for (x, y) in xy_arr:
if x != prev_x:
auc += (x - prev_x) * (y + prev_y) / 2.0
prev_x = x
prev_y = y
return auc |
def is_valid(r, c, size):
if 0 <= r < size and 0 <= c < size:
return True
return False
count_presents = int(input())
n = int(input())
matrix = []
nice_kids_count = 0
given_to_nice = 0
for _ in range(n):
data = input().split()
matrix.append(data)
nice_kids_count += data.count("V")
santa_row = int
santa_col = int
for row in range(n):
for col in range(n):
if matrix[row][col] == "S":
santa_row = row
santa_col = col
all_directions = {
"up": (-1, 0),
"down": (1, 0),
"left": (0, -1),
"right": (0, 1)
}
while True:
command = input()
if command == "Christmas morning":
break
next_row = santa_row + all_directions[command][0]
next_col = santa_col + all_directions[command][1]
if is_valid(next_row, next_col, n):
if matrix[next_row][next_col] == "V":
given_to_nice += 1
count_presents -= 1
elif matrix[next_row][next_col] == "C":
for direction in all_directions:
next_step_row = next_row + all_directions[direction][0]
next_step_col = next_col + all_directions[direction][1]
if is_valid(next_step_row, next_step_col, n):
if matrix[next_step_row][next_step_col] == "V":
given_to_nice += 1
count_presents -= 1
elif matrix[next_step_row][next_step_col] == "X":
count_presents -= 1
matrix[next_step_row][next_step_col] = "-"
if count_presents == 0:
break
matrix[santa_row][santa_col] = "-"
matrix[next_row][next_col] = "S"
santa_row = next_row
santa_col = next_col
if count_presents == 0:
break
if count_presents == 0 and nice_kids_count != given_to_nice:
print("Santa ran out of presents!")
for sublist in matrix:
print(" ".join(sublist))
if nice_kids_count == given_to_nice:
print(f"Good job, Santa! {given_to_nice} happy nice kid/s.")
else:
print(f"No presents for {nice_kids_count - given_to_nice} nice kid/s.") | def is_valid(r, c, size):
if 0 <= r < size and 0 <= c < size:
return True
return False
count_presents = int(input())
n = int(input())
matrix = []
nice_kids_count = 0
given_to_nice = 0
for _ in range(n):
data = input().split()
matrix.append(data)
nice_kids_count += data.count('V')
santa_row = int
santa_col = int
for row in range(n):
for col in range(n):
if matrix[row][col] == 'S':
santa_row = row
santa_col = col
all_directions = {'up': (-1, 0), 'down': (1, 0), 'left': (0, -1), 'right': (0, 1)}
while True:
command = input()
if command == 'Christmas morning':
break
next_row = santa_row + all_directions[command][0]
next_col = santa_col + all_directions[command][1]
if is_valid(next_row, next_col, n):
if matrix[next_row][next_col] == 'V':
given_to_nice += 1
count_presents -= 1
elif matrix[next_row][next_col] == 'C':
for direction in all_directions:
next_step_row = next_row + all_directions[direction][0]
next_step_col = next_col + all_directions[direction][1]
if is_valid(next_step_row, next_step_col, n):
if matrix[next_step_row][next_step_col] == 'V':
given_to_nice += 1
count_presents -= 1
elif matrix[next_step_row][next_step_col] == 'X':
count_presents -= 1
matrix[next_step_row][next_step_col] = '-'
if count_presents == 0:
break
matrix[santa_row][santa_col] = '-'
matrix[next_row][next_col] = 'S'
santa_row = next_row
santa_col = next_col
if count_presents == 0:
break
if count_presents == 0 and nice_kids_count != given_to_nice:
print('Santa ran out of presents!')
for sublist in matrix:
print(' '.join(sublist))
if nice_kids_count == given_to_nice:
print(f'Good job, Santa! {given_to_nice} happy nice kid/s.')
else:
print(f'No presents for {nice_kids_count - given_to_nice} nice kid/s.') |
# Setup
opt = ["yes", "no"]
directions = ["left", "right", "forward", "backward"]
# Introduction
name = input("What is your name, HaCKaToOnEr ?\n")
print("Welcome to Toonslate island , " + name + " Let us go on a Minecraft quest!")
print("You find yourself in front of a abandoned mineshaft.")
print("Can you find your way to explore the shaft and find the treasure chest ?\n")
# Start of game
response = ""
while response not in opt:
response = input("Would you like to go inside the Mineshaft?\nyes/no\n")
if response == "yes":
print("You head into the Mineshaft. You hear grumbling sound of zombies,hissing sound of spidersand rattling of skeletons.\n")
elif response == "no":
print("You are not ready for this quest. Goodbye, " + name + ".")
quit()
else:
print("I didn't understand that.\n")
# Next part of game
response = ""
while response not in directions:
print("To your left, you see a skeleton with a golden armor and a bow .")
print("To your right, there is a way to go more inside the shaft.")
print("There is a cobble stone wall directly in front of you.")
print("Behind you is the mineshaft exit.\n")
response = input("What direction would you like to move?\nleft/right/forward/backward\n")
if response == "left":
print(name+" was shot by an arrow. Farewell :( ")
quit()
elif response == "right":
print("You head deeper into the mineshaft and find the treasure chest ,Kudos!!!.\n")
elif response == "forward":
print("You broke the stone walls and find out it was a spider spawner, spiders slain you to deeath\n")
response = ""
elif response == "backward":
print("You leave the mineshaft un explored . Goodbye, " + name + ".")
quit()
else:
print("I didn't understand that.\n")
| opt = ['yes', 'no']
directions = ['left', 'right', 'forward', 'backward']
name = input('What is your name, HaCKaToOnEr ?\n')
print('Welcome to Toonslate island , ' + name + ' Let us go on a Minecraft quest!')
print('You find yourself in front of a abandoned mineshaft.')
print('Can you find your way to explore the shaft and find the treasure chest ?\n')
response = ''
while response not in opt:
response = input('Would you like to go inside the Mineshaft?\nyes/no\n')
if response == 'yes':
print('You head into the Mineshaft. You hear grumbling sound of zombies,hissing sound of spidersand rattling of skeletons.\n')
elif response == 'no':
print('You are not ready for this quest. Goodbye, ' + name + '.')
quit()
else:
print("I didn't understand that.\n")
response = ''
while response not in directions:
print('To your left, you see a skeleton with a golden armor and a bow .')
print('To your right, there is a way to go more inside the shaft.')
print('There is a cobble stone wall directly in front of you.')
print('Behind you is the mineshaft exit.\n')
response = input('What direction would you like to move?\nleft/right/forward/backward\n')
if response == 'left':
print(name + ' was shot by an arrow. Farewell :( ')
quit()
elif response == 'right':
print('You head deeper into the mineshaft and find the treasure chest ,Kudos!!!.\n')
elif response == 'forward':
print('You broke the stone walls and find out it was a spider spawner, spiders slain you to deeath\n')
response = ''
elif response == 'backward':
print('You leave the mineshaft un explored . Goodbye, ' + name + '.')
quit()
else:
print("I didn't understand that.\n") |
#Julian Conneely, 21/03/18
#WhileIF loop with increment
#first 5 is printed
#then it is decreased to 4
#as it is not satisfying i<=2
#it moves on
#then 4 is printed
#then it is decreased to 3
#as it is not satisfying i<=2,it moves on
#then 3 is printed
#then it is decreased to 2
#as now i<=2 has completely satisfied, the loop breaks
i = 5
while True:
print(i)
i=i-1
if i<=2:
break
| i = 5
while True:
print(i)
i = i - 1
if i <= 2:
break |
MIN_CONF = 0.3
NMS_THRESH = 0.3
USE_GPU = False
MIN_DISTANCE = 50
WEIGHT_PATH = "yolov3-tiny.weights"
CONFIG_PATH = "yolov3-tiny.cfg" | min_conf = 0.3
nms_thresh = 0.3
use_gpu = False
min_distance = 50
weight_path = 'yolov3-tiny.weights'
config_path = 'yolov3-tiny.cfg' |
expected_output = {
"address_family":{
"ipv4":{
"bfd_sessions_down":0,
"bfd_sessions_inactive":1,
"bfd_sessions_up":0,
"intf_down":1,
"intf_up":1,
"num_bfd_sessions":1,
"num_intf":2,
"state":{
"all":{
"sessions":2,
"slaves":0,
"total":2
},
"backup":{
"sessions":1,
"slaves":0,
"total":1
},
"init":{
"sessions":1,
"slaves":0,
"total":1
},
"master":{
"sessions":0,
"slaves":0,
"total":0
},
"master(owner)":{
"sessions":0,
"slaves":0,
"total":0
}
},
"virtual_addresses_active":0,
"virtual_addresses_inactive":2,
"vritual_addresses_total":2
},
"ipv6":{
"bfd_sessions_down":0,
"bfd_sessions_inactive":0,
"bfd_sessions_up":0,
"intf_down":0,
"intf_up":1,
"num_bfd_sessions":0,
"num_intf":1,
"state":{
"all":{
"sessions":1,
"slaves":0,
"total":1
},
"backup":{
"sessions":0,
"slaves":0,
"total":0
},
"init":{
"sessions":0,
"slaves":0,
"total":0
},
"master":{
"sessions":1,
"slaves":0,
"total":1
},
"master(owner)":{
"sessions":0,
"slaves":0,
"total":0
}
},
"virtual_addresses_active":1,
"virtual_addresses_inactive":0,
"vritual_addresses_total":1
},
"num_tracked_objects":2,
"tracked_objects_down":2,
"tracked_objects_up":0
}
}
| expected_output = {'address_family': {'ipv4': {'bfd_sessions_down': 0, 'bfd_sessions_inactive': 1, 'bfd_sessions_up': 0, 'intf_down': 1, 'intf_up': 1, 'num_bfd_sessions': 1, 'num_intf': 2, 'state': {'all': {'sessions': 2, 'slaves': 0, 'total': 2}, 'backup': {'sessions': 1, 'slaves': 0, 'total': 1}, 'init': {'sessions': 1, 'slaves': 0, 'total': 1}, 'master': {'sessions': 0, 'slaves': 0, 'total': 0}, 'master(owner)': {'sessions': 0, 'slaves': 0, 'total': 0}}, 'virtual_addresses_active': 0, 'virtual_addresses_inactive': 2, 'vritual_addresses_total': 2}, 'ipv6': {'bfd_sessions_down': 0, 'bfd_sessions_inactive': 0, 'bfd_sessions_up': 0, 'intf_down': 0, 'intf_up': 1, 'num_bfd_sessions': 0, 'num_intf': 1, 'state': {'all': {'sessions': 1, 'slaves': 0, 'total': 1}, 'backup': {'sessions': 0, 'slaves': 0, 'total': 0}, 'init': {'sessions': 0, 'slaves': 0, 'total': 0}, 'master': {'sessions': 1, 'slaves': 0, 'total': 1}, 'master(owner)': {'sessions': 0, 'slaves': 0, 'total': 0}}, 'virtual_addresses_active': 1, 'virtual_addresses_inactive': 0, 'vritual_addresses_total': 1}, 'num_tracked_objects': 2, 'tracked_objects_down': 2, 'tracked_objects_up': 0}} |
class Stack():
def __init__(self):
self.items=[]
def isEmpty(self):
return self.items==[]
def push(self,item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[-1]
def size(self):
return len(self.items)
s=Stack()
s.isEmpty()
s.push(5)
s.push(56)
s.push('sdfg')
s.push(9)
print(s.peek())
print(s.pop())
print(s.peek())
print(s.size())
| class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return self.items == []
def push(self, item):
self.items.append(item)
def pop(self):
return self.items.pop()
def peek(self):
return self.items[-1]
def size(self):
return len(self.items)
s = stack()
s.isEmpty()
s.push(5)
s.push(56)
s.push('sdfg')
s.push(9)
print(s.peek())
print(s.pop())
print(s.peek())
print(s.size()) |
hola = True
adiosguillermomurielsanchezlafuente = True
if (adiosguillermomurielsanchezlafuente
and hola):
print("ok con nombre muy largo")
| hola = True
adiosguillermomurielsanchezlafuente = True
if adiosguillermomurielsanchezlafuente and hola:
print('ok con nombre muy largo') |
for i in range(1, int(input()) + 1):
quadrado = i ** 2
cubo = i ** 3
print(f'{i} {quadrado} {cubo}')
print(f'{i} {quadrado + 1} {cubo + 1}')
| for i in range(1, int(input()) + 1):
quadrado = i ** 2
cubo = i ** 3
print(f'{i} {quadrado} {cubo}')
print(f'{i} {quadrado + 1} {cubo + 1}') |
Scale.default = Scale.chromatic
Root.default = 0
Clock.bpm = 120
var.ch = var(P[1,5,0,3],8)
~p1 >> play('m', amp=.8, dur=PDur(3,8), rate=[1,(1,2)])
~p2 >> play('-', amp=.5, dur=2, hpf=2000, hpr=linvar([.1,1],16), sample=1).often('stutter', 4, dur=3).every(8, 'sample.offadd', 1)
~p3 >> play('{ ppP[pP][Pp]}', amp=.8, dur=.5, sample=PRand(7), rate=PRand([.5,1,2]))
~p4 >> play('V', amp=.8, dur=1)
~p5 >> play('#', amp=1.2, dur=16, drive=.1, chop=128, formant=1)
~s1 >> glass(var.ch+(0,5,12), amp=1, dur=8, coarse=8)
~s2 >> piano(var.ch+(0,[5,5,3,7],12), amp=1, dur=8, delay=(0,.25,.5))
Group(p1, p2, p3).stop()
p4.lpf = linvar([4000,10],[32,0])
p4.stop()
s2.stop()
~s3 >> saw(var.ch+PWalk(), amp=PRand([0,.8])[:24], dur=PDur(3,8), scale=Scale.minor, oct=PRand([4,5,6])[:32], drive=.05, room=1, mix=.5).spread()
~s3 >> saw(var.ch+PWalk(), amp=PRand([0,.8])[:20], dur=PDur(5,8), scale=Scale.minor, oct=PRand([4,5,6])[:32], drive=.05, room=1, mix=.5).spread()
~s3 >> saw(var.ch+PWalk(), amp=PRand([0,.8])[:64], dur=.25, scale=Scale.minor, oct=PRand([4,5,6])[:32], drive=.05, room=1, mix=.5).spread()
~p4 >> play('V', amp=.5, dur=1, room=1, lpf=1200).every(7, 'stutter', cycle=16)
~p6 >> play('n', amp=.5, dur=1, delay=.5, room=1, hpf=linvar([2000,4000],16), hpr=.1)
s1.oct = 4
s1.formant = 1
~p3 >> play('{ ppP[pP][Pp]}', amp=.5, dur=.5, sample=PRand(7), rate=PRand([.5,1,2]), room=1, mix=.25)
Group(p6, s3).stop()
~s2 >> piano(var.ch+([12,0],[5,5,3,7],[0,12]), amp=1, dur=8, delay=(0,.25,.5), room=1, mix=.5, drive=.05, chop=32, echo=[1,2,1,4])
Group(p3, s1).stop()
Clock.clear()
| Scale.default = Scale.chromatic
Root.default = 0
Clock.bpm = 120
var.ch = var(P[1, 5, 0, 3], 8)
~p1 >> play('m', amp=0.8, dur=p_dur(3, 8), rate=[1, (1, 2)])
~p2 >> play('-', amp=0.5, dur=2, hpf=2000, hpr=linvar([0.1, 1], 16), sample=1).often('stutter', 4, dur=3).every(8, 'sample.offadd', 1)
~p3 >> play('{ ppP[pP][Pp]}', amp=0.8, dur=0.5, sample=p_rand(7), rate=p_rand([0.5, 1, 2]))
~p4 >> play('V', amp=0.8, dur=1)
~p5 >> play('#', amp=1.2, dur=16, drive=0.1, chop=128, formant=1)
~s1 >> glass(var.ch + (0, 5, 12), amp=1, dur=8, coarse=8)
~s2 >> piano(var.ch + (0, [5, 5, 3, 7], 12), amp=1, dur=8, delay=(0, 0.25, 0.5))
group(p1, p2, p3).stop()
p4.lpf = linvar([4000, 10], [32, 0])
p4.stop()
s2.stop()
~s3 >> saw(var.ch + p_walk(), amp=p_rand([0, 0.8])[:24], dur=p_dur(3, 8), scale=Scale.minor, oct=p_rand([4, 5, 6])[:32], drive=0.05, room=1, mix=0.5).spread()
~s3 >> saw(var.ch + p_walk(), amp=p_rand([0, 0.8])[:20], dur=p_dur(5, 8), scale=Scale.minor, oct=p_rand([4, 5, 6])[:32], drive=0.05, room=1, mix=0.5).spread()
~s3 >> saw(var.ch + p_walk(), amp=p_rand([0, 0.8])[:64], dur=0.25, scale=Scale.minor, oct=p_rand([4, 5, 6])[:32], drive=0.05, room=1, mix=0.5).spread()
~p4 >> play('V', amp=0.5, dur=1, room=1, lpf=1200).every(7, 'stutter', cycle=16)
~p6 >> play('n', amp=0.5, dur=1, delay=0.5, room=1, hpf=linvar([2000, 4000], 16), hpr=0.1)
s1.oct = 4
s1.formant = 1
~p3 >> play('{ ppP[pP][Pp]}', amp=0.5, dur=0.5, sample=p_rand(7), rate=p_rand([0.5, 1, 2]), room=1, mix=0.25)
group(p6, s3).stop()
~s2 >> piano(var.ch + ([12, 0], [5, 5, 3, 7], [0, 12]), amp=1, dur=8, delay=(0, 0.25, 0.5), room=1, mix=0.5, drive=0.05, chop=32, echo=[1, 2, 1, 4])
group(p3, s1).stop()
Clock.clear() |
def namedArgumentFunction(a, b, c):
print("the values are a: {}, b: {}, c: {}".format(a,b,c))
namedArgumentFunction(100, 200, 300) # positional arguments
namedArgumentFunction(c=3, a=1, b=2) # named arguments
#namedArgumentFunction(181, a=102, b=103) # mix of position + name error
namedArgumentFunction(101, b=102, c=103) # mix of position + no error | def named_argument_function(a, b, c):
print('the values are a: {}, b: {}, c: {}'.format(a, b, c))
named_argument_function(100, 200, 300)
named_argument_function(c=3, a=1, b=2)
named_argument_function(101, b=102, c=103) |
# Basic String Operations (Title)
# Reading
# Iterating over a String with the 'for' Loop (section)
# General Format:
# for variable in string:
# statement
# statement
# etc.
name = 'Juliet'
for ch in name:
print(ch)
# This program counts the number of times the letter T
# (uppercase or lowercase) appears in a string.
# (with 'for' loop)
def main():
count = 0
my_string = input('Enter a sentence: ')
for ch in my_string:
if ch == 'T' or ch == 't':
count += 1
print(f'The letter T appears {count} times.')
if __name__ == '__main__':
main()
# Indexing (section)
my_string = 'Roses are red'
ch = my_string[6]
my_string = 'Roses are red'
print(my_string[0], my_string[6], my_string[10])
# negative numbers
my_string = 'Roses are red'
print(my_string[-1], my_string[-2], my_string[-13])
# IndexError Exceptions (section)
# Occur if index out of range for a particular string
city = 'Boston'
print(city[6])
city = 'Boston'
index = 0
while index < 7:
print(city[index])
index += 1
# The 'len' Function (section)
# useful to prevent loops from iterating beyond the end
# of a string.
city = 'Boston'
size = len(city)
print(size)
city = 'Boston'
index = 0
while index < len(city):
print(city[index])
index += 1
# String Concatenation (section)
name = 'Kelly'
name += ' '
name += 'Yvonne'
name += ' '
name += 'Smith'
print(name)
# Strings are immutable (section)
# This program concatenates strings.
def main():
name = 'Carmen'
print(f'The name is: {name}')
name = name + ' Brown'
print(f'Now the name is: {name}')
if __name__ == '__main__':
main()
# no string[index] on left side of an assignment operator
# Error below
friend = 'Bill'
friend[0] = 'J'
# End
# Checkpoint
# 8.1 Assume the variable 'name' references a string. Write a
# 'for' loop that prints each character in the string.
name = 'name'
for letter in name:
print(letter)
# 8.2 What is the index of the first character in a string?
# A. 0
# 8.3 If a string has 10 characters, what is the index of the
# last character?
# A. 9
# 8.4 What happeneds if you try to use an invalid index to
# access a character in a string?
# A. An IndexError exception will occur if you try to use an
# index that is out of range for a particular string.
# 8.5 How do you find the length of a string?
# A. Use the built-in len function.
# 8.6 What is wrong with the following code?
animal = 'Tiger'
animal [0] = 'L'
# A. The second statement attempts to assign a value to an
# individual character in the string. Strings are immutable,
# however, so the expression animal [0] cannot appear on the
# left side of an assignment operator.
# End | name = 'Juliet'
for ch in name:
print(ch)
def main():
count = 0
my_string = input('Enter a sentence: ')
for ch in my_string:
if ch == 'T' or ch == 't':
count += 1
print(f'The letter T appears {count} times.')
if __name__ == '__main__':
main()
my_string = 'Roses are red'
ch = my_string[6]
my_string = 'Roses are red'
print(my_string[0], my_string[6], my_string[10])
my_string = 'Roses are red'
print(my_string[-1], my_string[-2], my_string[-13])
city = 'Boston'
print(city[6])
city = 'Boston'
index = 0
while index < 7:
print(city[index])
index += 1
city = 'Boston'
size = len(city)
print(size)
city = 'Boston'
index = 0
while index < len(city):
print(city[index])
index += 1
name = 'Kelly'
name += ' '
name += 'Yvonne'
name += ' '
name += 'Smith'
print(name)
def main():
name = 'Carmen'
print(f'The name is: {name}')
name = name + ' Brown'
print(f'Now the name is: {name}')
if __name__ == '__main__':
main()
friend = 'Bill'
friend[0] = 'J'
name = 'name'
for letter in name:
print(letter)
animal = 'Tiger'
animal[0] = 'L' |
height = int(input())
apartments = int(input())
is_first = True
isit = 0
for f in range(height, 0, -1):
for s in range(0, apartments, 1):
if is_first == True:
isit += 1
print(f"L{f}{s}", end=" ")
if isit == apartments:
is_first = False
continue
if is_first == False:
if f % 2 == 0:
print(f"O{f}{s}", end=" ")
else:
print(f"A{f}{s}", end=" ")
print(end="\n")
| height = int(input())
apartments = int(input())
is_first = True
isit = 0
for f in range(height, 0, -1):
for s in range(0, apartments, 1):
if is_first == True:
isit += 1
print(f'L{f}{s}', end=' ')
if isit == apartments:
is_first = False
continue
if is_first == False:
if f % 2 == 0:
print(f'O{f}{s}', end=' ')
else:
print(f'A{f}{s}', end=' ')
print(end='\n') |
#!/usr/bin/python3
# https://practice.geeksforgeeks.org/problems/twice-counter/0
def sol(words):
h = {}
res = 0
for word in words:
h[word] = h[word] + 1 if word in h else 1
for word in h:
if h[word] == 2:
res+=1
return res | def sol(words):
h = {}
res = 0
for word in words:
h[word] = h[word] + 1 if word in h else 1
for word in h:
if h[word] == 2:
res += 1
return res |
class Solution:
# Reverse Format String (Accepted), O(1) time and space
def reverseBits(self, n: int) -> int:
s = '{:032b}'.format(n)[::-1]
return int(s, 2)
# Bit Manipulation (Top Voted), O(1) time and space
def reverseBits(self, n: int) -> int:
ans = 0
for i in range(32):
ans = (ans << 1) + (n & 1)
n >>= 1
return ans
| class Solution:
def reverse_bits(self, n: int) -> int:
s = '{:032b}'.format(n)[::-1]
return int(s, 2)
def reverse_bits(self, n: int) -> int:
ans = 0
for i in range(32):
ans = (ans << 1) + (n & 1)
n >>= 1
return ans |
def count_frequency(a):
freq = dict()
for items in a:
freq[items] = a.count(items)
return freq
def solution(data, n):
frequency = count_frequency(data)
for key, value in frequency.items():
if value > n:
data = list(filter(lambda a: a != key, data))
return data
print(solution([1, 2, 3], 0))
print(solution([5, 10, 15, 10, 7], 1))
print(solution([1, 2, 2, 3, 3, 3, 4, 5, 5], 1))
| def count_frequency(a):
freq = dict()
for items in a:
freq[items] = a.count(items)
return freq
def solution(data, n):
frequency = count_frequency(data)
for (key, value) in frequency.items():
if value > n:
data = list(filter(lambda a: a != key, data))
return data
print(solution([1, 2, 3], 0))
print(solution([5, 10, 15, 10, 7], 1))
print(solution([1, 2, 2, 3, 3, 3, 4, 5, 5], 1)) |
# Copyright 2020 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, 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.
# [START root_tag]
# [START nested_tag]
def nested_method():
return 'nested'
# [END nested_tag]
def root_method():
return 'root'
# [END root_tag]
# [START root_tag]
def another_root_method():
return 'another root'
# [END root_tag]
| def nested_method():
return 'nested'
def root_method():
return 'root'
def another_root_method():
return 'another root' |
inventory = {'croissant': 19, 'bagel': 4, 'muffin': 8, 'cake': 1}
print(f'{inventory =}')
stock_list = inventory.copy()
print(f'{stock_list =}')
stock_list['hot cheetos'] = 25
stock_list.update({'cookie' : 18})
stock_list.pop('cake')
print(f'{stock_list =}') | inventory = {'croissant': 19, 'bagel': 4, 'muffin': 8, 'cake': 1}
print(f'inventory ={inventory!r}')
stock_list = inventory.copy()
print(f'stock_list ={stock_list!r}')
stock_list['hot cheetos'] = 25
stock_list.update({'cookie': 18})
stock_list.pop('cake')
print(f'stock_list ={stock_list!r}') |
#Program to change a given string to a new string where the first and last chars have been exchanged.
string=str(input("Enter a string :"))
first=string[0] #store first index element of string in variable
last=string[-1] #store last index element of string in variable
new=last+string[1:-1]+first #concatenate last the middle part and first part
print(new)
| string = str(input('Enter a string :'))
first = string[0]
last = string[-1]
new = last + string[1:-1] + first
print(new) |
# Make sure to rename this file as "config.py" before running the bot.
verbose=True
api_token='0000000000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
# Enter the user ID and a readable name for each user in your group.
# TODO make balaguer automatically collect user IDs.
# But that's only useful if the bot actually gathers widespread usage.
all_users={
000000000: 'Readable Name',
000000000: 'Readable Name',
000000000: 'Readable Name',
000000000: 'Readable Name',
}
# A list containing the user IDs of who can access the admin features of the bot.
admins = [000000000,
000000000,
000000000,
000000000]
# A list of the groups where the bot is allowed to operate (usually the main group and an admin test group)
approved_groups = [-000000000,
-000000000] | verbose = True
api_token = '0000000000:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
all_users = {0: 'Readable Name', 0: 'Readable Name', 0: 'Readable Name', 0: 'Readable Name'}
admins = [0, 0, 0, 0]
approved_groups = [-0, -0] |
class GameException(Exception):
pass
class GameFlowException(GameException):
pass
class EndProgram(GameFlowException):
pass
class InvalidPlayException(GameException):
pass
| class Gameexception(Exception):
pass
class Gameflowexception(GameException):
pass
class Endprogram(GameFlowException):
pass
class Invalidplayexception(GameException):
pass |
def count_vowels(txt):
vs = "a, e, i, o, u".split(', ')
return sum([1 for t in txt if t in vs])
print(count_vowels('Hello world')) | def count_vowels(txt):
vs = 'a, e, i, o, u'.split(', ')
return sum([1 for t in txt if t in vs])
print(count_vowels('Hello world')) |
class KarmaCard(object):
info = {'type': ['number', 'wild'],
'trait': ['4', '5', '6', '7', '8', '9', 'J', 'Q', 'K', 'A', '2', '3', '10', 'draw'],
'order': ['4:4', '4:3', '4:2', '4:1', '5:4', '5:3', '5:2', '5:1', '6:4', '6:3', '6:2', '6:1',
'7:4', '7:3', '7:2', '7:1', '8:4', '8:3', '8:2', '8:1', '9:4', '9:3', '9:2', '9:1',
'J:4', 'J:3', 'J:2', 'J:1', 'Q:4', 'Q:3', 'Q:2', 'Q:1', 'K:1', 'K:2', 'K:3', 'K:4',
'A:1', 'A:2', 'A:3', 'A:4', '2:1', '2:2', '2:3', '2:4', '3:1', '3:2', '3:3', '3:4',
'10:1', '10:2', '10:3', '10:4', 'draw:1'],
'order_start': ['4:4', '4:3', '4:2', '4:1', '5:4', '5:3', '5:2', '5:1', '6:4', '6:3', '6:2', '6:1',
'7:4', '7:3', '7:2', '7:1', '8:4', '8:3', '8:2', '8:1', '9:4', '9:3', '9:2', '9:1',
'J:1', 'J:2', 'J:3', 'J:4', 'Q:1', 'Q:2', 'Q:3', 'Q:4', 'K:1', 'K:2', 'K:3', 'K:4',
'A:1', 'A:2', 'A:3', 'A:4', '2:1', '2:2', '2:3', '2:4', '3:1', '3:2', '3:3', '3:4',
'10:1', '10:2', '10:3', '10:4', 'draw:1']
}
def __init__(self, card_type, trait):
''' Initialize the class of UnoCard
Args:
card_type (str): The type of card
trait (str): The trait of card
'''
self.type = card_type
self.trait = trait
self.str = self.get_str()
def get_str(self):
''' Get the string representation of card
Return:
(str): The string of card's trait
'''
return self.trait
def get_index(self):
''' Get the index of trait
Return:
(int): The index of card's trait (value)
'''
return self.info['trait'].index(self.trait)
@staticmethod
def print_cards(cards):
''' Print out card in a nice form
Args:
card (str or list): The string form or a list of a Karma card
'''
if isinstance(cards, str):
cards = [cards]
for i, card in enumerate(cards):
print(card, end='')
if i < len(cards) - 1:
print(', ', end='')
| class Karmacard(object):
info = {'type': ['number', 'wild'], 'trait': ['4', '5', '6', '7', '8', '9', 'J', 'Q', 'K', 'A', '2', '3', '10', 'draw'], 'order': ['4:4', '4:3', '4:2', '4:1', '5:4', '5:3', '5:2', '5:1', '6:4', '6:3', '6:2', '6:1', '7:4', '7:3', '7:2', '7:1', '8:4', '8:3', '8:2', '8:1', '9:4', '9:3', '9:2', '9:1', 'J:4', 'J:3', 'J:2', 'J:1', 'Q:4', 'Q:3', 'Q:2', 'Q:1', 'K:1', 'K:2', 'K:3', 'K:4', 'A:1', 'A:2', 'A:3', 'A:4', '2:1', '2:2', '2:3', '2:4', '3:1', '3:2', '3:3', '3:4', '10:1', '10:2', '10:3', '10:4', 'draw:1'], 'order_start': ['4:4', '4:3', '4:2', '4:1', '5:4', '5:3', '5:2', '5:1', '6:4', '6:3', '6:2', '6:1', '7:4', '7:3', '7:2', '7:1', '8:4', '8:3', '8:2', '8:1', '9:4', '9:3', '9:2', '9:1', 'J:1', 'J:2', 'J:3', 'J:4', 'Q:1', 'Q:2', 'Q:3', 'Q:4', 'K:1', 'K:2', 'K:3', 'K:4', 'A:1', 'A:2', 'A:3', 'A:4', '2:1', '2:2', '2:3', '2:4', '3:1', '3:2', '3:3', '3:4', '10:1', '10:2', '10:3', '10:4', 'draw:1']}
def __init__(self, card_type, trait):
""" Initialize the class of UnoCard
Args:
card_type (str): The type of card
trait (str): The trait of card
"""
self.type = card_type
self.trait = trait
self.str = self.get_str()
def get_str(self):
""" Get the string representation of card
Return:
(str): The string of card's trait
"""
return self.trait
def get_index(self):
""" Get the index of trait
Return:
(int): The index of card's trait (value)
"""
return self.info['trait'].index(self.trait)
@staticmethod
def print_cards(cards):
""" Print out card in a nice form
Args:
card (str or list): The string form or a list of a Karma card
"""
if isinstance(cards, str):
cards = [cards]
for (i, card) in enumerate(cards):
print(card, end='')
if i < len(cards) - 1:
print(', ', end='') |
def test_see_for_top_level(result):
assert (
"usage: vantage [-a PATH] [-e NAME ...] [-v KEY=[VALUE] ...] [--verbose] [-h] COMMAND..."
in result.stdout_
)
| def test_see_for_top_level(result):
assert 'usage: vantage [-a PATH] [-e NAME ...] [-v KEY=[VALUE] ...] [--verbose] [-h] COMMAND...' in result.stdout_ |
def wordBreakDP(word, dic):
n = len(word)
if word in dic:
return True
if len(dic) == 0:
return False
dp = [False for i in range(n + 1)]
dp[0] = True
for i in range(1, n + 1):
for j in range(i - 1, -1, -1):
if dp[j] == True:
substring = word[j:i]
if substring in dic:
dp[i] = True
break
return dp[-1]
def wordBreakRecursive(word, dic, startIndex=0):
if word in dic:
return True
if len(dic) == 0:
return false
if startIndex == len(word):
return True
for endIndex in range(startIndex + 1, len(word) + 1):
if word[startIndex: endIndex] in dic and wordBreakRecursive(word, dic, endIndex):
return True
return False
def wordBreakMemo(word, dic, startIndex=0, memo=None):
if word in dic:
return True
if len(dic) == 0:
return False
if memo == None:
memo = dict()
if startIndex in memo:
return memo[startIndex]
for endIndex in range(startIndex + 1, len(word) + 1):
if word[startIndex: endIndex] in dic and wordBreakRecursive(word, dic, endIndex):
memo[startIndex] = True
return memo[startIndex]
memo[startIndex] = False
return memo[startIndex]
word = "papapapokerface"
dic = {"pa", "poker", "face"}
print(wordBreakDP(word, dic))
print(wordBreakRecursive(word, dic))
print(wordBreakMemo(word, dic))
| def word_break_dp(word, dic):
n = len(word)
if word in dic:
return True
if len(dic) == 0:
return False
dp = [False for i in range(n + 1)]
dp[0] = True
for i in range(1, n + 1):
for j in range(i - 1, -1, -1):
if dp[j] == True:
substring = word[j:i]
if substring in dic:
dp[i] = True
break
return dp[-1]
def word_break_recursive(word, dic, startIndex=0):
if word in dic:
return True
if len(dic) == 0:
return false
if startIndex == len(word):
return True
for end_index in range(startIndex + 1, len(word) + 1):
if word[startIndex:endIndex] in dic and word_break_recursive(word, dic, endIndex):
return True
return False
def word_break_memo(word, dic, startIndex=0, memo=None):
if word in dic:
return True
if len(dic) == 0:
return False
if memo == None:
memo = dict()
if startIndex in memo:
return memo[startIndex]
for end_index in range(startIndex + 1, len(word) + 1):
if word[startIndex:endIndex] in dic and word_break_recursive(word, dic, endIndex):
memo[startIndex] = True
return memo[startIndex]
memo[startIndex] = False
return memo[startIndex]
word = 'papapapokerface'
dic = {'pa', 'poker', 'face'}
print(word_break_dp(word, dic))
print(word_break_recursive(word, dic))
print(word_break_memo(word, dic)) |
file1= "db_breakfast_menu.txt"
file2= "db_lunch_menu.txt"
file3= "db_dinner_menu.txt"
file4 = "db_label_text.txt"
retail = []
title = []
label = []
with open(file1, "r") as f:
data = f.readlines()
for line in data:
w = line.split(":")
title.append(w[1])
for line in data:
w = line.split("$")
price = w[1]
price.rstrip('\n')
conv = float(price)
retail.append(conv)
f.close()
with open (file4, "r") as f:
data = f.readlines()
for line in data:
i = 1
w = line.split(":")
string1 = w[i]
i+=1
string2 = w[i]
string = ("%s\n%s" %(string1,string2))
label.append(string)
f.close()
| file1 = 'db_breakfast_menu.txt'
file2 = 'db_lunch_menu.txt'
file3 = 'db_dinner_menu.txt'
file4 = 'db_label_text.txt'
retail = []
title = []
label = []
with open(file1, 'r') as f:
data = f.readlines()
for line in data:
w = line.split(':')
title.append(w[1])
for line in data:
w = line.split('$')
price = w[1]
price.rstrip('\n')
conv = float(price)
retail.append(conv)
f.close()
with open(file4, 'r') as f:
data = f.readlines()
for line in data:
i = 1
w = line.split(':')
string1 = w[i]
i += 1
string2 = w[i]
string = '%s\n%s' % (string1, string2)
label.append(string)
f.close() |
class Guesser:
def __init__(self, number, lives):
self.number = number
self.lives = lives
def guess(self,n):
if self.lives < 1:
raise Exception("Omae wa mo shindeiru")
match = n == self.number
if not match:
self.lives -= 1
return match | class Guesser:
def __init__(self, number, lives):
self.number = number
self.lives = lives
def guess(self, n):
if self.lives < 1:
raise exception('Omae wa mo shindeiru')
match = n == self.number
if not match:
self.lives -= 1
return match |
def get_assign(user_input):
key, value = user_input.split("gets")
key = key.strip()
value = int(value.strip())
my_dict[key] = value
print(my_dict)
def add_values(num1, num2):
return num1 + num2
print("Welcome to the Adder REPL.")
my_dict = dict()
while True:
user_input = input("???")
if 'gets' in user_input:
get_assign(user_input)
if 'input' in user_input:
print("Enter a value for :")
input_assign()
if 'adds' in user_input:
a, b = user_input.split("adds")
if 'print' in user_input:
print_values()
if 'quit' in user_input:
print("GoodBye")
exit() | def get_assign(user_input):
(key, value) = user_input.split('gets')
key = key.strip()
value = int(value.strip())
my_dict[key] = value
print(my_dict)
def add_values(num1, num2):
return num1 + num2
print('Welcome to the Adder REPL.')
my_dict = dict()
while True:
user_input = input('???')
if 'gets' in user_input:
get_assign(user_input)
if 'input' in user_input:
print('Enter a value for :')
input_assign()
if 'adds' in user_input:
(a, b) = user_input.split('adds')
if 'print' in user_input:
print_values()
if 'quit' in user_input:
print('GoodBye')
exit() |
try:
for i in ['a', 'b', 'c']:
print(i ** 2)
except TypeError:
print("An error occured!")
x = 5
y = 0
try:
z = x /y
print(z)
except ZeroDivisionError:
print("Can't devide by zero")
finally:
print("All done")
def ask():
while True:
try:
val = int(input("Input an integer: "))
except:
print("An error occured! Please try again")
else:
break
print("Thank you, you number sqared is: ", val ** 2)
ask()
| try:
for i in ['a', 'b', 'c']:
print(i ** 2)
except TypeError:
print('An error occured!')
x = 5
y = 0
try:
z = x / y
print(z)
except ZeroDivisionError:
print("Can't devide by zero")
finally:
print('All done')
def ask():
while True:
try:
val = int(input('Input an integer: '))
except:
print('An error occured! Please try again')
else:
break
print('Thank you, you number sqared is: ', val ** 2)
ask() |
NR_CLASSES = 10
hyperparameters = {
"number-epochs" : 30,
"batch-size" : 100,
"learning-rate" : 0.005,
"weight-decay" : 1e-9,
"learning-decay" : 1e-3
}
| nr_classes = 10
hyperparameters = {'number-epochs': 30, 'batch-size': 100, 'learning-rate': 0.005, 'weight-decay': 1e-09, 'learning-decay': 0.001} |
#!/usr/bin/python3
'''
BubbleSort.py
by Xiaoguang Zhu
'''
array = []
print("Enter at least two numbers to start bubble-sorting.")
print("(You can end inputing anytime by entering nonnumeric)")
# get numbers
while True:
try:
array.append(float(input(">> ")))
except ValueError: # exit inputing
break
print("\nThe array you've entered was:"); print(array)
print("\nNow sorting...")
# sorting
for x in range(len(array)-1, 0, -1):
for y in range(x):
if array[y] > array[y+1]:
array[y], array[y+1] = array[y+1], array[y]
print(array)
# output
print("\nAll done! Now the moment of truth!")
print(array)
| """
BubbleSort.py
by Xiaoguang Zhu
"""
array = []
print('Enter at least two numbers to start bubble-sorting.')
print('(You can end inputing anytime by entering nonnumeric)')
while True:
try:
array.append(float(input('>> ')))
except ValueError:
break
print("\nThe array you've entered was:")
print(array)
print('\nNow sorting...')
for x in range(len(array) - 1, 0, -1):
for y in range(x):
if array[y] > array[y + 1]:
(array[y], array[y + 1]) = (array[y + 1], array[y])
print(array)
print('\nAll done! Now the moment of truth!')
print(array) |
medida = float(input("uma distancai em metros: "))
cm = medida * 100
mm = medida * 1000
dm = medida / 10
dam = medida * 1000000
hm = medida / 100
km = medida * 0.001
ml = medida * 0.000621371
m = medida * 100000
print("A medida de {:.0f}m corresponde a {:.0f} mm \n{:.0f} cm \n{:.0f} dm \n{:.0f} dam \n{:.0f} hm \n{:.2f} km \n{:.2f} ml" .format (medida, cm, mm, dm, dam, hm, km, ml))
| medida = float(input('uma distancai em metros: '))
cm = medida * 100
mm = medida * 1000
dm = medida / 10
dam = medida * 1000000
hm = medida / 100
km = medida * 0.001
ml = medida * 0.000621371
m = medida * 100000
print('A medida de {:.0f}m corresponde a {:.0f} mm \n{:.0f} cm \n{:.0f} dm \n{:.0f} dam \n{:.0f} hm \n{:.2f} km \n{:.2f} ml'.format(medida, cm, mm, dm, dam, hm, km, ml)) |
def create_supervised_data(env, agents, num_runs=50):
val = []
# the data threeple
action_history = []
predict_history = []
mental_history = []
character_history = []
episode_history = []
traj_history = []
grids = []
ep_length = env.maxtime
filler = env.get_filler()
obs = env.reset(setting=setting, num_visible=num_goals)
for ep in tqdm.tqdm(range(num_runs*eps_per_run)):
buffer_s = [np.zeros(obs[0].shape) for _ in range(env.maxtime)]
if (ep % eps_per_run) == eps_per_run-1:
obs = env.reset(setting=setting, num_visible=num_goals)
else:
obs = env.reset()
if ep % eps_per_run == 0:
episode_number = 0
#clear ep_history here?
for agent in agents:
if not unarbitrary_prefs:
agent.reset_prefs()
else:
agent.hardcode_prefs()
prevact = None
prevpos = None
agentpos = agents[0].pos
episode_time = 0
while not env.done:
if rendering and ((ep % eps_per_run) == eps_per_run-1):
env.render()
buffer_s.append(obs[0])
actions = [agent.action(torch.FloatTensor([buffer_s[-env.maxtime:]]).cuda()),]
agentpos = agents[0].pos
thistraj = env.get_trajectory(agentpos, prevact, prevpos)
prevpos = agentpos
#without agent position, thisact of none is pretty meaningless
prevact = actions[0]
traj_history += [thistraj, ]
#moved this to before following if
episode_time += 1
if ((ep % eps_per_run) == eps_per_run-1):
# each step in last episode
#episode number is 3
if visualize:
render_path(env, ep, episode_time, vispath)
#print(actions)
run = np.zeros((eps_per_run, ep_length, *filler.shape))
if eps_per_run > 1:
run[-episode_number-1:-1] = episode_history[-episode_number:]
episode = np.zeros((ep_length, *filler.shape))
episode[ep_length-episode_time:] = traj_history[-episode_time]
run[-1] = episode
shortterm = np.asarray(traj_history[-1])
action_history += [one_hot(5, actions[0]),]
character_history += [run,]
mental_history += [episode,]
predict_history += [shortterm,]
if not env.full_test:
break
obs, _, _, = env.step(actions)
# end of episode
episode = np.zeros((ep_length, *filler.shape))
episode[ep_length-episode_time:] = traj_history[-episode_time:]
episode_history += [episode, ]
episode_number += 1
return character_history, mental_history, predict_history, action_history
def format_data_torch(data, **train_kwargs):
char = np.asarray(data[0]).astype('float32')
# (N, Ep, F, W, H, C) = first.shape
#first.reshape((N, Ep, F, C, H, W))
char = np.swapaxes(char, 3, 5)
mental = np.asarray(data[1]).astype('float32')
# (N, F, W, H, C) = first.shape
#first.reshape((N, F, C, H, W))
mental = np.swapaxes(mental, 2, 4)
query = np.asarray(data[2][:]).astype('float32')
# (N, W, H, C) = second.shape
#second.reshape((N, C, H, W))
query = np.swapaxes(query, 1, 3)
act = np.asarray(data[3][:]).astype('int32')
char1 = torch.Tensor(char).cuda()#[:, 0, :, :, :, :]
mental1 = torch.Tensor(mental).cuda()
query1 = torch.Tensor(query).cuda()#[:, 0, :, :, :]
act1 = torch.Tensor(act).cuda()
dataset = torch.utils.data.TensorDataset(char1, mental1, query1, act1)
return torch.utils.data.DataLoader(dataset, **train_kwargs)
def supervised_training(env, agents, data):
dummies = [Dummy(steps, model) for agent in agents]
class DummyAgent():
'''
railroads the agent for some steps,
then switches to an alternate model.
railroaded steps should be included in
environment's test condition,
returned as the final value of reset()
predefined strategies after the railroaded
steps are compared with the alt model's output
'''
def __init__(self, railroad, strategies, model):
self.n = -1
self.length = len(railroad)
self.model = model
self.rails = railroad
self.strats = strategies
def choose_action(self, obs):
if n <= self.length:
self.n += 1
return self.railroad[self.n], [0 for x in self.strats]
else:
self.n += 1
act = self.model.choose_action(obs)
return act, [act == x[self.n] for x in self.strats]
def reset(railroad, strategies):
self.length = len(railroad)
self.rails = railroad
self.strats = strategies
| def create_supervised_data(env, agents, num_runs=50):
val = []
action_history = []
predict_history = []
mental_history = []
character_history = []
episode_history = []
traj_history = []
grids = []
ep_length = env.maxtime
filler = env.get_filler()
obs = env.reset(setting=setting, num_visible=num_goals)
for ep in tqdm.tqdm(range(num_runs * eps_per_run)):
buffer_s = [np.zeros(obs[0].shape) for _ in range(env.maxtime)]
if ep % eps_per_run == eps_per_run - 1:
obs = env.reset(setting=setting, num_visible=num_goals)
else:
obs = env.reset()
if ep % eps_per_run == 0:
episode_number = 0
for agent in agents:
if not unarbitrary_prefs:
agent.reset_prefs()
else:
agent.hardcode_prefs()
prevact = None
prevpos = None
agentpos = agents[0].pos
episode_time = 0
while not env.done:
if rendering and ep % eps_per_run == eps_per_run - 1:
env.render()
buffer_s.append(obs[0])
actions = [agent.action(torch.FloatTensor([buffer_s[-env.maxtime:]]).cuda())]
agentpos = agents[0].pos
thistraj = env.get_trajectory(agentpos, prevact, prevpos)
prevpos = agentpos
prevact = actions[0]
traj_history += [thistraj]
episode_time += 1
if ep % eps_per_run == eps_per_run - 1:
if visualize:
render_path(env, ep, episode_time, vispath)
run = np.zeros((eps_per_run, ep_length, *filler.shape))
if eps_per_run > 1:
run[-episode_number - 1:-1] = episode_history[-episode_number:]
episode = np.zeros((ep_length, *filler.shape))
episode[ep_length - episode_time:] = traj_history[-episode_time]
run[-1] = episode
shortterm = np.asarray(traj_history[-1])
action_history += [one_hot(5, actions[0])]
character_history += [run]
mental_history += [episode]
predict_history += [shortterm]
if not env.full_test:
break
(obs, _, _) = env.step(actions)
episode = np.zeros((ep_length, *filler.shape))
episode[ep_length - episode_time:] = traj_history[-episode_time:]
episode_history += [episode]
episode_number += 1
return (character_history, mental_history, predict_history, action_history)
def format_data_torch(data, **train_kwargs):
char = np.asarray(data[0]).astype('float32')
char = np.swapaxes(char, 3, 5)
mental = np.asarray(data[1]).astype('float32')
mental = np.swapaxes(mental, 2, 4)
query = np.asarray(data[2][:]).astype('float32')
query = np.swapaxes(query, 1, 3)
act = np.asarray(data[3][:]).astype('int32')
char1 = torch.Tensor(char).cuda()
mental1 = torch.Tensor(mental).cuda()
query1 = torch.Tensor(query).cuda()
act1 = torch.Tensor(act).cuda()
dataset = torch.utils.data.TensorDataset(char1, mental1, query1, act1)
return torch.utils.data.DataLoader(dataset, **train_kwargs)
def supervised_training(env, agents, data):
dummies = [dummy(steps, model) for agent in agents]
class Dummyagent:
"""
railroads the agent for some steps,
then switches to an alternate model.
railroaded steps should be included in
environment's test condition,
returned as the final value of reset()
predefined strategies after the railroaded
steps are compared with the alt model's output
"""
def __init__(self, railroad, strategies, model):
self.n = -1
self.length = len(railroad)
self.model = model
self.rails = railroad
self.strats = strategies
def choose_action(self, obs):
if n <= self.length:
self.n += 1
return (self.railroad[self.n], [0 for x in self.strats])
else:
self.n += 1
act = self.model.choose_action(obs)
return (act, [act == x[self.n] for x in self.strats])
def reset(railroad, strategies):
self.length = len(railroad)
self.rails = railroad
self.strats = strategies |
n = int(input())
vip_guest = set()
regular_guest = set()
for _ in range(n):
reservation_code = input()
if reservation_code[0].isdigit():
vip_guest.add(reservation_code)
else:
regular_guest.add(reservation_code)
command = input()
while command != "END":
if command[0].isdigit():
vip_guest.discard(command)
else:
regular_guest.discard(command)
command = input()
missing_guest = len(vip_guest) + len(regular_guest)
print(missing_guest)
for vip in sorted(vip_guest):
print(vip)
for regular in sorted(regular_guest):
print(regular)
| n = int(input())
vip_guest = set()
regular_guest = set()
for _ in range(n):
reservation_code = input()
if reservation_code[0].isdigit():
vip_guest.add(reservation_code)
else:
regular_guest.add(reservation_code)
command = input()
while command != 'END':
if command[0].isdigit():
vip_guest.discard(command)
else:
regular_guest.discard(command)
command = input()
missing_guest = len(vip_guest) + len(regular_guest)
print(missing_guest)
for vip in sorted(vip_guest):
print(vip)
for regular in sorted(regular_guest):
print(regular) |
class alttprException(Exception):
pass
class alttprFailedToRetrieve(Exception):
pass
class alttprFailedToGenerate(Exception):
pass
| class Alttprexception(Exception):
pass
class Alttprfailedtoretrieve(Exception):
pass
class Alttprfailedtogenerate(Exception):
pass |
# Runtime: 84 ms, faster than 22.95% of Python3 online submissions for Lowest Common Ancestor of a Binary Tree.
# Memory Usage: 23.1 MB, less than 91.67% of Python3 online submissions for Lowest Common Ancestor of a Binary Tree.
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def lowestCommonAncestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
# Method 1
# ans = [None]
# def lca(node):
# if not node:
# return False
# mid = (node is p or node is q)
# left = lca(node.left)
# right = lca(node.right)
# if mid + left + right >= 2:
# ans[0] = node
# return mid or left or right
# lca(root)
# return ans[0]
# Method 2
# Time: O(n)
# Space: O(h)
if root is None:
return None
if root is p or root is q:
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
if left and right:
return root
else:
return left or right | class Solution:
def lowest_common_ancestor(self, root: 'TreeNode', p: 'TreeNode', q: 'TreeNode') -> 'TreeNode':
if root is None:
return None
if root is p or root is q:
return root
left = self.lowestCommonAncestor(root.left, p, q)
right = self.lowestCommonAncestor(root.right, p, q)
if left and right:
return root
else:
return left or right |
a = input("Enter the string:")
b = a.find("@")
c = a.find("#")
print("The original string is:",a)
print("The substring between @ and # is:",a[b+1:c]) | a = input('Enter the string:')
b = a.find('@')
c = a.find('#')
print('The original string is:', a)
print('The substring between @ and # is:', a[b + 1:c]) |
def fahrenheit_to_celsius(F):
'''
Function to compute Celsius from Fahrenheit
'''
K = fahrenheit_to_kelvin(F)
C = kelvin_to_celsius(K)
return C
| def fahrenheit_to_celsius(F):
"""
Function to compute Celsius from Fahrenheit
"""
k = fahrenheit_to_kelvin(F)
c = kelvin_to_celsius(K)
return C |
def read_lines(file_path):
with open(file_path, 'r') as handle:
return [line.strip() for line in handle]
def count_bits(numbers):
counts = [0] * len(numbers[0])
for num in numbers:
for i, bit in enumerate(num):
counts[i] += int(bit)
return counts
lines = read_lines('test.txt')
counts = count_bits(lines)
total_lines = len(lines)
gamma = [int(c > total_lines/2) for c in counts]
epsilon = [int(not bit) for bit in gamma]
gamma = int(''.join(str(bit) for bit in gamma), 2)
epsilon = int(''.join(str(bit) for bit in epsilon), 2)
print(f'Part 1:\n {gamma * epsilon}\n')
oxygen_rating = lines
co2_rating = lines
for i in range(len(oxygen_rating[0])):
counts = count_bits(oxygen_rating)
total = len(oxygen_rating)
more_common_bit = int(counts[i] >= total/2)
oxygen_rating = [num for num in oxygen_rating if int(num[i]) == more_common_bit]
if len(oxygen_rating) == 1:
break
for i in range(len(co2_rating[0])):
counts = count_bits(co2_rating)
total = len(co2_rating)
more_common_bit = int(counts[i] >= total/2)
co2_rating = [num for num in co2_rating if int(num[i]) != more_common_bit]
if len(co2_rating) == 1:
break
oxygen_rating = int(oxygen_rating[0], 2)
co2_rating = int(co2_rating[0], 2)
print('Part 2')
print(f' Oxygen rating: {oxygen_rating}')
print(f' CO2 rating: {co2_rating}')
print(' ' + str(oxygen_rating * co2_rating))
| def read_lines(file_path):
with open(file_path, 'r') as handle:
return [line.strip() for line in handle]
def count_bits(numbers):
counts = [0] * len(numbers[0])
for num in numbers:
for (i, bit) in enumerate(num):
counts[i] += int(bit)
return counts
lines = read_lines('test.txt')
counts = count_bits(lines)
total_lines = len(lines)
gamma = [int(c > total_lines / 2) for c in counts]
epsilon = [int(not bit) for bit in gamma]
gamma = int(''.join((str(bit) for bit in gamma)), 2)
epsilon = int(''.join((str(bit) for bit in epsilon)), 2)
print(f'Part 1:\n {gamma * epsilon}\n')
oxygen_rating = lines
co2_rating = lines
for i in range(len(oxygen_rating[0])):
counts = count_bits(oxygen_rating)
total = len(oxygen_rating)
more_common_bit = int(counts[i] >= total / 2)
oxygen_rating = [num for num in oxygen_rating if int(num[i]) == more_common_bit]
if len(oxygen_rating) == 1:
break
for i in range(len(co2_rating[0])):
counts = count_bits(co2_rating)
total = len(co2_rating)
more_common_bit = int(counts[i] >= total / 2)
co2_rating = [num for num in co2_rating if int(num[i]) != more_common_bit]
if len(co2_rating) == 1:
break
oxygen_rating = int(oxygen_rating[0], 2)
co2_rating = int(co2_rating[0], 2)
print('Part 2')
print(f' Oxygen rating: {oxygen_rating}')
print(f' CO2 rating: {co2_rating}')
print(' ' + str(oxygen_rating * co2_rating)) |
famous_name = "albert einstein"
motto = "A person who never made a mistake never tried anything new."
message = famous_name.title() + "once said, " + '"' + motto + '"'
print(message) | famous_name = 'albert einstein'
motto = 'A person who never made a mistake never tried anything new.'
message = famous_name.title() + 'once said, ' + '"' + motto + '"'
print(message) |
JIRA_DOMAIN = {'RD2': ['innodiv-hwacom.atlassian.net','innodiv-hwacom.atlassian.net'],
'RD5': ['srddiv5-hwacom.atlassian.net']}
API_PREFIX = 'rest/agile/1.0'
# project_id : column_name
STORY_POINT_COL_NAME = {'10005': 'customfield_10027',
'10006': 'customfield_10027',
'10004': 'customfield_10026'
}
| jira_domain = {'RD2': ['innodiv-hwacom.atlassian.net', 'innodiv-hwacom.atlassian.net'], 'RD5': ['srddiv5-hwacom.atlassian.net']}
api_prefix = 'rest/agile/1.0'
story_point_col_name = {'10005': 'customfield_10027', '10006': 'customfield_10027', '10004': 'customfield_10026'} |
class PixelMeasurer:
def __init__(self, coordinate_store, is_one_calib_block, correction_factor):
self.coordinate_store = coordinate_store
self.is_one_calib_block = is_one_calib_block
self.correction_factor = correction_factor
def get_distance(self, calibration_length):
distance_per_pixel = calibration_length / self.pixel_distance_calibration()
if not self.is_one_calib_block:
calibration_difference = float(self.pixel_distance_calibration_side()) / \
float(self.pixel_distance_calibration())
distance_correction = 1 - self.correction_factor*(1 - calibration_difference)
return self.pixel_distance_between_wheels() * distance_per_pixel * distance_correction
else:
return self.pixel_distance_between_wheels() * distance_per_pixel
def get_left_wheel_midpoint(self):
points = self.coordinate_store.get_left_wheel_points()
return int(abs(points[0][0] + points[1][0]) / 2)
def get_right_wheel_midpoint(self):
points = self.coordinate_store.get_right_wheel_points(is_one_calib_block=self.is_one_calib_block)
return int(abs(points[0][0] + points[1][0]) / 2)
def pixel_distance_between_wheels(self):
return abs(self.get_right_wheel_midpoint() - self.get_left_wheel_midpoint())
def pixel_distance_calibration(self):
calibration_points = self.coordinate_store.get_middle_calib_points()
return abs(calibration_points[0][0] - calibration_points[1][0])
def pixel_distance_calibration_side(self):
calibration_points = self.coordinate_store.get_side_calib_points()
return abs(calibration_points[0][0] - calibration_points[1][0])
| class Pixelmeasurer:
def __init__(self, coordinate_store, is_one_calib_block, correction_factor):
self.coordinate_store = coordinate_store
self.is_one_calib_block = is_one_calib_block
self.correction_factor = correction_factor
def get_distance(self, calibration_length):
distance_per_pixel = calibration_length / self.pixel_distance_calibration()
if not self.is_one_calib_block:
calibration_difference = float(self.pixel_distance_calibration_side()) / float(self.pixel_distance_calibration())
distance_correction = 1 - self.correction_factor * (1 - calibration_difference)
return self.pixel_distance_between_wheels() * distance_per_pixel * distance_correction
else:
return self.pixel_distance_between_wheels() * distance_per_pixel
def get_left_wheel_midpoint(self):
points = self.coordinate_store.get_left_wheel_points()
return int(abs(points[0][0] + points[1][0]) / 2)
def get_right_wheel_midpoint(self):
points = self.coordinate_store.get_right_wheel_points(is_one_calib_block=self.is_one_calib_block)
return int(abs(points[0][0] + points[1][0]) / 2)
def pixel_distance_between_wheels(self):
return abs(self.get_right_wheel_midpoint() - self.get_left_wheel_midpoint())
def pixel_distance_calibration(self):
calibration_points = self.coordinate_store.get_middle_calib_points()
return abs(calibration_points[0][0] - calibration_points[1][0])
def pixel_distance_calibration_side(self):
calibration_points = self.coordinate_store.get_side_calib_points()
return abs(calibration_points[0][0] - calibration_points[1][0]) |
# Programming for the Puzzled -- Srini Devadas
# You Will All Conform
# Input is a vector of F's and B's, in terms of forwards and backwards caps
# Output is a set of commands (printed out) to get either all F's or all B's
# Fewest commands are the goal
caps = ['F', 'F', 'B', 'B', 'B', 'F', 'B', 'B', 'B', 'F', 'F', 'B', 'F']
cap2 = ['F', 'F', 'B', 'B', 'B', 'F', 'B', 'B', 'B', 'F', 'F', 'F', 'F']
def pleaseConform(caps):
# Initialization
start = 0
forward = 0
backward = 0
intervals = []
# Determine intervals where caps are on in the same direction
for i in range(len(caps)):
if caps[start] != caps[i]:
# each interval is a tuple with 3 elements (start, end, type)
intervals.append((start, i - 1, caps[start]))
if caps[start] == 'F':
forward += 1
else:
backward += 1
start = i
# Need to add the last interval after for loop completes execution
intervals.append((start, len(caps) - 1, caps[start]))
if caps[start] == 'F':
forward += 1
else:
backward += 1
## print (intervals)
## print (forward, backward)
if forward < backward:
flip = 'F'
else:
flip = 'B'
for t in intervals:
if t[2] == flip:
# Exercise: if t[0] == t[1] change the printing!
if t[0] == t[1]:
print('Person at position', t[0], 'flip your cap!')
else:
print('People in positions', t[0], 'through', t[1], 'flip your caps!')
pleaseConform(caps)
##pleaseConform(cap2)
| caps = ['F', 'F', 'B', 'B', 'B', 'F', 'B', 'B', 'B', 'F', 'F', 'B', 'F']
cap2 = ['F', 'F', 'B', 'B', 'B', 'F', 'B', 'B', 'B', 'F', 'F', 'F', 'F']
def please_conform(caps):
start = 0
forward = 0
backward = 0
intervals = []
for i in range(len(caps)):
if caps[start] != caps[i]:
intervals.append((start, i - 1, caps[start]))
if caps[start] == 'F':
forward += 1
else:
backward += 1
start = i
intervals.append((start, len(caps) - 1, caps[start]))
if caps[start] == 'F':
forward += 1
else:
backward += 1
if forward < backward:
flip = 'F'
else:
flip = 'B'
for t in intervals:
if t[2] == flip:
if t[0] == t[1]:
print('Person at position', t[0], 'flip your cap!')
else:
print('People in positions', t[0], 'through', t[1], 'flip your caps!')
please_conform(caps) |
s=input()
t=input()
ss=sorted(map(s.count,set(s)))
tt=sorted(map(t.count,set(t)))
print('Yes' if ss==tt else 'No')
| s = input()
t = input()
ss = sorted(map(s.count, set(s)))
tt = sorted(map(t.count, set(t)))
print('Yes' if ss == tt else 'No') |
def anagrams(word, words):
agrams = []
s1 = sorted(word)
for i in range (0, len(words)):
s2 = sorted(words[i])
if s1 == s2:
agrams.append(words[i])
return agrams | def anagrams(word, words):
agrams = []
s1 = sorted(word)
for i in range(0, len(words)):
s2 = sorted(words[i])
if s1 == s2:
agrams.append(words[i])
return agrams |
initialScore = int(input())
def count_solutions(score, turn):
if score > 50 or turn > 4:
return 0
if score == 50:
return 1
result = count_solutions(score + 1, turn + 1)
for i in range(2, 13):
result += 2 * count_solutions(score + i, turn + 1)
return result
print(count_solutions(initialScore, 0))
| initial_score = int(input())
def count_solutions(score, turn):
if score > 50 or turn > 4:
return 0
if score == 50:
return 1
result = count_solutions(score + 1, turn + 1)
for i in range(2, 13):
result += 2 * count_solutions(score + i, turn + 1)
return result
print(count_solutions(initialScore, 0)) |
#!/usr/bin/env python3
def gcd(a, b):
if a == 0 :
return b
return gcd(b%a, a)
a = 12000
b = 8642
print(gcd(a, b))
| def gcd(a, b):
if a == 0:
return b
return gcd(b % a, a)
a = 12000
b = 8642
print(gcd(a, b)) |
def solve():
n = int(input())
k = list(map(int,input().split()))
hashmap = dict()
j = 0
ans = 0
c = 0
for i in range(n):
if k[i] in hashmap and hashmap[k[i]] > 0:
while i > j and k[i] in hashmap and hashmap[k[i]] > 0:
hashmap[k[j]] -= 1
j += 1
c -= 1
hashmap[k[i]] = 1
c += 1
ans = max(ans,c)
print(ans)
if __name__ == '__main__':
solve() | def solve():
n = int(input())
k = list(map(int, input().split()))
hashmap = dict()
j = 0
ans = 0
c = 0
for i in range(n):
if k[i] in hashmap and hashmap[k[i]] > 0:
while i > j and k[i] in hashmap and (hashmap[k[i]] > 0):
hashmap[k[j]] -= 1
j += 1
c -= 1
hashmap[k[i]] = 1
c += 1
ans = max(ans, c)
print(ans)
if __name__ == '__main__':
solve() |
# Here the rate is set for Policy flows, local to a compute, which is
# lesser than policy flows across computes
expected_flow_setup_rate = {}
expected_flow_setup_rate['policy'] = {
'1.04': 6000, '1.05': 9000, '1.06': 10000, '1.10': 10000, '2.10': 13000}
expected_flow_setup_rate['nat'] = {
'1.04': 4200, '1.05': 6300, '1.06': 7500, '1.10': 7500, '2.10': 10000}
| expected_flow_setup_rate = {}
expected_flow_setup_rate['policy'] = {'1.04': 6000, '1.05': 9000, '1.06': 10000, '1.10': 10000, '2.10': 13000}
expected_flow_setup_rate['nat'] = {'1.04': 4200, '1.05': 6300, '1.06': 7500, '1.10': 7500, '2.10': 10000} |
# Dynamic Programming Python implementation of Min Cost Path
# problem
R = 3
C = 3
def minCost(cost, m, n):
# Instead of following line, we can use int tc[m+1][n+1] or
# dynamically allocate memoery to save space. The following
# line is used to keep te program simple and make it working
# on all compilers.
tc = [[0 for x in range(C)] for x in range(R)]
tc[0][0] = cost[0][0]
# Initialize first column of total cost(tc) array
for i in range(1, m+1):
tc[i][0] = tc[i-1][0] + cost[i][0]
# Initialize first row of tc array
for j in range(1, n+1):
tc[0][j] = tc[0][j-1] + cost[0][j]
# Construct rest of the tc array
for i in range(1, m+1):
for j in range(1, n+1):
tc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j]
return tc[m][n]
# Driver program to test above functions
cost = [[1, 2, 3],
[4, 8, 2],
[1, 5, 3]]
print(minCost(cost, 2, 2))
#O(mn) | r = 3
c = 3
def min_cost(cost, m, n):
tc = [[0 for x in range(C)] for x in range(R)]
tc[0][0] = cost[0][0]
for i in range(1, m + 1):
tc[i][0] = tc[i - 1][0] + cost[i][0]
for j in range(1, n + 1):
tc[0][j] = tc[0][j - 1] + cost[0][j]
for i in range(1, m + 1):
for j in range(1, n + 1):
tc[i][j] = min(tc[i - 1][j - 1], tc[i - 1][j], tc[i][j - 1]) + cost[i][j]
return tc[m][n]
cost = [[1, 2, 3], [4, 8, 2], [1, 5, 3]]
print(min_cost(cost, 2, 2)) |
def create_box(input_corners):
x = (float(input_corners[0][0]), float(input_corners[1][0]))
y = (float(input_corners[0][1]), float(input_corners[1][1]))
windmill_lats, windmill_lons = zip(*[
(max(x), max(y)),
(min(x), max(y)),
(min(x), min(y)),
(max(x), min(y)),
(max(x), max(y))
])
return windmill_lats, windmill_lons
| def create_box(input_corners):
x = (float(input_corners[0][0]), float(input_corners[1][0]))
y = (float(input_corners[0][1]), float(input_corners[1][1]))
(windmill_lats, windmill_lons) = zip(*[(max(x), max(y)), (min(x), max(y)), (min(x), min(y)), (max(x), min(y)), (max(x), max(y))])
return (windmill_lats, windmill_lons) |
class Label:
@staticmethod
def from_str(value):
for l in Label._get_supported_labels():
if l.to_str() == value:
return l
raise Exception("Label by value '{}' doesn't supported".format(value))
@staticmethod
def from_int(value):
assert(isinstance(value, int))
for l in Label._get_supported_labels():
if l.to_int() == value:
return l
raise Exception("Label by value '{}' doesn't supported".format(value))
@staticmethod
def from_uint(value):
assert(isinstance(value, int) and value >= 0)
for l in Label._get_supported_labels():
if l.to_uint() == value:
return l
raise Exception("Label by unsigned value '{}' doesn't supported".format(value))
@staticmethod
def _get_supported_labels():
supported_labels = [
PositiveLabel(),
NegativeLabel()
]
return supported_labels
def to_str(self):
raise NotImplementedError()
def to_int(self):
raise NotImplementedError()
def to_uint(self):
raise Exception("Not implemented exception")
def __eq__(self, other):
assert(isinstance(other, Label))
return self.to_int() == other.to_int()
def __ne__(self, other):
assert(isinstance(other, Label))
return self.to_int() != other.to_int()
class PositiveLabel(Label):
def to_str(self):
return 'pos'
def to_int(self):
return int(1)
def to_uint(self):
return int(1)
class NegativeLabel(Label):
def to_str(self):
return 'neg'
def to_int(self):
return int(-1)
def to_uint(self):
return int(2)
| class Label:
@staticmethod
def from_str(value):
for l in Label._get_supported_labels():
if l.to_str() == value:
return l
raise exception("Label by value '{}' doesn't supported".format(value))
@staticmethod
def from_int(value):
assert isinstance(value, int)
for l in Label._get_supported_labels():
if l.to_int() == value:
return l
raise exception("Label by value '{}' doesn't supported".format(value))
@staticmethod
def from_uint(value):
assert isinstance(value, int) and value >= 0
for l in Label._get_supported_labels():
if l.to_uint() == value:
return l
raise exception("Label by unsigned value '{}' doesn't supported".format(value))
@staticmethod
def _get_supported_labels():
supported_labels = [positive_label(), negative_label()]
return supported_labels
def to_str(self):
raise not_implemented_error()
def to_int(self):
raise not_implemented_error()
def to_uint(self):
raise exception('Not implemented exception')
def __eq__(self, other):
assert isinstance(other, Label)
return self.to_int() == other.to_int()
def __ne__(self, other):
assert isinstance(other, Label)
return self.to_int() != other.to_int()
class Positivelabel(Label):
def to_str(self):
return 'pos'
def to_int(self):
return int(1)
def to_uint(self):
return int(1)
class Negativelabel(Label):
def to_str(self):
return 'neg'
def to_int(self):
return int(-1)
def to_uint(self):
return int(2) |
'''70. Climbing Stairs
Easy
3866
127
Add to List
Share
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
Example 1:
Input: 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Input: 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step'''
n = int(input())
a,b = 1,2
for i in range(n-1):
a,b = b,a+b
print(a) | """70. Climbing Stairs
Easy
3866
127
Add to List
Share
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
Example 1:
Input: 2
Output: 2
Explanation: There are two ways to climb to the top.
1. 1 step + 1 step
2. 2 steps
Example 2:
Input: 3
Output: 3
Explanation: There are three ways to climb to the top.
1. 1 step + 1 step + 1 step
2. 1 step + 2 steps
3. 2 steps + 1 step"""
n = int(input())
(a, b) = (1, 2)
for i in range(n - 1):
(a, b) = (b, a + b)
print(a) |
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.