content
stringlengths
7
1.05M
fixed_cases
stringlengths
1
1.28M
class Solution: def coinChange(self, coins: List[int], amount: int) -> int: # Space complexity O(amount) # Time complexity O(amount * the number of coins) # Using Dynamic programinig with bottom-up strategy # First, allocate the storage dp = [amount + 1] * (amount + 1) # Initialize the 0th dp to 0 dp[0] = 0 # Second. trace each number in the range of amount for num in range(amount+1): for coin in coins: # if this number can combine other coins and get the minimum value, replace to the dp[num] if num - coin >= 0: dp[num] = min(dp[num], dp[num-coin]+1) # means didn't match any coins if dp[amount] == amount + 1: return -1 return dp[amount]
class Solution: def coin_change(self, coins: List[int], amount: int) -> int: dp = [amount + 1] * (amount + 1) dp[0] = 0 for num in range(amount + 1): for coin in coins: if num - coin >= 0: dp[num] = min(dp[num], dp[num - coin] + 1) if dp[amount] == amount + 1: return -1 return dp[amount]
lis = [1, 3, 15, 26, 30, 37, 45, 56, ] divisibles = list(filter(lambda x: (x % 15 == 0), lis)) print(divisibles)
lis = [1, 3, 15, 26, 30, 37, 45, 56] divisibles = list(filter(lambda x: x % 15 == 0, lis)) print(divisibles)
# 2. Number Definer # Write a program that reads a floating-point number and prints "zero" if the number is zero. # Otherwise, print "positive" or "negative". Add "small" if the absolute value of the number is less than 1, # or "large" if it exceeds 1 000 000. number = float(input()) if number == 0: print('zero') if number > 0: if number > 1000000: print('large positive') elif number < 1: print('small positive') else: print('positive') if number < 0: if abs(number) > 1000000: print('large negative') elif abs(number) < 1: print('small negative') else: print('negative')
number = float(input()) if number == 0: print('zero') if number > 0: if number > 1000000: print('large positive') elif number < 1: print('small positive') else: print('positive') if number < 0: if abs(number) > 1000000: print('large negative') elif abs(number) < 1: print('small negative') else: print('negative')
# -*- coding: utf-8 -*- DATE = 'Data' TEMPERATURE = 'Temperatura do Ar Media (degC)' MAX_TEMP = 'Temperatura do Ar Maxima (degC)' MIN_TEMP = 'Temperatura do Ar Minima (degC)' VARIATION_TEMP = 'Variacao da Temperatura do Ar (degC)' HUMIDITY = 'Umidade relativa Media (%)' MAX_HUMIDITY = 'Umidade relativa Maxima (%)' MIN_HUMIDITY = 'Umidade relativa Minima (%)' VARIATION_HUMIDITY = 'Variacao da Umidade relativa (%)' PRESSURE = 'Pressao (hPa)' MAX_PRESSURE = 'Pressao Maxima (hPa)' MIN_PRESSURE = 'Pressao Minima (hPa)' VARIATION_PRESSURE = 'Variacao da Pressao (hPa)' YEAR = 'Ano' MONTH = 'Mes' DAY = 'Dia' DAY_OF_YEAR = 'Dia Juliano' SEASON = 'Estacao Metereologica do Ano' QUANTILE_MAX_TEMP_FIFTEEN_DAYS = 'Percentil Temperatura Max (15 dias)' QUANTILE_MIN_TEMP_FIFTEEN_DAYS = 'Percentil Temperatura Min (15 dias)' UNNAMED = 'Unnamed' JULIAN_DAY = 'Dia Juliano' HOUR_MINUTE = 'Hora - minuto' CODE = 'Cod' WIND_DIRECTION = 'Direcao do Vento no instante da aquisicao (deg)'
date = 'Data' temperature = 'Temperatura do Ar Media (degC)' max_temp = 'Temperatura do Ar Maxima (degC)' min_temp = 'Temperatura do Ar Minima (degC)' variation_temp = 'Variacao da Temperatura do Ar (degC)' humidity = 'Umidade relativa Media (%)' max_humidity = 'Umidade relativa Maxima (%)' min_humidity = 'Umidade relativa Minima (%)' variation_humidity = 'Variacao da Umidade relativa (%)' pressure = 'Pressao (hPa)' max_pressure = 'Pressao Maxima (hPa)' min_pressure = 'Pressao Minima (hPa)' variation_pressure = 'Variacao da Pressao (hPa)' year = 'Ano' month = 'Mes' day = 'Dia' day_of_year = 'Dia Juliano' season = 'Estacao Metereologica do Ano' quantile_max_temp_fifteen_days = 'Percentil Temperatura Max (15 dias)' quantile_min_temp_fifteen_days = 'Percentil Temperatura Min (15 dias)' unnamed = 'Unnamed' julian_day = 'Dia Juliano' hour_minute = 'Hora - minuto' code = 'Cod' wind_direction = 'Direcao do Vento no instante da aquisicao (deg)'
def swap(A, i, j): temp = A[i] A[i] = A[j] A[j] = temp def selectionSort(A): for i in range(len(A) - 1): min = i for j in range(i + 1, len(A)): if A[j] < A[min]: min = j swap(A, min, i) if __name__ == '__main__': A = [3, 5, 8, 4, 1, 9, -2] selectionSort(A) print(A)
def swap(A, i, j): temp = A[i] A[i] = A[j] A[j] = temp def selection_sort(A): for i in range(len(A) - 1): min = i for j in range(i + 1, len(A)): if A[j] < A[min]: min = j swap(A, min, i) if __name__ == '__main__': a = [3, 5, 8, 4, 1, 9, -2] selection_sort(A) print(A)
# should_error # skip-if: '-x' in EXTRA_JIT_ARGS # Syntax error to have a continue outside a loop. def foo(): try: continue finally: pass
def foo(): try: continue finally: pass
class Solution: def fullJustify(self, words: List[str], maxWidth: int) -> List[str]: n = len(words) res = [] row = [words[0]] length = len(words[0]) # length including necessary space lenwd = len(words[0]) # length of words in this row numwd = 1 # number of words in this row def postprocess(row, lenwd, numwd): res = "" if numwd > 1: numspace = maxWidth - lenwd spaces = [numspace // (numwd - 1)] * (numwd - 1) for i in range(numspace % (numwd - 1)): spaces[i] += 1 for i in range(numwd - 1): res += row[i] + ' ' * spaces[i] res += row[-1] else: res = row[0] + ' ' * (maxWidth - lenwd) return res for i in range(1, n): l = len(words[i]) + 1 if l + length > maxWidth: res.append(postprocess(row, lenwd, numwd)) row = [words[i]] numwd = 1 length = len(words[i]) lenwd = len(words[i]) else: row.append(words[i]) numwd += 1 lenwd += l - 1 length += l res.append(' '.join(row) + ' ' * (maxWidth - length)) # last row return res
class Solution: def full_justify(self, words: List[str], maxWidth: int) -> List[str]: n = len(words) res = [] row = [words[0]] length = len(words[0]) lenwd = len(words[0]) numwd = 1 def postprocess(row, lenwd, numwd): res = '' if numwd > 1: numspace = maxWidth - lenwd spaces = [numspace // (numwd - 1)] * (numwd - 1) for i in range(numspace % (numwd - 1)): spaces[i] += 1 for i in range(numwd - 1): res += row[i] + ' ' * spaces[i] res += row[-1] else: res = row[0] + ' ' * (maxWidth - lenwd) return res for i in range(1, n): l = len(words[i]) + 1 if l + length > maxWidth: res.append(postprocess(row, lenwd, numwd)) row = [words[i]] numwd = 1 length = len(words[i]) lenwd = len(words[i]) else: row.append(words[i]) numwd += 1 lenwd += l - 1 length += l res.append(' '.join(row) + ' ' * (maxWidth - length)) return res
# Dungeon problem statement # the dungeon has a size of R x C and you start at cell 'S' and there's an exit at cell 'E'. # a cell full of rock is indicated by a '#' and empty cells are represented by a '.' # ------------C------------- # | S . . # . . . | # | . # . . . # . | # R . # . . . . . | # | . . # # . . . | # | # . # E . # . | # -------------------------- # # for this case, use one queue for each dimension is the better approach than one queue pack/unpack coordinates. # the thing that needs to be aware is that the queues enqueue/dequeue needs to be in sync in each dimension. # the dungeon m = [ ['S', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '#', '.', '.', '.'], ['#', '.', '#', 'E', '.', '#', '.'] ] R = len(m) C = len(m[0]) # 'S' symbol row and column sr = 0 sc = 0 # direction vector technique # North, south, east, west dr = [-1, +1, 0, 0] dc = [0, 0, +1, -1] # row queue rq = [] # column queue cq = [] visited = [[False for i in range(C)] for j in range(R)] prev = [[None for i in range(C)] for j in range(R)] reach_end = False # end row/column er = -1 ec = -1 # at least 1 (current one) nodes_left_in_layer = 1 nodes_in_next_layer = 0 move_count = 0 def explore_neighbors(r, c): global nodes_in_next_layer, prev, visited for i in range(4): rr = r + dr[i] cc = c + dc[i] # bound check if rr < 0 or cc < 0: continue if rr >= R or cc >= C: continue # skip visited locations or blocked cells if visited[rr][cc]: continue if m[rr][cc] == '#': continue rq.insert(0, rr) cq.insert(0, cc) visited[rr][cc] = True prev[rr][cc] = [r, c] nodes_in_next_layer = nodes_in_next_layer + 1 def solve(sr, sc): global nodes_left_in_layer, nodes_in_next_layer, move_count, er, ec rq.insert(0, sr) cq.insert(0, sc) visited[sr][sc] = True while len(rq) > 0: # or len(cq) > 0 r = rq.pop() c = cq.pop() if m[r][c] == 'E': reach_end = True er = r ec = c break explore_neighbors(r, c) nodes_left_in_layer = nodes_left_in_layer - 1 if nodes_left_in_layer == 0: nodes_left_in_layer = nodes_in_next_layer nodes_in_next_layer = 0 move_count = move_count + 1 if reach_end: return move_count return -1 def reconstructPath(): # Reconstruct path going backward from e path = [] at = [er, ec] while(prev[at[0]][at[1]] != None): at = prev[at[0]][at[1]] path.append(at) path.reverse() if len(path) > 0 and path[0] == [sr, sc]: return path return [] def bfs(): result_move_count = solve(sr, sc) print('steps:' + str(result_move_count)) if result_move_count > 0: return reconstructPath() print(bfs())
m = [['S', '.', '.', '#', '.', '.', '.'], ['.', '#', '.', '.', '.', '#', '.'], ['.', '#', '.', '.', '.', '.', '.'], ['.', '.', '#', '#', '.', '.', '.'], ['#', '.', '#', 'E', '.', '#', '.']] r = len(m) c = len(m[0]) sr = 0 sc = 0 dr = [-1, +1, 0, 0] dc = [0, 0, +1, -1] rq = [] cq = [] visited = [[False for i in range(C)] for j in range(R)] prev = [[None for i in range(C)] for j in range(R)] reach_end = False er = -1 ec = -1 nodes_left_in_layer = 1 nodes_in_next_layer = 0 move_count = 0 def explore_neighbors(r, c): global nodes_in_next_layer, prev, visited for i in range(4): rr = r + dr[i] cc = c + dc[i] if rr < 0 or cc < 0: continue if rr >= R or cc >= C: continue if visited[rr][cc]: continue if m[rr][cc] == '#': continue rq.insert(0, rr) cq.insert(0, cc) visited[rr][cc] = True prev[rr][cc] = [r, c] nodes_in_next_layer = nodes_in_next_layer + 1 def solve(sr, sc): global nodes_left_in_layer, nodes_in_next_layer, move_count, er, ec rq.insert(0, sr) cq.insert(0, sc) visited[sr][sc] = True while len(rq) > 0: r = rq.pop() c = cq.pop() if m[r][c] == 'E': reach_end = True er = r ec = c break explore_neighbors(r, c) nodes_left_in_layer = nodes_left_in_layer - 1 if nodes_left_in_layer == 0: nodes_left_in_layer = nodes_in_next_layer nodes_in_next_layer = 0 move_count = move_count + 1 if reach_end: return move_count return -1 def reconstruct_path(): path = [] at = [er, ec] while prev[at[0]][at[1]] != None: at = prev[at[0]][at[1]] path.append(at) path.reverse() if len(path) > 0 and path[0] == [sr, sc]: return path return [] def bfs(): result_move_count = solve(sr, sc) print('steps:' + str(result_move_count)) if result_move_count > 0: return reconstruct_path() print(bfs())
class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self) -> None: self.root = None def push(self, value) -> None: if self.root is None: self.root = Node(value) else: root_node = self.root self.root = Node(value) self.root.next = root_node def pop(self): if self.root is None: return pop_data = self.root.data self.root = self.root.next return pop_data def top(self): if self.root is not None: return self.root.data return -1 def is_empty(self) -> bool: if self.root is None: return True return False def print_stack(self) -> None: if self.root is None: return return self._print_stack(self.root) def _print_stack(self, node: Node) -> None: if node is not None: print(node.data, end=' ') self._print_stack(node.next) else: print() if __name__ == '__main__': stack = Stack() for i in range(1, 11): stack.push(i) print(stack.pop()) print(stack.pop()) print(stack.pop()) print(stack.pop()) print(stack.pop()) print('Stack -->') stack.print_stack() print('Top --> '+str(stack.top())) print('Stack is empty --> '+str(stack.is_empty()))
class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self) -> None: self.root = None def push(self, value) -> None: if self.root is None: self.root = node(value) else: root_node = self.root self.root = node(value) self.root.next = root_node def pop(self): if self.root is None: return pop_data = self.root.data self.root = self.root.next return pop_data def top(self): if self.root is not None: return self.root.data return -1 def is_empty(self) -> bool: if self.root is None: return True return False def print_stack(self) -> None: if self.root is None: return return self._print_stack(self.root) def _print_stack(self, node: Node) -> None: if node is not None: print(node.data, end=' ') self._print_stack(node.next) else: print() if __name__ == '__main__': stack = stack() for i in range(1, 11): stack.push(i) print(stack.pop()) print(stack.pop()) print(stack.pop()) print(stack.pop()) print(stack.pop()) print('Stack -->') stack.print_stack() print('Top --> ' + str(stack.top())) print('Stack is empty --> ' + str(stack.is_empty()))
class Solution: def removeDuplicates(self, nums: List[int]) -> int: n = 0 if len(nums) == 0: return 0 for i in range(1,len(nums)): if nums[n] < nums[i]: n += 1 nums[n] = nums[i] return n+1
class Solution: def remove_duplicates(self, nums: List[int]) -> int: n = 0 if len(nums) == 0: return 0 for i in range(1, len(nums)): if nums[n] < nums[i]: n += 1 nums[n] = nums[i] return n + 1
# 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 ( str ) : n = len ( str ) - 1 i = n while ( i > 0 and str [ i - 1 ] <= str [ i ] ) : i -= 1 if ( i <= 0 ) : return False j = i - 1 while ( j + 1 <= n and str [ j + 1 ] <= str [ i - 1 ] ) : j += 1 str = list ( str ) temp = str [ i - 1 ] str [ i - 1 ] = str [ j ] str [ j ] = temp str = ''.join ( str ) str [ : : - 1 ] return True , str #TOFILL if __name__ == '__main__': param = [ (['B', 'I', 'K', 'M', 'Q', 'Y', 'b', 'e', 'e', 't', 'x'],), (['7', '0', '2', '5', '1', '1', '4', '4', '8', '0', '2', '6', '4', '4', '0', '6', '7', '1', '7', '9', '8', '6', '1', '8', '3', '0', '6', '4', '4', '6', '3', '1', '3', '1', '9', '9', '4', '7', '4', '4', '3', '1', '4', '2', '9', '8', '1', '2', '4'],), (['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1'],), (['o', 'S', 'R', 'm', 'i', 'S', 'z', 'z', 'W', 'X', 'A', 'A', 'M', 'L', 'V', 'Q', 'F', 'i', ' ', 'i', 'G', 'D', 'T', 'a', 'm', 'S', 'N', 's', 'j', 'P', 'E', 'n', 'a', 'Q', 'm'],), (['0', '0', '0', '0', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '3', '3', '4', '4', '4', '5', '5', '5', '5', '5', '5', '5', '5', '6', '7', '7', '8', '8', '8', '9', '9', '9', '9', '9'],), (['0', '0', '1', '0', '1', '0', '0'],), ([' ', 'B', 'D', 'D', 'E', 'E', 'G', 'J', 'J', 'K', 'L', 'L', 'L', 'M', 'N', 'N', 'P', 'Q', 'V', 'W', 'W', 'X', 'Y', 'a', 'b', 'b', 'd', 'f', 'h', 'i', 'j', 'j', 'k', 'k', 'l', 'm', 'm', 'm', 'n', 'p', 'r', 's', 'u', 'v', 'v', 'w', 'x'],), (['5', '4', '4', '7', '5', '5', '1', '8', '6', '6', '9', '9', '6', '6', '8', '7', '4', '0', '7', '3', '6', '0', '9'],), (['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],), (['q', 'a', 'U', 'N', 'V', 'v', 'U', 'R', 'x', 'i', 'S', 'N', 'V', 'V', 'j', 'r', 'e', 'N', 'M'],) ] 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(str): n = len(str) - 1 i = n while i > 0 and str[i - 1] <= str[i]: i -= 1 if i <= 0: return False j = i - 1 while j + 1 <= n and str[j + 1] <= str[i - 1]: j += 1 str = list(str) temp = str[i - 1] str[i - 1] = str[j] str[j] = temp str = ''.join(str) str[::-1] return (True, str) if __name__ == '__main__': param = [(['B', 'I', 'K', 'M', 'Q', 'Y', 'b', 'e', 'e', 't', 'x'],), (['7', '0', '2', '5', '1', '1', '4', '4', '8', '0', '2', '6', '4', '4', '0', '6', '7', '1', '7', '9', '8', '6', '1', '8', '3', '0', '6', '4', '4', '6', '3', '1', '3', '1', '9', '9', '4', '7', '4', '4', '3', '1', '4', '2', '9', '8', '1', '2', '4'],), (['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1'],), (['o', 'S', 'R', 'm', 'i', 'S', 'z', 'z', 'W', 'X', 'A', 'A', 'M', 'L', 'V', 'Q', 'F', 'i', ' ', 'i', 'G', 'D', 'T', 'a', 'm', 'S', 'N', 's', 'j', 'P', 'E', 'n', 'a', 'Q', 'm'],), (['0', '0', '0', '0', '1', '1', '1', '1', '1', '2', '2', '2', '2', '2', '3', '3', '3', '3', '3', '3', '3', '3', '4', '4', '4', '5', '5', '5', '5', '5', '5', '5', '5', '6', '7', '7', '8', '8', '8', '9', '9', '9', '9', '9'],), (['0', '0', '1', '0', '1', '0', '0'],), ([' ', 'B', 'D', 'D', 'E', 'E', 'G', 'J', 'J', 'K', 'L', 'L', 'L', 'M', 'N', 'N', 'P', 'Q', 'V', 'W', 'W', 'X', 'Y', 'a', 'b', 'b', 'd', 'f', 'h', 'i', 'j', 'j', 'k', 'k', 'l', 'm', 'm', 'm', 'n', 'p', 'r', 's', 'u', 'v', 'v', 'w', 'x'],), (['5', '4', '4', '7', '5', '5', '1', '8', '6', '6', '9', '9', '6', '6', '8', '7', '4', '0', '7', '3', '6', '0', '9'],), (['0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1', '1'],), (['q', 'a', 'U', 'N', 'V', 'v', 'U', 'R', 'x', 'i', 'S', 'N', 'V', 'V', 'j', 'r', 'e', 'N', 'M'],)] 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)))
class CaseChangingStream(): def __init__(self, stream, upper): self._stream = stream self._upper = upper def __getattr__(self, name): return self._stream.__getattribute__(name) def LA(self, offset): c = self._stream.LA(offset) if c <= 0: return c return ord(chr(c).upper() if self._upper else chr(c).lower()) def getText(self, start, stop): text = self._stream.getText(start, stop) return text.upper() if self._upper else text.lower()
class Casechangingstream: def __init__(self, stream, upper): self._stream = stream self._upper = upper def __getattr__(self, name): return self._stream.__getattribute__(name) def la(self, offset): c = self._stream.LA(offset) if c <= 0: return c return ord(chr(c).upper() if self._upper else chr(c).lower()) def get_text(self, start, stop): text = self._stream.getText(start, stop) return text.upper() if self._upper else text.lower()
fp = open("1.in", "r") drift = 0 for line in iter(fp.readline, ''): drift += int(line) print(drift) def findDup(): drift = 0 seen = set([0]) for _ in range(1000): fp = open("input1.txt", "r") for line in iter(fp.readline, ''): drift += int(line) if drift in seen: return drift seen.add(drift) fp = None return "No Duplicate Found" print(findDup())
fp = open('1.in', 'r') drift = 0 for line in iter(fp.readline, ''): drift += int(line) print(drift) def find_dup(): drift = 0 seen = set([0]) for _ in range(1000): fp = open('input1.txt', 'r') for line in iter(fp.readline, ''): drift += int(line) if drift in seen: return drift seen.add(drift) fp = None return 'No Duplicate Found' print(find_dup())
l1=[] ##Input number of elements in list n=int(input()) ##Input the elements in the list l1=list(map(int,input().split())) ## Create a new list l2 to store the index(from 1 to number of elements in list1) of elements of list 1 l2=[i for i in range(1,n+1)] ##Run a for loop from 1 till the length of list 1(l1) for i in range(1,n+1): ##Find the Index of ith element of list (l1) x=l1.index(i) ##print(x) ##Now find which element is located at that index in list (l2) y=l2[x] ##Now find the index of this element (y) in list (l1) ##Finally print the element located at that index in list (l2) print(l2[l1.index(y)])
l1 = [] n = int(input()) l1 = list(map(int, input().split())) l2 = [i for i in range(1, n + 1)] for i in range(1, n + 1): x = l1.index(i) y = l2[x] print(l2[l1.index(y)])
# Original version was a simple for loop incrementing counts. Refactored to a generic function using list comprehension. def main(filepath): depths = [int(x) for x in open(filepath,'r').read().split('\n')] increases = lambda x,y: len([d for i,d in enumerate(x[1:]) if len(x[i+1:]) >= y and sum(x[i+1:i+y+1]) > sum(x[i:i+y])]) return increases(depths,1), increases(depths,3) print(main('01.txt'))
def main(filepath): depths = [int(x) for x in open(filepath, 'r').read().split('\n')] increases = lambda x, y: len([d for (i, d) in enumerate(x[1:]) if len(x[i + 1:]) >= y and sum(x[i + 1:i + y + 1]) > sum(x[i:i + y])]) return (increases(depths, 1), increases(depths, 3)) print(main('01.txt'))
class Solution: def minRemoveToMakeValid(self, s: str) -> str: stack, indicesToRemove, result = [], set(), [] for i, c in enumerate(s): if c not in ['(', ')']: continue if c == '(': stack.append(i) elif not stack: indicesToRemove.add(i) else: stack.pop() indicesToRemove = indicesToRemove.union(set(stack)) for i, c in enumerate(s): if i not in indicesToRemove: result.append(c) return ''.join(result)
class Solution: def min_remove_to_make_valid(self, s: str) -> str: (stack, indices_to_remove, result) = ([], set(), []) for (i, c) in enumerate(s): if c not in ['(', ')']: continue if c == '(': stack.append(i) elif not stack: indicesToRemove.add(i) else: stack.pop() indices_to_remove = indicesToRemove.union(set(stack)) for (i, c) in enumerate(s): if i not in indicesToRemove: result.append(c) return ''.join(result)
MFCSAM = {'children': 3, 'cats': 7, 'samoyeds': 2, 'pomeranians': 3, 'akitas': 0, 'vizslas': 0, 'goldfish': 5, 'trees': 3, 'cars': 2, 'perfumes': 1} GREATER = ('cats', 'trees') FEWER = ('pomeranians', 'goldfish') sues = [] for row in open('input').read().splitlines(): sue_properties = {} for info in row.split(', '): if 'Sue' in info: name, value = info.split(': ')[1:] else: name, value = info.split(': ') sue_properties[name] = int(value) sues.append(sue_properties) for idx, sue in enumerate(sues): if all(k not in sue or sue[k] == v for k, v in MFCSAM.items()): print(f"Answer part one: {idx + 1}") if all( k not in sue or k not in GREATER + FEWER and sue[k] == v or k in GREATER and sue[k] > v or k in FEWER and sue[k] < v for k, v in MFCSAM.items() ): print(f"Answer part two: {idx + 1}")
mfcsam = {'children': 3, 'cats': 7, 'samoyeds': 2, 'pomeranians': 3, 'akitas': 0, 'vizslas': 0, 'goldfish': 5, 'trees': 3, 'cars': 2, 'perfumes': 1} greater = ('cats', 'trees') fewer = ('pomeranians', 'goldfish') sues = [] for row in open('input').read().splitlines(): sue_properties = {} for info in row.split(', '): if 'Sue' in info: (name, value) = info.split(': ')[1:] else: (name, value) = info.split(': ') sue_properties[name] = int(value) sues.append(sue_properties) for (idx, sue) in enumerate(sues): if all((k not in sue or sue[k] == v for (k, v) in MFCSAM.items())): print(f'Answer part one: {idx + 1}') if all((k not in sue or (k not in GREATER + FEWER and sue[k] == v) or (k in GREATER and sue[k] > v) or (k in FEWER and sue[k] < v) for (k, v) in MFCSAM.items())): print(f'Answer part two: {idx + 1}')
class Solution: def minDistance(self, word1: str, word2: str) -> int: dp = [ [0] * (len(word2)+1) for _ in range(len(word1)+1) ] for k in range(1, len(word2)+1): dp[0][k] = k for k in range(1, len(word1)+1): dp[k][0] = k for p in range(1, len(word1)+1): for q in range(1, len(word2)+1): if word1[p-1] == word2[q-1]: dp[p][q] = 1 + min(dp[p-1][q-1]-1, dp[p-1][q], dp[p][q-1]) else: dp[p][q] = 1 + min(dp[p-1][q-1], dp[p-1][q], dp[p][q-1]) return dp[-1][-1]
class Solution: def min_distance(self, word1: str, word2: str) -> int: dp = [[0] * (len(word2) + 1) for _ in range(len(word1) + 1)] for k in range(1, len(word2) + 1): dp[0][k] = k for k in range(1, len(word1) + 1): dp[k][0] = k for p in range(1, len(word1) + 1): for q in range(1, len(word2) + 1): if word1[p - 1] == word2[q - 1]: dp[p][q] = 1 + min(dp[p - 1][q - 1] - 1, dp[p - 1][q], dp[p][q - 1]) else: dp[p][q] = 1 + min(dp[p - 1][q - 1], dp[p - 1][q], dp[p][q - 1]) return dp[-1][-1]
class Runner: def __init__(self, graph): self.graph = graph self.cache = {} def findValues(self, inputs): self.cache = {} for inputIndex in range(len(inputs)): self.cache[(inputIndex + 1, 0)] = inputs[inputIndex] if not self.__calculateValues(self.graph.nodes[0]): return [] outputs = [] for i in range(len(self.graph.nodes[0].function.inputs)): outputs.append(self.cache[(0, i)]) del self.cache return outputs def __calculateValues(self, node): if (node.index, 0) in self.cache: return # if isInstance(node, IfFunction): # elif isInstance(node, WhileFunction): # elif isInstance(node, ForFunction): # else: inputs = [] unfinished = False for inputIndex in range(len(node.function.inputs)): conn = self.graph.getConnectionTo(node, inputIndex) if conn is None: unfinished = True continue if self.__calculateValues(conn.outputNode): inputs.append( self.cache[(conn.outputNode.index, conn.outputPlug)]) else: unfinished = True if unfinished: return False if len(node.function.outputs) == 0: outputs = inputs else: outputs = node.function.run(inputs) for i in range(len(outputs)): self.cache[(node.index, i)] = outputs[i] return True
class Runner: def __init__(self, graph): self.graph = graph self.cache = {} def find_values(self, inputs): self.cache = {} for input_index in range(len(inputs)): self.cache[inputIndex + 1, 0] = inputs[inputIndex] if not self.__calculateValues(self.graph.nodes[0]): return [] outputs = [] for i in range(len(self.graph.nodes[0].function.inputs)): outputs.append(self.cache[0, i]) del self.cache return outputs def __calculate_values(self, node): if (node.index, 0) in self.cache: return inputs = [] unfinished = False for input_index in range(len(node.function.inputs)): conn = self.graph.getConnectionTo(node, inputIndex) if conn is None: unfinished = True continue if self.__calculateValues(conn.outputNode): inputs.append(self.cache[conn.outputNode.index, conn.outputPlug]) else: unfinished = True if unfinished: return False if len(node.function.outputs) == 0: outputs = inputs else: outputs = node.function.run(inputs) for i in range(len(outputs)): self.cache[node.index, i] = outputs[i] return True
# Copyright (c) Moshe Zadka # See LICENSE for details. extensions = [ 'sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon', ] master_doc = 'index' project = 'Symplectic' copyright = '2017, Moshe Zadka' author = 'Moshe Zadka' version = '17.10' release = '17.10'
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx.ext.napoleon'] master_doc = 'index' project = 'Symplectic' copyright = '2017, Moshe Zadka' author = 'Moshe Zadka' version = '17.10' release = '17.10'
''' Created on 20 Jul 2015 @author: njohn ''' if __name__ == '__main__': pass
""" Created on 20 Jul 2015 @author: njohn """ if __name__ == '__main__': pass
# coding:utf-8 class Error(Exception): def __str__(self): return self.message class SessionExpiredError(Error): def __init__(self, message="Session has expired."): super(SessionExpiredError, self).__init__() self.message = message class SessionInvalidError(Error): def __init__(self, message="Session is invalid."): super(SessionInvalidError, self).__init__() self.message = message class SessionConsumedError(Error): def __init__(self, message="Session has been consumed."): super(SessionConsumedError, self).__init__() self.message = message class SessionExistsError(Error): def __init__(self, message="Session already exists."): super(SessionExistsError, self).__init__() self.message = message
class Error(Exception): def __str__(self): return self.message class Sessionexpirederror(Error): def __init__(self, message='Session has expired.'): super(SessionExpiredError, self).__init__() self.message = message class Sessioninvaliderror(Error): def __init__(self, message='Session is invalid.'): super(SessionInvalidError, self).__init__() self.message = message class Sessionconsumederror(Error): def __init__(self, message='Session has been consumed.'): super(SessionConsumedError, self).__init__() self.message = message class Sessionexistserror(Error): def __init__(self, message='Session already exists.'): super(SessionExistsError, self).__init__() self.message = message
# 1. Complete the function by filling in the missing parts. The color_translator # function receives the name of a color, then prints its hexadecimal value. # Currently, it only supports the three addictive primary colors (red, green, # blue), so it returns "unknown" for all other colors. def color_translator(color): if color == "red": hex_color = "#ff0000" elif color == "green": hex_color = "#00ff00" elif color == "blue": hex_color = "#0000ff" else: hex_color = "unknown" return hex_color print(color_translator("blue")) # Should be #0000ff print(color_translator("yellow")) # Should be unknown print(color_translator("red")) # Should be #ff0000 print(color_translator("black")) # Should be unknown print(color_translator("green")) # Should be #00ff00 print(color_translator("")) # Should be unknown print("big" > "small") # 4. Students in a class receive their grades as Pass/Fail. Scores of 60 or more # (out of 100) mean that the grade is "Pass". For lower scores, the grade is # "Fail". In addition, scores above 95 (not included) are graded as "Top Score". # Fill in this function so that it returns the proper grade. def exam_grade(score): if score > 95: grade = "Top Score" elif score >= 60: grade = "Pass" else: grade = "Fail" return grade print(exam_grade(65)) # Should be Pass print(exam_grade(55)) # Should be Fail print(exam_grade(60)) # Should be Pass print(exam_grade(95)) # Should be Pass print(exam_grade(100)) # Should be Top Score print(exam_grade(0)) # Should be Fail def format_name(first_name, last_name): # code goes here if first_name is not "" and last_name is not "": string = f"Name: {last_name}, {first_name}" elif first_name is "" and last_name is not "": string = f"Name: {last_name}" elif first_name is not "" and last_name is "": string = f"Name: {first_name}" else: string = "" return string print(format_name("Ernest", "Hemingway")) # Should return the string "Name: Hemingway, Ernest" print(format_name("", "Madonna")) # Should return the string "Name: Madonna" print(format_name("Voltaire", "")) # Should return the string "Name: Voltaire" print(format_name("", "")) # Should return an empty string def longest_word(word1, word2, word3): if len(word1) >= len(word2) and len(word1) >= len(word3): word = word1 elif len(word2) >= len(word1) and len(word2) >= len(word3): word = word2 else: word = word3 return word print(longest_word("chair", "couch", "table")) print(longest_word("bed", "bath", "beyond")) print(longest_word("laptop", "notebook", "desktop")) def sum(x, y): return x + y print(sum(sum(1, 2), sum(3, 4))) print((10 >= 5 * 2) and (10 <= 5 * 2)) # The fractional_part function divides the numerator by the denominator, adn # returns just the fractional part (a number between 0 and 1). Complete the # body of the function so that it returns the right number. # Note: Since division by 0 produces an error, if the denominator is 0, the # function should return 0 instead of attempting the division. def fractional_part(numerator, denominator): # Operate with numerator and denominator to # keep just the fractional part of the quotient if denominator == 0: return 0 answer = (numerator / denominator) - (numerator // denominator) if answer == 0.0: return 0 return answer print(fractional_part(5, 5)) # Should be 0 print(fractional_part(5, 4)) # Should be 0.25 print(fractional_part(5, 3)) # Should be 0.66... print(fractional_part(5, 2)) # Should be 0.5 print(fractional_part(5, 0)) # Should be 0 print(fractional_part(0, 5)) # Should be 0
def color_translator(color): if color == 'red': hex_color = '#ff0000' elif color == 'green': hex_color = '#00ff00' elif color == 'blue': hex_color = '#0000ff' else: hex_color = 'unknown' return hex_color print(color_translator('blue')) print(color_translator('yellow')) print(color_translator('red')) print(color_translator('black')) print(color_translator('green')) print(color_translator('')) print('big' > 'small') def exam_grade(score): if score > 95: grade = 'Top Score' elif score >= 60: grade = 'Pass' else: grade = 'Fail' return grade print(exam_grade(65)) print(exam_grade(55)) print(exam_grade(60)) print(exam_grade(95)) print(exam_grade(100)) print(exam_grade(0)) def format_name(first_name, last_name): if first_name is not '' and last_name is not '': string = f'Name: {last_name}, {first_name}' elif first_name is '' and last_name is not '': string = f'Name: {last_name}' elif first_name is not '' and last_name is '': string = f'Name: {first_name}' else: string = '' return string print(format_name('Ernest', 'Hemingway')) print(format_name('', 'Madonna')) print(format_name('Voltaire', '')) print(format_name('', '')) def longest_word(word1, word2, word3): if len(word1) >= len(word2) and len(word1) >= len(word3): word = word1 elif len(word2) >= len(word1) and len(word2) >= len(word3): word = word2 else: word = word3 return word print(longest_word('chair', 'couch', 'table')) print(longest_word('bed', 'bath', 'beyond')) print(longest_word('laptop', 'notebook', 'desktop')) def sum(x, y): return x + y print(sum(sum(1, 2), sum(3, 4))) print(10 >= 5 * 2 and 10 <= 5 * 2) def fractional_part(numerator, denominator): if denominator == 0: return 0 answer = numerator / denominator - numerator // denominator if answer == 0.0: return 0 return answer print(fractional_part(5, 5)) print(fractional_part(5, 4)) print(fractional_part(5, 3)) print(fractional_part(5, 2)) print(fractional_part(5, 0)) print(fractional_part(0, 5))
# Joshua Nelson Gomes (Joshua) # CIS 41A Spring 2020 # Take-Home Assignment I class Square: def __init__(self, side): self.side = side def getArea(self): return self.side * self.side class Cube(Square): def __init__(self, side): Square.__init__(self, side) def getVolume(self): return self.side * self.side * self.side def calcTotal(price, taxRate = 0.08): return price + (price * taxRate) def main(): s = Square(3) print (f'{s.getArea()}') c = Cube(4) print (f'{c.getVolume()}') print (f'{calcTotal(10)}') myLists = [] for row in range(1,6,2): newRow = [] for col in range(1,6,2): newRow.append(row*col**2) myLists.append(newRow) print(myLists[0][1]) if __name__ == '__main__': main() ''' Execution Results: Sorry Jimmy this is book is only for adult patrons. Jimmy has checked out Alice in Wonderland Jimmy has checked out The Cat in the Hat Jimmy has the following books checked out: Alice in Wonderland The Cat in the Hat Sorry Jimmy you are at your limit of 2 books Jimmy has returned Alice in Wonderland Jimmy has checked out Harry Potter and the Sorcerer's Stone Jimmy has the following books checked out: The Cat in the Hat Harry Potter and the Sorcerer's Stone Sophia has checked out The Da Vinci Code Sophia has checked out The Hobbit Sophia has the following books checked out: The Da Vinci Code The Hobbit '''
class Square: def __init__(self, side): self.side = side def get_area(self): return self.side * self.side class Cube(Square): def __init__(self, side): Square.__init__(self, side) def get_volume(self): return self.side * self.side * self.side def calc_total(price, taxRate=0.08): return price + price * taxRate def main(): s = square(3) print(f'{s.getArea()}') c = cube(4) print(f'{c.getVolume()}') print(f'{calc_total(10)}') my_lists = [] for row in range(1, 6, 2): new_row = [] for col in range(1, 6, 2): newRow.append(row * col ** 2) myLists.append(newRow) print(myLists[0][1]) if __name__ == '__main__': main() "\nExecution Results:\n\nSorry Jimmy this is book is only for adult patrons.\nJimmy has checked out Alice in Wonderland\nJimmy has checked out The Cat in the Hat\nJimmy has the following books checked out:\nAlice in Wonderland\nThe Cat in the Hat\nSorry Jimmy you are at your limit of 2 books\nJimmy has returned Alice in Wonderland\nJimmy has checked out Harry Potter and the Sorcerer's Stone\nJimmy has the following books checked out:\nThe Cat in the Hat\nHarry Potter and the Sorcerer's Stone\nSophia has checked out The Da Vinci Code\nSophia has checked out The Hobbit\nSophia has the following books checked out:\nThe Da Vinci Code\nThe Hobbit\n\n"
# The subroutine inserts the vector passed as the secondargument into row j of the matrix. # It also inserts this vector into column j of the matrix. # Insertion involves copying the vector into the corresponding row and column. # If the value of j is out of range, the subroutine returns -1 and does not perform any insertion, # otherwise, it returns 0 and performs the insertion in the corresponding row and column. def exercise(matrix, vector, N, j): if j < 0 or j > N: # return -1 raise Exception('j should be greater than 0 and smaller than N') i = 0 while i < len(matrix): element = vector[i] # Substitute row matrix[j][i] = element # Substitute column matrix[i][j] = element i += 1 # return 0 for row in matrix: print(row) if __name__ == '__main__': matrix = [[1.1, 1.3, 1.5], [3.5, 8.3, 2.1], [2.3, 2.1, 5.5]] vector = [0.5, 0.2, 0.1] N = 3 j = 1 exercise(matrix, vector, N, j)
def exercise(matrix, vector, N, j): if j < 0 or j > N: raise exception('j should be greater than 0 and smaller than N') i = 0 while i < len(matrix): element = vector[i] matrix[j][i] = element matrix[i][j] = element i += 1 for row in matrix: print(row) if __name__ == '__main__': matrix = [[1.1, 1.3, 1.5], [3.5, 8.3, 2.1], [2.3, 2.1, 5.5]] vector = [0.5, 0.2, 0.1] n = 3 j = 1 exercise(matrix, vector, N, j)
class HooksIter: def __init__(self, items=None): self.hooks = {} if items: for item in items: self.hooks[item] = item.hooks def __iter__(self): for hooks in self.hooks.values(): for event in hooks: for hook in event: yield hook def __getitem__(self, *args): results = self.hooks for arg in args: if results.get(arg): results = results.get(arg) else: results = None return results def __setitem__(self, item, hooks): self.hooks[item] = hooks def get(self, item): return self.hooks.get(item)
class Hooksiter: def __init__(self, items=None): self.hooks = {} if items: for item in items: self.hooks[item] = item.hooks def __iter__(self): for hooks in self.hooks.values(): for event in hooks: for hook in event: yield hook def __getitem__(self, *args): results = self.hooks for arg in args: if results.get(arg): results = results.get(arg) else: results = None return results def __setitem__(self, item, hooks): self.hooks[item] = hooks def get(self, item): return self.hooks.get(item)
#!/usr/bin/python # -*- coding: utf-8 -*- # Copyright: (c) 2019, Micah Hunsberger (@mhunsber) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) DOCUMENTATION = r''' --- module: win_file_compression short_description: Alters the compression of files and directories on NTFS partitions. description: - This module sets the compressed attribute for files and directories on a filesystem that supports it like NTFS. - NTFS compression can be used to save disk space. options: path: description: - The full path of the file or directory to modify. - The path must exist on file system that supports compression like NTFS. required: yes type: path state: description: - Set to C(present) to ensure the I(path) is compressed. - Set to C(absent) to ensure the I(path) is not compressed. type: str choices: - absent - present default: present recurse: description: - Whether to recursively apply changes to all subdirectories and files. - This option only has an effect when I(path) is a directory. - When set to C(false), only applies changes to I(path). - When set to C(true), applies changes to I(path) and all subdirectories and files. type: bool default: false force: description: - This option only has an effect when I(recurse) is C(true) - If C(true), will check the compressed state of all subdirectories and files and make a change if any are different from I(compressed). - If C(false), will only make a change if the compressed state of I(path) is different from I(compressed). - If the folder structure is complex or contains a lot of files, it is recommended to set this option to C(false) so that not every file has to be checked. type: bool default: true author: - Micah Hunsberger (@mhunsber) notes: - M(community.windows.win_file_compression) sets the file system's compression state, it does not create a zip archive file. - For more about NTFS Compression, see U(http://www.ntfs.com/ntfs-compressed.htm) ''' EXAMPLES = r''' - name: Compress log files directory community.windows.win_file_compression: path: C:\Logs state: present - name: Decompress log files directory community.windows.win_file_compression: path: C:\Logs state: absent - name: Compress reports directory and all subdirectories community.windows.win_file_compression: path: C:\business\reports state: present recurse: yes # This will only check C:\business\reports for the compressed state # If C:\business\reports is compressed, it will not make a change # even if one of the child items is uncompressed - name: Compress reports directory and all subdirectories (quick) community.windows.win_file_compression: path: C:\business\reports compressed: yes recurse: yes force: no ''' RETURN = r''' rc: description: - The return code of the compress/uncompress operation. - If no changes are made or the operation is successful, rc is 0. returned: always sample: 0 type: int '''
documentation = "\n---\nmodule: win_file_compression\nshort_description: Alters the compression of files and directories on NTFS partitions.\ndescription:\n - This module sets the compressed attribute for files and directories on a filesystem that supports it like NTFS.\n - NTFS compression can be used to save disk space.\noptions:\n path:\n description:\n - The full path of the file or directory to modify.\n - The path must exist on file system that supports compression like NTFS.\n required: yes\n type: path\n state:\n description:\n - Set to C(present) to ensure the I(path) is compressed.\n - Set to C(absent) to ensure the I(path) is not compressed.\n type: str\n choices:\n - absent\n - present\n default: present\n recurse:\n description:\n - Whether to recursively apply changes to all subdirectories and files.\n - This option only has an effect when I(path) is a directory.\n - When set to C(false), only applies changes to I(path).\n - When set to C(true), applies changes to I(path) and all subdirectories and files.\n type: bool\n default: false\n force:\n description:\n - This option only has an effect when I(recurse) is C(true)\n - If C(true), will check the compressed state of all subdirectories and files\n and make a change if any are different from I(compressed).\n - If C(false), will only make a change if the compressed state of I(path) is different from I(compressed).\n - If the folder structure is complex or contains a lot of files, it is recommended to set this\n option to C(false) so that not every file has to be checked.\n type: bool\n default: true\nauthor:\n - Micah Hunsberger (@mhunsber)\nnotes:\n - M(community.windows.win_file_compression) sets the file system's compression state, it does not create a zip\n archive file.\n - For more about NTFS Compression, see U(http://www.ntfs.com/ntfs-compressed.htm)\n" examples = '\n- name: Compress log files directory\n community.windows.win_file_compression:\n path: C:\\Logs\n state: present\n\n- name: Decompress log files directory\n community.windows.win_file_compression:\n path: C:\\Logs\n state: absent\n\n- name: Compress reports directory and all subdirectories\n community.windows.win_file_compression:\n path: C:\\business\\reports\n state: present\n recurse: yes\n\n# This will only check C:\\business\\reports for the compressed state\n# If C:\\business\\reports is compressed, it will not make a change\n# even if one of the child items is uncompressed\n\n- name: Compress reports directory and all subdirectories (quick)\n community.windows.win_file_compression:\n path: C:\\business\\reports\n compressed: yes\n recurse: yes\n force: no\n' return = '\nrc:\n description:\n - The return code of the compress/uncompress operation.\n - If no changes are made or the operation is successful, rc is 0.\n returned: always\n sample: 0\n type: int\n'
class PopulationIsNotEvaluatedException(RuntimeError): pass class StopEvolution(Exception): pass
class Populationisnotevaluatedexception(RuntimeError): pass class Stopevolution(Exception): pass
#121 # Time: O(n) # Space: O(1) # Say you have an array for which the ith element is # the price of a given stock on day i. # If you were only permitted to complete at most one transaction # (ie, buy one and sell one share of the stock), # design an algorithm to find the maximum profit. # # Example 1: # Input: [7, 1, 5, 3, 6, 4] # Output: 5 # max. difference = 6-1 = 5 # (not 7-1 = 6, as selling price needs to be larger than buying price) # # Example 2: # Input: [7, 6, 4, 3, 1] # Output: 0 # In this case, no transaction is done, i.e. max profit = 0. class arraySol(): def bestTimeSellBuyI(self,prices): min_price,max_profit=float('Inf'),0 for price in prices: min_price=min(min_price,price) max_profit=max(max_profit,price-min_price) return max_profit
class Arraysol: def best_time_sell_buy_i(self, prices): (min_price, max_profit) = (float('Inf'), 0) for price in prices: min_price = min(min_price, price) max_profit = max(max_profit, price - min_price) return max_profit
def partition(nums, low, high): pivot = nums[(low + high) // 2] i = low - 1 j = high + 1 while True: i += 1 while nums[i] < pivot: i += 1 j -= 1 while nums[j] > pivot: j -= 1 if i >= j: return j nums[i], nums[j] = nums[j], nums[i] def quick_sort(nums): def _quick_sort(items, low, high): if low < high: split_index = partition(items, low, high) _quick_sort(items, low, split_index) _quick_sort(items, split_index + 1, high) _quick_sort(nums, 0, len(nums) - 1) random_list_of_nums = [25, 10, 34, 16, 99] quick_sort(random_list_of_nums) print(random_list_of_nums)
def partition(nums, low, high): pivot = nums[(low + high) // 2] i = low - 1 j = high + 1 while True: i += 1 while nums[i] < pivot: i += 1 j -= 1 while nums[j] > pivot: j -= 1 if i >= j: return j (nums[i], nums[j]) = (nums[j], nums[i]) def quick_sort(nums): def _quick_sort(items, low, high): if low < high: split_index = partition(items, low, high) _quick_sort(items, low, split_index) _quick_sort(items, split_index + 1, high) _quick_sort(nums, 0, len(nums) - 1) random_list_of_nums = [25, 10, 34, 16, 99] quick_sort(random_list_of_nums) print(random_list_of_nums)
h, w = map(int, input().split()) ans = 0 if h == 1 or w == 1: ans = 1 else: if w % 2 == 0: ans += (w//2)*h else: if h % 2 == 0: ans += (h//2)*(w//2*2+1) else: ans += (h//2)*(w//2*2+1)+(w//2+1) print(max(1, ans))
(h, w) = map(int, input().split()) ans = 0 if h == 1 or w == 1: ans = 1 elif w % 2 == 0: ans += w // 2 * h elif h % 2 == 0: ans += h // 2 * (w // 2 * 2 + 1) else: ans += h // 2 * (w // 2 * 2 + 1) + (w // 2 + 1) print(max(1, ans))
### test examples for the rast_client.py file def test_somefunction(): pass
def test_somefunction(): pass
def main(): #with open(filename, (open for reading 'r', #writing 'w' or reading and writing 'rw')) word = input("What's your word? Enter it here: ") print("Scrabble score: " + (str)(scrabble_value(word))); #everything past here the file is closed # scrabble_value("potato") #three options: # 1) write a program to compute the "scrabble score" or a word (assuming no tile modifiers). #I'll provide tile values for each tile # 2) Write a program to determine if a given "scrabble rack" of seven letters can be formed into a valid srabble word using the provided scrabble_dictionary.txt # valid_word("cearr") --> return a list of words from the dictionary that you can make with these letters; if no words ossible, return emoty list # 3) A small game: "GHOST" # a loop with text input (use input() function we talked about) #4) "GHOST BOT" same as above but one player, and then the computer makes guesses that make life hard for the player #def scrabble_value(word): # do some work # return the value def scrabble_value(word): score = 0 scrabble_dict = { "a": 1, "b": 3, "c": 3, "d": 2, "e": 1, "f": 4, "g": 2, "h": 4, "i": 1, "j": 8, "k": 5, "l": 1, "m": 3, "n": 1, "o": 1, "p": 3, "q": 10, "r": 1, "s": 1, "t": 1, "u": 1, "v": 4, "w": 4, "x": 8, "y": 4, "z": 10 } for i in word: score = score + scrabble_dict[i] return score if __name__ == '__main__': main()
def main(): word = input("What's your word? Enter it here: ") print('Scrabble score: ' + str(scrabble_value(word))) def scrabble_value(word): score = 0 scrabble_dict = {'a': 1, 'b': 3, 'c': 3, 'd': 2, 'e': 1, 'f': 4, 'g': 2, 'h': 4, 'i': 1, 'j': 8, 'k': 5, 'l': 1, 'm': 3, 'n': 1, 'o': 1, 'p': 3, 'q': 10, 'r': 1, 's': 1, 't': 1, 'u': 1, 'v': 4, 'w': 4, 'x': 8, 'y': 4, 'z': 10} for i in word: score = score + scrabble_dict[i] return score if __name__ == '__main__': main()
ALL_DRIVERS = ['chromedriver', 'geckodriver'] DEFAULT_DRIVERS = ['chromedriver', 'geckodriver'] CHROMEDRIVER_STORAGE_URL = 'https://chromedriver.storage.googleapis.com' CHROMEDRIVER_LATEST_FILE = 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE' GECKODRIVER_LASTEST_URL = 'https://api.github.com/repos/mozilla/geckodriver/releases/latest' GECKODRIVER_URL_BASE = 'https://github.com/mozilla/geckodriver/releases/download'
all_drivers = ['chromedriver', 'geckodriver'] default_drivers = ['chromedriver', 'geckodriver'] chromedriver_storage_url = 'https://chromedriver.storage.googleapis.com' chromedriver_latest_file = 'https://chromedriver.storage.googleapis.com/LATEST_RELEASE' geckodriver_lastest_url = 'https://api.github.com/repos/mozilla/geckodriver/releases/latest' geckodriver_url_base = 'https://github.com/mozilla/geckodriver/releases/download'
# Ordering # Create a program that allows entry of 10 numbers and then sorts them into ascending or descending order, based on user input. def main(): isNumber = input('Do you want to enter numbers or a string: [N/S] ').upper() if isNumber == 'N': nums = [int(input('Enter a number: ')) for _ in range(10)] order = input('Do you want to order in ascending or descending order [A/D]: ').upper() if order == 'A': nums.sort() elif order == 'D': nums.sort(reverse=True) print(nums) elif isNumber == 'S': string = [i for i in input('Enter a string: ')] order = input('Do you want to order in ascending or descending order [A/D]: ').upper() if order == 'A': string.sort() elif order == 'D': string.sort(reverse=True) print(''.join(string)) if __name__ == '__main__': main()
def main(): is_number = input('Do you want to enter numbers or a string: [N/S] ').upper() if isNumber == 'N': nums = [int(input('Enter a number: ')) for _ in range(10)] order = input('Do you want to order in ascending or descending order [A/D]: ').upper() if order == 'A': nums.sort() elif order == 'D': nums.sort(reverse=True) print(nums) elif isNumber == 'S': string = [i for i in input('Enter a string: ')] order = input('Do you want to order in ascending or descending order [A/D]: ').upper() if order == 'A': string.sort() elif order == 'D': string.sort(reverse=True) print(''.join(string)) if __name__ == '__main__': main()
# This problem was recently asked by Twitter: # Implement a class for a stack that supports all the regular functions (push, pop) and # an additional function of max() which returns the maximum element in the stack (return None if the stack is empty) # Each method should run in constant time. class MaxStack: def __init__(self): # Fill this in. self.items = [] def push(self, val): # Fill this in. self.items.append(val) def pop(self): # Fill this in. return self.items.pop() def max(self): # Fill this in. maxN = 0 if len(self.items) == 0: return None for i in self.items: if i >= maxN: maxN = i return maxN s = MaxStack() s.push(1) s.push(2) s.push(3) s.push(2) print (s.max()) # 3 s.pop() s.pop() print (s.max()) # 2
class Maxstack: def __init__(self): self.items = [] def push(self, val): self.items.append(val) def pop(self): return self.items.pop() def max(self): max_n = 0 if len(self.items) == 0: return None for i in self.items: if i >= maxN: max_n = i return maxN s = max_stack() s.push(1) s.push(2) s.push(3) s.push(2) print(s.max()) s.pop() s.pop() print(s.max())
coins = { "Khan's Concentrated Magic": 80000, "Luminous Cobalt Ingot": 800, "Bright Reef Piece": 140, "Great Ocean Dark Iron": 160, "Cobalt Ingot": 150, "Brilliant Rock Salt Ingot": 1600, "Seaweed Stalk": 600, "Enhanced Island Tree Coated Plywood": 80, "Pure Pearl Crystal": 550, "Cox Pirates' Artifact (Parley Beginner)": 150, "Cox Pirates' Artifact (Parley Expert)": 800, "Cox Pirates' Artifact (Combat)": 800, "Deep Sea Memory Filled Glue": 140, "Brilliant Pearl Shard": 1600, "Ruddy Manganese Nodule": 1500, "Tear of the Ocean": 3900, "Khan's Tendon": 6000, "Khan's Scale": 1600, "Frosted Black Stone": 20, "Tide-Dyed Standardized Timber Square": 350, "Deep Tide-Dyed Standardized Timber Square": 1000, "Moon Vein Flax Fabric": 600, "Moon Scale Plywood": 160, "Fiery Black Stone": 10, "Mandragora Essence": 100, }
coins = {"Khan's Concentrated Magic": 80000, 'Luminous Cobalt Ingot': 800, 'Bright Reef Piece': 140, 'Great Ocean Dark Iron': 160, 'Cobalt Ingot': 150, 'Brilliant Rock Salt Ingot': 1600, 'Seaweed Stalk': 600, 'Enhanced Island Tree Coated Plywood': 80, 'Pure Pearl Crystal': 550, "Cox Pirates' Artifact (Parley Beginner)": 150, "Cox Pirates' Artifact (Parley Expert)": 800, "Cox Pirates' Artifact (Combat)": 800, 'Deep Sea Memory Filled Glue': 140, 'Brilliant Pearl Shard': 1600, 'Ruddy Manganese Nodule': 1500, 'Tear of the Ocean': 3900, "Khan's Tendon": 6000, "Khan's Scale": 1600, 'Frosted Black Stone': 20, 'Tide-Dyed Standardized Timber Square': 350, 'Deep Tide-Dyed Standardized Timber Square': 1000, 'Moon Vein Flax Fabric': 600, 'Moon Scale Plywood': 160, 'Fiery Black Stone': 10, 'Mandragora Essence': 100}
class Command: def execute(self): raise NotImplementedError
class Command: def execute(self): raise NotImplementedError
# Use a Q to keep recent timestamps. Whenever ping is called, add t to Q and remove all the expired ones. Return len(Q) class RecentCounter: def __init__(self): self.Q = [] def ping(self, t: int) -> int: self.Q.append(t) while self.Q[0]<t-3000: self.Q.pop(0) return len(self.Q) # Your RecentCounter object will be instantiated and called as such: # obj = RecentCounter() # param_1 = obj.ping(t)
class Recentcounter: def __init__(self): self.Q = [] def ping(self, t: int) -> int: self.Q.append(t) while self.Q[0] < t - 3000: self.Q.pop(0) return len(self.Q)
class Html_Maker: @classmethod def read_text_file(cls, path: str): ret = '' with open(path, 'r') as f: while True: line = f.readline() if not line: break line = line.replace( '\t', '<span style="white-space:pre">\t</span>') line = '<br>' if line == '\n' else line ret += '<div>'+line+'</div>\n' return ret @classmethod def hyper_link(cls, href: str, display: str): return '<a href="{}">'.format(href) + display + '</a>' @classmethod def image(cls, scr: str, width: int = None, height: int = None): info = [] info.append('src="{}"'.format(scr)) if width: width = 'width="{}px"'.format(width) info.append(width) if height: height = 'height="{}px"'.format(height) info.append(height) return '<img '+' '.join(info) + ' />' @classmethod def paragraph(cls, text: str): if text: return '<div>'+text+'</div>' else: return '<br>'
class Html_Maker: @classmethod def read_text_file(cls, path: str): ret = '' with open(path, 'r') as f: while True: line = f.readline() if not line: break line = line.replace('\t', '<span style="white-space:pre">\t</span>') line = '<br>' if line == '\n' else line ret += '<div>' + line + '</div>\n' return ret @classmethod def hyper_link(cls, href: str, display: str): return '<a href="{}">'.format(href) + display + '</a>' @classmethod def image(cls, scr: str, width: int=None, height: int=None): info = [] info.append('src="{}"'.format(scr)) if width: width = 'width="{}px"'.format(width) info.append(width) if height: height = 'height="{}px"'.format(height) info.append(height) return '<img ' + ' '.join(info) + ' />' @classmethod def paragraph(cls, text: str): if text: return '<div>' + text + '</div>' else: return '<br>'
a = list(range(10)) print(a) b = list("Pablo Fajardo") print(b) empty = [] print(empty) nine = [0,1,2,3,4,5,6,7,8,9] print(nine) mixed = ['a',1,'b',2,'c',3,"Pablo",empty,True] print(mixed) #Add a single item to a list mixed.append("Fajardo") print(mixed) #Add item with index mixed.insert(2,"PALABRA") print(mixed) #New List pies = ['cherry','cream','apple'] print(pies) #Another List desserts = ['cookies','lemon'] print(desserts) #Add a list with another list pies.extend(desserts) print(pies) #Remove a item with the index pies.pop(2) print(pies) #Remove the last item #pies.pop() #print(pies) pies.remove('lemon') print(pies) pies.remove('cookies') print(pies)
a = list(range(10)) print(a) b = list('Pablo Fajardo') print(b) empty = [] print(empty) nine = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] print(nine) mixed = ['a', 1, 'b', 2, 'c', 3, 'Pablo', empty, True] print(mixed) mixed.append('Fajardo') print(mixed) mixed.insert(2, 'PALABRA') print(mixed) pies = ['cherry', 'cream', 'apple'] print(pies) desserts = ['cookies', 'lemon'] print(desserts) pies.extend(desserts) print(pies) pies.pop(2) print(pies) pies.remove('lemon') print(pies) pies.remove('cookies') print(pies)
# This is a useful data structure for implementing # a counter that counts the time. class DFSTimeCounter: def __init__(self): self.count = 0 def reset(self): self.count = 0 def increment(self): self.count = self.count + 1 def get(self): return self.count class UndirectedGraph: # n is the number of vertices # we will label the vertices from 0 to self.n -1 # Initialize to an empty adjacency list # We will store the outgoing edges using a set data structure def __init__(self, n): self.n = n self.adj_list = [set() for i in range(self.n)] def add_edge(self, i, j): assert 0 <= i < self.n assert 0 <= j < self.n assert i != j # Make sure to add edge from i to j self.adj_list[i].add(j) # Also add edge from j to i self.adj_list[j].add(i) # get a set of all vertices that # are neighbors of the # vertex i def get_neighboring_vertices(self, i): assert 0 <= i < self.n return self.adj_list[i] # Function: dfs_visit # Program a DFS visit of a graph. # We maintain a list of discovery times and finish times. # Initially all discovery times and finish times are set to None. # When a vertex is first visited, we will set discovery time # When DFS visit has processed all the neighbors then # set the finish time. # DFS visit should update the list of discovery and finish times in-place # Arguments # i --> id of the vertex being visited. # dfs_timer --> An instance of DFSTimeCounter structure provided for you. # discovery --> discovery time of each vertex -- a list of size self.n # None if the vertex is yet to be visited. # finish --> finish time of each vertex -- a list of size self.n # None if the vertex is yet to be finished. # dfs_tree_parent --> the parent for for each node # if we visited node j from node i, then j's parent is i. # Do not forget to set tree_parent when you call dfs_visit # on node j from node i. # dfs_back_edges --> a list of back edges. # a back edge is an edge from i to j wherein # DFS has already discovered j when i is discovered # but not finished j def dfs_visit(self, i, dfs_timer, discovery_times, finish_times, dfs_tree_parent, dfs_back_edges): assert 0 <= i < self.n assert discovery_times[i] is None assert finish_times[i] is None discovery_times[i] = dfs_timer.get() dfs_timer.increment() for v in self.get_neighboring_vertices(i): if discovery_times[v] is not None and finish_times[v] is None: dfs_back_edges.append((i, v)) if discovery_times[v] is None: dfs_tree_parent[v] = i self.dfs_visit(v, dfs_timer, discovery_times, finish_times, dfs_tree_parent, dfs_back_edges) finish_times[i] = dfs_timer.get() dfs_timer.increment() # Function: dfs_traverse_graph # Traverse the entire graph. def dfs_traverse_graph(self): dfs_timer = DFSTimeCounter() discovery_times = [None] * self.n finish_times = [None] * self.n dfs_tree_parents = [None] * self.n dfs_back_edges = [] for i in range(self.n): if discovery_times[i] is None: self.dfs_visit(i, dfs_timer, discovery_times, finish_times, dfs_tree_parents, dfs_back_edges) # Clean up the back edges so that if (i,j) is a back edge then j cannot # be i's parent. non_trivial_back_edges = [(i, j) for (i, j) in dfs_back_edges if dfs_tree_parents[i] != j] return dfs_tree_parents, non_trivial_back_edges, discovery_times, finish_times def num_connected_components(g): # g is an UndirectedGraph class # your code here mscc = get_mscc(g) return len(mscc) def dfs_for_transposed_nodes(transposed_g, g_ordered_stack): timer = DFSTimeCounter() discovery_times = [None] * transposed_g.n finish_times = [None] * transposed_g.n dfs_tree_parents = [None] * transposed_g.n dfs_back_edges = [] dont_visit = [] mscc = [] for node in g_ordered_stack: scc = [] if node not in dont_visit: transposed_g.dfs_visit(node, timer, discovery_times, finish_times, dfs_tree_parents, dfs_back_edges) for i in range(len(finish_times)): if finish_times[i] is not None and i not in dont_visit: dont_visit.append(i) scc.append(i) dont_visit.append(node) if scc: mscc.append(scc) non_trivial_back_edges = [(i, j) for (i, j) in dfs_back_edges if dfs_tree_parents[i] != j] return mscc def transpose_g(g: UndirectedGraph) -> UndirectedGraph: transposed_g = UndirectedGraph(g.n) for node in range(len(g.adj_list)): for edge in g.adj_list[node]: transposed_g.add_edge(edge, node) return transposed_g def create_stack_from_finish_times(finish_times: list) -> list: stack = [] for i in range(0, len(finish_times)): max = 0 location = 0 for j in range(len(finish_times)): if finish_times[j] > max and j not in stack: max = finish_times[j] location = j stack.append(location) return stack def find_all_nodes_in_cycle(g): # g is an UndirectedGraph class # todo # your code here dfs_tree_parents, non_trivial_back_edges, discovery_times, finish_times = g.dfs_traverse_graph() python_set = set() for thing in non_trivial_back_edges: for item in thing: python_set.add(item) ret_set = set() for node in python_set: neighbors = g.get_neighboring_vertices(node) if len(neighbors) > 1: ret_set.add(node) for neighbor in neighbors: neighbor_neighbors = g.get_neighboring_vertices(neighbor) if len(neighbor_neighbors) > 1: ret_set.add(neighbor) return ret_set def get_mscc(g): dfs_tree_parents, non_trivial_back_edges, discovery_times, finish_times = g.dfs_traverse_graph() print(finish_times) first_stack = create_stack_from_finish_times(finish_times) # transpose transposed_g = transpose_g(g) # dfs of transposed mscc = dfs_for_transposed_nodes(transposed_g, first_stack) return mscc
class Dfstimecounter: def __init__(self): self.count = 0 def reset(self): self.count = 0 def increment(self): self.count = self.count + 1 def get(self): return self.count class Undirectedgraph: def __init__(self, n): self.n = n self.adj_list = [set() for i in range(self.n)] def add_edge(self, i, j): assert 0 <= i < self.n assert 0 <= j < self.n assert i != j self.adj_list[i].add(j) self.adj_list[j].add(i) def get_neighboring_vertices(self, i): assert 0 <= i < self.n return self.adj_list[i] def dfs_visit(self, i, dfs_timer, discovery_times, finish_times, dfs_tree_parent, dfs_back_edges): assert 0 <= i < self.n assert discovery_times[i] is None assert finish_times[i] is None discovery_times[i] = dfs_timer.get() dfs_timer.increment() for v in self.get_neighboring_vertices(i): if discovery_times[v] is not None and finish_times[v] is None: dfs_back_edges.append((i, v)) if discovery_times[v] is None: dfs_tree_parent[v] = i self.dfs_visit(v, dfs_timer, discovery_times, finish_times, dfs_tree_parent, dfs_back_edges) finish_times[i] = dfs_timer.get() dfs_timer.increment() def dfs_traverse_graph(self): dfs_timer = dfs_time_counter() discovery_times = [None] * self.n finish_times = [None] * self.n dfs_tree_parents = [None] * self.n dfs_back_edges = [] for i in range(self.n): if discovery_times[i] is None: self.dfs_visit(i, dfs_timer, discovery_times, finish_times, dfs_tree_parents, dfs_back_edges) non_trivial_back_edges = [(i, j) for (i, j) in dfs_back_edges if dfs_tree_parents[i] != j] return (dfs_tree_parents, non_trivial_back_edges, discovery_times, finish_times) def num_connected_components(g): mscc = get_mscc(g) return len(mscc) def dfs_for_transposed_nodes(transposed_g, g_ordered_stack): timer = dfs_time_counter() discovery_times = [None] * transposed_g.n finish_times = [None] * transposed_g.n dfs_tree_parents = [None] * transposed_g.n dfs_back_edges = [] dont_visit = [] mscc = [] for node in g_ordered_stack: scc = [] if node not in dont_visit: transposed_g.dfs_visit(node, timer, discovery_times, finish_times, dfs_tree_parents, dfs_back_edges) for i in range(len(finish_times)): if finish_times[i] is not None and i not in dont_visit: dont_visit.append(i) scc.append(i) dont_visit.append(node) if scc: mscc.append(scc) non_trivial_back_edges = [(i, j) for (i, j) in dfs_back_edges if dfs_tree_parents[i] != j] return mscc def transpose_g(g: UndirectedGraph) -> UndirectedGraph: transposed_g = undirected_graph(g.n) for node in range(len(g.adj_list)): for edge in g.adj_list[node]: transposed_g.add_edge(edge, node) return transposed_g def create_stack_from_finish_times(finish_times: list) -> list: stack = [] for i in range(0, len(finish_times)): max = 0 location = 0 for j in range(len(finish_times)): if finish_times[j] > max and j not in stack: max = finish_times[j] location = j stack.append(location) return stack def find_all_nodes_in_cycle(g): (dfs_tree_parents, non_trivial_back_edges, discovery_times, finish_times) = g.dfs_traverse_graph() python_set = set() for thing in non_trivial_back_edges: for item in thing: python_set.add(item) ret_set = set() for node in python_set: neighbors = g.get_neighboring_vertices(node) if len(neighbors) > 1: ret_set.add(node) for neighbor in neighbors: neighbor_neighbors = g.get_neighboring_vertices(neighbor) if len(neighbor_neighbors) > 1: ret_set.add(neighbor) return ret_set def get_mscc(g): (dfs_tree_parents, non_trivial_back_edges, discovery_times, finish_times) = g.dfs_traverse_graph() print(finish_times) first_stack = create_stack_from_finish_times(finish_times) transposed_g = transpose_g(g) mscc = dfs_for_transposed_nodes(transposed_g, first_stack) return mscc
class Obj(object): def __init__(self, filename): with open(filename) as f: self.lines = f.read().splitlines() self.vertices = [] self.vfaces = [] self.read() def read(self): for line in self.lines: if line: prefix, value = line.split(' ', 1) if prefix == 'v': self.vertices.append(list(map(float, value.split(' ')))) elif prefix == 'f': self.vfaces.append([list(map(int, face.split('/'))) for face in value.split(' ')])
class Obj(object): def __init__(self, filename): with open(filename) as f: self.lines = f.read().splitlines() self.vertices = [] self.vfaces = [] self.read() def read(self): for line in self.lines: if line: (prefix, value) = line.split(' ', 1) if prefix == 'v': self.vertices.append(list(map(float, value.split(' ')))) elif prefix == 'f': self.vfaces.append([list(map(int, face.split('/'))) for face in value.split(' ')])
# Consider a row of n coins of values v1 . . . vn, where n is even. # We play a game against an opponent by alternating turns. In each turn, # a player selects either the first or last coin from the row, removes it # from the row permanently, and receives the value of the coin. Determine the # maximum possible amount of money we can definitely win if we move first. # Note: The opponent is as clever as the user. # http://www.geeksforgeeks.org/dynamic-programming-set-31-optimal-strategy-for-a-game/ def find_max_val_recur(coins,l,r): if l + 1 == r: return max(coins[l],coins[r]) if l == r: return coins[i] left_choose = coins[l] + min(find_max_val_recur(coins,l+1,r - 1),find_max_val_recur(coins,l+2,r)) right_choose = coins[r] + min(find_max_val_recur(coins,l + 1,r-1),find_max_val_recur(coins,l,r-2)) return max(left_choose,right_choose) coin_map = {} def find_max_val_memo(coins,l,r): if l + 1 == r: return max(coins[l],coins[r]) if l == r: return coins[i] if (l,r) in coin_map: return coin_map[(l,r)] left_choose = coins[l] + min(find_max_val_memo(coins,l+1,r - 1),find_max_val_memo(coins,l+2,r)) right_choose = coins[r] + min(find_max_val_memo(coins,l + 1,r-1),find_max_val_memo(coins,l,r-2)) max_val = max(left_choose,right_choose) coin_map[(l,r)] = max_val return max_val def find_max_val_bottom_up(coins): coins_len = len(coins) table = [[0] * coins_len for i in range(coins_len + 1)] for gap in range(coins_len): i = 0 for j in range(gap,coins_len): # Here x is value of F(i+2, j), y is F(i+1, j-1) and # z is F(i, j-2) in above recursive formula x = table[i+2][j] if (i+2) <= j else 0 y = table[i+1][j-1] if (i+1) <= (j-1) else 0 z = table[i][j-2] if i <= (j-2) else 0 table[i][j] = max(coins[i] + min(x,y),coins[j] + min(y,z)) i += 1 return table[0][coins_len - 1] if __name__=="__main__": coins = [8,15,3,7] print(find_max_val_bottom_up(coins))
def find_max_val_recur(coins, l, r): if l + 1 == r: return max(coins[l], coins[r]) if l == r: return coins[i] left_choose = coins[l] + min(find_max_val_recur(coins, l + 1, r - 1), find_max_val_recur(coins, l + 2, r)) right_choose = coins[r] + min(find_max_val_recur(coins, l + 1, r - 1), find_max_val_recur(coins, l, r - 2)) return max(left_choose, right_choose) coin_map = {} def find_max_val_memo(coins, l, r): if l + 1 == r: return max(coins[l], coins[r]) if l == r: return coins[i] if (l, r) in coin_map: return coin_map[l, r] left_choose = coins[l] + min(find_max_val_memo(coins, l + 1, r - 1), find_max_val_memo(coins, l + 2, r)) right_choose = coins[r] + min(find_max_val_memo(coins, l + 1, r - 1), find_max_val_memo(coins, l, r - 2)) max_val = max(left_choose, right_choose) coin_map[l, r] = max_val return max_val def find_max_val_bottom_up(coins): coins_len = len(coins) table = [[0] * coins_len for i in range(coins_len + 1)] for gap in range(coins_len): i = 0 for j in range(gap, coins_len): x = table[i + 2][j] if i + 2 <= j else 0 y = table[i + 1][j - 1] if i + 1 <= j - 1 else 0 z = table[i][j - 2] if i <= j - 2 else 0 table[i][j] = max(coins[i] + min(x, y), coins[j] + min(y, z)) i += 1 return table[0][coins_len - 1] if __name__ == '__main__': coins = [8, 15, 3, 7] print(find_max_val_bottom_up(coins))
''' Example: Given an array of distinct integer values, count the number of pairs of integers that have difference k. For example, given the array { 1, 7, 5, 9, 2, 12, 3 } and the difference k = 2,there are four pairs with difference2: (1, 3), (3, 5), (5, 7), (7, 9). ''' def pairs_of_difference(array, diff): hash_table = {} for num in array: hash_table[num] = num count = 0 for num in array: if num + diff in hash_table: count += 1 if num - diff in hash_table: count += 1 return count // 2 print(pairs_of_difference([1, 7, 5, 9, 2, 12, 3], 2))
""" Example: Given an array of distinct integer values, count the number of pairs of integers that have difference k. For example, given the array { 1, 7, 5, 9, 2, 12, 3 } and the difference k = 2,there are four pairs with difference2: (1, 3), (3, 5), (5, 7), (7, 9). """ def pairs_of_difference(array, diff): hash_table = {} for num in array: hash_table[num] = num count = 0 for num in array: if num + diff in hash_table: count += 1 if num - diff in hash_table: count += 1 return count // 2 print(pairs_of_difference([1, 7, 5, 9, 2, 12, 3], 2))
numbers_count = int(input()) sum_number = 0 for counter in range(numbers_count): current_number = int(input()) sum_number += current_number print(sum_number)
numbers_count = int(input()) sum_number = 0 for counter in range(numbers_count): current_number = int(input()) sum_number += current_number print(sum_number)
# coding=utf-8 def test_common_stats_insert(session): raise NotImplementedError def test_duplicate_common_stats_error(session): raise NotImplementedError def test_common_stats_default_values(session): raise NotImplementedError def test_common_stats_negative_value_error(session): raise NotImplementedError def test_field_stats_default_values(session): raise NotImplementedError def test_field_stats_negative_value_error(session): raise NotImplementedError def test_goalkeeper_stats_default_values(session): raise NotImplementedError def test_goalkeeper_stats_negative_value_error(session): raise NotImplementedError def test_field_and_goalkeeper_stats_insert(session): raise NotImplementedError
def test_common_stats_insert(session): raise NotImplementedError def test_duplicate_common_stats_error(session): raise NotImplementedError def test_common_stats_default_values(session): raise NotImplementedError def test_common_stats_negative_value_error(session): raise NotImplementedError def test_field_stats_default_values(session): raise NotImplementedError def test_field_stats_negative_value_error(session): raise NotImplementedError def test_goalkeeper_stats_default_values(session): raise NotImplementedError def test_goalkeeper_stats_negative_value_error(session): raise NotImplementedError def test_field_and_goalkeeper_stats_insert(session): raise NotImplementedError
#common utilities for all module def trap_exc_during_debug(*args): # when app raises uncaught exception, print info print(args)
def trap_exc_during_debug(*args): print(args)
# Copyright 2011 Nicholas Bray # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def doNothing(node): pass class CFGDFS(object): def __init__(self, pre=doNothing, post=doNothing): self.pre = pre self.post = post self.processed = set() def process(self, node): if node not in self.processed: self.processed.add(node) self.pre(node) for child in node.forward(): self.process(child) self.post(node)
def do_nothing(node): pass class Cfgdfs(object): def __init__(self, pre=doNothing, post=doNothing): self.pre = pre self.post = post self.processed = set() def process(self, node): if node not in self.processed: self.processed.add(node) self.pre(node) for child in node.forward(): self.process(child) self.post(node)
def summation(number): total = 0 for num in range(number + 1): total += num return total if __name__ == "__main__": print(summation(1000))
def summation(number): total = 0 for num in range(number + 1): total += num return total if __name__ == '__main__': print(summation(1000))
a = int(input('Informe um numero:')) if a%2 == 0 : print("Par!") else: print('Impar!')
a = int(input('Informe um numero:')) if a % 2 == 0: print('Par!') else: print('Impar!')
class Piece: def __init__(self, board, square, white): self.square = square self.row = square[0] self.col = square[1] self.is_clicked = False #dk if i need this self._white = white self.pinned = False #self.letter def move(self): pass def check_move(self): if self.is_clicked == True: pass def clicked(self): self.is_clicked = True #white is uppercase #black loewrcase #team class Not_King(Piece): def __init__(self, square, white): #super().__init__(self, fname, lname) super().__init__(square, white) self.square = square self.is_pinned = False self.is_protected = False def check_pinned(self): pass def check_protection(self): pass class King(Piece): def move(self): moves = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1),] pass #check squares class Knight(Not_King): def move(self): moves = [(-1, -2), (-1, 2), (1, 2), (1,-2), (-2, -1), (-2, 1), (2, -1), (2, 1)] #move #check L shape 2,1 pass class Pawn(Not_King): def move(self): pass # check squares of board def __init__(self, board, square, white): super().__init__(board, square, white) if self._white: self.moves = [(-1,0)] #-1 row is going up one row else: self.moves = [(1,0)] def move(self): pass def possible_moves(self): if self._white: #white #board pass else: #black pass #
class Piece: def __init__(self, board, square, white): self.square = square self.row = square[0] self.col = square[1] self.is_clicked = False self._white = white self.pinned = False def move(self): pass def check_move(self): if self.is_clicked == True: pass def clicked(self): self.is_clicked = True class Not_King(Piece): def __init__(self, square, white): super().__init__(square, white) self.square = square self.is_pinned = False self.is_protected = False def check_pinned(self): pass def check_protection(self): pass class King(Piece): def move(self): moves = [(-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1)] pass class Knight(Not_King): def move(self): moves = [(-1, -2), (-1, 2), (1, 2), (1, -2), (-2, -1), (-2, 1), (2, -1), (2, 1)] pass class Pawn(Not_King): def move(self): pass def __init__(self, board, square, white): super().__init__(board, square, white) if self._white: self.moves = [(-1, 0)] else: self.moves = [(1, 0)] def move(self): pass def possible_moves(self): if self._white: pass else: pass
print('please input the starting annual salary(annual_salary):') annual_salary=float(input()) print('please input The portion of salary to be saved (portion_saved):') portion_saved=float(input()) print("The cost of your dream home (total_cost):") total_cost=float(input()) portion_down_payment=0.25 current_savings=0 number_of_months=0 savings=0 r=0.04 while(current_savings<total_cost*portion_down_payment): current_savings=annual_salary/12*portion_saved+current_savings*(1+r/12) number_of_months=number_of_months+1 print(number_of_months)
print('please input the starting annual salary(annual_salary):') annual_salary = float(input()) print('please input The portion of salary to be saved (portion_saved):') portion_saved = float(input()) print('The cost of your dream home (total_cost):') total_cost = float(input()) portion_down_payment = 0.25 current_savings = 0 number_of_months = 0 savings = 0 r = 0.04 while current_savings < total_cost * portion_down_payment: current_savings = annual_salary / 12 * portion_saved + current_savings * (1 + r / 12) number_of_months = number_of_months + 1 print(number_of_months)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- mylist = [ "a", 2, 4.5 ] myotherlist = mylist[ : ] mylist[1] = "hello" print(myotherlist) mytext = "Hello world" myothertext = mytext mytext = "Hallo Welt!" #print(myothertext) print(mylist[ : ])
mylist = ['a', 2, 4.5] myotherlist = mylist[:] mylist[1] = 'hello' print(myotherlist) mytext = 'Hello world' myothertext = mytext mytext = 'Hallo Welt!' print(mylist[:])
''' Pig Latin: Rules if word starts with a vowel, add 'ay' to end if word does not start with a vowel, put first letter at the end, then add 'ay' word -> ordway apple -> appleay ''' def pig_latin(word): initial_letter = word[0] if initial_letter in 'aeiou': translated_word = word + 'ay' else: translated_word = word[1:] + initial_letter + 'ay' return translated_word print(pig_latin('word')) print(pig_latin('apple'))
""" Pig Latin: Rules if word starts with a vowel, add 'ay' to end if word does not start with a vowel, put first letter at the end, then add 'ay' word -> ordway apple -> appleay """ def pig_latin(word): initial_letter = word[0] if initial_letter in 'aeiou': translated_word = word + 'ay' else: translated_word = word[1:] + initial_letter + 'ay' return translated_word print(pig_latin('word')) print(pig_latin('apple'))
class Break: def __init__(self, dbRow): self.flinch = dbRow[0] self.wound = dbRow[1] self.sever = dbRow[2] self.extract = dbRow[3] self.name = dbRow[4] def __repr__(self): return f"{self.__dict__!r}"
class Break: def __init__(self, dbRow): self.flinch = dbRow[0] self.wound = dbRow[1] self.sever = dbRow[2] self.extract = dbRow[3] self.name = dbRow[4] def __repr__(self): return f'{self.__dict__!r}'
# -*- coding: utf-8 -*- empty_dict = dict() print(empty_dict) d = {} print(type(d)) #zbiory definuje sie set e = set() print(type(e)) # klucze nie moga sie w slowniku powtarzac #w slowniku uporzadkowanie nie jest istotne, i nie jest uporzadkowane pol_to_eng = {'jeden':'one', 'dwa':'two', 'trzy': 'three'} name_to_digit = {'Jeden':1, 'dwa':2, 'trzy':3} #%% len(name_to_digit) #dict = {'key1'='value1,'key2'='value2'...} #%% #dodawanie kolejnych danych, nie trzeba sie martwic na ktore miejsce, bo #nie ma uporzadkowania pol_to_eng['cztery'] = 'four' #%% pol_to_eng.clear() #%% pol_to_eng_copied = pol_to_eng.copy() #%% #wydobycie kluczy ze slownika pol_to_eng.keys() #przekonwertowanie kluczy slownika na liste list(pol_to_eng.keys()) #%% #wydobycie wartosci ze slownika pol_to_eng.values() #przekonwertowanie wartosci slownika na liste list(pol_to_eng.values()) #%% # dostaje liste tupli, nie moge zmienic pary "klucz - wartosc" pol_to_eng.items() list(pol_to_eng.items()) #%% pol_to_eng['jeden'] #pol_to_eng['zero'] #%% #drugi argument podaje to, co jezeli nie ma danego klucza w slowniku pol_to_eng.get('zero', 'NaN') #%% # wartosc usuwana ze struktury #pol_to_eng.pop('dwa') pol_to_eng.popitem() #%% #aktualizacje danych ktore moga zmieniac sie w czasie pol_to_eng.update({'jeden':1})
empty_dict = dict() print(empty_dict) d = {} print(type(d)) e = set() print(type(e)) pol_to_eng = {'jeden': 'one', 'dwa': 'two', 'trzy': 'three'} name_to_digit = {'Jeden': 1, 'dwa': 2, 'trzy': 3} len(name_to_digit) pol_to_eng['cztery'] = 'four' pol_to_eng.clear() pol_to_eng_copied = pol_to_eng.copy() pol_to_eng.keys() list(pol_to_eng.keys()) pol_to_eng.values() list(pol_to_eng.values()) pol_to_eng.items() list(pol_to_eng.items()) pol_to_eng['jeden'] pol_to_eng.get('zero', 'NaN') pol_to_eng.popitem() pol_to_eng.update({'jeden': 1})
class WordDictionary: def __init__(self, cache=True): self.cache = cache def train(self, data): raise NotImplemented() def predict(self, data): raise NotImplemented() def save(self, model_path): raise NotImplemented() def read(self, model_path): raise NotImplemented()
class Worddictionary: def __init__(self, cache=True): self.cache = cache def train(self, data): raise not_implemented() def predict(self, data): raise not_implemented() def save(self, model_path): raise not_implemented() def read(self, model_path): raise not_implemented()
''' Exercise 2: Odd Or Even Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? Extras: If the number is a multiple of 4, print out a different message. Ask the user for two numbers: one number to check (call it num) and one number to divide by (check). If check divides evenly into num, tell that to the user. If not, print a different appropriate message. ''' input_number = int(input('Please input a number (num):')) input_check = int(input('Please input a check number (check):')) result_message = "Your input is an even number." if input_number % 2 == 0 else "Your input is an odd number." result_message += "\nYour input is a multiple of 4." if input_number % 4 == 0 else "" number_divided = "divides" if input_number % input_check == 0 else "dose not divide" result_message += "\nYour input number {yes_or_not} evenly by {check}".format(yes_or_not = number_divided, check = input_check) print(result_message)
""" Exercise 2: Odd Or Even Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? Extras: If the number is a multiple of 4, print out a different message. Ask the user for two numbers: one number to check (call it num) and one number to divide by (check). If check divides evenly into num, tell that to the user. If not, print a different appropriate message. """ input_number = int(input('Please input a number (num):')) input_check = int(input('Please input a check number (check):')) result_message = 'Your input is an even number.' if input_number % 2 == 0 else 'Your input is an odd number.' result_message += '\nYour input is a multiple of 4.' if input_number % 4 == 0 else '' number_divided = 'divides' if input_number % input_check == 0 else 'dose not divide' result_message += '\nYour input number {yes_or_not} evenly by {check}'.format(yes_or_not=number_divided, check=input_check) print(result_message)
#!/usr/bin/env python # Copyright (c) 2019 VMware, Inc. All Rights Reserved. # SPDX-License-Identifier: BSD-2 License # The full license information can be found in LICENSE.txt # in the root directory of this project. SERVER_CONSTANTS = ( REQUEST_QUEUE_SIZE, PACKET_SIZE, ALLOW_REUSE_ADDRESS ) = ( 100, 1024, True )
server_constants = (request_queue_size, packet_size, allow_reuse_address) = (100, 1024, True)
class Stack: def __init__(self, stack=[], lim=None): self._stack = stack self._lim = lim def push(self, data): if self._lim is not None and len(self._stack) == self._lim: print("~~STACK OVERFLOW~~") return self._stack.append(int(data)) def pop(self): if len(self._stack) == 0: print("~~STACK UNDERFLOW~~") return None return self._stack.pop() def __str__(self): return str(self._stack) if __name__ == '__main__': stack = Stack(lim=10) print("1. Push to stack") print("2. Pop stack") print("3. Print stack") while True: inp = input("Your choice: ") if inp == "1": stack.push(input(" Enter element: ")) elif inp == "2": print(" Element removed:", stack.pop()) else: print(stack)
class Stack: def __init__(self, stack=[], lim=None): self._stack = stack self._lim = lim def push(self, data): if self._lim is not None and len(self._stack) == self._lim: print('~~STACK OVERFLOW~~') return self._stack.append(int(data)) def pop(self): if len(self._stack) == 0: print('~~STACK UNDERFLOW~~') return None return self._stack.pop() def __str__(self): return str(self._stack) if __name__ == '__main__': stack = stack(lim=10) print('1. Push to stack') print('2. Pop stack') print('3. Print stack') while True: inp = input('Your choice: ') if inp == '1': stack.push(input(' Enter element: ')) elif inp == '2': print(' Element removed:', stack.pop()) else: print(stack)
### Code is based on PySimpleAutomata (https://github.com/Oneiroe/PySimpleAutomata/) # MIT License # Copyright (c) 2017 Alessio Cecconi # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. def _epsilon_closure(states, epsilon, transitions): ## add epsilon closure new_states = states while new_states: curr_states = set() for state in new_states: curr_states.update(transitions.get(state, {}).get(epsilon, set())) new_states = curr_states - states states.update(curr_states) def nfa_determinization(nfa: dict, any_input=None, epsilon=None) -> dict: dfa = { 'initial_state': None, 'accepting_states': set(), 'transitions': dict() } initial_states = nfa['initial_states'] _epsilon_closure(initial_states, epsilon, nfa['transitions']) initial_states = frozenset(initial_states) dfa['initial_state'] = initial_states if initial_states.intersection(nfa['accepting_states']): dfa['accepting_states'].add(initial_states) sets_states = set() sets_queue = list() sets_queue.append(initial_states) sets_states.add(initial_states) while sets_queue: current_set = sets_queue.pop(0) new_transitions = {} for state in current_set: old_transitions = nfa['transitions'].get(state, {}) for a in old_transitions.keys(): if a != epsilon: new_transitions[a] = new_transitions.get(a, set()) | old_transitions[a] for char, value in new_transitions.items(): next_set = value | new_transitions.get(any_input, set()) _epsilon_closure(next_set, epsilon, nfa['transitions']) next_set = frozenset(next_set) if next_set not in sets_states: sets_states.add(next_set) sets_queue.append(next_set) if next_set.intersection(nfa['accepting_states']): dfa['accepting_states'].add(next_set) dfa['transitions'].setdefault(current_set, {})[char] = next_set return dfa def dfa_intersection_language(dfa_1: dict, dfa_2: dict, any_input=None) -> dict: language = set() boundary = [(dfa_1['initial_state'], dfa_2['initial_state'])] while boundary: (state_dfa_1, state_dfa_2) = boundary.pop() if state_dfa_1 in dfa_1['accepting_states'] and state_dfa_2 in dfa_2['accepting_states']: language.add((state_dfa_1, state_dfa_2)) if any_input in dfa_1['transitions'].get(state_dfa_1, {}): characters = dfa_2['transitions'].get(state_dfa_2, {}).keys() elif any_input in dfa_2['transitions'].get(state_dfa_2, {}): characters = dfa_1['transitions'].get(state_dfa_1, {}).keys() else: characters = set(dfa_1['transitions'].get(state_dfa_1, {}).keys()).intersection(dfa_2['transitions'].get(state_dfa_2, {}).keys()) for a in characters: next_state_1 = dfa_1['transitions'][state_dfa_1].get(a, dfa_1['transitions'][state_dfa_1].get(any_input, frozenset())) next_state_2 = dfa_2['transitions'][state_dfa_2].get(a, dfa_2['transitions'][state_dfa_2].get(any_input, frozenset())) boundary.append((next_state_1, next_state_2)) return language
def _epsilon_closure(states, epsilon, transitions): new_states = states while new_states: curr_states = set() for state in new_states: curr_states.update(transitions.get(state, {}).get(epsilon, set())) new_states = curr_states - states states.update(curr_states) def nfa_determinization(nfa: dict, any_input=None, epsilon=None) -> dict: dfa = {'initial_state': None, 'accepting_states': set(), 'transitions': dict()} initial_states = nfa['initial_states'] _epsilon_closure(initial_states, epsilon, nfa['transitions']) initial_states = frozenset(initial_states) dfa['initial_state'] = initial_states if initial_states.intersection(nfa['accepting_states']): dfa['accepting_states'].add(initial_states) sets_states = set() sets_queue = list() sets_queue.append(initial_states) sets_states.add(initial_states) while sets_queue: current_set = sets_queue.pop(0) new_transitions = {} for state in current_set: old_transitions = nfa['transitions'].get(state, {}) for a in old_transitions.keys(): if a != epsilon: new_transitions[a] = new_transitions.get(a, set()) | old_transitions[a] for (char, value) in new_transitions.items(): next_set = value | new_transitions.get(any_input, set()) _epsilon_closure(next_set, epsilon, nfa['transitions']) next_set = frozenset(next_set) if next_set not in sets_states: sets_states.add(next_set) sets_queue.append(next_set) if next_set.intersection(nfa['accepting_states']): dfa['accepting_states'].add(next_set) dfa['transitions'].setdefault(current_set, {})[char] = next_set return dfa def dfa_intersection_language(dfa_1: dict, dfa_2: dict, any_input=None) -> dict: language = set() boundary = [(dfa_1['initial_state'], dfa_2['initial_state'])] while boundary: (state_dfa_1, state_dfa_2) = boundary.pop() if state_dfa_1 in dfa_1['accepting_states'] and state_dfa_2 in dfa_2['accepting_states']: language.add((state_dfa_1, state_dfa_2)) if any_input in dfa_1['transitions'].get(state_dfa_1, {}): characters = dfa_2['transitions'].get(state_dfa_2, {}).keys() elif any_input in dfa_2['transitions'].get(state_dfa_2, {}): characters = dfa_1['transitions'].get(state_dfa_1, {}).keys() else: characters = set(dfa_1['transitions'].get(state_dfa_1, {}).keys()).intersection(dfa_2['transitions'].get(state_dfa_2, {}).keys()) for a in characters: next_state_1 = dfa_1['transitions'][state_dfa_1].get(a, dfa_1['transitions'][state_dfa_1].get(any_input, frozenset())) next_state_2 = dfa_2['transitions'][state_dfa_2].get(a, dfa_2['transitions'][state_dfa_2].get(any_input, frozenset())) boundary.append((next_state_1, next_state_2)) return language
def ab(b): c=input("Term To Be Search:") if c in b: print ("Term Found") else: print ("Term Not Found") a=[] while True: b=input("Enter Term(To terminate type Exit):") if b=='Exit' or b=='exit': break else: a.append(b) ab(a)
def ab(b): c = input('Term To Be Search:') if c in b: print('Term Found') else: print('Term Not Found') a = [] while True: b = input('Enter Term(To terminate type Exit):') if b == 'Exit' or b == 'exit': break else: a.append(b) ab(a)
n = int(input()) def weird(n): string = str(n) while n != 1: if n%2 == 0: n = n//2 string += ' ' + str(n) else: n = n*3 + 1 string += ' ' + str(n) return string print(weird(n))
n = int(input()) def weird(n): string = str(n) while n != 1: if n % 2 == 0: n = n // 2 string += ' ' + str(n) else: n = n * 3 + 1 string += ' ' + str(n) return string print(weird(n))
PRICES = [0.01, 0.02, 0.05, 0.10, 0.20, 0.50, 1, 2] QUESTIONS = [ "Voer het aantal 1 centen in:\n", "Voer het aantal 2 centen in: \n", "Voer het aantal 5 centen in: \n", "Voer het aantal 10 centen in: \n", "Voer het aantal 20 centen in: \n", "Voer het aantal 50 centen in: \n", "Voer het aantal 1 euro's in: \n", "Voer het aantal 2 euro's in: \n" ] if __name__ == '__main__': munten = [int(input(question)) for question in QUESTIONS] aantal_munten = sum(munten) totale_waarde = sum(quantity * value for (quantity, value) in zip(munten, PRICES)) print("Totaal aantal munten: {}".format(aantal_munten)) print("Totale waarde van de munten: {} euro".format(totale_waarde))
prices = [0.01, 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2] questions = ['Voer het aantal 1 centen in:\n', 'Voer het aantal 2 centen in: \n', 'Voer het aantal 5 centen in: \n', 'Voer het aantal 10 centen in: \n', 'Voer het aantal 20 centen in: \n', 'Voer het aantal 50 centen in: \n', "Voer het aantal 1 euro's in: \n", "Voer het aantal 2 euro's in: \n"] if __name__ == '__main__': munten = [int(input(question)) for question in QUESTIONS] aantal_munten = sum(munten) totale_waarde = sum((quantity * value for (quantity, value) in zip(munten, PRICES))) print('Totaal aantal munten: {}'.format(aantal_munten)) print('Totale waarde van de munten: {} euro'.format(totale_waarde))
spec = { 'name' : "The devil's work...", 'external network name' : "exnet3", 'keypair' : "openstack_rsa", 'controller' : "r720", 'dns' : "10.30.65.200", 'credentials' : { 'user' : "nic", 'password' : "nic", 'project' : "nic" }, 'Networks' : [ { 'name' : "merlynctl" , "start": "172.16.1.2", "end": "172.16.1.100", "subnet" :" 172.16.1.0/24", "gateway": "172.16.1.1" }, { 'name' : "merlyn201" , "start": "192.168.1.201", "end": "192.168.1.202", "subnet" :" 192.168.1.0/24", "vlan": 201, "physical_network": "vlannet" }, { 'name' : "merlyn202" , "start": "192.168.1.202", "end": "192.168.1.203", "subnet" :" 192.168.1.0/24", "vlan": 202, "physical_network": "vlannet" } ], 'Hosts' : [ { 'name' : "monos" , 'image' : "centos7.2" , 'flavor':"m1.large" , 'net' : [ ("merlynctl","*","10.30.65.130")] }, { 'name' : "m201" , 'image' : "centos7.2" , 'flavor':"m1.medium" , 'net' : [ ("merlynctl","*","10.30.65.131"),("merlyn201" , "192.168.1.201") ] }, { 'name' : "m202" , 'image' : "centos7.2" , 'flavor':"m1.medium" , 'net' : [ ("merlynctl","*","10.30.65.132"),("merlyn202" , "192.168.1.202") ] }, ] }
spec = {'name': "The devil's work...", 'external network name': 'exnet3', 'keypair': 'openstack_rsa', 'controller': 'r720', 'dns': '10.30.65.200', 'credentials': {'user': 'nic', 'password': 'nic', 'project': 'nic'}, 'Networks': [{'name': 'merlynctl', 'start': '172.16.1.2', 'end': '172.16.1.100', 'subnet': ' 172.16.1.0/24', 'gateway': '172.16.1.1'}, {'name': 'merlyn201', 'start': '192.168.1.201', 'end': '192.168.1.202', 'subnet': ' 192.168.1.0/24', 'vlan': 201, 'physical_network': 'vlannet'}, {'name': 'merlyn202', 'start': '192.168.1.202', 'end': '192.168.1.203', 'subnet': ' 192.168.1.0/24', 'vlan': 202, 'physical_network': 'vlannet'}], 'Hosts': [{'name': 'monos', 'image': 'centos7.2', 'flavor': 'm1.large', 'net': [('merlynctl', '*', '10.30.65.130')]}, {'name': 'm201', 'image': 'centos7.2', 'flavor': 'm1.medium', 'net': [('merlynctl', '*', '10.30.65.131'), ('merlyn201', '192.168.1.201')]}, {'name': 'm202', 'image': 'centos7.2', 'flavor': 'm1.medium', 'net': [('merlynctl', '*', '10.30.65.132'), ('merlyn202', '192.168.1.202')]}]}
# coding: utf-8 # fields names BITMAP = 'bitmap' COLS = 'cols' DATA = 'data' EXTERIOR = 'exterior' INTERIOR = 'interior' MULTICHANNEL_BITMAP = 'multichannel_bitmap' ORIGIN = 'origin' POINTS = 'points' ROWS = 'rows' TYPE = 'type' NODES = 'nodes' EDGES = 'edges' ENABLED = 'enabled' LABEL = 'label' COLOR = 'color' TEMPLATE = 'template' LOCATION = 'location'
bitmap = 'bitmap' cols = 'cols' data = 'data' exterior = 'exterior' interior = 'interior' multichannel_bitmap = 'multichannel_bitmap' origin = 'origin' points = 'points' rows = 'rows' type = 'type' nodes = 'nodes' edges = 'edges' enabled = 'enabled' label = 'label' color = 'color' template = 'template' location = 'location'
# Data taken from the MathML 2.0 reference data = ''' "(" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" ")" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "[" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "]" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "{" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "}" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&CloseCurlyDoubleQuote;" form="postfix" fence="true" lspace="0em" rspace="0em" "&CloseCurlyQuote;" form="postfix" fence="true" lspace="0em" rspace="0em" "&LeftAngleBracket;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&LeftBracketingBar;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&LeftCeiling;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&LeftDoubleBracket;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&LeftDoubleBracketingBar;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&LeftFloor;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&OpenCurlyDoubleQuote;" form="prefix" fence="true" lspace="0em" rspace="0em" "&OpenCurlyQuote;" form="prefix" fence="true" lspace="0em" rspace="0em" "&RightAngleBracket;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&RightBracketingBar;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&RightCeiling;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&RightDoubleBracket;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&RightDoubleBracketingBar;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&RightFloor;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em" "&LeftSkeleton;" form="prefix" fence="true" lspace="0em" rspace="0em" "&RightSkeleton;" form="postfix" fence="true" lspace="0em" rspace="0em" "&InvisibleComma;" form="infix" separator="true" lspace="0em" rspace="0em" "," form="infix" separator="true" lspace="0em" rspace="verythickmathspace" "&HorizontalLine;" form="infix" stretchy="true" minsize="0" lspace="0em" rspace="0em" "&VerticalLine;" form="infix" stretchy="true" minsize="0" lspace="0em" rspace="0em" ";" form="infix" separator="true" lspace="0em" rspace="thickmathspace" ";" form="postfix" separator="true" lspace="0em" rspace="0em" ":=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Assign;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Because;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Therefore;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&VerticalSeparator;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "//" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Colon;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&amp;" form="prefix" lspace="0em" rspace="thickmathspace" "&amp;" form="postfix" lspace="thickmathspace" rspace="0em" "*=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "-=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "+=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "/=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "->" form="infix" lspace="thickmathspace" rspace="thickmathspace" ":" form="infix" lspace="thickmathspace" rspace="thickmathspace" ".." form="postfix" lspace="mediummathspace" rspace="0em" "..." form="postfix" lspace="mediummathspace" rspace="0em" "&SuchThat;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&DoubleLeftTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&DoubleRightTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&DownTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LeftTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&RightTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Implies;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RoundImplies;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "|" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "||" form="infix" lspace="mediummathspace" rspace="mediummathspace" "&Or;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "&amp;&amp;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&And;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "&amp;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "!" form="prefix" lspace="0em" rspace="thickmathspace" "&Not;" form="prefix" lspace="0em" rspace="thickmathspace" "&Exists;" form="prefix" lspace="0em" rspace="thickmathspace" "&ForAll;" form="prefix" lspace="0em" rspace="thickmathspace" "&NotExists;" form="prefix" lspace="0em" rspace="thickmathspace" "&Element;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotElement;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotReverseElement;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSquareSubset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSquareSubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSquareSuperset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSquareSupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSubset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSuperset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&ReverseElement;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SquareSubset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SquareSubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SquareSuperset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SquareSupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Subset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Superset;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&DoubleLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DoubleLeftRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DoubleRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownLeftRightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownLeftTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownLeftVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownLeftVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownRightTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownRightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&DownRightVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftArrowBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftArrowRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftRightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftTeeArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LeftVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LowerLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&LowerRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightArrowBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightArrowLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightTeeArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&ShortLeftArrow;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&ShortRightArrow;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&UpperLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&UpperRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&lt;" form="infix" lspace="thickmathspace" rspace="thickmathspace" ">" form="infix" lspace="thickmathspace" rspace="thickmathspace" "!=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "==" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&lt;=" form="infix" lspace="thickmathspace" rspace="thickmathspace" ">=" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Congruent;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&CupCap;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&DotEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&DoubleVerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Equal;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&EqualTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Equilibrium;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&GreaterEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&GreaterEqualLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&GreaterFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&GreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&GreaterLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&GreaterSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&GreaterTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&HumpDownHump;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&HumpEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LeftTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LeftTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LeftTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&le;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LessEqualGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LessFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LessGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LessSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&LessTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NestedGreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NestedLessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotCongruent;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotCupCap;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotDoubleVerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotEqualTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreaterEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreaterFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreaterLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreaterSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotGreaterTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotHumpDownHump;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotHumpEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLeftTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLeftTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLeftTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLessEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLessFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLessGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLessSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotLessTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotNestedGreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotNestedLessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotPrecedes;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotPrecedesEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotPrecedesSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotPrecedesTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotRightTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotRightTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotRightTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSucceeds;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSucceedsEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSucceedsSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotSucceedsTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotTildeEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotTildeFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotTildeTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&NotVerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Precedes;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&PrecedesEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&PrecedesSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&PrecedesTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Proportion;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Proportional;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&ReverseEquilibrium;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace" "&RightTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&RightTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&RightTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Succeeds;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SucceedsEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SucceedsSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SucceedsTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&Tilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&TildeEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&TildeFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&TildeTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&UpTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&VerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace" "&SquareUnion;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "&Union;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "&UnionPlus;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "-" form="infix" lspace="mediummathspace" rspace="mediummathspace" "+" form="infix" lspace="mediummathspace" rspace="mediummathspace" "&Intersection;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "&MinusPlus;" form="infix" lspace="mediummathspace" rspace="mediummathspace" "&PlusMinus;" form="infix" lspace="mediummathspace" rspace="mediummathspace" "&SquareIntersection;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace" "&Vee;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&CircleMinus;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace" "&CirclePlus;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace" "&Sum;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&Union;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&UnionPlus;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "lim" form="prefix" movablelimits="true" lspace="0em" rspace="thinmathspace" "max" form="prefix" movablelimits="true" lspace="0em" rspace="thinmathspace" "min" form="prefix" movablelimits="true" lspace="0em" rspace="thinmathspace" "&CircleMinus;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&CirclePlus;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&ClockwiseContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em" "&ContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em" "&CounterClockwiseContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em" "&DoubleContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em" "&Integral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em" "&Cup;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Cap;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&VerticalTilde;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Wedge;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&CircleTimes;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace" "&Coproduct;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&Product;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&Intersection;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace" "&Coproduct;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Star;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&CircleDot;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace" "*" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&InvisibleTimes;" form="infix" lspace="0em" rspace="0em" "&CenterDot;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&CircleTimes;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Vee;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Wedge;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Diamond;" form="infix" lspace="thinmathspace" rspace="thinmathspace" "&Backslash;" form="infix" stretchy="true" lspace="thinmathspace" rspace="thinmathspace" "/" form="infix" stretchy="true" lspace="thinmathspace" rspace="thinmathspace" "-" form="prefix" lspace="0em" rspace="veryverythinmathspace" "+" form="prefix" lspace="0em" rspace="veryverythinmathspace" "&MinusPlus;" form="prefix" lspace="0em" rspace="veryverythinmathspace" "&PlusMinus;" form="prefix" lspace="0em" rspace="veryverythinmathspace" "." form="infix" lspace="0em" rspace="0em" "&Cross;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "**" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&CircleDot;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&SmallCircle;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&Square;" form="prefix" lspace="0em" rspace="verythinmathspace" "&Del;" form="prefix" lspace="0em" rspace="verythinmathspace" "&PartialD;" form="prefix" lspace="0em" rspace="verythinmathspace" "&CapitalDifferentialD;" form="prefix" lspace="0em" rspace="verythinmathspace" "&DifferentialD;" form="prefix" lspace="0em" rspace="verythinmathspace" "&Sqrt;" form="prefix" stretchy="true" lspace="0em" rspace="verythinmathspace" "&DoubleDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DoubleLongLeftArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DoubleLongLeftRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DoubleLongRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DoubleUpArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DoubleUpDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DownArrowBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DownArrowUpArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&DownTeeArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftDownTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftDownVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftUpDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftUpTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftUpVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LeftUpVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LongLeftArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LongLeftRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&LongRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&ReverseUpEquilibrium;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightDownTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightDownVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightUpDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightUpTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightUpVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&RightUpVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&ShortDownArrow;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&ShortUpArrow;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&UpArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&UpArrowBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&UpArrowDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&UpDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&UpEquilibrium;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "&UpTeeArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace" "^" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&lt;>" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "'" form="postfix" lspace="verythinmathspace" rspace="0em" "!" form="postfix" lspace="verythinmathspace" rspace="0em" "!!" form="postfix" lspace="verythinmathspace" rspace="0em" "~" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "@" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "--" form="postfix" lspace="verythinmathspace" rspace="0em" "--" form="prefix" lspace="0em" rspace="verythinmathspace" "++" form="postfix" lspace="verythinmathspace" rspace="0em" "++" form="prefix" lspace="0em" rspace="verythinmathspace" "&ApplyFunction;" form="infix" lspace="0em" rspace="0em" "?" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "_" form="infix" lspace="verythinmathspace" rspace="verythinmathspace" "&Breve;" form="postfix" accent="true" lspace="0em" rspace="0em" "&Cedilla;" form="postfix" accent="true" lspace="0em" rspace="0em" "&DiacriticalGrave;" form="postfix" accent="true" lspace="0em" rspace="0em" "&DiacriticalDot;" form="postfix" accent="true" lspace="0em" rspace="0em" "&DiacriticalDoubleAcute;" form="postfix" accent="true" lspace="0em" rspace="0em" "&DiacriticalLeftArrow;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DiacriticalLeftRightArrow;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DiacriticalLeftRightVector;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DiacriticalLeftVector;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DiacriticalAcute;" form="postfix" accent="true" lspace="0em" rspace="0em" "&DiacriticalRightArrow;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DiacriticalRightVector;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DiacriticalTilde;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&DoubleDot;" form="postfix" accent="true" lspace="0em" rspace="0em" "&DownBreve;" form="postfix" accent="true" lspace="0em" rspace="0em" "&Hacek;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&Hat;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&OverBar;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&OverBrace;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&OverBracket;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&OverParenthesis;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&TripleDot;" form="postfix" accent="true" lspace="0em" rspace="0em" "&UnderBar;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&UnderBrace;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&UnderBracket;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" "&UnderParenthesis;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em" '''
data = '\n\n"(" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n")" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"[" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"]" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"{" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"}" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n \n"&CloseCurlyDoubleQuote;" form="postfix" fence="true" lspace="0em" rspace="0em"\n"&CloseCurlyQuote;" form="postfix" fence="true" lspace="0em" rspace="0em"\n"&LeftAngleBracket;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&LeftBracketingBar;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&LeftCeiling;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&LeftDoubleBracket;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&LeftDoubleBracketingBar;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&LeftFloor;" form="prefix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&OpenCurlyDoubleQuote;" form="prefix" fence="true" lspace="0em" rspace="0em"\n"&OpenCurlyQuote;" form="prefix" fence="true" lspace="0em" rspace="0em"\n"&RightAngleBracket;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&RightBracketingBar;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&RightCeiling;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&RightDoubleBracket;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&RightDoubleBracketingBar;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&RightFloor;" form="postfix" fence="true" stretchy="true" lspace="0em" rspace="0em"\n"&LeftSkeleton;" form="prefix" fence="true" lspace="0em" rspace="0em"\n"&RightSkeleton;" form="postfix" fence="true" lspace="0em" rspace="0em"\n \n"&InvisibleComma;" form="infix" separator="true" lspace="0em" rspace="0em"\n \n"," form="infix" separator="true" lspace="0em" rspace="verythickmathspace"\n \n"&HorizontalLine;" form="infix" stretchy="true" minsize="0" lspace="0em" rspace="0em"\n"&VerticalLine;" form="infix" stretchy="true" minsize="0" lspace="0em" rspace="0em"\n \n";" form="infix" separator="true" lspace="0em" rspace="thickmathspace"\n";" form="postfix" separator="true" lspace="0em" rspace="0em"\n \n":=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Assign;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&Because;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Therefore;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&VerticalSeparator;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n \n"//" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&Colon;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&amp;" form="prefix" lspace="0em" rspace="thickmathspace"\n"&amp;" form="postfix" lspace="thickmathspace" rspace="0em"\n \n"*=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"-=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"+=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"/=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"->" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n":" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n".." form="postfix" lspace="mediummathspace" rspace="0em"\n"..." form="postfix" lspace="mediummathspace" rspace="0em"\n \n"&SuchThat;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&DoubleLeftTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&DoubleRightTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&DownTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&RightTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&Implies;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RoundImplies;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"|" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"||" form="infix" lspace="mediummathspace" rspace="mediummathspace"\n"&Or;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n \n"&amp;&amp;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&And;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n \n"&amp;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"!" form="prefix" lspace="0em" rspace="thickmathspace"\n"&Not;" form="prefix" lspace="0em" rspace="thickmathspace"\n \n"&Exists;" form="prefix" lspace="0em" rspace="thickmathspace"\n"&ForAll;" form="prefix" lspace="0em" rspace="thickmathspace"\n"&NotExists;" form="prefix" lspace="0em" rspace="thickmathspace"\n \n"&Element;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotElement;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotReverseElement;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSquareSubset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSquareSubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSquareSuperset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSquareSupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSubset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSuperset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&ReverseElement;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SquareSubset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SquareSubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SquareSuperset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SquareSupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Subset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SubsetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Superset;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SupersetEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&DoubleLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DoubleLeftRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DoubleRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownLeftRightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownLeftTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownLeftVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownLeftVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownRightTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownRightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&DownRightVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftArrowBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftArrowRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftRightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftTeeArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LowerLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&LowerRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightArrowBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightArrowLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightTeeArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightTeeVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightVector;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightVectorBar;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&ShortLeftArrow;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&ShortRightArrow;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&UpperLeftArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&UpperRightArrow;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n \n"=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&lt;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n">" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"!=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"==" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&lt;=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n">=" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Congruent;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&CupCap;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&DotEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&DoubleVerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Equal;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&EqualTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Equilibrium;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterEqualLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&GreaterTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&HumpDownHump;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&HumpEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LeftTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&le;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LessEqualGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LessFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LessGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LessSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&LessTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NestedGreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NestedLessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotCongruent;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotCupCap;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotDoubleVerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotEqualTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreaterEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreaterFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreaterLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreaterSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotGreaterTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotHumpDownHump;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotHumpEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLeftTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLeftTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLeftTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLessEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLessFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLessGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLessSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotLessTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotNestedGreaterGreater;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotNestedLessLess;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotPrecedes;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotPrecedesEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotPrecedesSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotPrecedesTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotRightTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotRightTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotRightTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSucceeds;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSucceedsEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSucceedsSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotSucceedsTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotTildeEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotTildeFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotTildeTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&NotVerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Precedes;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&PrecedesEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&PrecedesSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&PrecedesTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Proportion;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Proportional;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&ReverseEquilibrium;" form="infix" stretchy="true" lspace="thickmathspace" rspace="thickmathspace"\n"&RightTriangle;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&RightTriangleBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&RightTriangleEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Succeeds;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SucceedsEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SucceedsSlantEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&SucceedsTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&Tilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&TildeEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&TildeFullEqual;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&TildeTilde;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&UpTee;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n"&VerticalBar;" form="infix" lspace="thickmathspace" rspace="thickmathspace"\n \n"&SquareUnion;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n"&Union;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n"&UnionPlus;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n \n"-" form="infix" lspace="mediummathspace" rspace="mediummathspace"\n"+" form="infix" lspace="mediummathspace" rspace="mediummathspace"\n"&Intersection;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n"&MinusPlus;" form="infix" lspace="mediummathspace" rspace="mediummathspace"\n"&PlusMinus;" form="infix" lspace="mediummathspace" rspace="mediummathspace"\n"&SquareIntersection;" form="infix" stretchy="true" lspace="mediummathspace" rspace="mediummathspace"\n \n"&Vee;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"&CircleMinus;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace"\n"&CirclePlus;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace"\n"&Sum;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"&Union;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"&UnionPlus;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"lim" form="prefix" movablelimits="true" lspace="0em" rspace="thinmathspace"\n"max" form="prefix" movablelimits="true" lspace="0em" rspace="thinmathspace"\n"min" form="prefix" movablelimits="true" lspace="0em" rspace="thinmathspace"\n \n"&CircleMinus;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n"&CirclePlus;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&ClockwiseContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em"\n"&ContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em"\n"&CounterClockwiseContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em"\n"&DoubleContourIntegral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em"\n"&Integral;" form="prefix" largeop="true" stretchy="true" lspace="0em" rspace="0em"\n \n"&Cup;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Cap;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&VerticalTilde;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Wedge;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"&CircleTimes;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace"\n"&Coproduct;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"&Product;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n"&Intersection;" form="prefix" largeop="true" movablelimits="true" stretchy="true" lspace="0em" rspace="thinmathspace"\n \n"&Coproduct;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Star;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&CircleDot;" form="prefix" largeop="true" movablelimits="true" lspace="0em" rspace="thinmathspace"\n \n"*" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n"&InvisibleTimes;" form="infix" lspace="0em" rspace="0em"\n \n"&CenterDot;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&CircleTimes;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Vee;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Wedge;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Diamond;" form="infix" lspace="thinmathspace" rspace="thinmathspace"\n \n"&Backslash;" form="infix" stretchy="true" lspace="thinmathspace" rspace="thinmathspace"\n \n"/" form="infix" stretchy="true" lspace="thinmathspace" rspace="thinmathspace"\n \n"-" form="prefix" lspace="0em" rspace="veryverythinmathspace"\n"+" form="prefix" lspace="0em" rspace="veryverythinmathspace"\n"&MinusPlus;" form="prefix" lspace="0em" rspace="veryverythinmathspace"\n"&PlusMinus;" form="prefix" lspace="0em" rspace="veryverythinmathspace"\n \n"." form="infix" lspace="0em" rspace="0em"\n \n"&Cross;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"**" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"&CircleDot;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"&SmallCircle;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"&Square;" form="prefix" lspace="0em" rspace="verythinmathspace"\n \n"&Del;" form="prefix" lspace="0em" rspace="verythinmathspace"\n"&PartialD;" form="prefix" lspace="0em" rspace="verythinmathspace"\n \n"&CapitalDifferentialD;" form="prefix" lspace="0em" rspace="verythinmathspace"\n"&DifferentialD;" form="prefix" lspace="0em" rspace="verythinmathspace"\n \n"&Sqrt;" form="prefix" stretchy="true" lspace="0em" rspace="verythinmathspace"\n \n"&DoubleDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DoubleLongLeftArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DoubleLongLeftRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DoubleLongRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DoubleUpArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DoubleUpDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DownArrowBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DownArrowUpArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&DownTeeArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftDownTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftDownVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftUpDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftUpTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftUpVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LeftUpVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LongLeftArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LongLeftRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&LongRightArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&ReverseUpEquilibrium;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightDownTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightDownVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightUpDownVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightUpTeeVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightUpVector;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&RightUpVectorBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&ShortDownArrow;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n"&ShortUpArrow;" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n"&UpArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&UpArrowBar;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&UpArrowDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&UpDownArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&UpEquilibrium;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n"&UpTeeArrow;" form="infix" stretchy="true" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"^" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"&lt;>" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"\'" form="postfix" lspace="verythinmathspace" rspace="0em"\n \n"!" form="postfix" lspace="verythinmathspace" rspace="0em"\n"!!" form="postfix" lspace="verythinmathspace" rspace="0em"\n \n"~" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"@" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"--" form="postfix" lspace="verythinmathspace" rspace="0em"\n"--" form="prefix" lspace="0em" rspace="verythinmathspace"\n"++" form="postfix" lspace="verythinmathspace" rspace="0em"\n"++" form="prefix" lspace="0em" rspace="verythinmathspace"\n \n"&ApplyFunction;" form="infix" lspace="0em" rspace="0em"\n \n"?" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"_" form="infix" lspace="verythinmathspace" rspace="verythinmathspace"\n \n"&Breve;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&Cedilla;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&DiacriticalGrave;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&DiacriticalDot;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&DiacriticalDoubleAcute;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&DiacriticalLeftArrow;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DiacriticalLeftRightArrow;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DiacriticalLeftRightVector;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DiacriticalLeftVector;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DiacriticalAcute;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&DiacriticalRightArrow;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DiacriticalRightVector;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DiacriticalTilde;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&DoubleDot;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&DownBreve;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&Hacek;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&Hat;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&OverBar;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&OverBrace;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&OverBracket;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&OverParenthesis;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&TripleDot;" form="postfix" accent="true" lspace="0em" rspace="0em"\n"&UnderBar;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&UnderBrace;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&UnderBracket;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n"&UnderParenthesis;" form="postfix" accent="true" stretchy="true" lspace="0em" rspace="0em"\n\n'
# -*- coding: utf-8 -*- # User role USER = 0 ADMIN = 1 USER_ROLE = { ADMIN: 'admin', USER: 'user', } # User status INACTIVE = 0 ACTIVE = 1 USER_STATUS = { INACTIVE: 'inactive', ACTIVE: 'active', } # Project progress PR_CHALLENGE = -1 PR_NEW = 0 PR_RESEARCHED = 10 PR_SKETCHED = 20 PR_PROTOTYPED = 30 PR_LAUNCHED = 40 PR_LIVE = 50 PROJECT_PROGRESS = { PR_CHALLENGE: 'This is an idea or challenge description', PR_NEW: 'A team has formed and started a project', PR_RESEARCHED: 'Research has been done to define the scope', PR_SKETCHED: 'Initial designs have been sketched and shared', PR_PROTOTYPED: 'A prototype of the idea has been developed', PR_LAUNCHED: 'The prototype has been deployed and presented', PR_LIVE: 'This project is live and available to the public', } PROJECT_PROGRESS_PHASE = { PR_NEW: 'Researching', PR_RESEARCHED: 'Sketching', PR_SKETCHED: 'Prototyping', PR_PROTOTYPED: 'Launching', PR_LAUNCHED: 'Promoting', PR_LIVE: 'Supporting', PR_CHALLENGE: 'Challenge', } def projectProgressList(All=True): if not All: return [(PR_CHALLENGE, PROJECT_PROGRESS[PR_CHALLENGE])] pl = [(g, PROJECT_PROGRESS[g]) for g in PROJECT_PROGRESS] return sorted(pl, key=lambda x: x[0])
user = 0 admin = 1 user_role = {ADMIN: 'admin', USER: 'user'} inactive = 0 active = 1 user_status = {INACTIVE: 'inactive', ACTIVE: 'active'} pr_challenge = -1 pr_new = 0 pr_researched = 10 pr_sketched = 20 pr_prototyped = 30 pr_launched = 40 pr_live = 50 project_progress = {PR_CHALLENGE: 'This is an idea or challenge description', PR_NEW: 'A team has formed and started a project', PR_RESEARCHED: 'Research has been done to define the scope', PR_SKETCHED: 'Initial designs have been sketched and shared', PR_PROTOTYPED: 'A prototype of the idea has been developed', PR_LAUNCHED: 'The prototype has been deployed and presented', PR_LIVE: 'This project is live and available to the public'} project_progress_phase = {PR_NEW: 'Researching', PR_RESEARCHED: 'Sketching', PR_SKETCHED: 'Prototyping', PR_PROTOTYPED: 'Launching', PR_LAUNCHED: 'Promoting', PR_LIVE: 'Supporting', PR_CHALLENGE: 'Challenge'} def project_progress_list(All=True): if not All: return [(PR_CHALLENGE, PROJECT_PROGRESS[PR_CHALLENGE])] pl = [(g, PROJECT_PROGRESS[g]) for g in PROJECT_PROGRESS] return sorted(pl, key=lambda x: x[0])
q = int(input()) e = str(input()).split() indq = 0 mini = int(e[0]) for i in range(1, len(e)): if int(e[i]) > mini: mini = int(e[i]) elif int(e[i]) < mini: indq = i + 1 break print(indq)
q = int(input()) e = str(input()).split() indq = 0 mini = int(e[0]) for i in range(1, len(e)): if int(e[i]) > mini: mini = int(e[i]) elif int(e[i]) < mini: indq = i + 1 break print(indq)
__version__ = "1.8.0" __all__ = ["epsonprinter","testpage"]
__version__ = '1.8.0' __all__ = ['epsonprinter', 'testpage']
class RequestExeption(Exception): def __init__(self, request): self.request = request def badRequest(self): self.message = "bad request url : %s" % self.request.url return self def __str__(self): return self.message
class Requestexeption(Exception): def __init__(self, request): self.request = request def bad_request(self): self.message = 'bad request url : %s' % self.request.url return self def __str__(self): return self.message
class Solution: def dieSimulator(self, n: int, rollMax: List[int]) -> int: # dp[i][j]: how many choices we have with i dices and the last face is j # again dp[i][j] means the number of distinct sequences that can be obtained when rolling i times and ending with j MOD = 10 ** 9 + 7 dp = [[0] * 7 for i in range(n + 1)] # dp[1][i]: roll once, end with i => only one possible sequence. so dp[1][i] = 1 for i in range(6): dp[1][i] = 1 # total dp[1][6] = 6 for i in range(2, n + 1): total = 0 for j in range(6): # if there is no constrains, the total sequences ending with j should be the total sequences from previous rolling dp[i][j] = dp[i - 1][6] # for axx1, only 111 is not allowed, so we need to remove 1 sequence from previous sum if i - rollMax[j] == 1: dp[i][j] -= 1 # for axx1, we need to remove the number of a11(211, 311, 411...) if i - rollMax[j] >= 2: reduction = dp[i - rollMax[j] - 1][6] - dp[i - rollMax[j] - 1][j] dp[i][j] = ((dp[i][j] - reduction) % MOD + MOD) % MOD total = (total + dp[i][j]) % MOD dp[i][6] = total return dp[n][6]
class Solution: def die_simulator(self, n: int, rollMax: List[int]) -> int: mod = 10 ** 9 + 7 dp = [[0] * 7 for i in range(n + 1)] for i in range(6): dp[1][i] = 1 dp[1][6] = 6 for i in range(2, n + 1): total = 0 for j in range(6): dp[i][j] = dp[i - 1][6] if i - rollMax[j] == 1: dp[i][j] -= 1 if i - rollMax[j] >= 2: reduction = dp[i - rollMax[j] - 1][6] - dp[i - rollMax[j] - 1][j] dp[i][j] = ((dp[i][j] - reduction) % MOD + MOD) % MOD total = (total + dp[i][j]) % MOD dp[i][6] = total return dp[n][6]
n1 = int(input('Digite um valor: ')) n2 = int(input('Digite um valor: ')) n3 = int(input('Digite um valor: ')) menor = n1 maior = n2 if n2 < n1 and n2 < 3: menor = n2 if n3 < n1 and n3 < n2: menor = n3 if n1 > n2 and n1 > n3: maior = n1 if n3 > n1 and n3 > n2: maior = n3 print(f'O maior valor digitado foi {maior}') print(f'O menor valor digitado foi {menor}')
n1 = int(input('Digite um valor: ')) n2 = int(input('Digite um valor: ')) n3 = int(input('Digite um valor: ')) menor = n1 maior = n2 if n2 < n1 and n2 < 3: menor = n2 if n3 < n1 and n3 < n2: menor = n3 if n1 > n2 and n1 > n3: maior = n1 if n3 > n1 and n3 > n2: maior = n3 print(f'O maior valor digitado foi {maior}') print(f'O menor valor digitado foi {menor}')
# a = ['a1','aa1','a2','aaa1'] # a.sort() # print(a) # print(2346/10) def repeat_to_length(string_to_expand, length): return (string_to_expand * (int(length/len(string_to_expand))+1))[:length] for i in range(200): if i > 10: strnum = str(i) tens = int(strnum[0:-1]) last = strnum[-1] print(strnum) print(tens) print(repeat_to_length("a",tens)+last)
def repeat_to_length(string_to_expand, length): return (string_to_expand * (int(length / len(string_to_expand)) + 1))[:length] for i in range(200): if i > 10: strnum = str(i) tens = int(strnum[0:-1]) last = strnum[-1] print(strnum) print(tens) print(repeat_to_length('a', tens) + last)
''' Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s). Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 10^9 + 7. Example 1: Input: s = "10101" Output: 4 Explanation: There are four ways to split s in 3 parts where each part contain the same number of letters '1'. "1|010|1" "1|01|01" "10|10|1" "10|1|01" Example 2: Input: s = "1001" Output: 0 Example 3: Input: s = "0000" Output: 3 Explanation: There are three ways to split s in 3 parts. "0|0|00" "0|00|0" "00|0|0" Example 4: Input: s = "100100010100110" Output: 12 Constraints: 3 <= s.length <= 10^5 s[i] is '0' or '1'. ''' class Solution: def numWays(self, s: str) -> int: length = len(s) one_count = 0 split_range = {} for i in range(length): if s[i] == '1': one_count += 1 if one_count % 3 != 0 or length < 3: return 0 if one_count == 0: return (length - 2) * (length - 1) // 2 % (10 ** 9 + 7) for i in range(1, 3): split_range[i * one_count // 3] = i - 1 one_count = 0 split_index = [[] for i in range(2)] flag = False tmp_count = 0 for i in range(length): if s[i] == '1': one_count += 1 if flag == True: split_index[tmp_count].append(i) flag = False if s[i] == '1' and one_count in split_range: tmp_count = split_range[one_count] split_index[tmp_count].append(i) flag = True output = (split_index[0][1] - split_index[0][0]) * (split_index[1][1] - split_index[1][0]) return output % (10 ** 9 + 7)
""" Given a binary string s (a string consisting only of '0's and '1's), we can split s into 3 non-empty strings s1, s2, s3 (s1+ s2+ s3 = s). Return the number of ways s can be split such that the number of characters '1' is the same in s1, s2, and s3. Since the answer may be too large, return it modulo 10^9 + 7. Example 1: Input: s = "10101" Output: 4 Explanation: There are four ways to split s in 3 parts where each part contain the same number of letters '1'. "1|010|1" "1|01|01" "10|10|1" "10|1|01" Example 2: Input: s = "1001" Output: 0 Example 3: Input: s = "0000" Output: 3 Explanation: There are three ways to split s in 3 parts. "0|0|00" "0|00|0" "00|0|0" Example 4: Input: s = "100100010100110" Output: 12 Constraints: 3 <= s.length <= 10^5 s[i] is '0' or '1'. """ class Solution: def num_ways(self, s: str) -> int: length = len(s) one_count = 0 split_range = {} for i in range(length): if s[i] == '1': one_count += 1 if one_count % 3 != 0 or length < 3: return 0 if one_count == 0: return (length - 2) * (length - 1) // 2 % (10 ** 9 + 7) for i in range(1, 3): split_range[i * one_count // 3] = i - 1 one_count = 0 split_index = [[] for i in range(2)] flag = False tmp_count = 0 for i in range(length): if s[i] == '1': one_count += 1 if flag == True: split_index[tmp_count].append(i) flag = False if s[i] == '1' and one_count in split_range: tmp_count = split_range[one_count] split_index[tmp_count].append(i) flag = True output = (split_index[0][1] - split_index[0][0]) * (split_index[1][1] - split_index[1][0]) return output % (10 ** 9 + 7)
arr = [2,3,5,8,1,8,0,9,11, 23, 51] num = 0 def searchElement(arr, num): n = len(arr) for i in range(n): if arr[i] == num: print("From if block") return i elif arr[n-1] == num: print("From else if block") return n-1 n-=1 print(searchElement(arr, num))
arr = [2, 3, 5, 8, 1, 8, 0, 9, 11, 23, 51] num = 0 def search_element(arr, num): n = len(arr) for i in range(n): if arr[i] == num: print('From if block') return i elif arr[n - 1] == num: print('From else if block') return n - 1 n -= 1 print(search_element(arr, num))
class MidiProtocol: NON_REAL_TIME_HEADER = 0x7E GENERAL_SYSTEM_INFORMATION = 0x06 DEVICE_IDENTITY_REQUEST = 0x01 @staticmethod def device_identify_request(target=0x00): TARGET_ID = target SUB_ID_1 = MidiProtocol.GENERAL_SYSTEM_INFORMATION SUB_ID_2 = MidiProtocol.DEVICE_IDENTITY_REQUEST return [MidiProtocol.NON_REAL_TIME_HEADER, TARGET_ID, SUB_ID_1, SUB_ID_2] @staticmethod def device_identity_reply_decode(data): ''' F0 7E 00 06 02 52 5A 00 00 00 32 2E 31 30 F7 F0 7E Universal Non Real Time Sys Ex header id ID of target device (default = 7F = All devices) 06 Sub ID#1 = General System Information 02 Sub ID#2 = Device Identity message mm Manufacturers System Exclusive ID code. If mm = 00, then the message is extended by 2 bytes to accomodate the additional manufacturers ID code. ff ff Device family code (14 bits, LSB first) dd dd Device family member code (14 bits, LSB first) ss ss ss ss Software revision level (the format is device specific) F7 EOX ''' # 7e id 06 02 mm ff ff dd dd ss ss ss ss EOX return { 'id': data[1], 'manufacturer': data[4], 'device family code': data[5:7], 'device family member code': data[7:11], }
class Midiprotocol: non_real_time_header = 126 general_system_information = 6 device_identity_request = 1 @staticmethod def device_identify_request(target=0): target_id = target sub_id_1 = MidiProtocol.GENERAL_SYSTEM_INFORMATION sub_id_2 = MidiProtocol.DEVICE_IDENTITY_REQUEST return [MidiProtocol.NON_REAL_TIME_HEADER, TARGET_ID, SUB_ID_1, SUB_ID_2] @staticmethod def device_identity_reply_decode(data): """ F0 7E 00 06 02 52 5A 00 00 00 32 2E 31 30 F7 F0 7E Universal Non Real Time Sys Ex header id ID of target device (default = 7F = All devices) 06 Sub ID#1 = General System Information 02 Sub ID#2 = Device Identity message mm Manufacturers System Exclusive ID code. If mm = 00, then the message is extended by 2 bytes to accomodate the additional manufacturers ID code. ff ff Device family code (14 bits, LSB first) dd dd Device family member code (14 bits, LSB first) ss ss ss ss Software revision level (the format is device specific) F7 EOX """ return {'id': data[1], 'manufacturer': data[4], 'device family code': data[5:7], 'device family member code': data[7:11]}
def get_chunks(start, value): for each in range(start, 2000000001, value): yield range(each, each+value) def sum_xor_n(value): mod_value = value&3 if mod_value == 3: return 0 elif mod_value == 2: return value+1 elif mod_value == 1: return 1 elif mod_value == 0: return value else: return None def get_numbers_xor(start, end): start_xor = sum_xor_n(start-1) end_xor = sum_xor_n(end) return start_xor^end_xor def solution(start, length): # Your code here checkpoint = length-1 value = 0 for each_chunk in get_chunks(start, length): if checkpoint < 0: break temp = get_numbers_xor( each_chunk[0], each_chunk[checkpoint]) if checkpoint == 0: value ^= each_chunk[0] else: value ^= temp checkpoint -= 1 return value print(solution(0, 3)) print(solution(17, 4))
def get_chunks(start, value): for each in range(start, 2000000001, value): yield range(each, each + value) def sum_xor_n(value): mod_value = value & 3 if mod_value == 3: return 0 elif mod_value == 2: return value + 1 elif mod_value == 1: return 1 elif mod_value == 0: return value else: return None def get_numbers_xor(start, end): start_xor = sum_xor_n(start - 1) end_xor = sum_xor_n(end) return start_xor ^ end_xor def solution(start, length): checkpoint = length - 1 value = 0 for each_chunk in get_chunks(start, length): if checkpoint < 0: break temp = get_numbers_xor(each_chunk[0], each_chunk[checkpoint]) if checkpoint == 0: value ^= each_chunk[0] else: value ^= temp checkpoint -= 1 return value print(solution(0, 3)) print(solution(17, 4))
#! /usr/bin/python # -*- coding: utf-8 -*- VER_MAIN = '3' VER_SUB = '5' BUILD_SN = '160809'
ver_main = '3' ver_sub = '5' build_sn = '160809'
#4-9 Cube Comprehension numberscube = [value ** 3 for value in range(1, 11)] print(numberscube)
numberscube = [value ** 3 for value in range(1, 11)] print(numberscube)
#coding:utf-8 while True: l_c = input().split() x1 = int(l_c[0]) y1 = int(l_c[1]) x2 = int(l_c[2]) y2 = int(l_c[3]) if x1+x2+y1+y2 == 0: break else: if (x1 == x2 and y1 == y2): print(0) elif ((x2-x1) == -(y2-y1) or -(x2-x1) == -(y2-y1)): print(1) elif -(x2-x1) == (y2-y1) or (x2-x1) == (y2-y1): print(1) elif (x1 == x2 or y1 == y2): print(1) else: print(2)
while True: l_c = input().split() x1 = int(l_c[0]) y1 = int(l_c[1]) x2 = int(l_c[2]) y2 = int(l_c[3]) if x1 + x2 + y1 + y2 == 0: break elif x1 == x2 and y1 == y2: print(0) elif x2 - x1 == -(y2 - y1) or -(x2 - x1) == -(y2 - y1): print(1) elif -(x2 - x1) == y2 - y1 or x2 - x1 == y2 - y1: print(1) elif x1 == x2 or y1 == y2: print(1) else: print(2)
# Definition for a binary tree node. # class Node(object): # def __init__(self, val=" ", left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def expTree(self, s: str) -> 'Node': def process_op(): op = op_stack.pop() rhs = val_stack.pop() lhs = val_stack.pop() node = Node(val=op, left=lhs, right=rhs) val_stack.append(node) def priority(op): if op in '+-': return 1 elif op in '*/': return 2 else: return -1 val_stack = [] op_stack = [] for ch in s: if ch.isdigit(): val_stack.append(Node(ch)) else: if ch == '(': op_stack.append('(') elif ch == ')': while op_stack[-1] != '(': process_op() op_stack.pop() else: cur_op = ch while op_stack and priority(op_stack[-1]) >= priority(cur_op): process_op() op_stack.append(cur_op) while op_stack: process_op() return val_stack[0]
class Solution: def exp_tree(self, s: str) -> 'Node': def process_op(): op = op_stack.pop() rhs = val_stack.pop() lhs = val_stack.pop() node = node(val=op, left=lhs, right=rhs) val_stack.append(node) def priority(op): if op in '+-': return 1 elif op in '*/': return 2 else: return -1 val_stack = [] op_stack = [] for ch in s: if ch.isdigit(): val_stack.append(node(ch)) elif ch == '(': op_stack.append('(') elif ch == ')': while op_stack[-1] != '(': process_op() op_stack.pop() else: cur_op = ch while op_stack and priority(op_stack[-1]) >= priority(cur_op): process_op() op_stack.append(cur_op) while op_stack: process_op() return val_stack[0]
# Practice problem 1 for chapter 4 # Function that takes an array and returns a comma-separated string def make_string(array): answer_string = "" for i in array: if array.index(i) == 0: answer_string += str(i) # Last index word finishes with "and" before it elif array.index(i) == len(array) - 1: answer_string += ", and " + str(i) else: answer_string += ", " + str(i) print(answer_string) # Test from book my_arr = ["apple", "bananas", "tofu", "cats"] answer = make_string(my_arr)
def make_string(array): answer_string = '' for i in array: if array.index(i) == 0: answer_string += str(i) elif array.index(i) == len(array) - 1: answer_string += ', and ' + str(i) else: answer_string += ', ' + str(i) print(answer_string) my_arr = ['apple', 'bananas', 'tofu', 'cats'] answer = make_string(my_arr)
class RCListener: def __iter__(self): raise NotImplementedError() class Source: def listener(self, *args, **kwargs): raise NotImplementedError() def query(self, start, end, *args, types=None, **kwargs): raise NotImplementedError()
class Rclistener: def __iter__(self): raise not_implemented_error() class Source: def listener(self, *args, **kwargs): raise not_implemented_error() def query(self, start, end, *args, types=None, **kwargs): raise not_implemented_error()
for _ in range(int(input())): n,q = [int(x) for x in input().split()] a = [int(x) for x in input().split()] for _ in range(q): k = int(input()) sum = 0 # if(k == 0):k = 1 for i in range(0,n,k + 1): sum += a[i] print(sum)
for _ in range(int(input())): (n, q) = [int(x) for x in input().split()] a = [int(x) for x in input().split()] for _ in range(q): k = int(input()) sum = 0 for i in range(0, n, k + 1): sum += a[i] print(sum)
def front_back(s): if len(s) > 1: string = [s[-1]] string.extend([i for i in s[1:-1]]) string.append(s[0]) return "".join(string) else: return s
def front_back(s): if len(s) > 1: string = [s[-1]] string.extend([i for i in s[1:-1]]) string.append(s[0]) return ''.join(string) else: return s
# twitter api data (replace yours here given are placeholder) # if you have not yet, go for applying at: https://developer.twitter.com/ TWITTER_KEY="" TWITTER_SECRET="" TWITTER_APP_KEY="" TWITTER_APP_SECRET="" with open("twitter_keys.txt") as f: for line in f: tups=line.strip().split("=") if tups[0] == "TWITTER_KEY": TWITTER_KEY=tups[1] elif tups[0] == "TWITTER_SECRET": TWITTER_SECRET=tups[1] elif tups[0] == "TWITTER_APP_KEY": TWITTER_APP_KEY=tups[1] elif tups[0] == "TWITTER_APP_SECRET": TWITTER_APP_SECRET=tups[1]
twitter_key = '' twitter_secret = '' twitter_app_key = '' twitter_app_secret = '' with open('twitter_keys.txt') as f: for line in f: tups = line.strip().split('=') if tups[0] == 'TWITTER_KEY': twitter_key = tups[1] elif tups[0] == 'TWITTER_SECRET': twitter_secret = tups[1] elif tups[0] == 'TWITTER_APP_KEY': twitter_app_key = tups[1] elif tups[0] == 'TWITTER_APP_SECRET': twitter_app_secret = tups[1]
def maximum_subarray_1(coll): n = len(coll) max_result = 0 for i in xrange(1, n+1): for j in range(n-i+1): result = sum(coll[j: j+i]) if max_result < result: max_result = result return max_result def maximum_subarray_2(coll): n = len(coll) max_result = 0 for i in xrange(n): result = 0 for j in xrange(i, n): result += coll[j] if max_result < result: max_result = result return max_result def maximum_subarray_3(coll): if len(coll) == 0: return 0 # return maximum of (1) maximum subarray of array excluding last one, and # (2) maximum subarray including the final element n = len(coll) result = 0 sums_with_final = [] for i in xrange(n-1, -1, -1): result += coll[i] sums_with_final.append(result) return max([maximum_subarray_3(coll[:-1])] + sums_with_final) def maximum_subarray(coll): return maximum_subarray_3(coll)
def maximum_subarray_1(coll): n = len(coll) max_result = 0 for i in xrange(1, n + 1): for j in range(n - i + 1): result = sum(coll[j:j + i]) if max_result < result: max_result = result return max_result def maximum_subarray_2(coll): n = len(coll) max_result = 0 for i in xrange(n): result = 0 for j in xrange(i, n): result += coll[j] if max_result < result: max_result = result return max_result def maximum_subarray_3(coll): if len(coll) == 0: return 0 n = len(coll) result = 0 sums_with_final = [] for i in xrange(n - 1, -1, -1): result += coll[i] sums_with_final.append(result) return max([maximum_subarray_3(coll[:-1])] + sums_with_final) def maximum_subarray(coll): return maximum_subarray_3(coll)
lines = [] for i in xrange(3): line = Line() line.xValues = xrange(5) line.yValues = [(i+1 / 2.0) * pow(x, i+1) for x in line.xValues] line.label = "Line %d" % (i + 1) lines.append(line) plot = Plot() plot.add(lines[0]) inset = Plot() inset.add(lines[1]) inset.hideTickLabels() inset.title = ("Inset in Yo Inset\n" "So You Can Inset\n" "While You Inset") insideInset = Plot() insideInset.hideTickLabels() insideInset.add(lines[2]) inset.addInset(insideInset, width=0.4, height=0.3, location="upper left") plot.addInset(inset, width=0.4, height=0.4, location="lower right") plot.save("inset.png")
lines = [] for i in xrange(3): line = line() line.xValues = xrange(5) line.yValues = [(i + 1 / 2.0) * pow(x, i + 1) for x in line.xValues] line.label = 'Line %d' % (i + 1) lines.append(line) plot = plot() plot.add(lines[0]) inset = plot() inset.add(lines[1]) inset.hideTickLabels() inset.title = 'Inset in Yo Inset\nSo You Can Inset\nWhile You Inset' inside_inset = plot() insideInset.hideTickLabels() insideInset.add(lines[2]) inset.addInset(insideInset, width=0.4, height=0.3, location='upper left') plot.addInset(inset, width=0.4, height=0.4, location='lower right') plot.save('inset.png')
file = open('csv_data.txt', 'r') lines = file.readlines() file.close() lines = [line.strip() for line in lines[1:]] for line in lines: person_data = line.split(',') name = person_data[0].title() age = person_data[1] university = person_data[2].title() degree = person_data[3].capitalize() print(f'{name} is {age}, studying {degree} at {university}.')
file = open('csv_data.txt', 'r') lines = file.readlines() file.close() lines = [line.strip() for line in lines[1:]] for line in lines: person_data = line.split(',') name = person_data[0].title() age = person_data[1] university = person_data[2].title() degree = person_data[3].capitalize() print(f'{name} is {age}, studying {degree} at {university}.')
def media(n1, n2): m = (n1 + n2)/2 return m print(media(n1=10, n2=5)) def juros(preco, juros): res = preco * (1 + juros/100) return res print(juros(preco=10, juros=50))
def media(n1, n2): m = (n1 + n2) / 2 return m print(media(n1=10, n2=5)) def juros(preco, juros): res = preco * (1 + juros / 100) return res print(juros(preco=10, juros=50))
def test_session_interruption(ui, ui_interrupted_session): ui_interrupted_session.click() interrupted_test = ui.driver.find_element_by_css_selector('.item.test') css_classes = interrupted_test.get_attribute('class') assert 'success' not in css_classes assert 'fail' not in css_classes interrupted_test.click() assert 'errors' not in ui.driver.current_url [link] = ui.driver.find_elements_by_xpath("//*[contains(text(), 'Interruptions')]") link.click() error_boxes = ui.driver.find_elements_by_class_name('error-box') assert len(error_boxes) == 1 [err] = error_boxes assert 'interruption' in err.get_attribute('class')
def test_session_interruption(ui, ui_interrupted_session): ui_interrupted_session.click() interrupted_test = ui.driver.find_element_by_css_selector('.item.test') css_classes = interrupted_test.get_attribute('class') assert 'success' not in css_classes assert 'fail' not in css_classes interrupted_test.click() assert 'errors' not in ui.driver.current_url [link] = ui.driver.find_elements_by_xpath("//*[contains(text(), 'Interruptions')]") link.click() error_boxes = ui.driver.find_elements_by_class_name('error-box') assert len(error_boxes) == 1 [err] = error_boxes assert 'interruption' in err.get_attribute('class')
# Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sortedArrayToBST(self, nums): return self.recurse(nums,0,len(nums)-1) def recurse(self,nums,start,end): if end<start: return None mid=int(start+(end-start)/2) root=TreeNode(val=nums[mid],left=self.recurse(nums,start,mid-1),right=self.recurse(nums,mid+1,end)) return root def forward(self,root): if not root: return print(root.val) self.forward(root.left) self.forward(root.right) if __name__ == '__main__': sol=Solution() nums = [-10, -3, 0, 5, 9] root=sol.sortedArrayToBST(nums) sol.forward(root)
class Treenode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def sorted_array_to_bst(self, nums): return self.recurse(nums, 0, len(nums) - 1) def recurse(self, nums, start, end): if end < start: return None mid = int(start + (end - start) / 2) root = tree_node(val=nums[mid], left=self.recurse(nums, start, mid - 1), right=self.recurse(nums, mid + 1, end)) return root def forward(self, root): if not root: return print(root.val) self.forward(root.left) self.forward(root.right) if __name__ == '__main__': sol = solution() nums = [-10, -3, 0, 5, 9] root = sol.sortedArrayToBST(nums) sol.forward(root)
Vivaldi = Goalkeeper('Juan Vivaldi', 83, 77, 72, 82) Peillat = Outfield_Player('Gonzalo Peillat', 'DF', 70, 89, 78, 73, 79, 67) Ortiz = Outfield_Player('Ignacio Ortiz', 'MF', 79, 78, 77, 80, 75, 81) Rey = Outfield_Player('Matias Rey', 'MF', 81, 77, 74, 72, 87, 72) Vila = Outfield_Player('Lucas Vila', 'FW', 87, 50, 80, 82, 74, 85) ARG = Team('Argentina', Vivaldi, Peillat, Ortiz, Rey, Vila)
vivaldi = goalkeeper('Juan Vivaldi', 83, 77, 72, 82) peillat = outfield__player('Gonzalo Peillat', 'DF', 70, 89, 78, 73, 79, 67) ortiz = outfield__player('Ignacio Ortiz', 'MF', 79, 78, 77, 80, 75, 81) rey = outfield__player('Matias Rey', 'MF', 81, 77, 74, 72, 87, 72) vila = outfield__player('Lucas Vila', 'FW', 87, 50, 80, 82, 74, 85) arg = team('Argentina', Vivaldi, Peillat, Ortiz, Rey, Vila)
def factorial(x): '''calculo de factorial con una funcion recursiva''' if x == 1: return 1 else: return (x * factorial(x-1)) num = 928 print('el factorial de: ', num ,'is ', factorial(num))
def factorial(x): """calculo de factorial con una funcion recursiva""" if x == 1: return 1 else: return x * factorial(x - 1) num = 928 print('el factorial de: ', num, 'is ', factorial(num))
# prompting user to enter the file name fname = input('Enter file name: ') d = dict() # catching exceptions try: fhand = open(fname) except: print('File does not exist') exit() # reading the lines in the file for line in fhand: words = line.split() # we only want email addresses if len(words) < 2 or words[0] != 'From': continue else: d[words[1]] = d.get(words[1], 0) + 1 print(d)
fname = input('Enter file name: ') d = dict() try: fhand = open(fname) except: print('File does not exist') exit() for line in fhand: words = line.split() if len(words) < 2 or words[0] != 'From': continue else: d[words[1]] = d.get(words[1], 0) + 1 print(d)
# Copyright 2014 Google Inc. # # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'variables': { 'skia_warnings_as_errors': 0, }, 'targets': [ { 'target_name': 'libpng', 'type': 'none', 'conditions': [ [ 'skia_android_framework', { 'dependencies': [ 'android_deps.gyp:png' ], 'export_dependent_settings': [ 'android_deps.gyp:png' ], },{ 'dependencies': [ 'libpng.gyp:libpng_static' ], 'export_dependent_settings': [ 'libpng.gyp:libpng_static' ], }] ] }, { 'target_name': 'libpng_static', 'type': 'static_library', 'standalone_static_library': 1, 'include_dirs': [ '../third_party/libpng', ], 'dependencies': [ 'zlib.gyp:zlib', ], 'export_dependent_settings': [ 'zlib.gyp:zlib', ], 'direct_dependent_settings': { 'include_dirs': [ '../third_party/libpng', ], }, 'cflags': [ '-w', '-fvisibility=hidden', ], 'sources': [ '../third_party/libpng/png.c', '../third_party/libpng/pngerror.c', '../third_party/libpng/pngget.c', '../third_party/libpng/pngmem.c', '../third_party/libpng/pngpread.c', '../third_party/libpng/pngread.c', '../third_party/libpng/pngrio.c', '../third_party/libpng/pngrtran.c', '../third_party/libpng/pngrutil.c', '../third_party/libpng/pngset.c', '../third_party/libpng/pngtrans.c', '../third_party/libpng/pngwio.c', '../third_party/libpng/pngwrite.c', '../third_party/libpng/pngwtran.c', '../third_party/libpng/pngwutil.c', ], 'conditions': [ [ '"x86" in skia_arch_type', { 'defines': [ 'PNG_INTEL_SSE_OPT=1', ], 'sources': [ '../third_party/libpng/contrib/intel/intel_init.c', '../third_party/libpng/contrib/intel/filter_sse2_intrinsics.c', ], }], [ '(("arm64" == skia_arch_type) or \ ("arm" == skia_arch_type and arm_neon == 1)) and \ ("ios" != skia_os)', { 'defines': [ 'PNG_ARM_NEON_OPT=2', 'PNG_ARM_NEON_IMPLEMENTATION=1', ], 'sources': [ '../third_party/libpng/arm/arm_init.c', '../third_party/libpng/arm/filter_neon_intrinsics.c', ], }], [ '"ios" == skia_os', { 'defines': [ 'PNG_ARM_NEON_OPT=0', ], }], ], } ] }
{'variables': {'skia_warnings_as_errors': 0}, 'targets': [{'target_name': 'libpng', 'type': 'none', 'conditions': [['skia_android_framework', {'dependencies': ['android_deps.gyp:png'], 'export_dependent_settings': ['android_deps.gyp:png']}, {'dependencies': ['libpng.gyp:libpng_static'], 'export_dependent_settings': ['libpng.gyp:libpng_static']}]]}, {'target_name': 'libpng_static', 'type': 'static_library', 'standalone_static_library': 1, 'include_dirs': ['../third_party/libpng'], 'dependencies': ['zlib.gyp:zlib'], 'export_dependent_settings': ['zlib.gyp:zlib'], 'direct_dependent_settings': {'include_dirs': ['../third_party/libpng']}, 'cflags': ['-w', '-fvisibility=hidden'], 'sources': ['../third_party/libpng/png.c', '../third_party/libpng/pngerror.c', '../third_party/libpng/pngget.c', '../third_party/libpng/pngmem.c', '../third_party/libpng/pngpread.c', '../third_party/libpng/pngread.c', '../third_party/libpng/pngrio.c', '../third_party/libpng/pngrtran.c', '../third_party/libpng/pngrutil.c', '../third_party/libpng/pngset.c', '../third_party/libpng/pngtrans.c', '../third_party/libpng/pngwio.c', '../third_party/libpng/pngwrite.c', '../third_party/libpng/pngwtran.c', '../third_party/libpng/pngwutil.c'], 'conditions': [['"x86" in skia_arch_type', {'defines': ['PNG_INTEL_SSE_OPT=1'], 'sources': ['../third_party/libpng/contrib/intel/intel_init.c', '../third_party/libpng/contrib/intel/filter_sse2_intrinsics.c']}], ['(("arm64" == skia_arch_type) or ("arm" == skia_arch_type and arm_neon == 1)) and ("ios" != skia_os)', {'defines': ['PNG_ARM_NEON_OPT=2', 'PNG_ARM_NEON_IMPLEMENTATION=1'], 'sources': ['../third_party/libpng/arm/arm_init.c', '../third_party/libpng/arm/filter_neon_intrinsics.c']}], ['"ios" == skia_os', {'defines': ['PNG_ARM_NEON_OPT=0']}]]}]}
_base_ = "./common_base.py" # ----------------------------------------------------------------------------- # base model cfg for gdrn # ----------------------------------------------------------------------------- MODEL = dict( DEVICE="cuda", WEIGHTS="", # PIXEL_MEAN = [103.530, 116.280, 123.675] # bgr # PIXEL_STD = [57.375, 57.120, 58.395] # PIXEL_MEAN = [123.675, 116.280, 103.530] # rgb # PIXEL_STD = [58.395, 57.120, 57.375] PIXEL_MEAN=[0, 0, 0], # to [0,1] PIXEL_STD=[255.0, 255.0, 255.0], LOAD_DETS_TEST=False, CDPN=dict( NAME="GDRN", # used module file name TASK="rot", USE_MTL=False, # uncertainty multi-task weighting ## backbone BACKBONE=dict( PRETRAINED="torchvision://resnet34", ARCH="resnet", NUM_LAYERS=34, INPUT_CHANNEL=3, INPUT_RES=256, OUTPUT_RES=64, FREEZE=False, ), ## rot head ROT_HEAD=dict( FREEZE=False, ROT_CONCAT=False, XYZ_BIN=64, # for classification xyz, the last one is bg NUM_LAYERS=3, NUM_FILTERS=256, CONV_KERNEL_SIZE=3, NORM="BN", NUM_GN_GROUPS=32, OUT_CONV_KERNEL_SIZE=1, NUM_CLASSES=13, ROT_CLASS_AWARE=False, XYZ_LOSS_TYPE="L1", # L1 | CE_coor XYZ_LOSS_MASK_GT="visib", # trunc | visib | obj XYZ_LW=1.0, MASK_CLASS_AWARE=False, MASK_LOSS_TYPE="L1", # L1 | BCE | CE MASK_LOSS_GT="trunc", # trunc | visib | gt MASK_LW=1.0, MASK_THR_TEST=0.5, # for region classification, 0 is bg, [1, num_regions] # num_regions <= 1: no region classification NUM_REGIONS=8, REGION_CLASS_AWARE=False, REGION_LOSS_TYPE="CE", # CE REGION_LOSS_MASK_GT="visib", # trunc | visib | obj REGION_LW=1.0, ), ## for direct regression PNP_NET=dict( FREEZE=False, R_ONLY=False, LR_MULT=1.0, # ConvPnPNet | SimplePointPnPNet | PointPnPNet | ResPointPnPNet PNP_HEAD_CFG=dict(type="ConvPnPNet", norm="GN", num_gn_groups=32, drop_prob=0.0), # 0.25 # PNP_HEAD_CFG=dict( # type="ConvPnPNet", # norm="GN", # num_gn_groups=32, # spatial_pooltype="max", # max | mean | soft | topk # spatial_topk=1, # region_softpool=False, # region_topk=8, # NOTE: default the same as NUM_REGIONS # ), WITH_2D_COORD=False, # using 2D XY coords REGION_ATTENTION=False, # region attention MASK_ATTENTION="none", # none | concat | mul TRANS_WITH_BOX_INFO="none", # none | ltrb | wh # TODO ## for losses # {allo/ego}_{quat/rot6d/log_quat/lie_vec} ROT_TYPE="ego_rot6d", TRANS_TYPE="centroid_z", # trans | centroid_z (SITE) | centroid_z_abs Z_TYPE="REL", # REL | ABS | LOG | NEG_LOG (only valid for centroid_z) # point matching loss NUM_PM_POINTS=3000, PM_LOSS_TYPE="L1", # L1 | Smooth_L1 PM_SMOOTH_L1_BETA=1.0, PM_LOSS_SYM=False, # use symmetric PM loss PM_NORM_BY_EXTENT=False, # 10. / extent.max(1, keepdim=True)[0] # if False, the trans loss is in point matching loss PM_R_ONLY=True, # only do R loss in PM PM_DISENTANGLE_T=False, # disentangle R/T PM_DISENTANGLE_Z=False, # disentangle R/xy/z PM_T_USE_POINTS=False, PM_LW=1.0, ROT_LOSS_TYPE="angular", # angular | L2 ROT_LW=0.0, CENTROID_LOSS_TYPE="L1", CENTROID_LW=0.0, Z_LOSS_TYPE="L1", Z_LW=0.0, TRANS_LOSS_TYPE="L1", TRANS_LOSS_DISENTANGLE=True, TRANS_LW=0.0, # bind term loss: R^T@t BIND_LOSS_TYPE="L1", BIND_LW=0.0, ), ## trans head TRANS_HEAD=dict( ENABLED=False, FREEZE=True, LR_MULT=1.0, NUM_LAYERS=3, NUM_FILTERS=256, NORM="BN", NUM_GN_GROUPS=32, CONV_KERNEL_SIZE=3, OUT_CHANNEL=3, TRANS_TYPE="centroid_z", # trans | centroid_z Z_TYPE="REL", # REL | ABS | LOG | NEG_LOG CENTROID_LOSS_TYPE="L1", CENTROID_LW=0.0, Z_LOSS_TYPE="L1", Z_LW=0.0, TRANS_LOSS_TYPE="L1", TRANS_LW=0.0, ), ), # some d2 keys but not used KEYPOINT_ON=False, LOAD_PROPOSALS=False, ) TEST = dict( EVAL_PERIOD=0, VIS=False, TEST_BBOX_TYPE="gt", # gt | est USE_PNP=False, # use pnp or direct prediction # ransac_pnp | net_iter_pnp (learned pnp init + iter pnp) | net_ransac_pnp (net init + ransac pnp) # net_ransac_pnp_rot (net_init + ransanc pnp --> net t + pnp R) PNP_TYPE="ransac_pnp", PRECISE_BN=dict(ENABLED=False, NUM_ITER=200), )
_base_ = './common_base.py' model = dict(DEVICE='cuda', WEIGHTS='', PIXEL_MEAN=[0, 0, 0], PIXEL_STD=[255.0, 255.0, 255.0], LOAD_DETS_TEST=False, CDPN=dict(NAME='GDRN', TASK='rot', USE_MTL=False, BACKBONE=dict(PRETRAINED='torchvision://resnet34', ARCH='resnet', NUM_LAYERS=34, INPUT_CHANNEL=3, INPUT_RES=256, OUTPUT_RES=64, FREEZE=False), ROT_HEAD=dict(FREEZE=False, ROT_CONCAT=False, XYZ_BIN=64, NUM_LAYERS=3, NUM_FILTERS=256, CONV_KERNEL_SIZE=3, NORM='BN', NUM_GN_GROUPS=32, OUT_CONV_KERNEL_SIZE=1, NUM_CLASSES=13, ROT_CLASS_AWARE=False, XYZ_LOSS_TYPE='L1', XYZ_LOSS_MASK_GT='visib', XYZ_LW=1.0, MASK_CLASS_AWARE=False, MASK_LOSS_TYPE='L1', MASK_LOSS_GT='trunc', MASK_LW=1.0, MASK_THR_TEST=0.5, NUM_REGIONS=8, REGION_CLASS_AWARE=False, REGION_LOSS_TYPE='CE', REGION_LOSS_MASK_GT='visib', REGION_LW=1.0), PNP_NET=dict(FREEZE=False, R_ONLY=False, LR_MULT=1.0, PNP_HEAD_CFG=dict(type='ConvPnPNet', norm='GN', num_gn_groups=32, drop_prob=0.0), WITH_2D_COORD=False, REGION_ATTENTION=False, MASK_ATTENTION='none', TRANS_WITH_BOX_INFO='none', ROT_TYPE='ego_rot6d', TRANS_TYPE='centroid_z', Z_TYPE='REL', NUM_PM_POINTS=3000, PM_LOSS_TYPE='L1', PM_SMOOTH_L1_BETA=1.0, PM_LOSS_SYM=False, PM_NORM_BY_EXTENT=False, PM_R_ONLY=True, PM_DISENTANGLE_T=False, PM_DISENTANGLE_Z=False, PM_T_USE_POINTS=False, PM_LW=1.0, ROT_LOSS_TYPE='angular', ROT_LW=0.0, CENTROID_LOSS_TYPE='L1', CENTROID_LW=0.0, Z_LOSS_TYPE='L1', Z_LW=0.0, TRANS_LOSS_TYPE='L1', TRANS_LOSS_DISENTANGLE=True, TRANS_LW=0.0, BIND_LOSS_TYPE='L1', BIND_LW=0.0), TRANS_HEAD=dict(ENABLED=False, FREEZE=True, LR_MULT=1.0, NUM_LAYERS=3, NUM_FILTERS=256, NORM='BN', NUM_GN_GROUPS=32, CONV_KERNEL_SIZE=3, OUT_CHANNEL=3, TRANS_TYPE='centroid_z', Z_TYPE='REL', CENTROID_LOSS_TYPE='L1', CENTROID_LW=0.0, Z_LOSS_TYPE='L1', Z_LW=0.0, TRANS_LOSS_TYPE='L1', TRANS_LW=0.0)), KEYPOINT_ON=False, LOAD_PROPOSALS=False) test = dict(EVAL_PERIOD=0, VIS=False, TEST_BBOX_TYPE='gt', USE_PNP=False, PNP_TYPE='ransac_pnp', PRECISE_BN=dict(ENABLED=False, NUM_ITER=200))
#This app does your math addition = input("Print your math sign, +, -, *, /: ") if addition == "+": a = int(input("First Number: ")) b = int(input("Seccond Number: ")) c = a + b print(c) elif addition == "-": a = int(input("First Number: ")) b = int(input("Seccond Number: ")) c = a - b print(c) elif addition == "*": a = int(input("First Number: ")) b = int(input("Seccond Number: ")) c = a * b print(c) elif addition == "/": a = int(input("First Number: ")) b = int(input("Seccond Number: ")) c = a / b print(c) else: print("That is not a valid operation. Please do +, -, *, /")
addition = input('Print your math sign, +, -, *, /: ') if addition == '+': a = int(input('First Number: ')) b = int(input('Seccond Number: ')) c = a + b print(c) elif addition == '-': a = int(input('First Number: ')) b = int(input('Seccond Number: ')) c = a - b print(c) elif addition == '*': a = int(input('First Number: ')) b = int(input('Seccond Number: ')) c = a * b print(c) elif addition == '/': a = int(input('First Number: ')) b = int(input('Seccond Number: ')) c = a / b print(c) else: print('That is not a valid operation. Please do +, -, *, /')