content
stringlengths 7
1.05M
| fixed_cases
stringlengths 1
1.28M
|
---|---|
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
class Solution(object):
def deleteDuplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
# Runtime: 32 ms
# Memory: 13.4 MB
if head is None:
return None
cur = head
while cur.next is not None:
if cur.next.val == cur.val:
# Find next node
ptr = cur.next.next
while ptr is not None:
if ptr.val != cur.val:
break
ptr = ptr.next
cur.next = ptr
cur = cur.next
if cur is None:
break
return head
|
class Solution(object):
def delete_duplicates(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if head is None:
return None
cur = head
while cur.next is not None:
if cur.next.val == cur.val:
ptr = cur.next.next
while ptr is not None:
if ptr.val != cur.val:
break
ptr = ptr.next
cur.next = ptr
cur = cur.next
if cur is None:
break
return head
|
print ("hola mundo/jhon")
a=45
b=5
print("Suma:",a+b)
print("Resta:",a-b)
print("Division:",a/b)
print("Multiplicacion:",a*b)
|
print('hola mundo/jhon')
a = 45
b = 5
print('Suma:', a + b)
print('Resta:', a - b)
print('Division:', a / b)
print('Multiplicacion:', a * b)
|
class Interfaces:
def __init__(self, interface: dict):
self.screen = interface['screen']
self.account_linking = interface['account_linking']
class MetaData:
def __init__(self, meta: dict):
self.locale = meta['locale']
self.timezone = meta['timezone']
self.interfaces = Interfaces(interface=meta['interfaces'])
class User:
def __init__(self, user: dict):
self.user_id = user['user_id']
self.access_token = user.get('access_token')
class Application:
def __init__(self, application: dict):
self.application_id = application['application_id']
class SessionData:
def __init__(self, session: dict):
self.session_id = session['session_id']
self.message_id = session['message_id']
self.skill_id = session['skill_id']
self.user = User(user=session['user'])
self.application = Application(application=session['application'])
self.new = session['new']
class Markup:
def __init__(self, markup: dict):
self.dangerous_context = markup['dangerous_context']
class Entity:
def __init__(self, entity: dict):
self.start = entity['tokens']['start']
self.end = entity['tokens']['end']
self.type = entity['type']
self.value = entity['value']
class Entities:
def __init__(self, entities: list):
self.datetime = None
self.fio = None
self.geo = None
self.number = None
for entity in entities:
if entity['type'] == 'YANDEX.DATETIME':
self.datetime = Entity(entity=entity)
elif entity['type'] == 'YANDEX.FIO':
self.fio = Entity(entity=entity)
elif entity['type'] == 'YANDEX.GEO':
self.geo = Entity(entity=entity)
elif entity['type'] == 'YANDEX.NUMBER':
self.number = Entity(entity=entity)
class NLU:
def __init__(self, nlu: dict):
self.tokens = nlu['tokens']
self.entities = Entities(entities=nlu['entities'])
class RequestData:
def __init__(self, request_json: dict):
self.command = request_json['command']
self.original_utterance = request_json['original_utterance']
self.type = request_json['type']
self.markup = Markup(markup=request_json['markup'])
self.payload = request_json.get('payload')
self.nlu = NLU(nlu=request_json['nlu'])
class StateValue:
def __init__(self, session: dict):
self.value = session.get('value') if session.get('value') is not None else None
class State:
def __init__(self, state: dict):
self.session = StateValue(session=state.get('session'))
self.user = StateValue(session=state.get('user'))
class Message:
def __init__(self, json: dict):
self.meta = MetaData(json['meta'])
self.session = SessionData(json['session'])
self.version = json['version']
self.request = RequestData(request_json=json['request'])
self.state = State(state=json.get('state'))
self.original_request = json
|
class Interfaces:
def __init__(self, interface: dict):
self.screen = interface['screen']
self.account_linking = interface['account_linking']
class Metadata:
def __init__(self, meta: dict):
self.locale = meta['locale']
self.timezone = meta['timezone']
self.interfaces = interfaces(interface=meta['interfaces'])
class User:
def __init__(self, user: dict):
self.user_id = user['user_id']
self.access_token = user.get('access_token')
class Application:
def __init__(self, application: dict):
self.application_id = application['application_id']
class Sessiondata:
def __init__(self, session: dict):
self.session_id = session['session_id']
self.message_id = session['message_id']
self.skill_id = session['skill_id']
self.user = user(user=session['user'])
self.application = application(application=session['application'])
self.new = session['new']
class Markup:
def __init__(self, markup: dict):
self.dangerous_context = markup['dangerous_context']
class Entity:
def __init__(self, entity: dict):
self.start = entity['tokens']['start']
self.end = entity['tokens']['end']
self.type = entity['type']
self.value = entity['value']
class Entities:
def __init__(self, entities: list):
self.datetime = None
self.fio = None
self.geo = None
self.number = None
for entity in entities:
if entity['type'] == 'YANDEX.DATETIME':
self.datetime = entity(entity=entity)
elif entity['type'] == 'YANDEX.FIO':
self.fio = entity(entity=entity)
elif entity['type'] == 'YANDEX.GEO':
self.geo = entity(entity=entity)
elif entity['type'] == 'YANDEX.NUMBER':
self.number = entity(entity=entity)
class Nlu:
def __init__(self, nlu: dict):
self.tokens = nlu['tokens']
self.entities = entities(entities=nlu['entities'])
class Requestdata:
def __init__(self, request_json: dict):
self.command = request_json['command']
self.original_utterance = request_json['original_utterance']
self.type = request_json['type']
self.markup = markup(markup=request_json['markup'])
self.payload = request_json.get('payload')
self.nlu = nlu(nlu=request_json['nlu'])
class Statevalue:
def __init__(self, session: dict):
self.value = session.get('value') if session.get('value') is not None else None
class State:
def __init__(self, state: dict):
self.session = state_value(session=state.get('session'))
self.user = state_value(session=state.get('user'))
class Message:
def __init__(self, json: dict):
self.meta = meta_data(json['meta'])
self.session = session_data(json['session'])
self.version = json['version']
self.request = request_data(request_json=json['request'])
self.state = state(state=json.get('state'))
self.original_request = json
|
#!/usr/bin/env python3
# https://codeforces.com/problemset/problem/4/A
n = int(input())
print('YES' if (n>2 and n%2==0) else 'NO')
|
n = int(input())
print('YES' if n > 2 and n % 2 == 0 else 'NO')
|
class Submissions:
def __init__(self, client):
self.client = client
def list(self, groupId, assignmentId):
url = self.client.api_url + '/groups/' + groupId + '/assignments/' + assignmentId + '/submissions'
method = 'get'
return self.client.api_handler(url=url, method=method)
def get(self, submissionId):
url = self.client.api_url + '/submissions/' + submissionId
method = 'get'
return self.client.api_handler(url=url, method=method)
|
class Submissions:
def __init__(self, client):
self.client = client
def list(self, groupId, assignmentId):
url = self.client.api_url + '/groups/' + groupId + '/assignments/' + assignmentId + '/submissions'
method = 'get'
return self.client.api_handler(url=url, method=method)
def get(self, submissionId):
url = self.client.api_url + '/submissions/' + submissionId
method = 'get'
return self.client.api_handler(url=url, method=method)
|
class NQ:
def __init__(self, size):
self.n = size
self.board = self.generateBoard()
def solve(self):
if self.__util(0) == False:
print("Solution does not exist")
self.printBoard()
def __util(self, col):
if col >= self.n:
return False
for row in range(self.n):
if self.__isSafe(row, col):
self.board[row][col] = 1
if self.__util(col + 1) == True:
return True
self.board[row][col] = 0
def __isSafe(self, row, col):
for i in range(col):
if self.board[row][i] == 1:
return False
for i, j in zip(range(row, -1, -1), range(col, -1, -1)):
if self.board[i][j] == 1:
return False
return True
def generateBoard(self):
temp_board = []
for i in range(self.n):
temp = []
for j in range(self.n):
temp.append(0)
temp_board.append(temp)
return temp_board
def printBoard(self):
for i in range(self.n):
for j in range(self.n):
print(self.board[i][j], end=" ")
print()
def main():
Nqueen = NQ(4)
Nqueen.solve()
Nqueen.printBoard()
if __name__ == "__main__":
main()
|
class Nq:
def __init__(self, size):
self.n = size
self.board = self.generateBoard()
def solve(self):
if self.__util(0) == False:
print('Solution does not exist')
self.printBoard()
def __util(self, col):
if col >= self.n:
return False
for row in range(self.n):
if self.__isSafe(row, col):
self.board[row][col] = 1
if self.__util(col + 1) == True:
return True
self.board[row][col] = 0
def __is_safe(self, row, col):
for i in range(col):
if self.board[row][i] == 1:
return False
for (i, j) in zip(range(row, -1, -1), range(col, -1, -1)):
if self.board[i][j] == 1:
return False
return True
def generate_board(self):
temp_board = []
for i in range(self.n):
temp = []
for j in range(self.n):
temp.append(0)
temp_board.append(temp)
return temp_board
def print_board(self):
for i in range(self.n):
for j in range(self.n):
print(self.board[i][j], end=' ')
print()
def main():
nqueen = nq(4)
Nqueen.solve()
Nqueen.printBoard()
if __name__ == '__main__':
main()
|
# %% [139. Word Break](https://leetcode.com/problems/word-break/)
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:
@functools.lru_cache(None)
def check(s):
if not s:
return True
for word in wordDict:
if s.startswith(word) and check(s[len(word) :]):
return True
return False
return check(s)
|
class Solution:
def word_break(self, s: str, wordDict: List[str]) -> bool:
@functools.lru_cache(None)
def check(s):
if not s:
return True
for word in wordDict:
if s.startswith(word) and check(s[len(word):]):
return True
return False
return check(s)
|
def wrapper(f):
def fun(l):
decorated_numbers = []
for number in l:
decorated_numbers.append("+91 " + number[-10:-5] + " " + number[-5:])
return f(decorated_numbers)
return fun
@wrapper
def sort_phone(l):
print(*sorted(l), sep='\n')
if __name__ == '__main__':
l = [input() for _ in range(int(input()))]
sort_phone(l)
|
def wrapper(f):
def fun(l):
decorated_numbers = []
for number in l:
decorated_numbers.append('+91 ' + number[-10:-5] + ' ' + number[-5:])
return f(decorated_numbers)
return fun
@wrapper
def sort_phone(l):
print(*sorted(l), sep='\n')
if __name__ == '__main__':
l = [input() for _ in range(int(input()))]
sort_phone(l)
|
def reverse_text(string):
return (x for x in string[::-1])
# for x in string[::-1]:
# yield x
# idx = len(string) - 1
# while idx >= 0:
# yield string[idx]
# idx -= 1
for char in reverse_text("step"):
print(char, end='')
|
def reverse_text(string):
return (x for x in string[::-1])
for char in reverse_text('step'):
print(char, end='')
|
class Ticket:
def __init__(self, payload, yt_api, gh_api, users_dict):
self.payload = payload
self.action = payload["action"]
self.yt_api = yt_api
self.gh_api = gh_api
self.users_dict = users_dict
self.pr = payload["pull_request"]
self.url = self.pr["html_url"]
self.branch_name = self.pr["head"]["ref"]
self.issue_id = yt_api.get_issue_id(self.branch_name)
def exists(self):
if self.issue_id is None:
print("No YouTrack issue associated with branch {}".format(
self.branch_name))
return False
return True
def update(self):
if self.action == "review_requested":
reviewer = self.pr["requested_reviewers"][0]["login"]
return self.__submit(reviewer)
if self.action == "closed":
return self.__close()
if self.action == "submitted":
review = self.payload["review"]
author = self.pr["user"]["login"]
if review["state"] == "approved":
url = self.pr["url"] + "/reviews"
reviewer = self.payload["review"]["user"]["login"]
payload = self.gh_api.get(url)
remaining_reviews = \
[p for p in payload if p["state"] != "APPROVED"
and not has_approved(payload, p["user"]["login"])
and p["user"]["login"] != reviewer
and p["user"]["login"] != author]
if len(remaining_reviews) > 0:
next_reviewer = remaining_reviews[0]["user"]["login"]
return self.__submit(next_reviewer)
return '', 200
author = self.pr["user"]["login"]
if author == review["user"]["login"]:
# ignore author reviewing their own code
return '', 200
return self.__reopen(author, review)
return '', 200
def __reopen(self, author, review):
assignee = self.users_dict[author]
review_url = review["html_url"]
print("Reopening ticket {} and assigning user {}".format(self.issue_id,
assignee))
commands = [self.yt_api.set_state("Reopened"),
self.yt_api.assign(assignee)]
print(review_url, self.issue_id, commands)
success, response = self.yt_api.update_ticket(self.issue_id,
commands=commands,
comment=review_url)
if not success:
return response.text, response.status_code
return '', 200
def __close(self):
if self.pr["merged"] is False:
return '', 200
print(("Closing ticket {} and unassigning".format(self.issue_id)))
commands = [self.yt_api.set_state("Ready to deploy"),
self.yt_api.assign("Unassigned")]
success, response = self.yt_api.update_ticket(self.issue_id,
commands=commands)
if not success:
return response.text, response.status_code
return '', 200
def __submit(self, reviewer):
assignee = self.users_dict[reviewer]
print(
"Submitting ticket {} and assigning user {}".format(self.issue_id,
assignee))
commands = [self.yt_api.set_state("Submitted"),
self.yt_api.assign(assignee)]
success, response = self.yt_api.update_ticket(self.issue_id,
commands=commands,
comment=self.url)
if not success:
return response.text, response.status_code
return '', 200
def has_approved(payload, username):
return len([p for p in payload if
p["state"] == "APPROVED" and p["user"]["login"] == username]) > 0
|
class Ticket:
def __init__(self, payload, yt_api, gh_api, users_dict):
self.payload = payload
self.action = payload['action']
self.yt_api = yt_api
self.gh_api = gh_api
self.users_dict = users_dict
self.pr = payload['pull_request']
self.url = self.pr['html_url']
self.branch_name = self.pr['head']['ref']
self.issue_id = yt_api.get_issue_id(self.branch_name)
def exists(self):
if self.issue_id is None:
print('No YouTrack issue associated with branch {}'.format(self.branch_name))
return False
return True
def update(self):
if self.action == 'review_requested':
reviewer = self.pr['requested_reviewers'][0]['login']
return self.__submit(reviewer)
if self.action == 'closed':
return self.__close()
if self.action == 'submitted':
review = self.payload['review']
author = self.pr['user']['login']
if review['state'] == 'approved':
url = self.pr['url'] + '/reviews'
reviewer = self.payload['review']['user']['login']
payload = self.gh_api.get(url)
remaining_reviews = [p for p in payload if p['state'] != 'APPROVED' and (not has_approved(payload, p['user']['login'])) and (p['user']['login'] != reviewer) and (p['user']['login'] != author)]
if len(remaining_reviews) > 0:
next_reviewer = remaining_reviews[0]['user']['login']
return self.__submit(next_reviewer)
return ('', 200)
author = self.pr['user']['login']
if author == review['user']['login']:
return ('', 200)
return self.__reopen(author, review)
return ('', 200)
def __reopen(self, author, review):
assignee = self.users_dict[author]
review_url = review['html_url']
print('Reopening ticket {} and assigning user {}'.format(self.issue_id, assignee))
commands = [self.yt_api.set_state('Reopened'), self.yt_api.assign(assignee)]
print(review_url, self.issue_id, commands)
(success, response) = self.yt_api.update_ticket(self.issue_id, commands=commands, comment=review_url)
if not success:
return (response.text, response.status_code)
return ('', 200)
def __close(self):
if self.pr['merged'] is False:
return ('', 200)
print('Closing ticket {} and unassigning'.format(self.issue_id))
commands = [self.yt_api.set_state('Ready to deploy'), self.yt_api.assign('Unassigned')]
(success, response) = self.yt_api.update_ticket(self.issue_id, commands=commands)
if not success:
return (response.text, response.status_code)
return ('', 200)
def __submit(self, reviewer):
assignee = self.users_dict[reviewer]
print('Submitting ticket {} and assigning user {}'.format(self.issue_id, assignee))
commands = [self.yt_api.set_state('Submitted'), self.yt_api.assign(assignee)]
(success, response) = self.yt_api.update_ticket(self.issue_id, commands=commands, comment=self.url)
if not success:
return (response.text, response.status_code)
return ('', 200)
def has_approved(payload, username):
return len([p for p in payload if p['state'] == 'APPROVED' and p['user']['login'] == username]) > 0
|
MULTI_SIGNAL_CSV_DATA = """
symbol,date,signal
ibm,1/1/06,1
ibm,2/1/06,0
ibm,3/1/06,0
ibm,4/1/06,0
ibm,5/1/06,1
ibm,6/1/06,1
ibm,7/1/06,1
ibm,8/1/06,1
ibm,9/1/06,0
ibm,10/1/06,1
ibm,11/1/06,1
ibm,12/1/06,5
ibm,1/1/07,1
ibm,2/1/07,0
ibm,3/1/07,1
ibm,4/1/07,0
ibm,5/1/07,1
dell,1/1/06,1
dell,2/1/06,0
dell,3/1/06,0
dell,4/1/06,0
dell,5/1/06,1
dell,6/1/06,1
dell,7/1/06,1
dell,8/1/06,1
dell,9/1/06,0
dell,10/1/06,1
dell,11/1/06,1
dell,12/1/06,5
dell,1/1/07,1
dell,2/1/07,0
dell,3/1/07,1
dell,4/1/07,0
dell,5/1/07,1
""".strip()
AAPL_CSV_DATA = """
symbol,date,signal
aapl,1/1/06,1
aapl,2/1/06,0
aapl,3/1/06,0
aapl,4/1/06,0
aapl,5/1/06,1
aapl,6/1/06,1
aapl,7/1/06,1
aapl,8/1/06,1
aapl,9/1/06,0
aapl,10/1/06,1
aapl,11/1/06,1
aapl,12/1/06,5
aapl,1/1/07,1
aapl,2/1/07,0
aapl,3/1/07,1
aapl,4/1/07,0
aapl,5/1/07,1
""".strip()
# times are expected in UTC
AAPL_MINUTE_CSV_DATA = """
symbol,date,signal
aapl,1/4/06 5:31AM, 1
aapl,1/4/06 11:30AM, 2
aapl,1/5/06 5:31AM, 1
aapl,1/5/06 11:30AM, 3
aapl,1/9/06 5:31AM, 1
aapl,1/9/06 11:30AM, 4
""".strip()
AAPL_IBM_CSV_DATA = """
symbol,date,signal
aapl,1/1/06,1
aapl,2/1/06,0
aapl,3/1/06,0
aapl,4/1/06,0
aapl,5/1/06,1
aapl,6/1/06,1
aapl,7/1/06,1
aapl,8/1/06,1
aapl,9/1/06,0
aapl,10/1/06,1
aapl,11/1/06,1
aapl,12/1/06,5
aapl,1/1/07,1
aapl,2/1/07,0
aapl,3/1/07,1
aapl,4/1/07,0
aapl,5/1/07,1
ibm,1/1/06,1
ibm,2/1/06,0
ibm,3/1/06,0
ibm,4/1/06,0
ibm,5/1/06,1
ibm,6/1/06,1
ibm,7/1/06,1
ibm,8/1/06,1
ibm,9/1/06,0
ibm,10/1/06,1
ibm,11/1/06,1
ibm,12/1/06,5
ibm,1/1/07,1
ibm,2/1/07,0
ibm,3/1/07,1
ibm,4/1/07,0
ibm,5/1/07,1
""".strip()
CPIAUCSL_DATA = """
Date,Value
2007-12-01,211.445
2007-11-01,210.834
2007-10-01,209.19
2007-09-01,208.547
2007-08-01,207.667
2007-07-01,207.603
2007-06-01,207.234
2007-05-01,206.755
2007-04-01,205.904
2007-03-01,205.288
2007-02-01,204.226
2007-01-01,203.437
2006-12-01,203.1
2006-11-01,202.0
2006-10-01,201.9
2006-09-01,202.8
2006-08-01,203.8
2006-07-01,202.9
2006-06-01,201.8
2006-05-01,201.3
2006-04-01,200.7
2006-03-01,199.7
2006-02-01,199.4
2006-01-01,199.3
""".strip()
PALLADIUM_DATA = """
Date,Hong Kong 8:30,Hong Kong 14:00,London 08:00,New York 9:30,New York 15:00
2007-12-31,367.0,367.0,368.0,368.0,368.0
2007-12-28,366.0,366.0,365.0,368.0,368.0
2007-12-27,367.0,367.0,366.0,363.0,367.0
2007-12-26,,,,365.0,365.0
2007-12-24,351.0,357.0,357.0,357.0,365.0
2007-12-21,356.0,356.0,354.0,357.0,357.0
2007-12-20,357.0,356.0,354.0,356.0,356.0
2007-12-19,359.0,359.0,359.0,356.0,358.0
2007-12-18,357.0,356.0,356.0,359.0,359.0
2007-12-17,353.0,353.0,351.0,354.0,360.0
2007-12-14,347.0,347.0,347.0,347.0,355.0
2007-12-13,349.0,349.0,349.0,349.0,347.0
2007-12-12,348.0,349.0,349.0,351.0,349.0
2007-12-11,346.0,346.0,346.0,348.0,350.0
2007-12-10,346.0,346.0,346.0,348.0,348.0
2007-12-07,348.0,348.0,348.0,346.0,346.0
2007-12-06,350.0,350.0,352.0,348.0,348.0
2007-12-05,350.0,350.0,352.0,351.0,351.0
2007-12-04,349.0,349.0,352.0,351.0,351.0
2007-12-03,350.0,350.0,354.0,350.0,350.0
2007-11-30,345.0,345.0,347.0,353.0,350.0
2007-11-29,348.0,348.0,348.0,347.0,345.0
2007-11-28,350.0,347.0,347.0,348.0,348.0
2007-11-27,356.0,356.0,358.0,354.0,350.0
2007-11-26,357.0,357.0,360.0,360.0,360.0
2007-11-23,353.0,354.0,357.0,355.0,
2007-11-22,359.0,359.0,359.0,358.0,
2007-11-21,364.0,364.0,366.0,365.0,359.0
2007-11-20,360.0,359.0,362.0,364.0,364.0
2007-11-19,366.0,365.0,365.0,365.0,361.0
2007-11-16,368.0,366.0,368.0,369.0,366.0
2007-11-15,373.0,372.0,372.0,368.0,368.0
2007-11-14,372.0,372.0,372.0,373.0,373.0
2007-11-13,365.0,365.0,368.0,372.0,372.0
2007-11-12,373.0,370.0,370.0,366.0,366.0
2007-11-09,376.0,375.0,373.0,373.0,373.0
2007-11-08,376.0,376.0,373.0,376.0,376.0
2007-11-07,379.0,379.0,383.0,378.0,378.0
2007-11-06,374.0,374.0,374.0,379.0,379.0
2007-11-05,376.0,376.0,376.0,376.0,374.0
2007-11-02,372.0,371.0,371.0,371.0,376.0
2007-11-01,374.0,374.0,374.0,374.0,374.0
2007-10-31,369.0,369.0,371.0,372.0,372.0
2007-10-30,373.0,372.0,373.0,371.0,371.0
2007-10-29,373.0,375.0,375.0,376.0,373.0
2007-10-26,364.0,368.0,370.0,373.0,373.0
2007-10-25,360.0,360.0,360.0,364.0,368.0
2007-10-24,364.0,364.0,364.0,360.0,360.0
2007-10-23,361.0,361.0,364.0,366.0,366.0
2007-10-22,367.0,362.0,361.0,361.0,361.0
2007-10-19,,,374.0,372.0,370.0
2007-10-18,373.0,373.0,374.0,373.0,373.0
2007-10-17,372.0,372.0,370.0,373.0,373.0
2007-10-16,375.0,375.0,375.0,372.0,372.0
2007-10-15,379.0,379.0,380.0,382.0,375.0
2007-10-12,378.0,378.0,378.0,379.0,379.0
2007-10-11,375.0,375.0,376.0,381.0,384.0
2007-10-10,365.0,365.0,367.0,377.0,377.0
2007-10-09,365.0,363.0,362.0,362.0,365.0
2007-10-08,369.0,369.0,367.0,366.0,365.0
2007-10-05,369.0,369.0,371.0,369.0,369.0
2007-10-04,359.0,359.0,360.0,362.0,369.0
2007-10-03,352.0,350.0,352.0,352.0,359.0
2007-10-02,358.0,357.0,356.0,352.0,352.0
2007-10-01,,,349.0,355.0,360.0
2007-09-28,345.0,345.0,345.0,346.0,348.0
2007-09-27,342.0,342.0,342.0,343.0,345.0
2007-09-26,,,341.0,340.0,343.0
2007-09-25,342.0,341.0,343.0,341.0,341.0
2007-09-24,340.0,340.0,342.0,342.0,342.0
2007-09-21,341.0,341.0,342.0,342.0,340.0
2007-09-20,335.0,335.0,335.0,338.0,341.0
2007-09-19,333.0,333.0,335.0,335.0,335.0
2007-09-18,333.0,333.0,334.0,333.0,333.0
2007-09-17,331.0,331.0,331.0,333.0,333.0
2007-09-14,334.0,333.0,333.0,333.0,331.0
2007-09-13,336.0,336.0,336.0,334.0,334.0
2007-09-12,336.0,336.0,336.0,336.0,336.0
2007-09-11,333.0,335.0,335.0,336.0,336.0
2007-09-10,337.0,337.0,337.0,336.0,333.0
2007-09-07,336.0,336.0,338.0,337.0,337.0
2007-09-06,333.0,333.0,336.0,336.0,336.0
2007-09-05,334.0,334.0,334.0,336.0,333.0
2007-09-04,333.0,333.0,334.0,334.0,334.0
2007-09-03,334.0,334.0,335.0,334.0,
2007-08-31,331.0,333.0,334.0,333.0,333.0
2007-08-30,331.0,331.0,332.0,331.0,331.0
2007-08-29,329.0,327.0,329.0,329.0,331.0
2007-08-28,331.0,331.0,334.0,331.0,331.0
2007-08-27,330.0,331.0,331.0,331.0,331.0
2007-08-24,326.0,326.0,327.0,325.0,330.0
2007-08-23,322.0,322.0,326.0,330.0,326.0
2007-08-22,321.0,319.0,319.0,322.0,322.0
2007-08-21,331.0,331.0,329.0,328.0,325.0
2007-08-20,331.0,331.0,331.0,331.0,331.0
2007-08-17,334.0,334.0,334.0,335.0,331.0
2007-08-16,348.0,346.0,345.0,338.0,329.0
2007-08-15,354.0,354.0,352.0,348.0,348.0
2007-08-14,357.0,357.0,356.0,351.0,354.0
2007-08-13,355.0,355.0,354.0,356.0,358.0
2007-08-10,361.0,357.0,357.0,350.0,358.0
2007-08-09,364.0,364.0,364.0,361.0,361.0
2007-08-08,362.0,362.0,362.0,364.0,364.0
2007-08-07,365.0,365.0,363.0,360.0,363.0
2007-08-06,365.0,365.0,365.0,365.0,365.0
2007-08-03,366.0,366.0,365.0,365.0,367.0
2007-08-02,365.0,365.0,365.0,368.0,366.0
2007-08-01,367.0,366.0,366.0,365.0,367.0
2007-07-31,367.0,367.0,365.0,367.0,367.0
2007-07-30,363.0,362.0,361.0,365.0,367.0
2007-07-27,365.0,365.0,364.0,363.0,363.0
2007-07-26,366.0,366.0,365.0,365.0,365.0
2007-07-25,368.0,368.0,368.0,366.0,366.0
2007-07-24,372.0,372.0,372.0,370.0,368.0
2007-07-23,372.0,372.0,372.0,372.0,372.0
2007-07-20,372.0,372.0,372.0,372.0,372.0
2007-07-19,370.0,369.0,369.0,370.0,372.0
2007-07-18,368.0,368.0,367.0,367.0,370.0
2007-07-17,368.0,368.0,368.0,368.0,365.0
2007-07-16,369.0,369.0,368.0,368.0,368.0
2007-07-13,370.0,370.0,370.0,369.0,369.0
2007-07-12,369.0,369.0,368.0,370.0,370.0
2007-07-11,369.0,369.0,369.0,369.0,369.0
2007-07-10,369.0,369.0,369.0,369.0,367.0
2007-07-09,367.0,367.0,366.0,370.0,369.0
2007-07-06,366.0,366.0,365.0,365.0,367.0
2007-07-05,366.0,366.0,366.0,367.0,366.0
2007-07-04,366.0,368.0,368.0,366.0,
2007-07-03,368.0,370.0,370.0,368.0,366.0
2007-07-02,,,369.0,368.0,368.0
2007-06-29,368.0,368.0,368.0,368.0,368.0
2007-06-28,367.0,367.0,368.0,368.0,368.0
2007-06-27,366.0,366.0,366.0,368.0,364.0
2007-06-26,372.0,372.0,370.0,368.0,366.0
2007-06-25,377.0,377.0,376.0,373.0,372.0
2007-06-22,376.0,376.0,375.0,377.0,377.0
2007-06-21,375.0,375.0,374.0,376.0,376.0
2007-06-20,373.0,373.0,371.0,375.0,377.0
2007-06-19,,,372.0,371.0,371.0
2007-06-18,370.0,371.0,373.0,373.0,373.0
2007-06-15,370.0,369.0,369.0,369.0,372.0
2007-06-14,367.0,367.0,369.0,369.0,369.0
2007-06-13,369.0,369.0,367.0,365.0,369.0
2007-06-12,368.0,368.0,371.0,369.0,369.0
2007-06-11,367.0,367.0,367.0,368.0,368.0
2007-06-08,369.0,368.0,368.0,371.0,369.0
2007-06-07,370.0,370.0,370.0,369.0,371.0
2007-06-06,370.0,370.0,370.0,368.0,368.0
2007-06-05,372.0,372.0,372.0,372.0,368.0
2007-06-04,376.0,374.0,374.0,372.0,372.0
2007-06-01,370.0,370.0,370.0,373.0,373.0
2007-05-31,368.0,368.0,368.0,370.0,370.0
2007-05-30,370.0,369.0,369.0,367.0,367.0
2007-05-29,370.0,369.0,369.0,371.0,368.0
2007-05-28,368.0,368.0,368.0,,
2007-05-25,368.0,368.0,368.0,367.0,367.0
2007-05-24,,,376.0,376.0,368.0
2007-05-23,375.0,375.0,378.0,376.0,376.0
2007-05-22,374.0,374.0,374.0,378.0,378.0
2007-05-21,364.0,364.0,365.0,368.0,374.0
2007-05-18,362.0,361.0,361.0,364.0,364.0
2007-05-17,359.0,359.0,359.0,359.0,362.0
2007-05-16,363.0,363.0,362.0,362.0,359.0
2007-05-15,362.0,362.0,362.0,358.0,362.0
2007-05-14,368.0,368.0,368.0,364.0,362.0
2007-05-11,361.0,363.0,362.0,364.0,367.0
2007-05-10,370.0,370.0,366.0,363.0,363.0
2007-05-09,376.0,376.0,373.0,372.0,370.0
2007-05-08,378.0,378.0,378.0,376.0,376.0
2007-05-07,378.0,378.0,381.0,381.0,381.0
2007-05-04,376.0,374.0,374.0,376.0,376.0
2007-05-03,373.0,373.0,373.0,376.0,376.0
2007-05-02,373.0,373.0,373.0,372.0,375.0
2007-05-01,,,371.0,369.0,374.0
2007-04-30,373.0,373.0,373.0,373.0,373.0
2007-04-27,373.0,372.0,372.0,374.0,374.0
2007-04-26,380.0,380.0,380.0,376.0,373.0
2007-04-25,377.0,377.0,377.0,380.0,380.0
2007-04-24,384.0,384.0,384.0,383.0,379.0
2007-04-23,386.0,386.0,386.0,382.0,386.0
2007-04-20,378.0,378.0,378.0,385.0,387.0
2007-04-19,383.0,382.0,377.0,377.0,377.0
2007-04-18,377.0,377.0,378.0,377.0,382.0
2007-04-17,376.0,376.0,376.0,376.0,379.0
2007-04-16,380.0,381.0,381.0,376.0,376.0
2007-04-13,371.0,371.0,371.0,374.0,380.0
2007-04-12,367.0,367.0,369.0,371.0,371.0
2007-04-11,360.0,360.0,363.0,366.0,369.0
2007-04-10,358.0,358.0,360.0,360.0,360.0
2007-04-09,,,,355.0,355.0
2007-04-05,,,355.0,353.0,355.0
2007-04-04,354.0,354.0,353.0,355.0,355.0
2007-04-03,353.0,353.0,354.0,354.0,354.0
2007-04-02,355.0,355.0,355.0,353.0,355.0
2007-03-30,354.0,354.0,356.0,355.0,355.0
2007-03-29,355.0,356.0,356.0,355.0,355.0
2007-03-28,355.0,356.0,356.0,356.0,356.0
2007-03-27,355.0,355.0,357.0,355.0,355.0
2007-03-26,354.0,354.0,355.0,355.0,357.0
2007-03-23,355.0,355.0,355.0,355.0,358.0
2007-03-22,354.0,354.0,353.0,356.0,356.0
2007-03-21,352.0,352.0,352.0,352.0,350.0
2007-03-20,352.0,352.0,352.0,352.0,352.0
2007-03-19,352.0,352.0,352.0,352.0,352.0
2007-03-16,352.0,352.0,352.0,352.0,352.0
2007-03-15,349.0,349.0,349.0,352.0,352.0
2007-03-14,351.0,349.0,348.0,349.0,349.0
2007-03-13,352.0,352.0,352.0,351.0,351.0
2007-03-12,353.0,353.0,353.0,352.0,352.0
2007-03-09,353.0,351.0,353.0,353.0,353.0
2007-03-08,349.0,349.0,349.0,353.0,355.0
2007-03-07,349.0,348.0,348.0,348.0,348.0
2007-03-06,342.0,343.0,345.0,345.0,350.0
2007-03-05,344.0,342.0,340.0,340.0,345.0
2007-03-02,351.0,351.0,351.0,349.0,349.0
2007-03-01,351.0,354.0,352.0,355.0,351.0
2007-02-28,347.0,348.0,348.0,350.0,350.0
2007-02-27,357.0,356.0,356.0,351.0,356.0
2007-02-26,358.0,359.0,359.0,357.0,357.0
2007-02-23,347.0,348.0,348.0,355.0,360.0
2007-02-22,346.0,346.0,346.0,350.0,350.0
2007-02-21,339.0,339.0,340.0,339.0,346.0
2007-02-20,,,342.0,337.0,337.0
2007-02-19,,,343.0,342.0,342.0
2007-02-16,344.0,343.0,343.0,340.0,343.0
2007-02-15,345.0,343.0,343.0,344.0,344.0
2007-02-14,343.0,343.0,343.0,345.0,347.0
2007-02-13,340.0,339.0,339.0,339.0,343.0
2007-02-12,338.0,338.0,340.0,338.0,340.0
2007-02-09,343.0,343.0,343.0,338.0,342.0
2007-02-08,344.0,344.0,344.0,339.0,342.0
2007-02-07,344.0,346.0,345.0,346.0,346.0
2007-02-06,340.0,340.0,342.0,344.0,344.0
2007-02-05,337.0,336.0,336.0,340.0,343.0
2007-02-02,344.0,344.0,343.0,341.0,341.0
2007-02-01,341.0,341.0,341.0,344.0,344.0
2007-01-31,341.0,340.0,340.0,334.0,341.0
2007-01-30,343.0,341.0,343.0,336.0,342.0
2007-01-29,349.0,349.0,350.0,342.0,346.0
2007-01-26,353.0,352.0,351.0,351.0,351.0
2007-01-25,350.0,350.0,350.0,353.0,353.0
2007-01-24,351.0,350.0,350.0,348.0,348.0
2007-01-23,345.0,345.0,347.0,350.0,350.0
2007-01-22,343.0,343.0,343.0,344.0,347.0
2007-01-19,340.0,340.0,341.0,341.0,344.0
2007-01-18,340.0,342.0,342.0,342.0,342.0
2007-01-17,335.0,335.0,333.0,334.0,343.0
2007-01-16,332.0,332.0,332.0,334.0,337.0
2007-01-15,334.0,336.0,335.0,332.0,332.0
2007-01-12,331.0,331.0,331.0,331.0,335.0
2007-01-11,331.0,331.0,331.0,333.0,333.0
2007-01-10,333.0,333.0,334.0,331.0,331.0
2007-01-09,333.0,333.0,336.0,329.0,329.0
2007-01-08,335.0,335.0,335.0,333.0,333.0
2007-01-05,340.0,340.0,340.0,342.0,336.0
2007-01-04,337.0,337.0,337.0,340.0,343.0
2007-01-03,338.0,336.0,336.0,342.0,342.0
2007-01-02,337.0,337.0,334.0,336.0,336.0
2006-12-29,327.0,327.0,327.0,327.0,337.0
2006-12-28,326.0,326.0,328.0,327.0,326.0
2006-12-27,326.0,328.0,328.0,328.0,326.0
2006-12-26,,,,327.0,327.0
2006-12-22,325.0,325.0,327.0,327.0,327.0
2006-12-21,326.0,326.0,327.0,325.0,325.0
2006-12-20,328.0,328.0,328.0,326.0,326.0
2006-12-19,324.0,324.0,325.0,322.0,326.0
2006-12-18,325.0,325.0,326.0,324.0,324.0
2006-12-15,330.0,329.0,329.0,327.0,325.0
2006-12-14,328.0,328.0,328.0,330.0,330.0
2006-12-13,329.0,329.0,330.0,328.0,328.0
2006-12-12,332.0,332.0,332.0,329.0,329.0
2006-12-11,329.0,329.0,329.0,329.0,329.0
2006-12-08,330.0,329.0,329.0,332.0,336.0
2006-12-07,328.0,326.0,326.0,328.0,328.0
2006-12-06,333.0,331.0,331.0,328.0,328.0
2006-12-05,330.0,330.0,329.0,333.0,333.0
2006-12-04,330.0,330.0,330.0,330.0,330.0
2006-12-01,330.0,330.0,330.0,328.0,328.0
2006-11-30,324.0,323.0,323.0,330.0,330.0
2006-11-29,326.0,326.0,328.0,321.0,321.0
2006-11-28,329.0,328.0,328.0,326.0,326.0
2006-11-27,330.0,329.0,329.0,329.0,329.0
2006-11-24,326.0,326.0,326.0,330.0,
2006-11-23,328.0,328.0,327.0,326.0,
2006-11-22,330.0,330.0,328.0,328.0,328.0
2006-11-21,323.0,327.0,327.0,330.0,330.0
2006-11-20,320.0,320.0,322.0,323.0,323.0
2006-11-17,321.0,321.0,321.0,318.0,320.0
2006-11-16,320.0,320.0,322.0,323.0,323.0
2006-11-15,321.0,321.0,321.0,317.0,320.0
2006-11-14,326.0,325.0,324.0,324.0,321.0
2006-11-13,333.0,333.0,333.0,326.0,326.0
2006-11-10,338.0,338.0,338.0,335.0,333.0
2006-11-09,329.0,329.0,328.0,331.0,338.0
2006-11-08,333.0,333.0,334.0,327.0,327.0
2006-11-07,334.0,332.0,332.0,335.0,335.0
2006-11-06,340.0,340.0,340.0,330.0,335.0
2006-11-03,326.0,326.0,325.0,330.0,333.0
2006-11-02,327.0,326.0,326.0,324.0,326.0
2006-11-01,323.0,323.0,324.0,326.0,326.0
2006-10-31,325.0,325.0,325.0,318.0,323.0
2006-10-30,,,325.0,325.0,325.0
2006-10-27,324.0,324.0,324.0,321.0,323.0
2006-10-26,325.0,324.0,324.0,323.0,326.0
2006-10-25,322.0,322.0,322.0,319.0,319.0
2006-10-24,319.0,318.0,318.0,320.0,323.0
2006-10-23,326.0,326.0,326.0,319.0,319.0
2006-10-20,337.0,337.0,334.0,329.0,329.0
2006-10-19,331.0,331.0,331.0,330.0,337.0
2006-10-18,320.0,320.0,320.0,326.0,334.0
2006-10-17,324.0,326.0,326.0,321.0,321.0
2006-10-16,318.0,321.0,320.0,324.0,324.0
2006-10-13,309.0,309.0,309.0,316.0,316.0
2006-10-12,305.0,308.0,308.0,310.0,310.0
2006-10-11,299.0,299.0,301.0,305.0,309.0
2006-10-10,304.0,308.0,308.0,299.0,299.0
2006-10-09,302.0,302.0,304.0,304.0,304.0
2006-10-06,301.0,301.0,301.0,297.0,297.0
2006-10-05,297.0,299.0,299.0,301.0,301.0
2006-10-04,300.0,298.0,298.0,302.0,297.0
2006-10-03,315.0,315.0,314.0,305.0,305.0
2006-10-02,,,322.0,315.0,315.0
2006-09-29,321.0,323.0,323.0,318.0,318.0
2006-09-28,320.0,323.0,323.0,323.0,323.0
2006-09-27,318.0,318.0,320.0,317.0,320.0
2006-09-26,318.0,318.0,319.0,318.0,318.0
2006-09-25,319.0,318.0,319.0,316.0,316.0
2006-09-22,310.0,310.0,313.0,325.0,322.0
2006-09-21,308.0,308.0,308.0,309.0,309.0
2006-09-20,307.0,307.0,308.0,311.0,311.0
2006-09-19,317.0,316.0,316.0,319.0,310.0
2006-09-18,313.0,313.0,313.0,306.0,312.0
2006-09-15,311.0,311.0,314.0,315.0,315.0
2006-09-14,317.0,317.0,317.0,332.0,326.0
2006-09-13,310.0,310.0,310.0,321.0,318.0
2006-09-12,311.0,323.0,322.0,320.0,314.0
2006-09-11,330.0,322.0,321.0,317.0,317.0
2006-09-08,347.0,345.0,345.0,323.0,330.0
2006-09-07,350.0,350.0,353.0,348.0,348.0
2006-09-06,351.0,351.0,351.0,351.0,356.0
2006-09-05,347.0,347.0,347.0,351.0,351.0
2006-09-04,346.0,346.0,347.0,346.0,
2006-09-01,348.0,345.0,346.0,346.0,346.0
2006-08-31,340.0,340.0,342.0,343.0,343.0
2006-08-30,339.0,341.0,340.0,339.0,340.0
2006-08-29,341.0,343.0,342.0,338.0,340.0
2006-08-28,345.0,345.0,345.0,345.0,345.0
2006-08-25,345.0,345.0,345.0,346.0,346.0
2006-08-24,345.0,345.0,347.0,348.0,348.0
2006-08-23,340.0,340.0,340.0,345.0,345.0
2006-08-22,347.0,347.0,346.0,340.0,340.0
2006-08-21,335.0,338.0,338.0,341.0,347.0
2006-08-18,332.0,334.0,333.0,335.0,335.0
2006-08-17,333.0,337.0,338.0,341.0,337.0
2006-08-16,326.0,325.0,324.0,334.0,337.0
2006-08-15,317.0,320.0,319.0,322.0,327.0
2006-08-14,320.0,320.0,320.0,314.0,319.0
2006-08-11,320.0,320.0,322.0,324.0,324.0
2006-08-10,326.0,326.0,327.0,326.0,324.0
2006-08-09,320.0,320.0,320.0,324.0,327.0
2006-08-08,327.0,325.0,324.0,320.0,320.0
2006-08-07,327.0,327.0,328.0,324.0,324.0
2006-08-04,324.0,324.0,324.0,327.0,327.0
2006-08-03,330.0,326.0,327.0,324.0,324.0
2006-08-02,319.0,319.0,322.0,325.0,330.0
2006-08-01,316.0,316.0,316.0,319.0,319.0
2006-07-31,315.0,315.0,317.0,313.0,316.0
2006-07-28,320.0,318.0,318.0,315.0,315.0
2006-07-27,315.0,315.0,318.0,320.0,320.0
2006-07-26,315.0,315.0,315.0,315.0,315.0
2006-07-25,314.0,314.0,315.0,314.0,317.0
2006-07-24,309.0,309.0,309.0,309.0,314.0
2006-07-21,308.0,311.0,310.0,310.0,310.0
2006-07-20,317.0,315.0,316.0,315.0,315.0
2006-07-19,308.0,308.0,311.0,311.0,318.0
2006-07-18,320.0,320.0,319.0,318.0,316.0
2006-07-17,333.0,333.0,333.0,321.0,321.0
2006-07-14,331.0,331.0,331.0,331.0,331.0
2006-07-13,330.0,328.0,328.0,331.0,331.0
2006-07-12,330.0,330.0,330.0,330.0,330.0
2006-07-11,318.0,320.0,323.0,326.0,330.0
2006-07-10,325.0,323.0,323.0,320.0,320.0
2006-07-07,329.0,329.0,329.0,327.0,327.0
2006-07-06,328.0,324.0,326.0,323.0,329.0
2006-07-05,328.0,328.0,330.0,328.0,328.0
2006-07-04,325.0,328.0,327.0,326.0,
2006-07-03,322.0,326.0,326.0,329.0,
2006-06-30,320.0,320.0,320.0,316.0,322.0
2006-06-29,309.0,309.0,307.0,314.0,314.0
2006-06-28,310.0,310.0,313.0,314.0,314.0
2006-06-27,318.0,320.0,320.0,318.0,318.0
2006-06-26,308.0,305.0,309.0,320.0,320.0
2006-06-23,310.0,304.0,305.0,306.0,310.0
2006-06-22,315.0,318.0,320.0,320.0,316.0
2006-06-21,303.0,306.0,308.0,311.0,315.0
2006-06-20,292.0,297.0,296.0,301.0,305.0
2006-06-19,307.0,304.0,303.0,302.0,297.0
2006-06-16,300.0,306.0,305.0,310.0,307.0
2006-06-15,290.0,290.0,292.0,300.0,300.0
2006-06-14,277.0,274.0,275.0,288.0,293.0
2006-06-13,313.0,308.0,307.0,286.0,277.0
2006-06-12,320.0,320.0,316.0,321.0,316.0
2006-06-09,317.0,313.0,313.0,327.0,327.0
2006-06-08,342.0,336.0,333.0,331.0,320.0
2006-06-07,348.0,346.0,346.0,335.0,343.0
2006-06-06,359.0,359.0,359.0,350.0,350.0
2006-06-05,356.0,356.0,358.0,363.0,363.0
2006-06-02,340.0,343.0,342.0,351.0,356.0
2006-06-01,347.0,345.0,345.0,340.0,340.0
2006-05-31,,,358.0,358.0,345.0
2006-05-30,352.0,350.0,355.0,359.0,358.0
2006-05-29,357.0,352.0,350.0,,
2006-05-26,355.0,353.0,354.0,354.0,354.0
2006-05-25,348.0,348.0,350.0,350.0,350.0
2006-05-24,358.0,362.0,365.0,352.0,352.0
2006-05-23,343.0,342.0,343.0,355.0,362.0
2006-05-22,350.0,345.0,345.0,340.0,340.0
2006-05-19,366.0,369.0,373.0,347.0,352.0
2006-05-18,372.0,375.0,376.0,380.0,375.0
2006-05-17,379.0,379.0,382.0,390.0,380.0
2006-05-16,368.0,370.0,366.0,379.0,379.0
2006-05-15,395.0,395.0,397.0,370.0,375.0
2006-05-12,400.0,396.0,398.0,407.0,399.0
2006-05-11,390.0,397.0,395.0,400.0,400.0
2006-05-10,394.0,397.0,398.0,390.0,390.0
2006-05-09,375.0,375.0,378.0,384.0,394.0
2006-05-08,380.0,380.0,381.0,377.0,375.0
2006-05-05,,,383.0,382.0,382.0
2006-05-04,379.0,379.0,378.0,379.0,379.0
2006-05-03,386.0,386.0,388.0,384.0,379.0
2006-05-02,377.0,377.0,380.0,380.0,384.0
2006-05-01,,,,380.0,380.0
2006-04-28,360.0,363.0,363.0,364.0,377.0
2006-04-27,368.0,365.0,367.0,364.0,364.0
2006-04-26,366.0,366.0,367.0,361.0,368.0
2006-04-25,356.0,355.0,355.0,362.0,362.0
2006-04-24,359.0,359.0,363.0,360.0,360.0
2006-04-21,344.0,348.0,347.0,352.0,359.0
2006-04-20,368.0,372.0,374.0,365.0,349.0
2006-04-19,366.0,364.0,364.0,371.0,374.0
2006-04-18,364.0,360.0,360.0,361.0,361.0
2006-04-17,,,,358.0,358.0
2006-04-13,347.0,342.0,341.0,346.0,349.0
2006-04-12,340.0,344.0,343.0,347.0,347.0
2006-04-11,359.0,359.0,360.0,359.0,345.0
2006-04-10,351.0,354.0,355.0,359.0,359.0
2006-04-07,352.0,352.0,354.0,351.0,351.0
2006-04-06,341.0,341.0,344.0,352.0,352.0
2006-04-05,,,336.0,341.0,341.0
2006-04-04,342.0,339.0,337.0,338.0,342.0
2006-04-03,332.0,337.0,338.0,341.0,345.0
2006-03-31,349.0,349.0,348.0,332.0,332.0
2006-03-30,338.0,341.0,343.0,349.0,349.0
2006-03-29,340.0,337.0,337.0,333.0,338.0
2006-03-28,340.0,344.0,345.0,340.0,340.0
2006-03-27,333.0,333.0,334.0,341.0,341.0
2006-03-24,321.0,321.0,320.0,326.0,333.0
2006-03-23,323.0,321.0,321.0,317.0,322.0
2006-03-22,317.0,318.0,322.0,320.0,324.0
2006-03-21,320.0,318.0,316.0,315.0,318.0
2006-03-20,318.0,318.0,319.0,317.0,317.0
2006-03-17,316.0,316.0,315.0,318.0,318.0
2006-03-16,315.0,314.0,314.0,316.0,316.0
2006-03-15,305.0,305.0,307.0,318.0,318.0
2006-03-14,300.0,300.0,300.0,302.0,306.0
2006-03-13,288.0,291.0,290.0,292.0,300.0
2006-03-10,289.0,289.0,289.0,288.0,288.0
2006-03-09,280.0,282.0,282.0,285.0,285.0
2006-03-08,291.0,289.0,289.0,285.0,282.0
2006-03-07,296.0,296.0,296.0,299.0,292.0
2006-03-06,307.0,304.0,302.0,302.0,297.0
2006-03-03,300.0,300.0,300.0,305.0,305.0
2006-03-02,297.0,297.0,296.0,294.0,300.0
2006-03-01,291.0,291.0,289.0,290.0,297.0
2006-02-28,284.0,284.0,285.0,288.0,291.0
2006-02-27,286.0,290.0,290.0,285.0,284.0
2006-02-24,283.0,285.0,286.0,286.0,286.0
2006-02-23,289.0,286.0,287.0,288.0,286.0
2006-02-22,293.0,293.0,293.0,292.0,289.0
2006-02-21,292.0,290.0,291.0,291.0,293.0
2006-02-20,292.0,292.0,292.0,292.0,292.0
2006-02-17,279.0,279.0,280.0,285.0,290.0
2006-02-16,276.0,276.0,278.0,275.0,279.0
2006-02-15,282.0,285.0,287.0,285.0,279.0
2006-02-14,273.0,270.0,274.0,278.0,282.0
2006-02-13,283.0,278.0,277.0,282.0,276.0
2006-02-10,304.0,298.0,297.0,296.0,285.0
2006-02-09,293.0,297.0,295.0,300.0,300.0
2006-02-08,288.0,288.0,287.0,290.0,290.0
2006-02-07,309.0,309.0,309.0,297.0,290.0
2006-02-06,317.0,317.0,320.0,305.0,312.0
2006-02-03,309.0,310.0,310.0,317.0,317.0
2006-02-02,294.0,296.0,295.0,300.0,305.0
2006-02-01,294.0,293.0,293.0,294.0,294.0
2006-01-31,,,282.0,293.0,295.0
2006-01-30,,,277.0,278.0,278.0
2006-01-27,275.0,275.0,276.0,275.0,275.0
2006-01-26,279.0,279.0,280.0,275.0,275.0
2006-01-25,275.0,275.0,275.0,279.0,279.0
2006-01-24,278.0,278.0,278.0,276.0,276.0
2006-01-23,276.0,278.0,277.0,278.0,278.0
2006-01-20,279.0,278.0,277.0,280.0,277.0
2006-01-19,273.0,275.0,275.0,273.0,277.0
2006-01-18,282.0,276.0,275.0,273.0,273.0
2006-01-17,289.0,286.0,286.0,281.0,283.0
2006-01-16,283.0,285.0,285.0,289.0,289.0
2006-01-13,273.0,273.0,273.0,275.0,281.0
2006-01-12,274.0,274.0,274.0,273.0,273.0
2006-01-11,274.0,274.0,274.0,271.0,274.0
2006-01-10,279.0,278.0,278.0,277.0,274.0
2006-01-09,272.0,272.0,274.0,275.0,278.0
2006-01-06,264.0,265.0,262.0,269.0,272.0
2006-01-05,274.0,274.0,272.0,263.0,263.0
2006-01-04,272.0,272.0,272.0,272.0,274.0
2006-01-03,260.0,262.0,262.0,267.0,267.0
""".strip()
FETCHER_UNIVERSE_DATA = """
date,symbol
1/9/2006,aapl
1/9/2006,ibm
1/9/2006,msft
1/11/2006,aapl
1/11/2006,ibm
1/11/2006,msft
1/11/2006,yhoo
""".strip()
NON_ASSET_FETCHER_UNIVERSE_DATA = """
date,symbol
1/9/2006,foobarbaz
1/9/2006,bazfoobar
1/9/2006,barbazfoo
1/11/2006,foobarbaz
1/11/2006,bazfoobar
1/11/2006,barbazfoo
1/11/2006,foobarbaz
""".strip()
FETCHER_ALTERNATE_COLUMN_HEADER = "ARGLEBARGLE"
FETCHER_UNIVERSE_DATA_TICKER_COLUMN = FETCHER_UNIVERSE_DATA.replace(
"symbol", FETCHER_ALTERNATE_COLUMN_HEADER)
|
multi_signal_csv_data = '\nsymbol,date,signal\nibm,1/1/06,1\nibm,2/1/06,0\nibm,3/1/06,0\nibm,4/1/06,0\nibm,5/1/06,1\nibm,6/1/06,1\nibm,7/1/06,1\nibm,8/1/06,1\nibm,9/1/06,0\nibm,10/1/06,1\nibm,11/1/06,1\nibm,12/1/06,5\nibm,1/1/07,1\nibm,2/1/07,0\nibm,3/1/07,1\nibm,4/1/07,0\nibm,5/1/07,1\ndell,1/1/06,1\ndell,2/1/06,0\ndell,3/1/06,0\ndell,4/1/06,0\ndell,5/1/06,1\ndell,6/1/06,1\ndell,7/1/06,1\ndell,8/1/06,1\ndell,9/1/06,0\ndell,10/1/06,1\ndell,11/1/06,1\ndell,12/1/06,5\ndell,1/1/07,1\ndell,2/1/07,0\ndell,3/1/07,1\ndell,4/1/07,0\ndell,5/1/07,1\n'.strip()
aapl_csv_data = '\nsymbol,date,signal\naapl,1/1/06,1\naapl,2/1/06,0\naapl,3/1/06,0\naapl,4/1/06,0\naapl,5/1/06,1\naapl,6/1/06,1\naapl,7/1/06,1\naapl,8/1/06,1\naapl,9/1/06,0\naapl,10/1/06,1\naapl,11/1/06,1\naapl,12/1/06,5\naapl,1/1/07,1\naapl,2/1/07,0\naapl,3/1/07,1\naapl,4/1/07,0\naapl,5/1/07,1\n'.strip()
aapl_minute_csv_data = '\nsymbol,date,signal\naapl,1/4/06 5:31AM, 1\naapl,1/4/06 11:30AM, 2\naapl,1/5/06 5:31AM, 1\naapl,1/5/06 11:30AM, 3\naapl,1/9/06 5:31AM, 1\naapl,1/9/06 11:30AM, 4\n'.strip()
aapl_ibm_csv_data = '\nsymbol,date,signal\naapl,1/1/06,1\naapl,2/1/06,0\naapl,3/1/06,0\naapl,4/1/06,0\naapl,5/1/06,1\naapl,6/1/06,1\naapl,7/1/06,1\naapl,8/1/06,1\naapl,9/1/06,0\naapl,10/1/06,1\naapl,11/1/06,1\naapl,12/1/06,5\naapl,1/1/07,1\naapl,2/1/07,0\naapl,3/1/07,1\naapl,4/1/07,0\naapl,5/1/07,1\nibm,1/1/06,1\nibm,2/1/06,0\nibm,3/1/06,0\nibm,4/1/06,0\nibm,5/1/06,1\nibm,6/1/06,1\nibm,7/1/06,1\nibm,8/1/06,1\nibm,9/1/06,0\nibm,10/1/06,1\nibm,11/1/06,1\nibm,12/1/06,5\nibm,1/1/07,1\nibm,2/1/07,0\nibm,3/1/07,1\nibm,4/1/07,0\nibm,5/1/07,1\n'.strip()
cpiaucsl_data = '\nDate,Value\n2007-12-01,211.445\n2007-11-01,210.834\n2007-10-01,209.19\n2007-09-01,208.547\n2007-08-01,207.667\n2007-07-01,207.603\n2007-06-01,207.234\n2007-05-01,206.755\n2007-04-01,205.904\n2007-03-01,205.288\n2007-02-01,204.226\n2007-01-01,203.437\n2006-12-01,203.1\n2006-11-01,202.0\n2006-10-01,201.9\n2006-09-01,202.8\n2006-08-01,203.8\n2006-07-01,202.9\n2006-06-01,201.8\n2006-05-01,201.3\n2006-04-01,200.7\n2006-03-01,199.7\n2006-02-01,199.4\n2006-01-01,199.3\n'.strip()
palladium_data = '\nDate,Hong Kong 8:30,Hong Kong 14:00,London 08:00,New York 9:30,New York 15:00\n2007-12-31,367.0,367.0,368.0,368.0,368.0\n2007-12-28,366.0,366.0,365.0,368.0,368.0\n2007-12-27,367.0,367.0,366.0,363.0,367.0\n2007-12-26,,,,365.0,365.0\n2007-12-24,351.0,357.0,357.0,357.0,365.0\n2007-12-21,356.0,356.0,354.0,357.0,357.0\n2007-12-20,357.0,356.0,354.0,356.0,356.0\n2007-12-19,359.0,359.0,359.0,356.0,358.0\n2007-12-18,357.0,356.0,356.0,359.0,359.0\n2007-12-17,353.0,353.0,351.0,354.0,360.0\n2007-12-14,347.0,347.0,347.0,347.0,355.0\n2007-12-13,349.0,349.0,349.0,349.0,347.0\n2007-12-12,348.0,349.0,349.0,351.0,349.0\n2007-12-11,346.0,346.0,346.0,348.0,350.0\n2007-12-10,346.0,346.0,346.0,348.0,348.0\n2007-12-07,348.0,348.0,348.0,346.0,346.0\n2007-12-06,350.0,350.0,352.0,348.0,348.0\n2007-12-05,350.0,350.0,352.0,351.0,351.0\n2007-12-04,349.0,349.0,352.0,351.0,351.0\n2007-12-03,350.0,350.0,354.0,350.0,350.0\n2007-11-30,345.0,345.0,347.0,353.0,350.0\n2007-11-29,348.0,348.0,348.0,347.0,345.0\n2007-11-28,350.0,347.0,347.0,348.0,348.0\n2007-11-27,356.0,356.0,358.0,354.0,350.0\n2007-11-26,357.0,357.0,360.0,360.0,360.0\n2007-11-23,353.0,354.0,357.0,355.0,\n2007-11-22,359.0,359.0,359.0,358.0,\n2007-11-21,364.0,364.0,366.0,365.0,359.0\n2007-11-20,360.0,359.0,362.0,364.0,364.0\n2007-11-19,366.0,365.0,365.0,365.0,361.0\n2007-11-16,368.0,366.0,368.0,369.0,366.0\n2007-11-15,373.0,372.0,372.0,368.0,368.0\n2007-11-14,372.0,372.0,372.0,373.0,373.0\n2007-11-13,365.0,365.0,368.0,372.0,372.0\n2007-11-12,373.0,370.0,370.0,366.0,366.0\n2007-11-09,376.0,375.0,373.0,373.0,373.0\n2007-11-08,376.0,376.0,373.0,376.0,376.0\n2007-11-07,379.0,379.0,383.0,378.0,378.0\n2007-11-06,374.0,374.0,374.0,379.0,379.0\n2007-11-05,376.0,376.0,376.0,376.0,374.0\n2007-11-02,372.0,371.0,371.0,371.0,376.0\n2007-11-01,374.0,374.0,374.0,374.0,374.0\n2007-10-31,369.0,369.0,371.0,372.0,372.0\n2007-10-30,373.0,372.0,373.0,371.0,371.0\n2007-10-29,373.0,375.0,375.0,376.0,373.0\n2007-10-26,364.0,368.0,370.0,373.0,373.0\n2007-10-25,360.0,360.0,360.0,364.0,368.0\n2007-10-24,364.0,364.0,364.0,360.0,360.0\n2007-10-23,361.0,361.0,364.0,366.0,366.0\n2007-10-22,367.0,362.0,361.0,361.0,361.0\n2007-10-19,,,374.0,372.0,370.0\n2007-10-18,373.0,373.0,374.0,373.0,373.0\n2007-10-17,372.0,372.0,370.0,373.0,373.0\n2007-10-16,375.0,375.0,375.0,372.0,372.0\n2007-10-15,379.0,379.0,380.0,382.0,375.0\n2007-10-12,378.0,378.0,378.0,379.0,379.0\n2007-10-11,375.0,375.0,376.0,381.0,384.0\n2007-10-10,365.0,365.0,367.0,377.0,377.0\n2007-10-09,365.0,363.0,362.0,362.0,365.0\n2007-10-08,369.0,369.0,367.0,366.0,365.0\n2007-10-05,369.0,369.0,371.0,369.0,369.0\n2007-10-04,359.0,359.0,360.0,362.0,369.0\n2007-10-03,352.0,350.0,352.0,352.0,359.0\n2007-10-02,358.0,357.0,356.0,352.0,352.0\n2007-10-01,,,349.0,355.0,360.0\n2007-09-28,345.0,345.0,345.0,346.0,348.0\n2007-09-27,342.0,342.0,342.0,343.0,345.0\n2007-09-26,,,341.0,340.0,343.0\n2007-09-25,342.0,341.0,343.0,341.0,341.0\n2007-09-24,340.0,340.0,342.0,342.0,342.0\n2007-09-21,341.0,341.0,342.0,342.0,340.0\n2007-09-20,335.0,335.0,335.0,338.0,341.0\n2007-09-19,333.0,333.0,335.0,335.0,335.0\n2007-09-18,333.0,333.0,334.0,333.0,333.0\n2007-09-17,331.0,331.0,331.0,333.0,333.0\n2007-09-14,334.0,333.0,333.0,333.0,331.0\n2007-09-13,336.0,336.0,336.0,334.0,334.0\n2007-09-12,336.0,336.0,336.0,336.0,336.0\n2007-09-11,333.0,335.0,335.0,336.0,336.0\n2007-09-10,337.0,337.0,337.0,336.0,333.0\n2007-09-07,336.0,336.0,338.0,337.0,337.0\n2007-09-06,333.0,333.0,336.0,336.0,336.0\n2007-09-05,334.0,334.0,334.0,336.0,333.0\n2007-09-04,333.0,333.0,334.0,334.0,334.0\n2007-09-03,334.0,334.0,335.0,334.0,\n2007-08-31,331.0,333.0,334.0,333.0,333.0\n2007-08-30,331.0,331.0,332.0,331.0,331.0\n2007-08-29,329.0,327.0,329.0,329.0,331.0\n2007-08-28,331.0,331.0,334.0,331.0,331.0\n2007-08-27,330.0,331.0,331.0,331.0,331.0\n2007-08-24,326.0,326.0,327.0,325.0,330.0\n2007-08-23,322.0,322.0,326.0,330.0,326.0\n2007-08-22,321.0,319.0,319.0,322.0,322.0\n2007-08-21,331.0,331.0,329.0,328.0,325.0\n2007-08-20,331.0,331.0,331.0,331.0,331.0\n2007-08-17,334.0,334.0,334.0,335.0,331.0\n2007-08-16,348.0,346.0,345.0,338.0,329.0\n2007-08-15,354.0,354.0,352.0,348.0,348.0\n2007-08-14,357.0,357.0,356.0,351.0,354.0\n2007-08-13,355.0,355.0,354.0,356.0,358.0\n2007-08-10,361.0,357.0,357.0,350.0,358.0\n2007-08-09,364.0,364.0,364.0,361.0,361.0\n2007-08-08,362.0,362.0,362.0,364.0,364.0\n2007-08-07,365.0,365.0,363.0,360.0,363.0\n2007-08-06,365.0,365.0,365.0,365.0,365.0\n2007-08-03,366.0,366.0,365.0,365.0,367.0\n2007-08-02,365.0,365.0,365.0,368.0,366.0\n2007-08-01,367.0,366.0,366.0,365.0,367.0\n2007-07-31,367.0,367.0,365.0,367.0,367.0\n2007-07-30,363.0,362.0,361.0,365.0,367.0\n2007-07-27,365.0,365.0,364.0,363.0,363.0\n2007-07-26,366.0,366.0,365.0,365.0,365.0\n2007-07-25,368.0,368.0,368.0,366.0,366.0\n2007-07-24,372.0,372.0,372.0,370.0,368.0\n2007-07-23,372.0,372.0,372.0,372.0,372.0\n2007-07-20,372.0,372.0,372.0,372.0,372.0\n2007-07-19,370.0,369.0,369.0,370.0,372.0\n2007-07-18,368.0,368.0,367.0,367.0,370.0\n2007-07-17,368.0,368.0,368.0,368.0,365.0\n2007-07-16,369.0,369.0,368.0,368.0,368.0\n2007-07-13,370.0,370.0,370.0,369.0,369.0\n2007-07-12,369.0,369.0,368.0,370.0,370.0\n2007-07-11,369.0,369.0,369.0,369.0,369.0\n2007-07-10,369.0,369.0,369.0,369.0,367.0\n2007-07-09,367.0,367.0,366.0,370.0,369.0\n2007-07-06,366.0,366.0,365.0,365.0,367.0\n2007-07-05,366.0,366.0,366.0,367.0,366.0\n2007-07-04,366.0,368.0,368.0,366.0,\n2007-07-03,368.0,370.0,370.0,368.0,366.0\n2007-07-02,,,369.0,368.0,368.0\n2007-06-29,368.0,368.0,368.0,368.0,368.0\n2007-06-28,367.0,367.0,368.0,368.0,368.0\n2007-06-27,366.0,366.0,366.0,368.0,364.0\n2007-06-26,372.0,372.0,370.0,368.0,366.0\n2007-06-25,377.0,377.0,376.0,373.0,372.0\n2007-06-22,376.0,376.0,375.0,377.0,377.0\n2007-06-21,375.0,375.0,374.0,376.0,376.0\n2007-06-20,373.0,373.0,371.0,375.0,377.0\n2007-06-19,,,372.0,371.0,371.0\n2007-06-18,370.0,371.0,373.0,373.0,373.0\n2007-06-15,370.0,369.0,369.0,369.0,372.0\n2007-06-14,367.0,367.0,369.0,369.0,369.0\n2007-06-13,369.0,369.0,367.0,365.0,369.0\n2007-06-12,368.0,368.0,371.0,369.0,369.0\n2007-06-11,367.0,367.0,367.0,368.0,368.0\n2007-06-08,369.0,368.0,368.0,371.0,369.0\n2007-06-07,370.0,370.0,370.0,369.0,371.0\n2007-06-06,370.0,370.0,370.0,368.0,368.0\n2007-06-05,372.0,372.0,372.0,372.0,368.0\n2007-06-04,376.0,374.0,374.0,372.0,372.0\n2007-06-01,370.0,370.0,370.0,373.0,373.0\n2007-05-31,368.0,368.0,368.0,370.0,370.0\n2007-05-30,370.0,369.0,369.0,367.0,367.0\n2007-05-29,370.0,369.0,369.0,371.0,368.0\n2007-05-28,368.0,368.0,368.0,,\n2007-05-25,368.0,368.0,368.0,367.0,367.0\n2007-05-24,,,376.0,376.0,368.0\n2007-05-23,375.0,375.0,378.0,376.0,376.0\n2007-05-22,374.0,374.0,374.0,378.0,378.0\n2007-05-21,364.0,364.0,365.0,368.0,374.0\n2007-05-18,362.0,361.0,361.0,364.0,364.0\n2007-05-17,359.0,359.0,359.0,359.0,362.0\n2007-05-16,363.0,363.0,362.0,362.0,359.0\n2007-05-15,362.0,362.0,362.0,358.0,362.0\n2007-05-14,368.0,368.0,368.0,364.0,362.0\n2007-05-11,361.0,363.0,362.0,364.0,367.0\n2007-05-10,370.0,370.0,366.0,363.0,363.0\n2007-05-09,376.0,376.0,373.0,372.0,370.0\n2007-05-08,378.0,378.0,378.0,376.0,376.0\n2007-05-07,378.0,378.0,381.0,381.0,381.0\n2007-05-04,376.0,374.0,374.0,376.0,376.0\n2007-05-03,373.0,373.0,373.0,376.0,376.0\n2007-05-02,373.0,373.0,373.0,372.0,375.0\n2007-05-01,,,371.0,369.0,374.0\n2007-04-30,373.0,373.0,373.0,373.0,373.0\n2007-04-27,373.0,372.0,372.0,374.0,374.0\n2007-04-26,380.0,380.0,380.0,376.0,373.0\n2007-04-25,377.0,377.0,377.0,380.0,380.0\n2007-04-24,384.0,384.0,384.0,383.0,379.0\n2007-04-23,386.0,386.0,386.0,382.0,386.0\n2007-04-20,378.0,378.0,378.0,385.0,387.0\n2007-04-19,383.0,382.0,377.0,377.0,377.0\n2007-04-18,377.0,377.0,378.0,377.0,382.0\n2007-04-17,376.0,376.0,376.0,376.0,379.0\n2007-04-16,380.0,381.0,381.0,376.0,376.0\n2007-04-13,371.0,371.0,371.0,374.0,380.0\n2007-04-12,367.0,367.0,369.0,371.0,371.0\n2007-04-11,360.0,360.0,363.0,366.0,369.0\n2007-04-10,358.0,358.0,360.0,360.0,360.0\n2007-04-09,,,,355.0,355.0\n2007-04-05,,,355.0,353.0,355.0\n2007-04-04,354.0,354.0,353.0,355.0,355.0\n2007-04-03,353.0,353.0,354.0,354.0,354.0\n2007-04-02,355.0,355.0,355.0,353.0,355.0\n2007-03-30,354.0,354.0,356.0,355.0,355.0\n2007-03-29,355.0,356.0,356.0,355.0,355.0\n2007-03-28,355.0,356.0,356.0,356.0,356.0\n2007-03-27,355.0,355.0,357.0,355.0,355.0\n2007-03-26,354.0,354.0,355.0,355.0,357.0\n2007-03-23,355.0,355.0,355.0,355.0,358.0\n2007-03-22,354.0,354.0,353.0,356.0,356.0\n2007-03-21,352.0,352.0,352.0,352.0,350.0\n2007-03-20,352.0,352.0,352.0,352.0,352.0\n2007-03-19,352.0,352.0,352.0,352.0,352.0\n2007-03-16,352.0,352.0,352.0,352.0,352.0\n2007-03-15,349.0,349.0,349.0,352.0,352.0\n2007-03-14,351.0,349.0,348.0,349.0,349.0\n2007-03-13,352.0,352.0,352.0,351.0,351.0\n2007-03-12,353.0,353.0,353.0,352.0,352.0\n2007-03-09,353.0,351.0,353.0,353.0,353.0\n2007-03-08,349.0,349.0,349.0,353.0,355.0\n2007-03-07,349.0,348.0,348.0,348.0,348.0\n2007-03-06,342.0,343.0,345.0,345.0,350.0\n2007-03-05,344.0,342.0,340.0,340.0,345.0\n2007-03-02,351.0,351.0,351.0,349.0,349.0\n2007-03-01,351.0,354.0,352.0,355.0,351.0\n2007-02-28,347.0,348.0,348.0,350.0,350.0\n2007-02-27,357.0,356.0,356.0,351.0,356.0\n2007-02-26,358.0,359.0,359.0,357.0,357.0\n2007-02-23,347.0,348.0,348.0,355.0,360.0\n2007-02-22,346.0,346.0,346.0,350.0,350.0\n2007-02-21,339.0,339.0,340.0,339.0,346.0\n2007-02-20,,,342.0,337.0,337.0\n2007-02-19,,,343.0,342.0,342.0\n2007-02-16,344.0,343.0,343.0,340.0,343.0\n2007-02-15,345.0,343.0,343.0,344.0,344.0\n2007-02-14,343.0,343.0,343.0,345.0,347.0\n2007-02-13,340.0,339.0,339.0,339.0,343.0\n2007-02-12,338.0,338.0,340.0,338.0,340.0\n2007-02-09,343.0,343.0,343.0,338.0,342.0\n2007-02-08,344.0,344.0,344.0,339.0,342.0\n2007-02-07,344.0,346.0,345.0,346.0,346.0\n2007-02-06,340.0,340.0,342.0,344.0,344.0\n2007-02-05,337.0,336.0,336.0,340.0,343.0\n2007-02-02,344.0,344.0,343.0,341.0,341.0\n2007-02-01,341.0,341.0,341.0,344.0,344.0\n2007-01-31,341.0,340.0,340.0,334.0,341.0\n2007-01-30,343.0,341.0,343.0,336.0,342.0\n2007-01-29,349.0,349.0,350.0,342.0,346.0\n2007-01-26,353.0,352.0,351.0,351.0,351.0\n2007-01-25,350.0,350.0,350.0,353.0,353.0\n2007-01-24,351.0,350.0,350.0,348.0,348.0\n2007-01-23,345.0,345.0,347.0,350.0,350.0\n2007-01-22,343.0,343.0,343.0,344.0,347.0\n2007-01-19,340.0,340.0,341.0,341.0,344.0\n2007-01-18,340.0,342.0,342.0,342.0,342.0\n2007-01-17,335.0,335.0,333.0,334.0,343.0\n2007-01-16,332.0,332.0,332.0,334.0,337.0\n2007-01-15,334.0,336.0,335.0,332.0,332.0\n2007-01-12,331.0,331.0,331.0,331.0,335.0\n2007-01-11,331.0,331.0,331.0,333.0,333.0\n2007-01-10,333.0,333.0,334.0,331.0,331.0\n2007-01-09,333.0,333.0,336.0,329.0,329.0\n2007-01-08,335.0,335.0,335.0,333.0,333.0\n2007-01-05,340.0,340.0,340.0,342.0,336.0\n2007-01-04,337.0,337.0,337.0,340.0,343.0\n2007-01-03,338.0,336.0,336.0,342.0,342.0\n2007-01-02,337.0,337.0,334.0,336.0,336.0\n2006-12-29,327.0,327.0,327.0,327.0,337.0\n2006-12-28,326.0,326.0,328.0,327.0,326.0\n2006-12-27,326.0,328.0,328.0,328.0,326.0\n2006-12-26,,,,327.0,327.0\n2006-12-22,325.0,325.0,327.0,327.0,327.0\n2006-12-21,326.0,326.0,327.0,325.0,325.0\n2006-12-20,328.0,328.0,328.0,326.0,326.0\n2006-12-19,324.0,324.0,325.0,322.0,326.0\n2006-12-18,325.0,325.0,326.0,324.0,324.0\n2006-12-15,330.0,329.0,329.0,327.0,325.0\n2006-12-14,328.0,328.0,328.0,330.0,330.0\n2006-12-13,329.0,329.0,330.0,328.0,328.0\n2006-12-12,332.0,332.0,332.0,329.0,329.0\n2006-12-11,329.0,329.0,329.0,329.0,329.0\n2006-12-08,330.0,329.0,329.0,332.0,336.0\n2006-12-07,328.0,326.0,326.0,328.0,328.0\n2006-12-06,333.0,331.0,331.0,328.0,328.0\n2006-12-05,330.0,330.0,329.0,333.0,333.0\n2006-12-04,330.0,330.0,330.0,330.0,330.0\n2006-12-01,330.0,330.0,330.0,328.0,328.0\n2006-11-30,324.0,323.0,323.0,330.0,330.0\n2006-11-29,326.0,326.0,328.0,321.0,321.0\n2006-11-28,329.0,328.0,328.0,326.0,326.0\n2006-11-27,330.0,329.0,329.0,329.0,329.0\n2006-11-24,326.0,326.0,326.0,330.0,\n2006-11-23,328.0,328.0,327.0,326.0,\n2006-11-22,330.0,330.0,328.0,328.0,328.0\n2006-11-21,323.0,327.0,327.0,330.0,330.0\n2006-11-20,320.0,320.0,322.0,323.0,323.0\n2006-11-17,321.0,321.0,321.0,318.0,320.0\n2006-11-16,320.0,320.0,322.0,323.0,323.0\n2006-11-15,321.0,321.0,321.0,317.0,320.0\n2006-11-14,326.0,325.0,324.0,324.0,321.0\n2006-11-13,333.0,333.0,333.0,326.0,326.0\n2006-11-10,338.0,338.0,338.0,335.0,333.0\n2006-11-09,329.0,329.0,328.0,331.0,338.0\n2006-11-08,333.0,333.0,334.0,327.0,327.0\n2006-11-07,334.0,332.0,332.0,335.0,335.0\n2006-11-06,340.0,340.0,340.0,330.0,335.0\n2006-11-03,326.0,326.0,325.0,330.0,333.0\n2006-11-02,327.0,326.0,326.0,324.0,326.0\n2006-11-01,323.0,323.0,324.0,326.0,326.0\n2006-10-31,325.0,325.0,325.0,318.0,323.0\n2006-10-30,,,325.0,325.0,325.0\n2006-10-27,324.0,324.0,324.0,321.0,323.0\n2006-10-26,325.0,324.0,324.0,323.0,326.0\n2006-10-25,322.0,322.0,322.0,319.0,319.0\n2006-10-24,319.0,318.0,318.0,320.0,323.0\n2006-10-23,326.0,326.0,326.0,319.0,319.0\n2006-10-20,337.0,337.0,334.0,329.0,329.0\n2006-10-19,331.0,331.0,331.0,330.0,337.0\n2006-10-18,320.0,320.0,320.0,326.0,334.0\n2006-10-17,324.0,326.0,326.0,321.0,321.0\n2006-10-16,318.0,321.0,320.0,324.0,324.0\n2006-10-13,309.0,309.0,309.0,316.0,316.0\n2006-10-12,305.0,308.0,308.0,310.0,310.0\n2006-10-11,299.0,299.0,301.0,305.0,309.0\n2006-10-10,304.0,308.0,308.0,299.0,299.0\n2006-10-09,302.0,302.0,304.0,304.0,304.0\n2006-10-06,301.0,301.0,301.0,297.0,297.0\n2006-10-05,297.0,299.0,299.0,301.0,301.0\n2006-10-04,300.0,298.0,298.0,302.0,297.0\n2006-10-03,315.0,315.0,314.0,305.0,305.0\n2006-10-02,,,322.0,315.0,315.0\n2006-09-29,321.0,323.0,323.0,318.0,318.0\n2006-09-28,320.0,323.0,323.0,323.0,323.0\n2006-09-27,318.0,318.0,320.0,317.0,320.0\n2006-09-26,318.0,318.0,319.0,318.0,318.0\n2006-09-25,319.0,318.0,319.0,316.0,316.0\n2006-09-22,310.0,310.0,313.0,325.0,322.0\n2006-09-21,308.0,308.0,308.0,309.0,309.0\n2006-09-20,307.0,307.0,308.0,311.0,311.0\n2006-09-19,317.0,316.0,316.0,319.0,310.0\n2006-09-18,313.0,313.0,313.0,306.0,312.0\n2006-09-15,311.0,311.0,314.0,315.0,315.0\n2006-09-14,317.0,317.0,317.0,332.0,326.0\n2006-09-13,310.0,310.0,310.0,321.0,318.0\n2006-09-12,311.0,323.0,322.0,320.0,314.0\n2006-09-11,330.0,322.0,321.0,317.0,317.0\n2006-09-08,347.0,345.0,345.0,323.0,330.0\n2006-09-07,350.0,350.0,353.0,348.0,348.0\n2006-09-06,351.0,351.0,351.0,351.0,356.0\n2006-09-05,347.0,347.0,347.0,351.0,351.0\n2006-09-04,346.0,346.0,347.0,346.0,\n2006-09-01,348.0,345.0,346.0,346.0,346.0\n2006-08-31,340.0,340.0,342.0,343.0,343.0\n2006-08-30,339.0,341.0,340.0,339.0,340.0\n2006-08-29,341.0,343.0,342.0,338.0,340.0\n2006-08-28,345.0,345.0,345.0,345.0,345.0\n2006-08-25,345.0,345.0,345.0,346.0,346.0\n2006-08-24,345.0,345.0,347.0,348.0,348.0\n2006-08-23,340.0,340.0,340.0,345.0,345.0\n2006-08-22,347.0,347.0,346.0,340.0,340.0\n2006-08-21,335.0,338.0,338.0,341.0,347.0\n2006-08-18,332.0,334.0,333.0,335.0,335.0\n2006-08-17,333.0,337.0,338.0,341.0,337.0\n2006-08-16,326.0,325.0,324.0,334.0,337.0\n2006-08-15,317.0,320.0,319.0,322.0,327.0\n2006-08-14,320.0,320.0,320.0,314.0,319.0\n2006-08-11,320.0,320.0,322.0,324.0,324.0\n2006-08-10,326.0,326.0,327.0,326.0,324.0\n2006-08-09,320.0,320.0,320.0,324.0,327.0\n2006-08-08,327.0,325.0,324.0,320.0,320.0\n2006-08-07,327.0,327.0,328.0,324.0,324.0\n2006-08-04,324.0,324.0,324.0,327.0,327.0\n2006-08-03,330.0,326.0,327.0,324.0,324.0\n2006-08-02,319.0,319.0,322.0,325.0,330.0\n2006-08-01,316.0,316.0,316.0,319.0,319.0\n2006-07-31,315.0,315.0,317.0,313.0,316.0\n2006-07-28,320.0,318.0,318.0,315.0,315.0\n2006-07-27,315.0,315.0,318.0,320.0,320.0\n2006-07-26,315.0,315.0,315.0,315.0,315.0\n2006-07-25,314.0,314.0,315.0,314.0,317.0\n2006-07-24,309.0,309.0,309.0,309.0,314.0\n2006-07-21,308.0,311.0,310.0,310.0,310.0\n2006-07-20,317.0,315.0,316.0,315.0,315.0\n2006-07-19,308.0,308.0,311.0,311.0,318.0\n2006-07-18,320.0,320.0,319.0,318.0,316.0\n2006-07-17,333.0,333.0,333.0,321.0,321.0\n2006-07-14,331.0,331.0,331.0,331.0,331.0\n2006-07-13,330.0,328.0,328.0,331.0,331.0\n2006-07-12,330.0,330.0,330.0,330.0,330.0\n2006-07-11,318.0,320.0,323.0,326.0,330.0\n2006-07-10,325.0,323.0,323.0,320.0,320.0\n2006-07-07,329.0,329.0,329.0,327.0,327.0\n2006-07-06,328.0,324.0,326.0,323.0,329.0\n2006-07-05,328.0,328.0,330.0,328.0,328.0\n2006-07-04,325.0,328.0,327.0,326.0,\n2006-07-03,322.0,326.0,326.0,329.0,\n2006-06-30,320.0,320.0,320.0,316.0,322.0\n2006-06-29,309.0,309.0,307.0,314.0,314.0\n2006-06-28,310.0,310.0,313.0,314.0,314.0\n2006-06-27,318.0,320.0,320.0,318.0,318.0\n2006-06-26,308.0,305.0,309.0,320.0,320.0\n2006-06-23,310.0,304.0,305.0,306.0,310.0\n2006-06-22,315.0,318.0,320.0,320.0,316.0\n2006-06-21,303.0,306.0,308.0,311.0,315.0\n2006-06-20,292.0,297.0,296.0,301.0,305.0\n2006-06-19,307.0,304.0,303.0,302.0,297.0\n2006-06-16,300.0,306.0,305.0,310.0,307.0\n2006-06-15,290.0,290.0,292.0,300.0,300.0\n2006-06-14,277.0,274.0,275.0,288.0,293.0\n2006-06-13,313.0,308.0,307.0,286.0,277.0\n2006-06-12,320.0,320.0,316.0,321.0,316.0\n2006-06-09,317.0,313.0,313.0,327.0,327.0\n2006-06-08,342.0,336.0,333.0,331.0,320.0\n2006-06-07,348.0,346.0,346.0,335.0,343.0\n2006-06-06,359.0,359.0,359.0,350.0,350.0\n2006-06-05,356.0,356.0,358.0,363.0,363.0\n2006-06-02,340.0,343.0,342.0,351.0,356.0\n2006-06-01,347.0,345.0,345.0,340.0,340.0\n2006-05-31,,,358.0,358.0,345.0\n2006-05-30,352.0,350.0,355.0,359.0,358.0\n2006-05-29,357.0,352.0,350.0,,\n2006-05-26,355.0,353.0,354.0,354.0,354.0\n2006-05-25,348.0,348.0,350.0,350.0,350.0\n2006-05-24,358.0,362.0,365.0,352.0,352.0\n2006-05-23,343.0,342.0,343.0,355.0,362.0\n2006-05-22,350.0,345.0,345.0,340.0,340.0\n2006-05-19,366.0,369.0,373.0,347.0,352.0\n2006-05-18,372.0,375.0,376.0,380.0,375.0\n2006-05-17,379.0,379.0,382.0,390.0,380.0\n2006-05-16,368.0,370.0,366.0,379.0,379.0\n2006-05-15,395.0,395.0,397.0,370.0,375.0\n2006-05-12,400.0,396.0,398.0,407.0,399.0\n2006-05-11,390.0,397.0,395.0,400.0,400.0\n2006-05-10,394.0,397.0,398.0,390.0,390.0\n2006-05-09,375.0,375.0,378.0,384.0,394.0\n2006-05-08,380.0,380.0,381.0,377.0,375.0\n2006-05-05,,,383.0,382.0,382.0\n2006-05-04,379.0,379.0,378.0,379.0,379.0\n2006-05-03,386.0,386.0,388.0,384.0,379.0\n2006-05-02,377.0,377.0,380.0,380.0,384.0\n2006-05-01,,,,380.0,380.0\n2006-04-28,360.0,363.0,363.0,364.0,377.0\n2006-04-27,368.0,365.0,367.0,364.0,364.0\n2006-04-26,366.0,366.0,367.0,361.0,368.0\n2006-04-25,356.0,355.0,355.0,362.0,362.0\n2006-04-24,359.0,359.0,363.0,360.0,360.0\n2006-04-21,344.0,348.0,347.0,352.0,359.0\n2006-04-20,368.0,372.0,374.0,365.0,349.0\n2006-04-19,366.0,364.0,364.0,371.0,374.0\n2006-04-18,364.0,360.0,360.0,361.0,361.0\n2006-04-17,,,,358.0,358.0\n2006-04-13,347.0,342.0,341.0,346.0,349.0\n2006-04-12,340.0,344.0,343.0,347.0,347.0\n2006-04-11,359.0,359.0,360.0,359.0,345.0\n2006-04-10,351.0,354.0,355.0,359.0,359.0\n2006-04-07,352.0,352.0,354.0,351.0,351.0\n2006-04-06,341.0,341.0,344.0,352.0,352.0\n2006-04-05,,,336.0,341.0,341.0\n2006-04-04,342.0,339.0,337.0,338.0,342.0\n2006-04-03,332.0,337.0,338.0,341.0,345.0\n2006-03-31,349.0,349.0,348.0,332.0,332.0\n2006-03-30,338.0,341.0,343.0,349.0,349.0\n2006-03-29,340.0,337.0,337.0,333.0,338.0\n2006-03-28,340.0,344.0,345.0,340.0,340.0\n2006-03-27,333.0,333.0,334.0,341.0,341.0\n2006-03-24,321.0,321.0,320.0,326.0,333.0\n2006-03-23,323.0,321.0,321.0,317.0,322.0\n2006-03-22,317.0,318.0,322.0,320.0,324.0\n2006-03-21,320.0,318.0,316.0,315.0,318.0\n2006-03-20,318.0,318.0,319.0,317.0,317.0\n2006-03-17,316.0,316.0,315.0,318.0,318.0\n2006-03-16,315.0,314.0,314.0,316.0,316.0\n2006-03-15,305.0,305.0,307.0,318.0,318.0\n2006-03-14,300.0,300.0,300.0,302.0,306.0\n2006-03-13,288.0,291.0,290.0,292.0,300.0\n2006-03-10,289.0,289.0,289.0,288.0,288.0\n2006-03-09,280.0,282.0,282.0,285.0,285.0\n2006-03-08,291.0,289.0,289.0,285.0,282.0\n2006-03-07,296.0,296.0,296.0,299.0,292.0\n2006-03-06,307.0,304.0,302.0,302.0,297.0\n2006-03-03,300.0,300.0,300.0,305.0,305.0\n2006-03-02,297.0,297.0,296.0,294.0,300.0\n2006-03-01,291.0,291.0,289.0,290.0,297.0\n2006-02-28,284.0,284.0,285.0,288.0,291.0\n2006-02-27,286.0,290.0,290.0,285.0,284.0\n2006-02-24,283.0,285.0,286.0,286.0,286.0\n2006-02-23,289.0,286.0,287.0,288.0,286.0\n2006-02-22,293.0,293.0,293.0,292.0,289.0\n2006-02-21,292.0,290.0,291.0,291.0,293.0\n2006-02-20,292.0,292.0,292.0,292.0,292.0\n2006-02-17,279.0,279.0,280.0,285.0,290.0\n2006-02-16,276.0,276.0,278.0,275.0,279.0\n2006-02-15,282.0,285.0,287.0,285.0,279.0\n2006-02-14,273.0,270.0,274.0,278.0,282.0\n2006-02-13,283.0,278.0,277.0,282.0,276.0\n2006-02-10,304.0,298.0,297.0,296.0,285.0\n2006-02-09,293.0,297.0,295.0,300.0,300.0\n2006-02-08,288.0,288.0,287.0,290.0,290.0\n2006-02-07,309.0,309.0,309.0,297.0,290.0\n2006-02-06,317.0,317.0,320.0,305.0,312.0\n2006-02-03,309.0,310.0,310.0,317.0,317.0\n2006-02-02,294.0,296.0,295.0,300.0,305.0\n2006-02-01,294.0,293.0,293.0,294.0,294.0\n2006-01-31,,,282.0,293.0,295.0\n2006-01-30,,,277.0,278.0,278.0\n2006-01-27,275.0,275.0,276.0,275.0,275.0\n2006-01-26,279.0,279.0,280.0,275.0,275.0\n2006-01-25,275.0,275.0,275.0,279.0,279.0\n2006-01-24,278.0,278.0,278.0,276.0,276.0\n2006-01-23,276.0,278.0,277.0,278.0,278.0\n2006-01-20,279.0,278.0,277.0,280.0,277.0\n2006-01-19,273.0,275.0,275.0,273.0,277.0\n2006-01-18,282.0,276.0,275.0,273.0,273.0\n2006-01-17,289.0,286.0,286.0,281.0,283.0\n2006-01-16,283.0,285.0,285.0,289.0,289.0\n2006-01-13,273.0,273.0,273.0,275.0,281.0\n2006-01-12,274.0,274.0,274.0,273.0,273.0\n2006-01-11,274.0,274.0,274.0,271.0,274.0\n2006-01-10,279.0,278.0,278.0,277.0,274.0\n2006-01-09,272.0,272.0,274.0,275.0,278.0\n2006-01-06,264.0,265.0,262.0,269.0,272.0\n2006-01-05,274.0,274.0,272.0,263.0,263.0\n2006-01-04,272.0,272.0,272.0,272.0,274.0\n2006-01-03,260.0,262.0,262.0,267.0,267.0\n'.strip()
fetcher_universe_data = '\ndate,symbol\n1/9/2006,aapl\n1/9/2006,ibm\n1/9/2006,msft\n1/11/2006,aapl\n1/11/2006,ibm\n1/11/2006,msft\n1/11/2006,yhoo\n'.strip()
non_asset_fetcher_universe_data = '\ndate,symbol\n1/9/2006,foobarbaz\n1/9/2006,bazfoobar\n1/9/2006,barbazfoo\n1/11/2006,foobarbaz\n1/11/2006,bazfoobar\n1/11/2006,barbazfoo\n1/11/2006,foobarbaz\n'.strip()
fetcher_alternate_column_header = 'ARGLEBARGLE'
fetcher_universe_data_ticker_column = FETCHER_UNIVERSE_DATA.replace('symbol', FETCHER_ALTERNATE_COLUMN_HEADER)
|
dna_seq1 = 'ACCTGATC'
gc_count = 0
for nucl in dna_seq1:
if nucl == 'G' or nucl == 'C':
gc_count += 1
print(gc_count / len(dna_seq1))
|
dna_seq1 = 'ACCTGATC'
gc_count = 0
for nucl in dna_seq1:
if nucl == 'G' or nucl == 'C':
gc_count += 1
print(gc_count / len(dna_seq1))
|
class BaseLoadTester(object):
def __init__(self, config):
self.config = config
def before(self):
raise NotImplementedError()
def on_result(self):
raise NotImplementedError()
|
class Baseloadtester(object):
def __init__(self, config):
self.config = config
def before(self):
raise not_implemented_error()
def on_result(self):
raise not_implemented_error()
|
description = 'POLI monochromator devices'
group = 'lowlevel'
tango_base = 'tango://phys.poli.frm2:10000/poli/'
s7_motor = tango_base + 's7_motor/'
devices = dict(
chi_m = device('nicos.devices.tango.Motor',
description = 'monochromator tilt (chi axis)',
tangodevice = s7_motor + 'chi_m',
fmtstr = '%.2f',
abslimits = (0, 12.7),
precision = 0.01,
),
theta_m = device('nicos.devices.tango.Motor',
description = 'monochromator rotation (theta axis)',
tangodevice = s7_motor + 'theta_m',
fmtstr = '%.2f',
abslimits = (0, 1300),
precision = 0.1,
),
x_m = device('nicos.devices.tango.Motor',
description = 'monochromator translation (x axis)',
tangodevice = s7_motor + 'x_m',
fmtstr = '%.2f',
abslimits = (0, 100),
precision = 0.01,
),
changer_m = device('nicos.devices.tango.Motor',
description = 'monochromator changer axis',
tangodevice = s7_motor + 'change_m',
fmtstr = '%.2f',
abslimits = (0, 4000),
precision = 0.1,
),
wavelength = device('nicos.devices.tas.Monochromator',
description = 'monochromator wavelength',
unit = 'A',
dvalue = 3.355,
theta = 'vmth',
twotheta = 'vmtt',
focush = None,
focusv = None,
abslimits = (0.1, 3.0),
warnlimits = (0.1, 3.0),
crystalside = 1,
),
vmth = device('nicos.devices.generic.VirtualMotor',
unit = 'deg',
abslimits = (-90, 90),
precision = 0.05,
speed = 0,
lowlevel = True,
),
vmtt = device('nicos.devices.generic.VirtualMotor',
unit = 'deg',
abslimits = (-180, 180),
precision = 0.05,
speed = 0,
lowlevel = True,
),
#h_m = device('nicos.devices.generic.DeviceAlias',
# ),
#v_m = device('nicos.devices.generic.DeviceAlias',
# ),
#h_m_alias = device('nicos.devices.generic.ParamDevice',
# lowlevel = True,
# device = 'h_m',
# parameter = 'alias',
# ),
#v_m_alias = device('nicos.devices.generic.ParamDevice',
# lowlevel = True,
# device = 'v_m',
# parameter = 'alias',
# ),
#mono = device('nicos_mlz.poli.devices.mono.MultiSwitcher',
# description = 'monochromator wavelength switcher',
# # note: precision of chi and theta is so large because they are expected
# # to be changed slightly depending on setup
# moveables = ['x_m', 'changer_m', 'chi_m', 'theta_m', 'h_m_alias', 'v_m_alias'],
# precision = [0.01, 0.01, 5, 10, None, None],
# mapping = {
# 0.9: [38, 190, 6.3, 236, 'cuh', 'cuv'],
# 1.14: [45, 3.79, 8.6, 236, 'sih', 'siv'],
# },
# changepos = 0,
# ),
)
|
description = 'POLI monochromator devices'
group = 'lowlevel'
tango_base = 'tango://phys.poli.frm2:10000/poli/'
s7_motor = tango_base + 's7_motor/'
devices = dict(chi_m=device('nicos.devices.tango.Motor', description='monochromator tilt (chi axis)', tangodevice=s7_motor + 'chi_m', fmtstr='%.2f', abslimits=(0, 12.7), precision=0.01), theta_m=device('nicos.devices.tango.Motor', description='monochromator rotation (theta axis)', tangodevice=s7_motor + 'theta_m', fmtstr='%.2f', abslimits=(0, 1300), precision=0.1), x_m=device('nicos.devices.tango.Motor', description='monochromator translation (x axis)', tangodevice=s7_motor + 'x_m', fmtstr='%.2f', abslimits=(0, 100), precision=0.01), changer_m=device('nicos.devices.tango.Motor', description='monochromator changer axis', tangodevice=s7_motor + 'change_m', fmtstr='%.2f', abslimits=(0, 4000), precision=0.1), wavelength=device('nicos.devices.tas.Monochromator', description='monochromator wavelength', unit='A', dvalue=3.355, theta='vmth', twotheta='vmtt', focush=None, focusv=None, abslimits=(0.1, 3.0), warnlimits=(0.1, 3.0), crystalside=1), vmth=device('nicos.devices.generic.VirtualMotor', unit='deg', abslimits=(-90, 90), precision=0.05, speed=0, lowlevel=True), vmtt=device('nicos.devices.generic.VirtualMotor', unit='deg', abslimits=(-180, 180), precision=0.05, speed=0, lowlevel=True))
|
# Advent of code 2021 : Day 1 | Part 1
# Author = Abhinav
# Date = 1st of December 2021
# Source = [Advent Of Code](https://adventofcode.com/2021/day/1)
# Solution :
inputs = open("input.txt", "rt")
inputs = list(map(int, inputs.read().splitlines()))
print(sum([1 for _ in range(1, len(inputs)) if inputs[_-1] < inputs[_]]))
# Answer : 1266
|
inputs = open('input.txt', 'rt')
inputs = list(map(int, inputs.read().splitlines()))
print(sum([1 for _ in range(1, len(inputs)) if inputs[_ - 1] < inputs[_]]))
|
# hello.py
"""
This is an demo of a python script in the `py` package.
"""
#import api # cythonized max c api
# basic examples
a = 10
b = 1.5
c = "HELLO WORLD!!!"
d = [1,2,3,4]
e = ['a','b', 'c']
f = lambda: "hello func"
g = lambda x: x+10
h = '"a"'
e = '"double-quoted"'
f = "'single-quoted'"
|
"""
This is an demo of a python script in the `py` package.
"""
a = 10
b = 1.5
c = 'HELLO WORLD!!!'
d = [1, 2, 3, 4]
e = ['a', 'b', 'c']
f = lambda : 'hello func'
g = lambda x: x + 10
h = '"a"'
e = '"double-quoted"'
f = "'single-quoted'"
|
class Charge:
def __init__(self, vehicle):
self._vehicle = vehicle
self._api_client = vehicle._api_client
async def get_state(self):
return await self._api_client.get(
"vehicles/{}/data_request/charge_state".format(self._vehicle.id))
async def start_charging(self):
return await self._vehicle._command("charge_start")
async def stop_charging(self):
return await self._vehicle._command("charge_stop")
async def set_charge_limit(self, percentage):
percentage = round(percentage)
if not (50 <= percentage <= 100):
raise ValueError("Percentage should be between 50 and 100")
return await self._vehicle._command("set_charge_limit", {"percent": percentage})
|
class Charge:
def __init__(self, vehicle):
self._vehicle = vehicle
self._api_client = vehicle._api_client
async def get_state(self):
return await self._api_client.get('vehicles/{}/data_request/charge_state'.format(self._vehicle.id))
async def start_charging(self):
return await self._vehicle._command('charge_start')
async def stop_charging(self):
return await self._vehicle._command('charge_stop')
async def set_charge_limit(self, percentage):
percentage = round(percentage)
if not 50 <= percentage <= 100:
raise value_error('Percentage should be between 50 and 100')
return await self._vehicle._command('set_charge_limit', {'percent': percentage})
|
test = { 'name': 'q3_1_2',
'points': 1,
'suites': [ { 'cases': [ { 'code': ">>> #It looks like you didn't give anything the name;\n"
">>> # seconds_in_a_decade. Maybe there's a typo, or maybe you ;\n"
'>>> # just need to run the cell below Question 3.2 where you defined ;\n'
'>>> # seconds_in_a_decade. Click that cell and then click the "run;\n'
'>>> # cell" button in the menu bar above.);\n'
">>> 'seconds_in_a_decade' in vars()\n"
'True',
'hidden': False,
'locked': False},
{ 'code': ">>> # It looks like you didn't change the cell to define;\n"
'>>> # seconds_in_a_decade appropriately. It should be a number,;\n'
">>> # computed using Python's arithmetic. For example, this is;\n"
'>>> # almost right:;\n'
'>>> # seconds_in_a_decade = 10*365*24*60*60;\n'
'>>> seconds_in_a_decade != ...\n'
'True',
'hidden': False,
'locked': False},
{ 'code': ">>> # It looks like you didn't account for leap years.;\n"
'>>> # There were 2 leap years and 8 non-leap years in this period.;\n'
'>>> # Leap years have 366 days instead of 365.;\n'
'>>> seconds_in_a_decade != 315360000\n'
'True',
'hidden': False,
'locked': False}],
'scored': True,
'setup': '',
'teardown': '',
'type': 'doctest'}]}
|
test = {'name': 'q3_1_2', 'points': 1, 'suites': [{'cases': [{'code': '>>> #It looks like you didn\'t give anything the name;\n>>> # seconds_in_a_decade. Maybe there\'s a typo, or maybe you ;\n>>> # just need to run the cell below Question 3.2 where you defined ;\n>>> # seconds_in_a_decade. Click that cell and then click the "run;\n>>> # cell" button in the menu bar above.);\n>>> \'seconds_in_a_decade\' in vars()\nTrue', 'hidden': False, 'locked': False}, {'code': ">>> # It looks like you didn't change the cell to define;\n>>> # seconds_in_a_decade appropriately. It should be a number,;\n>>> # computed using Python's arithmetic. For example, this is;\n>>> # almost right:;\n>>> # seconds_in_a_decade = 10*365*24*60*60;\n>>> seconds_in_a_decade != ...\nTrue", 'hidden': False, 'locked': False}, {'code': ">>> # It looks like you didn't account for leap years.;\n>>> # There were 2 leap years and 8 non-leap years in this period.;\n>>> # Leap years have 366 days instead of 365.;\n>>> seconds_in_a_decade != 315360000\nTrue", 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
|
# generated from catkin/cmake/template/pkg.context.pc.in
CATKIN_PACKAGE_PREFIX = ""
PROJECT_PKG_CONFIG_INCLUDE_DIRS = "/home/ros/lidar_ws/src/geometry/kdl_conversions/include;/opt/ros/kinetic/share/orocos_kdl/../../include;/usr/include/eigen3".split(';') if "/home/ros/lidar_ws/src/geometry/kdl_conversions/include;/opt/ros/kinetic/share/orocos_kdl/../../include;/usr/include/eigen3" != "" else []
PROJECT_CATKIN_DEPENDS = "geometry_msgs".replace(';', ' ')
PKG_CONFIG_LIBRARIES_WITH_PREFIX = "-lkdl_conversions;/opt/ros/kinetic/lib/liborocos-kdl.so.1.3.2".split(';') if "-lkdl_conversions;/opt/ros/kinetic/lib/liborocos-kdl.so.1.3.2" != "" else []
PROJECT_NAME = "kdl_conversions"
PROJECT_SPACE_DIR = "/home/ros/lidar_ws/devel"
PROJECT_VERSION = "1.11.9"
|
catkin_package_prefix = ''
project_pkg_config_include_dirs = '/home/ros/lidar_ws/src/geometry/kdl_conversions/include;/opt/ros/kinetic/share/orocos_kdl/../../include;/usr/include/eigen3'.split(';') if '/home/ros/lidar_ws/src/geometry/kdl_conversions/include;/opt/ros/kinetic/share/orocos_kdl/../../include;/usr/include/eigen3' != '' else []
project_catkin_depends = 'geometry_msgs'.replace(';', ' ')
pkg_config_libraries_with_prefix = '-lkdl_conversions;/opt/ros/kinetic/lib/liborocos-kdl.so.1.3.2'.split(';') if '-lkdl_conversions;/opt/ros/kinetic/lib/liborocos-kdl.so.1.3.2' != '' else []
project_name = 'kdl_conversions'
project_space_dir = '/home/ros/lidar_ws/devel'
project_version = '1.11.9'
|
if __name__ == '__main__':
n = int(input())
answer = ''
for i in range(n):
answer += str(i + 1)
print(answer)
|
if __name__ == '__main__':
n = int(input())
answer = ''
for i in range(n):
answer += str(i + 1)
print(answer)
|
def reset_io(buff):
buff.seek(0)
buff.truncate(0)
return buff
def truncate_io(buff, size):
# get the remainder value
buff.seek(size)
leftover = buff.read()
# remove the remainder
buff.seek(0)
buff.truncate(size)
return leftover
# def diesattheend(pool):
# import atexit
# def close(pool):
# try:
# pool.shutdown(wait=True)
# except OSError: # handle is closed
# pass # we already closed the pool
# atexit.unregister(pool.__del__)
# patch(pool, '__del__', close)
# atexit.register(pool.__del__)
# return pool
#
# def patch(obj, name, func):
# from functools import wraps
# oldfunc = getattr(obj, name, None) or (lambda: None)
# def replaced(*a, **kw):
# if oldfunc:
# oldfunc(*a, **kw)
# func(obj, *a, **kw)
# replaced.__name__ = name
# setattr(obj, name, wraps(oldfunc)(replaced) if oldfunc else replaced)
class FakePool:
def __init__(self, max_workers=None):
pass
def submit(self, func, *a, **kw):
return FakeFuture(func(*a, **kw))
def shutdown(self, wait=None):
pass
class FakeFuture:
def __init__(self, result):
self._result = result
def result(self):
return self._result
def add_done_callback(self, func):
return func(self)
|
def reset_io(buff):
buff.seek(0)
buff.truncate(0)
return buff
def truncate_io(buff, size):
buff.seek(size)
leftover = buff.read()
buff.seek(0)
buff.truncate(size)
return leftover
class Fakepool:
def __init__(self, max_workers=None):
pass
def submit(self, func, *a, **kw):
return fake_future(func(*a, **kw))
def shutdown(self, wait=None):
pass
class Fakefuture:
def __init__(self, result):
self._result = result
def result(self):
return self._result
def add_done_callback(self, func):
return func(self)
|
# This file is part of BenchExec, a framework for reliable benchmarking:
# https://github.com/sosy-lab/benchexec
#
# SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org>
#
# SPDX-License-Identifier: Apache-2.0
"""Main package of BenchExec.
The following modules are the public entry points:
- benchexec: for executing benchmark suites
- runexec: for executing single runs
- check_cgroups: for checking the availability of cgroups
- test_tool_info: for testing a tool-info module
Naming conventions used within BenchExec:
TOOL: a (verification) tool that should be executed
EXECUTABLE: the executable file that should be called for running a TOOL
INPUTFILE: one input file for the TOOL
RUN: one execution of a TOOL on one INPUTFILE
RUNSET: a set of RUNs of one TOOL with at most one RUN per INPUTFILE
RUNDEFINITION: a template for the creation of a RUNSET with RUNS from one or more INPUTFILESETs
BENCHMARK: a list of RUNDEFINITIONs and INPUTFILESETs for one TOOL
OPTION: a user-specified option to add to the command-line of the TOOL when it its run
CONFIG: the configuration of this script consisting of the command-line arguments given by the user
EXECUTOR: a module for executing a BENCHMARK
"run" always denotes a job to do and is never used as a verb.
"execute" is only used as a verb (this is what is done with a run).
A benchmark or a run set can also be executed, which means to execute all contained runs.
Variables ending with "file" contain filenames.
Variables ending with "tag" contain references to XML tag objects created by the XML parser.
"""
__version__ = "3.9-dev"
class BenchExecException(Exception):
pass
|
"""Main package of BenchExec.
The following modules are the public entry points:
- benchexec: for executing benchmark suites
- runexec: for executing single runs
- check_cgroups: for checking the availability of cgroups
- test_tool_info: for testing a tool-info module
Naming conventions used within BenchExec:
TOOL: a (verification) tool that should be executed
EXECUTABLE: the executable file that should be called for running a TOOL
INPUTFILE: one input file for the TOOL
RUN: one execution of a TOOL on one INPUTFILE
RUNSET: a set of RUNs of one TOOL with at most one RUN per INPUTFILE
RUNDEFINITION: a template for the creation of a RUNSET with RUNS from one or more INPUTFILESETs
BENCHMARK: a list of RUNDEFINITIONs and INPUTFILESETs for one TOOL
OPTION: a user-specified option to add to the command-line of the TOOL when it its run
CONFIG: the configuration of this script consisting of the command-line arguments given by the user
EXECUTOR: a module for executing a BENCHMARK
"run" always denotes a job to do and is never used as a verb.
"execute" is only used as a verb (this is what is done with a run).
A benchmark or a run set can also be executed, which means to execute all contained runs.
Variables ending with "file" contain filenames.
Variables ending with "tag" contain references to XML tag objects created by the XML parser.
"""
__version__ = '3.9-dev'
class Benchexecexception(Exception):
pass
|
'''
APDT: Ploting
--------------------------
Provide useful data visualizaton tools.
Check https://github.com/Zhiyuan-Wu/apdt for more information.
'''
|
"""
APDT: Ploting
--------------------------
Provide useful data visualizaton tools.
Check https://github.com/Zhiyuan-Wu/apdt for more information.
"""
|
dead_emcal = [128, 129, 131, 134, 139, 140, 182, 184, 188, 189, 385, 394, 397, 398, 399, 432, 434, 436, 440, 442, 5024, 5025, 5026, 5027, 5028, 5030, 5032, 5033, 5035, 5036, 5037, 5038, 5039, 5121, 5122, 5123, 5124, 5125, 5126, 5128, 5129, 5130, 5132, 5133, 5134, 5135, 5170, 5172, 5173, 5174, 5178, 5181, 6641, 6647, 6654, 6933, 6936, 6941, 6986, 6987, 6990, 8590, 8624, 8626, 8631, 8637, 10580, 10583, 10585, 10586, 10588, 10590, 10591, 10624, 10625, 10626, 10627, 10629, 10630, 10631, 10632, 10636, 10637, 10639, 11232, 11234, 11235, 11236, 11237, 11238, 11239, 11241, 11242, 11244, 11245, 11247, 11280, 11281, 11282, 11283, 11285, 11286, 11287, 11289, 11290, 11292, 11294, 11295]
dead_dcal = [12608, 12831, 12860, 13466, 13470, 13981, 14231, 14312, 14404, 14693, 14695, 14729, 15214, 15215, 15281, 15285, 15323, 15327, 15330, 15332, 15334, 15335, 15336, 15872, 15968, 15970, 15971, 16016, 16017, 16018, 16029, 16030, 16535, 16541, 16577, 16579, 16583, 16610, 16613, 16622, 16659, 16663, 16666, 16824, 17644, 17663]
bad_emcal = [3, 15, 56, 57, 58, 59, 60, 61, 62, 63, 74, 103, 130, 132, 133, 135, 136, 137, 138, 141, 142, 143, 176, 177, 178, 179, 180, 181, 183, 185, 186, 187, 190, 191, 198, 287, 288, 289, 290, 291, 292, 293, 294, 295, 297, 298, 299, 300, 301, 302, 303, 328, 336, 337, 338, 339, 340, 341, 343, 344, 345, 346, 347, 348, 349, 350, 353, 384, 386, 387, 388, 389, 390, 391, 392, 393, 395, 396, 433, 435, 437, 438, 439, 441, 443, 444, 445, 446, 447, 554, 594, 655, 720, 759, 917, 1002, 1038, 1050, 1061, 1067, 1175, 1204, 1212, 1222, 1276, 1288, 1366, 1376, 1380, 1384, 1386, 1414, 1441, 1519, 1534, 1535, 1704, 1711, 1738, 1825, 1836, 1837, 1838, 1839, 1844, 1860, 1892, 1963, 1967, 1968, 2014, 2020, 2022, 2026, 2047, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2122, 2123, 2124, 2125, 2127, 2161, 2196, 2210, 2245, 2298, 2325, 2389, 2395, 2397, 2399, 2424, 2487, 2505, 2506, 2533, 2534, 2540, 2575, 2581, 2586, 2665, 2688, 2776, 2778, 2787, 2793, 2797, 2805, 2823, 2824, 2825, 2857, 2884, 2888, 2891, 2915, 2921, 2985, 3039, 3051, 3135, 3161, 3196, 3223, 3236, 3244, 3259, 3297, 3339, 3353, 3488, 3503, 3732, 3740, 3748, 3754, 3772, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, 3789, 3790, 3791, 3796, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3839, 3840, 3854, 3906, 3908, 3914, 3940, 3962, 3974, 4011, 4026, 4027, 4058, 4129, 4212, 4230, 4282, 4299, 4320, 4372, 4421, 4516, 4530, 4531, 4532, 4538, 4543, 4569, 4571, 4596, 4605, 4613, 4614, 4621, 4627, 4637, 4817, 4835, 4837, 4838, 4839, 4846, 4847, 4967, 5029, 5031, 5034, 5120, 5127, 5131, 5168, 5169, 5171, 5175, 5176, 5177, 5179, 5180, 5182, 5183, 5231, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336, 5337, 5338, 5339, 5340, 5341, 5343, 5448, 5608, 5662, 5663, 5824, 5826, 5831, 5832, 5833, 5850, 6064, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089, 6090, 6091, 6092, 6093, 6094, 6095, 6104, 6128, 6129, 6130, 6131, 6132, 6133, 6134, 6135, 6136, 6137, 6138, 6139, 6140, 6141, 6142, 6143, 6184, 6275, 6331, 6340, 6481, 6640, 6645, 6646, 6649, 6701, 6735, 6811, 6886, 6928, 6929, 6930, 6931, 6932, 6934, 6935, 6937, 6938, 6939, 6940, 6942, 6943, 6976, 6977, 6978, 6979, 6980, 6981, 6982, 6983, 6984, 6985, 6988, 6989, 6991, 7089, 7150, 7371, 7417, 7425, 7430, 7491, 7572, 7793, 8000, 8001, 8002, 8004, 8005, 8006, 8007, 8008, 8009, 8012, 8013, 8014, 8047, 8051, 8052, 8053, 8054, 8055, 8060, 8061, 8062, 8063, 8244, 8260, 8275, 8340, 8352, 8353, 8356, 8357, 8372, 8420, 8453, 8576, 8577, 8578, 8579, 8580, 8581, 8582, 8583, 8584, 8585, 8586, 8587, 8588, 8589, 8591, 8610, 8625, 8627, 8628, 8629, 8630, 8632, 8633, 8634, 8635, 8636, 8638, 8639, 8724, 8807, 8809, 8813, 8855, 8904, 8906, 8907, 8911, 8916, 8938, 8944, 8976, 9078, 9202, 9217, 9269, 9275, 9282, 9286, 9291, 9338, 9354, 9357, 9361, 9533, 9598, 9703, 9706, 9769, 9798, 9801, 9802, 9807, 9819, 9849, 9872, 9874, 9878, 9927, 9940, 9942, 9943, 9945, 9951, 9960, 9982, 9983, 10091, 10138, 10139, 10142, 10164, 10171, 10203, 10326, 10363, 10451, 10462, 10505, 10558, 10560, 10561, 10562, 10563, 10564, 10565, 10566, 10567, 10568, 10569, 10570, 10571, 10572, 10573, 10574, 10575, 10576, 10577, 10578, 10579, 10581, 10582, 10584, 10587, 10589, 10608, 10609, 10610, 10611, 10612, 10613, 10614, 10615, 10616, 10617, 10618, 10619, 10620, 10621, 10622, 10623, 10628, 10633, 10634, 10635, 10638, 10655, 10666, 10750, 10751, 10759, 10798, 10823, 10829, 10831, 10921, 10981, 10982, 10988, 11034, 11042, 11044, 11048, 11050, 11052, 11091, 11093, 11095, 11097, 11099, 11102, 11141, 11148, 11150, 11197, 11198, 11233, 11240, 11243, 11246, 11284, 11288, 11291, 11293, 11411, 11462, 11534, 11551, 11630, 11647, 11738, 11904, 11905, 12033, 12035, 12046, 12047, 12117, 12127, 12147, 12160, 12161, 12162, 12163, 12164, 12165, 12166, 12167, 12168, 12169, 12170, 12171, 12172, 12173, 12174, 12175, 12271, 12276, 12280, 12282, 12286]
bad_dcal = [12320, 12321, 12322, 12323, 12324, 12325, 12326, 12327, 12328, 12329, 12330, 12331, 12332, 12333, 12334, 12335, 12368, 12369, 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, 12384, 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12397, 12398, 12399, 12432, 12433, 12434, 12435, 12436, 12437, 12438, 12439, 12440, 12441, 12442, 12443, 12444, 12445, 12446, 12447, 12487, 12604, 12607, 12609, 12610, 12613, 12614, 12615, 12616, 12617, 12618, 12620, 12621, 12622, 12623, 12800, 12801, 12802, 12803, 12805, 12806, 12807, 12809, 12810, 12811, 12812, 12813, 12814, 12815, 12818, 12821, 12822, 12823, 12826, 12827, 12828, 12829, 12830, 12848, 12850, 12856, 12857, 12858, 12859, 12862, 12914, 12915, 12918, 12922, 12925, 12927, 12988, 13049, 13053, 13055, 13056, 13058, 13059, 13064, 13068, 13120, 13122, 13123, 13126, 13128, 13130, 13131, 13156, 13248, 13249, 13280, 13282, 13284, 13287, 13288, 13290, 13292, 13294, 13392, 13394, 13395, 13398, 13399, 13400, 13402, 13403, 13405, 13406, 13407, 13433, 13458, 13459, 13460, 13462, 13463, 13464, 13465, 13467, 13469, 13471, 13476, 13477, 13478, 13479, 13481, 13483, 13485, 13486, 13487, 13508, 13510, 13512, 13517, 13524, 13553, 13556, 13558, 13559, 13574, 13578, 13589, 13630, 13780, 13786, 13798, 13828, 13835, 13848, 13903, 13921, 13926, 13933, 13953, 13968, 13969, 13972, 13973, 13975, 13980, 13983, 13988, 14017, 14058, 14060, 14081, 14116, 14117, 14119, 14123, 14125, 14126, 14153, 14157, 14191, 14193, 14207, 14225, 14228, 14229, 14233, 14234, 14236, 14237, 14239, 14247, 14249, 14254, 14255, 14302, 14303, 14304, 14305, 14306, 14307, 14308, 14309, 14311, 14313, 14314, 14315, 14317, 14318, 14319, 14320, 14325, 14326, 14362, 14363, 14373, 14374, 14398, 14400, 14402, 14403, 14406, 14407, 14409, 14410, 14411, 14412, 14413, 14414, 14415, 14432, 14433, 14434, 14435, 14436, 14437, 14438, 14439, 14440, 14441, 14442, 14443, 14444, 14445, 14446, 14447, 14480, 14481, 14482, 14483, 14484, 14485, 14486, 14487, 14488, 14489, 14490, 14491, 14492, 14493, 14494, 14495, 14498, 14501, 14502, 14503, 14505, 14544, 14545, 14546, 14549, 14550, 14553, 14554, 14557, 14558, 14559, 14592, 14593, 14594, 14597, 14598, 14602, 14604, 14605, 14607, 14608, 14609, 14610, 14611, 14613, 14616, 14617, 14618, 14621, 14622, 14623, 14624, 14625, 14626, 14627, 14628, 14629, 14630, 14631, 14632, 14633, 14634, 14635, 14636, 14637, 14638, 14639, 14640, 14647, 14657, 14659, 14660, 14661, 14662, 14663, 14668, 14669, 14671, 14672, 14679, 14688, 14689, 14690, 14691, 14692, 14694, 14697, 14698, 14700, 14701, 14702, 14703, 14704, 14705, 14706, 14707, 14708, 14709, 14711, 14712, 14713, 14716, 14717, 14721, 14722, 14723, 14724, 14725, 14726, 14727, 14728, 14730, 14731, 14732, 14733, 14734, 14735, 14736, 14737, 14738, 14739, 14740, 14741, 14742, 14744, 14745, 14746, 14747, 14748, 14749, 14750, 14752, 14753, 14754, 14755, 14756, 14757, 14758, 14759, 14760, 14761, 14762, 14763, 14764, 14765, 14766, 14767, 14768, 14770, 14772, 14773, 14774, 14775, 14776, 14777, 14779, 14782, 14783, 14839, 14862, 14867, 14872, 14874, 14895, 14977, 14980, 14991, 14993, 15009, 15012, 15015, 15020, 15021, 15027, 15033, 15094, 15096, 15137, 15140, 15143, 15152, 15154, 15155, 15158, 15162, 15164, 15200, 15201, 15202, 15203, 15204, 15205, 15206, 15207, 15208, 15209, 15210, 15211, 15212, 15213, 15217, 15266, 15272, 15276, 15280, 15282, 15284, 15286, 15287, 15288, 15289, 15290, 15291, 15292, 15293, 15294, 15295, 15296, 15298, 15299, 15314, 15315, 15318, 15328, 15331, 15333, 15338, 15339, 15341, 15342, 15343, 15345, 15354, 15359, 15398, 15445, 15460, 15463, 15469, 15470, 15476, 15624, 15670, 15690, 15719, 15754, 15776, 15777, 15785, 15821, 15870, 15877, 15908, 15936, 15947, 15949, 15955, 15958, 15963, 15965, 15967, 15969, 15972, 15979, 15980, 15981, 15982, 15983, 16019, 16026, 16028, 16031, 16082, 16083, 16088, 16089, 16090, 16091, 16094, 16215, 16258, 16268, 16304, 16306, 16307, 16308, 16311, 16317, 16349, 16395, 16422, 16428, 16429, 16431, 16440, 16442, 16443, 16446, 16466, 16467, 16468, 16469, 16472, 16473, 16474, 16475, 16476, 16477, 16478, 16479, 16481, 16482, 16483, 16488, 16489, 16491, 16492, 16493, 16496, 16497, 16498, 16500, 16501, 16502, 16506, 16509, 16510, 16511, 16528, 16529, 16530, 16531, 16532, 16533, 16534, 16536, 16537, 16538, 16539, 16540, 16542, 16543, 16576, 16578, 16580, 16581, 16582, 16584, 16585, 16586, 16587, 16588, 16589, 16590, 16591, 16608, 16609, 16611, 16612, 16614, 16615, 16616, 16617, 16618, 16619, 16620, 16621, 16623, 16634, 16656, 16657, 16658, 16660, 16661, 16662, 16664, 16665, 16667, 16668, 16669, 16670, 16671, 16784, 16785, 16789, 16821, 16826, 16830, 16886, 16907, 16911, 16927, 17046, 17088, 17089, 17090, 17091, 17097, 17107, 17117, 17202, 17203, 17204, 17206, 17232, 17233, 17234, 17236, 17237, 17249, 17265, 17291, 17295, 17296, 17312, 17313, 17314, 17315, 17316, 17317, 17318, 17319, 17320, 17321, 17322, 17323, 17324, 17325, 17326, 17327, 17328, 17329, 17330, 17331, 17332, 17333, 17334, 17335, 17336, 17337, 17338, 17339, 17340, 17341, 17342, 17343, 17352, 17377, 17381, 17396, 17452, 17463, 17537, 17597, 17632, 17633, 17634, 17635, 17636, 17637, 17638, 17639, 17640, 17641, 17642, 17643, 17645, 17646, 17647, 17648, 17649, 17650, 17651, 17652, 17653, 17654, 17655, 17656, 17657, 17658, 17659, 17660, 17661, 17662]
warm_emcal = [15, 594, 1276, 1384, 2113, 2127, 2389, 2778, 3135, 4299, 4531, 4569, 4571, 4605, 5608, 5832, 6340, 6640, 6646, 6886, 8000, 8001, 8004, 8005, 8006, 8007, 8009, 8014, 8051, 8052, 8053, 8054, 8055, 8061, 8813, 8855, 8904, 8906, 8907, 8911, 8944, 9202, 9217, 9819, 9849, 9872, 9878, 10091, 10462, 10558, 10655, 10750, 10751, 10798, 11034, 11042, 11044, 11050, 11052, 11093, 11095, 11097, 11099, 11102, 11148, 11150, 11197, 11198, 11411, 11534, 11551, 11647, 11904, 12033, 12035, 12046, 12047, 12117, 12127, 12271, 12276, 12280, 12282, 12286]
warm_dcal = [12609, 12610, 12613, 12615, 12616, 12617, 12618, 12620, 12807, 12811, 12812, 12813, 12818, 12823, 12829, 12830, 12850, 12858, 12914, 12922, 12988, 13056, 13058, 13120, 13128, 13130, 13131, 13288, 13395, 13398, 13399, 13405, 13458, 13462, 13463, 13469, 13477, 13479, 13481, 13483, 13486, 13487, 13512, 13517, 13553, 13574, 13630, 13780, 13786, 13798, 13848, 13921, 13973, 13975, 13980, 13983, 14058, 14081, 14116, 14126, 14304, 14320, 14326, 14362, 14363, 14400, 14402, 14407, 14409, 14411, 14412, 14414, 14498, 14501, 14545, 14546, 14593, 14597, 14609, 14613, 14621, 14622, 14623, 14657, 14659, 14661, 14671, 14703, 14705, 14706, 14707, 14708, 14716, 14717, 14721, 14722, 14725, 14728, 14731, 14739, 14740, 14746, 14748, 14749, 14752, 14759, 14762, 14768, 14770, 14774, 14776, 14777, 14782, 14783, 14874, 15027, 15154, 15158, 15162, 15280, 15284, 15287, 15289, 15290, 15292, 15293, 15298, 15314, 15315, 15341, 15342, 15460, 15470, 15476, 15776, 15947, 15967, 16082, 16083, 16090, 16306, 16308, 16431, 16442, 16466, 16469, 16472, 16475, 16483, 16489, 16491, 16497, 16502, 16510, 16907, 16911, 16927, 17088, 17090, 17107, 17296, 17352, 17396, 17452, 17463]
bad_all = dead_emcal + dead_dcal + bad_emcal + bad_dcal + warm_emcal + warm_dcal
|
dead_emcal = [128, 129, 131, 134, 139, 140, 182, 184, 188, 189, 385, 394, 397, 398, 399, 432, 434, 436, 440, 442, 5024, 5025, 5026, 5027, 5028, 5030, 5032, 5033, 5035, 5036, 5037, 5038, 5039, 5121, 5122, 5123, 5124, 5125, 5126, 5128, 5129, 5130, 5132, 5133, 5134, 5135, 5170, 5172, 5173, 5174, 5178, 5181, 6641, 6647, 6654, 6933, 6936, 6941, 6986, 6987, 6990, 8590, 8624, 8626, 8631, 8637, 10580, 10583, 10585, 10586, 10588, 10590, 10591, 10624, 10625, 10626, 10627, 10629, 10630, 10631, 10632, 10636, 10637, 10639, 11232, 11234, 11235, 11236, 11237, 11238, 11239, 11241, 11242, 11244, 11245, 11247, 11280, 11281, 11282, 11283, 11285, 11286, 11287, 11289, 11290, 11292, 11294, 11295]
dead_dcal = [12608, 12831, 12860, 13466, 13470, 13981, 14231, 14312, 14404, 14693, 14695, 14729, 15214, 15215, 15281, 15285, 15323, 15327, 15330, 15332, 15334, 15335, 15336, 15872, 15968, 15970, 15971, 16016, 16017, 16018, 16029, 16030, 16535, 16541, 16577, 16579, 16583, 16610, 16613, 16622, 16659, 16663, 16666, 16824, 17644, 17663]
bad_emcal = [3, 15, 56, 57, 58, 59, 60, 61, 62, 63, 74, 103, 130, 132, 133, 135, 136, 137, 138, 141, 142, 143, 176, 177, 178, 179, 180, 181, 183, 185, 186, 187, 190, 191, 198, 287, 288, 289, 290, 291, 292, 293, 294, 295, 297, 298, 299, 300, 301, 302, 303, 328, 336, 337, 338, 339, 340, 341, 343, 344, 345, 346, 347, 348, 349, 350, 353, 384, 386, 387, 388, 389, 390, 391, 392, 393, 395, 396, 433, 435, 437, 438, 439, 441, 443, 444, 445, 446, 447, 554, 594, 655, 720, 759, 917, 1002, 1038, 1050, 1061, 1067, 1175, 1204, 1212, 1222, 1276, 1288, 1366, 1376, 1380, 1384, 1386, 1414, 1441, 1519, 1534, 1535, 1704, 1711, 1738, 1825, 1836, 1837, 1838, 1839, 1844, 1860, 1892, 1963, 1967, 1968, 2014, 2020, 2022, 2026, 2047, 2112, 2113, 2114, 2115, 2116, 2117, 2118, 2119, 2120, 2122, 2123, 2124, 2125, 2127, 2161, 2196, 2210, 2245, 2298, 2325, 2389, 2395, 2397, 2399, 2424, 2487, 2505, 2506, 2533, 2534, 2540, 2575, 2581, 2586, 2665, 2688, 2776, 2778, 2787, 2793, 2797, 2805, 2823, 2824, 2825, 2857, 2884, 2888, 2891, 2915, 2921, 2985, 3039, 3051, 3135, 3161, 3196, 3223, 3236, 3244, 3259, 3297, 3339, 3353, 3488, 3503, 3732, 3740, 3748, 3754, 3772, 3776, 3777, 3778, 3779, 3780, 3781, 3782, 3783, 3784, 3785, 3786, 3787, 3788, 3789, 3790, 3791, 3796, 3824, 3825, 3826, 3827, 3828, 3829, 3830, 3831, 3832, 3833, 3834, 3835, 3839, 3840, 3854, 3906, 3908, 3914, 3940, 3962, 3974, 4011, 4026, 4027, 4058, 4129, 4212, 4230, 4282, 4299, 4320, 4372, 4421, 4516, 4530, 4531, 4532, 4538, 4543, 4569, 4571, 4596, 4605, 4613, 4614, 4621, 4627, 4637, 4817, 4835, 4837, 4838, 4839, 4846, 4847, 4967, 5029, 5031, 5034, 5120, 5127, 5131, 5168, 5169, 5171, 5175, 5176, 5177, 5179, 5180, 5182, 5183, 5231, 5328, 5329, 5330, 5331, 5332, 5333, 5334, 5335, 5336, 5337, 5338, 5339, 5340, 5341, 5343, 5448, 5608, 5662, 5663, 5824, 5826, 5831, 5832, 5833, 5850, 6064, 6080, 6081, 6082, 6083, 6084, 6085, 6086, 6087, 6088, 6089, 6090, 6091, 6092, 6093, 6094, 6095, 6104, 6128, 6129, 6130, 6131, 6132, 6133, 6134, 6135, 6136, 6137, 6138, 6139, 6140, 6141, 6142, 6143, 6184, 6275, 6331, 6340, 6481, 6640, 6645, 6646, 6649, 6701, 6735, 6811, 6886, 6928, 6929, 6930, 6931, 6932, 6934, 6935, 6937, 6938, 6939, 6940, 6942, 6943, 6976, 6977, 6978, 6979, 6980, 6981, 6982, 6983, 6984, 6985, 6988, 6989, 6991, 7089, 7150, 7371, 7417, 7425, 7430, 7491, 7572, 7793, 8000, 8001, 8002, 8004, 8005, 8006, 8007, 8008, 8009, 8012, 8013, 8014, 8047, 8051, 8052, 8053, 8054, 8055, 8060, 8061, 8062, 8063, 8244, 8260, 8275, 8340, 8352, 8353, 8356, 8357, 8372, 8420, 8453, 8576, 8577, 8578, 8579, 8580, 8581, 8582, 8583, 8584, 8585, 8586, 8587, 8588, 8589, 8591, 8610, 8625, 8627, 8628, 8629, 8630, 8632, 8633, 8634, 8635, 8636, 8638, 8639, 8724, 8807, 8809, 8813, 8855, 8904, 8906, 8907, 8911, 8916, 8938, 8944, 8976, 9078, 9202, 9217, 9269, 9275, 9282, 9286, 9291, 9338, 9354, 9357, 9361, 9533, 9598, 9703, 9706, 9769, 9798, 9801, 9802, 9807, 9819, 9849, 9872, 9874, 9878, 9927, 9940, 9942, 9943, 9945, 9951, 9960, 9982, 9983, 10091, 10138, 10139, 10142, 10164, 10171, 10203, 10326, 10363, 10451, 10462, 10505, 10558, 10560, 10561, 10562, 10563, 10564, 10565, 10566, 10567, 10568, 10569, 10570, 10571, 10572, 10573, 10574, 10575, 10576, 10577, 10578, 10579, 10581, 10582, 10584, 10587, 10589, 10608, 10609, 10610, 10611, 10612, 10613, 10614, 10615, 10616, 10617, 10618, 10619, 10620, 10621, 10622, 10623, 10628, 10633, 10634, 10635, 10638, 10655, 10666, 10750, 10751, 10759, 10798, 10823, 10829, 10831, 10921, 10981, 10982, 10988, 11034, 11042, 11044, 11048, 11050, 11052, 11091, 11093, 11095, 11097, 11099, 11102, 11141, 11148, 11150, 11197, 11198, 11233, 11240, 11243, 11246, 11284, 11288, 11291, 11293, 11411, 11462, 11534, 11551, 11630, 11647, 11738, 11904, 11905, 12033, 12035, 12046, 12047, 12117, 12127, 12147, 12160, 12161, 12162, 12163, 12164, 12165, 12166, 12167, 12168, 12169, 12170, 12171, 12172, 12173, 12174, 12175, 12271, 12276, 12280, 12282, 12286]
bad_dcal = [12320, 12321, 12322, 12323, 12324, 12325, 12326, 12327, 12328, 12329, 12330, 12331, 12332, 12333, 12334, 12335, 12368, 12369, 12370, 12371, 12372, 12373, 12374, 12375, 12376, 12377, 12378, 12379, 12380, 12381, 12382, 12383, 12384, 12385, 12386, 12387, 12388, 12389, 12390, 12391, 12392, 12393, 12394, 12395, 12396, 12397, 12398, 12399, 12432, 12433, 12434, 12435, 12436, 12437, 12438, 12439, 12440, 12441, 12442, 12443, 12444, 12445, 12446, 12447, 12487, 12604, 12607, 12609, 12610, 12613, 12614, 12615, 12616, 12617, 12618, 12620, 12621, 12622, 12623, 12800, 12801, 12802, 12803, 12805, 12806, 12807, 12809, 12810, 12811, 12812, 12813, 12814, 12815, 12818, 12821, 12822, 12823, 12826, 12827, 12828, 12829, 12830, 12848, 12850, 12856, 12857, 12858, 12859, 12862, 12914, 12915, 12918, 12922, 12925, 12927, 12988, 13049, 13053, 13055, 13056, 13058, 13059, 13064, 13068, 13120, 13122, 13123, 13126, 13128, 13130, 13131, 13156, 13248, 13249, 13280, 13282, 13284, 13287, 13288, 13290, 13292, 13294, 13392, 13394, 13395, 13398, 13399, 13400, 13402, 13403, 13405, 13406, 13407, 13433, 13458, 13459, 13460, 13462, 13463, 13464, 13465, 13467, 13469, 13471, 13476, 13477, 13478, 13479, 13481, 13483, 13485, 13486, 13487, 13508, 13510, 13512, 13517, 13524, 13553, 13556, 13558, 13559, 13574, 13578, 13589, 13630, 13780, 13786, 13798, 13828, 13835, 13848, 13903, 13921, 13926, 13933, 13953, 13968, 13969, 13972, 13973, 13975, 13980, 13983, 13988, 14017, 14058, 14060, 14081, 14116, 14117, 14119, 14123, 14125, 14126, 14153, 14157, 14191, 14193, 14207, 14225, 14228, 14229, 14233, 14234, 14236, 14237, 14239, 14247, 14249, 14254, 14255, 14302, 14303, 14304, 14305, 14306, 14307, 14308, 14309, 14311, 14313, 14314, 14315, 14317, 14318, 14319, 14320, 14325, 14326, 14362, 14363, 14373, 14374, 14398, 14400, 14402, 14403, 14406, 14407, 14409, 14410, 14411, 14412, 14413, 14414, 14415, 14432, 14433, 14434, 14435, 14436, 14437, 14438, 14439, 14440, 14441, 14442, 14443, 14444, 14445, 14446, 14447, 14480, 14481, 14482, 14483, 14484, 14485, 14486, 14487, 14488, 14489, 14490, 14491, 14492, 14493, 14494, 14495, 14498, 14501, 14502, 14503, 14505, 14544, 14545, 14546, 14549, 14550, 14553, 14554, 14557, 14558, 14559, 14592, 14593, 14594, 14597, 14598, 14602, 14604, 14605, 14607, 14608, 14609, 14610, 14611, 14613, 14616, 14617, 14618, 14621, 14622, 14623, 14624, 14625, 14626, 14627, 14628, 14629, 14630, 14631, 14632, 14633, 14634, 14635, 14636, 14637, 14638, 14639, 14640, 14647, 14657, 14659, 14660, 14661, 14662, 14663, 14668, 14669, 14671, 14672, 14679, 14688, 14689, 14690, 14691, 14692, 14694, 14697, 14698, 14700, 14701, 14702, 14703, 14704, 14705, 14706, 14707, 14708, 14709, 14711, 14712, 14713, 14716, 14717, 14721, 14722, 14723, 14724, 14725, 14726, 14727, 14728, 14730, 14731, 14732, 14733, 14734, 14735, 14736, 14737, 14738, 14739, 14740, 14741, 14742, 14744, 14745, 14746, 14747, 14748, 14749, 14750, 14752, 14753, 14754, 14755, 14756, 14757, 14758, 14759, 14760, 14761, 14762, 14763, 14764, 14765, 14766, 14767, 14768, 14770, 14772, 14773, 14774, 14775, 14776, 14777, 14779, 14782, 14783, 14839, 14862, 14867, 14872, 14874, 14895, 14977, 14980, 14991, 14993, 15009, 15012, 15015, 15020, 15021, 15027, 15033, 15094, 15096, 15137, 15140, 15143, 15152, 15154, 15155, 15158, 15162, 15164, 15200, 15201, 15202, 15203, 15204, 15205, 15206, 15207, 15208, 15209, 15210, 15211, 15212, 15213, 15217, 15266, 15272, 15276, 15280, 15282, 15284, 15286, 15287, 15288, 15289, 15290, 15291, 15292, 15293, 15294, 15295, 15296, 15298, 15299, 15314, 15315, 15318, 15328, 15331, 15333, 15338, 15339, 15341, 15342, 15343, 15345, 15354, 15359, 15398, 15445, 15460, 15463, 15469, 15470, 15476, 15624, 15670, 15690, 15719, 15754, 15776, 15777, 15785, 15821, 15870, 15877, 15908, 15936, 15947, 15949, 15955, 15958, 15963, 15965, 15967, 15969, 15972, 15979, 15980, 15981, 15982, 15983, 16019, 16026, 16028, 16031, 16082, 16083, 16088, 16089, 16090, 16091, 16094, 16215, 16258, 16268, 16304, 16306, 16307, 16308, 16311, 16317, 16349, 16395, 16422, 16428, 16429, 16431, 16440, 16442, 16443, 16446, 16466, 16467, 16468, 16469, 16472, 16473, 16474, 16475, 16476, 16477, 16478, 16479, 16481, 16482, 16483, 16488, 16489, 16491, 16492, 16493, 16496, 16497, 16498, 16500, 16501, 16502, 16506, 16509, 16510, 16511, 16528, 16529, 16530, 16531, 16532, 16533, 16534, 16536, 16537, 16538, 16539, 16540, 16542, 16543, 16576, 16578, 16580, 16581, 16582, 16584, 16585, 16586, 16587, 16588, 16589, 16590, 16591, 16608, 16609, 16611, 16612, 16614, 16615, 16616, 16617, 16618, 16619, 16620, 16621, 16623, 16634, 16656, 16657, 16658, 16660, 16661, 16662, 16664, 16665, 16667, 16668, 16669, 16670, 16671, 16784, 16785, 16789, 16821, 16826, 16830, 16886, 16907, 16911, 16927, 17046, 17088, 17089, 17090, 17091, 17097, 17107, 17117, 17202, 17203, 17204, 17206, 17232, 17233, 17234, 17236, 17237, 17249, 17265, 17291, 17295, 17296, 17312, 17313, 17314, 17315, 17316, 17317, 17318, 17319, 17320, 17321, 17322, 17323, 17324, 17325, 17326, 17327, 17328, 17329, 17330, 17331, 17332, 17333, 17334, 17335, 17336, 17337, 17338, 17339, 17340, 17341, 17342, 17343, 17352, 17377, 17381, 17396, 17452, 17463, 17537, 17597, 17632, 17633, 17634, 17635, 17636, 17637, 17638, 17639, 17640, 17641, 17642, 17643, 17645, 17646, 17647, 17648, 17649, 17650, 17651, 17652, 17653, 17654, 17655, 17656, 17657, 17658, 17659, 17660, 17661, 17662]
warm_emcal = [15, 594, 1276, 1384, 2113, 2127, 2389, 2778, 3135, 4299, 4531, 4569, 4571, 4605, 5608, 5832, 6340, 6640, 6646, 6886, 8000, 8001, 8004, 8005, 8006, 8007, 8009, 8014, 8051, 8052, 8053, 8054, 8055, 8061, 8813, 8855, 8904, 8906, 8907, 8911, 8944, 9202, 9217, 9819, 9849, 9872, 9878, 10091, 10462, 10558, 10655, 10750, 10751, 10798, 11034, 11042, 11044, 11050, 11052, 11093, 11095, 11097, 11099, 11102, 11148, 11150, 11197, 11198, 11411, 11534, 11551, 11647, 11904, 12033, 12035, 12046, 12047, 12117, 12127, 12271, 12276, 12280, 12282, 12286]
warm_dcal = [12609, 12610, 12613, 12615, 12616, 12617, 12618, 12620, 12807, 12811, 12812, 12813, 12818, 12823, 12829, 12830, 12850, 12858, 12914, 12922, 12988, 13056, 13058, 13120, 13128, 13130, 13131, 13288, 13395, 13398, 13399, 13405, 13458, 13462, 13463, 13469, 13477, 13479, 13481, 13483, 13486, 13487, 13512, 13517, 13553, 13574, 13630, 13780, 13786, 13798, 13848, 13921, 13973, 13975, 13980, 13983, 14058, 14081, 14116, 14126, 14304, 14320, 14326, 14362, 14363, 14400, 14402, 14407, 14409, 14411, 14412, 14414, 14498, 14501, 14545, 14546, 14593, 14597, 14609, 14613, 14621, 14622, 14623, 14657, 14659, 14661, 14671, 14703, 14705, 14706, 14707, 14708, 14716, 14717, 14721, 14722, 14725, 14728, 14731, 14739, 14740, 14746, 14748, 14749, 14752, 14759, 14762, 14768, 14770, 14774, 14776, 14777, 14782, 14783, 14874, 15027, 15154, 15158, 15162, 15280, 15284, 15287, 15289, 15290, 15292, 15293, 15298, 15314, 15315, 15341, 15342, 15460, 15470, 15476, 15776, 15947, 15967, 16082, 16083, 16090, 16306, 16308, 16431, 16442, 16466, 16469, 16472, 16475, 16483, 16489, 16491, 16497, 16502, 16510, 16907, 16911, 16927, 17088, 17090, 17107, 17296, 17352, 17396, 17452, 17463]
bad_all = dead_emcal + dead_dcal + bad_emcal + bad_dcal + warm_emcal + warm_dcal
|
#!/usr/bin/python3
#---------------------- Begin Serializer Boilerplate for GAPS ------------------------
HHEAD='''#ifndef GMA_HEADER_FILE
#define GMA_HEADER_FILE
#pragma pack(1)
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include <float.h>
#include "float754.h"
#define id(X) (X)
typedef struct _trailer_datatype {
uint32_t seq;
uint32_t rqr;
uint32_t oid;
uint16_t mid;
uint16_t crc;
} trailer_datatype;
'''
HTAIL='''#endif
'''
FLOATH='''#ifndef _FLOAT_H_
#define _FLOAT_H_
/* Network order for double/float: 0 = Little endian, 1 = Big endian */
/* Currently our DFDL uses littleEndian network order for float and double */
/* This choice was based on the convention used by the shapeFile format */
/* We are preserving bigEndian order for all integer types including uint64_t */
#define FLOAT_BIG_ENDIAN 0
#define big_end_test (1==htonl(1))
#define swap_uint16(x) (((uint16_t) ((x) & 0xFF) << 8) | (((x) & 0xFF00) >> 8))
#define swap_uint32(x) (((uint32_t)swap_uint16((x) & 0xFFFF) << 16) | swap_uint16((x) >> 16))
#define swap_uint64(x) (((uint64_t)swap_uint32((x) & 0xFFFFFFFF) << 32) | swap_uint32((x) >> 32))
#define my_htoxll(x) (big_end_test ? swap_uint64(x) : (x))
#define my_htoxl(x) (big_end_test ? swap_uint32(x) : (x))
#define my_htonll(x) (big_end_test ? (x) : swap_uint64(x))
#define my_htonl(x) (big_end_test ? (x) : swap_uint32(x))
/* Functions / macros called by user */
#define htonll(x) my_htonll(x)
#define ntohll(x) my_htonll(x)
extern uint32_t htonf(float);
extern float ntohf(uint32_t);
extern uint64_t htond(long double);
extern long double ntohd(uint64_t);
#endif /* _FLOAT_H_ */
'''
FLOATC='''/*
* FLOAT.C
* IEEE-754 uint64_t encoding/decoding, plus conversion macros into/from network (x865) byte order
*
* 1) Pack (double/float) encoder and decoder using: https://beej.us/guide/bgnet/examples/ieee754.c
* a) uint64_t = 1-bit Sign (1=-), 11-bit Biased Exponent (BE), 52-bit Normalised Mantisa (NM)
* e.g., 85.125 = 1.010101001 x 2^6 => S=0, BE=(bias=1023)+(6)=10000000101, NM=010101001000000...
* n) uint32_t = 1-bit Sign (1=-), 8-bit Biased Exponent (BE), 23-bit Normalised Mantisa (NM)
*
* 2) Endian converter changes byte order between host encoded (uint_xx_t) and big-endian network format
(unless FLOAT_BIG_ENDIAN=0, in which case it converts to a little-endian network format)
*/
#include <stdio.h>
#include <stdint.h>
#include <inttypes.h>
#include <arpa/inet.h>
#include "float754.h"
#define pack754_32(f) (pack754((f), 32, 8))
#define pack754_64(f) (pack754((f), 64, 11))
#define unpack754_32(i) (unpack754((i), 32, 8))
#define unpack754_64(i) (unpack754((i), 64, 11))
/* Encoding into IEEE-754 encoded double */
uint64_t pack754(long double f, unsigned bits, unsigned expbits)
{
long double fnorm;
int shift;
long long sign, exp, significand;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (f == 0.0) return 0; // get this special case out of the way
// check sign and begin normalization
if (f < 0) { sign = 1; fnorm = -f; }
else { sign = 0; fnorm = f; }
// get the normalized form of f and track the exponent
shift = 0;
while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }
while(fnorm < 1.0) { fnorm *= 2.0; shift--; }
fnorm = fnorm - 1.0;
// calculate the binary form (non-float) of the significand data
significand = fnorm * ((1LL<<significandbits) + 0.5f);
// get the biased exponent
exp = shift + ((1<<(expbits-1)) - 1); // shift + bias
// return the final answer
return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;
}
/* Decoding from IEEE-754 encoded double */
long double unpack754(uint64_t i, unsigned bits, unsigned expbits)
{
long double result;
long long shift;
unsigned bias;
unsigned significandbits = bits - expbits - 1; // -1 for sign bit
if (i == 0) return 0.0;
// pull the significand
result = (i&((1LL<<significandbits)-1)); // mask
result /= (1LL<<significandbits); // convert back to float
result += 1.0f; // add the one back on
// deal with the exponent
bias = (1<<(expbits-1)) - 1;
shift = ((i>>significandbits)&((1LL<<expbits)-1)) - bias;
while(shift > 0) { result *= 2.0; shift--; }
while(shift < 0) { result /= 2.0; shift++; }
// sign it
result *= (i>>(bits-1))&1? -1.0: 1.0;
return result;
}
/* Converts host float by encoding into IEEE-754 uint32_t and putting into Network byte order */
uint32_t htonf(float f) {
uint32_t h = pack754_32(f);
if (FLOAT_BIG_ENDIAN != 0) return ((my_htonl(h))); /* to Network Big-Endian */
else return ((my_htoxl(h))); /* to Network Little-Endian */
}
/* Converts IEEE-754 uint32_t in Network byte order into host float */
float ntohf(uint32_t i) {
uint32_t h;
if (FLOAT_BIG_ENDIAN != 0) h = (my_htonl(i)); /* from Network Big-Endian */
else h = (my_htoxl(i)); /* from Network Little-Endian */
return (unpack754_32(h));
}
/* Converts host double by encoding into IEEE-754 uint64_t and putting into Network byte order */
uint64_t htond(long double f) {
uint64_t h = pack754_64(f);
if (FLOAT_BIG_ENDIAN != 0) return ((my_htonll(h))); /* to Network Big-Endian */
else return ((my_htoxll(h))); /* to Network Little-Endian */
}
/* Converts IEEE-754 uint64_t in Network byte order into host double */
long double ntohd(uint64_t i) {
uint64_t h;
if (FLOAT_BIG_ENDIAN != 0) h = (my_htonll(i)); /* from Network Big-Endian */
else h = (my_htoxll(i)); /* from Network Little-Endian */
return (unpack754_64(h));
}
'''
#---------------------- End Serializer Boilerplate for GAPS ------------------------
cintyp = {
'double': 'double',
'ffloat': 'float',
'int8': 'int8_t',
'uint8': 'uint8_t',
'int16': 'int16_t',
'uint16': 'uint16_t',
'int32': 'int32_t',
'uint32': 'uint32_t',
'int64': 'int64_t',
'uint64': 'uint64_t'
}
coutyp = {
'double': 'uint64_t',
'ffloat': 'uint32_t',
'int8': 'int8_t',
'uint8': 'uint8_t',
'int16': 'int16_t',
'uint16': 'uint16_t',
'int32': 'int32_t',
'uint32': 'uint32_t',
'int64': 'int64_t',
'uint64': 'uint64_t'
}
fmtstr = {
'double': '%lf',
'ffloat': '%f',
'int8': '%hd',
'uint8': '%hu',
'int16': '%hd',
'uint16': '%hu',
'int32': '%d',
'uint32': '%u',
'int64': '%ld',
'uint64': '%lu'
}
encfn = {
'double': 'htond',
'ffloat': 'htonf',
'int8': 'id',
'uint8': 'id',
'int16': 'htons',
'uint16': 'htons',
'int32': 'htonl',
'uint32': 'htonl',
'int64': 'htonll',
'uint64': 'htonll'
}
decfn = {
'double': 'ntohd',
'ffloat': 'ntohf',
'int8': 'id',
'uint8': 'id',
'int16': 'ntohs',
'uint16': 'ntohs',
'int32': 'ntohl',
'uint32': 'ntohl',
'int64': 'ntohll',
'uint64': 'ntohll'
}
class CodecWriter:
def __init__(self,typbase=0):
self.typbase=typbase
def make_scalar(self,d,f,ser,inp):
appstr = ''
if ser == 'header':
t = cintyp[f[0]] if inp else coutyp[f[0]]
appstr += ' ' + t + ' ' + f[1] + ';' + '\n'
elif ser == 'printer':
appstr += ' ' + 'fprintf(stderr, " ' + fmtstr[f[0]] + ',", ' + d + '->' + f[1] + ');' + '\n'
elif ser == 'encoder':
appstr += ' ' + 'p2->' + f[1] + ' = ' + encfn[f[0]] + '(p1->' + f[1] + ');' + '\n'
elif ser == 'decoder':
appstr += ' ' + 'p2->' + f[1] + ' = ' + decfn[f[0]] + '(p1->' + f[1] + ');' + '\n'
elif ser == 'sizeof':
appstr += 'sizeof(' + cintyp[f[0]] + ') + '
else:
raise Exception('Unknown serializarion: ' + ser)
return appstr
def make_array(self,d,f,ser,inp):
appstr = ''
if ser == 'header':
t = cintyp[f[0]] if inp else coutyp[f[0]]
appstr += ' ' + t + ' ' + f[1] + '[' + str(f[2]) + '];' + '\n'
elif ser == 'printer':
appstr += ' for (int i=0; i<' + str(f[2]) + '; i++) {' + '\n'
appstr += ' ' + 'fprintf(stderr, " ' + fmtstr[f[0]] + ',", ' + d + '->' + f[1] + '[i]);' + '\n'
appstr += ' }' + '\n'
elif ser == 'encoder':
appstr += ' for (int i=0; i<' + str(f[2]) + '; i++) {' + '\n'
appstr += ' ' + 'p2->' + f[1] + '[i] = ' + encfn[f[0]] + '(p1->' + f[1] + '[i]);' + '\n'
appstr += ' }' + '\n'
elif ser == 'decoder':
appstr += ' for (int i=0; i<' + str(f[2]) + '; i++) {' + '\n'
appstr += ' ' + 'p2->' + f[1] + '[i] = ' + decfn[f[0]] + '(p1->' + f[1] + '[i]);' + '\n'
appstr += ' }' + '\n'
elif ser == 'sizeof':
appstr += 'sizeof(' + cintyp[f[0]] + ') * ' + str(f[2]) + ' + '
else:
raise Exception('Unknown serialization: ' + ser)
return appstr
def make_dtyp_enum(self,tree):
dtypid = 0
appstr = ''
appstr += '#ifndef TYP_BASE' + '\n'
appstr += '#define TYP_BASE ' + str(self.typbase) + '\n'
appstr += '#endif /* TYP_BASE */' + '\n'
for dtypnm in [l[0] for l in tree]:
dtypid += 1
appstr += '#define DATA_TYP_' + dtypnm.upper() + ' TYP_BASE + ' + str(dtypid) + '\n'
return appstr + '\n'
def make_structs(self,dtypnm,flds,inp=True):
appstr = ''
d = dtypnm.lower()
istr = 'datatype' if inp else 'output'
appstr += 'typedef struct _' + d + '_' + istr + ' {' + '\n'
for f in flds:
if len(f) == 2: appstr += self.make_scalar(d,f,'header',inp)
elif len(f) == 3: appstr += self.make_array(d,f,'header',inp)
else: raise Exception('Unhandled field: ' + f)
appstr += ' trailer_datatype trailer;' + '\n'
appstr += '} ' + d + '_' + istr + ';' + '\n'
return appstr + '\n'
def make_dtyp_struct(self,tree):
appstr = ''
for l in tree:
appstr += self.make_structs(l[0], l[1:],True)
appstr += self.make_structs(l[0], l[1:], False)
return appstr
def make_fn_sigs(self,tree):
dtypid = 0
appstr = ''
for dtypnm in [l[0] for l in tree]:
dtypid += 1
d = dtypnm.lower()
appstr += 'extern void ' + d + '_print (' + d + '_datatype *' + d + ');' + '\n'
appstr += 'extern void ' + d + '_data_encode (void *buff_out, void *buff_in, size_t *len_out);' + '\n'
appstr += 'extern void ' + d + '_data_decode (void *buff_out, void *buff_in, size_t *len_in);' + '\n'
appstr += '\n'
return appstr
def make_print_fn(self,l):
appstr = ''
d = l[0].lower()
appstr += 'void ' + d + '_print (' + d + '_datatype *' + d + ') {' + '\n'
appstr += ' fprintf(stderr, "' + d + '(len=%ld): ", sizeof(*' + d + '));' + '\n'
for f in l[1:]:
if len(f) == 2: appstr += self.make_scalar(d,f,'printer',True)
elif len(f) == 3: appstr += self.make_array(d,f,'printer',True)
else: raise Exception('Unhandled field: ' + f)
appstr += ' fprintf(stderr, " %u, %u, %u, %hu, %hu\\n",' + '\n'
appstr += ' ' + d + '->trailer.seq,' + '\n'
appstr += ' ' + d + '->trailer.rqr,' + '\n'
appstr += ' ' + d + '->trailer.oid,' + '\n'
appstr += ' ' + d + '->trailer.mid,' + '\n'
appstr += ' ' + d + '->trailer.crc);' + '\n'
appstr += '}' + '\n\n'
return appstr
def make_encode_fn(self,l):
appstr = ''
d = l[0].lower()
appstr += 'void ' + d + '_data_encode (void *buff_out, void *buff_in, size_t *len_out) {' + '\n'
appstr += ' ' + d + '_datatype *p1 = (' + d + '_datatype *) buff_in;' + '\n'
appstr += ' ' + d + '_output *p2 = (' + d + '_output *) buff_out;' + '\n'
for f in l[1:]:
if len(f) == 2: appstr += self.make_scalar(d,f,'encoder',True)
elif len(f) == 3: appstr += self.make_array(d,f,'encoder',True)
else: raise Exception('Unhandled field: ' + f)
appstr += ' p2->trailer.seq = htonl(p1->trailer.seq);' + '\n'
appstr += ' p2->trailer.rqr = htonl(p1->trailer.rqr);' + '\n'
appstr += ' p2->trailer.oid = htonl(p1->trailer.oid);' + '\n'
appstr += ' p2->trailer.mid = htons(p1->trailer.mid);' + '\n'
appstr += ' p2->trailer.crc = htons(p1->trailer.crc);' + '\n'
appstr += ' *len_out = '
for f in l[1:]:
if len(f) == 2: appstr += self.make_scalar(d,f,'sizeof',True)
elif len(f) == 3: appstr += self.make_array(d,f,'sizeof',True)
appstr += 'sizeof(trailer_datatype);' + '\n'
appstr += '}' + '\n\n'
return appstr
def make_decode_fn(self,l):
appstr = ''
d = l[0].lower()
appstr += 'void ' + d + '_data_decode (void *buff_out, void *buff_in, size_t *len_in) {' + '\n'
appstr += ' ' + d + '_output *p1 = (' + d + '_output *) buff_in;' + '\n'
appstr += ' ' + d + '_datatype *p2 = (' + d + '_datatype *) buff_out;' + '\n'
for f in l[1:]:
if len(f) == 2: appstr += self.make_scalar(d,f,'decoder',True)
elif len(f) == 3: appstr += self.make_array(d,f,'decoder',True)
else: raise Exception('Unhandled field: ' + f)
appstr += ' p2->trailer.seq = ntohl(p1->trailer.seq);' + '\n'
appstr += ' p2->trailer.rqr = ntohl(p1->trailer.rqr);' + '\n'
appstr += ' p2->trailer.oid = ntohl(p1->trailer.oid);' + '\n'
appstr += ' p2->trailer.mid = ntohs(p1->trailer.mid);' + '\n'
appstr += ' p2->trailer.crc = ntohs(p1->trailer.crc);' + '\n'
appstr += '}' + '\n\n'
return appstr
def writeheader(self, outfname, tree):
try:
hstr = HHEAD
hstr += self.make_dtyp_enum(tree)
hstr += self.make_dtyp_struct(tree)
hstr += self.make_fn_sigs(tree)
hstr += HTAIL
with open(outfname + '.h', 'w') as f:
f.write(hstr)
except Exception as e:
print("Error in header export: ", e)
def writecodecc(self, outfname, tree):
try:
cstr = '#include "' + outfname + '.h"' + '\n\n'
for l in tree:
cstr += self.make_print_fn(l)
cstr += self.make_encode_fn(l)
cstr += self.make_decode_fn(l)
with open(outfname + '.c', 'w') as f:
f.write(cstr)
except Exception as e:
print("Error in codecc export: ", e)
def writextras(self):
try:
with open('float754.c', 'w') as f:
f.write(FLOATC)
with open('float754.h', 'w') as f:
f.write(FLOATH)
except Exception as e:
print("Error writing extras: ", e)
if __name__ == '__main__':
pt = [['Position', ['double', 'x'], ['double', 'y'], ['double', 'z']],
['Distance', ['double', 'dx'], ['double', 'dy'], ['double', 'dz']],
['ArrayTest', ['double', 'doubloons', '3']]]
print('Writing test codec to codec.c/.h')
CodecWriter().writeheader('codec', pt)
CodecWriter().writecodecc('codec', pt)
print('Creating float754.c/.h')
CodecWriter().writextras()
|
hhead = '#ifndef GMA_HEADER_FILE\n#define GMA_HEADER_FILE\n#pragma pack(1)\n\n#include <stdio.h>\n#include <stdint.h>\n#include <string.h>\n#include <stdlib.h>\n#include <unistd.h>\n#include <inttypes.h>\n#include <arpa/inet.h>\n#include <float.h>\n\n#include "float754.h"\n\n#define id(X) (X)\n\ntypedef struct _trailer_datatype {\n uint32_t seq;\n uint32_t rqr;\n uint32_t oid;\n uint16_t mid;\n uint16_t crc;\n} trailer_datatype;\n\n'
htail = '#endif\n'
floath = '#ifndef _FLOAT_H_\n#define _FLOAT_H_\n\n/* Network order for double/float: 0 = Little endian, 1 = Big endian */\n/* Currently our DFDL uses littleEndian network order for float and double */\n/* This choice was based on the convention used by the shapeFile format */\n/* We are preserving bigEndian order for all integer types including uint64_t */\n#define FLOAT_BIG_ENDIAN 0\n\n#define big_end_test (1==htonl(1))\n\n#define swap_uint16(x) (((uint16_t) ((x) & 0xFF) << 8) | (((x) & 0xFF00) >> 8))\n#define swap_uint32(x) (((uint32_t)swap_uint16((x) & 0xFFFF) << 16) | swap_uint16((x) >> 16))\n#define swap_uint64(x) (((uint64_t)swap_uint32((x) & 0xFFFFFFFF) << 32) | swap_uint32((x) >> 32))\n\n#define my_htoxll(x) (big_end_test ? swap_uint64(x) : (x))\n#define my_htoxl(x) (big_end_test ? swap_uint32(x) : (x))\n#define my_htonll(x) (big_end_test ? (x) : swap_uint64(x))\n#define my_htonl(x) (big_end_test ? (x) : swap_uint32(x))\n\n/* Functions / macros called by user */\n#define htonll(x) my_htonll(x)\n#define ntohll(x) my_htonll(x)\n\nextern uint32_t htonf(float);\nextern float ntohf(uint32_t);\nextern uint64_t htond(long double);\nextern long double ntohd(uint64_t);\n\n#endif /* _FLOAT_H_ */\n'
floatc = '/*\n * FLOAT.C\n * IEEE-754 uint64_t encoding/decoding, plus conversion macros into/from network (x865) byte order\n *\n * 1) Pack (double/float) encoder and decoder using: https://beej.us/guide/bgnet/examples/ieee754.c\n * a) uint64_t = 1-bit Sign (1=-), 11-bit Biased Exponent (BE), 52-bit Normalised Mantisa (NM)\n * e.g., 85.125 = 1.010101001 x 2^6 => S=0, BE=(bias=1023)+(6)=10000000101, NM=010101001000000...\n * n) uint32_t = 1-bit Sign (1=-), 8-bit Biased Exponent (BE), 23-bit Normalised Mantisa (NM)\n *\n * 2) Endian converter changes byte order between host encoded (uint_xx_t) and big-endian network format\n (unless FLOAT_BIG_ENDIAN=0, in which case it converts to a little-endian network format)\n */\n\n#include <stdio.h>\n#include <stdint.h>\n#include <inttypes.h>\n#include <arpa/inet.h>\n \n#include "float754.h"\n\n#define pack754_32(f) (pack754((f), 32, 8))\n#define pack754_64(f) (pack754((f), 64, 11))\n#define unpack754_32(i) (unpack754((i), 32, 8))\n#define unpack754_64(i) (unpack754((i), 64, 11))\n\n/* Encoding into IEEE-754 encoded double */\nuint64_t pack754(long double f, unsigned bits, unsigned expbits)\n{\n long double fnorm;\n int shift;\n long long sign, exp, significand;\n unsigned significandbits = bits - expbits - 1; // -1 for sign bit\n\n if (f == 0.0) return 0; // get this special case out of the way\n\n // check sign and begin normalization\n if (f < 0) { sign = 1; fnorm = -f; }\n else { sign = 0; fnorm = f; }\n\n // get the normalized form of f and track the exponent\n shift = 0;\n while(fnorm >= 2.0) { fnorm /= 2.0; shift++; }\n while(fnorm < 1.0) { fnorm *= 2.0; shift--; }\n fnorm = fnorm - 1.0;\n\n // calculate the binary form (non-float) of the significand data\n significand = fnorm * ((1LL<<significandbits) + 0.5f);\n\n // get the biased exponent\n exp = shift + ((1<<(expbits-1)) - 1); // shift + bias\n\n // return the final answer\n return (sign<<(bits-1)) | (exp<<(bits-expbits-1)) | significand;\n}\n\n/* Decoding from IEEE-754 encoded double */\nlong double unpack754(uint64_t i, unsigned bits, unsigned expbits)\n{\n long double result;\n long long shift;\n unsigned bias;\n unsigned significandbits = bits - expbits - 1; // -1 for sign bit\n\n if (i == 0) return 0.0;\n\n // pull the significand\n result = (i&((1LL<<significandbits)-1)); // mask\n result /= (1LL<<significandbits); // convert back to float\n result += 1.0f; // add the one back on\n\n // deal with the exponent\n bias = (1<<(expbits-1)) - 1;\n shift = ((i>>significandbits)&((1LL<<expbits)-1)) - bias;\n while(shift > 0) { result *= 2.0; shift--; }\n while(shift < 0) { result /= 2.0; shift++; }\n\n // sign it\n result *= (i>>(bits-1))&1? -1.0: 1.0;\n\n return result;\n}\n\n/* Converts host float by encoding into IEEE-754 uint32_t and putting into Network byte order */\nuint32_t htonf(float f) {\n uint32_t h = pack754_32(f);\n if (FLOAT_BIG_ENDIAN != 0) return ((my_htonl(h))); /* to Network Big-Endian */\n else return ((my_htoxl(h))); /* to Network Little-Endian */\n}\n\n/* Converts IEEE-754 uint32_t in Network byte order into host float */\nfloat ntohf(uint32_t i) {\n uint32_t h;\n \n if (FLOAT_BIG_ENDIAN != 0) h = (my_htonl(i)); /* from Network Big-Endian */\n else h = (my_htoxl(i)); /* from Network Little-Endian */\n return (unpack754_32(h));\n}\n\n/* Converts host double by encoding into IEEE-754 uint64_t and putting into Network byte order */\nuint64_t htond(long double f) {\n uint64_t h = pack754_64(f);\n if (FLOAT_BIG_ENDIAN != 0) return ((my_htonll(h))); /* to Network Big-Endian */\n else return ((my_htoxll(h))); /* to Network Little-Endian */\n}\n\n/* Converts IEEE-754 uint64_t in Network byte order into host double */\nlong double ntohd(uint64_t i) {\n uint64_t h;\n if (FLOAT_BIG_ENDIAN != 0) h = (my_htonll(i)); /* from Network Big-Endian */\n else h = (my_htoxll(i)); /* from Network Little-Endian */\n return (unpack754_64(h));\n}\n'
cintyp = {'double': 'double', 'ffloat': 'float', 'int8': 'int8_t', 'uint8': 'uint8_t', 'int16': 'int16_t', 'uint16': 'uint16_t', 'int32': 'int32_t', 'uint32': 'uint32_t', 'int64': 'int64_t', 'uint64': 'uint64_t'}
coutyp = {'double': 'uint64_t', 'ffloat': 'uint32_t', 'int8': 'int8_t', 'uint8': 'uint8_t', 'int16': 'int16_t', 'uint16': 'uint16_t', 'int32': 'int32_t', 'uint32': 'uint32_t', 'int64': 'int64_t', 'uint64': 'uint64_t'}
fmtstr = {'double': '%lf', 'ffloat': '%f', 'int8': '%hd', 'uint8': '%hu', 'int16': '%hd', 'uint16': '%hu', 'int32': '%d', 'uint32': '%u', 'int64': '%ld', 'uint64': '%lu'}
encfn = {'double': 'htond', 'ffloat': 'htonf', 'int8': 'id', 'uint8': 'id', 'int16': 'htons', 'uint16': 'htons', 'int32': 'htonl', 'uint32': 'htonl', 'int64': 'htonll', 'uint64': 'htonll'}
decfn = {'double': 'ntohd', 'ffloat': 'ntohf', 'int8': 'id', 'uint8': 'id', 'int16': 'ntohs', 'uint16': 'ntohs', 'int32': 'ntohl', 'uint32': 'ntohl', 'int64': 'ntohll', 'uint64': 'ntohll'}
class Codecwriter:
def __init__(self, typbase=0):
self.typbase = typbase
def make_scalar(self, d, f, ser, inp):
appstr = ''
if ser == 'header':
t = cintyp[f[0]] if inp else coutyp[f[0]]
appstr += ' ' + t + ' ' + f[1] + ';' + '\n'
elif ser == 'printer':
appstr += ' ' + 'fprintf(stderr, " ' + fmtstr[f[0]] + ',", ' + d + '->' + f[1] + ');' + '\n'
elif ser == 'encoder':
appstr += ' ' + 'p2->' + f[1] + ' = ' + encfn[f[0]] + '(p1->' + f[1] + ');' + '\n'
elif ser == 'decoder':
appstr += ' ' + 'p2->' + f[1] + ' = ' + decfn[f[0]] + '(p1->' + f[1] + ');' + '\n'
elif ser == 'sizeof':
appstr += 'sizeof(' + cintyp[f[0]] + ') + '
else:
raise exception('Unknown serializarion: ' + ser)
return appstr
def make_array(self, d, f, ser, inp):
appstr = ''
if ser == 'header':
t = cintyp[f[0]] if inp else coutyp[f[0]]
appstr += ' ' + t + ' ' + f[1] + '[' + str(f[2]) + '];' + '\n'
elif ser == 'printer':
appstr += ' for (int i=0; i<' + str(f[2]) + '; i++) {' + '\n'
appstr += ' ' + 'fprintf(stderr, " ' + fmtstr[f[0]] + ',", ' + d + '->' + f[1] + '[i]);' + '\n'
appstr += ' }' + '\n'
elif ser == 'encoder':
appstr += ' for (int i=0; i<' + str(f[2]) + '; i++) {' + '\n'
appstr += ' ' + 'p2->' + f[1] + '[i] = ' + encfn[f[0]] + '(p1->' + f[1] + '[i]);' + '\n'
appstr += ' }' + '\n'
elif ser == 'decoder':
appstr += ' for (int i=0; i<' + str(f[2]) + '; i++) {' + '\n'
appstr += ' ' + 'p2->' + f[1] + '[i] = ' + decfn[f[0]] + '(p1->' + f[1] + '[i]);' + '\n'
appstr += ' }' + '\n'
elif ser == 'sizeof':
appstr += 'sizeof(' + cintyp[f[0]] + ') * ' + str(f[2]) + ' + '
else:
raise exception('Unknown serialization: ' + ser)
return appstr
def make_dtyp_enum(self, tree):
dtypid = 0
appstr = ''
appstr += '#ifndef TYP_BASE' + '\n'
appstr += '#define TYP_BASE ' + str(self.typbase) + '\n'
appstr += '#endif /* TYP_BASE */' + '\n'
for dtypnm in [l[0] for l in tree]:
dtypid += 1
appstr += '#define DATA_TYP_' + dtypnm.upper() + ' TYP_BASE + ' + str(dtypid) + '\n'
return appstr + '\n'
def make_structs(self, dtypnm, flds, inp=True):
appstr = ''
d = dtypnm.lower()
istr = 'datatype' if inp else 'output'
appstr += 'typedef struct _' + d + '_' + istr + ' {' + '\n'
for f in flds:
if len(f) == 2:
appstr += self.make_scalar(d, f, 'header', inp)
elif len(f) == 3:
appstr += self.make_array(d, f, 'header', inp)
else:
raise exception('Unhandled field: ' + f)
appstr += ' trailer_datatype trailer;' + '\n'
appstr += '} ' + d + '_' + istr + ';' + '\n'
return appstr + '\n'
def make_dtyp_struct(self, tree):
appstr = ''
for l in tree:
appstr += self.make_structs(l[0], l[1:], True)
appstr += self.make_structs(l[0], l[1:], False)
return appstr
def make_fn_sigs(self, tree):
dtypid = 0
appstr = ''
for dtypnm in [l[0] for l in tree]:
dtypid += 1
d = dtypnm.lower()
appstr += 'extern void ' + d + '_print (' + d + '_datatype *' + d + ');' + '\n'
appstr += 'extern void ' + d + '_data_encode (void *buff_out, void *buff_in, size_t *len_out);' + '\n'
appstr += 'extern void ' + d + '_data_decode (void *buff_out, void *buff_in, size_t *len_in);' + '\n'
appstr += '\n'
return appstr
def make_print_fn(self, l):
appstr = ''
d = l[0].lower()
appstr += 'void ' + d + '_print (' + d + '_datatype *' + d + ') {' + '\n'
appstr += ' fprintf(stderr, "' + d + '(len=%ld): ", sizeof(*' + d + '));' + '\n'
for f in l[1:]:
if len(f) == 2:
appstr += self.make_scalar(d, f, 'printer', True)
elif len(f) == 3:
appstr += self.make_array(d, f, 'printer', True)
else:
raise exception('Unhandled field: ' + f)
appstr += ' fprintf(stderr, " %u, %u, %u, %hu, %hu\\n",' + '\n'
appstr += ' ' + d + '->trailer.seq,' + '\n'
appstr += ' ' + d + '->trailer.rqr,' + '\n'
appstr += ' ' + d + '->trailer.oid,' + '\n'
appstr += ' ' + d + '->trailer.mid,' + '\n'
appstr += ' ' + d + '->trailer.crc);' + '\n'
appstr += '}' + '\n\n'
return appstr
def make_encode_fn(self, l):
appstr = ''
d = l[0].lower()
appstr += 'void ' + d + '_data_encode (void *buff_out, void *buff_in, size_t *len_out) {' + '\n'
appstr += ' ' + d + '_datatype *p1 = (' + d + '_datatype *) buff_in;' + '\n'
appstr += ' ' + d + '_output *p2 = (' + d + '_output *) buff_out;' + '\n'
for f in l[1:]:
if len(f) == 2:
appstr += self.make_scalar(d, f, 'encoder', True)
elif len(f) == 3:
appstr += self.make_array(d, f, 'encoder', True)
else:
raise exception('Unhandled field: ' + f)
appstr += ' p2->trailer.seq = htonl(p1->trailer.seq);' + '\n'
appstr += ' p2->trailer.rqr = htonl(p1->trailer.rqr);' + '\n'
appstr += ' p2->trailer.oid = htonl(p1->trailer.oid);' + '\n'
appstr += ' p2->trailer.mid = htons(p1->trailer.mid);' + '\n'
appstr += ' p2->trailer.crc = htons(p1->trailer.crc);' + '\n'
appstr += ' *len_out = '
for f in l[1:]:
if len(f) == 2:
appstr += self.make_scalar(d, f, 'sizeof', True)
elif len(f) == 3:
appstr += self.make_array(d, f, 'sizeof', True)
appstr += 'sizeof(trailer_datatype);' + '\n'
appstr += '}' + '\n\n'
return appstr
def make_decode_fn(self, l):
appstr = ''
d = l[0].lower()
appstr += 'void ' + d + '_data_decode (void *buff_out, void *buff_in, size_t *len_in) {' + '\n'
appstr += ' ' + d + '_output *p1 = (' + d + '_output *) buff_in;' + '\n'
appstr += ' ' + d + '_datatype *p2 = (' + d + '_datatype *) buff_out;' + '\n'
for f in l[1:]:
if len(f) == 2:
appstr += self.make_scalar(d, f, 'decoder', True)
elif len(f) == 3:
appstr += self.make_array(d, f, 'decoder', True)
else:
raise exception('Unhandled field: ' + f)
appstr += ' p2->trailer.seq = ntohl(p1->trailer.seq);' + '\n'
appstr += ' p2->trailer.rqr = ntohl(p1->trailer.rqr);' + '\n'
appstr += ' p2->trailer.oid = ntohl(p1->trailer.oid);' + '\n'
appstr += ' p2->trailer.mid = ntohs(p1->trailer.mid);' + '\n'
appstr += ' p2->trailer.crc = ntohs(p1->trailer.crc);' + '\n'
appstr += '}' + '\n\n'
return appstr
def writeheader(self, outfname, tree):
try:
hstr = HHEAD
hstr += self.make_dtyp_enum(tree)
hstr += self.make_dtyp_struct(tree)
hstr += self.make_fn_sigs(tree)
hstr += HTAIL
with open(outfname + '.h', 'w') as f:
f.write(hstr)
except Exception as e:
print('Error in header export: ', e)
def writecodecc(self, outfname, tree):
try:
cstr = '#include "' + outfname + '.h"' + '\n\n'
for l in tree:
cstr += self.make_print_fn(l)
cstr += self.make_encode_fn(l)
cstr += self.make_decode_fn(l)
with open(outfname + '.c', 'w') as f:
f.write(cstr)
except Exception as e:
print('Error in codecc export: ', e)
def writextras(self):
try:
with open('float754.c', 'w') as f:
f.write(FLOATC)
with open('float754.h', 'w') as f:
f.write(FLOATH)
except Exception as e:
print('Error writing extras: ', e)
if __name__ == '__main__':
pt = [['Position', ['double', 'x'], ['double', 'y'], ['double', 'z']], ['Distance', ['double', 'dx'], ['double', 'dy'], ['double', 'dz']], ['ArrayTest', ['double', 'doubloons', '3']]]
print('Writing test codec to codec.c/.h')
codec_writer().writeheader('codec', pt)
codec_writer().writecodecc('codec', pt)
print('Creating float754.c/.h')
codec_writer().writextras()
|
#!/usr/bin/env python
def add_multiply(x, y, z=1):
return (x + y) * z
add_multiply(1, 2) # x=1, y=2, z=1
|
def add_multiply(x, y, z=1):
return (x + y) * z
add_multiply(1, 2)
|
"""Errand gofers module
"""
class Gofers(object):
"""Errand gofers class
"""
def __init__(self, *sizes):
self._norm_sizes(*sizes)
def _norm_sizes(self, *sizes):
def _n(s):
if isinstance(s, int):
return ((s,1,1))
elif isinstance(s, (list, tuple)):
l = len(s)
if l >= 3:
return tuple(s[:3])
elif l == 2:
return (s[0], s[1], 1)
elif l == 1:
return (s[0], 1, 1)
else:
raise Exception("Wrong number of size dimension: %d" % l)
else:
raise Exception("Unsupported size type: %s" % str(s))
# (members, teams, assignments)
if len(sizes) == 3:
self.sizes = [_n(sizes[1]), _n(sizes[0]), _n(sizes[2])]
# (members, teams)
elif len(sizes) == 2:
self.sizes = [_n(sizes[1]), _n(sizes[0]), _n(1)]
# (members)
elif len(sizes) == 1:
self.sizes = [_n(1), _n(sizes[0]), _n(1)]
else:
raise Exception("Wrong # of Gofers initialization: %d" % len(sizes))
def run(self, workshop):
return workshop.open(*self.sizes)
|
"""Errand gofers module
"""
class Gofers(object):
"""Errand gofers class
"""
def __init__(self, *sizes):
self._norm_sizes(*sizes)
def _norm_sizes(self, *sizes):
def _n(s):
if isinstance(s, int):
return (s, 1, 1)
elif isinstance(s, (list, tuple)):
l = len(s)
if l >= 3:
return tuple(s[:3])
elif l == 2:
return (s[0], s[1], 1)
elif l == 1:
return (s[0], 1, 1)
else:
raise exception('Wrong number of size dimension: %d' % l)
else:
raise exception('Unsupported size type: %s' % str(s))
if len(sizes) == 3:
self.sizes = [_n(sizes[1]), _n(sizes[0]), _n(sizes[2])]
elif len(sizes) == 2:
self.sizes = [_n(sizes[1]), _n(sizes[0]), _n(1)]
elif len(sizes) == 1:
self.sizes = [_n(1), _n(sizes[0]), _n(1)]
else:
raise exception('Wrong # of Gofers initialization: %d' % len(sizes))
def run(self, workshop):
return workshop.open(*self.sizes)
|
'''
Write a function called my_func that takes two arguments---a list and a
substring---and returns a new list, containing only words that start with the
chosen substring. Make sure that your function is not case sensitive: meaning
that if you want to filter by words that start with 'a', both 'apple' and
'Apple' would be included.
If your function is working properly, this code:
my_list = ['apple', 'banana', 'cranberry', 'Apple', 'watermelon', 'avocado']
only_a = my_func(my_list, 'a')
only_c = my_func(my_list, 'c')
print(only_a)
print(only_c)
should output:
['apple', 'Apple', 'avocado']
['cranberry']
'''
def my_func(some_list, sub_string):
starting_with = []
for word in some_list:
if word.lower().startswith(sub_string):
starting_with.append(word)
return starting_with
|
"""
Write a function called my_func that takes two arguments---a list and a
substring---and returns a new list, containing only words that start with the
chosen substring. Make sure that your function is not case sensitive: meaning
that if you want to filter by words that start with 'a', both 'apple' and
'Apple' would be included.
If your function is working properly, this code:
my_list = ['apple', 'banana', 'cranberry', 'Apple', 'watermelon', 'avocado']
only_a = my_func(my_list, 'a')
only_c = my_func(my_list, 'c')
print(only_a)
print(only_c)
should output:
['apple', 'Apple', 'avocado']
['cranberry']
"""
def my_func(some_list, sub_string):
starting_with = []
for word in some_list:
if word.lower().startswith(sub_string):
starting_with.append(word)
return starting_with
|
# Copyright (c) 2015 Microsoft Corporation
"""
>>> from z3 import *
>>> x = Int('x')
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(x)
>>> s.add(x == 1)
>>> s.push()
>>> s
[x == 1]
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.add(x == 1)
>>> s.push()
>>> s
[]
>>> y = Int('y')
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(x)
>>> s.add(x == y, x > 0)
>>> s
[x == y, x > 0]
>>> s.push()
>>> s
[Not(x <= 0)]
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(y)
>>> s.add(x == y, x > 0)
>>> s
[x == y, x > 0]
>>> s.push()
>>> s
[Not(y <= 0)]
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(y)
>>> s.freeze(x)
>>> s.add(x == y, x > 0)
>>> s
[x == y, x > 0]
>>> s.push()
>>> s
[x == y, x > 0]
"""
# TODO: must install basic plugins to be able to handle this examples
# if __name__ == "__main__":
# import doctest
# if doctest.testmod().failed:
# exit(1)
|
"""
>>> from z3 import *
>>> x = Int('x')
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(x)
>>> s.add(x == 1)
>>> s.push()
>>> s
[x == 1]
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.add(x == 1)
>>> s.push()
>>> s
[]
>>> y = Int('y')
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(x)
>>> s.add(x == y, x > 0)
>>> s
[x == y, x > 0]
>>> s.push()
>>> s
[Not(x <= 0)]
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(y)
>>> s.add(x == y, x > 0)
>>> s
[x == y, x > 0]
>>> s.push()
>>> s
[Not(y <= 0)]
>>> s = MCSatCore()
>>> s.add_tactic('solve-eqs')
>>> s.freeze(y)
>>> s.freeze(x)
>>> s.add(x == y, x > 0)
>>> s
[x == y, x > 0]
>>> s.push()
>>> s
[x == y, x > 0]
"""
|
def transpose_grid(grid):
grid_t = []
grid_line = []
for i in range(len(grid[0])):
for row in grid:
grid_line.append(row[i])
grid_t.append(grid_line)
grid_line = []
return grid_t
def verify_row(row, necessary_length):
if len(row) < necessary_length:
return False, None
actual_length = 0
pawn_to_verify = row[0]
for element in row:
# Analyse each row
# Count repeated elements in a row
if element == pawn_to_verify and element != 0: # Do not consider 0 an element: it's considered an empty space
actual_length += 1
# If the length of these repeated elements reaches the necessary length to victory, stop
if actual_length == necessary_length:
# Return true and the winner element
return True, element
else:
actual_length = 1
pawn_to_verify = element
return False, None
def verify_grid_rows(grid, necessary_length):
row_number = 0
for row in grid:
is_winner_row, element = verify_row(row, necessary_length)
if is_winner_row:
return True, element, row_number
row_number += 1
return False, None, -1
def get_backslash_diagonal(grid, uppermost_coordinates):
"""
Gets the backslash-type diagonal of a grid based on the coordinates of the uppermost element.
:param grid: The base matrix
:param uppermost_coordinates: Tuple with the coordinates of the uppermost element of the form (row, column)
:return: A list of the diagonal elements, starting from the uppermost
"""
i = uppermost_coordinates[0]
j = uppermost_coordinates[1]
diagonal_elements = []
while i <= len(grid)-1 and j <= len(grid[0])-1:
# Put it in the list
diagonal_elements.append(grid[i][j])
# Go to next element:
i += 1
j += 1
return diagonal_elements
def get_forward_slash_diagonal(grid, uppermost_coordinates):
"""
Gets the forward slash-type diagonal of a grid based on the coordinates of the uppermost element.
:param grid: The base matrix
:param uppermost_coordinates: Tuple with the coordinates of the uppermost element of the form (row, column)
:return: A list of the diagonal elements, starting from the uppermost
"""
i = uppermost_coordinates[0]
j = uppermost_coordinates[1]
diagonal_elements = []
while i <= len(grid)-1 and j >= 0:
# Put it in the list
diagonal_elements.append(grid[i][j])
# Go to next element:
i += 1
j -= 1
return diagonal_elements
def tic_tac_toe_victory(grid, necessary_length):
# Horizontal verification
exists_winner, element, row_number = verify_grid_rows(grid, necessary_length)
if exists_winner:
print("Row victory")
return True, element, row_number
# Vertical verification
grid_t = transpose_grid(grid)
exists_winner, element, column_number = verify_grid_rows(grid_t, necessary_length)
if exists_winner:
print("Column victory")
return True, element, column_number
# Diagonal verification:
# Back slash type diagonals: (\)
# print("Backslash diagonals")
# Lower half of the diagonals
for i in range(len(grid)-1, -1, -1):
diagonal = get_backslash_diagonal(grid, (i, 0))
exists_winner, element = verify_row(diagonal, necessary_length)
if exists_winner:
print("Diagonal victory")
return True, element, 0
# print(diagonal)
# Upper half of the diagonals
for j in range(1, len(grid[0])):
diagonal = get_backslash_diagonal(grid, (0,j))
exists_winner, element = verify_row(diagonal, necessary_length)
if exists_winner:
print("Diagonal victory")
return True, element, 0
# print(diagonal)
# Forward slash type diagonals (/)
# print("Forward slash diagonals")
# Upper half of the diagonals
for j in range(len(grid[0])):
diagonal = get_forward_slash_diagonal(grid, (0, j))
exists_winner, element = verify_row(diagonal, necessary_length)
if exists_winner:
print("Diagonal victory")
return True, element, 0
# print(diagonal)
# Lower half of the diagonals
for i in range(1,len(grid)):
diagonal = get_forward_slash_diagonal(grid, (i, len(grid[0])-1))
exists_winner, element = verify_row(diagonal, necessary_length)
if exists_winner:
print("Diagonal victory")
return True, element, 0
# print(diagonal)
return False, None, -1
#grid = [[' ',' ',' ','B',' '],[' ',' ','X','A',' '],[' ','X',' ','A',' '],['X',' ',' ','A','B']]
#print(victory(grid, 4))
|
def transpose_grid(grid):
grid_t = []
grid_line = []
for i in range(len(grid[0])):
for row in grid:
grid_line.append(row[i])
grid_t.append(grid_line)
grid_line = []
return grid_t
def verify_row(row, necessary_length):
if len(row) < necessary_length:
return (False, None)
actual_length = 0
pawn_to_verify = row[0]
for element in row:
if element == pawn_to_verify and element != 0:
actual_length += 1
if actual_length == necessary_length:
return (True, element)
else:
actual_length = 1
pawn_to_verify = element
return (False, None)
def verify_grid_rows(grid, necessary_length):
row_number = 0
for row in grid:
(is_winner_row, element) = verify_row(row, necessary_length)
if is_winner_row:
return (True, element, row_number)
row_number += 1
return (False, None, -1)
def get_backslash_diagonal(grid, uppermost_coordinates):
"""
Gets the backslash-type diagonal of a grid based on the coordinates of the uppermost element.
:param grid: The base matrix
:param uppermost_coordinates: Tuple with the coordinates of the uppermost element of the form (row, column)
:return: A list of the diagonal elements, starting from the uppermost
"""
i = uppermost_coordinates[0]
j = uppermost_coordinates[1]
diagonal_elements = []
while i <= len(grid) - 1 and j <= len(grid[0]) - 1:
diagonal_elements.append(grid[i][j])
i += 1
j += 1
return diagonal_elements
def get_forward_slash_diagonal(grid, uppermost_coordinates):
"""
Gets the forward slash-type diagonal of a grid based on the coordinates of the uppermost element.
:param grid: The base matrix
:param uppermost_coordinates: Tuple with the coordinates of the uppermost element of the form (row, column)
:return: A list of the diagonal elements, starting from the uppermost
"""
i = uppermost_coordinates[0]
j = uppermost_coordinates[1]
diagonal_elements = []
while i <= len(grid) - 1 and j >= 0:
diagonal_elements.append(grid[i][j])
i += 1
j -= 1
return diagonal_elements
def tic_tac_toe_victory(grid, necessary_length):
(exists_winner, element, row_number) = verify_grid_rows(grid, necessary_length)
if exists_winner:
print('Row victory')
return (True, element, row_number)
grid_t = transpose_grid(grid)
(exists_winner, element, column_number) = verify_grid_rows(grid_t, necessary_length)
if exists_winner:
print('Column victory')
return (True, element, column_number)
for i in range(len(grid) - 1, -1, -1):
diagonal = get_backslash_diagonal(grid, (i, 0))
(exists_winner, element) = verify_row(diagonal, necessary_length)
if exists_winner:
print('Diagonal victory')
return (True, element, 0)
for j in range(1, len(grid[0])):
diagonal = get_backslash_diagonal(grid, (0, j))
(exists_winner, element) = verify_row(diagonal, necessary_length)
if exists_winner:
print('Diagonal victory')
return (True, element, 0)
for j in range(len(grid[0])):
diagonal = get_forward_slash_diagonal(grid, (0, j))
(exists_winner, element) = verify_row(diagonal, necessary_length)
if exists_winner:
print('Diagonal victory')
return (True, element, 0)
for i in range(1, len(grid)):
diagonal = get_forward_slash_diagonal(grid, (i, len(grid[0]) - 1))
(exists_winner, element) = verify_row(diagonal, necessary_length)
if exists_winner:
print('Diagonal victory')
return (True, element, 0)
return (False, None, -1)
|
font = CurrentFont()
for glyph in font.selection:
glyph = font[name]
glyph.prepareUndo()
glyph.rotate(-5)
glyph.skew(5)
glyph.performUndo()
|
font = current_font()
for glyph in font.selection:
glyph = font[name]
glyph.prepareUndo()
glyph.rotate(-5)
glyph.skew(5)
glyph.performUndo()
|
"""
A reimplementation of some useful python utilities missing from RPython
"""
def zip(list1, list2):
"""
expects two lists of equal length
"""
assert len(list1) == len(list2)
for i in xrange(len(list1)):
yield list1[i], list2[i]
raise StopIteration
def all(ls):
"""
expects list of Bool
"""
result = True
for l in ls:
if l is not True:
result = False
return result
def permutations(pool):
"""
based on itertools.permutations
"""
n = len(pool)
indices = range(n)
cycles = range(n, 0, -1)
yield pool
while n:
for i in range(n-1, -1, -1):
cycles[i] -= 1
if cycles[i] == 0:
num = indices[i]
for k in range(i, n-1):
indices[k] = indices[k+1]
indices[n-1] = num
cycles[i] = n-i
else:
j = cycles[i]
indices[i], indices[-j] = indices[-j], indices[i]
yield [pool[i] for i in indices]
break
else:
return
def replace(string, match, replace):
"""
RPython only supports character replacement
reimplements string.replace(match, replace)
"""
n = len(match)
m = len(replace)
i = 0
while i <= len(string) - n:
if string[i:i+n] == match:
string = string[:i] + replace + string[i+n:]
i += m-n+1
assert i >= 0
else:
i += 1
return string
|
"""
A reimplementation of some useful python utilities missing from RPython
"""
def zip(list1, list2):
"""
expects two lists of equal length
"""
assert len(list1) == len(list2)
for i in xrange(len(list1)):
yield (list1[i], list2[i])
raise StopIteration
def all(ls):
"""
expects list of Bool
"""
result = True
for l in ls:
if l is not True:
result = False
return result
def permutations(pool):
"""
based on itertools.permutations
"""
n = len(pool)
indices = range(n)
cycles = range(n, 0, -1)
yield pool
while n:
for i in range(n - 1, -1, -1):
cycles[i] -= 1
if cycles[i] == 0:
num = indices[i]
for k in range(i, n - 1):
indices[k] = indices[k + 1]
indices[n - 1] = num
cycles[i] = n - i
else:
j = cycles[i]
(indices[i], indices[-j]) = (indices[-j], indices[i])
yield [pool[i] for i in indices]
break
else:
return
def replace(string, match, replace):
"""
RPython only supports character replacement
reimplements string.replace(match, replace)
"""
n = len(match)
m = len(replace)
i = 0
while i <= len(string) - n:
if string[i:i + n] == match:
string = string[:i] + replace + string[i + n:]
i += m - n + 1
assert i >= 0
else:
i += 1
return string
|
load("//elm/private:test.bzl", _elm_test = "elm_test")
elm_test = _elm_test
def _elm_make_impl(ctx):
elm_compiler = ctx.toolchains["@rules_elm//elm:toolchain"].elm
output_file = ctx.actions.declare_file(ctx.attr.output)
env = {}
inputs = [elm_compiler, ctx.file.elm_json] + ctx.files.srcs
if ctx.file.elm_home != None:
env["ELM_HOME_ZIP"] = ctx.file.elm_home.path
inputs.append(ctx.file.elm_home)
arguments = [
ctx.file.elm_json.dirname,
"make", ctx.attr.main,
"--output", output_file.path,
]
if ctx.attr.optimize:
arguments.append("--optimize")
ctx.actions.run(
executable = ctx.executable._elm_wrapper,
arguments = arguments,
inputs = inputs,
outputs = [output_file],
env = env,
)
return [DefaultInfo(files = depset([output_file]))]
elm_make = rule(
_elm_make_impl,
attrs = {
"srcs": attr.label_list(allow_files = True),
"elm_json": attr.label(
mandatory = True,
allow_single_file = True,
),
"main": attr.string(
default = "src/Main.elm",
),
"output": attr.string(
default = "index.html",
),
"optimize": attr.bool(),
"elm_home": attr.label(
allow_single_file = True,
),
"_elm_wrapper": attr.label(
executable = True,
cfg = "host",
default = Label("@rules_elm//elm/private:elm_wrapper"),
),
},
toolchains = [
"@rules_elm//elm:toolchain",
]
)
def _elm_dependencies_impl(ctx):
elm_compiler = ctx.toolchains["@rules_elm//elm:toolchain"].elm
elm_home = ctx.actions.declare_directory(".elm")
output = ctx.actions.declare_file(".elm.zip")
ctx.actions.run(
executable = ctx.executable._elm_wrapper,
arguments = [ctx.file.elm_json.dirname],
inputs = [elm_compiler, ctx.file.elm_json],
outputs = [output, elm_home],
env = {"ELM_HOME": elm_home.path},
)
return [DefaultInfo(files = depset([output]))]
elm_dependencies = rule(
_elm_dependencies_impl,
attrs = {
"elm_json": attr.label(
mandatory = True,
allow_single_file = True,
),
"_elm_wrapper": attr.label(
executable = True,
cfg = "host",
default = Label("@rules_elm//elm/private:elm_dependencies"),
),
},
toolchains = [
"@rules_elm//elm:toolchain",
]
)
|
load('//elm/private:test.bzl', _elm_test='elm_test')
elm_test = _elm_test
def _elm_make_impl(ctx):
elm_compiler = ctx.toolchains['@rules_elm//elm:toolchain'].elm
output_file = ctx.actions.declare_file(ctx.attr.output)
env = {}
inputs = [elm_compiler, ctx.file.elm_json] + ctx.files.srcs
if ctx.file.elm_home != None:
env['ELM_HOME_ZIP'] = ctx.file.elm_home.path
inputs.append(ctx.file.elm_home)
arguments = [ctx.file.elm_json.dirname, 'make', ctx.attr.main, '--output', output_file.path]
if ctx.attr.optimize:
arguments.append('--optimize')
ctx.actions.run(executable=ctx.executable._elm_wrapper, arguments=arguments, inputs=inputs, outputs=[output_file], env=env)
return [default_info(files=depset([output_file]))]
elm_make = rule(_elm_make_impl, attrs={'srcs': attr.label_list(allow_files=True), 'elm_json': attr.label(mandatory=True, allow_single_file=True), 'main': attr.string(default='src/Main.elm'), 'output': attr.string(default='index.html'), 'optimize': attr.bool(), 'elm_home': attr.label(allow_single_file=True), '_elm_wrapper': attr.label(executable=True, cfg='host', default=label('@rules_elm//elm/private:elm_wrapper'))}, toolchains=['@rules_elm//elm:toolchain'])
def _elm_dependencies_impl(ctx):
elm_compiler = ctx.toolchains['@rules_elm//elm:toolchain'].elm
elm_home = ctx.actions.declare_directory('.elm')
output = ctx.actions.declare_file('.elm.zip')
ctx.actions.run(executable=ctx.executable._elm_wrapper, arguments=[ctx.file.elm_json.dirname], inputs=[elm_compiler, ctx.file.elm_json], outputs=[output, elm_home], env={'ELM_HOME': elm_home.path})
return [default_info(files=depset([output]))]
elm_dependencies = rule(_elm_dependencies_impl, attrs={'elm_json': attr.label(mandatory=True, allow_single_file=True), '_elm_wrapper': attr.label(executable=True, cfg='host', default=label('@rules_elm//elm/private:elm_dependencies'))}, toolchains=['@rules_elm//elm:toolchain'])
|
x = [2,3,5,6,8]
y = [1,6,22,33,61]
x_2 = list()
x_3 = list()
x_4 = list()
x_carpi_y = list()
x_2_carpi_y = list()
for i in x:
x_2.append(int(pow(i,2)))
x_3.append(int(pow(i,3)))
x_4.append(int(pow(i,4)))
print("xi : ", x, sum(x))
print("xi^2 : ", x_2, sum(x_2))
print("xi^3 : ", x_3, sum(x_3))
print("xi^4 : ", x_4, sum(x_4))
for i, j, z in zip(x, y, x_2):
x_carpi_y.append(i*j)
x_2_carpi_y.append(z*j)
print()
print("yi : ", y, sum(y))
print("xi.yi : ", x_carpi_y, sum(x_carpi_y))
print("xi^2.yi : ", x_2_carpi_y, sum(x_2_carpi_y))
|
x = [2, 3, 5, 6, 8]
y = [1, 6, 22, 33, 61]
x_2 = list()
x_3 = list()
x_4 = list()
x_carpi_y = list()
x_2_carpi_y = list()
for i in x:
x_2.append(int(pow(i, 2)))
x_3.append(int(pow(i, 3)))
x_4.append(int(pow(i, 4)))
print('xi : ', x, sum(x))
print('xi^2 : ', x_2, sum(x_2))
print('xi^3 : ', x_3, sum(x_3))
print('xi^4 : ', x_4, sum(x_4))
for (i, j, z) in zip(x, y, x_2):
x_carpi_y.append(i * j)
x_2_carpi_y.append(z * j)
print()
print('yi : ', y, sum(y))
print('xi.yi : ', x_carpi_y, sum(x_carpi_y))
print('xi^2.yi : ', x_2_carpi_y, sum(x_2_carpi_y))
|
#############################################################################
# Copyright 2016 Mass KonFuzion
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#############################################################################
class CollisionGeomType:
aabb = 0
# TODO add more types? Or otherwise, get rid of this crap? I'm not sure if we'll need it
|
class Collisiongeomtype:
aabb = 0
|
class Virus(object):
'''Properties and attributes of the virus used in Simulation.'''
def __init__(self, name, repro_rate, mortality_rate):
self.name = name
self.repro_rate = repro_rate
self.mortality_rate = mortality_rate
def test_virus_instantiation():
#TODO: Create your own test that models the virus you are working with
'''Check to make sure that the virus instantiator is working.'''
virus = Virus("HIV", 0.8, 0.3)
assert virus.name == "HIV"
assert virus.repro_rate == 0.8
assert virus.mortality_rate == 0.3
|
class Virus(object):
"""Properties and attributes of the virus used in Simulation."""
def __init__(self, name, repro_rate, mortality_rate):
self.name = name
self.repro_rate = repro_rate
self.mortality_rate = mortality_rate
def test_virus_instantiation():
"""Check to make sure that the virus instantiator is working."""
virus = virus('HIV', 0.8, 0.3)
assert virus.name == 'HIV'
assert virus.repro_rate == 0.8
assert virus.mortality_rate == 0.3
|
def tail(sequence, n):
"""Returns the last n items of a given sequence."""
if n <= 0:
return []
return list(sequence[-n:])
|
def tail(sequence, n):
"""Returns the last n items of a given sequence."""
if n <= 0:
return []
return list(sequence[-n:])
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
@author: Pieter Huycke
email: [email protected]
GitHub: phuycke
"""
#%%
def message_check(message = str):
if len(message) < 160:
return message
else:
return message[:160]
longer = message_check("In certain chat programs or messaging applications, there is a limit on the number of characters that you can send in a message. Write a function that takes as input the message (a string) and checks whether the number of characters is less than 160 (or not). If the length of the message is less than 160, the message should be returned. If the length of the message is greater than 160, a string consisting of only the first 160 characters should be returned.")
print(longer)
shorter = message_check("In certain chat programs, there is a limit on the number of characters that you can send in a message.")
print(shorter)
#%%
def first_20_words(message = str):
words = message.split(" ")
if len(words) > 20:
raise ValueError("\nError\nThe message can only contain 20 words.")
else:
print("\nMessage passed:\n{}".format(message))
first_20_words("There is a limit on the number of characters that you can send in a message.")
first_20_words(longer)
|
"""
@author: Pieter Huycke
email: [email protected]
GitHub: phuycke
"""
def message_check(message=str):
if len(message) < 160:
return message
else:
return message[:160]
longer = message_check('In certain chat programs or messaging applications, there is a limit on the number of characters that you can send in a message. Write a function that takes as input the message (a string) and checks whether the number of characters is less than 160 (or not). If the length of the message is less than 160, the message should be returned. If the length of the message is greater than 160, a string consisting of only the first 160 characters should be returned.')
print(longer)
shorter = message_check('In certain chat programs, there is a limit on the number of characters that you can send in a message.')
print(shorter)
def first_20_words(message=str):
words = message.split(' ')
if len(words) > 20:
raise value_error('\nError\nThe message can only contain 20 words.')
else:
print('\nMessage passed:\n{}'.format(message))
first_20_words('There is a limit on the number of characters that you can send in a message.')
first_20_words(longer)
|
def getInnerBlocks(string, begin, end, sep = [","]):
ret_list = []
if not isinstance(string, str):
return None
# read a name until depth 1. Store until depth 0, and append it along with
# the contents.
# at depth 0, ignore separators
cname = ""
depth = 0
last_name = ""
cstr = ""
clist = []
for char in string:
if char == end:
depth -= 1
if depth == 0:
clist.append(cstr)
ret_list.append({
'name': last_name,
'params': clist
})
clist = []
cstr = ""
if depth == 0:
if char not in sep and char not in [begin, end]:
cname += str(char)
elif depth == 1:
if char in sep:
clist.append(cstr)
cstr = ""
else:
cstr += str(char)
elif depth == 2:
cstr += str(char)
if char == begin:
depth += 1
if depth == 1:
last_name = cname
cname = ""
ret = []
for item in ret_list:
name = item['name'].strip()
params = []
for i in item['params']:
inner = getInnerBlocks(i.strip(), begin, end, sep)
if inner and len(inner) != 0:
params.extend(inner)
else:
params.append(i.strip())
ret.append({
'name': name,
'params': params
})
return ret
print(getInnerBlocks('2,3', '(', ')'))
|
def get_inner_blocks(string, begin, end, sep=[',']):
ret_list = []
if not isinstance(string, str):
return None
cname = ''
depth = 0
last_name = ''
cstr = ''
clist = []
for char in string:
if char == end:
depth -= 1
if depth == 0:
clist.append(cstr)
ret_list.append({'name': last_name, 'params': clist})
clist = []
cstr = ''
if depth == 0:
if char not in sep and char not in [begin, end]:
cname += str(char)
elif depth == 1:
if char in sep:
clist.append(cstr)
cstr = ''
else:
cstr += str(char)
elif depth == 2:
cstr += str(char)
if char == begin:
depth += 1
if depth == 1:
last_name = cname
cname = ''
ret = []
for item in ret_list:
name = item['name'].strip()
params = []
for i in item['params']:
inner = get_inner_blocks(i.strip(), begin, end, sep)
if inner and len(inner) != 0:
params.extend(inner)
else:
params.append(i.strip())
ret.append({'name': name, 'params': params})
return ret
print(get_inner_blocks('2,3', '(', ')'))
|
def solve(n):
a = []
for _ in range(n):
name, h = input().split()
h = float(h)
a.append((name, h))
a.sort(key = lambda t: t[1], reverse=True)
m = a[0][1]
for n, h in a:
if h != m: break
print(n, end = " ")
print()
while True:
n = int(input())
if n == 0: break
solve(n)
|
def solve(n):
a = []
for _ in range(n):
(name, h) = input().split()
h = float(h)
a.append((name, h))
a.sort(key=lambda t: t[1], reverse=True)
m = a[0][1]
for (n, h) in a:
if h != m:
break
print(n, end=' ')
print()
while True:
n = int(input())
if n == 0:
break
solve(n)
|
# IDLE (Python 3.8.0)
# module_for_lists_of_terms
def termal_generator(lict):
length_of_termal_generator = 16
padding = length_of_termal_generator - len(lict)
count = padding
while count != 0:
lict.append([''])
count = count - 1
termal_lict = []
for first_inner in lict[0]:
for second_inner in lict[1]:
for third_inner in lict[2]:
for fourth_inner in lict[3]:
for fifth_inner in lict[4]:
for sixth_inner in lict[5]:
for seventh_inner in lict[6]:
for eighth_inner in lict[7]:
for ninth_inner in lict[8]:
for tenth_inner in lict[9]:
for eleventh_inner in lict[10]:
for twelfth_inner in lict[11]:
for thirteenth_inner in lict[12]:
for fourteenth_inner in lict [13]:
for fifteenth_inner in lict [14]:
for sixteenth_inner in lict[15]:
term = (
first_inner + second_inner +
third_inner + fourth_inner +
fifth_inner + sixth_inner +
seventh_inner + eighth_inner +
ninth_inner + tenth_inner +
eleventh_inner + twelfth_inner +
thirteenth_inner + fourteenth_inner +
fifteenth_inner + sixteenth_inner
)
termal_lict.append(term)
return termal_lict
def user_input_handling_function_second(dictionary):
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
lict = []
while good_to_go == 'no':
for key in dictionary:
lict.append(key)
for element in user_input:
if element not in lict:
print('The form can only contain a combination of the characters that represent the lists of characters.')
errors.append('yes')
break
if len(user_input) < 2:
print('The form is too short. It can\'t be less than two-characters long.')
errors.append('yes')
if len(user_input) > 8:
print('The form is too long. It can\'t be more than eight-characters long.')
errors.append('yes')
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return user_input
def user_input_handling_function_third():
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
yes_or_no = ['yes', 'no']
while good_to_go == 'no':
if user_input not in yes_or_no:
print('You have to answer yes or no.')
errors.append('yes')
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return user_input
def user_input_handling_function_fourth(dictionary):
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
while good_to_go == 'no':
if user_input not in dictionary:
print('The form you entered does not match one of the forms in your termal_dictionary. Each form in your')
print('termal_dictionary is a name (key) that has an associated definition (value) that is a list of terms')
print('that all have the same form as the name (key).')
errors.append('yes')
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return user_input
def user_input_handling_function_eighth():
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-']
while good_to_go == 'no':
if user_input == 'None':
user_input = None
return user_input
else:
for inner in user_input:
if inner not in digits:
print('The number must be an integer that consists of digits. For example: 1, -2, etc. or the keyword:')
print('None.')
errors.append('yes')
break
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return int(user_input)
def user_input_handling_function_ninth():
''' a parser '''
print()
user_input = input('Enter: ')
print()
term = ''
lict = []
for element in user_input:
if element != ' ':
term = term + element
else:
lict.append(term)
term = ''
lict.append(term) # because term might not be empty....
return lict
def user_input_handling_function_tenth(dictionary):
''' a dictionary checker '''
user_input = user_input_handling_function_ninth()
good_to_go = 'no'
errors = []
while good_to_go == 'no':
string = ''
lict = []
for element in user_input:
string = string + element
for key in dictionary:
for element in dictionary[key]:
lict.append(element)
for element in string:
if element not in lict:
print('One of your unwanted characters or combination of characters does not match the characters you')
print('entered earlier.')
errors.append('yes')
break
if 'yes' in errors:
print()
user_input = input('Re-enter: ')
print()
good_to_go = 'no'
errors = []
else:
good_to_go = 'yes'
return user_input
def print_vertical_lict(lict):
for element in lict:
print(element)
def print_horizontal_lict(lict):
string = ''
for element in lict:
string = string + str(element) + ', '
print(string)
print()
def write_vertical_lict(file_name, lict): # <--
file = open(file_name, 'w')
for element in lict:
element = str(element) + '\n'
file.write(element)
file.close()
def write_horizontal_lict(file_name, lict):
if '.txt' not in file_name:
file_name = file_name + '.txt'
row = ''
for index in range(len(lict)):
lict[index] = str(lict[index]) + ', '
if len(row + lict[index]) > 100:
lict[index - 1] = lict[index - 1] + '\n'
row = lict[index]
else:
row = row + lict[index]
file = open(file_name, 'w')
for term in lict:
file.write(term)
file.close()
|
def termal_generator(lict):
length_of_termal_generator = 16
padding = length_of_termal_generator - len(lict)
count = padding
while count != 0:
lict.append([''])
count = count - 1
termal_lict = []
for first_inner in lict[0]:
for second_inner in lict[1]:
for third_inner in lict[2]:
for fourth_inner in lict[3]:
for fifth_inner in lict[4]:
for sixth_inner in lict[5]:
for seventh_inner in lict[6]:
for eighth_inner in lict[7]:
for ninth_inner in lict[8]:
for tenth_inner in lict[9]:
for eleventh_inner in lict[10]:
for twelfth_inner in lict[11]:
for thirteenth_inner in lict[12]:
for fourteenth_inner in lict[13]:
for fifteenth_inner in lict[14]:
for sixteenth_inner in lict[15]:
term = first_inner + second_inner + third_inner + fourth_inner + fifth_inner + sixth_inner + seventh_inner + eighth_inner + ninth_inner + tenth_inner + eleventh_inner + twelfth_inner + thirteenth_inner + fourteenth_inner + fifteenth_inner + sixteenth_inner
termal_lict.append(term)
return termal_lict
def user_input_handling_function_second(dictionary):
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
lict = []
while good_to_go == 'no':
for key in dictionary:
lict.append(key)
for element in user_input:
if element not in lict:
print('The form can only contain a combination of the characters that represent the lists of characters.')
errors.append('yes')
break
if len(user_input) < 2:
print("The form is too short. It can't be less than two-characters long.")
errors.append('yes')
if len(user_input) > 8:
print("The form is too long. It can't be more than eight-characters long.")
errors.append('yes')
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return user_input
def user_input_handling_function_third():
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
yes_or_no = ['yes', 'no']
while good_to_go == 'no':
if user_input not in yes_or_no:
print('You have to answer yes or no.')
errors.append('yes')
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return user_input
def user_input_handling_function_fourth(dictionary):
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
while good_to_go == 'no':
if user_input not in dictionary:
print('The form you entered does not match one of the forms in your termal_dictionary. Each form in your')
print('termal_dictionary is a name (key) that has an associated definition (value) that is a list of terms')
print('that all have the same form as the name (key).')
errors.append('yes')
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return user_input
def user_input_handling_function_eighth():
print()
user_input = input('Enter: ')
print()
good_to_go = 'no'
errors = []
digits = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-']
while good_to_go == 'no':
if user_input == 'None':
user_input = None
return user_input
else:
for inner in user_input:
if inner not in digits:
print('The number must be an integer that consists of digits. For example: 1, -2, etc. or the keyword:')
print('None.')
errors.append('yes')
break
if 'yes' in errors:
good_to_go = 'no'
errors = []
print()
user_input = input('Re-enter: ')
print()
else:
good_to_go = 'yes'
return int(user_input)
def user_input_handling_function_ninth():
""" a parser """
print()
user_input = input('Enter: ')
print()
term = ''
lict = []
for element in user_input:
if element != ' ':
term = term + element
else:
lict.append(term)
term = ''
lict.append(term)
return lict
def user_input_handling_function_tenth(dictionary):
""" a dictionary checker """
user_input = user_input_handling_function_ninth()
good_to_go = 'no'
errors = []
while good_to_go == 'no':
string = ''
lict = []
for element in user_input:
string = string + element
for key in dictionary:
for element in dictionary[key]:
lict.append(element)
for element in string:
if element not in lict:
print('One of your unwanted characters or combination of characters does not match the characters you')
print('entered earlier.')
errors.append('yes')
break
if 'yes' in errors:
print()
user_input = input('Re-enter: ')
print()
good_to_go = 'no'
errors = []
else:
good_to_go = 'yes'
return user_input
def print_vertical_lict(lict):
for element in lict:
print(element)
def print_horizontal_lict(lict):
string = ''
for element in lict:
string = string + str(element) + ', '
print(string)
print()
def write_vertical_lict(file_name, lict):
file = open(file_name, 'w')
for element in lict:
element = str(element) + '\n'
file.write(element)
file.close()
def write_horizontal_lict(file_name, lict):
if '.txt' not in file_name:
file_name = file_name + '.txt'
row = ''
for index in range(len(lict)):
lict[index] = str(lict[index]) + ', '
if len(row + lict[index]) > 100:
lict[index - 1] = lict[index - 1] + '\n'
row = lict[index]
else:
row = row + lict[index]
file = open(file_name, 'w')
for term in lict:
file.write(term)
file.close()
|
"""Implementation for yq rule"""
_yq_attrs = {
"srcs": attr.label_list(
allow_files = [".yaml", ".json", ".xml"],
mandatory = True,
allow_empty = True,
),
"expression": attr.string(mandatory = False),
"args": attr.string_list(),
"outs": attr.output_list(mandatory = True),
}
def is_split_operation(args):
for arg in args:
if arg.startswith("-s") or arg.startswith("--split-exp"):
return True
return False
def _escape_path(path):
return "/".join([".." for t in path.split("/")]) + "/"
def _yq_impl(ctx):
yq_bin = ctx.toolchains["@aspect_bazel_lib//lib:yq_toolchain_type"].yqinfo.bin
outs = ctx.outputs.outs
args = ctx.attr.args[:]
inputs = ctx.files.srcs[:]
split_operation = is_split_operation(args)
if "eval" in args or "eval-all" in args:
fail("Do not pass 'eval' or 'eval-all' into yq; this is already set based on the number of srcs")
if not split_operation and len(outs) > 1:
fail("Cannot specify multiple outputs when -s or --split-exp is not set")
if "-i" in args or "--inplace" in args:
fail("Cannot use arg -i or --inplace as it is not bazel-idiomatic to update the input file; consider using write_source_files to write back to the source tree")
if len(ctx.attr.srcs) == 0 and "-n" not in args and "--null-input" not in args:
args = args + ["--null-input"]
# For split operations, yq outputs files in the same directory so we
# must cd to the correct output dir before executing it
bin_dir = ctx.bin_dir.path + "/" + ctx.label.package
escape_bin_dir = _escape_path(bin_dir)
cmd = "cd {bin_dir} && {yq} {args} {eval_cmd} {expression} {sources} {maybe_out}".format(
bin_dir = ctx.bin_dir.path + "/" + ctx.label.package,
yq = escape_bin_dir + yq_bin.path,
eval_cmd = "eval" if len(inputs) <= 1 else "eval-all",
args = " ".join(args),
expression = "'%s'" % ctx.attr.expression if ctx.attr.expression else "",
sources = " ".join(["'%s%s'" % (escape_bin_dir, file.path) for file in ctx.files.srcs]),
# In the -s/--split-exr case, the out file names are determined by the yq expression
maybe_out = (" > %s%s" % (escape_bin_dir, outs[0].path)) if len(outs) == 1 else "",
)
ctx.actions.run_shell(
tools = [yq_bin],
inputs = inputs,
outputs = outs,
command = cmd,
mnemonic = "yq",
)
return DefaultInfo(files = depset(outs), runfiles = ctx.runfiles(outs))
yq_lib = struct(
attrs = _yq_attrs,
implementation = _yq_impl,
)
|
"""Implementation for yq rule"""
_yq_attrs = {'srcs': attr.label_list(allow_files=['.yaml', '.json', '.xml'], mandatory=True, allow_empty=True), 'expression': attr.string(mandatory=False), 'args': attr.string_list(), 'outs': attr.output_list(mandatory=True)}
def is_split_operation(args):
for arg in args:
if arg.startswith('-s') or arg.startswith('--split-exp'):
return True
return False
def _escape_path(path):
return '/'.join(['..' for t in path.split('/')]) + '/'
def _yq_impl(ctx):
yq_bin = ctx.toolchains['@aspect_bazel_lib//lib:yq_toolchain_type'].yqinfo.bin
outs = ctx.outputs.outs
args = ctx.attr.args[:]
inputs = ctx.files.srcs[:]
split_operation = is_split_operation(args)
if 'eval' in args or 'eval-all' in args:
fail("Do not pass 'eval' or 'eval-all' into yq; this is already set based on the number of srcs")
if not split_operation and len(outs) > 1:
fail('Cannot specify multiple outputs when -s or --split-exp is not set')
if '-i' in args or '--inplace' in args:
fail('Cannot use arg -i or --inplace as it is not bazel-idiomatic to update the input file; consider using write_source_files to write back to the source tree')
if len(ctx.attr.srcs) == 0 and '-n' not in args and ('--null-input' not in args):
args = args + ['--null-input']
bin_dir = ctx.bin_dir.path + '/' + ctx.label.package
escape_bin_dir = _escape_path(bin_dir)
cmd = 'cd {bin_dir} && {yq} {args} {eval_cmd} {expression} {sources} {maybe_out}'.format(bin_dir=ctx.bin_dir.path + '/' + ctx.label.package, yq=escape_bin_dir + yq_bin.path, eval_cmd='eval' if len(inputs) <= 1 else 'eval-all', args=' '.join(args), expression="'%s'" % ctx.attr.expression if ctx.attr.expression else '', sources=' '.join(["'%s%s'" % (escape_bin_dir, file.path) for file in ctx.files.srcs]), maybe_out=' > %s%s' % (escape_bin_dir, outs[0].path) if len(outs) == 1 else '')
ctx.actions.run_shell(tools=[yq_bin], inputs=inputs, outputs=outs, command=cmd, mnemonic='yq')
return default_info(files=depset(outs), runfiles=ctx.runfiles(outs))
yq_lib = struct(attrs=_yq_attrs, implementation=_yq_impl)
|
# ------------------------------
# 331. Verify Preorder Serialization of a Binary Tree
#
# Description:
# One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as #.
#
# _9_
# / \
# 3 2
# / \ / \
# 4 1 # 6
# / \ / \ / \
# # # # # # #
# For example, the above binary tree can be serialized to the string "9,3,4,#,#,1,#,#,2,#,6,#,#", where # represents a null node.
#
# Given a string of comma separated values, verify whether it is a correct preorder traversal serialization of a binary tree. Find an algorithm without reconstructing the tree.
# Each comma separated value in the string must be either an integer or a character '#' representing null pointer.
# You may assume that the input format is always valid, for example it could never contain two consecutive commas such as "1,,3".
#
# Example 1:
# Input: "9,3,4,#,#,1,#,#,2,#,6,#,#"
# Output: true
#
# Example 2:
# Input: "1,#"
# Output: false
#
# Example 3:
# Input: "9,#,#,1"
# Output: false
#
# Version: 1.0
# 09/27/19 by Jianfa
# ------------------------------
class Solution:
def isValidSerialization(self, preorder: str) -> bool:
nodes = preorder.split(",")
# diff = outdegree - indegree
diff = 1
for n in nodes:
diff -= 1 # every node bring 1 indegree
if diff < 0:
return False
if n != "#": # if not null, it brings 2 outdegree
diff += 2
return diff == 0
# Used for testing
if __name__ == "__main__":
test = Solution()
# ------------------------------
# Summary:
# Math solution idea from: https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/discuss/78551/7-lines-Easy-Java-Solution
# Consider null as leaves, then
# - all non-null node provides 2 outdegree and 1 indegree (2 children and 1 parent), except root
# - all null node provides 0 outdegree and 1 indegree (0 child and 1 parent).
# During building, we record the difference between out degree and in degree diff = outdegree - indegree.
# When the next node comes, we then decrease diff by 1, because the node provides an in degree. If the node is not null, we increase diff by 2, because it provides two out degrees.
# If a serialization is correct, diff should never be negative and diff will be zero when finished.
#
# Stack solution: https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/discuss/78560/Simple-Python-solution-using-stack.-With-Explanation.
# When you see two consecutive "#" characters on stack, pop both of them and replace the topmost element on the stack with "#". For example,
# preorder = 1,2,3,#,#,#,#
# Pass 1: stack = [1]
# Pass 2: stack = [1,2]
# Pass 3: stack = [1,2,3]
# Pass 4: stack = [1,2,3,#]
# Pass 5: stack = [1,2,3,#,#] -> two #s on top so pop them and replace top with #. -> stack = [1,2,#]
# Pass 6: stack = [1,2,#,#] -> two #s on top so pop them and replace top with #. -> stack = [1,#]
# Pass 7: stack = [1,#,#] -> two #s on top so pop them and replace top with #. -> stack = [#]
#
# If there is only one # on stack at the end of the string then return True else return False.
|
class Solution:
def is_valid_serialization(self, preorder: str) -> bool:
nodes = preorder.split(',')
diff = 1
for n in nodes:
diff -= 1
if diff < 0:
return False
if n != '#':
diff += 2
return diff == 0
if __name__ == '__main__':
test = solution()
|
class HsvFilter:
def __init__(self, hMin=None, sMin=None, vMin=None, hMax=None, sMax=None, vMax=None,
sAdd=None, sSub=None, vAdd=None, vSub=None):
self.hMin = hMin
self.sMin = sMin
self.vMin = vMin
self.hMax = hMax
self.sMax = sMax
self.vMax = vMax
self.sAdd = sAdd
self.sSub = sSub
self.vAdd = vAdd
self.vSub = vSub
|
class Hsvfilter:
def __init__(self, hMin=None, sMin=None, vMin=None, hMax=None, sMax=None, vMax=None, sAdd=None, sSub=None, vAdd=None, vSub=None):
self.hMin = hMin
self.sMin = sMin
self.vMin = vMin
self.hMax = hMax
self.sMax = sMax
self.vMax = vMax
self.sAdd = sAdd
self.sSub = sSub
self.vAdd = vAdd
self.vSub = vSub
|
class Solution:
def isHappy(self, n: int) -> bool:
def squaredSum(n: int) -> bool:
sum = 0
while n:
sum += pow(n % 10, 2)
n //= 10
return sum
slow = squaredSum(n)
fast = squaredSum(squaredSum(n))
while slow != fast:
slow = squaredSum(slow)
fast = squaredSum(squaredSum(fast))
return slow == 1
|
class Solution:
def is_happy(self, n: int) -> bool:
def squared_sum(n: int) -> bool:
sum = 0
while n:
sum += pow(n % 10, 2)
n //= 10
return sum
slow = squared_sum(n)
fast = squared_sum(squared_sum(n))
while slow != fast:
slow = squared_sum(slow)
fast = squared_sum(squared_sum(fast))
return slow == 1
|
def safeDict(elem, array_of_keys, default=""):
try:
for key in array_of_keys:
elem = elem[key]
return elem
except Exception as e:
return default
|
def safe_dict(elem, array_of_keys, default=''):
try:
for key in array_of_keys:
elem = elem[key]
return elem
except Exception as e:
return default
|
# Those constants are used from the library only
BASE_PAL_URL = "https://pal-{}.adyen.com/pal/servlet"
PAL_LIVE_ENDPOINT_URL_TEMPLATE = "https://{}-pal-live" \
".adyenpayments.com/pal/servlet"
BASE_HPP_URL = "https://{}.adyen.com/hpp"
ENDPOINT_CHECKOUT_TEST = "https://checkout-test.adyen.com"
ENDPOINT_CHECKOUT_LIVE_SUFFIX = "https://{}-checkout-live" \
".adyenpayments.com/checkout"
API_BIN_LOOKUP_VERSION = "v50"
API_CHECKOUT_VERSION = "v67"
API_CHECKOUT_UTILITY_VERSION = "v1"
API_RECURRING_VERSION = "v49"
API_PAYMENT_VERSION = "v64"
API_PAYOUT_VERSION = "v64"
LIB_VERSION = "5.1.0"
LIB_NAME = "adyen-python-api-library"
|
base_pal_url = 'https://pal-{}.adyen.com/pal/servlet'
pal_live_endpoint_url_template = 'https://{}-pal-live.adyenpayments.com/pal/servlet'
base_hpp_url = 'https://{}.adyen.com/hpp'
endpoint_checkout_test = 'https://checkout-test.adyen.com'
endpoint_checkout_live_suffix = 'https://{}-checkout-live.adyenpayments.com/checkout'
api_bin_lookup_version = 'v50'
api_checkout_version = 'v67'
api_checkout_utility_version = 'v1'
api_recurring_version = 'v49'
api_payment_version = 'v64'
api_payout_version = 'v64'
lib_version = '5.1.0'
lib_name = 'adyen-python-api-library'
|
__all__ = ['VERSION']
YOUTUBE_API_SERVICE_NAME = "youtube"
YOUTUBE_API_VERSION = "v3"
VIDEO = 'youtube#video'
YOUTUBE_VIDEO_URL = 'https://www.youtube.com/watch?v='
VERSION = '4.0.0'
|
__all__ = ['VERSION']
youtube_api_service_name = 'youtube'
youtube_api_version = 'v3'
video = 'youtube#video'
youtube_video_url = 'https://www.youtube.com/watch?v='
version = '4.0.0'
|
# mailbox_or_url_parsetab.py
# This file is automatically generated. Do not edit.
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'mailbox_or_urlFWSP AT DOT COMMA SEMICOLON LANGLE RANGLE ATOM DOT_ATOM LBRACKET RBRACKET DTEXT DQUOTE QTEXT QPAIR LPAREN RPAREN CTEXT URLmailbox_or_url_list : mailbox_or_url_list delim mailbox_or_url\n | mailbox_or_url_list delim\n | mailbox_or_urldelim : delim fwsp COMMA\n | delim fwsp SEMICOLON\n | COMMA\n | SEMICOLONmailbox_or_url : mailbox\n | urlurl : ofwsp URL ofwspmailbox : addr_spec\n | angle_addr\n | name_addrname_addr : ofwsp phrase angle_addrangle_addr : ofwsp LANGLE addr_spec RANGLE ofwspaddr_spec : ofwsp local_part AT domain ofwsplocal_part : DOT_ATOM\n | ATOM\n | quoted_stringdomain : DOT_ATOM\n | ATOM\n | domain_literalquoted_string : DQUOTE quoted_string_text DQUOTE\n | DQUOTE DQUOTEquoted_string_text : quoted_string_text QTEXT\n | quoted_string_text QPAIR\n | quoted_string_text fwsp\n | QTEXT\n | QPAIR\n | fwspdomain_literal : LBRACKET domain_literal_text RBRACKET\n | LBRACKET RBRACKETdomain_literal_text : domain_literal_text DTEXT\n | domain_literal_text fwsp\n | DTEXT\n | fwspcomment : LPAREN comment_text RPAREN\n | LPAREN RPARENcomment_text : comment_text CTEXT\n | comment_text fwsp\n | CTEXT\n | fwspphrase : phrase fwsp ATOM\n | phrase fwsp DOT_ATOM\n | phrase fwsp DOT\n | phrase fwsp quoted_string\n | phrase ATOM\n | phrase DOT_ATOM\n | phrase DOT\n | phrase quoted_string\n | ATOM\n | DOT_ATOM\n | DOT\n | quoted_stringofwsp : fwsp comment fwsp\n | fwsp comment\n | comment fwsp\n | comment\n | fwsp\n |fwsp : FWSP'
_lr_action_items = {'FWSP':([0,2,7,11,12,14,15,17,18,19,20,21,22,23,24,25,26,32,33,34,35,36,40,41,42,43,44,45,46,50,51,52,53,54,55,56,57,58,59,60,61,62,63,66,67,68,69,70,71,72,],[7,7,-61,7,7,7,7,-51,7,-52,7,-54,-53,-42,7,-38,-41,-30,-29,-28,-24,7,-48,-47,-50,-49,-40,-37,-39,7,7,7,-20,-21,-22,-27,-26,-25,-23,-44,-43,-46,-45,-36,-35,7,-32,-34,-33,-31,]),'LANGLE':([0,1,2,4,7,12,13,17,19,20,21,22,25,27,35,37,38,40,41,42,43,45,59,60,61,62,63,],[-60,-59,-58,14,-61,-56,-57,-51,-52,-60,-54,-53,-38,-55,-24,-59,14,-48,-47,-50,-49,-37,-23,-44,-43,-46,-45,]),'QPAIR':([7,18,32,33,34,36,56,57,58,],[-61,33,-30,-29,-28,57,-27,-26,-25,]),'URL':([0,1,2,4,7,12,13,25,27,45,],[-60,-59,-58,15,-61,-56,-57,-38,-55,-37,]),'QTEXT':([7,18,32,33,34,36,56,57,58,],[-61,34,-30,-29,-28,58,-27,-26,-25,]),'DTEXT':([7,52,66,67,68,70,71,],[-61,67,-36,-35,71,-34,-33,]),'DQUOTE':([0,1,2,4,7,12,13,14,17,18,19,20,21,22,25,27,28,32,33,34,35,36,37,40,41,42,43,45,56,57,58,59,60,61,62,63,],[-60,-59,-58,18,-61,-56,-57,-60,-51,35,-52,18,-54,-53,-38,-55,18,-30,-29,-28,-24,59,18,-48,-47,-50,-49,-37,-27,-26,-25,-23,-44,-43,-46,-45,]),'LBRACKET':([31,],[52,]),'DOT_ATOM':([0,1,2,4,7,12,13,14,17,19,20,21,22,25,27,28,31,35,37,40,41,42,43,45,59,60,61,62,63,],[-60,-59,-58,19,-61,-56,-57,-60,-51,-52,40,-54,-53,-38,-55,47,53,-24,60,-48,-47,-50,-49,-37,-23,-44,-43,-46,-45,]),'RPAREN':([7,11,23,24,26,44,46,],[-61,25,-42,45,-41,-40,-39,]),'AT':([16,17,19,21,35,47,48,49,59,],[31,-18,-17,-19,-24,-17,-18,-19,-23,]),'LPAREN':([0,1,7,14,15,17,19,20,21,22,35,37,40,41,42,43,50,51,53,54,55,59,60,61,62,63,69,72,],[11,11,-61,11,11,-51,-52,11,-54,-53,-24,11,-48,-47,-50,-49,11,11,-20,-21,-22,-23,-44,-43,-46,-45,-32,-31,]),'ATOM':([0,1,2,4,7,12,13,14,17,19,20,21,22,25,27,28,31,35,37,40,41,42,43,45,59,60,61,62,63,],[-60,-59,-58,17,-61,-56,-57,-60,-51,-52,41,-54,-53,-38,-55,48,54,-24,61,-48,-47,-50,-49,-37,-23,-44,-43,-46,-45,]),'RANGLE':([1,2,7,12,13,25,27,29,45,51,53,54,55,65,69,72,],[-59,-58,-61,-56,-57,-38,-55,50,-37,-60,-20,-21,-22,-16,-32,-31,]),'RBRACKET':([7,52,66,67,68,70,71,],[-61,69,-36,-35,72,-34,-33,]),'CTEXT':([7,11,23,24,26,44,46,],[-61,26,-42,46,-41,-40,-39,]),'DOT':([0,1,2,4,7,12,13,17,19,20,21,22,25,27,35,37,40,41,42,43,45,59,60,61,62,63,],[-60,-59,-58,22,-61,-56,-57,-51,-52,43,-54,-53,-38,-55,-24,63,-48,-47,-50,-49,-37,-23,-44,-43,-46,-45,]),'$end':([1,2,3,5,6,7,8,9,10,12,13,15,25,27,30,39,45,50,51,53,54,55,64,65,69,72,],[-59,-58,-13,-12,0,-61,-8,-9,-11,-56,-57,-60,-38,-55,-10,-14,-37,-60,-60,-20,-21,-22,-15,-16,-32,-31,]),}
_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 = {'fwsp':([0,2,11,12,14,15,18,20,24,36,50,51,52,68,],[1,13,23,27,1,1,32,37,44,56,1,1,66,70,]),'comment':([0,1,14,15,20,37,50,51,],[2,12,2,2,2,12,2,2,]),'domain':([31,],[51,]),'comment_text':([11,],[24,]),'name_addr':([0,],[3,]),'ofwsp':([0,14,15,20,50,51,],[4,28,30,38,64,65,]),'angle_addr':([0,20,],[5,39,]),'mailbox_or_url':([0,],[6,]),'local_part':([4,28,],[16,16,]),'domain_literal_text':([52,],[68,]),'mailbox':([0,],[8,]),'quoted_string_text':([18,],[36,]),'url':([0,],[9,]),'addr_spec':([0,14,],[10,29,]),'phrase':([4,],[20,]),'quoted_string':([4,20,28,37,],[21,42,49,62,]),'domain_literal':([31,],[55,]),}
_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' -> mailbox_or_url","S'",1,None,None,None),
('mailbox_or_url_list -> mailbox_or_url_list delim mailbox_or_url','mailbox_or_url_list',3,'p_expression_mailbox_or_url_list','parser.py',19),
('mailbox_or_url_list -> mailbox_or_url_list delim','mailbox_or_url_list',2,'p_expression_mailbox_or_url_list','parser.py',20),
('mailbox_or_url_list -> mailbox_or_url','mailbox_or_url_list',1,'p_expression_mailbox_or_url_list','parser.py',21),
('delim -> delim fwsp COMMA','delim',3,'p_delim','parser.py',30),
('delim -> delim fwsp SEMICOLON','delim',3,'p_delim','parser.py',31),
('delim -> COMMA','delim',1,'p_delim','parser.py',32),
('delim -> SEMICOLON','delim',1,'p_delim','parser.py',33),
('mailbox_or_url -> mailbox','mailbox_or_url',1,'p_expression_mailbox_or_url','parser.py',36),
('mailbox_or_url -> url','mailbox_or_url',1,'p_expression_mailbox_or_url','parser.py',37),
('url -> ofwsp URL ofwsp','url',3,'p_expression_url','parser.py',41),
('mailbox -> addr_spec','mailbox',1,'p_expression_mailbox','parser.py',45),
('mailbox -> angle_addr','mailbox',1,'p_expression_mailbox','parser.py',46),
('mailbox -> name_addr','mailbox',1,'p_expression_mailbox','parser.py',47),
('name_addr -> ofwsp phrase angle_addr','name_addr',3,'p_expression_name_addr','parser.py',51),
('angle_addr -> ofwsp LANGLE addr_spec RANGLE ofwsp','angle_addr',5,'p_expression_angle_addr','parser.py',55),
('addr_spec -> ofwsp local_part AT domain ofwsp','addr_spec',5,'p_expression_addr_spec','parser.py',59),
('local_part -> DOT_ATOM','local_part',1,'p_expression_local_part','parser.py',63),
('local_part -> ATOM','local_part',1,'p_expression_local_part','parser.py',64),
('local_part -> quoted_string','local_part',1,'p_expression_local_part','parser.py',65),
('domain -> DOT_ATOM','domain',1,'p_expression_domain','parser.py',69),
('domain -> ATOM','domain',1,'p_expression_domain','parser.py',70),
('domain -> domain_literal','domain',1,'p_expression_domain','parser.py',71),
('quoted_string -> DQUOTE quoted_string_text DQUOTE','quoted_string',3,'p_expression_quoted_string','parser.py',75),
('quoted_string -> DQUOTE DQUOTE','quoted_string',2,'p_expression_quoted_string','parser.py',76),
('quoted_string_text -> quoted_string_text QTEXT','quoted_string_text',2,'p_expression_quoted_string_text','parser.py',83),
('quoted_string_text -> quoted_string_text QPAIR','quoted_string_text',2,'p_expression_quoted_string_text','parser.py',84),
('quoted_string_text -> quoted_string_text fwsp','quoted_string_text',2,'p_expression_quoted_string_text','parser.py',85),
('quoted_string_text -> QTEXT','quoted_string_text',1,'p_expression_quoted_string_text','parser.py',86),
('quoted_string_text -> QPAIR','quoted_string_text',1,'p_expression_quoted_string_text','parser.py',87),
('quoted_string_text -> fwsp','quoted_string_text',1,'p_expression_quoted_string_text','parser.py',88),
('domain_literal -> LBRACKET domain_literal_text RBRACKET','domain_literal',3,'p_expression_domain_literal','parser.py',92),
('domain_literal -> LBRACKET RBRACKET','domain_literal',2,'p_expression_domain_literal','parser.py',93),
('domain_literal_text -> domain_literal_text DTEXT','domain_literal_text',2,'p_expression_domain_literal_text','parser.py',100),
('domain_literal_text -> domain_literal_text fwsp','domain_literal_text',2,'p_expression_domain_literal_text','parser.py',101),
('domain_literal_text -> DTEXT','domain_literal_text',1,'p_expression_domain_literal_text','parser.py',102),
('domain_literal_text -> fwsp','domain_literal_text',1,'p_expression_domain_literal_text','parser.py',103),
('comment -> LPAREN comment_text RPAREN','comment',3,'p_expression_comment','parser.py',107),
('comment -> LPAREN RPAREN','comment',2,'p_expression_comment','parser.py',108),
('comment_text -> comment_text CTEXT','comment_text',2,'p_expression_comment_text','parser.py',112),
('comment_text -> comment_text fwsp','comment_text',2,'p_expression_comment_text','parser.py',113),
('comment_text -> CTEXT','comment_text',1,'p_expression_comment_text','parser.py',114),
('comment_text -> fwsp','comment_text',1,'p_expression_comment_text','parser.py',115),
('phrase -> phrase fwsp ATOM','phrase',3,'p_expression_phrase','parser.py',119),
('phrase -> phrase fwsp DOT_ATOM','phrase',3,'p_expression_phrase','parser.py',120),
('phrase -> phrase fwsp DOT','phrase',3,'p_expression_phrase','parser.py',121),
('phrase -> phrase fwsp quoted_string','phrase',3,'p_expression_phrase','parser.py',122),
('phrase -> phrase ATOM','phrase',2,'p_expression_phrase','parser.py',123),
('phrase -> phrase DOT_ATOM','phrase',2,'p_expression_phrase','parser.py',124),
('phrase -> phrase DOT','phrase',2,'p_expression_phrase','parser.py',125),
('phrase -> phrase quoted_string','phrase',2,'p_expression_phrase','parser.py',126),
('phrase -> ATOM','phrase',1,'p_expression_phrase','parser.py',127),
('phrase -> DOT_ATOM','phrase',1,'p_expression_phrase','parser.py',128),
('phrase -> DOT','phrase',1,'p_expression_phrase','parser.py',129),
('phrase -> quoted_string','phrase',1,'p_expression_phrase','parser.py',130),
('ofwsp -> fwsp comment fwsp','ofwsp',3,'p_expression_ofwsp','parser.py',139),
('ofwsp -> fwsp comment','ofwsp',2,'p_expression_ofwsp','parser.py',140),
('ofwsp -> comment fwsp','ofwsp',2,'p_expression_ofwsp','parser.py',141),
('ofwsp -> comment','ofwsp',1,'p_expression_ofwsp','parser.py',142),
('ofwsp -> fwsp','ofwsp',1,'p_expression_ofwsp','parser.py',143),
('ofwsp -> <empty>','ofwsp',0,'p_expression_ofwsp','parser.py',144),
('fwsp -> FWSP','fwsp',1,'p_expression_fwsp','parser.py',148),
]
|
_tabversion = '3.10'
_lr_method = 'LALR'
_lr_signature = 'mailbox_or_urlFWSP AT DOT COMMA SEMICOLON LANGLE RANGLE ATOM DOT_ATOM LBRACKET RBRACKET DTEXT DQUOTE QTEXT QPAIR LPAREN RPAREN CTEXT URLmailbox_or_url_list : mailbox_or_url_list delim mailbox_or_url\n | mailbox_or_url_list delim\n | mailbox_or_urldelim : delim fwsp COMMA\n | delim fwsp SEMICOLON\n | COMMA\n | SEMICOLONmailbox_or_url : mailbox\n | urlurl : ofwsp URL ofwspmailbox : addr_spec\n | angle_addr\n | name_addrname_addr : ofwsp phrase angle_addrangle_addr : ofwsp LANGLE addr_spec RANGLE ofwspaddr_spec : ofwsp local_part AT domain ofwsplocal_part : DOT_ATOM\n | ATOM\n | quoted_stringdomain : DOT_ATOM\n | ATOM\n | domain_literalquoted_string : DQUOTE quoted_string_text DQUOTE\n | DQUOTE DQUOTEquoted_string_text : quoted_string_text QTEXT\n | quoted_string_text QPAIR\n | quoted_string_text fwsp\n | QTEXT\n | QPAIR\n | fwspdomain_literal : LBRACKET domain_literal_text RBRACKET\n | LBRACKET RBRACKETdomain_literal_text : domain_literal_text DTEXT\n | domain_literal_text fwsp\n | DTEXT\n | fwspcomment : LPAREN comment_text RPAREN\n | LPAREN RPARENcomment_text : comment_text CTEXT\n | comment_text fwsp\n | CTEXT\n | fwspphrase : phrase fwsp ATOM\n | phrase fwsp DOT_ATOM\n | phrase fwsp DOT\n | phrase fwsp quoted_string\n | phrase ATOM\n | phrase DOT_ATOM\n | phrase DOT\n | phrase quoted_string\n | ATOM\n | DOT_ATOM\n | DOT\n | quoted_stringofwsp : fwsp comment fwsp\n | fwsp comment\n | comment fwsp\n | comment\n | fwsp\n |fwsp : FWSP'
_lr_action_items = {'FWSP': ([0, 2, 7, 11, 12, 14, 15, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 32, 33, 34, 35, 36, 40, 41, 42, 43, 44, 45, 46, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 66, 67, 68, 69, 70, 71, 72], [7, 7, -61, 7, 7, 7, 7, -51, 7, -52, 7, -54, -53, -42, 7, -38, -41, -30, -29, -28, -24, 7, -48, -47, -50, -49, -40, -37, -39, 7, 7, 7, -20, -21, -22, -27, -26, -25, -23, -44, -43, -46, -45, -36, -35, 7, -32, -34, -33, -31]), 'LANGLE': ([0, 1, 2, 4, 7, 12, 13, 17, 19, 20, 21, 22, 25, 27, 35, 37, 38, 40, 41, 42, 43, 45, 59, 60, 61, 62, 63], [-60, -59, -58, 14, -61, -56, -57, -51, -52, -60, -54, -53, -38, -55, -24, -59, 14, -48, -47, -50, -49, -37, -23, -44, -43, -46, -45]), 'QPAIR': ([7, 18, 32, 33, 34, 36, 56, 57, 58], [-61, 33, -30, -29, -28, 57, -27, -26, -25]), 'URL': ([0, 1, 2, 4, 7, 12, 13, 25, 27, 45], [-60, -59, -58, 15, -61, -56, -57, -38, -55, -37]), 'QTEXT': ([7, 18, 32, 33, 34, 36, 56, 57, 58], [-61, 34, -30, -29, -28, 58, -27, -26, -25]), 'DTEXT': ([7, 52, 66, 67, 68, 70, 71], [-61, 67, -36, -35, 71, -34, -33]), 'DQUOTE': ([0, 1, 2, 4, 7, 12, 13, 14, 17, 18, 19, 20, 21, 22, 25, 27, 28, 32, 33, 34, 35, 36, 37, 40, 41, 42, 43, 45, 56, 57, 58, 59, 60, 61, 62, 63], [-60, -59, -58, 18, -61, -56, -57, -60, -51, 35, -52, 18, -54, -53, -38, -55, 18, -30, -29, -28, -24, 59, 18, -48, -47, -50, -49, -37, -27, -26, -25, -23, -44, -43, -46, -45]), 'LBRACKET': ([31], [52]), 'DOT_ATOM': ([0, 1, 2, 4, 7, 12, 13, 14, 17, 19, 20, 21, 22, 25, 27, 28, 31, 35, 37, 40, 41, 42, 43, 45, 59, 60, 61, 62, 63], [-60, -59, -58, 19, -61, -56, -57, -60, -51, -52, 40, -54, -53, -38, -55, 47, 53, -24, 60, -48, -47, -50, -49, -37, -23, -44, -43, -46, -45]), 'RPAREN': ([7, 11, 23, 24, 26, 44, 46], [-61, 25, -42, 45, -41, -40, -39]), 'AT': ([16, 17, 19, 21, 35, 47, 48, 49, 59], [31, -18, -17, -19, -24, -17, -18, -19, -23]), 'LPAREN': ([0, 1, 7, 14, 15, 17, 19, 20, 21, 22, 35, 37, 40, 41, 42, 43, 50, 51, 53, 54, 55, 59, 60, 61, 62, 63, 69, 72], [11, 11, -61, 11, 11, -51, -52, 11, -54, -53, -24, 11, -48, -47, -50, -49, 11, 11, -20, -21, -22, -23, -44, -43, -46, -45, -32, -31]), 'ATOM': ([0, 1, 2, 4, 7, 12, 13, 14, 17, 19, 20, 21, 22, 25, 27, 28, 31, 35, 37, 40, 41, 42, 43, 45, 59, 60, 61, 62, 63], [-60, -59, -58, 17, -61, -56, -57, -60, -51, -52, 41, -54, -53, -38, -55, 48, 54, -24, 61, -48, -47, -50, -49, -37, -23, -44, -43, -46, -45]), 'RANGLE': ([1, 2, 7, 12, 13, 25, 27, 29, 45, 51, 53, 54, 55, 65, 69, 72], [-59, -58, -61, -56, -57, -38, -55, 50, -37, -60, -20, -21, -22, -16, -32, -31]), 'RBRACKET': ([7, 52, 66, 67, 68, 70, 71], [-61, 69, -36, -35, 72, -34, -33]), 'CTEXT': ([7, 11, 23, 24, 26, 44, 46], [-61, 26, -42, 46, -41, -40, -39]), 'DOT': ([0, 1, 2, 4, 7, 12, 13, 17, 19, 20, 21, 22, 25, 27, 35, 37, 40, 41, 42, 43, 45, 59, 60, 61, 62, 63], [-60, -59, -58, 22, -61, -56, -57, -51, -52, 43, -54, -53, -38, -55, -24, 63, -48, -47, -50, -49, -37, -23, -44, -43, -46, -45]), '$end': ([1, 2, 3, 5, 6, 7, 8, 9, 10, 12, 13, 15, 25, 27, 30, 39, 45, 50, 51, 53, 54, 55, 64, 65, 69, 72], [-59, -58, -13, -12, 0, -61, -8, -9, -11, -56, -57, -60, -38, -55, -10, -14, -37, -60, -60, -20, -21, -22, -15, -16, -32, -31])}
_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 = {'fwsp': ([0, 2, 11, 12, 14, 15, 18, 20, 24, 36, 50, 51, 52, 68], [1, 13, 23, 27, 1, 1, 32, 37, 44, 56, 1, 1, 66, 70]), 'comment': ([0, 1, 14, 15, 20, 37, 50, 51], [2, 12, 2, 2, 2, 12, 2, 2]), 'domain': ([31], [51]), 'comment_text': ([11], [24]), 'name_addr': ([0], [3]), 'ofwsp': ([0, 14, 15, 20, 50, 51], [4, 28, 30, 38, 64, 65]), 'angle_addr': ([0, 20], [5, 39]), 'mailbox_or_url': ([0], [6]), 'local_part': ([4, 28], [16, 16]), 'domain_literal_text': ([52], [68]), 'mailbox': ([0], [8]), 'quoted_string_text': ([18], [36]), 'url': ([0], [9]), 'addr_spec': ([0, 14], [10, 29]), 'phrase': ([4], [20]), 'quoted_string': ([4, 20, 28, 37], [21, 42, 49, 62]), 'domain_literal': ([31], [55])}
_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' -> mailbox_or_url", "S'", 1, None, None, None), ('mailbox_or_url_list -> mailbox_or_url_list delim mailbox_or_url', 'mailbox_or_url_list', 3, 'p_expression_mailbox_or_url_list', 'parser.py', 19), ('mailbox_or_url_list -> mailbox_or_url_list delim', 'mailbox_or_url_list', 2, 'p_expression_mailbox_or_url_list', 'parser.py', 20), ('mailbox_or_url_list -> mailbox_or_url', 'mailbox_or_url_list', 1, 'p_expression_mailbox_or_url_list', 'parser.py', 21), ('delim -> delim fwsp COMMA', 'delim', 3, 'p_delim', 'parser.py', 30), ('delim -> delim fwsp SEMICOLON', 'delim', 3, 'p_delim', 'parser.py', 31), ('delim -> COMMA', 'delim', 1, 'p_delim', 'parser.py', 32), ('delim -> SEMICOLON', 'delim', 1, 'p_delim', 'parser.py', 33), ('mailbox_or_url -> mailbox', 'mailbox_or_url', 1, 'p_expression_mailbox_or_url', 'parser.py', 36), ('mailbox_or_url -> url', 'mailbox_or_url', 1, 'p_expression_mailbox_or_url', 'parser.py', 37), ('url -> ofwsp URL ofwsp', 'url', 3, 'p_expression_url', 'parser.py', 41), ('mailbox -> addr_spec', 'mailbox', 1, 'p_expression_mailbox', 'parser.py', 45), ('mailbox -> angle_addr', 'mailbox', 1, 'p_expression_mailbox', 'parser.py', 46), ('mailbox -> name_addr', 'mailbox', 1, 'p_expression_mailbox', 'parser.py', 47), ('name_addr -> ofwsp phrase angle_addr', 'name_addr', 3, 'p_expression_name_addr', 'parser.py', 51), ('angle_addr -> ofwsp LANGLE addr_spec RANGLE ofwsp', 'angle_addr', 5, 'p_expression_angle_addr', 'parser.py', 55), ('addr_spec -> ofwsp local_part AT domain ofwsp', 'addr_spec', 5, 'p_expression_addr_spec', 'parser.py', 59), ('local_part -> DOT_ATOM', 'local_part', 1, 'p_expression_local_part', 'parser.py', 63), ('local_part -> ATOM', 'local_part', 1, 'p_expression_local_part', 'parser.py', 64), ('local_part -> quoted_string', 'local_part', 1, 'p_expression_local_part', 'parser.py', 65), ('domain -> DOT_ATOM', 'domain', 1, 'p_expression_domain', 'parser.py', 69), ('domain -> ATOM', 'domain', 1, 'p_expression_domain', 'parser.py', 70), ('domain -> domain_literal', 'domain', 1, 'p_expression_domain', 'parser.py', 71), ('quoted_string -> DQUOTE quoted_string_text DQUOTE', 'quoted_string', 3, 'p_expression_quoted_string', 'parser.py', 75), ('quoted_string -> DQUOTE DQUOTE', 'quoted_string', 2, 'p_expression_quoted_string', 'parser.py', 76), ('quoted_string_text -> quoted_string_text QTEXT', 'quoted_string_text', 2, 'p_expression_quoted_string_text', 'parser.py', 83), ('quoted_string_text -> quoted_string_text QPAIR', 'quoted_string_text', 2, 'p_expression_quoted_string_text', 'parser.py', 84), ('quoted_string_text -> quoted_string_text fwsp', 'quoted_string_text', 2, 'p_expression_quoted_string_text', 'parser.py', 85), ('quoted_string_text -> QTEXT', 'quoted_string_text', 1, 'p_expression_quoted_string_text', 'parser.py', 86), ('quoted_string_text -> QPAIR', 'quoted_string_text', 1, 'p_expression_quoted_string_text', 'parser.py', 87), ('quoted_string_text -> fwsp', 'quoted_string_text', 1, 'p_expression_quoted_string_text', 'parser.py', 88), ('domain_literal -> LBRACKET domain_literal_text RBRACKET', 'domain_literal', 3, 'p_expression_domain_literal', 'parser.py', 92), ('domain_literal -> LBRACKET RBRACKET', 'domain_literal', 2, 'p_expression_domain_literal', 'parser.py', 93), ('domain_literal_text -> domain_literal_text DTEXT', 'domain_literal_text', 2, 'p_expression_domain_literal_text', 'parser.py', 100), ('domain_literal_text -> domain_literal_text fwsp', 'domain_literal_text', 2, 'p_expression_domain_literal_text', 'parser.py', 101), ('domain_literal_text -> DTEXT', 'domain_literal_text', 1, 'p_expression_domain_literal_text', 'parser.py', 102), ('domain_literal_text -> fwsp', 'domain_literal_text', 1, 'p_expression_domain_literal_text', 'parser.py', 103), ('comment -> LPAREN comment_text RPAREN', 'comment', 3, 'p_expression_comment', 'parser.py', 107), ('comment -> LPAREN RPAREN', 'comment', 2, 'p_expression_comment', 'parser.py', 108), ('comment_text -> comment_text CTEXT', 'comment_text', 2, 'p_expression_comment_text', 'parser.py', 112), ('comment_text -> comment_text fwsp', 'comment_text', 2, 'p_expression_comment_text', 'parser.py', 113), ('comment_text -> CTEXT', 'comment_text', 1, 'p_expression_comment_text', 'parser.py', 114), ('comment_text -> fwsp', 'comment_text', 1, 'p_expression_comment_text', 'parser.py', 115), ('phrase -> phrase fwsp ATOM', 'phrase', 3, 'p_expression_phrase', 'parser.py', 119), ('phrase -> phrase fwsp DOT_ATOM', 'phrase', 3, 'p_expression_phrase', 'parser.py', 120), ('phrase -> phrase fwsp DOT', 'phrase', 3, 'p_expression_phrase', 'parser.py', 121), ('phrase -> phrase fwsp quoted_string', 'phrase', 3, 'p_expression_phrase', 'parser.py', 122), ('phrase -> phrase ATOM', 'phrase', 2, 'p_expression_phrase', 'parser.py', 123), ('phrase -> phrase DOT_ATOM', 'phrase', 2, 'p_expression_phrase', 'parser.py', 124), ('phrase -> phrase DOT', 'phrase', 2, 'p_expression_phrase', 'parser.py', 125), ('phrase -> phrase quoted_string', 'phrase', 2, 'p_expression_phrase', 'parser.py', 126), ('phrase -> ATOM', 'phrase', 1, 'p_expression_phrase', 'parser.py', 127), ('phrase -> DOT_ATOM', 'phrase', 1, 'p_expression_phrase', 'parser.py', 128), ('phrase -> DOT', 'phrase', 1, 'p_expression_phrase', 'parser.py', 129), ('phrase -> quoted_string', 'phrase', 1, 'p_expression_phrase', 'parser.py', 130), ('ofwsp -> fwsp comment fwsp', 'ofwsp', 3, 'p_expression_ofwsp', 'parser.py', 139), ('ofwsp -> fwsp comment', 'ofwsp', 2, 'p_expression_ofwsp', 'parser.py', 140), ('ofwsp -> comment fwsp', 'ofwsp', 2, 'p_expression_ofwsp', 'parser.py', 141), ('ofwsp -> comment', 'ofwsp', 1, 'p_expression_ofwsp', 'parser.py', 142), ('ofwsp -> fwsp', 'ofwsp', 1, 'p_expression_ofwsp', 'parser.py', 143), ('ofwsp -> <empty>', 'ofwsp', 0, 'p_expression_ofwsp', 'parser.py', 144), ('fwsp -> FWSP', 'fwsp', 1, 'p_expression_fwsp', 'parser.py', 148)]
|
"""
142. Linked List Cycle II
Medium
Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to (0-indexed). It is -1 if there is no cycle. Note that pos is not passed as a parameter.
Do not modify the linked list.
Example 1:
Input: head = [3,2,0,-4], pos = 1
Output: tail connects to node index 1
Explanation: There is a cycle in the linked list, where tail connects to the second node.
Example 2:
Input: head = [1,2], pos = 0
Output: tail connects to node index 0
Explanation: There is a cycle in the linked list, where tail connects to the first node.
Example 3:
Input: head = [1], pos = -1
Output: no cycle
Explanation: There is no cycle in the linked list.
Constraints:
The number of the nodes in the list is in the range [0, 104].
-105 <= Node.val <= 105
pos is -1 or a valid index in the linked-list.
Follow up: Can you solve it using O(1) (i.e. constant) memory?
"""
# V0
# IDEA : 2 pointers + linked list basics
# https://github.com/yennanliu/CS_basics/blob/master/doc/cheatsheet/2_pointers.md
class Solution:
def detectCycle(self, head):
if not head or not head.next:
return
slow = fast = head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
#print ("slow = " + str(slow) + " fast = " + str(fast))
### NOTE : via below condition check if is a cycle linked list
if not fast or not fast.next:
return
"""
### NOTE : re-init slow or fast as head (from starting point)
-> can init slow or head
"""
slow = head
#fast = head
"""
### NOTE : check while slow != fast
### NOTE : use the same speed
"""
while slow != fast:
fast = fast.next
slow = slow.next
return slow
# V0'
# IDEA : SET
class Solution(object):
def detectCycle(self, head):
if not head or not head.next:
return
s = set()
while head:
s.add(head)
head = head.next
if head in s:
return head
return
# V0'
# IDEA : SET
class Solution(object):
def detectCycle(self, head):
if not head: return None
visited = set()
while head:
if head in visited:
return head
visited.add(head)
head = head.next
return None
# V1
# https://blog.csdn.net/fuxuemingzhu/article/details/79530638
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def detectCycle(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
slow, fast = head, head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
if not fast or not fast.next:
return None
slow = head
while slow != fast:
slow = slow.next
fast = fast.next
return fast
# V1'
# https://blog.csdn.net/fuxuemingzhu/article/details/79530638
# IDEA : SET
class Solution(object):
def detectCycle(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head: return None
visited = set()
while head:
if head in visited:
return head
visited.add(head)
head = head.next
return None
# V1''
# http://bookshadow.com/weblog/2015/07/10/leetcode-linked-list-cycle-ii/
class Solution:
# @param head, a ListNode
# @return a list node
def detectCycle(self, head):
if head is None or head.next is None:
return None
slow, fast = head.next, head.next.next
while fast and fast.next and slow != fast:
fast = fast.next.next
slow = slow.next
if fast is None or fast.next is None:
return None
slow = head
while slow != fast:
slow, fast = slow.next, fast.next
return slow
# V2
# https://www.cnblogs.com/zuoyuan/p/3701877.html
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
# @param head, a ListNode
# @return a list node
def detectCycle(self, head):
if head == None or head.__next__ == None:
return None
slow = fast = head
while fast and fast.__next__:
slow = slow.__next__
fast = fast.next.__next__
if fast == slow:
break
if slow == fast:
slow = head
while slow != fast:
slow = slow.__next__
fast = fast.__next__
return slow
return None
# V3
# Time: O(n)
# Space: O(1)
class ListNode(object):
def __init__(self, x):
self.val = x
self.next = None
def __str__(self):
if self:
return "{}".format(self.val)
else:
return None
class Solution(object):
# @param head, a ListNode
# @return a list node
def detectCycle(self, head):
fast, slow = head, head
while fast and fast.__next__:
fast, slow = fast.next.__next__, slow.__next__
if fast is slow:
fast = head
while fast is not slow:
fast, slow = fast.__next__, slow.__next__
return fast
return None
|
"""
142. Linked List Cycle II
Medium
Given the head of a linked list, return the node where the cycle begins. If there is no cycle, return null.
There is a cycle in a linked list if there is some node in the list that can be reached again by continuously following the next pointer. Internally, pos is used to denote the index of the node that tail's next pointer is connected to (0-indexed). It is -1 if there is no cycle. Note that pos is not passed as a parameter.
Do not modify the linked list.
Example 1:
Input: head = [3,2,0,-4], pos = 1
Output: tail connects to node index 1
Explanation: There is a cycle in the linked list, where tail connects to the second node.
Example 2:
Input: head = [1,2], pos = 0
Output: tail connects to node index 0
Explanation: There is a cycle in the linked list, where tail connects to the first node.
Example 3:
Input: head = [1], pos = -1
Output: no cycle
Explanation: There is no cycle in the linked list.
Constraints:
The number of the nodes in the list is in the range [0, 104].
-105 <= Node.val <= 105
pos is -1 or a valid index in the linked-list.
Follow up: Can you solve it using O(1) (i.e. constant) memory?
"""
class Solution:
def detect_cycle(self, head):
if not head or not head.next:
return
slow = fast = head
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
if not fast or not fast.next:
return
'\n ### NOTE : re-init slow or fast as head (from starting point)\n -> can init slow or head\n '
slow = head
'\n ### NOTE : check while slow != fast\n ### NOTE : use the same speed\n '
while slow != fast:
fast = fast.next
slow = slow.next
return slow
class Solution(object):
def detect_cycle(self, head):
if not head or not head.next:
return
s = set()
while head:
s.add(head)
head = head.next
if head in s:
return head
return
class Solution(object):
def detect_cycle(self, head):
if not head:
return None
visited = set()
while head:
if head in visited:
return head
visited.add(head)
head = head.next
return None
class Solution(object):
def detect_cycle(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
(slow, fast) = (head, head)
while fast and fast.next:
fast = fast.next.next
slow = slow.next
if fast == slow:
break
if not fast or not fast.next:
return None
slow = head
while slow != fast:
slow = slow.next
fast = fast.next
return fast
class Solution(object):
def detect_cycle(self, head):
"""
:type head: ListNode
:rtype: ListNode
"""
if not head:
return None
visited = set()
while head:
if head in visited:
return head
visited.add(head)
head = head.next
return None
class Solution:
def detect_cycle(self, head):
if head is None or head.next is None:
return None
(slow, fast) = (head.next, head.next.next)
while fast and fast.next and (slow != fast):
fast = fast.next.next
slow = slow.next
if fast is None or fast.next is None:
return None
slow = head
while slow != fast:
(slow, fast) = (slow.next, fast.next)
return slow
class Solution:
def detect_cycle(self, head):
if head == None or head.__next__ == None:
return None
slow = fast = head
while fast and fast.__next__:
slow = slow.__next__
fast = fast.next.__next__
if fast == slow:
break
if slow == fast:
slow = head
while slow != fast:
slow = slow.__next__
fast = fast.__next__
return slow
return None
class Listnode(object):
def __init__(self, x):
self.val = x
self.next = None
def __str__(self):
if self:
return '{}'.format(self.val)
else:
return None
class Solution(object):
def detect_cycle(self, head):
(fast, slow) = (head, head)
while fast and fast.__next__:
(fast, slow) = (fast.next.__next__, slow.__next__)
if fast is slow:
fast = head
while fast is not slow:
(fast, slow) = (fast.__next__, slow.__next__)
return fast
return None
|
def sum(a, b):
"""Returns sum
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
sum -- Sum
"""
return a + b
def difference(a, b):
"""Returns difference
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
diff -- Difference
"""
return a - b
def product(a, b):
"""Returns product
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
product -- Product
"""
return a * b
def quotient(a, b):
"""Returns quotient
Arguments:
a {float} -- Input 1
b {float} -- Input 2
Returns:
quotient -- Quotient
"""
if (b == 0):
return 0
return a / b
def modulus(a, b):
"""Returns modulus
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
mod -- Modulus
"""
if (b == 0):
return 0
return a % b
def getInputs():
"""Accepts user inputs and returns them
Returns:
tuple -- set of inputs
"""
return int(input("Enter X: ")), int(input("Enter Y: "))
if __name__ == "__main__":
x, y = getInputs()
for i in range(5):
if (i == 0):
print(f"\nSum: {sum(x, y)}")
elif (i == 1):
print(f"Difference: {difference(x, y)}")
elif (i == 2):
print(f"Product: {product(x, y)}")
elif (i == 3):
print(f"Quotient: {quotient(float(x), float(y))}")
elif (i == 4):
print(f"Modulus: {modulus(x, y)}")
print("\nExiting...\n")
|
def sum(a, b):
"""Returns sum
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
sum -- Sum
"""
return a + b
def difference(a, b):
"""Returns difference
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
diff -- Difference
"""
return a - b
def product(a, b):
"""Returns product
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
product -- Product
"""
return a * b
def quotient(a, b):
"""Returns quotient
Arguments:
a {float} -- Input 1
b {float} -- Input 2
Returns:
quotient -- Quotient
"""
if b == 0:
return 0
return a / b
def modulus(a, b):
"""Returns modulus
Arguments:
a {int} -- Input 1
b {int} -- Input 2
Returns:
mod -- Modulus
"""
if b == 0:
return 0
return a % b
def get_inputs():
"""Accepts user inputs and returns them
Returns:
tuple -- set of inputs
"""
return (int(input('Enter X: ')), int(input('Enter Y: ')))
if __name__ == '__main__':
(x, y) = get_inputs()
for i in range(5):
if i == 0:
print(f'\nSum: {sum(x, y)}')
elif i == 1:
print(f'Difference: {difference(x, y)}')
elif i == 2:
print(f'Product: {product(x, y)}')
elif i == 3:
print(f'Quotient: {quotient(float(x), float(y))}')
elif i == 4:
print(f'Modulus: {modulus(x, y)}')
print('\nExiting...\n')
|
print(add(5, 3))
def add(x, y):
return x+y
|
print(add(5, 3))
def add(x, y):
return x + y
|
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def kthLargest(self, root: TreeNode, k: int) -> int:
def dfs(root):
if root:
dfs(root.left)
nums.append(root.val)
dfs(root.right)
nums = []
dfs(root)
return nums[len(nums) - k]
def kthLargest(self, root: TreeNode, k: int) -> int:
def dfs(root):
if self.k and root:
dfs(root.right)
self.k -= 1
if not self.k:
self.rtn = root.val
return
dfs(root.left)
self.k = k
dfs(root)
return self.rtn
|
class Treenode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def kth_largest(self, root: TreeNode, k: int) -> int:
def dfs(root):
if root:
dfs(root.left)
nums.append(root.val)
dfs(root.right)
nums = []
dfs(root)
return nums[len(nums) - k]
def kth_largest(self, root: TreeNode, k: int) -> int:
def dfs(root):
if self.k and root:
dfs(root.right)
self.k -= 1
if not self.k:
self.rtn = root.val
return
dfs(root.left)
self.k = k
dfs(root)
return self.rtn
|
class Solution:
# O(n) time | O(1) space - where n is the length of the input list
def slowestKey(self, releaseTimes: List[int], keysPressed: str) -> str:
maxDuration, startTime, slowestKey = 0, 0, ''
for i in range(len(releaseTimes)):
pressTime = releaseTimes[i] - startTime
if pressTime > maxDuration:
maxDuration = pressTime
slowestKey = keysPressed[i]
elif pressTime == maxDuration and keysPressed[i] > slowestKey:
slowestKey = keysPressed[i]
startTime = releaseTimes[i]
return slowestKey
|
class Solution:
def slowest_key(self, releaseTimes: List[int], keysPressed: str) -> str:
(max_duration, start_time, slowest_key) = (0, 0, '')
for i in range(len(releaseTimes)):
press_time = releaseTimes[i] - startTime
if pressTime > maxDuration:
max_duration = pressTime
slowest_key = keysPressed[i]
elif pressTime == maxDuration and keysPressed[i] > slowestKey:
slowest_key = keysPressed[i]
start_time = releaseTimes[i]
return slowestKey
|
# -*- coding: utf-8 -*-
formatted_body_template = """<div id="vlivepy-post-html" style="width:728px;">
<p><a href="###LINK###">###LINK###</a></p>
<div style="padding:15px 0;border-bottom:1px solid #f2f2f2">
<span class="author" style="font-weight:600;color:#111;font-size:14px;display:block">###AUTHOR###</span>
<span class="createdAt" style="color:#777;font-size:12px">###TIME###</span>
</div>
<h2 class="title">###TITLE###</h2>
<div class="post_content">
###POST###
</div>
</div>"""
video_box_template = """<div style="position:relative;padding-top: 56.25%;background-color: #000;margin-bottom:10px">
<div style="position: absolute;top: 0;right: 0;bottom: 0;left: 0;z-index: 0;">
<div style="position:relative;z-index:1;height:100%;">
<div class="container" style="overflow:hidden;height:100%">###VIDEO###</div>
<div class="sizer"
style="position: absolute; inset: 0px; overflow: hidden; z-index: -1; visibility: hidden; opacity: 0;"></div>
</div>
</div>
</div>
"""
|
formatted_body_template = '<div id="vlivepy-post-html" style="width:728px;">\n <p><a href="###LINK###">###LINK###</a></p>\n<div style="padding:15px 0;border-bottom:1px solid #f2f2f2">\n <span class="author" style="font-weight:600;color:#111;font-size:14px;display:block">###AUTHOR###</span>\n <span class="createdAt" style="color:#777;font-size:12px">###TIME###</span>\n</div>\n <h2 class="title">###TITLE###</h2>\n <div class="post_content">\n ###POST###\n </div>\n</div>'
video_box_template = '<div style="position:relative;padding-top: 56.25%;background-color: #000;margin-bottom:10px">\n <div style="position: absolute;top: 0;right: 0;bottom: 0;left: 0;z-index: 0;">\n <div style="position:relative;z-index:1;height:100%;">\n <div class="container" style="overflow:hidden;height:100%">###VIDEO###</div>\n <div class="sizer"\n style="position: absolute; inset: 0px; overflow: hidden; z-index: -1; visibility: hidden; opacity: 0;"></div>\n </div>\n </div>\n</div>\n'
|
# AUTOGENERATED BY NBDEV! DO NOT EDIT!
__all__ = ["index", "modules", "custom_doc_links", "git_url"]
index = {"run_params": "000_exp_02_pretrained.ipynb",
"experiment": "000_exp_02_pretrained.ipynb",
"DatasetBuilder": "01_dataset_builder.ipynb",
"StatementClassifier": "02_statement_classifer.ipynb",
"Experiment": "03_experiment.ipynb",
"RunParams": "04_run_parameters.ipynb",
"BasicModel": "05_basic_model.ipynb",
"DataManager": "06_data_manager.ipynb",
"WikiDatabase": "08_database_proxy.ipynb",
"properties": "09_properties.ipynb"}
modules = ["exp_01.py",
"dataset_builder.py",
"statement_classifier.py",
"experiment.py",
"run_params.py",
"basic_model.py",
"data_manager.py",
"database_proxy.py",
"properties.py"]
doc_url = "https://rmorain.github.io/kirby/"
git_url = "https://github.com/rmorain/kirby/tree/master/"
def custom_doc_links(name): return None
|
__all__ = ['index', 'modules', 'custom_doc_links', 'git_url']
index = {'run_params': '000_exp_02_pretrained.ipynb', 'experiment': '000_exp_02_pretrained.ipynb', 'DatasetBuilder': '01_dataset_builder.ipynb', 'StatementClassifier': '02_statement_classifer.ipynb', 'Experiment': '03_experiment.ipynb', 'RunParams': '04_run_parameters.ipynb', 'BasicModel': '05_basic_model.ipynb', 'DataManager': '06_data_manager.ipynb', 'WikiDatabase': '08_database_proxy.ipynb', 'properties': '09_properties.ipynb'}
modules = ['exp_01.py', 'dataset_builder.py', 'statement_classifier.py', 'experiment.py', 'run_params.py', 'basic_model.py', 'data_manager.py', 'database_proxy.py', 'properties.py']
doc_url = 'https://rmorain.github.io/kirby/'
git_url = 'https://github.com/rmorain/kirby/tree/master/'
def custom_doc_links(name):
return None
|
A, B = map(int, input().split())
S = str(input())
flag = True
if not S[:A].isdecimal():
flag = False
elif S[A] != '-':
flag = False
elif not S[-B:].isdecimal():
flag = False
if flag:
print('Yes')
else:
print('No')
|
(a, b) = map(int, input().split())
s = str(input())
flag = True
if not S[:A].isdecimal():
flag = False
elif S[A] != '-':
flag = False
elif not S[-B:].isdecimal():
flag = False
if flag:
print('Yes')
else:
print('No')
|
def configure_tx_chains(txChains, streamNum, mcsIdx):
txChains = txChains.lower()
RATE_MCS_ANT_A_MSK = 0x04000
RATE_MCS_ANT_B_MSK = 0x08000
RATE_MCS_ANT_C_MSK = 0x10000
RATE_MCS_HT_MSK = 0x00100
mask = 0x0
usedAntNum = 0
if "a" in txChains:
mask |= RATE_MCS_ANT_A_MSK
usedAntNum += 1
if "b" in txChains:
mask |= RATE_MCS_ANT_B_MSK
usedAntNum += 1
if "c" in txChains:
mask |= RATE_MCS_ANT_C_MSK
usedAntNum += 1
mask |= RATE_MCS_HT_MSK
if streamNum > usedAntNum:
print("Cannot use {} streams with {} antennas".format(streamNum, usedAntNum))
print("Set stream num to {}".format(usedAntNum))
streamNum = usedAntNum
mcsMask = mcsIdx
if streamNum == 2:
mcsMask += 8
elif streamNum == 3:
mcsMask += 16
mask |= mcsMask
mask = "0x{:05x}".format(mask)
print("Set TX mask: ", mask)
filePath = "/sys/kernel/debug/iwlwifi/0000:03:00.0/iwldvm/debug/monitor_tx_rate"
f = open(filePath, 'w')
f.write(mask)
f.close()
def configure_rx_chains(rxChains):
rxChains = rxChains.lower()
mask = 0x0
aMask = 0x1
bMask = 0x2
cMask = 0x4
if "a" in rxChains:
mask |= aMask
if "b" in rxChains:
mask |= bMask
if "c" in rxChains:
mask |= cMask
mask = "0x{:01x}".format(mask)
print("Set RX chain mask: ", mask)
filePath = "/sys/kernel/debug/iwlwifi/0000:03:00.0/iwldvm/debug/rx_chains_msk"
f = open(filePath, 'w')
f.write(mask)
f.close()
|
def configure_tx_chains(txChains, streamNum, mcsIdx):
tx_chains = txChains.lower()
rate_mcs_ant_a_msk = 16384
rate_mcs_ant_b_msk = 32768
rate_mcs_ant_c_msk = 65536
rate_mcs_ht_msk = 256
mask = 0
used_ant_num = 0
if 'a' in txChains:
mask |= RATE_MCS_ANT_A_MSK
used_ant_num += 1
if 'b' in txChains:
mask |= RATE_MCS_ANT_B_MSK
used_ant_num += 1
if 'c' in txChains:
mask |= RATE_MCS_ANT_C_MSK
used_ant_num += 1
mask |= RATE_MCS_HT_MSK
if streamNum > usedAntNum:
print('Cannot use {} streams with {} antennas'.format(streamNum, usedAntNum))
print('Set stream num to {}'.format(usedAntNum))
stream_num = usedAntNum
mcs_mask = mcsIdx
if streamNum == 2:
mcs_mask += 8
elif streamNum == 3:
mcs_mask += 16
mask |= mcsMask
mask = '0x{:05x}'.format(mask)
print('Set TX mask: ', mask)
file_path = '/sys/kernel/debug/iwlwifi/0000:03:00.0/iwldvm/debug/monitor_tx_rate'
f = open(filePath, 'w')
f.write(mask)
f.close()
def configure_rx_chains(rxChains):
rx_chains = rxChains.lower()
mask = 0
a_mask = 1
b_mask = 2
c_mask = 4
if 'a' in rxChains:
mask |= aMask
if 'b' in rxChains:
mask |= bMask
if 'c' in rxChains:
mask |= cMask
mask = '0x{:01x}'.format(mask)
print('Set RX chain mask: ', mask)
file_path = '/sys/kernel/debug/iwlwifi/0000:03:00.0/iwldvm/debug/rx_chains_msk'
f = open(filePath, 'w')
f.write(mask)
f.close()
|
# 19. Remove Nth Node From End of List
# Time: O(n)
# Space: O(1)
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def removeNthFromEnd(self, head: ListNode, n: int) -> ListNode:
slow = head
fast = head
for i in range(n):
fast = fast.next
while fast:
prev = slow
slow = slow.next
fast = fast.next
if slow==head:
head = head.next
else:
prev.next = slow.next
return head
|
class Solution:
def remove_nth_from_end(self, head: ListNode, n: int) -> ListNode:
slow = head
fast = head
for i in range(n):
fast = fast.next
while fast:
prev = slow
slow = slow.next
fast = fast.next
if slow == head:
head = head.next
else:
prev.next = slow.next
return head
|
"""
A particular zoo determines the price of admission based on the age of the guest.
Guests 2 years of age and less are admitted without charge.
Children between 3 and 12 years of age cost $14.00.
Seniors aged 65 years and over cost $18.00.
Admission for all other guests is $23.00.
Create a program that
begins by reading the ages of all of the guests in a group from the user,
with one age entered on each line.
The user will enter a blank line to indicate that there are no more guests in the group.
Then your program should display the admission cost for the group with an appropriate message.
The cost should be displayed using two decimal places.
"""
# START Definition of FUNCTION
def valutaEntry(numero):
if numero.isdigit():
if 0 < int(numero) <= 120:
return True
return False
def computesAdmissionPrice(age):
age = int(age)
if age <= 2:
admissionPrice = 0 # no charge
elif 3 <= age <= 14:
admissionPrice = 14.00 # $14.00
elif 15 <= age <= 64:
admissionPrice = 23.00 # $23.00
else: # equal and over 65 years
admissionPrice = 18.00 # $18.00
return admissionPrice
# END Definition of FUNCTION
# Declaration of VARIABLES
groupCost = 0
# Acquisition and Control of the DATA entered by the USER
age = input("Enter the AGE of the GUEST: ")
ageValidated = valutaEntry(age)
while not(ageValidated):
print("Incorrect entry. Try again.")
age = input("Enter the AGE of the GUEST: ")
ageValidated = valutaEntry(age)
while age != "":
if ageValidated:
admissionPrice = computesAdmissionPrice(age) # ADMISSION PRICE computing
groupCost += admissionPrice # ADMISSION PRICE for the GROUP
age = input("Enter the AGE of the GUEST (or EMPTY line to QUIT): ")
ageValidated = valutaEntry(age)
else:
print("Incorrect entry. Try again.")
age = input("Enter the AGE of the GUEST (or EMPTY line to QUIT): ")
ageValidated = valutaEntry(age)
# Displaying the RESULT
print("The TOTAL ADMISSION PRICE to the ZOO for the GROUP is $ %.2f" % groupCost)
|
"""
A particular zoo determines the price of admission based on the age of the guest.
Guests 2 years of age and less are admitted without charge.
Children between 3 and 12 years of age cost $14.00.
Seniors aged 65 years and over cost $18.00.
Admission for all other guests is $23.00.
Create a program that
begins by reading the ages of all of the guests in a group from the user,
with one age entered on each line.
The user will enter a blank line to indicate that there are no more guests in the group.
Then your program should display the admission cost for the group with an appropriate message.
The cost should be displayed using two decimal places.
"""
def valuta_entry(numero):
if numero.isdigit():
if 0 < int(numero) <= 120:
return True
return False
def computes_admission_price(age):
age = int(age)
if age <= 2:
admission_price = 0
elif 3 <= age <= 14:
admission_price = 14.0
elif 15 <= age <= 64:
admission_price = 23.0
else:
admission_price = 18.0
return admissionPrice
group_cost = 0
age = input('Enter the AGE of the GUEST: ')
age_validated = valuta_entry(age)
while not ageValidated:
print('Incorrect entry. Try again.')
age = input('Enter the AGE of the GUEST: ')
age_validated = valuta_entry(age)
while age != '':
if ageValidated:
admission_price = computes_admission_price(age)
group_cost += admissionPrice
age = input('Enter the AGE of the GUEST (or EMPTY line to QUIT): ')
age_validated = valuta_entry(age)
else:
print('Incorrect entry. Try again.')
age = input('Enter the AGE of the GUEST (or EMPTY line to QUIT): ')
age_validated = valuta_entry(age)
print('The TOTAL ADMISSION PRICE to the ZOO for the GROUP is $ %.2f' % groupCost)
|
# Cloud Automation Services SDK for Python
# Copyright (c) 2019 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
class Region(object):
"""
Class for Region methods.
Used to discover regions for all fabric constructs (images, mappings,
networks and storage.)
"""
def __init__(self,
region
):
self.external_region_id = region['externalRegionId']
self.id = region['id']
self.updated_at = region['updatedAt']
self._links = region['_links']
@staticmethod
def list(session):
uri = f'/iaas/api/regions'
j = session._request(f'{session.baseurl}{uri}')
return j['content']
@classmethod
def describe(cls, session, id):
uri = f'/iaas/api/regions/{id}'
return cls(session._request(f'{session.baseurl}{uri}'))
def describe_by_name(self, session, name):
uri = f'/iaas/api/regions/?$filter=(externalRegionId eq \'{name}\')'
j = session._request(f'{session.baseurl}{uri}')
return j
|
class Region(object):
"""
Class for Region methods.
Used to discover regions for all fabric constructs (images, mappings,
networks and storage.)
"""
def __init__(self, region):
self.external_region_id = region['externalRegionId']
self.id = region['id']
self.updated_at = region['updatedAt']
self._links = region['_links']
@staticmethod
def list(session):
uri = f'/iaas/api/regions'
j = session._request(f'{session.baseurl}{uri}')
return j['content']
@classmethod
def describe(cls, session, id):
uri = f'/iaas/api/regions/{id}'
return cls(session._request(f'{session.baseurl}{uri}'))
def describe_by_name(self, session, name):
uri = f"/iaas/api/regions/?$filter=(externalRegionId eq '{name}')"
j = session._request(f'{session.baseurl}{uri}')
return j
|
'''
URL: https://leetcode.com/problems/find-lucky-integer-in-an-array/
Difficulty: Easy
Description: Find Lucky Integer in an Array
Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.
Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.
Example 1:
Input: arr = [2,2,3,4]
Output: 2
Explanation: The only lucky number in the array is 2 because frequency[2] == 2.
Example 2:
Input: arr = [1,2,2,3,3,3]
Output: 3
Explanation: 1, 2 and 3 are all lucky numbers, return the largest of them.
Example 3:
Input: arr = [2,2,2,3,3]
Output: -1
Explanation: There are no lucky numbers in the array.
Example 4:
Input: arr = [5]
Output: -1
Example 5:
Input: arr = [7,7,7,7,7,7,7]
Output: 7
Constraints:
1 <= arr.length <= 500
1 <= arr[i] <= 500
'''
class Solution:
def findLucky(self, arr):
counts = {}
for n in arr:
if n in counts:
counts[n] += 1
else:
counts[n] = 1
max_lucky_num = -1
for n, count in counts.items():
if n == count:
max_lucky_num = max(max_lucky_num, n)
return max_lucky_num
'''
OTHER SLOW SOLUTION
class Solution:
def findLucky(self, arr):
max_lucky_num = -1
for n in arr:
if n == arr.count(n):
max_lucky_num = max(max_lucky_num, n)
return max_lucky_num
'''
|
"""
URL: https://leetcode.com/problems/find-lucky-integer-in-an-array/
Difficulty: Easy
Description: Find Lucky Integer in an Array
Given an array of integers arr, a lucky integer is an integer which has a frequency in the array equal to its value.
Return a lucky integer in the array. If there are multiple lucky integers return the largest of them. If there is no lucky integer return -1.
Example 1:
Input: arr = [2,2,3,4]
Output: 2
Explanation: The only lucky number in the array is 2 because frequency[2] == 2.
Example 2:
Input: arr = [1,2,2,3,3,3]
Output: 3
Explanation: 1, 2 and 3 are all lucky numbers, return the largest of them.
Example 3:
Input: arr = [2,2,2,3,3]
Output: -1
Explanation: There are no lucky numbers in the array.
Example 4:
Input: arr = [5]
Output: -1
Example 5:
Input: arr = [7,7,7,7,7,7,7]
Output: 7
Constraints:
1 <= arr.length <= 500
1 <= arr[i] <= 500
"""
class Solution:
def find_lucky(self, arr):
counts = {}
for n in arr:
if n in counts:
counts[n] += 1
else:
counts[n] = 1
max_lucky_num = -1
for (n, count) in counts.items():
if n == count:
max_lucky_num = max(max_lucky_num, n)
return max_lucky_num
'\nOTHER SLOW SOLUTION\n\nclass Solution:\ndef findLucky(self, arr):\n \n max_lucky_num = -1\n \n for n in arr:\n if n == arr.count(n):\n max_lucky_num = max(max_lucky_num, n)\n \n return max_lucky_num\n \n'
|
#string.py
str1 = "Hello"
str2 = 'John'
print(type(str1))
print("\"Good\\Job\"")
greet = "Hello John"
print(greet[1])
print(greet[-4])
print(greet[0:3])
print("bad" + "apple")
print("wt" + "d" * 5)
print(len("pine"))
print(type(str(123)))
|
str1 = 'Hello'
str2 = 'John'
print(type(str1))
print('"Good\\Job"')
greet = 'Hello John'
print(greet[1])
print(greet[-4])
print(greet[0:3])
print('bad' + 'apple')
print('wt' + 'd' * 5)
print(len('pine'))
print(type(str(123)))
|
class DimensionError(Exception):
"""Represents an error involving matrix dimensions."""
class CoefficientError(Exception):
"""Represents an error involving transfer function coefficients."""
class StateSpaceError(Exception):
"""Represents a miscellaneous error involving `StateSpace`."""
class ResultError(Exception):
"""Represents an error involving the result of some calculation."""
|
class Dimensionerror(Exception):
"""Represents an error involving matrix dimensions."""
class Coefficienterror(Exception):
"""Represents an error involving transfer function coefficients."""
class Statespaceerror(Exception):
"""Represents a miscellaneous error involving `StateSpace`."""
class Resulterror(Exception):
"""Represents an error involving the result of some calculation."""
|
#!/usr/bin/env python
NAME = 'Reblaze (Reblaze)'
def is_waf(self):
if self.matchcookie(r'^rbzid='):
return True
if self.matchheader(('Server', 'Reblaze Secure Web Gateway')):
return True
# Now going for attack phase
for attack in self.attacks:
r = attack(self)
if r is None:
return
_, page = r
if all(i in page for i in (b'Current session has been terminated', b'do not hesitate to contact us',
b'Access denied (403)')):
return True
return False
|
name = 'Reblaze (Reblaze)'
def is_waf(self):
if self.matchcookie('^rbzid='):
return True
if self.matchheader(('Server', 'Reblaze Secure Web Gateway')):
return True
for attack in self.attacks:
r = attack(self)
if r is None:
return
(_, page) = r
if all((i in page for i in (b'Current session has been terminated', b'do not hesitate to contact us', b'Access denied (403)'))):
return True
return False
|
"""
Enumerated data types useful for data conversion
Created: 15 May 2018
Eva Berlot & Naveed Ejaz
"""
class BidsTags:
tSubj = 'sub-'
tSes = 'ses-'
tSesID = 'ses-id'
tParticipantID = 'participants-id'
tFunc = 'func'
tFuncEvents = 'task-{}_events'
tFuncRun = 'task-{}_run-{}_bold'
tAnat = 'anat'
tDWI = 'dwi'
tMask = 'masks'
tBehRaw = 'behavior-raw'
tSurface = 'surface'
tMovPar = 'movement-param'
tMVC = 'MVC'
tFuncPrep = 'func-preprocess'
fParticipantID = 'participants.tsv'
def __init__(self):
""" purposely left empty """
|
"""
Enumerated data types useful for data conversion
Created: 15 May 2018
Eva Berlot & Naveed Ejaz
"""
class Bidstags:
t_subj = 'sub-'
t_ses = 'ses-'
t_ses_id = 'ses-id'
t_participant_id = 'participants-id'
t_func = 'func'
t_func_events = 'task-{}_events'
t_func_run = 'task-{}_run-{}_bold'
t_anat = 'anat'
t_dwi = 'dwi'
t_mask = 'masks'
t_beh_raw = 'behavior-raw'
t_surface = 'surface'
t_mov_par = 'movement-param'
t_mvc = 'MVC'
t_func_prep = 'func-preprocess'
f_participant_id = 'participants.tsv'
def __init__(self):
""" purposely left empty """
|
#
# PySNMP MIB module TIME-AGGREGATE-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/TIME-AGGREGATE-MIB
# Produced by pysmi-0.3.4 at Mon Apr 29 21:09:20 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, SingleValueConstraint, ConstraintsUnion, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ConstraintsUnion", "ValueRangeConstraint", "ConstraintsIntersection")
OwnerString, = mibBuilder.importSymbols("RMON-MIB", "OwnerString")
SnmpAdminString, = mibBuilder.importSymbols("SNMP-FRAMEWORK-MIB", "SnmpAdminString")
NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup")
MibIdentifier, Integer32, IpAddress, Unsigned32, Bits, Opaque, ObjectIdentity, Gauge32, MibScalar, MibTable, MibTableRow, MibTableColumn, experimental, TimeTicks, NotificationType, Counter64, ModuleIdentity, iso, Counter32 = mibBuilder.importSymbols("SNMPv2-SMI", "MibIdentifier", "Integer32", "IpAddress", "Unsigned32", "Bits", "Opaque", "ObjectIdentity", "Gauge32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "experimental", "TimeTicks", "NotificationType", "Counter64", "ModuleIdentity", "iso", "Counter32")
RowStatus, StorageType, TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "StorageType", "TextualConvention", "DisplayString")
tAggrMIB = ModuleIdentity((1, 3, 6, 1, 3, 124))
tAggrMIB.setRevisions(('2006-04-27 00:00',))
if mibBuilder.loadTexts: tAggrMIB.setLastUpdated('200604270000Z')
if mibBuilder.loadTexts: tAggrMIB.setOrganization('Cyber Solutions Inc. NetMan Working Group')
class TAggrMOErrorStatus(TextualConvention, Opaque):
status = 'current'
subtypeSpec = Opaque.subtypeSpec + ValueSizeConstraint(0, 1024)
class TimeAggrMOValue(TextualConvention, Opaque):
status = 'current'
subtypeSpec = Opaque.subtypeSpec + ValueSizeConstraint(0, 1024)
class CompressedTimeAggrMOValue(TextualConvention, Opaque):
status = 'current'
subtypeSpec = Opaque.subtypeSpec + ValueSizeConstraint(0, 1024)
tAggrCtlTable = MibTable((1, 3, 6, 1, 3, 124, 1), )
if mibBuilder.loadTexts: tAggrCtlTable.setStatus('current')
tAggrCtlEntry = MibTableRow((1, 3, 6, 1, 3, 124, 1, 1), ).setIndexNames((0, "TIME-AGGREGATE-MIB", "tAggrCtlEntryID"))
if mibBuilder.loadTexts: tAggrCtlEntry.setStatus('current')
tAggrCtlEntryID = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 1), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(1, 32)))
if mibBuilder.loadTexts: tAggrCtlEntryID.setStatus('current')
tAggrCtlMOInstance = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 2), ObjectIdentifier()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlMOInstance.setStatus('current')
tAggrCtlAgMODescr = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 3), SnmpAdminString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlAgMODescr.setStatus('current')
tAggrCtlInterval = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 4), Integer32()).setUnits('micro seconds').setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlInterval.setStatus('current')
tAggrCtlSamples = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 5), Integer32()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlSamples.setStatus('current')
tAggrCtlCompressionAlgorithm = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("none", 1), ("deflate", 2))).clone('none')).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlCompressionAlgorithm.setStatus('current')
tAggrCtlEntryOwner = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 7), OwnerString()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlEntryOwner.setStatus('current')
tAggrCtlEntryStorageType = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 8), StorageType()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlEntryStorageType.setStatus('current')
tAggrCtlEntryStatus = MibTableColumn((1, 3, 6, 1, 3, 124, 1, 1, 9), RowStatus()).setMaxAccess("readcreate")
if mibBuilder.loadTexts: tAggrCtlEntryStatus.setStatus('current')
tAggrDataTable = MibTable((1, 3, 6, 1, 3, 124, 2), )
if mibBuilder.loadTexts: tAggrDataTable.setStatus('current')
tAggrDataEntry = MibTableRow((1, 3, 6, 1, 3, 124, 2, 1), ).setIndexNames((0, "TIME-AGGREGATE-MIB", "tAggrCtlEntryID"))
if mibBuilder.loadTexts: tAggrDataEntry.setStatus('current')
tAggrDataRecord = MibTableColumn((1, 3, 6, 1, 3, 124, 2, 1, 1), TimeAggrMOValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: tAggrDataRecord.setStatus('current')
tAggrDataRecordCompressed = MibTableColumn((1, 3, 6, 1, 3, 124, 2, 1, 2), CompressedTimeAggrMOValue()).setMaxAccess("readonly")
if mibBuilder.loadTexts: tAggrDataRecordCompressed.setStatus('current')
tAggrDataErrorRecord = MibTableColumn((1, 3, 6, 1, 3, 124, 2, 1, 3), TAggrMOErrorStatus()).setMaxAccess("readonly")
if mibBuilder.loadTexts: tAggrDataErrorRecord.setStatus('current')
tAggrConformance = MibIdentifier((1, 3, 6, 1, 3, 124, 3))
tAggrGroups = MibIdentifier((1, 3, 6, 1, 3, 124, 3, 1))
tAggrCompliances = MibIdentifier((1, 3, 6, 1, 3, 124, 3, 2))
tAggrMibCompliance = ModuleCompliance((1, 3, 6, 1, 3, 124, 3, 2, 1)).setObjects(("TIME-AGGREGATE-MIB", "tAggrMibBasicGroup"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
tAggrMibCompliance = tAggrMibCompliance.setStatus('current')
tAggrMibBasicGroup = ObjectGroup((1, 3, 6, 1, 3, 124, 3, 1, 1)).setObjects(("TIME-AGGREGATE-MIB", "tAggrCtlMOInstance"), ("TIME-AGGREGATE-MIB", "tAggrCtlAgMODescr"), ("TIME-AGGREGATE-MIB", "tAggrCtlInterval"), ("TIME-AGGREGATE-MIB", "tAggrCtlSamples"), ("TIME-AGGREGATE-MIB", "tAggrCtlCompressionAlgorithm"), ("TIME-AGGREGATE-MIB", "tAggrCtlEntryOwner"), ("TIME-AGGREGATE-MIB", "tAggrCtlEntryStorageType"), ("TIME-AGGREGATE-MIB", "tAggrCtlEntryStatus"), ("TIME-AGGREGATE-MIB", "tAggrDataRecord"), ("TIME-AGGREGATE-MIB", "tAggrDataRecordCompressed"), ("TIME-AGGREGATE-MIB", "tAggrDataErrorRecord"))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
tAggrMibBasicGroup = tAggrMibBasicGroup.setStatus('current')
mibBuilder.exportSymbols("TIME-AGGREGATE-MIB", tAggrCtlInterval=tAggrCtlInterval, tAggrDataEntry=tAggrDataEntry, tAggrDataTable=tAggrDataTable, tAggrCtlTable=tAggrCtlTable, tAggrGroups=tAggrGroups, tAggrDataErrorRecord=tAggrDataErrorRecord, tAggrCompliances=tAggrCompliances, tAggrCtlEntry=tAggrCtlEntry, tAggrConformance=tAggrConformance, tAggrCtlEntryOwner=tAggrCtlEntryOwner, tAggrCtlAgMODescr=tAggrCtlAgMODescr, tAggrCtlEntryStorageType=tAggrCtlEntryStorageType, tAggrCtlSamples=tAggrCtlSamples, tAggrCtlEntryStatus=tAggrCtlEntryStatus, tAggrMibBasicGroup=tAggrMibBasicGroup, tAggrMibCompliance=tAggrMibCompliance, TimeAggrMOValue=TimeAggrMOValue, tAggrMIB=tAggrMIB, PYSNMP_MODULE_ID=tAggrMIB, tAggrCtlEntryID=tAggrCtlEntryID, tAggrDataRecord=tAggrDataRecord, tAggrDataRecordCompressed=tAggrDataRecordCompressed, tAggrCtlCompressionAlgorithm=tAggrCtlCompressionAlgorithm, CompressedTimeAggrMOValue=CompressedTimeAggrMOValue, tAggrCtlMOInstance=tAggrCtlMOInstance, TAggrMOErrorStatus=TAggrMOErrorStatus)
|
(object_identifier, octet_string, integer) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'OctetString', 'Integer')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, constraints_union, value_range_constraint, constraints_intersection) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'SingleValueConstraint', 'ConstraintsUnion', 'ValueRangeConstraint', 'ConstraintsIntersection')
(owner_string,) = mibBuilder.importSymbols('RMON-MIB', 'OwnerString')
(snmp_admin_string,) = mibBuilder.importSymbols('SNMP-FRAMEWORK-MIB', 'SnmpAdminString')
(notification_group, module_compliance, object_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'NotificationGroup', 'ModuleCompliance', 'ObjectGroup')
(mib_identifier, integer32, ip_address, unsigned32, bits, opaque, object_identity, gauge32, mib_scalar, mib_table, mib_table_row, mib_table_column, experimental, time_ticks, notification_type, counter64, module_identity, iso, counter32) = mibBuilder.importSymbols('SNMPv2-SMI', 'MibIdentifier', 'Integer32', 'IpAddress', 'Unsigned32', 'Bits', 'Opaque', 'ObjectIdentity', 'Gauge32', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'experimental', 'TimeTicks', 'NotificationType', 'Counter64', 'ModuleIdentity', 'iso', 'Counter32')
(row_status, storage_type, textual_convention, display_string) = mibBuilder.importSymbols('SNMPv2-TC', 'RowStatus', 'StorageType', 'TextualConvention', 'DisplayString')
t_aggr_mib = module_identity((1, 3, 6, 1, 3, 124))
tAggrMIB.setRevisions(('2006-04-27 00:00',))
if mibBuilder.loadTexts:
tAggrMIB.setLastUpdated('200604270000Z')
if mibBuilder.loadTexts:
tAggrMIB.setOrganization('Cyber Solutions Inc. NetMan Working Group')
class Taggrmoerrorstatus(TextualConvention, Opaque):
status = 'current'
subtype_spec = Opaque.subtypeSpec + value_size_constraint(0, 1024)
class Timeaggrmovalue(TextualConvention, Opaque):
status = 'current'
subtype_spec = Opaque.subtypeSpec + value_size_constraint(0, 1024)
class Compressedtimeaggrmovalue(TextualConvention, Opaque):
status = 'current'
subtype_spec = Opaque.subtypeSpec + value_size_constraint(0, 1024)
t_aggr_ctl_table = mib_table((1, 3, 6, 1, 3, 124, 1))
if mibBuilder.loadTexts:
tAggrCtlTable.setStatus('current')
t_aggr_ctl_entry = mib_table_row((1, 3, 6, 1, 3, 124, 1, 1)).setIndexNames((0, 'TIME-AGGREGATE-MIB', 'tAggrCtlEntryID'))
if mibBuilder.loadTexts:
tAggrCtlEntry.setStatus('current')
t_aggr_ctl_entry_id = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 1), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(1, 32)))
if mibBuilder.loadTexts:
tAggrCtlEntryID.setStatus('current')
t_aggr_ctl_mo_instance = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 2), object_identifier()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlMOInstance.setStatus('current')
t_aggr_ctl_ag_mo_descr = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 3), snmp_admin_string().subtype(subtypeSpec=value_size_constraint(0, 64))).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlAgMODescr.setStatus('current')
t_aggr_ctl_interval = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 4), integer32()).setUnits('micro seconds').setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlInterval.setStatus('current')
t_aggr_ctl_samples = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 5), integer32()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlSamples.setStatus('current')
t_aggr_ctl_compression_algorithm = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 6), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2))).clone(namedValues=named_values(('none', 1), ('deflate', 2))).clone('none')).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlCompressionAlgorithm.setStatus('current')
t_aggr_ctl_entry_owner = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 7), owner_string()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlEntryOwner.setStatus('current')
t_aggr_ctl_entry_storage_type = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 8), storage_type()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlEntryStorageType.setStatus('current')
t_aggr_ctl_entry_status = mib_table_column((1, 3, 6, 1, 3, 124, 1, 1, 9), row_status()).setMaxAccess('readcreate')
if mibBuilder.loadTexts:
tAggrCtlEntryStatus.setStatus('current')
t_aggr_data_table = mib_table((1, 3, 6, 1, 3, 124, 2))
if mibBuilder.loadTexts:
tAggrDataTable.setStatus('current')
t_aggr_data_entry = mib_table_row((1, 3, 6, 1, 3, 124, 2, 1)).setIndexNames((0, 'TIME-AGGREGATE-MIB', 'tAggrCtlEntryID'))
if mibBuilder.loadTexts:
tAggrDataEntry.setStatus('current')
t_aggr_data_record = mib_table_column((1, 3, 6, 1, 3, 124, 2, 1, 1), time_aggr_mo_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
tAggrDataRecord.setStatus('current')
t_aggr_data_record_compressed = mib_table_column((1, 3, 6, 1, 3, 124, 2, 1, 2), compressed_time_aggr_mo_value()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
tAggrDataRecordCompressed.setStatus('current')
t_aggr_data_error_record = mib_table_column((1, 3, 6, 1, 3, 124, 2, 1, 3), t_aggr_mo_error_status()).setMaxAccess('readonly')
if mibBuilder.loadTexts:
tAggrDataErrorRecord.setStatus('current')
t_aggr_conformance = mib_identifier((1, 3, 6, 1, 3, 124, 3))
t_aggr_groups = mib_identifier((1, 3, 6, 1, 3, 124, 3, 1))
t_aggr_compliances = mib_identifier((1, 3, 6, 1, 3, 124, 3, 2))
t_aggr_mib_compliance = module_compliance((1, 3, 6, 1, 3, 124, 3, 2, 1)).setObjects(('TIME-AGGREGATE-MIB', 'tAggrMibBasicGroup'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
t_aggr_mib_compliance = tAggrMibCompliance.setStatus('current')
t_aggr_mib_basic_group = object_group((1, 3, 6, 1, 3, 124, 3, 1, 1)).setObjects(('TIME-AGGREGATE-MIB', 'tAggrCtlMOInstance'), ('TIME-AGGREGATE-MIB', 'tAggrCtlAgMODescr'), ('TIME-AGGREGATE-MIB', 'tAggrCtlInterval'), ('TIME-AGGREGATE-MIB', 'tAggrCtlSamples'), ('TIME-AGGREGATE-MIB', 'tAggrCtlCompressionAlgorithm'), ('TIME-AGGREGATE-MIB', 'tAggrCtlEntryOwner'), ('TIME-AGGREGATE-MIB', 'tAggrCtlEntryStorageType'), ('TIME-AGGREGATE-MIB', 'tAggrCtlEntryStatus'), ('TIME-AGGREGATE-MIB', 'tAggrDataRecord'), ('TIME-AGGREGATE-MIB', 'tAggrDataRecordCompressed'), ('TIME-AGGREGATE-MIB', 'tAggrDataErrorRecord'))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
t_aggr_mib_basic_group = tAggrMibBasicGroup.setStatus('current')
mibBuilder.exportSymbols('TIME-AGGREGATE-MIB', tAggrCtlInterval=tAggrCtlInterval, tAggrDataEntry=tAggrDataEntry, tAggrDataTable=tAggrDataTable, tAggrCtlTable=tAggrCtlTable, tAggrGroups=tAggrGroups, tAggrDataErrorRecord=tAggrDataErrorRecord, tAggrCompliances=tAggrCompliances, tAggrCtlEntry=tAggrCtlEntry, tAggrConformance=tAggrConformance, tAggrCtlEntryOwner=tAggrCtlEntryOwner, tAggrCtlAgMODescr=tAggrCtlAgMODescr, tAggrCtlEntryStorageType=tAggrCtlEntryStorageType, tAggrCtlSamples=tAggrCtlSamples, tAggrCtlEntryStatus=tAggrCtlEntryStatus, tAggrMibBasicGroup=tAggrMibBasicGroup, tAggrMibCompliance=tAggrMibCompliance, TimeAggrMOValue=TimeAggrMOValue, tAggrMIB=tAggrMIB, PYSNMP_MODULE_ID=tAggrMIB, tAggrCtlEntryID=tAggrCtlEntryID, tAggrDataRecord=tAggrDataRecord, tAggrDataRecordCompressed=tAggrDataRecordCompressed, tAggrCtlCompressionAlgorithm=tAggrCtlCompressionAlgorithm, CompressedTimeAggrMOValue=CompressedTimeAggrMOValue, tAggrCtlMOInstance=tAggrCtlMOInstance, TAggrMOErrorStatus=TAggrMOErrorStatus)
|
class ExtendedTextAttributes(object):
def __init__(
self,
text, matched_text, canonical_url, description, title, jpeg_thumbnail, context_info
):
self._text = text
self._matched_text = matched_text
self._canonical_url = canonical_url
self._description = description
self._title = title
self._jpeg_thumbnail = jpeg_thumbnail
self._context_info = context_info
def __str__(self):
attrs = []
if self.text is not None:
attrs.append(("text", self.text))
if self.matched_text is not None:
attrs.append(("matched_text", self.matched_text))
if self.canonical_url is not None:
attrs.append(("canonical_url", self.canonical_url))
if self.description is not None:
attrs.append(("description", self.description))
if self.title is not None:
attrs.append(("title", self.title))
if self.jpeg_thumbnail is not None:
attrs.append(("jpeg_thumbnail", "[binary data]"))
if self.context_info is not None:
attrs.append(("context_info", self.context_info))
return "[%s]" % " ".join((map(lambda item: "%s=%s" % item, attrs)))
@property
def text(self):
return self._text
@text.setter
def text(self, value):
self._text = value
@property
def matched_text(self):
return self._matched_text
@matched_text.setter
def matched_text(self, value):
self._matched_text = value
@property
def canonical_url(self):
return self._canonical_url
@canonical_url.setter
def canonical_url(self, value):
self._canonical_url = value
@property
def description(self):
return self._description
@description.setter
def description(self, value):
self._description = value
@property
def title(self):
return self._title
@title.setter
def title(self, value):
self._title = value
@property
def jpeg_thumbnail(self):
return self._jpeg_thumbnail
@jpeg_thumbnail.setter
def jpeg_thumbnail(self, value):
self._jpeg_thumbnail = value
@property
def context_info(self):
return self._context_info
@context_info.setter
def context_info(self, value):
self._context_info = value
|
class Extendedtextattributes(object):
def __init__(self, text, matched_text, canonical_url, description, title, jpeg_thumbnail, context_info):
self._text = text
self._matched_text = matched_text
self._canonical_url = canonical_url
self._description = description
self._title = title
self._jpeg_thumbnail = jpeg_thumbnail
self._context_info = context_info
def __str__(self):
attrs = []
if self.text is not None:
attrs.append(('text', self.text))
if self.matched_text is not None:
attrs.append(('matched_text', self.matched_text))
if self.canonical_url is not None:
attrs.append(('canonical_url', self.canonical_url))
if self.description is not None:
attrs.append(('description', self.description))
if self.title is not None:
attrs.append(('title', self.title))
if self.jpeg_thumbnail is not None:
attrs.append(('jpeg_thumbnail', '[binary data]'))
if self.context_info is not None:
attrs.append(('context_info', self.context_info))
return '[%s]' % ' '.join(map(lambda item: '%s=%s' % item, attrs))
@property
def text(self):
return self._text
@text.setter
def text(self, value):
self._text = value
@property
def matched_text(self):
return self._matched_text
@matched_text.setter
def matched_text(self, value):
self._matched_text = value
@property
def canonical_url(self):
return self._canonical_url
@canonical_url.setter
def canonical_url(self, value):
self._canonical_url = value
@property
def description(self):
return self._description
@description.setter
def description(self, value):
self._description = value
@property
def title(self):
return self._title
@title.setter
def title(self, value):
self._title = value
@property
def jpeg_thumbnail(self):
return self._jpeg_thumbnail
@jpeg_thumbnail.setter
def jpeg_thumbnail(self, value):
self._jpeg_thumbnail = value
@property
def context_info(self):
return self._context_info
@context_info.setter
def context_info(self, value):
self._context_info = value
|
#!/usr/bin/env python3
"""
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by
all of the numbers from 1 to 20?
https://projecteuler.net/problem=5
"""
|
"""
2520 is the smallest number that can be divided by each of the numbers
from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by
all of the numbers from 1 to 20?
https://projecteuler.net/problem=5
"""
|
_V = {}
# Stages: game, rounds
# State: probability, probability of co-operating
# Action:
# V(t,p) gives maximum expected value from starting game t with probability p of cooperating
def V(game, probability):
if game is 10:
return 0, 0
else:
if (game, probability) not in _V:
cooperate = probability * (3 + V(game + 1, min(1, probability + 0.1))[0]) + \
(1 - probability) * (0 + V(game + 1, min(1, probability + 0.1))[0])
defect = probability * (5 + V(game + 1, max(0, probability - 0.2))[0]) + \
(1 - probability) * (1 + V(game + 1, max(0, probability - 0.2))[0])
_V[game, probability] = max((cooperate, 'Co-operate'), (defect, 'Defect'))
return _V[game, probability]
print('---------------------------')
prob = 0.6
# Transitions are deterministic so we can generate sequence of actions
for games in range(10):
payoff, decision = V(games, prob)
print('|Round', games + 1, '\t|\t', decision)
prob = min(1, prob + 0.1) if decision == 'Co-operate' else max(0, prob - 0.2)
|
_v = {}
def v(game, probability):
if game is 10:
return (0, 0)
elif (game, probability) not in _V:
cooperate = probability * (3 + v(game + 1, min(1, probability + 0.1))[0]) + (1 - probability) * (0 + v(game + 1, min(1, probability + 0.1))[0])
defect = probability * (5 + v(game + 1, max(0, probability - 0.2))[0]) + (1 - probability) * (1 + v(game + 1, max(0, probability - 0.2))[0])
_V[game, probability] = max((cooperate, 'Co-operate'), (defect, 'Defect'))
return _V[game, probability]
print('---------------------------')
prob = 0.6
for games in range(10):
(payoff, decision) = v(games, prob)
print('|Round', games + 1, '\t|\t', decision)
prob = min(1, prob + 0.1) if decision == 'Co-operate' else max(0, prob - 0.2)
|
help = """
Your project has been created!
If you have not done so already, create a conda environment for your new
project with:
cd {{cookiecutter.repo_name}}
conda create --name {{cookiecutter.repo_name}} python=3.x
conda activate {{cookiecutter.repo_name}}
conda env export > environment.yml
Install your new project in your local conda environment with:
pip install -e .
Don't forget to sync to GitHub. Have fun!
"""
print(help)
|
help = "\nYour project has been created!\n\nIf you have not done so already, create a conda environment for your new \nproject with:\n\ncd {{cookiecutter.repo_name}}\nconda create --name {{cookiecutter.repo_name}} python=3.x\nconda activate {{cookiecutter.repo_name}}\nconda env export > environment.yml\n\nInstall your new project in your local conda environment with:\n\npip install -e .\n\nDon't forget to sync to GitHub. Have fun!\n"
print(help)
|
BASE_DIR = './'
environ = {
'KPK_DATA': '/home/kpk/data',
'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
}
KPK_DATA = environ.get('KPK_DATA')
# print(KPK_DATA)
# _KPK_DATA = environ['KPK_DATA']
# print(_KPK_DATA)
# os.environ.get('KPK_DATA') or BASE_DIR
#
# os.environ.get('KPK_DATA') if os.environ.get('KPK_DATA') else BASE_DIR
# ROOT = os.environ.get('KPK_DATA') if os.environ.get('KPK_DATA') else BASE_DIR
pass
if KPK_DATA:
ROOT = KPK_DATA
else:
ROOT = BASE_DIR
print(ROOT)
pass
ROOT = KPK_DATA if KPK_DATA else BASE_DIR
print(ROOT)
pass
ROOT = KPK_DATA or BASE_DIR
print(ROOT)
|
base_dir = './'
environ = {'KPK_DATA': '/home/kpk/data', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'}
kpk_data = environ.get('KPK_DATA')
pass
if KPK_DATA:
root = KPK_DATA
else:
root = BASE_DIR
print(ROOT)
pass
root = KPK_DATA if KPK_DATA else BASE_DIR
print(ROOT)
pass
root = KPK_DATA or BASE_DIR
print(ROOT)
|
class Reference:
def __init__(self, id, campaign_id, name, details, created, modified):
self.id = id
self.campaign_id = campaign_id
self.name = name
self.details = details
self.created = created
self.modified = modified
|
class Reference:
def __init__(self, id, campaign_id, name, details, created, modified):
self.id = id
self.campaign_id = campaign_id
self.name = name
self.details = details
self.created = created
self.modified = modified
|
NONE = 0x000000000
# Posting Permissions
CREATE_POST = 0x000000001
EDIT_POST = 0x000000002
DELETE_POST = 0x000000004
# Documents Permissions
UPLOAD_DOCUMENT = 0x000000008
EDIT_DOCUMENT = 0x000000010
DELETE_DOCUMENT = 0x000000020
# User Account Permissions
CREATE_USER = 0x000000040
EDIT_USER = 0x000000080
DELETE_USER = 0x000000100
|
none = 0
create_post = 1
edit_post = 2
delete_post = 4
upload_document = 8
edit_document = 16
delete_document = 32
create_user = 64
edit_user = 128
delete_user = 256
|
class Car:
wheels = 4 # Class (Static) Variables before __init__
def __init__(self):
self.com = "BMW" # Instance Variables inside __init__
self.mil = "10"
c1 = Car()
c2 = Car()
Car.wheels = 5 # The value of all the wheels is now 5
# c1.wheels = 10 # For individual changes
# c2.wheels = 15
print(c1.com, c1.mil, c1.wheels) # print(c1.com, c1.mil, Car.wheels)
print(c2.com, c2.mil, c2.wheels) # print(c1.com, c1.mil, Car.wheels)
|
class Car:
wheels = 4
def __init__(self):
self.com = 'BMW'
self.mil = '10'
c1 = car()
c2 = car()
Car.wheels = 5
print(c1.com, c1.mil, c1.wheels)
print(c2.com, c2.mil, c2.wheels)
|
"""
author : @akash kumar
github : https://github/Akash671
string fun:
string.replace(sub_old_string,new_sub_string,count)
string.count(your_string)
"""
def solve():
#n,m=map(int,input().split())
#n=int(input())
#a=list(map(int,input().split()[:n]))
#s=str(input())
#a,b=input().split()
n=int(input())
a=list(map(int,input().split()[:n]))
b=list(map(int,input().split()[:n]))
ans=1
for i in a:
for j in b:
if i^j in (a or b):
ans+=1
if ans%2==0:
print("Yes")
else:
print("No")
for _ in range(int(input())):
solve()
|
"""
author : @akash kumar
github : https://github/Akash671
string fun:
string.replace(sub_old_string,new_sub_string,count)
string.count(your_string)
"""
def solve():
n = int(input())
a = list(map(int, input().split()[:n]))
b = list(map(int, input().split()[:n]))
ans = 1
for i in a:
for j in b:
if i ^ j in (a or b):
ans += 1
if ans % 2 == 0:
print('Yes')
else:
print('No')
for _ in range(int(input())):
solve()
|
# -*- coding: utf-8 -*-
# Copyright 2021 Cohesity Inc.
class ThrottlingConfiguration(object):
"""Implementation of the 'ThrottlingConfiguration' model.
Specifies the throttling configuration parameters.
Attributes:
fixed_threshold (long|int): Fixed baseline threshold for throttling. This is
mandatory for any other throttling type than kNoThrottling.
pattern_type (int): Type of the throttling pattern.
"""
# Create a mapping from Model property names to API property names
_names = {
"fixed_threshold": 'fixedThreshold',
"pattern_type": 'patternType'
}
def __init__(self,
fixed_threshold=None,
pattern_type=None):
"""Constructor for the ThrottlingConfiguration class"""
# Initialize members of the class
self.fixed_threshold = fixed_threshold
self.pattern_type = pattern_type
@classmethod
def from_dictionary(cls,
dictionary):
"""Creates an instance of this model from a dictionary
Args:
dictionary (dictionary): A dictionary representation of the object as
obtained from the deserialization of the server's response. The keys
MUST match property names in the API description.
Returns:
object: An instance of this structure class.
"""
if dictionary is None:
return None
# Extract variables from the dictionary
fixed_threshold = dictionary.get('fixedThreshold', None)
pattern_type = dictionary.get('patternType', None)
# Return an object of this model
return cls(fixed_threshold,
pattern_type)
|
class Throttlingconfiguration(object):
"""Implementation of the 'ThrottlingConfiguration' model.
Specifies the throttling configuration parameters.
Attributes:
fixed_threshold (long|int): Fixed baseline threshold for throttling. This is
mandatory for any other throttling type than kNoThrottling.
pattern_type (int): Type of the throttling pattern.
"""
_names = {'fixed_threshold': 'fixedThreshold', 'pattern_type': 'patternType'}
def __init__(self, fixed_threshold=None, pattern_type=None):
"""Constructor for the ThrottlingConfiguration class"""
self.fixed_threshold = fixed_threshold
self.pattern_type = pattern_type
@classmethod
def from_dictionary(cls, dictionary):
"""Creates an instance of this model from a dictionary
Args:
dictionary (dictionary): A dictionary representation of the object as
obtained from the deserialization of the server's response. The keys
MUST match property names in the API description.
Returns:
object: An instance of this structure class.
"""
if dictionary is None:
return None
fixed_threshold = dictionary.get('fixedThreshold', None)
pattern_type = dictionary.get('patternType', None)
return cls(fixed_threshold, pattern_type)
|
class Solution:
def shortestDistance(self, words, word1, word2):
"""
:type words: List[str]
:type word1: str
:type word2: str
:rtype: int
"""
idx1, idx2 = len(words), len(words)
result = len(words)
for i in range(len(words)):
if words[i] == word1:
idx1 = i
result = min(result, abs(idx2 - idx1))
if words[i] == word2:
idx2 = i
result = min(result, abs(idx2 - idx1))
return result
|
class Solution:
def shortest_distance(self, words, word1, word2):
"""
:type words: List[str]
:type word1: str
:type word2: str
:rtype: int
"""
(idx1, idx2) = (len(words), len(words))
result = len(words)
for i in range(len(words)):
if words[i] == word1:
idx1 = i
result = min(result, abs(idx2 - idx1))
if words[i] == word2:
idx2 = i
result = min(result, abs(idx2 - idx1))
return result
|
'''
Discuss structure:
Getting input from user
Formatting the input (multiply by 100 then convert to integer)
Getting total amount of change (amount paid minus bill)
Getting dollars of change (divide by 100 then convert to integer)
Getting the amount of change leftover (either change minus dollars times 100 or change modulus 100)
Getting quarters of change (divide by 25 then convert to integer)
Getting the amount of change leftover (either change minus quarters times 25 or change modulus 25)
and so on.
Stress the use of comments to at least segment the project.
Stress the use of print statements to test regularly.
Stress the use of working it out on paper in detail to see the calculations that need to be made.
'''
#EXAMPLE SOLUTION:
#The following is not perfect but would benefit from some rounding.
bill=input("How many dollars is the bill for? ")
pay=input("How many dollars will you give the cashier? ")
change=float(pay)-float(bill)
dollars=int(change/1)
left=(change%1)
quarters=int(left/.25)
left=(left%.25)
dimes=int(left/.1)
left=left%.1
nickles=int(left%.05)
pennies=int(100*(left%.05))
left=left%.01
print("If you don't turn things into ints, you are in danger of getting this: "+str(left)+", instead of zero")
print("The bill is for $" + bill + ". You are giving the cashier $" + pay +". You will recieve $"+str(change) + " in the form of " + str(dollars) +" dollars, "+str(quarters)+" quarters, "+str(dimes)+" dimes, "+str(nickles)+" nickles and "+str(left)+" pennies. Thank you for your business")
|
"""
Discuss structure:
Getting input from user
Formatting the input (multiply by 100 then convert to integer)
Getting total amount of change (amount paid minus bill)
Getting dollars of change (divide by 100 then convert to integer)
Getting the amount of change leftover (either change minus dollars times 100 or change modulus 100)
Getting quarters of change (divide by 25 then convert to integer)
Getting the amount of change leftover (either change minus quarters times 25 or change modulus 25)
and so on.
Stress the use of comments to at least segment the project.
Stress the use of print statements to test regularly.
Stress the use of working it out on paper in detail to see the calculations that need to be made.
"""
bill = input('How many dollars is the bill for? ')
pay = input('How many dollars will you give the cashier? ')
change = float(pay) - float(bill)
dollars = int(change / 1)
left = change % 1
quarters = int(left / 0.25)
left = left % 0.25
dimes = int(left / 0.1)
left = left % 0.1
nickles = int(left % 0.05)
pennies = int(100 * (left % 0.05))
left = left % 0.01
print("If you don't turn things into ints, you are in danger of getting this: " + str(left) + ', instead of zero')
print('The bill is for $' + bill + '. You are giving the cashier $' + pay + '. You will recieve $' + str(change) + ' in the form of ' + str(dollars) + ' dollars, ' + str(quarters) + ' quarters, ' + str(dimes) + ' dimes, ' + str(nickles) + ' nickles and ' + str(left) + ' pennies. Thank you for your business')
|
class AzureCloudProviderResourceModel(object):
def __init__(self):
self.azure_application_id = '' # type: str
self.azure_mgmt_network_d = '' # type: str
self.azure_mgmt_nsg_id = '' # type: str
self.azure_application_key = '' # type: str
self.region = '' # type: str
self.vm_size = '' # type: str
self.keypairs_location = '' # type: str
self.networks_in_use = '' # type: str
self.azure_subscription_id = '' # type: str
self.azure_tenant = '' # type: str
self.storage_type = '' # type: str
self.management_group_name = '' # type: str
self.additional_mgmt_networks = '' # type: str
self.cloud_provider_name = '' # type: str
self.private_ip_allocation_method = '' # type: str
|
class Azurecloudproviderresourcemodel(object):
def __init__(self):
self.azure_application_id = ''
self.azure_mgmt_network_d = ''
self.azure_mgmt_nsg_id = ''
self.azure_application_key = ''
self.region = ''
self.vm_size = ''
self.keypairs_location = ''
self.networks_in_use = ''
self.azure_subscription_id = ''
self.azure_tenant = ''
self.storage_type = ''
self.management_group_name = ''
self.additional_mgmt_networks = ''
self.cloud_provider_name = ''
self.private_ip_allocation_method = ''
|
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Copyright (c) 2021. by Daniel Barrejon, UC3M. +
# All rights reserved. This file is part of the Shi-VAE, and is released under the +
# "MIT License Agreement". Please see the LICENSE file that should have been included +
# as part of this package. +
# ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
class EarlyStopping(object):
"""
EarlyStopping scheme to finish training if model is not improving any more.
"""
def __init__(self, patience=15, min_delta=0.1):
"""
Args:
patience: (int) Patience value to stop training.
min_delta: (float) Minimum margin for improving.
"""
self.patience = patience
self.min_delta = min_delta
self.patience_cnt = 0
self.prev_loss_val = 2000000
self.patient_cum = 0
def stop(self, loss_val):
"""
Args:
loss_val: (int) Validation loss to compare and apply early stopping.
Returns:
boolean: True if stop, False if continue.
"""
if (abs(self.prev_loss_val - loss_val)> self.min_delta):
self.patience_cnt = 0
self.prev_loss_val = loss_val
else:
self.patience_cnt += 1
self.patient_cum += 1
print('Patience count: ', self.patience_cnt)
if (self.patience_cnt > self.patience or self.patient_cum > 80):
return True
else:
return False
|
class Earlystopping(object):
"""
EarlyStopping scheme to finish training if model is not improving any more.
"""
def __init__(self, patience=15, min_delta=0.1):
"""
Args:
patience: (int) Patience value to stop training.
min_delta: (float) Minimum margin for improving.
"""
self.patience = patience
self.min_delta = min_delta
self.patience_cnt = 0
self.prev_loss_val = 2000000
self.patient_cum = 0
def stop(self, loss_val):
"""
Args:
loss_val: (int) Validation loss to compare and apply early stopping.
Returns:
boolean: True if stop, False if continue.
"""
if abs(self.prev_loss_val - loss_val) > self.min_delta:
self.patience_cnt = 0
self.prev_loss_val = loss_val
else:
self.patience_cnt += 1
self.patient_cum += 1
print('Patience count: ', self.patience_cnt)
if self.patience_cnt > self.patience or self.patient_cum > 80:
return True
else:
return False
|
class Solution(object):
def canCompleteCircuit(self, gas, cost):
"""
:type gas: List[int]
:type cost: List[int]
:rtype: int
"""
r, s, t = -1, 0, 0
for i in range(0, len(gas)):
t = t + gas[i] - cost[i]
s = s + gas[i] - cost[i]
if s < 0:
r = -1
s = 0
else:
if r == -1:
r = i
if t < 0:
r = -1
return r
def test_can_complete_circuit():
s = Solution()
assert 3 == s.canCompleteCircuit([1, 2, 3, 4, 5], [3, 4, 5, 1, 2])
assert -1 == s.canCompleteCircuit([2, 3, 4], [3, 4, 3])
assert 4 == s.canCompleteCircuit([5, 1, 2, 3, 4], [4, 4, 1, 5, 1])
|
class Solution(object):
def can_complete_circuit(self, gas, cost):
"""
:type gas: List[int]
:type cost: List[int]
:rtype: int
"""
(r, s, t) = (-1, 0, 0)
for i in range(0, len(gas)):
t = t + gas[i] - cost[i]
s = s + gas[i] - cost[i]
if s < 0:
r = -1
s = 0
elif r == -1:
r = i
if t < 0:
r = -1
return r
def test_can_complete_circuit():
s = solution()
assert 3 == s.canCompleteCircuit([1, 2, 3, 4, 5], [3, 4, 5, 1, 2])
assert -1 == s.canCompleteCircuit([2, 3, 4], [3, 4, 3])
assert 4 == s.canCompleteCircuit([5, 1, 2, 3, 4], [4, 4, 1, 5, 1])
|
# Given a binary matrix representing an image, we want to flip the image horizontally, then invert it.
# To flip an image horizontally means that each row of the image is reversed.
# For example, flipping [0, 1, 1] horizontally results in [1, 1, 0].
# To invert an image means that each 0 is replaced by 1, and each 1 is replaced by 0.
# For example, inverting [1, 1, 0] results in [0, 0, 1].
# Example 1:
# Input: [
# [1,0,1],
# [1,1,1],
# [0,1,1]
# ]
# Output: [
# [0,1,0],
# [0,0,0],
# [0,0,1]
# ]
# Explanation: First reverse each row: [[1,0,1],[1,1,1],[1,1,0]]. Then, invert the image: [[0,1,0],[0,0,0],[0,0,1]]
def flip_invert_image(matrix):
m = len(matrix)
n = len(matrix[0])
for i in range(m):
for j in range((n + 1) // 2):
matrix[i][j], matrix[i][n - j - 1] = matrix[i][n - j - 1] ^ 1, matrix[i][j] ^ 1
return matrix
print(flip_invert_image([
[1,0,1],
[1,1,1],
[0,1,1]
]))
print(flip_invert_image([
[1,1,0,0],
[1,0,0,1],
[0,1,1,1],
[1,0,1,0]
]))
|
def flip_invert_image(matrix):
m = len(matrix)
n = len(matrix[0])
for i in range(m):
for j in range((n + 1) // 2):
(matrix[i][j], matrix[i][n - j - 1]) = (matrix[i][n - j - 1] ^ 1, matrix[i][j] ^ 1)
return matrix
print(flip_invert_image([[1, 0, 1], [1, 1, 1], [0, 1, 1]]))
print(flip_invert_image([[1, 1, 0, 0], [1, 0, 0, 1], [0, 1, 1, 1], [1, 0, 1, 0]]))
|
# coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
_SNAKE_TO_CAMEL_CASE_TABLE = {
"availability_zones": "availabilityZones",
"backend_services": "backendServices",
"beanstalk_environment_name": "beanstalkEnvironmentName",
"block_devices_mode": "blockDevicesMode",
"capacity_unit": "capacityUnit",
"cluster_id": "clusterId",
"cluster_zone_name": "clusterZoneName",
"controller_id": "controllerId",
"cpu_credits": "cpuCredits",
"desired_capacity": "desiredCapacity",
"draining_timeout": "drainingTimeout",
"ebs_block_devices": "ebsBlockDevices",
"ebs_optimized": "ebsOptimized",
"elastic_ips": "elasticIps",
"elastic_load_balancers": "elasticLoadBalancers",
"enable_monitoring": "enableMonitoring",
"ephemeral_block_devices": "ephemeralBlockDevices",
"event_type": "eventType",
"fallback_to_ondemand": "fallbackToOndemand",
"health_check": "healthCheck",
"health_check_grace_period": "healthCheckGracePeriod",
"health_check_type": "healthCheckType",
"health_check_unhealthy_duration_before_replacement": "healthCheckUnhealthyDurationBeforeReplacement",
"iam_instance_profile": "iamInstanceProfile",
"image_id": "imageId",
"instance_types_customs": "instanceTypesCustoms",
"instance_types_ondemand": "instanceTypesOndemand",
"instance_types_preemptibles": "instanceTypesPreemptibles",
"instance_types_preferred_spots": "instanceTypesPreferredSpots",
"instance_types_spots": "instanceTypesSpots",
"instance_types_weights": "instanceTypesWeights",
"integration_codedeploy": "integrationCodedeploy",
"integration_docker_swarm": "integrationDockerSwarm",
"integration_ecs": "integrationEcs",
"integration_gitlab": "integrationGitlab",
"integration_kubernetes": "integrationKubernetes",
"integration_mesosphere": "integrationMesosphere",
"integration_multai_runtime": "integrationMultaiRuntime",
"integration_nomad": "integrationNomad",
"integration_rancher": "integrationRancher",
"integration_route53": "integrationRoute53",
"ip_forwarding": "ipForwarding",
"key_name": "keyName",
"lifetime_period": "lifetimePeriod",
"load_balancers": "loadBalancers",
"low_priority_sizes": "lowPrioritySizes",
"max_size": "maxSize",
"min_size": "minSize",
"multai_target_sets": "multaiTargetSets",
"network_interfaces": "networkInterfaces",
"node_image": "nodeImage",
"od_sizes": "odSizes",
"ondemand_count": "ondemandCount",
"persist_block_devices": "persistBlockDevices",
"persist_private_ip": "persistPrivateIp",
"persist_root_device": "persistRootDevice",
"placement_tenancy": "placementTenancy",
"preemptible_percentage": "preemptiblePercentage",
"preferred_availability_zones": "preferredAvailabilityZones",
"private_ips": "privateIps",
"resource_group_name": "resourceGroupName",
"resource_id": "resourceId",
"revert_to_spot": "revertToSpot",
"scaling_down_policies": "scalingDownPolicies",
"scaling_target_policies": "scalingTargetPolicies",
"scaling_up_policies": "scalingUpPolicies",
"scheduled_tasks": "scheduledTasks",
"security_groups": "securityGroups",
"service_account": "serviceAccount",
"shutdown_script": "shutdownScript",
"spot_percentage": "spotPercentage",
"startup_script": "startupScript",
"stateful_deallocation": "statefulDeallocation",
"subnet_ids": "subnetIds",
"target_group_arns": "targetGroupArns",
"update_policy": "updatePolicy",
"user_data": "userData",
"utilize_reserved_instances": "utilizeReservedInstances",
"wait_for_capacity": "waitForCapacity",
"wait_for_capacity_timeout": "waitForCapacityTimeout",
}
_CAMEL_TO_SNAKE_CASE_TABLE = {
"availabilityZones": "availability_zones",
"backendServices": "backend_services",
"beanstalkEnvironmentName": "beanstalk_environment_name",
"blockDevicesMode": "block_devices_mode",
"capacityUnit": "capacity_unit",
"clusterId": "cluster_id",
"clusterZoneName": "cluster_zone_name",
"controllerId": "controller_id",
"cpuCredits": "cpu_credits",
"desiredCapacity": "desired_capacity",
"drainingTimeout": "draining_timeout",
"ebsBlockDevices": "ebs_block_devices",
"ebsOptimized": "ebs_optimized",
"elasticIps": "elastic_ips",
"elasticLoadBalancers": "elastic_load_balancers",
"enableMonitoring": "enable_monitoring",
"ephemeralBlockDevices": "ephemeral_block_devices",
"eventType": "event_type",
"fallbackToOndemand": "fallback_to_ondemand",
"healthCheck": "health_check",
"healthCheckGracePeriod": "health_check_grace_period",
"healthCheckType": "health_check_type",
"healthCheckUnhealthyDurationBeforeReplacement": "health_check_unhealthy_duration_before_replacement",
"iamInstanceProfile": "iam_instance_profile",
"imageId": "image_id",
"instanceTypesCustoms": "instance_types_customs",
"instanceTypesOndemand": "instance_types_ondemand",
"instanceTypesPreemptibles": "instance_types_preemptibles",
"instanceTypesPreferredSpots": "instance_types_preferred_spots",
"instanceTypesSpots": "instance_types_spots",
"instanceTypesWeights": "instance_types_weights",
"integrationCodedeploy": "integration_codedeploy",
"integrationDockerSwarm": "integration_docker_swarm",
"integrationEcs": "integration_ecs",
"integrationGitlab": "integration_gitlab",
"integrationKubernetes": "integration_kubernetes",
"integrationMesosphere": "integration_mesosphere",
"integrationMultaiRuntime": "integration_multai_runtime",
"integrationNomad": "integration_nomad",
"integrationRancher": "integration_rancher",
"integrationRoute53": "integration_route53",
"ipForwarding": "ip_forwarding",
"keyName": "key_name",
"lifetimePeriod": "lifetime_period",
"loadBalancers": "load_balancers",
"lowPrioritySizes": "low_priority_sizes",
"maxSize": "max_size",
"minSize": "min_size",
"multaiTargetSets": "multai_target_sets",
"networkInterfaces": "network_interfaces",
"nodeImage": "node_image",
"odSizes": "od_sizes",
"ondemandCount": "ondemand_count",
"persistBlockDevices": "persist_block_devices",
"persistPrivateIp": "persist_private_ip",
"persistRootDevice": "persist_root_device",
"placementTenancy": "placement_tenancy",
"preemptiblePercentage": "preemptible_percentage",
"preferredAvailabilityZones": "preferred_availability_zones",
"privateIps": "private_ips",
"resourceGroupName": "resource_group_name",
"resourceId": "resource_id",
"revertToSpot": "revert_to_spot",
"scalingDownPolicies": "scaling_down_policies",
"scalingTargetPolicies": "scaling_target_policies",
"scalingUpPolicies": "scaling_up_policies",
"scheduledTasks": "scheduled_tasks",
"securityGroups": "security_groups",
"serviceAccount": "service_account",
"shutdownScript": "shutdown_script",
"spotPercentage": "spot_percentage",
"startupScript": "startup_script",
"statefulDeallocation": "stateful_deallocation",
"subnetIds": "subnet_ids",
"targetGroupArns": "target_group_arns",
"updatePolicy": "update_policy",
"userData": "user_data",
"utilizeReservedInstances": "utilize_reserved_instances",
"waitForCapacity": "wait_for_capacity",
"waitForCapacityTimeout": "wait_for_capacity_timeout",
}
|
_snake_to_camel_case_table = {'availability_zones': 'availabilityZones', 'backend_services': 'backendServices', 'beanstalk_environment_name': 'beanstalkEnvironmentName', 'block_devices_mode': 'blockDevicesMode', 'capacity_unit': 'capacityUnit', 'cluster_id': 'clusterId', 'cluster_zone_name': 'clusterZoneName', 'controller_id': 'controllerId', 'cpu_credits': 'cpuCredits', 'desired_capacity': 'desiredCapacity', 'draining_timeout': 'drainingTimeout', 'ebs_block_devices': 'ebsBlockDevices', 'ebs_optimized': 'ebsOptimized', 'elastic_ips': 'elasticIps', 'elastic_load_balancers': 'elasticLoadBalancers', 'enable_monitoring': 'enableMonitoring', 'ephemeral_block_devices': 'ephemeralBlockDevices', 'event_type': 'eventType', 'fallback_to_ondemand': 'fallbackToOndemand', 'health_check': 'healthCheck', 'health_check_grace_period': 'healthCheckGracePeriod', 'health_check_type': 'healthCheckType', 'health_check_unhealthy_duration_before_replacement': 'healthCheckUnhealthyDurationBeforeReplacement', 'iam_instance_profile': 'iamInstanceProfile', 'image_id': 'imageId', 'instance_types_customs': 'instanceTypesCustoms', 'instance_types_ondemand': 'instanceTypesOndemand', 'instance_types_preemptibles': 'instanceTypesPreemptibles', 'instance_types_preferred_spots': 'instanceTypesPreferredSpots', 'instance_types_spots': 'instanceTypesSpots', 'instance_types_weights': 'instanceTypesWeights', 'integration_codedeploy': 'integrationCodedeploy', 'integration_docker_swarm': 'integrationDockerSwarm', 'integration_ecs': 'integrationEcs', 'integration_gitlab': 'integrationGitlab', 'integration_kubernetes': 'integrationKubernetes', 'integration_mesosphere': 'integrationMesosphere', 'integration_multai_runtime': 'integrationMultaiRuntime', 'integration_nomad': 'integrationNomad', 'integration_rancher': 'integrationRancher', 'integration_route53': 'integrationRoute53', 'ip_forwarding': 'ipForwarding', 'key_name': 'keyName', 'lifetime_period': 'lifetimePeriod', 'load_balancers': 'loadBalancers', 'low_priority_sizes': 'lowPrioritySizes', 'max_size': 'maxSize', 'min_size': 'minSize', 'multai_target_sets': 'multaiTargetSets', 'network_interfaces': 'networkInterfaces', 'node_image': 'nodeImage', 'od_sizes': 'odSizes', 'ondemand_count': 'ondemandCount', 'persist_block_devices': 'persistBlockDevices', 'persist_private_ip': 'persistPrivateIp', 'persist_root_device': 'persistRootDevice', 'placement_tenancy': 'placementTenancy', 'preemptible_percentage': 'preemptiblePercentage', 'preferred_availability_zones': 'preferredAvailabilityZones', 'private_ips': 'privateIps', 'resource_group_name': 'resourceGroupName', 'resource_id': 'resourceId', 'revert_to_spot': 'revertToSpot', 'scaling_down_policies': 'scalingDownPolicies', 'scaling_target_policies': 'scalingTargetPolicies', 'scaling_up_policies': 'scalingUpPolicies', 'scheduled_tasks': 'scheduledTasks', 'security_groups': 'securityGroups', 'service_account': 'serviceAccount', 'shutdown_script': 'shutdownScript', 'spot_percentage': 'spotPercentage', 'startup_script': 'startupScript', 'stateful_deallocation': 'statefulDeallocation', 'subnet_ids': 'subnetIds', 'target_group_arns': 'targetGroupArns', 'update_policy': 'updatePolicy', 'user_data': 'userData', 'utilize_reserved_instances': 'utilizeReservedInstances', 'wait_for_capacity': 'waitForCapacity', 'wait_for_capacity_timeout': 'waitForCapacityTimeout'}
_camel_to_snake_case_table = {'availabilityZones': 'availability_zones', 'backendServices': 'backend_services', 'beanstalkEnvironmentName': 'beanstalk_environment_name', 'blockDevicesMode': 'block_devices_mode', 'capacityUnit': 'capacity_unit', 'clusterId': 'cluster_id', 'clusterZoneName': 'cluster_zone_name', 'controllerId': 'controller_id', 'cpuCredits': 'cpu_credits', 'desiredCapacity': 'desired_capacity', 'drainingTimeout': 'draining_timeout', 'ebsBlockDevices': 'ebs_block_devices', 'ebsOptimized': 'ebs_optimized', 'elasticIps': 'elastic_ips', 'elasticLoadBalancers': 'elastic_load_balancers', 'enableMonitoring': 'enable_monitoring', 'ephemeralBlockDevices': 'ephemeral_block_devices', 'eventType': 'event_type', 'fallbackToOndemand': 'fallback_to_ondemand', 'healthCheck': 'health_check', 'healthCheckGracePeriod': 'health_check_grace_period', 'healthCheckType': 'health_check_type', 'healthCheckUnhealthyDurationBeforeReplacement': 'health_check_unhealthy_duration_before_replacement', 'iamInstanceProfile': 'iam_instance_profile', 'imageId': 'image_id', 'instanceTypesCustoms': 'instance_types_customs', 'instanceTypesOndemand': 'instance_types_ondemand', 'instanceTypesPreemptibles': 'instance_types_preemptibles', 'instanceTypesPreferredSpots': 'instance_types_preferred_spots', 'instanceTypesSpots': 'instance_types_spots', 'instanceTypesWeights': 'instance_types_weights', 'integrationCodedeploy': 'integration_codedeploy', 'integrationDockerSwarm': 'integration_docker_swarm', 'integrationEcs': 'integration_ecs', 'integrationGitlab': 'integration_gitlab', 'integrationKubernetes': 'integration_kubernetes', 'integrationMesosphere': 'integration_mesosphere', 'integrationMultaiRuntime': 'integration_multai_runtime', 'integrationNomad': 'integration_nomad', 'integrationRancher': 'integration_rancher', 'integrationRoute53': 'integration_route53', 'ipForwarding': 'ip_forwarding', 'keyName': 'key_name', 'lifetimePeriod': 'lifetime_period', 'loadBalancers': 'load_balancers', 'lowPrioritySizes': 'low_priority_sizes', 'maxSize': 'max_size', 'minSize': 'min_size', 'multaiTargetSets': 'multai_target_sets', 'networkInterfaces': 'network_interfaces', 'nodeImage': 'node_image', 'odSizes': 'od_sizes', 'ondemandCount': 'ondemand_count', 'persistBlockDevices': 'persist_block_devices', 'persistPrivateIp': 'persist_private_ip', 'persistRootDevice': 'persist_root_device', 'placementTenancy': 'placement_tenancy', 'preemptiblePercentage': 'preemptible_percentage', 'preferredAvailabilityZones': 'preferred_availability_zones', 'privateIps': 'private_ips', 'resourceGroupName': 'resource_group_name', 'resourceId': 'resource_id', 'revertToSpot': 'revert_to_spot', 'scalingDownPolicies': 'scaling_down_policies', 'scalingTargetPolicies': 'scaling_target_policies', 'scalingUpPolicies': 'scaling_up_policies', 'scheduledTasks': 'scheduled_tasks', 'securityGroups': 'security_groups', 'serviceAccount': 'service_account', 'shutdownScript': 'shutdown_script', 'spotPercentage': 'spot_percentage', 'startupScript': 'startup_script', 'statefulDeallocation': 'stateful_deallocation', 'subnetIds': 'subnet_ids', 'targetGroupArns': 'target_group_arns', 'updatePolicy': 'update_policy', 'userData': 'user_data', 'utilizeReservedInstances': 'utilize_reserved_instances', 'waitForCapacity': 'wait_for_capacity', 'waitForCapacityTimeout': 'wait_for_capacity_timeout'}
|
# guess file size : https://softwareengineering.stackexchange.com/q/204417
# https://stackoverflow.com/a/1094933
def sizeof_fmt(num, suffix='B'):
for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.1f%s%s" % (num, 'Yi', suffix)
# def fsize(file_path):
# sizeof_fmt(self.size)
# if self.size > 1000000000:
# print('File is larger than 1 GB')
# else:
# print('File smaller than 1 GB')
|
def sizeof_fmt(num, suffix='B'):
for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
if abs(num) < 1024.0:
return '%3.1f%s%s' % (num, unit, suffix)
num /= 1024.0
return '%.1f%s%s' % (num, 'Yi', suffix)
|
# Source : https://leetcode.com/problems/rectangle-overlap/
# Author : foxfromworld
# Date : 07/04/2021
# Second attempt
class Solution:
def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:
if rec1[0] == rec1[2] or rec2[0] == rec2[2] or\
rec2[1] == rec2[3] or rec1[1] == rec1[3]:
return False
UpBound = min(rec1[3], rec2[3])
LoBound = max(rec1[1], rec2[1])
RtBound = min(rec1[2], rec2[2])
LtBound = max(rec1[0], rec2[0])
return True if UpBound > LoBound and RtBound > LtBound else False
# Date : 07/04/2021
# First attempt
class Solution:
def isRectangleOverlap(self, rec1: List[int], rec2: List[int]) -> bool:
if rec1[0] == rec1[2] or rec1[1] == rec1[3] or \
rec2[0] == rec2[2] or rec2[1] == rec2[3]:
return False # check if it's a line
return rec2[0] < rec1[2] and rec2[1] < rec1[3] and rec1[0] < rec2[2] and rec1[1] < rec2[3]
|
class Solution:
def is_rectangle_overlap(self, rec1: List[int], rec2: List[int]) -> bool:
if rec1[0] == rec1[2] or rec2[0] == rec2[2] or rec2[1] == rec2[3] or (rec1[1] == rec1[3]):
return False
up_bound = min(rec1[3], rec2[3])
lo_bound = max(rec1[1], rec2[1])
rt_bound = min(rec1[2], rec2[2])
lt_bound = max(rec1[0], rec2[0])
return True if UpBound > LoBound and RtBound > LtBound else False
class Solution:
def is_rectangle_overlap(self, rec1: List[int], rec2: List[int]) -> bool:
if rec1[0] == rec1[2] or rec1[1] == rec1[3] or rec2[0] == rec2[2] or (rec2[1] == rec2[3]):
return False
return rec2[0] < rec1[2] and rec2[1] < rec1[3] and (rec1[0] < rec2[2]) and (rec1[1] < rec2[3])
|
class Project():
def __init__(self, id_project, name, session_counter, token):
self.id_project = id_project
self.name = name
self.session_counter = session_counter
self.token = token
class Session():
def __init__(self, id_session, index, dt_start, dt_end, is_active, is_favorite, host, description, id_project):
self.id_session = id_session
self.index = index
self.dt_start = dt_start
self.dt_end = dt_end
self.is_active = is_active
self.is_favorite = is_favorite
self.host = host
self.description = description
self.id_project = id_project
class Epoch():
def __init__(self, id_epoch, index, metrics, time, id_session):
self.id_epoch = id_epoch
self.index = index
self.metrics = metrics
self.time = time
self.id_session = id_session
|
class Project:
def __init__(self, id_project, name, session_counter, token):
self.id_project = id_project
self.name = name
self.session_counter = session_counter
self.token = token
class Session:
def __init__(self, id_session, index, dt_start, dt_end, is_active, is_favorite, host, description, id_project):
self.id_session = id_session
self.index = index
self.dt_start = dt_start
self.dt_end = dt_end
self.is_active = is_active
self.is_favorite = is_favorite
self.host = host
self.description = description
self.id_project = id_project
class Epoch:
def __init__(self, id_epoch, index, metrics, time, id_session):
self.id_epoch = id_epoch
self.index = index
self.metrics = metrics
self.time = time
self.id_session = id_session
|
#=======================================================================
# Author: Isai Damier
# Title: Selection Sort
# Project: geekviewpoint
# Package: algorithm.sorting
#
# Statement:
# Given a disordered list of integers (or any other items),
# rearrange the integers in natural order.
#
# Sample Input: [18,5,3,1,19,6,0,7,4,2,5]
# Sample Output: [0,1,2,3,4,5,5,6,7,18,19]
#
# Time Complexity of Solution:
# Best O(n^2); Average O(n^2); Worst O(n^2).
#
# Approach:
# Selection sort is a step up from insertion sort from a memory
# viewpoint. It only swaps elements that need to be swapped. In terms
# of time complexity, however, insertion sort is better.
#=======================================================================
def selectionsort( aList ):
for i in range( len( aList ) ):
least = i
for k in range( i + 1 , len( aList ) ):
if aList[k] < aList[least]:
least = k
swap( aList, least, i )
def swap( A, x, y ):
tmp = A[x]
A[x] = A[y]
A[y] = tmp
|
def selectionsort(aList):
for i in range(len(aList)):
least = i
for k in range(i + 1, len(aList)):
if aList[k] < aList[least]:
least = k
swap(aList, least, i)
def swap(A, x, y):
tmp = A[x]
A[x] = A[y]
A[y] = tmp
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
a = 3
if a > 2:
print("H")
else:
print("L")
|
a = 3
if a > 2:
print('H')
else:
print('L')
|
"""
1720. Decode XORed Array
https://leetcode.com/problems/decode-xored-array/
There is a hidden integer array arr that consists of n non-negative integers.
It was encoded into another integer array encoded of length n - 1,
such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3].
You are given the encoded array. You are also given an integer first, that is the first element of arr, i.e. arr[0].
Return the original array arr. It can be proved that the answer exists and is unique.
Example:
Input: encoded = [1,2,3], first = 1
Output: [1,0,2,1]
Explanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]
"""
# Runtime: 232ms
class Solution:
def decode(self, encoded: List[int], first: int) -> List[int]:
# The first element in the hidden array: first
arr = [first]
# Initialise a temp variable to keep track of each reverse XOR
temp = 0
for idx, val in enumerate(encoded):
# a ^ b = c -> b = a ^ c
# to reverse an encoded XORed array, we need to XOR either value resulting in the XORed value
# the first element in the encoded array must XOR the first element in the hidden array
if idx == 0:
temp = first ^ val
# subsequently, we can just use the temp variable which to slowly decode the arr
else:
temp ^= val
arr.append(temp)
return arr
|
"""
1720. Decode XORed Array
https://leetcode.com/problems/decode-xored-array/
There is a hidden integer array arr that consists of n non-negative integers.
It was encoded into another integer array encoded of length n - 1,
such that encoded[i] = arr[i] XOR arr[i + 1]. For example, if arr = [1,0,2,1], then encoded = [1,2,3].
You are given the encoded array. You are also given an integer first, that is the first element of arr, i.e. arr[0].
Return the original array arr. It can be proved that the answer exists and is unique.
Example:
Input: encoded = [1,2,3], first = 1
Output: [1,0,2,1]
Explanation: If arr = [1,0,2,1], then first = 1 and encoded = [1 XOR 0, 0 XOR 2, 2 XOR 1] = [1,2,3]
"""
class Solution:
def decode(self, encoded: List[int], first: int) -> List[int]:
arr = [first]
temp = 0
for (idx, val) in enumerate(encoded):
if idx == 0:
temp = first ^ val
else:
temp ^= val
arr.append(temp)
return arr
|
# Enter your code here. Read input from STDIN. Print output to STDOUT
m = float(raw_input());
t = m * input() /100;
x = m * input() /100;
totalCost = round(m + x + t);
print ('The total meal cost is' " " + str(int(totalCost)) + " " 'dollars.')
|
m = float(raw_input())
t = m * input() / 100
x = m * input() / 100
total_cost = round(m + x + t)
print('The total meal cost is ' + str(int(totalCost)) + ' dollars.')
|
# program to match key values in two dictionaries.
x = {'key1': 1, 'key2': 3, 'key3': 2}
y = {'key1': 1, 'key2': 2}
for (key, value) in set(x.items()) & set(y.items()):
print('%s: %s is present in both x and y' % (key, value))
|
x = {'key1': 1, 'key2': 3, 'key3': 2}
y = {'key1': 1, 'key2': 2}
for (key, value) in set(x.items()) & set(y.items()):
print('%s: %s is present in both x and y' % (key, value))
|
class Number(object):
def __init__(self, value):
if value % 2 != 0:
self.even = self._odds_even
else:
self.even = self._even
def _even(self):
print("even")
return True
def _odds_even(self):
print("not odd")
return False
a = Number(2)
a.even()
b = Number(3)
b.even()
a.even()
|
class Number(object):
def __init__(self, value):
if value % 2 != 0:
self.even = self._odds_even
else:
self.even = self._even
def _even(self):
print('even')
return True
def _odds_even(self):
print('not odd')
return False
a = number(2)
a.even()
b = number(3)
b.even()
a.even()
|
WIDTH = 87
HEIGHT = 87
FIRST = 0x20
LAST = 0x7f
_font =\
b'\x00\x4a\x5a\x02\x44\x60\x44\x52\x60\x52\x02\x44\x60\x44\x60'\
b'\x60\x44\x02\x52\x52\x52\x3e\x52\x66\x02\x44\x60\x44\x44\x60'\
b'\x60\x02\x44\x60\x44\x52\x60\x52\x02\x46\x5e\x46\x59\x5e\x4b'\
b'\x02\x4b\x59\x4b\x5e\x59\x46\x02\x52\x52\x52\x44\x52\x60\x02'\
b'\x4b\x59\x4b\x46\x59\x5e\x02\x46\x5e\x46\x4b\x5e\x59\x02\x4b'\
b'\x59\x4b\x52\x59\x52\x02\x4d\x57\x4d\x57\x57\x4d\x02\x52\x52'\
b'\x52\x4b\x52\x59\x02\x4d\x57\x4d\x4d\x57\x57\x07\x47\x52\x52'\
b'\x47\x50\x47\x4d\x48\x4a\x4a\x48\x4d\x47\x50\x47\x52\x07\x47'\
b'\x52\x47\x52\x47\x54\x48\x57\x4a\x5a\x4d\x5c\x50\x5d\x52\x5d'\
b'\x07\x52\x5d\x52\x5d\x54\x5d\x57\x5c\x5a\x5a\x5c\x57\x5d\x54'\
b'\x5d\x52\x07\x52\x5d\x5d\x52\x5d\x50\x5c\x4d\x5a\x4a\x57\x48'\
b'\x54\x47\x52\x47\x08\x44\x60\x44\x4f\x47\x51\x4b\x53\x50\x54'\
b'\x54\x54\x59\x53\x5d\x51\x60\x4f\x08\x50\x55\x55\x44\x53\x47'\
b'\x51\x4b\x50\x50\x50\x54\x51\x59\x53\x5d\x55\x60\x08\x4f\x54'\
b'\x4f\x44\x51\x47\x53\x4b\x54\x50\x54\x54\x53\x59\x51\x5d\x4f'\
b'\x60\x08\x44\x60\x44\x55\x47\x53\x4b\x51\x50\x50\x54\x50\x59'\
b'\x51\x5d\x53\x60\x55\x04\x4b\x59\x52\x4a\x59\x4e\x4b\x56\x52'\
b'\x5a\x04\x4a\x5a\x4a\x52\x4e\x4b\x56\x59\x5a\x52\x04\x4b\x59'\
b'\x4b\x56\x4b\x4e\x59\x56\x59\x4e\x04\x4a\x5a\x4c\x58\x4a\x50'\
b'\x5a\x54\x58\x4c\x16\x4a\x5a\x4a\x5d\x4c\x5d\x4f\x5c\x51\x5b'\
b'\x54\x58\x55\x56\x56\x53\x56\x4f\x55\x4c\x54\x4a\x53\x49\x51'\
b'\x49\x50\x4a\x4f\x4c\x4e\x4f\x4e\x53\x4f\x56\x50\x58\x53\x5b'\
b'\x55\x5c\x58\x5d\x5a\x5d\x16\x49\x5d\x5d\x5a\x5d\x58\x5c\x55'\
b'\x5b\x53\x58\x50\x56\x4f\x53\x4e\x4f\x4e\x4c\x4f\x4a\x50\x49'\
b'\x51\x49\x53\x4a\x54\x4c\x55\x4f\x56\x53\x56\x56\x55\x58\x54'\
b'\x5b\x51\x5c\x4f\x5d\x4c\x5d\x4a\x16\x4a\x5a\x5a\x47\x58\x47'\
b'\x55\x48\x53\x49\x50\x4c\x4f\x4e\x4e\x51\x4e\x55\x4f\x58\x50'\
b'\x5a\x51\x5b\x53\x5b\x54\x5a\x55\x58\x56\x55\x56\x51\x55\x4e'\
b'\x54\x4c\x51\x49\x4f\x48\x4c\x47\x4a\x47\x16\x47\x5b\x47\x4a'\
b'\x47\x4c\x48\x4f\x49\x51\x4c\x54\x4e\x55\x51\x56\x55\x56\x58'\
b'\x55\x5a\x54\x5b\x53\x5b\x51\x5a\x50\x58\x4f\x55\x4e\x51\x4e'\
b'\x4e\x4f\x4c\x50\x49\x53\x48\x55\x47\x58\x47\x5a\x14\x45\x5b'\
b'\x45\x50\x46\x52\x48\x54\x4a\x55\x4d\x56\x51\x56\x55\x55\x58'\
b'\x53\x5a\x50\x5b\x4e\x5a\x4c\x57\x4c\x53\x4d\x51\x4e\x4e\x50'\
b'\x4c\x53\x4b\x56\x4b\x59\x4c\x5c\x4d\x5e\x12\x45\x59\x45\x54'\
b'\x48\x56\x4b\x57\x50\x57\x53\x56\x56\x54\x58\x51\x59\x4e\x59'\
b'\x4c\x58\x4b\x56\x4b\x53\x4c\x50\x4e\x4e\x51\x4d\x54\x4d\x59'\
b'\x4e\x5c\x50\x5f\x19\x4f\x55\x51\x4f\x4f\x51\x4f\x53\x51\x55'\
b'\x53\x55\x55\x53\x55\x51\x53\x4f\x51\x4f\x20\x52\x51\x50\x50'\
b'\x51\x50\x53\x51\x54\x53\x54\x54\x53\x54\x51\x53\x50\x51\x50'\
b'\x20\x52\x52\x51\x51\x52\x52\x53\x53\x52\x52\x51\x0a\x52\x57'\
b'\x52\x4d\x53\x4d\x55\x4e\x56\x4f\x57\x51\x57\x53\x56\x55\x55'\
b'\x56\x53\x57\x52\x57\x08\x44\x60\x44\x52\x4a\x52\x20\x52\x4f'\
b'\x52\x55\x52\x20\x52\x5a\x52\x60\x52\x04\x44\x60\x44\x55\x44'\
b'\x4f\x60\x4f\x60\x55\x05\x4a\x5a\x52\x44\x4a\x52\x20\x52\x52'\
b'\x44\x5a\x52\x08\x44\x60\x44\x52\x60\x52\x20\x52\x4a\x59\x5a'\
b'\x59\x20\x52\x50\x60\x54\x60\x08\x44\x60\x44\x52\x60\x52\x20'\
b'\x52\x44\x52\x52\x62\x20\x52\x60\x52\x52\x62\x11\x4b\x59\x51'\
b'\x4b\x4e\x4c\x4c\x4e\x4b\x51\x4b\x53\x4c\x56\x4e\x58\x51\x59'\
b'\x53\x59\x56\x58\x58\x56\x59\x53\x59\x51\x58\x4e\x56\x4c\x53'\
b'\x4b\x51\x4b\x05\x4c\x58\x4c\x4c\x4c\x58\x58\x58\x58\x4c\x4c'\
b'\x4c\x04\x4b\x59\x52\x4a\x4b\x56\x59\x56\x52\x4a\x05\x4c\x58'\
b'\x52\x48\x4c\x52\x52\x5c\x58\x52\x52\x48\x0b\x4a\x5a\x52\x49'\
b'\x50\x4f\x4a\x4f\x4f\x53\x4d\x59\x52\x55\x57\x59\x55\x53\x5a'\
b'\x4f\x54\x4f\x52\x49\x05\x4b\x59\x52\x4b\x52\x59\x20\x52\x4b'\
b'\x52\x59\x52\x05\x4d\x57\x4d\x4d\x57\x57\x20\x52\x57\x4d\x4d'\
b'\x57\x08\x4d\x57\x52\x4c\x52\x58\x20\x52\x4d\x4f\x57\x55\x20'\
b'\x52\x57\x4f\x4d\x55\x22\x4e\x56\x51\x4e\x4f\x4f\x4e\x51\x4e'\
b'\x53\x4f\x55\x51\x56\x53\x56\x55\x55\x56\x53\x56\x51\x55\x4f'\
b'\x53\x4e\x51\x4e\x20\x52\x4f\x51\x4f\x53\x20\x52\x50\x50\x50'\
b'\x54\x20\x52\x51\x4f\x51\x55\x20\x52\x52\x4f\x52\x55\x20\x52'\
b'\x53\x4f\x53\x55\x20\x52\x54\x50\x54\x54\x20\x52\x55\x51\x55'\
b'\x53\x1a\x4e\x56\x4e\x4e\x4e\x56\x56\x56\x56\x4e\x4e\x4e\x20'\
b'\x52\x4f\x4f\x4f\x55\x20\x52\x50\x4f\x50\x55\x20\x52\x51\x4f'\
b'\x51\x55\x20\x52\x52\x4f\x52\x55\x20\x52\x53\x4f\x53\x55\x20'\
b'\x52\x54\x4f\x54\x55\x20\x52\x55\x4f\x55\x55\x10\x4d\x57\x52'\
b'\x4c\x4d\x55\x57\x55\x52\x4c\x20\x52\x52\x4f\x4f\x54\x20\x52'\
b'\x52\x4f\x55\x54\x20\x52\x52\x52\x51\x54\x20\x52\x52\x52\x53'\
b'\x54\x10\x4c\x55\x4c\x52\x55\x57\x55\x4d\x4c\x52\x20\x52\x4f'\
b'\x52\x54\x55\x20\x52\x4f\x52\x54\x4f\x20\x52\x52\x52\x54\x53'\
b'\x20\x52\x52\x52\x54\x51\x10\x4d\x57\x52\x58\x57\x4f\x4d\x4f'\
b'\x52\x58\x20\x52\x52\x55\x55\x50\x20\x52\x52\x55\x4f\x50\x20'\
b'\x52\x52\x52\x53\x50\x20\x52\x52\x52\x51\x50\x10\x4f\x58\x58'\
b'\x52\x4f\x4d\x4f\x57\x58\x52\x20\x52\x55\x52\x50\x4f\x20\x52'\
b'\x55\x52\x50\x55\x20\x52\x52\x52\x50\x51\x20\x52\x52\x52\x50'\
b'\x53\x0a\x52\x59\x52\x4b\x52\x59\x20\x52\x52\x4b\x59\x4e\x52'\
b'\x51\x20\x52\x53\x4d\x56\x4e\x53\x4f\x14\x49\x5b\x52\x47\x52'\
b'\x56\x20\x52\x4d\x4a\x57\x50\x20\x52\x57\x4a\x4d\x50\x20\x52'\
b'\x49\x56\x4c\x5c\x20\x52\x5b\x56\x58\x5c\x20\x52\x49\x56\x5b'\
b'\x56\x20\x52\x4c\x5c\x58\x5c\x0c\x4d\x57\x52\x4c\x52\x58\x20'\
b'\x52\x4f\x4f\x55\x4f\x20\x52\x4d\x55\x4f\x57\x51\x58\x53\x58'\
b'\x55\x57\x57\x55\x0a\x4c\x58\x52\x4c\x52\x58\x20\x52\x4c\x51'\
b'\x4d\x4f\x57\x4f\x58\x51\x20\x52\x50\x57\x54\x57\x0d\x4b\x59'\
b'\x4d\x4e\x57\x58\x20\x52\x57\x4e\x4d\x58\x20\x52\x4f\x4c\x4c'\
b'\x4f\x4b\x51\x20\x52\x55\x4c\x58\x4f\x59\x51\x11\x49\x5b\x4e'\
b'\x49\x49\x5b\x20\x52\x56\x49\x5b\x5b\x20\x52\x4d\x4d\x5b\x5b'\
b'\x20\x52\x57\x4d\x49\x5b\x20\x52\x4e\x49\x56\x49\x20\x52\x4d'\
b'\x4d\x57\x4d\x02\x4b\x59\x4b\x46\x59\x5e\x0a\x47\x5b\x4d\x4a'\
b'\x53\x56\x20\x52\x4b\x50\x53\x4c\x20\x52\x47\x5c\x5b\x5c\x5b'\
b'\x52\x47\x5c\x0d\x4c\x58\x50\x4c\x50\x50\x4c\x50\x4c\x54\x50'\
b'\x54\x50\x58\x54\x58\x54\x54\x58\x54\x58\x50\x54\x50\x54\x4c'\
b'\x50\x4c\x1f\x4b\x59\x59\x50\x58\x4e\x56\x4c\x53\x4b\x51\x4b'\
b'\x4e\x4c\x4c\x4e\x4b\x51\x4b\x53\x4c\x56\x4e\x58\x51\x59\x53'\
b'\x59\x56\x58\x58\x56\x59\x54\x20\x52\x59\x50\x57\x4e\x55\x4d'\
b'\x53\x4d\x51\x4e\x50\x4f\x4f\x51\x4f\x53\x50\x55\x51\x56\x53'\
b'\x57\x55\x57\x57\x56\x59\x54\x09\x4b\x59\x52\x4a\x4b\x56\x59'\
b'\x56\x52\x4a\x20\x52\x52\x5a\x59\x4e\x4b\x4e\x52\x5a\x21\x47'\
b'\x5d\x50\x49\x50\x47\x51\x46\x53\x46\x54\x47\x54\x49\x20\x52'\
b'\x47\x5a\x48\x58\x4a\x56\x4b\x54\x4c\x50\x4c\x4b\x4d\x4a\x4f'\
b'\x49\x55\x49\x57\x4a\x58\x4b\x58\x50\x59\x54\x5a\x56\x5c\x58'\
b'\x5d\x5a\x20\x52\x47\x5a\x5d\x5a\x20\x52\x51\x5a\x50\x5b\x51'\
b'\x5c\x53\x5c\x54\x5b\x53\x5a\x3f\x4a\x5a\x52\x4d\x52\x53\x20'\
b'\x52\x52\x53\x51\x5c\x20\x52\x52\x53\x53\x5c\x20\x52\x51\x5c'\
b'\x53\x5c\x20\x52\x52\x4d\x51\x4a\x50\x48\x4e\x47\x20\x52\x51'\
b'\x4a\x4e\x47\x20\x52\x52\x4d\x53\x4a\x54\x48\x56\x47\x20\x52'\
b'\x53\x4a\x56\x47\x20\x52\x52\x4d\x4e\x4b\x4c\x4b\x4a\x4d\x20'\
b'\x52\x50\x4c\x4c\x4c\x4a\x4d\x20\x52\x52\x4d\x56\x4b\x58\x4b'\
b'\x5a\x4d\x20\x52\x54\x4c\x58\x4c\x5a\x4d\x20\x52\x52\x4d\x50'\
b'\x4e\x4f\x4f\x4f\x52\x20\x52\x52\x4d\x50\x4f\x4f\x52\x20\x52'\
b'\x52\x4d\x54\x4e\x55\x4f\x55\x52\x20\x52\x52\x4d\x54\x4f\x55'\
b'\x52\x5d\x4a\x5a\x52\x49\x52\x4b\x20\x52\x52\x4e\x52\x50\x20'\
b'\x52\x52\x53\x52\x55\x20\x52\x52\x59\x51\x5c\x20\x52\x52\x59'\
b'\x53\x5c\x20\x52\x51\x5c\x53\x5c\x20\x52\x52\x47\x51\x49\x50'\
b'\x4a\x20\x52\x52\x47\x53\x49\x54\x4a\x20\x52\x50\x4a\x52\x49'\
b'\x54\x4a\x20\x52\x52\x4b\x50\x4e\x4e\x4f\x4d\x4e\x20\x52\x52'\
b'\x4b\x54\x4e\x56\x4f\x57\x4e\x20\x52\x4e\x4f\x50\x4f\x52\x4e'\
b'\x54\x4f\x56\x4f\x20\x52\x52\x50\x50\x53\x4e\x54\x4c\x54\x4b'\
b'\x52\x4b\x53\x4c\x54\x20\x52\x52\x50\x54\x53\x56\x54\x58\x54'\
b'\x59\x52\x59\x53\x58\x54\x20\x52\x4e\x54\x50\x54\x52\x53\x54'\
b'\x54\x56\x54\x20\x52\x52\x55\x50\x58\x4f\x59\x4d\x5a\x4c\x5a'\
b'\x4b\x59\x4a\x57\x4a\x59\x4c\x5a\x20\x52\x52\x55\x54\x58\x55'\
b'\x59\x57\x5a\x58\x5a\x59\x59\x5a\x57\x5a\x59\x58\x5a\x20\x52'\
b'\x4d\x5a\x4f\x5a\x52\x59\x55\x5a\x57\x5a\x27\x4a\x5a\x52\x59'\
b'\x51\x5c\x20\x52\x52\x59\x53\x5c\x20\x52\x51\x5c\x53\x5c\x20'\
b'\x52\x52\x59\x55\x5a\x58\x5a\x5a\x58\x5a\x55\x59\x54\x57\x54'\
b'\x59\x52\x5a\x4f\x59\x4d\x57\x4c\x55\x4d\x56\x4a\x55\x48\x53'\
b'\x47\x51\x47\x4f\x48\x4e\x4a\x4f\x4d\x4d\x4c\x4b\x4d\x4a\x4f'\
b'\x4b\x52\x4d\x54\x4b\x54\x4a\x55\x4a\x58\x4c\x5a\x4f\x5a\x52'\
b'\x59\x1f\x4a\x5a\x52\x59\x51\x5c\x20\x52\x52\x59\x53\x5c\x20'\
b'\x52\x51\x5c\x53\x5c\x20\x52\x52\x59\x56\x58\x56\x56\x58\x55'\
b'\x58\x52\x5a\x51\x5a\x4c\x59\x49\x58\x48\x56\x48\x54\x47\x50'\
b'\x47\x4e\x48\x4c\x48\x4b\x49\x4a\x4c\x4a\x51\x4c\x52\x4c\x55'\
b'\x4e\x56\x4e\x58\x52\x59\x0e\x49\x5b\x49\x50\x4b\x52\x20\x52'\
b'\x4c\x4b\x4e\x50\x20\x52\x52\x47\x52\x4f\x20\x52\x58\x4b\x56'\
b'\x50\x20\x52\x5b\x50\x59\x52\x1b\x47\x5d\x49\x49\x4a\x4b\x4b'\
b'\x4f\x4b\x55\x4a\x59\x49\x5b\x20\x52\x5b\x49\x5a\x4b\x59\x4f'\
b'\x59\x55\x5a\x59\x5b\x5b\x20\x52\x49\x49\x4b\x4a\x4f\x4b\x55'\
b'\x4b\x59\x4a\x5b\x49\x20\x52\x49\x5b\x4b\x5a\x4f\x59\x55\x59'\
b'\x59\x5a\x5b\x5b\x36\x46\x5e\x52\x52\x52\x5b\x51\x5c\x20\x52'\
b'\x52\x56\x51\x5c\x20\x52\x52\x49\x51\x48\x4f\x48\x4e\x49\x4e'\
b'\x4b\x4f\x4e\x52\x52\x20\x52\x52\x49\x53\x48\x55\x48\x56\x49'\
b'\x56\x4b\x55\x4e\x52\x52\x20\x52\x52\x52\x4e\x4f\x4c\x4e\x4a'\
b'\x4e\x49\x4f\x49\x51\x4a\x52\x20\x52\x52\x52\x56\x4f\x58\x4e'\
b'\x5a\x4e\x5b\x4f\x5b\x51\x5a\x52\x20\x52\x52\x52\x4e\x55\x4c'\
b'\x56\x4a\x56\x49\x55\x49\x53\x4a\x52\x20\x52\x52\x52\x56\x55'\
b'\x58\x56\x5a\x56\x5b\x55\x5b\x53\x5a\x52\x2d\x4a\x5a\x55\x49'\
b'\x54\x4a\x55\x4b\x56\x4a\x56\x49\x55\x47\x53\x46\x51\x46\x4f'\
b'\x47\x4e\x49\x4e\x4b\x4f\x4d\x51\x4f\x56\x52\x20\x52\x4f\x4d'\
b'\x54\x50\x56\x52\x57\x54\x57\x56\x56\x58\x54\x5a\x20\x52\x50'\
b'\x4e\x4e\x50\x4d\x52\x4d\x54\x4e\x56\x50\x58\x55\x5b\x20\x52'\
b'\x4e\x56\x53\x59\x55\x5b\x56\x5d\x56\x5f\x55\x61\x53\x62\x51'\
b'\x62\x4f\x61\x4e\x5f\x4e\x5e\x4f\x5d\x50\x5e\x4f\x5f\x1d\x4a'\
b'\x5a\x52\x46\x51\x48\x52\x4a\x53\x48\x52\x46\x20\x52\x52\x46'\
b'\x52\x62\x20\x52\x52\x51\x51\x54\x52\x62\x53\x54\x52\x51\x20'\
b'\x52\x4c\x4d\x4e\x4e\x50\x4d\x4e\x4c\x4c\x4d\x20\x52\x4c\x4d'\
b'\x58\x4d\x20\x52\x54\x4d\x56\x4e\x58\x4d\x56\x4c\x54\x4d\x37'\
b'\x4a\x5a\x52\x46\x51\x48\x52\x4a\x53\x48\x52\x46\x20\x52\x52'\
b'\x46\x52\x54\x20\x52\x52\x50\x51\x52\x53\x56\x52\x58\x51\x56'\
b'\x53\x52\x52\x50\x20\x52\x52\x54\x52\x62\x20\x52\x52\x5e\x51'\
b'\x60\x52\x62\x53\x60\x52\x5e\x20\x52\x4c\x4d\x4e\x4e\x50\x4d'\
b'\x4e\x4c\x4c\x4d\x20\x52\x4c\x4d\x58\x4d\x20\x52\x54\x4d\x56'\
b'\x4e\x58\x4d\x56\x4c\x54\x4d\x20\x52\x4c\x5b\x4e\x5c\x50\x5b'\
b'\x4e\x5a\x4c\x5b\x20\x52\x4c\x5b\x58\x5b\x20\x52\x54\x5b\x56'\
b'\x5c\x58\x5b\x56\x5a\x54\x5b\x11\x45\x5f\x52\x49\x51\x4a\x52'\
b'\x4b\x53\x4a\x52\x49\x20\x52\x49\x59\x48\x5a\x49\x5b\x4a\x5a'\
b'\x49\x59\x20\x52\x5b\x59\x5a\x5a\x5b\x5b\x5c\x5a\x5b\x59\x20'\
b'\x46\x5e\x52\x48\x4e\x4c\x4b\x50\x4a\x53\x4a\x55\x4b\x57\x4d'\
b'\x58\x4f\x58\x51\x57\x52\x55\x20\x52\x52\x48\x56\x4c\x59\x50'\
b'\x5a\x53\x5a\x55\x59\x57\x57\x58\x55\x58\x53\x57\x52\x55\x20'\
b'\x52\x52\x55\x51\x59\x50\x5c\x20\x52\x52\x55\x53\x59\x54\x5c'\
b'\x20\x52\x50\x5c\x54\x5c\x19\x46\x5e\x52\x4e\x51\x4b\x50\x49'\
b'\x4e\x48\x4d\x48\x4b\x49\x4a\x4b\x4a\x4f\x4b\x52\x4c\x54\x4e'\
b'\x57\x52\x5c\x20\x52\x52\x4e\x53\x4b\x54\x49\x56\x48\x57\x48'\
b'\x59\x49\x5a\x4b\x5a\x4f\x59\x52\x58\x54\x56\x57\x52\x5c\x13'\
b'\x46\x5e\x52\x47\x50\x4a\x4c\x4f\x49\x52\x20\x52\x52\x47\x54'\
b'\x4a\x58\x4f\x5b\x52\x20\x52\x49\x52\x4c\x55\x50\x5a\x52\x5d'\
b'\x20\x52\x5b\x52\x58\x55\x54\x5a\x52\x5d\x2f\x46\x5e\x52\x54'\
b'\x54\x57\x56\x58\x58\x58\x5a\x57\x5b\x55\x5b\x53\x5a\x51\x58'\
b'\x50\x56\x50\x53\x51\x20\x52\x53\x51\x55\x4f\x56\x4d\x56\x4b'\
b'\x55\x49\x53\x48\x51\x48\x4f\x49\x4e\x4b\x4e\x4d\x4f\x4f\x51'\
b'\x51\x20\x52\x51\x51\x4e\x50\x4c\x50\x4a\x51\x49\x53\x49\x55'\
b'\x4a\x57\x4c\x58\x4e\x58\x50\x57\x52\x54\x20\x52\x52\x54\x51'\
b'\x59\x50\x5c\x20\x52\x52\x54\x53\x59\x54\x5c\x20\x52\x50\x5c'\
b'\x54\x5c\x2f\x49\x5b\x56\x2b\x53\x2d\x51\x2f\x50\x31\x4f\x34'\
b'\x4f\x38\x50\x3c\x54\x44\x55\x47\x55\x4a\x54\x4d\x52\x50\x20'\
b'\x52\x53\x2d\x51\x30\x50\x34\x50\x38\x51\x3b\x55\x43\x56\x47'\
b'\x56\x4a\x55\x4d\x52\x50\x4e\x52\x52\x54\x55\x57\x56\x5a\x56'\
b'\x5d\x55\x61\x51\x69\x50\x6c\x50\x70\x51\x74\x53\x77\x20\x52'\
b'\x52\x54\x54\x57\x55\x5a\x55\x5d\x54\x60\x50\x68\x4f\x6c\x4f'\
b'\x70\x50\x73\x51\x75\x53\x77\x56\x79\x2f\x49\x5b\x4e\x2b\x51'\
b'\x2d\x53\x2f\x54\x31\x55\x34\x55\x38\x54\x3c\x50\x44\x4f\x47'\
b'\x4f\x4a\x50\x4d\x52\x50\x20\x52\x51\x2d\x53\x30\x54\x34\x54'\
b'\x38\x53\x3b\x4f\x43\x4e\x47\x4e\x4a\x4f\x4d\x52\x50\x56\x52'\
b'\x52\x54\x4f\x57\x4e\x5a\x4e\x5d\x4f\x61\x53\x69\x54\x6c\x54'\
b'\x70\x53\x74\x51\x77\x20\x52\x52\x54\x50\x57\x4f\x5a\x4f\x5d'\
b'\x50\x60\x54\x68\x55\x6c\x55\x70\x54\x73\x53\x75\x51\x77\x4e'\
b'\x79\x1f\x49\x5b\x56\x2e\x53\x31\x51\x34\x4f\x38\x4e\x3d\x4e'\
b'\x43\x4f\x49\x50\x4d\x53\x58\x54\x5c\x55\x62\x55\x67\x54\x6c'\
b'\x53\x6f\x51\x73\x20\x52\x53\x31\x51\x35\x50\x38\x4f\x3d\x4f'\
b'\x42\x50\x48\x51\x4c\x54\x57\x55\x5b\x56\x61\x56\x67\x55\x6c'\
b'\x53\x70\x51\x73\x4e\x76\x1f\x49\x5b\x4e\x2e\x51\x31\x53\x34'\
b'\x55\x38\x56\x3d\x56\x43\x55\x49\x54\x4d\x51\x58\x50\x5c\x4f'\
b'\x62\x4f\x67\x50\x6c\x51\x6f\x53\x73\x20\x52\x51\x31\x53\x35'\
b'\x54\x38\x55\x3d\x55\x42\x54\x48\x53\x4c\x50\x57\x4f\x5b\x4e'\
b'\x61\x4e\x67\x4f\x6c\x51\x70\x53\x73\x56\x76\x0d\x37\x5a\x3a'\
b'\x52\x41\x52\x52\x6f\x20\x52\x40\x52\x51\x6f\x20\x52\x3f\x52'\
b'\x52\x72\x20\x52\x5a\x22\x56\x4a\x52\x72\x1a\x49\x5b\x54\x4d'\
b'\x56\x4e\x58\x50\x58\x4f\x57\x4e\x54\x4d\x51\x4d\x4e\x4e\x4d'\
b'\x4f\x4c\x51\x4c\x53\x4d\x55\x4f\x57\x53\x5a\x20\x52\x51\x4d'\
b'\x4f\x4e\x4e\x4f\x4d\x51\x4d\x53\x4e\x55\x53\x5a\x54\x5c\x54'\
b'\x5e\x53\x5f\x51\x5f\x2c\x47\x5d\x4c\x4d\x4b\x4e\x4a\x50\x4a'\
b'\x52\x4b\x55\x4f\x59\x50\x5b\x20\x52\x4a\x52\x4b\x54\x4f\x58'\
b'\x50\x5b\x50\x5d\x4f\x60\x4d\x62\x4c\x62\x4b\x61\x4a\x5f\x4a'\
b'\x5c\x4b\x58\x4d\x54\x4f\x51\x52\x4e\x54\x4d\x56\x4d\x59\x4e'\
b'\x5a\x50\x5a\x54\x59\x58\x57\x5a\x55\x5b\x54\x5b\x53\x5a\x53'\
b'\x58\x54\x57\x55\x58\x54\x59\x20\x52\x56\x4d\x58\x4e\x59\x50'\
b'\x59\x54\x58\x58\x57\x5a\x44\x45\x5f\x59\x47\x58\x48\x59\x49'\
b'\x5a\x48\x59\x47\x57\x46\x54\x46\x51\x47\x4f\x49\x4e\x4b\x4d'\
b'\x4e\x4c\x52\x4a\x5b\x49\x5f\x48\x61\x20\x52\x54\x46\x52\x47'\
b'\x50\x49\x4f\x4b\x4e\x4e\x4c\x57\x4b\x5b\x4a\x5e\x49\x60\x48'\
b'\x61\x46\x62\x44\x62\x43\x61\x43\x60\x44\x5f\x45\x60\x44\x61'\
b'\x20\x52\x5f\x47\x5e\x48\x5f\x49\x60\x48\x60\x47\x5f\x46\x5d'\
b'\x46\x5b\x47\x5a\x48\x59\x4a\x58\x4d\x55\x5b\x54\x5f\x53\x61'\
b'\x20\x52\x5d\x46\x5b\x48\x5a\x4a\x59\x4e\x57\x57\x56\x5b\x55'\
b'\x5e\x54\x60\x53\x61\x51\x62\x4f\x62\x4e\x61\x4e\x60\x4f\x5f'\
b'\x50\x60\x4f\x61\x20\x52\x49\x4d\x5e\x4d\x33\x46\x5e\x5b\x47'\
b'\x5a\x48\x5b\x49\x5c\x48\x5b\x47\x58\x46\x55\x46\x52\x47\x50'\
b'\x49\x4f\x4b\x4e\x4e\x4d\x52\x4b\x5b\x4a\x5f\x49\x61\x20\x52'\
b'\x55\x46\x53\x47\x51\x49\x50\x4b\x4f\x4e\x4d\x57\x4c\x5b\x4b'\
b'\x5e\x4a\x60\x49\x61\x47\x62\x45\x62\x44\x61\x44\x60\x45\x5f'\
b'\x46\x60\x45\x61\x20\x52\x59\x4d\x57\x54\x56\x58\x56\x5a\x57'\
b'\x5b\x5a\x5b\x5c\x59\x5d\x57\x20\x52\x5a\x4d\x58\x54\x57\x58'\
b'\x57\x5a\x58\x5b\x20\x52\x4a\x4d\x5a\x4d\x35\x46\x5e\x59\x47'\
b'\x58\x48\x59\x49\x5a\x48\x5a\x47\x58\x46\x20\x52\x5c\x46\x55'\
b'\x46\x52\x47\x50\x49\x4f\x4b\x4e\x4e\x4d\x52\x4b\x5b\x4a\x5f'\
b'\x49\x61\x20\x52\x55\x46\x53\x47\x51\x49\x50\x4b\x4f\x4e\x4d'\
b'\x57\x4c\x5b\x4b\x5e\x4a\x60\x49\x61\x47\x62\x45\x62\x44\x61'\
b'\x44\x60\x45\x5f\x46\x60\x45\x61\x20\x52\x5b\x46\x57\x54\x56'\
b'\x58\x56\x5a\x57\x5b\x5a\x5b\x5c\x59\x5d\x57\x20\x52\x5c\x46'\
b'\x58\x54\x57\x58\x57\x5a\x58\x5b\x20\x52\x4a\x4d\x59\x4d\x55'\
b'\x40\x63\x54\x47\x53\x48\x54\x49\x55\x48\x54\x47\x52\x46\x4f'\
b'\x46\x4c\x47\x4a\x49\x49\x4b\x48\x4e\x47\x52\x45\x5b\x44\x5f'\
b'\x43\x61\x20\x52\x4f\x46\x4d\x47\x4b\x49\x4a\x4b\x49\x4e\x47'\
b'\x57\x46\x5b\x45\x5e\x44\x60\x43\x61\x41\x62\x3f\x62\x3e\x61'\
b'\x3e\x60\x3f\x5f\x40\x60\x3f\x61\x20\x52\x60\x47\x5f\x48\x60'\
b'\x49\x61\x48\x60\x47\x5d\x46\x5a\x46\x57\x47\x55\x49\x54\x4b'\
b'\x53\x4e\x52\x52\x50\x5b\x4f\x5f\x4e\x61\x20\x52\x5a\x46\x58'\
b'\x47\x56\x49\x55\x4b\x54\x4e\x52\x57\x51\x5b\x50\x5e\x4f\x60'\
b'\x4e\x61\x4c\x62\x4a\x62\x49\x61\x49\x60\x4a\x5f\x4b\x60\x4a'\
b'\x61\x20\x52\x5e\x4d\x5c\x54\x5b\x58\x5b\x5a\x5c\x5b\x5f\x5b'\
b'\x61\x59\x62\x57\x20\x52\x5f\x4d\x5d\x54\x5c\x58\x5c\x5a\x5d'\
b'\x5b\x20\x52\x44\x4d\x5f\x4d\x57\x40\x63\x54\x47\x53\x48\x54'\
b'\x49\x55\x48\x54\x47\x52\x46\x4f\x46\x4c\x47\x4a\x49\x49\x4b'\
b'\x48\x4e\x47\x52\x45\x5b\x44\x5f\x43\x61\x20\x52\x4f\x46\x4d'\
b'\x47\x4b\x49\x4a\x4b\x49\x4e\x47\x57\x46\x5b\x45\x5e\x44\x60'\
b'\x43\x61\x41\x62\x3f\x62\x3e\x61\x3e\x60\x3f\x5f\x40\x60\x3f'\
b'\x61\x20\x52\x5e\x47\x5d\x48\x5e\x49\x5f\x48\x5f\x47\x5d\x46'\
b'\x20\x52\x61\x46\x5a\x46\x57\x47\x55\x49\x54\x4b\x53\x4e\x52'\
b'\x52\x50\x5b\x4f\x5f\x4e\x61\x20\x52\x5a\x46\x58\x47\x56\x49'\
b'\x55\x4b\x54\x4e\x52\x57\x51\x5b\x50\x5e\x4f\x60\x4e\x61\x4c'\
b'\x62\x4a\x62\x49\x61\x49\x60\x4a\x5f\x4b\x60\x4a\x61\x20\x52'\
b'\x60\x46\x5c\x54\x5b\x58\x5b\x5a\x5c\x5b\x5f\x5b\x61\x59\x62'\
b'\x57\x20\x52\x61\x46\x5d\x54\x5c\x58\x5c\x5a\x5d\x5b\x20\x52'\
b'\x44\x4d\x5e\x4d\x13\x4c\x59\x4d\x51\x4e\x4f\x50\x4d\x53\x4d'\
b'\x54\x4e\x54\x51\x52\x57\x52\x5a\x53\x5b\x20\x52\x52\x4d\x53'\
b'\x4e\x53\x51\x51\x57\x51\x5a\x52\x5b\x55\x5b\x57\x59\x58\x57'\
b'\x15\x4c\x58\x52\x4c\x4e\x57\x58\x50\x4c\x50\x56\x57\x52\x4c'\
b'\x20\x52\x52\x52\x52\x4c\x20\x52\x52\x52\x4c\x50\x20\x52\x52'\
b'\x52\x4e\x57\x20\x52\x52\x52\x56\x57\x20\x52\x52\x52\x58\x50'\
b'\x17\x46\x5e\x49\x55\x49\x53\x4a\x50\x4c\x4f\x4e\x4f\x50\x50'\
b'\x54\x53\x56\x54\x58\x54\x5a\x53\x5b\x51\x20\x52\x49\x53\x4a'\
b'\x51\x4c\x50\x4e\x50\x50\x51\x54\x54\x56\x55\x58\x55\x5a\x54'\
b'\x5b\x51\x5b\x4f'
_index =\
b'\x00\x00\x03\x00\x0a\x00\x11\x00\x18\x00\x1f\x00\x26\x00\x2d'\
b'\x00\x34\x00\x3b\x00\x42\x00\x49\x00\x50\x00\x57\x00\x5e\x00'\
b'\x65\x00\x76\x00\x87\x00\x98\x00\xa9\x00\xbc\x00\xcf\x00\xe2'\
b'\x00\xf5\x00\x00\x01\x0b\x01\x16\x01\x21\x01\x50\x01\x7f\x01'\
b'\xae\x01\xdd\x01\x08\x02\x2f\x02\x64\x02\x7b\x02\x8e\x02\x99'\
b'\x02\xa6\x02\xb9\x02\xcc\x02\xf1\x02\xfe\x02\x09\x03\x16\x03'\
b'\x2f\x03\x3c\x03\x49\x03\x5c\x03\xa3\x03\xda\x03\xfd\x03\x20'\
b'\x04\x43\x04\x66\x04\x7d\x04\xa8\x04\xc3\x04\xda\x04\xf7\x04'\
b'\x1c\x05\x23\x05\x3a\x05\x57\x05\x98\x05\xad\x05\xf2\x05\x73'\
b'\x06\x30\x07\x81\x07\xc2\x07\xe1\x07\x1a\x08\x89\x08\xe6\x08'\
b'\x23\x09\x94\x09\xb9\x09\xfc\x09\x31\x0a\x5a\x0a\xbb\x0a\x1c'\
b'\x0b\x7d\x0b\xbe\x0b\xff\x0b\x1c\x0c\x53\x0c\xae\x0c\x39\x0d'\
b'\xa2\x0d\x0f\x0e\xbc\x0e\x6d\x0f\x96\x0f\xc3\x0f'
INDEX = memoryview(_index)
FONT = memoryview(_font)
|
width = 87
height = 87
first = 32
last = 127
_font = b'\x00JZ\x02D`DR`R\x02D`D``D\x02RRR>Rf\x02D`DD``\x02D`DR`R\x02F^FY^K\x02KYK^YF\x02RRRDR`\x02KYKFY^\x02F^FK^Y\x02KYKRYR\x02MWMWWM\x02RRRKRY\x02MWMMWW\x07GRRGPGMHJJHMGPGR\x07GRGRGTHWJZM\\P]R]\x07R]R]T]W\\ZZ\\W]T]R\x07R]]R]P\\MZJWHTGRG\x08D`DOGQKSPTTTYS]Q`O\x08PUUDSGQKPPPTQYS]U`\x08OTODQGSKTPTTSYQ]O`\x08D`DUGSKQPPTPYQ]S`U\x04KYRJYNKVRZ\x04JZJRNKVYZR\x04KYKVKNYVYN\x04JZLXJPZTXL\x16JZJ]L]O\\Q[TXUVVSVOULTJSIQIPJOLNONSOVPXS[U\\X]Z]\x16I]]Z]X\\U[SXPVOSNONLOJPIQISJTLUOVSVVUXT[Q\\O]L]J\x16JZZGXGUHSIPLONNQNUOXPZQ[S[TZUXVUVQUNTLQIOHLGJG\x16G[GJGLHOIQLTNUQVUVXUZT[S[QZPXOUNQNNOLPISHUGXGZ\x14E[EPFRHTJUMVQVUUXSZP[NZLWLSMQNNPLSKVKYL\\M^\x12EYETHVKWPWSVVTXQYNYLXKVKSLPNNQMTMYN\\P_\x19OUQOOQOSQUSUUSUQSOQO RQPPQPSQTSTTSTQSPQP RRQQRRSSRRQ\nRWRMSMUNVOWQWSVUUVSWRW\x08D`DRJR RORUR RZR`R\x04D`DUDO`O`U\x05JZRDJR RRDZR\x08D`DR`R RJYZY RP`T`\x08D`DR`R RDRRb R`RRb\x11KYQKNLLNKQKSLVNXQYSYVXXVYSYQXNVLSKQK\x05LXLLLXXXXLLL\x04KYRJKVYVRJ\x05LXRHLRR\\XRRH\x0bJZRIPOJOOSMYRUWYUSZOTORI\x05KYRKRY RKRYR\x05MWMMWW RWMMW\x08MWRLRX RMOWU RWOMU"NVQNOONQNSOUQVSVUUVSVQUOSNQN ROQOS RPPPT RQOQU RRORU RSOSU RTPTT RUQUS\x1aNVNNNVVVVNNN ROOOU RPOPU RQOQU RRORU RSOSU RTOTU RUOUU\x10MWRLMUWURL RROOT RROUT RRRQT RRRST\x10LULRUWUMLR RORTU RORTO RRRTS RRRTQ\x10MWRXWOMORX RRUUP RRUOP RRRSP RRRQP\x10OXXROMOWXR RURPO RURPU RRRPQ RRRPS\nRYRKRY RRKYNRQ RSMVNSO\x14I[RGRV RMJWP RWJMP RIVL\\ R[VX\\ RIV[V RL\\X\\\x0cMWRLRX ROOUO RMUOWQXSXUWWU\nLXRLRX RLQMOWOXQ RPWTW\rKYMNWX RWNMX ROLLOKQ RULXOYQ\x11I[NII[ RVI[[ RMM[[ RWMI[ RNIVI RMMWM\x02KYKFY^\nG[MJSV RKPSL RG\\[\\[RG\\\rLXPLPPLPLTPTPXTXTTXTXPTPTLPL\x1fKYYPXNVLSKQKNLLNKQKSLVNXQYSYVXXVYT RYPWNUMSMQNPOOQOSPUQVSWUWWVYT\tKYRJKVYVRJ RRZYNKNRZ!G]PIPGQFSFTGTI RGZHXJVKTLPLKMJOIUIWJXKXPYTZV\\X]Z RGZ]Z RQZP[Q\\S\\T[SZ?JZRMRS RRSQ\\ RRSS\\ RQ\\S\\ RRMQJPHNG RQJNG RRMSJTHVG RSJVG RRMNKLKJM RPLLLJM RRMVKXKZM RTLXLZM RRMPNOOOR RRMPOOR RRMTNUOUR RRMTOUR]JZRIRK RRNRP RRSRU RRYQ\\ RRYS\\ RQ\\S\\ RRGQIPJ RRGSITJ RPJRITJ RRKPNNOMN RRKTNVOWN RNOPORNTOVO RRPPSNTLTKRKSLT RRPTSVTXTYRYSXT RNTPTRSTTVT RRUPXOYMZLZKYJWJYLZ RRUTXUYWZXZYYZWZYXZ RMZOZRYUZWZ\'JZRYQ\\ RRYS\\ RQ\\S\\ RRYUZXZZXZUYTWTYRZOYMWLUMVJUHSGQGOHNJOMMLKMJOKRMTKTJUJXLZOZRY\x1fJZRYQ\\ RRYS\\ RQ\\S\\ RRYVXVVXUXRZQZLYIXHVHTGPGNHLHKIJLJQLRLUNVNXRY\x0eI[IPKR RLKNP RRGRO RXKVP R[PYR\x1bG]IIJKKOKUJYI[ R[IZKYOYUZY[[ RIIKJOKUKYJ[I RI[KZOYUYYZ[[6F^RRR[Q\\ RRVQ\\ RRIQHOHNINKONRR RRISHUHVIVKUNRR RRRNOLNJNIOIQJR RRRVOXNZN[O[QZR RRRNULVJVIUISJR RRRVUXVZV[U[SZR-JZUITJUKVJVIUGSFQFOGNINKOMQOVR ROMTPVRWTWVVXTZ RPNNPMRMTNVPXU[ RNVSYU[V]V_UaSbQbOaN_N^O]P^O_\x1dJZRFQHRJSHRF RRFRb RRQQTRbSTRQ RLMNNPMNLLM RLMXM RTMVNXMVLTM7JZRFQHRJSHRF RRFRT RRPQRSVRXQVSRRP RRTRb RR^Q`RbS`R^ RLMNNPMNLLM RLMXM RTMVNXMVLTM RL[N\\P[NZL[ RL[X[ RT[V\\X[VZT[\x11E_RIQJRKSJRI RIYHZI[JZIY R[YZZ[[\\Z[Y F^RHNLKPJSJUKWMXOXQWRU RRHVLYPZSZUYWWXUXSWRU RRUQYP\\ RRUSYT\\ RP\\T\\\x19F^RNQKPINHMHKIJKJOKRLTNWR\\ RRNSKTIVHWHYIZKZOYRXTVWR\\\x13F^RGPJLOIR RRGTJXO[R RIRLUPZR] R[RXUTZR]/F^RTTWVXXXZW[U[SZQXPVPSQ RSQUOVMVKUISHQHOINKNMOOQQ RQQNPLPJQISIUJWLXNXPWRT RRTQYP\\ RRTSYT\\ RP\\T\\/I[V+S-Q/P1O4O8P<TDUGUJTMRP RS-Q0P4P8Q;UCVGVJUMRPNRRTUWVZV]UaQiPlPpQtSw RRTTWUZU]T`PhOlOpPsQuSwVy/I[N+Q-S/T1U4U8T<PDOGOJPMRP RQ-S0T4T8S;OCNGNJOMRPVRRTOWNZN]OaSiTlTpStQw RRTPWOZO]P`ThUlUpTsSuQwNy\x1fI[V.S1Q4O8N=NCOIPMSXT\\UbUgTlSoQs RS1Q5P8O=OBPHQLTWU[VaVgUlSpQsNv\x1fI[N.Q1S4U8V=VCUITMQXP\\ObOgPlQoSs RQ1S5T8U=UBTHSLPWO[NaNgOlQpSsVv\r7Z:RARRo R@RQo R?RRr RZ"VJRr\x1aI[TMVNXPXOWNTMQMNNMOLQLSMUOWSZ RQMONNOMQMSNUSZT\\T^S_Q_,G]LMKNJPJRKUOYP[ RJRKTOXP[P]O`MbLbKaJ_J\\KXMTOQRNTMVMYNZPZTYXWZU[T[SZSXTWUXTY RVMXNYPYTXXWZDE_YGXHYIZHYGWFTFQGOINKMNLRJ[I_Ha RTFRGPIOKNNLWK[J^I`HaFbDbCaC`D_E`Da R_G^H_I`H`G_F]F[GZHYJXMU[T_Sa R]F[HZJYNWWV[U^T`SaQbObNaN`O_P`Oa RIM^M3F^[GZH[I\\H[GXFUFRGPIOKNNMRK[J_Ia RUFSGQIPKONMWL[K^J`IaGbEbDaD`E_F`Ea RYMWTVXVZW[Z[\\Y]W RZMXTWXWZX[ RJMZM5F^YGXHYIZHZGXF R\\FUFRGPIOKNNMRK[J_Ia RUFSGQIPKONMWL[K^J`IaGbEbDaD`E_F`Ea R[FWTVXVZW[Z[\\Y]W R\\FXTWXWZX[ RJMYMU@cTGSHTIUHTGRFOFLGJIIKHNGRE[D_Ca ROFMGKIJKINGWF[E^D`CaAb?b>a>`?_@`?a R`G_H`IaH`G]FZFWGUITKSNRRP[O_Na RZFXGVIUKTNRWQ[P^O`NaLbJbIaI`J_K`Ja R^M\\T[X[Z\\[_[aYbW R_M]T\\X\\Z][ RDM_MW@cTGSHTIUHTGRFOFLGJIIKHNGRE[D_Ca ROFMGKIJKINGWF[E^D`CaAb?b>a>`?_@`?a R^G]H^I_H_G]F RaFZFWGUITKSNRRP[O_Na RZFXGVIUKTNRWQ[P^O`NaLbJbIaI`J_K`Ja R`F\\T[X[Z\\[_[aYbW RaF]T\\X\\Z][ RDM^M\x13LYMQNOPMSMTNTQRWRZS[ RRMSNSQQWQZR[U[WYXW\x15LXRLNWXPLPVWRL RRRRL RRRLP RRRNW RRRVW RRRXP\x17F^IUISJPLONOPPTSVTXTZS[Q RISJQLPNPPQTTVUXUZT[Q[O'
_index = b'\x00\x00\x03\x00\n\x00\x11\x00\x18\x00\x1f\x00&\x00-\x004\x00;\x00B\x00I\x00P\x00W\x00^\x00e\x00v\x00\x87\x00\x98\x00\xa9\x00\xbc\x00\xcf\x00\xe2\x00\xf5\x00\x00\x01\x0b\x01\x16\x01!\x01P\x01\x7f\x01\xae\x01\xdd\x01\x08\x02/\x02d\x02{\x02\x8e\x02\x99\x02\xa6\x02\xb9\x02\xcc\x02\xf1\x02\xfe\x02\t\x03\x16\x03/\x03<\x03I\x03\\\x03\xa3\x03\xda\x03\xfd\x03 \x04C\x04f\x04}\x04\xa8\x04\xc3\x04\xda\x04\xf7\x04\x1c\x05#\x05:\x05W\x05\x98\x05\xad\x05\xf2\x05s\x060\x07\x81\x07\xc2\x07\xe1\x07\x1a\x08\x89\x08\xe6\x08#\t\x94\t\xb9\t\xfc\t1\nZ\n\xbb\n\x1c\x0b}\x0b\xbe\x0b\xff\x0b\x1c\x0cS\x0c\xae\x0c9\r\xa2\r\x0f\x0e\xbc\x0em\x0f\x96\x0f\xc3\x0f'
index = memoryview(_index)
font = memoryview(_font)
|
#!/usr/bin/python
## Ejercicio 1 reverse Polish Notation
## Autor: Fabiola Tapara Quispe
## Description: Mediante el siguiente metodo recibe un string con datos y signos con operaciones basicas (+, -, *, /) usando una Pila como estructura.
## * Date: 15/11/21
def sum (a, b):
return a + b
def resta (a, b):
return a - b
def multipli (a, b):
return a * b
def division (a, b):
return a // b
## Funcion Notacion
def polishReverse(input):
operadores = "+-*/"
string = []
listado = input.split(" ")
for i in listado:
if (i in operadores):
num2 = string.pop()
num1 = string.pop()
if (i == "+"):
string.append(sum(num1, num2))
elif (i == "-"):
string.append(resta(num1, num2))
elif (i == "*"):
string.append(multipli(num1, num2))
else:
string.append(division(num1, num2))
else:
string.append(int(i))
continue
return string[0]
## Casos de prueba vistos en clase
input = "2 1 + 3 *"
print("Primer Input : " + input)
print(polishReverse(input))
input = "4 13 5 / +"
print("Segundo Input : " + input)
print(polishReverse(input))
input = "10 6 9 3 + -11 * / * 17 + 5 +"
print("Tercer Input : " + input)
print(polishReverse(input))
|
def sum(a, b):
return a + b
def resta(a, b):
return a - b
def multipli(a, b):
return a * b
def division(a, b):
return a // b
def polish_reverse(input):
operadores = '+-*/'
string = []
listado = input.split(' ')
for i in listado:
if i in operadores:
num2 = string.pop()
num1 = string.pop()
if i == '+':
string.append(sum(num1, num2))
elif i == '-':
string.append(resta(num1, num2))
elif i == '*':
string.append(multipli(num1, num2))
else:
string.append(division(num1, num2))
else:
string.append(int(i))
continue
return string[0]
input = '2 1 + 3 *'
print('Primer Input : ' + input)
print(polish_reverse(input))
input = '4 13 5 / +'
print('Segundo Input : ' + input)
print(polish_reverse(input))
input = '10 6 9 3 + -11 * / * 17 + 5 +'
print('Tercer Input : ' + input)
print(polish_reverse(input))
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 4 23:30:51 2017
@author: coskun
Problem 1 - Paying Debt off in a Year
10.0 points possible (graded)
Write a program to calculate the credit card balance after
one year if a person only pays the minimum monthly payment
required by the credit card company each month.
The following variables contain values as described below:
balance - the outstanding balance on the credit card
annualInterestRate - annual interest rate as a decimal
monthlyPaymentRate - minimum monthly payment rate as a decimal
For each month, calculate statements on the monthly payment and
remaining balance. At the end of 12 months, print out the remaining balance.
Be sure to print out no more than two decimal digits of accuracy - so print
print("Remaining balance: 813.41")
"""
#test Case 1:
balance = 42
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
grndTotal = 0
#Test Case 2:
balance = 484
annualInterestRate = 0.2
monthlyPaymentRate = 0.04
def unpaidBalance(Balance, MonthlyPaymentRate):
return Balance - (Balance * MonthlyPaymentRate)
def updatedNextMount(Unpaid, AnnualInterestRate):
return Unpaid + ((AnnualInterestRate/12.0) * Unpaid)
def annualSubDebt(balance, annualInterestRate, monthlyPaymentRate, mount = 12):
""" This Recursive Function calculates mountly interest applied debt and,
returns grand total debit.
"""
#b1 = updatedNextMount(unpaidBalance(balance, monthlyPaymentRate), annualInterestRate)
if mount == 0:
print("Month",12 - mount,"Remaining balance:",balance)
return balance
print("Month",12 - mount,"Remaining balance:",balance)
mount = mount - 1
ub = unpaidBalance(balance, monthlyPaymentRate)
return annualSubDebt(updatedNextMount(ub, annualInterestRate), annualInterestRate, monthlyPaymentRate, mount)
grndTotal = round(annualSubDebt(balance, annualInterestRate, monthlyPaymentRate), 2)
print("Remaining balance:",grndTotal)
|
"""
Created on Sat Mar 4 23:30:51 2017
@author: coskun
Problem 1 - Paying Debt off in a Year
10.0 points possible (graded)
Write a program to calculate the credit card balance after
one year if a person only pays the minimum monthly payment
required by the credit card company each month.
The following variables contain values as described below:
balance - the outstanding balance on the credit card
annualInterestRate - annual interest rate as a decimal
monthlyPaymentRate - minimum monthly payment rate as a decimal
For each month, calculate statements on the monthly payment and
remaining balance. At the end of 12 months, print out the remaining balance.
Be sure to print out no more than two decimal digits of accuracy - so print
print("Remaining balance: 813.41")
"""
balance = 42
annual_interest_rate = 0.2
monthly_payment_rate = 0.04
grnd_total = 0
balance = 484
annual_interest_rate = 0.2
monthly_payment_rate = 0.04
def unpaid_balance(Balance, MonthlyPaymentRate):
return Balance - Balance * MonthlyPaymentRate
def updated_next_mount(Unpaid, AnnualInterestRate):
return Unpaid + AnnualInterestRate / 12.0 * Unpaid
def annual_sub_debt(balance, annualInterestRate, monthlyPaymentRate, mount=12):
""" This Recursive Function calculates mountly interest applied debt and,
returns grand total debit.
"""
if mount == 0:
print('Month', 12 - mount, 'Remaining balance:', balance)
return balance
print('Month', 12 - mount, 'Remaining balance:', balance)
mount = mount - 1
ub = unpaid_balance(balance, monthlyPaymentRate)
return annual_sub_debt(updated_next_mount(ub, annualInterestRate), annualInterestRate, monthlyPaymentRate, mount)
grnd_total = round(annual_sub_debt(balance, annualInterestRate, monthlyPaymentRate), 2)
print('Remaining balance:', grndTotal)
|
def return_category_with_more_spending(transactions):
category_transactions = transactions.groupby(by=["column_category"])[
"column_installment_value"
].sum()
return category_transactions.idxmax(), category_transactions.max()
|
def return_category_with_more_spending(transactions):
category_transactions = transactions.groupby(by=['column_category'])['column_installment_value'].sum()
return (category_transactions.idxmax(), category_transactions.max())
|
# Copyright (c) 2020 Thomas Holland ([email protected])
# All rights reserved.
#
# This code is licensed under the MIT License.
#
# Refer to the LICENSE file which is part of the AdvPiStepper distribution or
# to https://opensource.org/licenses/MIT for a text of the license.
#
#
"""
Definitions used by the AdvPiStepper
CW and CCW constants defining clockwise / couterclockwise motions.
The Keys which are used as parameters to describe a motor and the driver.
* DRIVER_NAME Human readable name of the driver.
* MAX_SPEED: Maximum speed in steps per second. This is not a limit, just a recommendation.
* MAX_TORQUE_SPEED: Maximum speed at which the motor will still deliver full torque (optional, if known)
* ACCELERATION_RATE: Acceleration in steps per second squared.
* DECELERATION_RATE: Deceleration in steps per second squared.
* FULL_STEPS_PER_REV: Number of full (not micro-)steps per one revolution.
* MICROSTEP_OPTIONS: Tupel of all microsteps options.
* MICROSTEP_DEFAULT: The prefered microstep rate of the driver.
Other parameters which can be passed to the AdvPiStepper class
* PIGPIO_ADDR: The hostname of the system where the pigpio daemon is running on.
* PIGPIO_PORT: The port on which the pigpio daemon is listening on.
"""
CW: int = 1
"""Clockwise/forward rotation. Just an internal designation. True
direction may depend on the wiring of the stepper motor."""
CCW: int = -1
"""Counterclockwise/backward rotation. Just an internal designation.
True direction may depend on the wiring of the stepper motor."""
# Parameter Keys
DRIVER_NAME: str = "driver_name"
MAX_SPEED: str = "max_speed"
"""Maximum speed in steps per second. This is not a limit, just a recommendation"""
MAX_TORQUE_SPEED: str = "max_torque_speed"
"""Maximum speed at which the motor will still deliver full torque."""
ACCELERATION_RATE: str = "acceleration_rate"
"""Acceleration in steps per second squared."""
DECELERATION_RATE: str = "deceleration_rate"
"""Decelearation in steps per second squared."""
FULL_STEPS_PER_REV: str = "full_steps_per_rev"
"""Number of full (not micro-)steps per one revolution."""
MICROSTEP_OPTIONS: str = "microstep_options"
"""Tupel of all microsteps options. Default is only full steps."""
MICROSTEP_DEFAULT = "microstep_default"
"""The prefered microstep rate of the driver."""
PIGPIO_ADDR = "pigpio_addr"
"""The hostname of the system where the pigpio daemon is running on. Default is empty for the localhost."""
PIGPIO_PORT = "pigpio_port"
"""The port on which the pigpio daemon is listening on. Default is empty to use the default pigpio port (8888)."""
DIRECTION_INVERT = "direction_invert"
"""If this key exists then the direction signal is inverted by the driver,
i.e. Clockwise and Counterclockwise are swaped."""
# Paramaters of the Step/Dir Driver
DIRECTION_CHANGE_DELAY = "direction_change_delay"
"""The time between a change in direction and the first step pulse (in microseconds)"""
STEP_PULSE_LENGTH = "step_pulse_length"
"""The time for a step pulse (in microseconds)"""
STEP_PULSE_DELAY = "step_pulse_delay"
"""The minimum time between step pulses (in microseconds)"""
|
"""
Definitions used by the AdvPiStepper
CW and CCW constants defining clockwise / couterclockwise motions.
The Keys which are used as parameters to describe a motor and the driver.
* DRIVER_NAME Human readable name of the driver.
* MAX_SPEED: Maximum speed in steps per second. This is not a limit, just a recommendation.
* MAX_TORQUE_SPEED: Maximum speed at which the motor will still deliver full torque (optional, if known)
* ACCELERATION_RATE: Acceleration in steps per second squared.
* DECELERATION_RATE: Deceleration in steps per second squared.
* FULL_STEPS_PER_REV: Number of full (not micro-)steps per one revolution.
* MICROSTEP_OPTIONS: Tupel of all microsteps options.
* MICROSTEP_DEFAULT: The prefered microstep rate of the driver.
Other parameters which can be passed to the AdvPiStepper class
* PIGPIO_ADDR: The hostname of the system where the pigpio daemon is running on.
* PIGPIO_PORT: The port on which the pigpio daemon is listening on.
"""
cw: int = 1
'Clockwise/forward rotation. Just an internal designation. True\ndirection may depend on the wiring of the stepper motor.'
ccw: int = -1
'Counterclockwise/backward rotation. Just an internal designation.\nTrue direction may depend on the wiring of the stepper motor.'
driver_name: str = 'driver_name'
max_speed: str = 'max_speed'
'Maximum speed in steps per second. This is not a limit, just a recommendation'
max_torque_speed: str = 'max_torque_speed'
'Maximum speed at which the motor will still deliver full torque.'
acceleration_rate: str = 'acceleration_rate'
'Acceleration in steps per second squared.'
deceleration_rate: str = 'deceleration_rate'
'Decelearation in steps per second squared.'
full_steps_per_rev: str = 'full_steps_per_rev'
'Number of full (not micro-)steps per one revolution.'
microstep_options: str = 'microstep_options'
'Tupel of all microsteps options. Default is only full steps.'
microstep_default = 'microstep_default'
'The prefered microstep rate of the driver.'
pigpio_addr = 'pigpio_addr'
'The hostname of the system where the pigpio daemon is running on. Default is empty for the localhost.'
pigpio_port = 'pigpio_port'
'The port on which the pigpio daemon is listening on. Default is empty to use the default pigpio port (8888).'
direction_invert = 'direction_invert'
'If this key exists then the direction signal is inverted by the driver, \ni.e. Clockwise and Counterclockwise are swaped.'
direction_change_delay = 'direction_change_delay'
'The time between a change in direction and the first step pulse (in microseconds)'
step_pulse_length = 'step_pulse_length'
'The time for a step pulse (in microseconds)'
step_pulse_delay = 'step_pulse_delay'
'The minimum time between step pulses (in microseconds)'
|
def is_palindrome(n: int) -> bool:
s = str(n)
h = int(len(s) / 2)
s1 = s[:h]
s2 = s[h:][::-1]
is_palindrome = True
for i in range(h):
if s1[i] != s2[i]:
is_palindrome = False
return is_palindrome
def solution() -> int:
largest_palindrome = 0
for i in range(100, 1000):
for j in range(100, 1000):
n = i * j
if is_palindrome(n) and n > largest_palindrome:
largest_palindrome = n
return largest_palindrome
if __name__ == "__main__":
print(solution())
|
def is_palindrome(n: int) -> bool:
s = str(n)
h = int(len(s) / 2)
s1 = s[:h]
s2 = s[h:][::-1]
is_palindrome = True
for i in range(h):
if s1[i] != s2[i]:
is_palindrome = False
return is_palindrome
def solution() -> int:
largest_palindrome = 0
for i in range(100, 1000):
for j in range(100, 1000):
n = i * j
if is_palindrome(n) and n > largest_palindrome:
largest_palindrome = n
return largest_palindrome
if __name__ == '__main__':
print(solution())
|
''' Check valid age
Write a program that takes age fro the user and then decide whether the age is between 18 to 24. If so, then it will display the message "You can apply for youth festival program". Otherwise, display the message "Sorry, you cannot apply".
If age >= 18 and age <= 24 # Not correct
If age = 18 and age < 24 # correct solution
'''
age = int(input("Please enter the age: "))
if age >= 18 and age <= 24:
print("You can apply for Youth Festival program")
else:
print("Sorry, you cannot apply") # Please enter the age: 20
# You can apply for Youth Festival program
# Please enter the age: 30
# Sorry, you cannot apply
|
""" Check valid age
Write a program that takes age fro the user and then decide whether the age is between 18 to 24. If so, then it will display the message "You can apply for youth festival program". Otherwise, display the message "Sorry, you cannot apply".
If age >= 18 and age <= 24 # Not correct
If age = 18 and age < 24 # correct solution
"""
age = int(input('Please enter the age: '))
if age >= 18 and age <= 24:
print('You can apply for Youth Festival program')
else:
print('Sorry, you cannot apply')
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.