content stringlengths 7 1.05M | fixed_cases stringlengths 1 1.28M |
|---|---|
def func(a, b):
# a is state 1
# b is state 2
# this is horrible code but it works! :^)
s = r"\frac{1}{6}"
s1 = r"\frac{1}{2}"
s2 = r"\frac{1}{3}"
if a == 19 and b != 19:
return 0
if a == b:
if a == 19:
return 1
else:
return 0
elif a == 0:
if b <= 6:
return s
else:
return 0
elif a <= 6:
if b == 0:
return s
elif b > 18:
return 0
else:
if a == 1 and (b in [2, 6, 7, 8, 9]):
return s
elif a == 2 and (b in [1, 3, 9, 10, 11]):
return s
elif a == 3 and (b in [2, 4, 11, 12, 13]):
return s
elif a == 4 and (b in [3, 5, 13, 14, 15]):
return s
elif a == 5 and (b in [4, 6, 15, 16, 17]):
return s
elif a == 6 and (b in [1, 5, 7, 17, 18]):
return s
else:
return 0
else:
if b == 19:
if a % 2 == 1:
return s2
else:
return s1
else:
if b == 0:
return 0
elif b in [a - 1, a + 1]:
return s
elif a == 7 and b == 18:
return s
elif b == 7 and a == 18:
return s
else:
if a % 2 == 1:
arr = list(map(int, [0.5 * a - 3.5, 0.5 * a - 2.5]))
if b in arr:
return s
else:
return 0
else:
if b == int(0.5 * a - 3):
return s
else:
return 0
f = open("transition3.tex", "w")
f.write(r"$$")
f.write("\n")
f.write("P = ")
f.write("\n")
f.write(r"\left ( \scalemath{0.4} { \begin{array}{cccccccccccccccccccc}")
f.write("\n")
for i in range(20):
s = "\t"
for j in range(20):
s += "p_{{ {}, {} }} = ".format(i, j)
s += str(func(i, j))
s += " & "
s = s[:-3]
f.write(s)
f.write(r"\\")
f.write("\n")
f.write(r"\end{array} } \right)")
f.write("\n")
f.write(r"$$")
f.write("\n")
f.close()
| def func(a, b):
s = '\\frac{1}{6}'
s1 = '\\frac{1}{2}'
s2 = '\\frac{1}{3}'
if a == 19 and b != 19:
return 0
if a == b:
if a == 19:
return 1
else:
return 0
elif a == 0:
if b <= 6:
return s
else:
return 0
elif a <= 6:
if b == 0:
return s
elif b > 18:
return 0
elif a == 1 and b in [2, 6, 7, 8, 9]:
return s
elif a == 2 and b in [1, 3, 9, 10, 11]:
return s
elif a == 3 and b in [2, 4, 11, 12, 13]:
return s
elif a == 4 and b in [3, 5, 13, 14, 15]:
return s
elif a == 5 and b in [4, 6, 15, 16, 17]:
return s
elif a == 6 and b in [1, 5, 7, 17, 18]:
return s
else:
return 0
elif b == 19:
if a % 2 == 1:
return s2
else:
return s1
elif b == 0:
return 0
elif b in [a - 1, a + 1]:
return s
elif a == 7 and b == 18:
return s
elif b == 7 and a == 18:
return s
elif a % 2 == 1:
arr = list(map(int, [0.5 * a - 3.5, 0.5 * a - 2.5]))
if b in arr:
return s
else:
return 0
elif b == int(0.5 * a - 3):
return s
else:
return 0
f = open('transition3.tex', 'w')
f.write('$$')
f.write('\n')
f.write('P = ')
f.write('\n')
f.write('\\left ( \\scalemath{0.4} { \\begin{array}{cccccccccccccccccccc}')
f.write('\n')
for i in range(20):
s = '\t'
for j in range(20):
s += 'p_{{ {}, {} }} = '.format(i, j)
s += str(func(i, j))
s += ' & '
s = s[:-3]
f.write(s)
f.write('\\\\')
f.write('\n')
f.write('\\end{array} } \\right)')
f.write('\n')
f.write('$$')
f.write('\n')
f.close() |
"""
`InverseHaar1D <http://community.topcoder.com/stat?c=problem_statement&pm=5896>`__
"""
def solution (t, l):
if (l == 1):
# level-1 untransformation
i = len(t) / 2
sums, diffs = t[:i], t[i:]
ut = []
for j in range(len(sums)):
# a + b = s, a - b = d
# a = (s + d) / 2, b = (s - d) / 2
s, d = sums[j], diffs[j]
a, b = (s + d) / 2, (s - d) / 2
ut.extend([a, b])
return ut
else:
# level-x untransformation
i = len(t) / (2 ** (l - 1))
head, tail = t[:i], t[i:]
ut = solution(head, 1) + tail
return solution(ut, l - 1)
| """
`InverseHaar1D <http://community.topcoder.com/stat?c=problem_statement&pm=5896>`__
"""
def solution(t, l):
if l == 1:
i = len(t) / 2
(sums, diffs) = (t[:i], t[i:])
ut = []
for j in range(len(sums)):
(s, d) = (sums[j], diffs[j])
(a, b) = ((s + d) / 2, (s - d) / 2)
ut.extend([a, b])
return ut
else:
i = len(t) / 2 ** (l - 1)
(head, tail) = (t[:i], t[i:])
ut = solution(head, 1) + tail
return solution(ut, l - 1) |
# This file contains the credentials needed to connect to and use the TTN Lorawan network
#
# Steps:
# 1. Populate the values below from your TTN configuration and device/modem.
# (For RAK Wireless devices the dev_eui is printed on top of the device.)
# 2.Then rename the file to: creds_config.py
#
# Done, the file will then be imported into the other scripts at run time.
dev_eui="XXXXXXXXXXXXXX"
# or
dev_eui_rak4200="XXXXXXXXXXXXXX"
# or
dev_eui_rak3172="XXXXXXXXXXXXXX"
#
# Depending on which script you use etc.
app_eui="YYYYYYYYYYYYYY"
app_key="ZZZZZZZZZZZZZZ"
| dev_eui = 'XXXXXXXXXXXXXX'
dev_eui_rak4200 = 'XXXXXXXXXXXXXX'
dev_eui_rak3172 = 'XXXXXXXXXXXXXX'
app_eui = 'YYYYYYYYYYYYYY'
app_key = 'ZZZZZZZZZZZZZZ' |
"""
entradas
mujeres-->muj-->int
hombres-->hom-->int
sumatotal=tot
salidas
porcentajemujeres=mujp
porcentajehombres=homp
"""
#entradas
muj=int(input("Ingrese el numero de mujeres "))
hom=int(input("Ingrese el numero de hombres "))
#caja negra
tot=muj+hom
mujp=(muj/tot)*100
homp=(hom/tot)*100
#salidas
print("El porcentajes de mujeres es ", mujp, "%")
print("El porcentajes de hombres es ", homp, "%") | """
entradas
mujeres-->muj-->int
hombres-->hom-->int
sumatotal=tot
salidas
porcentajemujeres=mujp
porcentajehombres=homp
"""
muj = int(input('Ingrese el numero de mujeres '))
hom = int(input('Ingrese el numero de hombres '))
tot = muj + hom
mujp = muj / tot * 100
homp = hom / tot * 100
print('El porcentajes de mujeres es ', mujp, '%')
print('El porcentajes de hombres es ', homp, '%') |
def main():
n, m = [int(x) for x in input().split()]
def wczytajJiro():
defs = [0]*n
atks = [0]*n
both = [0]*2*n
defi = atki = bothi = 0
for i in range(n):
pi, si = input().split()
if (pi == 'ATK'):
atks[atki] = int(si)
atki += 1
both[bothi] = int(si)
bothi += 1
else:
defs[defi] = int(si)
defi += 1
both[bothi] = int(si) + 1
bothi += 1
return (sorted(defs[:defi]), sorted(atks[:atki]), sorted(both[:bothi]))
def wczytajCiel():
ms = [0]*m
for i in range(m):
si = int(input())
ms[i] = si
return sorted(ms)
jiro = wczytajJiro()
defenses, attacks, both = jiro
ciel = wczytajCiel()
def czyZabijamyWszyskie():
zzamkowane = zip(reversed(ciel), reversed(both))
checked = map(lambda cj : cj[0] - cj[1] >= 0, zzamkowane)
return all(checked)
def f(cj):
c, j = cj
r = c - j
if (r >= 0):
return r
else:
return 0
def bezNajslabszychObroncow():
w = 0
wyniklen = len(ciel)
for d in defenses:
while w != wyniklen and ciel[w] <= d:
w += 1
if w == wyniklen:
break
ciel[w] = 0
return sum(ciel)
if czyZabijamyWszyskie():
w = sum(map(f, zip(reversed(ciel), attacks)))
w1 = bezNajslabszychObroncow()
w2 = sum(attacks)
print(max(w, w1 - w2))
else:
w = sum(map(f, zip(reversed(ciel), attacks)))
print(w)
main()
| def main():
(n, m) = [int(x) for x in input().split()]
def wczytaj_jiro():
defs = [0] * n
atks = [0] * n
both = [0] * 2 * n
defi = atki = bothi = 0
for i in range(n):
(pi, si) = input().split()
if pi == 'ATK':
atks[atki] = int(si)
atki += 1
both[bothi] = int(si)
bothi += 1
else:
defs[defi] = int(si)
defi += 1
both[bothi] = int(si) + 1
bothi += 1
return (sorted(defs[:defi]), sorted(atks[:atki]), sorted(both[:bothi]))
def wczytaj_ciel():
ms = [0] * m
for i in range(m):
si = int(input())
ms[i] = si
return sorted(ms)
jiro = wczytaj_jiro()
(defenses, attacks, both) = jiro
ciel = wczytaj_ciel()
def czy_zabijamy_wszyskie():
zzamkowane = zip(reversed(ciel), reversed(both))
checked = map(lambda cj: cj[0] - cj[1] >= 0, zzamkowane)
return all(checked)
def f(cj):
(c, j) = cj
r = c - j
if r >= 0:
return r
else:
return 0
def bez_najslabszych_obroncow():
w = 0
wyniklen = len(ciel)
for d in defenses:
while w != wyniklen and ciel[w] <= d:
w += 1
if w == wyniklen:
break
ciel[w] = 0
return sum(ciel)
if czy_zabijamy_wszyskie():
w = sum(map(f, zip(reversed(ciel), attacks)))
w1 = bez_najslabszych_obroncow()
w2 = sum(attacks)
print(max(w, w1 - w2))
else:
w = sum(map(f, zip(reversed(ciel), attacks)))
print(w)
main() |
load_modules = {
'hw_USBtin': {'port':'auto', 'debug':2, 'speed':500}, # IO hardware module
'ecu_controls':
{'bus':'BMW_F10',
'commands':[
# Music actions
{'High light - blink': '0x1ee:2:20ff', 'cmd':'127'},
{'TURN LEFT and RIGHT': '0x2fc:7:31000000000000', 'cmd':'126'},
{'TURN right ON PERMANENT': '0x1ee:2:01ff', 'cmd':'124'},
{'TURN right x3 or OFF PERMANENT':'0x1ee:2:02ff','cmd':'123'},
{'TURN left ON PERMANENT': '0x1ee:2:04ff', 'cmd':'122'},
{'TURN left x3 or OFF PERMANENT':'0x1ee:2:08ff','cmd':'121'},
{'STOP lights': '0x173:8:3afa00022000f2c4', 'cmd':'120'},
{'CLEANER - once':'0x2a6:2:02a1','cmd':'119'},
{'CLEANER x3 + Wasser':'0x2a6:2:10f1','cmd':'118'},
{'Mirrors+windows FOLD':'0x26e:8:5b5b4002ffffffff','cmd':"117"},
{'Mirrors UNfold':'0x2fc:7:12000000000000','cmd':"116"},
{'Windows open':'0x26e:8:49494001ffffffff','cmd':"115"},
{'Windows rear close + Mirrors FOLD':'0x26e:8:405b4002ffffffff','cmd':"114"},
{'Trunk open':'0x2a0:8:88888001ffffffff','cmd':"113"},
{'Trunk close':'0x23a:8:00f310f0fcf0ffff','cmd':"112"}
],
'statuses':[
]
}
}
# Now let's describe the logic of this test
actions = [
{'ecu_controls' : {}},
{'hw_USBtin': {'action':'write','pipe': 1}}
] | load_modules = {'hw_USBtin': {'port': 'auto', 'debug': 2, 'speed': 500}, 'ecu_controls': {'bus': 'BMW_F10', 'commands': [{'High light - blink': '0x1ee:2:20ff', 'cmd': '127'}, {'TURN LEFT and RIGHT': '0x2fc:7:31000000000000', 'cmd': '126'}, {'TURN right ON PERMANENT': '0x1ee:2:01ff', 'cmd': '124'}, {'TURN right x3 or OFF PERMANENT': '0x1ee:2:02ff', 'cmd': '123'}, {'TURN left ON PERMANENT': '0x1ee:2:04ff', 'cmd': '122'}, {'TURN left x3 or OFF PERMANENT': '0x1ee:2:08ff', 'cmd': '121'}, {'STOP lights': '0x173:8:3afa00022000f2c4', 'cmd': '120'}, {'CLEANER - once': '0x2a6:2:02a1', 'cmd': '119'}, {'CLEANER x3 + Wasser': '0x2a6:2:10f1', 'cmd': '118'}, {'Mirrors+windows FOLD': '0x26e:8:5b5b4002ffffffff', 'cmd': '117'}, {'Mirrors UNfold': '0x2fc:7:12000000000000', 'cmd': '116'}, {'Windows open': '0x26e:8:49494001ffffffff', 'cmd': '115'}, {'Windows rear close + Mirrors FOLD': '0x26e:8:405b4002ffffffff', 'cmd': '114'}, {'Trunk open': '0x2a0:8:88888001ffffffff', 'cmd': '113'}, {'Trunk close': '0x23a:8:00f310f0fcf0ffff', 'cmd': '112'}], 'statuses': []}}
actions = [{'ecu_controls': {}}, {'hw_USBtin': {'action': 'write', 'pipe': 1}}] |
#!/usr/bin/env python3
fname = input("Enter file name: ")
fh = open(fname)
lst = list()
sorted_words = list()
for line in fh:
line = line.rstrip()
words = line.split()
for word in words:
if lst.count(word) == 0:
lst.append(word)
lst.sort()
print(lst)
| fname = input('Enter file name: ')
fh = open(fname)
lst = list()
sorted_words = list()
for line in fh:
line = line.rstrip()
words = line.split()
for word in words:
if lst.count(word) == 0:
lst.append(word)
lst.sort()
print(lst) |
# Python3 program to add two numbers
number1 = input("First number: ")
number2 = input("\nSecond number: ")
# Adding two numbers
# User might also enter float numbers
sum = float(number1) + float(number2)
# Display the sum
# will print value in float
print("The sum of {0} and {1} is {2}" .format(number1, number2, sum))
| number1 = input('First number: ')
number2 = input('\nSecond number: ')
sum = float(number1) + float(number2)
print('The sum of {0} and {1} is {2}'.format(number1, number2, sum)) |
def extractCNovelProj(item):
"""
"""
vol, chp, frag, postfix = extractVolChapterFragmentPostfix(item['title'])
if not (chp or vol) or "preview" in item['title'].lower():
return None
tagmap = [
('Please Be More Serious', 'Please Be More Serious', 'translated'),
('Still Not Wanting to Forget', 'Still Not Wanting to Forget', 'translated'),
('suddenly this summer', 'Suddenly, This Summer', 'translated'),
('mr earnest is my boyfriend', 'Mr. Earnest Is My Boyfriend', 'translated'),
]
for tagname, name, tl_type in tagmap:
if tagname in item['tags']:
return buildReleaseMessageWithType(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False | def extract_c_novel_proj(item):
"""
"""
(vol, chp, frag, postfix) = extract_vol_chapter_fragment_postfix(item['title'])
if not (chp or vol) or 'preview' in item['title'].lower():
return None
tagmap = [('Please Be More Serious', 'Please Be More Serious', 'translated'), ('Still Not Wanting to Forget', 'Still Not Wanting to Forget', 'translated'), ('suddenly this summer', 'Suddenly, This Summer', 'translated'), ('mr earnest is my boyfriend', 'Mr. Earnest Is My Boyfriend', 'translated')]
for (tagname, name, tl_type) in tagmap:
if tagname in item['tags']:
return build_release_message_with_type(item, name, vol, chp, frag=frag, postfix=postfix, tl_type=tl_type)
return False |
class Solution:
# @param {string} a a number
# @param {string} b a number
# @return {string} the result
def addBinary(self, a, b):
# Write your code here
max_len = max(len(a), len(b))
a = a.zfill(max_len)
b = b.zfill(max_len)
result = ''
carry = 0
for a, b in zip(a, b)[::-1]:
bits_sum = carry
bits_sum += int(a) + int(b)
result = ('0' if bits_sum % 2 == 0 else '1') + result
carry = 0 if bits_sum < 2 else 1
result = ('1' if carry > 0 else '') + result
return result
| class Solution:
def add_binary(self, a, b):
max_len = max(len(a), len(b))
a = a.zfill(max_len)
b = b.zfill(max_len)
result = ''
carry = 0
for (a, b) in zip(a, b)[::-1]:
bits_sum = carry
bits_sum += int(a) + int(b)
result = ('0' if bits_sum % 2 == 0 else '1') + result
carry = 0 if bits_sum < 2 else 1
result = ('1' if carry > 0 else '') + result
return result |
class Solution:
def dailyTemperatures(self, T: list) -> list:
if len(T) == 1:
return [0]
else:
mono_stack = [(T[0], 0)]
i = 1
res = [0] * len(T)
while i < len(T):
if T[i] <= mono_stack[-1][0]:
mono_stack.append((T[i], i))
else:
while mono_stack:
if T[i] > mono_stack[-1][0]:
_, popped_idx = mono_stack.pop()
res[popped_idx] = i - popped_idx
else:
break
mono_stack.append((T[i], i))
i += 1
return res
if __name__ == "__main__":
solu = Solution()
print(solu.dailyTemperatures([73, 74, 75, 71, 69, 72, 76, 73])) | class Solution:
def daily_temperatures(self, T: list) -> list:
if len(T) == 1:
return [0]
else:
mono_stack = [(T[0], 0)]
i = 1
res = [0] * len(T)
while i < len(T):
if T[i] <= mono_stack[-1][0]:
mono_stack.append((T[i], i))
else:
while mono_stack:
if T[i] > mono_stack[-1][0]:
(_, popped_idx) = mono_stack.pop()
res[popped_idx] = i - popped_idx
else:
break
mono_stack.append((T[i], i))
i += 1
return res
if __name__ == '__main__':
solu = solution()
print(solu.dailyTemperatures([73, 74, 75, 71, 69, 72, 76, 73])) |
with open("inputs_7.txt") as f:
inputs = [x.strip() for x in f.readlines()]
ex_inputs= [
"shiny gold bags contain 2 dark red bags.",
"dark red bags contain 2 dark orange bags.",
"dark orange bags contain 2 dark yellow bags.",
"dark yellow bags contain 2 dark green bags.",
"dark green bags contain 2 dark blue bags.",
"dark blue bags contain 2 dark violet bags.",
"dark violet bags contain no other bags."
]
def find_bags_containing_colour(roster, colour):
bags = []
for key, value in roster.items():
if colour in (x[1] for x in value):
bags.append(key)
bags.extend(find_bags_containing_colour(roster, key))
return bags
def part1(inputs):
roster = {}
for line in inputs:
colour = line[:line.index(" bags")]
contents = line.split("contain")[1].strip().replace(" bags", "").replace(" bag", "").split(", ")
if "no other" in line:
continue
roster[colour] = []
for content in contents:
num = content[:content.index(" ")]
content_colour = content[content.index(" ") + 1 :].strip(".")
roster[colour].append((num, content_colour))
bags = set(find_bags_containing_colour(roster, "shiny gold"))
print(len(bags))
def count_bags(roster, colour):
total = 1
for bag in roster[colour]:
if bag[1] == "None":
print(f"No Bags in {colour}, return 1")
return 1
else:
print(bag[0] * count_bags(roster, bag[1]))
total += bag[0] * count_bags(roster, bag[1])
print(total, colour)
return total
def part2(inputs):
roster = {}
for line in inputs:
colour = line[:line.index(" bags")]
contents = line.split("contain")[1].strip().replace(" bags", "").replace(" bag", "").split(", ")
roster[colour] = []
for content in contents:
if "no other" in line:
num = 0
content_colour = "None"
else:
num = int(content[:content.index(" ")])
content_colour = content[content.index(" ") + 1 :].strip(".")
roster[colour].append((int(num), content_colour))
total = 0
total = count_bags(roster,"shiny gold")
print(f"Current Total: {total}")
# minus the shiny gold bag from the count
print(total - 1)
# part1(inputs)
# not 75,31
part2(inputs) | with open('inputs_7.txt') as f:
inputs = [x.strip() for x in f.readlines()]
ex_inputs = ['shiny gold bags contain 2 dark red bags.', 'dark red bags contain 2 dark orange bags.', 'dark orange bags contain 2 dark yellow bags.', 'dark yellow bags contain 2 dark green bags.', 'dark green bags contain 2 dark blue bags.', 'dark blue bags contain 2 dark violet bags.', 'dark violet bags contain no other bags.']
def find_bags_containing_colour(roster, colour):
bags = []
for (key, value) in roster.items():
if colour in (x[1] for x in value):
bags.append(key)
bags.extend(find_bags_containing_colour(roster, key))
return bags
def part1(inputs):
roster = {}
for line in inputs:
colour = line[:line.index(' bags')]
contents = line.split('contain')[1].strip().replace(' bags', '').replace(' bag', '').split(', ')
if 'no other' in line:
continue
roster[colour] = []
for content in contents:
num = content[:content.index(' ')]
content_colour = content[content.index(' ') + 1:].strip('.')
roster[colour].append((num, content_colour))
bags = set(find_bags_containing_colour(roster, 'shiny gold'))
print(len(bags))
def count_bags(roster, colour):
total = 1
for bag in roster[colour]:
if bag[1] == 'None':
print(f'No Bags in {colour}, return 1')
return 1
else:
print(bag[0] * count_bags(roster, bag[1]))
total += bag[0] * count_bags(roster, bag[1])
print(total, colour)
return total
def part2(inputs):
roster = {}
for line in inputs:
colour = line[:line.index(' bags')]
contents = line.split('contain')[1].strip().replace(' bags', '').replace(' bag', '').split(', ')
roster[colour] = []
for content in contents:
if 'no other' in line:
num = 0
content_colour = 'None'
else:
num = int(content[:content.index(' ')])
content_colour = content[content.index(' ') + 1:].strip('.')
roster[colour].append((int(num), content_colour))
total = 0
total = count_bags(roster, 'shiny gold')
print(f'Current Total: {total}')
print(total - 1)
part2(inputs) |
#Simple calculator
def add(x,y):
return x+y
def subs(x,y):
return x-y
def multi(x,y):
return x*y
def divide(x,y):
return x/y
num1 = int(input("Enter the Value of Num1 :"))
num2 = int(input("Enter the Value of NUm2 :"))
print("Choose 1 for '+'/ 2 for '-'/ 3 for '*'/ 4 for '/' :-")
select = int(input("Enter the 1/2/3/4 :"))
if select == 1 :
print(num1,"+",num2,"=",add(num1,num2))
elif select == 2 :
print(num1,"-",num2,"=",subs(num1,num2))
elif select == 3 :
print(num1,"*",num2,"=",multi(num1,num2))
elif select == 4 :
print(num1,"/",num2,"=",divide(num1,num2))
else:
print("Enter the Valid number.")
| def add(x, y):
return x + y
def subs(x, y):
return x - y
def multi(x, y):
return x * y
def divide(x, y):
return x / y
num1 = int(input('Enter the Value of Num1 :'))
num2 = int(input('Enter the Value of NUm2 :'))
print("Choose 1 for '+'/ 2 for '-'/ 3 for '*'/ 4 for '/' :-")
select = int(input('Enter the 1/2/3/4 :'))
if select == 1:
print(num1, '+', num2, '=', add(num1, num2))
elif select == 2:
print(num1, '-', num2, '=', subs(num1, num2))
elif select == 3:
print(num1, '*', num2, '=', multi(num1, num2))
elif select == 4:
print(num1, '/', num2, '=', divide(num1, num2))
else:
print('Enter the Valid number.') |
PI = float(3.14159)
raio = float(input())
print("A=%0.4f" %(PI * (raio * raio)))
| pi = float(3.14159)
raio = float(input())
print('A=%0.4f' % (PI * (raio * raio))) |
x = {}
with open('input.txt', 'r', encoding='utf8') as f:
for line in f:
line = line.strip()
x[line] = x.get(line, 0) + 1
lol = [(y, x) for x, y in x.items()]
lol.sort()
with open('output.txt', 'w', encoding='utf8') as f:
if lol[-1][0] / sum(x.values()) > 0.5:
f.write(lol[-1][1])
else:
f.write(lol[-1][1])
f.write("\n")
f.write(lol[-2][1])
| x = {}
with open('input.txt', 'r', encoding='utf8') as f:
for line in f:
line = line.strip()
x[line] = x.get(line, 0) + 1
lol = [(y, x) for (x, y) in x.items()]
lol.sort()
with open('output.txt', 'w', encoding='utf8') as f:
if lol[-1][0] / sum(x.values()) > 0.5:
f.write(lol[-1][1])
else:
f.write(lol[-1][1])
f.write('\n')
f.write(lol[-2][1]) |
{
"includes": [
"drafter/common.gypi"
],
"targets": [
{
"target_name": "protagonist",
"include_dirs": [
"drafter/src",
"<!(node -e \"require('nan')\")"
],
"sources": [
"src/options_parser.cc",
"src/parse_async.cc",
"src/parse_sync.cc",
"src/protagonist.cc",
"src/protagonist.h",
"src/refractToV8.cc",
"src/validate_async.cc",
"src/validate_sync.cc"
],
"conditions" : [
[ 'libdrafter_type=="shared_library"', { 'defines' : [ 'DRAFTER_BUILD_SHARED' ] }, { 'defines' : [ 'DRAFTER_BUILD_STATIC' ] }],
],
"dependencies": [
"drafter/drafter.gyp:libdrafter",
]
}
]
}
| {'includes': ['drafter/common.gypi'], 'targets': [{'target_name': 'protagonist', 'include_dirs': ['drafter/src', '<!(node -e "require(\'nan\')")'], 'sources': ['src/options_parser.cc', 'src/parse_async.cc', 'src/parse_sync.cc', 'src/protagonist.cc', 'src/protagonist.h', 'src/refractToV8.cc', 'src/validate_async.cc', 'src/validate_sync.cc'], 'conditions': [['libdrafter_type=="shared_library"', {'defines': ['DRAFTER_BUILD_SHARED']}, {'defines': ['DRAFTER_BUILD_STATIC']}]], 'dependencies': ['drafter/drafter.gyp:libdrafter']}]} |
# Chalk Damage Skin
success = sm.addDamageSkin(2433236)
if success:
sm.chat("The Chalk Damage Skin has been added to your account's damage skin collection.")
| success = sm.addDamageSkin(2433236)
if success:
sm.chat("The Chalk Damage Skin has been added to your account's damage skin collection.") |
"""
Key point:
- Locate a '1' first and make all the right, left, up and down to '0'.
- Make all the adjacent '1' to '0' so all the islands would be counted.
"""
class Solution:
def numIslands(self, grid):
if not grid:
return 0
row = len(grid)
col = len(grid[0])
count = 0
for i in range(row):
for j in range(col):
if grid[i][j] == '1':
self.dfs(grid, row, col, i, j)
count += 1
return count
def dfs(self, grid, row, col, x, y):
if grid[x][y] == '0':
return
grid[x][y] = '0'
if x != 0:
self.dfs(grid, row, col, x - 1 , y)
if x != row - 1:
self.dfs(grid, row, col, x + 1, y)
if y != 0:
self.dfs(grid, row, col, x, y - 1)
if y != col - 1:
self.dfs(grid, row, col, x, y + 1)
if __name__ == "__main__":
grid = [
["1","1","1","1","0"],
["1","1","0","1","0"],
["1","1","0","0","0"],
["0","0","0","0","0"]
]
s = Solution()
print(s.numIslands(grid)) | """
Key point:
- Locate a '1' first and make all the right, left, up and down to '0'.
- Make all the adjacent '1' to '0' so all the islands would be counted.
"""
class Solution:
def num_islands(self, grid):
if not grid:
return 0
row = len(grid)
col = len(grid[0])
count = 0
for i in range(row):
for j in range(col):
if grid[i][j] == '1':
self.dfs(grid, row, col, i, j)
count += 1
return count
def dfs(self, grid, row, col, x, y):
if grid[x][y] == '0':
return
grid[x][y] = '0'
if x != 0:
self.dfs(grid, row, col, x - 1, y)
if x != row - 1:
self.dfs(grid, row, col, x + 1, y)
if y != 0:
self.dfs(grid, row, col, x, y - 1)
if y != col - 1:
self.dfs(grid, row, col, x, y + 1)
if __name__ == '__main__':
grid = [['1', '1', '1', '1', '0'], ['1', '1', '0', '1', '0'], ['1', '1', '0', '0', '0'], ['0', '0', '0', '0', '0']]
s = solution()
print(s.numIslands(grid)) |
N_T = input().split()
N = int(N_T[0])
T = int(N_T[1])
interactions = []
input_condition = input()
conditions = list(input_condition)
conditions = [int(x) for x in conditions]
for x in range(T):
input_line = input().split()
input_line = [int(x) for x in input_line]
interactions.append(input_line)
sorted_interactions = sorted(interactions)
largest_k = 0
minimum_k = T
patient_zero = 0
for cow_num in range(0, N): #zeros -- x is cow number
temp_conditions = [0 for x in range(len(conditions))]
temp_conditions[cow_num] = 1
for y in range(0, len(interactions)): #loops through the process
if cow_num == interactions[y][1]-1:
temp_conditions[interactions[y][2]-1] = 1
elif cow_num == interactions[y][2]-1:
temp_conditions[interactions[y][1]-1] = 1
if temp_conditions == conditions: #checks if condition arrays match, if so, counter + 1
patient_zero += 1
print(patient_zero)
| n_t = input().split()
n = int(N_T[0])
t = int(N_T[1])
interactions = []
input_condition = input()
conditions = list(input_condition)
conditions = [int(x) for x in conditions]
for x in range(T):
input_line = input().split()
input_line = [int(x) for x in input_line]
interactions.append(input_line)
sorted_interactions = sorted(interactions)
largest_k = 0
minimum_k = T
patient_zero = 0
for cow_num in range(0, N):
temp_conditions = [0 for x in range(len(conditions))]
temp_conditions[cow_num] = 1
for y in range(0, len(interactions)):
if cow_num == interactions[y][1] - 1:
temp_conditions[interactions[y][2] - 1] = 1
elif cow_num == interactions[y][2] - 1:
temp_conditions[interactions[y][1] - 1] = 1
if temp_conditions == conditions:
patient_zero += 1
print(patient_zero) |
#WAP to calculate and display the factorial of
#an inputted number.
num = int(input("enter the range for factorial: "))
f = 1
if num < 0:
print("factorial does not exist")
elif num == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,num + 1):
f = f * i
print("The factorial of",num,"is",f)
| num = int(input('enter the range for factorial: '))
f = 1
if num < 0:
print('factorial does not exist')
elif num == 0:
print('The factorial of 0 is 1')
else:
for i in range(1, num + 1):
f = f * i
print('The factorial of', num, 'is', f) |
"""
while / Else
contadores
acumuladores
"""
contador = 1
acumulador = 1
while contador <= 20:
print(contador, acumulador)
acumulador += contador
contador += 1
if contador > 7:
break
else:
print('cheguei no else')
print('sai do while')
| """
while / Else
contadores
acumuladores
"""
contador = 1
acumulador = 1
while contador <= 20:
print(contador, acumulador)
acumulador += contador
contador += 1
if contador > 7:
break
else:
print('cheguei no else')
print('sai do while') |
def pascal_nth_row(line_num):
if line_num == 0:
return [1]
line = [1]
last_line = pascal_nth_row(line_num - 1)
for i in range(len(last_line) - 1):
line.append(last_line[i] + last_line[i + 1])
line.append(1)
# line here will the line at num line_num
return line
print(pascal_nth_row(5)) | def pascal_nth_row(line_num):
if line_num == 0:
return [1]
line = [1]
last_line = pascal_nth_row(line_num - 1)
for i in range(len(last_line) - 1):
line.append(last_line[i] + last_line[i + 1])
line.append(1)
return line
print(pascal_nth_row(5)) |
#Attept a
def isPerfectSquare(n):
if n <= 1:
return True
start = 0
end = n//2
while((end - start) > 1):
mid = (start + end)//2
sq = mid*mid
print(mid, sq, start, end)
if sq == n:
return True
if sq > n:
end = mid
if sq < n:
start = mid
return False
s = 1111*1111
print(isPerfectSquare(s))
| def is_perfect_square(n):
if n <= 1:
return True
start = 0
end = n // 2
while end - start > 1:
mid = (start + end) // 2
sq = mid * mid
print(mid, sq, start, end)
if sq == n:
return True
if sq > n:
end = mid
if sq < n:
start = mid
return False
s = 1111 * 1111
print(is_perfect_square(s)) |
"""Below Python Programme demonstrate maketrans
functions in a string"""
#Example:
# example dictionary
dict = {"a": "123", "b": "456", "c": "789"}
string = "abc"
print(string.maketrans(dict))
# example dictionary
dict = {97: "123", 98: "456", 99: "789"}
string = "abc"
print(string.maketrans(dict))
| """Below Python Programme demonstrate maketrans
functions in a string"""
dict = {'a': '123', 'b': '456', 'c': '789'}
string = 'abc'
print(string.maketrans(dict))
dict = {97: '123', 98: '456', 99: '789'}
string = 'abc'
print(string.maketrans(dict)) |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
base_url = "https://es.wikiquote.org/w/api.php"
quote_of_the_day_url = "https://es.wikiquote.org/wiki/Portada"
def quote_of_the_day_parser(html):
table = html("table")[1]("table")[0]
quote = table("td")[3].text.strip()
author = table("td")[5].div.a.text.strip()
# Author and quote could have an accent
return (quote, author)
non_quote_sections = ["sobre", "referencias"]
| base_url = 'https://es.wikiquote.org/w/api.php'
quote_of_the_day_url = 'https://es.wikiquote.org/wiki/Portada'
def quote_of_the_day_parser(html):
table = html('table')[1]('table')[0]
quote = table('td')[3].text.strip()
author = table('td')[5].div.a.text.strip()
return (quote, author)
non_quote_sections = ['sobre', 'referencias'] |
# membuat tupple
buah = ('anggur', 'jeruk', 'mangga')
print(buah) # output: ('anggur', 'jeruk', 'mangga')
| buah = ('anggur', 'jeruk', 'mangga')
print(buah) |
input = """
1 2 0 0
1 3 0 0
1 4 0 0
1 5 0 0
1 6 0 0
1 7 0 0
1 8 0 0
1 9 0 0
1 10 0 0
1 11 0 0
1 12 0 0
1 13 0 0
1 14 0 0
1 15 0 0
1 16 0 0
1 17 0 0
1 18 0 0
1 19 0 0
1 20 0 0
1 21 0 0
1 22 0 0
1 23 0 0
1 24 0 0
1 25 0 0
1 26 0 0
1 27 0 0
1 28 0 0
1 29 0 0
1 30 0 0
1 31 0 0
1 32 0 0
1 33 0 0
1 34 0 0
1 35 0 0
1 36 0 0
1 37 0 0
1 38 0 0
1 39 0 0
1 40 0 0
1 41 0 0
1 42 0 0
1 43 0 0
1 44 0 0
1 45 0 0
1 46 0 0
1 47 0 0
1 48 0 0
1 49 0 0
1 50 0 0
1 51 0 0
1 52 0 0
1 53 0 0
1 54 0 0
1 55 0 0
1 56 0 0
1 57 0 0
1 58 0 0
1 59 0 0
1 60 0 0
1 61 0 0
1 62 0 0
1 63 0 0
1 64 0 0
1 65 0 0
1 66 0 0
1 67 0 0
1 68 0 0
1 69 0 0
1 70 0 0
1 71 0 0
1 72 0 0
1 73 0 0
1 74 0 0
1 75 0 0
1 76 0 0
1 77 0 0
1 78 0 0
1 79 0 0
1 80 0 0
1 81 0 0
1 82 0 0
1 83 0 0
1 84 0 0
1 85 0 0
1 86 0 0
1 87 0 0
1 88 0 0
1 89 0 0
1 90 0 0
1 91 2 1 92 93
1 92 2 1 91 93
1 93 0 0
1 94 2 1 95 96
1 95 2 1 94 96
1 96 0 0
1 97 2 1 98 99
1 98 2 1 97 99
1 99 0 0
1 100 2 1 101 102
1 101 2 1 100 102
1 102 0 0
1 103 2 1 104 105
1 104 2 1 103 105
1 105 0 0
1 106 2 1 107 108
1 107 2 1 106 108
1 108 0 0
1 109 2 1 110 111
1 110 2 1 109 111
1 111 0 0
1 112 2 1 113 114
1 113 2 1 112 114
1 114 0 0
1 115 2 1 116 117
1 116 2 1 115 117
1 117 0 0
1 118 2 1 119 120
1 119 2 1 118 120
1 120 0 0
1 121 2 1 122 123
1 122 2 1 121 123
1 123 0 0
1 124 2 1 125 126
1 125 2 1 124 126
1 126 0 0
1 127 2 1 128 129
1 128 2 1 127 129
1 129 0 0
1 130 2 1 131 132
1 131 2 1 130 132
1 132 0 0
1 133 2 1 134 135
1 134 2 1 133 135
1 135 0 0
1 136 2 1 137 138
1 137 2 1 136 138
1 138 0 0
1 139 2 1 140 141
1 140 2 1 139 141
1 141 0 0
1 142 2 1 143 144
1 143 2 1 142 144
1 144 0 0
1 145 2 1 146 147
1 146 2 1 145 147
1 147 0 0
1 148 2 1 149 150
1 149 2 1 148 150
1 150 0 0
1 151 2 1 152 153
1 152 2 1 151 153
1 153 0 0
1 154 2 1 155 156
1 155 2 1 154 156
1 156 0 0
1 157 2 1 158 159
1 158 2 1 157 159
1 159 0 0
1 160 2 1 161 162
1 161 2 1 160 162
1 162 0 0
1 163 2 1 164 165
1 164 2 1 163 165
1 165 0 0
1 166 2 1 167 168
1 167 2 1 166 168
1 168 0 0
1 169 2 1 170 171
1 170 2 1 169 171
1 171 0 0
1 172 2 1 173 174
1 173 2 1 172 174
1 174 0 0
1 175 2 1 176 177
1 176 2 1 175 177
1 177 0 0
1 178 2 1 179 180
1 179 2 1 178 180
1 180 0 0
1 181 2 1 182 183
1 182 2 1 181 183
1 183 0 0
1 184 2 1 185 186
1 185 2 1 184 186
1 186 0 0
1 187 2 1 188 189
1 188 2 1 187 189
1 189 0 0
1 190 2 1 191 192
1 191 2 1 190 192
1 192 0 0
1 193 2 1 194 195
1 194 2 1 193 195
1 195 0 0
1 196 2 1 197 198
1 197 2 1 196 198
1 198 0 0
1 199 2 1 200 201
1 200 2 1 199 201
1 201 0 0
1 202 2 1 203 204
1 203 2 1 202 204
1 204 0 0
1 205 2 1 206 207
1 206 2 1 205 207
1 207 0 0
1 208 2 1 209 210
1 209 2 1 208 210
1 210 0 0
1 211 2 1 212 213
1 212 2 1 211 213
1 213 0 0
1 214 2 1 215 216
1 215 2 1 214 216
1 216 0 0
1 217 2 1 218 219
1 218 2 1 217 219
1 219 0 0
1 220 2 1 221 222
1 221 2 1 220 222
1 222 0 0
1 223 2 1 224 225
1 224 2 1 223 225
1 225 0 0
1 226 2 1 227 228
1 227 2 1 226 228
1 228 0 0
1 229 2 1 230 231
1 230 2 1 229 231
1 231 0 0
1 232 2 1 233 234
1 233 2 1 232 234
1 234 0 0
1 235 2 1 236 237
1 236 2 1 235 237
1 237 0 0
1 238 2 1 239 240
1 239 2 1 238 240
1 240 0 0
1 241 2 1 242 243
1 242 2 1 241 243
1 243 0 0
1 244 2 1 245 246
1 245 2 1 244 246
1 246 0 0
1 247 2 1 248 249
1 248 2 1 247 249
1 249 0 0
1 250 2 1 251 252
1 251 2 1 250 252
1 252 0 0
1 253 2 1 254 255
1 254 2 1 253 255
1 255 0 0
1 256 2 1 257 258
1 257 2 1 256 258
1 258 0 0
1 259 2 1 260 261
1 260 2 1 259 261
1 261 0 0
1 262 2 1 263 264
1 263 2 1 262 264
1 264 0 0
1 265 2 1 266 267
1 266 2 1 265 267
1 267 0 0
1 268 2 1 269 270
1 269 2 1 268 270
1 270 0 0
2 271 3 0 2 211 151 91
1 1 1 0 271
2 272 3 0 2 214 154 94
1 1 1 0 272
2 273 3 0 2 217 157 97
1 1 1 0 273
2 274 3 0 2 220 160 100
1 1 1 0 274
2 275 3 0 2 223 163 103
1 1 1 0 275
2 276 3 0 2 226 166 106
1 1 1 0 276
2 277 3 0 2 229 169 109
1 1 1 0 277
2 278 3 0 2 232 172 112
1 1 1 0 278
2 279 3 0 2 235 175 115
1 1 1 0 279
2 280 3 0 2 238 178 118
1 1 1 0 280
2 281 3 0 2 241 181 121
1 1 1 0 281
2 282 3 0 2 244 184 124
1 1 1 0 282
2 283 3 0 2 247 187 127
1 1 1 0 283
2 284 3 0 2 250 190 130
1 1 1 0 284
2 285 3 0 2 253 193 133
1 1 1 0 285
2 286 3 0 2 256 196 136
1 1 1 0 286
2 287 3 0 2 259 199 139
1 1 1 0 287
2 288 3 0 2 262 202 142
1 1 1 0 288
2 289 3 0 2 265 205 145
1 1 1 0 289
2 290 3 0 2 268 208 148
1 1 1 0 290
2 291 3 0 1 211 151 91
1 1 1 1 291
2 292 3 0 1 214 154 94
1 1 1 1 292
2 293 3 0 1 217 157 97
1 1 1 1 293
2 294 3 0 1 220 160 100
1 1 1 1 294
2 295 3 0 1 223 163 103
1 1 1 1 295
2 296 3 0 1 226 166 106
1 1 1 1 296
2 297 3 0 1 229 169 109
1 1 1 1 297
2 298 3 0 1 232 172 112
1 1 1 1 298
2 299 3 0 1 235 175 115
1 1 1 1 299
2 300 3 0 1 238 178 118
1 1 1 1 300
2 301 3 0 1 241 181 121
1 1 1 1 301
2 302 3 0 1 244 184 124
1 1 1 1 302
2 303 3 0 1 247 187 127
1 1 1 1 303
2 304 3 0 1 250 190 130
1 1 1 1 304
2 305 3 0 1 253 193 133
1 1 1 1 305
2 306 3 0 1 256 196 136
1 1 1 1 306
2 307 3 0 1 259 199 139
1 1 1 1 307
2 308 3 0 1 262 202 142
1 1 1 1 308
2 309 3 0 1 265 205 145
1 1 1 1 309
2 310 3 0 1 268 208 148
1 1 1 1 310
1 1 2 0 268 220
1 1 2 0 265 253
1 1 2 0 265 223
1 1 2 0 265 217
1 1 2 0 262 256
1 1 2 0 262 253
1 1 2 0 262 226
1 1 2 0 262 211
1 1 2 0 259 226
1 1 2 0 256 217
1 1 2 0 256 211
1 1 2 0 253 226
1 1 2 0 253 217
1 1 2 0 250 235
1 1 2 0 250 226
1 1 2 0 247 244
1 1 2 0 247 241
1 1 2 0 247 235
1 1 2 0 247 229
1 1 2 0 241 235
1 1 2 0 241 226
1 1 2 0 238 235
1 1 2 0 238 211
1 1 2 0 235 211
1 1 2 0 232 229
1 1 2 0 232 220
1 1 2 0 229 217
1 1 2 0 226 223
1 1 2 0 226 217
1 1 2 0 223 211
1 1 2 0 220 217
1 1 2 0 217 211
1 1 2 0 214 211
1 1 2 0 208 160
1 1 2 0 205 193
1 1 2 0 205 163
1 1 2 0 205 157
1 1 2 0 202 196
1 1 2 0 202 193
1 1 2 0 202 166
1 1 2 0 202 151
1 1 2 0 199 166
1 1 2 0 196 157
1 1 2 0 196 151
1 1 2 0 193 166
1 1 2 0 193 157
1 1 2 0 190 175
1 1 2 0 190 166
1 1 2 0 187 184
1 1 2 0 187 181
1 1 2 0 187 175
1 1 2 0 187 169
1 1 2 0 181 175
1 1 2 0 181 166
1 1 2 0 178 175
1 1 2 0 178 151
1 1 2 0 175 151
1 1 2 0 172 169
1 1 2 0 172 160
1 1 2 0 169 157
1 1 2 0 166 163
1 1 2 0 166 157
1 1 2 0 163 151
1 1 2 0 160 157
1 1 2 0 157 151
1 1 2 0 154 151
1 1 2 0 148 100
1 1 2 0 145 133
1 1 2 0 145 103
1 1 2 0 145 97
1 1 2 0 142 136
1 1 2 0 142 133
1 1 2 0 142 106
1 1 2 0 142 91
1 1 2 0 139 106
1 1 2 0 136 97
1 1 2 0 136 91
1 1 2 0 133 106
1 1 2 0 133 97
1 1 2 0 130 115
1 1 2 0 130 106
1 1 2 0 127 124
1 1 2 0 127 121
1 1 2 0 127 115
1 1 2 0 127 109
1 1 2 0 121 115
1 1 2 0 121 106
1 1 2 0 118 115
1 1 2 0 118 91
1 1 2 0 115 91
1 1 2 0 112 109
1 1 2 0 112 100
1 1 2 0 109 97
1 1 2 0 106 103
1 1 2 0 106 97
1 1 2 0 103 91
1 1 2 0 100 97
1 1 2 0 97 91
1 1 2 0 94 91
0
22 link(1,17)
23 link(17,1)
24 link(2,6)
25 link(6,2)
26 link(2,16)
27 link(16,2)
28 link(2,18)
29 link(18,2)
30 link(3,5)
31 link(5,3)
32 link(3,6)
33 link(6,3)
34 link(3,15)
35 link(15,3)
36 link(3,20)
37 link(20,3)
38 link(4,15)
39 link(15,4)
40 link(5,18)
41 link(18,5)
42 link(5,20)
43 link(20,5)
44 link(6,15)
45 link(15,6)
46 link(6,18)
47 link(18,6)
48 link(7,12)
49 link(12,7)
50 link(7,15)
51 link(15,7)
52 link(8,9)
53 link(9,8)
54 link(8,10)
55 link(10,8)
56 link(8,12)
57 link(12,8)
58 link(8,14)
59 link(14,8)
60 link(10,12)
61 link(12,10)
62 link(10,15)
63 link(15,10)
64 link(11,12)
65 link(12,11)
66 link(11,20)
67 link(20,11)
68 link(12,20)
69 link(20,12)
70 link(13,14)
71 link(14,13)
72 link(13,17)
73 link(17,13)
74 link(14,18)
75 link(18,14)
76 link(15,16)
77 link(16,15)
78 link(15,18)
79 link(18,15)
80 link(16,20)
81 link(20,16)
82 link(17,18)
83 link(18,17)
84 link(18,20)
85 link(20,18)
86 link(19,20)
87 link(20,19)
88 colour(red0)
89 colour(green0)
90 colour(blue0)
91 chosenColour(20,blue0)
94 chosenColour(19,blue0)
97 chosenColour(18,blue0)
100 chosenColour(17,blue0)
103 chosenColour(16,blue0)
106 chosenColour(15,blue0)
109 chosenColour(14,blue0)
112 chosenColour(13,blue0)
115 chosenColour(12,blue0)
118 chosenColour(11,blue0)
121 chosenColour(10,blue0)
124 chosenColour(9,blue0)
127 chosenColour(8,blue0)
130 chosenColour(7,blue0)
133 chosenColour(6,blue0)
136 chosenColour(5,blue0)
139 chosenColour(4,blue0)
142 chosenColour(3,blue0)
145 chosenColour(2,blue0)
148 chosenColour(1,blue0)
151 chosenColour(20,green0)
154 chosenColour(19,green0)
157 chosenColour(18,green0)
160 chosenColour(17,green0)
163 chosenColour(16,green0)
166 chosenColour(15,green0)
169 chosenColour(14,green0)
172 chosenColour(13,green0)
175 chosenColour(12,green0)
178 chosenColour(11,green0)
181 chosenColour(10,green0)
184 chosenColour(9,green0)
187 chosenColour(8,green0)
190 chosenColour(7,green0)
193 chosenColour(6,green0)
196 chosenColour(5,green0)
199 chosenColour(4,green0)
202 chosenColour(3,green0)
205 chosenColour(2,green0)
208 chosenColour(1,green0)
211 chosenColour(20,red0)
214 chosenColour(19,red0)
217 chosenColour(18,red0)
220 chosenColour(17,red0)
223 chosenColour(16,red0)
226 chosenColour(15,red0)
229 chosenColour(14,red0)
232 chosenColour(13,red0)
235 chosenColour(12,red0)
238 chosenColour(11,red0)
241 chosenColour(10,red0)
244 chosenColour(9,red0)
247 chosenColour(8,red0)
250 chosenColour(7,red0)
253 chosenColour(6,red0)
256 chosenColour(5,red0)
259 chosenColour(4,red0)
262 chosenColour(3,red0)
265 chosenColour(2,red0)
268 chosenColour(1,red0)
2 node(1)
3 node(2)
4 node(3)
5 node(4)
6 node(5)
7 node(6)
8 node(7)
9 node(8)
10 node(9)
11 node(10)
12 node(11)
13 node(12)
14 node(13)
15 node(14)
16 node(15)
17 node(16)
18 node(17)
19 node(18)
20 node(19)
21 node(20)
92 notChosenColour(20,blue0)
95 notChosenColour(19,blue0)
98 notChosenColour(18,blue0)
101 notChosenColour(17,blue0)
104 notChosenColour(16,blue0)
107 notChosenColour(15,blue0)
110 notChosenColour(14,blue0)
113 notChosenColour(13,blue0)
116 notChosenColour(12,blue0)
119 notChosenColour(11,blue0)
122 notChosenColour(10,blue0)
125 notChosenColour(9,blue0)
128 notChosenColour(8,blue0)
131 notChosenColour(7,blue0)
134 notChosenColour(6,blue0)
137 notChosenColour(5,blue0)
140 notChosenColour(4,blue0)
143 notChosenColour(3,blue0)
146 notChosenColour(2,blue0)
149 notChosenColour(1,blue0)
152 notChosenColour(20,green0)
155 notChosenColour(19,green0)
158 notChosenColour(18,green0)
161 notChosenColour(17,green0)
164 notChosenColour(16,green0)
167 notChosenColour(15,green0)
170 notChosenColour(14,green0)
173 notChosenColour(13,green0)
176 notChosenColour(12,green0)
179 notChosenColour(11,green0)
182 notChosenColour(10,green0)
185 notChosenColour(9,green0)
188 notChosenColour(8,green0)
191 notChosenColour(7,green0)
194 notChosenColour(6,green0)
197 notChosenColour(5,green0)
200 notChosenColour(4,green0)
203 notChosenColour(3,green0)
206 notChosenColour(2,green0)
209 notChosenColour(1,green0)
212 notChosenColour(20,red0)
215 notChosenColour(19,red0)
218 notChosenColour(18,red0)
221 notChosenColour(17,red0)
224 notChosenColour(16,red0)
227 notChosenColour(15,red0)
230 notChosenColour(14,red0)
233 notChosenColour(13,red0)
236 notChosenColour(12,red0)
239 notChosenColour(11,red0)
242 notChosenColour(10,red0)
245 notChosenColour(9,red0)
248 notChosenColour(8,red0)
251 notChosenColour(7,red0)
254 notChosenColour(6,red0)
257 notChosenColour(5,red0)
260 notChosenColour(4,red0)
263 notChosenColour(3,red0)
266 notChosenColour(2,red0)
269 notChosenColour(1,red0)
0
B+
0
B-
1
0
1
"""
output = """
{node(1), node(2), node(3), node(4), node(5), node(6), node(7), node(8), node(9), node(10), node(11), node(12), node(13), node(14), node(15), node(16), node(17), node(18), node(19), node(20), link(1,17), link(17,1), link(2,6), link(6,2), link(2,16), link(16,2), link(2,18), link(18,2), link(3,5), link(5,3), link(3,6), link(6,3), link(3,15), link(15,3), link(3,20), link(20,3), link(4,15), link(15,4), link(5,18), link(18,5), link(5,20), link(20,5), link(6,15), link(15,6), link(6,18), link(18,6), link(7,12), link(12,7), link(7,15), link(15,7), link(8,9), link(9,8), link(8,10), link(10,8), link(8,12), link(12,8), link(8,14), link(14,8), link(10,12), link(12,10), link(10,15), link(15,10), link(11,12), link(12,11), link(11,20), link(20,11), link(12,20), link(20,12), link(13,14), link(14,13), link(13,17), link(17,13), link(14,18), link(18,14), link(15,16), link(16,15), link(15,18), link(18,15), link(16,20), link(20,16), link(17,18), link(18,17), link(18,20), link(20,18), link(19,20), link(20,19), colour(red0), colour(green0), colour(blue0)}
"""
| input = '\n1 2 0 0\n1 3 0 0\n1 4 0 0\n1 5 0 0\n1 6 0 0\n1 7 0 0\n1 8 0 0\n1 9 0 0\n1 10 0 0\n1 11 0 0\n1 12 0 0\n1 13 0 0\n1 14 0 0\n1 15 0 0\n1 16 0 0\n1 17 0 0\n1 18 0 0\n1 19 0 0\n1 20 0 0\n1 21 0 0\n1 22 0 0\n1 23 0 0\n1 24 0 0\n1 25 0 0\n1 26 0 0\n1 27 0 0\n1 28 0 0\n1 29 0 0\n1 30 0 0\n1 31 0 0\n1 32 0 0\n1 33 0 0\n1 34 0 0\n1 35 0 0\n1 36 0 0\n1 37 0 0\n1 38 0 0\n1 39 0 0\n1 40 0 0\n1 41 0 0\n1 42 0 0\n1 43 0 0\n1 44 0 0\n1 45 0 0\n1 46 0 0\n1 47 0 0\n1 48 0 0\n1 49 0 0\n1 50 0 0\n1 51 0 0\n1 52 0 0\n1 53 0 0\n1 54 0 0\n1 55 0 0\n1 56 0 0\n1 57 0 0\n1 58 0 0\n1 59 0 0\n1 60 0 0\n1 61 0 0\n1 62 0 0\n1 63 0 0\n1 64 0 0\n1 65 0 0\n1 66 0 0\n1 67 0 0\n1 68 0 0\n1 69 0 0\n1 70 0 0\n1 71 0 0\n1 72 0 0\n1 73 0 0\n1 74 0 0\n1 75 0 0\n1 76 0 0\n1 77 0 0\n1 78 0 0\n1 79 0 0\n1 80 0 0\n1 81 0 0\n1 82 0 0\n1 83 0 0\n1 84 0 0\n1 85 0 0\n1 86 0 0\n1 87 0 0\n1 88 0 0\n1 89 0 0\n1 90 0 0\n1 91 2 1 92 93\n1 92 2 1 91 93\n1 93 0 0\n1 94 2 1 95 96\n1 95 2 1 94 96\n1 96 0 0\n1 97 2 1 98 99\n1 98 2 1 97 99\n1 99 0 0\n1 100 2 1 101 102\n1 101 2 1 100 102\n1 102 0 0\n1 103 2 1 104 105\n1 104 2 1 103 105\n1 105 0 0\n1 106 2 1 107 108\n1 107 2 1 106 108\n1 108 0 0\n1 109 2 1 110 111\n1 110 2 1 109 111\n1 111 0 0\n1 112 2 1 113 114\n1 113 2 1 112 114\n1 114 0 0\n1 115 2 1 116 117\n1 116 2 1 115 117\n1 117 0 0\n1 118 2 1 119 120\n1 119 2 1 118 120\n1 120 0 0\n1 121 2 1 122 123\n1 122 2 1 121 123\n1 123 0 0\n1 124 2 1 125 126\n1 125 2 1 124 126\n1 126 0 0\n1 127 2 1 128 129\n1 128 2 1 127 129\n1 129 0 0\n1 130 2 1 131 132\n1 131 2 1 130 132\n1 132 0 0\n1 133 2 1 134 135\n1 134 2 1 133 135\n1 135 0 0\n1 136 2 1 137 138\n1 137 2 1 136 138\n1 138 0 0\n1 139 2 1 140 141\n1 140 2 1 139 141\n1 141 0 0\n1 142 2 1 143 144\n1 143 2 1 142 144\n1 144 0 0\n1 145 2 1 146 147\n1 146 2 1 145 147\n1 147 0 0\n1 148 2 1 149 150\n1 149 2 1 148 150\n1 150 0 0\n1 151 2 1 152 153\n1 152 2 1 151 153\n1 153 0 0\n1 154 2 1 155 156\n1 155 2 1 154 156\n1 156 0 0\n1 157 2 1 158 159\n1 158 2 1 157 159\n1 159 0 0\n1 160 2 1 161 162\n1 161 2 1 160 162\n1 162 0 0\n1 163 2 1 164 165\n1 164 2 1 163 165\n1 165 0 0\n1 166 2 1 167 168\n1 167 2 1 166 168\n1 168 0 0\n1 169 2 1 170 171\n1 170 2 1 169 171\n1 171 0 0\n1 172 2 1 173 174\n1 173 2 1 172 174\n1 174 0 0\n1 175 2 1 176 177\n1 176 2 1 175 177\n1 177 0 0\n1 178 2 1 179 180\n1 179 2 1 178 180\n1 180 0 0\n1 181 2 1 182 183\n1 182 2 1 181 183\n1 183 0 0\n1 184 2 1 185 186\n1 185 2 1 184 186\n1 186 0 0\n1 187 2 1 188 189\n1 188 2 1 187 189\n1 189 0 0\n1 190 2 1 191 192\n1 191 2 1 190 192\n1 192 0 0\n1 193 2 1 194 195\n1 194 2 1 193 195\n1 195 0 0\n1 196 2 1 197 198\n1 197 2 1 196 198\n1 198 0 0\n1 199 2 1 200 201\n1 200 2 1 199 201\n1 201 0 0\n1 202 2 1 203 204\n1 203 2 1 202 204\n1 204 0 0\n1 205 2 1 206 207\n1 206 2 1 205 207\n1 207 0 0\n1 208 2 1 209 210\n1 209 2 1 208 210\n1 210 0 0\n1 211 2 1 212 213\n1 212 2 1 211 213\n1 213 0 0\n1 214 2 1 215 216\n1 215 2 1 214 216\n1 216 0 0\n1 217 2 1 218 219\n1 218 2 1 217 219\n1 219 0 0\n1 220 2 1 221 222\n1 221 2 1 220 222\n1 222 0 0\n1 223 2 1 224 225\n1 224 2 1 223 225\n1 225 0 0\n1 226 2 1 227 228\n1 227 2 1 226 228\n1 228 0 0\n1 229 2 1 230 231\n1 230 2 1 229 231\n1 231 0 0\n1 232 2 1 233 234\n1 233 2 1 232 234\n1 234 0 0\n1 235 2 1 236 237\n1 236 2 1 235 237\n1 237 0 0\n1 238 2 1 239 240\n1 239 2 1 238 240\n1 240 0 0\n1 241 2 1 242 243\n1 242 2 1 241 243\n1 243 0 0\n1 244 2 1 245 246\n1 245 2 1 244 246\n1 246 0 0\n1 247 2 1 248 249\n1 248 2 1 247 249\n1 249 0 0\n1 250 2 1 251 252\n1 251 2 1 250 252\n1 252 0 0\n1 253 2 1 254 255\n1 254 2 1 253 255\n1 255 0 0\n1 256 2 1 257 258\n1 257 2 1 256 258\n1 258 0 0\n1 259 2 1 260 261\n1 260 2 1 259 261\n1 261 0 0\n1 262 2 1 263 264\n1 263 2 1 262 264\n1 264 0 0\n1 265 2 1 266 267\n1 266 2 1 265 267\n1 267 0 0\n1 268 2 1 269 270\n1 269 2 1 268 270\n1 270 0 0\n2 271 3 0 2 211 151 91\n1 1 1 0 271\n2 272 3 0 2 214 154 94\n1 1 1 0 272\n2 273 3 0 2 217 157 97\n1 1 1 0 273\n2 274 3 0 2 220 160 100\n1 1 1 0 274\n2 275 3 0 2 223 163 103\n1 1 1 0 275\n2 276 3 0 2 226 166 106\n1 1 1 0 276\n2 277 3 0 2 229 169 109\n1 1 1 0 277\n2 278 3 0 2 232 172 112\n1 1 1 0 278\n2 279 3 0 2 235 175 115\n1 1 1 0 279\n2 280 3 0 2 238 178 118\n1 1 1 0 280\n2 281 3 0 2 241 181 121\n1 1 1 0 281\n2 282 3 0 2 244 184 124\n1 1 1 0 282\n2 283 3 0 2 247 187 127\n1 1 1 0 283\n2 284 3 0 2 250 190 130\n1 1 1 0 284\n2 285 3 0 2 253 193 133\n1 1 1 0 285\n2 286 3 0 2 256 196 136\n1 1 1 0 286\n2 287 3 0 2 259 199 139\n1 1 1 0 287\n2 288 3 0 2 262 202 142\n1 1 1 0 288\n2 289 3 0 2 265 205 145\n1 1 1 0 289\n2 290 3 0 2 268 208 148\n1 1 1 0 290\n2 291 3 0 1 211 151 91\n1 1 1 1 291\n2 292 3 0 1 214 154 94\n1 1 1 1 292\n2 293 3 0 1 217 157 97\n1 1 1 1 293\n2 294 3 0 1 220 160 100\n1 1 1 1 294\n2 295 3 0 1 223 163 103\n1 1 1 1 295\n2 296 3 0 1 226 166 106\n1 1 1 1 296\n2 297 3 0 1 229 169 109\n1 1 1 1 297\n2 298 3 0 1 232 172 112\n1 1 1 1 298\n2 299 3 0 1 235 175 115\n1 1 1 1 299\n2 300 3 0 1 238 178 118\n1 1 1 1 300\n2 301 3 0 1 241 181 121\n1 1 1 1 301\n2 302 3 0 1 244 184 124\n1 1 1 1 302\n2 303 3 0 1 247 187 127\n1 1 1 1 303\n2 304 3 0 1 250 190 130\n1 1 1 1 304\n2 305 3 0 1 253 193 133\n1 1 1 1 305\n2 306 3 0 1 256 196 136\n1 1 1 1 306\n2 307 3 0 1 259 199 139\n1 1 1 1 307\n2 308 3 0 1 262 202 142\n1 1 1 1 308\n2 309 3 0 1 265 205 145\n1 1 1 1 309\n2 310 3 0 1 268 208 148\n1 1 1 1 310\n1 1 2 0 268 220\n1 1 2 0 265 253\n1 1 2 0 265 223\n1 1 2 0 265 217\n1 1 2 0 262 256\n1 1 2 0 262 253\n1 1 2 0 262 226\n1 1 2 0 262 211\n1 1 2 0 259 226\n1 1 2 0 256 217\n1 1 2 0 256 211\n1 1 2 0 253 226\n1 1 2 0 253 217\n1 1 2 0 250 235\n1 1 2 0 250 226\n1 1 2 0 247 244\n1 1 2 0 247 241\n1 1 2 0 247 235\n1 1 2 0 247 229\n1 1 2 0 241 235\n1 1 2 0 241 226\n1 1 2 0 238 235\n1 1 2 0 238 211\n1 1 2 0 235 211\n1 1 2 0 232 229\n1 1 2 0 232 220\n1 1 2 0 229 217\n1 1 2 0 226 223\n1 1 2 0 226 217\n1 1 2 0 223 211\n1 1 2 0 220 217\n1 1 2 0 217 211\n1 1 2 0 214 211\n1 1 2 0 208 160\n1 1 2 0 205 193\n1 1 2 0 205 163\n1 1 2 0 205 157\n1 1 2 0 202 196\n1 1 2 0 202 193\n1 1 2 0 202 166\n1 1 2 0 202 151\n1 1 2 0 199 166\n1 1 2 0 196 157\n1 1 2 0 196 151\n1 1 2 0 193 166\n1 1 2 0 193 157\n1 1 2 0 190 175\n1 1 2 0 190 166\n1 1 2 0 187 184\n1 1 2 0 187 181\n1 1 2 0 187 175\n1 1 2 0 187 169\n1 1 2 0 181 175\n1 1 2 0 181 166\n1 1 2 0 178 175\n1 1 2 0 178 151\n1 1 2 0 175 151\n1 1 2 0 172 169\n1 1 2 0 172 160\n1 1 2 0 169 157\n1 1 2 0 166 163\n1 1 2 0 166 157\n1 1 2 0 163 151\n1 1 2 0 160 157\n1 1 2 0 157 151\n1 1 2 0 154 151\n1 1 2 0 148 100\n1 1 2 0 145 133\n1 1 2 0 145 103\n1 1 2 0 145 97\n1 1 2 0 142 136\n1 1 2 0 142 133\n1 1 2 0 142 106\n1 1 2 0 142 91\n1 1 2 0 139 106\n1 1 2 0 136 97\n1 1 2 0 136 91\n1 1 2 0 133 106\n1 1 2 0 133 97\n1 1 2 0 130 115\n1 1 2 0 130 106\n1 1 2 0 127 124\n1 1 2 0 127 121\n1 1 2 0 127 115\n1 1 2 0 127 109\n1 1 2 0 121 115\n1 1 2 0 121 106\n1 1 2 0 118 115\n1 1 2 0 118 91\n1 1 2 0 115 91\n1 1 2 0 112 109\n1 1 2 0 112 100\n1 1 2 0 109 97\n1 1 2 0 106 103\n1 1 2 0 106 97\n1 1 2 0 103 91\n1 1 2 0 100 97\n1 1 2 0 97 91\n1 1 2 0 94 91\n0\n22 link(1,17)\n23 link(17,1)\n24 link(2,6)\n25 link(6,2)\n26 link(2,16)\n27 link(16,2)\n28 link(2,18)\n29 link(18,2)\n30 link(3,5)\n31 link(5,3)\n32 link(3,6)\n33 link(6,3)\n34 link(3,15)\n35 link(15,3)\n36 link(3,20)\n37 link(20,3)\n38 link(4,15)\n39 link(15,4)\n40 link(5,18)\n41 link(18,5)\n42 link(5,20)\n43 link(20,5)\n44 link(6,15)\n45 link(15,6)\n46 link(6,18)\n47 link(18,6)\n48 link(7,12)\n49 link(12,7)\n50 link(7,15)\n51 link(15,7)\n52 link(8,9)\n53 link(9,8)\n54 link(8,10)\n55 link(10,8)\n56 link(8,12)\n57 link(12,8)\n58 link(8,14)\n59 link(14,8)\n60 link(10,12)\n61 link(12,10)\n62 link(10,15)\n63 link(15,10)\n64 link(11,12)\n65 link(12,11)\n66 link(11,20)\n67 link(20,11)\n68 link(12,20)\n69 link(20,12)\n70 link(13,14)\n71 link(14,13)\n72 link(13,17)\n73 link(17,13)\n74 link(14,18)\n75 link(18,14)\n76 link(15,16)\n77 link(16,15)\n78 link(15,18)\n79 link(18,15)\n80 link(16,20)\n81 link(20,16)\n82 link(17,18)\n83 link(18,17)\n84 link(18,20)\n85 link(20,18)\n86 link(19,20)\n87 link(20,19)\n88 colour(red0)\n89 colour(green0)\n90 colour(blue0)\n91 chosenColour(20,blue0)\n94 chosenColour(19,blue0)\n97 chosenColour(18,blue0)\n100 chosenColour(17,blue0)\n103 chosenColour(16,blue0)\n106 chosenColour(15,blue0)\n109 chosenColour(14,blue0)\n112 chosenColour(13,blue0)\n115 chosenColour(12,blue0)\n118 chosenColour(11,blue0)\n121 chosenColour(10,blue0)\n124 chosenColour(9,blue0)\n127 chosenColour(8,blue0)\n130 chosenColour(7,blue0)\n133 chosenColour(6,blue0)\n136 chosenColour(5,blue0)\n139 chosenColour(4,blue0)\n142 chosenColour(3,blue0)\n145 chosenColour(2,blue0)\n148 chosenColour(1,blue0)\n151 chosenColour(20,green0)\n154 chosenColour(19,green0)\n157 chosenColour(18,green0)\n160 chosenColour(17,green0)\n163 chosenColour(16,green0)\n166 chosenColour(15,green0)\n169 chosenColour(14,green0)\n172 chosenColour(13,green0)\n175 chosenColour(12,green0)\n178 chosenColour(11,green0)\n181 chosenColour(10,green0)\n184 chosenColour(9,green0)\n187 chosenColour(8,green0)\n190 chosenColour(7,green0)\n193 chosenColour(6,green0)\n196 chosenColour(5,green0)\n199 chosenColour(4,green0)\n202 chosenColour(3,green0)\n205 chosenColour(2,green0)\n208 chosenColour(1,green0)\n211 chosenColour(20,red0)\n214 chosenColour(19,red0)\n217 chosenColour(18,red0)\n220 chosenColour(17,red0)\n223 chosenColour(16,red0)\n226 chosenColour(15,red0)\n229 chosenColour(14,red0)\n232 chosenColour(13,red0)\n235 chosenColour(12,red0)\n238 chosenColour(11,red0)\n241 chosenColour(10,red0)\n244 chosenColour(9,red0)\n247 chosenColour(8,red0)\n250 chosenColour(7,red0)\n253 chosenColour(6,red0)\n256 chosenColour(5,red0)\n259 chosenColour(4,red0)\n262 chosenColour(3,red0)\n265 chosenColour(2,red0)\n268 chosenColour(1,red0)\n2 node(1)\n3 node(2)\n4 node(3)\n5 node(4)\n6 node(5)\n7 node(6)\n8 node(7)\n9 node(8)\n10 node(9)\n11 node(10)\n12 node(11)\n13 node(12)\n14 node(13)\n15 node(14)\n16 node(15)\n17 node(16)\n18 node(17)\n19 node(18)\n20 node(19)\n21 node(20)\n92 notChosenColour(20,blue0)\n95 notChosenColour(19,blue0)\n98 notChosenColour(18,blue0)\n101 notChosenColour(17,blue0)\n104 notChosenColour(16,blue0)\n107 notChosenColour(15,blue0)\n110 notChosenColour(14,blue0)\n113 notChosenColour(13,blue0)\n116 notChosenColour(12,blue0)\n119 notChosenColour(11,blue0)\n122 notChosenColour(10,blue0)\n125 notChosenColour(9,blue0)\n128 notChosenColour(8,blue0)\n131 notChosenColour(7,blue0)\n134 notChosenColour(6,blue0)\n137 notChosenColour(5,blue0)\n140 notChosenColour(4,blue0)\n143 notChosenColour(3,blue0)\n146 notChosenColour(2,blue0)\n149 notChosenColour(1,blue0)\n152 notChosenColour(20,green0)\n155 notChosenColour(19,green0)\n158 notChosenColour(18,green0)\n161 notChosenColour(17,green0)\n164 notChosenColour(16,green0)\n167 notChosenColour(15,green0)\n170 notChosenColour(14,green0)\n173 notChosenColour(13,green0)\n176 notChosenColour(12,green0)\n179 notChosenColour(11,green0)\n182 notChosenColour(10,green0)\n185 notChosenColour(9,green0)\n188 notChosenColour(8,green0)\n191 notChosenColour(7,green0)\n194 notChosenColour(6,green0)\n197 notChosenColour(5,green0)\n200 notChosenColour(4,green0)\n203 notChosenColour(3,green0)\n206 notChosenColour(2,green0)\n209 notChosenColour(1,green0)\n212 notChosenColour(20,red0)\n215 notChosenColour(19,red0)\n218 notChosenColour(18,red0)\n221 notChosenColour(17,red0)\n224 notChosenColour(16,red0)\n227 notChosenColour(15,red0)\n230 notChosenColour(14,red0)\n233 notChosenColour(13,red0)\n236 notChosenColour(12,red0)\n239 notChosenColour(11,red0)\n242 notChosenColour(10,red0)\n245 notChosenColour(9,red0)\n248 notChosenColour(8,red0)\n251 notChosenColour(7,red0)\n254 notChosenColour(6,red0)\n257 notChosenColour(5,red0)\n260 notChosenColour(4,red0)\n263 notChosenColour(3,red0)\n266 notChosenColour(2,red0)\n269 notChosenColour(1,red0)\n0\nB+\n0\nB-\n1\n0\n1\n'
output = '\n{node(1), node(2), node(3), node(4), node(5), node(6), node(7), node(8), node(9), node(10), node(11), node(12), node(13), node(14), node(15), node(16), node(17), node(18), node(19), node(20), link(1,17), link(17,1), link(2,6), link(6,2), link(2,16), link(16,2), link(2,18), link(18,2), link(3,5), link(5,3), link(3,6), link(6,3), link(3,15), link(15,3), link(3,20), link(20,3), link(4,15), link(15,4), link(5,18), link(18,5), link(5,20), link(20,5), link(6,15), link(15,6), link(6,18), link(18,6), link(7,12), link(12,7), link(7,15), link(15,7), link(8,9), link(9,8), link(8,10), link(10,8), link(8,12), link(12,8), link(8,14), link(14,8), link(10,12), link(12,10), link(10,15), link(15,10), link(11,12), link(12,11), link(11,20), link(20,11), link(12,20), link(20,12), link(13,14), link(14,13), link(13,17), link(17,13), link(14,18), link(18,14), link(15,16), link(16,15), link(15,18), link(18,15), link(16,20), link(20,16), link(17,18), link(18,17), link(18,20), link(20,18), link(19,20), link(20,19), colour(red0), colour(green0), colour(blue0)}\n' |
class Solution:
def searchMatrix(self, matrix: 'List[List[int]]', target: int) -> bool:
m = len(matrix)
if m == 0:
return False
n = len(matrix[0])
if n == 0:
return False
left, right = 0, m * n
while left + 1 < right:
mid = (left + right) >> 1
num = matrix[mid // n][mid % n]
if num < target:
left = mid
elif num > target:
right = mid
else:
return True
return matrix[left // n][left % n] == target
if __name__ == "__main__":
# matrix = [
# [1, 3, 5, 7],
# [10, 11, 16, 20],
# [23, 30, 34, 50]
# ]
# target = 3
# print(Solution().searchMatrix(matrix, target))
#
# matrix = [
# [1, 3, 5, 7],
# [10, 11, 16, 20],
# [23, 30, 34, 50]
# ]
# target = 13
# print(Solution().searchMatrix(matrix, target))
matrix = [[]]
target = 1
print(Solution().searchMatrix(matrix, target))
| class Solution:
def search_matrix(self, matrix: 'List[List[int]]', target: int) -> bool:
m = len(matrix)
if m == 0:
return False
n = len(matrix[0])
if n == 0:
return False
(left, right) = (0, m * n)
while left + 1 < right:
mid = left + right >> 1
num = matrix[mid // n][mid % n]
if num < target:
left = mid
elif num > target:
right = mid
else:
return True
return matrix[left // n][left % n] == target
if __name__ == '__main__':
matrix = [[]]
target = 1
print(solution().searchMatrix(matrix, target)) |
#Eoin Lees
student = {
"name":"Mary",
"modules": [
{
"courseName":"Programming",
"grade":45
},
{
"courseName":"History",
"grade":99
}
]
}
print ("Student: {}".format(student["name"]))
for module in student["modules"]:
print("\t {} \t: {}".format(module["courseName"], module["grade"])) | student = {'name': 'Mary', 'modules': [{'courseName': 'Programming', 'grade': 45}, {'courseName': 'History', 'grade': 99}]}
print('Student: {}'.format(student['name']))
for module in student['modules']:
print('\t {} \t: {}'.format(module['courseName'], module['grade'])) |
# crypto_test.py 21/05/2016 D.J.Whale
#
# Placeholder for test harness for crypto.py
#TODO:
print("no tests defined")
# END
| print('no tests defined') |
def ask(name='Jack'):
print(name)
class Person:
def __init__(self):
print('Ma')
my_func = ask
my_func()
"""
Jack
"""
print()
my_class = Person
my_class()
"""
Ma
"""
print()
obj_list = []
obj_list.extend([ask, Person])
for item in obj_list:
print(item())
"""
Jack
None
Ma
<__main__.Person object at 0x0000024556E5AC50>
"""
def decorator_func():
print('dec start')
return ask
print()
my_ask = decorator_func()
my_ask('Tom')
"""
dec start
Tom
"""
| def ask(name='Jack'):
print(name)
class Person:
def __init__(self):
print('Ma')
my_func = ask
my_func()
'\nJack\n'
print()
my_class = Person
my_class()
'\nMa\n'
print()
obj_list = []
obj_list.extend([ask, Person])
for item in obj_list:
print(item())
'\nJack\nNone\nMa\n<__main__.Person object at 0x0000024556E5AC50>\n'
def decorator_func():
print('dec start')
return ask
print()
my_ask = decorator_func()
my_ask('Tom')
'\ndec start\nTom\n' |
'''
Given a balanced parentheses string S, compute the score of the string based on the following rule:
() has score 1
AB has score A + B, where A and B are balanced parentheses strings.
(A) has score 2 * A, where A is a balanced parentheses string.
Example 1:
Input: "()"
Output: 1
Example 2:
Input: "(())"
Output: 2
Example 3:
Input: "()()"
Output: 2
Example 4:
Input: "(()(()))"
Output: 6
Note:
S is a balanced parentheses string, containing only ( and ).
2 <= S.length <= 50
'''
class Solution(object):
def scoreOfParentheses(self, S):
"""
:type S: str
:rtype: int
"""
stack = []
for x in S:
if x == '(':
stack.append(0)
else:
tmp = 0
while stack and stack[-1] != 0:
tmp += stack.pop()
if stack and stack[-1] == 0:
stack.pop()
if tmp:
stack.append(tmp * 2)
else:
stack.append(1)
return sum(stack)
| """
Given a balanced parentheses string S, compute the score of the string based on the following rule:
() has score 1
AB has score A + B, where A and B are balanced parentheses strings.
(A) has score 2 * A, where A is a balanced parentheses string.
Example 1:
Input: "()"
Output: 1
Example 2:
Input: "(())"
Output: 2
Example 3:
Input: "()()"
Output: 2
Example 4:
Input: "(()(()))"
Output: 6
Note:
S is a balanced parentheses string, containing only ( and ).
2 <= S.length <= 50
"""
class Solution(object):
def score_of_parentheses(self, S):
"""
:type S: str
:rtype: int
"""
stack = []
for x in S:
if x == '(':
stack.append(0)
else:
tmp = 0
while stack and stack[-1] != 0:
tmp += stack.pop()
if stack and stack[-1] == 0:
stack.pop()
if tmp:
stack.append(tmp * 2)
else:
stack.append(1)
return sum(stack) |
# Modified from https://github.com/google/subpar/blob/master/debug.bzl
def dump(obj, obj_name):
"""Debugging method that recursively prints object fields to stderr
Args:
obj: Object to dump
obj_name: Name to print for that object
Example Usage:
```
load("debug", "dump")
...
dump(ctx, "ctx")
```
Example Output:
```
WARNING: /code/rrrrr/subpar/debug.bzl:11:5:
ctx[ctx]:
action[string]: <getattr(action) failed>
attr[struct]:
_action_listener[list]: []
_compiler[RuleConfiguredTarget]:
data_runfiles[runfiles]:
```
"""
s = '\n' + _dumpstr(obj, obj_name)
print(s)
def _dumpstr(root_obj, root_obj_name):
"""Helper method for dump() to just generate the string
Some fields always raise errors if we getattr() on them. We
manually blacklist them here. Other fields raise errors only if
we getattr() without a default. Those are handled below.
A bug was filed against Bazel, but it got fixed in a way that
didn't actually fix this.
"""
BLACKLIST = [
"InputFileConfiguredTarget.output_group",
"Label.Label",
"Label.relative",
"License.to_json",
"RuleConfiguredTarget.output_group",
"ctx.action",
"ctx.check_placeholders",
"ctx.empty_action",
"ctx.expand",
"ctx.expand_location",
"ctx.expand_make_variables",
"ctx.file_action",
"ctx.middle_man",
"ctx.new_file",
"ctx.resolve_command",
"ctx.rule",
"ctx.runfiles",
"ctx.build_setting_value",
"ctx.aspect_ids",
"scala_library",
"swift",
"ctx.template_action",
"ctx.tokenize",
"fragments.apple",
"fragments.cpp",
"fragments.java",
"fragments.jvm",
"fragments.objc",
"fragments.swift",
"fragments.py",
"fragments.proto",
"fragments.j2objc",
"fragments.android",
"runfiles.symlinks",
"struct.output_licenses",
"struct.to_json",
"struct.to_proto",
]
appendsCtx = ["_action_listener", "_bloop", "_code_coverage_instrumentation_worker", "_config_dependencies", "_dependency_analyzer_plugin", "_exe", "_host_javabase", "_java_runtime", "_java_toolchain", "_phase_providers", "_scala_toolchain", "_scalac", "_singlejar", "_unused_dependency_checker_plugin", "_zipper", "compatible_with", "data", "deps", "exec_compatible_with", "exports", "plugins", "resource_jars", "resources", "restricted_to", "runtime_deps", "srcs", "to_json", "to_proto", "toolchains", "unused_dependency_checker_ignored_targets"]
# for a in appendsCtx:
# BLACKLIST.append("ctx." + a)
# print(BLACKLIST)
MAXLINES = 4000
ROOT_MAXDEPTH = 5
# List of printable lines
lines = []
# Bazel doesn't allow a function to recursively call itself, so
# use an explicit stack
stack = [(root_obj, root_obj_name, 0, ROOT_MAXDEPTH)]
# No while() in Bazel, so use for loop over large range
for _ in range(MAXLINES):
if len(stack) == 0:
break
obj, obj_name, indent, maxdepth = stack.pop()
obj_type = type(obj)
indent_str = ' '*indent
line = '{indent_str}{obj_name}[{obj_type}]:'.format(
indent_str=indent_str, obj_name=obj_name, obj_type=obj_type)
if maxdepth == 0 or obj_type in ['dict', 'list', 'set', 'string']:
# Dump value as string, inline
line += ' ' + str(obj)
else:
# Dump all of value's fields on separate lines
attrs = dir(obj)
# print(attrs)
# Push each field to stack in reverse order, so they pop
# in sorted order
for attr in reversed(attrs):
# print("%s.%s" % (obj_type, attr))
if "%s.%s" % (obj_type, attr) in BLACKLIST:
value = '<blacklisted attr (%s)>' % attr
else:
value = getattr(obj, attr, '<getattr(%s) failed>' % attr)
stack.append((value, attr, indent+4, maxdepth-1))
lines.append(line)
return '\n'.join(lines) | def dump(obj, obj_name):
"""Debugging method that recursively prints object fields to stderr
Args:
obj: Object to dump
obj_name: Name to print for that object
Example Usage:
```
load("debug", "dump")
...
dump(ctx, "ctx")
```
Example Output:
```
WARNING: /code/rrrrr/subpar/debug.bzl:11:5:
ctx[ctx]:
action[string]: <getattr(action) failed>
attr[struct]:
_action_listener[list]: []
_compiler[RuleConfiguredTarget]:
data_runfiles[runfiles]:
```
"""
s = '\n' + _dumpstr(obj, obj_name)
print(s)
def _dumpstr(root_obj, root_obj_name):
"""Helper method for dump() to just generate the string
Some fields always raise errors if we getattr() on them. We
manually blacklist them here. Other fields raise errors only if
we getattr() without a default. Those are handled below.
A bug was filed against Bazel, but it got fixed in a way that
didn't actually fix this.
"""
blacklist = ['InputFileConfiguredTarget.output_group', 'Label.Label', 'Label.relative', 'License.to_json', 'RuleConfiguredTarget.output_group', 'ctx.action', 'ctx.check_placeholders', 'ctx.empty_action', 'ctx.expand', 'ctx.expand_location', 'ctx.expand_make_variables', 'ctx.file_action', 'ctx.middle_man', 'ctx.new_file', 'ctx.resolve_command', 'ctx.rule', 'ctx.runfiles', 'ctx.build_setting_value', 'ctx.aspect_ids', 'scala_library', 'swift', 'ctx.template_action', 'ctx.tokenize', 'fragments.apple', 'fragments.cpp', 'fragments.java', 'fragments.jvm', 'fragments.objc', 'fragments.swift', 'fragments.py', 'fragments.proto', 'fragments.j2objc', 'fragments.android', 'runfiles.symlinks', 'struct.output_licenses', 'struct.to_json', 'struct.to_proto']
appends_ctx = ['_action_listener', '_bloop', '_code_coverage_instrumentation_worker', '_config_dependencies', '_dependency_analyzer_plugin', '_exe', '_host_javabase', '_java_runtime', '_java_toolchain', '_phase_providers', '_scala_toolchain', '_scalac', '_singlejar', '_unused_dependency_checker_plugin', '_zipper', 'compatible_with', 'data', 'deps', 'exec_compatible_with', 'exports', 'plugins', 'resource_jars', 'resources', 'restricted_to', 'runtime_deps', 'srcs', 'to_json', 'to_proto', 'toolchains', 'unused_dependency_checker_ignored_targets']
maxlines = 4000
root_maxdepth = 5
lines = []
stack = [(root_obj, root_obj_name, 0, ROOT_MAXDEPTH)]
for _ in range(MAXLINES):
if len(stack) == 0:
break
(obj, obj_name, indent, maxdepth) = stack.pop()
obj_type = type(obj)
indent_str = ' ' * indent
line = '{indent_str}{obj_name}[{obj_type}]:'.format(indent_str=indent_str, obj_name=obj_name, obj_type=obj_type)
if maxdepth == 0 or obj_type in ['dict', 'list', 'set', 'string']:
line += ' ' + str(obj)
else:
attrs = dir(obj)
for attr in reversed(attrs):
if '%s.%s' % (obj_type, attr) in BLACKLIST:
value = '<blacklisted attr (%s)>' % attr
else:
value = getattr(obj, attr, '<getattr(%s) failed>' % attr)
stack.append((value, attr, indent + 4, maxdepth - 1))
lines.append(line)
return '\n'.join(lines) |
class Node:
def __init__(self, data):
self.data = data
self.both = id(data)
def __repr__(self):
return str(self.data)
a = Node("a")
b = Node("b")
c = Node("c")
d = Node("d")
e = Node("e")
# id_map simulates object pointer values
id_map = dict()
id_map[id("a")] = a
id_map[id("b")] = b
id_map[id("c")] = c
id_map[id("d")] = d
id_map[id("e")] = e
class LinkedList:
def __init__(self, node):
self.head = node
self.tail = node
self.head.both = 0
self.tail.both = 0
def add(self, element):
self.tail.both ^= id(element.data)
element.both = id(self.tail.data)
self.tail = element
def get(self, index):
prev_node_address = 0
result_node = self.head
for i in range(index):
next_node_address = prev_node_address ^ result_node.both
prev_node_address = id(result_node.data)
result_node = id_map[next_node_address]
return result_node.data
llist = LinkedList(c)
llist.add(d)
llist.add(e)
llist.add(a)
assert llist.get(0) == "c"
assert llist.get(1) == "d"
assert llist.get(2) == "e"
assert llist.get(3) == "a"
| class Node:
def __init__(self, data):
self.data = data
self.both = id(data)
def __repr__(self):
return str(self.data)
a = node('a')
b = node('b')
c = node('c')
d = node('d')
e = node('e')
id_map = dict()
id_map[id('a')] = a
id_map[id('b')] = b
id_map[id('c')] = c
id_map[id('d')] = d
id_map[id('e')] = e
class Linkedlist:
def __init__(self, node):
self.head = node
self.tail = node
self.head.both = 0
self.tail.both = 0
def add(self, element):
self.tail.both ^= id(element.data)
element.both = id(self.tail.data)
self.tail = element
def get(self, index):
prev_node_address = 0
result_node = self.head
for i in range(index):
next_node_address = prev_node_address ^ result_node.both
prev_node_address = id(result_node.data)
result_node = id_map[next_node_address]
return result_node.data
llist = linked_list(c)
llist.add(d)
llist.add(e)
llist.add(a)
assert llist.get(0) == 'c'
assert llist.get(1) == 'd'
assert llist.get(2) == 'e'
assert llist.get(3) == 'a' |
#!/usr/bin/env python3
# --------------------( LICENSE )--------------------
# Copyright (c) 2014-2022 Beartype authors.
# See "LICENSE" for further details.
'''
Project-wide **unimportable data submodule.**
This submodule exercises dynamic importability by providing an unimportable
submodule defining an arbitrary attribute. External unit tests are expected to
dynamically import this attribute from this submodule.
'''
# ....................{ EXCEPTIONS }....................
raise ValueError(
'Can you imagine a fulfilled society? '
'Whoa, what would everyone do?'
)
| """
Project-wide **unimportable data submodule.**
This submodule exercises dynamic importability by providing an unimportable
submodule defining an arbitrary attribute. External unit tests are expected to
dynamically import this attribute from this submodule.
"""
raise value_error('Can you imagine a fulfilled society? Whoa, what would everyone do?') |
while True:
print("hello")
if 2<1:
2
print('hi') | while True:
print('hello')
if 2 < 1:
2
print('hi') |
# Copyright 2016 by Raytheon BBN Technologies Corp. All Rights Reserved
"""
Names and descriptions of attributes that may be
added to AST nodes to represent information used
by the preprocessor.
Attribute names are typically used literally (except
when checking for the presence of an attribute by name)
so the purpose of this file is primarily documentation.
"""
class QGL2Ast(object):
"""
Attribute names and their descriptions
"""
# The name of the source file associated with this node
#
# All AST nodes that the preprocessor uses should have this
# attribute. When the preprocessor inserts new nodes, this
# attribute should be added
#
qgl_fname = 'qgl_fname'
# this attribute, if present, denotes the set of qbits
# referenced by descendants of this node (or None if there
# are no referenced qbits)
#
qgl_qbit_ref = 'qgl_qbit_ref'
# An attribute present on FunctionDef nodes that are marked
# as QGL2 functions
#
qgl_func = 'qgl_func'
# An attribute present on FunctionDef nodes that are marked
# as QGL2 stub functions. Stub functions are defined elsewhere
# (usually in QGL1) but the stub definition contains information
# about the type signature of the function
#
qgl_stub = 'qgl_stub'
# If a function call has been inlined, then the call node
# in the original AST is given an attribute that refers to
# the inlined version of the call
#
qgl_inlined = 'qgl_inlined'
| """
Names and descriptions of attributes that may be
added to AST nodes to represent information used
by the preprocessor.
Attribute names are typically used literally (except
when checking for the presence of an attribute by name)
so the purpose of this file is primarily documentation.
"""
class Qgl2Ast(object):
"""
Attribute names and their descriptions
"""
qgl_fname = 'qgl_fname'
qgl_qbit_ref = 'qgl_qbit_ref'
qgl_func = 'qgl_func'
qgl_stub = 'qgl_stub'
qgl_inlined = 'qgl_inlined' |
'''
A submodule for doing basic error analysis for experimental
physics results.
'''
def average(values):
# TODO: add documentation
pass
def percent_diff(expected, actual):
# TODO: add documentation
pass | """
A submodule for doing basic error analysis for experimental
physics results.
"""
def average(values):
pass
def percent_diff(expected, actual):
pass |
# A list is a collection which is ordered and changeable. In Python lists are written with square brackets.
thislist = ["apple", "banana", "cherry", "orange", "kiwi", "melon", "mango"]
print(thislist)
# You access the list items by referring to the index number
# Print the second item of the list
print("The second element of list are:" + thislist[1]);
# Negative indexing means beginning from the end, -1 refers to the last item,
# -2 refers to the second last item etc.
# Print the last item of the list
print("The last element of list are:" + thislist[-1] );
# You can specify a range of indexes by specifying where to start and where to end the range.
# When specifying a range, the return value will be a new list with the specified items.
# Return the third, fourth, and fifth item
print("The 3rd 4th and 5th item of list are:");
print(thislist[2:5]);
# This example returns the items from the beginning to "orange"
print(thislist[:4]);
# This example returns the items from "cherry" and to the en
print(thislist[2:]);
# Specify negative indexes if we want to start the search from the end of the list
print(thislist[-4:-1]);
# To change the value of a specific item, refer to the index number
thislist[1] = "blackcurrant";
print(thislist);
# You can loop through the list items by using a for loop
for item in thislist:
print(item);
# To determine if a specified item is present in a list use the in keyword
if "apple" in thislist:
print("Yes, 'apple' is in the fruits list")
else:
print("No, 'apple' is not in the fruits list")
#To determine how many items a list has, use the len() function
txt = "The length of list are {}";
length = len(thislist);
print(txt.format(length));
# To add an item to the end of the list, use the append() method
thislist.append("pineapple");
print(thislist);
# To add an item at the specified index, use the insert() method
thislist.insert(0,"Delicious Apple");
print(thislist);
# The remove() method removes the specified item
thislist.remove("orange");
print(thislist);
# The pop() method removes the specified index, (or the last item if index is not specified
thislist.pop();
print(thislist);
# The del keyword removes the specified index
thislist = ["apple", "banana", "cherry"]
del thislist[0]
print(thislist)
# The del keyword can also delete the list completely
del thislist;
# print(thislist);
# The clear() method empties the list
thislist = ["apple", "banana", "cherry"];
thislist.clear();
print(thislist);
# You cannot copy a list simply by typing list2 = list1,
# because: list2 will only be a reference to list1,
# and changes made in list1 will automatically also be made in list2.
# There are ways to make a copy, one way is to use the built-in List method copy().
# Make a copy of a list with the copy() method
thislist = ["apple", "banana", "cherry"]
mylist = thislist.copy()
print(mylist)
# Another way to make a copy is to use the built-in method list()
# Make a copy of a list with the list() method
mylist = list(thislist)
print(mylist)
# There are several ways to join, or concatenate, two or more lists in Python.
# One of the easiest ways are by using the + operator.
list1 = ["a", "b" , "c"]
list2 = [1, 2, 3]
list3 = list1 + list2
print(list3)
# Another way to join two lists are by appending all the items from list2 into list1, one by one:
list1 = ["a", "b" , "c"]
list2 = [5, 6, 7]
for x in list2:
list1.append(x)
print(list1)
# you can use the extend() method, which purpose is to add elements from one list to another list
list1 = ["a", "b" , "c"]
list2 = [8, 9, 10]
list1.extend(list2)
print(list1)
# It is also possible to use the list() constructor to make a new list
thislist = list(("apple", "banana", "cherry")) # note the double round-brackets
print(thislist)
# we can sort the list using the sort() method
print(thislist.sort()); | thislist = ['apple', 'banana', 'cherry', 'orange', 'kiwi', 'melon', 'mango']
print(thislist)
print('The second element of list are:' + thislist[1])
print('The last element of list are:' + thislist[-1])
print('The 3rd 4th and 5th item of list are:')
print(thislist[2:5])
print(thislist[:4])
print(thislist[2:])
print(thislist[-4:-1])
thislist[1] = 'blackcurrant'
print(thislist)
for item in thislist:
print(item)
if 'apple' in thislist:
print("Yes, 'apple' is in the fruits list")
else:
print("No, 'apple' is not in the fruits list")
txt = 'The length of list are {}'
length = len(thislist)
print(txt.format(length))
thislist.append('pineapple')
print(thislist)
thislist.insert(0, 'Delicious Apple')
print(thislist)
thislist.remove('orange')
print(thislist)
thislist.pop()
print(thislist)
thislist = ['apple', 'banana', 'cherry']
del thislist[0]
print(thislist)
del thislist
thislist = ['apple', 'banana', 'cherry']
thislist.clear()
print(thislist)
thislist = ['apple', 'banana', 'cherry']
mylist = thislist.copy()
print(mylist)
mylist = list(thislist)
print(mylist)
list1 = ['a', 'b', 'c']
list2 = [1, 2, 3]
list3 = list1 + list2
print(list3)
list1 = ['a', 'b', 'c']
list2 = [5, 6, 7]
for x in list2:
list1.append(x)
print(list1)
list1 = ['a', 'b', 'c']
list2 = [8, 9, 10]
list1.extend(list2)
print(list1)
thislist = list(('apple', 'banana', 'cherry'))
print(thislist)
print(thislist.sort()) |
with open("README.md", "r") as fh:
long_description = fh.read()
setuptools.setup(
name="gprpy",
version="1.0.8",
author="Alain Plattner",
author_email="plattner@alumni.ethz.ch",
description="GPRPy - open source ground penetrating radar processing and visualization",
entry_points={'console_scripts': ['gprpy = gprpy.__main__:main']},
long_description=long_description,
long_description_content_type="text/markdown",
url="https://github.com/NSGeophysics/GPRPy",
packages=['gprpy'],
package_data={'gprpy': ['exampledata/GSSI/*.DZT',
'exampledata/GSSI/*.txt',
'exampledata/SnS/ComOffs/*.xyz',
'exampledata/SnS/ComOffs/*.DT1',
'exampledata/SnS/ComOffs/*.HD',
'exampledata/SnS/WARR/*.DT1',
'exampledata/SnS/WARR/*.HD',
'exampledata/pickedSurfaceData/*.txt',
'examplescripts/*.py',
'toolbox/splashdat/*.png',
'toolbox/*.py',
'irlib/*.py',
'irlib/external/*.py']},
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
install_requires=['tqdm','numpy','scipy','matplotlib','Pmw','pyevtk']
)
| with open('README.md', 'r') as fh:
long_description = fh.read()
setuptools.setup(name='gprpy', version='1.0.8', author='Alain Plattner', author_email='plattner@alumni.ethz.ch', description='GPRPy - open source ground penetrating radar processing and visualization', entry_points={'console_scripts': ['gprpy = gprpy.__main__:main']}, long_description=long_description, long_description_content_type='text/markdown', url='https://github.com/NSGeophysics/GPRPy', packages=['gprpy'], package_data={'gprpy': ['exampledata/GSSI/*.DZT', 'exampledata/GSSI/*.txt', 'exampledata/SnS/ComOffs/*.xyz', 'exampledata/SnS/ComOffs/*.DT1', 'exampledata/SnS/ComOffs/*.HD', 'exampledata/SnS/WARR/*.DT1', 'exampledata/SnS/WARR/*.HD', 'exampledata/pickedSurfaceData/*.txt', 'examplescripts/*.py', 'toolbox/splashdat/*.png', 'toolbox/*.py', 'irlib/*.py', 'irlib/external/*.py']}, classifiers=['Programming Language :: Python :: 3', 'License :: OSI Approved :: MIT License', 'Operating System :: OS Independent'], install_requires=['tqdm', 'numpy', 'scipy', 'matplotlib', 'Pmw', 'pyevtk']) |
class _Emojis:
def __init__(self):
self.key = "\U0001F511"
self.link = "\U0001F4CE"
self.alert = "\U0001F6A8"
self.ghost = "\U0001F47B"
self.package = "\U0001F4E6"
self.folder = "\U0001F5C2"
self.bell = "\U0001F514"
self.dissy = "\U0001F4AB"
self.genie = "\U0001F9DE"
self.linked_paperclip = "\U0001F587"
self.file_cabinet = "\U0001F5C3"
self.graduation_cap = "\U0001F393"
self.safety_helmet = "\U000026D1"
self.grinning_cat1 = "\U0001F638"
self.fire = "\U0001F525"
self.pan = "\U0001F373"
Emojis = _Emojis() | class _Emojis:
def __init__(self):
self.key = '🔑'
self.link = '📎'
self.alert = '🚨'
self.ghost = '👻'
self.package = '📦'
self.folder = '🗂'
self.bell = '🔔'
self.dissy = '💫'
self.genie = '🧞'
self.linked_paperclip = '🖇'
self.file_cabinet = '🗃'
self.graduation_cap = '🎓'
self.safety_helmet = '⛑'
self.grinning_cat1 = '😸'
self.fire = '🔥'
self.pan = '🍳'
emojis = __emojis() |
icu_sources = [
'utypes.cpp',
'uloc.cpp',
'ustring.cpp',
'ucase.cpp',
'ubrk.cpp',
'brkiter.cpp',
'filteredbrk.cpp',
'ucharstriebuilder.cpp',
'uobject.cpp',
'resbund.cpp',
'servrbf.cpp',
'servlkf.cpp',
'serv.cpp',
'servnotf.cpp',
'servls.cpp',
'servlk.cpp',
'servslkf.cpp',
'stringtriebuilder.cpp',
'uvector.cpp',
'ustrenum.cpp',
'uenum.cpp',
'unistr.cpp',
'appendable.cpp',
'rbbi.cpp',
'rbbi_cache.cpp',
'cstring.cpp',
'umath.cpp',
'charstr.cpp',
'rbbidata.cpp',
'ustrfmt.cpp',
'ucharstrie.cpp',
'uloc_keytype.cpp',
'uhash.cpp',
'locdispnames.cpp',
'brkeng.cpp',
'dictionarydata.cpp',
'udataswp.cpp',
'uinvchar.cpp',
'uresbund.cpp',
'uresdata.cpp', # modified due to duplicate symbol `gEmptyString2`
'resource.cpp',
'locavailable.cpp',
'utrie2.cpp',
'ucol_swp.cpp',
'utrie_swap.cpp',
'schriter.cpp',
'uchriter.cpp',
'locid.cpp', # modified due to duplicate include `bytesinkutil.h`
'locbased.cpp',
'chariter.cpp',
'uvectr32.cpp',
'bytestrie.cpp',
'ustack.cpp',
'umutex.cpp',
'uniset.cpp', # modified due to duplicate symbol `compareUnicodeString2`
'stringpiece.cpp',
'locutil.cpp',
'unifilt.cpp',
'util.cpp', # modified due to duplicate symbol `BACKSLASH2`, `UPPER_U2`, and `LOWER_U2`
'bmpset.cpp',
'unifunct.cpp',
'unisetspan.cpp',
'uniset_props.cpp', # modified due to duplicate include `_dbgct2`
'patternprops.cpp',
'bytesinkutil.cpp', # modified due to duplicate include `bytesinkutil.h`
'dictbe.cpp',
'rbbirb.cpp',
'utext.cpp', # modified due to duplicate symbol `gEmptyString3`
'utf_impl.cpp',
'propsvec.cpp',
'locmap.cpp',
'loclikely.cpp',
'uloc_tag.cpp',
'ustrtrns.cpp',
'udatamem.cpp',
'putil.cpp',
'uhash_us.cpp',
'uprops.cpp',
'uchar.cpp', # modified due to duplicate symbol `_enumPropertyStartsRange2`
'parsepos.cpp',
'ruleiter.cpp',
'rbbitblb.cpp',
'edits.cpp',
'rbbinode.cpp',
'bytestream.cpp',
'rbbiscan.cpp',
'loadednormalizer2impl.cpp',
'characterproperties.cpp',
'locresdata.cpp',
'normalizer2impl.cpp', # modified due to duplicate include `bytesinkutil.h`
'normalizer2.cpp',
'rbbisetb.cpp',
'rbbistbl.cpp',
'unistr_case.cpp',
'unames.cpp', # modified due to duplicate symbol `DATA_TYPE2`
'propname.cpp',
'ustrcase.cpp',
'ustrcase_locale.cpp',
'ubidi.cpp',
'ucptrie.cpp',
'umutablecptrie.cpp', # modified due to duplicate symbol `getRange2` and `OVERFLOW2`
'cmemory.cpp',
'utrie2_builder.cpp', # modified due to duplicate symbol `writeBlock2`
'uscript.cpp',
'uscript_props.cpp',
'utrie.cpp', # modified due to duplicate symbol `equal_uint322` and `enumSameValue2`
'ucmndata.cpp',
'uarrsort.cpp',
'umapfile.cpp',
'ucln_cmn.cpp', # modified due to duplicate include `ucln_imp.h`
'uregex.cpp', # modified due to duplicate symbol `BACKSLASH3`
'ucol.cpp',
'coll.cpp', # modified due to duplicate symbol `gService2`, `getService2`, `initService2`, `hasService2`, `availableLocaleList2`
'collation.cpp',
'ucoleitr.cpp',
'rematch.cpp', # modified due to duplicate symbol `BACKSLASH4`
'regexcmp.cpp',
'repattrn.cpp',
'collationroot.cpp',
'ucol_res.cpp',
'collationbuilder.cpp',
'coleitr.cpp',
'sharedobject.cpp',
'collationdata.cpp',
'uiter.cpp',
'ucln_in.cpp', # modified due to duplicate symbol `copyright2` and duplicate include `ucln_imp.h`
'uniset_closure.cpp',
'unifiedcache.cpp', # modified due to duplicate symbol `gCacheInitOnce2`
'regexst.cpp',
'collationweights.cpp',
'caniter.cpp',
'collationiterator.cpp',
'collationfastlatin.cpp',
'collationtailoring.cpp',
'usetiter.cpp',
'collationdatareader.cpp',
'collationruleparser.cpp',
'collationdatabuilder.cpp',
'regeximp.cpp',
'collationsets.cpp',
'utf16collationiterator.cpp',
'uvectr64.cpp',
'rulebasedcollator.cpp',
'collationrootelements.cpp',
'ucol_sit.cpp', # modified due to duplicate symbol `internalBufferSize2`
'ulist.cpp',
'uset.cpp',
'regextxt.cpp',
'ucharstrieiterator.cpp',
'collationfcd.cpp',
'collationkeys.cpp',
'unistr_case_locale.cpp',
'collationsettings.cpp',
'collationcompare.cpp',
'utf8collationiterator.cpp',
'uitercollationiterator.cpp',
'collationfastlatinbuilder.cpp',
'collationdatawriter.cpp',
'uset_props.cpp',
'utrace.cpp',
'sortkey.cpp',
'unistr_titlecase_brkiter.cpp',
'ubidi_props.cpp', # modified due to duplicate symbol `_enumPropertyStartsRange3`
'bocsu.cpp',
'ubidiln.cpp',
'ubidiwrt.cpp',
'ustr_titlecase_brkiter.cpp',
'wintz.cpp',
'stubdata.cpp',
'udata.cpp',
# modified due to to comment out `extern "C" const DataHeader U_DATA_API
# U_ICUDATA_ENTRY_POINT;` and cast `(const DataHeader*)` due to
# stubdata.cpp being added
]
# Other modifications:
# Modify: regexcst.h
# Replace the header gaurd with:
# #ifndef REGEXCST_H
# #define REGEXCST_H
# Modify: regexcmp.h
# Replace the header gaurd with:
# #ifndef REGEXCMP_H
# #define REGEXCMP_H
# Modify: regexcst.h
# Append '2' to every enum in Regex_PatternParseAction
# Replace all of the references to those enums in regexcst.h and regexcmp.cpp
# Modify: regexcst.h
# Replace: `gRuleParseStateTable` symbol with `gRuleParseStateTable2`
# Replace with `gRuleParseStateTable` in regexcmp.cpp
| icu_sources = ['utypes.cpp', 'uloc.cpp', 'ustring.cpp', 'ucase.cpp', 'ubrk.cpp', 'brkiter.cpp', 'filteredbrk.cpp', 'ucharstriebuilder.cpp', 'uobject.cpp', 'resbund.cpp', 'servrbf.cpp', 'servlkf.cpp', 'serv.cpp', 'servnotf.cpp', 'servls.cpp', 'servlk.cpp', 'servslkf.cpp', 'stringtriebuilder.cpp', 'uvector.cpp', 'ustrenum.cpp', 'uenum.cpp', 'unistr.cpp', 'appendable.cpp', 'rbbi.cpp', 'rbbi_cache.cpp', 'cstring.cpp', 'umath.cpp', 'charstr.cpp', 'rbbidata.cpp', 'ustrfmt.cpp', 'ucharstrie.cpp', 'uloc_keytype.cpp', 'uhash.cpp', 'locdispnames.cpp', 'brkeng.cpp', 'dictionarydata.cpp', 'udataswp.cpp', 'uinvchar.cpp', 'uresbund.cpp', 'uresdata.cpp', 'resource.cpp', 'locavailable.cpp', 'utrie2.cpp', 'ucol_swp.cpp', 'utrie_swap.cpp', 'schriter.cpp', 'uchriter.cpp', 'locid.cpp', 'locbased.cpp', 'chariter.cpp', 'uvectr32.cpp', 'bytestrie.cpp', 'ustack.cpp', 'umutex.cpp', 'uniset.cpp', 'stringpiece.cpp', 'locutil.cpp', 'unifilt.cpp', 'util.cpp', 'bmpset.cpp', 'unifunct.cpp', 'unisetspan.cpp', 'uniset_props.cpp', 'patternprops.cpp', 'bytesinkutil.cpp', 'dictbe.cpp', 'rbbirb.cpp', 'utext.cpp', 'utf_impl.cpp', 'propsvec.cpp', 'locmap.cpp', 'loclikely.cpp', 'uloc_tag.cpp', 'ustrtrns.cpp', 'udatamem.cpp', 'putil.cpp', 'uhash_us.cpp', 'uprops.cpp', 'uchar.cpp', 'parsepos.cpp', 'ruleiter.cpp', 'rbbitblb.cpp', 'edits.cpp', 'rbbinode.cpp', 'bytestream.cpp', 'rbbiscan.cpp', 'loadednormalizer2impl.cpp', 'characterproperties.cpp', 'locresdata.cpp', 'normalizer2impl.cpp', 'normalizer2.cpp', 'rbbisetb.cpp', 'rbbistbl.cpp', 'unistr_case.cpp', 'unames.cpp', 'propname.cpp', 'ustrcase.cpp', 'ustrcase_locale.cpp', 'ubidi.cpp', 'ucptrie.cpp', 'umutablecptrie.cpp', 'cmemory.cpp', 'utrie2_builder.cpp', 'uscript.cpp', 'uscript_props.cpp', 'utrie.cpp', 'ucmndata.cpp', 'uarrsort.cpp', 'umapfile.cpp', 'ucln_cmn.cpp', 'uregex.cpp', 'ucol.cpp', 'coll.cpp', 'collation.cpp', 'ucoleitr.cpp', 'rematch.cpp', 'regexcmp.cpp', 'repattrn.cpp', 'collationroot.cpp', 'ucol_res.cpp', 'collationbuilder.cpp', 'coleitr.cpp', 'sharedobject.cpp', 'collationdata.cpp', 'uiter.cpp', 'ucln_in.cpp', 'uniset_closure.cpp', 'unifiedcache.cpp', 'regexst.cpp', 'collationweights.cpp', 'caniter.cpp', 'collationiterator.cpp', 'collationfastlatin.cpp', 'collationtailoring.cpp', 'usetiter.cpp', 'collationdatareader.cpp', 'collationruleparser.cpp', 'collationdatabuilder.cpp', 'regeximp.cpp', 'collationsets.cpp', 'utf16collationiterator.cpp', 'uvectr64.cpp', 'rulebasedcollator.cpp', 'collationrootelements.cpp', 'ucol_sit.cpp', 'ulist.cpp', 'uset.cpp', 'regextxt.cpp', 'ucharstrieiterator.cpp', 'collationfcd.cpp', 'collationkeys.cpp', 'unistr_case_locale.cpp', 'collationsettings.cpp', 'collationcompare.cpp', 'utf8collationiterator.cpp', 'uitercollationiterator.cpp', 'collationfastlatinbuilder.cpp', 'collationdatawriter.cpp', 'uset_props.cpp', 'utrace.cpp', 'sortkey.cpp', 'unistr_titlecase_brkiter.cpp', 'ubidi_props.cpp', 'bocsu.cpp', 'ubidiln.cpp', 'ubidiwrt.cpp', 'ustr_titlecase_brkiter.cpp', 'wintz.cpp', 'stubdata.cpp', 'udata.cpp'] |
while(True):
try:
x, a, y, b = map(int, input().split())
if(x * b == a * y):
print("=")
elif (x * b > a * y):
print(">")
else:
print("<")
except:
exit()
| while True:
try:
(x, a, y, b) = map(int, input().split())
if x * b == a * y:
print('=')
elif x * b > a * y:
print('>')
else:
print('<')
except:
exit() |
class Graph(object):
def __init__(self, graph={}):
""" create the graph dictionary. use empty dictionary if no input. """
self.graph = graph
def vertex(self, v):
""" add new vertex. checks to see if vertex is already present before adding. """
if v not in self.graph:
self.graph[v] = []
def vertices(self):
""" returns vertices of graph, the keys of the dictionary, as list. """
return list(self.graph.keys())
def edge(self, edge):
""" edge data is in format vertex 1, vertex 2, weight. checks to see if origin vertex is present before adding. """
(v1, v2, w) = tuple(edge)
if v1 in self.graph:
self.graph[v1].append([v2,w])
def adjacency(self):
return sorted(self.graph)
def edges(self):
""" return the edges connecting vertices. list of edges, """
edges = []
for v1 in self.graph:
for v2 in self.graph[v1]:
if [v2, v1] not in edges:
edges.append([v1, v2])
return sorted(edges)
def dfs(graph, start):
""" depth first search. uses a stack, first in last out. """
x = graph.edges()
path = []
stack = [start]
""" while there are elements in the stack, if the vertex has not been visited, add it to the visited list and remove it from the stack. if the vertex has any edges look in the edges and add destination nodes to the stack. repeat until there are no more items in the stack. """
while stack:
v = stack.pop()
if v not in visited:
visited.append(v)
for i in x:
if v in i:
stack.append(i[1][0])
return visited
def bfs(graph, start):
""" breadth first search. uses a queue, first in first out. """
x = graph.edges()
path = []
queue = [start]
""" while there are elements in the queue, if the vertex has not been visited, add it to the visited list and remove it from the queue. if the vertex has any edges look in the edges and add destination nodes to the queue. repeat until there are no items in the queue. """
while queue:
v = queue.pop(0)
if v not in visited:
visited.append(v)
for i in x:
if v in i:
queue.append(i[1][0])
return visited
""" write to file """
def save_file(graph, start):
f = open('search.txt','w')
f.write("DFS: ")
f.write(str(dfs(graph, start)))
f.write("\n")
f.write("BFS : ")
f.write(str(bfs(graph, start)))
f.close()
| class Graph(object):
def __init__(self, graph={}):
""" create the graph dictionary. use empty dictionary if no input. """
self.graph = graph
def vertex(self, v):
""" add new vertex. checks to see if vertex is already present before adding. """
if v not in self.graph:
self.graph[v] = []
def vertices(self):
""" returns vertices of graph, the keys of the dictionary, as list. """
return list(self.graph.keys())
def edge(self, edge):
""" edge data is in format vertex 1, vertex 2, weight. checks to see if origin vertex is present before adding. """
(v1, v2, w) = tuple(edge)
if v1 in self.graph:
self.graph[v1].append([v2, w])
def adjacency(self):
return sorted(self.graph)
def edges(self):
""" return the edges connecting vertices. list of edges, """
edges = []
for v1 in self.graph:
for v2 in self.graph[v1]:
if [v2, v1] not in edges:
edges.append([v1, v2])
return sorted(edges)
def dfs(graph, start):
""" depth first search. uses a stack, first in last out. """
x = graph.edges()
path = []
stack = [start]
' while there are elements in the stack, if the vertex has not been visited, add it to the visited list and remove it from the stack. if the vertex has any edges look in the edges and add destination nodes to the stack. repeat until there are no more items in the stack. '
while stack:
v = stack.pop()
if v not in visited:
visited.append(v)
for i in x:
if v in i:
stack.append(i[1][0])
return visited
def bfs(graph, start):
""" breadth first search. uses a queue, first in first out. """
x = graph.edges()
path = []
queue = [start]
' while there are elements in the queue, if the vertex has not been visited, add it to the visited list and remove it from the queue. if the vertex has any edges look in the edges and add destination nodes to the queue. repeat until there are no items in the queue. '
while queue:
v = queue.pop(0)
if v not in visited:
visited.append(v)
for i in x:
if v in i:
queue.append(i[1][0])
return visited
' write to file '
def save_file(graph, start):
f = open('search.txt', 'w')
f.write('DFS: ')
f.write(str(dfs(graph, start)))
f.write('\n')
f.write('BFS : ')
f.write(str(bfs(graph, start)))
f.close() |
META = [{
'lookup': 'city',
'tag': 'city',
'path': ['names','en'],
},{
'lookup': 'continent',
'tag': 'continent',
'path': ['names','en'],
},{
'lookup': 'continent_code',
'tag': 'continent',
'path': ['code'],
},{
'lookup': 'country',
'tag': 'country',
'path': ['names','en'],
},{
'lookup': 'iso_code',
'tag': 'country',
'path': ['iso_code'],
},{
'lookup': 'latitude',
'tag': 'location',
'path': ['latitude'],
},{
'lookup': 'longitude',
'tag': 'location',
'path': ['longitude'],
},{
'lookup': 'metro_code',
'tag': 'location',
'path': ['metro_code'],
},{
'lookup': 'postal_code',
'tag': 'postal',
'path': ['code'],
}]
PORTMAP = {
0:"DoS", # Denial of Service
1:"ICMP", # ICMP
20:"FTP", # FTP Data
21:"FTP", # FTP Control
22:"SSH", # SSH
23:"TELNET", # Telnet
25:"EMAIL", # SMTP
43:"WHOIS", # Whois
53:"DNS", # DNS
80:"HTTP", # HTTP
88:"AUTH", # Kerberos
109:"EMAIL", # POP v2
110:"EMAIL", # POP v3
115:"FTP", # SFTP
118:"SQL", # SQL
143:"EMAIL", # IMAP
156:"SQL", # SQL
161:"SNMP", # SNMP
220:"EMAIL", # IMAP v3
389:"AUTH", # LDAP
443:"HTTPS", # HTTPS
445:"SMB", # SMB
636:"AUTH", # LDAP of SSL/TLS
1433:"SQL", # MySQL Server
1434:"SQL", # MySQL Monitor
3306:"SQL", # MySQL
3389:"RDP", # RDP
5900:"RDP", # VNC:0
5901:"RDP", # VNC:1
5902:"RDP", # VNC:2
5903:"RDP", # VNC:3
8080:"HTTP", # HTTP Alternative
}
| meta = [{'lookup': 'city', 'tag': 'city', 'path': ['names', 'en']}, {'lookup': 'continent', 'tag': 'continent', 'path': ['names', 'en']}, {'lookup': 'continent_code', 'tag': 'continent', 'path': ['code']}, {'lookup': 'country', 'tag': 'country', 'path': ['names', 'en']}, {'lookup': 'iso_code', 'tag': 'country', 'path': ['iso_code']}, {'lookup': 'latitude', 'tag': 'location', 'path': ['latitude']}, {'lookup': 'longitude', 'tag': 'location', 'path': ['longitude']}, {'lookup': 'metro_code', 'tag': 'location', 'path': ['metro_code']}, {'lookup': 'postal_code', 'tag': 'postal', 'path': ['code']}]
portmap = {0: 'DoS', 1: 'ICMP', 20: 'FTP', 21: 'FTP', 22: 'SSH', 23: 'TELNET', 25: 'EMAIL', 43: 'WHOIS', 53: 'DNS', 80: 'HTTP', 88: 'AUTH', 109: 'EMAIL', 110: 'EMAIL', 115: 'FTP', 118: 'SQL', 143: 'EMAIL', 156: 'SQL', 161: 'SNMP', 220: 'EMAIL', 389: 'AUTH', 443: 'HTTPS', 445: 'SMB', 636: 'AUTH', 1433: 'SQL', 1434: 'SQL', 3306: 'SQL', 3389: 'RDP', 5900: 'RDP', 5901: 'RDP', 5902: 'RDP', 5903: 'RDP', 8080: 'HTTP'} |
# Example: Fetch single bridge by ID
my_bridge = api.get_bridge('brg-bridgeId')
print(my_bridge)
## { 'bridgeAudio': True,
## 'calls' : 'https://api.catapult.inetwork.com/v1/users/u-123/bridges/brg-bridgeId/calls',
## 'createdTime': '2017-01-26T01:15:09Z',
## 'id' : 'brg-bridgeId',
## 'state' : 'created'}
print(my_bridge["state"])
## created
| my_bridge = api.get_bridge('brg-bridgeId')
print(my_bridge)
print(my_bridge['state']) |
# partisan.tests
# Tests for the complete partisan package.
#
# Author: Benjamin Bengfort <bbengfort@districtdatalabs.com>
# Created: Sat Jul 16 11:36:08 2016 -0400
#
# Copyright (C) 2016 District Data Labs
# For license information, see LICENSE.txt
#
# ID: __init__.py [80822db] benjamin@bengfort.com $
"""
Tests for the complete partisan package.
"""
##########################################################################
## Imports
##########################################################################
| """
Tests for the complete partisan package.
""" |
class Solution:
def isAdditiveNumber(self, num: str) -> bool:
l = len(num)
for i in range(1, (2 * l) // 3):
for j in range(0, i):
if num[0] == "0" and j + 1 != 1:
break
if num[j + 1] == "0" and i - j != 1:
continue
lst1, lst2 = int(num[0: j + 1]), int(num[j + 1: i + 1])
cur = i + 1
flag = 1
while cur < l:
nxt = lst1 + lst2
ll = len(str(nxt))
if ll + cur > l or int(num[cur: cur + ll]) != nxt:
flag = 0
break
cur += ll
lst1, lst2 = lst2, nxt
if not flag:
continue
else:
return True
return False | class Solution:
def is_additive_number(self, num: str) -> bool:
l = len(num)
for i in range(1, 2 * l // 3):
for j in range(0, i):
if num[0] == '0' and j + 1 != 1:
break
if num[j + 1] == '0' and i - j != 1:
continue
(lst1, lst2) = (int(num[0:j + 1]), int(num[j + 1:i + 1]))
cur = i + 1
flag = 1
while cur < l:
nxt = lst1 + lst2
ll = len(str(nxt))
if ll + cur > l or int(num[cur:cur + ll]) != nxt:
flag = 0
break
cur += ll
(lst1, lst2) = (lst2, nxt)
if not flag:
continue
else:
return True
return False |
# Database Config
config = {
'MYSQL_DATABASE_USER' : 'root', #Username for mysql
'MYSQL_DATABASE_DB' : 'CoveServices',
'MYSQL_DATABASE_PASSWORD' : 'root', # Password to connect to mysql
'MYSQL_DATABASE_HOST' : 'localhost',
'USERNAME' : '',
'USERID' :'',
} | config = {'MYSQL_DATABASE_USER': 'root', 'MYSQL_DATABASE_DB': 'CoveServices', 'MYSQL_DATABASE_PASSWORD': 'root', 'MYSQL_DATABASE_HOST': 'localhost', 'USERNAME': '', 'USERID': ''} |
nota1 = float(input())
while nota1 > 10 or nota1 < 0:
print('nota invalida')
nota1 = float(input())
nota2 = float(input())
while nota2 > 10 or nota2 < 0:
print('nota invalida')
nota2 = float(input())
media = (nota1+nota2)/2
print('media = %.2f'%media)
| nota1 = float(input())
while nota1 > 10 or nota1 < 0:
print('nota invalida')
nota1 = float(input())
nota2 = float(input())
while nota2 > 10 or nota2 < 0:
print('nota invalida')
nota2 = float(input())
media = (nota1 + nota2) / 2
print('media = %.2f' % media) |
players = """
-- Name; Case Race; Beer Ball; Flip 50;
Nicole;1;2;2;
Jenna;2;2;5;
Krendan;4;3;3;
Dylan;4;3;3;
Luke;5;5;3;
Jason;5;4;3;
Brendan;5;4;3;
James E;3;3;3;
Aidan;3;4;5;
Daniel;4;5;4;
Maya;3;3;5;
James C;3;3;3;
Kayvan;3;2;2;
Steph;3;2;4;
Kevin;3;3;3;
"""
| players = '\n-- Name; Case Race; Beer Ball; Flip 50;\nNicole;1;2;2;\nJenna;2;2;5;\nKrendan;4;3;3;\nDylan;4;3;3;\nLuke;5;5;3;\nJason;5;4;3;\nBrendan;5;4;3;\nJames E;3;3;3;\nAidan;3;4;5;\nDaniel;4;5;4;\nMaya;3;3;5;\nJames C;3;3;3;\nKayvan;3;2;2;\nSteph;3;2;4;\nKevin;3;3;3;\n' |
# -*- coding: utf-8 -*-
# TODO: deprecated
URL_DID_SIGN_IN = '/api/v2/did/signin'
URL_DID_AUTH = '/api/v2/did/auth'
URL_DID_BACKUP_AUTH = '/api/v2/did/backup_auth'
URL_BACKUP_SERVICE = '/api/v2/internal_backup/service'
URL_BACKUP_FINISH = '/api/v2/internal_backup/finished_confirmation'
URL_BACKUP_FILES = '/api/v2/internal_backup/files'
URL_BACKUP_FILE = '/api/v2/internal_backup/file'
URL_BACKUP_PATCH_HASH = '/api/v2/internal_backup/patch_hash'
URL_BACKUP_PATCH_DELTA = '/api/v2/internal_backup/patch_delta'
URL_BACKUP_PATCH_FILE = '/api/v2/internal_backup/patch_file'
URL_RESTORE_FINISH = '/api/v2/internal_restore/finished_confirmation'
# TODO: deprecated
URL_IPFS_BACKUP_PIN_CIDS = '/api/v2/ipfs-backup-internal/pin_cids'
URL_IPFS_BACKUP_GET_CIDS = '/api/v2/ipfs-backup-internal/get_cids'
URL_IPFS_BACKUP_GET_DBFILES = '/api/v2/ipfs-backup-internal/get_dbfiles'
URL_IPFS_BACKUP_STATE = '/api/v2/ipfs-backup-internal/state'
URL_VAULT_BACKUP_SERVICE_BACKUP = '/api/v2/vault-backup-service/backup'
URL_VAULT_BACKUP_SERVICE_RESTORE = '/api/v2/vault-backup-service/restore'
URL_VAULT_BACKUP_SERVICE_STATE = '/api/v2/vault-backup-service/state'
BACKUP_FILE_SUFFIX = '.backup'
DID = 'did'
USR_DID = 'user_did'
APP_DID = 'app_did'
OWNER_ID = 'owner_id'
CREATE_TIME = 'create_time'
MODIFY_TIME = 'modify_time'
SIZE = 'size'
STATE = 'state'
STATE_RUNNING = 'running'
STATE_FINISH = 'finish'
STATE_FAILED = 'failed'
ORIGINAL_SIZE = 'original_size'
IS_UPGRADED = 'is_upgraded'
CID = 'cid'
COUNT = 'count'
COL_ORDERS = 'vault_order'
COL_ORDERS_SUBSCRIPTION = 'subscription'
COL_ORDERS_PRICING_NAME = 'pricing_name'
COL_ORDERS_ELA_AMOUNT = 'ela_amount'
COL_ORDERS_ELA_ADDRESS = 'ela_address'
COL_ORDERS_PROOF = 'proof'
COL_ORDERS_STATUS = 'status'
COL_ORDERS_STATUS_NORMAL = 'normal'
COL_ORDERS_STATUS_PAID = 'paid'
COL_ORDERS_STATUS_ARCHIVE = 'archive'
COL_RECEIPTS = 'vault_receipt'
COL_RECEIPTS_ID = 'receipt_id'
COL_RECEIPTS_ORDER_ID = 'order_id'
COL_RECEIPTS_TRANSACTION_ID = 'transaction_id'
COL_RECEIPTS_PAID_DID = 'paid_did'
COL_IPFS_FILES = 'ipfs_files'
COL_IPFS_FILES_PATH = 'path'
COL_IPFS_FILES_SHA256 = 'sha256'
COL_IPFS_FILES_IS_FILE = 'is_file'
COL_IPFS_FILES_IPFS_CID = 'ipfs_cid'
COL_IPFS_CID_REF = 'ipfs_cid_ref'
COL_IPFS_BACKUP_CLIENT = 'ipfs_backup_client'
COL_IPFS_BACKUP_SERVER = 'ipfs_backup_server'
BACKUP_TARGET_TYPE = 'type'
BACKUP_TARGET_TYPE_HIVE_NODE = 'hive_node'
BACKUP_TARGET_TYPE_GOOGLE_DRIVER = 'google_driver'
BACKUP_REQUEST_ACTION = 'action'
BACKUP_REQUEST_ACTION_BACKUP = 'backup'
BACKUP_REQUEST_ACTION_RESTORE = 'restore'
BACKUP_REQUEST_STATE = 'state'
BACKUP_REQUEST_STATE_STOP = 'stop'
BACKUP_REQUEST_STATE_INPROGRESS = 'process'
BACKUP_REQUEST_STATE_SUCCESS = 'success'
BACKUP_REQUEST_STATE_FAILED = 'failed'
BACKUP_REQUEST_STATE_MSG = 'state_msg'
BACKUP_REQUEST_TARGET_HOST = 'target_host'
BACKUP_REQUEST_TARGET_DID = 'target_did'
BACKUP_REQUEST_TARGET_TOKEN = 'target_token'
# For backup subscription.
BKSERVER_REQ_ACTION = 'req_action'
BKSERVER_REQ_STATE = 'req_state'
BKSERVER_REQ_STATE_MSG = 'req_state_msg'
BKSERVER_REQ_CID = 'req_cid'
BKSERVER_REQ_SHA256 = 'req_sha256'
BKSERVER_REQ_SIZE = 'req_size'
def get_unique_dict_item_from_list(dict_list: list):
if not dict_list:
return list()
return list({frozenset(item.items()): item for item in dict_list}.values())
| url_did_sign_in = '/api/v2/did/signin'
url_did_auth = '/api/v2/did/auth'
url_did_backup_auth = '/api/v2/did/backup_auth'
url_backup_service = '/api/v2/internal_backup/service'
url_backup_finish = '/api/v2/internal_backup/finished_confirmation'
url_backup_files = '/api/v2/internal_backup/files'
url_backup_file = '/api/v2/internal_backup/file'
url_backup_patch_hash = '/api/v2/internal_backup/patch_hash'
url_backup_patch_delta = '/api/v2/internal_backup/patch_delta'
url_backup_patch_file = '/api/v2/internal_backup/patch_file'
url_restore_finish = '/api/v2/internal_restore/finished_confirmation'
url_ipfs_backup_pin_cids = '/api/v2/ipfs-backup-internal/pin_cids'
url_ipfs_backup_get_cids = '/api/v2/ipfs-backup-internal/get_cids'
url_ipfs_backup_get_dbfiles = '/api/v2/ipfs-backup-internal/get_dbfiles'
url_ipfs_backup_state = '/api/v2/ipfs-backup-internal/state'
url_vault_backup_service_backup = '/api/v2/vault-backup-service/backup'
url_vault_backup_service_restore = '/api/v2/vault-backup-service/restore'
url_vault_backup_service_state = '/api/v2/vault-backup-service/state'
backup_file_suffix = '.backup'
did = 'did'
usr_did = 'user_did'
app_did = 'app_did'
owner_id = 'owner_id'
create_time = 'create_time'
modify_time = 'modify_time'
size = 'size'
state = 'state'
state_running = 'running'
state_finish = 'finish'
state_failed = 'failed'
original_size = 'original_size'
is_upgraded = 'is_upgraded'
cid = 'cid'
count = 'count'
col_orders = 'vault_order'
col_orders_subscription = 'subscription'
col_orders_pricing_name = 'pricing_name'
col_orders_ela_amount = 'ela_amount'
col_orders_ela_address = 'ela_address'
col_orders_proof = 'proof'
col_orders_status = 'status'
col_orders_status_normal = 'normal'
col_orders_status_paid = 'paid'
col_orders_status_archive = 'archive'
col_receipts = 'vault_receipt'
col_receipts_id = 'receipt_id'
col_receipts_order_id = 'order_id'
col_receipts_transaction_id = 'transaction_id'
col_receipts_paid_did = 'paid_did'
col_ipfs_files = 'ipfs_files'
col_ipfs_files_path = 'path'
col_ipfs_files_sha256 = 'sha256'
col_ipfs_files_is_file = 'is_file'
col_ipfs_files_ipfs_cid = 'ipfs_cid'
col_ipfs_cid_ref = 'ipfs_cid_ref'
col_ipfs_backup_client = 'ipfs_backup_client'
col_ipfs_backup_server = 'ipfs_backup_server'
backup_target_type = 'type'
backup_target_type_hive_node = 'hive_node'
backup_target_type_google_driver = 'google_driver'
backup_request_action = 'action'
backup_request_action_backup = 'backup'
backup_request_action_restore = 'restore'
backup_request_state = 'state'
backup_request_state_stop = 'stop'
backup_request_state_inprogress = 'process'
backup_request_state_success = 'success'
backup_request_state_failed = 'failed'
backup_request_state_msg = 'state_msg'
backup_request_target_host = 'target_host'
backup_request_target_did = 'target_did'
backup_request_target_token = 'target_token'
bkserver_req_action = 'req_action'
bkserver_req_state = 'req_state'
bkserver_req_state_msg = 'req_state_msg'
bkserver_req_cid = 'req_cid'
bkserver_req_sha256 = 'req_sha256'
bkserver_req_size = 'req_size'
def get_unique_dict_item_from_list(dict_list: list):
if not dict_list:
return list()
return list({frozenset(item.items()): item for item in dict_list}.values()) |
"""
.. module: lemur.plugins.utils
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
def get_plugin_option(name, options):
"""
Retrieve option name from options dict.
:param options:
:return:
"""
for o in options:
if o.get('name') == name:
return o['value']
| """
.. module: lemur.plugins.utils
:platform: Unix
:copyright: (c) 2018 by Netflix Inc., see AUTHORS for more
:license: Apache, see LICENSE for more details.
.. moduleauthor:: Kevin Glisson <kglisson@netflix.com>
"""
def get_plugin_option(name, options):
"""
Retrieve option name from options dict.
:param options:
:return:
"""
for o in options:
if o.get('name') == name:
return o['value'] |
def input(channel):
pass
def wait_for_edge(channel, edge_type, timeout=None):
pass
def add_event_detect(channel, edge_type, callback=None, bouncetime=None):
pass
def add_event_callback(channel, callback, bouncetime=None):
pass
def event_detected(channel):
pass
def remove_event_detect(channel):
pass
| def input(channel):
pass
def wait_for_edge(channel, edge_type, timeout=None):
pass
def add_event_detect(channel, edge_type, callback=None, bouncetime=None):
pass
def add_event_callback(channel, callback, bouncetime=None):
pass
def event_detected(channel):
pass
def remove_event_detect(channel):
pass |
class Solution:
def generateParenthesis(self, n: int) -> List[str]:
st = []
res = []
def backtracking(op ,cl):
if op == cl == n :
res.append("".join(st))
return
if op < n :
st.append("(")
backtracking(op+1,cl)
st.pop()
if cl < op :
st.append(")")
backtracking(op,cl+1)
st.pop()
backtracking(0,0)
return res
| class Solution:
def generate_parenthesis(self, n: int) -> List[str]:
st = []
res = []
def backtracking(op, cl):
if op == cl == n:
res.append(''.join(st))
return
if op < n:
st.append('(')
backtracking(op + 1, cl)
st.pop()
if cl < op:
st.append(')')
backtracking(op, cl + 1)
st.pop()
backtracking(0, 0)
return res |
general_desc = """
<div><span class="bold">$name</span><span>: $desc</span></div>
"""
general_head = """
<html>
<body>
"""
general_foot = """
</html>
</body>
"""
not_srd = """
<!DOCTYPE html>
<html>
<head>
<style>
.name {
font-size:225%;
font-family:Georgia, serif;
font-variant:small-caps;
font-weight:bold;
color:#A73335;
</style>
</head>
<body>
<div contenteditable="false" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">
<div class="name"> $name is not SRD :( </div>
"""
item_dict = dict(
header="""
<!DOCTYPE html>
<html>
<head>
<style>
.gradient {
margin:10px 0px;
}
.name {
font-size:225%;
font-family:Georgia, serif;
font-variant:small-caps;
font-weight:bold;
color:#A73335;
}
.description {
font-style:italic;
}
.bold {
font-weight:bold;
}
.red {
color:#A73335;
}
table {
width:100%;
border:0px;
border-collapse:collapse;
color:#A73335;
}
th, td {
width:50px;
text-align:center;
}
.actions {
font-size:175%;
font-variant:small-caps;
margin:17px 0px 0px 0px;
}
.hr {
background: #A73335;
height:2px;
}
.attack_odd {
margin:10px 0px;
color: black;
}
.attack_even {
margin:10px 0px;
color: white;
}
.bolditalic {
font-weight:bold;
font-style:italic;
}
</style>
</head>
<body>
<div contenteditable="true" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">
""",
gradient="""
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
""",
name="""
<div class="name"> $desc </div>
""",
desc="""
<div><span class="bold">$name</span><span> $desc</span></div>
""",
dmg="""
<div><span class="bold">Damage</span><span> $dmg1 $dmgType</span></div>
""",
dmg_vers="""
<div><span class="bold">Damage</span><span> $dmg1($dmg2) $dmgType</span></div>
""",
text="""
<div><span> $text</span></div>
""",
foot="""
</div>
</body>
</html>
""",
body35="""
No description available
"""
)
spell_dict = dict(
entire="""
<!DOCTYPE html>
<html>
<head>
<style>
.gradient {
margin:10px 0px;
}
.name {
font-size:225%;
font-family:Georgia, serif;
font-variant:small-caps;
font-weight:bold;
color:#A73335;
}
.description {
font-style:italic;
}
.bold {
font-weight:bold;
}
.red {
color:#A73335;
}
table {
width:100%;
border:0px;
border-collapse:collapse;
color:#A73335;
}
th, td {
width:50px;
text-align:center;
}
.actions {
font-size:175%;
font-variant:small-caps;
margin:17px 0px 0px 0px;
}
.hr {
background: #A73335;
height:2px;
}
.attack_odd {
margin:10px 0px;
color: black;
}
.attack_even {
margin:10px 0px;
color: white;
}
.bolditalic {
font-weight:bold;
font-style:italic;
}
</style>
</head>
<body>
<div contenteditable="true" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">
<div class="name"> $name </div>
<div class="description">$level $school</div>
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
<br>
<div><span class="bold">Casting Time:</span><span> $time</span></div>
<div><span class="bold">Range:</span><span> $range</span></div>
<div><span class="bold">Component:</span><span> $components</span></div>
<div><span class="bold">Duration:</span><span> $duration</span></div>
<br>
<div><span class="bold">$classes</span></div>
<br>
<div><span>$text</span></div>
</div>
</body>
</html>
"""
)
monster_dict = dict(
first="""
<!DOCTYPE html>
<html>
<head>
<style>
.gradient {
margin:10px 0px;
}
.name {
font-size:225%;
font-family:Georgia, serif;
font-variant:small-caps;
font-weight:bold;
color:#A73335;
}
.description {
font-style:italic;
}
.bold {
font-weight:bold;
}
.red {
color:#A73335;
}
table {
width:100%;
border:0px;
border-collapse:collapse;
color:#A73335;
}
th, td {
width:50px;
text-align:center;
}
.actions {
font-size:175%;
font-variant:small-caps;
margin:17px 0px 0px 0px;
}
.hr {
background: #A73335;
height:2px;
}
.attack_odd {
margin:10px 0px;
color: black;
}
.attack_even {
margin:10px 0px;
color: white;
}
.bolditalic {
font-weight:bold;
font-style:italic;
}
</style>
</head>
<body>
<div contenteditable="true" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">
<div class="name"> $name </div>
<div class="description">$size $type, $alignment</div>
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
<div class="red">
<div ><span class="bold red">Armor Class</span><span> $armor_class </span></div>
<div><span class="bold red">Hit Points</span><span> $hit_points</span></div>
<div><span class="bold red">Speed</span><span> $speed</span></div>
</div>
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
<table cellspacing = "0">
<tr><th>STR</th> <th>DEX</th><th>CON</th><th>INT</th><th>WIS</th><th>CHA</th></tr>
<tr><td style="padding: 0 10px;">$str ($str_mod)</td> <td style="padding: 0 10px;">$dex ($dex_mod)</td>
<td style="padding: 0 10px;">$con ($con_mod)</td><td style="padding: 0 10px;">$int ($int_mod)</td>
<td style="padding: 0 10px;">$wis ($wis_mod)</td><td style="padding: 0 10px;">$cha ($cha_mod)</td></tr>
</table>
<br>
""",
desc="""
<div><span class="bold">$name</span><span> $desc</span></div>
""",
cr="""
<div><span class="bold">Challenge Rating</span><span> $cr</span><span class="description"> ($xp XP)</span></div>
""",
gradient="""
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
""",
special_abilities="""
<div><span class="bolditalic">$name</span><span> $desc</span></div>
""",
second="""
<div class="actions red">Actions</div>
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
""",
action_odd="""
<div class="hr"></div>
<div class="attack_even"><span class="bolditalic">$name</span><span> $text</span></div>
""",
action_even="""
<div class="attack_odd"><span class="bolditalic">$name</span><span> $text</span></div>
""",
legendary_header="""
<div class="actions red">Legendary Actions</div>
<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>
""",
rest="""
</div>
</body>
</html>
""")
| general_desc = '\n<div><span class="bold">$name</span><span>: $desc</span></div> \n'
general_head = '\n<html>\n<body>\n'
general_foot = '\n</html>\n</body>\n'
not_srd = '\n<!DOCTYPE html>\n <html>\n <head>\n <style>\n .name {\n font-size:225%;\n font-family:Georgia, serif;\n font-variant:small-caps;\n font-weight:bold;\n color:#A73335;\n </style>\n </head>\n <body>\n <div contenteditable="false" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">\n <div class="name"> $name is not SRD :( </div>\n'
item_dict = dict(header='\n <!DOCTYPE html>\n <html>\n <head>\n <style>\n .gradient {\n margin:10px 0px;\n }\n .name {\n font-size:225%;\n font-family:Georgia, serif;\n font-variant:small-caps;\n font-weight:bold;\n color:#A73335;\n }\n .description {\n font-style:italic; \n }\n .bold {\n font-weight:bold;\n }\n .red {\n color:#A73335;\n }\n table {\n width:100%;\n border:0px;\n border-collapse:collapse;\n color:#A73335;\n }\n th, td {\n width:50px;\n text-align:center;\n }\n .actions {\n font-size:175%;\n font-variant:small-caps;\n margin:17px 0px 0px 0px;\n }\n .hr {\n background: #A73335;\n height:2px;\n }\n .attack_odd {\n margin:10px 0px;\n color: black;\n }\n .attack_even {\n margin:10px 0px;\n color: white;\n }\n .bolditalic {\n font-weight:bold;\n font-style:italic;\n }\n </style>\n </head>\n <body>\n <div contenteditable="true" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">\n ', gradient='\n <div class="gradient"><img scr="assets/linear_gradient.png;" /></div>\n ', name='\n <div class="name"> $desc </div>\n ', desc='\n <div><span class="bold">$name</span><span> $desc</span></div> \n ', dmg='\n <div><span class="bold">Damage</span><span> $dmg1 $dmgType</span></div> \n ', dmg_vers='\n <div><span class="bold">Damage</span><span> $dmg1($dmg2) $dmgType</span></div> \n ', text='\n \n <div><span> $text</span></div>\n \n ', foot='\n </div>\n </body>\n </html>\n ', body35='\n No description available\n ')
spell_dict = dict(entire='\n<!DOCTYPE html>\n<html>\n<head>\n<style>\n.gradient {\n margin:10px 0px;\n}\n.name {\n font-size:225%;\n font-family:Georgia, serif;\n font-variant:small-caps;\n font-weight:bold;\n color:#A73335;\n}\n.description {\n font-style:italic; \n}\n.bold {\n font-weight:bold;\n}\n.red {\n color:#A73335;\n}\ntable {\n width:100%;\n border:0px;\n border-collapse:collapse;\n color:#A73335;\n}\nth, td {\n width:50px;\n text-align:center;\n}\n.actions {\n font-size:175%;\n font-variant:small-caps;\n margin:17px 0px 0px 0px;\n}\n.hr {\n background: #A73335;\n height:2px;\n}\n.attack_odd {\n margin:10px 0px;\n color: black;\n}\n.attack_even {\n margin:10px 0px;\n color: white;\n}\n.bolditalic {\n font-weight:bold;\n font-style:italic;\n}\n</style>\n</head>\n<body>\n<div contenteditable="true" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">\n<div class="name"> $name </div>\n<div class="description">$level $school</div>\n\n<div class="gradient"><img scr="assets/linear_gradient.png;" /></div> \n<br>\n<div><span class="bold">Casting Time:</span><span> $time</span></div>\n<div><span class="bold">Range:</span><span> $range</span></div>\n<div><span class="bold">Component:</span><span> $components</span></div>\n<div><span class="bold">Duration:</span><span> $duration</span></div>\n<br>\n<div><span class="bold">$classes</span></div>\n<br>\n\n<div><span>$text</span></div>\n</div>\n</body>\n</html>\n')
monster_dict = dict(first='\n<!DOCTYPE html>\n<html>\n<head>\n<style>\n.gradient {\n margin:10px 0px;\n}\n.name {\n font-size:225%;\n font-family:Georgia, serif;\n font-variant:small-caps;\n font-weight:bold;\n color:#A73335;\n}\n.description {\n font-style:italic; \n}\n.bold {\n font-weight:bold;\n}\n.red {\n color:#A73335;\n}\ntable {\n width:100%;\n border:0px;\n border-collapse:collapse;\n color:#A73335;\n}\nth, td {\n width:50px;\n text-align:center;\n}\n.actions {\n font-size:175%;\n font-variant:small-caps;\n margin:17px 0px 0px 0px;\n}\n.hr {\n background: #A73335;\n height:2px;\n}\n.attack_odd {\n margin:10px 0px;\n color: black;\n}\n.attack_even {\n margin:10px 0px;\n color: white;\n}\n.bolditalic {\n font-weight:bold;\n font-style:italic;\n}\n</style>\n</head>\n<body>\n<div contenteditable="true" style="width:310px; font-family:Arial,Helvetica,sans-serif;font-size:17px;">\n<div class="name"> $name </div>\n<div class="description">$size $type, $alignment</div>\n\n<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>\n\n<div class="red">\n <div ><span class="bold red">Armor Class</span><span> $armor_class </span></div>\n <div><span class="bold red">Hit Points</span><span> $hit_points</span></div>\n <div><span class="bold red">Speed</span><span> $speed</span></div>\n</div>\n\n<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>\n\n<table cellspacing = "0">\n <tr><th>STR</th> <th>DEX</th><th>CON</th><th>INT</th><th>WIS</th><th>CHA</th></tr>\n <tr><td style="padding: 0 10px;">$str ($str_mod)</td> <td style="padding: 0 10px;">$dex ($dex_mod)</td>\n <td style="padding: 0 10px;">$con ($con_mod)</td><td style="padding: 0 10px;">$int ($int_mod)</td>\n <td style="padding: 0 10px;">$wis ($wis_mod)</td><td style="padding: 0 10px;">$cha ($cha_mod)</td></tr>\n</table>\n \n<br>\n', desc='\n<div><span class="bold">$name</span><span> $desc</span></div> \n', cr='\n<div><span class="bold">Challenge Rating</span><span> $cr</span><span class="description"> ($xp XP)</span></div> \n', gradient='\n<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>\n', special_abilities='\n<div><span class="bolditalic">$name</span><span> $desc</span></div>\n', second=' \n<div class="actions red">Actions</div>\n<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>\n', action_odd='\n<div class="hr"></div>\n<div class="attack_even"><span class="bolditalic">$name</span><span> $text</span></div> \n', action_even='\n<div class="attack_odd"><span class="bolditalic">$name</span><span> $text</span></div> \n', legendary_header=' \n<div class="actions red">Legendary Actions</div>\n<div class="gradient"><img scr="assets/linear_gradient.png;" /></div>\n', rest='\n</div>\n</body>\n</html>\n') |
"""
Eugene
"""
__all__ = ["Config", "Primatives", "Node", "Tree", "Individual", "Population", "Util"]
__version__ = '0.1.1'
__date__ = '2015-08-07 07:09:00 -0700'
__author__ = 'tmthydvnprt'
__status__ = 'development'
__website__ = 'https://github.com/tmthydvnprt/eugene'
__email__ = 'tmthydvnprt@users.noreply.github.com'
__maintainer__ = 'tmthydvnprt'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015, eugene'
__credits__ = ''
"""
Eugene
Operators:
===========
Unary:
-------
o.abs(a) - Same as abs(a).
o.inv(a) - Same as ~a.
o.neg(a) - Same as -a.
o.pos(a) - Same as +a.
Binary:
--------
o.or_(a, b) - Same as a | b.
o.add(a, b) - Same as a + b.
o.and_(a, b) - Same as a & b.
o.div(a, b) - Same as a / b when __future__.division is not in effect.
o.eq(a, b) - Same as a==b.
o.floordiv(a, b) - Same as a // b.
o.ge(a, b) - Same as a>=b.
o.gt(a, b) - Same as a>b.
o.le(a, b) - Same as a<=b.
o.lt(a, b) - Same as a<b.
o.mod(a, b) - Same as a % b.
o.mul(a, b) - Same as a * b.
o.ne(a, b) - Same as a!=b.
o.pow(a, b) - Same as a ** b.
o.sub(a, b) - Same as a - b.
o.truediv(a, b) - Same as a / b when __future__.division is in effect.
o.xor(a, b) - Same as a ^ b.
Functions:
===========
Unary:
-------
np.acos(x) - Return the arc cosine (measured in radians) of x.
np.acosh(x) - Return the hyperbolic arc cosine (measured in radians) of x.
np.asin(x) - Return the arc sine (measured in radians) of x.
np.asinh(x) - Return the hyperbolic arc sine (measured in radians) of x.
np.atan(x) - Return the arc tangent (measured in radians) of x.
np.atanh(x) - Return the hyperbolic arc tangent (measured in radians) of x.
np.ceil(x) - Return the ceiling of x as a float. This is the smallest integral value >= x.
np.cos(x) - Return the cosine of x (measured in radians).
np.cosh(x) - Return the hyperbolic cosine of x.
np.degrees(x) - Convert angle x from radians to degrees.
sp.erf(x) - Error function at x.
sp.erfc(x) - Complementary error function at x.
np.exp(x) - Return e raised to the power of x.
np.expm1(x) - Return exp(x)-1. This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.
np.fabs(x) - Return the absolute value of the float x.
sm.factorial(x) - Find x!. Raise a ValueError if x is negative or non-integral. -> Integral
np.floor(x) - Return the floor of x as a float. This is the largest integral value <= x.
sp.gamma(x) - Gamma function at x.
np.isinf(x) - Check if float x is infinite (positive or negative). -> bool
np.isnan(x) - Check if float x is not a number (NaN). -> bool
sp.lgamma(x) - Natural logarithm of absolute value of Gamma function at x.
np.log10(x) - Return the base 10 logarithm of x.
np.log2(x) - Return the base 2 logarithm of x.
np.log1p(x) - Return the natural logarithm of 1+x (base e). The result is computed in a way which is accurate for x near zero.
np.log(x) - Return the natural logarithm of x.
np.radians(x) - Convert angle x from degrees to radians.
np.sin(x) - Return the sine of x (measured in radians).
np.sinh(x) - Return the hyperbolic sine of x.
np.sqrt(x) - Return the square root of x.
np.tan(x) - Return the tangent of x (measured in radians).
np.tanh(x) - Return the hyperbolic tangent of x.
np.trunc(x:Real) - Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method. -> Integral
Binary:
--------
np.atan2(y, x) - Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered.
np.copysign(x, y) - Return x with the sign of y.
np.fmod(x, y) - Return fmod(x, y), according to platform C. x % y may differ.
np.hypot(x, y) - Return the Euclidean distance, sqrt(x*x + y*y).
np.ldexp(x, i) - Return x * (2**i).
np.pow(x, y) - Return x**y (x to the power of y).
np.round(x[, y]) - Return the floating point value x rounded to y digits after the decimal point.
N-ary:
--------
np.max(x, y, ...) - Return the largest item in an iterable or the largest of two or more arguments.
np.min(x, y, ...) - Return the smallest item in an iterable or the smallest of two or more arguments.
np.fsum([x,y,...]) - Return an accurate floating point sum of values in the iterable.
np.prod([x,y,...]) - Return an accurate floating point product of values in the iterable.
Constants:
===========
np.p - The mathematical constant pi = 3.141592..., to available precision.
np.e - The mathematical constant e = 2.718281..., to available precision.
Ephemeral Variables : - once created stay constant, only can be used during initialization or mutation
=====================
r.random() - Returns x in the interval [0, 1).
r.randint(a, b) - Returns integer x in range [a, b].
r.uniform(a, b) - Returns number x in the range [a, b) or [a, b] depending on rounding.
r.normalvariate(mu, sigma) - Returns number x from Normal distribution. mu is the mean, and sigma is the standard deviation.
Variables:
===========
a, b, c, ..., x, y, z - whatever you need, define in `eugene.Config.VAR`
To add:
========
pd.shift()
removed:
=========
o.not_() - can't operate on array, but o.inv() can & produces the same result
"""
| """
Eugene
"""
__all__ = ['Config', 'Primatives', 'Node', 'Tree', 'Individual', 'Population', 'Util']
__version__ = '0.1.1'
__date__ = '2015-08-07 07:09:00 -0700'
__author__ = 'tmthydvnprt'
__status__ = 'development'
__website__ = 'https://github.com/tmthydvnprt/eugene'
__email__ = 'tmthydvnprt@users.noreply.github.com'
__maintainer__ = 'tmthydvnprt'
__license__ = 'MIT'
__copyright__ = 'Copyright 2015, eugene'
__credits__ = ''
"\nEugene\n\nOperators:\n===========\n Unary:\n -------\n o.abs(a) - Same as abs(a).\n o.inv(a) - Same as ~a.\n o.neg(a) - Same as -a.\n o.pos(a) - Same as +a.\n\n Binary:\n --------\n o.or_(a, b) - Same as a | b.\n o.add(a, b) - Same as a + b.\n o.and_(a, b) - Same as a & b.\n o.div(a, b) - Same as a / b when __future__.division is not in effect.\n o.eq(a, b) - Same as a==b.\n o.floordiv(a, b) - Same as a // b.\n o.ge(a, b) - Same as a>=b.\n o.gt(a, b) - Same as a>b.\n o.le(a, b) - Same as a<=b.\n o.lt(a, b) - Same as a<b.\n o.mod(a, b) - Same as a % b.\n o.mul(a, b) - Same as a * b.\n o.ne(a, b) - Same as a!=b.\n o.pow(a, b) - Same as a ** b.\n o.sub(a, b) - Same as a - b.\n o.truediv(a, b) - Same as a / b when __future__.division is in effect.\n o.xor(a, b) - Same as a ^ b.\n\nFunctions:\n===========\n Unary:\n -------\n np.acos(x) - Return the arc cosine (measured in radians) of x.\n np.acosh(x) - Return the hyperbolic arc cosine (measured in radians) of x.\n np.asin(x) - Return the arc sine (measured in radians) of x.\n np.asinh(x) - Return the hyperbolic arc sine (measured in radians) of x.\n np.atan(x) - Return the arc tangent (measured in radians) of x.\n np.atanh(x) - Return the hyperbolic arc tangent (measured in radians) of x.\n np.ceil(x) - Return the ceiling of x as a float. This is the smallest integral value >= x.\n np.cos(x) - Return the cosine of x (measured in radians).\n np.cosh(x) - Return the hyperbolic cosine of x.\n np.degrees(x) - Convert angle x from radians to degrees.\n sp.erf(x) - Error function at x.\n sp.erfc(x) - Complementary error function at x.\n np.exp(x) - Return e raised to the power of x.\n np.expm1(x) - Return exp(x)-1. This function avoids the loss of precision involved in the direct evaluation of exp(x)-1 for small x.\n np.fabs(x) - Return the absolute value of the float x.\n sm.factorial(x) - Find x!. Raise a ValueError if x is negative or non-integral. -> Integral\n np.floor(x) - Return the floor of x as a float. This is the largest integral value <= x.\n sp.gamma(x) - Gamma function at x.\n np.isinf(x) - Check if float x is infinite (positive or negative). -> bool\n np.isnan(x) - Check if float x is not a number (NaN). -> bool\n sp.lgamma(x) - Natural logarithm of absolute value of Gamma function at x.\n np.log10(x) - Return the base 10 logarithm of x.\n np.log2(x) - Return the base 2 logarithm of x.\n np.log1p(x) - Return the natural logarithm of 1+x (base e). The result is computed in a way which is accurate for x near zero.\n np.log(x) - Return the natural logarithm of x.\n np.radians(x) - Convert angle x from degrees to radians.\n np.sin(x) - Return the sine of x (measured in radians).\n np.sinh(x) - Return the hyperbolic sine of x.\n np.sqrt(x) - Return the square root of x.\n np.tan(x) - Return the tangent of x (measured in radians).\n np.tanh(x) - Return the hyperbolic tangent of x.\n np.trunc(x:Real) - Truncates x to the nearest Integral toward 0. Uses the __trunc__ magic method. -> Integral\n\n Binary:\n --------\n np.atan2(y, x) - Return the arc tangent (measured in radians) of y/x. Unlike atan(y/x), the signs of both x and y are considered.\n np.copysign(x, y) - Return x with the sign of y.\n np.fmod(x, y) - Return fmod(x, y), according to platform C. x % y may differ.\n np.hypot(x, y) - Return the Euclidean distance, sqrt(x*x + y*y).\n np.ldexp(x, i) - Return x * (2**i).\n np.pow(x, y) - Return x**y (x to the power of y).\n np.round(x[, y]) - Return the floating point value x rounded to y digits after the decimal point.\n\n N-ary:\n --------\n np.max(x, y, ...) - Return the largest item in an iterable or the largest of two or more arguments.\n np.min(x, y, ...) - Return the smallest item in an iterable or the smallest of two or more arguments.\n np.fsum([x,y,...]) - Return an accurate floating point sum of values in the iterable.\n np.prod([x,y,...]) - Return an accurate floating point product of values in the iterable.\n\nConstants:\n===========\n np.p - The mathematical constant pi = 3.141592..., to available precision.\n np.e - The mathematical constant e = 2.718281..., to available precision.\n\nEphemeral Variables : - once created stay constant, only can be used during initialization or mutation\n=====================\n r.random() - Returns x in the interval [0, 1).\n r.randint(a, b) - Returns integer x in range [a, b].\n r.uniform(a, b) - Returns number x in the range [a, b) or [a, b] depending on rounding.\n r.normalvariate(mu, sigma) - Returns number x from Normal distribution. mu is the mean, and sigma is the standard deviation.\n\nVariables:\n===========\n a, b, c, ..., x, y, z - whatever you need, define in `eugene.Config.VAR`\n\nTo add:\n========\npd.shift()\n\nremoved:\n=========\no.not_() - can't operate on array, but o.inv() can & produces the same result\n\n" |
# Do not edit this file directly.
# It was auto-generated by: code/programs/reflexivity/reflexive_refresh
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
def glog():
http_archive(
name="glog" ,
sha256="bae42ec37b50e156071f5b92d2ff09aa5ece56fd8c58d2175fc1ffea85137664" ,
strip_prefix="glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6" ,
urls = [
"https://github.com/Unilang/glog/archive/0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6.tar.gz",
], repo_mapping = {
"@com_github_gflags_gflags" : "@gflags",
},
)
| load('@bazel_tools//tools/build_defs/repo:http.bzl', 'http_archive')
def glog():
http_archive(name='glog', sha256='bae42ec37b50e156071f5b92d2ff09aa5ece56fd8c58d2175fc1ffea85137664', strip_prefix='glog-0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6', urls=['https://github.com/Unilang/glog/archive/0a2e5931bd5ff22fd3bf8999eb8ce776f159cda6.tar.gz'], repo_mapping={'@com_github_gflags_gflags': '@gflags'}) |
'''
Created on 14.10.2019
@author: JM
'''
class TMC2130_register_variant:
" ===== TMC2130 register variants ===== "
"..." | """
Created on 14.10.2019
@author: JM
"""
class Tmc2130_Register_Variant:
""" ===== TMC2130 register variants ===== """
'...' |
# Rainbow Grid handgezeichnet
add_library('handy')
def setup():
global h
h = HandyRenderer(this)
size(600, 600)
this.surface.setTitle("Rainbow Grid Handy")
rectMode(CENTER)
h.setRoughness(1)
h.setFillWeight(0.9)
h.setFillGap(0.9)
def draw():
colorMode(RGB)
background(235, 215, 182)
colorMode(HSB)
translate(12, 12)
for x in range(20):
for y in range(20):
d = dist(30*x, 30*y, mouseX, mouseY)
fill(0.5*d, 255, 255)
h.rect(x*30 + 3, y*30 + 3, 24, 24)
| add_library('handy')
def setup():
global h
h = handy_renderer(this)
size(600, 600)
this.surface.setTitle('Rainbow Grid Handy')
rect_mode(CENTER)
h.setRoughness(1)
h.setFillWeight(0.9)
h.setFillGap(0.9)
def draw():
color_mode(RGB)
background(235, 215, 182)
color_mode(HSB)
translate(12, 12)
for x in range(20):
for y in range(20):
d = dist(30 * x, 30 * y, mouseX, mouseY)
fill(0.5 * d, 255, 255)
h.rect(x * 30 + 3, y * 30 + 3, 24, 24) |
set_name(0x800A0CD8, "VID_OpenModule__Fv", SN_NOWARN)
set_name(0x800A0D98, "InitScreens__Fv", SN_NOWARN)
set_name(0x800A0E88, "MEM_SetupMem__Fv", SN_NOWARN)
set_name(0x800A0EB4, "SetupWorkRam__Fv", SN_NOWARN)
set_name(0x800A0F44, "SYSI_Init__Fv", SN_NOWARN)
set_name(0x800A1050, "GM_Open__Fv", SN_NOWARN)
set_name(0x800A1074, "PA_Open__Fv", SN_NOWARN)
set_name(0x800A10AC, "PAD_Open__Fv", SN_NOWARN)
set_name(0x800A10F0, "OVR_Open__Fv", SN_NOWARN)
set_name(0x800A1110, "SCR_Open__Fv", SN_NOWARN)
set_name(0x800A1140, "DEC_Open__Fv", SN_NOWARN)
set_name(0x800A13B4, "GetVersionString__FPc", SN_NOWARN)
set_name(0x800A1488, "GetWord__FPc", SN_NOWARN)
set_name(0x800A1164, "StrDate", SN_NOWARN)
set_name(0x800A1170, "StrTime", SN_NOWARN)
set_name(0x800A117C, "Words", SN_NOWARN)
set_name(0x800A1354, "MonDays", SN_NOWARN)
| set_name(2148142296, 'VID_OpenModule__Fv', SN_NOWARN)
set_name(2148142488, 'InitScreens__Fv', SN_NOWARN)
set_name(2148142728, 'MEM_SetupMem__Fv', SN_NOWARN)
set_name(2148142772, 'SetupWorkRam__Fv', SN_NOWARN)
set_name(2148142916, 'SYSI_Init__Fv', SN_NOWARN)
set_name(2148143184, 'GM_Open__Fv', SN_NOWARN)
set_name(2148143220, 'PA_Open__Fv', SN_NOWARN)
set_name(2148143276, 'PAD_Open__Fv', SN_NOWARN)
set_name(2148143344, 'OVR_Open__Fv', SN_NOWARN)
set_name(2148143376, 'SCR_Open__Fv', SN_NOWARN)
set_name(2148143424, 'DEC_Open__Fv', SN_NOWARN)
set_name(2148144052, 'GetVersionString__FPc', SN_NOWARN)
set_name(2148144264, 'GetWord__FPc', SN_NOWARN)
set_name(2148143460, 'StrDate', SN_NOWARN)
set_name(2148143472, 'StrTime', SN_NOWARN)
set_name(2148143484, 'Words', SN_NOWARN)
set_name(2148143956, 'MonDays', SN_NOWARN) |
__title__ = "Django REST framework Caching Tools"
__version__ = "1.0.3"
__author__ = "Vincent Wantchalk"
__license__ = "MIT"
__copyright__ = "Copyright 2011-2019 xsudo.com"
# Version synonym
VERSION = __version__
# Header encoding (see RFC5987)
HTTP_HEADER_ENCODING = "iso-8859-1"
default_app_config = "drf_cache.apps.DOTConfig"
| __title__ = 'Django REST framework Caching Tools'
__version__ = '1.0.3'
__author__ = 'Vincent Wantchalk'
__license__ = 'MIT'
__copyright__ = 'Copyright 2011-2019 xsudo.com'
version = __version__
http_header_encoding = 'iso-8859-1'
default_app_config = 'drf_cache.apps.DOTConfig' |
# Generate input data for EM 514, Homework Problem 8
def DefineInputs():
area = 200.0e-6
nodes = [{'x': 0.0e0, 'y': 0.0e0, 'z': 0.0e0, 'xflag': 'd', 'xbcval': 0.0, 'yflag': 'd', 'ybcval': 0.0e0, 'zflag': 'd', 'zbcval': 0.0e0}]
nodes.append({'x': 3.0e0, 'y': 0.0e0, 'z': 0.0e0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': 0.0e0, 'zflag': 'd', 'zbcval': 0.0e0})
nodes.append({'x': 6.0e0, 'y': 0.0e0, 'z': 0.0e0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': 0.0e0, 'zflag': 'd', 'zbcval': 0.0e0})
nodes.append({'x': 3.0e0, 'y': -4.0e0, 'z': 0.0e0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': -9.0e3, 'zflag': 'd', 'zbcval': 0.0e0})
nodes.append({'x': 6.0e0, 'y': -4.0e0, 'z': 0.0e0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': -15.0e3, 'zflag': 'd', 'zbcval': 0.0e0})
nodes.append({'x': 9.0e0, 'y': -4.0e0, 'z': 0.0e0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'd', 'ybcval': 0.0e0, 'zflag': 'd', 'zbcval': 0.0e0})
members = [{'start': 0, 'end': 1, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6}]
members.append({'start': 1, 'end': 2, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 0, 'end': 3, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 1, 'end': 3, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 2, 'end': 3, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 3, 'end': 4, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 2, 'end': 4, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 2, 'end': 5, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
members.append({'start': 4, 'end': 5, 'E': 200.0e9, 'A': area, 'sigma_yield': 36.0e6, 'sigma_ult': 66.0e6})
return nodes, members | def define_inputs():
area = 0.0002
nodes = [{'x': 0.0, 'y': 0.0, 'z': 0.0, 'xflag': 'd', 'xbcval': 0.0, 'yflag': 'd', 'ybcval': 0.0, 'zflag': 'd', 'zbcval': 0.0}]
nodes.append({'x': 3.0, 'y': 0.0, 'z': 0.0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': 0.0, 'zflag': 'd', 'zbcval': 0.0})
nodes.append({'x': 6.0, 'y': 0.0, 'z': 0.0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': 0.0, 'zflag': 'd', 'zbcval': 0.0})
nodes.append({'x': 3.0, 'y': -4.0, 'z': 0.0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': -9000.0, 'zflag': 'd', 'zbcval': 0.0})
nodes.append({'x': 6.0, 'y': -4.0, 'z': 0.0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'f', 'ybcval': -15000.0, 'zflag': 'd', 'zbcval': 0.0})
nodes.append({'x': 9.0, 'y': -4.0, 'z': 0.0, 'xflag': 'f', 'xbcval': 0.0, 'yflag': 'd', 'ybcval': 0.0, 'zflag': 'd', 'zbcval': 0.0})
members = [{'start': 0, 'end': 1, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0}]
members.append({'start': 1, 'end': 2, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 0, 'end': 3, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 1, 'end': 3, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 2, 'end': 3, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 3, 'end': 4, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 2, 'end': 4, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 2, 'end': 5, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
members.append({'start': 4, 'end': 5, 'E': 200000000000.0, 'A': area, 'sigma_yield': 36000000.0, 'sigma_ult': 66000000.0})
return (nodes, members) |
n = int(input('Valor do produto: '))
val = (n*5) / 100
res = val
print('O VALOR FINAL COM 5% DE DESCONTO VAI SER ${}:'.format(val))
| n = int(input('Valor do produto: '))
val = n * 5 / 100
res = val
print('O VALOR FINAL COM 5% DE DESCONTO VAI SER ${}:'.format(val)) |
quarter = (dta.inspection_date.dt.month - 1) // 3
quarter_size = dta.groupby((quarter, violation_num)).size()
axes = quarter_size.unstack(level=0).plot.bar(
figsize=(14, 8),
)
| quarter = (dta.inspection_date.dt.month - 1) // 3
quarter_size = dta.groupby((quarter, violation_num)).size()
axes = quarter_size.unstack(level=0).plot.bar(figsize=(14, 8)) |
# pin numbers
# http://micropython-on-wemos-d1-mini.readthedocs.io/en/latest/setup.html
# https://forum.micropython.org/viewtopic.php?t=2503
D0 = 16 # wake
D5 = 14 # sck
D6 = 12 # miso
D7 = 13 # mosi
D8 = 15 # cs PULL-DOWN 10k
D4 = 2 # boot PULL-UP 10k
D3 = 0 # flash PULL-UP 10k
D2 = 4 # sda
D1 = 5 # scl
RX = 3 # rx
TX = 1 # tx
# note: D4 is also used to control the builtin blue led, but it's reversed
# (when D4 is 1, the led is off)
LED = D4
| d0 = 16
d5 = 14
d6 = 12
d7 = 13
d8 = 15
d4 = 2
d3 = 0
d2 = 4
d1 = 5
rx = 3
tx = 1
led = D4 |
CENTRALIZED = False
EXAMPLE_PAIR = "ZRX-WETH"
USE_ETHEREUM_WALLET = True
FEE_TYPE = "FlatFee"
FEE_TOKEN = "ETH"
DEFAULT_FEES = [0, 0.00001]
| centralized = False
example_pair = 'ZRX-WETH'
use_ethereum_wallet = True
fee_type = 'FlatFee'
fee_token = 'ETH'
default_fees = [0, 1e-05] |
'''
154. Find Minimum in Rotated Sorted Array II
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/
similar problem: "153. Find Minimum in Rotated Sorted Array"
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
Find the minimum element.
The array may contain duplicates.
Example 1:
Input: [1,3,5]
Output: 1
Example 2:
Input: [2,2,2,0,1]
Output: 0
Note:
This is a follow up problem to Find Minimum in Rotated Sorted Array.
Would allow duplicates affect the run-time complexity? How and why?
'''
# correct:
class Solution:
def findMin(self, nums: List[int]) -> int:
lo, hi = 0, len(nums) - 1
while lo < hi:
mid = lo + (hi - lo) // 2
if nums[mid] > nums[hi]:
lo = mid + 1
else:
hi = mid if nums[hi] != nums[mid] else hi - 1
return nums[lo]
# reference:
# https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/discuss/48908/Clean-python-solution
'''
wrong:
class Solution:
def findMin(self, nums: List[int]) -> int:
lo, hi = 0, len(nums)-1
while lo < hi:
mid = lo + (hi - lo) // 2
# if nums[mid] < nums[hi]: wrong! should use >
hi = mid if nums[hi] != nums[mid] else hi -1
else:
lo = mid + 1
return nums[lo]
''' | """
154. Find Minimum in Rotated Sorted Array II
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array-ii/
similar problem: "153. Find Minimum in Rotated Sorted Array"
https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand.
(i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]).
Find the minimum element.
The array may contain duplicates.
Example 1:
Input: [1,3,5]
Output: 1
Example 2:
Input: [2,2,2,0,1]
Output: 0
Note:
This is a follow up problem to Find Minimum in Rotated Sorted Array.
Would allow duplicates affect the run-time complexity? How and why?
"""
class Solution:
def find_min(self, nums: List[int]) -> int:
(lo, hi) = (0, len(nums) - 1)
while lo < hi:
mid = lo + (hi - lo) // 2
if nums[mid] > nums[hi]:
lo = mid + 1
else:
hi = mid if nums[hi] != nums[mid] else hi - 1
return nums[lo]
'\nwrong:\nclass Solution:\n def findMin(self, nums: List[int]) -> int:\n lo, hi = 0, len(nums)-1\n while lo < hi:\n mid = lo + (hi - lo) // 2\n # if nums[mid] < nums[hi]: wrong! should use >\n hi = mid if nums[hi] != nums[mid] else hi -1\n\n else:\n lo = mid + 1\n\n return nums[lo]\n' |
def self_powers(final:int):
sum_pows = 0
for integer in range(1, final + 1):
power = 1
for _ in range(integer):
power = (power * integer) % (10**11)
sum_pows += power
return sum_pows % (10 ** 10)
if __name__ == "__main__":
print(self_powers(1000)) | def self_powers(final: int):
sum_pows = 0
for integer in range(1, final + 1):
power = 1
for _ in range(integer):
power = power * integer % 10 ** 11
sum_pows += power
return sum_pows % 10 ** 10
if __name__ == '__main__':
print(self_powers(1000)) |
SP500 = {'A.O. Smith Corp': 'AOS',
'Abbott Laboratories': 'ABT',
'AbbVie Inc.': 'ABBV',
'Accenture plc': 'ACN',
'Activision Blizzard': 'ATVI',
'Acuity Brands Inc': 'AYI',
'Adobe Systems Inc': 'ADBE',
'Advance Auto Parts': 'AAP',
'Advanced Micro Devices Inc': 'AMD',
'AES Corp': 'AES',
'Aetna Inc': 'AET',
'Affiliated Managers Group Inc': 'AMG',
'AFLAC Inc': 'AFL',
'Agilent Technologies Inc': 'A',
'Air Products & Chemicals Inc': 'APD',
'Akamai Technologies Inc': 'AKAM',
'Alaska Air Group Inc': 'ALK',
'Albemarle Corp': 'ALB',
'Alexandria Real Estate Equities Inc': 'ARE',
'Alexion Pharmaceuticals': 'ALXN',
'Align Technology': 'ALGN',
'Allegion': 'ALLE',
'Alliance Data Systems': 'ADS',
'Alliant Energy Corp': 'LNT',
'Allstate Corp': 'ALL',
'Alphabet Inc Class A': 'GOOGL',
'Alphabet Inc Class C': 'GOOG',
'Altria Group Inc': 'MO',
'Amazon.com Inc.': 'AMZN',
'Ameren Corp': 'AEE',
'American Airlines Group': 'AAL',
'American Electric Power': 'AEP',
'American Express Co': 'AXP',
'American International Group Inc.': 'AIG',
'American Tower Corp A': 'AMT',
'American Water Works Company Inc': 'AWK',
'Ameriprise Financial': 'AMP',
'AmerisourceBergen Corp': 'ABC',
'AMETEK Inc.': 'AME',
'Amgen Inc.': 'AMGN',
'Amphenol Corp': 'APH',
'Andeavor': 'ANDV',
'ANSYS': 'ANSS',
'Anthem Inc.': 'ANTM',
'Aon plc': 'AON',
'Apache Corporation': 'APA',
'Apartment Investment & Management': 'AIV',
'Apple Inc.': 'AAPL',
'Applied Materials Inc.': 'AMAT',
'Aptiv Plc': 'APTV',
'Archer-Daniels-Midland Co': 'ADM',
'Arconic Inc.': 'ARNC',
'Arthur J. Gallagher & Co.': 'AJG',
'Assurant Inc.': 'AIZ',
'AT&T Inc.': 'T',
'Autodesk Inc.': 'ADSK',
'Automatic Data Processing': 'ADP',
'AutoZone Inc': 'AZO',
'AvalonBay Communities Inc.': 'AVB',
'Avery Dennison Corp': 'AVY',
'Baker Hughes a GE Company': 'BKR',
'Ball Corp': 'BLL',
'Bank of America Corp': 'BAC',
'Baxter International Inc.': 'BAX',
'Becton Dickinson': 'BDX',
'Berkshire Hathaway': 'BRK.A',
'Best Buy Co. Inc.': 'BBY',
'Biogen Inc.': 'BIIB',
'BlackRock': 'BLK',
'Block H&R': 'HRB',
'Boeing Company': 'BA',
'Booking Holdings Inc': 'BKNG',
'BorgWarner': 'BWA',
'Boston Properties': 'BXP',
'Boston Scientific': 'BSX',
'Brighthouse Financial Inc': 'BHF',
'Bristol-Myers Squibb': 'BMY',
'Broadcom': 'AVGO',
'Brown-Forman Corp.': 'BF.B',
'C. H. Robinson Worldwide': 'CHRW',
'CA Inc.': 'CA',
'Cabot Oil & Gas': 'COG',
'Cadence Design Systems': 'CDNS',
'Campbell Soup': 'CPB',
'Capital One Financial': 'COF',
'Cardinal Health Inc.': 'CAH',
'Carmax Inc': 'KMX',
'Carnival Corp.': 'CCL',
'Caterpillar Inc.': 'CAT',
'Cboe Global Markets': 'CBOE',
'CBRE Group': 'CBRE',
'Centene Corporation': 'CNC',
'CenterPoint Energy': 'CNP',
'CenturyLink Inc': 'CTL',
'Cerner': 'CERN',
'CF Industries Holdings Inc': 'CF',
'Charles Schwab Corporation': 'SCHW',
'Charter Communications': 'CHTR',
'Chevron Corp.': 'CVX',
'Chipotle Mexican Grill': 'CMG',
'Chubb Limited': 'CB',
'Church & Dwight': 'CHD',
'CIGNA Corp.': 'CI',
'Cimarex Energy': 'XEC',
'Cincinnati Financial': 'CINF',
'Cintas Corporation': 'CTAS',
'Cisco Systems': 'CSCO',
'Citigroup Inc.': 'C',
'Citizens Financial Group': 'CFG',
'Citrix Systems': 'CTXS',
'CME Group Inc.': 'CME',
'CMS Energy': 'CMS',
'Coca-Cola Company (The)': 'KO',
'Cognizant Technology Solutions': 'CTSH',
'Colgate-Palmolive': 'CL',
'Comcast Corp.': 'CMCSA',
'Comerica Inc.': 'CMA',
'Conagra Brands': 'CAG',
'Concho Resources': 'CXO',
'ConocoPhillips': 'COP',
'Consolidated Edison': 'ED',
'Constellation Brands': 'STZ',
'Corning Inc.': 'GLW',
'Costco Wholesale Corp.': 'COST',
'Coty Inc': 'COTY',
'Crown Castle International Corp.': 'CCI',
'CSRA Inc.': 'CSRA',
'CSX Corp.': 'CSX',
'Cummins Inc.': 'CMI',
'CVS Health': 'CVS',
'D. R. Horton': 'DHI',
'Danaher Corp.': 'DHR',
'Darden Restaurants': 'DRI',
'DaVita Inc.': 'DVA',
'Deere & Co.': 'DE',
'Delta Air Lines Inc.': 'DAL',
'Dentsply Sirona': 'XRAY',
'Devon Energy Corp.': 'DVN',
'Digital Realty Trust Inc': 'DLR',
'Discover Financial Services': 'DFS',
'Discovery Inc. Class A': 'DISCA',
'Discovery Inc. Class C': 'DISCK',
'Dish Network': 'DISH',
'Dollar General': 'DG',
'Dollar Tree': 'DLTR',
'Dominion Energy': 'D',
'Dover Corp.': 'DOV',
'DTE Energy Co.': 'DTE',
'Duke Energy': 'DUK',
'Duke Realty Corp': 'DRE',
'DXC Technology': 'DXC',
'E*Trade': 'ETFC',
'Eastman Chemical': 'EMN',
'Eaton Corporation': 'ETN',
'eBay Inc.': 'EBAY',
'Ecolab Inc.': 'ECL',
'Edison International': 'EIX',
'Edwards Lifesciences': 'EW',
'Electronic Arts': 'EA',
'Emerson Electric Company': 'EMR',
'Entergy Corp.': 'ETR',
'Envision Healthcare': 'EVHC',
'EOG Resources': 'EOG',
'EQT Corporation': 'EQT',
'Equifax Inc.': 'EFX',
'Equinix': 'EQIX',
'Equity Residential': 'EQR',
'Essex Property Trust Inc.': 'ESS',
'Estee Lauder Cos.': 'EL',
'Everest Re Group Ltd.': 'RE',
'Eversource Energy': 'ES',
'Exelon Corp.': 'EXC',
'Expedia Inc.': 'EXPE',
'Expeditors International': 'EXPD',
'Express Scripts': 'ESRX',
'Extra Space Storage': 'EXR',
'Exxon Mobil Corp.': 'XOM',
'F5 Networks': 'FFIV',
'Facebook Inc.': 'FB',
'Fastenal Co': 'FAST',
'Federal Realty Investment Trust': 'FRT',
'FedEx Corporation': 'FDX',
'Fidelity National Information Services': 'FIS',
'Fifth Third Bancorp': 'FITB',
'FirstEnergy Corp': 'FE',
'Fiserv Inc': 'FISV',
'FLIR Systems': 'FLIR',
'Flowserve Corporation': 'FLS',
'Fluor Corp.': 'FLR',
'FMC Corporation': 'FMC',
'Foot Locker Inc': 'FL',
'Ford Motor': 'F',
'Fortive Corp': 'FTV',
'Fortune Brands Home & Security': 'FBHS',
'Franklin Resources': 'BEN',
'Freeport-McMoRan Inc.': 'FCX',
'Gap Inc.': 'GPS',
'Garmin Ltd.': 'GRMN',
'Gartner Inc': 'IT',
'General Dynamics': 'GD',
'General Electric': 'GE',
'General Growth Properties Inc.': 'GGP',
'General Mills': 'GIS',
'General Motors': 'GM',
'Genuine Parts': 'GPC',
'Gilead Sciences': 'GILD',
'Global Payments Inc.': 'GPN',
'Goldman Sachs Group': 'GS',
'Goodyear Tire & Rubber': 'GT',
'Grainger (W.W.) Inc.': 'GWW',
'Halliburton Co.': 'HAL',
'Hanesbrands Inc': 'HBI',
'Harley-Davidson': 'HOG',
'Hartford Financial Svc.Gp.': 'HIG',
'Hasbro Inc.': 'HAS',
'HCA Holdings': 'HCA',
'Helmerich & Payne': 'HP',
'Henry Schein': 'HSIC',
'Hess Corporation': 'HES',
'Hewlett Packard Enterprise': 'HPE',
'Hilton Worldwide Holdings Inc': 'HLT',
'Hologic': 'HOLX',
'Home Depot': 'HD',
'Honeywell International Inc.': 'HON',
'Hormel Foods Corp.': 'HRL',
'Host Hotels & Resorts': 'HST',
'HP Inc.': 'HPQ',
'Humana Inc.': 'HUM',
'Huntington Bancshares': 'HBAN',
'Huntington Ingalls Industries': 'HII',
'IDEXX Laboratories': 'IDXX',
'IHS Markit Ltd.': 'INFO',
'Illinois Tool Works': 'ITW',
'Illumina Inc': 'ILMN',
'Incyte': 'INCY',
'Ingersoll-Rand PLC': 'IR',
'Intel Corp.': 'INTC',
'Intercontinental Exchange': 'ICE',
'International Business Machines': 'IBM',
'International Paper': 'IP',
'Interpublic Group': 'IPG',
'Intl Flavors & Fragrances': 'IFF',
'Intuit Inc.': 'INTU',
'Intuitive Surgical Inc.': 'ISRG',
'Invesco Ltd.': 'IVZ',
'IPG Photonics Corp.': 'IPGP',
'IQVIA Holdings Inc.': 'IQV',
'Iron Mountain Incorporated': 'IRM',
'J. B. Hunt Transport Services': 'JBHT',
'Jacobs Engineering Group': 'J',
'JM Smucker': 'SJM',
'Johnson & Johnson': 'JNJ',
'Johnson Controls International': 'JCI',
'JPMorgan Chase & Co.': 'JPM',
'Juniper Networks': 'JNPR',
'Kansas City Southern': 'KSU',
'Kellogg Co.': 'K',
'KeyCorp': 'KEY',
'Kimberly-Clark': 'KMB',
'Kimco Realty': 'KIM',
'Kinder Morgan': 'KMI',
'KLA-Tencor Corp.': 'KLAC',
'Kohls Corp.': 'KSS',
'Kraft Heinz Co': 'KHC',
'Kroger Co.': 'KR',
'L Brands Inc.': 'LB',
'Laboratory Corp. of America Holding': 'LH',
'Lam Research': 'LRCX',
'Leggett & Platt': 'LEG',
'Lennar Corp.': 'LEN',
'Lilly (Eli) & Co.': 'LLY',
'Lincoln National': 'LNC',
'LKQ Corporation': 'LKQ',
'Lockheed Martin Corp.': 'LMT',
'Loews Corp.': 'L',
'Lowes Cos.': 'LOW',
'LyondellBasell': 'LYB',
'M&T Bank Corp.': 'MTB',
'Macerich': 'MAC',
'Macys Inc.': 'M',
'Marathon Oil Corp.': 'MRO',
'Marathon Petroleum': 'MPC',
'Marriott International.': 'MAR',
'Marsh & McLennan': 'MMC',
'Martin Marietta Materials': 'MLM',
'Masco Corp.': 'MAS',
'Mastercard Inc.': 'MA',
'Mattel Inc.': 'MAT',
'McCormick & Co.': 'MKC',
'McDonalds Corp.': 'MCD',
'McKesson Corp.': 'MCK',
'Medtronic plc': 'MDT',
'Merck & Co.': 'MRK',
'MetLife Inc.': 'MET',
'Mettler Toledo': 'MTD',
'MGM Resorts International': 'MGM',
'Microchip Technology': 'MCHP',
'Micron Technology': 'MU',
'Microsoft Corp.': 'MSFT',
'Mid-America Apartments': 'MAA',
'Mohawk Industries': 'MHK',
'Molson Coors Brewing Company': 'TAP',
'Mondelez International': 'MDLZ',
'Monsanto Co.': 'MON',
'Monster Beverage': 'MNST',
'Moodys Corp': 'MCO',
'Morgan Stanley': 'MS',
'Motorola Solutions Inc.': 'MSI',
'Mylan N.V.': 'MYL',
'Nasdaq Inc.': 'NDAQ',
'National Oilwell Varco Inc.': 'NOV',
'Navient': 'NAVI',
'Nektar Therapeutics': 'NKTR',
'NetApp': 'NTAP',
'Netflix Inc.': 'NFLX',
'Newell Brands': 'NWL',
'Newmont Mining Corporation': 'NEM',
'News Corp. Class A': 'NWSA',
'News Corp. Class B': 'NWS',
'NextEra Energy': 'NEE',
'Nielsen Holdings': 'NLSN',
'Nike': 'NKE',
'NiSource Inc.': 'NI',
'Noble Energy Inc': 'NBL',
'Nordstrom': 'JWN',
'Norfolk Southern Corp.': 'NSC',
'Northern Trust Corp.': 'NTRS',
'Northrop Grumman Corp.': 'NOC',
'Norwegian Cruise Line': 'NCLH',
'NRG Energy': 'NRG',
'Nucor Corp.': 'NUE',
'Nvidia Corporation': 'NVDA',
'OReilly Automotive': 'ORLY',
'Occidental Petroleum': 'OXY',
'Omnicom Group': 'OMC',
'ONEOK': 'OKE',
'Oracle Corp.': 'ORCL',
'PACCAR Inc.': 'PCAR',
'Packaging Corporation of America': 'PKG',
'Parker-Hannifin': 'PH',
'Paychex Inc.': 'PAYX',
'PayPal': 'PYPL',
'Pentair Ltd.': 'PNR',
'Peoples United Financial': 'PBCT',
'PepsiCo Inc.': 'PEP',
'PerkinElmer': 'PKI',
'Perrigo': 'PRGO',
'Pfizer Inc.': 'PFE',
'PG&E Corp.': 'PCG',
'Philip Morris International': 'PM',
'Phillips 66': 'PSX',
'Pinnacle West Capital': 'PNW',
'Pioneer Natural Resources': 'PXD',
'PNC Financial Services': 'PNC',
'Polo Ralph Lauren Corp.': 'RL',
'PPG Industries': 'PPG',
'PPL Corp.': 'PPL',
'Principal Financial Group': 'PFG',
'Procter & Gamble': 'PG',
'Progressive Corp.': 'PGR',
'Prologis': 'PLD',
'Prudential Financial': 'PRU',
'Public Serv. Enterprise Inc.': 'PEG',
'Public Storage': 'PSA',
'Pulte Homes Inc.': 'PHM',
'PVH Corp.': 'PVH',
'Qorvo': 'QRVO',
'QUALCOMM Inc.': 'QCOM',
'Quanta Services Inc.': 'PWR',
'Quest Diagnostics': 'DGX',
'Range Resources Corp.': 'RRC',
'Raymond James Financial Inc.': 'RJF',
'Realty Income Corporation': 'O',
'Regency Centers Corporation': 'REG',
'Regeneron': 'REGN',
'Regions Financial Corp.': 'RF',
'Republic Services Inc': 'RSG',
'ResMed': 'RMD',
'Robert Half International': 'RHI',
'Rockwell Automation Inc.': 'ROK',
'Rockwell Collins': 'COL',
'Roper Technologies': 'ROP',
'Ross Stores': 'ROST',
'Royal Caribbean Cruises Ltd': 'RCL',
'S&P Global Inc.': 'SPGI',
'Salesforce.com': 'CRM',
'SBA Communications': 'SBAC',
'SCANA Corp': 'SCG',
'Schlumberger Ltd.': 'SLB',
'Seagate Technology': 'STX',
'Sealed Air': 'SEE',
'Sempra Energy': 'SRE',
'Sherwin-Williams': 'SHW',
'Simon Property Group Inc': 'SPG',
'Skyworks Solutions': 'SWKS',
'SL Green Realty': 'SLG',
'Snap-On Inc.': 'SNA',
'Southern Co.': 'SO',
'Southwest Airlines': 'LUV',
'Stanley Black & Decker': 'SWK',
'Starbucks Corp.': 'SBUX',
'State Street Corp.': 'STT',
'Stericycle Inc': 'SRCL',
'Stryker Corp.': 'SYK',
'SVB Financial': 'SIVB',
'Synchrony Financial': 'SYF',
'Synopsys Inc.': 'SNPS',
'Sysco Corp.': 'SYY',
'T. Rowe Price Group': 'TROW',
'Take-Two Interactive': 'TTWO',
'Tapestry Inc.': 'TPR',
'Target Corp.': 'TGT',
'TE Connectivity Ltd.': 'TEL',
'TechnipFMC': 'FTI',
'Texas Instruments': 'TXN',
'Textron Inc.': 'TXT',
'The Bank of New York Mellon Corp.': 'BK',
'The Clorox Company': 'CLX',
'The Cooper Companies': 'COO',
'The Hershey Company': 'HSY',
'The Mosaic Company': 'MOS',
'The Travelers Companies Inc.': 'TRV',
'The Walt Disney Company': 'DIS',
'Thermo Fisher Scientific': 'TMO',
'Tiffany & Co.': 'TIF',
'Time Warner Inc.': 'TWX',
'TJX Companies Inc.': 'TJX',
'Tractor Supply Company': 'TSCO',
'TransDigm Group': 'TDG',
'TripAdvisor': 'TRIP',
'Twenty-First Century Fox Class A': 'FOXA',
'Twenty-First Century Fox Class B': 'FOX',
'Tyson Foods': 'TSN',
'U.S. Bancorp': 'USB',
'UDR Inc': 'UDR',
'Ulta Beauty': 'ULTA',
'Under Armour Class A': 'UAA',
'Under Armour Class C': 'UA',
'Union Pacific': 'UNP',
'United Continental Holdings': 'UAL',
'United Health Group Inc.': 'UNH',
'United Parcel Service': 'UPS',
'United Rentals Inc.': 'URI',
'Universal Health Services Inc.': 'UHS',
'Unum Group': 'UNM',
'V.F. Corp.': 'VFC',
'Valero Energy': 'VLO',
'Varian Medical Systems': 'VAR',
'Ventas Inc': 'VTR',
'Verisign Inc.': 'VRSN',
'Verisk Analytics': 'VRSK',
'Verizon Communications': 'VZ',
'Vertex Pharmaceuticals Inc': 'VRTX',
'Viacom Inc.': 'VIAC',
'Visa Inc.': 'V',
'Vornado Realty Trust': 'VNO',
'Vulcan Materials': 'VMC',
'Wal-Mart Stores': 'WMT',
'Walgreens Boots Alliance': 'WBA',
'Waste Management Inc.': 'WM',
'Waters Corporation': 'WAT',
'Wec Energy Group Inc': 'WEC',
'Wells Fargo': 'WFC',
'Welltower Inc.': 'WELL',
'Western Digital': 'WDC',
'Western Union Co': 'WU',
'WestRock Company': 'WRK',
'Weyerhaeuser Corp.': 'WY',
'Whirlpool Corp.': 'WHR',
'Williams Cos.': 'WMB',
'Willis Towers Watson': 'WLTW',
'Wynn Resorts Ltd': 'WYNN',
'Xcel Energy Inc': 'XEL',
'Xerox Corp.': 'XRX',
'Xilinx Inc': 'XLNX',
'XL Capital': 'XL',
'Xylem Inc.': 'XYL',
'Yum! Brands Inc': 'YUM',
'Zimmer Biomet Holdings': 'ZBH',
'Zions Bancorp': 'ZION',
'Zoetis': 'ZTS'}
ISO3 = {'Afghanistan': 'AFG',
'Albania': 'ALB',
'Algeria': 'DZA',
'Angola': 'AGO',
'Antigua and Barbuda': 'ATG',
'Argentina': 'ARG',
'Armenia': 'ARM',
'Aruba': 'ABW',
'Australia': 'AUS',
'Austria': 'AUT',
'Azerbaijan': 'AZE',
'Bahamas': 'BHS',
'Bahrain': 'BHR',
'Bangladesh': 'BGD',
'Barbados': 'BRB',
'Belarus': 'BLR',
'Belgium': 'BEL',
'Belize': 'BLZ',
'Benin': 'BEN',
'Bhutan': 'BTN',
'Bolivia': 'BOL',
'Bosnia and Herzegovina': 'BIH',
'Botswana': 'BWA',
'Brazil': 'BRA',
'Brunei Darussalam': 'BRN',
'Bulgaria': 'BGR',
'Burkina Faso': 'BFA',
'Burundi': 'BDI',
'Cabo Verde': 'CPV',
'Cambodia': 'KHM',
'Cameroon': 'CMR',
'Canada': 'CAN',
'Chad': 'TCD',
'Chile': 'CHL',
'China': 'CHN',
'Colombia': 'COL',
'Comoros': 'COM',
'Congo Dem. Rep.': 'COD',
'Congo Rep.': 'COG',
'Costa Rica': 'CRI',
'Cote dIvoire': 'CIV',
'Croatia': 'HRV',
'Cyprus': 'CYP',
'Czech Republic': 'CZE',
'Denmark': 'DNK',
'Djibouti': 'DJI',
'Dominica': 'DMA',
'Dominican Republic': 'DOM',
'Ecuador': 'ECU',
'Egypt Arab Rep.': 'EGY',
'El Salvador': 'SLV',
'Equatorial Guinea': 'GNQ',
'Eritrea': 'ERI',
'Estonia': 'EST',
'Ethiopia': 'ETH',
'Fiji': 'FJI',
'Finland': 'FIN',
'France': 'FRA',
'Gabon': 'GAB',
'Gambia': 'GMB',
'Georgia': 'GEO',
'Germany': 'DEU',
'Ghana': 'GHA',
'Greece': 'GRC',
'Grenada': 'GRD',
'Guatemala': 'GTM',
'Guinea': 'GIN',
'Guinea-Bissau': 'GNB',
'Guyana': 'GUY',
'Haiti': 'HTI',
'Honduras': 'HND',
'Hong Kong SAR China': 'HKG',
'Hungary': 'HUN',
'Iceland': 'ISL',
'India': 'IND',
'Indonesia': 'IDN',
'Iran Islamic Rep.': 'IRN',
'Iraq': 'IRQ',
'Ireland': 'IRL',
'Israel': 'ISR',
'Italy': 'ITA',
'Jamaica': 'JAM',
'Japan': 'JPN',
'Jordan': 'JOR',
'Kazakhstan': 'KAZ',
'Kenya': 'KEN',
'Kiribati': 'KIR',
'Korea Rep': 'KOR',
'Kuwait': 'KWT',
'Kyrgyz Republic': 'KGZ',
'Lao PDR': 'LAO',
'Latvia': 'LVA',
'Lebanon': 'LBN',
'Lesotho': 'LSO',
'Liberia': 'LBR',
'Libya': 'LBY',
'Lithuania': 'LTU',
'Luxembourg': 'LUX',
'Macao SAR China': 'MAC',
'Macedonia FYR': 'MKD',
'Madagascar': 'MDG',
'Malawi': 'MWI',
'Malaysia': 'MYS',
'Maldives': 'MDV',
'Mali': 'MLI',
'Malta': 'MLT',
'Marshall Islands': 'MHL',
'Mauritania': 'MRT',
'Mauritius': 'MUS',
'Mexico': 'MEX',
'Micronesia Fed. Sts.': 'FSM',
'Moldova': 'MDA',
'Mongolia': 'MNG',
'Montenegro': 'MNE',
'Morocco': 'MAR',
'Mozambique': 'MOZ',
'Myanmar': 'MMR',
'Namibia': 'NAM',
'Nepal': 'NPL',
'Netherlands': 'NLD',
'New Zealand': 'NZL',
'Nicaragua': 'NIC',
'Niger': 'NER',
'Nigeria': 'NGA',
'Norway': 'NOR',
'Oman': 'OMN',
'Pakistan': 'PAK',
'Palau': 'PLW',
'Panama': 'PAN',
'Papua New Guinea': 'PNG',
'Paraguay': 'PRY',
'Peru': 'PER',
'Philippines': 'PHL',
'Poland': 'POL',
'Portugal': 'PRT',
'Puerto Rico': 'PRI',
'Qatar': 'QAT',
'Romania': 'ROU',
'Russian Federation': 'RUS',
'Rwanda': 'RWA',
'Samoa': 'WSM',
'San Marino': 'SMR',
'Sao Tome and Principe': 'STP',
'Saudi Arabia': 'SAU',
'Senegal': 'SEN',
'Serbia': 'SRB',
'Seychelles': 'SYC',
'Sierra Leone': 'SLE',
'Singapore': 'SGP',
'Slovak Republic': 'SVK',
'Slovenia': 'SVN',
'Solomon Islands': 'SLB',
'South Africa': 'ZAF',
'South Sudan': 'SSD',
'Spain': 'ESP',
'Sri Lanka': 'LKA',
'St. Kitts and Nevis': 'KNA',
'St. Lucia': 'LCA',
'St. Vincent and the Grenadines': 'VCT',
'Sudan': 'SDN',
'Suriname': 'SUR',
'Swaziland': 'SWZ',
'Sweden': 'SWE',
'Switzerland': 'CHE',
'Syrian Arab Republic': 'SYR',
'Tajikistan': 'TJK',
'Tanzania': 'TZA',
'Thailand': 'THA',
'Timor-Leste': 'TLS',
'Togo': 'TGO',
'Tonga': 'TON',
'Trinidad and Tobago': 'TTO',
'Tunisia': 'TUN',
'Turkey': 'TUR',
'Turkmenistan': 'TKM',
'Tuvalu': 'TUV',
'Uganda': 'UGA',
'Ukraine': 'UKR',
'United Arab Emirates': 'ARE',
'United Kingdom': 'GBR',
'United States': 'USA',
'Uruguay': 'URY',
'Uzbekistan': 'UZB',
'Vanuatu': 'VUT',
'Venezuela RB': 'VEN',
'Vietnam': 'VNM',
'Yemen Rep.': 'YEM',
'Zambia': 'ZMB',
'Zimbabwe': 'ZWE'} | sp500 = {'A.O. Smith Corp': 'AOS', 'Abbott Laboratories': 'ABT', 'AbbVie Inc.': 'ABBV', 'Accenture plc': 'ACN', 'Activision Blizzard': 'ATVI', 'Acuity Brands Inc': 'AYI', 'Adobe Systems Inc': 'ADBE', 'Advance Auto Parts': 'AAP', 'Advanced Micro Devices Inc': 'AMD', 'AES Corp': 'AES', 'Aetna Inc': 'AET', 'Affiliated Managers Group Inc': 'AMG', 'AFLAC Inc': 'AFL', 'Agilent Technologies Inc': 'A', 'Air Products & Chemicals Inc': 'APD', 'Akamai Technologies Inc': 'AKAM', 'Alaska Air Group Inc': 'ALK', 'Albemarle Corp': 'ALB', 'Alexandria Real Estate Equities Inc': 'ARE', 'Alexion Pharmaceuticals': 'ALXN', 'Align Technology': 'ALGN', 'Allegion': 'ALLE', 'Alliance Data Systems': 'ADS', 'Alliant Energy Corp': 'LNT', 'Allstate Corp': 'ALL', 'Alphabet Inc Class A': 'GOOGL', 'Alphabet Inc Class C': 'GOOG', 'Altria Group Inc': 'MO', 'Amazon.com Inc.': 'AMZN', 'Ameren Corp': 'AEE', 'American Airlines Group': 'AAL', 'American Electric Power': 'AEP', 'American Express Co': 'AXP', 'American International Group Inc.': 'AIG', 'American Tower Corp A': 'AMT', 'American Water Works Company Inc': 'AWK', 'Ameriprise Financial': 'AMP', 'AmerisourceBergen Corp': 'ABC', 'AMETEK Inc.': 'AME', 'Amgen Inc.': 'AMGN', 'Amphenol Corp': 'APH', 'Andeavor': 'ANDV', 'ANSYS': 'ANSS', 'Anthem Inc.': 'ANTM', 'Aon plc': 'AON', 'Apache Corporation': 'APA', 'Apartment Investment & Management': 'AIV', 'Apple Inc.': 'AAPL', 'Applied Materials Inc.': 'AMAT', 'Aptiv Plc': 'APTV', 'Archer-Daniels-Midland Co': 'ADM', 'Arconic Inc.': 'ARNC', 'Arthur J. Gallagher & Co.': 'AJG', 'Assurant Inc.': 'AIZ', 'AT&T Inc.': 'T', 'Autodesk Inc.': 'ADSK', 'Automatic Data Processing': 'ADP', 'AutoZone Inc': 'AZO', 'AvalonBay Communities Inc.': 'AVB', 'Avery Dennison Corp': 'AVY', 'Baker Hughes a GE Company': 'BKR', 'Ball Corp': 'BLL', 'Bank of America Corp': 'BAC', 'Baxter International Inc.': 'BAX', 'Becton Dickinson': 'BDX', 'Berkshire Hathaway': 'BRK.A', 'Best Buy Co. Inc.': 'BBY', 'Biogen Inc.': 'BIIB', 'BlackRock': 'BLK', 'Block H&R': 'HRB', 'Boeing Company': 'BA', 'Booking Holdings Inc': 'BKNG', 'BorgWarner': 'BWA', 'Boston Properties': 'BXP', 'Boston Scientific': 'BSX', 'Brighthouse Financial Inc': 'BHF', 'Bristol-Myers Squibb': 'BMY', 'Broadcom': 'AVGO', 'Brown-Forman Corp.': 'BF.B', 'C. H. Robinson Worldwide': 'CHRW', 'CA Inc.': 'CA', 'Cabot Oil & Gas': 'COG', 'Cadence Design Systems': 'CDNS', 'Campbell Soup': 'CPB', 'Capital One Financial': 'COF', 'Cardinal Health Inc.': 'CAH', 'Carmax Inc': 'KMX', 'Carnival Corp.': 'CCL', 'Caterpillar Inc.': 'CAT', 'Cboe Global Markets': 'CBOE', 'CBRE Group': 'CBRE', 'Centene Corporation': 'CNC', 'CenterPoint Energy': 'CNP', 'CenturyLink Inc': 'CTL', 'Cerner': 'CERN', 'CF Industries Holdings Inc': 'CF', 'Charles Schwab Corporation': 'SCHW', 'Charter Communications': 'CHTR', 'Chevron Corp.': 'CVX', 'Chipotle Mexican Grill': 'CMG', 'Chubb Limited': 'CB', 'Church & Dwight': 'CHD', 'CIGNA Corp.': 'CI', 'Cimarex Energy': 'XEC', 'Cincinnati Financial': 'CINF', 'Cintas Corporation': 'CTAS', 'Cisco Systems': 'CSCO', 'Citigroup Inc.': 'C', 'Citizens Financial Group': 'CFG', 'Citrix Systems': 'CTXS', 'CME Group Inc.': 'CME', 'CMS Energy': 'CMS', 'Coca-Cola Company (The)': 'KO', 'Cognizant Technology Solutions': 'CTSH', 'Colgate-Palmolive': 'CL', 'Comcast Corp.': 'CMCSA', 'Comerica Inc.': 'CMA', 'Conagra Brands': 'CAG', 'Concho Resources': 'CXO', 'ConocoPhillips': 'COP', 'Consolidated Edison': 'ED', 'Constellation Brands': 'STZ', 'Corning Inc.': 'GLW', 'Costco Wholesale Corp.': 'COST', 'Coty Inc': 'COTY', 'Crown Castle International Corp.': 'CCI', 'CSRA Inc.': 'CSRA', 'CSX Corp.': 'CSX', 'Cummins Inc.': 'CMI', 'CVS Health': 'CVS', 'D. R. Horton': 'DHI', 'Danaher Corp.': 'DHR', 'Darden Restaurants': 'DRI', 'DaVita Inc.': 'DVA', 'Deere & Co.': 'DE', 'Delta Air Lines Inc.': 'DAL', 'Dentsply Sirona': 'XRAY', 'Devon Energy Corp.': 'DVN', 'Digital Realty Trust Inc': 'DLR', 'Discover Financial Services': 'DFS', 'Discovery Inc. Class A': 'DISCA', 'Discovery Inc. Class C': 'DISCK', 'Dish Network': 'DISH', 'Dollar General': 'DG', 'Dollar Tree': 'DLTR', 'Dominion Energy': 'D', 'Dover Corp.': 'DOV', 'DTE Energy Co.': 'DTE', 'Duke Energy': 'DUK', 'Duke Realty Corp': 'DRE', 'DXC Technology': 'DXC', 'E*Trade': 'ETFC', 'Eastman Chemical': 'EMN', 'Eaton Corporation': 'ETN', 'eBay Inc.': 'EBAY', 'Ecolab Inc.': 'ECL', 'Edison International': 'EIX', 'Edwards Lifesciences': 'EW', 'Electronic Arts': 'EA', 'Emerson Electric Company': 'EMR', 'Entergy Corp.': 'ETR', 'Envision Healthcare': 'EVHC', 'EOG Resources': 'EOG', 'EQT Corporation': 'EQT', 'Equifax Inc.': 'EFX', 'Equinix': 'EQIX', 'Equity Residential': 'EQR', 'Essex Property Trust Inc.': 'ESS', 'Estee Lauder Cos.': 'EL', 'Everest Re Group Ltd.': 'RE', 'Eversource Energy': 'ES', 'Exelon Corp.': 'EXC', 'Expedia Inc.': 'EXPE', 'Expeditors International': 'EXPD', 'Express Scripts': 'ESRX', 'Extra Space Storage': 'EXR', 'Exxon Mobil Corp.': 'XOM', 'F5 Networks': 'FFIV', 'Facebook Inc.': 'FB', 'Fastenal Co': 'FAST', 'Federal Realty Investment Trust': 'FRT', 'FedEx Corporation': 'FDX', 'Fidelity National Information Services': 'FIS', 'Fifth Third Bancorp': 'FITB', 'FirstEnergy Corp': 'FE', 'Fiserv Inc': 'FISV', 'FLIR Systems': 'FLIR', 'Flowserve Corporation': 'FLS', 'Fluor Corp.': 'FLR', 'FMC Corporation': 'FMC', 'Foot Locker Inc': 'FL', 'Ford Motor': 'F', 'Fortive Corp': 'FTV', 'Fortune Brands Home & Security': 'FBHS', 'Franklin Resources': 'BEN', 'Freeport-McMoRan Inc.': 'FCX', 'Gap Inc.': 'GPS', 'Garmin Ltd.': 'GRMN', 'Gartner Inc': 'IT', 'General Dynamics': 'GD', 'General Electric': 'GE', 'General Growth Properties Inc.': 'GGP', 'General Mills': 'GIS', 'General Motors': 'GM', 'Genuine Parts': 'GPC', 'Gilead Sciences': 'GILD', 'Global Payments Inc.': 'GPN', 'Goldman Sachs Group': 'GS', 'Goodyear Tire & Rubber': 'GT', 'Grainger (W.W.) Inc.': 'GWW', 'Halliburton Co.': 'HAL', 'Hanesbrands Inc': 'HBI', 'Harley-Davidson': 'HOG', 'Hartford Financial Svc.Gp.': 'HIG', 'Hasbro Inc.': 'HAS', 'HCA Holdings': 'HCA', 'Helmerich & Payne': 'HP', 'Henry Schein': 'HSIC', 'Hess Corporation': 'HES', 'Hewlett Packard Enterprise': 'HPE', 'Hilton Worldwide Holdings Inc': 'HLT', 'Hologic': 'HOLX', 'Home Depot': 'HD', 'Honeywell International Inc.': 'HON', 'Hormel Foods Corp.': 'HRL', 'Host Hotels & Resorts': 'HST', 'HP Inc.': 'HPQ', 'Humana Inc.': 'HUM', 'Huntington Bancshares': 'HBAN', 'Huntington Ingalls Industries': 'HII', 'IDEXX Laboratories': 'IDXX', 'IHS Markit Ltd.': 'INFO', 'Illinois Tool Works': 'ITW', 'Illumina Inc': 'ILMN', 'Incyte': 'INCY', 'Ingersoll-Rand PLC': 'IR', 'Intel Corp.': 'INTC', 'Intercontinental Exchange': 'ICE', 'International Business Machines': 'IBM', 'International Paper': 'IP', 'Interpublic Group': 'IPG', 'Intl Flavors & Fragrances': 'IFF', 'Intuit Inc.': 'INTU', 'Intuitive Surgical Inc.': 'ISRG', 'Invesco Ltd.': 'IVZ', 'IPG Photonics Corp.': 'IPGP', 'IQVIA Holdings Inc.': 'IQV', 'Iron Mountain Incorporated': 'IRM', 'J. B. Hunt Transport Services': 'JBHT', 'Jacobs Engineering Group': 'J', 'JM Smucker': 'SJM', 'Johnson & Johnson': 'JNJ', 'Johnson Controls International': 'JCI', 'JPMorgan Chase & Co.': 'JPM', 'Juniper Networks': 'JNPR', 'Kansas City Southern': 'KSU', 'Kellogg Co.': 'K', 'KeyCorp': 'KEY', 'Kimberly-Clark': 'KMB', 'Kimco Realty': 'KIM', 'Kinder Morgan': 'KMI', 'KLA-Tencor Corp.': 'KLAC', 'Kohls Corp.': 'KSS', 'Kraft Heinz Co': 'KHC', 'Kroger Co.': 'KR', 'L Brands Inc.': 'LB', 'Laboratory Corp. of America Holding': 'LH', 'Lam Research': 'LRCX', 'Leggett & Platt': 'LEG', 'Lennar Corp.': 'LEN', 'Lilly (Eli) & Co.': 'LLY', 'Lincoln National': 'LNC', 'LKQ Corporation': 'LKQ', 'Lockheed Martin Corp.': 'LMT', 'Loews Corp.': 'L', 'Lowes Cos.': 'LOW', 'LyondellBasell': 'LYB', 'M&T Bank Corp.': 'MTB', 'Macerich': 'MAC', 'Macys Inc.': 'M', 'Marathon Oil Corp.': 'MRO', 'Marathon Petroleum': 'MPC', 'Marriott International.': 'MAR', 'Marsh & McLennan': 'MMC', 'Martin Marietta Materials': 'MLM', 'Masco Corp.': 'MAS', 'Mastercard Inc.': 'MA', 'Mattel Inc.': 'MAT', 'McCormick & Co.': 'MKC', 'McDonalds Corp.': 'MCD', 'McKesson Corp.': 'MCK', 'Medtronic plc': 'MDT', 'Merck & Co.': 'MRK', 'MetLife Inc.': 'MET', 'Mettler Toledo': 'MTD', 'MGM Resorts International': 'MGM', 'Microchip Technology': 'MCHP', 'Micron Technology': 'MU', 'Microsoft Corp.': 'MSFT', 'Mid-America Apartments': 'MAA', 'Mohawk Industries': 'MHK', 'Molson Coors Brewing Company': 'TAP', 'Mondelez International': 'MDLZ', 'Monsanto Co.': 'MON', 'Monster Beverage': 'MNST', 'Moodys Corp': 'MCO', 'Morgan Stanley': 'MS', 'Motorola Solutions Inc.': 'MSI', 'Mylan N.V.': 'MYL', 'Nasdaq Inc.': 'NDAQ', 'National Oilwell Varco Inc.': 'NOV', 'Navient': 'NAVI', 'Nektar Therapeutics': 'NKTR', 'NetApp': 'NTAP', 'Netflix Inc.': 'NFLX', 'Newell Brands': 'NWL', 'Newmont Mining Corporation': 'NEM', 'News Corp. Class A': 'NWSA', 'News Corp. Class B': 'NWS', 'NextEra Energy': 'NEE', 'Nielsen Holdings': 'NLSN', 'Nike': 'NKE', 'NiSource Inc.': 'NI', 'Noble Energy Inc': 'NBL', 'Nordstrom': 'JWN', 'Norfolk Southern Corp.': 'NSC', 'Northern Trust Corp.': 'NTRS', 'Northrop Grumman Corp.': 'NOC', 'Norwegian Cruise Line': 'NCLH', 'NRG Energy': 'NRG', 'Nucor Corp.': 'NUE', 'Nvidia Corporation': 'NVDA', 'OReilly Automotive': 'ORLY', 'Occidental Petroleum': 'OXY', 'Omnicom Group': 'OMC', 'ONEOK': 'OKE', 'Oracle Corp.': 'ORCL', 'PACCAR Inc.': 'PCAR', 'Packaging Corporation of America': 'PKG', 'Parker-Hannifin': 'PH', 'Paychex Inc.': 'PAYX', 'PayPal': 'PYPL', 'Pentair Ltd.': 'PNR', 'Peoples United Financial': 'PBCT', 'PepsiCo Inc.': 'PEP', 'PerkinElmer': 'PKI', 'Perrigo': 'PRGO', 'Pfizer Inc.': 'PFE', 'PG&E Corp.': 'PCG', 'Philip Morris International': 'PM', 'Phillips 66': 'PSX', 'Pinnacle West Capital': 'PNW', 'Pioneer Natural Resources': 'PXD', 'PNC Financial Services': 'PNC', 'Polo Ralph Lauren Corp.': 'RL', 'PPG Industries': 'PPG', 'PPL Corp.': 'PPL', 'Principal Financial Group': 'PFG', 'Procter & Gamble': 'PG', 'Progressive Corp.': 'PGR', 'Prologis': 'PLD', 'Prudential Financial': 'PRU', 'Public Serv. Enterprise Inc.': 'PEG', 'Public Storage': 'PSA', 'Pulte Homes Inc.': 'PHM', 'PVH Corp.': 'PVH', 'Qorvo': 'QRVO', 'QUALCOMM Inc.': 'QCOM', 'Quanta Services Inc.': 'PWR', 'Quest Diagnostics': 'DGX', 'Range Resources Corp.': 'RRC', 'Raymond James Financial Inc.': 'RJF', 'Realty Income Corporation': 'O', 'Regency Centers Corporation': 'REG', 'Regeneron': 'REGN', 'Regions Financial Corp.': 'RF', 'Republic Services Inc': 'RSG', 'ResMed': 'RMD', 'Robert Half International': 'RHI', 'Rockwell Automation Inc.': 'ROK', 'Rockwell Collins': 'COL', 'Roper Technologies': 'ROP', 'Ross Stores': 'ROST', 'Royal Caribbean Cruises Ltd': 'RCL', 'S&P Global Inc.': 'SPGI', 'Salesforce.com': 'CRM', 'SBA Communications': 'SBAC', 'SCANA Corp': 'SCG', 'Schlumberger Ltd.': 'SLB', 'Seagate Technology': 'STX', 'Sealed Air': 'SEE', 'Sempra Energy': 'SRE', 'Sherwin-Williams': 'SHW', 'Simon Property Group Inc': 'SPG', 'Skyworks Solutions': 'SWKS', 'SL Green Realty': 'SLG', 'Snap-On Inc.': 'SNA', 'Southern Co.': 'SO', 'Southwest Airlines': 'LUV', 'Stanley Black & Decker': 'SWK', 'Starbucks Corp.': 'SBUX', 'State Street Corp.': 'STT', 'Stericycle Inc': 'SRCL', 'Stryker Corp.': 'SYK', 'SVB Financial': 'SIVB', 'Synchrony Financial': 'SYF', 'Synopsys Inc.': 'SNPS', 'Sysco Corp.': 'SYY', 'T. Rowe Price Group': 'TROW', 'Take-Two Interactive': 'TTWO', 'Tapestry Inc.': 'TPR', 'Target Corp.': 'TGT', 'TE Connectivity Ltd.': 'TEL', 'TechnipFMC': 'FTI', 'Texas Instruments': 'TXN', 'Textron Inc.': 'TXT', 'The Bank of New York Mellon Corp.': 'BK', 'The Clorox Company': 'CLX', 'The Cooper Companies': 'COO', 'The Hershey Company': 'HSY', 'The Mosaic Company': 'MOS', 'The Travelers Companies Inc.': 'TRV', 'The Walt Disney Company': 'DIS', 'Thermo Fisher Scientific': 'TMO', 'Tiffany & Co.': 'TIF', 'Time Warner Inc.': 'TWX', 'TJX Companies Inc.': 'TJX', 'Tractor Supply Company': 'TSCO', 'TransDigm Group': 'TDG', 'TripAdvisor': 'TRIP', 'Twenty-First Century Fox Class A': 'FOXA', 'Twenty-First Century Fox Class B': 'FOX', 'Tyson Foods': 'TSN', 'U.S. Bancorp': 'USB', 'UDR Inc': 'UDR', 'Ulta Beauty': 'ULTA', 'Under Armour Class A': 'UAA', 'Under Armour Class C': 'UA', 'Union Pacific': 'UNP', 'United Continental Holdings': 'UAL', 'United Health Group Inc.': 'UNH', 'United Parcel Service': 'UPS', 'United Rentals Inc.': 'URI', 'Universal Health Services Inc.': 'UHS', 'Unum Group': 'UNM', 'V.F. Corp.': 'VFC', 'Valero Energy': 'VLO', 'Varian Medical Systems': 'VAR', 'Ventas Inc': 'VTR', 'Verisign Inc.': 'VRSN', 'Verisk Analytics': 'VRSK', 'Verizon Communications': 'VZ', 'Vertex Pharmaceuticals Inc': 'VRTX', 'Viacom Inc.': 'VIAC', 'Visa Inc.': 'V', 'Vornado Realty Trust': 'VNO', 'Vulcan Materials': 'VMC', 'Wal-Mart Stores': 'WMT', 'Walgreens Boots Alliance': 'WBA', 'Waste Management Inc.': 'WM', 'Waters Corporation': 'WAT', 'Wec Energy Group Inc': 'WEC', 'Wells Fargo': 'WFC', 'Welltower Inc.': 'WELL', 'Western Digital': 'WDC', 'Western Union Co': 'WU', 'WestRock Company': 'WRK', 'Weyerhaeuser Corp.': 'WY', 'Whirlpool Corp.': 'WHR', 'Williams Cos.': 'WMB', 'Willis Towers Watson': 'WLTW', 'Wynn Resorts Ltd': 'WYNN', 'Xcel Energy Inc': 'XEL', 'Xerox Corp.': 'XRX', 'Xilinx Inc': 'XLNX', 'XL Capital': 'XL', 'Xylem Inc.': 'XYL', 'Yum! Brands Inc': 'YUM', 'Zimmer Biomet Holdings': 'ZBH', 'Zions Bancorp': 'ZION', 'Zoetis': 'ZTS'}
iso3 = {'Afghanistan': 'AFG', 'Albania': 'ALB', 'Algeria': 'DZA', 'Angola': 'AGO', 'Antigua and Barbuda': 'ATG', 'Argentina': 'ARG', 'Armenia': 'ARM', 'Aruba': 'ABW', 'Australia': 'AUS', 'Austria': 'AUT', 'Azerbaijan': 'AZE', 'Bahamas': 'BHS', 'Bahrain': 'BHR', 'Bangladesh': 'BGD', 'Barbados': 'BRB', 'Belarus': 'BLR', 'Belgium': 'BEL', 'Belize': 'BLZ', 'Benin': 'BEN', 'Bhutan': 'BTN', 'Bolivia': 'BOL', 'Bosnia and Herzegovina': 'BIH', 'Botswana': 'BWA', 'Brazil': 'BRA', 'Brunei Darussalam': 'BRN', 'Bulgaria': 'BGR', 'Burkina Faso': 'BFA', 'Burundi': 'BDI', 'Cabo Verde': 'CPV', 'Cambodia': 'KHM', 'Cameroon': 'CMR', 'Canada': 'CAN', 'Chad': 'TCD', 'Chile': 'CHL', 'China': 'CHN', 'Colombia': 'COL', 'Comoros': 'COM', 'Congo Dem. Rep.': 'COD', 'Congo Rep.': 'COG', 'Costa Rica': 'CRI', 'Cote dIvoire': 'CIV', 'Croatia': 'HRV', 'Cyprus': 'CYP', 'Czech Republic': 'CZE', 'Denmark': 'DNK', 'Djibouti': 'DJI', 'Dominica': 'DMA', 'Dominican Republic': 'DOM', 'Ecuador': 'ECU', 'Egypt Arab Rep.': 'EGY', 'El Salvador': 'SLV', 'Equatorial Guinea': 'GNQ', 'Eritrea': 'ERI', 'Estonia': 'EST', 'Ethiopia': 'ETH', 'Fiji': 'FJI', 'Finland': 'FIN', 'France': 'FRA', 'Gabon': 'GAB', 'Gambia': 'GMB', 'Georgia': 'GEO', 'Germany': 'DEU', 'Ghana': 'GHA', 'Greece': 'GRC', 'Grenada': 'GRD', 'Guatemala': 'GTM', 'Guinea': 'GIN', 'Guinea-Bissau': 'GNB', 'Guyana': 'GUY', 'Haiti': 'HTI', 'Honduras': 'HND', 'Hong Kong SAR China': 'HKG', 'Hungary': 'HUN', 'Iceland': 'ISL', 'India': 'IND', 'Indonesia': 'IDN', 'Iran Islamic Rep.': 'IRN', 'Iraq': 'IRQ', 'Ireland': 'IRL', 'Israel': 'ISR', 'Italy': 'ITA', 'Jamaica': 'JAM', 'Japan': 'JPN', 'Jordan': 'JOR', 'Kazakhstan': 'KAZ', 'Kenya': 'KEN', 'Kiribati': 'KIR', 'Korea Rep': 'KOR', 'Kuwait': 'KWT', 'Kyrgyz Republic': 'KGZ', 'Lao PDR': 'LAO', 'Latvia': 'LVA', 'Lebanon': 'LBN', 'Lesotho': 'LSO', 'Liberia': 'LBR', 'Libya': 'LBY', 'Lithuania': 'LTU', 'Luxembourg': 'LUX', 'Macao SAR China': 'MAC', 'Macedonia FYR': 'MKD', 'Madagascar': 'MDG', 'Malawi': 'MWI', 'Malaysia': 'MYS', 'Maldives': 'MDV', 'Mali': 'MLI', 'Malta': 'MLT', 'Marshall Islands': 'MHL', 'Mauritania': 'MRT', 'Mauritius': 'MUS', 'Mexico': 'MEX', 'Micronesia Fed. Sts.': 'FSM', 'Moldova': 'MDA', 'Mongolia': 'MNG', 'Montenegro': 'MNE', 'Morocco': 'MAR', 'Mozambique': 'MOZ', 'Myanmar': 'MMR', 'Namibia': 'NAM', 'Nepal': 'NPL', 'Netherlands': 'NLD', 'New Zealand': 'NZL', 'Nicaragua': 'NIC', 'Niger': 'NER', 'Nigeria': 'NGA', 'Norway': 'NOR', 'Oman': 'OMN', 'Pakistan': 'PAK', 'Palau': 'PLW', 'Panama': 'PAN', 'Papua New Guinea': 'PNG', 'Paraguay': 'PRY', 'Peru': 'PER', 'Philippines': 'PHL', 'Poland': 'POL', 'Portugal': 'PRT', 'Puerto Rico': 'PRI', 'Qatar': 'QAT', 'Romania': 'ROU', 'Russian Federation': 'RUS', 'Rwanda': 'RWA', 'Samoa': 'WSM', 'San Marino': 'SMR', 'Sao Tome and Principe': 'STP', 'Saudi Arabia': 'SAU', 'Senegal': 'SEN', 'Serbia': 'SRB', 'Seychelles': 'SYC', 'Sierra Leone': 'SLE', 'Singapore': 'SGP', 'Slovak Republic': 'SVK', 'Slovenia': 'SVN', 'Solomon Islands': 'SLB', 'South Africa': 'ZAF', 'South Sudan': 'SSD', 'Spain': 'ESP', 'Sri Lanka': 'LKA', 'St. Kitts and Nevis': 'KNA', 'St. Lucia': 'LCA', 'St. Vincent and the Grenadines': 'VCT', 'Sudan': 'SDN', 'Suriname': 'SUR', 'Swaziland': 'SWZ', 'Sweden': 'SWE', 'Switzerland': 'CHE', 'Syrian Arab Republic': 'SYR', 'Tajikistan': 'TJK', 'Tanzania': 'TZA', 'Thailand': 'THA', 'Timor-Leste': 'TLS', 'Togo': 'TGO', 'Tonga': 'TON', 'Trinidad and Tobago': 'TTO', 'Tunisia': 'TUN', 'Turkey': 'TUR', 'Turkmenistan': 'TKM', 'Tuvalu': 'TUV', 'Uganda': 'UGA', 'Ukraine': 'UKR', 'United Arab Emirates': 'ARE', 'United Kingdom': 'GBR', 'United States': 'USA', 'Uruguay': 'URY', 'Uzbekistan': 'UZB', 'Vanuatu': 'VUT', 'Venezuela RB': 'VEN', 'Vietnam': 'VNM', 'Yemen Rep.': 'YEM', 'Zambia': 'ZMB', 'Zimbabwe': 'ZWE'} |
a= int(input())
if (a%4 == 0) and (a%100 != 0):
print(1)
elif a%400 ==0:
print(1)
else:
print(0)
| a = int(input())
if a % 4 == 0 and a % 100 != 0:
print(1)
elif a % 400 == 0:
print(1)
else:
print(0) |
# encoding: utf-8
# module cv2.optflow
# from /home/davtoh/anaconda3/envs/rrtools/lib/python3.5/site-packages/cv2.cpython-35m-x86_64-linux-gnu.so
# by generator 1.144
# no doc
# no imports
# Variables with simple values
DISOpticalFlow_PRESET_FAST = 1
DISOpticalFlow_PRESET_MEDIUM = 2
DISOpticalFlow_PRESET_ULTRAFAST = 0
DISOPTICAL_FLOW_PRESET_FAST = 1
DISOPTICAL_FLOW_PRESET_MEDIUM = 2
DISOPTICAL_FLOW_PRESET_ULTRAFAST = 0
GPC_DESCRIPTOR_DCT = 0
GPC_DESCRIPTOR_WHT = 1
__loader__ = None
__spec__ = None
# functions
# real signature unknown; restored from __doc__
def calcOpticalFlowSF(from_, to, layers, averaging_block_size, max_flow, flow=None):
""" calcOpticalFlowSF(from, to, layers, averaging_block_size, max_flow[, flow]) -> flow or calcOpticalFlowSF(from, to, layers, averaging_block_size, max_flow, sigma_dist, sigma_color, postprocess_window, sigma_dist_fix, sigma_color_fix, occ_thr, upscale_averaging_radius, upscale_sigma_dist, upscale_sigma_color, speed_up_thr[, flow]) -> flow """
pass
# real signature unknown; restored from __doc__
def calcOpticalFlowSparseToDense(from_, to, flow=None, grid_step=None, k=None, sigma=None, use_post_proc=None, fgs_lambda=None, fgs_sigma=None):
""" calcOpticalFlowSparseToDense(from, to[, flow[, grid_step[, k[, sigma[, use_post_proc[, fgs_lambda[, fgs_sigma]]]]]]]) -> flow """
pass
def createOptFlow_DeepFlow(): # real signature unknown; restored from __doc__
""" createOptFlow_DeepFlow() -> retval """
pass
def createOptFlow_DIS(preset=None): # real signature unknown; restored from __doc__
""" createOptFlow_DIS([, preset]) -> retval """
pass
def createOptFlow_Farneback(): # real signature unknown; restored from __doc__
""" createOptFlow_Farneback() -> retval """
pass
def createOptFlow_PCAFlow(): # real signature unknown; restored from __doc__
""" createOptFlow_PCAFlow() -> retval """
pass
def createOptFlow_SimpleFlow(): # real signature unknown; restored from __doc__
""" createOptFlow_SimpleFlow() -> retval """
pass
def createOptFlow_SparseToDense(): # real signature unknown; restored from __doc__
""" createOptFlow_SparseToDense() -> retval """
pass
def createVariationalFlowRefinement(): # real signature unknown; restored from __doc__
""" createVariationalFlowRefinement() -> retval """
pass
def readOpticalFlow(path): # real signature unknown; restored from __doc__
""" readOpticalFlow(path) -> retval """
pass
def writeOpticalFlow(path, flow): # real signature unknown; restored from __doc__
""" writeOpticalFlow(path, flow) -> retval """
pass
# no classes
| dis_optical_flow_preset_fast = 1
dis_optical_flow_preset_medium = 2
dis_optical_flow_preset_ultrafast = 0
disoptical_flow_preset_fast = 1
disoptical_flow_preset_medium = 2
disoptical_flow_preset_ultrafast = 0
gpc_descriptor_dct = 0
gpc_descriptor_wht = 1
__loader__ = None
__spec__ = None
def calc_optical_flow_sf(from_, to, layers, averaging_block_size, max_flow, flow=None):
""" calcOpticalFlowSF(from, to, layers, averaging_block_size, max_flow[, flow]) -> flow or calcOpticalFlowSF(from, to, layers, averaging_block_size, max_flow, sigma_dist, sigma_color, postprocess_window, sigma_dist_fix, sigma_color_fix, occ_thr, upscale_averaging_radius, upscale_sigma_dist, upscale_sigma_color, speed_up_thr[, flow]) -> flow """
pass
def calc_optical_flow_sparse_to_dense(from_, to, flow=None, grid_step=None, k=None, sigma=None, use_post_proc=None, fgs_lambda=None, fgs_sigma=None):
""" calcOpticalFlowSparseToDense(from, to[, flow[, grid_step[, k[, sigma[, use_post_proc[, fgs_lambda[, fgs_sigma]]]]]]]) -> flow """
pass
def create_opt_flow__deep_flow():
""" createOptFlow_DeepFlow() -> retval """
pass
def create_opt_flow_dis(preset=None):
""" createOptFlow_DIS([, preset]) -> retval """
pass
def create_opt_flow__farneback():
""" createOptFlow_Farneback() -> retval """
pass
def create_opt_flow_pca_flow():
""" createOptFlow_PCAFlow() -> retval """
pass
def create_opt_flow__simple_flow():
""" createOptFlow_SimpleFlow() -> retval """
pass
def create_opt_flow__sparse_to_dense():
""" createOptFlow_SparseToDense() -> retval """
pass
def create_variational_flow_refinement():
""" createVariationalFlowRefinement() -> retval """
pass
def read_optical_flow(path):
""" readOpticalFlow(path) -> retval """
pass
def write_optical_flow(path, flow):
""" writeOpticalFlow(path, flow) -> retval """
pass |
c = 0
while(True):
c+=1
inp = input()
if(inp == '0'):
break
n = int(inp)
inp = input().split(' ')
su = 0
for j in range(0,len(inp)):
su += int(inp[j])
av = int(su / len(inp))
count = 0
for j in range(0,len(inp)):
count += abs(av - int(inp[j]))
print('Set #' + str(c))
print('The minimum number of moves is ' + str(int(count/2)) + '.')
print('')
| c = 0
while True:
c += 1
inp = input()
if inp == '0':
break
n = int(inp)
inp = input().split(' ')
su = 0
for j in range(0, len(inp)):
su += int(inp[j])
av = int(su / len(inp))
count = 0
for j in range(0, len(inp)):
count += abs(av - int(inp[j]))
print('Set #' + str(c))
print('The minimum number of moves is ' + str(int(count / 2)) + '.')
print('') |
# cook your dish here
def highestPowerOf2(n):
return (n & (~(n - 1)))
for t in range(int(input())):
ts=int(input())
sum=0
if ts%2==1:
print((ts-1)//2)
else:
x=highestPowerOf2(ts)
print(ts//((x*2)))
| def highest_power_of2(n):
return n & ~(n - 1)
for t in range(int(input())):
ts = int(input())
sum = 0
if ts % 2 == 1:
print((ts - 1) // 2)
else:
x = highest_power_of2(ts)
print(ts // (x * 2)) |
"""Functions to help edit essay homework using string manipulation."""
def capitalize_title(title):
"""Convert the first letter of each word in the title to uppercase if needed.
:param title: str - title string that needs title casing.
:return: str - title string in title case (first letters capitalized).
"""
return title.title()
def check_sentence_ending(sentence):
"""Check the ending of the sentence to verify that a period is present.
:param sentence: str - a sentence to check.
:return: bool - is the sentence punctuated correctly?
"""
return sentence.endswith(".")
def clean_up_spacing(sentence):
"""Trim any leading or trailing whitespace from the sentence.
:param sentence: str - a sentence to clean of leading and trailing space characters.
:return: str - a sentence that has been cleaned of leading and trailing space characters.
"""
clean_sentence = sentence.strip()
return clean_sentence
def replace_word_choice(sentence, old_word, new_word):
"""Replace a word in the provided sentence with a new one.
:param sentence: str - a sentence to replace words in.
:param old_word: str - word to replace.
:param new_word: str - replacement word.
:return: str - input sentence with new words in place of old words.
"""
better_sentence = sentence.replace(old_word, new_word)
return better_sentence
| """Functions to help edit essay homework using string manipulation."""
def capitalize_title(title):
"""Convert the first letter of each word in the title to uppercase if needed.
:param title: str - title string that needs title casing.
:return: str - title string in title case (first letters capitalized).
"""
return title.title()
def check_sentence_ending(sentence):
"""Check the ending of the sentence to verify that a period is present.
:param sentence: str - a sentence to check.
:return: bool - is the sentence punctuated correctly?
"""
return sentence.endswith('.')
def clean_up_spacing(sentence):
"""Trim any leading or trailing whitespace from the sentence.
:param sentence: str - a sentence to clean of leading and trailing space characters.
:return: str - a sentence that has been cleaned of leading and trailing space characters.
"""
clean_sentence = sentence.strip()
return clean_sentence
def replace_word_choice(sentence, old_word, new_word):
"""Replace a word in the provided sentence with a new one.
:param sentence: str - a sentence to replace words in.
:param old_word: str - word to replace.
:param new_word: str - replacement word.
:return: str - input sentence with new words in place of old words.
"""
better_sentence = sentence.replace(old_word, new_word)
return better_sentence |
'''rig pipeline prototype
by Ben Barker, copyright (c) 2015
ben.barker@gmail.com
for license info see license.txt
''' | """rig pipeline prototype
by Ben Barker, copyright (c) 2015
ben.barker@gmail.com
for license info see license.txt
""" |
def main():
# Manage input file
input = open(r"C:\Users\lawht\Desktop\Github\ROSALIND\Bioinformatics Stronghold\(2) Transcribing DNA into RNA\(2) Transcribing DNA into RNA\rosalind_rna.txt","r");
DNA_string = input.readline(); # take first line of input file for counting
# Take in input file of DNA string and print out its corresponding RNA sequence
print(DNA_to_RNA(DNA_string));
input.close();
# Given: A DNA string t having length at most 1000 nt.
# Return: The transcribed RNA string of t.
def DNA_to_RNA(s):
rna = "";
for n in s:
if n == "T":
rna = rna + "U";
else:
rna = rna + n;
return rna;
# Manually call main() on the file load
if __name__ == "__main__":
main(); | def main():
input = open('C:\\Users\\lawht\\Desktop\\Github\\ROSALIND\\Bioinformatics Stronghold\\(2) Transcribing DNA into RNA\\(2) Transcribing DNA into RNA\\rosalind_rna.txt', 'r')
dna_string = input.readline()
print(dna_to_rna(DNA_string))
input.close()
def dna_to_rna(s):
rna = ''
for n in s:
if n == 'T':
rna = rna + 'U'
else:
rna = rna + n
return rna
if __name__ == '__main__':
main() |
class Solution:
def minDifference(self, nums: List[int]) -> int:
# pick three values
if len(nums) <= 4:
return 0
nums.sort()
ans = nums[-1] - nums[0]
for i in range(4):
ans = min(nums[-1 - (3 - i)] - nums[i], ans)
return ans
| class Solution:
def min_difference(self, nums: List[int]) -> int:
if len(nums) <= 4:
return 0
nums.sort()
ans = nums[-1] - nums[0]
for i in range(4):
ans = min(nums[-1 - (3 - i)] - nums[i], ans)
return ans |
'''https://practice.geeksforgeeks.org/problems/bottom-view-of-binary-tree/1
https://www.geeksforgeeks.org/bottom-view-binary-tree/
Bottom View of Binary Tree
Medium Accuracy: 45.32% Submissions: 90429 Points: 4
Given a binary tree, print the bottom view from left to right.
A node is included in bottom view if it can be seen when we look at the tree from bottom.
20
/ \
8 22
/ \ \
5 3 25
/ \
10 14
For the above tree, the bottom view is 5 10 3 14 25.
If there are multiple bottom-most nodes for a horizontal distance from root, then print the later one in level traversal. For example, in the below diagram, 3 and 4 are both the bottommost nodes at horizontal distance 0, we need to print 4.
20
/ \
8 22
/ \ / \
5 3 4 25
/ \
10 14
For the above tree the output should be 5 10 4 14 25.
Example 1:
Input:
1
/ \
3 2
Output: 3 1 2
Explanation:
First case represents a tree with 3 nodes
and 2 edges where root is 1, left child of
1 is 3 and right child of 1 is 2.
Thus nodes of the binary tree will be
printed as such 3 1 2.
Example 2:
Input:
10
/ \
20 30
/ \
40 60
Output: 40 20 60 30
Your Task:
This is a functional problem, you don't need to care about input, just complete the function bottomView() which takes the root node of the tree as input and returns an array containing the bottom view of the given tree.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
1 <= Number of nodes <= 105
1 <= Data of a node <= 105'''
# Python3 program to print Bottom
# View of Binary Tree
# Tree node class
class Node:
def __init__(self, key):
self.data = key
self.hd = 1000000
self.left = None
self.right = None
# Method that prints the bottom view.
def bottomView(root):
if (root == None):
return
# Initialize a variable 'hd' with 0
# for the root element.
hd = 0
# TreeMap which stores key value pair
# sorted on key value
m = dict()
# Queue to store tree nodes in level
# order traversal
q = []
# Assign initialized horizontal distance
# value to root node and add it to the queue.
root.hd = hd
# In STL, append() is used enqueue an item
q.append(root)
# Loop until the queue is empty (standard
# level order loop)
while (len(q) != 0):
temp = q[0]
# In STL, pop() is used dequeue an item
q.pop(0)
# Extract the horizontal distance value
# from the dequeued tree node.
hd = temp.hd
# Put the dequeued tree node to TreeMap
# having key as horizontal distance. Every
# time we find a node having same horizontal
# distance we need to replace the data in
# the map.
m[hd] = temp.data
# If the dequeued node has a left child, add
# it to the queue with a horizontal distance hd-1.
if (temp.left != None):
temp.left.hd = hd - 1
q.append(temp.left)
# If the dequeued node has a right child, add
# it to the queue with a horizontal distance
# hd+1.
if (temp.right != None):
temp.right.hd = hd + 1
q.append(temp.right)
# Traverse the map elements using the iterator.
for i in sorted(m.keys()):
print(m[i], end=' ')
# Driver Code
if __name__ == '__main__':
root = Node(20)
root.left = Node(8)
root.right = Node(22)
root.left.left = Node(5)
root.left.right = Node(3)
root.right.left = Node(4)
root.right.right = Node(25)
root.left.right.left = Node(10)
root.left.right.right = Node(14)
print("Bottom view of the given binary tree :")
bottomView(root)
# Using Hash Map
# Python3 program to print Bottom
# View of Binary Tree
class Node:
def __init__(self, key=None,
left=None,
right=None):
self.data = key
self.left = left
self.right = right
def printBottomView(root):
# Create a dictionary where
# key -> relative horizontal distance
# of the node from root node and
# value -> pair containing node's
# value and its level
d = dict()
printBottomViewUtil(root, d, 0, 0)
# Traverse the dictionary in sorted
# order of their keys and print
# the bottom view
for i in sorted(d.keys()):
print(d[i][0], end=" ")
def printBottomViewUtil(root, d, hd, level):
# Base case
if root is None:
return
# If current level is more than or equal
# to maximum level seen so far for the
# same horizontal distance or horizontal
# distance is seen for the first time,
# update the dictionary
if hd in d:
if level >= d[hd][1]:
d[hd] = [root.data, level]
else:
d[hd] = [root.data, level]
# recur for left subtree by decreasing
# horizontal distance and increasing
# level by 1
printBottomViewUtil(root.left, d, hd - 1,
level + 1)
# recur for right subtree by increasing
# horizontal distance and increasing
# level by 1
printBottomViewUtil(root.right, d, hd + 1,
level + 1)
# Driver Code
if __name__ == '__main__':
root = Node(20)
root.left = Node(8)
root.right = Node(22)
root.left.left = Node(5)
root.left.right = Node(3)
root.right.left = Node(4)
root.right.right = Node(25)
root.left.right.left = Node(10)
root.left.right.right = Node(14)
print("Bottom view of the given binary tree :")
printBottomView(root)
| """https://practice.geeksforgeeks.org/problems/bottom-view-of-binary-tree/1
https://www.geeksforgeeks.org/bottom-view-binary-tree/
Bottom View of Binary Tree
Medium Accuracy: 45.32% Submissions: 90429 Points: 4
Given a binary tree, print the bottom view from left to right.
A node is included in bottom view if it can be seen when we look at the tree from bottom.
20
/ 8 22
/ \\ 5 3 25
/ \\
10 14
For the above tree, the bottom view is 5 10 3 14 25.
If there are multiple bottom-most nodes for a horizontal distance from root, then print the later one in level traversal. For example, in the below diagram, 3 and 4 are both the bottommost nodes at horizontal distance 0, we need to print 4.
20
/ 8 22
/ \\ / 5 3 4 25
/ \\
10 14
For the above tree the output should be 5 10 4 14 25.
Example 1:
Input:
1
/ 3 2
Output: 3 1 2
Explanation:
First case represents a tree with 3 nodes
and 2 edges where root is 1, left child of
1 is 3 and right child of 1 is 2.
Thus nodes of the binary tree will be
printed as such 3 1 2.
Example 2:
Input:
10
/ 20 30
/ 40 60
Output: 40 20 60 30
Your Task:
This is a functional problem, you don't need to care about input, just complete the function bottomView() which takes the root node of the tree as input and returns an array containing the bottom view of the given tree.
Expected Time Complexity: O(N).
Expected Auxiliary Space: O(N).
Constraints:
1 <= Number of nodes <= 105
1 <= Data of a node <= 105"""
class Node:
def __init__(self, key):
self.data = key
self.hd = 1000000
self.left = None
self.right = None
def bottom_view(root):
if root == None:
return
hd = 0
m = dict()
q = []
root.hd = hd
q.append(root)
while len(q) != 0:
temp = q[0]
q.pop(0)
hd = temp.hd
m[hd] = temp.data
if temp.left != None:
temp.left.hd = hd - 1
q.append(temp.left)
if temp.right != None:
temp.right.hd = hd + 1
q.append(temp.right)
for i in sorted(m.keys()):
print(m[i], end=' ')
if __name__ == '__main__':
root = node(20)
root.left = node(8)
root.right = node(22)
root.left.left = node(5)
root.left.right = node(3)
root.right.left = node(4)
root.right.right = node(25)
root.left.right.left = node(10)
root.left.right.right = node(14)
print('Bottom view of the given binary tree :')
bottom_view(root)
class Node:
def __init__(self, key=None, left=None, right=None):
self.data = key
self.left = left
self.right = right
def print_bottom_view(root):
d = dict()
print_bottom_view_util(root, d, 0, 0)
for i in sorted(d.keys()):
print(d[i][0], end=' ')
def print_bottom_view_util(root, d, hd, level):
if root is None:
return
if hd in d:
if level >= d[hd][1]:
d[hd] = [root.data, level]
else:
d[hd] = [root.data, level]
print_bottom_view_util(root.left, d, hd - 1, level + 1)
print_bottom_view_util(root.right, d, hd + 1, level + 1)
if __name__ == '__main__':
root = node(20)
root.left = node(8)
root.right = node(22)
root.left.left = node(5)
root.left.right = node(3)
root.right.left = node(4)
root.right.right = node(25)
root.left.right.left = node(10)
root.left.right.right = node(14)
print('Bottom view of the given binary tree :')
print_bottom_view(root) |
class dotControlObject_t(object):
# no doc
aName = None
Color = None
Extension = None
IsMagnetic = None
ModelObject = None
Plane = None
| class Dotcontrolobject_T(object):
a_name = None
color = None
extension = None
is_magnetic = None
model_object = None
plane = None |
#Ask User for his role and save it in a variable
role = input ("Are you an administrator, teacher, or student?: ")
#If role "administrator or teacher" print they have keys
if role == "administrator" or role == "teacher":
print ("Administrators and teachers get keys!")
#If role "Student" print they dont get keys
elif role == "student":
print ("Students do not get keys")
#Else of the options, say the roles that can be used
else:
print("You can only be an administrator, teacher, or student!") | role = input('Are you an administrator, teacher, or student?: ')
if role == 'administrator' or role == 'teacher':
print('Administrators and teachers get keys!')
elif role == 'student':
print('Students do not get keys')
else:
print('You can only be an administrator, teacher, or student!') |
# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
def f_gold ( k , s1 , s2 ) :
n = len ( s1 )
m = len ( s2 )
lcs = [ [ 0 for x in range ( m + 1 ) ] for y in range ( n + 1 ) ]
cnt = [ [ 0 for x in range ( m + 1 ) ] for y in range ( n + 1 ) ]
for i in range ( 1 , n + 1 ) :
for j in range ( 1 , m + 1 ) :
lcs [ i ] [ j ] = max ( lcs [ i - 1 ] [ j ] , lcs [ i ] [ j - 1 ] )
if ( s1 [ i - 1 ] == s2 [ j - 1 ] ) :
cnt [ i ] [ j ] = cnt [ i - 1 ] [ j - 1 ] + 1 ;
if ( cnt [ i ] [ j ] >= k ) :
for a in range ( k , cnt [ i ] [ j ] + 1 ) :
lcs [ i ] [ j ] = max ( lcs [ i ] [ j ] , lcs [ i - a ] [ j - a ] + a )
return lcs [ n ] [ m ]
#TOFILL
if __name__ == '__main__':
param = [
(4,'aggayxysdfa','aggajxaaasdfa',),
(2,'55571659965107','390286654154',),
(3,'01011011100','0000110001000',),
(5,'aggasdfa','aggajasdfaxy',),
(2,'5710246551','79032504084062',),
(3,'0100010','10100000',),
(3,'aabcaaaa','baaabcd',),
(1,'1219','3337119582',),
(2,'111000011','011',),
(2,'wiC oD','csiuGOUwE',)
]
n_success = 0
for i, parameters_set in enumerate(param):
if f_filled(*parameters_set) == f_gold(*parameters_set):
n_success+=1
print("#Results: %i, %i" % (n_success, len(param))) | def f_gold(k, s1, s2):
n = len(s1)
m = len(s2)
lcs = [[0 for x in range(m + 1)] for y in range(n + 1)]
cnt = [[0 for x in range(m + 1)] for y in range(n + 1)]
for i in range(1, n + 1):
for j in range(1, m + 1):
lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1])
if s1[i - 1] == s2[j - 1]:
cnt[i][j] = cnt[i - 1][j - 1] + 1
if cnt[i][j] >= k:
for a in range(k, cnt[i][j] + 1):
lcs[i][j] = max(lcs[i][j], lcs[i - a][j - a] + a)
return lcs[n][m]
if __name__ == '__main__':
param = [(4, 'aggayxysdfa', 'aggajxaaasdfa'), (2, '55571659965107', '390286654154'), (3, '01011011100', '0000110001000'), (5, 'aggasdfa', 'aggajasdfaxy'), (2, '5710246551', '79032504084062'), (3, '0100010', '10100000'), (3, 'aabcaaaa', 'baaabcd'), (1, '1219', '3337119582'), (2, '111000011', '011'), (2, 'wiC oD', 'csiuGOUwE')]
n_success = 0
for (i, parameters_set) in enumerate(param):
if f_filled(*parameters_set) == f_gold(*parameters_set):
n_success += 1
print('#Results: %i, %i' % (n_success, len(param))) |
name = 'Zed A. Shaw'
age = 35
height = 74
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
print(f"Let's talk about {name}.")
print(f"He's {height} inches tall.")
print(f"He's {weight} pounds heavy.")
print("Actually it's not too heavy")
print(f"He's got {eyes} eyes and {hair} hair.")
print(f"His teeth are usually {teeth} depending on the coffee.")
total = age + weight + height
print(f"If I add {age}, {height}, and {weight} I get {total}")
#Study Drills:
print("Conversion from lbs to kg")
print("=" * 20) #Writes = 20 times on same line
customLBS = 200
kg = round(customLBS / 2.2046226218488, 2)
print(f"{customLBS} is {kg} kg") | name = 'Zed A. Shaw'
age = 35
height = 74
weight = 180
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
print(f"Let's talk about {name}.")
print(f"He's {height} inches tall.")
print(f"He's {weight} pounds heavy.")
print("Actually it's not too heavy")
print(f"He's got {eyes} eyes and {hair} hair.")
print(f'His teeth are usually {teeth} depending on the coffee.')
total = age + weight + height
print(f'If I add {age}, {height}, and {weight} I get {total}')
print('Conversion from lbs to kg')
print('=' * 20)
custom_lbs = 200
kg = round(customLBS / 2.2046226218488, 2)
print(f'{customLBS} is {kg} kg') |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jul 17 16:17:25 2017
@author: jorgemauricio
- Escribe un programa que calcule el valor neto de una cuenta de banco basado
en las transacciones que se ingresan en la consola de comandos.
Ej:
D 200
D 250
P 300
D 100
P 200
Donde:
D = Deposito
P = Pago
Resultado
50
"""
| """
Created on Mon Jul 17 16:17:25 2017
@author: jorgemauricio
- Escribe un programa que calcule el valor neto de una cuenta de banco basado
en las transacciones que se ingresan en la consola de comandos.
Ej:
D 200
D 250
P 300
D 100
P 200
Donde:
D = Deposito
P = Pago
Resultado
50
""" |
def get_data(path):
try:
file_handler = open(path, "r")
except:
return 0
data = []
for line in file_handler:
values = line.strip().split(" ")
data.append([int(values[1]), int(values[2]), int(values[3])])
return data
def sensortxt_parser(path):
order = ['lu', 'ru', 'lu', 'ru']
order2 = ['ld', 'rd', 'ld', 'rd']
dict1 = {} # walker1
dict2 = {} # walker2
with open(path, 'r') as f:
c = 0
for line in f:
if c == 2:
sensors = []
for elem in line.strip().split("\t"):
if elem == ' ':
sensors.append("x")
else:
sensors.append(int(elem))
if len(line.strip().split("\t")) == 3:
sensors.append("x")
for i in range(len(sensors)):
if i > 1:
dict2[order[i]] = sensors[i]
else:
dict1[order[i]] = sensors[i]
if c == 3:
sensors = []
for elem in line.strip().split("\t"):
if elem == ' ':
sensors.append("x")
else:
sensors.append(int(elem))
if len(line.strip().split("\t")) == 3:
sensors.append("x")
for i in range(len(sensors)):
if i > 1:
dict2[order2[i]] = sensors[i]
else:
dict1[order2[i]] = sensors[i]
c += 1
return dict1, dict2
| def get_data(path):
try:
file_handler = open(path, 'r')
except:
return 0
data = []
for line in file_handler:
values = line.strip().split(' ')
data.append([int(values[1]), int(values[2]), int(values[3])])
return data
def sensortxt_parser(path):
order = ['lu', 'ru', 'lu', 'ru']
order2 = ['ld', 'rd', 'ld', 'rd']
dict1 = {}
dict2 = {}
with open(path, 'r') as f:
c = 0
for line in f:
if c == 2:
sensors = []
for elem in line.strip().split('\t'):
if elem == ' ':
sensors.append('x')
else:
sensors.append(int(elem))
if len(line.strip().split('\t')) == 3:
sensors.append('x')
for i in range(len(sensors)):
if i > 1:
dict2[order[i]] = sensors[i]
else:
dict1[order[i]] = sensors[i]
if c == 3:
sensors = []
for elem in line.strip().split('\t'):
if elem == ' ':
sensors.append('x')
else:
sensors.append(int(elem))
if len(line.strip().split('\t')) == 3:
sensors.append('x')
for i in range(len(sensors)):
if i > 1:
dict2[order2[i]] = sensors[i]
else:
dict1[order2[i]] = sensors[i]
c += 1
return (dict1, dict2) |
# -*- coding: utf-8 -*-
# Copyright (C) 2018 by
# Marta Grobelna <marta.grobelna@rwth-aachen.de>
# Petre Petrov <petrepp4@gmail.com>
# Rudi Floren <rudi.floren@gmail.com>
# Tobias Winkler <tobias.winkler1@rwth-aachen.de>
# All rights reserved.
# BSD license.
#
# Authors: Marta Grobelna <marta.grobelna@rwth-aachen.de>
# Petre Petrov <petrepp4@gmail.com>
# Rudi Floren <rudi.floren@gmail.com>
# Tobias Winkler <tobias.winkler1@rwth-aachen.de>
# Gets a list of probabilities
# Gets a random_function
# Returns the index or the size of the probabiliy.
# Acts as Bernoulli for len(probabilites) == 2
def bern_choice(probabilities, random_function) -> int:
"""Draws a random value with random_function and returns
the index of a probability which the random value undercuts.
The list is theoretically expanded to include 1-p
"""
assert type(probabilities) is list
random_value = random_function()
for index in range(len(probabilities)):
if random_value <= probabilities[index]:
return index
return len(probabilities)
def poiss(p) -> int:
pass | def bern_choice(probabilities, random_function) -> int:
"""Draws a random value with random_function and returns
the index of a probability which the random value undercuts.
The list is theoretically expanded to include 1-p
"""
assert type(probabilities) is list
random_value = random_function()
for index in range(len(probabilities)):
if random_value <= probabilities[index]:
return index
return len(probabilities)
def poiss(p) -> int:
pass |
r"""
*************************
Text rendering With LaTeX
*************************
Matplotlib can use LaTeX to render text. This is activated by setting
``text.usetex : True`` in your rcParams, or by setting the ``usetex`` property
to True on individual `.Text` objects. Text handling through LaTeX is slower
than Matplotlib's very capable :doc:`mathtext </tutorials/text/mathtext>`, but
is more flexible, since different LaTeX packages (font packages, math packages,
etc.) can be used. The results can be striking, especially when you take care
to use the same fonts in your figures as in the main document.
Matplotlib's LaTeX support requires a working LaTeX_ installation. For the
\*Agg backends, dvipng_ is additionally required; for the PS backend, psfrag_,
dvips_ and Ghostscript_ are additionally required. The executables for these
external dependencies must all be located on your :envvar:`PATH`.
There are a couple of options to mention, which can be changed using
:doc:`rc settings </tutorials/introductory/customizing>`. Here is an example
matplotlibrc file::
font.family : serif
font.serif : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif : Helvetica, Avant Garde, Computer Modern Sans Serif
font.cursive : Zapf Chancery
font.monospace : Courier, Computer Modern Typewriter
text.usetex : true
The first valid font in each family is the one that will be loaded. If the
fonts are not specified, the Computer Modern fonts are used by default. All of
the other fonts are Adobe fonts. Times and Palatino each have their own
accompanying math fonts, while the other Adobe serif fonts make use of the
Computer Modern math fonts. See the PSNFSS_ documentation for more details.
To use LaTeX and select Helvetica as the default font, without editing
matplotlibrc use::
import matplotlib.pyplot as plt
plt.rcParams.update({
"text.usetex": True,
"font.family": "sans-serif",
"font.sans-serif": ["Helvetica"]})
# for Palatino and other serif fonts use:
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.serif": ["Palatino"],
})
Here is the standard example,
:file:`/gallery/text_labels_and_annotations/tex_demo`:
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
:align: center
:scale: 50
Note that display math mode (``$$ e=mc^2 $$``) is not supported, but adding the
command ``\displaystyle``, as in the above demo, will produce the same results.
Non-ASCII characters (e.g. the degree sign in the y-label above) are supported
to the extent that they are supported by inputenc_.
.. note::
Certain characters require special escaping in TeX, such as::
# $ % & ~ _ ^ \ { } \( \) \[ \]
Therefore, these characters will behave differently depending on
:rc:`text.usetex`.
PostScript options
==================
In order to produce encapsulated PostScript (EPS) files that can be embedded
in a new LaTeX document, the default behavior of Matplotlib is to distill the
output, which removes some PostScript operators used by LaTeX that are illegal
in an EPS file. This step produces results which may be unacceptable to some
users, because the text is coarsely rasterized and converted to bitmaps, which
are not scalable like standard PostScript, and the text is not searchable. One
workaround is to set :rc:`ps.distiller.res` to a higher value (perhaps 6000)
in your rc settings, which will produce larger files but may look better and
scale reasonably. A better workaround, which requires Poppler_ or Xpdf_, can
be activated by changing :rc:`ps.usedistiller` to ``xpdf``. This alternative
produces PostScript without rasterizing text, so it scales properly, can be
edited in Adobe Illustrator, and searched text in pdf documents.
.. _usetex-hangups:
Possible hangups
================
* On Windows, the :envvar:`PATH` environment variable may need to be modified
to include the directories containing the latex, dvipng and ghostscript
executables. See :ref:`environment-variables` and
:ref:`setting-windows-environment-variables` for details.
* Using MiKTeX with Computer Modern fonts, if you get odd \*Agg and PNG
results, go to MiKTeX/Options and update your format files
* On Ubuntu and Gentoo, the base texlive install does not ship with
the type1cm package. You may need to install some of the extra
packages to get all the goodies that come bundled with other latex
distributions.
* Some progress has been made so matplotlib uses the dvi files
directly for text layout. This allows latex to be used for text
layout with the pdf and svg backends, as well as the \*Agg and PS
backends. In the future, a latex installation may be the only
external dependency.
.. _usetex-troubleshooting:
Troubleshooting
===============
* Try deleting your :file:`.matplotlib/tex.cache` directory. If you don't know
where to find :file:`.matplotlib`, see :ref:`locating-matplotlib-config-dir`.
* Make sure LaTeX, dvipng and ghostscript are each working and on your
:envvar:`PATH`.
* Make sure what you are trying to do is possible in a LaTeX document,
that your LaTeX syntax is valid and that you are using raw strings
if necessary to avoid unintended escape sequences.
* :rc:`text.latex.preamble` is not officially supported. This
option provides lots of flexibility, and lots of ways to cause
problems. Please disable this option before reporting problems to
the mailing list.
* If you still need help, please see :ref:`reporting-problems`
.. _dvipng: http://www.nongnu.org/dvipng/
.. _dvips: https://tug.org/texinfohtml/dvips.html
.. _Ghostscript: https://ghostscript.com/
.. _inputenc: https://ctan.org/pkg/inputenc
.. _LaTeX: http://www.tug.org
.. _Poppler: https://poppler.freedesktop.org/
.. _PSNFSS: http://www.ctan.org/tex-archive/macros/latex/required/psnfss/psnfss2e.pdf
.. _psfrag: https://ctan.org/pkg/psfrag
.. _Xpdf: http://www.xpdfreader.com/
"""
| """
*************************
Text rendering With LaTeX
*************************
Matplotlib can use LaTeX to render text. This is activated by setting
``text.usetex : True`` in your rcParams, or by setting the ``usetex`` property
to True on individual `.Text` objects. Text handling through LaTeX is slower
than Matplotlib's very capable :doc:`mathtext </tutorials/text/mathtext>`, but
is more flexible, since different LaTeX packages (font packages, math packages,
etc.) can be used. The results can be striking, especially when you take care
to use the same fonts in your figures as in the main document.
Matplotlib's LaTeX support requires a working LaTeX_ installation. For the
\\*Agg backends, dvipng_ is additionally required; for the PS backend, psfrag_,
dvips_ and Ghostscript_ are additionally required. The executables for these
external dependencies must all be located on your :envvar:`PATH`.
There are a couple of options to mention, which can be changed using
:doc:`rc settings </tutorials/introductory/customizing>`. Here is an example
matplotlibrc file::
font.family : serif
font.serif : Times, Palatino, New Century Schoolbook, Bookman, Computer Modern Roman
font.sans-serif : Helvetica, Avant Garde, Computer Modern Sans Serif
font.cursive : Zapf Chancery
font.monospace : Courier, Computer Modern Typewriter
text.usetex : true
The first valid font in each family is the one that will be loaded. If the
fonts are not specified, the Computer Modern fonts are used by default. All of
the other fonts are Adobe fonts. Times and Palatino each have their own
accompanying math fonts, while the other Adobe serif fonts make use of the
Computer Modern math fonts. See the PSNFSS_ documentation for more details.
To use LaTeX and select Helvetica as the default font, without editing
matplotlibrc use::
import matplotlib.pyplot as plt
plt.rcParams.update({
"text.usetex": True,
"font.family": "sans-serif",
"font.sans-serif": ["Helvetica"]})
# for Palatino and other serif fonts use:
plt.rcParams.update({
"text.usetex": True,
"font.family": "serif",
"font.serif": ["Palatino"],
})
Here is the standard example,
:file:`/gallery/text_labels_and_annotations/tex_demo`:
.. figure:: ../../gallery/text_labels_and_annotations/images/sphx_glr_tex_demo_001.png
:target: ../../gallery/text_labels_and_annotations/tex_demo.html
:align: center
:scale: 50
Note that display math mode (``$$ e=mc^2 $$``) is not supported, but adding the
command ``\\displaystyle``, as in the above demo, will produce the same results.
Non-ASCII characters (e.g. the degree sign in the y-label above) are supported
to the extent that they are supported by inputenc_.
.. note::
Certain characters require special escaping in TeX, such as::
# $ % & ~ _ ^ \\ { } \\( \\) \\[ \\]
Therefore, these characters will behave differently depending on
:rc:`text.usetex`.
PostScript options
==================
In order to produce encapsulated PostScript (EPS) files that can be embedded
in a new LaTeX document, the default behavior of Matplotlib is to distill the
output, which removes some PostScript operators used by LaTeX that are illegal
in an EPS file. This step produces results which may be unacceptable to some
users, because the text is coarsely rasterized and converted to bitmaps, which
are not scalable like standard PostScript, and the text is not searchable. One
workaround is to set :rc:`ps.distiller.res` to a higher value (perhaps 6000)
in your rc settings, which will produce larger files but may look better and
scale reasonably. A better workaround, which requires Poppler_ or Xpdf_, can
be activated by changing :rc:`ps.usedistiller` to ``xpdf``. This alternative
produces PostScript without rasterizing text, so it scales properly, can be
edited in Adobe Illustrator, and searched text in pdf documents.
.. _usetex-hangups:
Possible hangups
================
* On Windows, the :envvar:`PATH` environment variable may need to be modified
to include the directories containing the latex, dvipng and ghostscript
executables. See :ref:`environment-variables` and
:ref:`setting-windows-environment-variables` for details.
* Using MiKTeX with Computer Modern fonts, if you get odd \\*Agg and PNG
results, go to MiKTeX/Options and update your format files
* On Ubuntu and Gentoo, the base texlive install does not ship with
the type1cm package. You may need to install some of the extra
packages to get all the goodies that come bundled with other latex
distributions.
* Some progress has been made so matplotlib uses the dvi files
directly for text layout. This allows latex to be used for text
layout with the pdf and svg backends, as well as the \\*Agg and PS
backends. In the future, a latex installation may be the only
external dependency.
.. _usetex-troubleshooting:
Troubleshooting
===============
* Try deleting your :file:`.matplotlib/tex.cache` directory. If you don't know
where to find :file:`.matplotlib`, see :ref:`locating-matplotlib-config-dir`.
* Make sure LaTeX, dvipng and ghostscript are each working and on your
:envvar:`PATH`.
* Make sure what you are trying to do is possible in a LaTeX document,
that your LaTeX syntax is valid and that you are using raw strings
if necessary to avoid unintended escape sequences.
* :rc:`text.latex.preamble` is not officially supported. This
option provides lots of flexibility, and lots of ways to cause
problems. Please disable this option before reporting problems to
the mailing list.
* If you still need help, please see :ref:`reporting-problems`
.. _dvipng: http://www.nongnu.org/dvipng/
.. _dvips: https://tug.org/texinfohtml/dvips.html
.. _Ghostscript: https://ghostscript.com/
.. _inputenc: https://ctan.org/pkg/inputenc
.. _LaTeX: http://www.tug.org
.. _Poppler: https://poppler.freedesktop.org/
.. _PSNFSS: http://www.ctan.org/tex-archive/macros/latex/required/psnfss/psnfss2e.pdf
.. _psfrag: https://ctan.org/pkg/psfrag
.. _Xpdf: http://www.xpdfreader.com/
""" |
# first line: 1
@mem.cache
def get_data(filename):
data=load_svmlight_file(filename)
return data[0],data[1]
| @mem.cache
def get_data(filename):
data = load_svmlight_file(filename)
return (data[0], data[1]) |
"""
Defines an Indexer Object with different methods to index data, look up, add, remove etc
Extremely useful across all NLP tasks
Author: Greg Durrett
Contact: gdurrett@cs.utexas.edu
"""
class Indexer(object):
"""
Bijection between objects and integers starting at 0. Useful for mapping
labels, features, etc. into coordinates of a vector space.
Attributes:
objs_to_ints
ints_to_objs
"""
def __init__(self):
self.objs_to_ints = {}
self.ints_to_objs = {}
def __repr__(self):
return str([str(self.get_object(i)) for i in range(0, len(self))])
def __str__(self):
return self.__repr__()
def __len__(self):
return len(self.objs_to_ints)
def get_object(self, index):
"""
:param index: integer index to look up
:return: Returns the object corresponding to the particular index or None if not found
"""
if index not in self.ints_to_objs:
return None
else:
return self.ints_to_objs[index]
def contains(self, object):
"""
:param object: object to look up
:return: Returns True if it is in the Indexer, False otherwise
"""
return self.index_of(object) != -1
def index_of(self, object):
"""
:param object: object to look up
:return: Returns -1 if the object isn't present, index otherwise
"""
if object not in self.objs_to_ints:
return -1
else:
return self.objs_to_ints[object]
def add_and_get_index(self, object, add=True):
"""
Adds the object to the index if it isn't present, always returns a nonnegative index
:param object: object to look up or add
:param add: True by default, False if we shouldn't add the object. If False, equivalent to index_of.
:return: The index of the object
"""
if not add:
return self.index_of(object)
if object not in self.objs_to_ints:
new_idx = len(self.objs_to_ints)
self.objs_to_ints[object] = new_idx
self.ints_to_objs[new_idx] = object
return self.objs_to_ints[object] | """
Defines an Indexer Object with different methods to index data, look up, add, remove etc
Extremely useful across all NLP tasks
Author: Greg Durrett
Contact: gdurrett@cs.utexas.edu
"""
class Indexer(object):
"""
Bijection between objects and integers starting at 0. Useful for mapping
labels, features, etc. into coordinates of a vector space.
Attributes:
objs_to_ints
ints_to_objs
"""
def __init__(self):
self.objs_to_ints = {}
self.ints_to_objs = {}
def __repr__(self):
return str([str(self.get_object(i)) for i in range(0, len(self))])
def __str__(self):
return self.__repr__()
def __len__(self):
return len(self.objs_to_ints)
def get_object(self, index):
"""
:param index: integer index to look up
:return: Returns the object corresponding to the particular index or None if not found
"""
if index not in self.ints_to_objs:
return None
else:
return self.ints_to_objs[index]
def contains(self, object):
"""
:param object: object to look up
:return: Returns True if it is in the Indexer, False otherwise
"""
return self.index_of(object) != -1
def index_of(self, object):
"""
:param object: object to look up
:return: Returns -1 if the object isn't present, index otherwise
"""
if object not in self.objs_to_ints:
return -1
else:
return self.objs_to_ints[object]
def add_and_get_index(self, object, add=True):
"""
Adds the object to the index if it isn't present, always returns a nonnegative index
:param object: object to look up or add
:param add: True by default, False if we shouldn't add the object. If False, equivalent to index_of.
:return: The index of the object
"""
if not add:
return self.index_of(object)
if object not in self.objs_to_ints:
new_idx = len(self.objs_to_ints)
self.objs_to_ints[object] = new_idx
self.ints_to_objs[new_idx] = object
return self.objs_to_ints[object] |
#
# Copyright 2017, Data61
# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
# ABN 41 687 119 230.
#
# This software may be distributed and modified according to the terms of
# the BSD 2-Clause license. Note that NO WARRANTY is provided.
# See "LICENSE_BSD2.txt" for details.
#
# @TAG(DATA61_BSD)
#
'''
Helpers for accessing architecture-specific information
'''
def is_64_bit_arch(arch):
return arch in ('x86_64', 'aarch64')
def min_untyped_size(arch):
return 4
def max_untyped_size(arch):
if is_64_bit_arch(arch):
return 47
else:
return 29
| """
Helpers for accessing architecture-specific information
"""
def is_64_bit_arch(arch):
return arch in ('x86_64', 'aarch64')
def min_untyped_size(arch):
return 4
def max_untyped_size(arch):
if is_64_bit_arch(arch):
return 47
else:
return 29 |
def find_num_1(response_list):
responses = []
for r in response_list:
responses.extend([i for i in r])
responses = list(set(responses))
return len(responses)
def find_num_2(response_list):
if len(response_list) == 0:
return 0
responses = set(response_list[0])
if len(response_list) == 1:
print(str(list(responses)) + "\t" + str(len(responses)))
return len(list(responses))
responses = list(responses.intersection(*response_list[1:]))
print(str(responses) + "\t" + str(len(responses)))
return len(responses)
def parse_file(input_file):
responses = []
family = []
for r in input_file:
if not r.strip():
responses.append(family)
family = []
else:
family.append(r)
responses.append(family)
return responses
file = "input_day6.txt"
with open(file, "r") as input:
input_file = input.read().splitlines()
parsed_input_file = parse_file(input_file)
num_1 = 0
num_2 = 0
for family in parsed_input_file:
num_1 += find_num_1(family)
num_2 += find_num_2(family)
print("Number of exceptions, pt1:\t"+str(num_1))
print("Number of exceptions, pt2:\t"+str(num_2))
| def find_num_1(response_list):
responses = []
for r in response_list:
responses.extend([i for i in r])
responses = list(set(responses))
return len(responses)
def find_num_2(response_list):
if len(response_list) == 0:
return 0
responses = set(response_list[0])
if len(response_list) == 1:
print(str(list(responses)) + '\t' + str(len(responses)))
return len(list(responses))
responses = list(responses.intersection(*response_list[1:]))
print(str(responses) + '\t' + str(len(responses)))
return len(responses)
def parse_file(input_file):
responses = []
family = []
for r in input_file:
if not r.strip():
responses.append(family)
family = []
else:
family.append(r)
responses.append(family)
return responses
file = 'input_day6.txt'
with open(file, 'r') as input:
input_file = input.read().splitlines()
parsed_input_file = parse_file(input_file)
num_1 = 0
num_2 = 0
for family in parsed_input_file:
num_1 += find_num_1(family)
num_2 += find_num_2(family)
print('Number of exceptions, pt1:\t' + str(num_1))
print('Number of exceptions, pt2:\t' + str(num_2)) |
LOWER_PRIORITY = 100
LOW_PRIORITY = 75
DEFAULT_PRIORITY = 50
HIGH_PRIORITY = 25
HIGHEST_PRIORITY = 0
| lower_priority = 100
low_priority = 75
default_priority = 50
high_priority = 25
highest_priority = 0 |
class Config(object):
data = './'
activation='Relu'#Swish,Relu,Mish,Selu
init = "kaiming"#kaiming
save = './checkpoints'#save best model dir
arch = 'resnet'
depth = 50 #resnet-50
gpu_id = '0,1' #gpu id
train_data = '/home/daixiangzi/dataset/cifar-10/files/train.txt'# train file
test_data = '/home/daixiangzi/dataset/cifar-10/files/test.txt'# test file
train_batch=512
test_batch=512
epochs= 150
lr = 0.1#0.003
gamma =0.1#'LR is multiplied by gamma on schedule.
drop = 0
momentum = 0.9
fre_print=2
weight_decay = 1e-4
schedule = [60,100,125]
seed = 666
workers=4
num_classes=10 #classes
resume = None #path to latest checkpoint
#label_smoothing
label_smooth = False
esp = 0.1
# warmming_up
warmming_up = False
decay_epoch=1000
#mix up
mix_up= True
alpha = 0.5#0.1
# Cutout
cutout = False #set cutout flag
cutout_n = 5
cutout_len = 5
evaluate=False #wether to test
start_epoch = 0
optim = "SGD" #SGD,Adam,RAdam,AdamW
#lookahead
lookahead = False
la_steps=5
la_alpha=0.5
logs = './logs/'+arch+str(depth)+optim+str(lr)+("_lookahead" if lookahead else "")+"_"+activation+"_"+init+("_cutout" if cutout else "")+("_mix_up"+str(alpha) if mix_up else "")+("_warmup"+str(decay_epoch) if warmming_up else "")+str('_label_smooth'+str(esp) if label_smooth else "")
| class Config(object):
data = './'
activation = 'Relu'
init = 'kaiming'
save = './checkpoints'
arch = 'resnet'
depth = 50
gpu_id = '0,1'
train_data = '/home/daixiangzi/dataset/cifar-10/files/train.txt'
test_data = '/home/daixiangzi/dataset/cifar-10/files/test.txt'
train_batch = 512
test_batch = 512
epochs = 150
lr = 0.1
gamma = 0.1
drop = 0
momentum = 0.9
fre_print = 2
weight_decay = 0.0001
schedule = [60, 100, 125]
seed = 666
workers = 4
num_classes = 10
resume = None
label_smooth = False
esp = 0.1
warmming_up = False
decay_epoch = 1000
mix_up = True
alpha = 0.5
cutout = False
cutout_n = 5
cutout_len = 5
evaluate = False
start_epoch = 0
optim = 'SGD'
lookahead = False
la_steps = 5
la_alpha = 0.5
logs = './logs/' + arch + str(depth) + optim + str(lr) + ('_lookahead' if lookahead else '') + '_' + activation + '_' + init + ('_cutout' if cutout else '') + ('_mix_up' + str(alpha) if mix_up else '') + ('_warmup' + str(decay_epoch) if warmming_up else '') + str('_label_smooth' + str(esp) if label_smooth else '') |
# Make an xor function
# Truth table
# | left | right | Result |
# |-------|-------|--------|
# | True | True | False |
# | True | False | True |
# | False | True | True |
# | False | False | False |
# def xor(left, right):
# return left != right
xor = lambda left, right: left != right
print(xor(True, True)) # > False
print(xor(True, False)) # > True
print(xor(False, True)) # > True
print(xor(False, False)) # > False
def print_powers_of(base, exp=1):
i = 1
while i <= exp:
print(base ** i)
i += 1
# We are not hoisting the function declaration, we need to invoke after declared
print_powers_of(15)
print_powers_of(exp=6, base=7)
print_powers_of(2, 5)
print_powers_of(3, 5)
print_powers_of(10, 5)
if True:
x = 10
print(x)
print(i)
| xor = lambda left, right: left != right
print(xor(True, True))
print(xor(True, False))
print(xor(False, True))
print(xor(False, False))
def print_powers_of(base, exp=1):
i = 1
while i <= exp:
print(base ** i)
i += 1
print_powers_of(15)
print_powers_of(exp=6, base=7)
print_powers_of(2, 5)
print_powers_of(3, 5)
print_powers_of(10, 5)
if True:
x = 10
print(x)
print(i) |
class Users:
'''
Class that generates new instances of users
'''
users_list = []
def save_users(self):
'''
This method will save all users to the user list
'''
Users.users_list.append(self)
def __init__ (self,user_name,first_name,last_name,birth_month,password):
'''
This is a blueprint that every user instance must conform to
'''
self.user_name = user_name
self.first_name = first_name
self.last_name = last_name
self.birth_month = birth_month
self.password = password
@classmethod
def find_user_byPassword(cls,password):
'''
This method will take in a password and check if the password exists to find the user
'''
for user in cls.users_list:
if user.password == password:
return user
@classmethod
def user_registered(cls,user_name,password):
'''
Method that checks if a user exists in the user list.Will help in authentication
'''
for user in cls.users_list:
if user.user_name == user_name and user.password == password:
return True
return False
| class Users:
"""
Class that generates new instances of users
"""
users_list = []
def save_users(self):
"""
This method will save all users to the user list
"""
Users.users_list.append(self)
def __init__(self, user_name, first_name, last_name, birth_month, password):
"""
This is a blueprint that every user instance must conform to
"""
self.user_name = user_name
self.first_name = first_name
self.last_name = last_name
self.birth_month = birth_month
self.password = password
@classmethod
def find_user_by_password(cls, password):
"""
This method will take in a password and check if the password exists to find the user
"""
for user in cls.users_list:
if user.password == password:
return user
@classmethod
def user_registered(cls, user_name, password):
"""
Method that checks if a user exists in the user list.Will help in authentication
"""
for user in cls.users_list:
if user.user_name == user_name and user.password == password:
return True
return False |
PREDEFINED_TORQUE_INPUTS = [
"$torque.environment.id",
"$torque.environment.virtual_network_id",
"$torque.environment.public_address",
"$torque.repos.current.current",
"$torque.repos.current.url",
"$torque.repos.current.token"
]
| predefined_torque_inputs = ['$torque.environment.id', '$torque.environment.virtual_network_id', '$torque.environment.public_address', '$torque.repos.current.current', '$torque.repos.current.url', '$torque.repos.current.token'] |
def iterate(days):
with open("inputs/day6.txt") as f:
input = [int(x) for x in f.readline().strip().split(",")]
fish = {}
for f in input:
fish[f] = fish.get(f, 0) + 1
for day in range(1, days+1):
new_fish = {}
for x in fish:
if x == 0:
new_fish[6] = new_fish.get(6,0) + fish[x]
new_fish[8] = fish[x]
else:
new_fish[x-1] = new_fish.get(x-1, 0) + fish[x]
fish = new_fish
fish_count = sum(fish.values())
return fish_count
print("part1:", iterate(80))
print("part2:", iterate(256))
| def iterate(days):
with open('inputs/day6.txt') as f:
input = [int(x) for x in f.readline().strip().split(',')]
fish = {}
for f in input:
fish[f] = fish.get(f, 0) + 1
for day in range(1, days + 1):
new_fish = {}
for x in fish:
if x == 0:
new_fish[6] = new_fish.get(6, 0) + fish[x]
new_fish[8] = fish[x]
else:
new_fish[x - 1] = new_fish.get(x - 1, 0) + fish[x]
fish = new_fish
fish_count = sum(fish.values())
return fish_count
print('part1:', iterate(80))
print('part2:', iterate(256)) |
rows, cols = [int(x) for x in input().split()]
line = input()
index = 0
matrix = []
for row in range(rows):
matrix.append([None]*cols)
for col in range(cols):
if row % 2 == 0:
matrix[row][col] = line[index]
else:
matrix[row][cols - 1 - col] = line[index]
index = (index +1 ) % len(line)
for el in matrix:
print(''.join(el)) | (rows, cols) = [int(x) for x in input().split()]
line = input()
index = 0
matrix = []
for row in range(rows):
matrix.append([None] * cols)
for col in range(cols):
if row % 2 == 0:
matrix[row][col] = line[index]
else:
matrix[row][cols - 1 - col] = line[index]
index = (index + 1) % len(line)
for el in matrix:
print(''.join(el)) |
# -*- coding: utf-8 -*-
"""
Created on Wed Jul 21 08:25:14 2021
@author: ASUS
"""
| """
Created on Wed Jul 21 08:25:14 2021
@author: ASUS
""" |
class SplendaException(Exception):
def __init__(self, method_name, fake_class, spec_class):
self.fake_class = fake_class
self.spec_class = spec_class
self.method_name = method_name
def __str__(self):
spec_name = self.spec_class.__name__
fake_name = self.fake_class.__name__
return self.message.format(
fake_name=fake_name,
method_name=self.method_name,
spec_name=spec_name)
| class Splendaexception(Exception):
def __init__(self, method_name, fake_class, spec_class):
self.fake_class = fake_class
self.spec_class = spec_class
self.method_name = method_name
def __str__(self):
spec_name = self.spec_class.__name__
fake_name = self.fake_class.__name__
return self.message.format(fake_name=fake_name, method_name=self.method_name, spec_name=spec_name) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.