content
stringlengths
7
1.05M
""" Optional problems for Lab 3 """ def is_prime(n): """Returns True if n is a prime number and False otherwise. >>> is_prime(2) True >>> is_prime(16) False >>> is_prime(521) True """ "*** YOUR CODE HERE ***" def gcd(a, b): """Returns the greatest common divisor of a and b. Should be implemented using recursion. >>> gcd(34, 19) 1 >>> gcd(39, 91) 13 >>> gcd(20, 30) 10 >>> gcd(40, 40) 40 """ "*** YOUR CODE HERE ***" def ten_pairs(n): """Return the number of ten-pairs within positive integer n. >>> ten_pairs(7823952) 3 >>> ten_pairs(55055) 6 >>> ten_pairs(9641469) 6 """ "*** YOUR CODE HERE ***"
""" 551. Student Attendance Record I """ class Solution: def checkRecord(self, s): """ :type s: str :rtype: bool """ A = i = 0 while i < len(s): if s[i] == 'A': A+=1 if A>=2: return False if s[i] == 'L': j = i while i < len(s) and s[i] == 'L': i+=1 if i - j > 2: return False i-=1 i+=1 return True class Solution: def checkRecord(self, s): """ :type s: str :rtype: bool """ if s.find('A') != s.rfind('A'): return False for i in range(len(s)-2): if s[i] == s[i + 1] == s[i+2] == 'L': return False return True class Solution: def checkRecord(self, s): return not re.search('A.*A|LLL',s)
print('ex01:') for c in range (1, 6): print('Oi') print('FIM') print('-=' *10) print('ex02') for c in range(0, 7, 2):#PULA DUAS CASAS(2) print(c) print('FIM') print('-=' *10) print('ex03') i = int(input('Início: ')) f = int(input('fim:')) p = int(input('Passo: ')) for c in range (i, f+1, p): print(c) print('FIM') print('-=' *10) print('-=' *10) print('ex04') s = 0 for c in range(0, 3): n = int(input('Digite um valor: ')) s += n print(f'O somatório de todos os valres foi {s}')
class dtype(object): def __init__(self): super().__init__() def is_floating_point(self) -> bool: raise NotImplementedError('is_floating_point NotImplementedError') def is_complex(self) -> bool: raise NotImplementedError('is_complex NotImplementedError') def is_signed(self) -> bool: raise NotImplementedError('is_signed NotImplementedError') class dtype_float32(dtype): def __init__(self): super().__init__() def is_floating_point(self) -> bool: return True def is_complex(self) -> bool: return False def is_signed(self) -> bool: return True float32 = dtype_float32() float = float32
data = { '北京':{ '海淀':{ '五道口':{ 'soho':{}, '网易':{}, 'Google':{} }, '中关村':{ '爱奇艺':{}, '汽车之家':{}, 'youku':{}, }, '上地':{ '百度':{}, } }, '昌平':{ '沙河':{ '老男孩':{}, '北航':{} }, '天通苑':{}, '回龙观':{} }, '朝阳':{}, '东城':{} }, '上海':{}, '湖北':{}, '广东':{} } ##print(list(data.keys())) ##current = [] ##lom = 1 #level of menu ##while True: ## entr = input('Input the option you want to get into:') ## if entr == 'e': ## break ## elif entr == 'p': ## lom -= 1 ## if lom == 0: ## lom = 1 ## if lom == 1 and data.keys() : ## print(list(data.keys()),'\n') ## current = list(data.keys()) ## elif lom == 2 and flpm in data and data[flpm].keys(): ## print(list(data[flpm].keys()),'\n') ## current = list(data[flpm].keys()) ## elif lom == 3 and slpm in data[flpm] and data[flpm][slpm].keys(): ## print(list(data[flpm][slpm].keys()),'\n') ## current = list(data[flpm][slpm].keys()) ## elif lom == 1 and entr in data and data[entr].keys(): ## print(list(data[entr].keys()),'\n') ## current = list(data[entr].keys()) ## flpm = entr #First level parent menu ## lom += 1 ## elif lom == 2 and entr in data[flpm] and data[flpm][entr].keys(): ## print(list(data[flpm][entr].keys()),'\n') ## current = list(data[flpm][entr].keys()) ## slpm = entr #second level parent menu ## lom += 1 ## elif lom == 3 and entr in data[flpm][slpm] and data[flpm][slpm][entr].keys(): ## print(list(data[flpm][slpm][entr].keys()),'\n') ## current = list(data[flpm][slpm][entr].keys()) ## tlpm = entr # third level parent menu ## lom += 1 ## else: ## print("Invalid input!".center(50,'*'),'\n') ## print(current) ##print('\n','Bye!'.center(50,'*'),'\n') current_layer = data layers = [] while True: print(list(current_layer.keys())) entr = input('Input the option you want to get into:') if entr in current_layer and current_layer[entr].keys(): layers.append(current_layer) # save current layer before getting into next layer current_layer = current_layer[entr] elif entr == 'b'and layers: current_layer = layers.pop() elif entr == 'e': break print('Bye!'.center(50,'*'))
def print_conversion(prev_char, cur_count, first_char): space = '' if first_char else ' ' if prev_char == '0': print('{}00 {}'.format(space, '0' * cur_count), end='') else: print('{}0 {}'.format(space, '0' * cur_count), end='') def solution(): binary = [] for char in input(): binary.extend('{:b}'.format(ord(char)).zfill(7)) prev_char = None cur_count = 0 first_char = True for x in binary: if prev_char is None: prev_char = x cur_count += 1 elif prev_char == x: cur_count += 1 else: print_conversion(prev_char, cur_count, first_char) first_char = False prev_char = x cur_count = 1 print_conversion(prev_char, cur_count, first_char) solution()
class Exchange: def __init__(self, name): self.name = name self.market_bases = {'BTC', 'ETH', 'USDT'} self.coins = self.get_all_coin_balance() self.dontTouch = {'XRP', 'XEM', 'BTC', 'DOGE', 'SC', 'NEO', 'ZEC', 'BTG', 'MONA', 'WINGS', 'USDT', 'IOTA', 'EOS', 'QTUM', 'ADA', 'XLM', 'LSK', 'BTS', 'XMR', 'DASH', 'SNT', 'BCC', 'BCH', 'SBTC', 'BCX', 'ETF', 'LTC', 'ETH', 'BNB', 'ADA', 'BTS', 'SNT'} def connect_success(self): print('connected %s' % self.name) def get_pair(self, coin, base): # return the specific pair format for this exchange raise NotImplementedError("Please Implement this method") def get_all_trading_pairs(self): ''' get all possible traing pairs in the form { 'bases': {'BTC', 'ETH', etc...}, 'pairs': { 'BTC': { ... }, 'ETH': { ... }, ...... } 'all_pairs': { ... }, } ''' raise NotImplementedError("Please Implement this method") def get_all_trading_coins(self): ''' get all possible traing coins in the form {'eos, neo, ...'} ''' raise NotImplementedError("Please Implement this method") def get_my_pair(self, coin, base): # return my format return '%s-%s' % (coin, base) def get_BTC_price(self): raise NotImplementedError("Please Implement this method") def get_price(self, coin, base='BTC'): raise NotImplementedError("Please Implement this method") def get_full_balance(self, allow_zero=False): ''' return format { 'total': { 'BTC': BTC_value, 'USD': USD_value, 'num': coin_num }, 'USD': { ... }, coinName1: { ... }, coinName2: { ... }, ... } ''' raise NotImplementedError("Please Implement this method") def get_all_coin_balance(self, allow_zero=False): ''' return format { coinName1: num1, coinName2: num2, ... } ''' raise NotImplementedError("Please Implement this method") def get_trading_pairs(self): ''' return format: { 'BTC': {'ADA', 'BAT', 'BTG', ...}, 'ETH': {'BAT', 'BNT', 'DNT', 'ETC', ...}, 'USDT': {'NEO', 'BTC', 'LTC', ...} ... } ''' raise NotImplementedError("Please Implement this method") def get_market(self, coin, base): raise NotImplementedError("Please Implement this method") def get_coin_balance(self, coin): if coin in self.coins.keys(): return self.coins[coin] else: return 0 def get_order(self, id): raise NotImplementedError("Please Implement this method") # ----------- might need to update self.coins after buy/sell ----------- # def market_buy(self, coin, base='BTC', quantity=0): ''' return format { 'exchange': [exchange name], 'side': [buy or sell], 'pair': [coin-base], 'price': [average filled price], 'quantity': [filled quantity], 'total': [total order value in BTC], 'fee': [fee in BTC], 'id': order id, 'id2': customed order id } ''' raise NotImplementedError("Please Implement this method") def market_sell(self, coin, base='BTC', quantity=0): raise NotImplementedError("Please Implement this method") def market_sell_all(self, coin, base='BTC'): quantity = self.get_coin_balance(coin) if quantity <= 0: print('%s does not have enough balance to sell' % coin) return None else: return self.market_sell(coin, base=base, quantity=quantity) def market_buy_everything(self, USD_price): raise NotImplementedError("Please Implement this method") def market_sell_everything(self): res = [] for coin, num in self.coins.items(): if coin not in self.dontTouch: response = self.market_sell_all(coin) res.append(response) print (response) return res
CELLMAP_WIDTH = 200 CELLMAP_HEIGHT = 200 SCREEN_WIDTH = 1200 SCREEN_HEIGHT = 1200 CELL_WIDTH = SCREEN_WIDTH / CELLMAP_WIDTH CELL_HEIGHT = SCREEN_HEIGHT / CELLMAP_HEIGHT FILL_CELL = 0 SHOW_QUADTREE = True BLACK = (0, 0, 0) WHITE = (255, 255, 255) BLUE = (0, 0, 255) RANDOM_CHANCE = 0.0625
# This is the output of analyzeImage.py (each value indicates a RGB color) myScreenshot = """ 0 4 264 267 527 530 789 66328 66588 66591 66849 132388 132647 132650 132908 198447 198706 198708 264503 264505 330299 330557 330560 396354 396612 462150 462408 527946 528204 593998 594000 659794 660052 725590 791383 791641 857435 857437 923230 989024 989026 1054819 1120613 1120870 1186408 1252201 1252459 1318252 1384046 1384047 1449841 1515634 1515892 1581429 1647222 1713016 1713273 1779066 1844860 1910397 1976190 1976447 2042241 2108034 2173827 2239364 2239621 2305415 2371208 2437001 2502794 2568587 2568844 2634381 2700174 2765968 2831761 2897554 2963347 3029140 3029397 3095190 3160983 3226520 3292313 3358106 3423899 3489692 3555485 3621278 3687071 3752864 3818656 3884449 3950242 4016035 4081828 4147621 4147878 4213671 4279464 4345256 4411049 4476842 4542635 4608428 4739757 4805550 4871342 4937135 5002928 5068721 5134514 5200306 5266099 5331892 5397685 5463477 5529270 5595063 5660856 5726648 5792441 5858234 5924027 5989819 6121148 6186941 6252734 6318526 6384319 6450112 6515904 6581953 6647746 6779074 6844867 6910660 6976452 7042245 7108038 7173830 7239623 7370952 7436744 7502793 7568586 7634378 7700171 7765964 7897292 7963085 8028877 8094670 8160719 8226511 8357840 8423632 8489425 8555218 8621010 8752339 8818387 8884180 8949973 9015765 9147094 9212886 9278679 9344727 9410520 9541849 9607641 9673434 9739226 9870555 9936603 10002396 10068188 10133981 10265309 10331102 10397150 10462943 10594272 10660064 10725857 10791905 10923234 10989026 11054819 11120611 11251940 11317988 11383781 11515109 11580902 11646694 11712743 11844071 11909864 11975656 12106985 12173033 12238826 12304618 12435947 12501995 12567787 12699116 12764908 12830701 12962285 13028078 13093870 13159663 13291247 13357040 13422832 13554161 13619953 13686001 13817330 13883122 13948915 14080499 14146292 14212084 14343412 14409461 14475253 14606582 14672374 14738423 14869751 14935543 15066872 15132920 15198713 15330041 15396090 15461882 15593210 15659003 15725051 15856380 15922172 16053500 16119549 16185341 16316670 16382718 16448510 16579839 16645631 16777215 """ # https://www.i2phd.org/images/argo143screen.gif webScreenshot = """ 0 4 264 267 527 530 789 66328 66588 66591 66849 132388 132647 132650 132908 198447 198706 198708 264503 264505 330299 330557 330560 396354 396612 462150 462408 527946 528204 593998 594000 659794 660052 725590 791383 791641 857435 857437 923230 989024 989026 1054819 1120613 1120870 1186408 1252201 1252459 1318252 1384046 1384047 1449841 1515634 1515892 1581429 1647222 1713016 1713273 1779066 1844860 1910397 1976190 1976447 2042241 2108034 2173827 2239364 2239621 2305415 2371208 2437001 2502794 2568587 2568844 2634381 2700174 2765968 2831761 2897554 2963347 3029140 3029397 3095190 3160983 3226520 3292313 3358106 3423899 3489692 3555485 3621278 3687071 3752864 3818656 3884449 3950242 4016035 4081828 4147621 4147878 4213671 4279464 4345256 4411049 4476842 4542635 4608428 4739757 4805550 4871342 4937135 5002928 5068721 5134514 5200306 5266099 5331892 5397685 5463477 5529270 5595063 5660856 5726648 5792441 5858234 5924027 5989819 6121148 6186941 6252734 6318526 6384319 6450112 6515904 6581953 6647746 6779074 6844867 6910660 6976452 7042245 7108038 7173830 7239623 7370952 7436744 7502793 7568586 7634378 7700171 7765964 7897292 7963085 8028877 8094670 8160719 8226511 8357840 8423632 8489425 8555218 8621010 8752339 8818387 8884180 8949973 9015765 9147094 9212886 9278679 9344727 9410520 9541849 9607641 9673434 9739226 9870555 9936603 10002396 10068188 10133981 10265309 10331102 10397150 10462943 10594272 10660064 10725857 10791905 10923234 10989026 11054819 11120611 11251940 11317988 11383781 11515109 11580902 11646694 11712743 11844071 11909864 11975656 12106985 12173033 12238826 12304618 12435947 12501995 12567787 12699116 12764908 12830701 12962285 13028078 13093870 13159663 13291247 13357040 13422832 13554161 13619953 13686001 13817330 13883122 13948915 14080499 14146292 14212084 14343412 14409461 14475253 14606582 14672374 14738423 14869751 14935543 15066872 15132920 15198713 15330041 15396090 15461882 15593210 15659003 15725051 15856380 15922172 16053500 16119549 16185341 16316670 16382718 16448510 16579839 16645631 16777215 """ if __name__ == "__main__": values = [x.strip() for x in myScreenshot.replace(",", " ").split(" ")] values = [int(x) for x in values if len(x)] assert (len(values) == 256) txt = f"# colormap argo\n" for i in range(256): int32 = values[i] * 255 # alpha txt += f"{int32:010d}, " if i % 8 == 7: txt += "\n" with open(f"../analyzed2/argo.csv", 'w') as f: f.write(txt) print(txt)
#!/usr/bin/env python3 inversions = 0 def count_inversions(input): _ = merge_sort(input) return inversions def merge_sort(input): if len(input) <= 1: return input mid = len(input) // 2 left = input[:mid] right = input[mid:] left = merge_sort(left) right = merge_sort(right) return merge(left, right) def merge(left, right): global inversions result = [] len_left, len_right = len(left), len(right) left_idx, right_idx = 0, 0 while left_idx < len_left and right_idx < len_right: if left[left_idx] <= right[right_idx]: result.append(left[left_idx]) left_idx += 1 else: result.append(right[right_idx]) right_idx += 1 inversions += len(left[left_idx:]) if left_idx < len_left: result.extend(left[left_idx:]) elif right_idx < len_right: result.extend(right[right_idx:]) return result
test = { 'name': 'q3a', 'points': 1, 'suites': [ { 'cases': [ { 'code': '>>> diabetes_2d.shape\n' '(442, 2)', 'hidden': False, 'locked': False}, { 'code': '>>> -0.10 < ' 'np.sum(diabetes_2d[0]) < 0\n' 'True', 'hidden': False, 'locked': False}, { 'code': '>>> np.isclose(0, ' 'np.sum(diabetes_2d))\n' 'True', 'hidden': False, 'locked': False}], 'scored': True, 'setup': '', 'teardown': '', 'type': 'doctest'}]}
def binary_diagnostic(input): numberLength = (len(input[0])) gammaRate = '' for col in range(numberLength): ones = 0 for line in input: if line[col] == '1': ones += 1 else: ones -= 1 gammaRate += '1' if ones >= 0 else '0' gammaRate = int(gammaRate, 2) epsilonRate = ~gammaRate & (2 ** numberLength) - 1 return gammaRate * epsilonRate with open('input.txt') as f: print(binary_diagnostic(f.read().split()))
def test(func, verbose=True): """ Tests a sort function by comparing it to Python's builtin 'Timsort.' """ tests = [ [5, 7, 1, 9, 89, 15, 14, 2], [False, True, False, True, False, True, True, True, False, False], ['z', 'x', 'u', 'i', 'o', 'z', 'r', 'a', 'b'], ['grape', 'orange', 'apple', 'zebra'], [1.0, 1.1, 0.8, 0.01, -0.0001, 0.05, 0.9, 9.8, -10.2, 1.3, 4.5, -2.2] ] for testlist in tests: if verbose: print("Unsorted: ", testlist) testsort = func(testlist) if verbose: print("Sorted: ", testsort, "\n") stdsort = testlist.copy() stdsort.sort() assert stdsort == testsort, \ "Sorted list " + str(testsort) + \ " was not sorted correctly by " + func.__name__ print(func.__name__, "passed all tests") def swap(x, i, j): """ Swaps the position of elements i and j in list x """ if i == j: pass else: temp = x[j] # Store element j for later use x[j] = x[i] x[i] = temp
def maxmin(A): if len(A) == 1: return A[0], A[0] elif len(A) == 2: return max(A[0], A[1]), min(A[0], A[1]) maxl, minl = maxmin(A[:int(len(A) / 2)]) maxr, minr = maxmin(A[int(len(A) / 2):]) return max(maxl, maxr), min(minl, minr) class Solution: # @param A : list of integers # @return an integer def solve(self, A): return sum(maxmin(A)) # Explanation of complexity: # T(n) denotes the number of comparisons for input of size number # T(0) = 0, T(1) = 0, T(2) = 1 # Base equation # T(n) = 2T(n / 2) + 2 # Derived equation # T(n) = 2^kT(n / 2^k) + 2^k+1 - 2 # Since T(2) = 1, # n / 2^k = 2 => k = log(n) - 1 where base(log) = 2 # Replacing the value of k in the derived equation above: # T(n) = 3n / 2 - 2
#!/usr/bin/env python class DocumentProperty(object): """NOTE: This class is auto generated by the swagger code generator program. Do not edit the class manually.""" def __init__(self): """ Attributes: swaggerTypes (dict): The key is attribute name and the value is attribute type. attributeMap (dict): The key is attribute name and the value is json key in definition. """ self.swaggerTypes = { 'Name': 'str', 'Value': 'str', 'BuiltIn': 'bool', 'SelfUri': 'ResourceUri', 'AlternateLinks': 'list[ResourceUri]', 'Links': 'list[ResourceUri]' } self.attributeMap = { 'Name': 'Name','Value': 'Value','BuiltIn': 'BuiltIn','SelfUri': 'SelfUri','AlternateLinks': 'AlternateLinks','Links': 'Links'} self.Name = None # str self.Value = None # str self.BuiltIn = None # bool self.SelfUri = None # ResourceUri self.AlternateLinks = None # list[ResourceUri] self.Links = None # list[ResourceUri]
class StartTimeVariables: @classmethod def Checklist(cls): cls.INTAG = None return cls
class Encoder(): def encode_char(self, char, order): return char def _to_index(self, char): return ord(char) - ord('A') def _to_char(self, index): return chr(index + ord('A'))
# EXERCICIO 048 - SOMA IMPARES MULTIPLOS DE 3 soma = 0 cont = 0 for cont in range(1,501,2): if cont % 3 == 0: cont += 1 soma += cont print('A soma dos {} impares multiplos de 3 é {}'.format(cont,soma))
# ----------------------Cutter Model Error Messages--------------------------- NEG_OVERLAP_LAST_PROP_MESSAGE = \ "the overlap or last segment proportion should not be negative" LARGER_SEG_SIZE_MESSAGE = \ "the segment size should be larger than the overlap size" INVALID_CUTTING_TYPE_MESSAGE = "the cutting type should be letters, lines, " \ "number, words or milestone" EMPTY_MILESTONE_MESSAGE = "the milestone should not be empty" # ---------------------------------------------------------------------------- # ----------------------Similarity Model Error Messages----------------------- NON_NEGATIVE_INDEX_MESSAGE = "the index should be larger than or equal to zero" # ---------------------------------------------------------------------------- # ----------------------Topword Model Error Messages-------------------------- NOT_ENOUGH_CLASSES_MESSAGE = "Only one class given, cannot do Z-test by " \ "class, at least 2 classes needed." # ---------------------------------------------------------------------------- # ----------------------Rolling Window Analyzer Error Messages---------------- WINDOW_SIZE_LARGE_MESSAGE = "The window size must be less than or equal to" \ " the length of the given document" WINDOW_NON_POSITIVE_MESSAGE = "The window size must be a positive integer" # ---------------------------------------------------------------------------- # ----------------------Scrubber Error Messages------------------------------- NOT_ONE_REPLACEMENT_COLON_MESSAGE = "Invalid number of colons or commas." REPLACEMENT_RIGHT_OPERAND_MESSAGE = \ "Too many values on right side of replacement string." REPLACEMENT_NO_LEFT_HAND_MESSAGE = \ "Missing value on the left side of replacement string." # ---------------------------------------------------------------------------- # ======================== General Errors ==================================== SEG_NON_POSITIVE_MESSAGE = "The segment size must be a positive integer." EMPTY_DTM_MESSAGE = "Empty DTM received, please upload files." EMPTY_LIST_MESSAGE = "The list should not be empty." EMPTY_NP_ARRAY_MESSAGE = "The input numpy array should not be empty." # ======================== Base Model Errors ================================= NO_DATA_SENT_ERROR_MESSAGE = 'Front end did not send data to backend'
base = 40 altura = 47 print('area del cuadrado =', base*altura)
def main(): K = input() D = int(input()) L = len(K) dp = [[[0, 0] for _ in range(D)] for _ in range(L+1)] mod = 10 ** 9 + 7 dp[0][0][1] = 1 for i in range(L): d = int(K[i]) for j in range(D): for k in range(10): dp[i+1][(j + k) % D][0] += dp[i][j][0] dp[i+1][(j + k) % D][0] %= mod if k < d: dp[i+1][(j + k) % D][0] += dp[i][j][1] dp[i+1][(j + k) % D][0] %= mod elif k == d: dp[i+1][(j + k) % D][1] += dp[i][j][1] dp[i+1][(j + k) % D][1] %= mod print((sum(dp[-1][0]) + mod - 1) % mod) if __name__ == '__main__': main()
# Twitter error codes TWITTER_PAGE_DOES_NOT_EXISTS_ERROR = 34 TWITTER_USER_NOT_FOUND_ERROR = 50 TWITTER_TWEET_NOT_FOUND_ERROR = 144 TWITTER_DELETE_OTHER_USER_TWEET = 183 TWITTER_ACCOUNT_SUSPENDED_ERROR = 64 TWITTER_USER_IS_NOT_LIST_MEMBER_SUBSCRIBER = 109 TWITTER_AUTOMATED_REQUEST_ERROR = 226 TWITTER_OVER_CAPACITY_ERROR = 130 TWITTER_DAILY_STATUS_UPDATE_LIMIT_ERROR = 185 TWITTER_CHARACTER_LIMIT_ERROR_1 = 186 TWITTER_CHARACTER_LIMIT_ERROR_2 = 354 TWITTER_STATUS_DUPLICATE_ERROR = 187 # Twitter non-tweet events TWITTER_NON_TWEET_EVENTS = ['access_revoked', 'block', 'unblock', 'favorite', 'unfavorite', 'follow', 'unfollow', 'list_created', 'list_destroyed', 'list_updated', 'list_member_added', 'list_member_removed', 'list_user_subscribed', 'list_user_unsubscribed', 'quoted_tweet', 'user_update']
dados = {} dados['nome'] = str(input('Qual o nome do aluno: ')).strip().upper() nota1 = float(input(f'Digite a primeira nota de {dados["nome"]}: ')) nota2 = float(input('Digite a segunda nota: ')) media = float((nota1 + nota2)/2) dados['media'] = media if media < 5.0: dados['situacao'] = 'Reprovado' elif media < 7.0: dados['situacao'] = 'Recuperação' else: dados['situacao'] = 'Aprovado' print( f'O aluno {dados["nome"]} tem média de {dados["media"]:.2f} e a situação é {dados["situacao"]}.')
valores = list() rodando = True while rodando: valor = int(input("Digite um valor: ")) if valor in valores: print("Valor duplicado! Não irei adicionar...") else: valores.append(valor) print("Valor adicionado com sucesso...") while True: continuar = input("Deseja continuar? [S/N] ").upper().strip() if continuar == "N" or continuar == "NAO" or continuar == "NÃO": rodando = False break elif continuar == "SIM" or continuar in "SS": break else: print("Oops! Valor inválido! Digite novamente.") print(f"Você digitou os valores {sorted(valores)}")
with open('./inputs/04.txt') as f: passphrases = f.readlines() first = 0 second = 0 are_only_distinct = lambda x: len(x) == len(set(x)) for line in passphrases: words = line.split() first += are_only_distinct(words) anagrams = [''.join(sorted(word)) for word in words] second += are_only_distinct(anagrams) print(first) print(second)
{ "CDPCQ04700": "계좌 거래내역", # order / 5 / 현물 "CEXAQ21100": "유렉스 주문체결내역조회", # order / 5 / 유렉스 "CEXAQ21200": "유렉스 주문가능 수량/금액 조회", # order / 5 / 유렉스 "CEXAQ31100": "유렉스 야간장잔고및 평가현황", # order / 4 / 유렉스 "CEXAQ31200": "유렉스 예탁금 및 통합잔고조회", # order / 4 / 유렉스 "CEXAQ44200": "EUREX 야간옵션 기간주문체결조회", # order / 3 / 유렉스 "CEXAT11100": "유렉스 매수/매도주문", # order / 5 / 유렉스 "CEXAT11200": "유렉스 정정주문", # order / 4 / 유렉스 "CEXAT11300": "유렉스 취소주문", # order / 4 / 유렉스 "CFOAQ00600": "선물옵션 계좌주문체결내역조회", # order / 5 / 선물 "CFOAQ10100": "선물옵션 주문가능수량조회", # order / 4 / 선물 "CFOAT00100": "선물옵션 정상주문", # order / 5 / 선물 "CFOAT00200": "선물옵션 정정주문", # order / 3 / 선물 "CFOAT00300": "선물옵션 취소주문", # order / 3 / 선물 "CFOBQ10500": "선물옵션 계좌예탁금증거금조회", # order / 2 / 선물 "CFOBQ10800": "선물옵션 옵션매도시 주문증거금조회", # order / 2 / 선물 "CFOEQ11100": "선물옵션가정산예탁금상세", # order / 2 / 선물 "CFOEQ82600": "선물옵션 일별 계좌손익내역", # order / 3 / 선물 "CFOFQ02400": "계좌 미결제 약정현황(평균가)", # order / 3 / 현물 "ChartExcel": "챠트엑셀데이터조회", # data / 2 / 현물 "ChartIndex": "챠트지표데이터조회", # data / 2 / 현물 "CLNAQ00100": "예탁담보융자가능종목현황조회", # order / 1 / 현물 "CSPAQ00600": "계좌별신용한도조회", # order / 3 / 현물 "CSPAQ12200": "현물계좌예수금 주문가능금액 총평가 조회", # order / 3 / 현물 "CSPAQ12300": "BEP단가조회", # order / 3 / 현물 "CSPAQ13700": "현물계좌주문체결내역조회", # order / 3 / 현물 "CSPAQ22200": "현물계좌예수금 주문가능금액 총평가2", # order / 3 / 현물 "CSPAT00600": "현물주문", # order / 5 / 현물 "CSPAT00700": "현물정정주문", # order / 4 / 현물 "CSPAT00800": "현물취소주문", # order / 4 / 현물 "CSPBQ00200": "현물계좌증거금률별주문가능수량조회", # order / 2 / 현물 "FOCCQ33600": "주식계좌 기간별수익률 상세", # order / 4 / 현물 "FOCCQ33700": "선물옵션 기간별 계좌 수익률 현황", # order / 3 / 선물 "MMDAQ91200": "파생상품증거금율조회", # order / 3 / 파생 "t0150": "주식당일매매일지/수수료", # basic / 4 / 현물 "t0151": "주식당일매매일지/수수료(전일)", # basic / 4 / 현물 "t0167": "서버시간조회", # data / 2 / 현물 "t0424": "주식잔고2", # order / 5 / 현물 "t0425": "주식체결/미체결", # order / 5 / 현물 "t0434": "선물/옵션체결/미체결", # order / 5 / 선물 "t0441": "선물/옵션잔고평가(이동평균)", # order / 4 / 선물 "t1101": "주식현재가호가조회", # data / 5 / 현물 "t1102": "주식현재가(시세)조회", # data / 5 / 현물 "t1104": "주식현재가시세메모", # data / 3 / 현물 "t1105": "주식피못/디마크조회", # data / 3 / 현물 "t1301": "주식시간대별체결조회", # data / 4 / 현물 "t1302": "주식분별주가조회", # data / 4 / 현물 "t1305": "기간별주가", # basic / 3 / 현물 "t1308": "주식시간대별체결조회챠트", # data / 4 / 현물 "t1310": "주식당일전일분틱조회", # data / 4 / 현물 "t1403": "신규상장종목조회", # basic / 3 / 현물 "t1404": "관리/불성실/투자유의조회", # basic / 4 / 현물 "t1405": "투자경고/매매정지/정리매매조회", # basic / 4 / 현물 "t1410": "초저유동성조회", # data / 3 / 현물 "t1411": "증거금율별종목조회", # data / 3 / 현물 "t1422": "상/하한", # data / 4 / 현물 "t1427": "상/하한가직전", # data / 4 / 현물 "t1442": "신고/신저가", # data / 4 / 현물 "t1444": "시가총액상위", # basic / 4 / 현물 "t1449": "가격대별매매비중조회", # data / 4 / 현물 "t1452": "거래량상위", # basic / 4 / 현물 "t1463": "거래대금상위", # basic / 4 / 현물 "t1471": "시간대별호가잔량추이", # data / 4 / 현물 "t1475": "체결강도추이", # data / 4 / 현물 "t1485": "예상지수", # data / 4 / 현물 "t1486": "시간별예상체결가", # data / 3 / 현물 "t1488": "예상체결가등락율상위조회", # data / 3 / 현물 "t1489": "예상체결량상위조회", # data / 3 / 현물 "t1511": "업종현재가", # data / 4 / 현물 "t1514": "업종기간별추이", # data / 3 / 현물 "t1516": "업종별종목시세", # data / 3 / 현물 "t1531": "테마별종목", # basic / 5 / 현물 "t1532": "종목별테마", # basic / 5 / 현물 "t1533": "특이테마", # basic / 5 / 현물 "t1537": "테마종목별시세조회", # data / 5 / 현물 "t1601": "투자자별종합", # data / 4 / 현물 "t1602": "시간대별투자자매매추이", # data / 4 / 현물 "t1603": "시간대별투자자매매추이상세", # data / 4 / 현물 "t1615": "투자자매매종합1", # data / 3 / 현물 "t1617": "투자자매매종합2", # data / 3 / 현물 "t1621": "업종별분별투자자매매동향(챠트용)", # data / 4 / 현물 "t1631": "프로그램매매종합조회", # data / 3 / 현물 "t1632": "시간대별프로그램매매추이", # data / 3 / 현물 "t1633": "기간별프로그램매매추이", # data / 3 / 현물 "t1636": "종목별프로그램매매동향", # data / 3 / 현물 "t1637": "종목별프로그램매매추이", # data / 3 / 현물 "t1638": "종목별잔량/사전공시", # data / 3 / 현물 "t1640": "프로그램매매종합조회(미니)", # data / 3 / 현물 "t1662": "시간대별프로그램매매추이(차트)", # data / 3 / 현물 "t1664": "투자자매매종합(챠트)", # data / 3 / 현물 "t1665": "기간별투자자매매추이(챠트)", # data / 3 / 현물 "t1701": "외인기관종목별동향", # data / 4 / 현물 "t1702": "외인기관종목별동향", # data / 4 / 현물 "t1717": "외인기관종목별동향", # data / 4 / 현물 "t1752": "종목별상위회원사", # data / 3 / 현물 "t1764": "회원사리스트", # basic / 3 / 현물 "t1771": "종목별회원사추이", # data / 3 / 현물 "t1809": "신호조회", # data / 3 / 현물 "t1825": "종목Q클릭검색(씽큐스마트)", # Qclick / 3 / 현물 "t1826": "종목Q클릭검색리스트조회(씽큐스마트)", # Qclick / 3 / 현물 "t1857": "e종목검색(신버전API용)", # Catch / 3 / 현물 "t1866": "서버저장조건리스트조회(API)", # basic / 3 / 현물 "t1901": "ETF현재가(시세)조회", # data / 3 / ETF "t1902": "ETF시간별추이", # data / 3 / ETF "t1903": "ETF일별추이", # data / 3 / ETF "t1904": "ETF구성종목조회", # data / 3 / ETF "t1906": "ETFLP호가", # data / 3 / ETF "t1921": "신용거래동향", # basic / 3 / 현물 "t1926": "종목별신용정보", # data / 3 / 현물 "t1927": "공매도일별추이", # data / 3 / 현물 "t1941": "종목별대차거래일간추이", # data / 3 / 현물 "t1950": "ELW현재가(시세)조회", # data / 3 / ELW "t1951": "ELW시간대별체결조회", # data / 3 / ELW "t1954": "ELW일별주가", # data / 3 / ELW "t1955": "ELW지표검색", # data / 3 / ELW "t1956": "ELW현재가(확정지급액)조회", # data / 3 / ELW "t1958": "ELW종목비교", # data / 3 / ELW "t1959": "LP대상종목정보조회", # data / 2 / ELW "t1960": "ELW등락율상위", # data / 3 / ELW "t1961": "ELW거래량상위", # data / 3 / ELW "t1964": "ELW전광판", # data / 3 / ELW "t1966": "ELW거래대금상위", # data / 3 / ELW "t1971": "ELW현재가호가조회", # data / 3 / ELW "t1972": "ELW현재가(거래원)조회", # data / 3 / ELW "t1973": "ELW시간대별예상체결조회", # data / 3 / ELW "t1974": "ELW기초자산동일종목", # data / 3 / ELW "t1981": "기초자산리스트조회", # data / 3 / ELW "t2101": "선물/옵션현재가(시세)조회", # data / 3 / 선물 "t2105": "선물/옵션현재가호가조회", # data / 3 / 선물 "t2106": "선물/옵션현재가시세메모", # data / 3 / 선물 "t2201": "선물옵션시간대별체결조회", # data / 3 / 선물 "t2203": "기간별주가", # data / 3 / 선물 "t2209": "선물옵션틱분별체결조회챠트", # data / 3 / 선물 "t2210": "선물옵션시간대별체결조회(단일출력용)", # data / 3 / 선물 "t2301": "옵션전광판", # data / 3 / 선물 "t2405": "선물옵션호가잔량비율챠트", # data / 3 / 선물 "t2421": "미결제약정추이", # data / 3 / 선물 "t2541": "상품선물투자자매매동향(실시간)", # data / 3 / 선물 "t2545": "상품선물투자자매매동향(챠트용)", # data / 3 / 선물 "t2830": "EUREXKOSPI200옵션선물현재가(시세)조회", # data / 3 / 유렉스 "t2831": "EUREXKOSPI200옵션선물호가조회", # data / 3 / 유렉스 "t2832": "EUREX야간옵션선물시간대별체결조회", # data / 3 / 유렉스 "t2833": "EUREX야간옵션선물기간별추이", # data / 3 / 유렉스 "t2835": "EUREX옵션선물시세전광판", # data / 3 / 유렉스 "t3102": "뉴스본문", # data / 2 / 현물 "t3202": "종목별증시일정", # basic / 3 / 현물 "t3320": "FNG_요약", # basic / 3 / 현물 "t3341": "재무순위종합", # basic / 3 / 현물 "t3401": "투자의견", # basic / 3 / 현물 "t3518": "해외실시간지수", # data / 3 / 해외 "t3521": "해외지수조회(API용)", # basic / 3 / 해외 "t4201": "주식챠트(종합)", # data / 5 / 현물 "t4203": "업종챠트(종합)", # data / 5 / 현물 "t8401": "주식선물마스터조회(API용)", # data / 3 / 선물 "t8402": "주식선물현재가조회(API용)", # data / 3 / 선물 "t8403": "주식선물호가조회(API용)", # data / 3 / 선물 "t8404": "주식선물시간대별체결조회(API용)", # data / 3 / 선물 "t8405": "주식선물기간별주가(API용)", # data / 3 / 선물 "t8406": "주식선물틱분별체결조회(API용)", # data / 3 / 선물 "t8407": "API용주식멀티현재가조회", # data / 3 / 현물 "t8411": "주식챠트(틱/n틱)", # data / 5 / 현물 "t8412": "주식챠트(N분)", # data / 5 / 현물 "t8413": "주식챠트(일주월)", # data / 5 / 현물 "t8414": "선물옵션차트(틱/n틱)", # data / 3 / 선물 "t8415": "선물/옵션챠트(N분)", # data / 3 / 선물 "t8416": "선물/옵션챠트(일주월)", # data / 3 / 선물 "t8417": "업종차트(틱/n틱)", # data / 5 / 현물 "t8418": "업종챠트(N분)", # data / 5 / 현물 "t8419": "업종챠트(일주월)", # data / 5 / 현물 "t8424": "전체업종", # basic / 5 / 현물 "t8425": "전체테마", # basic / 4 / 현물 "t8426": "상품선물마스터조회(API용)", # data / 3 / 선물 "t8427": "과거데이터시간대별조회", # data / 3 / 선물 "t8428": "증시주변자금추이", # basic / 3 / 현물 "t8429": "EUREX야간옵션선물틱분별체결조회챠트", # data / 3 / 유렉스 "t8430": "주식종목조회", # basic / 5 / 현물 "t8431": "ELW종목조회", # data / 3 / ELW "t8432": "지수선물마스터조회API용", # data / 3 / 선물 "t8433": "지수옵션마스터조회API용", # data / 3 / 선물 "t8434": "선물/옵션멀티현재가조회", # data / 3 / 선물 "t8435": "파생종목마스터조회API용", # data / 3 / 파생 "t8436": "주식종목조회 API용", # basic / 5 / 현물 "t8437": "CME/EUREX마스터조회(API용)", # data / 3 / 유렉스 "t9905": "기초자산리스트조회", # data / 3 / ELW "t9907": "만기월조회", # data / 3 / ELW "t9942": "ELW마스터조회API용", # data / 3 / ELW "t9943": "지수선물마스터조회API용", # data / 3 / 선물 "t9944": "지수옵션마스터조회API용", # data / 3 / 선물 "t9945": "주식마스터조회API용-종목명40bytes" # data / 5 / 현물 }
# 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 sumNumbers(self, root: TreeNode) -> int: res = [] num = root.val val=0 self.helper(root,val,res) return sum(res) def helper(self,root,val,res): if not root: return if not root.left and not root.right: val=val*10+root.val res.append(val) return if root: val=val*10+root.val self.helper(root.left,val,res) self.helper(root.right,val,res)
def cart_prod(*sets): result = [[]] set_list = list(sets) for s in set_list: result = [x+[y] for x in result for y in s] if (len(set_list) > 0): return {tuple(prod) for prod in result} else: return set(tuple()) A = {1} B = {1, 2} C = {1, 2, 3} X = {'a'} Y = {'a', 'b'} Z = {'a', 'b', 'c'} print(cart_prod(A, B, C)) print(cart_prod(X, Y, Z))
class Solution: def getRow(self, rowIndex): def n_c_r(n, r): numerator = 1 for i in xrange(1, r + 1): numerator *= n - (i - 1) numerator /= i return numerator return [n_c_r(rowIndex, i) for i in xrange(rowIndex + 1)]
def somme_consecutive(n: int) -> bool: """ Description: Verifie si un nombre peut être exprimé en somme de deux ou plusieurs nombres entiers positifs consecutifs. Paramètres: n: {int} -- Le nombre à tester. Retourne: {bool} -- True si le nombre peut être exprimé en somme de deux ou plusieurs nombres entiers positifs consecutifs, False sinon. Exemple: >>> somme_consecutive(10) True >>> somme_consecutive(64) False La fonction bool() retourne la valeur booléenne d'un objet. """ return bool(n & (n - 1))
class Solution: def removeOuterParentheses(self, S: str) -> str: stack = [] is_assemble = False assembler = "" result = "" for p in S: if p == "(": if is_assemble: assembler += p if not stack: is_assemble = True stack.append(p) else: stack.pop() if not stack: result += assembler assembler = "" is_assemble = False if is_assemble: assembler += p return result
message = "Hello python world" print(message) message = "Hello python crash course world" print(message)
class Solution: def singleNumber(self, nums: List[int]) -> int: d = {} for n in nums: if n in d: d[n] += 1 else: d[n] = 1 for k in d: if d[k] == 1: return k
def postorder(tree): if tree != None: postorder(tree.getLeftChild()) postorder(tree.getRightChild()) print(tree.getRootVal())
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ 阶乘, n! 分成 n 和 (n - 1)! """ def test(fact): assert fact(0) == 1 assert fact(1) == 1 assert fact(2) == 2 assert fact(4) == 2 * 3 * 4 == 24 def fact(n): if n < 2: return 1 t = 1 for i in range(2, n + 1): t *= i return t test(fact) def rfact(n): if n < 2: return 1 return n * rfact(n - 1) test(rfact)
# Set random seed np.random.seed(0) # Generate data true_mean = 5 true_standard_dev = 1 n_samples = 1000 x = np.random.normal(true_mean, true_standard_dev, size = (n_samples,)) # We define the function to optimise, the negative log likelihood def negLogLike(theta): """ Function for computing the negative log-likelihood given the observed data and given parameter values stored in theta. Args: theta (ndarray): normal distribution parameters (mean is theta[0], variance is theta[1]) Returns: Calculated negative Log Likelihood value! """ return -sum(np.log(norm.pdf(x, theta[0], theta[1]))) # Define bounds, var has to be positive bnds = ((None, None), (0, None)) # Optimize with scipy! optimal_parameters = sp.optimize.minimize(negLogLike, (2, 2), bounds = bnds) print("The optimal mean estimate is: " + str(optimal_parameters.x[0])) print("The optimal variance estimate is: " + str(optimal_parameters.x[1])) # optimal_parameters contains a lot of information about the optimization, # but we mostly want the mean and variance
__version__ = "0.8.10" __format_version__ = 3 __format_version_mcool__ = 2 __format_version_scool__ = 1
class Solution: def maxIncreaseKeepingSkyline(self, grid: List[List[int]]) -> int: row_max = list(map(max, grid)) col_max = list(map(max, zip(*grid))) return sum( min(row_max[i], col_max[j]) - val for i, row in enumerate(grid) for j, val in enumerate(row) )
# hw08_02 for i in range(1, 9+1, 2): print("{:^9}".format("^"*i)) ''' ^ ^^^ ^^^^^ ^^^^^^^ ^^^^^^^^^ '''
# # @lc app=leetcode id=430 lang=python3 # # [430] Flatten a Multilevel Doubly Linked List # """ # Definition for a Node. class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child """ class Node: def __init__(self, val, prev, next, child): self.val = val self.prev = prev self.next = next self.child = child def __repr__(self): return str(self.val) class Solution: def flatten(self, head: Node) -> Node: dummy = Node(0, None, None, None) res = dummy stack = list() while head: res.next = head res = res.next if head.child: if head.next: stack.append(head.next) head.next = head.child head.child.prev = head head = head.child head.prev.child = None continue if head.next is None: if not stack: head.next = None head.child = None break else: n = stack.pop() head.next = n head.child = None n.prev = head head = n continue head = head.next return dummy.next def create_node(): node_1 = Node(1, None, None, None) node_2 = Node(2, None, None, None) node_3 = Node(3, None, None, None) node_4 = Node(4, None, None, None) node_5 = Node(5, None, None, None) node_6 = Node(6, None, None, None) node_7 = Node(7, None, None, None) node_8 = Node(8, None, None, None) node_9 = Node(9, None, None, None) node_10 = Node(10, None, None, None) node_11 = Node(11, None, None, None) node_12 = Node(12, None, None, None) node_1.next = node_2 node_2.prev = node_1 node_2.next = node_3 node_3.prev = node_2 node_3.next = node_4 node_3.child = node_7 node_4.prev = node_3 node_4.next = node_5 node_5.prev = node_4 node_5.next = node_6 node_6.prev = node_5 node_7.next = node_8 node_8.prev = node_7 node_8.next = node_9 node_8.child = node_11 node_9.prev = node_8 node_9.next = node_10 node_10.prev = node_9 node_11.next = node_12 node_12.prev = node_11 return node_1 if __name__ == '__main__': Solution().flatten(create_node())
# http://www.codewars.com/kata/55c933c115a8c426ac000082/ def eval_object(v): return {"+": v['a'] + v['b'], "-": v['a'] - v['b'], "/": v['a'] / v['b'], "*": v['a'] * v['b'], "%": v['a'] % v['b'], "**": v['a'] ** v['b']}.get(v.get('operation', 1))
a = 5 b = 3 c = 72 d = 304 s1 = 'string' pi = 3.141592 print('{0:-^48}'.format(' % 사용 ')) print('%d + %d = %d' % (a, b, a + b)) print('%d + %d = %d' % (c, d, c + d)) print('*' * 16) print('%2d + %2d = %2d' % (a, b, a + b)) print('%2d + %2d = %2d' % (c, d, c + d)) print('*' * 16) print('%03d + %03d = %03d' % (a, b, a + b)) print('%03d + %03d = %03d' % (c, d, c + d)) print('*' * 16) print('string: %s' % s1) print('string: [%10s]' % s1) print('string: [%-10s]' % s1) print('*' * 16) print('pi = %f' % pi) print('pi = %.3f' % pi) print('pi = %10.3f' % pi) print('%d = 0x%04X' % (d, d)) print() print('{0:-^48}'.format(' Use format() ')) print('{0} + {1} = {2}'.format(a, b, a + b)) print('{0} + {1} = {2}'.format(c, d, c + d)) print('*' * 16) print('{0:2} + {1:2} = {2:2}'.format(a, b, a + b)) print('{0:2} + {1:2} = {2:2}'.format(c, d, c + d)) print('*' * 16) print('{0:03} + {1:03} = {2:03}'.format(a, b, a + b)) print('{0:03} + {1:03} = {2:03}'.format(c, d, c + d)) print() print('{0:-^48}'.format(' Use f formatting ')) print(f'{a} + {b} = {a + b}') print(f'{c} + {d} = {c + d}') print('*' * 16) print(f'{a:2} + {b:2} = {a + b:2}') print(f'{c:2} + {d:2} = {c + d:2}') print('*' * 16) print(f'{a:03} + {b:03} = {a + b:03}') print(f'{c:03} + {d:03} = {c + d:03}') print('*' * 16) print(f'string: {s1}') print(f'string: {s1:<10}') print(f'string: {s1:>10}') print('*' * 16) print(f'pi: {pi}') print(f'pi: {pi:.3f}') print(f'pi: {pi:8.3f}') print(f'pi: {pi:08.3f}') print('*' * 16) print(f'{d} = 0x{d:04X}')
def oddNumbers(l, r): result = [] for i in range(l, r + 1): if i % 2 == 1: result.append(i) return result
description = 'Lambda power supplies' group = 'optional' tango_base = 'tango://172.28.77.81:10000/antares/' devices = dict( I_lambda1 = device('nicos.devices.entangle.PowerSupply', description = 'Current 1', tangodevice = tango_base + 'lambda1/current', precision = 0.04, timeout = 10, ), )
def solution(): def integers(): num = 1 while True: yield num num += 1 def halves(): for i in integers(): yield i / 2 def take(n, seq): take_list = [] for num in seq: if len(take_list) == n: return take_list take_list.append(num) return take, halves, integers take = solution()[0] halves = solution()[1] print(take(5, halves()))
def longest_consecutive_subsequence(input_list): # TODO: Write longest consecutive subsequence solution input_list.sort() # iterate over the list and store element in a suitable data structure subseq_indexes = {} index = 0 for el in input_list: if index not in subseq_indexes: subseq_indexes[index] = [el] elif subseq_indexes[index][-1] + 1 == el: subseq_indexes[index].append(el) else: index += 1 subseq_indexes[index] = [el] # traverse / go over the data structure in a reasonable order to determine the solution longest_subseq = max(subseq_indexes.values(), key=len) return longest_subseq res = longest_consecutive_subsequence([5, 4, 7, 10, 1, 3, 55, 2, 6]) print(res) # should be [1, 2, 3, 4, 5, 6, 7]
"""DNA na RNA""" DNA_RNA = { 'G':'C', 'C':'G', 'T':'A', 'A':'U', } def transcribe_rna(dna): rna = '' for i in dna: rna += DNA_RNA[i] return rna def validate_dna(dna): return set(dna).issubset(set('GCTA')) def main(): while True: my_dna = input('Type DNA sequence: ') if not validate_dna(my_dna): answer = input('Invalid DNA sequence, try again (y/n)? ') if answer.lower() != 'y': break continue rna = transcribe_rna(my_dna) print(f'Transcribed RNA: {rna}') if __name__ == '__main__': main()
def value_2_class(value): if value < 0.33: return [1, 0, 0] elif 0.33 <= value < 0.66: return [0, 1, 0] else: # I know that he is not necessary the else but I like it return [0, 0, 1]
lista = [] maior = 0 menor = 9 ** 9 maiorn = list() menorn = list() while True: pessoa = [str(input('Nome: ')), float(input('Peso: '))] lista.append(pessoa[:]) co = str(input('Continuar?[S/N]: ')) if co in 'Nn': break for l in lista: if l[1] >= maior: if l[1] > maior and l != lista[0]: maiorn.pop() maior = l[1] maiorn.append(l[0]) if l[1] <= menor: if l[1] < menor and l != lista[0]: menorn.pop() menor = l[1] menorn.append(l[0]) print(f'Maior peso: {maior}Kg de {maiorn}') print(f'Menor peso: {menor}Kg de {menorn}')
# all jobs for letters created via the api must have this filename LETTER_API_FILENAME = 'letter submitted via api' LETTER_TEST_API_FILENAME = 'test letter submitted via api' # S3 tags class Retention: KEY = 'retention' ONE_WEEK = 'ONE_WEEK'
class Queue: def __init__(self, number_of_queues, array_lenght): self.number_of_queues = number_of_queues self.array_length = array_lenght self.array = [-1] * array_lenght self.front = [-1] * number_of_queues self.back = [-1] * number_of_queues self.next_array = list(range(1, array_lenght)) self.next_array.append(-1) self.free = 0 def isEmpty(self, queue_number): return(True if self.front[queue_number] == -1 else False) def isFull(self, queue_number): return(True if self.free == -1 else False) def EnQueue(self, item, queue_number): if(self.isFull(queue_number)): print("Queue Full") return next_free = self.next_array[self.free] if(self.isEmpty(queue_number)): self.front[queue_number] = self.back[queue_number] = self.free else: self.next_array[self.back[queue_number]] = self.free self.back[queue_number] = self.free self.next_array[self.free] = -1 self.array[self.free] = item self.free = next_free def DeQueue(self, queue_number): if(self.isEmpty(queue_number)): print("Queue Empty") return front_index = self.front[queue_number] self.front[queue_number] = self.next_array[front_index] self.next_array[front_index] = self.free self.free = front_index return(self.array[front_index]) if __name__ == "__main__": q = Queue(3, 10) q.EnQueue(15, 2) q.EnQueue(45, 2) q.EnQueue(17, 1) q.EnQueue(49, 1) q.EnQueue(39, 1) q.EnQueue(11, 0) q.EnQueue(9, 0) q.EnQueue(7, 0) print("Dequeued element from queue 2 is {}".format(q.DeQueue(2))) print("Dequeued element from queue 1 is {}".format(q.DeQueue(1))) print("Dequeued element from queue 0 is {}".format(q.DeQueue(0)))
hora = float(input('INFORME AS HORAS POR FAVOR: ')) if hora <=11: print ('BOM DIA!!!') if hora >= 12 and hora <= 17: print ('BOA TARDE!!!') if hora >= 18 and hora <= 23: print ('BOA NOITE!!!') print ('OBRIGADO, VOLTE SEMPRE!!!')
# Your Fitbit access credentials, which must be requested from Fitbit. # You must provide these in your project's settings. FITAPP_CONSUMER_KEY = None FITAPP_CONSUMER_SECRET = None # The verification code for verifying subscriber endpoints FITAPP_VERIFICATION_CODE = None # Where to redirect to after Fitbit authentication is successfully completed. FITAPP_LOGIN_REDIRECT = '/' # Where to redirect to after Fitbit authentication credentials have been # removed. FITAPP_LOGOUT_REDIRECT = '/' # By default, don't subscribe to user data. Set this to true to subscribe. FITAPP_SUBSCRIBE = False # Only retrieve data for resources in FITAPP_SUBSCRIPTIONS. The default value # of none results in all subscriptions being retrieved. Override it to be an # OrderedDict of just the items you want retrieved, in the order you want them # retrieved, eg: # from collections import OrderedDict # FITAPP_SUBSCRIPTIONS = OrderedDict([ # ('foods', ['log/caloriesIn', 'log/water']), # ]) # The default ordering is ['category', 'resource'] when a subscriptions dict is # not specified. FITAPP_SUBSCRIPTIONS = None # The initial delay (in seconds) when doing the historical data import FITAPP_HISTORICAL_INIT_DELAY = 10 # The delay (in seconds) between items when doing requests FITAPP_BETWEEN_DELAY = 5 # By default, don't try to get intraday time series data. See # https://dev.fitbit.com/docs/activity/#get-activity-intraday-time-series for # more info. FITAPP_GET_INTRADAY = False # The verification code used by Fitbit to verify subscription endpoints. Only # needed temporarily. See: # https://dev.fitbit.com/docs/subscriptions/#verify-a-subscriber FITAPP_VERIFICATION_CODE = None # The template to use when an unavoidable error occurs during Fitbit # integration. FITAPP_ERROR_TEMPLATE = 'fitapp/error.html' # The default message used by the fitbit_integration_warning decorator to # inform the user about Fitbit integration. If a callable is given, it is # called with the request as the only parameter to get the final value for the # message. FITAPP_DECORATOR_MESSAGE = 'This page requires Fitbit integration.' # Whether or not a user must be authenticated in order to hit the login, # logout, error, and complete views. FITAPP_LOGIN_REQUIRED = True # Whether or not intraday data points with step values of 0 are saved # to the database. FITAPP_SAVE_INTRADAY_ZERO_VALUES = False # The default amount of data we pull for each user registered with this app FITAPP_DEFAULT_PERIOD = 'max' # The collection we want to recieve subscription updates for # (e.g. 'activities'). None defaults to all collections. FITAPP_SUBSCRIPTION_COLLECTION = None # The default fitbit scope, None defaults to all scopes, otherwise take # a list of scopes (eg. ["activity", "profile", "settings"]) FITAPP_SCOPE = None
N, K = map(int, input().split()) ans = 0 for i in reversed(range(1, N+1)): n = 1 # i番目のサイコロの目(=i)がKを超えるには何回コインで面を出す必要があるか while i < K: # 2倍にしている n = n*2 i = i*2 # Kを超える確率(=超えるために必要なコインが連続で表になる確率をansに加算する) ans += 1/n # ansには各目が出る確率の合計が格納されているので値をN(サイコロの目の数)で割る print(ans/N)
# -*- coding: utf-8 -*- def main(): s = input()[::-1] w_count = 0 ans = 0 for si in s: if si == 'W': w_count += 1 else: ans += w_count print(ans) if __name__ == '__main__': main()
src = ['board.c'] component = aos_board_component('board_mk3060', 'moc108', src) aos_global_config.add_ld_files('memory.ld.S') build_types="" linux_only_targets="athostapp blink coapapp helloworld http2app id2_app itls_app linkkit_gateway linkkitapp meshapp modbus_demo mqttapp otaapp prov_app tls udataapp udevapp ulocationapp yts"
class Config(object): pass class Production(Config): ELASTICSEARCH_HOST = 'elasticsearch' JANUS_HOST = 'janus' class Development(Config): ELASTICSEARCH_HOST = '127.0.0.1' JANUS_HOST = '127.0.0.1'
string = input() vowels = {'a', 'e', 'i', 'o', 'u'} v = sum(1 for char in string if char.lower() in vowels) print(v, len(string)-v)
#Copyright ReportLab Europe Ltd. 2000-2016 #see license.txt for license details #history http://www.reportlab.co.uk/cgi-bin/viewcvs.cgi/public/reportlab/trunk/reportlab/lib/enums.py __version__='3.3.0' __doc__=""" Container for constants. Hardly used! """ TA_LEFT = 0 TA_CENTER = 1 TA_RIGHT = 2 TA_JUSTIFY = 4
_base_ = [ '../../_base_/models/convnext/convnext-tiny.py', './dataset.py', './schedule.py', './default_runtime.py', ] custom_hooks = [dict(type='EMAHook', momentum=4e-5, priority='ABOVE_NORMAL')] model = dict( type='TextureMixClassifier', style_weight=1.5, content_weight=0.5, mix_lr=0.03, mix_iter=15, backbone=dict( type='ConvNeXtTextureMix', ), head=dict( num_classes=20, ), ) # model = dict( # pretrained='data/convnext-tiny_3rdparty_32xb128-noema.pth', # head=dict( # num_classes=20, # ), # backbone=dict( # frozen_stages=4, # ), # )
# -*- coding: utf-8 -*- #Comentário de uma linha print("Hello World!") print("Olá Mundo!") print (2 * 2) print (2 / 2) print (3 ** 2) print (10 % 3) minha_variavel = "Olá Mundo!" print(minha_variavel) """ Comentário com diversas linhas """
N = int(input()) X = input().split() for i in range(N): X[i] = int(X[i]) minimum = min(X) result = X.index(minimum) + 1 print(result)
def generate(event, context): print(event) response = { "statusCode": 200, "body": "this worked" } return response
__title__ = 'Voice Collab' __description__ = "Let's harness the power of voice to collaborate and interact with your code and the people you work with" __email__ = "santhoshkdhana@gmail.com" __author__ = 'Santhosh Kumar' __github__ = 'https://github.com/Santhoshkumard11/Voice-Collab' __license__ = 'MIT' __copyright__ = 'Copyright @2022 - Santhosh Kumar'
# IBM Preliminary Test direction,floor,floor_requests,z = input(),int(input()),sorted(list(map(int,input().split())),reverse=True),0 if(floor_requests[-1]>=0 and floor_requests[0]<=15 and (direction=="UP" or direction=="DN")): while(floor_requests[z]>floor): z+=1 print(*(floor_requests[:z][::-1]+floor_requests[z:]),sep="\n") if(direction=="UP") else print(*(floor_requests[z:]+floor_requests[:z][::-1]),sep="\n") else: print("Invalid")
""" Bar configuration constants """ # # Colours # BG_COL = "#1b1b1b" BG_SEC_COL = "#262626" FG_COL = "#9e9e9e" FG_SEC_COL = "#616161" HL_COL = "#7cafc2" # # Placeholder space # BATTERY_PLACEHOLDER = " " WORKSPACE_PLACEHOLDER = " " CLOCK_PLACEHOLDER = " " VOLUME_PLACEHOLDER = " " GENERAL_PLACEHOLDER = " " # # Fonts # TEXT_FONT = "DroidSansMono-8" ICON_FONT = "FontAwesome"
""" This file will generate output that will be in error because the name of this module (tests) clashes with the @tests annotation. """ def this_wont_work(): pass
""" A python file must contain a prefix to be detected by pytest as a test file. You can run the test using: pytest tests/must_have_a_prefx.py To allow pytest to find this file add the test_ prefix, e.g.: test_basics.py once done you can run it using: pytest test.py """ def test_assertions(): """ Most of the times we will use assertions to run our tests. An assert accepts a boolean value, either True or False. Most of the times we have a single assert, but we can use more than one. If the value: - is True the test is considered passed - is False the test is considered failing Make this test pass, """ assert False, "Fix me" def test_one_is_two(): """ This will raise an assertion error: E AssertionError: One is not two! E assert 1 == 2 When the test passes the message will not contribute to the noise. As exercise try to fix this test. """ assert 1 == 2, 'One is not two!' def this_will_not_run(): """ To run this function needs to have the test_ prefix, e.g.: As exercise try to rename this test. """ assert False, "This will not fail"
def compute_single_neuron_isis(spike_times, neuron_idx): """Compute a vector of ISIs for a single neuron given spike times. Args: spike_times (list of 1D arrays): Spike time dataset, with the first dimension corresponding to different neurons. neuron_idx (int): Index of the unit to compute ISIs for. Returns: isis (1D array): Duration of time between each spike from one neuron. """ # Extract the spike times for the specified neuron single_neuron_spikes = spike_times[neuron_idx] # Compute the ISIs for this set of spikes isis = np.diff(single_neuron_spikes) return isis single_neuron_isis = compute_single_neuron_isis(spike_times, neuron_idx=283) with plt.xkcd(): plt.hist(single_neuron_isis, bins=50, histtype="stepfilled") plt.axvline(single_neuron_isis.mean(), color="orange", label="Mean ISI") plt.xlabel("ISI duration (s)") plt.ylabel("Number of spikes") plt.legend()
sequence = input("Enter your sequence: ") sequence_list = sequence[1:len(sequence)-1].split(", ") subset_sum = False for element in sequence_list: for other in sequence_list: if int(element) + int(other) == 0: subset_sum = True print(str(subset_sum))
# AUTOGENERATED BY NBDEV! DO NOT EDIT! __all__ = ["index", "modules", "custom_doc_links", "git_url"] index = {"get_py_files": "01_nbutils.ipynb", "get_cells_one_nb": "01_nbutils.ipynb", "write_code_cell": "01_nbutils.ipynb", "py_to_nb": "01_nbutils.ipynb", "get_module_text": "01_nbutils.ipynb", "write_module_text": "01_nbutils.ipynb", "clear_all_modules": "01_nbutils.ipynb", "simple_export_one_nb": "01_nbutils.ipynb", "simple_export_all_nb": "01_nbutils.ipynb", "get_corr": "02_tabutils.ipynb", "corr_drop_cols": "02_tabutils.ipynb", "rf_feat_importance": "02_tabutils.ipynb", "plot_fi": "02_tabutils.ipynb", "TabularPandas.export": "02_tabutils.ipynb", "load_pandas": "02_tabutils.ipynb", "create": "03_Tracking.ipynb", "append": "03_Tracking.ipynb", "delete": "03_Tracking.ipynb", "print_keys": "03_Tracking.ipynb", "get_stat": "03_Tracking.ipynb", "get_stats": "03_Tracking.ipynb", "print_best": "03_Tracking.ipynb", "graph_stat": "03_Tracking.ipynb", "graph_stats": "03_Tracking.ipynb", "run_bash": "04_kaggle.ipynb", "update_datset": "04_kaggle.ipynb", "create_dataset": "04_kaggle.ipynb", "download_dataset_metadata": "04_kaggle.ipynb", "download_dataset_content": "04_kaggle.ipynb", "download_dataset": "04_kaggle.ipynb", "add_library_to_dataset": "04_kaggle.ipynb", "bin_df": "05_splitting.ipynb", "kfold_Stratified_df": "05_splitting.ipynb"} modules = ["nbutils.py", "tabutils.py", "tracking.py", "kaggle.py", "splitting.py"] doc_url = "https://Isaac.Flath@gmail.com.github.io/perutils/" git_url = "https://github.com/Isaac.Flath@gmail.com/perutils/tree/{branch}/" def custom_doc_links(name): return None
# # PySNMP MIB module MITEL-DHCP-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/MITEL-DHCP-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:02:56 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueSizeConstraint, ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Unsigned32, Counter64, Bits, TimeTicks, enterprises, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, Gauge32, Integer32, Counter32, ObjectIdentity, MibIdentifier, ModuleIdentity, IpAddress = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "Counter64", "Bits", "TimeTicks", "enterprises", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "Gauge32", "Integer32", "Counter32", "ObjectIdentity", "MibIdentifier", "ModuleIdentity", "IpAddress") RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TextualConvention") mitelRouterDhcpGroup = ModuleIdentity((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3)) mitelRouterDhcpGroup.setRevisions(('2005-11-07 12:00', '2003-03-21 12:31', '1999-03-01 00:00',)) if mibBuilder.loadTexts: mitelRouterDhcpGroup.setLastUpdated('200511071200Z') if mibBuilder.loadTexts: mitelRouterDhcpGroup.setOrganization('MITEL Corporation') class MitelDhcpServerProtocol(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4)) namedValues = NamedValues(("none", 1), ("bootp", 2), ("dhcp", 3), ("bootp-or-dhcp", 4)) class MitelDhcpServerOptionList(TextualConvention, Integer32): status = 'current' subtypeSpec = Integer32.subtypeSpec + ConstraintsUnion(SingleValueConstraint(2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 1)) namedValues = NamedValues(("time-offset", 2), ("default-router", 3), ("time-server", 4), ("name-server", 5), ("dns-server", 6), ("log-server", 7), ("cookie-server", 8), ("lpr-server", 9), ("impress-server", 10), ("resource-location-server", 11), ("host-name", 12), ("boot-file-size", 13), ("merit-dump-file-name", 14), ("domain-name", 15), ("swap-server", 16), ("root-path", 17), ("extension-path", 18), ("ip-forwarding", 19), ("non-local-source-routing", 20), ("policy-filter", 21), ("max-datagram-reassembly", 22), ("default-ip-time-to-live", 23), ("path-MTU-aging-timeout", 24), ("path-MTU-plateau-table", 25), ("interface-MTU-value", 26), ("all-subnets-are-local", 27), ("broadcast-address", 28), ("perform-mask-discovery", 29), ("mask-supplier", 30), ("perform-router-discovery", 31), ("router-solicitation-address", 32), ("static-route", 33), ("trailer-encapsulation", 34), ("arp-cache-timeout", 35), ("ethernet-encapsulation", 36), ("tcp-default-ttl", 37), ("tcp-keepalive-interval", 38), ("tcp-keepalive-garbage", 39), ("nis-domain-name", 40), ("nis-server", 41), ("ntp-server", 42), ("vendor-specific-information", 43), ("netbios-ip-name-server", 44), ("netbios-ip-dgram-distrib-server", 45), ("netbios-ip-node-type", 46), ("netbios-ip-scope", 47), ("x-window-font-server", 48), ("x-window-display-manager", 49), ("nis-plus-domain", 64), ("nis-plus-server", 65), ("tftp-server-name", 66), ("bootfile-name", 67), ("mobile-ip-home-agent", 68), ("smtp-server", 69), ("pop3-server", 70), ("nntp-server", 71), ("www-server", 72), ("finger-server", 73), ("irc-server", 74), ("streettalk-server", 75), ("streettalk-directory-assistance-server", 76), ("requested-ip", 50), ("lease-time", 51), ("option-overload", 52), ("message-type", 53), ("server-identifier", 54), ("parameter-request-list", 55), ("message", 56), ("max-dhcp-message-size", 57), ("renewal-time-value-t1", 58), ("rebinding-time-value-t2", 59), ("vendor-class-identifier", 60), ("client-identifier", 61), ("subnet-mask", 1)) mitel = MibIdentifier((1, 3, 6, 1, 4, 1, 1027)) mitelProprietary = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4)) mitelPropIpNetworking = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8)) mitelIpNetRouter = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1)) mitelIdentification = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1)) mitelIdCallServers = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 2)) mitelIdCsIpera1000 = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 1, 2, 4)) mitelDhcpRelayAgentEnable = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone(2)).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpRelayAgentEnable.setStatus('current') mitelDhcpRelayAgentMaxHops = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpRelayAgentMaxHops.setStatus('current') mitelDhcpRelayAgentBroadcast = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpRelayAgentBroadcast.setStatus('current') mitelDhcpRelayAgentServerTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 3), ) if mibBuilder.loadTexts: mitelDhcpRelayAgentServerTable.setStatus('current') mitelDhcpRelayAgentServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 3, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpRelayAgentServerAddr")) if mibBuilder.loadTexts: mitelDhcpRelayAgentServerEntry.setStatus('current') mitelDhcpRelayAgentServerAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 3, 1, 1), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpRelayAgentServerAddr.setStatus('current') mitelDhcpRelayAgentServerName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 3, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpRelayAgentServerName.setStatus('current') mitelDhcpRelayAgentServerStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 3, 1, 3), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpRelayAgentServerStatus.setStatus('current') mitelDhcpServerGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5)) mitelDhcpServerGeneralGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 1)) mitelDhcpServerGeneralEnable = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2), ("autoconfig", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerGeneralEnable.setStatus('current') mitelDhcpServerGeneralGateway = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("this-if-first", 1), ("this-if-last", 2), ("not-this-if", 3)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerGeneralGateway.setStatus('current') mitelDhcpServerGeneralRefDhcpServer = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 1, 3), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerGeneralRefDhcpServer.setStatus('current') mitelDhcpServerGeneralPingStatus = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enable", 1), ("disable", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerGeneralPingStatus.setStatus('current') mitelDhcpServerSubnetTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2), ) if mibBuilder.loadTexts: mitelDhcpServerSubnetTable.setStatus('current') mitelDhcpServerSubnetEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpServerSubnetAddr"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerSubnetSharedNet")) if mibBuilder.loadTexts: mitelDhcpServerSubnetEntry.setStatus('current') mitelDhcpServerSubnetAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerSubnetAddr.setStatus('current') mitelDhcpServerSubnetSharedNet = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerSubnetSharedNet.setStatus('current') mitelDhcpServerSubnetMask = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 3), IpAddress()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerSubnetMask.setStatus('current') mitelDhcpServerSubnetGateway = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("this-if-first", 1), ("this-if-last", 2), ("not-this-if", 3), ("default", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerSubnetGateway.setStatus('current') mitelDhcpServerSubnetName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 5), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerSubnetName.setStatus('current') mitelDhcpServerSubnetDeleteTree = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerSubnetDeleteTree.setStatus('current') mitelDhcpServerSubnetStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 2, 1, 7), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpServerSubnetStatus.setStatus('current') mitelDhcpServerRangeTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3), ) if mibBuilder.loadTexts: mitelDhcpServerRangeTable.setStatus('current') mitelDhcpServerRangeEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpServerRangeStart"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerRangeEnd"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerRangeSubnet")) if mibBuilder.loadTexts: mitelDhcpServerRangeEntry.setStatus('current') mitelDhcpServerRangeStart = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerRangeStart.setStatus('current') mitelDhcpServerRangeEnd = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerRangeEnd.setStatus('current') mitelDhcpServerRangeSubnet = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 3), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerRangeSubnet.setStatus('current') mitelDhcpServerRangeProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 4), MitelDhcpServerProtocol()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerRangeProtocol.setStatus('current') mitelDhcpServerRangeGateway = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("this-if-first", 1), ("this-if-last", 2), ("not-this-if", 3), ("default", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerRangeGateway.setStatus('current') mitelDhcpServerRangeLeaseTime = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 6), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerRangeLeaseTime.setStatus('current') mitelDhcpServerRangeName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 7), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerRangeName.setStatus('current') mitelDhcpServerRangeMatchClassId = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerRangeMatchClassId.setStatus('current') mitelDhcpServerRangeDeleteTree = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerRangeDeleteTree.setStatus('current') mitelDhcpServerRangeStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 3, 1, 10), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpServerRangeStatus.setStatus('current') mitelDhcpServerStaticIpTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4), ) if mibBuilder.loadTexts: mitelDhcpServerStaticIpTable.setStatus('current') mitelDhcpServerStaticIpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpServerStaticIpAddr"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerStaticIpSubnet")) if mibBuilder.loadTexts: mitelDhcpServerStaticIpEntry.setStatus('current') mitelDhcpServerStaticIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStaticIpAddr.setStatus('current') mitelDhcpServerStaticIpSubnet = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStaticIpSubnet.setStatus('current') mitelDhcpServerStaticIpProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 3), MitelDhcpServerProtocol()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerStaticIpProtocol.setStatus('current') mitelDhcpServerStaticIpGateway = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("this-if-first", 1), ("this-if-last", 2), ("not-this-if", 3), ("default", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerStaticIpGateway.setStatus('current') mitelDhcpServerStaticIpMacAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 5), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerStaticIpMacAddress.setStatus('current') mitelDhcpServerStaticIpClientId = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 6), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerStaticIpClientId.setStatus('current') mitelDhcpServerStaticIpName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 7), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 16))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerStaticIpName.setStatus('current') mitelDhcpServerStaticIpDeleteTree = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerStaticIpDeleteTree.setStatus('current') mitelDhcpServerStaticIpStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 4, 1, 9), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpServerStaticIpStatus.setStatus('current') mitelDhcpServerOptionTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5), ) if mibBuilder.loadTexts: mitelDhcpServerOptionTable.setStatus('current') mitelDhcpServerOptionEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpServerOptionAddr"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerOptionNumber")) if mibBuilder.loadTexts: mitelDhcpServerOptionEntry.setStatus('current') mitelDhcpServerOptionAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerOptionAddr.setStatus('current') mitelDhcpServerOptionNumber = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5, 1, 2), MitelDhcpServerOptionList()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerOptionNumber.setStatus('current') mitelDhcpServerOptionDisplayFormat = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("default", 1), ("ip-address", 2), ("ascii-string", 3), ("integer", 4), ("octet-string", 5)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerOptionDisplayFormat.setStatus('current') mitelDhcpServerOptionValue = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5, 1, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerOptionValue.setStatus('current') mitelDhcpServerOptionStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 5, 1, 5), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpServerOptionStatus.setStatus('current') mitelDhcpServerLeaseTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6), ) if mibBuilder.loadTexts: mitelDhcpServerLeaseTable.setStatus('current') mitelDhcpServerLeaseEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpServerLeaseAddr")) if mibBuilder.loadTexts: mitelDhcpServerLeaseEntry.setStatus('current') mitelDhcpServerLeaseAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 1), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseAddr.setStatus('current') mitelDhcpServerLeaseSubnet = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 2), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseSubnet.setStatus('current') mitelDhcpServerLeaseRange = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 3), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseRange.setStatus('current') mitelDhcpServerLeaseType = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("static", 1), ("dynamic", 2), ("configuration-reserved", 3), ("server-reserved", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseType.setStatus('current') mitelDhcpServerLeaseEndTime = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 5), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseEndTime.setStatus('current') mitelDhcpServerLeaseAllowedProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("none", 1), ("bootp", 2), ("dhcp", 3), ("bootp-or-dhcp", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseAllowedProtocol.setStatus('current') mitelDhcpServerLeaseServedProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("none", 1), ("bootp", 2), ("dhcp", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseServedProtocol.setStatus('current') mitelDhcpServerLeaseMacAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 8), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseMacAddress.setStatus('current') mitelDhcpServerLeaseClientId = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 9), OctetString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseClientId.setStatus('current') mitelDhcpServerLeaseHostName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseHostName.setStatus('current') mitelDhcpServerLeaseDomainName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 11), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 255))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseDomainName.setStatus('current') mitelDhcpServerLeaseServedTime = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 12), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerLeaseServedTime.setStatus('current') mitelDhcpServerLeaseStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 6, 1, 13), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpServerLeaseStatus.setStatus('current') mitelDhcpServerStatsGroup = MibIdentifier((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7)) mitelDhcpServerStatsNumServers = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStatsNumServers.setStatus('current') mitelDhcpServerStatsConfSubnets = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStatsConfSubnets.setStatus('current') mitelDhcpServerStatsConfRanges = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStatsConfRanges.setStatus('current') mitelDhcpServerStatsConfStatic = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStatsConfStatic.setStatus('current') mitelDhcpServerStatsConfOptions = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStatsConfOptions.setStatus('current') mitelDhcpServerStatsConfLeases = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 7, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerStatsConfLeases.setStatus('current') mitelDhcpServerVendorInfoTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8), ) if mibBuilder.loadTexts: mitelDhcpServerVendorInfoTable.setStatus('current') mitelDhcpServerVendorInfoEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpServerOptionAddr"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerOptionNumber"), (0, "MITEL-DHCP-MIB", "mitelDhcpServerVendorInfoID")) if mibBuilder.loadTexts: mitelDhcpServerVendorInfoEntry.setStatus('current') mitelDhcpServerVendorInfoID = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerVendorInfoID.setStatus('current') mitelDhcpServerVendorInfoName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8, 1, 2), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpServerVendorInfoName.setStatus('current') mitelDhcpServerVendorInfoOptionDisplayFormat = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("default", 1), ("ip-address", 2), ("ascii-string", 3), ("integer", 4), ("octet-string", 5)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerVendorInfoOptionDisplayFormat.setStatus('current') mitelDhcpServerVendorInfoOptionValue = MibScalar((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8, 1, 4), OctetString().subtype(subtypeSpec=ValueSizeConstraint(1, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpServerVendorInfoOptionValue.setStatus('current') mitelDhcpServerVendorInfoStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 5, 8, 1, 5), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: mitelDhcpServerVendorInfoStatus.setStatus('current') mitelDhcpClientTable = MibTable((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6), ) if mibBuilder.loadTexts: mitelDhcpClientTable.setStatus('current') mitelDhcpClientEntry = MibTableRow((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1), ).setIndexNames((0, "MITEL-DHCP-MIB", "mitelDhcpClientIndex")) if mibBuilder.loadTexts: mitelDhcpClientEntry.setStatus('current') mitelDhcpClientIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientIndex.setStatus('current') mitelDhcpClientId = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 2), OctetString()).setMaxAccess("readwrite") if mibBuilder.loadTexts: mitelDhcpClientId.setStatus('current') mitelDhcpClientLeaseAction = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("none", 1), ("release", 2), ("renew", 3)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientLeaseAction.setStatus('current') mitelDhcpClientIpAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 4), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientIpAddress.setStatus('current') mitelDhcpClientLeaseObtained = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 5), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientLeaseObtained.setStatus('current') mitelDhcpClientLeaseExpired = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 6), TimeTicks()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientLeaseExpired.setStatus('current') mitelDhcpClientDefaultGateway = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 7), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientDefaultGateway.setStatus('current') mitelDhcpClientServerIp = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 8), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientServerIp.setStatus('current') mitelDhcpClientPrimaryDns = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 9), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientPrimaryDns.setStatus('current') mitelDhcpClientSecondaryDns = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 10), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientSecondaryDns.setStatus('current') mitelDhcpClientPrimaryWins = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 11), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientPrimaryWins.setStatus('current') mitelDhcpClientSecondaryWins = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 12), IpAddress()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientSecondaryWins.setStatus('current') mitelDhcpClientDomainName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 13), OctetString()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientDomainName.setStatus('current') mitelDhcpClientName = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 14), OctetString()).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientName.setStatus('current') mitelDhcpClientAdminState = MibTableColumn((1, 3, 6, 1, 4, 1, 1027, 4, 8, 1, 3, 6, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readonly") if mibBuilder.loadTexts: mitelDhcpClientAdminState.setStatus('current') mitelIpera1000Notifications = NotificationGroup((1, 3, 6, 1, 4, 1, 1027, 1, 2, 4, 0)).setObjects(("MITEL-DHCP-MIB", "mitelDhcpClientObtainedIp"), ("MITEL-DHCP-MIB", "mitelDhcpClientLeaseExpiry")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): mitelIpera1000Notifications = mitelIpera1000Notifications.setStatus('current') mitelDhcpClientObtainedIp = NotificationType((1, 3, 6, 1, 4, 1, 1027, 1, 2, 4, 0, 404)).setObjects(("MITEL-DHCP-MIB", "mitelDhcpClientIndex"), ("MITEL-DHCP-MIB", "mitelDhcpClientIpAddress"), ("MITEL-DHCP-MIB", "mitelDhcpClientServerIp")) if mibBuilder.loadTexts: mitelDhcpClientObtainedIp.setStatus('current') mitelDhcpClientLeaseExpiry = NotificationType((1, 3, 6, 1, 4, 1, 1027, 1, 2, 4, 0, 405)).setObjects(("MITEL-DHCP-MIB", "mitelDhcpClientIndex")) if mibBuilder.loadTexts: mitelDhcpClientLeaseExpiry.setStatus('current') mibBuilder.exportSymbols("MITEL-DHCP-MIB", mitelDhcpServerLeaseDomainName=mitelDhcpServerLeaseDomainName, mitelDhcpServerRangeSubnet=mitelDhcpServerRangeSubnet, mitelDhcpRelayAgentServerTable=mitelDhcpRelayAgentServerTable, mitelDhcpRelayAgentMaxHops=mitelDhcpRelayAgentMaxHops, mitelDhcpServerRangeGateway=mitelDhcpServerRangeGateway, mitelDhcpServerStaticIpTable=mitelDhcpServerStaticIpTable, mitelDhcpServerRangeStart=mitelDhcpServerRangeStart, mitelDhcpServerVendorInfoOptionValue=mitelDhcpServerVendorInfoOptionValue, mitelDhcpClientLeaseExpired=mitelDhcpClientLeaseExpired, mitelDhcpServerRangeEnd=mitelDhcpServerRangeEnd, mitelDhcpServerSubnetStatus=mitelDhcpServerSubnetStatus, mitelDhcpClientId=mitelDhcpClientId, mitelDhcpClientPrimaryDns=mitelDhcpClientPrimaryDns, mitelDhcpClientLeaseExpiry=mitelDhcpClientLeaseExpiry, mitelDhcpServerStaticIpDeleteTree=mitelDhcpServerStaticIpDeleteTree, mitel=mitel, mitelDhcpServerVendorInfoID=mitelDhcpServerVendorInfoID, mitelDhcpServerLeaseAddr=mitelDhcpServerLeaseAddr, mitelDhcpServerLeaseMacAddress=mitelDhcpServerLeaseMacAddress, mitelDhcpServerOptionEntry=mitelDhcpServerOptionEntry, mitelDhcpServerLeaseTable=mitelDhcpServerLeaseTable, mitelDhcpClientEntry=mitelDhcpClientEntry, mitelDhcpClientIndex=mitelDhcpClientIndex, mitelDhcpServerStatsGroup=mitelDhcpServerStatsGroup, mitelDhcpRelayAgentServerName=mitelDhcpRelayAgentServerName, mitelDhcpRelayAgentServerAddr=mitelDhcpRelayAgentServerAddr, mitelDhcpServerRangeLeaseTime=mitelDhcpServerRangeLeaseTime, mitelIdentification=mitelIdentification, mitelDhcpServerSubnetGateway=mitelDhcpServerSubnetGateway, mitelDhcpServerStatsConfRanges=mitelDhcpServerStatsConfRanges, mitelDhcpServerRangeStatus=mitelDhcpServerRangeStatus, mitelDhcpClientSecondaryDns=mitelDhcpClientSecondaryDns, mitelProprietary=mitelProprietary, mitelDhcpServerGroup=mitelDhcpServerGroup, mitelDhcpServerVendorInfoName=mitelDhcpServerVendorInfoName, mitelDhcpServerOptionStatus=mitelDhcpServerOptionStatus, mitelDhcpServerStatsConfStatic=mitelDhcpServerStatsConfStatic, mitelDhcpServerSubnetEntry=mitelDhcpServerSubnetEntry, mitelDhcpClientDomainName=mitelDhcpClientDomainName, mitelDhcpServerGeneralRefDhcpServer=mitelDhcpServerGeneralRefDhcpServer, mitelDhcpClientAdminState=mitelDhcpClientAdminState, mitelDhcpClientObtainedIp=mitelDhcpClientObtainedIp, mitelDhcpServerStatsConfLeases=mitelDhcpServerStatsConfLeases, mitelDhcpServerStaticIpSubnet=mitelDhcpServerStaticIpSubnet, mitelDhcpServerSubnetAddr=mitelDhcpServerSubnetAddr, mitelDhcpServerLeaseHostName=mitelDhcpServerLeaseHostName, mitelPropIpNetworking=mitelPropIpNetworking, mitelDhcpServerLeaseEntry=mitelDhcpServerLeaseEntry, mitelRouterDhcpGroup=mitelRouterDhcpGroup, mitelDhcpRelayAgentEnable=mitelDhcpRelayAgentEnable, mitelDhcpServerVendorInfoOptionDisplayFormat=mitelDhcpServerVendorInfoOptionDisplayFormat, mitelDhcpServerOptionTable=mitelDhcpServerOptionTable, mitelDhcpServerOptionNumber=mitelDhcpServerOptionNumber, mitelDhcpServerOptionAddr=mitelDhcpServerOptionAddr, mitelIpNetRouter=mitelIpNetRouter, mitelDhcpClientSecondaryWins=mitelDhcpClientSecondaryWins, mitelDhcpServerStaticIpClientId=mitelDhcpServerStaticIpClientId, mitelDhcpServerStaticIpEntry=mitelDhcpServerStaticIpEntry, mitelDhcpRelayAgentBroadcast=mitelDhcpRelayAgentBroadcast, mitelDhcpRelayAgentServerEntry=mitelDhcpRelayAgentServerEntry, mitelDhcpServerLeaseStatus=mitelDhcpServerLeaseStatus, mitelDhcpClientDefaultGateway=mitelDhcpClientDefaultGateway, mitelDhcpClientLeaseObtained=mitelDhcpClientLeaseObtained, mitelDhcpServerStaticIpMacAddress=mitelDhcpServerStaticIpMacAddress, mitelDhcpServerRangeName=mitelDhcpServerRangeName, mitelDhcpServerStaticIpAddr=mitelDhcpServerStaticIpAddr, mitelIdCallServers=mitelIdCallServers, mitelDhcpServerLeaseClientId=mitelDhcpServerLeaseClientId, mitelDhcpClientLeaseAction=mitelDhcpClientLeaseAction, mitelDhcpRelayAgentServerStatus=mitelDhcpRelayAgentServerStatus, mitelDhcpClientName=mitelDhcpClientName, mitelIdCsIpera1000=mitelIdCsIpera1000, mitelDhcpServerRangeTable=mitelDhcpServerRangeTable, mitelDhcpServerStaticIpStatus=mitelDhcpServerStaticIpStatus, mitelDhcpServerLeaseEndTime=mitelDhcpServerLeaseEndTime, mitelDhcpServerLeaseRange=mitelDhcpServerLeaseRange, mitelDhcpServerOptionValue=mitelDhcpServerOptionValue, mitelDhcpServerLeaseSubnet=mitelDhcpServerLeaseSubnet, mitelDhcpServerStaticIpName=mitelDhcpServerStaticIpName, mitelDhcpServerVendorInfoStatus=mitelDhcpServerVendorInfoStatus, MitelDhcpServerProtocol=MitelDhcpServerProtocol, mitelDhcpServerSubnetName=mitelDhcpServerSubnetName, mitelDhcpServerLeaseAllowedProtocol=mitelDhcpServerLeaseAllowedProtocol, mitelDhcpClientIpAddress=mitelDhcpClientIpAddress, mitelDhcpServerLeaseType=mitelDhcpServerLeaseType, mitelDhcpClientServerIp=mitelDhcpClientServerIp, mitelDhcpServerStatsNumServers=mitelDhcpServerStatsNumServers, mitelDhcpServerSubnetMask=mitelDhcpServerSubnetMask, mitelDhcpServerStatsConfSubnets=mitelDhcpServerStatsConfSubnets, mitelDhcpClientTable=mitelDhcpClientTable, mitelDhcpServerStaticIpGateway=mitelDhcpServerStaticIpGateway, mitelDhcpServerSubnetTable=mitelDhcpServerSubnetTable, mitelDhcpServerRangeEntry=mitelDhcpServerRangeEntry, mitelDhcpServerSubnetDeleteTree=mitelDhcpServerSubnetDeleteTree, mitelDhcpServerSubnetSharedNet=mitelDhcpServerSubnetSharedNet, PYSNMP_MODULE_ID=mitelRouterDhcpGroup, mitelDhcpClientPrimaryWins=mitelDhcpClientPrimaryWins, mitelDhcpServerGeneralEnable=mitelDhcpServerGeneralEnable, mitelIpera1000Notifications=mitelIpera1000Notifications, mitelDhcpServerLeaseServedTime=mitelDhcpServerLeaseServedTime, mitelDhcpServerRangeMatchClassId=mitelDhcpServerRangeMatchClassId, mitelDhcpServerStatsConfOptions=mitelDhcpServerStatsConfOptions, mitelDhcpServerVendorInfoTable=mitelDhcpServerVendorInfoTable, mitelDhcpServerRangeDeleteTree=mitelDhcpServerRangeDeleteTree, mitelDhcpServerStaticIpProtocol=mitelDhcpServerStaticIpProtocol, mitelDhcpServerLeaseServedProtocol=mitelDhcpServerLeaseServedProtocol, mitelDhcpServerVendorInfoEntry=mitelDhcpServerVendorInfoEntry, mitelDhcpServerGeneralGroup=mitelDhcpServerGeneralGroup, MitelDhcpServerOptionList=MitelDhcpServerOptionList, mitelDhcpServerGeneralPingStatus=mitelDhcpServerGeneralPingStatus, mitelDhcpServerOptionDisplayFormat=mitelDhcpServerOptionDisplayFormat, mitelDhcpServerGeneralGateway=mitelDhcpServerGeneralGateway, mitelDhcpServerRangeProtocol=mitelDhcpServerRangeProtocol)
def setup(): print(10*'=' + ' Notas SIGAA setup ' + 10*'=') username = str(input('SIGAA username: ')) password = str(input('SIGAA password: ')) webdriver_path = str(input('Webdriver path (always use / and, if in the same dir, use ./): ')) csv_output = str(input('CSV output path (always use / and, if in the same dir, use ./): ')) g_credentials_path = str(input( 'Google Cloud credentials.json path (always use / and, if in the same dir, use ./): ')) g_sheet = str(input("Google Sheet's sheet name: ")) downloads_path = str(input('Downloads folder path (always use / and, if in the same dir, use ./): ')) with open('./.env', 'w') as file: file.write(f"""MY_USERNAME="{username}" MY_PASSWORD="{password}" DRIVER_PATH="{webdriver_path}" CSV_OUTPUT="{csv_output}" G_CREDENTIALS="{g_credentials_path}" G_SHEET="{g_sheet}" DOWNLOADS_PATH="{downloads_path}" """) if __name__ == '__main__': setup()
ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" print("*** Caesar Cipher ***") shift = int(input("Please enter a number from -26 to 26: ")) if input("Press 'd' to decipher, anything else to encipher: ").lower() == "d": msg = input("Please enter your message: ") decrypted = [] for char in msg: index = ALPHABET.index(char) index = (index - shift) % len(ALPHABET) decrypted.append(ALPHABET[index]) print("Here is the deciphered message:") print("".join(decrypted)) else: msg = input("Please enter your message: ") msg = msg.upper().replace(" ", "") encrypted = [] for char in msg: index = ALPHABET.index(char) index = (index + shift) % len(ALPHABET) encrypted.append(ALPHABET[index]) print("Here is the enciphered message:") print("".join(encrypted))
"""This is where we store the created dicts of callbacks for global and template execution""" REGISTERED_GLOBAL_BEFORE_CALLBACKS = {} REGISTERED_GLOBAL_AFTER_CALLBACKS = {} REGISTERED_TEMPLATE_AFTER_CALLBACKS = {} REGISTERED_TEMPLATE_BEFORE_CALLBACKS = {} callback_kinds = { "GLOBAL_BEFORE": REGISTERED_GLOBAL_BEFORE_CALLBACKS, "GLOBAL_AFTER": REGISTERED_GLOBAL_AFTER_CALLBACKS, "TEMPLATE_BEFORE": REGISTERED_TEMPLATE_BEFORE_CALLBACKS, "TEMPLATE_AFTER": REGISTERED_TEMPLATE_AFTER_CALLBACKS, } def register_callback(cls, kind): """ Args: cls: kind: Returns: """ registered_callbacks = callback_kinds.get(kind) if cls.name in registered_callbacks: callbacks = registered_callbacks[cls.name] callbacks.append(cls) registered_callbacks[cls.name] = callbacks else: registered_callbacks[cls.name] = [cls] return cls def register_global_callback_before(cls): """ Decorator class for registering after run pre template callbacks Args: cls: Returns: """ return register_callback(cls, "GLOBAL_BEFORE") def register_template_callback_before(cls): """ Decorator class for registering before run pre template callbacks Args: cls: Returns: """ return register_callback(cls, "TEMPLATE_BEFORE") def register_template_callback_after(cls): """ Decorator class for registering after run pre template callbacks Args: cls: Returns: """ return register_callback(cls, "TEMPLATE_AFTER") def register_global_callback_after(cls): """ Decorator class for registering after run pre template callbacks Args: cls: Returns: """ return register_callback(cls, "GLOBAL_AFTER")
""" Allure Framework是一种灵活的轻量级多语言测试报告工具。 它提供清晰的图形报告,并允许开发过程中的每个人从日常测试过程中提取最大的信息。 先安装 allure pip3 install allure-pytest -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com $ pip install allure-pytest $ py.test --alluredir=%allure_result_folder% ./tests $ allure serve %allure_result_folder% pytest --alluredir=allure allure serve allure 可以把测试用例跟bug关联起来!!! """
_CALCULATIONS_GRAPHVIZSHAPE = "ellipse" def _raise(e): raise e
def preprocess_data(_data): nul, shape = _data.shape[0], _data.shape[1:] print(nul) print(shape) _data = _data.reshape(nul, shape[0], shape[1], 1) _data = _data.astype('float32') _data /= 255 return _data
class NotFound(Exception): """The requested data was not found during a call to .get().""" pass
# @Title: 二叉搜索树的后序遍历序列 (二叉搜索树的后序遍历序列 LCOF) # @Author: 18015528893 # @Date: 2021-01-20 21:49:53 # @Runtime: 40 ms # @Memory: 14.8 MB class Solution: def verifyPostorder(self, postorder: List[int]) -> bool: def recur(i, j): if i >= j: return True m = i while postorder[m] < postorder[j]: m += 1 n = m while postorder[m] > postorder[j]: m += 1 return m == j and recur(i, n-1) and recur(n, j-1) return recur(0, len(postorder)-1)
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def bstFromPreorder(self, preorder: List[int]) -> TreeNode: def rectree(orderlist): if len(orderlist) == 0: return None if len(orderlist) == 1: return TreeNode(orderlist[0]) left = list() right = list() head = TreeNode(orderlist[0]) for i in range(1,len(orderlist)): if orderlist[i] < head.val: left.append(orderlist[i]) else: right.append(orderlist[i]) head.left = rectree(left) head.right = rectree(right) return head return rectree(preorder)
class TypeLibFuncAttribute(Attribute,_Attribute): """ Contains the System.Runtime.InteropServices.FUNCFLAGS that were originally imported for this method from the COM type library. TypeLibFuncAttribute(flags: TypeLibFuncFlags) TypeLibFuncAttribute(flags: Int16) """ def __init__(self,*args): """ x.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signaturex.__init__(...) initializes x; see x.__class__.__doc__ for signature """ pass @staticmethod def __new__(self,flags): """ __new__(cls: type,flags: TypeLibFuncFlags) __new__(cls: type,flags: Int16) """ pass Value=property(lambda self: object(),lambda self,v: None,lambda self: None) """Gets the System.Runtime.InteropServices.TypeLibFuncFlags value for this method. Get: Value(self: TypeLibFuncAttribute) -> TypeLibFuncFlags """
class IcmpException(OSError): pass class BufferTooSmall(IcmpException): pass class DestinationNetUnreachable(IcmpException): pass class DestinationHostUnreachable(IcmpException): pass class DestinationProtocolUnreachable(IcmpException): pass class DestinationPortUnreachable(IcmpException): pass class NoResources(IcmpException): pass class BadOption(IcmpException): pass class HardwareError(IcmpException): pass class PacketTooBig(IcmpException): pass class RequestTimedOut(IcmpException): pass class BadRequest(IcmpException): pass class BadRoute(IcmpException): pass class TTLExpiredInTransit(IcmpException): pass class TTLExpiredOnReassembly(IcmpException): pass class ParameterProblem(IcmpException): pass class SourceQuench(IcmpException): pass class OptionTooBig(IcmpException): pass class BadDestination(IcmpException): pass class GeneralFailure(IcmpException): pass errno_map = { 11001: BufferTooSmall, 11002: DestinationNetUnreachable, 11003: DestinationHostUnreachable, 11004: DestinationProtocolUnreachable, 11005: DestinationPortUnreachable, 11006: NoResources, 11007: BadOption, 11008: HardwareError, 11009: PacketTooBig, 11010: RequestTimedOut, 11011: BadRequest, 11012: BadRoute, 11013: TTLExpiredInTransit, 11014: TTLExpiredOnReassembly, 11015: ParameterProblem, 11016: SourceQuench, 11017: OptionTooBig, 11018: BadDestination, 11050: GeneralFailure, }
test = { 'name': 'has-cycle', 'points': 1, 'suites': [ { 'cases': [ { 'code': r""" scm> (has-cycle s) #f scm> (has-cycle cycle) #t scm> (has-cycle cycle-within) #t """, 'hidden': False, 'locked': False } ], 'scored': True, 'setup': r""" scm> (load 'hw11) scm> (define s (cons-stream 1 (cons-stream 2 nil))) scm> (define cycle (cons-stream 1 (cons-stream 1 cycle))) scm> (define cycle-within (cons-stream 1 (cons-stream 2 cycle))) """, 'teardown': '', 'type': 'scheme' } ] }
for x in range(6, 0, -1): if (x % 2 != 0): ctrl = x + 1 else: ctrl = x for y in range(0, ctrl): print("*", end="") print()
day_of_week = input() work_days = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'] vacation_days = ['Saturday', 'Sunday'] if day_of_week in (work_days): print('Working day') elif day_of_week in (vacation_days): print('Weekend') else: print('Error')
x = 10 y = 2 a = x*y print(a) b = 12
# pma.py --maxTransitions 100 --output synchronous_graph synchronous # 4 states, 4 transitions, 1 accepting states, 0 unsafe states, 0 finished and 0 deadend states # actions here are just labels, but must be symbols with __name__ attribute def send_return(): pass def send_call(): pass def recv_call(): pass def recv_return(): pass # states, key of each state here is its number in graph etc. below states = { 0 : {'synchronous': 0}, 1 : {'synchronous': 1}, 2 : {'synchronous': 2}, 3 : {'synchronous': 3}, } # initial state, accepting states, unsafe states, frontier states, deadend states initial = 0 accepting = [0] unsafe = [] frontier = [] finished = [] deadend = [] runstarts = [0] # finite state machine, list of tuples: (current, (action, args, result), next) graph = ( (0, (send_call, (), None), 1), (1, (send_return, (), None), 2), (2, (recv_call, (), None), 3), (3, (recv_return, (), None), 0), )
# -*- coding: utf-8 -*- """ Created on Thu Jul 15 11:46:46 2021 @author: Easin """ in1 = input() #flag = True for elem in range(len(in1)): if in1[elem] == "H" or in1[elem] == "Q" or in1[elem] == "9": flag = False break else: flag = True if flag == False: print("YES") else: print("NO")
fr = open('cora/features.features') a = fr.readlines() fr.close() fw = open('cora/features.txt','w') for i in range(len(a)): s = a[i].strip().split(' ') fw.write(s[0]+'\t') for j in range(1,len(s)): if (s[j]=='0.0'): fw.write('0\t') else: fw.write('1\t') fw.write('\n') fw.close()
""" [2017-03-17] Challenge #306 [Hard] Generate Strings to Match a Regular Expression https://www.reddit.com/r/dailyprogrammer/comments/5zxebw/20170317_challenge_306_hard_generate_strings_to/ # Description Most everyone who programs using general purpose languages is familiar with regular expressions, which enable you to match inputs using patterns. Today, we'll do the inverse: given a regular expression, can you generate a pattern that will match? For this challenge we'll use a subset of regular expression syntax: - character literals, like the letter A - \* meaning zero or more of the previous thing (a character or an entity) - + meaning one or more of the previous thing - . meaning any single literal - [a-z] meaning a range of characters from *a* to *z* inclusive To tackle this you'll probably want to consider using a finite state machine and traversing it using a random walk. # Example Input You'll be given a list of patterns, one per line. Example: a+b abc*d # Example Output Your program should emit strings that match these patterns. From our examples: aab abd Note that `abcccccd` would also match the second one, and `ab` would match the first one. There is no single solution, but there are wrong ones. # Challenge Input [A-Za-z0-9$.+!*'(){},~:;=@#%_\-]* ab[c-l]+jkm9*10+ iqb[beoqob-q]872+0qbq* # Challenge Output While multiple strings can match, here are some examples. g~*t@C308*-sK.eSlM_#-EMg*9Jp_1W!7tB+SY@jRHD+-'QlWh=~k'}X$=08phGW1iS0+:G abhclikjijfiifhdjjgllkheggccfkdfdiccifjccekhcijdfejgldkfeejkecgdfhcihdhilcjigchdhdljdjkm9999910000 iqbe87222222222222222222222222222222222222222220qbqqqqqqqqqqqqqqqqqqqqqqqqq """ def main(): pass if __name__ == "__main__": main()
''' While the very latest in 1518 alchemical technology might have solved their problem eventually, you can do better. You scan the chemical composition of the suit's material and discover that it is formed by extremely long polymers. The polymer is formed by smaller units which, when triggered, react with each other such that two adjacent units of the same type and opposite polarity are destroyed. How many units remain after fully reacting the polymer you scanned? ''' def react(polymer): ''' Given a polymer string, removes two adjacent characters if they are the same character but in opposite cases Removes: aA, Aa Does not remove: aa, AA, aB, Ba ''' for char_1, char_2 in zip(polymer, polymer[1:]): if char_1.lower() == char_2.lower() and char_1 != char_2: polymer = polymer.replace(f'{char_1}{char_2}', '', 1) return polymer def react_loop(polymer): ''' Given a polymer string, reacts repeatedly until no reaction occurs, returns the polymer string ''' old_polymer = polymer while True: new_polymer = react(old_polymer) if new_polymer == old_polymer: return new_polymer else: old_polymer = new_polymer def main(): with open('input.txt') as input_file: polymer = input_file.read().strip() final_polymer = react_loop(polymer) print( f'''The units remaining after fully reacting the polymer is { len(final_polymer) } units.''' ) if __name__ == '__main__': main()
""" A collection of command-line tools for building encoded update.xml files. """ class InfoFile: update_file = "" version = None checksum = None # A multi-line HTML document describing the changes between # this version and the previous version description = "" @classmethod def from_info_file(filename): return def files2xml(filenames): """ Given a list of filenames, extracts the app version and log information from accompanying files produces an output xml file. There are no constraints or restrictions on the names or extensions of the input files. They just need to be accompanied by a sidecar file named similarly, but with a ".info" extension, that can be loaded by the InfoFile class. """ return
''' # 977. [Squares of a Sorted Array](https://leetcode.com/problems/squares-of-a-sorted-array/) Given an array of integers A sorted in non-decreasing order, return an array of the squares of each number, also in sorted non-decreasing order. Example 1: Input: [-4,-1,0,3,10] Output: [0,1,9,16,100] Example 2: Input: [-7,-3,2,3,11] Output: [4,9,9,49,121] Note: 1 <= A.length <= 10000 -10000 <= A[i] <= 10000 A is sorted in non-decreasing order. ''' # Solutions class Solution: def sortedSquares(self, A: List[int]) -> List[int]: i = 0 j = len(A) - 1 while i < j: A[i] = A[i] * A[i] A[j] = A[j] * A[j] i += 1 j -= 1 if i == j: A[i] = A[i] * A[i] A.sort() return A # Runtime: 240 ms # Memory Usage: 15.2 MB
""" The permissions of a file in a Linux system are split into three sets of three permissions: read, write, and execute for the owner, group, and others. Each of the three values can be expressed as an octal number summing each permission, with 4 corresponding to read, 2 to write, and 1 to execute. Or it can be written with a string using the letters r, w, and x or - when the permission is not granted. For example: 640 is read/write for the owner, read for the group, and no permissions for the others; converted to a string, it would be: "rw-r-----" 755 is read/write/execute for the owner, and read/execute for group and others; converted to a string, it would be: "rwxr-xr-x" """ def octal_to_string(octal): result = "" value_letters = [(4,"r"),(2,"w"),(1,"x")] # Iterate over each of the digits in octal for num in [int(n) for n in str(octal)]: # Check for each of the permissions values for value, letter in value_letters: if num >= value: result += letter num -= value else: result += '-' return result print(octal_to_string(755)) # Should be rwxr-xr-x print(octal_to_string(644)) # Should be rw-r--r-- print(octal_to_string(750)) # Should be rwxr-x--- print(octal_to_string(600)) # Should be rw-------
__all__ = ["decoder"] def decoder(x: list) -> int: x = int(str("0b" + "".join(reversed(list(map(str, x))))), 2) return x
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") def repos(): http_archive( name = "vim", urls = [ "https://github.com/vim/vim/archive/v8.1.1846.tar.gz", ], sha256 = "68de2854199a396aee19fe34c32c02db5784c76c0334d58b510266436c7529bb", strip_prefix = "vim-8.1.1846", build_file = str(Label("//app-editor:vim.BUILD")), )
class InvalidInput(Exception): def __init__(self): Exception.__init__(self, "Sorry, your input doesn't look good. " "Or, Maybe you've tried too many times and " "google thinks you aren't receiving the phone code?")
_formats = { 'cic': [100, "CIrculant Columns"], 'cir': [101, "CIrculant Rows"], 'chb': [102, "Circulant Horizontal Blocks"], 'cvb': [103, "Circulant Vertical Blocks"], 'hsb': [104, "Horizontally Stacked Blocks"], 'vsb': [104, "Vertically Stacked Blocks"] }
# # (c) Copyright 2015 Hewlett Packard Enterprise Development LP # (c) Copyright 2017-2018 SUSE LLC # # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. # class DependencyElement(object): def __init__(self, plugin): self._plugin = plugin self._dependencies = plugin.get_dependencies() @property def slug(self): return self._plugin.slug @property def plugin(self): return self._plugin @property def dependencies(self): return self._dependencies def remove_dependency(self, slug): if slug in self._dependencies: self._dependencies.remove(slug) def has_dependencies(self): return len(self._dependencies) > 0 def has_dependency(self, slug): return slug in self._dependencies