content
stringlengths
7
1.05M
h,m,s = map(int, input().split()) s += (m*60 + h*3600 + int(input())) h = s//3600 m = (s%3600)//60 s = (s%3600)%60 if h>23: h %= 24 print(h,m,s)
#!/usr/bin/env python # -*- coding: UTF-8 -*- # 地址:http: //www.runoob.com/python/python-exercise-example85.html def func(num): j = 1 sum = 9 m = 9 flag = True while flag: if sum % num == 0: print(sum) flag = False else: m *= 10 sum += m j += 1 print("%d 个 9 可以被 %d 整除 : %d" % (j, num, sum)) r = sum / num print("%d / %d = %d" % (sum, num, r)) # 给出一个奇数需要多少个99 才可以除尽它 if __name__ == "__main__": num = 21 # num = int(input("请输入一个正奇数:")) if num > 0 and num % 2 == 1: func(num) else: print("输入错误")
#!/usr/bin/env python3 def main(): s = 0 for j in range(1, 1001): s += j ** j print(str(s)[-10:]) if __name__ == '__main__': main()
""" Audio segment """ class Segment(): """ Audio segment """ def __init__(self, waveform, boundaries, sample_rate, channel): self._waveform = waveform self._boundaries = boundaries self._sample_rate = sample_rate self._channel = channel @property def waveform(self): """ Segment waveform """ return self._waveform @property def boundaries(self): """ Segment begin and end timestamp (in seconds) """ return self._boundaries @property def sample_rate(self): """ Sample rate """ return self._sample_rate @property def channel(self): """ Channel number (starts from 0) """ return self._channel
f = open("thirteen.txt", "r") lines = [x.strip() for x in f.readlines()] dots = [] for line in lines: if line == "": break p = line.split(",") dots.append((int(p[0]), int(p[1]))) folds = [line.split()[2] for line in lines if line.startswith("fold along ")] fold = folds[0] dir = fold[0] line = int(fold[2:]) new_dots = [] for x,y in dots: if dir == "y": if y > line: new_dots.append((x, y - 2 * (y - line))) else: new_dots.append((x, y)) elif dir == "x": if x > line: new_dots.append((x- 2 * (x - line), y)) else: new_dots.append((x, y)) print(len(set(new_dots))) for fold in folds: dir = fold[0] line = int(fold[2:]) new_dots = [] for x,y in dots: if dir == "y": if y > line: new_dots.append((x, y - 2 * (y - line))) else: new_dots.append((x, y)) elif dir == "x": if x > line: new_dots.append((x- 2 * (x - line), y)) else: new_dots.append((x, y)) dots = list(set(new_dots)) max_x = max([x for x,y in dots]) + 1 max_y = max([y for x,y in dots]) + 1 print(dots) screen = [] for y in range(max_y): screen.append([" "] * max_x) for x,y in dots: screen[y][x] = "#" for s in screen: print("".join(s))
class FormattedTextRun(object, IDisposable): """ A structure that defines a single run of a formatted text. """ def Dispose(self): """ Dispose(self: FormattedTextRun) """ pass def ReleaseUnmanagedResources(self, *args): """ ReleaseUnmanagedResources(self: FormattedTextRun,disposing: bool) """ pass def __enter__(self, *args): """ __enter__(self: IDisposable) -> object """ pass def __exit__(self, *args): """ __exit__(self: IDisposable,exc_type: object,exc_value: object,exc_back: object) """ pass 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 def __repr__(self, *args): """ __repr__(self: object) -> str """ pass BaselineStyle = property( lambda self: object(), lambda self, v: None, lambda self: None ) """Specifies the style of the text as related to the baseline position. Get: BaselineStyle(self: FormattedTextRun) -> TextBaselineStyle """ Bold = property(lambda self: object(), lambda self, v: None, lambda self: None) """Indicates whether this text run uses Bold text. Get: Bold(self: FormattedTextRun) -> bool """ IsValidObject = property( lambda self: object(), lambda self, v: None, lambda self: None ) """Specifies whether the .NET object represents a valid Revit entity. Get: IsValidObject(self: FormattedTextRun) -> bool """ Italic = property(lambda self: object(), lambda self, v: None, lambda self: None) """Indicates whether this text run uses Italic text. Get: Italic(self: FormattedTextRun) -> bool """ ListStyle = property(lambda self: object(), lambda self, v: None, lambda self: None) """Specifies the style of a paragraph if the paragraph is a list. Get: ListStyle(self: FormattedTextRun) -> TextListStyle """ NewLine = property(lambda self: object(), lambda self, v: None, lambda self: None) """Indicates whether this text run starts on a new line. Get: NewLine(self: FormattedTextRun) -> bool """ NewParagraph = property( lambda self: object(), lambda self, v: None, lambda self: None ) """Indicates whether this text run starts a new paragraph. Get: NewParagraph(self: FormattedTextRun) -> bool """ TabNumber = property(lambda self: object(), lambda self, v: None, lambda self: None) """For a text run that starts at a tab stop,this value indicates the number of the tab stop. Get: TabNumber(self: FormattedTextRun) -> int """ Text = property(lambda self: object(), lambda self, v: None, lambda self: None) """The text segment in this text run. Get: Text(self: FormattedTextRun) -> str """ Underlined = property( lambda self: object(), lambda self, v: None, lambda self: None ) """Indicates whether this text run uses Underlined text. Get: Underlined(self: FormattedTextRun) -> bool """
def test_register_get(client, captured_templates): """ GIVEN a Flask application configured for testing (client) WHEN the '/' route is requested (GET) THEN there should be the correct `status_code`, `template.name`, and the correct `page_title` in the context """ # mimic a browser: 'GET /', as if you visit the site response = client.get("/register") # check that the HTTP response is a success assert response.status_code == 200 # check that the rendered template is the correct one assert len(captured_templates) == 1 template, context = captured_templates[0] assert template.name == "register.html" assert "page_title" in context assert context["page_title"] == "Register" def test_valid_register_post(client, captured_templates, test_db): """ GIVEN a Flask application configured for testing (client), the test db WHEN a user wants to register and posts valid data to '/register' (POST) THEN the user should be registered to the db, logged in, and redirected to the landing page. """ # mimic a browser: 'POST /register', as if you visit the site response = client.post( "/register", data=dict( username="28kadsen", email_address="28kadsen@gmail.com", password1="123456", password2="123456", ), follow_redirects=True, ) # check that the HTTP response fail assert response.status_code == 200 # check that the rendered template is the correct one assert len(captured_templates) == 1 template, context = captured_templates[0] assert template.name == "landing_page.html" assert "page_title" in context assert context["page_title"] == "Help & Help" html_content = response.data.decode() assert '<a class="nav-link" href="#">Welcome, 28kadsen</a>' in html_content def test_invalid_register_post(client, captured_templates, test_db): """ GIVEN a Flask application configured for testing (client) and the test db WHEN a user wants to register and posts invalid data to '/register' (POST) THEN the user should NOT be registered to the db, html contain error messages. """ # mimic a browser: 'POST /register', as if you visit the site response = client.post( "/register", data=dict( username="gottheit", email_address="28kadsengmail.com", password1="44444", password2="55555", ), follow_redirects=True, ) # check that the HTTP response is a success assert response.status_code == 400 # check that the rendered template is the correct one assert len(captured_templates) == 1 template, context = captured_templates[0] assert template.name == "register.html" assert "page_title" in context assert context["page_title"] == "Register" html_content = response.data.decode() assert "Invalid email address." in html_content assert "Field must be equal to password1." in html_content def test_login_get(client, captured_templates): """ GIVEN a Flask application configured for testing (client) WHEN the '/login' route is requested (GET) THEN there should be the correct `status_code`, `template.name`, and the correct `page_title` in the context """ # mimic a browser: 'GET /', as if you visit the site response = client.get("/login") # check that the HTTP response is a success assert response.status_code == 200 # check that the rendered template is the correct one assert len(captured_templates) == 1 template, context = captured_templates[0] assert template.name == "login.html" assert "page_title" in context assert context["page_title"] == "Login" def test_login_post(client, captured_templates, fake_user): """ GIVEN a Flask application configured for testing (client) and the fake_user WHEN the fake_user data is posted THEN then the fake_user should be logged in and redirected to the landing page """ # mimic a browser: 'POST /', as if you visit the site response = client.post( "/login", data=dict(username=fake_user.username, password="123456"), follow_redirects=True, ) # check that the HTTP response is a success assert response.status_code == 200 # check that the rendered template is the correct one assert len(captured_templates) == 1 template, context = captured_templates[0] assert template.name == "landing_page.html" assert "page_title" in context assert context["page_title"] == "Help & Help" def test_logout(client, captured_templates): """ GIVEN a Flask application configured for testing (client) WHEN the '/logout' route is requested (GET) THEN the user should be logged out and there should be the correct `status_code`, `template.name`, and the correct `page_title` in the context """ # mimic a browser: 'GET /', as if you visit the site response = client.get("/logout", follow_redirects=True) # check that the HTTP response is a success assert response.status_code == 200 # check that the rendered template is the correct one assert len(captured_templates) == 1 template, context = captured_templates[0] assert template.name == "login.html" assert "page_title" in context assert context["page_title"] == "Login"
# -*- coding: UTF-8 -*- # @author: xuyong # @file: 202-fbnqsl.py # @time: 2018/7/27 下午7:33 # @desc: 斐波那契数列实现 # 获取用户输入数据 # 随便手动输入数字,比如 10 # nterms = int(input("你需要几项?")) nterms = 10 # 第一和第二项 n1 = 0 n2 = 1 count = 2 # 判断输入的值是否合法 if nterms <= 0: print("请输入一个正整数。") elif nterms == 1: print("斐波那契数列:") print(n1) else: print("斐波那契数列:") print(n1, ",", n2, end=", ") while count < nterms: nth = n1 + n2 print(nth, end=", ") # 更新值 n1 = n2 n2 = nth count += 1
class Solution: # @param A : integer # @return a list of strings def fizzBuzz(self, n): result = [] for i in range(1, n+1): s = '' if i %3 == 0: s += 'Fizz' if i % 5 == 0: s += 'Buzz' if s == '': result.append(i) else: result.append(s) return result
class Tag: _major: str _minor: str _separator: str _factors: dict def __init__(self, major: str, minor="", separator="", **kwargs): self._major = major self._minor = minor self._separator = separator self._factors = kwargs @property def major(self) -> str: return self._major @major.setter def major(self, value: str): self._major = value @property def minor(self) -> str: return self._minor @minor.setter def minor(self, value: str): self._minor = value @property def separator(self) -> str: return self._separator @separator.setter def separator(self, value: str): self._separator = value @property def factors(self) -> dict: return self._factors @factors.setter def factors(self, value: dict): self._factors = value def __str__(self): tags = [] if self._minor != '': tags.append(self._major + self._separator + self._minor) else: tags.append(self._major) for key, val in self._factors.items(): tags.append(f"{key}={val}") return ';'.join(tags) class MimeTypeTag(Tag): def __init__(self, mime_type: str = "*", sub_type: str = "*", **kwargs): super(MimeTypeTag, self).__init__(mime_type, sub_type, '/', **kwargs) class LanguageTag(Tag): def __init__(self, lang: str, country_code: str = '', **kwargs): super(LanguageTag, self).__init__(lang, country_code, '-', **kwargs)
# -*- coding: utf-8 -*- """ File Name: minimum-number-of-arrows-to-burst-balloons.py Author : jynnezhang Date: 2020/11/23 3:34 下午 Description: https://leetcode-cn.com/problems/minimum-number-of-arrows-to-burst-balloons/ """ class Solution: def findMinArrowShots(self, points) -> int: """ 排序:按照结束位置 贪心:每次选择最末尾的位置射箭,这样覆盖的气球范围最广 :param points: :return: """ if not points and len(points) == 0: return 0 points.sort(key=lambda x: (x[1])) arrow = 1 arrow_pos = points[0][1] for i in range(1, len(points)): if points[i][0] <= arrow_pos <= points[i][1]: continue else: arrow += 1 arrow_pos = points[i][1] return arrow if __name__ == '__main__': print(Solution().findMinArrowShots(points=[[1,2],[2,3],[3,4],[4,5]]))
"""197 · Permutation Index""" class Solution: """ @param A: An array of integers @return: A long integer """ def permutationIndex(self, A): # write your code here permutation = 1 result = 0 for i in range(len(A) - 2, -1, -1): smaller = 0 for j in range(i + 1, len(A)): if A[j] < A[i]: smaller += 1 result += smaller * permutation permutation *= len(A) - i return result + 1 """Q:为了找寻每个元素右侧有多少元素比自己小,用了O(n^2)的时间,能不能更快些? A:可以做到O(nlogn),但是很复杂,这是另外一个问题了,可以使用BST, 归并排序或者线段树:http://www.lintcode.com/zh-cn/problem/count-of-smaller-number-before-itself/ Q:元素有重复怎么办? A:好问题!元素有重复,情况会复杂的多。因为这会影响 A[i] 右侧元素的排列数, 此时的排列数计算方法为总元素数的阶乘,除以各元素值个数的阶乘,例如 [1, 1, 1, 2, 2, 3] ,排列数为 6! ÷ (3! × 2! × 1!) 。为了正确计算阶乘数,需要用哈系表记录 A[i] 及右侧的元素值个数, 并考虑到 A[i] 与右侧比其小的元素 A[k] 交换后,要把 A[k] 的计数减一。用该哈系表计算正确的阶乘数。 而且要注意,右侧比 A[i]小 的重复元素值只能计算一次,不要重复计算!"""
print('ANALISANDO DADOS') pessoas = dict() lista = list() media = soma = 0 print('-=' * 50) while True: pessoas.clear() pessoas['nome'] = str(input('Nome: ')) pessoas['sexo'] = str(input('Sexo [M/F]: ')).upper().strip()[0] while pessoas['sexo'] not in 'MF': print('Erro, digite apenas M ou F.') pessoas['sexo'] = str(input('Sexo: ')).upper().strip()[0] pessoas['idade'] = int(input('Idade: ')) soma += pessoas['idade'] escolha = str(input('Deseja continuar [S/N]: ')).upper().strip()[0] lista.append(pessoas.copy()) while escolha not in 'SN': print('Erro, digite apenas [S] para sim ou [N] para não.') escolha = str(input('Deseja continuar [S/N]: ')).upper().strip()[0] if escolha == 'N': break print('-=' * 50) media = soma / len(lista) print('-=' * 50) print(f'A => Foram cadastradas {len(lista)} pessoas.') print(f'B => A média de idade cadastrada foi de {media} anos.') print('C => As mulheres cadastradas foram: ', end='') for cont in lista: if cont['sexo'] == 'F': print(f'{cont["nome"]}', end='...') print('\nD => As pessoas com idade acima da média foram:') for cont in lista: if cont['idade'] > media: print(f'{cont["nome"]} com {cont["idade"]} anos, ficou acima de média.')
def boyer_moore_bad_environment(A, p, m, k): bad_table = {(i, a): True for i in range(1, m + 1) for a in A} for i in range(1, m + 1): for j in range(max(0, i - k), min(i + k, m) + 1): bad_table[(j, p[i])] = False return bad_table def boyer_moore_multi_dim_shift(A, p, m, k): ready = {a: m + 1 for a in A} BM_k = {(i, a): m for a in A for i in range(m, m - k - 1, -1)} for i in range(m - 1, 0, -1): for j in range(ready[p[i]] - 1, max(i, m - k) - 1, -1): BM_k[(j, p[i])] = j - i ready[p[i]] = max(i, m - k) return BM_k def approximate_boyer_moore(text, p, n, m, k, A=None): if A is None: A = set(list(text[1:] + p[1:])) BM_k = boyer_moore_multi_dim_shift(A, p, m, k) BAD = boyer_moore_bad_environment(A, p, m, k) j, top = m, min(k + 1, m) D_0 = list(range(m + 1)) D_curr = D_0[:] curr_col, j = next_possible_occurence(text, n, m, k, BM_k, BAD, j) if curr_col <= 0: curr_col = 1 last_col = curr_col + m + 2 * k while curr_col <= n: for r in range(curr_col, last_col + 1): c = 0 # evaluate another column of D for i in range(1, top + 1): d = c if r <= n and p[i] == text[r] \ else min(D_curr[i - 1], D_curr[i], c) + 1 c, D_curr[i] = D_curr[i], d while D_curr[top] > k: top -= 1 # if D[m] <= k we have a match if top == m: if r <= n: yield r else: top += 1 next_possible, j = next_possible_occurence(text, n, m, k, BM_k, BAD, j) if next_possible > last_col + 1: D_curr, top, curr_col = D_0[:], min(k + 1, m), next_possible else: curr_col = last_col + 1 last_col = next_possible + m + 2 * k def next_possible_occurence(text, n, m, k, BM_k, BAD, j): while j <= n + k: r, i, bad, d = j, m, 0, m while i > k >= bad: if i >= m - k and r <= n: d = min(d, BM_k[(i, text[r])]) if r <= n and BAD[(i, text[r])]: bad = bad + 1 i, r = i - 1, r - 1 if bad <= k: if j <= (n + k): npo = j - m - k j = j + max(k + 1, d) return npo, j j = j + max(k + 1, d) return n + 1, j def simple_dynamic_edit_distance(text, p, n, m, k): D = {(0, j): 0 for j in range(n + 1)} for i in range(m + 1): D[(i, 0)] = i for i in range(1, m + 1): for j in range(1, n + 1): D[(i, j)] = min(D[(i - 1, j)] + 1, D[(i, j - 1)] + 1, D[(i - 1, j - 1)] + int(p[i] != text[j])) for j in range(1, n + 1): if D[(m, j)] <= k: yield j
# dfir_ntfs: an NTFS parser for digital forensics & incident response # (c) Maxim Suhanov __version__ = '1.0.3' __all__ = [ 'MFT', 'Attributes', 'WSL', 'USN', 'LogFile', 'BootSector', 'ShadowCopy', 'PartitionTable' ]
# motorsports.vehicles # description # # Author: Allen Leis <allen.leis@georgetown.edu> # Created: Fri Sep 11 23:22:32 2015 -0400 # # Copyright (C) 2015 georgetown.edu # For license information, see LICENSE.txt # # ID: vehicles.py [] allen.leis@georgetown.edu $ """ A module to supply building related classes """ ########################################################################## ## Imports ########################################################################## ########################################################################## ## Classes ########################################################################## class BaseVehicle(object): def __init__(self): self._state = None @property def state(self): """ return a string describing the state of the vehicle """ return self._state or 'stopped' @property def description(self): """ return a string describing this object """ return self.__class__.__name__ def start(self): """ Starts the vehicle """ self._state = 'started' def shutdown(self): """ Starts the vehicle """ self._state = 'stopped' def __str__(self): return "I am a {}.".format(self.description) class Car(BaseVehicle): def __init__(self, color, make, model): self.color = color self.make = make self.model = model super(Car, self).__init__() @property def description(self): """ return a string describing this object """ return '{} {} {}'.format(self.color, self.make, self.model) def start(self): """ Starts the vehicle """ super(Car, self).start() print('vroom') ########################################################################## ## Execution ########################################################################## if __name__ == '__main__': c = Car('white', 'Ford', 'Bronco') print(c.state) c.start() print(c.state)
# obtain the comma-separated value from the user csv = input("Enter string: ") # split the string by the coma and save it in a list csv = csv.split(',') # displaying each of the variables # csv[0] is the name # csv[1] is the age # csv[2] is the phone number print('\n{0:=<30}\nName: {1:30}\nAge: {2:30}\nContact: {3:30}\n{4:=<30}\n'.format('', csv[0], csv[1], csv[2], ''))
class Solution: def sortedSquares(self, nums: List[int]) -> List[int]: arr = [] for i in nums: sq = i*i arr.append(sq) return sorted(arr)
# Fibonacci numbers def fibs(_to, _from=0): ''' Returns a given range of fibonacci sequence. Both indexes are included. fibonacci_sequence[_from:_to] param _to: int [required] - upper index of requested range param _from: int [optional] - lower index of requested range returns: list - requested range of fibonacci sequence ''' rev_ord = _from > _to if rev_ord: neg_end, pos_end = _to, _from else: neg_end, pos_end = _from, _to neg = neg_end < 0 pos = pos_end > 0 if pos_end < 0: rev_ord = not rev_ord def fib_a(end, neg=0): seq.append(0) if end > 1: seq.append(neg or 1) if end > 2: fib_b(end-2) neg and seq.reverse() def fib_b(reps): for i in range(reps): seq.append(seq[-2] + seq[-1]) seq = []; if neg: fib_a(-neg_end, -1) if pos: fib_a(pos_end) if pos_end < 0: seq.reverse() seq = seq[-(pos_end-neg_end+1):] if rev_ord: seq.reverse() return seq def fib(num): ''' Runs a fibs function with given num param as fibs(end=num), and returns last element from fibs run result. param num: int, required; requested number of fibonacci sequence returns: int; number from fibonacci sequence ''' if num == 0: return None return fibs(num)[-1] if __name__ == '__main__': print(fibs(255, -255))
def greedy_player_mgt(game_mgr): game_mgr = game_mgr def fn_get_action(pieces): valid_moves = game_mgr.fn_get_valid_moves(pieces, 1) if valid_moves is None: return None candidates = [] for a in range(game_mgr.fn_get_action_size()): if valid_moves[a]==0: continue nextPieces = game_mgr.fn_get_next_state(pieces, 1, a) score = game_mgr.fn_get_score(nextPieces, 1) candidates += [(-score, a)] candidates.sort() return candidates[0][1] return fn_get_action
# Time: O(n) # Space: O(1) class Solution(object): def maximumPopulation(self, logs): """ :type logs: List[List[int]] :rtype: int """ MIN_YEAR, MAX_YEAR = 1950, 2050 years = [0]*(MAX_YEAR-MIN_YEAR+1) for s, e in logs: years[s-MIN_YEAR] += 1 years[e-MIN_YEAR] -= 1 result = 0 for i in xrange(len(years)): if i: years[i] += years[i-1] if years[i] > years[result]: result = i return result+MIN_YEAR
# Time: O(1), per move. # Space: O(n^2) class TicTacToe(object): def __init__(self, n): """ Initialize your data structure here. :type n: int """ self.__rows = [[0, 0] for _ in xrange(n)] self.__cols = [[0, 0] for _ in xrange(n)] self.__diagonal = [0, 0] self.__anti_diagonal = [0, 0] def move(self, row, col, player): """ Player {player} makes a move at ({row}, {col}). @param row The row of the board. @param col The column of the board. @param player The player, can be either 1 or 2. @return The current winning condition, can be either: 0: No one wins. 1: Player 1 wins. 2: Player 2 wins. :type row: int :type col: int :type player: int :rtype: int """ i = player - 1 self.__rows[row][i] += 1 self.__cols[col][i] += 1 if row == col: self.__diagonal[i] += 1 if col == len(self.__rows) - row - 1: self.__anti_diagonal[i] += 1 if any([self.__rows[row][i] == len(self.__rows), \ self.__cols[col][i] == len(self.__cols), \ self.__diagonal[i] == len(self.__rows), \ self.__anti_diagonal[i] == len(self.__cols)]): return player return 0 # Your TicTacToe object will be instantiated and called as such: # obj = TicTacToe(n) # param_1 = obj.move(row,col,player)
# Lists in Python are mutable objects that may contain # any number of items of different types my_list = [1, "Hello", True, 3.4] # Python allows negative indexing my_list = [1, 2, 3, 4, 5, 6] print(my_list[-1]) # We can access a range of items within the list using slicing # my_list[start:stop:step] my_list = ['H', 'e', 'l', 'l', 'o', 'W', 'o', 'r', 'l', 'd'] print(my_list[2:5]) print(my_list[5:]) print(my_list[:-2]) print(my_list[::-1]) my_list = [1, 2, 3, 4, 5] my_list.append(6) my_list.insert(2, 7) print(my_list) print(my_list.pop()) print(my_list.pop(0)) print(my_list.count(3))
l = [2, 5, 6, 5, 11] def isPal(x): str_num = str(x) if len(str_num) == 1: return True if len(str_num) % 2 != 0: mid = int(len(str_num)/2) front = str_num[:mid] back = str_num[mid+1:] else: mid = int(len(str_num)/2) front = str_num[:mid] back = str_num[mid:] stack = [i for i in back] back = '' for i in range(0, len(stack)): back = back + stack.pop() if front == back: return True else: return False print(isPal(1011301))
# take two input numbers number1 = input("Insert first number : ") number2 = input("Insert second number : ") operator = input("Insert operator (+ or - or * or /)") if operator == '+': total = number1 + number2 elif operator == '-': total = number1 - number2 elif operator == '*': total = number2 * number1 elif operator == '/': total = number1 / number2 else: total = "invalid operator" # printing output print(total)
""" File containing all local variable necessary for the script to run """ #Enter your domain name. A value beginning with a period can be used as a subdomain wildcard. DOMAIN = ".locktopus.fr" #PATHS : DEVELOPMENT_SETTINGS_FILE_PATH = "../locktopus/web_project/settings.py"
#var #n, media, cont: int #i: str i='s' cont=0 media=0 while i!='n': n=int(input('Digite um número: ')) media=media+n cont=cont+1 i=input("Desejar continuar somando (s) ou deseja encerrar o programa (n)? ") media=media/cont print (media)
# https://leetcode.com/problems/gray-code/ # # algorithms # Easy (35.75%) # Total Accepted: 365,649 # Total Submissions: 1,022,741 # beats 95.52% of python submissions class Solution(object): def merge(self, nums1, m, nums2, n): """ :type nums1: List[int] :type m: int :type nums2: List[int] :type n: int :rtype: void Do not return anything, modify nums1 in-place instead. """ while m and n: if nums1[m - 1] > nums2[n - 1]: nums1[m + n - 1] = nums1[m - 1] m -= 1 else: nums1[m + n - 1] = nums2[n - 1] n -= 1 nums1[:n] = nums2[:n] return nums1
# Geometry.py # Tasks # Write these functions to calculate following tasks # 1. Areas ==> Circle, Triangle, Reactangle, Square,.. # 2. Volumes ==> Sphere, Pyramid, Prism, Cone, def rectangle(width, length): return width * length def perimeter_rect(width, length): return 2*width + 2*length def triangle(base, height): return 0.5 * base * height def perimeter_triangle(a, b, c): return a + b + c if __name__ == '__main__': print("Geometry.py") area_rect = rectangle(10, 100) peri_rect = perimeter_rect(10, 100) area_tri = triangle(30, 60) peri_tri = perimeter_triangle(10, 20, 30) print(f'Area of React = {area_rect} unit sqrt.') print(f'Perimeter of React = {peri_rect} unit.') print('='*50) print(f'Area of Triangle = {area_tri} unit sqrt') print(f'Perimeter of Triangle = {peri_tri} unit')
def pascal(p): result = [] for i in range(p): if i == 0: result.append([1]) else: result.append([1] + [result[i - 1][j] + result[i - 1][j + 1] for j in range(len(result[i - 1]) - 1)] + [1]) return result
def encode(key: str, txt: str): txt_c = '' for index in range(0, len(txt)): txt_int = ord(txt[index].lower()) + (ord(key[index % len(key)].upper()) - 65) if txt_int > 122: txt_int = txt_int - 26 if txt_int < 97 or txt_int > 122: txt_c = txt_c + txt[index] else: txt_c = txt_c + chr(txt_int) return txt_c.upper() def decode(key: str, txt_c: str): txt = '' for index in range(0, len(txt_c)): txt_int = ord(txt_c[index]) - (ord(key[index % len(key)].upper()) - 65) if txt_int < 97: txt_int = txt_int + 26 if txt_int < 97 or txt_int > 122: txt = txt + txt_c[index] else: txt = txt + chr(txt_int) return txt
# Class to store Trie(Patterns) # It handles all cases particularly the case where a pattern Pi is a subtext of a pattern Pj for i != j class Trie_Patterns: def __init__(self, patterns, start, end): self.build_trie(patterns, start, end) # The trie will be a dictionary of dictionaries where: # ... The key of the external dictionary is the node ID (integer), # ... The internal dictionary: # ...... It contains all the trie edges outgoing from the corresponding node # ...... Its keys are the letters on those edges # ...... Its values are the node IDs to which these edges lead # Time Complexity: O(|patterns|) # Space Complexity: O(|patterns|) def build_trie(self, patterns, start, end): self.trie = dict() self.trie[0] = dict() self.node_patterns_mapping = dict() self.max_node_no = 0 for i in range(len(patterns)): self.insert(patterns[i], i, start, end) def insert(self, pattern, pattern_no, start, end): (index, node) = self.search_text(pattern, start, end) i = index while i <= (end+1): if i == end + 1: c = '$' # to handle the case where Pi is a substring of Pj for i != j else: c = pattern[i] self.max_node_no += 1 self.trie[node][c] = self.max_node_no self.trie[self.max_node_no] = dict() node = self.max_node_no i += 1 if not node in self.node_patterns_mapping: self.node_patterns_mapping[node] = [] self.node_patterns_mapping[node].append(pattern_no) def search_text(self, pattern, start, end): if len(self.trie) == 0: return (0, -1) node = 0 i = start while i <= (end+1): if i == end + 1: c = '$' # to handle the case where Pi is a substring of Pj for i != j else: c = pattern[i] if c in self.trie[node]: node = self.trie[node][c] i += 1 continue else: break return (i, node) # Prints the trie in the form of a dictionary of dictionaries # E.g. For the following patterns: ["AC", "T"] {0:{'A':1,'T':2},1:{'C':3}} def print_tree(self): for node in self.trie: for c in self.trie[node]: print("{}->{}:{}".format(node, self.trie[node][c], c)) print(self.node_patterns_mapping) # Time Complexity: O(|text| * |longest pattern|) def multi_pattern_matching(self, text, start, end): if len(self.trie) == 0: return [] (i, node) = self.search_text(text, start, end) return self.node_patterns_mapping[node] if node in self.node_patterns_mapping else []
def trikotniska_stevila(n): vsota = 0 for i in range(1, n + 1): vsota += i return vsota def najdi(): j = 0 n = 0 st_deliteljev = 0 while st_deliteljev <= 500: st_deliteljev = 0 j += 1 n = trikotniska_stevila(j) i = 1 while i <= n ** 0.5: if n % i == 0: st_deliteljev += 1 i += 1 st_deliteljev *= 2 return n print(najdi())
pid_yaw = rm_ctrl.PIDCtrl() list_LineList = RmList() variable_X = 0 def start(): global variable_X global list_LineList global pid_yaw robot_ctrl.set_mode(rm_define.robot_mode_chassis_follow) # rotate gimbal downward so the line is more visible gimbal_ctrl.pitch_ctrl(-20) # enable line detection and set color to blue vision_ctrl.enable_detection(rm_define.vision_detection_line) vision_ctrl.line_follow_color_set(rm_define.line_follow_color_blue) pid_yaw.set_ctrl_params(330, 0, 28) gimbal_ctrl.set_rotate_speed(30) while True: # get line information list_LineList = RmList(vision_ctrl.get_line_detection_info()) # if ten points are detected follow the line if len(list_LineList) == 42: if list_LineList[2] <= 1: variable_X = list_LineList[19] pid_yaw.set_error(variable_X - 0.5) gimbal_ctrl.rotate_with_speed(pid_yaw.get_output(), 0) chassis_ctrl.set_trans_speed(0.5) chassis_ctrl.move(0) time.sleep(0.05) # if no line was detected rotate around to find line else: chassis_ctrl.stop() gimbal_ctrl.rotate_with_speed(90, -20) time.sleep(2)
def f1(a, b, c=0, *args, **kw): print('a =', a, 'b =', b, 'c =', c, 'args =', args, 'kw =', kw) def f2(a, b, c=0, *, d, **kw): print('a =', a, 'b =', b, 'c =', c, 'd =', d, 'kw =', kw) def product(*x): sum = 1 if len(x) > 0: for item in x: sum = item * sum print(sum) def trim(s): start = 0 for c in s[:]: if(c == ' '): start += 1 else: break end = -1 for c in s[-1:]: if (c == ' '): end += -1 else: break print(s[start: end]) def find_min_and_max(L): temp_min = L[0] temp_max = L[0] for x in L: if x < temp_min: temp_min = x if x > temp_max: temp_max = x print(temp_min, temp_max) def fib(max): n, a, b = 0, 0, 1 while n < max: yield b a, b = b, a + b n = n + 1 return 'done' def triangles(n = 10): results = [] for x in range(n): if x == 0: results.append([1]) elif x == 1: results.append([1, 1]) else: temp = [1] for y in range(x): temp.append(results[x-1][y]) def odd(): n = 1 for index in range(1, max + 1): yield n n = n + 2 print('step = ', index, 'n = ', n) def add(x, y, f): return f(x) + f(y) f1(1, 2) f1(1, 2, c=3) f1(1, 2, 3, 'a', 'b') f1(1, 2, 3, 'a', 'b', x=99) f2(1, 2, d=99, ext=None) product(5, 6, 7, 9) trim(" 123 ") find_min_and_max([10, 9, 11, 23, 21, 7, 99, 11]) L1 = ['Hello', 'World', 18, 'Apple', None] L2 = [x.lower() for x in L1 if isinstance(x, str)] list1 = [1,6,2,5,3] list2 = [34,67,13,678,67] print(add(list1,list2,max))
# def form_list(): # with open("words.txt",'r') as f: # import pdb; pdb.set_trace() # data=f.readlines() # form_list() data=['TEMPERATURE', 'PARTICULAR', 'INSTRUMENT', 'EXPERIMENT', 'EXPERIENCE', 'ESPECIALLY', 'DICTIONARY', 'SUBSTANCE', 'REPRESENT', 'PARAGRAPH', 'NECESSARY', 'DIFFICULT', 'DETERMINE', 'CONTINENT', 'CONSONANT', 'CONDITION', 'CHARACTER', 'TRIANGLE', 'TOGETHER', 'THOUSAND', 'SYLLABLE', 'SURPRISE', 'SUBTRACT', 'STRAIGHT', 'SOLUTION', 'SHOULDER', 'SEPARATE', 'SENTENCE', 'REMEMBER', 'QUOTIENT', 'QUESTION', 'PROPERTY', 'PROBABLE', 'PRACTICE', 'POSSIBLE', 'POSITION', 'POPULATE', 'ORIGINAL', 'OPPOSITE', 'NEIGHBOR', 'MULTIPLY', 'MOUNTAIN', 'MOLECULE', 'MATERIAL', 'LANGUAGE', 'INTEREST', 'INDUSTRY', 'INDICATE', 'FRACTION', 'EXERCISE', 'ELECTRIC', 'DIVISION', 'DESCRIBE', 'CONTINUE', 'CONSIDER', 'COMPLETE', 'CHILDREN', 'WRITTEN', 'WHETHER', 'WEATHER', 'VILLAGE', 'TROUBLE', 'THROUGH', 'THOUGHT', 'SURFACE', 'SUPPORT', 'SUGGEST', 'SUCCESS', 'SUBJECT', 'STUDENT', 'STRETCH', 'STRANGE', 'STATION', 'SPECIAL', 'SOLDIER', 'SIMILAR', 'SEVERAL', 'SEGMENT', 'SECTION', 'SCIENCE', 'REQUIRE', 'RECEIVE', 'PROVIDE', 'PROTECT', 'PRODUCT', 'PRODUCE', 'PROCESS', 'PROBLEM', 'PRESENT', 'PREPARE', 'PICTURE', 'PERHAPS', 'PATTERN', 'OPERATE', 'OBSERVE', 'NUMERAL', 'NOTHING', 'NATURAL', 'MORNING', 'MILLION', 'MEASURE', 'MACHINE', 'INSTANT', 'INCLUDE', 'IMAGINE', 'HUNDRED', 'HISTORY', 'GENERAL', 'FORWARD', 'EXAMPLE', 'EVENING', 'ELEMENT', 'DISTANT', 'DISCUSS', 'DEVELOP', 'DECIMAL', 'CURRENT', 'COUNTRY', 'CORRECT', 'CONTROL', 'CONTAIN', 'CONNECT', 'COMPARE', 'COMPANY', 'COLLECT', 'CERTAIN', 'CENTURY', 'CAPTAIN', 'CAPITAL', 'BROUGHT', 'BROTHER', 'BETWEEN', 'BELIEVE', 'ARRANGE', 'AGAINST', 'YELLOW', 'WONDER', 'WINTER', 'WINDOW', 'WEIGHT', 'VALLEY', 'TWENTY', 'TRAVEL', 'TOWARD', 'THOUGH', 'SYSTEM', 'SYMBOL', 'SUPPLY', 'SUMMER', 'SUFFIX', 'SUDDEN', 'STRONG', 'STRING', 'STREET', 'STREAM', 'SQUARE', 'SPRING', 'SPREAD', 'SPEECH', 'SISTER', 'SINGLE', 'SIMPLE', 'SILVER', 'SILENT', 'SHOULD', 'SETTLE', 'SELECT', 'SECOND', 'SEASON', 'SEARCH', 'SCHOOL', 'RESULT', 'REPEAT', 'REGION', 'RECORD', 'REASON', 'RATHER', 'PROPER', 'PRETTY', 'PLURAL', 'PLEASE', 'PLANET', 'PHRASE', 'PERSON', 'PERIOD', 'PEOPLE', 'PARENT', 'OXYGEN', 'OFFICE', 'OBJECT', 'NUMBER', 'NOTICE', 'NATURE', 'NATION', 'MOTION', 'MOTHER', 'MOMENT', 'MODERN', 'MINUTE', 'MIDDLE', 'METHOD', 'MELODY', 'MATTER', 'MASTER', 'MARKET', 'MAGNET', 'LOCATE', 'LITTLE', 'LISTEN', 'LIQUID', 'LETTER', 'LENGTH', 'ISLAND', 'INVENT', 'INSECT', 'HAPPEN', 'GROUND', 'GOVERN', 'GENTLE', 'GATHER', 'GARDEN', 'FRIEND', 'FOREST', 'FOLLOW', 'FLOWER', 'FINISH', 'FINGER', 'FIGURE', 'FATHER', 'FAMOUS', 'FAMILY', 'EXPECT', 'EXCITE', 'EXCEPT', 'EQUATE', 'ENOUGH', 'ENGINE', 'ENERGY', 'EITHER', 'EFFECT', 'DURING', 'DOUBLE', 'DOLLAR', 'DOCTOR', 'DIVIDE', 'DIRECT', 'DIFFER', 'DESIGN', 'DESERT', 'DEPEND', 'DEGREE', 'DECIDE', 'DANGER', 'CREATE', 'CREASE', 'COURSE', 'COTTON', 'CORNER', 'COMMON', 'COLUMN', 'COLONY', 'CLOTHE', 'CIRCLE', 'CHOOSE', 'CHARGE', 'CHANGE', 'CHANCE', 'CENTER', 'CAUGHT', 'BRIGHT', 'BRANCH', 'BOUGHT', 'BOTTOM', 'BETTER', 'BEHIND', 'BEFORE', 'BEAUTY', 'ARRIVE', 'APPEAR', 'ANSWER', 'ANIMAL', 'ALWAYS', 'AFRAID', 'YOUNG', 'WROTE', 'WRONG', 'WRITE', 'WOULD', 'WORLD', "WON'T", 'WOMEN', 'WOMAN', 'WHOSE', 'WHOLE', 'WHITE', 'WHILE', 'WHICH', 'WHERE', 'WHEEL', 'WATER', 'WATCH', 'VOWEL', 'VOICE', 'VISIT', 'VALUE', 'USUAL', 'UNTIL', 'UNDER', 'TRUCK', 'TRAIN', 'TRADE', 'TRACK', 'TOUCH', 'TOTAL', 'THROW', 'THREE', 'THOSE', 'THIRD', 'THINK', 'THING', 'THICK', 'THESE', 'THERE', 'THEIR', 'THANK', 'TEETH', 'TEACH', 'TABLE', 'SUGAR', 'STUDY', 'STORY', 'STORE', 'STOOD', 'STONE', 'STILL', 'STICK', 'STEEL', 'STEAM', 'STEAD', 'STATE', 'START', 'STAND', 'SPOKE', 'SPEND', 'SPELL', 'SPEED', 'SPEAK', 'SPACE', 'SOUTH', 'SOUND', 'SOLVE', 'SMILE', 'SMELL', 'SMALL', 'SLEEP', 'SLAVE', 'SKILL', 'SINCE', 'SIGHT', 'SHOUT', 'SHORT', 'SHORE', 'SHINE', 'SHELL', 'SHEET', 'SHARP', 'SHARE', 'SHAPE', 'SHALL', 'SEVEN', 'SERVE', 'SENSE', 'SCORE', 'SCALE', 'ROUND', 'RIVER', 'RIGHT', 'REPLY', 'READY', 'REACH', 'RANGE', 'RAISE', 'RADIO', 'QUITE', 'QUIET', 'QUICK', 'QUART', 'PROVE', 'PRINT', 'PRESS', 'POWER', 'POUND', 'POINT', 'PLANT', 'PLANE', 'PLAIN', 'PLACE', 'PITCH', 'PIECE', 'PARTY', 'PAPER', 'PAINT', 'OTHER', 'ORGAN', 'ORDER', 'OFTEN', 'OFFER', 'OCEAN', 'OCCUR', 'NORTH', 'NOISE', 'NIGHT', 'NEVER', 'MUSIC', 'MOUTH', 'MOUNT', 'MONTH', 'MONEY', 'MIGHT', 'METAL', 'MEANT', 'MATCH', 'MAJOR', 'LIGHT', 'LEVEL', 'LEAVE', 'LEAST', 'LEARN', 'LAUGH', 'LARGE', 'HURRY', 'HUMAN', 'HOUSE', 'HORSE', 'HEAVY', 'HEART', 'HEARD', 'HAPPY', 'GUIDE', 'GUESS', 'GROUP', 'GREEN', 'GREAT', 'GRASS', 'GRAND', 'GLASS', 'FRUIT', 'FRONT', 'FRESH', 'FOUND', 'FORCE', 'FLOOR', 'FIRST', 'FINAL', 'FIGHT', 'FIELD', 'FAVOR', 'EXACT', 'EVERY', 'EVENT', 'EQUAL', 'ENTER', 'ENEMY', 'EIGHT', 'EARTH', 'EARLY', 'DRIVE', 'DRINK', 'DRESS', 'DREAM', "DON'T", 'DEATH', 'DANCE', 'CROWD', 'CROSS', 'COVER', 'COUNT', 'COULD', 'COLOR', 'COAST', 'CLOUD', 'CLOSE', 'CLOCK', 'CLIMB', 'CLEAR', 'CLEAN', 'CLASS', 'CLAIM', 'CHORD', 'CHILD', 'CHIEF', 'CHICK', 'CHECK', 'CHART', 'CHAIR', 'CAUSE', 'CATCH', 'CARRY', 'BUILD', 'BROWN', 'BROKE', 'BROAD', 'BRING', 'BREAK', 'BREAD', 'BOARD', 'BLOOD', 'BLOCK', 'BLACK', 'BEGIN', 'BEGAN', 'BASIC', 'APPLE', 'ANGER', 'AMONG', 'ALLOW', 'AGREE', 'AGAIN', 'AFTER', 'ABOVE', 'ABOUT', 'YOUR', 'YEAR', 'YARD', 'WORK', 'WORD', 'WOOD', 'WITH', 'WISH', 'WIRE', 'WING', 'WIND', 'WILL', 'WILD', 'WIFE', 'WIDE', 'WHEN', 'WHAT', 'WEST', 'WERE', 'WENT', 'WELL', 'WEEK', 'WEAR', 'WAVE', 'WASH', 'WARM', 'WANT', 'WALL', 'WALK', 'WAIT', 'VIEW', 'VERY', 'VERB', 'VARY', 'UNIT', 'TYPE', 'TURN', 'TUBE', 'TRUE', 'TRIP', 'TREE', 'TOWN', 'TOOL', 'TOOK', 'TONE', 'TOLD', 'TIRE', 'TINY', 'TIME', 'THUS', 'THIS', 'THIN', 'THEY', 'THEN', 'THEM', 'THAT', 'THAN', 'TEST', 'TERM', 'TELL', 'TEAM', 'TALL', 'TALK', 'TAKE', 'TAIL', 'SWIM', 'SURE', 'SUIT', 'SUCH', 'STOP', 'STEP', 'STAY', 'STAR', 'SPOT', 'SOON', 'SONG', 'SOME', 'SOIL', 'SOFT', 'SNOW', 'SLOW', 'SLIP', 'SKIN', 'SIZE', 'SING', 'SIGN', 'SIDE', 'SHOW', 'SHOP', 'SHOE', 'SHIP', 'SENT', 'SEND', 'SELL', 'SELF', 'SEEM', 'SEED', 'SEAT', 'SAVE', 'SAND', 'SAME', 'SALT', 'SAIL', 'SAID', 'SAFE', 'RULE', 'ROSE', 'ROPE', 'ROOT', 'ROOM', 'ROLL', 'ROCK', 'ROAD', 'RISE', 'RING', 'RIDE', 'RICH', 'REST', 'REAL', 'READ', 'RAIN', 'RAIL', 'RACE', 'PUSH', 'PULL', 'POST', 'POSE', 'PORT', 'POOR', 'POEM', 'PLAY', 'PLAN', 'PICK', 'PATH', 'PAST', 'PASS', 'PART', 'PAIR', 'PAGE', 'OVER', 'OPEN', 'ONLY', 'ONCE', 'NOUN', 'NOTE', 'NOSE', 'NOON', 'NINE', 'NEXT', 'NEED', 'NEAR', 'NAME', 'MUST', 'MUCH', 'MOVE', 'MOST', 'MORE', 'MOON', 'MISS', 'MINE', 'MIND', 'MILK', 'MILE', 'MEET', 'MEAT', 'MEAN', 'MASS', 'MARK', 'MANY', 'MAKE', 'MAIN', 'MADE', 'LOVE', 'LOUD', 'LOST', 'LOOK', 'LONG', 'LONE', 'LIVE', 'LIST', 'LINE', 'LIKE', 'LIFT', 'LIFE', 'LESS', 'LEFT', 'LEAD', 'LATE', 'LAST', 'LAND', 'LAKE', 'LADY', 'KNOW', 'KNEW', 'KING', 'KIND', 'KILL', 'KEPT', 'KEEP', 'JUST', 'JUMP', 'JOIN', 'IRON', 'INCH', 'IDEA', 'HUNT', 'HUGE', 'HOUR', 'HOPE', 'HOME', 'HOLE', 'HOLD', 'HILL', 'HIGH', 'HERE', 'HELP', 'HELD', 'HEAT', 'HEAR', 'HEAD', 'HAVE', 'HARD', 'HAND', 'HALF', 'HAIR', 'GROW', 'GREW', 'GRAY', 'GOOD', 'GONE', 'GOLD', 'GLAD', 'GIVE', 'GIRL', 'GAVE', 'GAME', 'FULL', 'FROM', 'FREE', 'FOUR', 'FORM', 'FOOT', 'FOOD', 'FLOW', 'FLAT', 'FIVE', 'FISH', 'FIRE', 'FINE', 'FIND', 'FILL', 'FELT', 'FELL', 'FEET', 'FEEL', 'FEED', 'FEAR', 'FAST', 'FARM', 'FALL', 'FAIR', 'FACT', 'FACE', 'EVER', 'EVEN', 'ELSE', 'EDGE', 'EAST', 'EASE', 'EACH', 'DUCK', 'DROP', 'DRAW', 'DOWN', 'DOOR', 'DONE', 'DOES', 'DEEP', 'DEAR', 'DEAL', 'DEAD', 'DARK', 'CROP', 'COST', 'CORN', 'COPY', 'COOL', 'COOK', 'COME', 'COLD', 'COAT', 'CITY', 'CENT', 'CELL', 'CASE', 'CARE', 'CARD', 'CAMP', 'CAME', 'CALL', 'BUSY', 'BURN', 'BOTH', 'BORN', 'BOOK', 'BONE', 'BODY', 'BOAT', 'BLUE', 'BLOW', 'BIRD', 'BEST', 'BELL', 'BEEN', 'BEAT', 'BEAR', 'BASE', 'BANK', 'BAND', 'BALL', 'BACK', 'BABY', 'ATOM', 'AREA', 'ALSO', 'ABLE', 'YOU', 'YET', 'YES', 'WIN', 'WHY', 'WHO', 'WAY', 'WAS', 'WAR', 'USE', 'TWO', 'TRY', 'TOP', 'TOO', 'TIE', 'THE', 'TEN', 'SUN', 'SON', 'SKY', 'SIX', 'SIT', 'SHE', 'SET', 'SEE', 'SEA', 'SAY', 'SAW', 'SAT', 'RUN', 'RUB', 'ROW', 'RED', 'RAN', 'PUT', 'PAY', 'OWN', 'OUT', 'OUR', 'ONE', 'OLD', 'OIL', 'OFF', 'NOW', 'NOR', 'NEW', 'NEC', 'MIX', 'MEN', 'MAY', 'MAP', 'MAN', 'LOW', 'LOT', 'LOG', 'LIE', 'LET', 'LEG', 'LED', 'LAY', 'LAW', 'KEY', 'JOY', 'JOB', 'ICE', 'HOW', 'HOT', 'HOT', 'HIT', 'HIS', 'HIM', 'HER', 'HAT', 'HAS', 'HAD', 'GUN', 'GOT', 'GET', 'GAS', 'FUN', 'FOR', 'FLY', 'FIT', 'FIG', 'FEW', 'FAT', 'FAR', 'EYE', 'END', 'EGG', 'EAT', 'EAR', 'DRY', 'DOG', 'DIE', 'DID', 'DAY', 'DAD', 'CUT', 'CRY', 'COW', 'CAT', 'CAR', 'CAN', 'BUY', 'BUT', 'BOY', 'BOX', 'BIT', 'BIG', 'BED', 'BAT', 'BAR', 'BAD', 'ASK', 'ART', 'ARM', 'ARE', 'ANY', 'AND', 'ALL', 'AIR', 'AGO', 'AGE', 'ADD', 'ACT', 'WE', 'US', 'UP', 'TO', 'SO', 'OR', 'ON', 'OH', 'OF', 'NO', 'MY', 'ME', 'IT', 'IS', 'IN', 'IF', 'HE', 'GO', 'DO', 'BY', 'BE', 'AT', 'AS', 'AN', 'AM', 'I', 'A'] # import pdb; pdb.set_trace() # data.sort(reverse=true)
# -*- coding: utf-8 -*- """ 1534. Count Good Triplets Given an array of integers arr, and three integers a, b and c. You need to find the number of good triplets. A triplet (arr[i], arr[j], arr[k]) is good if the following conditions are true: 0 <= i < j < k < arr.length |arr[i] - arr[j]| <= a |arr[j] - arr[k]| <= b |arr[i] - arr[k]| <= c Where |x| denotes the absolute value of x. Return the number of good triplets. Constraints: 3 <= arr.length <= 100 0 <= arr[i] <= 1000 0 <= a, b, c <= 1000 """ class Solution: def countGoodTriplets(self, arr, a: int, b: int, c: int) -> int: res = 0 cache = {} length = len(arr) for i in range(0, length - 2): for j in range(i + 1, length - 1): for k in range(j + 1, length): if (i, j) not in cache: cache[(i, j)] = abs(arr[i] - arr[j]) if (j, k) not in cache: cache[(j, k)] = abs(arr[j] - arr[k]) if (i, k) not in cache: cache[(i, k)] = abs(arr[i] - arr[k]) if cache[(i, j)] <= a and cache[(j, k)] <= b and cache[(i, k)] <= c: res += 1 return res
# # PySNMP MIB module HH3C-RADIUS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/HH3C-RADIUS-MIB # Produced by pysmi-0.3.4 at Wed May 1 13:29:17 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, ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueSizeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueRangeConstraint") hh3cCommon, = mibBuilder.importSymbols("HH3C-OID-MIB", "hh3cCommon") InetAddress, InetAddressType = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddress", "InetAddressType") Ipv6Address, = mibBuilder.importSymbols("IPV6-TC", "Ipv6Address") radiusAccServerAddress, radiusAccClientServerPortNumber, radiusAccServerIndex = mibBuilder.importSymbols("RADIUS-ACC-CLIENT-MIB", "radiusAccServerAddress", "radiusAccClientServerPortNumber", "radiusAccServerIndex") radiusAuthClientServerPortNumber, radiusAuthServerIndex, radiusAuthServerAddress = mibBuilder.importSymbols("RADIUS-AUTH-CLIENT-MIB", "radiusAuthClientServerPortNumber", "radiusAuthServerIndex", "radiusAuthServerAddress") ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup") ObjectIdentity, TimeTicks, Unsigned32, MibIdentifier, IpAddress, MibScalar, MibTable, MibTableRow, MibTableColumn, Bits, Counter32, Counter64, Gauge32, iso, NotificationType, ModuleIdentity, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "TimeTicks", "Unsigned32", "MibIdentifier", "IpAddress", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Bits", "Counter32", "Counter64", "Gauge32", "iso", "NotificationType", "ModuleIdentity", "Integer32") DisplayString, RowStatus, TextualConvention, TruthValue = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TextualConvention", "TruthValue") hh3cRadius = ModuleIdentity((1, 3, 6, 1, 4, 1, 25506, 2, 13)) hh3cRadius.setRevisions(('2014-06-07 18:00',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: hh3cRadius.setRevisionsDescriptions(('Modified description of hh3cRdSecondaryAuthRowStatus. Modified description of hh3cRdSecondaryAccRowStatus',)) if mibBuilder.loadTexts: hh3cRadius.setLastUpdated('201406071800Z') if mibBuilder.loadTexts: hh3cRadius.setOrganization('Hangzhou H3C Technologies Co., Ltd.') if mibBuilder.loadTexts: hh3cRadius.setContactInfo('Platform Team Hangzhou H3C Technologies Co., Ltd. Hai-Dian District Beijing P.R. China http://www.h3c.com Zip:100085 ') if mibBuilder.loadTexts: hh3cRadius.setDescription('The HH3C-RADIUS-MIB contains objects to Manage configuration and Monitor running state for RADIUS feature.') hh3cRdObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1)) hh3cRdInfoTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1), ) if mibBuilder.loadTexts: hh3cRdInfoTable.setStatus('current') if mibBuilder.loadTexts: hh3cRdInfoTable.setDescription('The (conceptual) table listing RADIUS authentication servers.') hh3cRdInfoEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1), ).setIndexNames((0, "HH3C-RADIUS-MIB", "hh3cRdGroupName")) if mibBuilder.loadTexts: hh3cRdInfoEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRdInfoEntry.setDescription('An entry (conceptual row) representing a RADIUS authentication server.') hh3cRdGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) if mibBuilder.loadTexts: hh3cRdGroupName.setStatus('current') if mibBuilder.loadTexts: hh3cRdGroupName.setDescription('The name of the RADIUS authentication group referred to in this table entry.') hh3cRdPrimAuthIp = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 2), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAuthIp.setStatus('deprecated') if mibBuilder.loadTexts: hh3cRdPrimAuthIp.setDescription('The IP address of primary RADIUS authentication server.') hh3cRdPrimUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 3), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimUdpPort.setDescription('The UDP port the client is using to send requests to primary RADIUS authentication server. Default value is 1812.') hh3cRdPrimState = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("block", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimState.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimState.setDescription('The state of the primary RADIUS authentication server. 1 (active) The primary authentication server is in active state. 2 (block) The primary authentication server is in block state.') hh3cRdSecAuthIp = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 5), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAuthIp.setStatus('deprecated') if mibBuilder.loadTexts: hh3cRdSecAuthIp.setDescription('The IP address of secondary RADIUS authentication server.') hh3cRdSecUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 6), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecUdpPort.setDescription('The UDP port the client is using to send requests to secondary RADIUS authentication server. Default value is 1812.') hh3cRdSecState = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("block", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecState.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecState.setDescription('The state of the secondary RADIUS authentication server. 1 (active) The secondary authentication server is in active state. 2 (block) The secondary authentication server is in block state.') hh3cRdKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 8), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdKey.setStatus('current') if mibBuilder.loadTexts: hh3cRdKey.setDescription('The secret shared between the RADIUS client and RADIUS authentication server used in encoding and decoding sensitive data. When read, hh3cRdKey always returns an Octet String of length zero.') hh3cRdRetry = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 9), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdRetry.setStatus('current') if mibBuilder.loadTexts: hh3cRdRetry.setDescription('The number of attempts the client will make when trying to send requests to a server before it will consider the attempt failed. Default value is 3.') hh3cRdTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 10), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdTimeout.setStatus('current') if mibBuilder.loadTexts: hh3cRdTimeout.setDescription('The timeout value the client will use when sending requests to a server. The unit is second. Default value is 3.') hh3cRdPrimAuthIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 11), InetAddressType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAuthIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAuthIpAddrType.setDescription('The IP addresses type (IPv4 or IPv6) of primary RADIUS authentication server.') hh3cRdPrimAuthIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 12), InetAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAuthIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAuthIpAddr.setDescription('The IP address of primary RADIUS authentication server.') hh3cRdSecAuthIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 13), InetAddressType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAuthIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAuthIpAddrType.setDescription('The IP addresses type (IPv4 or IPv6) of secondary RADIUS authentication server.') hh3cRdSecAuthIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 14), InetAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAuthIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAuthIpAddr.setDescription('The IP address of secondary RADIUS authentication server.') hh3cRdServerType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("standard", 1), ("iphotel", 2), ("portal", 3), ("extended", 4)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdServerType.setStatus('current') if mibBuilder.loadTexts: hh3cRdServerType.setDescription('Specify the type of RADIUS server. 1 (standard) - Server based on RFC protocol(s). 2 (iphotel) - Server for IP-Hotel or 201+ system. 3 (portal) - Server for iTellin Portal system. 4 (extended) - Server based on RADIUS extensions. Default type is standard.') hh3cRdQuietTime = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdQuietTime.setStatus('current') if mibBuilder.loadTexts: hh3cRdQuietTime.setDescription('The time for server returning active. The unit is minute. When the value is 0, the server state retains active. Default value is 5.') hh3cRdUserNameFormat = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3))).clone(namedValues=NamedValues(("withoutdomain", 1), ("withdomain", 2), ("keeporignal", 3)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdUserNameFormat.setStatus('current') if mibBuilder.loadTexts: hh3cRdUserNameFormat.setDescription('Specify the user-name format that is sent to RADIUS server. 1 (withoutdomain) - send the user-name without domain. 2 (withdomain) - send the user-name with domain. 3 (keeporignal) - send the user-name as it is entered. Default format is withdomain.') hh3cRdRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 18), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdRowStatus.setStatus('current') if mibBuilder.loadTexts: hh3cRdRowStatus.setDescription('This object is responsible for managing the creation, deletion and modification of rows, which support active status and CreateAndGo, Destroy operation. To create a new row, hh3cRdGroupName must be specified. To destroy an existent row, the hh3cRdGroupName MUST NOT be referred by hh3cDomainTable in hh3cDomainRadiusGroupName column.') hh3cRdSecKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 19), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecKey.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecKey.setDescription('The secret shared between the RADIUS client and the secondary RADIUS authentication server used in encoding and decoding sensitive data. When read, hh3cRdSecKey always returns an Octet String of length zero.') hh3cRdPrimVpnName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 20), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimVpnName.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimVpnName.setDescription('The human-readable name of the VPN in which the primary RADIUS authentication server is placed.') hh3cRdSecVpnName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 21), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecVpnName.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecVpnName.setDescription('The human-readable name of the VPN in which the secondary RADIUS authentication server is placed.') hh3cRdAuthNasIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 22), InetAddressType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAuthNasIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdAuthNasIpAddrType.setDescription('The type (IPv4 or IPv6) of the source IP used to communicate with RADIUS authentication server.') hh3cRdAuthNasIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 23), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAuthNasIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdAuthNasIpAddr.setDescription('The source IPv4 address used to communicate with the RADIUS authentication server.') hh3cRdAuthNasIpv6Addr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 1, 1, 24), Ipv6Address()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAuthNasIpv6Addr.setStatus('current') if mibBuilder.loadTexts: hh3cRdAuthNasIpv6Addr.setDescription('The source IPv6 address used to communicate with the RADIUS authentication server.') hh3cRdAccInfoTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2), ) if mibBuilder.loadTexts: hh3cRdAccInfoTable.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccInfoTable.setDescription('The (conceptual) table listing RADIUS accounting servers.') hh3cRdAccInfoEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1), ).setIndexNames((0, "HH3C-RADIUS-MIB", "hh3cRdAccGroupName")) if mibBuilder.loadTexts: hh3cRdAccInfoEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccInfoEntry.setDescription('An entry (conceptual row) representing a RADIUS accounting server.') hh3cRdAccGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 1), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(1, 32))) if mibBuilder.loadTexts: hh3cRdAccGroupName.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccGroupName.setDescription('The name of the RADIUS group referred to in this table entry.') hh3cRdPrimAccIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 2), InetAddressType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAccIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAccIpAddrType.setDescription('The IP addresses type (IPv4 or IPv6) of primary RADIUS accounting server.') hh3cRdPrimAccIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 3), InetAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAccIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAccIpAddr.setDescription('The IP address of primary RADIUS accounting server.') hh3cRdPrimAccUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 4), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAccUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAccUdpPort.setDescription('The UDP port the client is using to send requests to primary RADIUS accounting server. Default value is 1813.') hh3cRdPrimAccState = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("block", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAccState.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAccState.setDescription('The state of the primary RADIUS accounting server. 1 (active) The primary accounting server is in active state. 2 (block) The primary accounting server is in block state.') hh3cRdSecAccIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 6), InetAddressType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAccIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAccIpAddrType.setDescription('The IP addresses type (IPv4 or IPv6) of secondary RADIUS accounting server.') hh3cRdSecAccIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 7), InetAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAccIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAccIpAddr.setDescription('The IP address of secondary RADIUS accounting server.') hh3cRdSecAccUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 8), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAccUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAccUdpPort.setDescription('The UDP port the client is using to send requests to secondary RADIUS accounting server. Default value is 1813.') hh3cRdSecAccState = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("block", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAccState.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAccState.setDescription('The state of the secondary RADIUS accounting server. 1 (active) The secondary accounting server is in active state. 2 (block) The secondary accounting server is in block state.') hh3cRdAccKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 10), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccKey.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccKey.setDescription('The secret shared between the RADIUS client and RADIUS accounting server used in encoding and decoding sensitive data. When read, hh3cRdAccKey always returns an Octet String of length zero.') hh3cRdAccRetry = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 11), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccRetry.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccRetry.setDescription('The number of attempt the client will make when trying to send requests to a server before it will consider the attempt failed. Default value is 3.') hh3cRdAccTimeout = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 12), Integer32()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccTimeout.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccTimeout.setDescription('The timeout value the client will use when sending requests to a server. The unit is second. Default value is 3.') hh3cRdAccServerType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 13), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("standard", 1), ("iphotel", 2), ("portal", 3), ("extended", 4)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccServerType.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccServerType.setDescription('Specify the type of RADIUS server. 1 (standard) - Server based on RFC protocol(s). 2 (iphotel) - Server for IP-Hotel or 201+ system. 3 (portal) - Server for iTellin Portal system. 4 (extended) - Server based on RADIUS extensions. Default type is standard.') hh3cRdAccQuietTime = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccQuietTime.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccQuietTime.setDescription('The time for server returning active. The unit is minute. When the value is 0, the server state retains active. Default value is 5.') hh3cRdAccFailureAction = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("ignore", 1), ("reject", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccFailureAction.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccFailureAction.setDescription('Defines the action that authentication should take if authentication succeeds but the associated accounting start fails. 1 (ignore) - treat as authentication success; ignore accounting start failure. 2 (reject) - treat as authentication failed if corresponding accounting start fails. Default value is 1(reject).') hh3cRdAccRealTime = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 60))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccRealTime.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccRealTime.setDescription("Interval of realtime-accounting packets. The unit is minute. When the value is 0, the device doesn't send realtime-accounting packets. Default value is 12.") hh3cRdAccRealTimeRetry = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 17), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 255)).clone(5)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccRealTimeRetry.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccRealTimeRetry.setDescription('The number of attempt the client will make when trying to send realtime-accounting packet to accounting server before it will consider the attempt failed. Default value is 5.') hh3cRdAccSaveStopPktEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 18), TruthValue()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccSaveStopPktEnable.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccSaveStopPktEnable.setDescription("The control of whether save stop-accounting packet in local buffer and resend later when the accounting server doesn't respond. When SaveStopPktEnable is set to false, the value of AccStopRetry will be ignored. Default value is true.") hh3cRdAccStopRetry = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(10, 65535))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccStopRetry.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccStopRetry.setDescription('The number of attempt the client will make when trying to send stop-accounting packet to accounting server. Default value is 500.') hh3cRdAccDataFlowUnit = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 20), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("byte", 1), ("kiloByte", 2), ("megaByte", 3), ("gigaByte", 4)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccDataFlowUnit.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccDataFlowUnit.setDescription("Specify data flow format that is sent to RADIUS server. The value SHOULD be set the same as the value of corresponding server. 1 (byte) - Specify 'byte' as the unit of data flow. 2 (kiloByte) - Specify 'kilo-byte' as the unit of data flow. 3 (megaByte) - Specify 'mega-byte' as the unit of data flow. 4 (gigaByte) - Specify 'giga-byte' as the unit of data flow. Default value is 1.") hh3cRdAccPacketUnit = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 21), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("onePacket", 1), ("kiloPacket", 2), ("megaPacket", 3), ("gigaPacket", 4)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccPacketUnit.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccPacketUnit.setDescription("Specify packet format that is sent to RADIUS server. The value SHOULD be set the same as the value of corresponding server. 1 (onePacket) - Specify 'one-packet' as the unit of packet. 2 (kiloPacket) - Specify 'kilo-packet' as the unit of packet. 3 (megaPacket) - Specify 'mega-packet' as the unit of packet. 4 (gigaPacket) - Specify 'giga-packet' as the unit of packet. Default value is 1.") hh3cRdAccRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 22), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccRowStatus.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccRowStatus.setDescription('This object is responsible for managing the creation, deletion and modification of rows, which support active status and CreateAndGo, Destroy operation. To create a new row, hh3cRdAccGroupName must be specified. To destroy an existent row, the hh3cRdAccGroupName MUST NOT be referred by hh3cDomainTable in hh3cDomainRadiusGroupName column.') hh3cRdAcctOnEnable = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 23), TruthValue()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAcctOnEnable.setStatus('current') if mibBuilder.loadTexts: hh3cRdAcctOnEnable.setDescription('The control of Accounting-On function. The Accounting-On function is used by the client to mark the start of accounting (for example, upon booting) by sending Accounting-On packets and to mark the end of accounting (for example, just before a scheduled reboot) by sending Accounting-Off packets. Default value is false.') hh3cRdAcctOnSendTimes = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 24), Integer32().clone(50)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAcctOnSendTimes.setStatus('current') if mibBuilder.loadTexts: hh3cRdAcctOnSendTimes.setDescription('The number of Accounting-On packets the client will send before it considers the accounting server failed. Default value is 50.') hh3cRdAcctOnSendInterval = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 25), Integer32().clone(3)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAcctOnSendInterval.setStatus('current') if mibBuilder.loadTexts: hh3cRdAcctOnSendInterval.setDescription('Interval of Accounting-On packets. The unit is second. Default value is 3.') hh3cRdSecAccKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 26), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAccKey.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAccKey.setDescription('The secret shared between the RADIUS client and the secondary RADIUS accounting server used in encoding and decoding sensitive data. When read, hh3cRdSecAccKey always returns an Octet String of length zero.') hh3cRdPrimAccVpnName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 27), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdPrimAccVpnName.setStatus('current') if mibBuilder.loadTexts: hh3cRdPrimAccVpnName.setDescription('The human-readable name of the VPN in which the primary RADIUS accounting server is placed.') hh3cRdSecAccVpnName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 28), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecAccVpnName.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecAccVpnName.setDescription('The human-readable name of the VPN in which the secondary RADIUS accounting server is placed.') hh3cRdAccNasIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 29), InetAddressType()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccNasIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccNasIpAddrType.setDescription('The type (IPv4 or IPv6) of the source IP used to communicate with RADIUS accounting server.') hh3cRdAccNasIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 30), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccNasIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccNasIpAddr.setDescription('The source IPv4 address used to communicate with the RADIUS accounting server.') hh3cRdAccNasIpv6Addr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 2, 1, 31), Ipv6Address()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdAccNasIpv6Addr.setStatus('current') if mibBuilder.loadTexts: hh3cRdAccNasIpv6Addr.setDescription('The source IPv6 address used to communicate with the RADIUS accounting server.') hh3cRadiusGlobalConfig = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 3)) hh3cRadiusAuthErrThreshold = MibScalar((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 3, 1), Unsigned32().subtype(subtypeSpec=ValueRangeConstraint(1, 100)).clone(30)).setUnits('percentage').setMaxAccess("readwrite") if mibBuilder.loadTexts: hh3cRadiusAuthErrThreshold.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthErrThreshold.setDescription('The threshold of authentication failure trap. A trap will be sent when the percent of the unsuccessful authentication exceeds this threshold.') hh3cRdSecondaryAuthServerTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4), ) if mibBuilder.loadTexts: hh3cRdSecondaryAuthServerTable.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthServerTable.setDescription('The (conceptual) table listing RADIUS secondary authentication servers.') hh3cRdSecondaryAuthServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1), ).setIndexNames((0, "HH3C-RADIUS-MIB", "hh3cRdGroupName"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAuthIpAddrType"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAuthIpAddr"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAuthVpnName"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAuthUdpPort")) if mibBuilder.loadTexts: hh3cRdSecondaryAuthServerEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthServerEntry.setDescription('An entry (conceptual row) representing a RADIUS secondary authentication server.') hh3cRdSecondaryAuthIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 1), InetAddressType()) if mibBuilder.loadTexts: hh3cRdSecondaryAuthIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthIpAddrType.setDescription('The IP addresses type (IPv4 or IPv6) of secondary RADIUS authentication server.') hh3cRdSecondaryAuthIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 2), InetAddress()) if mibBuilder.loadTexts: hh3cRdSecondaryAuthIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthIpAddr.setDescription('The IP address of secondary RADIUS authentication server.') hh3cRdSecondaryAuthVpnName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))) if mibBuilder.loadTexts: hh3cRdSecondaryAuthVpnName.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthVpnName.setDescription('The human-readable name of the VPN in which the secondary RADIUS authentication server is placed.') hh3cRdSecondaryAuthUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: hh3cRdSecondaryAuthUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthUdpPort.setDescription('The UDP port the client is using to send requests to secondary RADIUS authentication server. Default value is 1812.') hh3cRdSecondaryAuthState = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("block", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecondaryAuthState.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthState.setDescription('The state of the secondary RADIUS authentication server. 1 (active) The secondary authentication server is in active state. 2 (block) The secondary authentication server is in block state.') hh3cRdSecondaryAuthKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecondaryAuthKey.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthKey.setDescription('The secret shared between the RADIUS client and the secondary RADIUS authentication server used in encoding and decoding sensitive data. When read, hh3cRdSecondaryAuthKey always returns an Octet String of length zero.') hh3cRdSecondaryAuthRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 4, 1, 7), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecondaryAuthRowStatus.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAuthRowStatus.setDescription("This object is responsible for managing the creation, deletion and modification of rows, which support active status and CreateAndGo, Destroy operation. To create a new row, hh3cRdGroupName must be specified. The number of rows with the same hh3cRdGroupName can't be more than 16.") hh3cRdSecondaryAccServerTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5), ) if mibBuilder.loadTexts: hh3cRdSecondaryAccServerTable.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccServerTable.setDescription('The (conceptual) table listing RADIUS secondary accounting servers.') hh3cRdSecondaryAccServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1), ).setIndexNames((0, "HH3C-RADIUS-MIB", "hh3cRdAccGroupName"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAccIpAddrType"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAccIpAddr"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAccVpnName"), (0, "HH3C-RADIUS-MIB", "hh3cRdSecondaryAccUdpPort")) if mibBuilder.loadTexts: hh3cRdSecondaryAccServerEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccServerEntry.setDescription('An entry (conceptual row) representing a RADIUS secondary accounting server.') hh3cRdSecondaryAccIpAddrType = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 1), InetAddressType()) if mibBuilder.loadTexts: hh3cRdSecondaryAccIpAddrType.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccIpAddrType.setDescription('The IP addresses type (IPv4 or IPv6) of secondary RADIUS accounting server.') hh3cRdSecondaryAccIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 2), InetAddress()) if mibBuilder.loadTexts: hh3cRdSecondaryAccIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccIpAddr.setDescription('The IP address of secondary RADIUS accounting server.') hh3cRdSecondaryAccVpnName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 3), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 31))) if mibBuilder.loadTexts: hh3cRdSecondaryAccVpnName.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccVpnName.setDescription('The human-readable name of the VPN in which the secondary RADIUS accounting server is placed.') hh3cRdSecondaryAccUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))) if mibBuilder.loadTexts: hh3cRdSecondaryAccUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccUdpPort.setDescription('The UDP port the client is using to send requests to secondary RADIUS accounting server. Default value is 1813.') hh3cRdSecondaryAccState = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("active", 1), ("block", 2)))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecondaryAccState.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccState.setDescription('The state of the secondary RADIUS accounting server. 1 (active) The secondary accounting server is in active state. 2 (block) The secondary accounting server is in block state.') hh3cRdSecondaryAccKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 6), DisplayString().subtype(subtypeSpec=ValueSizeConstraint(0, 64))).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecondaryAccKey.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccKey.setDescription('The secret shared between the RADIUS client and the secondary RADIUS accounting server used in encoding and decoding sensitive data. When read, hh3cRdSecondaryAccKey always returns an Octet String of length zero.') hh3cRdSecondaryAccRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 1, 5, 1, 7), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRdSecondaryAccRowStatus.setStatus('current') if mibBuilder.loadTexts: hh3cRdSecondaryAccRowStatus.setDescription("This object is responsible for managing the creation, deletion and modification of rows, which support active status and CreateAndGo, Destroy operation. To create a new row, hh3cRdAccGroupName must be specified. The number of rows with the same hh3cRdAccGroupName can't be more than 16.") hh3cRadiusAccounting = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2)) hh3cRadiusAccClient = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1)) hh3cRadiusAccServerTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1), ) if mibBuilder.loadTexts: hh3cRadiusAccServerTable.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccServerTable.setDescription('The (conceptual) table listing the RADIUS accounting servers with which the client shares a secret.') hh3cRadiusAccServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1), ).setIndexNames((0, "RADIUS-ACC-CLIENT-MIB", "radiusAccServerIndex")) if mibBuilder.loadTexts: hh3cRadiusAccServerEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccServerEntry.setDescription('An entry (conceptual row) representing a RADIUS accounting server with which a client shares a secret.') hh3cRadiusAccClientStartRequests = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAccClientStartRequests.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccClientStartRequests.setDescription('The number of RADIUS accounting start request sent to this server.') hh3cRadiusAccClientStartResponses = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAccClientStartResponses.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccClientStartResponses.setDescription('The number of RADIUS accounting start response received from this server.') hh3cRadiusAccClientInterimRequests = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAccClientInterimRequests.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccClientInterimRequests.setDescription('The number of RADIUS interim accounting request sent to this server.') hh3cRadiusAccClientInterimResponses = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1, 4), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAccClientInterimResponses.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccClientInterimResponses.setDescription('The number of RADIUS interim accounting response received from this server.') hh3cRadiusAccClientStopRequests = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1, 5), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAccClientStopRequests.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccClientStopRequests.setDescription('The number of RADIUS stop accounting request sent to this RADIUS server.') hh3cRadiusAccClientStopResponses = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 2, 1, 1, 1, 6), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAccClientStopResponses.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccClientStopResponses.setDescription('The number of RADIUS stop accounting response received from this server.') hh3cRadiusServerTrap = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3)) hh3cRadiusAuthServerDownTrap = NotificationType((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3, 1)).setObjects(("RADIUS-AUTH-CLIENT-MIB", "radiusAuthServerAddress"), ("RADIUS-AUTH-CLIENT-MIB", "radiusAuthClientServerPortNumber"), ("HH3C-RADIUS-MIB", "hh3cRadiusServerFirstTrapTime")) if mibBuilder.loadTexts: hh3cRadiusAuthServerDownTrap.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthServerDownTrap.setDescription("This trap is generated when the authentication RADIUS server doesn't respond client's requests for specified times.") hh3cRadiusAccServerDownTrap = NotificationType((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3, 2)).setObjects(("RADIUS-ACC-CLIENT-MIB", "radiusAccServerAddress"), ("RADIUS-ACC-CLIENT-MIB", "radiusAccClientServerPortNumber"), ("HH3C-RADIUS-MIB", "hh3cRadiusServerFirstTrapTime")) if mibBuilder.loadTexts: hh3cRadiusAccServerDownTrap.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccServerDownTrap.setDescription("This trap is generated when the accounting RADIUS server doesn't respond client's requests for specified times.") hh3cRadiusServerTrapPrefix = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3, 0)) hh3cRadiusAuthServerUpTrap = NotificationType((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3, 0, 1)).setObjects(("RADIUS-AUTH-CLIENT-MIB", "radiusAuthServerAddress"), ("RADIUS-AUTH-CLIENT-MIB", "radiusAuthClientServerPortNumber"), ("HH3C-RADIUS-MIB", "hh3cRadiusServerFirstTrapTime")) if mibBuilder.loadTexts: hh3cRadiusAuthServerUpTrap.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthServerUpTrap.setDescription('This trap is generated when the device finds that the state of RADIUS authentication server becomes reachable from unreachable.') hh3cRadiusAccServerUpTrap = NotificationType((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3, 0, 2)).setObjects(("RADIUS-ACC-CLIENT-MIB", "radiusAccServerAddress"), ("RADIUS-ACC-CLIENT-MIB", "radiusAccClientServerPortNumber"), ("HH3C-RADIUS-MIB", "hh3cRadiusServerFirstTrapTime")) if mibBuilder.loadTexts: hh3cRadiusAccServerUpTrap.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAccServerUpTrap.setDescription('This trap is generated when the device finds that the state of RADIUS accounting server becomes reachable from unreachable.') hh3cRadiusAuthErrTrap = NotificationType((1, 3, 6, 1, 4, 1, 25506, 2, 13, 3, 0, 3)).setObjects(("RADIUS-AUTH-CLIENT-MIB", "radiusAuthServerAddress"), ("RADIUS-AUTH-CLIENT-MIB", "radiusAuthClientServerPortNumber")) if mibBuilder.loadTexts: hh3cRadiusAuthErrTrap.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthErrTrap.setDescription('This trap is generated when the device finds that the percent of unsuccessful authentication exceeds a threshold, and the threshold is the value of node hh3cRadiusAuthErrThreshold.') hh3cRadiusAuthenticating = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4)) hh3cRadiusAuthClient = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4, 1)) hh3cRadiusAuthServerTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4, 1, 1), ) if mibBuilder.loadTexts: hh3cRadiusAuthServerTable.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthServerTable.setDescription('The (conceptual) table listing the RADIUS authenticating servers with which the client shares a secret.') hh3cRadiusAuthServerEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4, 1, 1, 1), ).setIndexNames((0, "RADIUS-AUTH-CLIENT-MIB", "radiusAuthServerIndex")) if mibBuilder.loadTexts: hh3cRadiusAuthServerEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthServerEntry.setDescription('An entry (conceptual row) representing a RADIUS authenticating server with which a client shares a secret.') hh3cRadiusAuthFailureTimes = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4, 1, 1, 1, 1), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAuthFailureTimes.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthFailureTimes.setDescription('The number of RADIUS authenticating failed to this server.') hh3cRadiusAuthTimeoutTimes = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4, 1, 1, 1, 2), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAuthTimeoutTimes.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthTimeoutTimes.setDescription('The number of RADIUS authenticating timeout to this server.') hh3cRadiusAuthRejectTimes = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 4, 1, 1, 1, 3), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusAuthRejectTimes.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusAuthRejectTimes.setDescription('The number of RADIUS authenticating rejected to this server.') hh3cRadiusExtend = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5)) hh3cRadiusExtendObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 1)) hh3cRadiusExtendTables = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2)) hh3cRadiusExtendTraps = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 3)) hh3cRadiusSchAuthTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1), ) if mibBuilder.loadTexts: hh3cRadiusSchAuthTable.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthTable.setDescription('The (conceptual) table listing RADIUS authentication servers.') hh3cRadiusSchAuthEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1), ).setIndexNames((0, "HH3C-RADIUS-MIB", "hh3cRadiusSchAuthGroupName")) if mibBuilder.loadTexts: hh3cRadiusSchAuthEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthEntry.setDescription('An entry (conceptual row) representing RADIUS authentication servers.') hh3cRadiusSchAuthGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 1), DisplayString()) if mibBuilder.loadTexts: hh3cRadiusSchAuthGroupName.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthGroupName.setDescription('The name of the RADIUS authentication server group referred to in this table entry.') hh3cRadiusSchAuthPrimIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 2), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthPrimIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthPrimIpAddr.setDescription('The IP address of primary RADIUS authenticaiton server.') hh3cRadiusSchAuthPrimUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 3), Integer32().clone(1812)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthPrimUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthPrimUdpPort.setDescription('The UDP port the client is using to send requests to primary RADIUS authentication server. Default value is 1812.') hh3cRadiusSchAuthPrimKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 4), DisplayString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthPrimKey.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthPrimKey.setDescription('The secret shared between the RADIUS client and the primary RADIUS authentication server used in encoding and decoding sensitive data.') hh3cRadiusSchAuthSecIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 5), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthSecIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthSecIpAddr.setDescription('The IP address of secondary RADIUS authenticaiton server.') hh3cRadiusSchAuthSecUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 6), Integer32().clone(1812)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthSecUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthSecUdpPort.setDescription('The UDP port the client is using to send requests to secondary RADIUS authentication server. Default value is 1812.') hh3cRadiusSchAuthSecKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 7), DisplayString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthSecKey.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthSecKey.setDescription('The secret shared between the RADIUS client and the secondary RADIUS authentication server used in encoding and decoding sensitive data.') hh3cRadiusSchAuthRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 1, 1, 8), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAuthRowStatus.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAuthRowStatus.setDescription('This object is responsible for managing the creation, deletion and modification of rows, which support active status and CreateAndGo, Destroy operation. To create a new row, hh3cRadiusSchAuthGroupName must be specified, and this action will create a corresponding domain that hh3cDomainRadiusGroupName is the same as hh3cRadiusSchAuthGroupName. To destroy an existent row, the hh3cRadiusSchAuthGroupName MUST NOT be referred by hh3cDomainTable in hh3cDomainRadiusGroupName column.') hh3cRadiusSchAccTable = MibTable((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2), ) if mibBuilder.loadTexts: hh3cRadiusSchAccTable.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccTable.setDescription('The (conceptual) table listing RADIUS accounting servers.') hh3cRadiusSchAccEntry = MibTableRow((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1), ).setIndexNames((0, "HH3C-RADIUS-MIB", "hh3cRadiusSchAccGroupName")) if mibBuilder.loadTexts: hh3cRadiusSchAccEntry.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccEntry.setDescription('An entry (conceptual row) representing RADIUS accounting servers.') hh3cRadiusSchAccGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 1), DisplayString()) if mibBuilder.loadTexts: hh3cRadiusSchAccGroupName.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccGroupName.setDescription('The name of the RADIUS accounting server group referred to in this table entry.') hh3cRadiusSchAccPrimIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 2), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccPrimIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccPrimIpAddr.setDescription('The IP address of primary RADIUS accounting server.') hh3cRadiusSchAccPrimUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 3), Integer32().clone(1813)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccPrimUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccPrimUdpPort.setDescription('The UDP port the client is using to send requests to primary RADIUS accounting server. Default value is 1813.') hh3cRadiusSchAccPrimKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 4), DisplayString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccPrimKey.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccPrimKey.setDescription('The secret shared between the RADIUS client and the primary RADIUS accounting server used in encoding and decoding sensitive data.') hh3cRadiusSchAccSecIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 5), IpAddress()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccSecIpAddr.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccSecIpAddr.setDescription('The IP address of secondary RADIUS accounting server.') hh3cRadiusSchAccSecUdpPort = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 6), Integer32().clone(1813)).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccSecUdpPort.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccSecUdpPort.setDescription('The UDP port the client is using to send requests to secondary RADIUS accounting server. Default value is 1813.') hh3cRadiusSchAccSecKey = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 7), DisplayString()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccSecKey.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccSecKey.setDescription('The secret shared between the RADIUS client and the secondary RADIUS accounting server used in encoding and decoding sensitive data.') hh3cRadiusSchAccRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 25506, 2, 13, 5, 2, 2, 1, 8), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: hh3cRadiusSchAccRowStatus.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusSchAccRowStatus.setDescription('This object is responsible for managing the creation, deletion and modification of rows, which support active status and CreateAndGo, Destroy operation. To create a new row, hh3cRadiusSchAccGroupName must be specified, and this action will create a corresponding domain that hh3cDomainRadiusGroupName is the same as hh3cRadiusSchAccGroupName. To destroy an existent row, the hh3cRadiusSchAccGroupName MUST NOT be referred by hh3cDomainTable in hh3cDomainRadiusGroupName column.') hh3cRadiusStatistic = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 6)) hh3cRadiusStatAccReq = MibScalar((1, 3, 6, 1, 4, 1, 25506, 2, 13, 6, 1), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusStatAccReq.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusStatAccReq.setDescription('It shows the number of radius account request to the radius server.') hh3cRadiusStatAccAck = MibScalar((1, 3, 6, 1, 4, 1, 25506, 2, 13, 6, 2), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusStatAccAck.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusStatAccAck.setDescription('It shows the number of radius account response from the radius server.') hh3cRadiusStatLogoutReq = MibScalar((1, 3, 6, 1, 4, 1, 25506, 2, 13, 6, 3), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusStatLogoutReq.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusStatLogoutReq.setDescription('It shows the number of logout request to the radius server.') hh3cRadiusStatLogoutAck = MibScalar((1, 3, 6, 1, 4, 1, 25506, 2, 13, 6, 4), Counter64()).setMaxAccess("readonly") if mibBuilder.loadTexts: hh3cRadiusStatLogoutAck.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusStatLogoutAck.setDescription('It shows the number of logout response from the radius server.') hh3cRadiusServerTrapVarObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 25506, 2, 13, 7)) hh3cRadiusServerFirstTrapTime = MibScalar((1, 3, 6, 1, 4, 1, 25506, 2, 13, 7, 1), TimeTicks()).setMaxAccess("accessiblefornotify") if mibBuilder.loadTexts: hh3cRadiusServerFirstTrapTime.setStatus('current') if mibBuilder.loadTexts: hh3cRadiusServerFirstTrapTime.setDescription('Represents the first trap time.') mibBuilder.exportSymbols("HH3C-RADIUS-MIB", hh3cRdSecondaryAccState=hh3cRdSecondaryAccState, hh3cRdSecAccUdpPort=hh3cRdSecAccUdpPort, hh3cRdSecondaryAccKey=hh3cRdSecondaryAccKey, hh3cRadiusSchAccSecUdpPort=hh3cRadiusSchAccSecUdpPort, hh3cRdSecondaryAuthIpAddr=hh3cRdSecondaryAuthIpAddr, hh3cRdSecondaryAuthVpnName=hh3cRdSecondaryAuthVpnName, hh3cRdAuthNasIpAddrType=hh3cRdAuthNasIpAddrType, hh3cRadiusExtendTraps=hh3cRadiusExtendTraps, hh3cRadiusSchAuthGroupName=hh3cRadiusSchAuthGroupName, hh3cRadiusGlobalConfig=hh3cRadiusGlobalConfig, hh3cRdSecondaryAuthKey=hh3cRdSecondaryAuthKey, hh3cRadiusAccClientInterimResponses=hh3cRadiusAccClientInterimResponses, hh3cRadiusStatAccAck=hh3cRadiusStatAccAck, hh3cRdKey=hh3cRdKey, hh3cRdSecAuthIpAddrType=hh3cRdSecAuthIpAddrType, hh3cRdAccRetry=hh3cRdAccRetry, hh3cRadiusSchAuthSecKey=hh3cRadiusSchAuthSecKey, hh3cRdUserNameFormat=hh3cRdUserNameFormat, hh3cRdAccServerType=hh3cRdAccServerType, hh3cRdAcctOnSendTimes=hh3cRdAcctOnSendTimes, hh3cRadiusSchAccGroupName=hh3cRadiusSchAccGroupName, hh3cRadiusServerFirstTrapTime=hh3cRadiusServerFirstTrapTime, hh3cRdAuthNasIpAddr=hh3cRdAuthNasIpAddr, hh3cRdRowStatus=hh3cRdRowStatus, hh3cRadiusAuthServerDownTrap=hh3cRadiusAuthServerDownTrap, hh3cRdAccNasIpv6Addr=hh3cRdAccNasIpv6Addr, hh3cRdRetry=hh3cRdRetry, hh3cRadiusAccounting=hh3cRadiusAccounting, hh3cRadiusServerTrap=hh3cRadiusServerTrap, hh3cRdAccQuietTime=hh3cRdAccQuietTime, hh3cRadiusAccServerEntry=hh3cRadiusAccServerEntry, hh3cRdAccInfoEntry=hh3cRdAccInfoEntry, hh3cRdAccPacketUnit=hh3cRdAccPacketUnit, hh3cRadiusAuthServerUpTrap=hh3cRadiusAuthServerUpTrap, hh3cRadiusSchAuthEntry=hh3cRadiusSchAuthEntry, hh3cRadiusServerTrapVarObjects=hh3cRadiusServerTrapVarObjects, hh3cRadiusStatLogoutAck=hh3cRadiusStatLogoutAck, hh3cRdPrimAuthIpAddr=hh3cRdPrimAuthIpAddr, hh3cRadiusAccServerDownTrap=hh3cRadiusAccServerDownTrap, hh3cRdPrimState=hh3cRdPrimState, hh3cRadiusExtendObjects=hh3cRadiusExtendObjects, hh3cRdGroupName=hh3cRdGroupName, hh3cRdPrimAccIpAddr=hh3cRdPrimAccIpAddr, hh3cRadiusSchAccEntry=hh3cRadiusSchAccEntry, hh3cRadiusSchAccSecKey=hh3cRadiusSchAccSecKey, hh3cRdAccStopRetry=hh3cRdAccStopRetry, hh3cRdServerType=hh3cRdServerType, hh3cRadiusSchAuthPrimUdpPort=hh3cRadiusSchAuthPrimUdpPort, hh3cRdInfoEntry=hh3cRdInfoEntry, PYSNMP_MODULE_ID=hh3cRadius, hh3cRadiusAuthServerEntry=hh3cRadiusAuthServerEntry, hh3cRadiusSchAuthSecUdpPort=hh3cRadiusSchAuthSecUdpPort, hh3cRdSecUdpPort=hh3cRdSecUdpPort, hh3cRdAccDataFlowUnit=hh3cRdAccDataFlowUnit, hh3cRdPrimAccVpnName=hh3cRdPrimAccVpnName, hh3cRdSecAccVpnName=hh3cRdSecAccVpnName, hh3cRdSecondaryAccVpnName=hh3cRdSecondaryAccVpnName, hh3cRadiusAuthTimeoutTimes=hh3cRadiusAuthTimeoutTimes, hh3cRdAccFailureAction=hh3cRdAccFailureAction, hh3cRdQuietTime=hh3cRdQuietTime, hh3cRdAccGroupName=hh3cRdAccGroupName, hh3cRadiusAccClient=hh3cRadiusAccClient, hh3cRadiusSchAccSecIpAddr=hh3cRadiusSchAccSecIpAddr, hh3cRdSecondaryAuthServerEntry=hh3cRdSecondaryAuthServerEntry, hh3cRdObjects=hh3cRdObjects, hh3cRdAccRowStatus=hh3cRdAccRowStatus, hh3cRdSecondaryAccUdpPort=hh3cRdSecondaryAccUdpPort, hh3cRdSecondaryAccRowStatus=hh3cRdSecondaryAccRowStatus, hh3cRdSecondaryAuthUdpPort=hh3cRdSecondaryAuthUdpPort, hh3cRdSecAuthIp=hh3cRdSecAuthIp, hh3cRadiusSchAccPrimIpAddr=hh3cRadiusSchAccPrimIpAddr, hh3cRadiusExtendTables=hh3cRadiusExtendTables, hh3cRadiusStatAccReq=hh3cRadiusStatAccReq, hh3cRdSecondaryAuthServerTable=hh3cRdSecondaryAuthServerTable, hh3cRadiusSchAuthPrimKey=hh3cRadiusSchAuthPrimKey, hh3cRadiusAccClientStartResponses=hh3cRadiusAccClientStartResponses, hh3cRdSecondaryAccServerEntry=hh3cRdSecondaryAccServerEntry, hh3cRadiusAccServerUpTrap=hh3cRadiusAccServerUpTrap, hh3cRadiusAccClientInterimRequests=hh3cRadiusAccClientInterimRequests, hh3cRdAccRealTimeRetry=hh3cRdAccRealTimeRetry, hh3cRdSecAccIpAddr=hh3cRdSecAccIpAddr, hh3cRdPrimAccState=hh3cRdPrimAccState, hh3cRdInfoTable=hh3cRdInfoTable, hh3cRdPrimAuthIpAddrType=hh3cRdPrimAuthIpAddrType, hh3cRdSecAccState=hh3cRdSecAccState, hh3cRadiusAuthFailureTimes=hh3cRadiusAuthFailureTimes, hh3cRdSecAccKey=hh3cRdSecAccKey, hh3cRadiusAuthErrTrap=hh3cRadiusAuthErrTrap, hh3cRdSecondaryAccIpAddrType=hh3cRdSecondaryAccIpAddrType, hh3cRadiusAccClientStartRequests=hh3cRadiusAccClientStartRequests, hh3cRadiusAuthErrThreshold=hh3cRadiusAuthErrThreshold, hh3cRdPrimAuthIp=hh3cRdPrimAuthIp, hh3cRadiusSchAuthSecIpAddr=hh3cRadiusSchAuthSecIpAddr, hh3cRadiusStatistic=hh3cRadiusStatistic, hh3cRadiusAuthRejectTimes=hh3cRadiusAuthRejectTimes, hh3cRadiusSchAccRowStatus=hh3cRadiusSchAccRowStatus, hh3cRdSecondaryAuthRowStatus=hh3cRdSecondaryAuthRowStatus, hh3cRadiusSchAccPrimKey=hh3cRadiusSchAccPrimKey, hh3cRdSecKey=hh3cRdSecKey, hh3cRdPrimAccIpAddrType=hh3cRdPrimAccIpAddrType, hh3cRdPrimVpnName=hh3cRdPrimVpnName, hh3cRdTimeout=hh3cRdTimeout, hh3cRdAcctOnSendInterval=hh3cRdAcctOnSendInterval, hh3cRdPrimAccUdpPort=hh3cRdPrimAccUdpPort, hh3cRadiusAuthServerTable=hh3cRadiusAuthServerTable, hh3cRadius=hh3cRadius, hh3cRadiusExtend=hh3cRadiusExtend, hh3cRdAccKey=hh3cRdAccKey, hh3cRdSecVpnName=hh3cRdSecVpnName, hh3cRadiusSchAuthRowStatus=hh3cRadiusSchAuthRowStatus, hh3cRadiusServerTrapPrefix=hh3cRadiusServerTrapPrefix, hh3cRadiusSchAuthPrimIpAddr=hh3cRadiusSchAuthPrimIpAddr, hh3cRadiusAccClientStopRequests=hh3cRadiusAccClientStopRequests, hh3cRdAccInfoTable=hh3cRdAccInfoTable, hh3cRdSecondaryAccIpAddr=hh3cRdSecondaryAccIpAddr, hh3cRadiusAuthenticating=hh3cRadiusAuthenticating, hh3cRadiusSchAuthTable=hh3cRadiusSchAuthTable, hh3cRdAccTimeout=hh3cRdAccTimeout, hh3cRadiusAccClientStopResponses=hh3cRadiusAccClientStopResponses, hh3cRdAuthNasIpv6Addr=hh3cRdAuthNasIpv6Addr, hh3cRdAccSaveStopPktEnable=hh3cRdAccSaveStopPktEnable, hh3cRadiusAuthClient=hh3cRadiusAuthClient, hh3cRdPrimUdpPort=hh3cRdPrimUdpPort, hh3cRdSecAccIpAddrType=hh3cRdSecAccIpAddrType, hh3cRdSecondaryAccServerTable=hh3cRdSecondaryAccServerTable, hh3cRadiusSchAccPrimUdpPort=hh3cRadiusSchAccPrimUdpPort, hh3cRdSecAuthIpAddr=hh3cRdSecAuthIpAddr, hh3cRdAccRealTime=hh3cRdAccRealTime, hh3cRadiusAccServerTable=hh3cRadiusAccServerTable, hh3cRdSecondaryAuthState=hh3cRdSecondaryAuthState, hh3cRadiusSchAccTable=hh3cRadiusSchAccTable, hh3cRdSecondaryAuthIpAddrType=hh3cRdSecondaryAuthIpAddrType, hh3cRdAcctOnEnable=hh3cRdAcctOnEnable, hh3cRadiusStatLogoutReq=hh3cRadiusStatLogoutReq, hh3cRdSecState=hh3cRdSecState, hh3cRdAccNasIpAddrType=hh3cRdAccNasIpAddrType, hh3cRdAccNasIpAddr=hh3cRdAccNasIpAddr)
#!/usr/bin/env python3 # python3 program of subtraction of # two numbers using 2's complement . # function to subtract two values # using 2's complement method def Subtract(a, b): # ~b is the 1's Complement of b # adding 1 to it make it 2's Complement c = a + (~b + 1) return c # Driver code if __name__ == "__main__": # multiple assignments a, b = 56, 22 print(Subtract(a, b)) # a, b = 9, 7 # print(Subtract(a, b))
class Solution: """ @param nums: The integer array. @param target: Target to find. @return: The first position of target. Position starts from 0. """ def binarySearch(self, nums, target): left = 0 right = len(nums) - 1 while right != left: mid = (left + right) // 2 if nums[mid] == target: while mid > 0 and nums[mid - 1] == nums[mid]: mid -= 1 return mid elif nums[mid] > target: right = mid else: if left == mid: left += 1 else: left = mid return -1
''' This solution worked out because it has a time complexity of O(N) ''' # you can write to stdout for debugging purposes, e.g. # print("this is a debug message") def solution(A): # write your code in Python 3.6 lengthy = len(A) if (lengthy == 0 or lengthy == 1): return 0 diffies =[] maxy = sum(A) tempy = 0 for i in range(0, lengthy-1, 1): tempy = tempy + A[i] diffies.append(abs(maxy-tempy-tempy)) print('diffies ',diffies) # print(min(diffies)) return(min(diffies))
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def binaryTreePaths(self, root): """ :type root: TreeNode :rtype: List[str] """ if not root: return "" paths = [] self.binaryTreePathsHelper(root, paths, []) return paths def binaryTreePathsHelper(self, root, paths, currentRoute): if root: currentRoute.append(str(root.val)) if not root.left and not root.right: # If the node is a leaf paths.append("->".join(currentRoute)) else: if root.left: self.binaryTreePathsHelper(root.left, paths, currentRoute) if root.right: self.binaryTreePathsHelper(root.right, paths, currentRoute) currentRoute.pop()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # ============================================================================= # # ============================================================================= __author__ = 'Chet Coenen' __copyright__ = 'Copyright 2020' __credits__ = ['Chet Coenen'] __license__ = '/LICENSE' __version__ = '1.0' __maintainer__ = 'Chet Coenen' __email__ = 'chet.m.coenen@icloud.com' __socials__ = '@Denimbeard' __status__ = 'Complete' __description__ = 'et of code to convert a whole number from base 10 to variable base without directly using base conversions' __date__ = '30 November 2020 at 15:42' #============================================================================== n = int(input("Input a whole number to convert from base 10: ")) #User inputs a whole positive number, converted to an int b = int(input("Input a base to convert into: ")) #User inputs the new base for their number, converted to an int def toDigits(n, b): #Convert a positive number n to its digit representation in base b. digits = [] #Digits is an empty array that will fill with the math while n > 0: #While your whole number is greater than 0 do the following digits.insert(0, n % b) #Insert into position 0 of digits array the remainder of n/b n = n // b #Your whole number now equals the previous whole number divided by b, rounded down return digits #Print the array named digits list = toDigits(n, b) #Sets the resulting array to the variable list def convert(list): #Converts the array into a single number res = int("".join(map(str, list))) return res cr = convert(list) print("The number {n} converted to base {b} is: {cr}." .format(n=n, b=b, cr=cr)) #Gives results
# coding: utf-8 """ https://leetcode.com/problems/min-stack/ """ class MinStack: def __init__(self): self.array = [] def push(self, x: int) -> None: self.array.append(x) def pop(self) -> None: self.array.pop() def top(self) -> int: return self.array[-1] def getMin(self) -> int: return min(self.array) class MinStack2: def __init__(self): self.stack = [] # We use an extra variable to track the minimum value. self.min_value = float('inf') def push(self, x: int) -> None: self.stack.append(x) if x < self.min_value: self.min_value = x def pop(self) -> None: popped = self.stack.pop() if popped == self.min_value: if self.stack: self.min_value = min(self.stack) else: self.min_value = float('inf') def top(self) -> int: return self.stack[-1] def getMin(self) -> int: if self.min_value == float('inf'): return self.stack[0] return self.min_value class MinStack3: def __init__(self): self.stack = [] # We keep track of the minimum value for each push(), # and push the minimum value into track_stack. # NOTE: The length of both stacks are always equal. # https://www.geeksforgeeks.org/tracking-current-maximum-element-in-a-stack/ self.track_stack = [] def push(self, x: int) -> None: self.stack.append(x) try: current_min = self.track_stack[-1] except IndexError: self.track_stack.append(x) else: if x < current_min: # There is a new minimum value. current_min = x else: # The minimum is still the same as the last push(). pass self.track_stack.append(current_min) def pop(self) -> None: self.stack.pop() self.track_stack.pop() def top(self) -> int: return self.stack[-1] def getMin(self) -> int: return self.track_stack[-1] # Your MinStack object will be instantiated and called as such: # obj = MinStack() # obj.push(x) # obj.pop() # param_3 = obj.top() # param_4 = obj.getMin()
# vim:tw=50 """Tuples You have already seen one kind of sequence: the string. Strings are a sequence of one-character strings - they're strings all the way down. They are also **immutable**: once you have defined one, it can never change. Another immutable seqeunce type in Python is the **tuple**. You define a tuple by separating values by commas, thus: 10, 20, 30 # This is a 3-element tuple. They are usually set apart with parentheses, e.g., |(10, 20, 30)|, though these are not always required (the empty tuple |()|, however, does require parentheses). It's usually best to just use them. Tuples, as is true of every other Python sequence, support **indexing**, accessing a single element with the |[]| notation: print(my_tuple[10]) # Get element 10. Exercises - Create a one-element tuple and print it out, e.g., |a = 4,| (the trailing comma is required). - Try comparing two tuples to each other using standard comparison operators, like |<| or |>=|. How does the comparison work? """ # A basic tuple. a = 1, 3, 'hey', 2 print(a) # Usually you see them with parentheses: b = (1, 3, 'hey', 2) print(b) print("b has", len(b), "elements") # Indexing is easy: print("first element", b[0]) print("third element", b[2]) # Even from the right side (the 'back'): print("last element", b[-1]) print("penultimate", b[-2]) # Parentheses are always required for the empty # tuple: print("empty", ()) # And single-element tuples have to have a comma: print("singleton", (5,)) # A tuple print("not a tuple", (5)) # A number # They are immutable, though: you can't change # them. b[1] = 'new value' # oops
""" @apiDefine Success @apiError 0 Success. """ """ @apiDefine IdNotFound @apiError 1 Swimmer <code>id</code> not found. """ """ @apiDefine InvalidParamLaps @apiError 2 Invalid value for <code>laps</code> param. """ """ @apiDefine AvatarNotFound @apiError 3 Swimmer avatar file not found. """ """ @apiDefine MissingParamNewSwimmer @apiError 4 Missing value or file for new swimmer, requires <code>id</code>, <code>name</code> and <code>avatar</code>. """ """ @apiDefine InvalidId @apiError 5 Invalid swimmer <code>id</code>. """ """ @apiDefine ExistingId @apiError 6 Existing swimmer <code>id</code>. """ """ @apiDefine AlreadyRecording @apiError 7 Swimmer already being recorded. """ """ @apiDefine NotRecording @apiError 8 Swimmer is not being recorded. """ """ @apiDefine AlreadyZeroLaps @apiError 9 Already 0 laps. """ """ @apiDefine MissingParamUpdateAvatar @apiError 10 Missing value or file for updating swimmer\'s avatar, requires <code>id</code> and <code>avatar</code>. """ """ @api {GET} /swimmer/info/:id Request Swimmer Information @apiName GetSwimmerInfo @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiUse Success @apiUse IdNotFound @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response @apiSuccess {Dictionary} result Information of the requested swimmer @apiSuccess {String} result.id Unique ID of swimmer @apiSuccess {String} result.name Name of swimmer @apiSuccess {Integer} result.laps Laps completed by swimmer @apiSuccessExample {json} Success Response { "status": 0, "msg": "Success", "result": { "id": "001", "name": "John Appleseed", "laps": 15 } } """ """ @api {GET} /swimmer/avatar/:id Request Swimmer Avatar @apiName GetSwimmerAvatar @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiUse Success @apiUse IdNotFound @apiSuccess {Blob} N/A Avatar of the requested swimmer """ """ @api {GET} /swimmer/start-record/:id Start Recording Swimmer @apiName StartRecordSwimmer @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiUse Success @apiUse IdNotFound @apiUse AlreadyRecording @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response """ """ @api {GET} /swimmer/stop-record/:id Stop Recording Swimmer @apiName StopRecordSwimmer @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiUse Success @apiUse IdNotFound @apiUse NotRecording @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response """ """ @api {GET} /swimmer/addlap/:id Increment Lap Count @apiName AddLap @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiUse Success @apiUse IdNotFound @apiUse NotRecording @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response @apiSuccess {Dictionary} result New information of the swimmer @apiSuccess {String} result.id Unique ID of swimmer @apiSuccess {String} result.name Name of swimmer @apiSuccess {Integer} result.laps Updated laps completed by swimmer """ """ @api {GET} /swimmer/sublap/:id Decrement Lap Count @apiName SubtractLap @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiUse Success @apiUse IdNotFound @apiUse NotRecording @apiUse AlreadyZeroLaps @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response @apiSuccess {Dictionary} result New information of the swimmer @apiSuccess {String} result.id Unique ID of swimmer @apiSuccess {String} result.name Name of swimmer @apiSuccess {Integer} result.laps Updated laps completed by swimmer """ """ @api {GET} /swimmer/setlap/:id/:laps Set Lap Count @apiName SetLap @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiParam {Integer} laps Swimmer’s new lap count (non-negative) @apiUse Success @apiUse IdNotFound @apiUse InvalidParamLaps @apiUse NotRecording @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response @apiSuccess {Dictionary} result New information of the swimmer @apiSuccess {String} result.id Unique ID of swimmer @apiSuccess {String} result.name Name of swimmer @apiSuccess {Integer} result.laps Updated laps completed by swimmer """ """ @api {POST} /swimmer/new Create New Swimmer @apiName NewSwimmer @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiParam {String} name Swimmer’s name @apiParam {Blob} avatar Swimmer’s avatar image file in JPEG format @apiParam {Integer} laps <em>(Optional. Default: 0)</em> Swimmer’s lap count (non-negative) @apiUse Success @apiUse InvalidParamLaps @apiUse MissingParamNewSwimmer @apiUse InvalidId @apiUse ExistingId @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response """ """ @api {POST} /swimmer/update/avatar Update Swimmer Avatar @apiName UpdateAvatar @apiGroup Swimmer @apiParam {String} id Swimmer’s unique 3-digit ID @apiParam {Blob} avatar Swimmer’s avatar image file in JPEG format @apiUse Success @apiUse IdNotFound @apiUse InvalidId @apiUse MissingParamUpdateAvatar @apiSuccess {Integer} status Response code of the request @apiSuccess {String} msg Description about the response """
""" # COMBINATION SUM II Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target. Each number in candidates may only be used once in the combination. Note: The solution set must not contain duplicate combinations. Example 1: Input: candidates = [10,1,2,7,6,1,5], target = 8 Output: [ [1,1,6], [1,2,5], [1,7], [2,6] ] Example 2: Input: candidates = [2,5,2,1,2], target = 5 Output: [ [1,2,2], [5] ] Constraints: 1 <= candidates.length <= 100 1 <= candidates[i] <= 50 1 <= target <= 30 """ def combinationSum2(candidates, target): candidates.sort() return combo(candidates, target) def combo(candidates, target): if len(candidates) == 0 or target < min(candidates): return [] result = [] if target in candidates: result.append([target]) for i, x in enumerate(candidates): if i > 0 and x == candidates[i - 1]: continue y = combo(candidates[i+1:], target - x) if len(y) == 0: continue for t in y: t.append(x) result.append(t) return result
# EASY # find all multiples less than n # ex Input 6 # arr = [1:True, 2:True ,3:True ,4:True ,5:True ] # start from 2, mark 2*2, 2*3, 2*4 ... False # Time O(N^2) Space O(N) class Solution: def countPrimes(self, n: int) -> int: arr = [1 for _ in range(n)] count = 0 for i in range(2,n): j = 2 while arr[i] and i*j < n: arr[i*j] = 0 j += 1 for i in range(2,n): if arr[i]: count+= 1 return count
def test_sm_etprf_include_eic_yestoday(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(3, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 100 def test_sm_etprf_without_eic_yestoday(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(3, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.find_in_container_number(11, 2, 1) app.testHelperSMSearch.find_in_container_number(11, 6, 3) app.testHelperSMSearch.find_in_container_number(11, 6, 4) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 30 def test_sm_etprf_include_eic_yestoday_today(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(11, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 100 def test_sm_etprf_without_eic_yestoday_today(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(11, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.find_in_container_number(11, 2, 1) app.testHelperSMSearch.find_in_container_number(11, 6, 3) app.testHelperSMSearch.find_in_container_number(11, 6, 4) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 30 def test_sm_etprf_include_eic_7_days(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(4, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 600 def test_sm_etprf_without_eic_7_days(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(4, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.find_in_container_number(11, 2, 1) app.testHelperSMSearch.find_in_container_number(11, 6, 3) app.testHelperSMSearch.find_in_container_number(11, 6, 4) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 120 def test_sm_etprf_include_eic_current_month(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(5, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > int(app.testHelperSMSearch.current_date_time_day())*100 def test_sm_etprf_without_eic_current_month(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(5, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.find_in_container_number(11, 2, 1) app.testHelperSMSearch.find_in_container_number(11, 6, 3) app.testHelperSMSearch.find_in_container_number(11, 6, 4) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > int(app.testHelperSMSearch.current_date_time_day())*20 def test_sm_etprf_include_eic_prev_month(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(6, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 3500 def test_sm_etprf_without_eic_prev_month(app): app.testhelpersm.refresh_page() app.session.open_SM_page(app.smPurchases) app.session.ensure_login_sm(app.username, app.password) app.session.ensure_login_sm(app.username, app.password) app.session.open_SM_page(app.smPurchases) app.testHelperSMSearch.expand_show_hide() # Искать в контейнере (всего контейнеров + 1, номер контейнера(если 0 - случайный выбор), номер строки # в контейнере если 0 - случайный выбор) name = 'ETPRF' app.testHelperSMSearch.select_first_publish_date(6, 0) app.testHelperSMSearch.find_torgovaya_ploschadka(name) app.testHelperSMSearch.find_in_container_number(11, 2, 1) app.testHelperSMSearch.find_in_container_number(11, 6, 3) app.testHelperSMSearch.find_in_container_number(11, 6, 4) app.testHelperSMSearch.press_search_button() assert app.testHelperSMSearch.check_results() != '0' assert int(app.testHelperSMSearch.check_results()) > 600
class ViewModel: current_model = None def __init__(self, view): self.view = view def switch(self, model): self.clear_annotation() self.current_model = model self.view.show(model) def get_current_id(self): return self.current_model.identifier def clear_annotation(self): self.view.clear_annotation() def show_annotation(self, annotation): self.view.show_annotation(annotation)
var1 = "Hello World" var2 = 100 # while something is true do stuff while(var2 < 110): print("still less than 110!") var2 += 1 else: print(f"Not less than 110: var2 = {var2}")
def sort_carries(carries): sorted_results = {"loss": [], "no_gain": [], "short_gain": [], "med_gain": [], "big_gain": []} for carry in carries: if carry < 0: sorted_results["loss"].append(carry) elif carry == 0: sorted_results["no_gain"].append(carry) elif 0 < carry < 5: sorted_results["short_gain"].append(carry) elif 5 <= carry < 10: sorted_results["med_gain"].append(carry) elif carry >= 10: sorted_results["big_gain"].append(carry) return sorted_results def bucket_carry_counts(raw_carries): sorted_carries = sort_carries(raw_carries) bucketed_carries = {'loss': len(sorted_carries['loss']), 'no_gain': len(sorted_carries['no_gain']), 'short_gain': len(sorted_carries['short_gain']), 'med_gain': len(sorted_carries['med_gain']), 'big_gain': len(sorted_carries['big_gain'])} return bucketed_carries
# # PySNMP MIB module CXPhysicalInterfaceManager-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CXPhysicalInterfaceManager-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:17:44 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) # OctetString, ObjectIdentifier, Integer = mibBuilder.importSymbols("ASN1", "OctetString", "ObjectIdentifier", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, ValueSizeConstraint, SingleValueConstraint, ValueRangeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueSizeConstraint", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsIntersection") cxPortManager, = mibBuilder.importSymbols("CXProduct-SMI", "cxPortManager") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") ObjectIdentity, IpAddress, MibIdentifier, Gauge32, Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, ModuleIdentity, Unsigned32, Counter64, Counter32, iso, TimeTicks, Bits, NotificationType = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "IpAddress", "MibIdentifier", "Gauge32", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ModuleIdentity", "Unsigned32", "Counter64", "Counter32", "iso", "TimeTicks", "Bits", "NotificationType") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") cxPhyIfTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 5, 16, 3), ) if mibBuilder.loadTexts: cxPhyIfTable.setStatus('mandatory') cxPhyIfEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 5, 16, 3, 1), ).setIndexNames((0, "CXPhysicalInterfaceManager-MIB", "cxPhyIfIndex")) if mibBuilder.loadTexts: cxPhyIfEntry.setStatus('mandatory') cxPhyIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 5, 16, 3, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxPhyIfIndex.setStatus('mandatory') cxPhyIfType = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 5, 16, 3, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 5, 6, 8, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28))).clone(namedValues=NamedValues(("others", 1), ("v24", 2), ("v35", 3), ("x21", 4), ("v34", 5), ("u-isdn-bri", 6), ("st-isdn-bri", 8), ("dds-56k", 10), ("dds-t1e1", 11), ("fxs-voice", 12), ("fxo-voice", 13), ("em-voice", 14), ("ethernet", 15), ("token-ring", 16), ("v35-eu", 17), ("hsIO", 18), ("usIO", 19), ("lanIO", 20), ("elIO", 21), ("voxIO", 22), ("tlIO", 23), ("t1e1IO", 24), ("dvc", 25), ("multi-io", 26), ("fast-ethernet", 27), ("atm-cell-io", 28)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxPhyIfType.setStatus('mandatory') mibBuilder.exportSymbols("CXPhysicalInterfaceManager-MIB", cxPhyIfIndex=cxPhyIfIndex, cxPhyIfTable=cxPhyIfTable, cxPhyIfEntry=cxPhyIfEntry, cxPhyIfType=cxPhyIfType)
def df_to_lower(data, cols=None): '''Convert all string values to lowercase data : pandas dataframe The dataframe to be cleaned cols : str, list, or None If None, an attempt will be made to turn all string columns into lowercase. ''' if isinstance(cols, str): cols = [cols] elif cols is None: cols = data.columns for col in cols: try: data[col] = data[col].str.lower() except AttributeError: pass return data
nome = str(input("Digite seu nome: ")).strip() print("Seu nome em maiusculas é {}".format(nome.upper())) print("Seu nome em minusculas é {}".format(nome.lower())) print("Seu nome tem ao todo {} letras".format(len(nome) - nome.count(' '))) print("Seu primeiro nome é {} e ele tem {} letras.".format(nome[:nome.find(' ')], nome.find(' ')))
def exercise_1(): a_word = "hello world" f = open("exo1.txt",'a') f.write(a_word) f.close() def save_list2file(sentences, filename): f = open(filename,"w") f.close()
''' The .pivot_table() method has several useful arguments, including fill_value and margins. fill_value replaces missing values with a real value (known as imputation). What to replace missing values with is a topic big enough to have its own course (Dealing with Missing Data in Python), but the simplest thing to do is to substitute a dummy value. margins is a shortcut for when you pivoted by two variables, but also wanted to pivot by each of those variables separately: it gives the row and column totals of the pivot table contents. In this exercise, you'll practice using these arguments to up your pivot table skills, which will help you crunch numbers more efficiently! ''' # Print mean weekly_sales by department and type; fill missing values with 0 print(sales.pivot_table(values="weekly_sales", index="type", columns="department", fill_value=0)) # Print the mean weekly_sales by department and type; fill missing values with 0s; sum all rows and cols print(sales.pivot_table(values="weekly_sales", index="department", columns="type", fill_value=0, margins=True))
def matrix_rank(x): """ Returns the rank of a Galois field matrix. References ---------- * https://numpy.org/doc/stable/reference/generated/numpy.linalg.matrix_rank.html Examples -------- .. ipython:: python GF = galois.GF(31) A = GF.Identity(4); A np.linalg.matrix_rank(A) One column is a linear combination of another. .. ipython:: python GF = galois.GF(31) A = GF.Random((4,4)); A A[:,2] = A[:,1] * GF(17); A np.linalg.matrix_rank(A) One row is a linear combination of another. .. ipython:: python GF = galois.GF(31) A = GF.Random((4,4)); A A[3,:] = A[2,:] * GF(8); A np.linalg.matrix_rank(A) """ return def matrix_power(x): """ Raises a square Galois field matrix to an integer power. References ---------- * https://numpy.org/doc/stable/reference/generated/numpy.linalg.matrix_power.html Examples -------- .. ipython:: python GF = galois.GF(31) A = GF.Random((3,3)); A np.linalg.matrix_power(A, 3) A @ A @ A .. ipython:: python GF = galois.GF(31) # Ensure A is full rank and invertible while True: A = GF.Random((3,3)) if np.linalg.matrix_rank(A) == 3: break A np.linalg.matrix_power(A, -3) A_inv = np.linalg.inv(A) A_inv @ A_inv @ A_inv """ return def det(A): """ Computes the determinant of the matrix. References ---------- * https://numpy.org/doc/stable/reference/generated/numpy.linalg.det.html Examples -------- .. ipython:: python GF = galois.GF(31) A = GF.Random((2,2)); A np.linalg.det(A) A[0,0]*A[1,1] - A[0,1]*A[1,0] """ return def inv(A): """ Computes the inverse of the matrix. References ---------- * https://numpy.org/doc/stable/reference/generated/numpy.linalg.inv.html Examples -------- .. ipython:: python GF = galois.GF(31) # Ensure A is full rank and invertible while True: A = GF.Random((3,3)) if np.linalg.matrix_rank(A) == 3: break A A_inv = np.linalg.inv(A); A_inv A_inv @ A """ return def solve(x): """ Solves the system of linear equations. References ---------- * https://numpy.org/doc/stable/reference/generated/numpy.linalg.solve.html Examples -------- .. ipython:: python GF = galois.GF(31) # Ensure A is full rank and invertible while True: A = GF.Random((4,4)) if np.linalg.matrix_rank(A) == 4: break A b = GF.Random(4); b x = np.linalg.solve(A, b); x A @ x .. ipython:: python GF = galois.GF(31) # Ensure A is full rank and invertible while True: A = GF.Random((4,4)) if np.linalg.matrix_rank(A) == 4: break A B = GF.Random((4,2)); B X = np.linalg.solve(A, B); X A @ X """ return
def make_differences(arr): diff_arr = [0] * (len(arr) - 1) for i in range(1, len(arr)): diff_arr[i - 1] = arr[i] - arr[i - 1] return diff_arr def paths_reconstruction(arr): num_paths_arr = [0] * len(arr) num_paths_arr[-1] = 1 for i in range(len(arr) - 2, -1, -1): num_paths = 0 for j in range(1, 4): if i + j >= len(arr): break if arr[i+j] - arr[i] > 3: break num_paths += num_paths_arr[i + j] num_paths_arr[i] = num_paths return num_paths_arr[0]
class EmptyDicomSeriesException(Exception): """ Exception that is raised when the given folder does not contain dcm-files. """ def __init__(self, *args): if not args: args = ('The specified path does not contain dcm-files. Please ensure that ' 'the path points to a folder containing a DICOM-series.', ) Exception.__init__(self, *args)
#!/usr/bin/env python3 # A feladat megoldásához felhasználtam: https://docs.python.org/3/library/stdtypes.html def tizesbe(rendszer, szamstr): res = 0 for b in range(len(szamstr)): if szamstr[b].isdecimal(): res += int(szamstr[b]) * rendszer ** (len(szamstr) - 1 - b) else: res += (ord(szamstr[b].upper())-55) * rendszer ** (len(szamstr) - 1 - b) return res def main(): rendszer = int(input("Add meg a számrendszert: ")) szam = input("Add meg a számot: ") print("A megadott szám 10-es számrendszerben: {}".format(tizesbe(rendszer, szam))) main()
#DictExample8.py student = {"name":"sumit","college":"stanford","grade":"A"} #this will prints whole key and values pairs using items() for x in student.items(): print(x) print("-----------------------------------------------------") #you can also store key and value in two differnet variable like for x,y in student.items(): print(x,"-",y)
# -*- coding: utf-8 -*- def uninstall(portal, reinstall=False): """ launch uninstall profile """ setup_tool = portal.portal_setup setup_tool.runAllImportStepsFromProfile( 'profile-Products.PloneGlossary:uninstall')
class config: global auth; auth = "YOUR TOKEN" # Enter your discord token for Auto-Login. global prefix; prefix = "$" # Enter your prefix for selfbot. global nitro_sniper; nitro_sniper = "true" # 'true' to enable nitro sniper, 'false' to disable. global giveaway_sniper; giveaway_sniper = "true" # 'true' to enable giveaway sniper, 'false' to disable.
# # PySNMP MIB module HUAWEI-IMA-MIB (http://pysnmp.sf.net) # ASN.1 source http://mibs.snmplabs.com:80/asn1/HUAWEI-IMA-MIB # Produced by pysmi-0.0.7 at Sun Jul 3 11:25:20 2016 # On host localhost.localdomain platform Linux version 3.10.0-229.7.2.el7.x86_64 by user root # Using Python version 2.7.5 (default, Jun 24 2015, 00:41:19) # (Integer, ObjectIdentifier, OctetString,) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") (NamedValues,) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") (ConstraintsUnion, SingleValueConstraint, ConstraintsIntersection, ValueSizeConstraint, ValueRangeConstraint,) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ConstraintsIntersection", "ValueSizeConstraint", "ValueRangeConstraint") (hwDatacomm,) = mibBuilder.importSymbols("HUAWEI-MIB", "hwDatacomm") (ifIndex, InterfaceIndexOrZero, InterfaceIndex,) = mibBuilder.importSymbols("IF-MIB", "ifIndex", "InterfaceIndexOrZero", "InterfaceIndex") (NotificationGroup, ModuleCompliance, ObjectGroup,) = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") (Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, NotificationType, MibIdentifier, IpAddress, TimeTicks, Counter64, Unsigned32, enterprises, ModuleIdentity, Gauge32, iso, ObjectIdentity, Bits, Counter32,) = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "NotificationType", "MibIdentifier", "IpAddress", "TimeTicks", "Counter64", "Unsigned32", "enterprises", "ModuleIdentity", "Gauge32", "iso", "ObjectIdentity", "Bits", "Counter32") (DisplayString, RowStatus, TextualConvention, DateAndTime,) = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TextualConvention", "DateAndTime") hwImaMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176)) hwImaMibObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1)) hwImaMibConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2)) hwImaNotifications = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3)) class MilliSeconds(Integer32, TextualConvention): pass class ImaGroupState(Integer32, TextualConvention): subtypeSpec = Integer32.subtypeSpec + SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, ) namedValues = NamedValues(("notConfigured", 1), ("startUp", 2), ("startUpAck", 3), ("configAbortUnsupportedM", 4), ("configAbortIncompatibleSymmetry", 5), ("configAbortOther", 6), ("insufficientLinks", 7), ("blocked", 8), ("operational", 9), ("configAbortUnsupportedImaVersion", 10), ) class ImaGroupSymmetry(Integer32, TextualConvention): subtypeSpec = Integer32.subtypeSpec + SingleValueConstraint(1, 2, 3, ) namedValues = NamedValues(("symmetricOperation", 1), ("asymmetricOperation", 2), ("asymmetricConfiguration", 3), ) class ImaFrameLength(Integer32, TextualConvention): subtypeSpec = Integer32.subtypeSpec + SingleValueConstraint(1, 2, 3, 4, ) namedValues = NamedValues(("m32", 1), ("m64", 2), ("m128", 3), ("m256", 4), ) class ImaLinkState(Integer32, TextualConvention): subtypeSpec = Integer32.subtypeSpec + SingleValueConstraint(1, 2, 3, 4, 5, 6, 7, 8, ) namedValues = NamedValues(("notInGroup", 1), ("unusableNoGivenReason", 2), ("unusableFault", 3), ("unusableMisconnected", 4), ("unusableInhibited", 5), ("unusableFailed", 6), ("usable", 7), ("active", 8), ) hwImaGroupTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1), ) hwImaGroupEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1), ).setIndexNames( (0, "HUAWEI-IMA-MIB", "hwImaGroupIfIndex")) hwImaGroupIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 1), InterfaceIndex()).setMaxAccess( "readonly") hwImaGroupNeState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 2), ImaGroupState()).setMaxAccess( "readonly") hwImaGroupFeState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 3), ImaGroupState()).setMaxAccess( "readonly") hwImaGroupSymmetry = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 4), ImaGroupSymmetry()).setMaxAccess( "readonly") hwImaGroupMinNumTxLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 32))).setMaxAccess( "readcreate") hwImaGroupMinNumRxLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 32))).setMaxAccess( "readcreate") hwImaGroupTxTimingRefLink = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 7), InterfaceIndexOrZero()).setMaxAccess("readonly") hwImaGroupRxTimingRefLink = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 8), InterfaceIndexOrZero()).setMaxAccess("readonly") hwImaGroupTxImaId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess( "readonly") hwImaGroupRxImaId = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess( "readonly") hwImaGroupTxFrameLength = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 11), ImaFrameLength()).setMaxAccess("readcreate") hwImaGroupRxFrameLength = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 12), ImaFrameLength()).setMaxAccess("readonly") hwImaGroupDiffDelayMax = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 13), MilliSeconds().subtype(subtypeSpec=ValueRangeConstraint(25, 120))).setMaxAccess( "readcreate") hwImaGroupAlphaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 2))).setMaxAccess( "readonly") hwImaGroupBetaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 5))).setMaxAccess( "readonly") hwImaGroupGammaValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 16), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 5))).setMaxAccess( "readonly") hwImaGroupNumTxActLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 17), Gauge32()).setMaxAccess( "readonly") hwImaGroupNumRxActLinks = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 18), Gauge32()).setMaxAccess( "readonly") hwImaGroupTxOamLabelValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 255))).setMaxAccess( "readonly") hwImaGroupRxOamLabelValue = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 20), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess( "readonly") hwImaGroupFirstLinkIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 21), InterfaceIndex()).setMaxAccess("readonly") hwImaGroupName = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 1, 1, 22), OctetString()).setMaxAccess( "accessiblefornotify") hwImaLinkTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2), ) hwImaLinkEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1), ).setIndexNames( (0, "HUAWEI-IMA-MIB", "hwImaLinkIfIndex")) hwImaLinkIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 1), InterfaceIndex()) hwImaLinkGroupIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 2), InterfaceIndex()).setMaxAccess( "readcreate") hwImaLinkNeTxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 3), ImaLinkState()).setMaxAccess( "readonly") hwImaLinkNeRxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 4), ImaLinkState()).setMaxAccess( "readonly") hwImaLinkFeTxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 5), ImaLinkState()).setMaxAccess( "readonly") hwImaLinkFeRxState = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 6), ImaLinkState()).setMaxAccess( "readonly") hwImaLinkRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 51), RowStatus()).setMaxAccess( "readcreate") hwImaLinkName = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 2, 1, 52), OctetString()).setMaxAccess( "accessiblefornotify") hwImaAlarmTable = MibTable((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3), ) hwImaAlarmEntry = MibTableRow((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1), ).setIndexNames( (0, "HUAWEI-IMA-MIB", "hwImaAlarmIfIndex")) hwImaAlarmIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 1), Integer32()) hwImaGroupNeDownEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 2), Integer32()).setMaxAccess( "readwrite") hwImaGroupFeDownEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 3), Integer32()).setMaxAccess( "readwrite") hwImaGroupTxClkMismatchEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 4), Integer32()).setMaxAccess( "readwrite") hwImaLinkLifEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 5), Integer32()).setMaxAccess("readwrite") hwImaLinkLodsEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 6), Integer32()).setMaxAccess( "readwrite") hwImaLinkRfiEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 7), Integer32()).setMaxAccess("readwrite") hwImaLinkFeTxUnusableEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 8), Integer32()).setMaxAccess( "readwrite") hwImaLinkFeRxUnusableEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 9), Integer32()).setMaxAccess( "readwrite") hwIMAAllEn = MibTableColumn((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 1, 3, 1, 10), Integer32()).setMaxAccess("readwrite") hwImaMibGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1)) hwImaMibCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 2)) hwImaMibCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 2, 1)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupGroup"), ("HUAWEI-IMA-MIB", "hwImaLinkGroup"),)) hwImaGroupGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1, 1)).setObjects(*( ("HUAWEI-IMA-MIB", "hwImaGroupIfIndex"), ("HUAWEI-IMA-MIB", "hwImaGroupNeState"), ("HUAWEI-IMA-MIB", "hwImaGroupFeState"), ("HUAWEI-IMA-MIB", "hwImaGroupSymmetry"), ("HUAWEI-IMA-MIB", "hwImaGroupMinNumTxLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupMinNumRxLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupTxTimingRefLink"), ("HUAWEI-IMA-MIB", "hwImaGroupRxTimingRefLink"), ("HUAWEI-IMA-MIB", "hwImaGroupTxImaId"), ("HUAWEI-IMA-MIB", "hwImaGroupRxImaId"), ("HUAWEI-IMA-MIB", "hwImaGroupTxFrameLength"), ("HUAWEI-IMA-MIB", "hwImaGroupRxFrameLength"), ("HUAWEI-IMA-MIB", "hwImaGroupDiffDelayMax"), ("HUAWEI-IMA-MIB", "hwImaGroupAlphaValue"), ("HUAWEI-IMA-MIB", "hwImaGroupBetaValue"), ("HUAWEI-IMA-MIB", "hwImaGroupGammaValue"), ("HUAWEI-IMA-MIB", "hwImaGroupNumTxActLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupNumRxActLinks"), ("HUAWEI-IMA-MIB", "hwImaGroupTxOamLabelValue"), ("HUAWEI-IMA-MIB", "hwImaGroupRxOamLabelValue"), ("HUAWEI-IMA-MIB", "hwImaGroupFirstLinkIfIndex"),)) hwImaLinkGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 2, 1, 2)).setObjects(*( ("HUAWEI-IMA-MIB", "hwImaLinkGroupIfIndex"), ("HUAWEI-IMA-MIB", "hwImaLinkNeTxState"), ("HUAWEI-IMA-MIB", "hwImaLinkNeRxState"), ("HUAWEI-IMA-MIB", "hwImaLinkFeTxState"), ("HUAWEI-IMA-MIB", "hwImaLinkFeRxState"), ("HUAWEI-IMA-MIB", "hwImaLinkRowStatus"),)) hwImaGroupNeDownAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 1)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupName"),)) hwImaGroupNeDownAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 2)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupName"),)) hwImaGroupFeDownAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 3)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupName"),)) hwImaGroupFeDownAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 4)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupName"),)) hwImaGroupTxClkMismatch = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 5)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupName"),)) hwImaGroupTxClkMismatchResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 6)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaGroupName"),)) hwImaLinkLifAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 7)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkLifAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 8)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkLodsAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 9)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkLodsAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 10)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkRfiAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 11)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkRfiAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 12)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkFeTxUnusableAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 13)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkFeTxUnusableAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 14)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkFeRxUnusableAlarm = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 15)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) hwImaLinkFeRxUnusableAlarmResume = NotificationType((1, 3, 6, 1, 4, 1, 2011, 5, 25, 176, 3, 16)).setObjects( *(("HUAWEI-IMA-MIB", "hwImaLinkName"),)) mibBuilder.exportSymbols("HUAWEI-IMA-MIB", hwImaGroupFirstLinkIfIndex=hwImaGroupFirstLinkIfIndex, hwImaLinkFeRxState=hwImaLinkFeRxState, PYSNMP_MODULE_ID=hwImaMIB, hwImaLinkRfiEn=hwImaLinkRfiEn, hwImaGroupNumRxActLinks=hwImaGroupNumRxActLinks, hwImaLinkRfiAlarmResume=hwImaLinkRfiAlarmResume, hwImaLinkLifAlarm=hwImaLinkLifAlarm, hwImaGroupTxClkMismatch=hwImaGroupTxClkMismatch, hwImaGroupRxOamLabelValue=hwImaGroupRxOamLabelValue, hwImaLinkLifEn=hwImaLinkLifEn, hwImaGroupFeDownAlarmResume=hwImaGroupFeDownAlarmResume, hwImaLinkNeRxState=hwImaLinkNeRxState, hwImaGroupFeDownAlarm=hwImaGroupFeDownAlarm, ImaGroupState=ImaGroupState, hwImaAlarmIfIndex=hwImaAlarmIfIndex, hwImaGroupNeDownEn=hwImaGroupNeDownEn, hwImaLinkEntry=hwImaLinkEntry, hwImaGroupRxTimingRefLink=hwImaGroupRxTimingRefLink, hwImaGroupNeDownAlarm=hwImaGroupNeDownAlarm, hwImaGroupTable=hwImaGroupTable, hwImaLinkFeTxState=hwImaLinkFeTxState, ImaGroupSymmetry=ImaGroupSymmetry, hwImaLinkName=hwImaLinkName, hwImaLinkLodsEn=hwImaLinkLodsEn, hwImaGroupFeState=hwImaGroupFeState, hwImaLinkIfIndex=hwImaLinkIfIndex, hwImaGroupMinNumRxLinks=hwImaGroupMinNumRxLinks, hwImaMIB=hwImaMIB, hwImaGroupGroup=hwImaGroupGroup, hwImaLinkFeTxUnusableEn=hwImaLinkFeTxUnusableEn, hwImaNotifications=hwImaNotifications, hwImaGroupFeDownEn=hwImaGroupFeDownEn, hwImaGroupTxImaId=hwImaGroupTxImaId, hwImaGroupTxFrameLength=hwImaGroupTxFrameLength, hwIMAAllEn=hwIMAAllEn, ImaLinkState=ImaLinkState, hwImaLinkFeRxUnusableAlarm=hwImaLinkFeRxUnusableAlarm, hwImaLinkFeRxUnusableAlarmResume=hwImaLinkFeRxUnusableAlarmResume, hwImaLinkLifAlarmResume=hwImaLinkLifAlarmResume, hwImaGroupNeDownAlarmResume=hwImaGroupNeDownAlarmResume, hwImaGroupEntry=hwImaGroupEntry, hwImaMibCompliances=hwImaMibCompliances, hwImaAlarmEntry=hwImaAlarmEntry, hwImaLinkRowStatus=hwImaLinkRowStatus, hwImaLinkLodsAlarm=hwImaLinkLodsAlarm, hwImaGroupNeState=hwImaGroupNeState, hwImaMibCompliance=hwImaMibCompliance, hwImaLinkFeTxUnusableAlarm=hwImaLinkFeTxUnusableAlarm, hwImaGroupIfIndex=hwImaGroupIfIndex, hwImaGroupTxClkMismatchEn=hwImaGroupTxClkMismatchEn, hwImaGroupDiffDelayMax=hwImaGroupDiffDelayMax, hwImaGroupRxFrameLength=hwImaGroupRxFrameLength, hwImaGroupTxClkMismatchResume=hwImaGroupTxClkMismatchResume, hwImaGroupTxOamLabelValue=hwImaGroupTxOamLabelValue, hwImaGroupTxTimingRefLink=hwImaGroupTxTimingRefLink, hwImaGroupBetaValue=hwImaGroupBetaValue, hwImaGroupName=hwImaGroupName, hwImaMibGroups=hwImaMibGroups, hwImaGroupRxImaId=hwImaGroupRxImaId, hwImaLinkFeRxUnusableEn=hwImaLinkFeRxUnusableEn, hwImaAlarmTable=hwImaAlarmTable, hwImaLinkNeTxState=hwImaLinkNeTxState, hwImaGroupSymmetry=hwImaGroupSymmetry, hwImaMibConformance=hwImaMibConformance, hwImaMibObjects=hwImaMibObjects, MilliSeconds=MilliSeconds, hwImaGroupMinNumTxLinks=hwImaGroupMinNumTxLinks, hwImaLinkTable=hwImaLinkTable, hwImaLinkGroup=hwImaLinkGroup, hwImaLinkRfiAlarm=hwImaLinkRfiAlarm, ImaFrameLength=ImaFrameLength, hwImaGroupGammaValue=hwImaGroupGammaValue, hwImaGroupAlphaValue=hwImaGroupAlphaValue, hwImaLinkLodsAlarmResume=hwImaLinkLodsAlarmResume, hwImaGroupNumTxActLinks=hwImaGroupNumTxActLinks, hwImaLinkFeTxUnusableAlarmResume=hwImaLinkFeTxUnusableAlarmResume, hwImaLinkGroupIfIndex=hwImaLinkGroupIfIndex)
def sort_a_little_bit(items, begin_index, end_index): left_index = begin_index pivot_index = end_index pivot_value = items[pivot_index] while pivot_index != left_index: item = items[left_index] if item <= pivot_value: left_index += 1 continue items[left_index] = items[pivot_index - 1] items[pivot_index - 1] = pivot_value items[pivot_index] = item pivot_index -= 1 return pivot_index def sort_all(items, begin_index, end_index): if end_index <= begin_index: return pivot_index = sort_a_little_bit(items, begin_index, end_index) sort_all(items, begin_index, pivot_index - 1) sort_all(items, pivot_index + 1, end_index) def quicksort(items): sort_all(items, 0, len(items) - 1) def rearrange_digits(input_list): """ Rearrange Array Elements so as to form two number such that their sum is maximum. Args: input_list(list): Input List Returns: (int),(int): Two maximum sums """ if len(input_list) <= 0: return -1, -1 if len(input_list) == 1: return input_list[0], 0 quicksort(input_list) # num1 is bigger num2_len = len(input_list) // 2 num1_len = len(input_list) - num2_len num1_index = num1_len - 1 num2_index = num2_len - 1 num1 = [''] * num1_len num2 = [''] * num2_len for i, element in enumerate(input_list): if i % 2 == 0: num1[num1_index] = str(element) num1_index -= 1 else: num2[num2_index] = str(element) num2_index -= 1 return int("".join(num1)), int("".join(num2)) def test_function(test_case): output = rearrange_digits(test_case[0]) solution = test_case[1] if sum(output) == sum(solution): print("Pass") else: print("Fail") if __name__ == '__main__': test_function([[1, 2, 3, 4, 5], [542, 31]]) test_function([[4, 6, 2, 5, 9, 8], [964, 852]]) # corner case test_function([[], [-1, -1]]) test_function([[3], [3, 0]])
@auth.requires_membership('admin') def album(): grid = SQLFORM.grid(db.t_mtalbum) return dict(grid=grid) @auth.requires_membership('admin') def dataset(): grid = SQLFORM.grid(db.t_mtdataset) return dict(grid=grid) @auth.requires_membership('admin') def item(): grid = SQLFORM.grid(db.t_mtitem) return dict(grid=grid) @auth.requires_membership('admin') def itemtype(): grid = SQLFORM.grid(db.t_mtitemtype) return dict(grid=grid) @auth.requires_membership('admin') def search(): grid = SQLFORM.grid(db.t_mtsearch) return dict(grid=grid) @auth.requires_membership('admin') def user(): grid = SQLFORM.grid(db.t_mtuser) return dict(grid=grid)
n = int(input().strip()) value1 = 0 value2 = 0 for i in range(n): a_t = [int(a_temp) for a_temp in input().strip().split(' ')] value1 += a_t[i] value2 += a_t[-1-i] print(abs(value2-value1))
def test(): # noqa assert 1 + 1 == 2 def test_multi_line_args(math_fixture, *args, **kwargs): # noqa assert 1 + 1 == 2
def checkio(str_number, radix): try: return int(str_number,radix) except: return -1 #These "asserts" using only for self-checking and not necessary for auto-testing if __name__ == '__main__': assert checkio("AF", 16) == 175, "Hex" assert checkio("101", 2) == 5, "Bin" assert checkio("101", 5) == 26, "5 base" assert checkio("Z", 36) == 35, "Z base" assert checkio("AB", 10) == -1, "B > A = 10" print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
async def _asyncWrapWith(res, wrapper_fn): result = await res return wrapper_fn(result["id"]) def wrapWith(res, wrapper_fn): if isinstance(res, dict): return wrapper_fn(res) else: return _asyncWrapWith(res, wrapper_fn)
#!/usr/bin/env python # encoding: utf-8 def run(whatweb, pluginname): whatweb.recog_from_file(pluginname, "themes\default\Wikiwyg\Wikiwy\Phpwiki.js", "phpwiki")
r = float(input('Raio = ')) h = float(input('Altura = ')) r2 = r ** 2 v = 3.14159 * h * r2 print('Volume da lata de óleo é {:.2f}'.format(v))
# DLS and JLS are bored with a Math lesson. In order to entertain themselves, DLS took a sheet of paper and drew n distinct lines, given by equations y=x+piy = x + p_iy=x+pi​ for some distinct p1,p2,…,pnp_1, p_2, \ldots, p_np1​,p2​,…,pn​. # Then JLS drew on the same paper sheet m distinct lines given by equations y=−x+qiy = -x + q_iy=−x+qi​ for some distinct q1,q2,…,qmq_1, q_2, \ldots, q_mq1​,q2​,…,qm​. # DLS and JLS are interested in counting how many line pairs have integer intersection points, i.e. points with both coordinates that are integers. Unfortunately, the lesson will end up soon, so DLS and JLS are asking for your help. #number of test cases t = int(input()) for i in range(t): #number of lines #dls n = int(input()) dls = list(map(int, input().split())) #jls m = int(input()) jls = list(map(int, input().split())) #calculate the intersection points intersection = 0 for p in dls: for q in jls: if (p-q)==0 or (p-q)%2 == 0: intersection += 1 print(intersection)
# Given two non-empty binary trees s and t, # check whether tree t has exactly the same structure and node values with a subtree of s. # A subtree of s is a tree consists of a node in s and all of this node's descendants. # The tree s could also be considered as a subtree of itself. # Example 1: # Given tree s: # 3 # / \ # 4 5 # / \ # 1 2 # Given tree t: # 4 # / \ # 1 2 # Return true, because t has the same structure and node values with a subtree of s. # Example 2: # Given tree s: # 3 # / \ # 4 5 # / \ # 1 2 # / # 0 # Given tree t: # 4 # / \ # 1 2 # Hints: # Which approach is better here- recursive or iterative? # If recursive approach is better, can you write recursive function with its parameters? # Two trees s and t are said to be identical if their root values are same # and their left and right subtrees are identical. Can you write this in form of recursive formulae? # Recursive formulae can be: # isIdentical(s,t)= s.val==t.val AND isIdentical(s.left,t.left) AND isIdentical(s.right,t.right) # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSubtree(self, s, t): """ :type s: TreeNode :type t: TreeNode :rtype: bool """ # M1. 递归先序遍历 # print(self.preorder(s),len(self.preorder(s))) # print(self.preorder(t),len(self.preorder(t))) return self.preorder(t) in self.preorder(s) def preorder(self, root): if not root: return "*" else: # “ ” for case like [12] and [2] # You can also note that we've added a '#' before every considering every value. # If this isn't done, the trees of the form s:[23, 4, 5] and t:[3, 4, 5] will also give a true result # since the preorder string of the t("23 4 lnull rull 5 lnull rnull") will be a substring of the preorder string of s("3 4 lnull rull 5 lnull rnull"). # Adding a '#' before the node's value solves this problem. return " " + str(root.val) + self.preorder(root.left) + self.preorder(root.right) # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def isSubtree(self, s, t): """ :type s: TreeNode :type t: TreeNode :rtype: bool """ # M2. 模拟比较 # for case middle if not s or not t: return False isIdentical = False if s.val == t.val: isIdentical = self.tree_comparor(s,t) if isIdentical: return True else: return self.isSubtree(s.left,t) or self.isSubtree(s.right,t) def tree_comparor(self, t1, t2): if t1 is None or t2 is None: if t1 is None and t2 is None: return True else: return False if t1.val != t2.val: return False else: return self.tree_comparor(t1.left,t2.left) and self.tree_comparor(t1.right,t2.right)
__author__ = "Prikly Grayp" __license__ = "MIT" __version__ = "1.0.0" __email__ = "priklygrayp@gmail.com" __status__ = "Development" def first(iterable): iterator = iter(iterable) try: return next(iterator) except StopIteration: raise ValueError('iterable is empty') first(['Spring', 'Summer', 'Autumn', 'Winter'])
# https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/submissions/ class Solution: def kidsWithCandies(self, candies: [int], extraCandies: int) -> [bool]: maxCandies = max(candies, default=0) return [True if v + extraCandies >= maxCandies else False for v in candies]
# Alternating Characters # Developer: Murillo Grubler # Link: https://www.hackerrank.com/challenges/alternating-characters/problem # Time complexity: O(n) def alternatingCharacters(s): sumChars = 0 for i in range(len(s)): if i == 0 or tempChar != s[i]: tempChar = s[i] continue if tempChar == s[i]: sumChars += 1 return sumChars q = int(input().strip()) for a0 in range(q): print(alternatingCharacters(input().strip()))
# A simple use of user defined functions in python def greet_user(name): print(f"Hi {name}!") print("Welcome Aboard!") print("Start") greet_user("Kwadwo") greet_user("Sammy") print("finish")
#!/usr/bin/env python3 """ binary_tree contains methods to search a binary tree """ def is_valid_binary_search_tree(node): """ Traverses tree depth first in order """ return is_valid_bst(node, float('-inf'), float('inf')) def is_valid_bst(node, value_min, value_max): """ Traverses tree depth first in order Note the tree may be a subtree of a larger tree. The method may be called recursively. Tree does not have to be "balanced", may have more levels than necessary. Duplicate values are not allowed. https://en.wikipedia.org/wiki/Binary_search_tree https://en.wikipedia.org/wiki/Tree_traversal http://stackoverflow.com/questions/10832496/finding-if-a-binary-tree-is-a-binary-search-tree?noredirect=1&lq=1 http://stackoverflow.com/questions/499995/how-do-you-validate-a-binary-search-tree#759851 http://stackoverflow.com/questions/300935/are-duplicate-keys-allowed-in-the-definition-of-binary-search-trees#300968 http://stackoverflow.com/questions/7604966/maximum-and-minimum-values-for-ints#7604981 value_min: initial call should set to float('-inf') value_max: initial call should set to float('inf') :return True if node is None or is the root of a valid binary search tree return False if node value is None or node isn't the root of a valid binary search tree return False if tree contains a duplicate value """ print("is_valid_binary_search_tree") if node is None: # e.g. parent node doesn't have a node at this child return True if node.value is None: return False if (node.value > value_min and node.value < value_max and is_valid_bst(node.left, value_min, node.value) and is_valid_bst(node.right, node.value, value_max)): return True else: return False
""" In a given grid, each cell can have one of three values: - the value 0 representing an empty cell; - the value 1 representing a fresh orange; - the value 2 representing a rotten orange. Every minute, any fresh orange that is adjacent (4-directionally) to a rotten orange becomes rotten. Return the minimum number of minutes that must elapse until no cell has a fresh orange. If this is impossible, return -1 instead. Example: Input: [[2,1,1],[1,1,0],[0,1,1]] Output: 4 Example: Input: [[2,1,1],[0,1,1],[1,0,1]] Output: -1 Explanation: The orange in the bottom left corner (row 2, column 0) is never rotten, because rotting only happens 4-directiona Note: 1. 1 <= grid.length <= 10 2. 1 <= grid[0].length <= 10 3. grid[i][j] is only 0, 1, or 2. """ #Difficulty: Medium #303 / 303 test cases passed. #Runtime: 52 ms #Memory Usage: 13.7 MB #Runtime: 52 ms, faster than 84.00% of Python3 online submissions for Rotting Oranges. #Memory Usage: 13.7 MB, less than 91.03% of Python3 online submissions for Rotting Oranges. class Solution: def orangesRotting(self, grid: List[List[int]]) -> int: minutes = 0 self.rows = len(grid) self.cols = len(grid[0]) self.rotten_value = 2 self.rotting = True while self.rotting and self.checkForFreshOranges(grid): self.rotting = False for i in range(self.rows): for j in range(self.cols): if grid[i][j] == self.rotten_value: self.rottenOrange(grid, i - 1, j) self.rottenOrange(grid, i, j - 1) self.rottenOrange(grid, i, j + 1) self.rottenOrange(grid, i + 1, j) if self.rotting: minutes += 1 self.rotten_value += 1 if not self.rotting: return -1 return minutes def rottenOrange(self, grid, i, j): if i < 0 or i >= len(grid) or j < 0 or j >= len(grid[i]): return if grid[i][j] == 1: grid[i][j] += self.rotten_value self.rotting = True def checkForFreshOranges(self, grid): for i in range(self.rows): for j in range(self.cols): if grid[i][j] == 1: return True return False
""" A proxy provides a surrogate or place holder to provide access to an object. Ex1: Use an extra level of indirection to support distributed, controlled, or conditional access. """ class SubjectInterface: """ Define the common interface for RealSubject and Proxy so that a Proxy can be used anywhere a RealSubject is expected. """ def request(self): raise NotImplementedError() class Proxy(SubjectInterface): """ Maintain a reference that lets the proxy access the real subject. Provide an interface identical to Subject's. """ def __init__(self, real_subject): self.real_subject = real_subject def request(self): print('Proxy may be doing something, like controlling request access.') self.real_subject.request() class RealSubject(SubjectInterface): """ Define the real object that the proxy represents. """ def request(self): print('The real thing is dealing with the request') real_subject = RealSubject() real_subject.request() proxy = Proxy(real_subject) proxy.request()
""" 30 Dec 2015. code interpretation by Dealga McArdle of this paper. http://www.cc.gatech.edu/~jarek/graphics/papers/04PolygonBooleansMargalit.pdf It's the first thing that came up after a 'polygon unions' Google search. This repo is an attempt at getting that psuedo code into a working state. It might be over my head but won't know until attempted. """ ''' Table 1 -------------------------------------------------- 1 = island, 0 = hole polygonorientation [polygonAtype, polygonBtype, oper] contains indicators which specify whether the two input polygons should have the same or opposite orientations according to the oper. and polygon types. ''' SM = "same" OP = "opposite" polygonorientation = { (1, 1): {'AnB': SM, 'AuB': SM, 'A-B': OP, 'B-A': OP}, (1, 0): {'AnB': OP, 'AuB': OP, 'A-B': SM, 'B-A': SM}, (0, 1): {'AnB': OP, 'AuB': OP, 'A-B': SM, 'B-A': SM}, (0, 0): {'AnB': SM, 'AuB': SM, 'A-B': OP, 'B-A': OP} } ''' Table 2 -------------------------------------------------- fragmenttype [ polygonAtype, polygonBtype, oper, polygon] contains the type of edge fragments, besides the boundary line fragments, to be selected for insertion into the line fragments table according to the operations and the polygon types. ''' IO = ['inside', 'outside'] OI = ['outside', 'inside'] II = ['inside', 'inside'] OO = ['outside', 'outside'] fragmenttype = { (1, 1): {'AnB': II, 'AuB': OO, 'A-B': OI, 'B-A': IO}, (1, 0): {'AnB': OI, 'AuB': IO, 'A-B': II, 'B-A': OO}, (0, 1): {'AnB': IO, 'AuB': OI, 'A-B': OO, 'B-A': II}, (0, 0): {'AnB': OO, 'AuB': II, 'A-B': IO, 'B-A': OI} } ''' Table 3 -------------------------------------------------- boundaryfragment [polygonAtype, polygonBtype, situation, oper, reg] contains indicators which specifies how many boundary edge fragments are to be selected given the edge fragments situation for regular and non-regular operations. The table is according to the operation and the polygon types. ''' ... ''' Table 4 -------------------------------------------------- resltorientation [polygonAtype, polygonBtype, oper] ''' def polygon_operation(Oper, Reg, A, B, Atype, Btype, Out): def find_intersection(segment_one, segment_two, point): """ https://stackoverflow.com/a/19550879/1243487 original: return True if the two line segments intersect False otherwise. If intersection then point is given the coordinate interpretation: return [] if no intersection and [x, y] if there is one. """ (p0, p1), (p2, p3) = segment_one, segment_two segment_one_dx = p1[0] - p0[0] segment_one_dy = p1[1] - p0[1] segment_two_dx = p3[0] - p2[0] segment_two_dy = p3[1] - p2[1] denom = (segment_one_dx * segment_two_dy) - (segment_two_dx * segment_one_dy) if denom == 0: return [] # collinear denom_is_positive = denom > 0 s02_x = p0[0] - p2[0] s02_y = p0[1] - p2[1] s_numer = segment_one_dx * s02_y - segment_one_dy * s02_x if (s_numer < 0) == denom_is_positive: return [] # no collision t_numer = segment_two_dx * s02_y - segment_two_dy * s02_x if (t_numer < 0) == denom_is_positive: return [] # no collision if (s_numer > denom) == denom_is_positive or (t_numer > denom) == denom_is_positive: return [] # no collision t = t_numer / denom return [ p0[0] + (t * segment_one_dx), p0[1] + (t * segment_one_dy) ] def inside_polygon(v, polygon): """ finds and returns the following - whether the v is inside or outside the boundary of polygon - check for every edge of polygon if point on the edge - 1] and if not, whether the edge intersects with a ray that - begins at the point v and is directed in the X-axis direction - 2] if point v is on the edge, the function returns 'boundary' If the edge intersects with the raw, except at the edge's lower endpoint, a counter is incremented. When all edges are checked, the procedure returns 'inside' if the counter is an odd number or 'outside' if the counter is even. """ ... def insertV(dsv, point, io_type): ''' 3rd param enum [inside, outside, boundary] inserts into the vertex ring, DSV, the point, with the type io_type. ''' ... def insertE(fragment, reg): """ Inserts an edge frament into the edge fragments table, EF, if it is not already there. If regular output result polygons are required and non-boundary edge fragment is to be inserted, the procedure checks whether the same edge fragment with the opposite direction is already in EF, if So. it does not insert the edge-fragment and it deletes the existing edge fragment with the opposite direction from the edge fragments table """ ... def deleteE(fragment): """ Deletes an edge fragment from edge fragments table """ ... def search_nextE(point): """ Searches and returns from the edge fragments table an edge fragment whose first endpoint is point """ ... def organizeE(): """ organizes the edge fragments table to allow fast search and deletion operations """ ... def find_orientation(polygon): """ returns 'clockwise' or 'counterclockwise'. CW / CCW it finds the vertex with the minimum X value and compares the slopes of the two edges attached to this vertex in order to find the orientation """ ... def change_orientation(polygon): """ self explanatory, reverses vertices """ ... ''' Find and set the orientations of the input polygons ''' orientationA = find_orientation(A) orientationB = find_orientation(B) if polygonorientation[(Atype, Btype)][Oper] == 'same': if not (orientationA == orientationB): change_orientation(B) elif orientationA == orientationB: change_orientation(B) ''' Initiate the verts rings and classify the vertices ''' for v in A: insertV(AV, v, inside_polyon(v, B)) for v in B: insertV(BV, v, inside_polyon(v, A)) ''' Find intersections '''
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def insertionSortList(self, head: ListNode) -> ListNode: dummyHead = ListNode(float('-inf'), head) currentNode = dummyHead.next while currentNode and currentNode.next: if currentNode.val <= currentNode.next.val: currentNode = currentNode.next else: tempNode = currentNode.next currentNode.next = tempNode.next iterator = dummyHead while iterator.next and iterator.next.val <= tempNode.val: iterator = iterator.next tempNode.next = iterator.next iterator.next = tempNode return dummyHead.next
def Factorial_Head(n): # Base Case: 0! = 1 if(n == 0): return 1 # Recursion result1 = Factorial_Head(n-1) result2 = n * result1 return result2 def Factorial_Tail(n, accumulator): # Base Case: 0! = 1 if( n == 0): return accumulator # Recursion return Factorial_Tail(n-1, n*accumulator) # n = 5 # 1st loop: n=5, accumulator= 1 # 2nd loop: n=4, accumulator= 5 # 3rd loop: n=3, accumulator= 20 # 4th loop: n=2, accumulator= 60 # 5th loop: n=1, accumulator= 120 (answer) n = 5 head = Factorial_Head(n) print(f"Factorial {n} using HEAD Recursion: {head}") n = 6 tail = Factorial_Tail(n, 1) print(f"Factorial {n} using TAIL Recursion: {tail}")
class palin: def __init__(self,string): self.string=string s=self.string a=[] for i in s: a.append(i) b=[] for i in range(len(a)-1,-1,-1): b.append(a[i]) if(a==b): print('True') else: print('False') # if __name__=='__main__': # obj=palin('kaif') # obj.check()
class UnboundDataPullException(Exception): pass class DataPullInProgressError(Exception): pass
print("To define a new function, you use 'def+<your_function_name>+(+<your_params_comma_separated>+)', example: 'def myFunction(param1, param2, ..., paramn)'") # Creating a simple function and calling it print("Creating simple function and calling it") def sayHello(name): print("Hello",name) sayHello("balam909") # Defining a simple function with default params print("Creating a simple function with default params") def giveMeTwoNumbersAndAText(number1, number2, myText="This is my default text"): print("number1:",number1,"number2:",number2,"myText:",myText) print("This function receive 3 parameters, if we have 'default values' defined, we can call this function without send the parameter(s) that has a default value asigned") print("The function 'giveMeTwoNumbersAndAText' has 2 parameters with non default value and 1 parameter with a default value") print("The function looks like this: 'giveMeTwoNumbersAndAText(number1, number2, myText=\"This is my default text\")'") print("This is a call with the 3 parameters: giveMeTwoNumbersAndAText(1,2,\"Look at this awesome value\")") giveMeTwoNumbersAndAText(1,2,"Look at this awesome value") print("This is a call with 2 parameters: giveMeTwoNumbersAndAText(1,2)") giveMeTwoNumbersAndAText(1,2) print("If you do not have a default value for a param, you can not call the function without it") print("For example: 'giveMeTwoNumbersAndAText(1)' will result in an error") print("The default value is evaluated only once, when we define the function, so it not possible to change it arround the execution") print("In python we can follow the argument order, or we can add the 'key,value' pair") print("A valid example could be giveMeTwoNumbersAndAText(1, myText=\"Some Text\", number2=10)") giveMeTwoNumbersAndAText(1, myText="Some Text", number2=10) print("Once we use the 'key/value' definition, we have to use the 'key/value' for the next elements, an invalid call for this case looks like this: giveMeTwoNumbersAndAText(1, myText=\"Some Text\", 10)") # Defining a function receiving pocitional arguments print("Defining a function receiving pocitional arguments") def sayAbunchOfWords(*args): for arg in args: print(arg) print("A call with cero arg") sayAbunchOfWords() print("A call with one arg") sayAbunchOfWords("one") print("A call with two args") sayAbunchOfWords("one","two") print("A call with three arg") sayAbunchOfWords("one","two","three") # Defining a function receiving a dictionary print("Defining a function receiving a dictionary") def printMyDictionary(**myDictionary): for key in myDictionary.keys(): print("The key:",key+"_k",",","The value:",myDictionary[key]+"_v") print("This is the function call with a dictionary as an input") printMyDictionary(param1="param1", param2="param2", param3="param3")
#!/user/bin/python # -*- coding: utf-8 -*- """ 文件读取 测试 """ print('hello world')
ecn_show_config_output="""\ Profile: AZURE_LOSSLESS ----------------------- ------- red_max_threshold 2097152 wred_green_enable true ecn ecn_all green_min_threshold 1048576 red_min_threshold 1048576 wred_yellow_enable true yellow_min_threshold 1048576 green_max_threshold 2097152 green_drop_probability 5 yellow_max_threshold 2097152 wred_red_enable true yellow_drop_probability 5 red_drop_probability 5 ----------------------- ------- """ testData = { 'ecn_show_config' : {'cmd' : ['show'], 'args' : [], 'rc' : 0, 'rc_output': ecn_show_config_output }, 'ecn_cfg_gmin' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-gmin', '1048600'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,green_min_threshold,1048600'] }, 'ecn_cfg_gmax' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-gmax', '2097153'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,green_max_threshold,2097153'] }, 'ecn_cfg_ymin' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-ymin', '1048600'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,yellow_min_threshold,1048600'] }, 'ecn_cfg_ymax' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-ymax', '2097153'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,yellow_max_threshold,2097153'] }, 'ecn_cfg_rmin' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-rmin', '1048600'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,red_min_threshold,1048600'] }, 'ecn_cfg_rmax' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-rmax', '2097153'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,red_max_threshold,2097153'] }, 'ecn_cfg_rdrop' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-rdrop', '10'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,red_drop_probability,10'] }, 'ecn_cfg_ydrop' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-ydrop', '11'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,yellow_drop_probability,11'] }, 'ecn_cfg_gdrop' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-gdrop', '12'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,green_drop_probability,12'] }, 'ecn_cfg_multi_set' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-gdrop', '12', '-gmax', '2097153'], 'rc' : 0, 'cmp_args' : ['AZURE_LOSSLESS,green_drop_probability,12', 'AZURE_LOSSLESS,green_max_threshold,2097153' ] }, 'ecn_cfg_gmin_gmax_invalid' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-gmax', '2097153', '-gmin', '2097154'], 'rc' : 1, 'rc_msg' : 'Invalid gmin (2097154) and gmax (2097153). gmin should be smaller than gmax' }, 'ecn_cfg_ymin_ymax_invalid' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-ymax', '2097153', '-ymin', '2097154'], 'rc' : 1, 'rc_msg' : 'Invalid ymin (2097154) and ymax (2097153). ymin should be smaller than ymax' }, 'ecn_cfg_rmin_rmax_invalid' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-rmax', '2097153', '-rmin', '2097154'], 'rc' : 1, 'rc_msg' : 'Invalid rmin (2097154) and rmax (2097153). rmin should be smaller than rmax' }, 'ecn_cfg_rmax_invalid' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-rmax', '-2097153'], 'rc' : 1, 'rc_msg' : 'Invalid rmax (-2097153). rmax should be an non-negative integer' }, 'ecn_cfg_rdrop_invalid' : {'cmd' : ['config'], 'args' : ['-profile', 'AZURE_LOSSLESS', '-rdrop', '105'], 'rc' : 1, 'rc_msg' : 'Invalid value for "-rdrop": 105 is not in the valid range of 0 to 100' } }
# package org.apache.helix.store #from org.apache.helix.store import * class HelixPropertyListener: def onDataChange(self, path): """ Returns void Parameters: path: String """ pass def onDataCreate(self, path): """ Returns void Parameters: path: String """ pass def onDataDelete(self, path): """ Returns void Parameters: path: String """ pass
# -*- coding: utf-8 -*- GRAPPELLI_INDEX_DASHBOARD = 'dashboard.CustomIndexDashboard' GRAPPELLI_ADMIN_TITLE = u'Админка'
class Credentials: """ Class that generates new instances of credentials. """ credentials_list = [] #empty user list def __init__(self,account,username,password): self.account = account self.username = username self.password = password def save_credentials(self): ''' save_credentials method saves credentials objects into credentials_list ''' Credentials.credentials_list.append(self) def delete_credentials(self): ''' delete_credentials method deletes a saved credential from the credentials_list ''' Credentials.credentials_list.remove(self) @classmethod def find_by_account(cls,account): ''' Method that takes in a account and returns a credentials that matches that account. Args: account: Phone account to search for Returns : Credentials of person that matches the account. ''' for credentials in cls.credentials_list: if credentials.account == account: return credentials @classmethod def display_credentials(cls): ''' method that returns the credentials list ''' return cls.credentials_list
class Solution: def brokenCalc(self, X: int, Y: int) -> int: count = 0 while Y>X: if Y%2==0: Y //= 2 else: Y += 1 count += 1 return count + X - Y
s = float(input('What is the salary of the functionary? $')) if s > 1250.00: t = s + s * 0.10 print(f'His salary increased by 10% and is now {t:.2f}') else: f = s + s * 0.15 print(f'His salary increased by 15% and is now {f:.2f}')
# Use dictionary # 1-) Herhangi bir düğümü seçin, bitişikteki ziyaret edilmemiş köşeyi ziyaret edin, # ziyaret edildi olarak işaretleyin, görüntüleyin ve bir sıraya ekleyin. # 2-) Kalan bitişik tepe noktası yoksa, ilk tepe noktasını kuyruktan çıkarın # 3-) Sıra boşalana veya istenen düğüm bulunana kadar 1. ve 2. adımları tekrarlayın. # Time Complexity # Since all of the nodes and vertices are visited, the time complexity for BFS on a graph is O(V + E); # where V is the number of vertices and E is the number of edges. graph = { 'A': ['B', 'C'], 'B': ['D', 'E'], 'C': ['F'], 'D': [], 'E': ['F'], 'F': [] } visited = [] # List to keep track of visited nodes. queue = [] # Initialize a queue def bfs(node): visited.append(node) queue.append(node) while queue: s = queue.pop(0) print(s, end=" ") for neighbour in graph[s]: if neighbour not in visited: visited.append(neighbour) queue.append(neighbour) # Driver Code bfs("d".upper())
condition_table_true = ["lt", "gt", "eq"] condition_table_false = ["ge", "le", "ne"] trap_condition_table = { 1: "lgt", 2: "llt", 4: "eq", 5: "lge", 8: "gt", 12: "ge", 16: "lt", 20: "le", 31: "u" } spr_table = { 8: "lr", 9: "ctr" } def decodeI(value): return (value >> 2) & 0xFFFFFF, (value >> 1) & 1, value & 1 def decodeB(value): return (value >> 21) & 0x1F, (value >> 16) & 0x1F, (value >> 2) & 0x3FFF, (value >> 1) & 1, value & 1 def decodeD(value): return (value >> 21) & 0x1F, (value >> 16) & 0x1F, value & 0xFFFF def decodeX(value): return (value >> 21) & 0x1F, (value >> 16) & 0x1F, (value >> 11) & 0x1F, (value >> 1) & 0x3FF, value & 1 def extend_sign(value, bits=16): if value & 1 << (bits - 1): value -= 1 << bits return value def ihex(value): return "-" * (value < 0) + "0x" + hex(value).lstrip("-0x").rstrip("L").zfill(1).upper() def decodeCond(BO, BI): #TODO: Better condition code if BO == 20: return "" if BO & 1: return "?" if BI > 2: return "?" if BO == 4: return condition_table_false[BI] if BO == 12: return condition_table_true[BI] return "?" def loadStore(value, regtype="r"): D, A, d = decodeD(value) d = extend_sign(d) return "%s%i, %s(r%i)" %(regtype, D, ihex(d), A) def loadStoreX(D, A, B, pad): if pad: return "<invalid>" return "r%i, %s, r%i" %(D, ("r%i" %A) if A else "0", B) def add(D, A, B, Rc): return "add%s" %("." * Rc), "r%i, r%i, r%i" %(D, A, B) def addi(value, addr): D, A, SIMM = decodeD(value) SIMM = extend_sign(SIMM) if A == 0: return "li", "r%i, %s" %(D, ihex(SIMM)) return "addi", "r%i, r%i, %s" %(D, A, ihex(SIMM)) def addic(value, addr): D, A, SIMM = decodeD(value) SIMM = extend_sign(SIMM) return "addic", "r%i, r%i, %s" %(D, A, ihex(SIMM)) def addic_(value, addr): D, A, SIMM = decodeD(value) SIMM = extend_sign(SIMM) return "addic.", "r%i, r%i, %s" %(D, A, ihex(SIMM)) def addis(value, addr): D, A, SIMM = decodeD(value) SIMM = extend_sign(SIMM) if A == 0: return "lis", "r%i, %s" %(D, ihex(SIMM)) return "addis", "r%i, r%i, %s" %(D, A, ihex(SIMM)) def and_(S, A, B, Rc): return "and%s" % ("." * Rc), "r%i, r%i, r%i" % (A, S, B) def b(value, addr): LI, AA, LK = decodeI(value) LI = extend_sign(LI, 24) * 4 if AA: dst = LI else: dst = addr + LI return "b%s%s" %("l" * LK, "a" * AA), ihex(dst) def bc(value, addr): BO, BI, BD, AA, LK = decodeB(value) LI = extend_sign(LK, 14) * 4 instr = "b" + decodeCond(BO, BI) if LK: instr += "l" if AA: instr += "a" dst = LI else: dst = addr + LI return instr, ihex(dst) def bcctr(BO, BI, pad, LK): if pad: return "<invalid>" instr = "b" + decodeCond(BO, BI) + "ctr" if LK: instr += "l" return instr def bclr(BO, BI, pad, LK): if pad: return "<invalid>" instr = "b" + decodeCond(BO, BI) + "lr" if LK: instr += "l" return instr def cmp(cr, A, B, pad): if pad: return "<invalid>" if cr & 3: return "<invalid>" return "cmp", "cr%i, r%i, r%i" %(cr >> 2, A, B) def cmpi(value, addr): cr, A, SIMM = decodeD(value) SIMM = extend_sign(SIMM) if cr & 3: return "<invalid>" return "cmpwi", "cr%i, r%i, %s" %(cr >> 2, A, ihex(SIMM)) def cmpl(cr, A, B, pad): if pad: return "<invalid>" if cr & 3: return "<invalid>" return "cmplw", "cr%i, r%i, r%i" %(cr >> 2, A, B) def cmpli(value, addr): cr, A, UIMM = decodeD(value) if cr & 3: return "<invalid>" return "cmplwi", "cr%i, r%i, %s" %(cr >> 2, A, ihex(UIMM)) def cntlzw(S, A, pad, Rc): if pad: return "<invalid>" return "cntlzw%s" %("." * Rc), "r%i, r%i" %(A, S) def dcbst(pad1, A, B, pad2): if pad1 or pad2: return "<invalid>" return "dcbst", "r%i, r%i" %(A, B) def fmr(D, pad, B, Rc): if pad: return "<invalid>" return "fmr%s" %("." * Rc), "f%i, f%i" %(D, B) def fneg(D, pad, B, Rc): if pad: return "<invalid>" return "fneg%s" %("." * Rc), "f%i, f%i" %(D, B) def mfspr(D, sprLo, sprHi, pad): if pad: return "<invalid>" sprnum = (sprHi << 5) | sprLo if sprnum not in spr_table: spr = "?" else: spr = spr_table[sprnum] return "mf%s" %spr, "r%i" %D def mtspr(S, sprLo, sprHi, pad): if pad: return "<invalid>" sprnum = (sprHi << 5) | sprLo if sprnum not in spr_table: spr = ihex(sprnum) else: spr = spr_table[sprnum] return "mt%s" %spr, "r%i" %S def lbz(value, addr): return "lbz", loadStore(value) def lfd(value, addr): return "lfd", loadStore(value, "f") def lfs(value, addr): return "lfs", loadStore(value, "f") def lmw(value, addr): return "lmw", loadStore(value) def lwz(value, addr): return "lwz", loadStore(value) def lwzu(value, addr): return "lwzu", loadStore(value) def lwarx(D, A, B, pad): return "lwarx", loadStoreX(D, A, B, pad) def lwzx(D, A, B, pad): return "lwzx", loadStoreX(D, A, B, pad) def or_(S, A, B, Rc): if S == B: return "mr%s" %("." * Rc), "r%i, r%i" %(A, S) return "or%s" %("." * Rc), "r%i, r%i, r%i" %(A, S, B) def ori(value, addr): S, A, UIMM = decodeD(value) if UIMM == 0: return "nop" return "ori", "r%s, r%s, %s" %(A, S, ihex(UIMM)) def oris(value, addr): S, A, UIMM = decodeD(value) return "oris", "r%s, r%s, %s" %(A, S, ihex(UIMM)) def rlwinm(value, addr): S, A, SH, M, Rc = decodeX(value) MB = M >> 5 ME = M & 0x1F dot = "." * Rc if SH == 0 and MB == 0 and ME == 31: return "nop" if MB == 0 and ME == 31 - SH: return "slwi%s" %dot, "r%i, r%i, %i" %(A, S, SH) if ME == 31 and SH == 32 - MB: return "srwi%s" %dot, "r%i, r%i, %i" %(A, S, MB) if MB == 0 and ME < 31: return "extlwi%s" %dot, "r%i, r%i, %i,%i" %(A, S, ME + 1, SH) #extrwi if MB == 0 and ME == 31: if SH >= 16: return "rotlwi%s" %dot, "r%i, r%i, %i" %(A, S, SH) return "rotrwi%s" %dot, "r%i, r%i, %i" %(A, S, 32 - SH) if SH == 0 and ME == 31: return "clrlwi%s" %dot, "r%i, r%i, %i" %(A, S, MB) if SH == 0 and MB == 0: return "clrrwi%s" %dot, "r%i, r%i, %i" %(A, S, 31 - ME) #clrlslwi return "rlwinm%s" %dot, "r%i, r%i, r%i,r%i,r%i" %(A, S, SH, MB, ME) def sc(value, addr): if value & 0x3FFFFFF != 2: return "<invalid>" return "sc" def stb(value, addr): return "stb", loadStore(value) def stfd(value, addr): return "stfd", loadStore(value, "f") def stfs(value, addr): return "stfs", loadStore(value, "f") def stfsu(value, addr): return "stfsu", loadStore(value, "f") def stmw(value, addr): return "stmw", loadStore(value) def stw(value, addr): return "stw", loadStore(value) def stwu(value, addr): return "stwu", loadStore(value) def stbx(S, A, B, pad): return "stbx", loadStoreX(S, A, B, pad) def stwx(S, A, B, pad): return "stwx", loadStoreX(S, A, B, pad) def stwcx(S, A, B, pad): return "stwcx", loadStoreX(S, A, B, pad ^ 1) def tw(TO, A, B, pad): if pad: return "<invalid>" if TO == 31 and A == 0 and B == 0: return "trap" if TO not in trap_condition_table: condition = "?" else: condition = trap_condition_table[TO] return "tw%s" %condition, "r%i, r%i" %(A, B) opcode_table_ext1 = { 16: bclr, 528: bcctr } opcode_table_ext2 = { 0: cmp, 4: tw, 20: lwarx, 23: lwzx, 26: cntlzw, 28: and_, 32: cmpl, 54: dcbst, 150: stwcx, 151: stwx, 215: stbx, 266: add, 339: mfspr, 444: or_, 467: mtspr } opcode_table_float_ext1 = { 40: fneg, 72: fmr } def ext1(value, addr): DS, A, B, XO, Rc = decodeX(value) if not XO in opcode_table_ext1: return "ext1 - %s" %bin(XO) return opcode_table_ext1[XO](DS, A, B, Rc) def ext2(value, addr): DS, A, B, XO, Rc = decodeX(value) if not XO in opcode_table_ext2: return "ext2 - %s" %bin(XO) return opcode_table_ext2[XO](DS, A, B, Rc) def float_ext1(value, addr): D, A, B, XO, Rc = decodeX(value) if not XO in opcode_table_float_ext1: return "float_ext1 - %s" %bin(XO) return opcode_table_float_ext1[XO](D, A, B, Rc) opcode_table = { 10: cmpli, 11: cmpi, 12: addic, 13: addic_, 14: addi, 15: addis, 16: bc, 17: sc, 18: b, 19: ext1, 21: rlwinm, 24: ori, 25: oris, 31: ext2, 32: lwz, 33: lwzu, 34: lbz, 36: stw, 37: stwu, 38: stb, 46: lmw, 47: stmw, 48: lfs, 50: lfd, 52: stfs, 53: stfsu, 54: stfd, 63: float_ext1 } def disassemble(value, address): opcode = value >> 26 if opcode not in opcode_table: return "???" instr = opcode_table[opcode](value, address) if type(instr) == str: return instr return instr[0] + " " * (10 - len(instr[0])) + instr[1]
__version__ = "2.2.3" __title__ = "taxidTools" __description__ = "A Python Toolkit for Taxonomy" __author__ = "Gregoire Denay" __author_email__ = 'gregoire.denay@cvua-rrw.de' __licence__ = 'BSD License' __url__ = "https://github.com/CVUA-RRW/taxidTools"
#!/usr/bin/python3.3 S1 = 'abc' S2 = 'xyz123' z = zip(S1, S2) print(list(z)) print(list(zip([1, 2, 3], [2, 3, 4, 5]))) print(list(map(abs, [-2, -1, 0, 1, 2]))) print(list(map(pow, [1, 2, 3], [2, 3, 4, 5]))) print(list(map(lambda x, y: x+y, open('script2.py'), open('script2.py')))) print([x+y for (x, y) in zip(open('script2.py'), open('script2.py'))]) def mymap(func, *seqs): res = [] for x in zip(*seqs): res.append(func(*x)) return res print(list(mymap(abs, [-2, -1, 0, 1, 2]))) print(list(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))) def mymap(func, *seqs): return [func(*x) for x in zip(*seqs)] print(list(mymap(abs, [-2, -1, 0, 1, 2]))) print(list(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))) def mymap(func, *seqs): return (func(*x) for x in zip(*seqs)) print(list(mymap(abs, [-2, -1, 0, 1, 2]))) print(list(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))) def mymap(func, *seqs): for x in zip(*seqs): yield func(*x) print(list(mymap(abs, [-2, -1, 0, 1, 2]))) print(list(mymap(pow, [1, 2, 3], [2, 3, 4, 5]))) def myzip(*seq): res = [] seqs = [list(S) for S in seq] while all(seqs): res.append(tuple(S.pop(0) for S in seqs)) return res print(list(myzip([1, 2, 3], [2, 3, 4, 5]))) print([x+y for (x, y) in zip(open('script2.py'), open('script2.py'))]) def mymappad(*seq, pad=None): res = [] seqs = [list(S) for S in seq] while any(seqs): res.append(tuple((S.pop(0) if S else pad) for S in seqs)) return res print(mymappad(S1, S2, pad=99)) print(mymappad(S1, S2)) def myzip(*seq): seqs = [list(S) for S in seq] while all(seqs): yield tuple(S.pop(0) for S in seqs) print(list(myzip([1, 2, 3], [2, 3, 4, 5]))) print([x+y for (x, y) in myzip(open('script2.py'), open('script2.py'))]) def mymappad(*seq, pad=None): seqs = [list(S) for S in seq] while any(seqs): yield tuple((S.pop(0) if S else pad) for S in seqs) print(list(mymappad(S1, S2, pad=99))) print(list(mymappad(S1, S2))) def myzip(*seq): minlen = min(len(S) for S in seq) return [tuple(S[i] for S in seq) for i in range(minlen)] print(list(myzip([1, 2, 3], [2, 3, 4, 5]))) def mymappad(*seq, pad=None): maxlen = max(len(S) for S in seq) return [tuple(S[i] if i < len(S) else pad for S in seq) for i in range(maxlen)] print(list(mymappad(S1, S2, pad=99))) print(list(mymappad(S1, S2))) def myzip(*seq): minlen = min(len(S) for S in seq) return (tuple(S[i] for S in seq) for i in range(minlen)) print(list(myzip([1, 2, 3], [2, 3, 4, 5]))) def myzip(*seq): iters = list(map(iter, seq)) i = 0 while iters: i = i+1 print(i) res = [next(i) for i in iters] print(bool(iters)) yield tuple(res) print('lala') print(list(myzip([1, 2, 3], [2, 3, 4, 5])))
class Solution(object): def isPalindrome(self, s): """ :type s: str :rtype: bool """ ns = '' for ch in s: if ch.isalnum(): ns += ch.lower() return ns == ns[::-1]