content
stringlengths 7
1.05M
|
---|
#Maciej Sudol 303073
#Elektronika AGH 3 rok
# zadanie zrealizowane w formie ksiazki adresowej
# imie nazwisko i rok urodzenia powinny byc podane w jednej linii
# wcisnij q by wyjsc i wyswietlic listę
lines =list()
print('Wprowadz imię, nazwisko oraz datę urodzenia:')
line=input('podaj dane:')
while line !='q':
lines.append(line)
line = input('podaj dane:')
print("\n Lista wprowadzonych danych:")
print(*lines,sep ="\n")
|
definition = [
{
"project_name" : "Project1",
"end_points": [
{
"local_development": "http://localhost:8066/",
"local_team_development": "http://192.168.5.217:8066/"
}
],
"api_end_point_partial_path": "api/"
}
]
|
print('----- range(3) -----')
print(range(3))
for x in range(3): print(x)
print('----- range(3, 10) -----')
print(range(3, 10))
for x in range(3, 10): print(x)
print('----- range(-3) -----')
print(range(-3))
for x in range(-3): print(x)
print('----- range(0,-3) -----')
print(range(0,-3))
for x in range(0,-3): print(x)
print('----- range(-3,0) -----')
print(range(-3,0))
for x in range(-3,0): print(x)
print('----- range(0,-3,-1) -----')
print(range(0,-3,-1))
for x in range(0,-3,-1): print(x)
|
# leetcode
class Solution:
def reverse(self, x: int) -> int:
str_x = str(x)
if str_x[:1] == "-":
isNeg = True
str_x = str_x[1:]
else:
isNeg = False
str_x = str_x[::-1]
new_x = int(str_x)
if isNeg:
new_x *= -1
if new_x < 2**31 * -1 or new_x > 2**31:
return 0
else:
return new_x
|
# -*- coding: utf-8 -*-
class UnknownServiceEnvironmentNotConfiguredError(Exception):
"""
Raised when unknown service-environment is not configured for plugin.
"""
pass
|
n = input()
# Reading first list
list1 = list(map(int, input().split()))
# Reading second list then to set
set1 = set(list(map(int, input().split())))
set2 = set(list(map(int, input().split())))
count = 0
# Looping through elements in
for el in list1:
# checking the element existence Set
if el in set1:
count += 1
elif el in set2:
count -= 1
print(count)
|
pairs = {1: "apple",
"orange": [2,3,5],
True:False,
None:"True",
}
print(pairs.get("orange"))
print(pairs.get(7))
print(pairs.get(12345, "not in dictionary"))
|
main = [{'category': 'Transfer Limits',
'field': [{'name': 'tx_transfer_min',
'title': 'Minimum amount a user can transfer per transaction',
'note': 'Default is set to zero.'},
{'name': 'tx_transfer_max_day',
'title': 'Maximum total amount a user can transfer per day',
'note': 'Default is set to unlimited.'},
{'name': 'tx_transfer_max_month',
'title': 'Maximum total amount a user can transfer per month',
'note': 'Default is set to unlimited.'}]},
{'category': 'Withdrawal Limits',
'field': [{'name': 'tx_withdraw_min',
'title': 'Minimum amount a user can withdraw per transaction',
'note': 'Default is set to zero.'},
{'name': 'tx_withdraw_max_day',
'title': 'Maximum total amount a user can withdraw per day',
'note': 'Default is set to unlimited.'},
{'name': 'tx_withdraw_max_month',
'title': 'Maximum total amount a user can withdraw per month',
'note': 'Default is set to unlimited.'}]},
{'category': 'Deposit Limits',
'field': [{'name': 'tx_deposit_min',
'title': 'Minimum amount a user can deposit per transaction',
'note': 'Default is set to zero.'},
{'name': 'tx_deposit_max_day',
'title': 'Maximum amount a user can deposit per day',
'note': 'Default is set to unlimited.'},
{'name': 'tx_deposit_max_month',
'title': 'Maximum amount a user can deposit per month',
'note': 'Default is set to unlimited.'},
]}]
template_list = main
def choice_list():
c = []
for l in main:
for i in l['field']:
c.append([i['name'], i['name']])
t = tuple(tuple(x) for x in c)
return t
|
# Author: Luke Hindman
# Date: Tue Oct 24 13:10:06 MDT 2017
# Description: In-class example for user input and lists
# Create an empty grocery list
groceryList = []
# Shopping list loop
done = False
while done == False:
# Prompt the user for an item to add to the list
item = input("Please enter an item or done when finished: ")
# Check if user is done entering items,
# otherwise add the item to the grocery list
if item.lower() == "done":
done = True
else:
groceryList.append(item)
# Print the grocery list
for g in groceryList:
print ("Don't forget the " + g + "!")
|
space = [[1 for _ in range(21)] for _ in range(21)]
for x in range(1,21):
for y in range(1,21):
space[x][y] = space[x-1][y] + space[x][y-1]
print(space[20][20])
|
#4.6
def computepay(h,r):
# ( 40 hours * normal rate ) + (( overtime hours ) * time-and-a-half rate)
if(h>40):
p = ( 40 * r ) + (( h - 40 ) * 1.5 * r)
return p
else:
p = h * r
return p
hours = float(input("Enter Hours: "))
rate = float(input("Enter Rate per hour: "))
pay = computepay(hours, rate)
print("Pay", pay)
|
class CellCountMissingCellsException(Exception):
pass
class UnknownAtlasValue(Exception):
pass
def atlas_value_to_structure_id(atlas_value, structures_reference_df):
line = structures_reference_df[
structures_reference_df["id"] == atlas_value
]
if len(line) == 0:
raise UnknownAtlasValue(atlas_value)
structure_id = line["structure_id_path"].values[0]
return structure_id
def atlas_value_to_name(atlas_value, structures_reference_df):
line = structures_reference_df[
structures_reference_df["id"] == atlas_value
]
if len(line) == 0:
raise UnknownAtlasValue(atlas_value)
name = line["name"]
return str(name.values[0])
|
x = 'abc'
x = "abc"
x = r'abc'
x = 'abc' \
'def'
x = ('abc'
'def')
x = 'ab"c'
x = "ab'c"
x = '''ab'c'''
|
class DefaultConfig (object) :
root_raw_train_data = 'path to be filled' # downloaded training data root
root_raw_eval_data = 'path to be filled' # downloaded evaluation/testing data root
root_dataset_file = './dataset/' # preprocessed dataset root
root_train_volume = './dataset/train/' # preprocessed training dataset root
root_eval_volume = './dataset/eval/' # preprocessed evaluation/testing dataset root
root_exp_file = './exp/' # training exp root
root_submit_file = './submit/' # submit file root
root_pred_dcm = 'path to be filled' # prediction array root
root_pred_save = 'path to be filled' # prediction result root
root_model_param = './params.pkl' # reference model parameter root
use_gpu = True
batch_size = 2
max_epoch = 1
learning_rate = 1e-3
decay_LR = (5, 0.1)
opt = DefaultConfig()
|
def main():
n = int(input())
a = list(map(int,input().split()))
count2 = 0
count4 = 0
for e in a:
if e%2 == 0:
count2 += 1
if e%4 == 0:
count4 += 1
if n == 3 and count4:
print("Yes")
return
if count2 == n:
print("Yes")
return
if count4 >= n-count2:
print("Yes")
return
if n%2 and n//2 == count4:
print("Yes")
return
print("No")
if __name__ == "__main__":
main()
|
class Solution:
def canPartition(self, nums):
"""
:type nums: List[int]
:rtype: bool
"""
total_sum = sum(nums)
if total_sum % 2 == 1:
return False
half_sum = total_sum//2
dp = [[0 for col in range(half_sum+1)] for row in range(len(nums))]
for j in range(nums[0], half_sum+1):
dp[0][j] = nums[0]
for i in range(1, len(nums)):
for j in range(nums[i], half_sum+1):
dp[i][j] = max(dp[i-1][j], dp[i-1][j-nums[i]]+nums[i])
if dp[len(nums)-1][half_sum] == half_sum:
return True
else:
return False
|
class Node:
def __init__(self, game, parent, action):
self.game = game
self.parent = parent
self.action = action
self.player = game.get_current_player()
self.score = game.get_score()
self.children = []
self.visits = 0
def is_leaf(self):
return not self.children
def add_child(self, node):
self.children.append(node)
|
def product(x, y):
ret = list()
for _x in x:
for _y in y:
ret.append((_x, _y))
return ret
print(product([1, 2, 3], ["a", "b"]))
|
# configuration
class Config:
DEBUG = True
# db
SQLALCHEMY_DATABASE_URI = 'mysql://root:root@localhost/djangoapp'
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
class VaultConfig(object):
def __init__(self):
self.method = None
self.address = None
self.username = None
self.namespace = None
self.studio = None
self.mount_point = None
self.connect = False
|
# -*- coding: utf-8 -*-
# Copyright: (c) 2020, Garfield Lee Freeman (@shinmog)
class ModuleDocFragment(object):
# Standard files documentation fragment
DOCUMENTATION = r'''
'''
FACTS = r'''
notes:
- As this is a facts module, check mode is not supported.
options:
search_type:
description:
- How to interpret the value given for the primary param.
choices:
- exact
- substring
- regex
default: 'exact'
details:
description:
- Whether to retrieve full detailed results or not.
type: bool
default: false
'''
FACTS_WITHOUT_DETAILS = r'''
notes:
- As this is a facts module, check mode is not supported.
options:
search_type:
description:
- How to interpret the value given for the primary param.
choices:
- exact
- substring
- regex
default: 'exact'
'''
STATE = r'''
options:
state:
description:
- The state.
type: str
default: 'present'
choices:
- present
- absent
'''
|
#!/usr/bin/env python3
class Canvas(object):
def __init__(self, width, height):
self.width = width
self.height = height
self._area = []
for _ in range(height):
self._area.append([c for c in ' ' * width])
def _inside_canvas(self, x, y):
return 0 < x <= self.width and 0 < y <= self.height
def draw_line(self, x1, y1, x2, y2, colour='x'):
if self._inside_canvas(x1, y1) and self._inside_canvas(x2, y2):
if x1 == x2: # vertical line
for i in range(y1 - 1, y2):
self._area[i][x1 - 1] = colour
elif y1 == y2: # horizontal line
for i in range(x1 - 1, x2):
self._area[y1 - 1][i] = colour
def draw_rectangle(self, x1, y1, x2, y2, colour='x'):
if self._inside_canvas(x1, y1) and self._inside_canvas(x2, y2):
self.draw_line(x1, y1, x1, y2, colour)
self.draw_line(x1, y1, x2, y1, colour)
self.draw_line(x2, y1, x2, y2, colour)
self.draw_line(x1, y2, x2, y2, colour)
def _change_fill_colour(self, x, y, new_colour, old_colour):
if self._inside_canvas(x, y):
if self._area[y - 1][x - 1] == old_colour:
self._area[y - 1][x - 1] = new_colour
# recursively apply colour on surrounding points
self._change_fill_colour(x, y + 1, new_colour, old_colour)
self._change_fill_colour(x + 1, y, new_colour, old_colour)
self._change_fill_colour(x, y - 1, new_colour, old_colour)
self._change_fill_colour(x - 1, y, new_colour, old_colour)
def bucket_fill(self, x, y, colour):
if colour and self._inside_canvas(x, y):
existing_colour = self._area[y - 1][x - 1]
if existing_colour != colour:
self._change_fill_colour(x, y, colour, existing_colour)
def __str__(self):
canvas_str = '-' * (self.width + 2) + '\n'
for line in self._area:
canvas_str += '|' + ''.join(line) + '|\n'
canvas_str += '-' * (self.width + 2)
return canvas_str
|
'''
Praveen Manimaran
CIS 41A Spring 2020
Exercise A
'''
height = 2.9
width = 7.1
height = height// 2
width = width// 2
area = height*width
print("height: ",height)
print("width: ",width)
print("area: ",area)
|
class A:
def __new__(cls, *args, **kwargs):
if not hasattr(cls, "_jaexiste"):
cls._jaexiste = object.__new__(cls)
def cumprimento(*args, **kwargs):
print("Olá Terráqueo")
cls.cumprimento = cumprimento
cls.nome = "NATALIA"
return super().__new__(cls)
def __init__(self):
print("inicio")
def __call__(self, *args, **kwargs):
resultado = 1
for i in args:
resultado *= i
return resultado
def __setattr__(self, key, value):
self.__dict__[key] = value # precisa dessa linha pra definir o parametro nome ali em baixo
print(key, value)
def __del__(self):
print("objeto coletado.")
def __str__(self):
return "classe A em str"
def __len__(self):
return 55
a = A()
var = a(1, 2, 3, 4, 5, 6, 7)
print(var)
a.cumprimento()
print(a.nome) #definido em def new
print(a) # imprime o def str
print(len(a))
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
class Solution:
def longestPalindrome(self,s):
dp = [[False for _ in range(len(s))] for _ in range(len(s))]
l,r = 0,0
for head in range(len(s)-2,0,-1):
for tail in range(head,len(s)):
if s[head] == s[tail] and (tail-head < 3 or dp[head+1][tail-1]):
dp[head][tail] = True
if r-l < tail-head:
l,r=head,tail
return s[l:r+1]
a=Solution()
print(a.longestPalindrome("babad"))
|
#!/usr/bin/env python3
def part1():
data = open('day8_input.txt').read().splitlines()
one = 2 # 2 segments light up to display 1
four = 4
seven = 3
eight = 7
output = [i.rpartition('|')[2].strip() for i in data]
counter = 0
for i in range(len(output)):
strings = output[i].split()
for string in strings:
length = len(string)
if length == one or length == four or length == seven or length == eight:
counter += 1
print(counter)
def part2():
data = open('day8_input.txt').read().splitlines()
input = [i.rpartition('|')[0].strip() for i in data]
output = [i.rpartition('|')[2].strip() for i in data]
#signals = ['cagedb', 'ab', 'gcdfa','fbcad', 'eafb','cdfbe', 'dab', 'acedgfb']
summation = 0
for i in range(len(input)):
signals = input[i].split()
display = output[i].split()
one = find1478(signals, 2)
four = find1478(signals, 4)
seven = find1478(signals, 3)
eight = find1478(signals, 7)
three = findDigit(signals, one, 5)
six = find6(signals, one, 6)
nine = findDigit(signals, four, 6)
zero = find0(signals, six, nine, 6)
five = find5(signals, nine, three, 5)
two = find2(signals, five, three, 5)
allDigits = [zero, one, two, three, four, five, six, seven, eight, nine]
number = ''
for j in display:
for i in range(len(allDigits)):
if (containsAll(j, allDigits[i])):
number += str(i)
summation += int(number)
print(summation)
# function to check if all characters in set are in str
def containsAll(str, set):
if(len(str) != len(set)):
return False
for c in set:
if c not in str:
return False
return True
def containsChars(str, set):
for c in set:
if c not in str:
return False
return True
#little helper functions to find all the digits
# helper to find 1,4,7,8
def find1478(signals, length):
for i in range(len(signals)):
string = signals[i]
if (len(string) == length):
return string
# helper to find 3, 5, 9
def findDigit(signals, digit, length):
for string in signals:
if (len(string) == length) and containsChars(string, digit):
return string
# helper to find 6
def find6(signals, one, length):
for string in signals:
# print(string)
if (len(string) == length and (not containsChars(string,one))):
return string
# helper to find 0
def find0(signals, six, nine, length):
for string in signals:
if ((len(string) == length) and (not string == six) and (not string ==nine)):
return string
# helper to find 5
def find5(signals, nine, three, length):
for string in signals:
if(len(string) == length) and string != three and containsChars(nine,string):
return string
# helper to find 2
def find2(signals, five, three, length):
for string in signals:
if((len(string) == length and string!= five and string!= three)):
return string
part1()
part2()
|
valores = input().split()
x, y = valores
x = float(x)
y = float(y)
if(x == 0.0 and y == 0.0):
print('Origem')
if(x == 0.0 and y != 0.0):
print('Eixo Y')
if(x != 0.0 and y == 0.0):
print('Eixo X')
if(x > 0 and y > 0):
print('Q1')
if(x < 0 and y > 0):
print('Q2')
if(x < 0 and y < 0):
print('Q3')
if(x > 0 and y < 0):
print('Q4')
|
#! python3
# Configuration file for cf-py-importer
globalSettings = {
# FQDN or IP address of the CyberFlood Controller. Do NOT prefix with https://
"cfControllerAddress": "your.cyberflood.controller",
"userName": "your@login",
"userPassword": "yourPassword"
}
|
#OPCODE_Init = b"0"
OPCODE_ActivateLayer0 = b"1"
OPCODE_ActivateLayer1 = b"2"
OPCODE_ActivateLayer2 = b"3"
OPCODE_ActivateLayer3 = b"4"
OPCODE_NextAI = b"5"
OPCODE_NewTournament = b"6"
OPCODE_Exit = b"7"
|
'''
This is how you work out whether if a particular year is a leap year.
on every year that is evenly divisible by 4
**except** every year that is evenly divisible by 100
**unless** the year is also evenly divisible by 400
'''
# 🚨 Don't change the code below 👇
year = int(input("Which year do you want to check? "))
# 🚨 Don't change the code above 👆
#Write your code below this line 👇
leap_year = False
if year % 4 == 0:
leap_year = True
if year % 100 == 0:
leap_year = False
if year % 400 == 0:
leap_year = True
if leap_year:
print("Leap year.")
else:
print("Not leap year.")
|
class InvalidProtocolMessage(Exception):
"""Invalid protocol message function name"""
class InvalidHandshake(Exception):
"""Handshake message from peer is invalid"""
class InvalidAck(Exception):
"""Handshake message from peer is invalid"""
class IncompatibleProtocolVersion(Exception):
"""Protocol versions incompatible"""
class DuplicateConnection(Exception):
"""Already have connection with peer"""
class TooManyheadersRequested(Exception):
"""Requested too many header blocks"""
class TooManyBlocksRequested(Exception):
"""Requested too many blocks"""
class BlockNotInBlockchain(Exception):
"""Block not in blockchain"""
class NoProofsOfSpaceFound(Exception):
"""No proofs of space found for this challenge"""
class PeersDontHaveBlock(Exception):
"""None of our peers have the block we want"""
# Consensus errors
class InvalidWeight(Exception):
"""The weight of this block can not be validated"""
class InvalidUnfinishedBlock(Exception):
"""The unfinished block we received is invalid"""
class InvalidGenesisBlock(Exception):
"""Genesis block is not valid according to the consensus constants and rules"""
|
"""
Florian Guillot & Julien Donche: Project 7
Topic modeling and keywords extractions for Holi.io
Jedha Full Stack, dsmf-paris-13
08-2021
FILE NAME :
topic_text.py
OBJECTIVE :
This function use a pretrained topic_modeling model to associate topics to a text
INPUTS:
- 'model' : a topic modeling model that will associate your text to topics. On our side we have chosen LDA
- 'article' : string, text to colorize
- 'n_topics' : integer, number of topics you want to associate to the text
OUTPUTS:
list of topics as string
"""
# -----------------------------------------------------------------------------
# Initialization
# -----------------------------------------------------------------------------
#The topics (bags of words from LDA) are analized by the business and associated and named.
list_topics = ['garbage', 'fooding', 'competition', 'people', 'weather', 'entertainment', 'finance', 'household', 'tourism', 'football', 'law', 'environment', 'university sport', 'cooking', 'urbanism', 'police', 'international', 'education', 'consumption', 'nfl', 'motors', 'basketball', 'baseball', 'health', 'US elections']
# Total number of topics in our model
topics_number =len(list_topics)
# We associate each topic_id to a name
dict_topics = {i: list_topics[i] for i in range(topics_number)}
# -----------------------------------------------------------------------------
# The model
# -----------------------------------------------------------------------------
def topic_text(model, article, n_topics):
topics = []
doc = model.id2word.doc2bow(article.split()) # Vectorization with Doc2Bow
doc_topics, word_topics, phi_values = model.get_document_topics(doc, per_word_topics=True) # Be careful to have a model with per_word_topics = True
for idd, prop in sorted(doc_topics,key=lambda x: x[1], reverse=True)[:n_topics+1]: # We sort the list to have the best topics at the beginning, and add 1 because we handle the topic "11" which is the trash topic
if idd != 0: # The topic '0' is a trash topic, as the model has put everything it does not understand in it. We won't use it
topics.append(dict_topics[idd])
if len(topics)>n_topics: topics = topics[:n_topics]
return topics
|
lista = []
print('type s to exit\ndigite s para sair')
while 1:
num = input('N: ')
if num == 's': break
else: lista.append(int(num))
lista.reverse()
print('lista reversa', lista)
print('foram digitados', len(lista), ' numeros')
print('numero 5 foi digitado' if 5 in lista else 'sem 5')
#Exercício Python 081:
# Crie um programa que vai ler vários números e colocar em uma lista.
# Depois disso, mostre:
#A) Quantos números foram digitados.
#B) A lista de valores, ordenada de forma decrescente.
#C) Se o valor 5 foi digitado e está ou não na lista.
|
greek_alp = {
"Alpha" : "Alp",
"Beta" : "Bet",
"Gamma" : "Gam",
"Delta" : "Del",
"Epsilon" : "Eps",
"Zeta" : "Zet",
"Eta" : "Eta",
"Theta" : "The",
"Iota" : "Iot",
"Kappa" : "Kap",
"Lambda" : "Lam",
"Mu" : "Mu ",
"Nu" : "Nu ",
"Xi" : "Xi ",
"Omicron" : "Omi",
"Pi" : "Pi ",
"Rho" : "Rho",
"Sigma" : "Sig",
"Tau" : "Tau",
"Upsilon" : "Ups",
"Phi" : "Phi",
"Chi" : "Chi",
"Psi" : "Psi",
"Omega" : "Ome",
}
greek_unicode = {
"Alp" : "\\u03b1",
"Bet" : "\\u03b2",
"Gam" : "\\u03b3",
"Del" : "\\u03b4",
"Eps" : "\\u03b5",
"Zet" : "\\u03b6",
"Eta" : "\\u03b7",
"The" : "\\u03b8",
"Iot" : "\\u03b9",
"Kap" : "\\u03ba",
"Lam" : "\\u03bb",
"Mu " : "\\u03bc",
"Nu " : "\\u03bd",
"Xi " : "\\u03be",
"Omi" : "\\u03bf",
"Pi " : "\\u03c0",
"Rho" : "\\u03c1",
"Sig" : "\\u03c3",
"Tau" : "\\u03c4",
"Ups" : "\\u03c5",
"Phi" : "\\u03c6",
"Chi" : "\\u03c7",
"Psi" : "\\u03c8",
"Ome" : "\\u03c9",
}
|
data = ["React", "Angular", "Svelte", "Vue"]
# or
data = [
{"value": "React", "label": "React"},
{"value": "Angular", "label": "Angular"},
{"value": "Svelte", "label": "Svelte"},
{"value": "Vue", "label": "Vue"},
]
|
#! /usr/bin/env python
# -*- coding: utf-8 -*-
# pylint: disable=line-too-long
"""Reduce integer values in coords attributes comma separated list of html 3.2 map area elements."""
ENCODING = "utf-8"
ENCODING_ERRORS_POLICY = "ignore"
def apply_scaling(reduction_factor:int, text_line: str):
"""Apply the scaling if coords attribute present in line."""
coords_token_start = ' coords="'
coords_token_end = '" '
line = text_line.rstrip()
if coords_token_start not in line:
return line
prefix, rest = line.split(coords_token_start, 1)
csv, postfix = rest.split(coords_token_end, 1)
numbers_in = [int(x.strip()) for x in csv.split(',')]
numbers_out = [n // reduction_factor for n in numbers_in]
coords = ','.join(str(s) for s in numbers_out)
return f"{prefix}{coords_token_start}{coords}{coords_token_end}{postfix}"
def scale_html_map_area_coords(reduction_factor: int, html_read_path: str):
"""Naive scaling of the coords attribute values relying on attribute name and values being on the same line."""
if not html_read_path: # Early raise
raise ValueError("path to html file missing")
scaled = []
with open(html_read_path, "rt", encoding=ENCODING) as handle:
for line in handle:
scaled.append(apply_scaling(reduction_factor, line))
return '\n'.join(scaled) + '\n'
|
FONT = "Arial"
FONT_SIZE_TINY = 8
FONT_SIZE_SMALL = 11
FONT_SIZE_REGULAR = 14
FONT_SIZE_LARGE = 16
FONT_SIZE_EXTRA_LARGE = 20
FONT_WEIGHT_LIGHT = 100
FONT_WEIGHT_REGULAR = 600
FONT_WEIGHT_BOLD = 900
|
# Copyright (c) 2021 Qianyun, Inc. All rights reserved.
class ValidationError(Exception):
"""The validation exception"""
message = "ValidationError"
def __init__(self, message=None):
self.message = message or self.message
super(ValidationError, self).__init__(self.message)
class FusionComputeClientError(Exception):
def __init__(self, message, server_traceback=None,
status_code=-1, error_code=None):
super(FusionComputeClientError, self).__init__(message)
self.status_code = status_code
self.error_code = error_code
self.server_traceback = server_traceback
def __str__(self):
if self.status_code != -1:
return '{0}: {1}'.format(self.status_code, self.message)
return self.message
class IllegalParametersError(FusionComputeClientError):
ERROR_CODE = 'illegal_parameters_error'
class ServerNotFound(FusionComputeClientError):
ERROR_CODE = 'server_not_found'
class ServerCreationFailed(FusionComputeClientError):
ERROR_CODE = 'server_creation_failed'
ERROR_MAPPING = dict([
(error.ERROR_CODE, error)
for error in [
IllegalParametersError,
ServerNotFound,
ServerCreationFailed
]])
|
person = ('Nana', 25, 'piza')
# unpack mikonim person ro
# chandta ro ba ham takhsis midim
name, age, food = person
print(name)
print(age)
print(food)
person2 = ["ali", 26, "eli"]
name, age, food = person2
print(name)
print(age)
print(food)
# dictionary order nadare o nmishe tekrari dasht
dic = {'banana', 'blueberry'}
dic.add("kiwi")
# add mikone
print(dic)
# farghe set o dictionary ine k set key o value
# nadare faghat data gheyre tekrari dare
# vali dictionary ha key o value daran
lis = [1, 1, 1, 1, 2, 2, 3, 4, 5, 5, 6, 8, 6]
no_duplicate = set(lis)
print(no_duplicate)
library1 = {'harry', 'hungry', 'ali'}
library2 = {'harry', 'eli'}
print(library2.union(library1))
# union baes mishe 2ta set ro ba ham edgham konim
print(library2.intersection(library1))
# intersection un chizi k eshterak ro mide
print(library2.difference(library1))
# un chizi k tu lib2 bashe ama tu lib1 nabashe
print(library1.clear())
dictionary = {'ali': 20, 'eli': 25, 'elnaz': 10}
print(dictionary['ali'])
# faghat value hamun key ro print mikone
print(dictionary.get("amo"))
# get baes mishe age nabashe bede none be jaye error
contacts = {"amir": 921,
"abolfazt": ['0912', "akbar"]}
print(contacts)
# dic tu dic
contacts = {"amir": {'phone': 921, 'email': "aboli@g"},
"abolfazt": ['0912', "akbar"]}
print(contacts["amir"]["email"])
sen="i am going to be the best python coder " \
"and will have a great life with elham"
word_count={
"I":1,"elham":1,'python':1
}
word_count["elham"] = word_count["elham"]+1
print(contacts.items())
#hamasho mide
print(contacts.keys())
#key haro mide
print(contacts.values())
#value haro mide
print(word_count)
word_count.pop("I")
#ye ite ro az dictionary pop mikone
print(word_count)
word_count.popitem()
#akharin item pop mikone
print(word_count)
d= {(1,2):1,5:7}
print(d.keys())
|
# -*- coding: utf-8 -*-
def main():
n = int(input())
a_score, b_score = 0, 0
for i in range(n):
ai, bi = map(int, input().split())
if ai > bi:
a_score += ai + bi
elif ai < bi:
b_score += ai + bi
else:
a_score += ai
b_score += bi
print(a_score, b_score)
if __name__ == '__main__':
main()
|
UPWARDS = 1
UPDOWN = -1
FARAWAY = 1.0e39
SKYBOX_DISTANCE = 1.0e6
|
class Solution:
def checkStraightLine(self, coordinates: [[int]]) -> bool:
(x1, y1), (x2, y2) = coordinates[:2]
for i in range(2, len(coordinates)):
x, y = coordinates[i]
if (y2 - y1) * (x1 - x) != (y1 - y) * (x2 - x1):
return False
return True
|
#coding: utf-8
LEFT = 'left'
X = 'x'
RIGHT = 'right'
WIDTH = 'width'
MAX_WIDTH = 'max_width'
MIN_WIDTH = 'min_width'
INNER_WIDTH = 'inner_width'
CENTER = 'center'
TOP = 'top'
Y = 'y'
BOTTOM = 'bottom'
HEIGHT = 'height'
MAX_HEIGHT = 'max_height'
MIN_HEIGHT = 'min_height'
INNER_HEIGHT = 'inner_height'
MIDDLE = 'middle'
GRID_SIZE = 'grid_size'
HORIZONTAL = 'horizontal'
VERTICAL = 'vertical'
PORTRAIT = 'portrait'
LANDSCAPE = 'landscape'
SQUARE = 'square'
SIZE = 'size'
|
#!/usr/bin/python
#
"""
Virtual superclass for all devices
Homepage and documentation: http://dev.moorescloud.com/
Copyright (c) 2013, Mark Pesce.
License: MIT (see LICENSE for details)
"""
__author__ = 'Mark Pesce'
__version__ = '0.1a'
__license__ = 'MIT'
class Device:
def __init__(self, dev):
self.dev = dev
return
def on(self):
self.dev.on()
return
def off(self):
self.dev.off()
return
def value(self):
try:
val = self.dev.value()
except:
raise Error("Method does not exist")
return val
|
class Solution:
def validPalindrome(self, s: str) -> bool:
l, r = 0, len(s) - 1
while l < r:
if s[l] != s[r]:
return self._validPalindrome(s, l + 1, r) or self._validPalindrome(s, l, r - 1)
l += 1
r -= 1
return True
def _validPalindrome(self, s, left, right):
while left < right:
if s[left] != s[right]:
return False
left += 1
right -= 1
return True
|
# 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 isValidBST(self, root: Optional[TreeNode]) -> bool:
ary = []
self.traverse(root, ary)
return self.is_valid(ary)
# inorder
def traverse(self, root, ary):
if root.left is not None:
self.traverse(root.left, ary)
ary.append(root.val)
if root.right is not None:
self.traverse(root.right, ary)
def is_valid(self, ary):
for i in range(1, len(ary)):
if ary[i-1] >= ary[i]:
return False
return True
|
# -*- coding: utf-8 -*-
"""
This module provides the utilities used by the requester.
"""
def make_host(headers, dst_ip):
if "Host" in headers:
return headers["Host"]
elif "host" in headers:
return headers["host"]
else:
return dst_ip
def make_request_url(host, port, uri):
if "http://" in host or "https://" in host:
return "%s%s" % (host, uri)
if port == 443:
return "https://%s%s" % (host, uri)
return "http://%s%s" % (host, uri)
def make_dumy_body(byte):
dumy_body = ""
if byte is None or byte <= 0:
return dumy_body
for i in range(byte):
dumy_body += "\x00"
return dumy_body
def make_ellipsis(text, max_len=1000):
if max_len <= 0 or len(text) < max_len:
return text
return text[:max_len] + "\n(ellipsised...)"
|
def solution(N, P):
ans = []
for c in P:
ans.append('S' if c == 'E' else 'E')
return ''.join(ans)
def main():
T = int(input())
for t in range(T):
N, P = int(input()), input()
answer = solution(N, P)
print('Case #' + str(t+1) + ': ' + answer)
if __name__ == '__main__':
main()
|
# https://codeforces.com/problemset/problem/1220/A
n, s = int(input()), input()
ones = s.count('n')
zeros = (n-(ones*3))//4
print(f"{'1 '*ones}{'0 '*zeros}")
|
# Reverse Nodes in k-Group: https://leetcode.com/problems/reverse-nodes-in-k-group/
# Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.
# k is a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multiple of k then left-out nodes, in the end, should remain as it is.
# You may not alter the values in the list's nodes, only nodes themselves may be changed.
# So this problem seems like we need to put in a for loop counting up to k and then reverse from start to k
# I think that we can probably pass the sort to another function to keep this code ab it clean
# Definition for singly-linked list.
class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def reverseKGroup(self, head: ListNode, k: int) -> ListNode:
count = 0
cur = head
# Check to see if k is smaller than the length of the list
while count < k and cur:
cur = cur.next
count += 1
if count == k:
# Reverse from head to k
reversedList = self.reverse(head, k)
# Recursively call down the stack
head.next = self.reverseKGroup(cur, k)
return reversedList
# Otherwise we just return the list as is
return head
return
def reverse(self, head, k):
prev = None
cur = head
while k:
# Keep track of the node after k
ourNext = cur.next
cur.next = prev
prev = cur
cur = ourNext
k -= 1
return prev
# So the above works, what happens is that we call recursively down the list swapping k elements at a time and if there is more
# we call the function itself if we loop through the list and we don't reach k we are at the end and we start returning the list
# The bonus is that we assign the reversed k and keep them on the stack as we come up which really simplifies the problem
# This runs in o(n) and o(n/k) as we visit each node and store the value of n/k on the stack until we reach n
# Can we do better? I think so I know that we can recursively call through the list so I think that if we approach this problem
# as we go across from 0 -> n checking for index % k we can find the point where we need to end the reverse from! Then all we
# need is to call our reverse function like we did above and we should be good.
def reverseKGroup(self, head: ListNode, k: int) -> ListNode:
cur = head
# We need to check for the node that we point to from as it can't always be none
lastTail = None
# The new head
result = None
while cur:
count = 0
cur = head
# Loop over the values like before
while count < k and cur:
cur = cur.next
count += 1
# If we need to reverse keep track of the reversed list
if count == k:
reversedList = self.reverse(head, k)
# If we reveresed the first k update the new head
if not result:
result = reversedList
# if we have a node that is pointing to our start
# we need to point it to the new head
if lastTail:
lastTail.next = reversedList
# we need to update head to the cur pointer (to mirror the recursion)
lastTail = head
head = cur
# Even if we have gone through if we haven't pointed the last node to the new head
# we need to do that agin
if lastTail:
lastTail.next = head
# return either new head or the old head depending if k is in the length of the linked list
return result if result else head
# So the iterative step is the same thing like I explained there is a little bit of extra to handle if you have a node
# before you start reveresing. The difference is that this will run in o(n) and o(1) space as we are changing the result
# as we go along
# Score Card
# Did I need hints? Yes
# Did you finish within 30 min? n 45
# Was the solution optimal? The initial solution I though of definitely wasn't but when I got to thinking I solved in optimal
# improving on the intial
# Were there any bugs? Nope
# 3 3 3 4 = 3.25
|
def test_get_building_block_id(case_data):
"""
Test :meth:`.BondInfo.get_building_block_id`.
Parameters
----------
case_data : :class:`.CaseData`
A test case. Holds the bond info to test and the building
block id it should be holding.
Returns
-------
None : :class:`NoneType`
"""
assert (
case_data.bond_info.get_building_block_id()
== case_data.building_block_id
)
|
#Faço um mini-sistema que utilize o Interactive Help do Python. O usuário vai digitar o comando e o manual vai aparecer.
#Quando o usuário digitar a palavra 'FIM', o programa se encerrará. OBS:Use cores.
c = ('\033[m', # 0 - sem cor
'\033[0:0:41m', # 1 - vermelho
'\033[0:0:42m', # 2 - verde
'\033[0:0:44m', # 3 - azul
'\033[7;0m' # 4 - branco
)
def ajuda(comando):
titulo(f'Acessando o manual do comando \'{comando}\'', 3)
print(c[4])
help(comando)
print(c[0])
def titulo(msg, cor=0):
tam = len(msg) + 4
print(c[cor],end='')
print('~' * tam)
print(f'{msg:^30}')
print('~' * tam)
print(c[0],end='')
while True:
titulo('SISTEMA DE AJUDA PyHELP', 2)
comando = str(input('Função ou Biblioteca >'))
if comando.strip().upper() == 'FIM':
break
else:
ajuda(comando)
titulo('ATÉ LOGO', 1)
|
# @Title: 跳跃游戏 II (Jump Game II)
# @Author: KivenC
# @Date: 2019-03-01 09:07:22
# @Runtime: 80 ms
# @Memory: 14.5 MB
class Solution:
def jump(self, nums: List[int]) -> int:
if len(nums) < 2:
return 0
i, step, jump_point, max_dis = 0, 0, 0, nums[0]
while i < len(nums):
step += 1
if max_dis >= len(nums) - 1:
return step
for j in range(i+1, i+nums[i]+1):
temp = j + nums[j]
if temp >= len(nums) - 1:
return step + 1
if temp > max_dis:
max_dis = temp
jump_point = j
i = jump_point
|
class Solution:
def isAnagram(self, s: str, t: str) -> bool:
h = {}
for i in s:
h[i] = h.get(i, 0) + 1
for j in t:
if h.get(j, 0) == 0:
return False
else:
h[j] -= 1
for k in h:
if h[k] >= 1:
return False
return True
|
#!/usr/bin/env python
# descriptors from http://www.winning-homebrew.com/beer-flavor-descriptors.html
aroma_basic = [
'malty', 'grainy', 'sweet',
'corn', 'hay', 'straw',
'cracker', 'bicuity',
'caramel', 'toast', 'roast',
'coffee', 'espresso', 'burnt',
'alcohol', 'tobacco', 'gunpowder',
'leather', 'pine', 'grass',
'dank', 'piney', 'floral',
'perfume'
]
aroma_dark_fruit = [
'raisins', 'currant', 'plum',
'dates', 'prunes', 'figs',
'blackberry', 'blueberry'
]
aroma_light_fruit = [
'banana', 'pineapple', 'apricot',
'pear', 'apple', 'nectarine',
'peach', 'mango'
]
aroma_citrus = [
'lemon', 'lime', 'orange',
'tangerine', 'clementine',
'grapefruit', 'grapefruity', 'peel',
'zest', 'citrus', 'orangey',
]
aroma_other = [
'metallic', 'vinegar', 'copper',
'cidery', 'champagne', 'astringent',
'chlorine'
]
aroma_spices_yeast = [
'phenolic', 'pepper', 'clove', 'anise',
'licorice', 'smoke', 'bacon', 'fatty',
'nutty', 'butterscotch', 'vanilla',
'earthy', 'woody', 'horsey',
'bread', 'saddle', 'musty',
'barnyard', 'spice'
]
appearance_color = [
'honey', 'caramel', 'red',
'brown', 'rootbeer', 'amber',
'chestnut', 'dark', 'apricot',
'orange', 'black', 'burnt',
'auburn', 'garnet', 'ruby',
'copper', 'gold'
]
appearance_clarity = [
'brilliant', 'hazy', 'cloudy',
'turbid', 'opaque', 'clear',
'crystal', 'bright', 'dull',
'haze'
]
appearance_head = [
'persistent', 'rocky', 'large',
'fluffy', 'dissipating', 'lingering',
'white', 'offwhite', 'tan',
'frothy', 'delicate'
]
taste_basic = [
'roasted', 'bready', 'bitter',
'sweet', 'spicy', 'fruity',
'chocolate', 'caramel', 'toffee',
'coffee', 'malty', 'tart',
'subtle', 'woodsy', 'earthy',
'sulfur', 'sulfuric'
]
taste_intensity = [
'assertive', 'mild', 'bold',
'balanced', 'robust', 'intense',
'metallic', 'harsh', 'complex',
'delicate', 'refined', 'hearty'
]
taste_finish = [
'dry', 'fruity', 'sweet',
'alcoholic', 'warming', 'bitter',
'acidic', 'buttery', 'wet',
'quenching', 'lingering'
]
palate_mouthfeel = [
'smooth', 'silky', 'velvety',
'prickly', 'tingly', 'creamy',
'warming', 'viscous', 'hot',
'astringent', 'oily'
]
palate_carbonation = [
'spritzy', 'prickly', 'round',
'creamy', 'light', 'gassy',
'sharp', 'delicate'
]
palate_body = [
'full', 'heavy', 'dense',
'viscous', 'robust', 'medium',
'balanced', 'light', 'delicate',
'wispy'
]
# define larger groups
aroma = (
aroma_basic + aroma_dark_fruit + aroma_light_fruit +
aroma_citrus + aroma_other + aroma_spices_yeast
)
appearance = (
appearance_color + appearance_clarity + appearance_head
)
taste = (
taste_basic + taste_intensity + taste_finish
)
palate = (
palate_mouthfeel + palate_carbonation + palate_body
)
# define union of all descriptors
all_descriptors = list(set(
aroma + appearance + taste + palate
))
|
def get_fact(i):
if i==1:
return 1
else:
return i*get_fact(i-1)
t=int(input())
for i in range(t):
x=int(input())
print(get_fact(x))
|
# /Users/dvs/Dropbox/Code/graphql-py/graphql/parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.5'
_lr_method = 'LALR'
_lr_signature = 'CDC982EBD105CCA216971D7DA325FA06'
_lr_action_items = {'BRACE_L':([0,8,10,11,21,23,24,25,26,27,28,29,30,31,32,33,36,37,50,51,52,58,59,61,67,68,70,71,73,80,81,82,83,87,90,91,92,96,98,99,103,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,134,135,136,137,139,143,147,148,149,151,153,154,155,156,157,158,159,160,161,165,166,167,169,172,173,174,176,],[5,5,-18,-19,5,-76,-72,-73,-74,-75,-77,-78,-79,5,5,5,-56,-58,5,5,5,5,5,5,-57,-60,5,5,5,5,-55,-127,5,-65,-59,5,5,-61,126,5,5,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,126,-70,126,-107,-109,-115,162,-106,-108,-114,126,-90,-91,-92,-93,-94,-95,-96,-97,162,162,-111,-113,-120,-110,-112,-119,162,]),'FRAGMENT':([0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,34,36,37,38,39,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,60,62,63,66,67,68,69,70,71,72,73,74,75,76,77,79,84,85,86,90,92,93,94,95,96,97,98,100,101,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,133,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[9,9,9,-7,25,-8,-9,25,39,-18,-19,-6,9,-5,25,-22,-23,-24,-25,25,-41,39,-76,-72,-73,-74,-75,-77,-78,-79,-17,-56,-58,25,-49,-48,-50,-51,-52,-53,-54,-4,-20,-21,-37,-38,-39,-40,-80,25,-43,25,-13,-15,-16,25,-57,-60,25,-36,-35,-34,-33,-32,-31,25,-63,-42,-11,-12,-14,-59,-30,-29,-28,-27,-61,-62,121,-47,-10,25,-45,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,25,-100,-98,-99,-101,-102,-103,-104,-105,121,25,-46,25,-44,-70,121,-107,-109,25,-115,-117,121,-106,-108,-114,-116,121,-90,-91,-92,-93,-94,-95,-96,-97,121,25,-118,121,-111,-113,25,-120,-122,-110,-112,-119,-121,121,-123,]),'QUERY':([0,2,4,5,6,7,8,9,10,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,34,36,37,38,39,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,60,62,63,66,67,68,69,70,71,72,73,74,75,76,77,79,84,85,86,90,92,93,94,95,96,97,98,100,101,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,133,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[10,10,-7,26,-8,-9,26,42,-18,-19,-6,26,-22,-23,-24,-25,26,-41,42,-76,-72,-73,-74,-75,-77,-78,-79,-17,-56,-58,26,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,26,-43,26,-13,-15,-16,26,-57,-60,26,-36,-35,-34,-33,-32,-31,26,-63,-42,-11,-12,-14,-59,-30,-29,-28,-27,-61,-62,122,-47,-10,26,-45,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,26,-100,-98,-99,-101,-102,-103,-104,-105,122,26,-46,26,-44,-70,122,-107,-109,26,-115,-117,122,-106,-108,-114,-116,122,-90,-91,-92,-93,-94,-95,-96,-97,122,26,-118,122,-111,-113,26,-120,-122,-110,-112,-119,-121,122,-123,]),'MUTATION':([0,2,4,5,6,7,8,9,10,11,12,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,34,36,37,38,39,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,60,62,63,66,67,68,69,70,71,72,73,74,75,76,77,79,84,85,86,90,92,93,94,95,96,97,98,100,101,102,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,133,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[11,11,-7,27,-8,-9,27,43,-18,-19,-6,27,-22,-23,-24,-25,27,-41,43,-76,-72,-73,-74,-75,-77,-78,-79,-17,-56,-58,27,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,27,-43,27,-13,-15,-16,27,-57,-60,27,-36,-35,-34,-33,-32,-31,27,-63,-42,-11,-12,-14,-59,-30,-29,-28,-27,-61,-62,123,-47,-10,27,-45,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,27,-100,-98,-99,-101,-102,-103,-104,-105,123,27,-46,27,-44,-70,123,-107,-109,27,-115,-117,123,-106,-108,-114,-116,123,-90,-91,-92,-93,-94,-95,-96,-97,123,27,-118,123,-111,-113,27,-120,-122,-110,-112,-119,-121,123,-123,]),'$end':([1,2,3,4,6,7,12,13,14,34,47,48,60,62,63,84,85,86,101,104,133,],[0,-1,-2,-7,-8,-9,-6,-3,-5,-17,-4,-20,-13,-15,-16,-11,-12,-14,-10,-45,-44,]),'SPREAD':([5,15,16,17,18,19,21,23,24,25,26,27,28,29,30,36,37,39,41,42,43,44,45,46,48,49,50,51,52,53,56,67,68,70,71,72,73,74,75,79,90,92,93,94,95,96,100,105,127,],[22,22,-22,-23,-24,-25,-41,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-43,-57,-60,-36,-35,-34,-33,-32,-31,-42,-59,-30,-29,-28,-27,-61,-47,-26,-46,]),'NAME':([5,8,9,10,11,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,36,37,38,39,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,66,67,68,69,70,71,72,73,74,75,76,77,79,90,92,93,94,95,96,97,98,100,102,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[24,24,41,-18,-19,24,-22,-23,-24,-25,24,-41,41,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,24,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,24,-43,24,24,-57,-60,24,-36,-35,-34,-33,-32,-31,24,-63,-42,-59,-30,-29,-28,-27,-61,-62,120,-47,24,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,24,-100,-98,-99,-101,-102,-103,-104,-105,120,24,-46,24,-70,120,-107,-109,24,-115,-117,120,-106,-108,-114,-116,120,-90,-91,-92,-93,-94,-95,-96,-97,120,24,-118,120,-111,-113,24,-120,-122,-110,-112,-119,-121,120,-123,]),'ON':([5,8,10,11,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,36,37,38,39,40,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,66,67,68,69,70,71,72,73,74,75,76,77,79,90,92,93,94,95,96,97,98,100,102,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[23,23,-18,-19,23,-22,-23,-24,-25,23,-41,57,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,23,-49,69,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,23,-43,23,23,-57,-60,23,-36,-35,-34,-33,-32,-31,23,-63,-42,-59,-30,-29,-28,-27,-61,-62,124,-47,23,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,23,-100,-98,-99,-101,-102,-103,-104,-105,124,23,-46,23,-70,124,-107,-109,23,-115,-117,124,-106,-108,-114,-116,124,-90,-91,-92,-93,-94,-95,-96,-97,124,23,-118,124,-111,-113,23,-120,-122,-110,-112,-119,-121,124,-123,]),'TRUE':([5,8,9,10,11,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,36,37,38,39,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,66,67,68,69,70,71,72,73,74,75,76,77,79,90,92,93,94,95,96,97,98,100,102,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[28,28,44,-18,-19,28,-22,-23,-24,-25,28,-41,44,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,28,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,28,-43,28,28,-57,-60,28,-36,-35,-34,-33,-32,-31,28,-63,-42,-59,-30,-29,-28,-27,-61,-62,118,-47,28,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,28,-100,-98,-99,-101,-102,-103,-104,-105,118,28,-46,28,-70,118,-107,-109,28,-115,-117,118,-106,-108,-114,-116,118,-90,-91,-92,-93,-94,-95,-96,-97,118,28,-118,118,-111,-113,28,-120,-122,-110,-112,-119,-121,118,-123,]),'FALSE':([5,8,9,10,11,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,36,37,38,39,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,66,67,68,69,70,71,72,73,74,75,76,77,79,90,92,93,94,95,96,97,98,100,102,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[29,29,45,-18,-19,29,-22,-23,-24,-25,29,-41,45,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,29,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,29,-43,29,29,-57,-60,29,-36,-35,-34,-33,-32,-31,29,-63,-42,-59,-30,-29,-28,-27,-61,-62,119,-47,29,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,29,-100,-98,-99,-101,-102,-103,-104,-105,119,29,-46,29,-70,119,-107,-109,29,-115,-117,119,-106,-108,-114,-116,119,-90,-91,-92,-93,-94,-95,-96,-97,119,29,-118,119,-111,-113,29,-120,-122,-110,-112,-119,-121,119,-123,]),'NULL':([5,8,9,10,11,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,36,37,38,39,41,42,43,44,45,46,48,49,50,51,52,53,54,55,56,57,66,67,68,69,70,71,72,73,74,75,76,77,79,90,92,93,94,95,96,97,98,100,102,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,132,134,135,136,137,138,139,140,143,147,148,149,150,151,153,154,155,156,157,158,159,160,161,162,164,165,166,167,168,169,170,172,173,174,175,176,177,],[30,30,46,-18,-19,30,-22,-23,-24,-25,30,-41,46,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,30,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-80,30,-43,30,30,-57,-60,30,-36,-35,-34,-33,-32,-31,30,-63,-42,-59,-30,-29,-28,-27,-61,-62,117,-47,30,-26,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,30,-100,-98,-99,-101,-102,-103,-104,-105,117,30,-46,30,-70,117,-107,-109,30,-115,-117,117,-106,-108,-114,-116,117,-90,-91,-92,-93,-94,-95,-96,-97,117,30,-118,117,-111,-113,30,-120,-122,-110,-112,-119,-121,117,-123,]),'PAREN_L':([8,10,11,21,23,24,25,26,27,28,29,30,31,50,68,],[35,-18,-19,55,-76,-72,-73,-74,-75,-77,-78,-79,35,55,55,]),'AT':([8,10,11,21,23,24,25,26,27,28,29,30,31,32,36,37,39,41,42,43,44,45,46,50,51,56,58,67,68,70,80,81,82,87,90,91,96,],[38,-18,-19,38,-76,-72,-73,-74,-75,-77,-78,-79,38,38,38,-58,-49,-48,-50,-51,-52,-53,-54,38,38,38,38,-57,-60,38,38,-55,-127,-65,-59,38,-61,]),'BRACE_R':([15,16,17,18,19,21,23,24,25,26,27,28,29,30,36,37,39,41,42,43,44,45,46,48,49,50,51,52,53,56,67,68,70,71,72,73,74,75,79,90,92,93,94,95,96,100,105,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,126,127,134,136,138,139,140,147,149,150,153,154,155,156,157,158,159,160,162,164,166,168,169,170,172,174,175,177,],[48,-22,-23,-24,-25,-41,-76,-72,-73,-74,-75,-77,-78,-79,-56,-58,-49,-48,-50,-51,-52,-53,-54,-20,-21,-37,-38,-39,-40,-43,-57,-60,-36,-35,-34,-33,-32,-31,-42,-59,-30,-29,-28,-27,-61,-47,-26,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,139,-46,-70,-107,149,-115,-117,-106,-114,-116,-90,-91,-92,-93,-94,-95,-96,-97,169,-118,-111,174,-120,-122,-110,-119,-121,-123,]),'COLON':([21,23,24,25,26,27,28,29,30,78,89,141,171,],[54,-76,-72,-73,-74,-75,-77,-78,-79,98,102,151,176,]),'BANG':([23,24,25,26,27,28,29,30,82,129,130,163,],[-76,-72,-73,-74,-75,-77,-78,-79,-127,144,145,-128,]),'EQUALS':([23,24,25,26,27,28,29,30,82,128,129,130,131,144,145,163,],[-76,-72,-73,-74,-75,-77,-78,-79,-127,143,-124,-125,-126,-129,-130,-128,]),'PAREN_R':([23,24,25,26,27,28,29,30,64,65,76,77,82,88,97,106,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,128,129,130,131,134,136,139,142,144,145,147,149,152,153,154,155,156,157,158,159,160,163,166,169,172,174,],[-76,-72,-73,-74,-75,-77,-78,-79,87,-67,96,-63,-127,-66,-62,-64,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,-69,-124,-125,-126,-70,-107,-115,-68,-129,-130,-106,-114,-71,-90,-91,-92,-93,-94,-95,-96,-97,-128,-111,-120,-110,-119,]),'DOLLAR':([23,24,25,26,27,28,29,30,35,64,65,82,88,98,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,128,129,130,131,134,135,136,137,139,142,144,145,147,148,149,151,152,153,154,155,156,157,158,159,160,163,166,169,172,174,],[-76,-72,-73,-74,-75,-77,-78,-79,66,66,-67,-127,-66,116,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,116,-69,-124,-125,-126,-70,116,-107,-109,-115,-68,-129,-130,-106,-108,-114,116,-71,-90,-91,-92,-93,-94,-95,-96,-97,-128,-111,-120,-110,-119,]),'BRACKET_R':([23,24,25,26,27,28,29,30,82,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,129,130,131,134,135,136,137,139,144,145,146,147,148,149,153,154,155,156,157,158,159,160,161,163,165,166,167,169,172,173,174,],[-76,-72,-73,-74,-75,-77,-78,-79,-127,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,136,-124,-125,-126,-70,147,-107,-109,-115,-129,-130,163,-106,-108,-114,-90,-91,-92,-93,-94,-95,-96,-97,166,-128,172,-111,-113,-120,-110,-112,-119,]),'INT_VALUE':([23,24,25,26,27,28,29,30,98,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,134,135,136,137,139,143,147,148,149,151,153,154,155,156,157,158,159,160,161,165,166,167,169,172,173,174,176,],[-76,-72,-73,-74,-75,-77,-78,-79,108,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,108,-70,108,-107,-109,-115,153,-106,-108,-114,108,-90,-91,-92,-93,-94,-95,-96,-97,153,153,-111,-113,-120,-110,-112,-119,153,]),'FLOAT_VALUE':([23,24,25,26,27,28,29,30,98,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,134,135,136,137,139,143,147,148,149,151,153,154,155,156,157,158,159,160,161,165,166,167,169,172,173,174,176,],[-76,-72,-73,-74,-75,-77,-78,-79,109,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,109,-70,109,-107,-109,-115,154,-106,-108,-114,109,-90,-91,-92,-93,-94,-95,-96,-97,154,154,-111,-113,-120,-110,-112,-119,154,]),'STRING_VALUE':([23,24,25,26,27,28,29,30,98,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,134,135,136,137,139,143,147,148,149,151,153,154,155,156,157,158,159,160,161,165,166,167,169,172,173,174,176,],[-76,-72,-73,-74,-75,-77,-78,-79,110,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,110,-70,110,-107,-109,-115,155,-106,-108,-114,110,-90,-91,-92,-93,-94,-95,-96,-97,155,155,-111,-113,-120,-110,-112,-119,155,]),'BRACKET_L':([23,24,25,26,27,28,29,30,98,102,107,108,109,110,111,112,113,114,115,117,118,119,120,121,122,123,124,125,132,134,135,136,137,139,143,147,148,149,151,153,154,155,156,157,158,159,160,161,165,166,167,169,172,173,174,176,],[-76,-72,-73,-74,-75,-77,-78,-79,125,132,-81,-82,-83,-84,-85,-86,-87,-88,-89,-100,-98,-99,-101,-102,-103,-104,-105,125,132,-70,125,-107,-109,-115,161,-106,-108,-114,125,-90,-91,-92,-93,-94,-95,-96,-97,161,161,-111,-113,-120,-110,-112,-119,161,]),}
_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 = {'document':([0,],[1,]),'definition_list':([0,],[2,]),'selection_set':([0,8,21,31,32,33,50,51,52,58,59,61,70,71,73,80,83,91,92,99,103,],[3,34,53,60,62,63,72,74,75,84,85,86,93,94,95,100,101,104,105,127,133,]),'definition':([0,2,],[4,12,]),'operation_definition':([0,2,],[6,6,]),'fragment_definition':([0,2,3,13,],[7,7,14,47,]),'operation_type':([0,2,],[8,8,]),'fragment_list':([3,],[13,]),'selection_list':([5,],[15,]),'selection':([5,15,],[16,49,]),'field':([5,15,],[17,17,]),'fragment_spread':([5,15,],[18,18,]),'inline_fragment':([5,15,],[19,19,]),'alias':([5,15,],[20,20,]),'name':([5,8,15,20,38,55,57,66,69,76,102,116,126,132,138,162,168,],[21,31,21,50,68,78,82,89,82,78,82,134,141,82,141,171,171,]),'variable_definitions':([8,31,],[32,58,]),'directives':([8,21,31,32,50,51,56,58,70,80,91,],[33,52,59,61,71,73,79,83,92,99,103,]),'directive_list':([8,21,31,32,50,51,56,58,70,80,91,],[36,36,36,36,36,36,36,36,36,36,36,]),'directive':([8,21,31,32,36,50,51,56,58,70,80,91,],[37,37,37,37,67,37,37,37,37,37,37,37,]),'fragment_name':([9,22,],[40,56,]),'arguments':([21,50,68,],[51,70,90,]),'variable_definition_list':([35,],[64,]),'variable_definition':([35,64,],[65,88,]),'argument_list':([55,],[76,]),'argument':([55,76,],[77,97,]),'type_condition':([57,69,],[80,91,]),'named_type':([57,69,102,132,],[81,81,129,129,]),'value':([98,125,135,151,],[106,137,148,164,]),'variable':([98,125,135,151,],[107,107,107,107,]),'null_value':([98,125,135,143,151,161,165,176,],[111,111,111,156,111,156,156,156,]),'boolean_value':([98,125,135,143,151,161,165,176,],[112,112,112,157,112,157,157,157,]),'enum_value':([98,125,135,143,151,161,165,176,],[113,113,113,158,113,158,158,158,]),'list_value':([98,125,135,151,],[114,114,114,114,]),'object_value':([98,125,135,151,],[115,115,115,115,]),'type':([102,132,],[128,146,]),'list_type':([102,132,],[130,130,]),'non_null_type':([102,132,],[131,131,]),'value_list':([125,],[135,]),'object_field_list':([126,],[138,]),'object_field':([126,138,],[140,150,]),'default_value':([128,],[142,]),'const_value':([143,161,165,176,],[152,167,173,177,]),'const_list_value':([143,161,165,176,],[159,159,159,159,]),'const_object_value':([143,161,165,176,],[160,160,160,160,]),'const_value_list':([161,],[165,]),'const_object_field_list':([162,],[168,]),'const_object_field':([162,168,],[170,175,]),}
_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' -> document","S'",1,None,None,None),
('document -> definition_list','document',1,'p_document','parser.py',42),
('document -> selection_set','document',1,'p_document_shorthand','parser.py',48),
('document -> selection_set fragment_list','document',2,'p_document_shorthand_with_fragments','parser.py',54),
('fragment_list -> fragment_list fragment_definition','fragment_list',2,'p_fragment_list','parser.py',60),
('fragment_list -> fragment_definition','fragment_list',1,'p_fragment_list_single','parser.py',66),
('definition_list -> definition_list definition','definition_list',2,'p_definition_list','parser.py',72),
('definition_list -> definition','definition_list',1,'p_definition_list_single','parser.py',78),
('definition -> operation_definition','definition',1,'p_definition','parser.py',84),
('definition -> fragment_definition','definition',1,'p_definition','parser.py',85),
('operation_definition -> operation_type name variable_definitions directives selection_set','operation_definition',5,'p_operation_definition1','parser.py',97),
('operation_definition -> operation_type name variable_definitions selection_set','operation_definition',4,'p_operation_definition2','parser.py',108),
('operation_definition -> operation_type name directives selection_set','operation_definition',4,'p_operation_definition3','parser.py',118),
('operation_definition -> operation_type name selection_set','operation_definition',3,'p_operation_definition4','parser.py',128),
('operation_definition -> operation_type variable_definitions directives selection_set','operation_definition',4,'p_operation_definition5','parser.py',134),
('operation_definition -> operation_type variable_definitions selection_set','operation_definition',3,'p_operation_definition6','parser.py',144),
('operation_definition -> operation_type directives selection_set','operation_definition',3,'p_operation_definition7','parser.py',153),
('operation_definition -> operation_type selection_set','operation_definition',2,'p_operation_definition8','parser.py',162),
('operation_type -> QUERY','operation_type',1,'p_operation_type','parser.py',168),
('operation_type -> MUTATION','operation_type',1,'p_operation_type','parser.py',169),
('selection_set -> BRACE_L selection_list BRACE_R','selection_set',3,'p_selection_set','parser.py',175),
('selection_list -> selection_list selection','selection_list',2,'p_selection_list','parser.py',181),
('selection_list -> selection','selection_list',1,'p_selection_list_single','parser.py',187),
('selection -> field','selection',1,'p_selection','parser.py',193),
('selection -> fragment_spread','selection',1,'p_selection','parser.py',194),
('selection -> inline_fragment','selection',1,'p_selection','parser.py',195),
('field -> alias name arguments directives selection_set','field',5,'p_field_all','parser.py',201),
('field -> name arguments directives selection_set','field',4,'p_field_optional1_1','parser.py',208),
('field -> alias name directives selection_set','field',4,'p_field_optional1_2','parser.py',215),
('field -> alias name arguments selection_set','field',4,'p_field_optional1_3','parser.py',221),
('field -> alias name arguments directives','field',4,'p_field_optional1_4','parser.py',227),
('field -> name directives selection_set','field',3,'p_field_optional2_1','parser.py',233),
('field -> name arguments selection_set','field',3,'p_field_optional2_2','parser.py',239),
('field -> name arguments directives','field',3,'p_field_optional2_3','parser.py',245),
('field -> alias name selection_set','field',3,'p_field_optional2_4','parser.py',251),
('field -> alias name directives','field',3,'p_field_optional2_5','parser.py',257),
('field -> alias name arguments','field',3,'p_field_optional2_6','parser.py',263),
('field -> alias name','field',2,'p_field_optional3_1','parser.py',269),
('field -> name arguments','field',2,'p_field_optional3_2','parser.py',275),
('field -> name directives','field',2,'p_field_optional3_3','parser.py',281),
('field -> name selection_set','field',2,'p_field_optional3_4','parser.py',287),
('field -> name','field',1,'p_field_optional4','parser.py',293),
('fragment_spread -> SPREAD fragment_name directives','fragment_spread',3,'p_fragment_spread1','parser.py',299),
('fragment_spread -> SPREAD fragment_name','fragment_spread',2,'p_fragment_spread2','parser.py',305),
('fragment_definition -> FRAGMENT fragment_name ON type_condition directives selection_set','fragment_definition',6,'p_fragment_definition1','parser.py',311),
('fragment_definition -> FRAGMENT fragment_name ON type_condition selection_set','fragment_definition',5,'p_fragment_definition2','parser.py',318),
('inline_fragment -> SPREAD ON type_condition directives selection_set','inline_fragment',5,'p_inline_fragment1','parser.py',325),
('inline_fragment -> SPREAD ON type_condition selection_set','inline_fragment',4,'p_inline_fragment2','parser.py',332),
('fragment_name -> NAME','fragment_name',1,'p_fragment_name','parser.py',338),
('fragment_name -> FRAGMENT','fragment_name',1,'p_fragment_name','parser.py',339),
('fragment_name -> QUERY','fragment_name',1,'p_fragment_name','parser.py',340),
('fragment_name -> MUTATION','fragment_name',1,'p_fragment_name','parser.py',341),
('fragment_name -> TRUE','fragment_name',1,'p_fragment_name','parser.py',342),
('fragment_name -> FALSE','fragment_name',1,'p_fragment_name','parser.py',343),
('fragment_name -> NULL','fragment_name',1,'p_fragment_name','parser.py',344),
('type_condition -> named_type','type_condition',1,'p_type_condition','parser.py',350),
('directives -> directive_list','directives',1,'p_directives','parser.py',356),
('directive_list -> directive_list directive','directive_list',2,'p_directive_list','parser.py',362),
('directive_list -> directive','directive_list',1,'p_directive_list_single','parser.py',368),
('directive -> AT name arguments','directive',3,'p_directive','parser.py',374),
('directive -> AT name','directive',2,'p_directive','parser.py',375),
('arguments -> PAREN_L argument_list PAREN_R','arguments',3,'p_arguments','parser.py',382),
('argument_list -> argument_list argument','argument_list',2,'p_argument_list','parser.py',388),
('argument_list -> argument','argument_list',1,'p_argument_list_single','parser.py',394),
('argument -> name COLON value','argument',3,'p_argument','parser.py',400),
('variable_definitions -> PAREN_L variable_definition_list PAREN_R','variable_definitions',3,'p_variable_definitions','parser.py',406),
('variable_definition_list -> variable_definition_list variable_definition','variable_definition_list',2,'p_variable_definition_list','parser.py',412),
('variable_definition_list -> variable_definition','variable_definition_list',1,'p_variable_definition_list_single','parser.py',418),
('variable_definition -> DOLLAR name COLON type default_value','variable_definition',5,'p_variable_definition1','parser.py',424),
('variable_definition -> DOLLAR name COLON type','variable_definition',4,'p_variable_definition2','parser.py',430),
('variable -> DOLLAR name','variable',2,'p_variable','parser.py',436),
('default_value -> EQUALS const_value','default_value',2,'p_default_value','parser.py',442),
('name -> NAME','name',1,'p_name','parser.py',448),
('name -> FRAGMENT','name',1,'p_name','parser.py',449),
('name -> QUERY','name',1,'p_name','parser.py',450),
('name -> MUTATION','name',1,'p_name','parser.py',451),
('name -> ON','name',1,'p_name','parser.py',452),
('name -> TRUE','name',1,'p_name','parser.py',453),
('name -> FALSE','name',1,'p_name','parser.py',454),
('name -> NULL','name',1,'p_name','parser.py',455),
('alias -> name COLON','alias',2,'p_alias','parser.py',461),
('value -> variable','value',1,'p_value','parser.py',467),
('value -> INT_VALUE','value',1,'p_value','parser.py',468),
('value -> FLOAT_VALUE','value',1,'p_value','parser.py',469),
('value -> STRING_VALUE','value',1,'p_value','parser.py',470),
('value -> null_value','value',1,'p_value','parser.py',471),
('value -> boolean_value','value',1,'p_value','parser.py',472),
('value -> enum_value','value',1,'p_value','parser.py',473),
('value -> list_value','value',1,'p_value','parser.py',474),
('value -> object_value','value',1,'p_value','parser.py',475),
('const_value -> INT_VALUE','const_value',1,'p_const_value','parser.py',481),
('const_value -> FLOAT_VALUE','const_value',1,'p_const_value','parser.py',482),
('const_value -> STRING_VALUE','const_value',1,'p_const_value','parser.py',483),
('const_value -> null_value','const_value',1,'p_const_value','parser.py',484),
('const_value -> boolean_value','const_value',1,'p_const_value','parser.py',485),
('const_value -> enum_value','const_value',1,'p_const_value','parser.py',486),
('const_value -> const_list_value','const_value',1,'p_const_value','parser.py',487),
('const_value -> const_object_value','const_value',1,'p_const_value','parser.py',488),
('boolean_value -> TRUE','boolean_value',1,'p_boolean_value','parser.py',494),
('boolean_value -> FALSE','boolean_value',1,'p_boolean_value','parser.py',495),
('null_value -> NULL','null_value',1,'p_null_value','parser.py',501),
('enum_value -> NAME','enum_value',1,'p_enum_value','parser.py',507),
('enum_value -> FRAGMENT','enum_value',1,'p_enum_value','parser.py',508),
('enum_value -> QUERY','enum_value',1,'p_enum_value','parser.py',509),
('enum_value -> MUTATION','enum_value',1,'p_enum_value','parser.py',510),
('enum_value -> ON','enum_value',1,'p_enum_value','parser.py',511),
('list_value -> BRACKET_L value_list BRACKET_R','list_value',3,'p_list_value','parser.py',517),
('list_value -> BRACKET_L BRACKET_R','list_value',2,'p_list_value','parser.py',518),
('value_list -> value_list value','value_list',2,'p_value_list','parser.py',524),
('value_list -> value','value_list',1,'p_value_list_single','parser.py',530),
('const_list_value -> BRACKET_L const_value_list BRACKET_R','const_list_value',3,'p_const_list_value','parser.py',536),
('const_list_value -> BRACKET_L BRACKET_R','const_list_value',2,'p_const_list_value','parser.py',537),
('const_value_list -> const_value_list const_value','const_value_list',2,'p_const_value_list','parser.py',543),
('const_value_list -> const_value','const_value_list',1,'p_const_value_list_single','parser.py',549),
('object_value -> BRACE_L object_field_list BRACE_R','object_value',3,'p_object_value','parser.py',555),
('object_value -> BRACE_L BRACE_R','object_value',2,'p_object_value','parser.py',556),
('object_field_list -> object_field_list object_field','object_field_list',2,'p_object_field_list','parser.py',562),
('object_field_list -> object_field','object_field_list',1,'p_object_field_list_single','parser.py',570),
('object_field -> name COLON value','object_field',3,'p_object_field','parser.py',576),
('const_object_value -> BRACE_L const_object_field_list BRACE_R','const_object_value',3,'p_const_object_value','parser.py',582),
('const_object_value -> BRACE_L BRACE_R','const_object_value',2,'p_const_object_value','parser.py',583),
('const_object_field_list -> const_object_field_list const_object_field','const_object_field_list',2,'p_const_object_field_list','parser.py',589),
('const_object_field_list -> const_object_field','const_object_field_list',1,'p_const_object_field_list_single','parser.py',597),
('const_object_field -> name COLON const_value','const_object_field',3,'p_const_object_field','parser.py',603),
('type -> named_type','type',1,'p_type','parser.py',609),
('type -> list_type','type',1,'p_type','parser.py',610),
('type -> non_null_type','type',1,'p_type','parser.py',611),
('named_type -> name','named_type',1,'p_named_type','parser.py',617),
('list_type -> BRACKET_L type BRACKET_R','list_type',3,'p_list_type','parser.py',623),
('non_null_type -> named_type BANG','non_null_type',2,'p_non_null_type','parser.py',629),
('non_null_type -> list_type BANG','non_null_type',2,'p_non_null_type','parser.py',630),
]
|
a = list(map(int, input().split()))
if sum(a) < 22:
print("win")
else:
print("bust")
|
# for holding settings for use later
class IndividualSetting:
settingkey = ""
settingvalue = ""
|
#!/usr/bin/env python3
class Evaluate:
def __init__(self):
self.formula = []
self.result = ''
self.error = False
def eval(self, expression):
if (self.percent(expression)):
return self.result
if (self.sum(expression)):
return self.result
if (self.substract(expression)):
return self.result
if (self.multiply(expression)):
return self.result
if (self.divide(expression)):
return self.result
if (self.error):
return "Error"
return None
def percent(self, expression):
position = expression.find('%')
if position != -1:
number1 = expression[0:position]
try:
result = float(number1) / 100
self.result = self.clear_result(result)
except:
self.error = True
return False
return True
return False
def sum(self, expression):
position = expression.find('+')
if position != -1:
if position == 0:
number1 = 0
else:
number1 = expression[0:position]
number2 = expression[position+1:len(expression)]
try:
result = float(number1) + float(number2)
self.result = self.clear_result(result)
except:
self.error = True
return False
return True
return False
def substract(self, expression):
position = expression.find('-')
if position != -1:
if position == 0:
number1 = 0
else:
number1 = expression[0:position]
number2 = expression[position+1:len(expression)]
try:
result = float(number1) - float(number2)
self.result = self.clear_result(result)
except:
self.error = True
return False
return True
return False
def multiply(self, expression):
position = expression.find('*')
if position != -1:
number1 = expression[0:position]
number2 = expression[position+1:len(expression)]
try:
result = float(number1) * float(number2)
self.result = self.clear_result(result)
except:
self.error = True
return False
return True
return False
def divide(self, expression):
position = expression.find('/')
if position != -1:
number1 = expression[0:position]
number2 = expression[position+1:len(expression)]
if number2 == '0':
self.error = True
return False
try:
result = float(number1) / float(number2)
self.result = self.clear_result(result)
except:
self.error = True
return False
return True
return False
def clear_result(self, result):
result = str(result)
if result[-2:] == '.0':
return result[:-2]
return result
|
#!/usr/bin/python3
#https://practice.geeksforgeeks.org/problems/bit-difference/0
def sol(a, b):
"""
Take an XOR, so 1 will be set whereever there is bit diff.
Keep doing AND with the number to check if the last bit is set
"""
c = a^b
count=0
while c:
if c&1:
count+=1
c=c>>1
return count
|
# https://leetcode.com/explore/learn/card/n-ary-tree/130/traversal/925/
# N-ary Tree Preorder Traversal
#
# Given an n-ary tree, return the preorder traversal of its nodes'
# values.
# Definition for a Node.
class Node(object):
def __init__(self, val, children):
self.val = val
self.children = children
# Note: for iterative, simply add all children to stack
#
# in reverse order so order matches leetcode check. Technically this
# is not required as the children can be processed in any order.
class Solution(object):
def preorder(self, root):
"""
:type root: Node
:rtype: List[int]
"""
return self.my_preorder(root)
# recursive, simple
def my_preorder(self, root):
def walk(x):
if x:
A.append(x.val)
for c in x.children:
walk(c)
A = []
walk(root)
return A
# 36 / 36 test cases passed.
# Status: Accepted
# Runtime: 217 ms
def my_preorder_iter(self, root):
# add node, then process children in reverse (reverse not
# technically required but needed so our answer matches
# leetcode check).
def walk(x):
s = [x] # initial stack
while s: # while stack is not empty
x = s.pop()
A.append(x.val) # visit(x)
for c in reversed(x.children): # add all children to stack
s.append(c)
A = []
if root:
walk(root)
return A
|
#定义一个输入输出的函数
def writefilecontent():
circel = True
responses = []
while circel:
print("请开始输入")
print("退出请输入Q或q")
f_name = input("请输入您的姓名:")
f_place = input("请输入您的出生地:")
responses.append(f_name + " " + f_place)
f_quit = input("是否还要继续:请输入是或否")
if f_quit == 'q' or f_quit == 'Q':
circel = False
return responses
filename = "writefile.txt"
with open(filename,"w") as file_object:
myMessage = writefilecontent()
messgeStr = ''
for name in myMessage:
messgeStr += name + '\n'
print(messgeStr)
file_object.write(messgeStr)
#open file函数的中的参数
"""
Character Meaning
--------- ---------------------------------------------------------------
'r' open for reading (default) 只读
'w' open for writing, truncating the file first
'x' create a new file and open it for writing
'a' open for writing, appending to the end of the file if it exists
'b' binary mode
't' text mode (default)
'+' open a disk file for updating (reading and writing)
'U' universal newline mode (deprecated)
========= ===============================================================
"""
"""try-except处理可能引发的异常"""
print("输入两个数字,求他们的商是多少")
print("输入q退出")
while True:
first_num = input("first number:")
if first_num == 'q':
break
second_num = input("second number:")
if second_num == 'q':
break
try:
answer = int(first_num)/int(second_num)
except ZeroDivisionError:
print("被除数不能为0")
else:
print(answer)
#实现每个方法的函数对象,添加显示的集合
|
def covert(df, drop, rename, inflow_source):
print(df)
result = df.copy()
outflow = []
inflow = []
for _, row in df.iterrows():
if row.get(inflow_source) >= 0:
inflow.append(row.get(inflow_source))
outflow.append(0)
else:
inflow.append(0)
outflow.append(abs(row.get(inflow_source)))
result['Outflow'] = outflow
result['Inflow'] = inflow
result.drop(columns=drop, inplace=True)
result.rename(columns=rename, inplace=True)
print(result)
return result
|
#-*-python-*-
def guild_python_workspace():
native.new_http_archive(
name = "org_pyyaml",
build_file = "//third-party:pyyaml.BUILD",
urls = [
"https://pypi.python.org/packages/4a/85/db5a2df477072b2902b0eb892feb37d88ac635d36245a72a6a69b23b383a/PyYAML-3.12.tar.gz",
],
strip_prefix = "PyYAML-3.12",
sha256 = "592766c6303207a20efc445587778322d7f73b161bd994f227adaa341ba212ab",
)
native.new_http_archive(
name = "org_psutil",
build_file = "//third-party:psutil.BUILD",
urls = [
"https://pypi.python.org/packages/57/93/47a2e3befaf194ccc3d05ffbcba2cdcdd22a231100ef7e4cf63f085c900b/psutil-5.2.2.tar.gz"
],
strip_prefix = "psutil-5.2.2",
sha256 = "44746540c0fab5b95401520d29eb9ffe84b3b4a235bd1d1971cbe36e1f38dd13",
)
native.new_http_archive(
name = "org_semantic_version",
build_file = "//third-party:semantic_version.BUILD",
urls = [
"https://pypi.python.org/packages/72/83/f76958017f3094b072d8e3a72d25c3ed65f754cc607fdb6a7b33d84ab1d5/semantic_version-2.6.0.tar.gz"
],
strip_prefix = "semantic_version-2.6.0",
sha256 = "2a4328680073e9b243667b201119772aefc5fc63ae32398d6afafff07c4f54c0",
)
native.new_http_archive(
name = "org_tqdm",
build_file = "//third-party:tqdm.BUILD",
urls = [
"https://pypi.python.org/packages/01/f7/2058bd94a903f445e8ff19c0af64b9456187acab41090ff2da21c7c7e193/tqdm-4.15.0.tar.gz"
],
strip_prefix = "tqdm-4.15.0",
sha256 = "6ec1dc74efacf2cda936b4a6cf4082ce224c76763bdec9f17e437c8cfcaa9953",
)
native.new_http_archive(
name = "org_click",
build_file = "//third-party:click.BUILD",
urls = [
"https://github.com/pallets/click/archive/752ff79d680fceb26d2a93f1eef376d90823ec47.zip",
],
strip_prefix = "click-752ff79d680fceb26d2a93f1eef376d90823ec47",
sha256 = "ecbdbd641b388b072b3b21d94622d7288df61a1e9643b978081d0ee173791c70",
)
|
#
# PySNMP MIB module ENGENIUS-CLIENT-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ENGENIUS-CLIENT-MIB
# Produced by pysmi-0.3.4 at Wed May 1 13:02:54 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, OctetString, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "Integer", "OctetString", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, ConstraintsIntersection, ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion")
ifIndex, = mibBuilder.importSymbols("IF-MIB", "ifIndex")
InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
TimeTicks, IpAddress, Unsigned32, MibScalar, MibTable, MibTableRow, MibTableColumn, Gauge32, iso, enterprises, Counter32, MibIdentifier, Integer32, ObjectIdentity, NotificationType, Counter64, Bits, ModuleIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "IpAddress", "Unsigned32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Gauge32", "iso", "enterprises", "Counter32", "MibIdentifier", "Integer32", "ObjectIdentity", "NotificationType", "Counter64", "Bits", "ModuleIdentity")
DisplayString, DateAndTime, TimeInterval, MacAddress, RowStatus, TextualConvention, TimeStamp, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "DateAndTime", "TimeInterval", "MacAddress", "RowStatus", "TextualConvention", "TimeStamp", "TruthValue")
engeniusmesh = ModuleIdentity((1, 3, 6, 1, 4, 1, 14125, 1))
engeniusmesh.setRevisions(('2007-05-02 10:00',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: engeniusmesh.setRevisionsDescriptions(('First Release for client purpose',))
if mibBuilder.loadTexts: engeniusmesh.setLastUpdated('200705021000Z')
if mibBuilder.loadTexts: engeniusmesh.setOrganization('Senao Networks, Inc')
if mibBuilder.loadTexts: engeniusmesh.setContactInfo('Senao Networks, Inc. No. 500, Fusing 3rd Rd, Hwa-Ya Technology Park Kuei-Shan Hsiang, Taoyuan County 333, Taiwan. Website: http://www.engeniustech.com/corporate/')
if mibBuilder.loadTexts: engeniusmesh.setDescription('MIB Definition used in the EnGenius Mesh Product Line: iso(1).org(3).dod(6).internet(1).private(4).enterprises(1). engenius(14125).engeniusmesh(1)')
engenius = MibIdentifier((1, 3, 6, 1, 4, 1, 14125))
nodeConfiguration = MibIdentifier((1, 3, 6, 1, 4, 1, 14125, 1, 2))
nodeConfigurationSignallevel = MibIdentifier((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30))
signallevelTable = MibTable((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 2), )
if mibBuilder.loadTexts: signallevelTable.setStatus('current')
if mibBuilder.loadTexts: signallevelTable.setDescription('This table contains the list of signal level between the node and its neighbour nodes.')
signallevelTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 2, 1), ).setIndexNames((0, "ENGENIUS-CLIENT-MIB", "signallevelTableIndex"))
if mibBuilder.loadTexts: signallevelTableEntry.setStatus('current')
if mibBuilder.loadTexts: signallevelTableEntry.setDescription('Represent the entry in the Signal Level table.')
signallevelTableIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 2, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 32)))
if mibBuilder.loadTexts: signallevelTableIndex.setStatus('current')
if mibBuilder.loadTexts: signallevelTableIndex.setDescription('Specify the index of the node Signal Level table.')
signallevelTableSource = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 2, 1, 2), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: signallevelTableSource.setStatus('current')
if mibBuilder.loadTexts: signallevelTableSource.setDescription("The source node's IP Address")
signallevelTableDestination = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 2, 1, 3), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: signallevelTableDestination.setStatus('current')
if mibBuilder.loadTexts: signallevelTableDestination.setDescription("The destination node's IP Address")
signallevelTableRssi = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 2, 1, 4), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: signallevelTableRssi.setStatus('current')
if mibBuilder.loadTexts: signallevelTableRssi.setDescription('The singal level between the source node and destination node in RSSI.')
signallevelExecute = MibScalar((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess("readonly")
if mibBuilder.loadTexts: signallevelExecute.setStatus('current')
if mibBuilder.loadTexts: signallevelExecute.setDescription('A command to execute the RSSI update')
clientInfoTable = MibTable((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3), )
if mibBuilder.loadTexts: clientInfoTable.setStatus('current')
if mibBuilder.loadTexts: clientInfoTable.setDescription('This table contains the list of clients info of the nodes.')
clientInfoTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1), ).setIndexNames((0, "ENGENIUS-CLIENT-MIB", "clientInfoTableIndex"))
if mibBuilder.loadTexts: clientInfoTableEntry.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableEntry.setDescription('Represent the entry in the Client Info table.')
clientInfoTableIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 64)))
if mibBuilder.loadTexts: clientInfoTableIndex.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableIndex.setDescription('Specify the index of the node Client Info table.')
clientInfoTableEssid = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 2), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: clientInfoTableEssid.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableEssid.setDescription('The ESSID of the AP')
clientInfoTableMac = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 3), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: clientInfoTableMac.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableMac.setDescription('The MAC Address of the client')
clientInfoTableChannel = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 4), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: clientInfoTableChannel.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableChannel.setDescription('The channel of the Client')
clientInfoTableRate = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 5), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: clientInfoTableRate.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableRate.setDescription('The speed rate of the client in kbps')
clientInfoTableRssi = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 6), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: clientInfoTableRssi.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableRssi.setDescription('The singal level between the client and node in RSSI.')
clientInfoTableIdletime = MibTableColumn((1, 3, 6, 1, 4, 1, 14125, 1, 2, 30, 3, 1, 7), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: clientInfoTableIdletime.setStatus('current')
if mibBuilder.loadTexts: clientInfoTableIdletime.setDescription('The idle timeout in second of the client.')
mibBuilder.exportSymbols("ENGENIUS-CLIENT-MIB", signallevelTableEntry=signallevelTableEntry, clientInfoTableMac=clientInfoTableMac, signallevelTableDestination=signallevelTableDestination, clientInfoTableEssid=clientInfoTableEssid, clientInfoTableEntry=clientInfoTableEntry, signallevelExecute=signallevelExecute, clientInfoTableRate=clientInfoTableRate, nodeConfigurationSignallevel=nodeConfigurationSignallevel, clientInfoTableIdletime=clientInfoTableIdletime, PYSNMP_MODULE_ID=engeniusmesh, nodeConfiguration=nodeConfiguration, clientInfoTableRssi=clientInfoTableRssi, signallevelTable=signallevelTable, clientInfoTableIndex=clientInfoTableIndex, signallevelTableRssi=signallevelTableRssi, engeniusmesh=engeniusmesh, clientInfoTableChannel=clientInfoTableChannel, signallevelTableIndex=signallevelTableIndex, signallevelTableSource=signallevelTableSource, clientInfoTable=clientInfoTable, engenius=engenius)
|
# Habibu-R-ahman
# 7th Jan, 2021
a = float(input())
salary = money = percentage = None
if a <= 400:
salary = a * 1.15
percentage = 15
elif a <= 800:
salary = a * 1.12
percentage = 12
elif a <= 1200:
salary = a * 1.10
percentage = 10
elif a <= 2000:
salary = a * 1.07
percentage = 7
else:
salary = a * 1.04
percentage = 4
print(f"Novo salario: {salary:.2f}")
print(f"Reajuste ganho: {salary - a:.2f}")
print(f"Em percentual: {percentage} %")
|
# -*- coding: utf-8 -*-
"""Top-level package for Generador Ficheros Agencia Tributaria."""
__author__ = """Pau Rosello Van Schoor"""
__email__ = '[email protected]'
__version__ = '0.1.1'
|
def arbitage(plen):
lst1=list(permutations(lst,plen))
for j in [[0]+list(i)+[0] for i in lst1]:
val=1
length=len(j)
print([x+1 for x in j])
index=0
for k in j:
if index+1>=length:
break
print("index:{}, index+1:{},val:{}".format(j[index],j[index+1],vals[j[index]][j[index+1]]))
val=vals[j[index]][j[index+1]]*val
index+=1
print(val,(val-1)*100)
arbitage(1)
if __name__=="__main__":
dim=int(input())
lst=list(range(0,dim))
vals=[]
counter=0
for line in sys.stdin:
temp = list(map(float, line.split()))
temp.insert(counter,1)
counter+=1
vals.append(temp)
print(vals)
|
class Http:
def __init__(self, session):
self.session = session
async def download(self, url: str):
async with self.session.get(url, timeout=10) as res:
if res.status == 200:
return await res.read()
else:
return None
async def get_headers(self, url: str):
async with self.session.head(url, timeout=10) as res:
if res.status == 200:
return res.headers
|
"""
LeetCode Problem: 78. Subsets
Link: https://leetcode.com/problems/subsets/
Language: Python
Written by: Mostofa Adib Shakib
Time Complexity: O(n*2^n)
Space Complexity: O(n*2^n)
"""
# Solution 1
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def recursiveHelper(index, current):
# Creates a shallow copy of the current array and appends to the result array
result.append(current.copy())
for j in range(index, len(nums)):
current.append(nums[j]) # push the value at the current index to the current array
recursiveHelper(j+1, current) # Recursively call the next index
current.pop() # Backtrack
result = [] # Keeps track of the result
recursiveHelper(0, []) # Calls the recursive function
return result # Returns the answer
# Solution 2
class Solution:
def subsets(self, nums: List[int]) -> List[List[int]]:
def recursiveHelper(index, current):
# Base case
if index == len(nums):
result.append(current) # Append current to the result array
else:
recursiveHelper(index+1, current) # If the element is not selected
recursiveHelper(index+1, current + [nums[index]]) # if the element is selected
result = [] # Keeps track of the result
recursiveHelper(0, []) # Calls the recursive function
return result # Returns the answer
|
# Pretty lame athlete model
LT = 160
REST_HR = 50
MAX_HR = 175
|
class Solution(object):
def findNthDigit(self, n):
"""
:type n: int
:rtype: int
"""
index = 1
result = 0
digit_num = 9 * 10 ** (index - 1)
while n > digit_num * index:
n -= digit_num * index
result += digit_num
index += 1
digit_num = 9 * 10 ** (index - 1)
offset = n / index
remainder = n - index * offset
return int(str(result + offset + (remainder > 0))[remainder-1])
|
# Inputs
# ------
#
# Let’s define some inputs for the run:
#
# - **dataroot** - the path to the root of the dataset folder. We will
# talk more about the dataset in the next section
# - **workers** - the number of worker threads for loading the data with
# the DataLoader
# - **batch_size** - the batch size used in training. The DCGAN paper
# uses a batch size of 128
# - **image_size** - the spatial size of the images used for training.
# This implementation defaults to 64x64. If another size is desired,
# the structures of D and G must be changed. See
# `here <https://github.com/pytorch/examples/issues/70>`__ for more
# details
# - **nc** - number of color channels in the input images. For color
# images this is 3
# - **nz** - length of latent vector
# - **ngf** - relates to the depth of feature maps carried through the
# generator
# - **ndf** - sets the depth of feature maps propagated through the
# discriminator
# - **num_epochs** - number of training epochs to run. Training for
# longer will probably lead to better results but will also take much
# longer
# - **lr** - learning rate for training. As described in the DCGAN paper,
# this number should be 0.0002
# - **beta1** - beta1 hyperparameter for Adam optimizers. As described in
# paper, this number should be 0.5
# - **ngpu** - number of GPUs available. If this is 0, code will run in
# CPU mode. If this number is greater than 0 it will run on that number
# of GPUs
#
#
#
# Root directory for dataset
dataroot = "./celeba"
# Number of workers for dataloader
workers = 2
# Batch size during training
batch_size = 128
# Spatial size of training images. All images will be resized to this
# size using a transformer.
image_size = 64
# Number of channels in the training images. For color images this is 3
nc = 3
# Size of z latent vector (i.e. size of generator input)
nz = 100
# Size of feature maps in generator
ngf = 64
# Size of feature maps in discriminator
ndf = 64
# Number of training epochs
num_epochs = 5
# Learning rate for optimizers
lr = 0.0002
# Beta1 hyperparam for Adam optimizers
beta1 = 0.5
# Number of GPUs available. Use 0 for CPU mode.
ngpu = 1
|
class User:
def __init__(self, id, first_name, last_name, email, account_creation_date):
self.id = id
self.first_name = first_name
self.last_name = last_name
self.email = email
self.account_creation_date = account_creation_date
|
# Copyright (C) 2007 Samuel Abels
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
class WorkflowInfo(object):
"""
This class represents a workflow definition.
"""
def __init__(self, handle, **kwargs):
"""
Constructor.
"""
assert not (kwargs.has_key('xml') and kwargs.has_key('file'))
self.id = None
self.handle = handle
self.name = handle
self.xml = kwargs.get('xml', None)
if kwargs.has_key('file'):
file = open(kwargs.get('file'), 'r')
self.xml = file.read()
file.close()
|
frase = 'Curso em video Python'
print(frase[5::2])
print('''jfafj aj fjaljsfkjasj fkasjfkaj sfjsajfljslkjjf
a fsjdfjs flasjfkldjfdjsfjasjfjaskjfsjfk sdkf
sjfsd fskjfs asfjlkds fjsf sdjflksjfslfs
s fslfjklsdjfsjfjlsjfklsjkfksldfk dsjfsdf''')
|
BRANCHES = {
'AdditiveExpression' : {
"!" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"(" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"+" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"-" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"BOUND" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"DATATYPE" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"LANG" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"LANGMATCHES" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"REGEX" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"STR" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'BooleanLiteral' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'DECIMAL' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'DOUBLE' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'INTEGER' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'IRI_REF' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'PNAME_LN' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'PNAME_NS' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'STRING_LITERAL1' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'STRING_LITERAL2' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'STRING_LITERAL_LONG1' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'STRING_LITERAL_LONG2' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'VAR1' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
'VAR2' : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"ISBLANK" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"ISIRI" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"ISLITERAL" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"ISURI" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"SAMETERM" : ['MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
},
'ArgList' : {
"(" : ["(",
'_Expression_COMMA_Expression_Star',
")"],
'NIL' : ['NIL'],
},
'AskQuery' : {
"ASK" : ["ASK",
'_DatasetClause_Star',
'WhereClause'],
},
'BaseDecl' : {
"BASE" : ["BASE",
'IRI_REF'],
},
'BlankNode' : {
'ANON' : ['ANON'],
'BLANK_NODE_LABEL' : ['BLANK_NODE_LABEL'],
},
'BlankNodePropertyList' : {
"[" : ["[",
'PropertyListNotEmpty',
"]"],
},
'BrackettedExpression' : {
"(" : ["(",
'Expression',
")"],
},
'BuiltInCall' : {
"BOUND" : ["BOUND",
"(",
'Var',
")"],
"DATATYPE" : ["DATATYPE",
"(",
'Expression',
")"],
"LANG" : ["LANG",
"(",
'Expression',
")"],
"LANGMATCHES" : ["LANGMATCHES",
"(",
'Expression',
",",
'Expression',
")"],
"REGEX" : ['RegexExpression'],
"STR" : ["STR",
"(",
'Expression',
")"],
"ISBLANK" : ["ISBLANK",
"(",
'Expression',
")"],
"ISIRI" : ["ISIRI",
"(",
'Expression',
")"],
"ISLITERAL" : ["ISLITERAL",
"(",
'Expression',
")"],
"ISURI" : ["ISURI",
"(",
'Expression',
")"],
"SAMETERM" : ["SAMETERM",
"(",
'Expression',
",",
'Expression',
")"],
},
'Collection' : {
"(" : ["(",
'_GraphNode_Plus',
")"],
},
'ConditionalAndExpression' : {
"!" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"(" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"+" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"-" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"BOUND" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"DATATYPE" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"LANG" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"LANGMATCHES" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"REGEX" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"STR" : ['ValueLogical',
'_AND_ValueLogical_Star'],
'BooleanLiteral' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'DECIMAL' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'DOUBLE' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'INTEGER' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'IRI_REF' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'PNAME_LN' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'PNAME_NS' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'STRING_LITERAL1' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'STRING_LITERAL2' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'STRING_LITERAL_LONG1' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'STRING_LITERAL_LONG2' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'VAR1' : ['ValueLogical',
'_AND_ValueLogical_Star'],
'VAR2' : ['ValueLogical',
'_AND_ValueLogical_Star'],
"ISBLANK" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"ISIRI" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"ISLITERAL" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"ISURI" : ['ValueLogical',
'_AND_ValueLogical_Star'],
"SAMETERM" : ['ValueLogical',
'_AND_ValueLogical_Star'],
},
'ConditionalOrExpression' : {
"!" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"(" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"+" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"-" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"BOUND" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"DATATYPE" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"LANG" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"LANGMATCHES" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"REGEX" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"STR" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'BooleanLiteral' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'DECIMAL' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'DOUBLE' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'INTEGER' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'IRI_REF' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'PNAME_LN' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'PNAME_NS' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'STRING_LITERAL1' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'STRING_LITERAL2' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'STRING_LITERAL_LONG1' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'STRING_LITERAL_LONG2' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'VAR1' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
'VAR2' : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"ISBLANK" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"ISIRI" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"ISLITERAL" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"ISURI" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
"SAMETERM" : ['ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
},
'Constraint' : {
"(" : ['BrackettedExpression'],
"BOUND" : ['BuiltInCall'],
"DATATYPE" : ['BuiltInCall'],
"LANG" : ['BuiltInCall'],
"LANGMATCHES" : ['BuiltInCall'],
"REGEX" : ['BuiltInCall'],
"STR" : ['BuiltInCall'],
'IRI_REF' : ['FunctionCall'],
'PNAME_LN' : ['FunctionCall'],
'PNAME_NS' : ['FunctionCall'],
"ISBLANK" : ['BuiltInCall'],
"ISIRI" : ['BuiltInCall'],
"ISLITERAL" : ['BuiltInCall'],
"ISURI" : ['BuiltInCall'],
"SAMETERM" : ['BuiltInCall'],
},
'ConstructQuery' : {
"CONSTRUCT" : ["CONSTRUCT",
'ConstructTemplate',
'_DatasetClause_Star',
'WhereClause',
'SolutionModifier'],
},
'ConstructTemplate' : {
"{" : ["{",
'_ConstructTriples_Opt',
"}"],
},
'ConstructTriples' : {
"(" : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
"+" : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
"-" : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
"[" : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'ANON' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'BLANK_NODE_LABEL' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'BooleanLiteral' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'DECIMAL' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'DOUBLE' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'INTEGER' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'IRI_REF' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'NIL' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'PNAME_LN' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'PNAME_NS' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'STRING_LITERAL1' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'STRING_LITERAL2' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'STRING_LITERAL_LONG1' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'STRING_LITERAL_LONG2' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'VAR1' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
'VAR2' : ['TriplesSameSubject',
'_DOT_ConstructTriples_Opt_Opt'],
},
'DatasetClause' : {
"FROM" : ["FROM",
'_DefaultGraphClause_or_NamedGraphClause'],
},
'DefaultGraphClause' : {
'IRI_REF' : ['SourceSelector'],
'PNAME_LN' : ['SourceSelector'],
'PNAME_NS' : ['SourceSelector'],
},
'DescribeQuery' : {
"DESCRIBE" : ["DESCRIBE",
'_VarOrIRIref_Plus_or_Star',
'_DatasetClause_Star',
'_WhereClause_Opt',
'SolutionModifier'],
},
'Expression' : {
"!" : ['ConditionalOrExpression'],
"(" : ['ConditionalOrExpression'],
"+" : ['ConditionalOrExpression'],
"-" : ['ConditionalOrExpression'],
"BOUND" : ['ConditionalOrExpression'],
"DATATYPE" : ['ConditionalOrExpression'],
"LANG" : ['ConditionalOrExpression'],
"LANGMATCHES" : ['ConditionalOrExpression'],
"REGEX" : ['ConditionalOrExpression'],
"STR" : ['ConditionalOrExpression'],
'BooleanLiteral' : ['ConditionalOrExpression'],
'DECIMAL' : ['ConditionalOrExpression'],
'DOUBLE' : ['ConditionalOrExpression'],
'INTEGER' : ['ConditionalOrExpression'],
'IRI_REF' : ['ConditionalOrExpression'],
'PNAME_LN' : ['ConditionalOrExpression'],
'PNAME_NS' : ['ConditionalOrExpression'],
'STRING_LITERAL1' : ['ConditionalOrExpression'],
'STRING_LITERAL2' : ['ConditionalOrExpression'],
'STRING_LITERAL_LONG1' : ['ConditionalOrExpression'],
'STRING_LITERAL_LONG2' : ['ConditionalOrExpression'],
'VAR1' : ['ConditionalOrExpression'],
'VAR2' : ['ConditionalOrExpression'],
"ISBLANK" : ['ConditionalOrExpression'],
"ISIRI" : ['ConditionalOrExpression'],
"ISLITERAL" : ['ConditionalOrExpression'],
"ISURI" : ['ConditionalOrExpression'],
"SAMETERM" : ['ConditionalOrExpression'],
},
'Filter' : {
"FILTER" : ["FILTER",
'Constraint'],
},
'FunctionCall' : {
'IRI_REF' : ['IRIref',
'ArgList'],
'PNAME_LN' : ['IRIref',
'ArgList'],
'PNAME_NS' : ['IRIref',
'ArgList'],
},
'GraphGraphPattern' : {
"GRAPH" : ["GRAPH",
'VarOrIRIref',
'GroupGraphPattern'],
},
'GraphNode' : {
"(" : ['TriplesNode'],
"+" : ['VarOrTerm'],
"-" : ['VarOrTerm'],
"[" : ['TriplesNode'],
'ANON' : ['VarOrTerm'],
'BLANK_NODE_LABEL' : ['VarOrTerm'],
'BooleanLiteral' : ['VarOrTerm'],
'DECIMAL' : ['VarOrTerm'],
'DOUBLE' : ['VarOrTerm'],
'INTEGER' : ['VarOrTerm'],
'IRI_REF' : ['VarOrTerm'],
'NIL' : ['VarOrTerm'],
'PNAME_LN' : ['VarOrTerm'],
'PNAME_NS' : ['VarOrTerm'],
'STRING_LITERAL1' : ['VarOrTerm'],
'STRING_LITERAL2' : ['VarOrTerm'],
'STRING_LITERAL_LONG1' : ['VarOrTerm'],
'STRING_LITERAL_LONG2' : ['VarOrTerm'],
'VAR1' : ['VarOrTerm'],
'VAR2' : ['VarOrTerm'],
},
'GraphPatternNotTriples' : {
"GRAPH" : ['GraphGraphPattern'],
"OPTIONAL" : ['OptionalGraphPattern'],
"{" : ['GroupOrUnionGraphPattern'],
},
'GraphTerm' : {
"+" : ['NumericLiteral'],
"-" : ['NumericLiteral'],
'ANON' : ['BlankNode'],
'BLANK_NODE_LABEL' : ['BlankNode'],
'BooleanLiteral' : ['BooleanLiteral'],
'DECIMAL' : ['NumericLiteral'],
'DOUBLE' : ['NumericLiteral'],
'INTEGER' : ['NumericLiteral'],
'IRI_REF' : ['IRIref'],
'NIL' : ['NIL'],
'PNAME_LN' : ['IRIref'],
'PNAME_NS' : ['IRIref'],
'STRING_LITERAL1' : ['RDFLiteral'],
'STRING_LITERAL2' : ['RDFLiteral'],
'STRING_LITERAL_LONG1' : ['RDFLiteral'],
'STRING_LITERAL_LONG2' : ['RDFLiteral'],
},
'GroupGraphPattern' : {
"{" : ["{",
'_TriplesBlock_Opt',
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star',
"}"],
},
'GroupOrUnionGraphPattern' : {
"{" : ['GroupGraphPattern',
'_UNION_GroupGraphPattern_Star'],
},
'IRIref' : {
'IRI_REF' : ['IRI_REF'],
'PNAME_LN' : ['PrefixedName'],
'PNAME_NS' : ['PrefixedName'],
},
'IRIrefOrFunction' : {
'IRI_REF' : ['IRIref',
'_ArgList_Opt'],
'PNAME_LN' : ['IRIref',
'_ArgList_Opt'],
'PNAME_NS' : ['IRIref',
'_ArgList_Opt'],
},
'LimitClause' : {
"LIMIT" : ["LIMIT",
'INTEGER'],
},
'LimitOffsetClauses' : {
"LIMIT" : ['LimitClause',
'_OffsetClause_Opt'],
"OFFSET" : ['OffsetClause',
'_LimitClause_Opt'],
},
'MultiplicativeExpression' : {
"!" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"(" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"+" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"-" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"BOUND" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"DATATYPE" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"LANG" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"LANGMATCHES" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"REGEX" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"STR" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'BooleanLiteral' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'DECIMAL' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'DOUBLE' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'INTEGER' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'IRI_REF' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'PNAME_LN' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'PNAME_NS' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'STRING_LITERAL1' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'STRING_LITERAL2' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'STRING_LITERAL_LONG1' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'STRING_LITERAL_LONG2' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'VAR1' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
'VAR2' : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"ISBLANK" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"ISIRI" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"ISLITERAL" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"ISURI" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"SAMETERM" : ['UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
},
'NamedGraphClause' : {
"NAMED" : ["NAMED",
'SourceSelector'],
},
'NumericExpression' : {
"!" : ['AdditiveExpression'],
"(" : ['AdditiveExpression'],
"+" : ['AdditiveExpression'],
"-" : ['AdditiveExpression'],
"BOUND" : ['AdditiveExpression'],
"DATATYPE" : ['AdditiveExpression'],
"LANG" : ['AdditiveExpression'],
"LANGMATCHES" : ['AdditiveExpression'],
"REGEX" : ['AdditiveExpression'],
"STR" : ['AdditiveExpression'],
'BooleanLiteral' : ['AdditiveExpression'],
'DECIMAL' : ['AdditiveExpression'],
'DOUBLE' : ['AdditiveExpression'],
'INTEGER' : ['AdditiveExpression'],
'IRI_REF' : ['AdditiveExpression'],
'PNAME_LN' : ['AdditiveExpression'],
'PNAME_NS' : ['AdditiveExpression'],
'STRING_LITERAL1' : ['AdditiveExpression'],
'STRING_LITERAL2' : ['AdditiveExpression'],
'STRING_LITERAL_LONG1' : ['AdditiveExpression'],
'STRING_LITERAL_LONG2' : ['AdditiveExpression'],
'VAR1' : ['AdditiveExpression'],
'VAR2' : ['AdditiveExpression'],
"ISBLANK" : ['AdditiveExpression'],
"ISIRI" : ['AdditiveExpression'],
"ISLITERAL" : ['AdditiveExpression'],
"ISURI" : ['AdditiveExpression'],
"SAMETERM" : ['AdditiveExpression'],
},
'NumericLiteral' : {
"+" : ['NumericLiteralPositive'],
"-" : ['NumericLiteralNegative'],
'DECIMAL' : ['NumericLiteralUnsigned'],
'DOUBLE' : ['NumericLiteralUnsigned'],
'INTEGER' : ['NumericLiteralUnsigned'],
},
'NumericLiteralNegative' : {
"-" : ["-",
'NumericLiteralUnsigned'],
},
'NumericLiteralPositive' : {
"+" : ["+",
'NumericLiteralUnsigned'],
},
'NumericLiteralUnsigned' : {
'DECIMAL' : ['DECIMAL'],
'DOUBLE' : ['DOUBLE'],
'INTEGER' : ['INTEGER'],
},
'Object' : {
"(" : ['GraphNode'],
"+" : ['GraphNode'],
"-" : ['GraphNode'],
"[" : ['GraphNode'],
'ANON' : ['GraphNode'],
'BLANK_NODE_LABEL' : ['GraphNode'],
'BooleanLiteral' : ['GraphNode'],
'DECIMAL' : ['GraphNode'],
'DOUBLE' : ['GraphNode'],
'INTEGER' : ['GraphNode'],
'IRI_REF' : ['GraphNode'],
'NIL' : ['GraphNode'],
'PNAME_LN' : ['GraphNode'],
'PNAME_NS' : ['GraphNode'],
'STRING_LITERAL1' : ['GraphNode'],
'STRING_LITERAL2' : ['GraphNode'],
'STRING_LITERAL_LONG1' : ['GraphNode'],
'STRING_LITERAL_LONG2' : ['GraphNode'],
'VAR1' : ['GraphNode'],
'VAR2' : ['GraphNode'],
},
'ObjectList' : {
"(" : ['Object',
'_COMMA_Object_Star'],
"+" : ['Object',
'_COMMA_Object_Star'],
"-" : ['Object',
'_COMMA_Object_Star'],
"[" : ['Object',
'_COMMA_Object_Star'],
'ANON' : ['Object',
'_COMMA_Object_Star'],
'BLANK_NODE_LABEL' : ['Object',
'_COMMA_Object_Star'],
'BooleanLiteral' : ['Object',
'_COMMA_Object_Star'],
'DECIMAL' : ['Object',
'_COMMA_Object_Star'],
'DOUBLE' : ['Object',
'_COMMA_Object_Star'],
'INTEGER' : ['Object',
'_COMMA_Object_Star'],
'IRI_REF' : ['Object',
'_COMMA_Object_Star'],
'NIL' : ['Object',
'_COMMA_Object_Star'],
'PNAME_LN' : ['Object',
'_COMMA_Object_Star'],
'PNAME_NS' : ['Object',
'_COMMA_Object_Star'],
'STRING_LITERAL1' : ['Object',
'_COMMA_Object_Star'],
'STRING_LITERAL2' : ['Object',
'_COMMA_Object_Star'],
'STRING_LITERAL_LONG1' : ['Object',
'_COMMA_Object_Star'],
'STRING_LITERAL_LONG2' : ['Object',
'_COMMA_Object_Star'],
'VAR1' : ['Object',
'_COMMA_Object_Star'],
'VAR2' : ['Object',
'_COMMA_Object_Star'],
},
'OffsetClause' : {
"OFFSET" : ["OFFSET",
'INTEGER'],
},
'OptionalGraphPattern' : {
"OPTIONAL" : ["OPTIONAL",
'GroupGraphPattern'],
},
'OrderClause' : {
"ORDER" : ["ORDER",
"BY",
'OrderCondition',
'_OrderCondition_Plus'],
},
'OrderCondition' : {
"(" : ['_Constraint_or_Var'],
"ASC" : ['_ASC_Or_DESC_BrackettedExpression'],
"BOUND" : ['_Constraint_or_Var'],
"DATATYPE" : ['_Constraint_or_Var'],
"DESC" : ['_ASC_Or_DESC_BrackettedExpression'],
"LANG" : ['_Constraint_or_Var'],
"LANGMATCHES" : ['_Constraint_or_Var'],
"REGEX" : ['_Constraint_or_Var'],
"STR" : ['_Constraint_or_Var'],
'IRI_REF' : ['_Constraint_or_Var'],
'PNAME_LN' : ['_Constraint_or_Var'],
'PNAME_NS' : ['_Constraint_or_Var'],
'VAR1' : ['_Constraint_or_Var'],
'VAR2' : ['_Constraint_or_Var'],
"ISBLANK" : ['_Constraint_or_Var'],
"ISIRI" : ['_Constraint_or_Var'],
"ISLITERAL" : ['_Constraint_or_Var'],
"ISURI" : ['_Constraint_or_Var'],
"SAMETERM" : ['_Constraint_or_Var'],
},
'PrefixDecl' : {
"PREFIX" : ["PREFIX",
'PNAME_NS',
'IRI_REF'],
},
'PrefixedName' : {
'PNAME_LN' : ['PNAME_LN'],
'PNAME_NS' : ['PNAME_NS'],
},
'PrimaryExpression' : {
"(" : ['BrackettedExpression'],
"+" : ['NumericLiteral'],
"-" : ['NumericLiteral'],
"BOUND" : ['BuiltInCall'],
"DATATYPE" : ['BuiltInCall'],
"LANG" : ['BuiltInCall'],
"LANGMATCHES" : ['BuiltInCall'],
"REGEX" : ['BuiltInCall'],
"STR" : ['BuiltInCall'],
'BooleanLiteral' : ['BooleanLiteral'],
'DECIMAL' : ['NumericLiteral'],
'DOUBLE' : ['NumericLiteral'],
'INTEGER' : ['NumericLiteral'],
'IRI_REF' : ['IRIrefOrFunction'],
'PNAME_LN' : ['IRIrefOrFunction'],
'PNAME_NS' : ['IRIrefOrFunction'],
'STRING_LITERAL1' : ['RDFLiteral'],
'STRING_LITERAL2' : ['RDFLiteral'],
'STRING_LITERAL_LONG1' : ['RDFLiteral'],
'STRING_LITERAL_LONG2' : ['RDFLiteral'],
'VAR1' : ['Var'],
'VAR2' : ['Var'],
"ISBLANK" : ['BuiltInCall'],
"ISIRI" : ['BuiltInCall'],
"ISLITERAL" : ['BuiltInCall'],
"ISURI" : ['BuiltInCall'],
"SAMETERM" : ['BuiltInCall'],
},
'Prologue' : {
"ASK" : ['_BaseDecl_Opt',
'_PrefixDecl_Star'],
"BASE" : ['_BaseDecl_Opt',
'_PrefixDecl_Star'],
"CONSTRUCT" : ['_BaseDecl_Opt',
'_PrefixDecl_Star'],
"DESCRIBE" : ['_BaseDecl_Opt',
'_PrefixDecl_Star'],
"PREFIX" : ['_BaseDecl_Opt',
'_PrefixDecl_Star'],
"SELECT" : ['_BaseDecl_Opt',
'_PrefixDecl_Star'],
},
'PropertyList' : {
"." : [],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"a" : ['PropertyListNotEmpty'],
'IRI_REF' : ['PropertyListNotEmpty'],
'PNAME_LN' : ['PropertyListNotEmpty'],
'PNAME_NS' : ['PropertyListNotEmpty'],
'VAR1' : ['PropertyListNotEmpty'],
'VAR2' : ['PropertyListNotEmpty'],
"{" : [],
"}" : [],
},
'PropertyListNotEmpty' : {
"a" : ['Verb',
'ObjectList',
'_SEMI_Verb_ObjectList_Opt_Star'],
'IRI_REF' : ['Verb',
'ObjectList',
'_SEMI_Verb_ObjectList_Opt_Star'],
'PNAME_LN' : ['Verb',
'ObjectList',
'_SEMI_Verb_ObjectList_Opt_Star'],
'PNAME_NS' : ['Verb',
'ObjectList',
'_SEMI_Verb_ObjectList_Opt_Star'],
'VAR1' : ['Verb',
'ObjectList',
'_SEMI_Verb_ObjectList_Opt_Star'],
'VAR2' : ['Verb',
'ObjectList',
'_SEMI_Verb_ObjectList_Opt_Star'],
},
'Query' : {
"ASK" : ['Prologue',
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
'eof'],
"BASE" : ['Prologue',
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
'eof'],
"CONSTRUCT" : ['Prologue',
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
'eof'],
"DESCRIBE" : ['Prologue',
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
'eof'],
"PREFIX" : ['Prologue',
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
'eof'],
"SELECT" : ['Prologue',
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery',
'eof'],
},
'RDFLiteral' : {
'STRING_LITERAL1' : ['String',
'_LANGTAG_IRIref_Opt'],
'STRING_LITERAL2' : ['String',
'_LANGTAG_IRIref_Opt'],
'STRING_LITERAL_LONG1' : ['String',
'_LANGTAG_IRIref_Opt'],
'STRING_LITERAL_LONG2' : ['String',
'_LANGTAG_IRIref_Opt'],
},
'RegexExpression' : {
"REGEX" : ["REGEX",
"(",
'Expression',
",",
'Expression',
'_COMMA_Expression_Opt',
")"],
},
'RelationalExpression' : {
"!" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"(" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"+" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"-" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"BOUND" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"DATATYPE" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"LANG" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"LANGMATCHES" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"REGEX" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"STR" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'BooleanLiteral' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'DECIMAL' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'DOUBLE' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'INTEGER' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'IRI_REF' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'PNAME_LN' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'PNAME_NS' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'STRING_LITERAL1' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'STRING_LITERAL2' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'STRING_LITERAL_LONG1' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'STRING_LITERAL_LONG2' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'VAR1' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
'VAR2' : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"ISBLANK" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"ISIRI" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"ISLITERAL" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"ISURI" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
"SAMETERM" : ['NumericExpression',
'_Compare_NumericExpression_Opt'],
},
'SelectQuery' : {
"SELECT" : ["SELECT",
'_DISTINCT_OR_REDUCED_Opt',
'_Var_Plus_or_Star',
'_DatasetClause_Star',
'WhereClause',
'SolutionModifier'],
},
'SolutionModifier' : {
"LIMIT" : ['_OrderClause_Opt',
'_LimitOffsetClauses_Opt'],
"OFFSET" : ['_OrderClause_Opt',
'_LimitOffsetClauses_Opt'],
"ORDER" : ['_OrderClause_Opt',
'_LimitOffsetClauses_Opt'],
'eof' : ['_OrderClause_Opt',
'_LimitOffsetClauses_Opt'],
},
'SourceSelector' : {
'IRI_REF' : ['IRIref'],
'PNAME_LN' : ['IRIref'],
'PNAME_NS' : ['IRIref'],
},
'String' : {
'STRING_LITERAL1' : ['STRING_LITERAL1'],
'STRING_LITERAL2' : ['STRING_LITERAL2'],
'STRING_LITERAL_LONG1' : ['STRING_LITERAL_LONG1'],
'STRING_LITERAL_LONG2' : ['STRING_LITERAL_LONG2'],
},
'TriplesBlock' : {
"(" : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
"+" : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
"-" : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
"[" : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'ANON' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'BLANK_NODE_LABEL' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'BooleanLiteral' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'DECIMAL' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'DOUBLE' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'INTEGER' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'IRI_REF' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'NIL' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'PNAME_LN' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'PNAME_NS' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'STRING_LITERAL1' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'STRING_LITERAL2' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'STRING_LITERAL_LONG1' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'STRING_LITERAL_LONG2' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'VAR1' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
'VAR2' : ['TriplesSameSubject',
'_Dot_TriplesBlock_Opt_Opt'],
},
'TriplesNode' : {
"(" : ['Collection'],
"[" : ['BlankNodePropertyList'],
},
'TriplesSameSubject' : {
"(" : ['TriplesNode',
'PropertyList'],
"+" : ['VarOrTerm',
'PropertyListNotEmpty'],
"-" : ['VarOrTerm',
'PropertyListNotEmpty'],
"[" : ['TriplesNode',
'PropertyList'],
'ANON' : ['VarOrTerm',
'PropertyListNotEmpty'],
'BLANK_NODE_LABEL' : ['VarOrTerm',
'PropertyListNotEmpty'],
'BooleanLiteral' : ['VarOrTerm',
'PropertyListNotEmpty'],
'DECIMAL' : ['VarOrTerm',
'PropertyListNotEmpty'],
'DOUBLE' : ['VarOrTerm',
'PropertyListNotEmpty'],
'INTEGER' : ['VarOrTerm',
'PropertyListNotEmpty'],
'IRI_REF' : ['VarOrTerm',
'PropertyListNotEmpty'],
'NIL' : ['VarOrTerm',
'PropertyListNotEmpty'],
'PNAME_LN' : ['VarOrTerm',
'PropertyListNotEmpty'],
'PNAME_NS' : ['VarOrTerm',
'PropertyListNotEmpty'],
'STRING_LITERAL1' : ['VarOrTerm',
'PropertyListNotEmpty'],
'STRING_LITERAL2' : ['VarOrTerm',
'PropertyListNotEmpty'],
'STRING_LITERAL_LONG1' : ['VarOrTerm',
'PropertyListNotEmpty'],
'STRING_LITERAL_LONG2' : ['VarOrTerm',
'PropertyListNotEmpty'],
'VAR1' : ['VarOrTerm',
'PropertyListNotEmpty'],
'VAR2' : ['VarOrTerm',
'PropertyListNotEmpty'],
},
'UnaryExpression' : {
"!" : ["!",
'PrimaryExpression'],
"(" : ['PrimaryExpression'],
"+" : ["+", 'PrimaryExpression'], # GK: Added back due to conflict
"-" : ["-", 'PrimaryExpression'], # GK: Added back due to conflict
"BOUND" : ['PrimaryExpression'],
"DATATYPE" : ['PrimaryExpression'],
"LANG" : ['PrimaryExpression'],
"LANGMATCHES" : ['PrimaryExpression'],
"REGEX" : ['PrimaryExpression'],
"STR" : ['PrimaryExpression'],
'BooleanLiteral' : ['PrimaryExpression'],
'DECIMAL' : ['PrimaryExpression'],
'DOUBLE' : ['PrimaryExpression'],
'INTEGER' : ['PrimaryExpression'],
'IRI_REF' : ['PrimaryExpression'],
'PNAME_LN' : ['PrimaryExpression'],
'PNAME_NS' : ['PrimaryExpression'],
'STRING_LITERAL1' : ['PrimaryExpression'],
'STRING_LITERAL2' : ['PrimaryExpression'],
'STRING_LITERAL_LONG1' : ['PrimaryExpression'],
'STRING_LITERAL_LONG2' : ['PrimaryExpression'],
'VAR1' : ['PrimaryExpression'],
'VAR2' : ['PrimaryExpression'],
"ISBLANK" : ['PrimaryExpression'],
"ISIRI" : ['PrimaryExpression'],
"ISLITERAL" : ['PrimaryExpression'],
"ISURI" : ['PrimaryExpression'],
"SAMETERM" : ['PrimaryExpression'],
},
'ValueLogical' : {
"!" : ['RelationalExpression'],
"(" : ['RelationalExpression'],
"+" : ['RelationalExpression'],
"-" : ['RelationalExpression'],
"BOUND" : ['RelationalExpression'],
"DATATYPE" : ['RelationalExpression'],
"LANG" : ['RelationalExpression'],
"LANGMATCHES" : ['RelationalExpression'],
"REGEX" : ['RelationalExpression'],
"STR" : ['RelationalExpression'],
'BooleanLiteral' : ['RelationalExpression'],
'DECIMAL' : ['RelationalExpression'],
'DOUBLE' : ['RelationalExpression'],
'INTEGER' : ['RelationalExpression'],
'IRI_REF' : ['RelationalExpression'],
'PNAME_LN' : ['RelationalExpression'],
'PNAME_NS' : ['RelationalExpression'],
'STRING_LITERAL1' : ['RelationalExpression'],
'STRING_LITERAL2' : ['RelationalExpression'],
'STRING_LITERAL_LONG1' : ['RelationalExpression'],
'STRING_LITERAL_LONG2' : ['RelationalExpression'],
'VAR1' : ['RelationalExpression'],
'VAR2' : ['RelationalExpression'],
"ISBLANK" : ['RelationalExpression'],
"ISIRI" : ['RelationalExpression'],
"ISLITERAL" : ['RelationalExpression'],
"ISURI" : ['RelationalExpression'],
"SAMETERM" : ['RelationalExpression'],
},
'Var' : {
'VAR1' : ['VAR1'],
'VAR2' : ['VAR2'],
},
'VarOrIRIref' : {
'IRI_REF' : ['IRIref'],
'PNAME_LN' : ['IRIref'],
'PNAME_NS' : ['IRIref'],
'VAR1' : ['Var'],
'VAR2' : ['Var'],
},
'VarOrTerm' : {
"+" : ['GraphTerm'],
"-" : ['GraphTerm'],
'ANON' : ['GraphTerm'],
'BLANK_NODE_LABEL' : ['GraphTerm'],
'BooleanLiteral' : ['GraphTerm'],
'DECIMAL' : ['GraphTerm'],
'DOUBLE' : ['GraphTerm'],
'INTEGER' : ['GraphTerm'],
'IRI_REF' : ['GraphTerm'],
'NIL' : ['GraphTerm'],
'PNAME_LN' : ['GraphTerm'],
'PNAME_NS' : ['GraphTerm'],
'STRING_LITERAL1' : ['GraphTerm'],
'STRING_LITERAL2' : ['GraphTerm'],
'STRING_LITERAL_LONG1' : ['GraphTerm'],
'STRING_LITERAL_LONG2' : ['GraphTerm'],
'VAR1' : ['Var'],
'VAR2' : ['Var'],
},
'Verb' : {
"a" : ["a"],
'IRI_REF' : ['VarOrIRIref'],
'PNAME_LN' : ['VarOrIRIref'],
'PNAME_NS' : ['VarOrIRIref'],
'VAR1' : ['VarOrIRIref'],
'VAR2' : ['VarOrIRIref'],
},
'WhereClause' : {
"WHERE" : ['_WHERE_Opt',
'GroupGraphPattern'],
"{" : ['_WHERE_Opt',
'GroupGraphPattern'],
},
'_AND_ValueLogical' : {
"&&" : ["&&",
'ValueLogical'],
},
'_AND_ValueLogical_Star' : {
"&&" : ['_AND_ValueLogical',
'_AND_ValueLogical_Star'],
")" : [],
"," : [],
"||" : [],
},
'_ASC_Or_DESC' : {
"ASC" : ["ASC"],
"DESC" : ["DESC"],
},
'_ASC_Or_DESC_BrackettedExpression' : {
"ASC" : ['_ASC_Or_DESC',
'BrackettedExpression'],
"DESC" : ['_ASC_Or_DESC',
'BrackettedExpression'],
},
'_Add_Sub_MultiplicativeExpression_Star' : {
"!=" : [],
"&&" : [],
")" : [],
"+" : ["+",
'MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"," : [],
"-" : ["-",
'MultiplicativeExpression',
'_Add_Sub_MultiplicativeExpression_Star'],
"<" : [],
"<=" : [],
"=" : [],
">=" : [],
">" : [],
"||" : [],
},
'_ArgList_Opt' : {
"!=" : [],
"&&" : [],
"(" : ['ArgList'],
")" : [],
"*" : [],
"+" : [],
"," : [],
"-" : [],
"/" : [],
"<" : [],
"<=" : [],
"=" : [],
">=" : [],
">" : [],
'NIL' : ['ArgList'],
"||" : [],
},
'_BaseDecl_Opt' : {
"ASK" : [],
"BASE" : ['BaseDecl'],
"CONSTRUCT" : [],
"DESCRIBE" : [],
"PREFIX" : [],
"SELECT" : [],
},
'_COMMA_Expression_Opt' : {
")" : [],
"," : [",",
'Expression'],
},
'_COMMA_Expression_Star' : {
")" : [],
"," : [",",
'Expression'],
},
'_COMMA_Object' : {
"," : [",",
'Object'],
},
'_COMMA_Object_Star' : {
"," : ['_COMMA_Object',
'_COMMA_Object_Star'],
"." : [],
";" : [],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"]" : [],
"{" : [],
"}" : [],
},
'_Compare_NumericExpression_Opt' : {
"!=" : ["!=",
'NumericExpression'],
"&&" : [],
")" : [],
"," : [],
"<" : ["<",
'NumericExpression'],
"<=" : ["<=",
'NumericExpression'],
"=" : ["=",
'NumericExpression'],
">=" : [">=",
'NumericExpression'],
">" : [">",
'NumericExpression'],
"||" : [],
},
'_Constraint_or_Var' : {
"(" : ['Constraint'],
"BOUND" : ['Constraint'],
"DATATYPE" : ['Constraint'],
"LANG" : ['Constraint'],
"LANGMATCHES" : ['Constraint'],
"REGEX" : ['Constraint'],
"STR" : ['Constraint'],
'IRI_REF' : ['Constraint'],
'PNAME_LN' : ['Constraint'],
'PNAME_NS' : ['Constraint'],
'VAR1' : ['Var'],
'VAR2' : ['Var'],
"ISBLANK" : ['Constraint'],
"ISIRI" : ['Constraint'],
"ISLITERAL" : ['Constraint'],
"ISURI" : ['Constraint'],
"SAMETERM" : ['Constraint'],
},
'_ConstructTriples_Opt' : {
"(" : ['ConstructTriples'],
"+" : ['ConstructTriples'],
"-" : ['ConstructTriples'],
"[" : ['ConstructTriples'],
'ANON' : ['ConstructTriples'],
'BLANK_NODE_LABEL' : ['ConstructTriples'],
'BooleanLiteral' : ['ConstructTriples'],
'DECIMAL' : ['ConstructTriples'],
'DOUBLE' : ['ConstructTriples'],
'INTEGER' : ['ConstructTriples'],
'IRI_REF' : ['ConstructTriples'],
'NIL' : ['ConstructTriples'],
'PNAME_LN' : ['ConstructTriples'],
'PNAME_NS' : ['ConstructTriples'],
'STRING_LITERAL1' : ['ConstructTriples'],
'STRING_LITERAL2' : ['ConstructTriples'],
'STRING_LITERAL_LONG1' : ['ConstructTriples'],
'STRING_LITERAL_LONG2' : ['ConstructTriples'],
'VAR1' : ['ConstructTriples'],
'VAR2' : ['ConstructTriples'],
"}" : [],
},
'_DISTINCT_OR_REDUCED_Opt' : {
"*" : [],
"DISTINCT" : ["DISTINCT"],
"REDUCED" : ["REDUCED"],
'VAR1' : [],
'VAR2' : [],
},
'_DOT_ConstructTriples_Opt_Opt' : {
"." : [".",
'_ConstructTriples_Opt'],
"}" : [],
},
'_DOT_Opt' : {
"(" : [],
"+" : [],
"-" : [],
"." : ["."],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"[" : [],
'ANON' : [],
'BLANK_NODE_LABEL' : [],
'BooleanLiteral' : [],
'DECIMAL' : [],
'DOUBLE' : [],
'INTEGER' : [],
'IRI_REF' : [],
'NIL' : [],
'PNAME_LN' : [],
'PNAME_NS' : [],
'STRING_LITERAL1' : [],
'STRING_LITERAL2' : [],
'STRING_LITERAL_LONG1' : [],
'STRING_LITERAL_LONG2' : [],
'VAR1' : [],
'VAR2' : [],
"{" : [],
"}" : [],
},
'_DatasetClause_Star' : {
"FROM" : ['DatasetClause',
'_DatasetClause_Star'],
"LIMIT" : [],
"OFFSET" : [],
"ORDER" : [],
"WHERE" : [],
'eof' : [],
"{" : [],
},
'_DefaultGraphClause_or_NamedGraphClause' : {
"NAMED" : ['NamedGraphClause'],
'IRI_REF' : ['DefaultGraphClause'],
'PNAME_LN' : ['DefaultGraphClause'],
'PNAME_NS' : ['DefaultGraphClause'],
},
'_Dot_TriplesBlock_Opt_Opt' : {
"." : [".",
'_TriplesBlock_Opt'],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"{" : [],
"}" : [],
},
'_Expression_COMMA_Expression_Star' : {
"!" : ['Expression',
'_COMMA_Expression_Star'],
"(" : ['Expression',
'_COMMA_Expression_Star'],
"+" : ['Expression',
'_COMMA_Expression_Star'],
"-" : ['Expression',
'_COMMA_Expression_Star'],
"BOUND" : ['Expression',
'_COMMA_Expression_Star'],
"DATATYPE" : ['Expression',
'_COMMA_Expression_Star'],
"LANG" : ['Expression',
'_COMMA_Expression_Star'],
"LANGMATCHES" : ['Expression',
'_COMMA_Expression_Star'],
"REGEX" : ['Expression',
'_COMMA_Expression_Star'],
"STR" : ['Expression',
'_COMMA_Expression_Star'],
'BooleanLiteral' : ['Expression',
'_COMMA_Expression_Star'],
'DECIMAL' : ['Expression',
'_COMMA_Expression_Star'],
'DOUBLE' : ['Expression',
'_COMMA_Expression_Star'],
'INTEGER' : ['Expression',
'_COMMA_Expression_Star'],
'IRI_REF' : ['Expression',
'_COMMA_Expression_Star'],
'PNAME_LN' : ['Expression',
'_COMMA_Expression_Star'],
'PNAME_NS' : ['Expression',
'_COMMA_Expression_Star'],
'STRING_LITERAL1' : ['Expression',
'_COMMA_Expression_Star'],
'STRING_LITERAL2' : ['Expression',
'_COMMA_Expression_Star'],
'STRING_LITERAL_LONG1' : ['Expression',
'_COMMA_Expression_Star'],
'STRING_LITERAL_LONG2' : ['Expression',
'_COMMA_Expression_Star'],
'VAR1' : ['Expression',
'_COMMA_Expression_Star'],
'VAR2' : ['Expression',
'_COMMA_Expression_Star'],
"ISBLANK" : ['Expression',
'_COMMA_Expression_Star'],
"ISIRI" : ['Expression',
'_COMMA_Expression_Star'],
"ISLITERAL" : ['Expression',
'_COMMA_Expression_Star'],
"ISURI" : ['Expression',
'_COMMA_Expression_Star'],
"SAMETERM" : ['Expression',
'_COMMA_Expression_Star'],
},
'_GraphNode_Opt' : {
"(" : ['GraphNode',
'_GraphNode_Opt'],
")" : [],
"+" : ['GraphNode',
'_GraphNode_Opt'],
"-" : ['GraphNode',
'_GraphNode_Opt'],
"[" : ['GraphNode',
'_GraphNode_Opt'],
'ANON' : ['GraphNode',
'_GraphNode_Opt'],
'BLANK_NODE_LABEL' : ['GraphNode',
'_GraphNode_Opt'],
'BooleanLiteral' : ['GraphNode',
'_GraphNode_Opt'],
'DECIMAL' : ['GraphNode',
'_GraphNode_Opt'],
'DOUBLE' : ['GraphNode',
'_GraphNode_Opt'],
'INTEGER' : ['GraphNode',
'_GraphNode_Opt'],
'IRI_REF' : ['GraphNode',
'_GraphNode_Opt'],
'NIL' : ['GraphNode',
'_GraphNode_Opt'],
'PNAME_LN' : ['GraphNode',
'_GraphNode_Opt'],
'PNAME_NS' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL1' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL2' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL_LONG1' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL_LONG2' : ['GraphNode',
'_GraphNode_Opt'],
'VAR1' : ['GraphNode',
'_GraphNode_Opt'],
'VAR2' : ['GraphNode',
'_GraphNode_Opt'],
},
'_GraphNode_Plus' : {
"(" : ['GraphNode',
'_GraphNode_Opt'],
"+" : ['GraphNode',
'_GraphNode_Opt'],
"-" : ['GraphNode',
'_GraphNode_Opt'],
"[" : ['GraphNode',
'_GraphNode_Opt'],
'ANON' : ['GraphNode',
'_GraphNode_Opt'],
'BLANK_NODE_LABEL' : ['GraphNode',
'_GraphNode_Opt'],
'BooleanLiteral' : ['GraphNode',
'_GraphNode_Opt'],
'DECIMAL' : ['GraphNode',
'_GraphNode_Opt'],
'DOUBLE' : ['GraphNode',
'_GraphNode_Opt'],
'INTEGER' : ['GraphNode',
'_GraphNode_Opt'],
'IRI_REF' : ['GraphNode',
'_GraphNode_Opt'],
'NIL' : ['GraphNode',
'_GraphNode_Opt'],
'PNAME_LN' : ['GraphNode',
'_GraphNode_Opt'],
'PNAME_NS' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL1' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL2' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL_LONG1' : ['GraphNode',
'_GraphNode_Opt'],
'STRING_LITERAL_LONG2' : ['GraphNode',
'_GraphNode_Opt'],
'VAR1' : ['GraphNode',
'_GraphNode_Opt'],
'VAR2' : ['GraphNode',
'_GraphNode_Opt'],
},
'_GraphPatternNotTriples_or_Filter' : {
"FILTER" : ['Filter'],
"GRAPH" : ['GraphPatternNotTriples'],
"OPTIONAL" : ['GraphPatternNotTriples'],
"{" : ['GraphPatternNotTriples'],
},
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt' : {
"FILTER" : ['_GraphPatternNotTriples_or_Filter',
'_DOT_Opt',
'_TriplesBlock_Opt'],
"GRAPH" : ['_GraphPatternNotTriples_or_Filter',
'_DOT_Opt',
'_TriplesBlock_Opt'],
"OPTIONAL" : ['_GraphPatternNotTriples_or_Filter',
'_DOT_Opt',
'_TriplesBlock_Opt'],
"{" : ['_GraphPatternNotTriples_or_Filter',
'_DOT_Opt',
'_TriplesBlock_Opt'],
},
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star' : {
"FILTER" : ['_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt',
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star'],
"GRAPH" : ['_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt',
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star'],
"OPTIONAL" : ['_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt',
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star'],
"{" : ['_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt',
'_GraphPatternNotTriples_or_Filter_Dot_Opt_TriplesBlock_Opt_Star'],
"}" : [],
},
'_LANGTAG_IRIref_Opt' : {
"!=" : [],
"&&" : [],
"(" : [],
")" : [],
"*" : [],
"+" : [],
"," : [],
"-" : [],
"." : [],
"/" : [],
";" : [],
"<" : [],
"<=" : [],
"=" : [],
">=" : [],
">" : [],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"[" : [],
"]" : [],
"^^" : ["^^",
'IRIref'],
"a" : [],
'ANON' : [],
'BLANK_NODE_LABEL' : [],
'BooleanLiteral' : [],
'DECIMAL' : [],
'DOUBLE' : [],
'INTEGER' : [],
'IRI_REF' : [],
'LANGTAG' : ['LANGTAG'],
'NIL' : [],
'PNAME_LN' : [],
'PNAME_NS' : [],
'STRING_LITERAL1' : [],
'STRING_LITERAL2' : [],
'STRING_LITERAL_LONG1' : [],
'STRING_LITERAL_LONG2' : [],
'VAR1' : [],
'VAR2' : [],
"{" : [],
"||" : [],
"}" : [],
},
'_LimitClause_Opt' : {
"LIMIT" : ['LimitClause'],
'eof' : [],
},
'_LimitOffsetClauses_Opt' : {
"LIMIT" : ['LimitOffsetClauses'],
"OFFSET" : ['LimitOffsetClauses'],
'eof' : [],
},
'_Mul_Div_UnaryExpression_Star' : {
"!=" : [],
"&&" : [],
")" : [],
"*" : ["*",
'UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"+" : [],
"," : [],
"-" : [],
"/" : ["/",
'UnaryExpression',
'_Mul_Div_UnaryExpression_Star'],
"<" : [],
"<=" : [],
"=" : [],
">=" : [],
">" : [],
"||" : [],
},
'_OR_ConditionalAndExpression' : {
"||" : ["||",
'ConditionalAndExpression'],
},
'_OR_ConditionalAndExpression_Star' : {
")" : [],
"," : [],
"||" : ['_OR_ConditionalAndExpression',
'_OR_ConditionalAndExpression_Star'],
},
'_OffsetClause_Opt' : {
"OFFSET" : ['OffsetClause'],
'eof' : [],
},
'_OrderClause_Opt' : {
"LIMIT" : [],
"OFFSET" : [],
"ORDER" : ['OrderClause'],
'eof' : [],
},
'_OrderCondition_Plus' : {
"(" : ['OrderCondition',
'_OrderCondition_Plus'],
"ASC" : ['OrderCondition',
'_OrderCondition_Plus'],
"BOUND" : ['OrderCondition',
'_OrderCondition_Plus'],
"DATATYPE" : ['OrderCondition',
'_OrderCondition_Plus'],
"DESC" : ['OrderCondition',
'_OrderCondition_Plus'],
"LANG" : ['OrderCondition',
'_OrderCondition_Plus'],
"LANGMATCHES" : ['OrderCondition',
'_OrderCondition_Plus'],
"LIMIT" : [],
"OFFSET" : [],
"REGEX" : ['OrderCondition',
'_OrderCondition_Plus'],
"STR" : ['OrderCondition',
'_OrderCondition_Plus'],
'eof' : [],
'IRI_REF' : ['OrderCondition',
'_OrderCondition_Plus'],
'PNAME_LN' : ['OrderCondition',
'_OrderCondition_Plus'],
'PNAME_NS' : ['OrderCondition',
'_OrderCondition_Plus'],
'VAR1' : ['OrderCondition',
'_OrderCondition_Plus'],
'VAR2' : ['OrderCondition',
'_OrderCondition_Plus'],
"ISBLANK" : ['OrderCondition',
'_OrderCondition_Plus'],
"ISIRI" : ['OrderCondition',
'_OrderCondition_Plus'],
"ISLITERAL" : ['OrderCondition',
'_OrderCondition_Plus'],
"ISURI" : ['OrderCondition',
'_OrderCondition_Plus'],
"SAMETERM" : ['OrderCondition',
'_OrderCondition_Plus'],
},
'_PrefixDecl_Star' : {
"ASK" : [],
"CONSTRUCT" : [],
"DESCRIBE" : [],
"PREFIX" : ['PrefixDecl',
'_PrefixDecl_Star'],
"SELECT" : [],
},
'_SEMI_Verb_ObjectList_Opt' : {
";" : [";",
'_Verb_ObjectList_Opt'],
},
'_SEMI_Verb_ObjectList_Opt_Star' : {
"." : [],
";" : ['_SEMI_Verb_ObjectList_Opt',
'_SEMI_Verb_ObjectList_Opt_Star'],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"]" : [],
"{" : [],
"}" : [],
},
'_SelectQuery_or_ConstructQuery_or_DescribeQuery_or_AskQuery' : {
"ASK" : ['AskQuery'],
"CONSTRUCT" : ['ConstructQuery'],
"DESCRIBE" : ['DescribeQuery'],
"SELECT" : ['SelectQuery'],
},
'_TriplesBlock_Opt' : {
"(" : ['TriplesBlock'],
"+" : ['TriplesBlock'],
"-" : ['TriplesBlock'],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"[" : ['TriplesBlock'],
'ANON' : ['TriplesBlock'],
'BLANK_NODE_LABEL' : ['TriplesBlock'],
'BooleanLiteral' : ['TriplesBlock'],
'DECIMAL' : ['TriplesBlock'],
'DOUBLE' : ['TriplesBlock'],
'INTEGER' : ['TriplesBlock'],
'IRI_REF' : ['TriplesBlock'],
'NIL' : ['TriplesBlock'],
'PNAME_LN' : ['TriplesBlock'],
'PNAME_NS' : ['TriplesBlock'],
'STRING_LITERAL1' : ['TriplesBlock'],
'STRING_LITERAL2' : ['TriplesBlock'],
'STRING_LITERAL_LONG1' : ['TriplesBlock'],
'STRING_LITERAL_LONG2' : ['TriplesBlock'],
'VAR1' : ['TriplesBlock'],
'VAR2' : ['TriplesBlock'],
"{" : [],
"}" : [],
},
'_UNION_GroupGraphPattern' : {
"UNION" : ["UNION",
'GroupGraphPattern'],
},
'_UNION_GroupGraphPattern_Star' : {
"(" : [],
"+" : [],
"-" : [],
"." : [],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"UNION" : ['_UNION_GroupGraphPattern',
'_UNION_GroupGraphPattern_Star'],
"[" : [],
'ANON' : [],
'BLANK_NODE_LABEL' : [],
'BooleanLiteral' : [],
'DECIMAL' : [],
'DOUBLE' : [],
'INTEGER' : [],
'IRI_REF' : [],
'NIL' : [],
'PNAME_LN' : [],
'PNAME_NS' : [],
'STRING_LITERAL1' : [],
'STRING_LITERAL2' : [],
'STRING_LITERAL_LONG1' : [],
'STRING_LITERAL_LONG2' : [],
'VAR1' : [],
'VAR2' : [],
"{" : [],
"}" : [],
},
'_VarOrIRIRef_Plus' : {
"FROM" : [],
"LIMIT" : [],
"OFFSET" : [],
"ORDER" : [],
"WHERE" : [],
'eof' : [],
'IRI_REF' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'PNAME_LN' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'PNAME_NS' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'VAR1' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'VAR2' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
"{" : [],
},
'_VarOrIRIref_Plus_or_Star' : {
"*" : ["*"],
'IRI_REF' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'PNAME_LN' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'PNAME_NS' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'VAR1' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
'VAR2' : ['VarOrIRIref',
'_VarOrIRIRef_Plus'],
},
'_Var_Plus' : {
"FROM" : [],
"LIMIT" : [],
"OFFSET" : [],
"ORDER" : [],
"WHERE" : [],
'eof' : [],
'VAR1' : ['Var',
'_Var_Plus'],
'VAR2' : ['Var',
'_Var_Plus'],
"{" : [],
},
'_Var_Plus_or_Star' : {
"*" : ["*"],
'VAR1' : ['Var',
'_Var_Plus'],
'VAR2' : ['Var',
'_Var_Plus'],
},
'_Verb_ObjectList_Opt' : {
"." : [],
";" : [],
"FILTER" : [],
"GRAPH" : [],
"OPTIONAL" : [],
"]" : [],
"a" : ['Verb',
'ObjectList'],
'IRI_REF' : ['Verb',
'ObjectList'],
'PNAME_LN' : ['Verb',
'ObjectList'],
'PNAME_NS' : ['Verb',
'ObjectList'],
'VAR1' : ['Verb',
'ObjectList'],
'VAR2' : ['Verb',
'ObjectList'],
"{" : [],
"}" : [],
},
'_WHERE_Opt' : {
"WHERE" : ["WHERE"],
"{" : [],
},
'_WhereClause_Opt' : {
"LIMIT" : [],
"OFFSET" : [],
"ORDER" : [],
"WHERE" : ['WhereClause'],
'eof' : [],
"{" : ['WhereClause'],
},
}
|
class Solution:
def minSteps(self, s: str, t: str) -> int:
res = 0
dic = {}
for _ in s:
if _ in dic:
dic[_] += 1
else:
dic[_] = 1
for _ in t:
if _ in dic:
dic[_] -= 1
if not dic[_]:
del dic[_]
else:
res += 1
return res
|
# * Daily Coding Problem August 25 2020
# * [Easy] -- Google
# * In linear algebra, a Toeplitz matrix is one in which the elements on
# * any given diagonal from top left to bottom right are identical.
# * Write a program to determine whether a given input is a Toeplitz matrix.
def checkDiagonal(mat, i, j):
res = mat[i][j]
i += 1
j += 1
rows = len(mat)
cols = len(mat[0])
while (i < rows and j < cols):
# mismatch found
if (mat[i][j] != res):
return False
i += 1
j += 1
# we only reach here when all elements
# in given diagonal are same
return True
def isToeplitz(mat):
rows = len(mat)
cols = len(mat[0])
for j in range(rows - 1):
# check descending diagonal starting from
# position (0, j) in the matrix
if not(checkDiagonal(mat, 0, j)):
return False
for i in range(1, cols - 1):
# check descending diagonal starting
# from position (i, 0) in the matrix
if not(checkDiagonal(mat, i, 0)):
return False
return True
def main():
matrix = [
[1, 2, 3, 4, 8],
[5, 1, 2, 3, 4],
[4, 5, 1, 2, 3],
[7, 4, 5, 1, 2]
]
print('\n'.join(['\t'.join([str(cell) for cell in row])
for row in matrix]))
print(f"Toeplitz matrix ? {isToeplitz(matrix)}")
main()
# --------------------------TESTs----------------------------
def testIsToeplitz1():
matrix = [
[1, 2, 3, 4, 8],
[5, 1, 2, 3, 4],
[4, 5, 1, 2, 3],
[7, 4, 5, 1, 2]
]
assert isToeplitz(matrix) == True
def testIsToeplitz2():
matrix = [
[1, 5, 3, 4, 8],
[5, 1, 2, 3, 4],
[4, 5, 1, 2, 3],
[7, 4, 5, 1, 2]
]
assert isToeplitz(matrix) == False
def testIsToeplitz3():
matrix = [
[6, 7, 8, 9],
[4, 6, 7, 8],
[1, 4, 6, 7],
[0, 1, 4, 6],
[2, 0, 1, 4]
]
assert isToeplitz(matrix) == True
|
# Initialize sum
sum = 0
# Add 0.01, 0.02, ..., 0.99, 1 to sum
i = 0.01
while i <= 1.0:
sum += i
i = i + 0.01
# Display result
print("The sum is", sum)
|
"""
1. For $V>-75$ mV, the derivative is negative.
2. For $V<-75$ mV, the derivative is positive.
3. For $V=-75$ mV, the derivative is equal to $0$ is and a stable point.
"""
|
print('-' * 15)
medida = float(input('Digite uma distancia em metros:'))
centimetros = medida * 100
milimetros = medida * 1000
print('A media de {} corresponde a {:.0f} e {:.0f}'.format(medida, centimetros, milimetros))
|
def exponentiation(base, exponent):
if isinstance(base, str) or isinstance(exponent, str):
return "Trying to use strings in calculator"
solution = float(base) ** exponent
return solution
|
#!/usr/bin/env python
# -*- coding: utf-8
"""
Taxonomy Resolver
:copyright: (c) 2020-2021.
:license: Apache 2.0, see LICENSE for more details.
"""
ncbi_ranks = [
"class",
"cohort",
"family",
"forma",
"genus",
"infraclass",
"infraorder",
"kingdom",
"order",
"parvorder",
"phylum",
"section",
"series",
"species group",
"species subgroup",
"species",
"subclass",
"subcohort",
"subfamily",
"subgenus",
"subkingdom",
"suborder",
"subphylum",
"subsection",
"subspecies",
"subtribe",
"superclass",
"superfamily",
"superkingdom",
"superorder",
"superphylum",
"tribe",
"varietas",
"strain", # new from here
"isolate",
"clade",
"forma specialis",
"serotype",
"biotype",
"serogroup",
"genotype",
"morph",
"subvariety",
"pathogroup",
]
ncbi_node_fields = [
"tax_id", # node id in GenBank taxonomy database
"parent_tax_id", # parent node id in GenBank taxonomy database
"rank", # rank of this node (superkingdom, kingdom, ...)
"embl_code", # locus-name prefix; not unique
"division_id", # see division.dmp file
"inherited_div_flag", # (1 or 0) 1 if node inherits division from parent
"genetic_code_id", # see gencode.dmp file
"inherited_GC_flag", # (1 or 0) 1 if node inherits genetic code from parent
"mitochondrial_genetic_code_id", # see gencode.dmp file
"inherited_MGC_flag", # (1 or 0) 1 if node inherits mitochondrial gencode from parent
"GenBank_hidden_flag", # (1 or 0) 1 if name is suppressed in GenBank entry lineage
"hidden_subtree_root_flag", # (1 or 0) 1 if this subtree has no sequence data yet
"comments", # free-text comments and citations
]
|
#Ler 6 numeros inteiros e mostre a soma dqls q são par
s = 0
for c in range(0, 6):
n = int(input('\033[1;34mNÚMERO A SER ANALISADO: '))
if n % 2 == 0:
s += n
print('A soma dos valores pares é {}'.format(s))
|
# Curbrock's Revenge (5501)
SABITRAMA = 1061005 # NPC ID
CURBROCKS_HIDEOUT_VER3 = 600050020 # MAP ID
CURBROCKS_ESCAPE_ROUTE_VER3 = 600050050 # MAP ID 3
sm.setSpeakerID(SABITRAMA)
if sm.getFieldID() == CURBROCKS_ESCAPE_ROUTE_VER3:
sm.sendSayOkay("Please leave before reaccepting this quest again.")
else:
sm.sendNext("The rumors are true. "
"Curbrock has returned, and the people are worried.")
sm.sendSay("However, he doesn't seem to be interested in anyone but you.")
response = sm.sendAskYesNo("I can send you there now if you want. "
"Are you prepared?")
if response:
sm.sendNext("Since you last fought, Curbrock has learned a few new tricks.")
sm.sendSay("His Seal spell will stop you from using your skills.")
sm.sendSay("His Blind spell will stop you from seeing.")
sm.sendSay("And his Stun spell will stop you from moving.")
sm.sendSay("If you can avoid or counter his spells, you might yet beat him.")
chr.setPreviousFieldID(chr.getFieldID())
sm.startQuest(parentID)
sm.warpInstanceIn(CURBROCKS_HIDEOUT_VER3)
|
#
# PySNMP MIB module CISCOSB-SECSD-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CISCOSB-SECSD-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 18:06:01 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)
#
OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueRangeConstraint, ValueSizeConstraint, SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion")
switch001, = mibBuilder.importSymbols("CISCOSB-MIB", "switch001")
EnabledStatus, = mibBuilder.importSymbols("P-BRIDGE-MIB", "EnabledStatus")
NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance")
Counter64, Bits, ObjectIdentity, MibIdentifier, Counter32, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, Integer32, TimeTicks, iso, Unsigned32, ModuleIdentity, NotificationType, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "Counter64", "Bits", "ObjectIdentity", "MibIdentifier", "Counter32", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Integer32", "TimeTicks", "iso", "Unsigned32", "ModuleIdentity", "NotificationType", "Gauge32")
DisplayString, RowStatus, TruthValue, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TruthValue", "TextualConvention")
rlSecSd = ModuleIdentity((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209))
rlSecSd.setRevisions(('2011-08-31 00:00',))
if mibBuilder.loadTexts: rlSecSd.setLastUpdated('201108310000Z')
if mibBuilder.loadTexts: rlSecSd.setOrganization('Cisco Small Business')
class RlSecSdRuleUserType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))
namedValues = NamedValues(("user-name", 1), ("default-user", 2), ("level-15-users", 3), ("all-users", 4))
class RlSecSdChannelType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))
namedValues = NamedValues(("secure-xml-snmp", 1), ("secure", 2), ("insecure", 3), ("insecure-xml-snmp", 4))
class RlSecSdAccessType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3))
namedValues = NamedValues(("exclude", 1), ("include-encrypted", 2), ("include-decrypted", 3))
class RlSecSdPermitAccessType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))
namedValues = NamedValues(("exclude", 1), ("include-encrypted", 2), ("include-decrypted", 3), ("include-all", 4))
class RlSecSdSessionAccessType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))
namedValues = NamedValues(("exclude", 1), ("include-encrypted", 2), ("include-decrypted", 3), ("default", 4))
class RlSecSdRuleOwnerType(TextualConvention, Integer32):
status = 'current'
subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2))
namedValues = NamedValues(("default", 1), ("user", 2))
rlSecSdRulesTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1), )
if mibBuilder.loadTexts: rlSecSdRulesTable.setStatus('current')
rlSecSdRulesEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1), ).setIndexNames((0, "CISCOSB-SECSD-MIB", "rlSecSdRuleUser"), (0, "CISCOSB-SECSD-MIB", "rlSecSdRuleUserName"), (0, "CISCOSB-SECSD-MIB", "rlSecSdRuleChannel"))
if mibBuilder.loadTexts: rlSecSdRulesEntry.setStatus('current')
rlSecSdRuleUser = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 1), RlSecSdRuleUserType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRuleUser.setStatus('current')
rlSecSdRuleUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 39))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRuleUserName.setStatus('current')
rlSecSdRuleChannel = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 3), RlSecSdChannelType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRuleChannel.setStatus('current')
rlSecSdRuleRead = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 4), RlSecSdAccessType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRuleRead.setStatus('current')
rlSecSdRulePermitRead = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 5), RlSecSdPermitAccessType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRulePermitRead.setStatus('current')
rlSecSdRuleIsDefault = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 6), TruthValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlSecSdRuleIsDefault.setStatus('current')
rlSecSdRuleOwner = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 7), RlSecSdRuleOwnerType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRuleOwner.setStatus('current')
rlSecSdRuleStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 1, 1, 8), RowStatus()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdRuleStatus.setStatus('current')
rlSecSdMngSessionsTable = MibTable((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 2), )
if mibBuilder.loadTexts: rlSecSdMngSessionsTable.setStatus('current')
rlSecSdMngSessionsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 2, 2), ).setIndexNames((0, "CISCOSB-SECSD-MIB", "rlSecSdMngSessionId"))
if mibBuilder.loadTexts: rlSecSdMngSessionsEntry.setStatus('current')
rlSecSdMngSessionId = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 2, 2, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlSecSdMngSessionId.setStatus('current')
rlSecSdMngSessionUserLevel = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 2, 2, 2), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlSecSdMngSessionUserLevel.setStatus('current')
rlSecSdMngSessionUserName = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 2, 2, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 160))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdMngSessionUserName.setStatus('current')
rlSecSdMngSessionChannel = MibTableColumn((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 2, 2, 4), RlSecSdChannelType()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlSecSdMngSessionChannel.setStatus('current')
rlSecSdSessionControl = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 3), RlSecSdSessionAccessType()).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdSessionControl.setStatus('current')
rlSecSdCurrentSessionId = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 4), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: rlSecSdCurrentSessionId.setStatus('current')
rlSecSdPassPhrase = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 160))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdPassPhrase.setStatus('current')
rlSecSdFilePassphraseControl = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("restricted", 1), ("unrestricted", 2))).clone('unrestricted')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdFilePassphraseControl.setStatus('current')
rlSecSdFileIntegrityControl = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2))).clone('enable')).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdFileIntegrityControl.setStatus('current')
rlSecSdConfigurationFileSsdDigest = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 8), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 160))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdConfigurationFileSsdDigest.setStatus('current')
rlSecSdConfigurationFileDigest = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 9), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 160))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdConfigurationFileDigest.setStatus('current')
rlSecSdFileIndicator = MibScalar((1, 3, 6, 1, 4, 1, 9, 6, 1, 101, 209, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 39))).setMaxAccess("readwrite")
if mibBuilder.loadTexts: rlSecSdFileIndicator.setStatus('current')
mibBuilder.exportSymbols("CISCOSB-SECSD-MIB", PYSNMP_MODULE_ID=rlSecSd, rlSecSdRuleOwner=rlSecSdRuleOwner, rlSecSdRulesEntry=rlSecSdRulesEntry, rlSecSdMngSessionUserName=rlSecSdMngSessionUserName, rlSecSdCurrentSessionId=rlSecSdCurrentSessionId, RlSecSdSessionAccessType=RlSecSdSessionAccessType, rlSecSdRulesTable=rlSecSdRulesTable, RlSecSdChannelType=RlSecSdChannelType, rlSecSdRuleStatus=rlSecSdRuleStatus, rlSecSdRuleIsDefault=rlSecSdRuleIsDefault, rlSecSdRulePermitRead=rlSecSdRulePermitRead, RlSecSdRuleOwnerType=RlSecSdRuleOwnerType, rlSecSdMngSessionId=rlSecSdMngSessionId, rlSecSdSessionControl=rlSecSdSessionControl, rlSecSdMngSessionsTable=rlSecSdMngSessionsTable, rlSecSdRuleUserName=rlSecSdRuleUserName, RlSecSdAccessType=RlSecSdAccessType, rlSecSdConfigurationFileDigest=rlSecSdConfigurationFileDigest, rlSecSdMngSessionsEntry=rlSecSdMngSessionsEntry, RlSecSdRuleUserType=RlSecSdRuleUserType, rlSecSdMngSessionUserLevel=rlSecSdMngSessionUserLevel, rlSecSdRuleUser=rlSecSdRuleUser, rlSecSdConfigurationFileSsdDigest=rlSecSdConfigurationFileSsdDigest, rlSecSdRuleRead=rlSecSdRuleRead, rlSecSdPassPhrase=rlSecSdPassPhrase, rlSecSdMngSessionChannel=rlSecSdMngSessionChannel, RlSecSdPermitAccessType=RlSecSdPermitAccessType, rlSecSd=rlSecSd, rlSecSdFileIndicator=rlSecSdFileIndicator, rlSecSdFileIntegrityControl=rlSecSdFileIntegrityControl, rlSecSdRuleChannel=rlSecSdRuleChannel, rlSecSdFilePassphraseControl=rlSecSdFilePassphraseControl)
|
#
# @lc app=leetcode id=680 lang=python3
#
# [680] Valid Palindrome II
#
# @lc code=start
class Solution:
def validPalindrome(self, s: str) -> bool:
l, r = 0, len(s) - 1
while l < r:
if s[l] != s[r]:
pre, las = s[l:r], s[l + 1:r + 1]
return pre[::-1] == pre or las[::-1] == las
else:
l += 1
r -= 1
return True
# @lc code=end
|
# Space/Time O(n), O(nLogn)
class Solution:
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
# Sort intervals
intervals.sort(key=lambda x:x[0])
# start merged list and go through intervals
merged = [intervals[0]]
for si, ei in intervals:
sm, em = merged[-1]
if si <= em:
merged[-1] = (sm, max(em,ei))
else:
merged.append((si, ei))
return merged
def merge(self, intervals: List[List[int]]) -> List[List[int]]:
if not intervals:
return
# sort intervals
intervals.sort(key = lambda x:x[0])
# start merged list and go through intervals
merged = [intervals[0]]
for i in intervals:
ms, me = merged[-1]
s, e = i
if s <= me:
merged[-1] = (ms, max(me, e))
else:
merged.append(i)
return merged
|
start_range = int(input())
stop_range = int(input())
for x in range(start_range, stop_range + 1):
print(f"{(chr(x))}", end=" ")
|
def brackets(sequence: str) -> bool:
brackets_dict = {"]": "[", ")": "(", "}": "{", ">": "<"}
stack = []
for symbol in sequence:
if symbol in "[({<":
stack.append(symbol)
elif symbol in "])}>":
if brackets_dict[symbol] != stack.pop():
return False
return True
if __name__ == "__main__":
print(brackets("[12 / (9) + 2(5{15 * <2 - 3>}6)]"))
print(brackets("1{2 + [3}45 - 6] * (7 - 8)9"))
|
def merge(left, right):
m = []
i,j = 0,0
k = 0
while i < len(left) and j < len(right):
# print(left,right,left[i], right[j])
if left[i] <= right[j]:
m.append(left[i])
i+=1
else:
m.append(right[j])
j +=1
if i < len(left):
m.extend(left[i:])
if j < len(right):
m.extend(right[j:])
print(left, right)
print(m)
return m
def sort(a):
n = len(a)
mid = n//2
if n <= 1:
return a
left = sort(a[:mid])
right = sort(a[mid:])
m=merge(left, right)
return m
if __name__ == "__main__":
a= [5,1,5,8,12,13,5,8,1,23,1,11]
print(sort(a))
|
boxes = """cvfueihajytpmrdkgsxfqplbxn
cbzueihajytnmrdkgtxfqplbwn
cvzucihajytomrdkgstfqplqwn
cvzueilajytomrdkgsxfqwnbwn
cvzueihajytomrdkgsgwqphbwn
wuzuerhajytomrdkgsxfqplbwn
cyzueifajybomrdkgsxfqplbwn
cvzueihajxtomrdkgpxfqplmwn
ivzfevhajytomrdkgsxfqplbwn
cvzueihajytomrdlgsxfqphbbn
uvzueihajjtomrdkgsxfqpobwn
cvzupihajytomrdkgsxfqplpwe
cvzueihajyvomrdkgsxfqplbrl
cczueihajytomrdkgsnfqpxbwn
cvzueigajytdmrdkgsxyqplbwn
cvzujihljytomrdkgsxuqplbwn
cvzueisajytomrddgsxkqplbwn
cvzneihajytomrdkgsgaqplbwn
cvzueihajytomrdkgsinmplbwn
cveueihajyromrdkgsxfqplown
cypueihajytotrdkgzxfqplbwn
cvzuoihajytomvdqgsxfqplbwn
cvzuekhejytwmrdkgsxfqplbwn
cvzseihajytomrdkgsxfqgmbwn
cvfuhihajytomrdkgsxfqplbwi
cvzueihujxtomrdkgsufqplbwn
cvzueihdjytomrdogsxfqplbwh
cvzueihdjyfohrdkgsxfqplbwn
cvtudihajytolrdkgsxfqplbwn
cvzueihajytymrdkgshzqplbwn
cvzuebhajytomxdkgsxfqplbwt
cvzulihajyxomrdkgsbfqplbwn
cvzueihajywomrdkgsxfqplbts
cvzueihajytouodkdsxfqplbwn
cvzueihajytomgdkgqxfqklbwn
cvzubihajytomvdkgsxfqplmwn
cvhueihajyyocrdkgsxfqplbwn
zvzueihajytourdkgsxflplbwn
cvzbeihajytomadkgsxfoplbwn
cvzueihajytomrdkgnxfqplbsl
cvfueihajftkmrdkgsxfqplbwn
cvzuexhajytomryugsxfqplbwn
cvzueihajytomsckgsxfqalbwn
cvzuexhajytomrdkbsxfqpluwn
cvzueihajytbmrtkgsxwqplbwn
cvzueihajytomrdigsxfqqlbsn
cvzweihajytomydkgsxfmplbwn
bvzteihajytimrdkgsxfqplbwn
cvzueihajytpmrdkgsxfcpbbwn
cvzueigsjltomrdkgsxfqplbwn
cvzueihajytomrikgsxfopldwn
cvzueihajstomrdkgsxfqplgon
cvzueimajytomrnkxsxfqplbwn
cvzleihagatomrdkgsxfqplbwn
cvbueihajotomrdkgsxfqjlbwn
cvzueihajytomrdkgsxfqppnvn
hvzueihajytomrdkghxfkplbwn
cvzueigajytxmrdkgsxfqplbjn
cvzueihaaxtokrdkgsxfqplbwn
cvzueihajyeomrdkgujfqplbwn
cvzueiwajpoomrdkgsxfqplbwn
cvzieidtjytomrdkgsxfqplbwn
cvzueihalytomrakbsxfqplbwn
wtzueihajytomrdkgsxfqplbwq
cvzuelhaiytomrdkgsxfqplcwn
cvzueihajytomrdkgsxfqslswd
cvzueihajytomrykgssfqplbon
cvzueihfjytovrdegsxfqplbwn
cvzueihajytomldqgsxfqplbwy
cvzleihjjytomrtkgsxfqplbwn
cvzueihaldtomrdtgsxfqplbwn
cvzueihajytzmrdkgsxfeplqwn
cvzueihrjytomddkgsxfqpgbwn
cyzulihajytokrdkgsxfqplbwn
cvsueihajytoordfgsxfqplbwn
fvzueyhajytomrdkgaxfqplbwn
cczueihajytobrdkgsefqplbwn
cvzueihajytomcdrgscfqplbwn
cvzuexhajyvomrdkgssfqplbwn
cvzsmihajyiomrdkgsxfqplbwn
cvzzeihajttomrdkgsxzqplbwn
cvzseihajytomrdkgsxfqpebvn
cvzueihajgthmrdkgsbfqplbwn
ruzueihajytomrdkgsxfqphbwn
cvzueihajytofrdkgsnfrplbwn
cvzuetdajytojrdkgsxfqplbwn
fvzueihajytomrdkghxfqpobwn
cvzueihsjytomrdkgsxfqglbxn
cvzueihajytowrdkgsxfqpsbun
cvzteihaiytomrdkfsxfqplbwn
cvzueihajytkmrdkrsxfqplvwn
cvzueihajyoomrdkasxfqjlbwn
lvzurihajytkmrdkgsxfqplbwn
cvzueihajyyomrdagsxfqelbwn
cvfueihajytomrdkgsxfqplbbx
cvwueihajytommdkgkxfqplbwn
cvzucicajytomrdkgsxcqplbwn
dvzueihahytgmrdkgsxfqplbwn
cvzuechajytomrdkgsxfqelwwn
cvzuekhajytomrdkgsxknplbwn
cvtueihajytomphkgsxfqplbwn
cvzueihabytnzrdkgsxfqplbwn
cvzusihajytomrdkgfxfqplban
cvfueihajytomcdfgsxfqplbwn
mvzueihapytomrdkgsxfdplbwn
cvzueihajytomhdkgsxmqppbwn
jvsueihajytomrdkgsxfqplbln
cvzujihajybomrdkgsxtqplbwn
cvzuekhawytomrdkgsxfqplbwc
svzueihanytomrdogsxfqplbwn
cvzujihajytodrdkgslfqplbwn
cvgdeihajytorrdkgsxfqplbwn
cvzbeihajytoprdkgsxfqplbyn
cvzueihkyytomjdkgsxfqplbwn
cvzuelhojytomrdkgsxfqjlbwn
evzueihajytimrdkgsxfqpsbwn
cvzueihajydomrdkjsxfqplbjn
ovzteihajytosrdkgsxfqplbwn
cvzueihajyaomrdzgsxfqplbgn
cvzuewhajmtomrdkgsufqplbwn
cvzueihajqtomhukgsxfqplbwn
cvzueihajytomzqkgsxfqplbwk
cazuewhakytomrdkgsxfqplbwn
clzueihatytomrdkgzxfqplbwn
dvzueihajytomqdkgsxfqpnbwn
cvzueidajdtomrdkgsxtqplbwn
cvzueihabytowrdkgsxoqplbwn
cvzujihwjytomrdkgsxeqplbwn
cvtuedhajytomrdkgsxfqplbbn
cvzueihajcgomrdkgsxfqplswn
cvzuephajyiomrdngsxfqplbwn
cvzueihajythmqdkgsxfqplbwf
cvzueitajytomrdkgsxfepvbwn
cvzueihajytomydkgsxfqplvwb
dvzueshajytomrddgsxfqplbwn
cvzueihajytomrdkgvxfqpwben
cvzueihajytomrdkgvxfpplwwn
cvzuefhajftomrdkgsxfqrlbwn
cvzueihajytpmrvkgsxfqplbcn
cvzueihajytohrdkgsxfqxnbwn
cvzueihajytomrdposxfqulbwn
cozueihajytomrpkgsxfqrlbwn
cvzuuihaxytomrdkgsxfqplbtn
cvzueihajytomrbzgsxyqplbwn
cveueihajyxoqrdkgsxfqplbwn
cvzueihajytomrkkgsxfqptbrn
cvzuezhajatomrdkssxfqplbwn
cpzueihajytomrdkgsxfhplbwo
lviueihajytomrekgsxfqplbwn
cvzueihwjytomrdkusxfyplbwn
cvzgeihajytomwdkgsxfrplbwn
cvzsejhzjytomrdkgsxfqplbwn
cvzuuihajytomrdkgsxfqdlbwz
cvzjeihajytomrdugsxftplbwn
cvzueihaxytomrrkgsxfmplbwn
cvzueihajgtomrdhgsxfqplwwn
cvzulihajytomedkgsxfqplewn
cvzueivajytomrdkmsxfqplbwc
cvzuervajytomrdkgsxfwplbwn
cvzuemhcjytomrdkgslfqplbwn
cvzyerhauytomrdkgsxfqplbwn
cvzueihaoytomrdkgsyfqplewn
cvzueihanytomrdkgsafkplbwn
cvzueihajvtomrdugsxfqpcbwn
chzueihajytamrdxgsxfqplbwn
cvzueihalytomrdsgsxfqplbln
cvzueihajytoyaykgsxfqplbwn
tlzueihajyeomrdkgsxfqplbwn
cvpueihajytbmrdkgsxfxplbwn
cvzueihajytomjdkgsxuqplkwn
cvzueihajygomrdkgkxfqplbwg
cvzueihajhtomrdkgbxsqplbwn
cvzurihajytomrdkgsafqplbwx
cdzuezhajytomrdkgsxrqplbwn
cvbueihajytotrwkgsxfqplbwn
cwzkeihajytomrdkgsxfqplbwh
cvzheihajytolrikgsxfqplbwn
cozuevhajytomrdkgkxfqplbwn
chzueihajytomrjkgsxfqulbwn
cvzueihkjyromrdkgsxvqplbwn
cvzveihajytomrdkgsxpqplnwn
cvzueihajytoirdkgsxfqihbwn
cvoueihajytomrdkgsxfqpdawn
pvzueihajytomrdkgnxfqplbfn
cvzueihakytomxdkgssfqplbwn
cvzueivajytomrdbgsxaqplbwn
cvzueihajytokrdkgszrqplbwn
cvzuevhajytomrdkgsxgqplbwi
cvzueihajylomrdkgsxflplbpn
hvzueihajytomvdkgsxfqplgwn
cvzleihajytymrrkgsxfqplbwn
crzueieajytomrdkgsxfqplbon
cszueihajytomrdlgqxfqplbwn
cvzueihacytomrdkgsxfjblbwn
cvzreihajytomrdkgsxfqplzun
cvzurihajytomrdkgsxiqplawn
uvzueihajyhovrdkgsxfqplbwn
cvzueihajyqodrdkgssfqplbwn
cvzwiihrjytomrdkgsxfqplbwn
cqzueihajytomrdkgjxfqplban
cvmueihajytoordkgsxfqplbyn
cypueihajytomrdkgzxfqplbwn
cvzueihajykomrdkgsmfqplbtn
cvzueidajytimrdkgsxfqpdbwn
cvzheihajytomrdkgsxfqpfewn
dvzueihajytumrdzgsxfqplbwn
cvzueixajytomrdkgsvfqplgwn
cvzuevhzjyzomrdkgsxfqplbwn
cvyeeihajytomrdkgsxnqplbwn
cvzueihajytomrdkggtpqplbwn
cvzceiyajytomrdkgexfqplbwn
cvzuelhajyyomrdkzsxfqplbwn
cvzhzihajygomrdkgsxfqplbwn
cvzueihwjytomrdkgsgfqplbrn
cvzsevhajytomrdkgqxfqplbwn
cvzueiuajytomrdkgsxfppebwn
nvzueihajytemrdkgsxwqplbwn
cvzueihajytocgdkgsxfqvlbwn
cczusihajytomrdkgsxfqplbpn
cmzueihajytomrdkbsxwqplbwn
cvzumfdajytomrdkgsxfqplbwn
cvzueihcjytomrdkgsxfqplbkl
cvzueihajytomawknsxfqplbwn
kvzueihijytomrdkgsxdqplbwn
cdzutihajytomrdkgsxfkplbwn
cvzufihadylomrdkgsxfqplbwn
cvzueihajytomrgkxsxfqphbwn
cvzuewhajyzomrdkgsxfqelbwn
cvzueihajytomrdkgqxfqelbwc
cvzueshajyoomrdkgsxfqflbwn
cvzueihajyromrekgixfqplbwn
chzugihajytomrdkgsxfqplawn
cvzueihajytomrdkgsxfhpmbwy
cvzueihacytodxdkgsxfqplbwn
cvzurihajytourdkgsdfqplbwn
cvzzeihmjytomrddgsxfqplbwn
cvzucyhajygomrdkgsxfqplbwn
ckzueihzjytomrdkgsxwqplbwn
cvlueihajmtozrdkgsxfqplbwn
cvzkeihajytomrdkgsxfqclbwc
cvzueihajytomrdkgsxgdplbwa
cvzueihyjytoxrdkgcxfqplbwn
cvzueizavytomfdkgsxfqplbwn
cvzueihajwtosrdkgsxfqllbwn
cvzueihajytomrdaksxfqpllwn
cvzuuihojytombdkgsxfqplbwn
cvzuiibajytpmrdkgsxfqplbwn
cvzueihajyuomydkgsxfqplzwn
cvzueihajytimrmkgsxfqplfwn
cvzueihajytomrdkgzxfqpljwo"""
boxes = boxes.split("\n")
def has_two(s):
d = {}
for c in s:
d[c] = d.get(c, 0) + 1
return(2 in d.values())
def has_three(s):
d = {}
for c in s:
d[c] = d.get(c, 0) + 1
return(3 in d.values())
twos = sum(map(int, map(has_two, boxes))) # for each box, get has_two, convert to 0/1 and sum
threes = sum(map(int, map(has_three, boxes))) # same for threes
checksum = twos * threes
def has_match(ss):
d = {}
for s in ss:
for ri in range(0, len(s)):
c = s[:ri] + s[ri+1:]
d[(c,ri)] = d.get((c,ri), 0) + 1
for key in d:
if d[key] == 2:
return(key, d)
return(None, d)
match, matchd = has_match(boxes)
|
# T Y P E O F V E R B S
def pert_subjective_verbs(texts_tokens):
total_verbs = 0
total_subj_verbs = 0
return
def pert_report_verbs(text_tokens):
return
def pert_factive_verbs(text_tokens):
return
def pert_imperative_commands(text_tokens):
return
|
"""
AnalysisPipeline operators
"""
class AnalysisOperation:
"""
An analysis task performed by an AnalysisPipeline.
This is an internal class that facilitates keeping track of a
function, arguments, and keyword arguments that together represent a
single operation in a pipeline.
Parameters
----------
function : callable
A function that minimally accepts a
:class:`~ytree.data_structures.tree_node.TreeNode` object. The
function may also accept additional positional and keyword arguments.
"""
def __init__(self, function, *args, **kwargs):
self.function = function
self.args = args
self.kwargs = kwargs
def __call__(self, target):
return self.function(target, *self.args, **self.kwargs)
|
"""
* Assignment: CSV Format WriteListDict
* Complexity: medium
* Lines of code: 7 lines
* Time: 8 min
English:
1. Define `result: str` with `DATA` converted to CSV format
2. Non-functional requirements:
a. Do not use `import` and any module
b. Quotechar: None
c. Quoting: never
d. Delimiter: `,`
e. Lineseparator: `\n`
3. Run doctests - all must succeed
Polish:
1. Zdefiniuj `result: str` z `DATA` przekonwertowaną do formatu CSV
2. Wymagania niefunkcjonalne:
a. Nie używaj `import` ani żadnych modułów
b. Quotechar: None
c. Quoting: nigdy
d. Delimiter: `,`
e. Lineseparator: `\n`
3. Uruchom doctesty - wszystkie muszą się powieść
Hints:
* `vars(obj)`
Tests:
>>> import sys; sys.tracebacklimit = 0
>>> assert result is not Ellipsis, \
'Assign result to variable: `result`'
>>> assert type(result) is str, \
'Variable `result` has invalid type, should be str'
>>> print(result)
sepal_length,sepal_width,petal_length,petal_width,species
5.1,3.5,1.4,0.2,setosa
5.8,2.7,5.1,1.9,virginica
5.1,3.5,1.4,0.2,setosa
5.7,2.8,4.1,1.3,versicolor
6.3,2.9,5.6,1.8,virginica
6.4,3.2,4.5,1.5,versicolor
<BLANKLINE>
"""
DATA = [{'sepal_length': 5.1, 'sepal_width': 3.5, 'petal_length': 1.4,
'petal_width': 0.2, 'species': 'setosa'},
{'sepal_length': 5.8, 'sepal_width': 2.7, 'petal_length': 5.1,
'petal_width': 1.9, 'species': 'virginica'},
{'sepal_length': 5.1, 'sepal_width': 3.5, 'petal_length': 1.4,
'petal_width': 0.2, 'species': 'setosa'},
{'sepal_length': 5.7, 'sepal_width': 2.8, 'petal_length': 4.1,
'petal_width': 1.3, 'species': 'versicolor'},
{'sepal_length': 6.3, 'sepal_width': 2.9, 'petal_length': 5.6,
'petal_width': 1.8, 'species': 'virginica'},
{'sepal_length': 6.4, 'sepal_width': 3.2, 'petal_length': 4.5,
'petal_width': 1.5, 'species': 'versicolor'}]
# str: DATA converted to CSV format
result = ...
|
load("@rules_python//python:defs.bzl", "py_test")
pycoverage_requirements = [
"//tools/pycoverage",
]
def pycoverage(name, deps):
if not name or not deps:
fail("Arguments 'name' and 'deps' are required")
py_test(
name = name,
main = "pycoverage_runner.py",
srcs = ["//tools/pycoverage:pycoverage_runner"],
imports = ["."],
args = deps,
deps = depset(direct = deps + pycoverage_requirements).to_list(),
)
|
filename = "test2.txt"
tree = [None]*16
with open(filename) as f:
line = f.readline().strip().strip('[]')
for c in line:
if c == ',':
continue
for line in f:
n = line.strip().strip('[]')
print(n)
|
class Solution:
def searchMatrix(self, matrix, target):
i, j, r = 0, len(matrix[0]) - 1, len(matrix)
while i < r and j >= 0:
if matrix[i][j] == target:
return True
elif matrix[i][j] > target:
j -= 1
elif matrix[i][j] < target:
i += 1
return False
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.