content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
'''
Mysql Table Create Queries
'''
tables = [
# master_config Table
'''
CREATE TABLE IF NOT EXISTS master_config (
id INT UNSIGNED NOT NULL AUTO_INCREMENT,
author VARCHAR(20) NOT NULL,
PRIMARY KEY(id)
);
''',
'''
CREATE TABLE IF NOT EXISTS user (
id VARCHAR(200) NOT NULL,
pw VARCHAR(200) NOT NULL,
PRIMARY KEY(id)
);
''',
]
| """
Mysql Table Create Queries
"""
tables = ['\n CREATE TABLE IF NOT EXISTS master_config (\n id INT UNSIGNED NOT NULL AUTO_INCREMENT,\n author VARCHAR(20) NOT NULL,\n PRIMARY KEY(id)\n );\n', '\n CREATE TABLE IF NOT EXISTS user (\n id VARCHAR(200) NOT NULL,\n pw VARCHAR(200) NOT NULL,\n PRIMARY KEY(id)\n );\n'] |
x,y = map(int,input().split())
if x+y < 10:
print(x+y)
else:
print("error") | (x, y) = map(int, input().split())
if x + y < 10:
print(x + y)
else:
print('error') |
class Address(object):
ADDRESS_UTIM = 0
ADDRESS_UHOST = 1
ADDRESS_DEVICE = 2
ADDRESS_PLATFORM = 3
| class Address(object):
address_utim = 0
address_uhost = 1
address_device = 2
address_platform = 3 |
s = "a quick {0} brown fox {2} jumped over {1} the lazy dog";
x = 100;
y = 200;
z = 300;
t = s.format(x,y,z);
print(t); | s = 'a quick {0} brown fox {2} jumped over {1} the lazy dog'
x = 100
y = 200
z = 300
t = s.format(x, y, z)
print(t) |
def uncollapse(s):
for n in ['zero','one','two','three','four','five','six','seven','eight','nine']:
s=s.replace(n,n+' ')
return s[:-1]
def G(s):
for n in ['zero','one','two','three','four','five','six','seven','eight','nine']:
s=s.replace(n,n+' ')
return s[:-1]
| def uncollapse(s):
for n in ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']:
s = s.replace(n, n + ' ')
return s[:-1]
def g(s):
for n in ['zero', 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine']:
s = s.replace(n, n + ' ')
return s[:-1] |
# based on https://nlp.stanford.edu/software/dependencies_manual.pdf
DEPENDENCY_DEFINITONS = {
'acomp': 'adjectival_complement',
'advcl': 'adverbial_clause_modifier',
'advmod': 'adverb_modifier',
'agent': 'agent',
'amod': 'adjectival_modifier',
'appos': 'appositional_modifier',
'aux': 'auxiliary',
'auxpass': 'passive_auxiliary',
'cc': 'coordination',
'ccomp': 'clausal_complement',
'conj': 'conjunct',
'cop': 'copula',
'csubj': 'clausal_subject',
'csubjpass': 'clausal_passive_subject',
'dep': 'dependent',
'det': 'determiner',
'discourse': 'discourse_element',
'dobj': 'direct_object',
'expl': 'expletive',
'goeswith': 'goes_with',
'iobj': 'indirect_object',
'mark': 'marker',
'mwe': 'multiword_expression',
'neg': 'negation_modifier',
'nn': 'noun_compound_modifier',
'npadvmod': 'noun_phrase_as_adverbial_modifier',
'nsubj': 'nominal_subject',
'nsubjpass': 'passive_nominal_subject',
'num': 'numeric_modifier',
'nummod': 'numeric_modifier',
'number': 'element_of_compound_number',
'parataxis': 'parataxis',
'pcomp': 'prepositional_complement',
'pobj': 'preposition_object',
'poss': 'possession_modifier',
'possessive': 'possessive_modifier',
'preconj': 'preconjunct',
'predet': 'predeterminer',
'prep': 'prepositional_modifier',
'prepc': 'prepositional_clausal_modifier',
'prt': 'phrasal_verb_particle',
'punct': 'punctuation',
'quantmod': 'quantifier_phrase_modifier',
'rcmod': 'relative_clause_modifier',
'ref': 'referent',
'root': 'root',
'tmod': 'temporal_modifier',
'vmod': 'reduced_nonfinite_verbal_modifier',
'xcomp': 'open_clausal_complement',
'xsubj': 'controlling_subject',
'attr': 'attributive',
'relcl': 'relative_clause_modifier',
'intj': 'interjection'
} | dependency_definitons = {'acomp': 'adjectival_complement', 'advcl': 'adverbial_clause_modifier', 'advmod': 'adverb_modifier', 'agent': 'agent', 'amod': 'adjectival_modifier', 'appos': 'appositional_modifier', 'aux': 'auxiliary', 'auxpass': 'passive_auxiliary', 'cc': 'coordination', 'ccomp': 'clausal_complement', 'conj': 'conjunct', 'cop': 'copula', 'csubj': 'clausal_subject', 'csubjpass': 'clausal_passive_subject', 'dep': 'dependent', 'det': 'determiner', 'discourse': 'discourse_element', 'dobj': 'direct_object', 'expl': 'expletive', 'goeswith': 'goes_with', 'iobj': 'indirect_object', 'mark': 'marker', 'mwe': 'multiword_expression', 'neg': 'negation_modifier', 'nn': 'noun_compound_modifier', 'npadvmod': 'noun_phrase_as_adverbial_modifier', 'nsubj': 'nominal_subject', 'nsubjpass': 'passive_nominal_subject', 'num': 'numeric_modifier', 'nummod': 'numeric_modifier', 'number': 'element_of_compound_number', 'parataxis': 'parataxis', 'pcomp': 'prepositional_complement', 'pobj': 'preposition_object', 'poss': 'possession_modifier', 'possessive': 'possessive_modifier', 'preconj': 'preconjunct', 'predet': 'predeterminer', 'prep': 'prepositional_modifier', 'prepc': 'prepositional_clausal_modifier', 'prt': 'phrasal_verb_particle', 'punct': 'punctuation', 'quantmod': 'quantifier_phrase_modifier', 'rcmod': 'relative_clause_modifier', 'ref': 'referent', 'root': 'root', 'tmod': 'temporal_modifier', 'vmod': 'reduced_nonfinite_verbal_modifier', 'xcomp': 'open_clausal_complement', 'xsubj': 'controlling_subject', 'attr': 'attributive', 'relcl': 'relative_clause_modifier', 'intj': 'interjection'} |
class Solution:
def reverse(self, x: int) -> int:
s = ''
if x < 0:
s += '-'
x *= -1
else:
s += '0'
while x > 0:
tmp = x % 10
s += str(tmp)
x = x // 10
res = int(s)
if res > 2**31 - 1 or res < - 2**31:
return 0
else:
return res
if __name__ == '__main__':
s = Solution()
print(s.reverse(1534236469))
| class Solution:
def reverse(self, x: int) -> int:
s = ''
if x < 0:
s += '-'
x *= -1
else:
s += '0'
while x > 0:
tmp = x % 10
s += str(tmp)
x = x // 10
res = int(s)
if res > 2 ** 31 - 1 or res < -2 ** 31:
return 0
else:
return res
if __name__ == '__main__':
s = solution()
print(s.reverse(1534236469)) |
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution:
def addTwoNumbers(self, l1: ListNode, l2: ListNode) -> ListNode:
result = ListNode(0)
curr = result
carry = 0
while l1 or l2:
x = l1.val if l1 else 0
y = l2.val if l2 else 0
value = carry + x + y
carry = value // 10
curr.next = ListNode(value % 10)
curr = curr.next
l1 = l1.next if l1 else None
l2 = l2.next if l2 else None
if carry > 0:
curr.next = ListNode(carry)
return result.next | class Solution:
def add_two_numbers(self, l1: ListNode, l2: ListNode) -> ListNode:
result = list_node(0)
curr = result
carry = 0
while l1 or l2:
x = l1.val if l1 else 0
y = l2.val if l2 else 0
value = carry + x + y
carry = value // 10
curr.next = list_node(value % 10)
curr = curr.next
l1 = l1.next if l1 else None
l2 = l2.next if l2 else None
if carry > 0:
curr.next = list_node(carry)
return result.next |
string = "PATTERN"
strlen = len(string)
for x in range(0, strlen):
print(string[0:strlen-x]) | string = 'PATTERN'
strlen = len(string)
for x in range(0, strlen):
print(string[0:strlen - x]) |
#Donal Maher
# Check if one number divides by another
def sleep_in(weekday, vacation):
if (weekday and vacation == False):
return False
else:
return True
result = sleep_in(False, False)
print("The result is {} ".format(result)) | def sleep_in(weekday, vacation):
if weekday and vacation == False:
return False
else:
return True
result = sleep_in(False, False)
print('The result is {} '.format(result)) |
def calc(n1 ,op ,n2):
result = 0
if op == '+':
result = n1 + n2
elif op == '-':
result = n1 - n2
elif op == '*':
result = n1 * n2
elif op == '/':
result = n1 / n2
else:
result = 0
return result
num1 = input('Input num1...')
num2 = input('Input num2...')
op = input('Input op...')
data = calc(int(num1), op , int(num2))
print(data) | def calc(n1, op, n2):
result = 0
if op == '+':
result = n1 + n2
elif op == '-':
result = n1 - n2
elif op == '*':
result = n1 * n2
elif op == '/':
result = n1 / n2
else:
result = 0
return result
num1 = input('Input num1...')
num2 = input('Input num2...')
op = input('Input op...')
data = calc(int(num1), op, int(num2))
print(data) |
n = int(input())
L = list(map(int,input().split()))
ans = 1
c = L[0]
cnt = 1
for i in L[1:]:
if c <= i:
cnt+=1
c = i
ans = max(ans,cnt)
else:
cnt = 1
c = i
c = L[0]
cnt = 1
for i in L[1:]:
if c >= i:
cnt+=1
c = i
ans = max(ans,cnt)
else:
cnt = 1
c = i
print(ans) | n = int(input())
l = list(map(int, input().split()))
ans = 1
c = L[0]
cnt = 1
for i in L[1:]:
if c <= i:
cnt += 1
c = i
ans = max(ans, cnt)
else:
cnt = 1
c = i
c = L[0]
cnt = 1
for i in L[1:]:
if c >= i:
cnt += 1
c = i
ans = max(ans, cnt)
else:
cnt = 1
c = i
print(ans) |
# -*- coding: utf-8 -*-
class Config(object):
def __init__(self, bucket, root):
self.bucket = bucket
self.root = root
| class Config(object):
def __init__(self, bucket, root):
self.bucket = bucket
self.root = root |
def find_best_investment(arr):
if len(arr) < 2:
return None, None
current_min = arr[0]
current_max_profit = -float("inf")
result = (None, None)
for item in arr[1:]:
current_profit = item - current_min
if current_profit > current_max_profit:
current_max_profit = current_profit
result = (current_min, item)
if item < current_min:
current_min = item
return result
if __name__ == '__main__':
print(find_best_investment([1, 2, -1, 4, 5, 6, 7])) | def find_best_investment(arr):
if len(arr) < 2:
return (None, None)
current_min = arr[0]
current_max_profit = -float('inf')
result = (None, None)
for item in arr[1:]:
current_profit = item - current_min
if current_profit > current_max_profit:
current_max_profit = current_profit
result = (current_min, item)
if item < current_min:
current_min = item
return result
if __name__ == '__main__':
print(find_best_investment([1, 2, -1, 4, 5, 6, 7])) |
def returnValues(z):
results = [(x, y)
for x in range(z)
for y in range(z)
if x + y == 5
if x > y]
return results
print(returnValues(10)) | def return_values(z):
results = [(x, y) for x in range(z) for y in range(z) if x + y == 5 if x > y]
return results
print(return_values(10)) |
# This file is used on sr restored train set (which includes dev segments) tagged with their segment headers
# It splits the set into the dev and train sets using the header information
dev_path = 'dev/text' # stores dev segment information
restored_sr = 'train/text_restored_by_inference_version2_with_timing' # restored full train + dev segments with headers
save_dev = open('../../data/sr_restored_split_by_inference_version2/dev', 'a')
save_train = open('../../data/sr_restored_split_by_inference_version2/train','a')
def convert_word(text):
t = text.strip()
if t == '':
return ''
# get first punctuation
for i in range(len(t)):
if t[i] == ',':
return t[:i] + "\t" + "COMMA"
elif t[i]== '.':
return t[:i] + "\t" + "PERIOD"
elif t[i] == '?':
return t[:i] + "\t" + "QUESTION"
return t + "\t" + "O"
def get_dev_headers(file_path):
'''
takes in data file processed by sr which labels lines by their id (swXXXXX)
returns the number of unique files in that data file
'''
data_file = open(file_path, "r", encoding="utf-8")
lines = data_file.readlines()
lines = list(map(lambda x: x.split(" ")[0], lines))
lines = list(dict.fromkeys(lines))
lines.sort()
return set(lines)
dev_headers = get_dev_headers(dev_path)
data_file = open(restored_sr, "r", encoding="utf-8")
lines = data_file.readlines()
for l in lines:
line = l.split(' ', 1)
segment_header = line[0]
segment_text = line[1]
segment = segment_text.split(' ')
word_list = list(map(convert_word, segment))
if segment_header in dev_headers:
save_dev.write('\n'.join(word_list))
save_dev.write('\n')
else:
save_train.write('\n'.join(word_list))
save_train.write('\n')
| dev_path = 'dev/text'
restored_sr = 'train/text_restored_by_inference_version2_with_timing'
save_dev = open('../../data/sr_restored_split_by_inference_version2/dev', 'a')
save_train = open('../../data/sr_restored_split_by_inference_version2/train', 'a')
def convert_word(text):
t = text.strip()
if t == '':
return ''
for i in range(len(t)):
if t[i] == ',':
return t[:i] + '\t' + 'COMMA'
elif t[i] == '.':
return t[:i] + '\t' + 'PERIOD'
elif t[i] == '?':
return t[:i] + '\t' + 'QUESTION'
return t + '\t' + 'O'
def get_dev_headers(file_path):
"""
takes in data file processed by sr which labels lines by their id (swXXXXX)
returns the number of unique files in that data file
"""
data_file = open(file_path, 'r', encoding='utf-8')
lines = data_file.readlines()
lines = list(map(lambda x: x.split(' ')[0], lines))
lines = list(dict.fromkeys(lines))
lines.sort()
return set(lines)
dev_headers = get_dev_headers(dev_path)
data_file = open(restored_sr, 'r', encoding='utf-8')
lines = data_file.readlines()
for l in lines:
line = l.split(' ', 1)
segment_header = line[0]
segment_text = line[1]
segment = segment_text.split(' ')
word_list = list(map(convert_word, segment))
if segment_header in dev_headers:
save_dev.write('\n'.join(word_list))
save_dev.write('\n')
else:
save_train.write('\n'.join(word_list))
save_train.write('\n') |
async with pyryver.Ryver("organization_name", "username", "password") as ryver:
await ryver.load_chats()
a_user = ryver.get_user(username="tylertian123")
a_forum = ryver.get_groupchat(display_name="Off-Topic")
| async with pyryver.Ryver('organization_name', 'username', 'password') as ryver:
await ryver.load_chats()
a_user = ryver.get_user(username='tylertian123')
a_forum = ryver.get_groupchat(display_name='Off-Topic') |
# tests require to import from Faiss module
# so thus require PYTHONPATH
# the other option would be installing via requirements
# but that would always be a different version
# only required for CI. DO NOT add real tests here, but in top-level integration
def test_dummy():
pass
| def test_dummy():
pass |
numbers = [int(n) for n in input().split(", ")]
count_of_beggars = int(input())
collected = []
index = 0
for i in range(count_of_beggars):
current_list = []
for index in range(0, len(numbers) + 1, count_of_beggars):
index += i
if index < len(numbers):
current_list.append(numbers[index])
collected.append(sum(current_list))
print(collected)
# nums_str = input().split(', ')
# count = int(input())
#
# nums = []
#
# for num in nums_str:
# nums.append(int(num))
#
# result_sum = [0] * count
#
# for i in range(len(nums)):
# index = i % count
# result_sum[index] += nums[i]
#
# print(result_sum) | numbers = [int(n) for n in input().split(', ')]
count_of_beggars = int(input())
collected = []
index = 0
for i in range(count_of_beggars):
current_list = []
for index in range(0, len(numbers) + 1, count_of_beggars):
index += i
if index < len(numbers):
current_list.append(numbers[index])
collected.append(sum(current_list))
print(collected) |
# list comprehension is an elegant way to creats list based on exesting list
# We can use this one liner comprehensioner for dictnory ans sets also.
#l1 = [3,5,6,7,8,90,12,34,67,0]
'''
# For addind even in l2
l2 =[]
for item in l1:
if item%2 == 0:
l2.append(item)
print(l2)
'''
'''
# Shortcut to write the same:
l2 = [item for item in l1 if item < 8]
l3 = [item for item in l1 if item%2 ==0] # creating a list for
print(l2)
print(l3)
'''
# print a reaptated element from both list.
l4 = ['am' , 'em' , 'fcgh' , 'em' , 'em']
l5 = ['am', 'f' , 'em' , 'rg' , 'em']
flist = [item for item in l4+l5 if item == 'em']
#print(flist)
#print(flist.count('em'))
a= [4,6,8,5,4,4,4]
b = [4,5,6,4,5,4]
c = [i for i in a+b if i==4]
print(c)
print(c.count(4)) | """
# For addind even in l2
l2 =[]
for item in l1:
if item%2 == 0:
l2.append(item)
print(l2)
"""
'\n# Shortcut to write the same:\nl2 = [item for item in l1 if item < 8]\nl3 = [item for item in l1 if item%2 ==0] # creating a list for \nprint(l2)\nprint(l3)\n'
l4 = ['am', 'em', 'fcgh', 'em', 'em']
l5 = ['am', 'f', 'em', 'rg', 'em']
flist = [item for item in l4 + l5 if item == 'em']
a = [4, 6, 8, 5, 4, 4, 4]
b = [4, 5, 6, 4, 5, 4]
c = [i for i in a + b if i == 4]
print(c)
print(c.count(4)) |
'''
Created on Apr 11, 2017
tutorial:
https://www.youtube.com/watch?v=nefopNkZmB4&list=PL6gx4Cwl9DGAcbMi1sH6oAMk4JHw91mC_&index=3
modules:
https://www.youtube.com/watch?v=sKYiQLRe254
@author: halil
'''
class BayesianFilter(object):
'''
classdocs
'''
def __init__(self):
'''
Constructor
'''
print ("hello bayesian filter!")
| """
Created on Apr 11, 2017
tutorial:
https://www.youtube.com/watch?v=nefopNkZmB4&list=PL6gx4Cwl9DGAcbMi1sH6oAMk4JHw91mC_&index=3
modules:
https://www.youtube.com/watch?v=sKYiQLRe254
@author: halil
"""
class Bayesianfilter(object):
"""
classdocs
"""
def __init__(self):
"""
Constructor
"""
print('hello bayesian filter!') |
rules = {}
appearances = {}
original = input()
input()
while True:
try:
l, r = input().split(" -> ")
except:
break
rules[l] = r
appearances[l] = 0
for i in range(len(original)-1):
a = original[i]
b = original[i+1]
appearances[a+b] += 1
def polymerization(d):
new = {x: 0 for x in rules}
singular = {x: 0 for x in rules.values()}
for ((a, b), c) in rules.items():
new[a+c] += d[a+b]
new[c+b] += d[a+b]
singular[c] += d[a+b]
singular[a] += d[a+b]
#last letter of the word is a K (not not counted above)
singular["K"] += 1
return new, singular
for i in range(40):
(appearances, sing) = polymerization(appearances)
counts = [(v, k) for (k, v) in sing.items()]
counts.sort()
print(counts[-1][0] - counts[0][0]) | rules = {}
appearances = {}
original = input()
input()
while True:
try:
(l, r) = input().split(' -> ')
except:
break
rules[l] = r
appearances[l] = 0
for i in range(len(original) - 1):
a = original[i]
b = original[i + 1]
appearances[a + b] += 1
def polymerization(d):
new = {x: 0 for x in rules}
singular = {x: 0 for x in rules.values()}
for ((a, b), c) in rules.items():
new[a + c] += d[a + b]
new[c + b] += d[a + b]
singular[c] += d[a + b]
singular[a] += d[a + b]
singular['K'] += 1
return (new, singular)
for i in range(40):
(appearances, sing) = polymerization(appearances)
counts = [(v, k) for (k, v) in sing.items()]
counts.sort()
print(counts[-1][0] - counts[0][0]) |
n, m = map(int, input().split())
res = []
for _ in range(m):
res.append(int(input()))
res.sort()
price, ans = 0,0
for i in range(m):
result = min(m-i, n)
if ans < res[i] * result:
price = res[i]
ans = res[i] * result
print(price, ans) | (n, m) = map(int, input().split())
res = []
for _ in range(m):
res.append(int(input()))
res.sort()
(price, ans) = (0, 0)
for i in range(m):
result = min(m - i, n)
if ans < res[i] * result:
price = res[i]
ans = res[i] * result
print(price, ans) |
__version__ = "0.3.1"
__logo__ = [
" _ _",
"| | _____ | |__ _ __ __ _",
"| |/ / _ \\| '_ \\| '__/ _` |",
"| < (_) | |_) | | | (_| |",
"|_|\\_\\___/|_.__/|_| \\__,_|",
" "
]
| __version__ = '0.3.1'
__logo__ = [' _ _', '| | _____ | |__ _ __ __ _', "| |/ / _ \\| '_ \\| '__/ _` |", '| < (_) | |_) | | | (_| |', '|_|\\_\\___/|_.__/|_| \\__,_|', ' '] |
def _RELIC__word_list_prep():
file = open('stopwords.txt')
new_file = open('stopwords_new.txt', 'w')
for line in file:
if line.strip():
new_file.write(line)
file.close()
new_file.close()
| def _relic__word_list_prep():
file = open('stopwords.txt')
new_file = open('stopwords_new.txt', 'w')
for line in file:
if line.strip():
new_file.write(line)
file.close()
new_file.close() |
# acutal is the list of actual labels, pred is the list of predicted labels.
# sensitive is the column of sensitive attribute, target_group is s in S = s
# positive_pred is the favorable result in prediction task. e.g. get approved for a loan
def calibration_pos(actual,pred,sensitive,target_group,positive_pred):
tot_pred_pos = 0
act_pos = 0
for act, pred_val, sens in zip(actual, pred,sensitive):
# the case S != s
if sens != target_group:
continue
else:
# Yhat = 1
if pred_val == positive_pred:
tot_pred_pos += 1
# the case both Yhat = 1 and Y = 1
if act == positive_pred:
act_pos +=1
if act_pos == 0 and tot_pred_pos ==0:
return 1
if tot_pred_pos == 0:
return 0
return act_pos/tot_pred_pos
| def calibration_pos(actual, pred, sensitive, target_group, positive_pred):
tot_pred_pos = 0
act_pos = 0
for (act, pred_val, sens) in zip(actual, pred, sensitive):
if sens != target_group:
continue
elif pred_val == positive_pred:
tot_pred_pos += 1
if act == positive_pred:
act_pos += 1
if act_pos == 0 and tot_pred_pos == 0:
return 1
if tot_pred_pos == 0:
return 0
return act_pos / tot_pred_pos |
# Problem Link: https://www.hackerrank.com/contests/projecteuler/challenges/euler013/problem
sum = 0
for _ in range(int(input())):
sum += int(input())
print(str(sum)[:10])
| sum = 0
for _ in range(int(input())):
sum += int(input())
print(str(sum)[:10]) |
# -*- coding: utf-8 -*-
#
# -- General configuration -------------------------------------
source_suffix = ".rst"
master_doc = "index"
project = u"Sphinx theme for dynamic html presentation style"
copyright = u"2012-2021, Sphinx-users.jp"
version = "0.5.0"
# -- Options for HTML output -----------------------------------
extensions = [
"sphinxjp.themes.impressjs",
]
html_theme = "impressjs"
html_use_index = False
| source_suffix = '.rst'
master_doc = 'index'
project = u'Sphinx theme for dynamic html presentation style'
copyright = u'2012-2021, Sphinx-users.jp'
version = '0.5.0'
extensions = ['sphinxjp.themes.impressjs']
html_theme = 'impressjs'
html_use_index = False |
operators = {
'+': (lambda a, b: a + b),
'-': (lambda a, b: a - b),
'*': (lambda a, b: a * b),
'/': (lambda a, b: a / b),
'**': (lambda a, b: a ** b),
'^': (lambda a, b: a ** b)
}
priorities = {
'+': 1,
'-': 1,
'*': 2,
'/': 2,
'**': 3,
'^': 3
}
op_chars = {char for op in operators for char in op}
def evaluate(expression):
infix = _parse_tokens(expression.replace(' ', ''))
postfix = _postfix(infix)
stack = []
for token in postfix:
if _is_number(token):
stack.append(ExpressionNode(token))
if token in operators:
t1, t2 = stack.pop(), stack.pop()
node = ExpressionNode(token)
node.left, node.right = t1, t2
stack.append(node)
return stack.pop().result()
class ExpressionNode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def result(self):
if _is_number(self.value):
return _to_number(self.value)
else:
return operators[self.value](
self.right.result(), self.left.result())
def _postfix(tokens):
stack = ['(']
tokens.append(')')
postfix = []
for token in tokens:
if _is_number(token):
postfix.append(token)
elif token == '(':
stack.append('(')
elif token == ')':
while stack[-1] != '(':
postfix.append(stack.pop())
stack.pop()
else:
while _priority(token) <= _priority(stack[-1]):
postfix.append(stack.pop())
stack.append(token)
return postfix
def _priority(token):
if token in priorities:
return priorities[token]
return 0
def _parse_tokens(exp):
tokens = []
next_token = ""
pos = 0
while pos < len(exp):
if _is_number(exp[pos]):
next_token, pos = _read_next_value(exp, pos)
elif exp[pos] in op_chars:
next_token, pos = _read_next_operator(exp, pos)
elif exp[pos] in ('(', ')'):
next_token = exp[pos]
else:
raise ValueError("Unrecognized character at position " + str(pos))
tokens.append(next_token)
pos += 1
return tokens
def _read_next_value(exp, pos):
token = ""
while pos < len(exp) and (_is_number(exp[pos]) or exp[pos] == '.'):
token += exp[pos]
pos += 1
return token, pos - 1
def _read_next_operator(exp, pos):
token = ""
while (pos < len(exp) and exp[pos] in op_chars):
token += exp[pos]
pos += 1
return token, pos - 1
def _to_number(str):
try:
return int(str)
except ValueError:
return float(str)
def _is_number(str):
try:
complex(str)
return True
except ValueError:
return False
| operators = {'+': lambda a, b: a + b, '-': lambda a, b: a - b, '*': lambda a, b: a * b, '/': lambda a, b: a / b, '**': lambda a, b: a ** b, '^': lambda a, b: a ** b}
priorities = {'+': 1, '-': 1, '*': 2, '/': 2, '**': 3, '^': 3}
op_chars = {char for op in operators for char in op}
def evaluate(expression):
infix = _parse_tokens(expression.replace(' ', ''))
postfix = _postfix(infix)
stack = []
for token in postfix:
if _is_number(token):
stack.append(expression_node(token))
if token in operators:
(t1, t2) = (stack.pop(), stack.pop())
node = expression_node(token)
(node.left, node.right) = (t1, t2)
stack.append(node)
return stack.pop().result()
class Expressionnode:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def result(self):
if _is_number(self.value):
return _to_number(self.value)
else:
return operators[self.value](self.right.result(), self.left.result())
def _postfix(tokens):
stack = ['(']
tokens.append(')')
postfix = []
for token in tokens:
if _is_number(token):
postfix.append(token)
elif token == '(':
stack.append('(')
elif token == ')':
while stack[-1] != '(':
postfix.append(stack.pop())
stack.pop()
else:
while _priority(token) <= _priority(stack[-1]):
postfix.append(stack.pop())
stack.append(token)
return postfix
def _priority(token):
if token in priorities:
return priorities[token]
return 0
def _parse_tokens(exp):
tokens = []
next_token = ''
pos = 0
while pos < len(exp):
if _is_number(exp[pos]):
(next_token, pos) = _read_next_value(exp, pos)
elif exp[pos] in op_chars:
(next_token, pos) = _read_next_operator(exp, pos)
elif exp[pos] in ('(', ')'):
next_token = exp[pos]
else:
raise value_error('Unrecognized character at position ' + str(pos))
tokens.append(next_token)
pos += 1
return tokens
def _read_next_value(exp, pos):
token = ''
while pos < len(exp) and (_is_number(exp[pos]) or exp[pos] == '.'):
token += exp[pos]
pos += 1
return (token, pos - 1)
def _read_next_operator(exp, pos):
token = ''
while pos < len(exp) and exp[pos] in op_chars:
token += exp[pos]
pos += 1
return (token, pos - 1)
def _to_number(str):
try:
return int(str)
except ValueError:
return float(str)
def _is_number(str):
try:
complex(str)
return True
except ValueError:
return False |
states = ["Washington", "Oregon", "California"]
for x in states:
print(x)
print("Washington" in states)
print("Tennessee" in states)
print("Washington" not in states)
states2 = ["Arizona", "Ohio", "Louisiana"]
best_states = states + states2
print(best_states)
print(best_states[1:3])
print(best_states[:2])
print(best_states[4:])
| states = ['Washington', 'Oregon', 'California']
for x in states:
print(x)
print('Washington' in states)
print('Tennessee' in states)
print('Washington' not in states)
states2 = ['Arizona', 'Ohio', 'Louisiana']
best_states = states + states2
print(best_states)
print(best_states[1:3])
print(best_states[:2])
print(best_states[4:]) |
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
##
# Calculates and display a restaurant bill with tax and tips
# @author: rafael magalhaes
# Tax Rate in percent
TAX = 8/100
# Tip percentage
TIP = 18/100
# Getting the meal value
print("Welcome to grand total restaurant app.")
meal_value = float(input("How much was the ordered total meal: "))
# calculate and display the grand total amount
tax_value = meal_value * TAX
tip_value = meal_value * TIP
grand_total = meal_value + tax_value + tip_value
print("\n\nGreat Meal! Your meal and total amount is:\n")
print("${:10,.2f} - Net meal ordered value".format(meal_value))
print("${:10,.2f} - State TAX of meal".format(tax_value))
print("${:10,.2f} - Suggested TIP of the meal".format(tip_value))
print("---------------------")
print("${:10,.2f} - Grand TOTAL\n".format(grand_total))
| tax = 8 / 100
tip = 18 / 100
print('Welcome to grand total restaurant app.')
meal_value = float(input('How much was the ordered total meal: '))
tax_value = meal_value * TAX
tip_value = meal_value * TIP
grand_total = meal_value + tax_value + tip_value
print('\n\nGreat Meal! Your meal and total amount is:\n')
print('${:10,.2f} - Net meal ordered value'.format(meal_value))
print('${:10,.2f} - State TAX of meal'.format(tax_value))
print('${:10,.2f} - Suggested TIP of the meal'.format(tip_value))
print('---------------------')
print('${:10,.2f} - Grand TOTAL\n'.format(grand_total)) |
# Topics
topics = {
# Letter A
"Amor post mortem" : ["Love beyond death.", "The nature of love is eternal, a bond that goes beyond physical death."]
, "Amor bonus" : ["Good love.", "The nature of love is good."]
, "Amor ferus" : ["Fiery love.", "A negative nature of the physical love, reference to passionate, rough sex."]
, "Amor mixtus" : ["Mix love.", "The complex nature of love when the physical and spiritual parts merge."]
# Letter B
, "Beatus ille" : ["Blissful thee.", "A praise to the simple life, farm and rural instead of the hustle of the modern life."]
# Letter C
, "Carpe diem" : ["Seize the day.", "To enjoy the present and not worry about the future; to live in the moment."]
, "Collige virgo rosas" : ["Grab the roses, virgin.", "The irrecoverable nature of youth and beauty; an invitation to enjoy love (represented in the symbol of a rose) before time takes away our youth."]
, "Contempus mundi" : ["Contempt to the world.", "Contempt to the world and the terrenal life, nothing but a valley of pain and tears."]
# Letter D
, "Descriptio puellae" : ["Description of a young girl.", "Description of a young girl in a descendant order, head, neck, chest, ..."]
, "Dum vivimus, vivamus" : ["While we're alive, we live.", "The idea of life as something transient and inalienable, hence an invitation to enjoy and seize it."]
# Letter F
, "Fugit irreparabile tempus" : ["Time passes irredeemably.", "The idea of time as something that cannot be recovered, life itself is fleeting and transient."]
, "Furor amoris" : ["Passionate love.", "The idea of love as a disease that negates all reason and logic."]
# Letter H
, "Homo viator" : ["Traveling man.", "The idea of the living man as an itinerant being, consider your existence as a journey through life."]
# Letter I
, "Ignis amoris" : ["The fire of love.", "The idea of love as a fire that burns inside you."]
# Letter L
, "Locus amoenus" : ["A nice scene.", "The mythical nature of the ideal scene described by its bucolic elements, almost always related to love."]
# Letter M
, "Memento mori" : ["Reminder of your death.", "Death is certain, the end of everyone's life, a reminder to never forget."]
, "Militia est vita hominis super terra" : ["The life of men on this earth is a struggle.", "The idea of life as a military thing, a field of war against everyone; society, other men, love, destiny, ..."]
, "Militia species amor est" : ["Love is a struggle.", "The idea of love as a struggle between the two lovers."]
# Letter O
, "Omnia mors aequat" : ["Death sets everyone equal.", "Death as an equality force, it doesn't care about hierarchy, richness or power; upon its arrival all humans are the same."]
, "Oculos Sicarii" : ["Murdering eyes.", "The idea of a stare that would kill you if it could."]
# Letter P
, "Peregrinatio vitae" : ["Life as a journey.", "The idea of life as a journey, a road which where the man must walk through."]
# Letter Q
, "Quodomo fabula, sic vita" : ["Life is like theater.", "The idea that life is a play with the man itself as protagonist."]
, "Quotidie morimur" : ["We die every day.", "Life has a determined time, by each moment that passes we're closer to the end of our journey which is death."]
# Letter R
, "Recusatio" : ["Rejection.", "Reject others values and actions."]
, "Religio amoris" : ["Worship love.", "Love is a cult which man is bound to serve, as such we must free ourselves from it."]
, "Ruit hora" : ["Time runs.", "By nature time is fleeting, hence life is too. As such we're running towards our inevitable death."]
# Letter S
, "Sic transit gloria mundi" : ["Glory is mundane and it passes by.", "Fortune, glory and reputation are all fleeting, death takes everything away."]
, "Somnium, imago mortis" : ["Sleep, an image of death.", "When a man sleeps it's as though he was dead."]
# Letter T
, "Theatrum mundi" : ["The world, a theater.", "The idea of the world and life as a play, think of them as different dramatic scenarios in which actors -mankind- represent their lives on an already written play."]
# Letter U
, "Ubi sunt" : ["Where are they?", "The idea of the unkown, beyond death nothing is certain."]
# Letter V
, "Vanitas vanitatis" : ["Vanity of vanities.", "Looks are decieving, human ambitions are vain, thus they should be rejected."]
, "Varium et mutabile semper femina" : ["Wayward and unsettled, women are.", "Women have a wayward nature, they change and never settle."]
, "Venatus amoris" : ["The hunt for love.", "Love is presented as a hunt, where one hunts for its lover."]
, "Vita flumen" : ["Life is a river.", "Existence is a river that always goes foward, never stopping, until it reaches the sea. Death."]
, "Vita somnium" : ["Life is a dream.", "Life is irreal, strange and fleeting, much like a dream."]
}
first_word = []
for phrase in topics:
templo = phrase.split(" ",1)[0].lower()
tempup = phrase.split(" ",1)[0].capitalize()
first_word.append(templo)
first_word.append(tempup) | topics = {'Amor post mortem': ['Love beyond death.', 'The nature of love is eternal, a bond that goes beyond physical death.'], 'Amor bonus': ['Good love.', 'The nature of love is good.'], 'Amor ferus': ['Fiery love.', 'A negative nature of the physical love, reference to passionate, rough sex.'], 'Amor mixtus': ['Mix love.', 'The complex nature of love when the physical and spiritual parts merge.'], 'Beatus ille': ['Blissful thee.', 'A praise to the simple life, farm and rural instead of the hustle of the modern life.'], 'Carpe diem': ['Seize the day.', 'To enjoy the present and not worry about the future; to live in the moment.'], 'Collige virgo rosas': ['Grab the roses, virgin.', 'The irrecoverable nature of youth and beauty; an invitation to enjoy love (represented in the symbol of a rose) before time takes away our youth.'], 'Contempus mundi': ['Contempt to the world.', 'Contempt to the world and the terrenal life, nothing but a valley of pain and tears.'], 'Descriptio puellae': ['Description of a young girl.', 'Description of a young girl in a descendant order, head, neck, chest, ...'], 'Dum vivimus, vivamus': ["While we're alive, we live.", 'The idea of life as something transient and inalienable, hence an invitation to enjoy and seize it.'], 'Fugit irreparabile tempus': ['Time passes irredeemably.', 'The idea of time as something that cannot be recovered, life itself is fleeting and transient.'], 'Furor amoris': ['Passionate love.', 'The idea of love as a disease that negates all reason and logic.'], 'Homo viator': ['Traveling man.', 'The idea of the living man as an itinerant being, consider your existence as a journey through life.'], 'Ignis amoris': ['The fire of love.', 'The idea of love as a fire that burns inside you.'], 'Locus amoenus': ['A nice scene.', 'The mythical nature of the ideal scene described by its bucolic elements, almost always related to love.'], 'Memento mori': ['Reminder of your death.', "Death is certain, the end of everyone's life, a reminder to never forget."], 'Militia est vita hominis super terra': ['The life of men on this earth is a struggle.', 'The idea of life as a military thing, a field of war against everyone; society, other men, love, destiny, ...'], 'Militia species amor est': ['Love is a struggle.', 'The idea of love as a struggle between the two lovers.'], 'Omnia mors aequat': ['Death sets everyone equal.', "Death as an equality force, it doesn't care about hierarchy, richness or power; upon its arrival all humans are the same."], 'Oculos Sicarii': ['Murdering eyes.', 'The idea of a stare that would kill you if it could.'], 'Peregrinatio vitae': ['Life as a journey.', 'The idea of life as a journey, a road which where the man must walk through.'], 'Quodomo fabula, sic vita': ['Life is like theater.', 'The idea that life is a play with the man itself as protagonist.'], 'Quotidie morimur': ['We die every day.', "Life has a determined time, by each moment that passes we're closer to the end of our journey which is death."], 'Recusatio': ['Rejection.', 'Reject others values and actions.'], 'Religio amoris': ['Worship love.', 'Love is a cult which man is bound to serve, as such we must free ourselves from it.'], 'Ruit hora': ['Time runs.', "By nature time is fleeting, hence life is too. As such we're running towards our inevitable death."], 'Sic transit gloria mundi': ['Glory is mundane and it passes by.', 'Fortune, glory and reputation are all fleeting, death takes everything away.'], 'Somnium, imago mortis': ['Sleep, an image of death.', "When a man sleeps it's as though he was dead."], 'Theatrum mundi': ['The world, a theater.', 'The idea of the world and life as a play, think of them as different dramatic scenarios in which actors -mankind- represent their lives on an already written play.'], 'Ubi sunt': ['Where are they?', 'The idea of the unkown, beyond death nothing is certain.'], 'Vanitas vanitatis': ['Vanity of vanities.', 'Looks are decieving, human ambitions are vain, thus they should be rejected.'], 'Varium et mutabile semper femina': ['Wayward and unsettled, women are.', 'Women have a wayward nature, they change and never settle.'], 'Venatus amoris': ['The hunt for love.', 'Love is presented as a hunt, where one hunts for its lover.'], 'Vita flumen': ['Life is a river.', 'Existence is a river that always goes foward, never stopping, until it reaches the sea. Death.'], 'Vita somnium': ['Life is a dream.', 'Life is irreal, strange and fleeting, much like a dream.']}
first_word = []
for phrase in topics:
templo = phrase.split(' ', 1)[0].lower()
tempup = phrase.split(' ', 1)[0].capitalize()
first_word.append(templo)
first_word.append(tempup) |
def xfail(fun, excp):
flag = False
try:
fun()
except excp:
flag = True
assert flag
| def xfail(fun, excp):
flag = False
try:
fun()
except excp:
flag = True
assert flag |
def reverse_words(text): # 7 kyu
reverse = []
words = text.split(' ')
for word in words:
reverse.append(word[::-1])
return ' '.join(reverse)
t = "This is an example!"
print(reverse_words(t)) | def reverse_words(text):
reverse = []
words = text.split(' ')
for word in words:
reverse.append(word[::-1])
return ' '.join(reverse)
t = 'This is an example!'
print(reverse_words(t)) |
with open('p11_grid.txt', 'r') as file:
lines = file.readlines()
n = []
for line in lines:
a = line.split(' ')
b = []
for i in a:
b.append(int(i))
n.append(b)
N = 0
for i in range(20):
for j in range(20):
horizontal, vertical, diag1, diag2 = 0, 0, 0, 0
if j < 17:
horizontal = n[i][j]*n[i][j+1]*n[i][j+2]*n[i][j+3]
if horizontal > N:
N = horizontal
if i < 17:
vertical = n[i][j]*n[i+1][j]*n[i+2][j]*n[i+3][j]
if vertical > N:
N = vertical
if i < 17 and j < 17:
diag1 = n[i][j]*n[i+1][j+1]*n[i+2][j+2]*n[i+3][j+3]
if diag1 > N:
N = diag1
if i > 3 and j < 17:
diag2 = n[i-1][j]*n[i-2][j+1]*n[i-3][j+2]*n[i-4][j+3]
if diag2 > N:
N = diag2
print(N)
| with open('p11_grid.txt', 'r') as file:
lines = file.readlines()
n = []
for line in lines:
a = line.split(' ')
b = []
for i in a:
b.append(int(i))
n.append(b)
n = 0
for i in range(20):
for j in range(20):
(horizontal, vertical, diag1, diag2) = (0, 0, 0, 0)
if j < 17:
horizontal = n[i][j] * n[i][j + 1] * n[i][j + 2] * n[i][j + 3]
if horizontal > N:
n = horizontal
if i < 17:
vertical = n[i][j] * n[i + 1][j] * n[i + 2][j] * n[i + 3][j]
if vertical > N:
n = vertical
if i < 17 and j < 17:
diag1 = n[i][j] * n[i + 1][j + 1] * n[i + 2][j + 2] * n[i + 3][j + 3]
if diag1 > N:
n = diag1
if i > 3 and j < 17:
diag2 = n[i - 1][j] * n[i - 2][j + 1] * n[i - 3][j + 2] * n[i - 4][j + 3]
if diag2 > N:
n = diag2
print(N) |
class BST:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
class TreeInfo:
def __init__(self, numberOfNodesVisited, latestVisitedNodeValue):
self.numberOfNodesVisited = numberOfNodesVisited
self.latestVisitedNodeValue = latestVisitedNodeValue
# O(h + k) time | O(h) space, where h is the height/depth and k the kth largest element.
def findKthLargestValueInBst(tree, k):
# To solve this problem, what we do is to traverse from right - visit - left. And when we reach a visit element we add a counter and
# keep track of it's value. We will add +1 every time until counter = k. We create a DS to store the treeInfo value
treeInfo = TreeInfo(0, -1)
reverseInOrderTraverse(tree, k, treeInfo)
return treeInfo.latestVisitedNodeValue
def reverseInOrderTraverse(node, k, treeInfo):
# base case, when the node is none or the number of nodes visited is equal to k, we simply return until
# find Kth largest value, where we return the latest visited node value.
if node == None or treeInfo.numberOfNodesVisited >= k:
return
# reverse in order: right - visited - left
reverseInOrderTraverse(node.right, k, treeInfo)
if treeInfo.numberOfNodesVisited < k:
treeInfo.numberOfNodesVisited += 1
treeInfo.latestVisitedNodeValue = node.value
# if numberOfNodesVisited is less than k, we want to return; but if is equal to k we don't want, we want to inmediately return
# otherwise it will update the value
reverseInOrderTraverse(node.left, k, treeInfo) | class Bst:
def __init__(self, value, left=None, right=None):
self.value = value
self.left = left
self.right = right
class Treeinfo:
def __init__(self, numberOfNodesVisited, latestVisitedNodeValue):
self.numberOfNodesVisited = numberOfNodesVisited
self.latestVisitedNodeValue = latestVisitedNodeValue
def find_kth_largest_value_in_bst(tree, k):
tree_info = tree_info(0, -1)
reverse_in_order_traverse(tree, k, treeInfo)
return treeInfo.latestVisitedNodeValue
def reverse_in_order_traverse(node, k, treeInfo):
if node == None or treeInfo.numberOfNodesVisited >= k:
return
reverse_in_order_traverse(node.right, k, treeInfo)
if treeInfo.numberOfNodesVisited < k:
treeInfo.numberOfNodesVisited += 1
treeInfo.latestVisitedNodeValue = node.value
reverse_in_order_traverse(node.left, k, treeInfo) |
n = int(input())
count = 0
a_prev, b_prev = -1, 0
for _ in range(n):
a, b = map(int, input().split())
start = max(a_prev, b_prev)
end = min(a, b)
if end >= start:
count += end - start + 1
if a_prev == b_prev:
count -= 1
a_prev, b_prev = a, b
print(count)
| n = int(input())
count = 0
(a_prev, b_prev) = (-1, 0)
for _ in range(n):
(a, b) = map(int, input().split())
start = max(a_prev, b_prev)
end = min(a, b)
if end >= start:
count += end - start + 1
if a_prev == b_prev:
count -= 1
(a_prev, b_prev) = (a, b)
print(count) |
# Copyright 2021 by Saithalavi M, saithalavi@gmail.com
# All rights reserved.
# This file is part of the Nessaid readline Framework, nessaid_readline python package
# and is released under the "MIT License Agreement". Please see the LICENSE
# file included as part of this package.
#
# common
CR = "\x0d"
LF = "\x0a"
BACKSPACE = "\x7f"
SPACE = "\x20"
TAB = "\x09"
ESC = "\x1b"
INSERT = "\x1b\x5b\x32\x7e"
DELETE = "\x1b\x5b\x33\x7e"
PAGE_UP = "\x1b\x5b\x35\x7e"
PAGE_DOWN = "\x1b\x5b\x36\x7e"
HOME = "\x1b\x5b\x48"
END = "\x1b\x5b\x46"
# cursors
UP = "\x1b\x5b\x41"
DOWN = "\x1b\x5b\x42"
LEFT = "\x1b\x5b\x44"
RIGHT = "\x1b\x5b\x43"
# CTRL
CTRL_A = '\x01'
CTRL_B = '\x02'
CTRL_C = '\x03'
CTRL_D = '\x04'
CTRL_E = '\x05'
CTRL_F = '\x06'
CTRL_G = '\x07'
# CTRL_H is '\x08', '\b', BACKSPACE
# CTRL_I is '\x09', '\t', TAB
# CTRL_J is '\x0a', '\n', LF
CTRL_K = '\x0b'
CTRL_L = '\x0c'
# CTRL_M is '\x0d', '\r', CR
CTRL_N = '\x0e'
CTRL_O = '\x0f'
CTRL_P = '\x10'
CTRL_Q = '\x11'
CTRL_R = '\x12'
CTRL_S = '\x13'
CTRL_T = '\x14'
CTRL_U = '\x15'
CTRL_V = '\x16'
CTRL_W = '\x17'
CTRL_X = '\x18'
CTRL_Y = '\x19'
CTRL_Z = '\x1a'
# ALT
ALT_A = "\x1b" + 'a'
ALT_B = "\x1b" + 'b'
ALT_C = "\x1b" + 'c'
ALT_D = "\x1b" + 'd'
ALT_E = "\x1b" + 'e'
ALT_F = "\x1b" + 'f'
ALT_G = "\x1b" + 'g'
ALT_H = "\x1b" + 'h'
ALT_I = "\x1b" + 'i'
ALT_J = "\x1b" + 'j'
ALT_K = "\x1b" + 'k'
ALT_L = "\x1b" + 'l'
ALT_M = "\x1b" + 'm'
ALT_N = "\x1b" + 'n'
ALT_O = "\x1b" + 'o'
ALT_P = "\x1b" + 'p'
ALT_Q = "\x1b" + 'q'
ALT_R = "\x1b" + 'r'
ALT_S = "\x1b" + 's'
ALT_T = "\x1b" + 't'
ALT_U = "\x1b" + 'u'
ALT_V = "\x1b" + 'v'
ALT_W = "\x1b" + 'w'
ALT_X = "\x1b" + 'x'
ALT_Y = "\x1b" + 'y'
ALT_Z = "\x1b" + 'z'
# CTRL + ALT
CTRL_ALT_A = "\x1b" + CTRL_A
CTRL_ALT_B = "\x1b" + CTRL_B
CTRL_ALT_C = "\x1b" + CTRL_C
CTRL_ALT_D = "\x1b" + CTRL_D
CTRL_ALT_E = "\x1b" + CTRL_E
CTRL_ALT_F = "\x1b" + CTRL_F
CTRL_ALT_G = "\x1b" + CTRL_G
CTRL_ALT_H = "\x1b" + '\x08'
CTRL_ALT_I = "\x1b" + '\x09'
CTRL_ALT_J = "\x1b" + '\x0a'
CTRL_ALT_K = "\x1b" + CTRL_K
CTRL_ALT_L = "\x1b" + CTRL_L
CTRL_ALT_M = "\x1b" + '\x0d'
CTRL_ALT_N = "\x1b" + CTRL_N
CTRL_ALT_O = "\x1b" + CTRL_O
CTRL_ALT_P = "\x1b" + CTRL_P
CTRL_ALT_Q = "\x1b" + CTRL_Q
CTRL_ALT_R = "\x1b" + CTRL_R
CTRL_ALT_S = "\x1b" + CTRL_S
CTRL_ALT_T = "\x1b" + CTRL_T
CTRL_ALT_U = "\x1b" + CTRL_U
CTRL_ALT_V = "\x1b" + CTRL_V
CTRL_ALT_W = "\x1b" + CTRL_W
CTRL_ALT_X = "\x1b" + CTRL_X
CTRL_ALT_Y = "\x1b" + CTRL_Y
CTRL_ALT_Z = "\x1b" + CTRL_Z
CTRL_ALT_DELETE = "\x1b\x5b\x33\x5e"
KEY_NAME_MAP = {
"cr": CR,
"lf": LF,
"tab": TAB,
"page-up": PAGE_UP,
"page-down": PAGE_DOWN,
"insert": INSERT,
"delete": DELETE,
"backspace": BACKSPACE,
"home": HOME,
"end": END,
"left": LEFT,
"right": RIGHT,
"up": UP,
"down": DOWN,
"esc": ESC,
"escape": ESC,
"ctrl-a": CTRL_A,
"ctrl-b": CTRL_B,
"ctrl-c": CTRL_C,
"ctrl-d": CTRL_D,
"ctrl-e": CTRL_E,
"ctrl-f": CTRL_F,
"ctrl-g": CTRL_G,
"ctrl-k": CTRL_K,
"ctrl-l": CTRL_L,
"ctrl-n": CTRL_N,
"ctrl-o": CTRL_O,
"ctrl-p": CTRL_P,
"ctrl-q": CTRL_Q,
"ctrl-r": CTRL_R,
"ctrl-s": CTRL_S,
"ctrl-t": CTRL_T,
"ctrl-u": CTRL_U,
"ctrl-v": CTRL_V,
"ctrl-w": CTRL_W,
"ctrl-x": CTRL_X,
"ctrl-y": CTRL_Y,
"ctrl-z": CTRL_Z,
"alt-a": ALT_A,
"alt-b": ALT_B,
"alt-c": ALT_C,
"alt-d": ALT_D,
"alt-e": ALT_E,
"alt-f": ALT_F,
"alt-g": ALT_G,
"alt-h": ALT_H,
"alt-i": ALT_I,
"alt-j": ALT_J,
"alt-k": ALT_K,
"alt-l": ALT_L,
"alt-m": ALT_M,
"alt-n": ALT_N,
"alt-o": ALT_O,
"alt-p": ALT_P,
"alt-q": ALT_Q,
"alt-r": ALT_R,
"alt-s": ALT_S,
"alt-t": ALT_T,
"alt-u": ALT_U,
"alt-v": ALT_V,
"alt-w": ALT_W,
"alt-x": ALT_X,
"alt-y": ALT_Y,
"alt-z": ALT_Z,
"ctrl-alt-a": CTRL_ALT_A,
"ctrl-alt-b": CTRL_ALT_B,
"ctrl-alt-c": CTRL_ALT_C,
"ctrl-alt-d": CTRL_ALT_D,
"ctrl-alt-e": CTRL_ALT_E,
"ctrl-alt-f": CTRL_ALT_F,
"ctrl-alt-g": CTRL_ALT_G,
"ctrl-alt-h": CTRL_ALT_H,
"ctrl-alt-i": CTRL_ALT_I,
"ctrl-alt-j": CTRL_ALT_J,
"ctrl-alt-k": CTRL_ALT_K,
"ctrl-alt-l": CTRL_ALT_L,
"ctrl-alt-m": CTRL_ALT_M,
"ctrl-alt-n": CTRL_ALT_N,
"ctrl-alt-o": CTRL_ALT_O,
"ctrl-alt-p": CTRL_ALT_P,
"ctrl-alt-q": CTRL_ALT_Q,
"ctrl-alt-r": CTRL_ALT_R,
"ctrl-alt-s": CTRL_ALT_S,
"ctrl-alt-t": CTRL_ALT_T,
"ctrl-alt-u": CTRL_ALT_U,
"ctrl-alt-v": CTRL_ALT_V,
"ctrl-alt-w": CTRL_ALT_W,
"ctrl-alt-x": CTRL_ALT_X,
"ctrl-alt-y": CTRL_ALT_Y,
"ctrl-alt-z": CTRL_ALT_Z,
"ctrl-alt-delete": CTRL_ALT_DELETE,
}
| cr = '\r'
lf = '\n'
backspace = '\x7f'
space = ' '
tab = '\t'
esc = '\x1b'
insert = '\x1b[2~'
delete = '\x1b[3~'
page_up = '\x1b[5~'
page_down = '\x1b[6~'
home = '\x1b[H'
end = '\x1b[F'
up = '\x1b[A'
down = '\x1b[B'
left = '\x1b[D'
right = '\x1b[C'
ctrl_a = '\x01'
ctrl_b = '\x02'
ctrl_c = '\x03'
ctrl_d = '\x04'
ctrl_e = '\x05'
ctrl_f = '\x06'
ctrl_g = '\x07'
ctrl_k = '\x0b'
ctrl_l = '\x0c'
ctrl_n = '\x0e'
ctrl_o = '\x0f'
ctrl_p = '\x10'
ctrl_q = '\x11'
ctrl_r = '\x12'
ctrl_s = '\x13'
ctrl_t = '\x14'
ctrl_u = '\x15'
ctrl_v = '\x16'
ctrl_w = '\x17'
ctrl_x = '\x18'
ctrl_y = '\x19'
ctrl_z = '\x1a'
alt_a = '\x1b' + 'a'
alt_b = '\x1b' + 'b'
alt_c = '\x1b' + 'c'
alt_d = '\x1b' + 'd'
alt_e = '\x1b' + 'e'
alt_f = '\x1b' + 'f'
alt_g = '\x1b' + 'g'
alt_h = '\x1b' + 'h'
alt_i = '\x1b' + 'i'
alt_j = '\x1b' + 'j'
alt_k = '\x1b' + 'k'
alt_l = '\x1b' + 'l'
alt_m = '\x1b' + 'm'
alt_n = '\x1b' + 'n'
alt_o = '\x1b' + 'o'
alt_p = '\x1b' + 'p'
alt_q = '\x1b' + 'q'
alt_r = '\x1b' + 'r'
alt_s = '\x1b' + 's'
alt_t = '\x1b' + 't'
alt_u = '\x1b' + 'u'
alt_v = '\x1b' + 'v'
alt_w = '\x1b' + 'w'
alt_x = '\x1b' + 'x'
alt_y = '\x1b' + 'y'
alt_z = '\x1b' + 'z'
ctrl_alt_a = '\x1b' + CTRL_A
ctrl_alt_b = '\x1b' + CTRL_B
ctrl_alt_c = '\x1b' + CTRL_C
ctrl_alt_d = '\x1b' + CTRL_D
ctrl_alt_e = '\x1b' + CTRL_E
ctrl_alt_f = '\x1b' + CTRL_F
ctrl_alt_g = '\x1b' + CTRL_G
ctrl_alt_h = '\x1b' + '\x08'
ctrl_alt_i = '\x1b' + '\t'
ctrl_alt_j = '\x1b' + '\n'
ctrl_alt_k = '\x1b' + CTRL_K
ctrl_alt_l = '\x1b' + CTRL_L
ctrl_alt_m = '\x1b' + '\r'
ctrl_alt_n = '\x1b' + CTRL_N
ctrl_alt_o = '\x1b' + CTRL_O
ctrl_alt_p = '\x1b' + CTRL_P
ctrl_alt_q = '\x1b' + CTRL_Q
ctrl_alt_r = '\x1b' + CTRL_R
ctrl_alt_s = '\x1b' + CTRL_S
ctrl_alt_t = '\x1b' + CTRL_T
ctrl_alt_u = '\x1b' + CTRL_U
ctrl_alt_v = '\x1b' + CTRL_V
ctrl_alt_w = '\x1b' + CTRL_W
ctrl_alt_x = '\x1b' + CTRL_X
ctrl_alt_y = '\x1b' + CTRL_Y
ctrl_alt_z = '\x1b' + CTRL_Z
ctrl_alt_delete = '\x1b[3^'
key_name_map = {'cr': CR, 'lf': LF, 'tab': TAB, 'page-up': PAGE_UP, 'page-down': PAGE_DOWN, 'insert': INSERT, 'delete': DELETE, 'backspace': BACKSPACE, 'home': HOME, 'end': END, 'left': LEFT, 'right': RIGHT, 'up': UP, 'down': DOWN, 'esc': ESC, 'escape': ESC, 'ctrl-a': CTRL_A, 'ctrl-b': CTRL_B, 'ctrl-c': CTRL_C, 'ctrl-d': CTRL_D, 'ctrl-e': CTRL_E, 'ctrl-f': CTRL_F, 'ctrl-g': CTRL_G, 'ctrl-k': CTRL_K, 'ctrl-l': CTRL_L, 'ctrl-n': CTRL_N, 'ctrl-o': CTRL_O, 'ctrl-p': CTRL_P, 'ctrl-q': CTRL_Q, 'ctrl-r': CTRL_R, 'ctrl-s': CTRL_S, 'ctrl-t': CTRL_T, 'ctrl-u': CTRL_U, 'ctrl-v': CTRL_V, 'ctrl-w': CTRL_W, 'ctrl-x': CTRL_X, 'ctrl-y': CTRL_Y, 'ctrl-z': CTRL_Z, 'alt-a': ALT_A, 'alt-b': ALT_B, 'alt-c': ALT_C, 'alt-d': ALT_D, 'alt-e': ALT_E, 'alt-f': ALT_F, 'alt-g': ALT_G, 'alt-h': ALT_H, 'alt-i': ALT_I, 'alt-j': ALT_J, 'alt-k': ALT_K, 'alt-l': ALT_L, 'alt-m': ALT_M, 'alt-n': ALT_N, 'alt-o': ALT_O, 'alt-p': ALT_P, 'alt-q': ALT_Q, 'alt-r': ALT_R, 'alt-s': ALT_S, 'alt-t': ALT_T, 'alt-u': ALT_U, 'alt-v': ALT_V, 'alt-w': ALT_W, 'alt-x': ALT_X, 'alt-y': ALT_Y, 'alt-z': ALT_Z, 'ctrl-alt-a': CTRL_ALT_A, 'ctrl-alt-b': CTRL_ALT_B, 'ctrl-alt-c': CTRL_ALT_C, 'ctrl-alt-d': CTRL_ALT_D, 'ctrl-alt-e': CTRL_ALT_E, 'ctrl-alt-f': CTRL_ALT_F, 'ctrl-alt-g': CTRL_ALT_G, 'ctrl-alt-h': CTRL_ALT_H, 'ctrl-alt-i': CTRL_ALT_I, 'ctrl-alt-j': CTRL_ALT_J, 'ctrl-alt-k': CTRL_ALT_K, 'ctrl-alt-l': CTRL_ALT_L, 'ctrl-alt-m': CTRL_ALT_M, 'ctrl-alt-n': CTRL_ALT_N, 'ctrl-alt-o': CTRL_ALT_O, 'ctrl-alt-p': CTRL_ALT_P, 'ctrl-alt-q': CTRL_ALT_Q, 'ctrl-alt-r': CTRL_ALT_R, 'ctrl-alt-s': CTRL_ALT_S, 'ctrl-alt-t': CTRL_ALT_T, 'ctrl-alt-u': CTRL_ALT_U, 'ctrl-alt-v': CTRL_ALT_V, 'ctrl-alt-w': CTRL_ALT_W, 'ctrl-alt-x': CTRL_ALT_X, 'ctrl-alt-y': CTRL_ALT_Y, 'ctrl-alt-z': CTRL_ALT_Z, 'ctrl-alt-delete': CTRL_ALT_DELETE} |
# The contents of this file is free and unencumbered software released into the
# public domain. For more information, please refer to <http://unlicense.org/>
manga_query = '''
query ($id: Int,$search: String) {
Page (perPage: 10) {
media (id: $id, type: MANGA,search: $search) {
id
title {
romaji
english
native
}
description (asHtml: false)
startDate{
year
}
type
format
status
siteUrl
averageScore
genres
bannerImage
}
}
}
''' | manga_query = '\nquery ($id: Int,$search: String) {\n Page (perPage: 10) {\n media (id: $id, type: MANGA,search: $search) {\n id\n title {\n romaji\n english\n native\n }\n description (asHtml: false)\n startDate{\n year\n }\n type\n format\n status\n siteUrl\n averageScore\n genres\n bannerImage\n }\n }\n}\n' |
# this code will accept an input string and check if it is a plandrome
# it will then return true if it is a plaindrome and false if it is not
def reverse(str1):
if(len(str1) == 0):
return str1
else:
return reverse(str1[1:]) + str1[0]
string = input("Please enter your own String : ")
# check for strings
str1 = reverse(string)
print("String in reverse Order : ", str1)
if(string == str1):
print("This is a Palindrome String")
else:
print("This is Not a Palindrome String")
| def reverse(str1):
if len(str1) == 0:
return str1
else:
return reverse(str1[1:]) + str1[0]
string = input('Please enter your own String : ')
str1 = reverse(string)
print('String in reverse Order : ', str1)
if string == str1:
print('This is a Palindrome String')
else:
print('This is Not a Palindrome String') |
ticket_dict1 = {
"pagination": {
"object_count": 2,
"continuation": None,
"page_count": 1,
"page_size": 50,
"has_more_items": False,
"page_number": 1
},
"ticket_classes": [
{
"actual_cost": None,
"actual_fee": {
"display": "$7.72",
"currency": "USD",
"value": 772,
"major_value": "7.72"
},
"cost": {
"display": "$100.00",
"currency": "USD",
"value": 10000,
"major_value": "100.00"
},
"fee": {
"display": "$7.72",
"currency": "USD",
"value": 772,
"major_value": "7.72"
},
"tax": {
"display": "$0.00",
"currency": "USD",
"value": 0,
"major_value": "0.00"
},
"resource_uri": "https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/567567567/",
"display_name": "Regular Price",
"name": "Regular Price",
"description": None,
"sorting": 1,
"donation": False,
"free": False,
"minimum_quantity": 1,
"maximum_quantity": 10,
"maximum_quantity_per_order": 10,
"on_sale_status": "AVAILABLE",
"has_pdf_ticket": True,
"order_confirmation_message": None,
"delivery_methods": [
"electronic"
],
"category": "admission",
"sales_channels": [
"online",
"atd"
],
"secondary_assignment_enabled": False,
"event_id": "12122222111111",
"image_id": None,
"id": "278648077",
"capacity": 300,
"quantity_total": 300,
"quantity_sold": 0,
"sales_start": "2021-06-02T04:00:00Z",
"sales_end": "2021-09-03T19:00:00Z",
"sales_end_relative": None,
"hidden": False,
"hidden_currently": False,
"include_fee": False,
"split_fee": False,
"hide_description": True,
"hide_sale_dates": False,
"auto_hide": False,
"payment_constraints": []
},
{
"actual_cost": None,
"actual_fee": None,
"cost": None,
"fee": None,
"tax": None,
"resource_uri": "https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/678678678/",
"display_name": "Super Special Free Admission",
"name": "Super Special Free Admission",
"description": None,
"sorting": 2,
"donation": False,
"free": True,
"minimum_quantity": 1,
"maximum_quantity": 1,
"maximum_quantity_per_order": 1,
"on_sale_status": "AVAILABLE",
"has_pdf_ticket": True,
"order_confirmation_message": None,
"delivery_methods": [
"electronic"
],
"category": "admission",
"sales_channels": [
"online",
"atd"
],
"secondary_assignment_enabled": False,
"event_id": "12122222111111",
"image_id": None,
"id": "278648079",
"capacity": 50,
"quantity_total": 50,
"quantity_sold": 0,
"sales_start": "2021-06-02T04:00:00Z",
"sales_end": "2021-09-03T19:00:00Z",
"sales_end_relative": None,
"hidden": True,
"hidden_currently": True,
"include_fee": False,
"split_fee": False,
"hide_description": True,
"hide_sale_dates": False,
"auto_hide": False,
"payment_constraints": []
}
]
}
ticket_dict2 = {
"pagination": {
"object_count": 2,
"continuation": None,
"page_count": 1,
"page_size": 50,
"has_more_items": False,
"page_number": 1
},
"ticket_classes": [
{
"actual_cost": None,
"actual_fee": {
"display": "$7.72",
"currency": "USD",
"value": 772,
"major_value": "7.72"
},
"cost": {
"display": "$100.00",
"currency": "USD",
"value": 10000,
"major_value": "100.00"
},
"fee": {
"display": "$7.72",
"currency": "USD",
"value": 772,
"major_value": "7.72"
},
"tax": {
"display": "$0.00",
"currency": "USD",
"value": 0,
"major_value": "0.00"
},
"resource_uri": "https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/3255985/",
"display_name": "Regular Price",
"name": "Regular Price",
"description": None,
"sorting": 1,
"donation": False,
"free": False,
"minimum_quantity": 1,
"maximum_quantity": 10,
"maximum_quantity_per_order": 10,
"on_sale_status": "AVAILABLE",
"has_pdf_ticket": True,
"order_confirmation_message": None,
"delivery_methods": [
"electronic"
],
"category": "admission",
"sales_channels": [
"online",
"atd"
],
"secondary_assignment_enabled": False,
"event_id": "2222333332323232",
"image_id": None,
"id": "278648077",
"capacity": 300,
"quantity_total": 300,
"quantity_sold": 0,
"sales_start": "2021-06-02T04:00:00Z",
"sales_end": "2021-09-03T19:00:00Z",
"sales_end_relative": None,
"hidden": False,
"hidden_currently": False,
"include_fee": False,
"split_fee": False,
"hide_description": True,
"hide_sale_dates": False,
"auto_hide": False,
"payment_constraints": []
},
{
"actual_cost": None,
"actual_fee": None,
"cost": None,
"fee": None,
"tax": None,
"resource_uri": "https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/890890890/",
"display_name": "Super Special Free Admission",
"name": "Super Special Free Admission",
"description": None,
"sorting": 2,
"donation": False,
"free": True,
"minimum_quantity": 1,
"maximum_quantity": 1,
"maximum_quantity_per_order": 1,
"on_sale_status": "AVAILABLE",
"has_pdf_ticket": True,
"order_confirmation_message": None,
"delivery_methods": [
"electronic"
],
"category": "admission",
"sales_channels": [
"online",
"atd"
],
"secondary_assignment_enabled": False,
"event_id": "2222333332323232",
"image_id": None,
"id": "278648079",
"capacity": 50,
"quantity_total": 50,
"quantity_sold": 0,
"sales_start": "2021-06-02T04:00:00Z",
"sales_end": "2021-09-03T19:00:00Z",
"sales_end_relative": None,
"hidden": True,
"hidden_currently": True,
"include_fee": False,
"split_fee": False,
"hide_description": True,
"hide_sale_dates": False,
"auto_hide": False,
"payment_constraints": []
}
]
}
ticket_dict3 = {
"pagination": {
"object_count": 2,
"continuation": None,
"page_count": 1,
"page_size": 50,
"has_more_items": False,
"page_number": 1
},
"ticket_classes": [
{
"actual_cost": None,
"actual_fee": {
"display": "$7.72",
"currency": "USD",
"value": 772,
"major_value": "7.72"
},
"cost": {
"display": "$100.00",
"currency": "USD",
"value": 10000,
"major_value": "100.00"
},
"fee": {
"display": "$7.72",
"currency": "USD",
"value": 772,
"major_value": "7.72"
},
"tax": {
"display": "$0.00",
"currency": "USD",
"value": 0,
"major_value": "0.00"
},
"resource_uri": "https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/098098098/",
"display_name": "Regular Price",
"name": "Regular Price",
"description": None,
"sorting": 1,
"donation": False,
"free": False,
"minimum_quantity": 1,
"maximum_quantity": 10,
"maximum_quantity_per_order": 10,
"on_sale_status": "AVAILABLE",
"has_pdf_ticket": True,
"order_confirmation_message": None,
"delivery_methods": [
"electronic"
],
"category": "admission",
"sales_channels": [
"online",
"atd"
],
"secondary_assignment_enabled": False,
"event_id": "44454545454545454",
"image_id": None,
"id": "278648077",
"capacity": 300,
"quantity_total": 300,
"quantity_sold": 0,
"sales_start": "2021-06-02T04:00:00Z",
"sales_end": "2021-09-03T19:00:00Z",
"sales_end_relative": None,
"hidden": False,
"hidden_currently": False,
"include_fee": False,
"split_fee": False,
"hide_description": True,
"hide_sale_dates": False,
"auto_hide": False,
"payment_constraints": []
},
{
"actual_cost": None,
"actual_fee": None,
"cost": None,
"fee": None,
"tax": None,
"resource_uri": "https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/987987987/",
"display_name": "Super Special Free Admission",
"name": "Super Special Free Admission",
"description": None,
"sorting": 2,
"donation": False,
"free": True,
"minimum_quantity": 1,
"maximum_quantity": 1,
"maximum_quantity_per_order": 1,
"on_sale_status": "AVAILABLE",
"has_pdf_ticket": True,
"order_confirmation_message": None,
"delivery_methods": [
"electronic"
],
"category": "admission",
"sales_channels": [
"online",
"atd"
],
"secondary_assignment_enabled": False,
"event_id": "44454545454545454",
"image_id": None,
"id": "278648079",
"capacity": 50,
"quantity_total": 50,
"quantity_sold": 0,
"sales_start": "2021-06-02T04:00:00Z",
"sales_end": "2021-09-03T19:00:00Z",
"sales_end_relative": None,
"hidden": True,
"hidden_currently": True,
"include_fee": False,
"split_fee": False,
"hide_description": True,
"hide_sale_dates": False,
"auto_hide": False,
"payment_constraints": []
}
]
}
| ticket_dict1 = {'pagination': {'object_count': 2, 'continuation': None, 'page_count': 1, 'page_size': 50, 'has_more_items': False, 'page_number': 1}, 'ticket_classes': [{'actual_cost': None, 'actual_fee': {'display': '$7.72', 'currency': 'USD', 'value': 772, 'major_value': '7.72'}, 'cost': {'display': '$100.00', 'currency': 'USD', 'value': 10000, 'major_value': '100.00'}, 'fee': {'display': '$7.72', 'currency': 'USD', 'value': 772, 'major_value': '7.72'}, 'tax': {'display': '$0.00', 'currency': 'USD', 'value': 0, 'major_value': '0.00'}, 'resource_uri': 'https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/567567567/', 'display_name': 'Regular Price', 'name': 'Regular Price', 'description': None, 'sorting': 1, 'donation': False, 'free': False, 'minimum_quantity': 1, 'maximum_quantity': 10, 'maximum_quantity_per_order': 10, 'on_sale_status': 'AVAILABLE', 'has_pdf_ticket': True, 'order_confirmation_message': None, 'delivery_methods': ['electronic'], 'category': 'admission', 'sales_channels': ['online', 'atd'], 'secondary_assignment_enabled': False, 'event_id': '12122222111111', 'image_id': None, 'id': '278648077', 'capacity': 300, 'quantity_total': 300, 'quantity_sold': 0, 'sales_start': '2021-06-02T04:00:00Z', 'sales_end': '2021-09-03T19:00:00Z', 'sales_end_relative': None, 'hidden': False, 'hidden_currently': False, 'include_fee': False, 'split_fee': False, 'hide_description': True, 'hide_sale_dates': False, 'auto_hide': False, 'payment_constraints': []}, {'actual_cost': None, 'actual_fee': None, 'cost': None, 'fee': None, 'tax': None, 'resource_uri': 'https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/678678678/', 'display_name': 'Super Special Free Admission', 'name': 'Super Special Free Admission', 'description': None, 'sorting': 2, 'donation': False, 'free': True, 'minimum_quantity': 1, 'maximum_quantity': 1, 'maximum_quantity_per_order': 1, 'on_sale_status': 'AVAILABLE', 'has_pdf_ticket': True, 'order_confirmation_message': None, 'delivery_methods': ['electronic'], 'category': 'admission', 'sales_channels': ['online', 'atd'], 'secondary_assignment_enabled': False, 'event_id': '12122222111111', 'image_id': None, 'id': '278648079', 'capacity': 50, 'quantity_total': 50, 'quantity_sold': 0, 'sales_start': '2021-06-02T04:00:00Z', 'sales_end': '2021-09-03T19:00:00Z', 'sales_end_relative': None, 'hidden': True, 'hidden_currently': True, 'include_fee': False, 'split_fee': False, 'hide_description': True, 'hide_sale_dates': False, 'auto_hide': False, 'payment_constraints': []}]}
ticket_dict2 = {'pagination': {'object_count': 2, 'continuation': None, 'page_count': 1, 'page_size': 50, 'has_more_items': False, 'page_number': 1}, 'ticket_classes': [{'actual_cost': None, 'actual_fee': {'display': '$7.72', 'currency': 'USD', 'value': 772, 'major_value': '7.72'}, 'cost': {'display': '$100.00', 'currency': 'USD', 'value': 10000, 'major_value': '100.00'}, 'fee': {'display': '$7.72', 'currency': 'USD', 'value': 772, 'major_value': '7.72'}, 'tax': {'display': '$0.00', 'currency': 'USD', 'value': 0, 'major_value': '0.00'}, 'resource_uri': 'https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/3255985/', 'display_name': 'Regular Price', 'name': 'Regular Price', 'description': None, 'sorting': 1, 'donation': False, 'free': False, 'minimum_quantity': 1, 'maximum_quantity': 10, 'maximum_quantity_per_order': 10, 'on_sale_status': 'AVAILABLE', 'has_pdf_ticket': True, 'order_confirmation_message': None, 'delivery_methods': ['electronic'], 'category': 'admission', 'sales_channels': ['online', 'atd'], 'secondary_assignment_enabled': False, 'event_id': '2222333332323232', 'image_id': None, 'id': '278648077', 'capacity': 300, 'quantity_total': 300, 'quantity_sold': 0, 'sales_start': '2021-06-02T04:00:00Z', 'sales_end': '2021-09-03T19:00:00Z', 'sales_end_relative': None, 'hidden': False, 'hidden_currently': False, 'include_fee': False, 'split_fee': False, 'hide_description': True, 'hide_sale_dates': False, 'auto_hide': False, 'payment_constraints': []}, {'actual_cost': None, 'actual_fee': None, 'cost': None, 'fee': None, 'tax': None, 'resource_uri': 'https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/890890890/', 'display_name': 'Super Special Free Admission', 'name': 'Super Special Free Admission', 'description': None, 'sorting': 2, 'donation': False, 'free': True, 'minimum_quantity': 1, 'maximum_quantity': 1, 'maximum_quantity_per_order': 1, 'on_sale_status': 'AVAILABLE', 'has_pdf_ticket': True, 'order_confirmation_message': None, 'delivery_methods': ['electronic'], 'category': 'admission', 'sales_channels': ['online', 'atd'], 'secondary_assignment_enabled': False, 'event_id': '2222333332323232', 'image_id': None, 'id': '278648079', 'capacity': 50, 'quantity_total': 50, 'quantity_sold': 0, 'sales_start': '2021-06-02T04:00:00Z', 'sales_end': '2021-09-03T19:00:00Z', 'sales_end_relative': None, 'hidden': True, 'hidden_currently': True, 'include_fee': False, 'split_fee': False, 'hide_description': True, 'hide_sale_dates': False, 'auto_hide': False, 'payment_constraints': []}]}
ticket_dict3 = {'pagination': {'object_count': 2, 'continuation': None, 'page_count': 1, 'page_size': 50, 'has_more_items': False, 'page_number': 1}, 'ticket_classes': [{'actual_cost': None, 'actual_fee': {'display': '$7.72', 'currency': 'USD', 'value': 772, 'major_value': '7.72'}, 'cost': {'display': '$100.00', 'currency': 'USD', 'value': 10000, 'major_value': '100.00'}, 'fee': {'display': '$7.72', 'currency': 'USD', 'value': 772, 'major_value': '7.72'}, 'tax': {'display': '$0.00', 'currency': 'USD', 'value': 0, 'major_value': '0.00'}, 'resource_uri': 'https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/098098098/', 'display_name': 'Regular Price', 'name': 'Regular Price', 'description': None, 'sorting': 1, 'donation': False, 'free': False, 'minimum_quantity': 1, 'maximum_quantity': 10, 'maximum_quantity_per_order': 10, 'on_sale_status': 'AVAILABLE', 'has_pdf_ticket': True, 'order_confirmation_message': None, 'delivery_methods': ['electronic'], 'category': 'admission', 'sales_channels': ['online', 'atd'], 'secondary_assignment_enabled': False, 'event_id': '44454545454545454', 'image_id': None, 'id': '278648077', 'capacity': 300, 'quantity_total': 300, 'quantity_sold': 0, 'sales_start': '2021-06-02T04:00:00Z', 'sales_end': '2021-09-03T19:00:00Z', 'sales_end_relative': None, 'hidden': False, 'hidden_currently': False, 'include_fee': False, 'split_fee': False, 'hide_description': True, 'hide_sale_dates': False, 'auto_hide': False, 'payment_constraints': []}, {'actual_cost': None, 'actual_fee': None, 'cost': None, 'fee': None, 'tax': None, 'resource_uri': 'https://www.eventbriteapi.com/v3/events/158717222485/ticket_classes/987987987/', 'display_name': 'Super Special Free Admission', 'name': 'Super Special Free Admission', 'description': None, 'sorting': 2, 'donation': False, 'free': True, 'minimum_quantity': 1, 'maximum_quantity': 1, 'maximum_quantity_per_order': 1, 'on_sale_status': 'AVAILABLE', 'has_pdf_ticket': True, 'order_confirmation_message': None, 'delivery_methods': ['electronic'], 'category': 'admission', 'sales_channels': ['online', 'atd'], 'secondary_assignment_enabled': False, 'event_id': '44454545454545454', 'image_id': None, 'id': '278648079', 'capacity': 50, 'quantity_total': 50, 'quantity_sold': 0, 'sales_start': '2021-06-02T04:00:00Z', 'sales_end': '2021-09-03T19:00:00Z', 'sales_end_relative': None, 'hidden': True, 'hidden_currently': True, 'include_fee': False, 'split_fee': False, 'hide_description': True, 'hide_sale_dates': False, 'auto_hide': False, 'payment_constraints': []}]} |
# sorting
n=7
print(n)
arr=[5,1,1,2,10,2,1]
arr.sort()
for i in arr:
print(i,end=' ')
| n = 7
print(n)
arr = [5, 1, 1, 2, 10, 2, 1]
arr.sort()
for i in arr:
print(i, end=' ') |
n = int(input())
for _ in range(n):
(d, m) = map(int, input().split(' '))
days = list(map(int, input().split(' ')))
day_of_week = 0
friday_13s = 0
for month in range(m):
for day in range(1, days[month] + 1):
if day_of_week == 5 and day == 13:
friday_13s += 1
day_of_week = (day_of_week + 1) % 7
print(friday_13s)
| n = int(input())
for _ in range(n):
(d, m) = map(int, input().split(' '))
days = list(map(int, input().split(' ')))
day_of_week = 0
friday_13s = 0
for month in range(m):
for day in range(1, days[month] + 1):
if day_of_week == 5 and day == 13:
friday_13s += 1
day_of_week = (day_of_week + 1) % 7
print(friday_13s) |
f = open("13.txt", "r")
sum = 0
while (1):
num = 0
line = f.readline()
if line:
line = line.strip('\n')
for i in range(0, len(line)):
num = num * 10 + int(line[i])
sum += num
else:
break
ans = str(sum)
for i in range(0, 10):
print(ans[i], end = '') | f = open('13.txt', 'r')
sum = 0
while 1:
num = 0
line = f.readline()
if line:
line = line.strip('\n')
for i in range(0, len(line)):
num = num * 10 + int(line[i])
sum += num
else:
break
ans = str(sum)
for i in range(0, 10):
print(ans[i], end='') |
def getNewAddress():
pass
def pushRawP2PKHTxn():
pass
def pushRawP2SHTxn():
pass
def pushRawBareP2WPKHTxn():
pass
def pushRawBareP2WSHTxn():
pass
def pushRawP2SH_P2WPKHTxn():
pass
def pushRawP2SH_P2WSHTxn():
pass
def getSignedTxn():
pass
| def get_new_address():
pass
def push_raw_p2_pkh_txn():
pass
def push_raw_p2_sh_txn():
pass
def push_raw_bare_p2_wpkh_txn():
pass
def push_raw_bare_p2_wsh_txn():
pass
def push_raw_p2_sh_p2_wpkh_txn():
pass
def push_raw_p2_sh_p2_wsh_txn():
pass
def get_signed_txn():
pass |
# -*- coding:utf-8 -*-
# Author: hankcs
# Date: 2019-12-29 15:17
albert_models_google = {
'albert_base_zh': 'https://storage.googleapis.com/albert_models/albert_base_zh.tar.gz',
'albert_large_zh': 'https://storage.googleapis.com/albert_models/albert_large_zh.tar.gz',
'albert_xlarge_zh': 'https://storage.googleapis.com/albert_models/albert_xlarge_zh.tar.gz',
'albert_xxlarge_zh': 'https://storage.googleapis.com/albert_models/albert_xxlarge_zh.tar.gz',
}
| albert_models_google = {'albert_base_zh': 'https://storage.googleapis.com/albert_models/albert_base_zh.tar.gz', 'albert_large_zh': 'https://storage.googleapis.com/albert_models/albert_large_zh.tar.gz', 'albert_xlarge_zh': 'https://storage.googleapis.com/albert_models/albert_xlarge_zh.tar.gz', 'albert_xxlarge_zh': 'https://storage.googleapis.com/albert_models/albert_xxlarge_zh.tar.gz'} |
AWR_CONFIGS = {
"Ant-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.00005,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.2,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"HalfCheetah-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.00005,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.4,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"Hopper-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.0001,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.4,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"Humanoid-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.00001,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.4,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"LunarLander-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.0005,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_l2_weight": 0.001,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 100000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"LunarLanderContinuous-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.0001,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.2,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"Reacher-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.0001,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.2,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
},
"Walker2d-v2":
{
"actor_net_layers": [128, 64],
"actor_stepsize": 0.000025,
"actor_momentum": 0.9,
"actor_init_output_scale": 0.01,
"actor_batch_size": 256,
"actor_steps": 1000,
"action_std": 0.4,
"critic_net_layers": [128, 64],
"critic_stepsize": 0.01,
"critic_momentum": 0.9,
"critic_batch_size": 256,
"critic_steps": 200,
"discount": 0.99,
"samples_per_iter": 2048,
"replay_buffer_size": 50000,
"normalizer_samples": 300000,
"weight_clip": 20,
"td_lambda": 0.95,
"temp": 1.0,
}
} | awr_configs = {'Ant-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 5e-05, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.2, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'HalfCheetah-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 5e-05, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.4, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'Hopper-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 0.0001, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.4, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'Humanoid-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 1e-05, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.4, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'LunarLander-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 0.0005, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_l2_weight': 0.001, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 100000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'LunarLanderContinuous-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 0.0001, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.2, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'Reacher-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 0.0001, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.2, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}, 'Walker2d-v2': {'actor_net_layers': [128, 64], 'actor_stepsize': 2.5e-05, 'actor_momentum': 0.9, 'actor_init_output_scale': 0.01, 'actor_batch_size': 256, 'actor_steps': 1000, 'action_std': 0.4, 'critic_net_layers': [128, 64], 'critic_stepsize': 0.01, 'critic_momentum': 0.9, 'critic_batch_size': 256, 'critic_steps': 200, 'discount': 0.99, 'samples_per_iter': 2048, 'replay_buffer_size': 50000, 'normalizer_samples': 300000, 'weight_clip': 20, 'td_lambda': 0.95, 'temp': 1.0}} |
class MonoMacPackage (Package):
def __init__ (self):
self.pkgconfig_version = '1.0'
self.maccore_tag = '0b71453'
self.maccore_source_dir_name = 'mono-maccore-0b71453'
self.monomac_tag = 'ae428c7'
self.monomac_source_dir_name = 'mono-monomac-ae428c7'
Package.__init__ (self, 'monomac', self.monomac_tag)
self.sources = [
'https://github.com/mono/maccore/tarball/%{maccore_tag}',
'https://github.com/mono/monomac/tarball/%{monomac_tag}'
]
def prep (self):
self.sh ('tar xf "%{sources[0]}"')
self.sh ('tar xf "%{sources[1]}"')
self.sh ('mv %{maccore_source_dir_name} maccore')
self.sh ('mv %{monomac_source_dir_name} monomac')
self.cd ('monomac/src')
def build (self):
self.sh ('make')
def install (self):
self.sh ('mkdir -p %{prefix}/lib/monomac')
self.sh ('mkdir -p %{prefix}/share/pkgconfig')
self.sh ('echo "Libraries=%{prefix}/lib/monomac/MonoMac.dll\n\nName: MonoMac\nDescription: Mono Mac bindings\nVersion:%{pkgconfig_version}\nLibs: -r:%{prefix}/lib/monomac/MonoMac.dll" > %{prefix}/share/pkgconfig/monomac.pc')
self.sh ('cp MonoMac.dll %{prefix}/lib/monomac')
MonoMacPackage ()
| class Monomacpackage(Package):
def __init__(self):
self.pkgconfig_version = '1.0'
self.maccore_tag = '0b71453'
self.maccore_source_dir_name = 'mono-maccore-0b71453'
self.monomac_tag = 'ae428c7'
self.monomac_source_dir_name = 'mono-monomac-ae428c7'
Package.__init__(self, 'monomac', self.monomac_tag)
self.sources = ['https://github.com/mono/maccore/tarball/%{maccore_tag}', 'https://github.com/mono/monomac/tarball/%{monomac_tag}']
def prep(self):
self.sh('tar xf "%{sources[0]}"')
self.sh('tar xf "%{sources[1]}"')
self.sh('mv %{maccore_source_dir_name} maccore')
self.sh('mv %{monomac_source_dir_name} monomac')
self.cd('monomac/src')
def build(self):
self.sh('make')
def install(self):
self.sh('mkdir -p %{prefix}/lib/monomac')
self.sh('mkdir -p %{prefix}/share/pkgconfig')
self.sh('echo "Libraries=%{prefix}/lib/monomac/MonoMac.dll\n\nName: MonoMac\nDescription: Mono Mac bindings\nVersion:%{pkgconfig_version}\nLibs: -r:%{prefix}/lib/monomac/MonoMac.dll" > %{prefix}/share/pkgconfig/monomac.pc')
self.sh('cp MonoMac.dll %{prefix}/lib/monomac')
mono_mac_package() |
# flake8: noqa
# Disable all security
c.NotebookApp.token = ""
c.NotebookApp.password = ""
c.NotebookApp.open_browser = True
c.NotebookApp.ip = "localhost"
| c.NotebookApp.token = ''
c.NotebookApp.password = ''
c.NotebookApp.open_browser = True
c.NotebookApp.ip = 'localhost' |
A, B = map(int, input().split())
if A > 8 or B > 8:
print(":(")
else:
print("Yay!") | (a, b) = map(int, input().split())
if A > 8 or B > 8:
print(':(')
else:
print('Yay!') |
# Copyright 2021 Jake Arkinstall
#
# Work based on efforts copyrighted 2018 The Bazel Authors.
#
# 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.
load("//toolchain/internal:common.bzl", _python = "python")
# If a new Circle version is missing from this list, please add the details here
# and send a PR on github. To calculate the sha256, use
# ```
# curl -s https://www.circle-lang.org/linux/build_{X}.tgz | sha256sum
# ```
_circle_builds = {
"141": struct(
version = "141",
url = "https://www.circle-lang.org/linux/build_141.tgz",
sha256 = "90228ff369fb478bd4c0f86092725a22ec775924bdfff201cd4529ed9a969848",
),
"142": struct(
version = "142",
url = "https://www.circle-lang.org/linux/build_142.tgz",
sha256 = "fda3c2ea0f9bfb02e9627f1cb401e6f67a85a778c5ca26bd543101d51f274711",
),
}
def download_circle(rctx):
circle_version = str(rctx.attr.circle_version)
if circle_version not in _circle_builds:
fail("Circle version %s has not been configured in toolchain/internal/circle_builds.bzl" % circle_version)
spec = _circle_builds[circle_version]
rctx.download_and_extract(
spec.url,
sha256 = spec.sha256,
)
| load('//toolchain/internal:common.bzl', _python='python')
_circle_builds = {'141': struct(version='141', url='https://www.circle-lang.org/linux/build_141.tgz', sha256='90228ff369fb478bd4c0f86092725a22ec775924bdfff201cd4529ed9a969848'), '142': struct(version='142', url='https://www.circle-lang.org/linux/build_142.tgz', sha256='fda3c2ea0f9bfb02e9627f1cb401e6f67a85a778c5ca26bd543101d51f274711')}
def download_circle(rctx):
circle_version = str(rctx.attr.circle_version)
if circle_version not in _circle_builds:
fail('Circle version %s has not been configured in toolchain/internal/circle_builds.bzl' % circle_version)
spec = _circle_builds[circle_version]
rctx.download_and_extract(spec.url, sha256=spec.sha256) |
def add(matA,matB):
dimA = []
dimB = []
# find dimensions of arrA
a = matA
b = matB
while type(a) == list:
dimA.append(len(a))
a = a[0]
# find dimensions of arrB
while type(b) == list:
dimB.append(len(b))
b = b[0]
#is it possible to add them
if dimA != dimB:
raise Exception("dimension mismath {} != {}".format(dimA,dimB))
#add em together
newArr = [[0 for _ in range(dimA[1])] for _ in range(dimA[0])]
for i in range(dimA[0]):
for j in range(dimA[1]):
newArr[i][j] = matA[i][j] + matB[i][j]
return newArr | def add(matA, matB):
dim_a = []
dim_b = []
a = matA
b = matB
while type(a) == list:
dimA.append(len(a))
a = a[0]
while type(b) == list:
dimB.append(len(b))
b = b[0]
if dimA != dimB:
raise exception('dimension mismath {} != {}'.format(dimA, dimB))
new_arr = [[0 for _ in range(dimA[1])] for _ in range(dimA[0])]
for i in range(dimA[0]):
for j in range(dimA[1]):
newArr[i][j] = matA[i][j] + matB[i][j]
return newArr |
# This file contains code that can be used later which cannot fit in right now.
'''This is the function to run 'map'. This is paused so that PyCUDA can support dynamic parallelism.
if stmt.count('map') > 0:
self.kernel_final.append(kernel+"}")
start = stmt.index('map') + 2
declar = self.device_py[self.device_func_name.index(stmt[start])]
print declar, stmt
caller = stmt[start+1:-1]
called = declar[declar.index('('):-2]
print caller, called
end = len(stmt) - 1
map_name = "map_" + str(stmt[start])
print map_name
self.map_func.append(map_name)
# self.global_func.append(map_name)
kernel = "__device__ void " + map_name + "( "
args = []
# print self.device_py, self.device_sentences, self.device_func_name, self.device_var_nam, self.device_type_vars
for i in declar[3:-2]:
if i != ",":
args.append(i)
kernel += str(self.type_vars[self.var_nam.index(caller[called.index(i)])]) + " " + str(i) + ","
# print self.type_args, self.var_nam, self.type_args[self.var_nam.index(i)]
kernel += str(self.type_vars[self.var_nam.index(stmt[0])]) + " " + str(stmt[0])
kernel += "){\n" + "int tid = threadIdx.x + blockIdx.x * blockDim.x;\n"
shh = shlex.shlex(self.device_sentences[self.device_func_name.index(stmt[start])][0])
self.ismap.append(True)
print self.type_vars
kernel += stmt[0] + "[tid] = "
print self.device_sentences[self.device_func_name.index(stmt[start])]
if shh.get_token() == 'return':
j = shh.get_token()
while j is not shh.eof:
if j in args:
kernel += j + "[tid] "
else:
kernel += j
j = shh.get_token()
kernel += ";\n"
# print kernel
# print stmt[0]
print "Printing Kernel", kernel
return kernel'''
| """This is the function to run 'map'. This is paused so that PyCUDA can support dynamic parallelism.
if stmt.count('map') > 0:
self.kernel_final.append(kernel+"}")
start = stmt.index('map') + 2
declar = self.device_py[self.device_func_name.index(stmt[start])]
print declar, stmt
caller = stmt[start+1:-1]
called = declar[declar.index('('):-2]
print caller, called
end = len(stmt) - 1
map_name = "map_" + str(stmt[start])
print map_name
self.map_func.append(map_name)
# self.global_func.append(map_name)
kernel = "__device__ void " + map_name + "( "
args = []
# print self.device_py, self.device_sentences, self.device_func_name, self.device_var_nam, self.device_type_vars
for i in declar[3:-2]:
if i != ",":
args.append(i)
kernel += str(self.type_vars[self.var_nam.index(caller[called.index(i)])]) + " " + str(i) + ","
# print self.type_args, self.var_nam, self.type_args[self.var_nam.index(i)]
kernel += str(self.type_vars[self.var_nam.index(stmt[0])]) + " " + str(stmt[0])
kernel += "){
" + "int tid = threadIdx.x + blockIdx.x * blockDim.x;
"
shh = shlex.shlex(self.device_sentences[self.device_func_name.index(stmt[start])][0])
self.ismap.append(True)
print self.type_vars
kernel += stmt[0] + "[tid] = "
print self.device_sentences[self.device_func_name.index(stmt[start])]
if shh.get_token() == 'return':
j = shh.get_token()
while j is not shh.eof:
if j in args:
kernel += j + "[tid] "
else:
kernel += j
j = shh.get_token()
kernel += ";
"
# print kernel
# print stmt[0]
print "Printing Kernel", kernel
return kernel""" |
# Copyright 2017 Rice University
#
# 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 RetReverseMapper:
def __init__(self, vocab):
self.vocab = vocab
self.ret_type = []
self.num_data = 0
return
def add_data(self, ret_type):
self.ret_type.extend(ret_type)
self.num_data += len(ret_type)
def get_element(self, id):
return self.ret_type[id]
def decode_ret(self, ret_type):
print('--Ret Type--')
print(self.vocab.chars_type[ret_type])
def reset(self):
self.ret_type = []
self.num_data = 0 | class Retreversemapper:
def __init__(self, vocab):
self.vocab = vocab
self.ret_type = []
self.num_data = 0
return
def add_data(self, ret_type):
self.ret_type.extend(ret_type)
self.num_data += len(ret_type)
def get_element(self, id):
return self.ret_type[id]
def decode_ret(self, ret_type):
print('--Ret Type--')
print(self.vocab.chars_type[ret_type])
def reset(self):
self.ret_type = []
self.num_data = 0 |
names = []
children = []
with open("day7.txt") as f:
for line in f.readlines():
data = line.split('->')
names.append(data[0].split(" ")[0])
if len(data) == 2:
[x.strip() for x in data[1].split(',')]
children.append([x.strip() for x in data[1].split(',')])
children = [element for sublist in children for element in sublist]
print("Result = ", [x for x in names if x not in children])
| names = []
children = []
with open('day7.txt') as f:
for line in f.readlines():
data = line.split('->')
names.append(data[0].split(' ')[0])
if len(data) == 2:
[x.strip() for x in data[1].split(',')]
children.append([x.strip() for x in data[1].split(',')])
children = [element for sublist in children for element in sublist]
print('Result = ', [x for x in names if x not in children]) |
# Implementation of EA
def gcd(p, q):
while q != 0:
(p, q) = (q, p % q)
return p
# Implementation of the EEA
def extgcd(r0, r1):
u, v, s, t = 1, 0, 0, 1
# Swap arguments if r1 is smaller
if r1 < r0:
temp = r1
r1 = r0
r0 = temp
# While Loop to cumpute params
while r1 != 0:
q = r0//r1
r0, r1 = r1, r0-q*r1
u, s = s, u-q*s
v, t = t, v-q*t
return r0, u, v
# User Interface function
def main():
print("Geben sie r0 ein: ")
r0 = int(input())
print("Geben sie r1 ein: ")
r1 = int(input())
print("----- Ergebnis ----")
a1, u1, v1 = extgcd(r0, r1)
print("GCD: ", a1)
print("s: ", u1)
print("t: ", v1)
if __name__ == "__main__":
main() | def gcd(p, q):
while q != 0:
(p, q) = (q, p % q)
return p
def extgcd(r0, r1):
(u, v, s, t) = (1, 0, 0, 1)
if r1 < r0:
temp = r1
r1 = r0
r0 = temp
while r1 != 0:
q = r0 // r1
(r0, r1) = (r1, r0 - q * r1)
(u, s) = (s, u - q * s)
(v, t) = (t, v - q * t)
return (r0, u, v)
def main():
print('Geben sie r0 ein: ')
r0 = int(input())
print('Geben sie r1 ein: ')
r1 = int(input())
print('----- Ergebnis ----')
(a1, u1, v1) = extgcd(r0, r1)
print('GCD: ', a1)
print('s: ', u1)
print('t: ', v1)
if __name__ == '__main__':
main() |
year=int(input("Enter any year to check for leap year: "))
if year%4==0:
if year%100==0:
if year%400==0:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
else:
print("{0} is a leap year".format(year))
else:
print("{0} is not a leap year".format(year))
| year = int(input('Enter any year to check for leap year: '))
if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print('{0} is a leap year'.format(year))
else:
print('{0} is not a leap year'.format(year))
else:
print('{0} is a leap year'.format(year))
else:
print('{0} is not a leap year'.format(year)) |
s = input().strip()
while(s != '0'):
tam = len(s)
i = 1
anagrama = 1
while(i <= tam):
anagrama = anagrama * i
i = i + 1
print(anagrama)
s = input().strip() | s = input().strip()
while s != '0':
tam = len(s)
i = 1
anagrama = 1
while i <= tam:
anagrama = anagrama * i
i = i + 1
print(anagrama)
s = input().strip() |
#
# @lc app=leetcode.cn id=1587 lang=python3
#
# [1587] parallel-courses-ii
#
None
# @lc code=end | None |
class Solution:
def findComplement(self, num: int) -> int:
num = bin(num)[2:]
ans = ''
for i in num:
if i == "1":
ans += '0'
else:
ans += '1'
ans = int(ans, 2)
return ans | class Solution:
def find_complement(self, num: int) -> int:
num = bin(num)[2:]
ans = ''
for i in num:
if i == '1':
ans += '0'
else:
ans += '1'
ans = int(ans, 2)
return ans |
#
# PySNMP MIB module AT-PIM-MIB (http://snmplabs.com/pysmi)
# ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/AT-PIM-MIB
# Produced by pysmi-0.3.4 at Wed May 1 11:30:27 2019
# On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4
# Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15)
#
ObjectIdentifier, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString")
NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection, ConstraintsUnion = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "ConstraintsUnion")
modules, = mibBuilder.importSymbols("AT-SMI-MIB", "modules")
pimNeighborIfIndex, pimInterfaceStatus = mibBuilder.importSymbols("PIM-MIB", "pimNeighborIfIndex", "pimInterfaceStatus")
ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup")
IpAddress, Counter32, ModuleIdentity, TimeTicks, ObjectIdentity, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter64, Integer32, iso, Unsigned32, NotificationType, Bits, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Counter32", "ModuleIdentity", "TimeTicks", "ObjectIdentity", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter64", "Integer32", "iso", "Unsigned32", "NotificationType", "Bits", "Gauge32")
DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention")
pim4 = ModuleIdentity((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97))
pim4.setRevisions(('2005-01-20 15:25',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts: pim4.setRevisionsDescriptions(('Initial Revision',))
if mibBuilder.loadTexts: pim4.setLastUpdated('200501201525Z')
if mibBuilder.loadTexts: pim4.setOrganization('Allied Telesis, Inc')
if mibBuilder.loadTexts: pim4.setContactInfo('http://www.alliedtelesis.com')
if mibBuilder.loadTexts: pim4.setDescription('Contains definitions of managed objects for the handling PIM4 enterprise functions on AT switches. ')
pim4Events = MibIdentifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0))
pim4NeighbourAddedTrap = NotificationType((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 1)).setObjects(("PIM-MIB", "pimNeighborIfIndex"))
if mibBuilder.loadTexts: pim4NeighbourAddedTrap.setStatus('current')
if mibBuilder.loadTexts: pim4NeighbourAddedTrap.setDescription('A pim4NeighbourAddedTrap trap signifies that a PIM neighbour has been added')
pim4NeighbourDeletedTrap = NotificationType((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 2)).setObjects(("PIM-MIB", "pimNeighborIfIndex"))
if mibBuilder.loadTexts: pim4NeighbourDeletedTrap.setStatus('current')
if mibBuilder.loadTexts: pim4NeighbourDeletedTrap.setDescription('A pim4NeighbourDeletedTrap trap signifies that a PIM neighbour has been deleted')
pim4InterfaceUpTrap = NotificationType((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 3)).setObjects(("PIM-MIB", "pimInterfaceStatus"))
if mibBuilder.loadTexts: pim4InterfaceUpTrap.setStatus('current')
if mibBuilder.loadTexts: pim4InterfaceUpTrap.setDescription('A pimInterfaceUp trap signifies that a PIM interface has been enabled and is active')
pim4InterfaceDownTrap = NotificationType((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 4)).setObjects(("PIM-MIB", "pimInterfaceStatus"))
if mibBuilder.loadTexts: pim4InterfaceDownTrap.setStatus('current')
if mibBuilder.loadTexts: pim4InterfaceDownTrap.setDescription('A pimInterfaceDown trap signifies that a PIM interface has been disabled and is inactive')
pim4ErrorTrap = NotificationType((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 5)).setObjects(("AT-PIM-MIB", "pim4ErrorTrapType"))
if mibBuilder.loadTexts: pim4ErrorTrap.setStatus('current')
if mibBuilder.loadTexts: pim4ErrorTrap.setDescription('A pim4ErrorTrap trap is generated when a PIM error is incremented')
pim4ErrorTrapType = MibScalar((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=NamedValues(("pim4InvalidPacket", 1), ("pim4InvalidDestinationError", 2), ("pim4FragmentError", 3), ("pim4LengthError", 4), ("pim4GroupaddressError", 5), ("pim4SourceaddressError", 6), ("pim4MissingOptionError", 7), ("pim4GeneralError", 8), ("pim4InternalError", 9), ("pim4RpaddressError", 10)))).setMaxAccess("accessiblefornotify")
if mibBuilder.loadTexts: pim4ErrorTrapType.setStatus('current')
if mibBuilder.loadTexts: pim4ErrorTrapType.setDescription('The type of the last error that resulted in a error trap being sent. The default value is 0 if no errors have been detected')
mibBuilder.exportSymbols("AT-PIM-MIB", pim4InterfaceDownTrap=pim4InterfaceDownTrap, pim4NeighbourAddedTrap=pim4NeighbourAddedTrap, pim4ErrorTrap=pim4ErrorTrap, pim4InterfaceUpTrap=pim4InterfaceUpTrap, pim4NeighbourDeletedTrap=pim4NeighbourDeletedTrap, pim4=pim4, pim4Events=pim4Events, PYSNMP_MODULE_ID=pim4, pim4ErrorTrapType=pim4ErrorTrapType)
| (object_identifier, integer, octet_string) = mibBuilder.importSymbols('ASN1', 'ObjectIdentifier', 'Integer', 'OctetString')
(named_values,) = mibBuilder.importSymbols('ASN1-ENUMERATION', 'NamedValues')
(value_size_constraint, single_value_constraint, value_range_constraint, constraints_intersection, constraints_union) = mibBuilder.importSymbols('ASN1-REFINEMENT', 'ValueSizeConstraint', 'SingleValueConstraint', 'ValueRangeConstraint', 'ConstraintsIntersection', 'ConstraintsUnion')
(modules,) = mibBuilder.importSymbols('AT-SMI-MIB', 'modules')
(pim_neighbor_if_index, pim_interface_status) = mibBuilder.importSymbols('PIM-MIB', 'pimNeighborIfIndex', 'pimInterfaceStatus')
(module_compliance, notification_group) = mibBuilder.importSymbols('SNMPv2-CONF', 'ModuleCompliance', 'NotificationGroup')
(ip_address, counter32, module_identity, time_ticks, object_identity, mib_identifier, mib_scalar, mib_table, mib_table_row, mib_table_column, counter64, integer32, iso, unsigned32, notification_type, bits, gauge32) = mibBuilder.importSymbols('SNMPv2-SMI', 'IpAddress', 'Counter32', 'ModuleIdentity', 'TimeTicks', 'ObjectIdentity', 'MibIdentifier', 'MibScalar', 'MibTable', 'MibTableRow', 'MibTableColumn', 'Counter64', 'Integer32', 'iso', 'Unsigned32', 'NotificationType', 'Bits', 'Gauge32')
(display_string, textual_convention) = mibBuilder.importSymbols('SNMPv2-TC', 'DisplayString', 'TextualConvention')
pim4 = module_identity((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97))
pim4.setRevisions(('2005-01-20 15:25',))
if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0):
if mibBuilder.loadTexts:
pim4.setRevisionsDescriptions(('Initial Revision',))
if mibBuilder.loadTexts:
pim4.setLastUpdated('200501201525Z')
if mibBuilder.loadTexts:
pim4.setOrganization('Allied Telesis, Inc')
if mibBuilder.loadTexts:
pim4.setContactInfo('http://www.alliedtelesis.com')
if mibBuilder.loadTexts:
pim4.setDescription('Contains definitions of managed objects for the handling PIM4 enterprise functions on AT switches. ')
pim4_events = mib_identifier((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0))
pim4_neighbour_added_trap = notification_type((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 1)).setObjects(('PIM-MIB', 'pimNeighborIfIndex'))
if mibBuilder.loadTexts:
pim4NeighbourAddedTrap.setStatus('current')
if mibBuilder.loadTexts:
pim4NeighbourAddedTrap.setDescription('A pim4NeighbourAddedTrap trap signifies that a PIM neighbour has been added')
pim4_neighbour_deleted_trap = notification_type((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 2)).setObjects(('PIM-MIB', 'pimNeighborIfIndex'))
if mibBuilder.loadTexts:
pim4NeighbourDeletedTrap.setStatus('current')
if mibBuilder.loadTexts:
pim4NeighbourDeletedTrap.setDescription('A pim4NeighbourDeletedTrap trap signifies that a PIM neighbour has been deleted')
pim4_interface_up_trap = notification_type((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 3)).setObjects(('PIM-MIB', 'pimInterfaceStatus'))
if mibBuilder.loadTexts:
pim4InterfaceUpTrap.setStatus('current')
if mibBuilder.loadTexts:
pim4InterfaceUpTrap.setDescription('A pimInterfaceUp trap signifies that a PIM interface has been enabled and is active')
pim4_interface_down_trap = notification_type((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 4)).setObjects(('PIM-MIB', 'pimInterfaceStatus'))
if mibBuilder.loadTexts:
pim4InterfaceDownTrap.setStatus('current')
if mibBuilder.loadTexts:
pim4InterfaceDownTrap.setDescription('A pimInterfaceDown trap signifies that a PIM interface has been disabled and is inactive')
pim4_error_trap = notification_type((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 0, 5)).setObjects(('AT-PIM-MIB', 'pim4ErrorTrapType'))
if mibBuilder.loadTexts:
pim4ErrorTrap.setStatus('current')
if mibBuilder.loadTexts:
pim4ErrorTrap.setDescription('A pim4ErrorTrap trap is generated when a PIM error is incremented')
pim4_error_trap_type = mib_scalar((1, 3, 6, 1, 4, 1, 207, 8, 4, 4, 4, 97, 1), integer32().subtype(subtypeSpec=constraints_union(single_value_constraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))).clone(namedValues=named_values(('pim4InvalidPacket', 1), ('pim4InvalidDestinationError', 2), ('pim4FragmentError', 3), ('pim4LengthError', 4), ('pim4GroupaddressError', 5), ('pim4SourceaddressError', 6), ('pim4MissingOptionError', 7), ('pim4GeneralError', 8), ('pim4InternalError', 9), ('pim4RpaddressError', 10)))).setMaxAccess('accessiblefornotify')
if mibBuilder.loadTexts:
pim4ErrorTrapType.setStatus('current')
if mibBuilder.loadTexts:
pim4ErrorTrapType.setDescription('The type of the last error that resulted in a error trap being sent. The default value is 0 if no errors have been detected')
mibBuilder.exportSymbols('AT-PIM-MIB', pim4InterfaceDownTrap=pim4InterfaceDownTrap, pim4NeighbourAddedTrap=pim4NeighbourAddedTrap, pim4ErrorTrap=pim4ErrorTrap, pim4InterfaceUpTrap=pim4InterfaceUpTrap, pim4NeighbourDeletedTrap=pim4NeighbourDeletedTrap, pim4=pim4, pim4Events=pim4Events, PYSNMP_MODULE_ID=pim4, pim4ErrorTrapType=pim4ErrorTrapType) |
def create_phone_number(n):
return (f'({n[0]}{n[1]}{n[2]}) {n[3]}{n[4]}{n[5]}-{n[6]}{n[7]}{n[8]}{n[9]}')
# Best Practices
def create_phone_number(n):
print ("({}{}{}) {}{}{}-{}{}{}{}".format(*n))
| def create_phone_number(n):
return f'({n[0]}{n[1]}{n[2]}) {n[3]}{n[4]}{n[5]}-{n[6]}{n[7]}{n[8]}{n[9]}'
def create_phone_number(n):
print('({}{}{}) {}{}{}-{}{}{}{}'.format(*n)) |
class Class:
def __init__(self, name):
self.name = name
self.fields = []
def __str__(self):
lines = ['class %s:' % self.name]
if not self.fields:
lines.append(' pass')
else:
lines.append(' def __init__(self):')
for f in self.fields:
lines.append(' %s' % f)
return '\n'.join(lines)
| class Class:
def __init__(self, name):
self.name = name
self.fields = []
def __str__(self):
lines = ['class %s:' % self.name]
if not self.fields:
lines.append(' pass')
else:
lines.append(' def __init__(self):')
for f in self.fields:
lines.append(' %s' % f)
return '\n'.join(lines) |
class LCS:
def __init__(self,str1,str2):
self.str1=str1
self.str2=str2
self.m=len(str1)
self.n=len(str2)
self.dp = [[0 for x in range(self.n + 1)] for x in range(self.m + 1)]
def lcs_length(self):
for i in range(self.m):
for j in range(self.n):
if self.str1[i] == self.str2[j]:
self.dp[i+1][j+1]=self.dp[i][j]+1
else:
self.dp[i+1][j+1]=max(self.dp[i][j+1],self.dp[i+1][j])
return self.dp[-1][-1]
def lcs_sequence(self):
index = self.dp[self.m][self.n]
seq = [""] * (index+1)
seq[index] = ""
i,j = self.m,self.n
while i > 0 and j > 0:
if self.str1[i-1] == self.str2[j-1]:
seq[index-1] = self.str1[i-1]
i = i - 1
j = j - 1
index -= 1
elif self.dp[i][j-1] < self.dp[i-1][j]:
i = i - 1
else:
j = j - 1
seq_str=''.join(seq[:-1])
return seq_str
str1 = "CDEFGABC"
str2 = "CEFDABGAC"
MySeq=LCS(str1,str2)
print('Least Common Subsequence length-->',MySeq.lcs_length())
print('Least Common Subsequence-->',MySeq.lcs_sequence())
##OUTPUT:
'''
Least Common Subsequence length--> 6
Least Common Subsequence--> CEFABC
'''
| class Lcs:
def __init__(self, str1, str2):
self.str1 = str1
self.str2 = str2
self.m = len(str1)
self.n = len(str2)
self.dp = [[0 for x in range(self.n + 1)] for x in range(self.m + 1)]
def lcs_length(self):
for i in range(self.m):
for j in range(self.n):
if self.str1[i] == self.str2[j]:
self.dp[i + 1][j + 1] = self.dp[i][j] + 1
else:
self.dp[i + 1][j + 1] = max(self.dp[i][j + 1], self.dp[i + 1][j])
return self.dp[-1][-1]
def lcs_sequence(self):
index = self.dp[self.m][self.n]
seq = [''] * (index + 1)
seq[index] = ''
(i, j) = (self.m, self.n)
while i > 0 and j > 0:
if self.str1[i - 1] == self.str2[j - 1]:
seq[index - 1] = self.str1[i - 1]
i = i - 1
j = j - 1
index -= 1
elif self.dp[i][j - 1] < self.dp[i - 1][j]:
i = i - 1
else:
j = j - 1
seq_str = ''.join(seq[:-1])
return seq_str
str1 = 'CDEFGABC'
str2 = 'CEFDABGAC'
my_seq = lcs(str1, str2)
print('Least Common Subsequence length-->', MySeq.lcs_length())
print('Least Common Subsequence-->', MySeq.lcs_sequence())
'\nLeast Common Subsequence length--> 6\nLeast Common Subsequence--> CEFABC\n\n' |
################################################################################
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
## License as published by the Free Software Foundation; either
## version 2.1 of the License, or (at your option) any later version.
##
## This library is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public
## License along with this library; if not, write to the Free Software
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
##
## (C) Copyrights Dr. Michel F. Sanner and TSRI 2016
##
################################################################################
########################################################################
#
# Date: 2015 Authors: Michel Sanner
#
# sanner@scripps.edu
#
# The Scripps Research Institute (TSRI)
# Molecular Graphics Lab
# La Jolla, CA 92037, USA
#
# Copyright: Michel Sanner and TSRI 2015
#
#########################################################################
#
# $Header: /mnt/raid/services/cvs/python/packages/share1.5/mglutil/util/io.py,v 1.1.4.1 2017/07/26 22:31:38 annao Exp $
#
# $Id: io.py,v 1.1.4.1 2017/07/26 22:31:38 annao Exp $
#
class Stream:
def __init__(self):
self.lines = []
def write(self, line):
self.lines.append(line)
# helper class to make stdout set of lines look like a file that ProDy can parse
class BufferAsFile:
def __init__(self, lines):
self.lines = lines
def readlines(self):
return self.lines
| class Stream:
def __init__(self):
self.lines = []
def write(self, line):
self.lines.append(line)
class Bufferasfile:
def __init__(self, lines):
self.lines = lines
def readlines(self):
return self.lines |
# Copyright (c) 2019 The Bazel Utils Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
load("//:conditions.bzl", "if_windows")
load("//:warnings.bzl", "default_warnings")
###############################################################################
# warning
###############################################################################
# NOTE: Should be combiend wih safest_code_linkopts() in "linkopts.bzl"
def safest_code_copts():
return select({
"@com_chokobole_bazel_utils//:windows": [
"/W4",
],
"@com_chokobole_bazel_utils//:clang_or_clang_cl": [
"-Wextra",
],
"//conditions:default": [
"-Wall",
"-Werror",
],
}) + default_warnings()
# NOTE: Should be combiend wih safer_code_linkopts() in "linkopts.bzl"
def safer_code_copts():
return if_windows([
"/W3",
], [
"-Wall",
"-Werror",
]) + default_warnings()
###############################################################################
# symbol visibility
###############################################################################
def visibility_hidden():
return if_windows([], ["-fvisibility=hidden"])
###############################################################################
# sanitizers
###############################################################################
# NOTE: Should be combiend wih asan_linkopts() in "linkopts.bzl"
def asan_copts():
return ["-fsanitize=address"]
| load('//:conditions.bzl', 'if_windows')
load('//:warnings.bzl', 'default_warnings')
def safest_code_copts():
return select({'@com_chokobole_bazel_utils//:windows': ['/W4'], '@com_chokobole_bazel_utils//:clang_or_clang_cl': ['-Wextra'], '//conditions:default': ['-Wall', '-Werror']}) + default_warnings()
def safer_code_copts():
return if_windows(['/W3'], ['-Wall', '-Werror']) + default_warnings()
def visibility_hidden():
return if_windows([], ['-fvisibility=hidden'])
def asan_copts():
return ['-fsanitize=address'] |
fps = 60
game_duration = 120 # in sec
window_width = 1550
window_height = 800
| fps = 60
game_duration = 120
window_width = 1550
window_height = 800 |
def main():
ans = 1
for n in range(1, 501):
ans += f(n)
print(ans)
def f(n):
return 4 * (2 * n + 1)**2 - (12 * n)
if __name__ == '__main__':
main()
| def main():
ans = 1
for n in range(1, 501):
ans += f(n)
print(ans)
def f(n):
return 4 * (2 * n + 1) ** 2 - 12 * n
if __name__ == '__main__':
main() |
class A(object):
pass
print(A.__sizeof__)
# <ref> | class A(object):
pass
print(A.__sizeof__) |
#Write a Python program to print the following floating numbers upto 2 decimal places with a sign.
x = 3.1415926
y = 12.9999
a = float(+x)
b = float(-y)
print(round(a,2))
print(round(b,2)) | x = 3.1415926
y = 12.9999
a = float(+x)
b = float(-y)
print(round(a, 2))
print(round(b, 2)) |
# A place for secret local/dev environment settings
UNIFIED_DB = {
'ENGINE': 'django.db.backends.oracle',
'NAME': 'DB_NAME',
'USER': 'username',
'PASSWORD': 'password',
}
MONGODB_DATABASES = {
'default': {
'NAME': 'wtc-console',
'USER': 'root',
'PASSWORD': 'root',
}
}
| unified_db = {'ENGINE': 'django.db.backends.oracle', 'NAME': 'DB_NAME', 'USER': 'username', 'PASSWORD': 'password'}
mongodb_databases = {'default': {'NAME': 'wtc-console', 'USER': 'root', 'PASSWORD': 'root'}} |
# Definition for a binary tree node.
class TreeNode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def pseudoPalindromicPaths (self, root: TreeNode) -> int:
s = set()
def dfs(root):
if not root: return 0
if root.val in s:
s.discard(root.val)
else:
s.add(root.val)
res = dfs(root.left) + dfs(root.right)
if not root.left and not root.right:
res += len(s)<=1
if root.val in s:
s.discard(root.val)
else:
s.add(root.val)
return res
return dfs(root) | class Treenode:
def __init__(self, val=0, left=None, right=None):
self.val = val
self.left = left
self.right = right
class Solution:
def pseudo_palindromic_paths(self, root: TreeNode) -> int:
s = set()
def dfs(root):
if not root:
return 0
if root.val in s:
s.discard(root.val)
else:
s.add(root.val)
res = dfs(root.left) + dfs(root.right)
if not root.left and (not root.right):
res += len(s) <= 1
if root.val in s:
s.discard(root.val)
else:
s.add(root.val)
return res
return dfs(root) |
'''For 18 points, answer the following questions:
"Recursion" is when a function solves a problem by calling itself.
Recursive functions have at least 2 parts:
1. Base case - This is where the function is finished.
2. Recursive case (aka Induction case) - this is where the
function calls itself and gets closer to the base case.
'''
#The Fibonacci sequence is a classic example of a recursive function.
#The sequence is: 1,1,2,3,5,8,13,21,34,55, and so on.
#You calculate the sequence by starting with two numbers (such as 1,1)
#then you get the next number by adding the previous two numbers.
#Here it is as a recursive function.
def fibonacci(a,b,n):
'''a and b are the starting numbers. n is how deep into the
sequence you want to calculate.'''
if n==0:
return a+b
else:
return fibonacci(b,a+b,n-1)
#1. Which case (the if or the else) is the base case and which
#is the recursive case?
#2. Write code that uses the function to print out the first 8 numbers
#in the sequence.
#3. What error do you get if you pass a decimal as the third argument
#to the function?
#4. How can you fix that error?
#5. Write this function using loops.
#You can factor using recursion. Check it out.
#Note that start=2 defines an argument with a default value.
#For example: If I write factor(10) then start defaults at the value 2
#If I write: factor(81,3) then start takes the value 3.
def factor(number, start=2):
if start > number:
return []
elif number % start == 0:
return [start]+factor(number/start, start)
else:
return factor(number,start+1)
#6. Find all the factors of 360 using this function.
#7. There are three cases in factor. Which are the base case(s)?
#Which are the recursive case(s)?
| """For 18 points, answer the following questions:
"Recursion" is when a function solves a problem by calling itself.
Recursive functions have at least 2 parts:
1. Base case - This is where the function is finished.
2. Recursive case (aka Induction case) - this is where the
function calls itself and gets closer to the base case.
"""
def fibonacci(a, b, n):
"""a and b are the starting numbers. n is how deep into the
sequence you want to calculate."""
if n == 0:
return a + b
else:
return fibonacci(b, a + b, n - 1)
def factor(number, start=2):
if start > number:
return []
elif number % start == 0:
return [start] + factor(number / start, start)
else:
return factor(number, start + 1) |
'''
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Solution:
Copyright 2017 Dave Cuthbert
License MIT
'''
def find_multiples(factor, limit):
list_of_factors = []
for num in range(limit):
if num % factor == 0:
list_of_factors.append(num)
return list_of_factors
def sum_of_list(list_to_sum):
list_sum = 0
for i in list_to_sum:
list_sum += i
return list_sum
def clean_up_lists(list1, list2):
tmp_list = list1[:]
tmp_list.extend(list2)
return set(tmp_list)
def solve_problem(factor1, factor2, maximum):
list_factor_1 = find_multiples(factor1, maximum)
list_factor_2 = find_multiples(factor2, maximum)
return(sum_of_list(clean_up_lists(list_factor_1, list_factor_2)))
if __name__ == "__main__":
MAX_VALUE = 1000
LIST_FACTOR_1 = 3
LIST_FACTOR_2 = 5
print(solve_problem(LIST_FACTOR_1, LIST_FACTOR_2, MAX_VALUE))
| """
Problem 1
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Solution:
Copyright 2017 Dave Cuthbert
License MIT
"""
def find_multiples(factor, limit):
list_of_factors = []
for num in range(limit):
if num % factor == 0:
list_of_factors.append(num)
return list_of_factors
def sum_of_list(list_to_sum):
list_sum = 0
for i in list_to_sum:
list_sum += i
return list_sum
def clean_up_lists(list1, list2):
tmp_list = list1[:]
tmp_list.extend(list2)
return set(tmp_list)
def solve_problem(factor1, factor2, maximum):
list_factor_1 = find_multiples(factor1, maximum)
list_factor_2 = find_multiples(factor2, maximum)
return sum_of_list(clean_up_lists(list_factor_1, list_factor_2))
if __name__ == '__main__':
max_value = 1000
list_factor_1 = 3
list_factor_2 = 5
print(solve_problem(LIST_FACTOR_1, LIST_FACTOR_2, MAX_VALUE)) |
d1=['13CS10001','12CS30016','12CS30043','12CS30042','12CS30043','13CS10038','12CS30017','12CS30044','13CS10041','12CS30041','12CS30010',
'13CS10020','12CS30025','12CS30027','12CS30032','13CS10035','12CS30003','12CS30044','12CS30016','13CS10038','13CS10021','12CS30028',
'12CS30016','13CS10006','13CS10046','13CS10034','12CS30037','12CS30017','13CS10025','12CS30014','13CS10035','12CS30005','12CS30036']
d1s = set(d1)
print(len(d1))
print(len(d1s))
| d1 = ['13CS10001', '12CS30016', '12CS30043', '12CS30042', '12CS30043', '13CS10038', '12CS30017', '12CS30044', '13CS10041', '12CS30041', '12CS30010', '13CS10020', '12CS30025', '12CS30027', '12CS30032', '13CS10035', '12CS30003', '12CS30044', '12CS30016', '13CS10038', '13CS10021', '12CS30028', '12CS30016', '13CS10006', '13CS10046', '13CS10034', '12CS30037', '12CS30017', '13CS10025', '12CS30014', '13CS10035', '12CS30005', '12CS30036']
d1s = set(d1)
print(len(d1))
print(len(d1s)) |
# -*- coding: utf-8 -*-
def includeme(config):
config.add_route('index', '')
config.include(admin_include, '/admin')
config.include(post_include, '/post')
config.add_route('firework', '/firework')
config.add_route('baymax', '/baymax')
def admin_include(config):
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('all_posts', '/all_posts')
def post_include(config):
config.add_route('new_post', '/new_post')
config.add_route('post_detail', '/detail/{id}')
config.add_route('post_edit', '/edit/{id}')
config.add_route('post_delete', '/delete/{id}')
| def includeme(config):
config.add_route('index', '')
config.include(admin_include, '/admin')
config.include(post_include, '/post')
config.add_route('firework', '/firework')
config.add_route('baymax', '/baymax')
def admin_include(config):
config.add_route('login', '/login')
config.add_route('logout', '/logout')
config.add_route('all_posts', '/all_posts')
def post_include(config):
config.add_route('new_post', '/new_post')
config.add_route('post_detail', '/detail/{id}')
config.add_route('post_edit', '/edit/{id}')
config.add_route('post_delete', '/delete/{id}') |
def ada_int(f, a, b, tol=1.0e-6, n=5, N=10):
area = trapezoid(f, a, b, N)
check = trapezoid(f, a, b, n)
if abs(area - check) > tol:
# bad accuracy, add more points to interval
m = (b + a) / 2.0
area = ada_int(f, a, m) + ada_int(f, m, b)
return area
| def ada_int(f, a, b, tol=1e-06, n=5, N=10):
area = trapezoid(f, a, b, N)
check = trapezoid(f, a, b, n)
if abs(area - check) > tol:
m = (b + a) / 2.0
area = ada_int(f, a, m) + ada_int(f, m, b)
return area |
# -*- coding:utf-8 -*-
# @Script: array_partition_1.py
# @Author: Pradip Patil
# @Contact: @pradip__patil
# @Created: 2019-03-20 23:06:35
# @Last Modified By: Pradip Patil
# @Last Modified: 2019-03-21 21:07:13
# @Description: https://leetcode.com/problems/array-partition-i/
'''
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible.
Example 1:
Input: [1,4,3,2]
Output: 4
Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, 2) + min(3, 4).
Note:
n is a positive integer, which is in the range of [1, 10000].
All the integers in the array will be in the range of [-10000, 10000].
'''
class Solution:
def arrayPairSum(self, nums):
return sum(sorted(nums)[::2])
if __name__ == "__main__":
print(Solution().arrayPairSum([1, 4, 3, 2]))
print(Solution().arrayPairSum([]))
| """
Given an array of 2n integers, your task is to group these integers into n pairs of integer, say (a1, b1), (a2, b2), ..., (an, bn) which makes sum of min(ai, bi) for all i from 1 to n as large as possible.
Example 1:
Input: [1,4,3,2]
Output: 4
Explanation: n is 2, and the maximum sum of pairs is 4 = min(1, 2) + min(3, 4).
Note:
n is a positive integer, which is in the range of [1, 10000].
All the integers in the array will be in the range of [-10000, 10000].
"""
class Solution:
def array_pair_sum(self, nums):
return sum(sorted(nums)[::2])
if __name__ == '__main__':
print(solution().arrayPairSum([1, 4, 3, 2]))
print(solution().arrayPairSum([])) |
# Options
class SimpleOpt():
def __init__(self):
self.method = 'gvae'
self.graph_type = 'ENZYMES'
self.data_dir = './data/ENZYMES_20-50_res.graphs'
self.emb_size = 8
self.encode_dim = 32
self.layer_num = 3
self.decode_dim = 32
self.dropout = 0.5
self.logits = 10
# self.adj_thresh = 0.6
self.max_epochs = 50
self.lr = 0.003
self.gpu = '2'
self.batch_size = 56
self.epochs_log = 1
# self.DATA_DIR = './data/dblp/'
# self.output_dir = './output/'
class Options():
def __init__(self):
self.opt_type = 'simple'
# self.opt_type = 'argparser
@staticmethod
def initialize(epoch_num=1800):
opt = SimpleOpt()
opt.max_epochs = epoch_num
return opt
| class Simpleopt:
def __init__(self):
self.method = 'gvae'
self.graph_type = 'ENZYMES'
self.data_dir = './data/ENZYMES_20-50_res.graphs'
self.emb_size = 8
self.encode_dim = 32
self.layer_num = 3
self.decode_dim = 32
self.dropout = 0.5
self.logits = 10
self.max_epochs = 50
self.lr = 0.003
self.gpu = '2'
self.batch_size = 56
self.epochs_log = 1
class Options:
def __init__(self):
self.opt_type = 'simple'
@staticmethod
def initialize(epoch_num=1800):
opt = simple_opt()
opt.max_epochs = epoch_num
return opt |
set_name(0x8013570C, "PresOnlyTestRoutine__Fv", SN_NOWARN)
set_name(0x80135734, "FeInitBuffer__Fv", SN_NOWARN)
set_name(0x80135760, "FeAddEntry__Fii8TXT_JUSTUsP7FeTableP5CFont", SN_NOWARN)
set_name(0x801357E4, "FeAddTable__FP11FeMenuTablei", SN_NOWARN)
set_name(0x80135860, "FeAddNameTable__FPUci", SN_NOWARN)
set_name(0x80135988, "FeDrawBuffer__Fv", SN_NOWARN)
set_name(0x80135FB4, "FeNewMenu__FP7FeTable", SN_NOWARN)
set_name(0x80136034, "FePrevMenu__Fv", SN_NOWARN)
set_name(0x8013617C, "FeSelUp__Fi", SN_NOWARN)
set_name(0x80136264, "FeSelDown__Fi", SN_NOWARN)
set_name(0x8013634C, "FeGetCursor__Fv", SN_NOWARN)
set_name(0x80136360, "FeSelect__Fv", SN_NOWARN)
set_name(0x801363B0, "FeMainKeyCtrl__FP7CScreen", SN_NOWARN)
set_name(0x80136578, "InitDummyMenu__Fv", SN_NOWARN)
set_name(0x80136580, "InitFrontEnd__FP9FE_CREATE", SN_NOWARN)
set_name(0x801366A0, "FeInitMainMenu__Fv", SN_NOWARN)
set_name(0x8013671C, "FeInitNewGameMenu__Fv", SN_NOWARN)
set_name(0x801367D0, "FeNewGameMenuCtrl__Fv", SN_NOWARN)
set_name(0x80136984, "FeInitPlayer1ClassMenu__Fv", SN_NOWARN)
set_name(0x80136A08, "FeInitPlayer2ClassMenu__Fv", SN_NOWARN)
set_name(0x80136A8C, "FePlayerClassMenuCtrl__Fv", SN_NOWARN)
set_name(0x80136AD4, "FeDrawChrClass__Fv", SN_NOWARN)
set_name(0x80136F6C, "FeInitNewP1NameMenu__Fv", SN_NOWARN)
set_name(0x80136FC8, "FeInitNewP2NameMenu__Fv", SN_NOWARN)
set_name(0x8013701C, "FeNewNameMenuCtrl__Fv", SN_NOWARN)
set_name(0x801375E4, "FeCopyPlayerInfoForReturn__Fv", SN_NOWARN)
set_name(0x80137710, "FeEnterGame__Fv", SN_NOWARN)
set_name(0x80137738, "FeInitLoadMemcardSelect__Fv", SN_NOWARN)
set_name(0x801377B8, "FeInitLoadChar1Menu__Fv", SN_NOWARN)
set_name(0x80137820, "FeInitLoadChar2Menu__Fv", SN_NOWARN)
set_name(0x80137890, "FeInitDifficultyMenu__Fv", SN_NOWARN)
set_name(0x80137934, "FeDifficultyMenuCtrl__Fv", SN_NOWARN)
set_name(0x80137A20, "FeInitBackgroundMenu__Fv", SN_NOWARN)
set_name(0x80137A6C, "FeInitBook1Menu__Fv", SN_NOWARN)
set_name(0x80137ABC, "FeInitBook2Menu__Fv", SN_NOWARN)
set_name(0x80137B0C, "FeBackBookMenuCtrl__Fv", SN_NOWARN)
set_name(0x80137D50, "PlayDemo__Fv", SN_NOWARN)
set_name(0x80137D64, "FadeFEOut__Fv", SN_NOWARN)
set_name(0x80137E28, "DrawBackTSK__FP4TASK", SN_NOWARN)
set_name(0x80137FB0, "FeInitMainStuff__FP4TASK", SN_NOWARN)
set_name(0x8013805C, "FrontEndTask__FP4TASK", SN_NOWARN)
set_name(0x80138508, "DrawFeTwinkle__Fii", SN_NOWARN)
set_name(0x801385E4, "___6Dialog", SN_NOWARN)
set_name(0x8013860C, "__6Dialog", SN_NOWARN)
set_name(0x8013868C, "GetOverlayOtBase__7CBlocks", SN_NOWARN)
set_name(0x80138694, "CheckActive__4CPad", SN_NOWARN)
set_name(0x80138CB0, "InitCredits__Fv", SN_NOWARN)
set_name(0x80138D44, "PrintCredits__Fiiiiii", SN_NOWARN)
set_name(0x80139574, "DrawCreditsTitle__Fiiiii", SN_NOWARN)
set_name(0x8013962C, "DrawCreditsSubTitle__Fiiiii", SN_NOWARN)
set_name(0x801396E4, "CredCountNL__Fi", SN_NOWARN)
set_name(0x80139750, "DoCredits__Fv", SN_NOWARN)
set_name(0x80139B38, "PRIM_GetPrim__FPP8POLY_FT4", SN_NOWARN)
set_name(0x80139BB4, "ClearFont__5CFont", SN_NOWARN)
set_name(0x80139BD8, "GetCharHeight__5CFontUc", SN_NOWARN)
set_name(0x80139C18, "___7CScreen", SN_NOWARN)
set_name(0x80139C38, "GetFr__7TextDati", SN_NOWARN)
set_name(0x8013E1F4, "endian_swap__FPUci", SN_NOWARN)
set_name(0x8013E228, "sjis_endian_swap__FPUci", SN_NOWARN)
set_name(0x8013E270, "to_sjis__Fc", SN_NOWARN)
set_name(0x8013E2F0, "to_ascii__FUs", SN_NOWARN)
set_name(0x8013E378, "ascii_to_sjis__FPcPUs", SN_NOWARN)
set_name(0x8013E3FC, "is_sjis__FPUc", SN_NOWARN)
set_name(0x8013E408, "sjis_to_ascii__FPUsPc", SN_NOWARN)
set_name(0x8013E490, "read_card_directory__Fi", SN_NOWARN)
set_name(0x8013E6F0, "test_card_format__Fi", SN_NOWARN)
set_name(0x8013E7E0, "checksum_data__FPci", SN_NOWARN)
set_name(0x8013E81C, "delete_card_file__Fii", SN_NOWARN)
set_name(0x8013E914, "read_card_file__FiiiPc", SN_NOWARN)
set_name(0x8013EAF0, "format_card__Fi", SN_NOWARN)
set_name(0x8013EBB4, "write_card_file__FiiPcT2PUcPUsiT4", SN_NOWARN)
set_name(0x8013EED8, "new_card__Fi", SN_NOWARN)
set_name(0x8013EF6C, "service_card__Fi", SN_NOWARN)
set_name(0x80155064, "GetFileNumber__FiPc", SN_NOWARN)
set_name(0x80155124, "DoSaveOptions__Fv", SN_NOWARN)
set_name(0x8015514C, "DoSaveGame__Fv", SN_NOWARN)
set_name(0x8015529C, "DoLoadGame__Fv", SN_NOWARN)
set_name(0x80155340, "DoFrontEndLoadCharacter__Fi", SN_NOWARN)
set_name(0x80155398, "McInitLoadCard1Menu__Fv", SN_NOWARN)
set_name(0x801553D8, "McInitLoadCard2Menu__Fv", SN_NOWARN)
set_name(0x80155418, "ChooseCardLoad__Fv", SN_NOWARN)
set_name(0x801554B4, "McInitLoadGameMenu__Fv", SN_NOWARN)
set_name(0x80155518, "McMainKeyCtrl__Fv", SN_NOWARN)
set_name(0x80155768, "McCharCardMenuCtrl__Fv", SN_NOWARN)
set_name(0x801559B0, "McMainCharKeyCtrl__Fv", SN_NOWARN)
set_name(0x80155E28, "ShowAlertBox__Fv", SN_NOWARN)
set_name(0x80156034, "GetLoadStatusMessage__FPc", SN_NOWARN)
set_name(0x801560E8, "GetSaveStatusMessage__FiPc", SN_NOWARN)
set_name(0x80156208, "ShowGameFiles__FPciiG4RECTi", SN_NOWARN)
set_name(0x80156368, "ShowCharacterFiles__FiiG4RECTi", SN_NOWARN)
set_name(0x801564E4, "PackItem__FP12PkItemStructPC10ItemStruct", SN_NOWARN)
set_name(0x80156570, "PackPlayer__FP14PkPlayerStructi", SN_NOWARN)
set_name(0x8015677C, "UnPackItem__FPC12PkItemStructP10ItemStruct", SN_NOWARN)
set_name(0x80156884, "VerifyGoldSeeds__FP12PlayerStruct", SN_NOWARN)
set_name(0x8015695C, "UnPackPlayer__FPC14PkPlayerStructiUc", SN_NOWARN)
set_name(0x80156C20, "ConstructSlotName__FPci", SN_NOWARN)
set_name(0x80156D18, "GetSpinnerWidth__Fi", SN_NOWARN)
set_name(0x80156DBC, "ReconstructSlotName__Fii", SN_NOWARN)
set_name(0x801571B4, "GetTick__C4CPad", SN_NOWARN)
set_name(0x801571DC, "GetDown__C4CPad", SN_NOWARN)
set_name(0x80157204, "SetPadTickMask__4CPadUs", SN_NOWARN)
set_name(0x8015720C, "SetPadTick__4CPadUs", SN_NOWARN)
set_name(0x80157214, "SetRGB__6DialogUcUcUc", SN_NOWARN)
set_name(0x80157234, "SetBack__6Dialogi", SN_NOWARN)
set_name(0x8015723C, "SetBorder__6Dialogi", SN_NOWARN)
set_name(0x80157244, "___6Dialog_addr_80157244", SN_NOWARN)
set_name(0x8015726C, "__6Dialog_addr_8015726C", SN_NOWARN)
set_name(0x801572EC, "GetOverlayOtBase__7CBlocks_addr_801572EC", SN_NOWARN)
set_name(0x801572F4, "BLoad__Fv", SN_NOWARN)
set_name(0x80157310, "ILoad__Fv", SN_NOWARN)
set_name(0x80157364, "OLoad__Fv", SN_NOWARN)
set_name(0x80157388, "LoadQuest__Fi", SN_NOWARN)
set_name(0x80157450, "BSave__Fc", SN_NOWARN)
set_name(0x80157468, "ISave__Fi", SN_NOWARN)
set_name(0x801574C8, "OSave__FUc", SN_NOWARN)
set_name(0x8015750C, "SaveQuest__Fi", SN_NOWARN)
set_name(0x801575D8, "PSX_GM_SaveGame__FiPcT1", SN_NOWARN)
set_name(0x80157B38, "PSX_GM_LoadGame__FUcii", SN_NOWARN)
set_name(0x80157C5C, "PSX_CH_LoadGame__Fi", SN_NOWARN)
set_name(0x80157CFC, "PSX_CH_LoadBlock__Fii", SN_NOWARN)
set_name(0x80157D24, "PSX_CH_SaveGame__Fii", SN_NOWARN)
set_name(0x80157EA8, "RestorePads__Fv", SN_NOWARN)
set_name(0x80157F68, "StorePads__Fv", SN_NOWARN)
set_name(0x80158024, "GetIcon__Fv", SN_NOWARN)
set_name(0x80158060, "PSX_OPT_LoadGame__Fiib", SN_NOWARN)
set_name(0x801580BC, "PSX_OPT_SaveGame__FiPc", SN_NOWARN)
set_name(0x801581F4, "LoadOptions__Fv", SN_NOWARN)
set_name(0x801582CC, "SaveOptions__Fv", SN_NOWARN)
set_name(0x80158370, "RestoreLoadedData__Fb", SN_NOWARN)
set_name(0x801386C4, "CreditsText", SN_NOWARN)
set_name(0x8013891C, "CreditsTable", SN_NOWARN)
set_name(0x80139CF4, "card_dir", SN_NOWARN)
set_name(0x8013A1F4, "card_header", SN_NOWARN)
set_name(0x80139C54, "sjis_table", SN_NOWARN)
set_name(0x8013F1C0, "save_buffer", SN_NOWARN)
set_name(0x801531C4, "CharDataStruct", SN_NOWARN)
set_name(0x80154FA4, "TempStr", SN_NOWARN)
set_name(0x80154FE4, "AlertStr", SN_NOWARN)
set_name(0x8013F118, "McLoadGameMenu", SN_NOWARN)
set_name(0x8013F0C4, "ClassStrTbl", SN_NOWARN)
set_name(0x8013F134, "McLoadCard1Menu", SN_NOWARN)
set_name(0x8013F150, "McLoadCard2Menu", SN_NOWARN)
| set_name(2148751116, 'PresOnlyTestRoutine__Fv', SN_NOWARN)
set_name(2148751156, 'FeInitBuffer__Fv', SN_NOWARN)
set_name(2148751200, 'FeAddEntry__Fii8TXT_JUSTUsP7FeTableP5CFont', SN_NOWARN)
set_name(2148751332, 'FeAddTable__FP11FeMenuTablei', SN_NOWARN)
set_name(2148751456, 'FeAddNameTable__FPUci', SN_NOWARN)
set_name(2148751752, 'FeDrawBuffer__Fv', SN_NOWARN)
set_name(2148753332, 'FeNewMenu__FP7FeTable', SN_NOWARN)
set_name(2148753460, 'FePrevMenu__Fv', SN_NOWARN)
set_name(2148753788, 'FeSelUp__Fi', SN_NOWARN)
set_name(2148754020, 'FeSelDown__Fi', SN_NOWARN)
set_name(2148754252, 'FeGetCursor__Fv', SN_NOWARN)
set_name(2148754272, 'FeSelect__Fv', SN_NOWARN)
set_name(2148754352, 'FeMainKeyCtrl__FP7CScreen', SN_NOWARN)
set_name(2148754808, 'InitDummyMenu__Fv', SN_NOWARN)
set_name(2148754816, 'InitFrontEnd__FP9FE_CREATE', SN_NOWARN)
set_name(2148755104, 'FeInitMainMenu__Fv', SN_NOWARN)
set_name(2148755228, 'FeInitNewGameMenu__Fv', SN_NOWARN)
set_name(2148755408, 'FeNewGameMenuCtrl__Fv', SN_NOWARN)
set_name(2148755844, 'FeInitPlayer1ClassMenu__Fv', SN_NOWARN)
set_name(2148755976, 'FeInitPlayer2ClassMenu__Fv', SN_NOWARN)
set_name(2148756108, 'FePlayerClassMenuCtrl__Fv', SN_NOWARN)
set_name(2148756180, 'FeDrawChrClass__Fv', SN_NOWARN)
set_name(2148757356, 'FeInitNewP1NameMenu__Fv', SN_NOWARN)
set_name(2148757448, 'FeInitNewP2NameMenu__Fv', SN_NOWARN)
set_name(2148757532, 'FeNewNameMenuCtrl__Fv', SN_NOWARN)
set_name(2148759012, 'FeCopyPlayerInfoForReturn__Fv', SN_NOWARN)
set_name(2148759312, 'FeEnterGame__Fv', SN_NOWARN)
set_name(2148759352, 'FeInitLoadMemcardSelect__Fv', SN_NOWARN)
set_name(2148759480, 'FeInitLoadChar1Menu__Fv', SN_NOWARN)
set_name(2148759584, 'FeInitLoadChar2Menu__Fv', SN_NOWARN)
set_name(2148759696, 'FeInitDifficultyMenu__Fv', SN_NOWARN)
set_name(2148759860, 'FeDifficultyMenuCtrl__Fv', SN_NOWARN)
set_name(2148760096, 'FeInitBackgroundMenu__Fv', SN_NOWARN)
set_name(2148760172, 'FeInitBook1Menu__Fv', SN_NOWARN)
set_name(2148760252, 'FeInitBook2Menu__Fv', SN_NOWARN)
set_name(2148760332, 'FeBackBookMenuCtrl__Fv', SN_NOWARN)
set_name(2148760912, 'PlayDemo__Fv', SN_NOWARN)
set_name(2148760932, 'FadeFEOut__Fv', SN_NOWARN)
set_name(2148761128, 'DrawBackTSK__FP4TASK', SN_NOWARN)
set_name(2148761520, 'FeInitMainStuff__FP4TASK', SN_NOWARN)
set_name(2148761692, 'FrontEndTask__FP4TASK', SN_NOWARN)
set_name(2148762888, 'DrawFeTwinkle__Fii', SN_NOWARN)
set_name(2148763108, '___6Dialog', SN_NOWARN)
set_name(2148763148, '__6Dialog', SN_NOWARN)
set_name(2148763276, 'GetOverlayOtBase__7CBlocks', SN_NOWARN)
set_name(2148763284, 'CheckActive__4CPad', SN_NOWARN)
set_name(2148764848, 'InitCredits__Fv', SN_NOWARN)
set_name(2148764996, 'PrintCredits__Fiiiiii', SN_NOWARN)
set_name(2148767092, 'DrawCreditsTitle__Fiiiii', SN_NOWARN)
set_name(2148767276, 'DrawCreditsSubTitle__Fiiiii', SN_NOWARN)
set_name(2148767460, 'CredCountNL__Fi', SN_NOWARN)
set_name(2148767568, 'DoCredits__Fv', SN_NOWARN)
set_name(2148768568, 'PRIM_GetPrim__FPP8POLY_FT4', SN_NOWARN)
set_name(2148768692, 'ClearFont__5CFont', SN_NOWARN)
set_name(2148768728, 'GetCharHeight__5CFontUc', SN_NOWARN)
set_name(2148768792, '___7CScreen', SN_NOWARN)
set_name(2148768824, 'GetFr__7TextDati', SN_NOWARN)
set_name(2148786676, 'endian_swap__FPUci', SN_NOWARN)
set_name(2148786728, 'sjis_endian_swap__FPUci', SN_NOWARN)
set_name(2148786800, 'to_sjis__Fc', SN_NOWARN)
set_name(2148786928, 'to_ascii__FUs', SN_NOWARN)
set_name(2148787064, 'ascii_to_sjis__FPcPUs', SN_NOWARN)
set_name(2148787196, 'is_sjis__FPUc', SN_NOWARN)
set_name(2148787208, 'sjis_to_ascii__FPUsPc', SN_NOWARN)
set_name(2148787344, 'read_card_directory__Fi', SN_NOWARN)
set_name(2148787952, 'test_card_format__Fi', SN_NOWARN)
set_name(2148788192, 'checksum_data__FPci', SN_NOWARN)
set_name(2148788252, 'delete_card_file__Fii', SN_NOWARN)
set_name(2148788500, 'read_card_file__FiiiPc', SN_NOWARN)
set_name(2148788976, 'format_card__Fi', SN_NOWARN)
set_name(2148789172, 'write_card_file__FiiPcT2PUcPUsiT4', SN_NOWARN)
set_name(2148789976, 'new_card__Fi', SN_NOWARN)
set_name(2148790124, 'service_card__Fi', SN_NOWARN)
set_name(2148880484, 'GetFileNumber__FiPc', SN_NOWARN)
set_name(2148880676, 'DoSaveOptions__Fv', SN_NOWARN)
set_name(2148880716, 'DoSaveGame__Fv', SN_NOWARN)
set_name(2148881052, 'DoLoadGame__Fv', SN_NOWARN)
set_name(2148881216, 'DoFrontEndLoadCharacter__Fi', SN_NOWARN)
set_name(2148881304, 'McInitLoadCard1Menu__Fv', SN_NOWARN)
set_name(2148881368, 'McInitLoadCard2Menu__Fv', SN_NOWARN)
set_name(2148881432, 'ChooseCardLoad__Fv', SN_NOWARN)
set_name(2148881588, 'McInitLoadGameMenu__Fv', SN_NOWARN)
set_name(2148881688, 'McMainKeyCtrl__Fv', SN_NOWARN)
set_name(2148882280, 'McCharCardMenuCtrl__Fv', SN_NOWARN)
set_name(2148882864, 'McMainCharKeyCtrl__Fv', SN_NOWARN)
set_name(2148884008, 'ShowAlertBox__Fv', SN_NOWARN)
set_name(2148884532, 'GetLoadStatusMessage__FPc', SN_NOWARN)
set_name(2148884712, 'GetSaveStatusMessage__FiPc', SN_NOWARN)
set_name(2148885000, 'ShowGameFiles__FPciiG4RECTi', SN_NOWARN)
set_name(2148885352, 'ShowCharacterFiles__FiiG4RECTi', SN_NOWARN)
set_name(2148885732, 'PackItem__FP12PkItemStructPC10ItemStruct', SN_NOWARN)
set_name(2148885872, 'PackPlayer__FP14PkPlayerStructi', SN_NOWARN)
set_name(2148886396, 'UnPackItem__FPC12PkItemStructP10ItemStruct', SN_NOWARN)
set_name(2148886660, 'VerifyGoldSeeds__FP12PlayerStruct', SN_NOWARN)
set_name(2148886876, 'UnPackPlayer__FPC14PkPlayerStructiUc', SN_NOWARN)
set_name(2148887584, 'ConstructSlotName__FPci', SN_NOWARN)
set_name(2148887832, 'GetSpinnerWidth__Fi', SN_NOWARN)
set_name(2148887996, 'ReconstructSlotName__Fii', SN_NOWARN)
set_name(2148889012, 'GetTick__C4CPad', SN_NOWARN)
set_name(2148889052, 'GetDown__C4CPad', SN_NOWARN)
set_name(2148889092, 'SetPadTickMask__4CPadUs', SN_NOWARN)
set_name(2148889100, 'SetPadTick__4CPadUs', SN_NOWARN)
set_name(2148889108, 'SetRGB__6DialogUcUcUc', SN_NOWARN)
set_name(2148889140, 'SetBack__6Dialogi', SN_NOWARN)
set_name(2148889148, 'SetBorder__6Dialogi', SN_NOWARN)
set_name(2148889156, '___6Dialog_addr_80157244', SN_NOWARN)
set_name(2148889196, '__6Dialog_addr_8015726C', SN_NOWARN)
set_name(2148889324, 'GetOverlayOtBase__7CBlocks_addr_801572EC', SN_NOWARN)
set_name(2148889332, 'BLoad__Fv', SN_NOWARN)
set_name(2148889360, 'ILoad__Fv', SN_NOWARN)
set_name(2148889444, 'OLoad__Fv', SN_NOWARN)
set_name(2148889480, 'LoadQuest__Fi', SN_NOWARN)
set_name(2148889680, 'BSave__Fc', SN_NOWARN)
set_name(2148889704, 'ISave__Fi', SN_NOWARN)
set_name(2148889800, 'OSave__FUc', SN_NOWARN)
set_name(2148889868, 'SaveQuest__Fi', SN_NOWARN)
set_name(2148890072, 'PSX_GM_SaveGame__FiPcT1', SN_NOWARN)
set_name(2148891448, 'PSX_GM_LoadGame__FUcii', SN_NOWARN)
set_name(2148891740, 'PSX_CH_LoadGame__Fi', SN_NOWARN)
set_name(2148891900, 'PSX_CH_LoadBlock__Fii', SN_NOWARN)
set_name(2148891940, 'PSX_CH_SaveGame__Fii', SN_NOWARN)
set_name(2148892328, 'RestorePads__Fv', SN_NOWARN)
set_name(2148892520, 'StorePads__Fv', SN_NOWARN)
set_name(2148892708, 'GetIcon__Fv', SN_NOWARN)
set_name(2148892768, 'PSX_OPT_LoadGame__Fiib', SN_NOWARN)
set_name(2148892860, 'PSX_OPT_SaveGame__FiPc', SN_NOWARN)
set_name(2148893172, 'LoadOptions__Fv', SN_NOWARN)
set_name(2148893388, 'SaveOptions__Fv', SN_NOWARN)
set_name(2148893552, 'RestoreLoadedData__Fb', SN_NOWARN)
set_name(2148763332, 'CreditsText', SN_NOWARN)
set_name(2148763932, 'CreditsTable', SN_NOWARN)
set_name(2148769012, 'card_dir', SN_NOWARN)
set_name(2148770292, 'card_header', SN_NOWARN)
set_name(2148768852, 'sjis_table', SN_NOWARN)
set_name(2148790720, 'save_buffer', SN_NOWARN)
set_name(2148872644, 'CharDataStruct', SN_NOWARN)
set_name(2148880292, 'TempStr', SN_NOWARN)
set_name(2148880356, 'AlertStr', SN_NOWARN)
set_name(2148790552, 'McLoadGameMenu', SN_NOWARN)
set_name(2148790468, 'ClassStrTbl', SN_NOWARN)
set_name(2148790580, 'McLoadCard1Menu', SN_NOWARN)
set_name(2148790608, 'McLoadCard2Menu', SN_NOWARN) |
APKG_COL = r'''
INSERT INTO col VALUES(
null,
:creation_time,
:modification_time,
:modification_time,
11,
0,
0,
0,
'{
"activeDecks": [
1
],
"addToCur": true,
"collapseTime": 1200,
"curDeck": 1,
"curModel": "' || :modification_time || '",
"dueCounts": true,
"estTimes": true,
"newBury": true,
"newSpread": 0,
"nextPos": 1,
"sortBackwards": false,
"sortType": "noteFld",
"timeLim": 0
}',
:models,
'{
"1": {
"collapsed": false,
"conf": 1,
"desc": "",
"dyn": 0,
"extendNew": 10,
"extendRev": 50,
"id": 1,
"lrnToday": [
0,
0
],
"mod": 1425279151,
"name": "Default",
"newToday": [
0,
0
],
"revToday": [
0,
0
],
"timeToday": [
0,
0
],
"usn": 0
},
"' || :deck_id || '": {
"collapsed": false,
"conf": ' || :options_id || ',
"desc": "' || :description || '",
"dyn": 0,
"extendNew": 10,
"extendRev": 50,
"id": ' || :deck_id || ',
"lrnToday": [
5,
0
],
"mod": 1425278051,
"name": "' || :name || '",
"newToday": [
5,
0
],
"revToday": [
5,
0
],
"timeToday": [
5,
0
],
"usn": -1
}
}',
'{
"' || :options_id || '": {
"id": ' || :options_id || ',
"autoplay": ' || :autoplay_audio || ',
"lapse": {
"delays": ' || :lapse_steps || ',
"leechAction": ' || :leech_action || ',
"leechFails": ' || :leech_threshold || ',
"minInt": ' || :lapse_min_interval || ',
"mult": ' || :leech_interval_multiplier || '
},
"maxTaken": ' || :max_time_per_answer || ',
"mod": 0,
"name": "' || :options_group_name || '",
"new": {
"bury": ' || :bury_related_new_cards || ',
"delays": ' || :new_steps || ',
"initialFactor": ' || :starting_ease || ',
"ints": [
' || :graduating_interval || ',
' || :easy_interval || ',
7
],
"order": ' || :order || ',
"perDay": ' || :new_cards_per_day || ',
"separate": true
},
"replayq": ' || :replay_audio_for_answer || ',
"rev": {
"bury": ' || :bury_related_review_cards || ',
"ease4": ' || :easy_bonus || ',
"fuzz": 0.05,
"ivlFct": ' || :interval_modifier || ',
"maxIvl": ' || :max_interval || ',
"minSpace": 1,
"perDay": ' || :max_reviews_per_day || '
},
"timer": ' || :show_timer || ',
"usn": 0
}
}',
'{}'
);
'''
| apkg_col = '\nINSERT INTO col VALUES(\n null,\n :creation_time,\n :modification_time,\n :modification_time,\n 11,\n 0,\n 0,\n 0,\n \'{\n "activeDecks": [\n 1\n ],\n "addToCur": true,\n "collapseTime": 1200,\n "curDeck": 1,\n "curModel": "\' || :modification_time || \'",\n "dueCounts": true,\n "estTimes": true,\n "newBury": true,\n "newSpread": 0,\n "nextPos": 1,\n "sortBackwards": false,\n "sortType": "noteFld",\n "timeLim": 0\n }\',\n :models,\n \'{\n "1": {\n "collapsed": false,\n "conf": 1,\n "desc": "",\n "dyn": 0,\n "extendNew": 10,\n "extendRev": 50,\n "id": 1,\n "lrnToday": [\n 0,\n 0\n ],\n "mod": 1425279151,\n "name": "Default",\n "newToday": [\n 0,\n 0\n ],\n "revToday": [\n 0,\n 0\n ],\n "timeToday": [\n 0,\n 0\n ],\n "usn": 0\n },\n "\' || :deck_id || \'": {\n "collapsed": false,\n "conf": \' || :options_id || \',\n "desc": "\' || :description || \'",\n "dyn": 0,\n "extendNew": 10,\n "extendRev": 50,\n "id": \' || :deck_id || \',\n "lrnToday": [\n 5,\n 0\n ],\n "mod": 1425278051,\n "name": "\' || :name || \'",\n "newToday": [\n 5,\n 0\n ],\n "revToday": [\n 5,\n 0\n ],\n "timeToday": [\n 5,\n 0\n ],\n "usn": -1\n }\n }\',\n \'{\n "\' || :options_id || \'": {\n "id": \' || :options_id || \',\n "autoplay": \' || :autoplay_audio || \',\n "lapse": {\n "delays": \' || :lapse_steps || \',\n "leechAction": \' || :leech_action || \',\n "leechFails": \' || :leech_threshold || \',\n "minInt": \' || :lapse_min_interval || \',\n "mult": \' || :leech_interval_multiplier || \'\n },\n "maxTaken": \' || :max_time_per_answer || \',\n "mod": 0,\n "name": "\' || :options_group_name || \'",\n "new": {\n "bury": \' || :bury_related_new_cards || \',\n "delays": \' || :new_steps || \',\n "initialFactor": \' || :starting_ease || \',\n "ints": [\n \' || :graduating_interval || \',\n \' || :easy_interval || \',\n 7\n ],\n "order": \' || :order || \',\n "perDay": \' || :new_cards_per_day || \',\n "separate": true\n },\n "replayq": \' || :replay_audio_for_answer || \',\n "rev": {\n "bury": \' || :bury_related_review_cards || \',\n "ease4": \' || :easy_bonus || \',\n "fuzz": 0.05,\n "ivlFct": \' || :interval_modifier || \',\n "maxIvl": \' || :max_interval || \',\n "minSpace": 1,\n "perDay": \' || :max_reviews_per_day || \'\n },\n "timer": \' || :show_timer || \',\n "usn": 0\n }\n }\',\n \'{}\'\n);\n' |
def sum_numbers(text: str) -> int:
return sum([int(x) for x in text.split() if x.isnumeric()])
if __name__ == '__main__':
print("Example:")
print(sum_numbers('hi'))
# These "asserts" are used for self-checking and not for an auto-testing
assert sum_numbers('hi') == 0
assert sum_numbers('who is 1st here') == 0
assert sum_numbers('my numbers is 2') == 2
assert sum_numbers(
'This picture is an oil on canvas painting by Danish artist Anna Petersen between 1845 and 1910 year'
) == 3755
assert sum_numbers('5 plus 6 is') == 11
assert sum_numbers('') == 0
print("Coding complete? Click 'Check' to earn cool rewards!")
| def sum_numbers(text: str) -> int:
return sum([int(x) for x in text.split() if x.isnumeric()])
if __name__ == '__main__':
print('Example:')
print(sum_numbers('hi'))
assert sum_numbers('hi') == 0
assert sum_numbers('who is 1st here') == 0
assert sum_numbers('my numbers is 2') == 2
assert sum_numbers('This picture is an oil on canvas painting by Danish artist Anna Petersen between 1845 and 1910 year') == 3755
assert sum_numbers('5 plus 6 is') == 11
assert sum_numbers('') == 0
print("Coding complete? Click 'Check' to earn cool rewards!") |
class snake:
poison='venom' # shared by all instances
def __init__(self, name):
self.name=name # instance variable unique to each instance
def change_name(self, new_name):
self.name=new_name
cobra= snake('cobra')
print(cobra.name)
| class Snake:
poison = 'venom'
def __init__(self, name):
self.name = name
def change_name(self, new_name):
self.name = new_name
cobra = snake('cobra')
print(cobra.name) |
name = input("Enter Your Username: ")
age = int(input("Enter Your Age: "))
print(type(age))
if type(age) == int:
print("Name :" ,name)
print("Age :", age)
else:
print("Enter a valid Username or Age") | name = input('Enter Your Username: ')
age = int(input('Enter Your Age: '))
print(type(age))
if type(age) == int:
print('Name :', name)
print('Age :', age)
else:
print('Enter a valid Username or Age') |
# glob.py
viewPortX = None
viewPortY = None
| view_port_x = None
view_port_y = None |
'''
Given an array of ints, return True if 6 appears as either the first or last
element in the array. The array will be length 1 or more.
'''
def first_last6(nums):
return nums[0] == 6 or nums[-1] == 6
| """
Given an array of ints, return True if 6 appears as either the first or last
element in the array. The array will be length 1 or more.
"""
def first_last6(nums):
return nums[0] == 6 or nums[-1] == 6 |
def insertion_sort(lst):
for i in range(len(lst)):
j = (i - 1)
temp = lst[i]
while j >= 0 and temp < lst[j]:
lst[j+1] = lst[j]
j = j-1
lst[j + 1] = temp
return lst
| def insertion_sort(lst):
for i in range(len(lst)):
j = i - 1
temp = lst[i]
while j >= 0 and temp < lst[j]:
lst[j + 1] = lst[j]
j = j - 1
lst[j + 1] = temp
return lst |
# the public parameters are passed as they are known globally
def attacker(prime, root, alicepublic, bobpublic):
attacksecret1=int(input("Enter a secret number1 for attacker: "))
attacksecret2=int(input("Enter a secret number2 for attacker: "))
print('\n')
print ("Attacker's public key -> C=root^attacksecret(mod(prime))")
attackpublic1=(root**attacksecret1)%prime
attackpublic2=(root**attacksecret2)%prime
print ("Attacker public key1 which is shared with Party1: ", attackpublic1)
print ("Attacker public key2 which is shared with Party2: ", attackpublic2)
print('\n')
key1=(alicepublic**attacksecret1)%prime
key2=(bobpublic**attacksecret2)%prime
print("The key used to decrypt message from A and modify: ",key1)
print("The key used to encrypt message to be sent to B is: ",key2)
return(attackpublic1,attackpublic2)
# Prime to be used
print ("Both parties agree to a single prime")
prime=int(input("Enter the prime number to be considered: "))
# Primitive root to be used
print ("Both must agree with single primitive root to use")
root=int(input("Enter the primitive root: "))
# Party1 chooses a secret number
alicesecret=int(input("Enter a secret number for Party1: "))
# Party2 chooses a secret number
bobsecret=int(input("Enter a secret number for Party2: "))
print('\n')
# Party1 public key A=(root^alicesecret)*mod(prime)
print ("Party1's public key -> A=root^alicesecret(mod(prime))")
alicepublic=(root**alicesecret)%prime
print ("Party1 public key is: ",alicepublic, "\n")
# Party2 public key B=(root^bobsecret)*mod(prime)
print ("Party2's public key -> B=root^bobsecret(mod(prime))")
bobpublic=(root**bobsecret)%prime
print ("Party2 public key is", bobpublic, "\n")
# Party1 now calculates the shared key K1:
# K1 = B^(alicesecret)*mod(prime)
print ("Party1 calculates the shared key as K=B^alicesecret*(mod(prime))")
alicekey=(bobpublic**alicesecret)%prime
print ("Party1 calculates the shared key and results: ",alicekey, "\n")
# Party2 calculates the shared key K2:
# K2 = A^(bobsecret)*mod(prime)
print ("Party2 calculates the shared key as K=A^bobsecret(mod(prime))")
bobkey =(alicepublic**bobsecret)%prime
print ("Party2 calculates the shared key and results: ", bobkey, "\n")
#Both Alice and Bob now share a key which Eve cannot calculate
print ("Attacker does not know the shared private key that Party1 & Party2 can now use")
print("Now Eve implements Man In the Middle Attack !!")
# Party1 and Party2 exchange their public keys
# Eve(attacker) nows both parties public keys
keys=attacker(prime, root, alicepublic, bobpublic)
alicekey=(keys[0]**alicesecret)%prime
print("Party1 calculates the shared key with attacker's public key1: ")
print ("Shared final key: ",alicekey)
bobkey =(keys[1]**bobsecret)%prime
print("Party2 calculates the shared key with attacker's public key2: ")
print ("Shared final key: ", bobkey, "\n")
print("The final keys are different. ")
'''
----------OUTPUT----------
Both parties agree to a single prime
Enter the prime number to be considered: 61
Both must agree with single primitive root to use
Enter the primitive root: 43
Enter a secret number for Party1: 6756
Enter a secret number for Party2: 8356
Party1's public key -> A=root^alicesecret(mod(prime))
Party1 public key is: 34
Party2's public key -> B=root^bobsecret(mod(prime))
Party2 public key is 15
Party1 calculates the shared key as K=B^alicesecret*(mod(prime))
Party1 calculates the shared key and results: 34
Party2 calculates the shared key as K=A^bobsecret(mod(prime))
Party2 calculates the shared key and results: 34
Attacker does not know the shared private key that Party1 & Party2 can now use
Now Eve implements Man In the Middle Attack !!
Enter a secret number1 for attacker: 7349
Enter a secret number2 for attacker: 3560
Attacker's public key -> C=root^attacksecret(mod(prime))
Attacker public key1 which is shared with Party1: 17
Attacker public key2 which is shared with Party2: 47
The key used to decrypt message from A and modify: 9
The key used to encrypt message to be sent to B is: 47
Party1 calculates the shared key with attacker's public key1:
Shared final key: 9
Party2 calculates the shared key with attacker's public key2:
Shared final key: 47
The final keys are different.
>>>
'''
'''
Took help from:
1. https://sublimerobots.com/2015/01/simple-diffie-hellman-example-python/
2. https://trinket.io/python/d574095364
3. https://www.wolframalpha.com/widgets/view.jsp?id=ef51422db7db201ebc03c8800f41ba99
Thanks for the help !
'''
| def attacker(prime, root, alicepublic, bobpublic):
attacksecret1 = int(input('Enter a secret number1 for attacker: '))
attacksecret2 = int(input('Enter a secret number2 for attacker: '))
print('\n')
print("Attacker's public key -> C=root^attacksecret(mod(prime))")
attackpublic1 = root ** attacksecret1 % prime
attackpublic2 = root ** attacksecret2 % prime
print('Attacker public key1 which is shared with Party1: ', attackpublic1)
print('Attacker public key2 which is shared with Party2: ', attackpublic2)
print('\n')
key1 = alicepublic ** attacksecret1 % prime
key2 = bobpublic ** attacksecret2 % prime
print('The key used to decrypt message from A and modify: ', key1)
print('The key used to encrypt message to be sent to B is: ', key2)
return (attackpublic1, attackpublic2)
print('Both parties agree to a single prime')
prime = int(input('Enter the prime number to be considered: '))
print('Both must agree with single primitive root to use')
root = int(input('Enter the primitive root: '))
alicesecret = int(input('Enter a secret number for Party1: '))
bobsecret = int(input('Enter a secret number for Party2: '))
print('\n')
print("Party1's public key -> A=root^alicesecret(mod(prime))")
alicepublic = root ** alicesecret % prime
print('Party1 public key is: ', alicepublic, '\n')
print("Party2's public key -> B=root^bobsecret(mod(prime))")
bobpublic = root ** bobsecret % prime
print('Party2 public key is', bobpublic, '\n')
print('Party1 calculates the shared key as K=B^alicesecret*(mod(prime))')
alicekey = bobpublic ** alicesecret % prime
print('Party1 calculates the shared key and results: ', alicekey, '\n')
print('Party2 calculates the shared key as K=A^bobsecret(mod(prime))')
bobkey = alicepublic ** bobsecret % prime
print('Party2 calculates the shared key and results: ', bobkey, '\n')
print('Attacker does not know the shared private key that Party1 & Party2 can now use')
print('Now Eve implements Man In the Middle Attack !!')
keys = attacker(prime, root, alicepublic, bobpublic)
alicekey = keys[0] ** alicesecret % prime
print("Party1 calculates the shared key with attacker's public key1: ")
print('Shared final key: ', alicekey)
bobkey = keys[1] ** bobsecret % prime
print("Party2 calculates the shared key with attacker's public key2: ")
print('Shared final key: ', bobkey, '\n')
print('The final keys are different. ')
"\n----------OUTPUT----------\nBoth parties agree to a single prime\nEnter the prime number to be considered: 61\nBoth must agree with single primitive root to use\nEnter the primitive root: 43\nEnter a secret number for Party1: 6756\nEnter a secret number for Party2: 8356\n\n\nParty1's public key -> A=root^alicesecret(mod(prime))\nParty1 public key is: 34 \n\nParty2's public key -> B=root^bobsecret(mod(prime))\nParty2 public key is 15 \n\nParty1 calculates the shared key as K=B^alicesecret*(mod(prime))\nParty1 calculates the shared key and results: 34 \n\nParty2 calculates the shared key as K=A^bobsecret(mod(prime))\nParty2 calculates the shared key and results: 34 \n\nAttacker does not know the shared private key that Party1 & Party2 can now use\nNow Eve implements Man In the Middle Attack !!\nEnter a secret number1 for attacker: 7349\nEnter a secret number2 for attacker: 3560\n\n\nAttacker's public key -> C=root^attacksecret(mod(prime))\nAttacker public key1 which is shared with Party1: 17\nAttacker public key2 which is shared with Party2: 47\n\n\nThe key used to decrypt message from A and modify: 9\nThe key used to encrypt message to be sent to B is: 47\nParty1 calculates the shared key with attacker's public key1: \nShared final key: 9\nParty2 calculates the shared key with attacker's public key2: \nShared final key: 47 \n\nThe final keys are different. \n>>> \n"
'\nTook help from:\n1. https://sublimerobots.com/2015/01/simple-diffie-hellman-example-python/\n2. https://trinket.io/python/d574095364\n3. https://www.wolframalpha.com/widgets/view.jsp?id=ef51422db7db201ebc03c8800f41ba99\nThanks for the help !\n' |
''' your local settings.
Note that if you install using setuptools, change this
module first before running setup.py install.
'''
oauthkey = '7dkss6x9fn5v'
secret = 't5f28uhdmct7zhdr'
country = 'US'
| """ your local settings.
Note that if you install using setuptools, change this
module first before running setup.py install.
"""
oauthkey = '7dkss6x9fn5v'
secret = 't5f28uhdmct7zhdr'
country = 'US' |
#!/usr/bin/env python3
# Conditional Statements
def drink(money):
if (money >= 2):
return "You've got yourself a drink!"
else:
return "NO drink for you!"
print(drink(3))
print(drink(1))
def alcohol(age, money):
if (age >= 21) and (money >= 5): # if statement
return "we're getting a drink!"
elif (age >= 21) and (money < 5): # else-if statement
return "Come back with more money!"
elif (age < 21) and (money >= 5):
return "Nice try, kid!"
else: # else statement
return "You're too poor and too young"
print(alcohol(21, 5))
print(alcohol(21, 4))
print(alcohol(20, 4))
| def drink(money):
if money >= 2:
return "You've got yourself a drink!"
else:
return 'NO drink for you!'
print(drink(3))
print(drink(1))
def alcohol(age, money):
if age >= 21 and money >= 5:
return "we're getting a drink!"
elif age >= 21 and money < 5:
return 'Come back with more money!'
elif age < 21 and money >= 5:
return 'Nice try, kid!'
else:
return "You're too poor and too young"
print(alcohol(21, 5))
print(alcohol(21, 4))
print(alcohol(20, 4)) |
def getUniqueID(inArray):
'''
Given an int array that contains many duplicates and a single
unique ID, find it and return it.
'''
pairDictionary = {}
for quadID in inArray:
# print(quadID)
# print(pairDictionary)
if quadID in pairDictionary:
del pairDictionary[quadID]
else:
pairDictionary[quadID] = 1
return pairDictionary.keys()
def getUniqueIDSpaceOptimized(inArray):
a = 0
for quadID in inArray:
a = a ^ quadID
return a
def main():
# should return 9 as the unique integer
testArray = [1,2,5,3,2,5,3,1,9,3,4,3,4]
print("Unique ID was: %s"%(getUniqueID(testArray)))
print("With space optimized solution, unique ID was: %s"%(getUniqueIDSpaceOptimized(testArray)))
if __name__ == "__main__":
main() | def get_unique_id(inArray):
"""
Given an int array that contains many duplicates and a single
unique ID, find it and return it.
"""
pair_dictionary = {}
for quad_id in inArray:
if quadID in pairDictionary:
del pairDictionary[quadID]
else:
pairDictionary[quadID] = 1
return pairDictionary.keys()
def get_unique_id_space_optimized(inArray):
a = 0
for quad_id in inArray:
a = a ^ quadID
return a
def main():
test_array = [1, 2, 5, 3, 2, 5, 3, 1, 9, 3, 4, 3, 4]
print('Unique ID was: %s' % get_unique_id(testArray))
print('With space optimized solution, unique ID was: %s' % get_unique_id_space_optimized(testArray))
if __name__ == '__main__':
main() |
# create a dictionary from two lists using zip()
# More information using help('zip') and help('dict')
# create two lists
dict_keys = ['bananas', 'bread flour', 'cheese', 'milk']
dict_values = [2, 1, 4, 3]
# iterate over lists using zip
iterator_using_zip = zip(dict_keys, dict_values)
# create the dictionary from the zip
dictionary_from_zip = dict(iterator_using_zip)
print(dictionary_from_zip)
# prints {'bananas': 2, 'bread flour': 1, 'cheese': 4, 'milk': 3}
| dict_keys = ['bananas', 'bread flour', 'cheese', 'milk']
dict_values = [2, 1, 4, 3]
iterator_using_zip = zip(dict_keys, dict_values)
dictionary_from_zip = dict(iterator_using_zip)
print(dictionary_from_zip) |
p = int(input())
q = int(input())
for i in range(1, 101):
if i % p == q:
print(i) | p = int(input())
q = int(input())
for i in range(1, 101):
if i % p == q:
print(i) |
# PATH
UPLOAD_FOLDER = './upload_file'
GENERATE_PATH = './download_file'
# DATABASE
DATABASE = 'mysql'
DATABASE_URL = 'localhost:3306'
USERNAME = 'root'
PASSWORD = 'root'
| upload_folder = './upload_file'
generate_path = './download_file'
database = 'mysql'
database_url = 'localhost:3306'
username = 'root'
password = 'root' |
# TODO - bisect operations
class SortedDictCore:
def __init__(self, *a, **kw):
self._items = []
self.dict = dict(*a,**kw)
##
def __setitem__(self,k,v):
self._items = []
self.dict[k]=v
def __getitem__(self,k):
return self.dict[k]
def __delitem__(self,k):
self._items = []
del self.dict[k]
##
def sort(self):
if self._items: return
self._items = sorted(self.dict.items(),key=lambda x:(x[1],x[0]))
def items(self):
self.sort()
return self._items
def update(self,*a,**kw):
self._items = []
self.dict.update(*a,**kw)
class SortedDict(SortedDictCore):
def sd_get(self,k):
return self.dict.get(k)
def sd_set(self,k,v):
self[k] = v
def sd_del(self,k):
if k in self.dict:
del self.dict[k]
def sd_add(self,k,v):
try:
self[k] += v
except KeyError:
self[k] = v
return self[k]
def sd_items(self,a=None,b=None,c=None):
if a is not None or b is not None or c is not None:
return self.items()
else:
return self.items()[a:b:c]
# *_many
def sd_get_many(self,k_iter):
return (self.sd_get(k) for k in k_iter)
def sd_set_many(self,kv_iter):
for k,v in kv_iter:
self.sd_set(k,v)
def sd_del_many(self,k_iter):
for k in k_iter:
self.sd_del(k)
def sd_add_many(self,kv_iter):
out = []
for k,v in kv_iter:
x = self.sd_add(k,v)
out.append(x)
return out
if __name__=="__main__":
d = SortedDict(a=3,b=1,c=2,d=(2,2))
d['x'] = 1.5
d.sd_add('a',0.1)
d.sd_add('y',0.1)
print(d.items()[-2:])
| class Sorteddictcore:
def __init__(self, *a, **kw):
self._items = []
self.dict = dict(*a, **kw)
def __setitem__(self, k, v):
self._items = []
self.dict[k] = v
def __getitem__(self, k):
return self.dict[k]
def __delitem__(self, k):
self._items = []
del self.dict[k]
def sort(self):
if self._items:
return
self._items = sorted(self.dict.items(), key=lambda x: (x[1], x[0]))
def items(self):
self.sort()
return self._items
def update(self, *a, **kw):
self._items = []
self.dict.update(*a, **kw)
class Sorteddict(SortedDictCore):
def sd_get(self, k):
return self.dict.get(k)
def sd_set(self, k, v):
self[k] = v
def sd_del(self, k):
if k in self.dict:
del self.dict[k]
def sd_add(self, k, v):
try:
self[k] += v
except KeyError:
self[k] = v
return self[k]
def sd_items(self, a=None, b=None, c=None):
if a is not None or b is not None or c is not None:
return self.items()
else:
return self.items()[a:b:c]
def sd_get_many(self, k_iter):
return (self.sd_get(k) for k in k_iter)
def sd_set_many(self, kv_iter):
for (k, v) in kv_iter:
self.sd_set(k, v)
def sd_del_many(self, k_iter):
for k in k_iter:
self.sd_del(k)
def sd_add_many(self, kv_iter):
out = []
for (k, v) in kv_iter:
x = self.sd_add(k, v)
out.append(x)
return out
if __name__ == '__main__':
d = sorted_dict(a=3, b=1, c=2, d=(2, 2))
d['x'] = 1.5
d.sd_add('a', 0.1)
d.sd_add('y', 0.1)
print(d.items()[-2:]) |
n = 2001
number = 1
while n < 2101:
if number % 10 == 0:
print("\n")
number += 1
if n % 100 == 0:
if n % 400 == 0:
print(n, end=" ")
n += 1
number += 1
continue
else:
n += 1
continue
else:
if n % 4 == 0:
print(n, end=" ")
n += 1
number += 1
continue
else:
n += 1
continue
| n = 2001
number = 1
while n < 2101:
if number % 10 == 0:
print('\n')
number += 1
if n % 100 == 0:
if n % 400 == 0:
print(n, end=' ')
n += 1
number += 1
continue
else:
n += 1
continue
elif n % 4 == 0:
print(n, end=' ')
n += 1
number += 1
continue
else:
n += 1
continue |
# Python - 3.6.0
def high_and_low(numbers):
lst = [*map(int, numbers.split(' '))]
return f'{max(lst)} {min(lst)}'
| def high_and_low(numbers):
lst = [*map(int, numbers.split(' '))]
return f'{max(lst)} {min(lst)}' |
online_store = {
"keychain": 0.75,
"tshirt": 8.50,
"bottle": 10.00
}
choicekey = int(input("How many keychains will you be purchasing? If not purchasing keychains, enter 0. "))
choicetshirt = int(input("How many t-shirts will you be purchasing? If not purchasing t-shirts, enter 0. "))
choicebottle = int(input("How many t-shirts will you be purchasing? If not purchasing water bottles, enter 0. "))
if choicekey > 9:
online_store['keychain'] = 0.65
if choicetshirt > 9:
online_store['tshirt'] = 8.00
if choicebottle > 9:
online_store['bottle'] = 8.75
print("You are purchasing " + str(choicekey) + " keychains, " + str(choicetshirt) + " t-shirts, and " + str(choicebottle) + " water bottles.")
perskey = input("Will you personalize the keychains for an additional $1.00 each? Type yes or no. ")
perstshirt = input("Will you personalize the t-shirts for an additional $5.00 each? Type yes or no. ")
persbottle = input("Will you personalize the water bottles for an additional $7.50 each? Type yes or no. ")
if perskey == ("yes" or "Yes"):
online_store['keychain'] = online_store['keychain'] + 1.00
if perstshirt == ("yes" or "Yes"):
online_store['tshirt'] = online_store['tshirt'] + 5.00
if persbottle == ("yes" or "Yes"):
online_store['bottle'] = online_store['bottle'] + 7.50
keychain = online_store['keychain']
tshirt = online_store['tshirt']
bottle = online_store['bottle']
totalkey = choicekey * keychain
totaltshirt = choicetshirt * tshirt
totalbottle = choicebottle * bottle
grandtotal = totalkey + totaltshirt + totalbottle
print("Keychain total: $" + str(totalkey))
print("T-shirt total: $" + str(totaltshirt))
print("Water bottle total: $" + str(totalbottle))
print("Your order total: $" + str(grandtotal))
| online_store = {'keychain': 0.75, 'tshirt': 8.5, 'bottle': 10.0}
choicekey = int(input('How many keychains will you be purchasing? If not purchasing keychains, enter 0. '))
choicetshirt = int(input('How many t-shirts will you be purchasing? If not purchasing t-shirts, enter 0. '))
choicebottle = int(input('How many t-shirts will you be purchasing? If not purchasing water bottles, enter 0. '))
if choicekey > 9:
online_store['keychain'] = 0.65
if choicetshirt > 9:
online_store['tshirt'] = 8.0
if choicebottle > 9:
online_store['bottle'] = 8.75
print('You are purchasing ' + str(choicekey) + ' keychains, ' + str(choicetshirt) + ' t-shirts, and ' + str(choicebottle) + ' water bottles.')
perskey = input('Will you personalize the keychains for an additional $1.00 each? Type yes or no. ')
perstshirt = input('Will you personalize the t-shirts for an additional $5.00 each? Type yes or no. ')
persbottle = input('Will you personalize the water bottles for an additional $7.50 each? Type yes or no. ')
if perskey == ('yes' or 'Yes'):
online_store['keychain'] = online_store['keychain'] + 1.0
if perstshirt == ('yes' or 'Yes'):
online_store['tshirt'] = online_store['tshirt'] + 5.0
if persbottle == ('yes' or 'Yes'):
online_store['bottle'] = online_store['bottle'] + 7.5
keychain = online_store['keychain']
tshirt = online_store['tshirt']
bottle = online_store['bottle']
totalkey = choicekey * keychain
totaltshirt = choicetshirt * tshirt
totalbottle = choicebottle * bottle
grandtotal = totalkey + totaltshirt + totalbottle
print('Keychain total: $' + str(totalkey))
print('T-shirt total: $' + str(totaltshirt))
print('Water bottle total: $' + str(totalbottle))
print('Your order total: $' + str(grandtotal)) |
# -*- coding: utf-8 -*-
config = {}
config['log_name'] = 'app_log.log'
config['log_format'] = '%(asctime)s - %(levelname)s: %(message)s'
config['log_date_format'] = '%Y-%m-%d %I:%M:%S'
config['format'] = 'json'
config['source_dir'] = 'data'
config['output_dir'] = 'export'
config['source_glob'] = 'monitoraggio_serviz_controllo_giornaliero_*.pdf'
config['processed_dir'] = 'processed' | config = {}
config['log_name'] = 'app_log.log'
config['log_format'] = '%(asctime)s - %(levelname)s: %(message)s'
config['log_date_format'] = '%Y-%m-%d %I:%M:%S'
config['format'] = 'json'
config['source_dir'] = 'data'
config['output_dir'] = 'export'
config['source_glob'] = 'monitoraggio_serviz_controllo_giornaliero_*.pdf'
config['processed_dir'] = 'processed' |
_mods = []
def get():
return _mods
def add(mod):
_mods.append(mod)
| _mods = []
def get():
return _mods
def add(mod):
_mods.append(mod) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.