content
stringlengths
7
1.05M
def oneaway(x,y): # INSERT x = list(x) y = list(y) if (len(x)+1) == len(y): for k in x: if k in y: continue else: return "1 FUCK" # REMOVAL if (len(x)-1) == len(y): for k in y: if k in x: continue else: return "2 FUCK" # REPLACE count = 0 if len(x) == len(y): x = list(dict.fromkeys(x)) y = list(dict.fromkeys(y)) for k in x: if k in y: count += 1 if len(x) != (count+1): return "3 FUCK" return "WE ARE LAUGHING" ############################### print(oneaway("pale", "ple")) print(oneaway("pales", "pale")) print(oneaway("pale", "bale")) print(oneaway("pale", "bake"))
""" State machine data structure with one start state and one stop state. Source: http://www.python-course.eu/finite_state_machine.php """ class InitializationError(ValueError): pass class InputError(ValueError): pass ############################################################################### class StateMachine: def __init__(self): self.handlers = {} self.start = None # s self.end = None # t def add_state(self, name, callback=None, start_state=False, end_state=False): name = name.upper() if name in self.handlers: raise InitializationError('unable to reassign state name "' + name + '"') self.handlers[name] = callback if end_state: self.end = name if start_state: self.start = name def set_start(self, name): self.start = name.upper() def set_end(self, name): self.end = name.upper() def run(self, cargo, start=None): run_start = self.start if start: run_start = start.upper() if None == run_start: raise InitializationError("assign start state before .run()") if not self.end: raise InitializationError("assign end state(s) before .run()") if not cargo or len(cargo) == 0: raise InputError("invalid fsm transitions supplied") try: handler = self.handlers[run_start] except: raise InitializationError("assign start state before .run()") #print(cargo) while True: (newState, cargo) = handler(cargo) #print("Reached", newState) if newState.upper() == self.end: break else: handler = self.handlers[newState.upper()] if not handler: raise InputError("invalid fsm transitions supplied") ############################################################################### if __name__ == '__main__': example = StateMachine() def parse_command(text, enclosures = '()'): lparen = text.find(enclosures[0]) rparen = text.rfind(enclosures[1]) return text[:lparen], text[lparen + 1: rparen] for lines in range(int(input().strip())): command, value = parse_command(input().strip()) if command == 'add_state': example.add_state(value) elif command == 'set_start': example.set_start(value) elif command == 'set_end': example.set_end(value) elif command == 'print_state_machine': for h in example.handlers: print(str(h) + ' --> ' + str(example.handlers[h])) print('Start =', example.start) print('End =', example.end) else: print("Invalid command detected:", command)
"""Find the smallest integer in the array, Kata in Codewars.""" def smallest(alist): """Return the smallest integer in the list. input: a list of integers output: a single integer ex: [34, 15, 88, 2] should return 34 ex: [34, -345, -1, 100] should return -345 """ res = [alist[0]] for num in alist: if res[0] > num: res.pop() res.append(num) return res[0]
""" 백준 6810번 : ISBN """ ans = 91 a = int(input()) b = int(input()) c = int(input()) print('The 1-3-sum is {}'.format(ans + a + b*3 + c))
# Python - 3.6.0 test.describe('Example Tests') tests = ( ('John', 'Hello, John!'), ('aLIce', 'Hello, Alice!'), ('', 'Hello, World!') ) for inp, exp in tests: test.assert_equals(hello(inp), exp) test.assert_equals(hello(), 'Hello, World!')
''' Author: Ajay Mahar Lang: python3 Github: https://www.github.com/ajaymahar YT: https://www.youtube.com/ajaymaharyt ''' class Node: def __init__(self, data): """TODO: Docstring for __init__. :returns: TODO """ self.data = data self.next = None class Stack: def __init__(self): """TODO: Docstring for __init__. :returns: TODO """ self.head = None self.size = 0 def push(self, data): """TODO: Docstring for push. :returns: TODO """ if self.head: newNode = Node(data) newNode.next = self.head self.head = newNode self.size += 1 else: self.head = Node(data) self.size += 1 def pop(self): """TODO: Docstring for pop. :returns: TODO """ if self.size == 0: return None tmpHead = self.head self.head = tmpHead.next self.size -= 1 tmpHead.next = None return tmpHead.data def peek(self): """TODO: Docstring for peek. :arg1: TODO :returns: TODO """ if self.head: return self.head.data return None def isEmpty(self): """TODO: Docstring for isEmpty. :returns: TODO """ return self.size == 0 if __name__ == "__main__": st = Stack() st.push(10) st.push(20) st.push(30) st.push(40) st.push(50) print(st.peek()) print(st.size) print(st.isEmpty()) print(st.pop()) print(st.pop()) print(st.pop()) print(st.pop()) print(st.pop()) print(st.pop()) print(st.isEmpty())
'''PROGRAM TO, FOR A GIVEN LIST OF TUPLES, WHERE EACH TUPLE TAKES PATTERN (NAME,MARKS) OF A STUDENT, DISPLAY ONLY NAMES.''' #Given list scores = [("akash", 85), ("arind", 80), ("asha",95), ('bhavana',90), ('bhavik',87)] #Seperaing names and marks sep = list(zip(*scores)) names = sep[0] #Displaying names print('\nNames of students:') for x in names: print(x.title()) print()
"""Sorts GO IDs or user-provided sections containing GO IDs.""" __copyright__ = "Copyright (C) 2016-2019, DV Klopfenstein, H Tang, All rights reserved." __author__ = "DV Klopfenstein" class SorterNts(object): """Handles GO IDs in user-created sections. * Get a 2-D list of sections: sections = [ ['Immune', [ "GO:HHHHHH0", "GO:UUUUU00", ... "GO:UUUUU0N", "GO:HHHHHH1", ...]], ['Neuro', [ "GO:HHHHHH2", "GO:UUUUU20", ... "GO:UUUUU2N", "GO:HHHHHH3", ...]], ] Also contains function for various tasks on grouped GO IDs: * Sort in various ways (sort by: p=value, depth, proximity to leaf-level, etc.): * Header GO ID groups * User GO IDs within a group """ def __init__(self, sortgos, section_sortby=None): # User GO IDs grouped under header GO IDs are not sorted by the Grouper class. # Sort both user GO IDs in a group and header GO IDs across groups with these: # S: section_sortby (T=True, F=False, S=lambda sort function) # H: hdrgo_sortby Sorts hdr GO IDs # U: sortby Sorts user GO IDs # P: hdrgo_prt If True, Removes GO IDs used as GO group headers; Leaves list in # sorted order, but removes header GO IDs which are not user GO IDs. # # rm_h hdr_sort usr_sort S H U P # --- ------------ ------------ _ _ _ - # NO hdrgo_sortby usrgo_sortby T H U T # YES hdrgo_sortby usrgo_sortby T H U F # NO section_order usrgo_sortby F - U T # YES section_order usrgo_sortby F - U F # YES |<----section_sortby---->| S - - - # print("SSSS SorterNts(sortgos, section_sortby={})".format(section_sortby)) self.sortgos = sortgos # SorterGoIds # section_sortby: True, False or None, or a sort_fnc self.section_sortby = section_sortby self.sections = self.sortgos.grprobj.hdrobj.sections # print('IIIIIIIIIIII SorterNts section_sortby', section_sortby) def get_sorted_nts_keep_section(self, hdrgo_prt): """Get 2-D list: 1st level is sections and 2nd level is grouped and sorted namedtuples.""" section_nts = [] # print("SSSS SorterNts:get_sorted_nts_keep_section(hdrgo_prt={})".format(hdrgo_prt)) hdrgos_actual = self.sortgos.grprobj.get_hdrgos() hdrgos_secs = set() hdrgo_sort = False if self.section_sortby is False else True secname_dflt = self.sortgos.grprobj.hdrobj.secdflt for section_name, section_hdrgos_all in self.sections: #section_hdrgos_act = set(section_hdrgos_all).intersection(hdrgos_actual) section_hdrgos_act = [h for h in section_hdrgos_all if h in hdrgos_actual] hdrgos_secs |= set(section_hdrgos_act) nts_section = self.sortgos.get_nts_sorted(hdrgo_prt, section_hdrgos_act, hdrgo_sort) if nts_section: nts_section = self._get_sorted_section(nts_section) section_nts.append((section_name, nts_section)) remaining_hdrgos = hdrgos_actual.difference(hdrgos_secs) # Add GO group headers not yet used under new section, Misc. if remaining_hdrgos: nts_section = self.sortgos.get_nts_sorted(hdrgo_prt, remaining_hdrgos, hdrgo_sort) if nts_section: nts_section = self._get_sorted_section(nts_section) section_nts.append((secname_dflt, nts_section)) return section_nts def get_sorted_nts_omit_section(self, hdrgo_prt, hdrgo_sort): """Return a flat list of sections (wo/section names) with GO terms grouped and sorted.""" nts_flat = [] # print("SSSS SorterNts:get_sorted_nts_omit_section(hdrgo_prt={}, hdrgo_sort={})".format( # hdrgo_prt, hdrgo_sort)) hdrgos_seen = set() hdrgos_actual = self.sortgos.grprobj.get_hdrgos() for _, section_hdrgos_all in self.sections: #section_hdrgos_act = set(section_hdrgos_all).intersection(hdrgos_actual) section_hdrgos_act = [h for h in section_hdrgos_all if h in hdrgos_actual] hdrgos_seen |= set(section_hdrgos_act) self.sortgos.get_sorted_hdrgo2usrgos( section_hdrgos_act, nts_flat, hdrgo_prt, hdrgo_sort) remaining_hdrgos = set(self.sortgos.grprobj.get_hdrgos()).difference(hdrgos_seen) self.sortgos.get_sorted_hdrgo2usrgos(remaining_hdrgos, nts_flat, hdrgo_prt, hdrgo_sort) return nts_flat def _get_sorted_section(self, nts_section): """Sort GO IDs in each section, if requested by user.""" #pylint: disable=unnecessary-lambda if self.section_sortby is True: return sorted(nts_section, key=lambda nt: self.sortgos.usrgo_sortby(nt)) if self.section_sortby is False or self.section_sortby is None: return nts_section # print('SORT GO IDS IN A SECTION') return sorted(nts_section, key=lambda nt: self.section_sortby(nt)) # Copyright (C) 2016-2019, DV Klopfenstein, H Tang, All rights reserved.
# https://binarysearch.com/problems/Largest-Anagram-Group class Solution: def solve(self, words): anagrams = {} for i in range(len(words)): words[i] = "".join(sorted(list(words[i]))) if words[i] in anagrams: anagrams[words[i]]+=1 else: anagrams[words[i]]=1 return max(anagrams.values())
class Solution: def mostCommonWord(self, paragraph: str, banned: List[str]) -> str: paraList = re.split('\W', paragraph.lower()) paraListAlpha = [] for item in paraList: item = ''.join([i for i in item if i.isalpha()]) paraListAlpha.append(item) countParaList = Counter(paraListAlpha) countParaListSort = sorted(countParaList.items(), key = lambda x:x[1], reverse=True) print(countParaListSort) for item in countParaListSort: if item[0] in banned or item[0] == '': continue return item[0]
with open("a.txt",'r') as ifile: with open("b.txt","w") as ofile: char = ifile.read(1) while char: if char==".": ofile.write(char) ofile.write("\n") char = ifile.read(1) else: ofile.write(char) char = ifile.read(1)
L, R = map(int, input().split()) ll = list(map(int, input().split())) rl = list(map(int, input().split())) lsize = [0]*41 rsize = [0]*41 for l in ll: lsize[l] += 1 for r in rl: rsize[r] += 1 ans = 0 for i in range(10, 41): ans += min(lsize[i], rsize[i]) print(ans)
SIZE = 32 class Tile(): def __init__(self, collision=False, image=None, action_index=None): self.collision = collision self.image = image self.action_index = action_index
A = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] B = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20] C = [21, 22, 23, 24, 25, 26, 27, 28, 29, 30] intercalada = [] contador = 0 for i in range(10): intercalada.append(A[contador]) intercalada.append(B[contador]) intercalada.append(C[contador]) contador += 1 print(intercalada)
# Python program to demonstrate working of # Set in Python # Creating two sets set1 = set() set2 = set() # Adding elements to set1 for i in range(1, 6): set1.add(i) # Adding elements to set2 for i in range(3, 8): set2.add(i) set1.add(1) print("Set1 = ", set1) print("Set2 = ", set2) print("\n") # Difference between discard() and remove() # initialize my_set my_set = {1, 3, 4, 5, 6} print(my_set) # discard an element # Output: {1, 3, 5, 6} my_set.discard(4) print(my_set) # remove an element # Output: {1, 3, 5} my_set.remove(6) print(my_set) # discard an element # not present in my_set # Output: {1, 3, 5} my_set.discard(2) print(my_set) # remove an element # not present in my_set # you will get an error. # Output: KeyError #my_set.remove(2) # initialize my_set # Output: set of unique elements my_set = set("HelloWorld") print(my_set) # pop an element # Output: random element print(my_set.pop()) # pop another element my_set.pop() print(my_set) # clear my_set # Output: set() my_set.clear() print(my_set) print(my_set) # Set union method # initialize A and B A = {1, 2, 3, 4, 5} B = {4, 5, 6, 7, 8} # use | operator # Output: {1, 2, 3, 4, 5, 6, 7, 8} print(A | B) print(A.union(B)) # Intersection of sets # initialize A and B A = {1, 2, 3, 4, 5} B = {4, 5, 6, 7, 8} # use & operator # Output: {4, 5} print(A & B) # A.intersection(B) # Difference of two sets # initialize A and B A = {1, 2, 3, 4, 5} B = {4, 5, 6, 7, 8} # use - operator on A # Output: {1, 2, 3} print(A - B) #A.difference(B) # in keyword in a set # initialize my_set my_set = set("apple") # check if 'a' is present # Output: True print('a' in my_set) # check if 'p' is present # Output: False print('p' not in my_set) for letter in set("apple"): print(letter)
''' Copyright 2011 Acknack Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ''' ''' Set of friendly error codes that can be displayed to the user on a webpage ''' CANNOT_CONNECT_TO_WAVE_ERR = "e0000" BOT_NOT_PARTICIPANT_ERR = "e0001" PERMISSION_DENIED_ERR = "e0002" REQUEST_DEADLINE_ERR = "e0003" UNKNOWN_ERR = "e0004" USER_DELETED_ERR = "e0005" INADEQUATE_PERMISSION_ERR = "e0006"
# This is your Application's Configuration File. # Make sure not to upload this file! # Flask App Secret. Used for "session". flaskSecret = "<generateKey>" # Register your V1 app at https://portal.azure.com. # Sign-On URL as <domain>/customer/login/authorized i.e. http://localhost:5000/customer/login/authorized # Make the Application Multi-Tenant # Add access to Windows Azure Service Management API # Create an App Key clientId = "<GUID>" clientSecret = "<SECRET>" # The various resource endpoints. You may need to update this for different cloud environments. aad_endpoint = "https://login.microsoftonline.com/" resource_arm = "https://management.azure.com/" resource_graph = "https://graph.windows.net/" api_version_graph = "1.6"
""" This package contains definitions for the geometric primitives in use in ``phantomas``. """ __all__ = ['fiber', 'models', 'utils', 'rois']
def min4(*args): min_ = args[0] for item in args: if item < min_: min_ = item return min_ a, b, c, d = int(input()), int(input()), int(input()), int(input()) print(min4(a, b, c, d))
class Contender: def __init__(self, names, values): self.names = names self.values = values def __repr__(self): strings = tuple(str(v.id()) for v in self.values) return str(strings) + " contender" def __lt__(self, other): return self.values < other.values def __getitem__(self, item): idx = self.index_of(item) return self.values[idx] def index_of(self, varname): return self.names.index(varname) def id(self): return tuple(v.id() for v in self.values) def set_executor(self, executor): self.executor = executor def run(self, options, invocation): return self.executor.run_with(options, invocation)
def non_repeat(line): ls = [line[i:j] for i in range(len(line)) for j in range(i+1, len(line)+1) if len(set(line[i:j])) == j - i] return max(ls, key=len, default='')
first_number = int(input("Enter the first number(divisor): ")) second_number = int(input("Enter the second number(boundary): ")) for number in range(second_number, 0, -1): if number % first_number == 0: print(number) break
n = int(input()) last = 1 lastlast = 0 print('0 1 ', end="") for i in range(n-2): now = last+lastlast if i == n-3: print('{}'.format(now)) else: print('{} '.format(now), end="") lastlast = last last = now
""" In the Code tab is a function which is meant to return how many uppercase letters there are in a list of various words. Fix the list comprehension so that the code functions normally! Examples count_uppercase(["SOLO", "hello", "Tea", "wHat"]) ➞ 6 count_uppercase(["little", "lower", "down"]) ➞ 0 count_uppercase(["EDAbit", "Educate", "Coding"]) ➞ 5 Notes Check the Resources for some helpful tutorials on list comprehensions. """ def count_uppercase(lst): return sum(letter.isupper() for word in lst for letter in word) print(count_uppercase(["SOLO", "hello", "Tea", "wHat"]))
# -*- coding: utf-8 -*- def main(): n = int(input()) dishes = list() ans = 0 # See: # https://poporix.hatenablog.com/entry/2019/01/28/222905 # https://misteer.hatenablog.com/entry/NIKKEI2019qual?_ga=2.121425408.962332021.1548821392-1201012407.1527836447 for i in range(n): ai, bi = map(int, input().split()) dishes.append((ai, bi)) for index, dish in enumerate(sorted(dishes, key=lambda x: x[0] + x[1], reverse=True)): if index % 2 == 0: ans += dish[0] else: ans -= dish[1] print(ans) if __name__ == '__main__': main()
class Cell: def __init__(self, x, y, entity = None, agent = None, dirty = False): self.x = x self.y = y self.entity = entity self.agent = agent self.dirty = dirty def set_entity(self, entity): self.entity = entity self.entity.x = self.x self.entity.y = self.y def set_agent(self, agent): self.agent = agent self.agent.x = self.x self.agent.y = self.y def free_entity(self): self.entity = None def free_agent(self): self.agent = None @property def is_dirty(self): return self.dirty @property def is_empty(self): return self.entity == None and self.agent == None and not self.dirty def __str__(self): if self.agent: return str(self.agent) elif self.entity: return str(self.entity) elif self.dirty: return "X" else: return "-"
# Ann watched a TV program about health and learned that it is # recommended to sleep at least A hours per day, but # oversleeping is also not healthy, and you should not sleep more # than B hours. Now Ann sleeps H hours per day. If Ann's sleep # schedule complies with the requirements of that TV program - # print "Normal". If Ann sleeps less than A hours, output # "Deficiency", and if she sleeps more than B hours, output # "Excess". # Input to this program are the three strings with variables in the # following order: A, B, H. A is always less than or equal to B. # Please note the letter's cases: the output should exactly # correspendond to what required in the program, i.e. if the program # must output "Excess", output such as "excess", "EXCESS", or # "ExCess" will not be graded as correct. # You should carefully think about all the conditions, which you # need to use. Special attention should be paid to the strictness # of used conditional operators: distinguish between < and <=; # > and >=. In order to understand which ones to use, please # carefully read the problem statement. (a, b, h) = (int(input()), int(input()), int(input())) if h < a: print("Deficiency") elif h > b: print("Excess") else: print("Normal")
numeros = [[], []] for i in range(1, 8): num = int(input(f'Digite o {i}° valor: ')) if num % 2 == 0: numeros[0].append(num) else: numeros[1].append(num) numeros[0].sort() numeros[1].sort() print('-=' * 30) print(f'Pares: {numeros[0]}\nImpares: {numeros[1]}')
# your_name = input(f'Please enter name: ') # back_name = your_name[::-1] # print(f'{your_name} -> {(back_name.capitalize())} , pamatigs juceklis vai ne {your_name[0].upper()}?') name = input("Enter the name:") name = name.capitalize() name_rev = name[::-1].capitalize() print(f"{name_rev}, pamatīgs juceklis, vai ne {name[0]}?")
def menu(): simulation_name = "listWithOptionsOptimized" use_existing = True save_results = False print("This project is made to train agents to fight each other\nThere is three types of agents\n-dummy : don't do anything\n-runner : just moving\n-killer : move and shoot\nWe are only using dummies and runners for the three first basic levels\n\nYou will now choose the parameters of the game\n") skipParam = input("skip and use default setup ? (best and latest trained agents) Y/N\n") if skipParam == "Y" or skipParam == "y": pass elif skipParam == "N" or skipParam == "n": answer = input("Select the number corresponding to the simulation you want to make:\n1: killer vs dummy (only killer is an agent, 2D)\n2: killer vs runner (only killer is an agent, 2D)\n3: killer vs runner (both are agents, 2D)\n4: killer vs killer (2D)\n5: three killers (2D)\n6: with Options (create your own in 2D)\n7: Optimized version (memory optimized version of 6:)\n") if answer=='1': simulation_name = "killerVsDummy" elif answer=='2': simulation_name = "killerVsRunner" elif answer=='3': simulation_name = "listKillerVsRunner" elif answer=='4': simulation_name = "listKillerVsKiller" elif answer=='5': simulation_name = "listThreeKillers" elif answer=='6': simulation_name = "listWithOptions" elif answer=="7": simulation_name = "listWithOptionsOptimized" else: print("wrong value selected") answer = input("Do you want to use the already trained agents ? Y/N\n") if answer == "Y" or answer == "y": #use_existing = True pass elif answer == "N" or answer == "n": use_existing = False save = input("Do you want to save results after the training ? Y/N\n") if save == "Y" or save == "y": save_results = True elif save == "N" or save == "n": pass else: print("wrong value selected") else: print("wrong value selected") else: print("wrong value selected") print("\nYou have selected : "+str(simulation_name)+", using trained agents:"+str(use_existing)+", saving results:"+str(save_results)) return use_existing, save_results, simulation_name
my_set = {4, 2, 8, 5, 10, 11, 10} # seturile sunt neordonate my_set2 = {9, 5, 77, 22, 98, 11, 10} print(my_set) # print(my_set[0:]) #nu se poate lst = (11, 12, 12, 14, 15, 13, 14) print(set(lst)) #eliminam duplicatele din lista prin transformarea in set print(my_set.difference(my_set2)) print(my_set.intersection(my_set2))
def make_weights_for_balanced_classes(images, nclasses): count = [0] * nclasses for item in images: count[item[1]] += 1 weight_per_class = [0.] * nclasses N = float(sum(count)) for i in range(nclasses): weight_per_class[i] = N/float(count[i]) weight = [0] * len(images) for idx, val in enumerate(images): weight[idx] = weight_per_class[val[1]] return weight def train(net,train_loader,criterion,optimizer,epoch_num,device): print('\nEpoch: %d' % epoch_num) net.train() train_loss = 0 correct = 0 total = 0 with tqdm(total=math.ceil(len(train_loader)), desc="Training") as pbar: for batch_idx, (inputs, targets) in enumerate(train_loader): inputs, targets = inputs.to(device), targets.to(device) outputs = net(inputs) loss = criterion(outputs, targets) optimizer.zero_grad() loss.backward() optimizer.step() train_loss += criterion(outputs, targets).item() _, predicted = torch.max(outputs.data, 1) total += targets.size(0) correct += predicted.eq(targets.data).sum() pbar.set_postfix({'loss': '{0:1.5f}'.format(loss), 'accuracy': '{:.2%}'.format(correct.item() / total)}) pbar.update(1) pbar.close() return net def evaluate(net,test_loader,criterion,best_val_acc,save_name,device): with torch.no_grad(): test_loss = 0 correct = 0 total = 0 with tqdm(total=math.ceil(len(test_loader)), desc="Testing") as pbar: for batch_idx, (inputs, targets) in enumerate(test_loader): inputs, targets = inputs.to(device), targets.to(device) outputs = net(inputs) loss = criterion(outputs, targets) test_loss += loss.item() _, predicted = torch.max(outputs.data, 1) total += targets.size(0) correct += predicted.eq(targets.data).sum() pbar.set_postfix({'loss': '{0:1.5f}'.format(loss), 'accuracy': '{:.2%}'.format(correct.item() / total)}) pbar.update(1) pbar.close() acc = 100 * int(correct) / int(total) if acc > best_val_acc: torch.save(net.state_dict(),save_name) best_val_acc = acc return test_loss / (batch_idx + 1), best_val_acc
''' You own a Goal Parser that can interpret a string command. The command consists of an alphabet of "G", "()" and/or "(al)" in some order. The Goal Parser will interpret "G" as the string "G", "()" as the string "o", and "(al)" as the string "al". The interpreted strings are then concatenated in the original order. Given the string command, return the Goal Parser's interpretation of command. Example: Input: command = "G()(al)" Output: "Goal" Explanation: The Goal Parser interprets the command as follows: G -> G () -> o (al) -> al The final concatenated result is "Goal". Example: Input: command = "G()()()()(al)" Output: "Gooooal" Example: Input: command = "(al)G(al)()()G" Output: "alGalooG" Constraints: - 1 <= command.length <= 100 - command consists of "G", "()", and/or "(al)" in some order. ''' #Difficulty:Easy #105 / 105 test cases passed. #Runtime: 32 ms #Memory Usage: 14.1 MB #Runtime: 32 ms, faster than 77.40% of Python3 online submissions for Goal Parser Interpretation. #Memory Usage: 14.1 MB, less than 90.67% of Python3 online submissions for Goal Parser Interpretation. class Solution: def interpret(self, command: str) -> str: command = list(command) l = False for i, char in enumerate(command): if char == 'l': l = True elif char == '(': command[i] = '' elif char == ')': command[i] = '' if l else 'o' l = False return ''.join(command)
def sequencia(): i = 0 j = 1 while i <= 2: for aux in range(3): if int(i) == i: print(f'I={int(i)} J={int(j)}') else: print(f'I={i:.1f} J={j:.1f}') j += 1 j = round(j - 3 + 0.2, 1) i = round(i + 0.2, 1) sequencia()
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: longest = 0 """ @param root: the root of binary tree @return: the length of the longest consecutive sequence path """ def longestConsecutive(self, root): self.longest = 0 self.dfs(root, 0, []) return self.longest def dfs(self, node, length, combination): if node is None: return if length != 0 and node.val != combination[-1] + 1: length = 0 combination = [] length += 1 combination.append(node.val) if length > self.longest: self.longest = length if node.left: self.dfs(node.left, length, combination) if node.right: self.dfs(node.right, length, combination) combination.pop()
def twoSum( nums, target: int): #Vaule = {}.fromkeys for i in range(len(nums)): a = target - nums[i] for j in range(i+1,len(nums),1): if a == nums[j]: return [i,j] findSum = twoSum(nums = [1,2,3,4,5,6,8],target=14) print(findSum)
#!/usr/bin/python # -*- coding: utf-8 -*- """ MIT License Copyright (c) 2013-2016 Frantisek Uhrecky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. """ class UserModel: """ Holds User data. """ def __init__(self, u_id = None, name = None, passwd = None, salt = None, master = None): """ Initialize UserModel. @param u_id: user id @param name: user name @param passwd: user passwd hash @param salt: password salt @param master: master password, plain text """ self._id = u_id self._name = name self._passwd = passwd self._salt = salt self._master = master
""" 1764 : 듣보잡 URL : https://www.acmicpc.net/problem/1764 Input : 3 4 ohhenrie charlie baesangwook obama baesangwook ohhenrie clinton Output : 2 baesangwook ohhenrie """ n, m = map(int, input().split()) d = set() for i in range(n): d.add(input()) b = set() for i in range(m): b.add(input()) dbj = d.intersection(b) print(len(dbj)) for i in sorted(dbj): print(i)
# Events for actors to send __all__ = [ "NodeEvent", "AuthPingEvent", "TagEvent", "UntagEvent", "DetagEvent", "RawMsgEvent", "PingEvent", "GoodNodeEvent", "RecoverEvent", "SetupEvent", ] class NodeEvent: pass class AuthPingEvent(NodeEvent): """ Superclass for tag and ping: must arrive within :meth:`cycle_time_max` seconds of each other. Non-abstract subclasses of this must have ``name`` and ``value`` attributes. (TODO: enforce this) """ pass class TagEvent(AuthPingEvent): """ This event says that for the moment, you're "it". Arguments: node(str): this node name. value (any): the value attached to me. """ def __init__(self, node, value): self.node = node self.value = value def __repr__(self): return "<Tag %s %r>" % (self.node, self.value) class UntagEvent(NodeEvent): """ Your tag cycle time has passed. You're no longer "it". """ def __repr__(self): return "<UnTag>" class DetagEvent(UntagEvent): """ A ping from another node has arrived while you're "it". Unfortunately, it is "better" than ours. Arguments: node (str): The node that superseded us. """ def __init__(self, node): self.node = node def __repr__(self): return "<DeTag %s>" % (self.node,) class RawMsgEvent(NodeEvent): """ A message shows up. Not filtered. You must set "send_raw" when you create the actor. Arguments: msg (dict): The raw data """ def __init__(self, msg): self.msg = msg def __repr__(self): return "<RawMsg %r>" % (self.msg,) class PingEvent(AuthPingEvent): """ A ping from another node shows up: the node ``.node`` is "it". Arguments: msg (Message): The ping message sent by the currently-active actor. """ def __init__(self, msg): self.msg = msg def __repr__(self): return "<Ping %r>" % (self.msg,) @property def node(self): """ Name of the node. Shortcut to ``msg['node']``. """ try: return self.msg.node except AttributeError: return None @property def value(self): """ Name of the node. Shortcut to ``msg['node']``. """ try: return self.msg.value except AttributeError: return None class GoodNodeEvent(NodeEvent): """ A known-good node has been seen. We might want to get data from it. Arguments: nodes (list(str)): Nodes known to have a non-``None`` value. This event is seen while starting up, when our value is ``None``. """ def __init__(self, nodes): self.nodes = nodes def __repr__(self): return "<Good %s>" % (self.nodes,) class RecoverEvent(NodeEvent): """ We need to recover from a network split. Arguments: prio: Our recovery priority. Zero is highest. replace: Flag whether the other side has superseded ours. local_nodes: A list of recent actors on our side. remote_nodes: A list of recent actors on the other side. """ def __init__(self, prio, replace, local_nodes, remote_nodes): self.prio = prio self.replace = replace self.local_nodes = local_nodes self.remote_nodes = remote_nodes def __repr__(self): return "<Recover %d %s %r %r>" % ( self.prio, self.replace, self.local_nodes, self.remote_nodes, ) class SetupEvent(NodeEvent): """ Parameters have been updated, most likely by the network. """ version = None def __init__(self, msg): for k in "version cycle gap nodes splits n_hosts".split(): try: setattr(self, k, getattr(msg, k)) except AttributeError: pass def __repr__(self): return "<Setup v:%s>" % (self.version,)
# Tot's reward lv 50 sm.completeQuest(5522) # Lv. 50 Equipment box sm.giveItem(2430450, 1) sm.dispose()
""" Inner module for card utilities. """ def is_location(card): """ Return true if `card` is a location card, false otherwise. """ return card.kind is not None and card.color is not None def is_door(card): """ Return true if `card` is a door card, false otherwise. """ return card.kind is None and card.color is not None def is_nightmare(card): """ Return true if `card` is a nightmare card, false otherwise. """ return card.kind is None and card.color is None
class Board: def __init__(self): self.board = [0] * 9 def __getitem__(self, n): return self.board[n] def __setitem__(self, n, value): self.board[n] = value def __str__(self): return "\n".join([ "".join([[" ", "o", "x"][j] for j in self.board[3*i:3*i+3]]) for i in range(3) ]) def in_set(self, set): set = [s.n() for s in set] for a in self.permutations(): if a in set: return True return False def is_max(self): return self.n() == max(self.permutations()) def permutations(self): out = [] for rot in [ (0, 1, 2, 3, 4, 5, 6, 7, 8), (2, 5, 8, 1, 4, 7, 0, 3, 6), (8, 7, 6, 5, 4, 3, 2, 1, 0), (6, 3, 0, 7, 4, 1, 8, 5, 2), (2, 1, 0, 5, 4, 3, 8, 7, 6), (8, 5, 2, 7, 4, 1, 6, 3, 0), (6, 7, 8, 3, 4, 5, 0, 1, 2), (0, 3, 6, 1, 4, 7, 2, 5, 8) ]: out.append(self.nrot(rot)) return out def has_winner(self): for i, j, k in [ (0, 1, 2), (3, 4, 5), (6, 7, 8), (0, 3, 6), (1, 4, 7), (2, 5, 8), (0, 4, 8), (2, 4, 6) ]: if self[i] != 0 and self[i] == self[j] == self[k]: return True return False def n(self): return self.nrot(list(range(9))) def nrot(self, rot): out = 0 for i in range(9): out += 3 ** i * self[rot[i]] return out def as_latex(self): out = "\\begin{tikzpicture}\n" out += "\\clip (3.75mm,-1mm) rectangle (40.25mm,25mm);\n" out += "\\draw[gray] (5mm,5mm) -- (39mm,5mm);\n" out += "\\draw[gray] (5mm,19mm) -- (39mm,19mm);\n" out += "\\draw[gray] (5mm,0mm) -- (5mm,24mm);\n" out += "\\draw[gray] (39mm,0mm) -- (39mm,24mm);\n" out += "\\draw (16mm,10mm) -- (28mm,10mm);\n" out += "\\draw (16mm,14mm) -- (28mm,14mm);\n" out += "\\draw (20mm,6mm) -- (20mm,18mm);\n" out += "\\draw (24mm,6mm) -- (24mm,18mm);\n" for i, c in enumerate([ (16, 6), (20, 6), (24, 6), (16, 10), (20, 10), (24, 10), (16, 14), (20, 14), (24, 14) ]): if self[i] == 1: # o out += f"\\draw ({c[0]+2}mm,{c[1]+2}mm) circle (1mm);\n" if self[i] == 2: # x out += (f"\\draw ({c[0]+1}mm,{c[1]+1}mm)" f" -- ({c[0]+3}mm,{c[1]+3}mm);\n" f"\\draw ({c[0]+1}mm,{c[1]+3}mm)" f" -- ({c[0]+3}mm,{c[1]+1}mm);\n") out += "\\end{tikzpicture}" return out
line = input() words = line.split() for word in words: line = line.replace(word, word.capitalize()) print(line)
"""Leetcode 9. Palindrome Number Easy URL: https://leetcode.com/problems/palindrome-number/ Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Example 3: Input: 10 Output: false Explanation: Reads 01 from right to left. Therefore it is not a palindrome. Follow up: Coud you solve it without converting the integer to a string? """ class Solution(object): def isPalindrome(self, x): # faster """ :type x: int :rtype: bool """ x_str = str(x) if x_str[::-1] == x_str: return True else: return False class Solution(object): def isPalindrome(self, x): result = [] if x < 0: return False while x != 0: num = divmod(x, 10) x_div = num[0] #12, 1, 0 x_mod = num[1] #1, 2, 1 x = x_div result.append(x_mod) if result != result[::-1]: return False else: return True class Solution1(object): def isPalindrome(self, x): if x < 0: return False xx = x y = 0 while xx != 0: x_div, x_mod = divmod(xx, 10) y = y * 10 + x_mod xx = x_div if y == x: return True return False def main(): # Output: True x = 121 print(Solution().isPalindrome(x)) # Output: False x = -121 print(Solution().isPalindrome(x)) # Output: False x = 10 print(Solution().isPalindrome(x)) # Output: True x = 262 print(Solution().isPalindrome(x)) if __name__ == '__main__': main()
expected_output = { 'jid': {1: {'index': {1: {'data': 344, 'dynamic': 0, 'jid': 1, 'process': 'init', 'stack': 136, 'text': 296}}}, 51: {'index': {1: {'data': 1027776, 'dynamic': 5668, 'jid': 51, 'process': 'processmgr', 'stack': 136, 'text': 1372}}}, 53: {'index': {1: {'data': 342500, 'dynamic': 7095, 'jid': 53, 'process': 'dsr', 'stack': 136, 'text': 32}}}, 111: {'index': {1: {'data': 531876, 'dynamic': 514, 'jid': 111, 'process': 'devc-conaux-aux', 'stack': 136, 'text': 8}}}, 112: {'index': {1: {'data': 861144, 'dynamic': 957, 'jid': 112, 'process': 'qsm', 'stack': 136, 'text': 144}}}, 113: {'index': {1: {'data': 400776, 'dynamic': 671, 'jid': 113, 'process': 'spp', 'stack': 136, 'text': 328}}}, 114: {'index': {1: {'data': 531912, 'dynamic': 545, 'jid': 114, 'process': 'devc-conaux-con', 'stack': 136, 'text': 8}}}, 115: {'index': {1: {'data': 662452, 'dynamic': 366, 'jid': 115, 'process': 'syslogd_helper', 'stack': 136, 'text': 52}}}, 118: {'index': {1: {'data': 200748, 'dynamic': 426, 'jid': 118, 'process': 'shmwin_svr', 'stack': 136, 'text': 56}}}, 119: {'index': {1: {'data': 397880, 'dynamic': 828, 'jid': 119, 'process': 'syslog_dev', 'stack': 136, 'text': 12}}}, 121: {'index': {1: {'data': 470008, 'dynamic': 6347, 'jid': 121, 'process': 'calv_alarm_mgr', 'stack': 136, 'text': 504}}}, 122: {'index': {1: {'data': 1003480, 'dynamic': 2838, 'jid': 122, 'process': 'udp', 'stack': 136, 'text': 180}}}, 123: {'index': {1: {'data': 529852, 'dynamic': 389, 'jid': 123, 'process': 'enf_broker', 'stack': 136, 'text': 40}}}, 124: {'index': {1: {'data': 200120, 'dynamic': 351, 'jid': 124, 'process': 'procfs_server', 'stack': 168, 'text': 20}}}, 125: {'index': {1: {'data': 333592, 'dynamic': 1506, 'jid': 125, 'process': 'pifibm_server_rp', 'stack': 136, 'text': 312}}}, 126: {'index': {1: {'data': 399332, 'dynamic': 305, 'jid': 126, 'process': 'ltrace_sync', 'stack': 136, 'text': 28}}}, 127: {'index': {1: {'data': 797548, 'dynamic': 2573, 'jid': 127, 'process': 'ifindex_server', 'stack': 136, 'text': 96}}}, 128: {'index': {1: {'data': 532612, 'dynamic': 3543, 'jid': 128, 'process': 'eem_ed_test', 'stack': 136, 'text': 44}}}, 130: {'index': {1: {'data': 200120, 'dynamic': 257, 'jid': 130, 'process': 'igmp_policy_reg_agent', 'stack': 136, 'text': 8}}}, 132: {'index': {1: {'data': 200628, 'dynamic': 280, 'jid': 132, 'process': 'show_mediang_edm', 'stack': 136, 'text': 20}}}, 134: {'index': {1: {'data': 466168, 'dynamic': 580, 'jid': 134, 'process': 'ipv4_acl_act_agent', 'stack': 136, 'text': 28}}}, 136: {'index': {1: {'data': 997196, 'dynamic': 5618, 'jid': 136, 'process': 'resmon', 'stack': 136, 'text': 188}}}, 137: {'index': {1: {'data': 534184, 'dynamic': 2816, 'jid': 137, 'process': 'bundlemgr_local', 'stack': 136, 'text': 612}}}, 138: {'index': {1: {'data': 200652, 'dynamic': 284, 'jid': 138, 'process': 'chkpt_proxy', 'stack': 136, 'text': 16}}}, 139: {'index': {1: {'data': 200120, 'dynamic': 257, 'jid': 139, 'process': 'lisp_xr_policy_reg_agent', 'stack': 136, 'text': 8}}}, 141: {'index': {1: {'data': 200648, 'dynamic': 246, 'jid': 141, 'process': 'linux_nto_misc_showd', 'stack': 136, 'text': 20}}}, 143: {'index': {1: {'data': 200644, 'dynamic': 247, 'jid': 143, 'process': 'procfind', 'stack': 136, 'text': 20}}}, 146: {'index': {1: {'data': 200240, 'dynamic': 275, 'jid': 146, 'process': 'bgp_policy_reg_agent', 'stack': 136, 'text': 28}}}, 147: {'index': {1: {'data': 201332, 'dynamic': 418, 'jid': 147, 'process': 'type6_server', 'stack': 136, 'text': 68}}}, 149: {'index': {1: {'data': 663524, 'dynamic': 1297, 'jid': 149, 'process': 'clns', 'stack': 136, 'text': 188}}}, 152: {'index': {1: {'data': 532616, 'dynamic': 3541, 'jid': 152, 'process': 'eem_ed_none', 'stack': 136, 'text': 52}}}, 154: {'index': {1: {'data': 729896, 'dynamic': 1046, 'jid': 154, 'process': 'ipv4_acl_mgr', 'stack': 136, 'text': 140}}}, 155: {'index': {1: {'data': 200120, 'dynamic': 261, 'jid': 155, 'process': 'ospf_policy_reg_agent', 'stack': 136, 'text': 12}}}, 157: {'index': {1: {'data': 200908, 'dynamic': 626, 'jid': 157, 'process': 'ssh_key_server', 'stack': 136, 'text': 44}}}, 158: {'index': {1: {'data': 200628, 'dynamic': 285, 'jid': 158, 'process': 'heap_summary_edm', 'stack': 136, 'text': 20}}}, 161: {'index': {1: {'data': 200640, 'dynamic': 297, 'jid': 161, 'process': 'cmp_edm', 'stack': 136, 'text': 16}}}, 162: {'index': {1: {'data': 267456, 'dynamic': 693, 'jid': 162, 'process': 'ip_aps', 'stack': 136, 'text': 52}}}, 166: {'index': {1: {'data': 935480, 'dynamic': 8194, 'jid': 166, 'process': 'mpls_lsd', 'stack': 136, 'text': 1108}}}, 167: {'index': {1: {'data': 730776, 'dynamic': 3649, 'jid': 167, 'process': 'ipv6_ma', 'stack': 136, 'text': 540}}}, 168: {'index': {1: {'data': 266788, 'dynamic': 589, 'jid': 168, 'process': 'nd_partner', 'stack': 136, 'text': 36}}}, 169: {'index': {1: {'data': 735000, 'dynamic': 6057, 'jid': 169, 'process': 'ipsub_ma', 'stack': 136, 'text': 680}}}, 171: {'index': {1: {'data': 266432, 'dynamic': 530, 'jid': 171, 'process': 'shelf_mgr_proxy', 'stack': 136, 'text': 16}}}, 172: {'index': {1: {'data': 200604, 'dynamic': 253, 'jid': 172, 'process': 'early_fast_discard_verifier', 'stack': 136, 'text': 16}}}, 174: {'index': {1: {'data': 200096, 'dynamic': 256, 'jid': 174, 'process': 'bundlemgr_checker', 'stack': 136, 'text': 56}}}, 175: {'index': {1: {'data': 200120, 'dynamic': 248, 'jid': 175, 'process': 'syslog_infra_hm', 'stack': 136, 'text': 12}}}, 177: {'index': {1: {'data': 200112, 'dynamic': 241, 'jid': 177, 'process': 'meminfo_svr', 'stack': 136, 'text': 8}}}, 178: {'index': {1: {'data': 468272, 'dynamic': 2630, 'jid': 178, 'process': 'accounting_ma', 'stack': 136, 'text': 264}}}, 180: {'index': {1: {'data': 1651090, 'dynamic': 242, 'jid': 180, 'process': 'aipc_cleaner', 'stack': 136, 'text': 8}}}, 181: {'index': {1: {'data': 201280, 'dynamic': 329, 'jid': 181, 'process': 'nsr_ping_reply', 'stack': 136, 'text': 16}}}, 182: {'index': {1: {'data': 334236, 'dynamic': 843, 'jid': 182, 'process': 'spio_ma', 'stack': 136, 'text': 4}}}, 183: {'index': {1: {'data': 266788, 'dynamic': 607, 'jid': 183, 'process': 'statsd_server', 'stack': 136, 'text': 40}}}, 184: {'index': {1: {'data': 407016, 'dynamic': 8579, 'jid': 184, 'process': 'subdb_svr', 'stack': 136, 'text': 368}}}, 186: {'index': {1: {'data': 932992, 'dynamic': 3072, 'jid': 186, 'process': 'smartlicserver', 'stack': 136, 'text': 16}}}, 187: {'index': {1: {'data': 200120, 'dynamic': 259, 'jid': 187, 'process': 'rip_policy_reg_agent', 'stack': 136, 'text': 8}}}, 188: {'index': {1: {'data': 533704, 'dynamic': 3710, 'jid': 188, 'process': 'eem_ed_nd', 'stack': 136, 'text': 60}}}, 189: {'index': {1: {'data': 401488, 'dynamic': 3499, 'jid': 189, 'process': 'ifmgr', 'stack': 136, 'text': 4}}}, 190: {'index': {1: {'data': 1001552, 'dynamic': 3082, 'jid': 190, 'process': 'rdsfs_svr', 'stack': 136, 'text': 196}}}, 191: {'index': {1: {'data': 398300, 'dynamic': 632, 'jid': 191, 'process': 'hostname_sync', 'stack': 136, 'text': 12}}}, 192: {'index': {1: {'data': 466168, 'dynamic': 570, 'jid': 192, 'process': 'l2vpn_policy_reg_agent', 'stack': 136, 'text': 20}}}, 193: {'index': {1: {'data': 665096, 'dynamic': 1405, 'jid': 193, 'process': 'ntpd', 'stack': 136, 'text': 344}}}, 194: {'index': {1: {'data': 794692, 'dynamic': 2629, 'jid': 194, 'process': 'nrssvr', 'stack': 136, 'text': 180}}}, 195: {'index': {1: {'data': 531776, 'dynamic': 748, 'jid': 195, 'process': 'ipv4_io', 'stack': 136, 'text': 256}}}, 196: {'index': {1: {'data': 200624, 'dynamic': 274, 'jid': 196, 'process': 'domain_sync', 'stack': 136, 'text': 16}}}, 197: {'index': {1: {'data': 1015252, 'dynamic': 21870, 'jid': 197, 'process': 'parser_server', 'stack': 136, 'text': 304}}}, 198: {'index': {1: {'data': 532612, 'dynamic': 3540, 'jid': 198, 'process': 'eem_ed_config', 'stack': 136, 'text': 56}}}, 199: {'index': {1: {'data': 200648, 'dynamic': 282, 'jid': 199, 'process': 'cerrno_server', 'stack': 136, 'text': 48}}}, 200: {'index': {1: {'data': 531264, 'dynamic': 1810, 'jid': 200, 'process': 'ipv4_arm', 'stack': 136, 'text': 344}}}, 201: {'index': {1: {'data': 268968, 'dynamic': 1619, 'jid': 201, 'process': 'session_mon', 'stack': 136, 'text': 68}}}, 202: {'index': {1: {'data': 864208, 'dynamic': 3472, 'jid': 202, 'process': 'netio', 'stack': 136, 'text': 292}}}, 204: {'index': {1: {'data': 268932, 'dynamic': 2122, 'jid': 204, 'process': 'ether_caps_partner', 'stack': 136, 'text': 152}}}, 205: {'index': {1: {'data': 201168, 'dynamic': 254, 'jid': 205, 'process': 'sunstone_stats_svr', 'stack': 136, 'text': 28}}}, 206: {'index': {1: {'data': 794684, 'dynamic': 2967, 'jid': 206, 'process': 'sysdb_shared_nc', 'stack': 136, 'text': 4}}}, 207: {'index': {1: {'data': 601736, 'dynamic': 2823, 'jid': 207, 'process': 'yang_server', 'stack': 136, 'text': 268}}}, 208: {'index': {1: {'data': 200096, 'dynamic': 251, 'jid': 208, 'process': 'ipodwdm', 'stack': 136, 'text': 16}}}, 209: {'index': {1: {'data': 200656, 'dynamic': 253, 'jid': 209, 'process': 'crypto_edm', 'stack': 136, 'text': 24}}}, 210: {'index': {1: {'data': 878632, 'dynamic': 13237, 'jid': 210, 'process': 'nvgen_server', 'stack': 136, 'text': 244}}}, 211: {'index': {1: {'data': 334080, 'dynamic': 2169, 'jid': 211, 'process': 'pfilter_ma', 'stack': 136, 'text': 228}}}, 213: {'index': {1: {'data': 531840, 'dynamic': 1073, 'jid': 213, 'process': 'kim', 'stack': 136, 'text': 428}}}, 216: {'index': {1: {'data': 267224, 'dynamic': 451, 'jid': 216, 'process': 'showd_lc', 'stack': 136, 'text': 64}}}, 217: {'index': {1: {'data': 406432, 'dynamic': 4666, 'jid': 217, 'process': 'pppoe_ma', 'stack': 136, 'text': 520}}}, 218: {'index': {1: {'data': 664484, 'dynamic': 2602, 'jid': 218, 'process': 'l2rib', 'stack': 136, 'text': 484}}}, 220: {'index': {1: {'data': 598812, 'dynamic': 3443, 'jid': 220, 'process': 'eem_ed_syslog', 'stack': 136, 'text': 60}}}, 221: {'index': {1: {'data': 267264, 'dynamic': 290, 'jid': 221, 'process': 'lpts_fm', 'stack': 136, 'text': 52}}}, 222: {'index': {1: {'data': 205484, 'dynamic': 5126, 'jid': 222, 'process': 'mpa_fm_svr', 'stack': 136, 'text': 12}}}, 243: {'index': {1: {'data': 267576, 'dynamic': 990, 'jid': 243, 'process': 'spio_ea', 'stack': 136, 'text': 8}}}, 244: {'index': {1: {'data': 200632, 'dynamic': 247, 'jid': 244, 'process': 'mempool_edm', 'stack': 136, 'text': 8}}}, 245: {'index': {1: {'data': 532624, 'dynamic': 3541, 'jid': 245, 'process': 'eem_ed_counter', 'stack': 136, 'text': 48}}}, 247: {'index': {1: {'data': 1010268, 'dynamic': 1923, 'jid': 247, 'process': 'cfgmgr-rp', 'stack': 136, 'text': 344}}}, 248: {'index': {1: {'data': 465260, 'dynamic': 1243, 'jid': 248, 'process': 'alarm-logger', 'stack': 136, 'text': 104}}}, 249: {'index': {1: {'data': 797376, 'dynamic': 1527, 'jid': 249, 'process': 'locald_DLRSC', 'stack': 136, 'text': 604}}}, 250: {'index': {1: {'data': 265800, 'dynamic': 438, 'jid': 250, 'process': 'lcp_mgr', 'stack': 136, 'text': 12}}}, 251: {'index': {1: {'data': 265840, 'dynamic': 712, 'jid': 251, 'process': 'tamfs', 'stack': 136, 'text': 32}}}, 252: {'index': {1: {'data': 531384, 'dynamic': 7041, 'jid': 252, 'process': 'sysdb_svr_local', 'stack': 136, 'text': 4}}}, 253: {'index': {1: {'data': 200672, 'dynamic': 256, 'jid': 253, 'process': 'tty_show_users_edm', 'stack': 136, 'text': 32}}}, 254: {'index': {1: {'data': 534032, 'dynamic': 4463, 'jid': 254, 'process': 'eem_ed_generic', 'stack': 136, 'text': 96}}}, 255: {'index': {1: {'data': 201200, 'dynamic': 409, 'jid': 255, 'process': 'ipv6_acl_cfg_agent', 'stack': 136, 'text': 32}}}, 256: {'index': {1: {'data': 334104, 'dynamic': 756, 'jid': 256, 'process': 'mpls_vpn_mib', 'stack': 136, 'text': 156}}}, 257: {'index': {1: {'data': 267888, 'dynamic': 339, 'jid': 257, 'process': 'bundlemgr_adj', 'stack': 136, 'text': 156}}}, 258: {'index': {1: {'data': 1651090, 'dynamic': 244, 'jid': 258, 'process': 'file_paltx', 'stack': 136, 'text': 16}}}, 259: {'index': {1: {'data': 1000600, 'dynamic': 6088, 'jid': 259, 'process': 'ipv6_nd', 'stack': 136, 'text': 1016}}}, 260: {'index': {1: {'data': 533044, 'dynamic': 1793, 'jid': 260, 'process': 'sdr_instagt', 'stack': 136, 'text': 260}}}, 261: {'index': {1: {'data': 334860, 'dynamic': 806, 'jid': 261, 'process': 'ipsec_pp', 'stack': 136, 'text': 220}}}, 266: {'index': {1: {'data': 266344, 'dynamic': 717, 'jid': 266, 'process': 'pm_server', 'stack': 136, 'text': 92}}}, 267: {'index': {1: {'data': 598760, 'dynamic': 2768, 'jid': 267, 'process': 'object_tracking', 'stack': 136, 'text': 204}}}, 268: {'index': {1: {'data': 200700, 'dynamic': 417, 'jid': 268, 'process': 'wdsysmon_fd_edm', 'stack': 136, 'text': 20}}}, 269: {'index': {1: {'data': 664752, 'dynamic': 2513, 'jid': 269, 'process': 'eth_mgmt', 'stack': 136, 'text': 60}}}, 270: {'index': {1: {'data': 200064, 'dynamic': 257, 'jid': 270, 'process': 'gcp_fib_verifier', 'stack': 136, 'text': 20}}}, 271: {'index': {1: {'data': 400624, 'dynamic': 2348, 'jid': 271, 'process': 'rsi_agent', 'stack': 136, 'text': 580}}}, 272: {'index': {1: {'data': 794692, 'dynamic': 1425, 'jid': 272, 'process': 'nrssvr_global', 'stack': 136, 'text': 180}}}, 273: {'index': {1: {'data': 494124, 'dynamic': 19690, 'jid': 273, 'process': 'invmgr_proxy', 'stack': 136, 'text': 112}}}, 275: {'index': {1: {'data': 199552, 'dynamic': 264, 'jid': 275, 'process': 'nsr_fo', 'stack': 136, 'text': 12}}}, 276: {'index': {1: {'data': 202328, 'dynamic': 436, 'jid': 276, 'process': 'mpls_fwd_show_proxy', 'stack': 136, 'text': 204}}}, 277: {'index': {1: {'data': 267112, 'dynamic': 688, 'jid': 277, 'process': 'tam_sync', 'stack': 136, 'text': 44}}}, 278: {'index': {1: {'data': 200120, 'dynamic': 259, 'jid': 278, 'process': 'mldp_policy_reg_agent', 'stack': 136, 'text': 8}}}, 290: {'index': {1: {'data': 200640, 'dynamic': 262, 'jid': 290, 'process': 'sh_proc_mem_edm', 'stack': 136, 'text': 20}}}, 291: {'index': {1: {'data': 794684, 'dynamic': 3678, 'jid': 291, 'process': 'sysdb_shared_sc', 'stack': 136, 'text': 4}}}, 293: {'index': {1: {'data': 200120, 'dynamic': 259, 'jid': 293, 'process': 'pim6_policy_reg_agent', 'stack': 136, 'text': 8}}}, 294: {'index': {1: {'data': 267932, 'dynamic': 1495, 'jid': 294, 'process': 'issumgr', 'stack': 136, 'text': 560}}}, 295: {'index': {1: {'data': 266744, 'dynamic': 296, 'jid': 295, 'process': 'vlan_ea', 'stack': 136, 'text': 220}}}, 296: {'index': {1: {'data': 796404, 'dynamic': 1902, 'jid': 296, 'process': 'correlatord', 'stack': 136, 'text': 292}}}, 297: {'index': {1: {'data': 201304, 'dynamic': 367, 'jid': 297, 'process': 'imaedm_server', 'stack': 136, 'text': 56}}}, 298: {'index': {1: {'data': 200224, 'dynamic': 246, 'jid': 298, 'process': 'ztp_cfg', 'stack': 136, 'text': 12}}}, 299: {'index': {1: {'data': 268000, 'dynamic': 459, 'jid': 299, 'process': 'ipv6_ea', 'stack': 136, 'text': 92}}}, 301: {'index': {1: {'data': 200644, 'dynamic': 250, 'jid': 301, 'process': 'sysmgr_show_proc_all_edm', 'stack': 136, 'text': 88}}}, 303: {'index': {1: {'data': 399360, 'dynamic': 882, 'jid': 303, 'process': 'tftp_fs', 'stack': 136, 'text': 68}}}, 304: {'index': {1: {'data': 202220, 'dynamic': 306, 'jid': 304, 'process': 'ncd', 'stack': 136, 'text': 32}}}, 305: {'index': {1: {'data': 1001716, 'dynamic': 9508, 'jid': 305, 'process': 'gsp', 'stack': 136, 'text': 1096}}}, 306: {'index': {1: {'data': 794684, 'dynamic': 1792, 'jid': 306, 'process': 'sysdb_svr_admin', 'stack': 136, 'text': 4}}}, 308: {'index': {1: {'data': 333172, 'dynamic': 538, 'jid': 308, 'process': 'devc-vty', 'stack': 136, 'text': 8}}}, 309: {'index': {1: {'data': 1012628, 'dynamic': 9404, 'jid': 309, 'process': 'tcp', 'stack': 136, 'text': 488}}}, 310: {'index': {1: {'data': 333572, 'dynamic': 2092, 'jid': 310, 'process': 'daps', 'stack': 136, 'text': 512}}}, 312: {'index': {1: {'data': 200620, 'dynamic': 283, 'jid': 312, 'process': 'ipv6_assembler', 'stack': 136, 'text': 36}}}, 313: {'index': {1: {'data': 199844, 'dynamic': 551, 'jid': 313, 'process': 'ssh_key_client', 'stack': 136, 'text': 48}}}, 314: {'index': {1: {'data': 332076, 'dynamic': 371, 'jid': 314, 'process': 'timezone_config', 'stack': 136, 'text': 28}}}, 316: {'index': {1: {'data': 531560, 'dynamic': 2016, 'jid': 316, 'process': 'bcdls', 'stack': 136, 'text': 112}}}, 317: {'index': {1: {'data': 531560, 'dynamic': 2015, 'jid': 317, 'process': 'bcdls', 'stack': 136, 'text': 112}}}, 318: {'index': {1: {'data': 532344, 'dynamic': 2874, 'jid': 318, 'process': 'bcdls', 'stack': 136, 'text': 112}}}, 319: {'index': {1: {'data': 532344, 'dynamic': 2874, 'jid': 319, 'process': 'bcdls', 'stack': 136, 'text': 112}}}, 320: {'index': {1: {'data': 531556, 'dynamic': 2013, 'jid': 320, 'process': 'bcdls', 'stack': 136, 'text': 112}}}, 326: {'index': {1: {'data': 398256, 'dynamic': 348, 'jid': 326, 'process': 'sld', 'stack': 136, 'text': 116}}}, 327: {'index': {1: {'data': 997196, 'dynamic': 3950, 'jid': 327, 'process': 'eem_policy_dir', 'stack': 136, 'text': 268}}}, 329: {'index': {1: {'data': 267464, 'dynamic': 434, 'jid': 329, 'process': 'mpls_io_ea', 'stack': 136, 'text': 108}}}, 332: {'index': {1: {'data': 332748, 'dynamic': 276, 'jid': 332, 'process': 'redstatsd', 'stack': 136, 'text': 20}}}, 333: {'index': {1: {'data': 799488, 'dynamic': 4511, 'jid': 333, 'process': 'rsi_master', 'stack': 136, 'text': 404}}}, 334: {'index': {1: {'data': 333648, 'dynamic': 351, 'jid': 334, 'process': 'sconbkup', 'stack': 136, 'text': 12}}}, 336: {'index': {1: {'data': 199440, 'dynamic': 204, 'jid': 336, 'process': 'pam_manager', 'stack': 136, 'text': 12}}}, 337: {'index': {1: {'data': 600644, 'dynamic': 3858, 'jid': 337, 'process': 'nve_mgr', 'stack': 136, 'text': 204}}}, 339: {'index': {1: {'data': 266800, 'dynamic': 679, 'jid': 339, 'process': 'rmf_svr', 'stack': 136, 'text': 140}}}, 341: {'index': {1: {'data': 465864, 'dynamic': 1145, 'jid': 341, 'process': 'ipv6_io', 'stack': 136, 'text': 160}}}, 342: {'index': {1: {'data': 864468, 'dynamic': 1011, 'jid': 342, 'process': 'syslogd', 'stack': 136, 'text': 224}}}, 343: {'index': {1: {'data': 663932, 'dynamic': 1013, 'jid': 343, 'process': 'ipv6_acl_daemon', 'stack': 136, 'text': 212}}}, 344: {'index': {1: {'data': 996048, 'dynamic': 2352, 'jid': 344, 'process': 'plat_sl_client', 'stack': 136, 'text': 108}}}, 346: {'index': {1: {'data': 598152, 'dynamic': 778, 'jid': 346, 'process': 'cinetd', 'stack': 136, 'text': 136}}}, 347: {'index': {1: {'data': 200648, 'dynamic': 261, 'jid': 347, 'process': 'debug_d', 'stack': 136, 'text': 24}}}, 349: {'index': {1: {'data': 200612, 'dynamic': 284, 'jid': 349, 'process': 'debug_d_admin', 'stack': 136, 'text': 20}}}, 350: {'index': {1: {'data': 399188, 'dynamic': 1344, 'jid': 350, 'process': 'vm-monitor', 'stack': 136, 'text': 72}}}, 352: {'index': {1: {'data': 465844, 'dynamic': 1524, 'jid': 352, 'process': 'lpts_pa', 'stack': 136, 'text': 308}}}, 353: {'index': {1: {'data': 1002896, 'dynamic': 5160, 'jid': 353, 'process': 'call_home', 'stack': 136, 'text': 728}}}, 355: {'index': {1: {'data': 994116, 'dynamic': 7056, 'jid': 355, 'process': 'eem_server', 'stack': 136, 'text': 292}}}, 356: {'index': {1: {'data': 200720, 'dynamic': 396, 'jid': 356, 'process': 'tcl_secure_mode', 'stack': 136, 'text': 8}}}, 357: {'index': {1: {'data': 202040, 'dynamic': 486, 'jid': 357, 'process': 'tamsvcs_tamm', 'stack': 136, 'text': 36}}}, 359: {'index': {1: {'data': 531256, 'dynamic': 1788, 'jid': 359, 'process': 'ipv6_arm', 'stack': 136, 'text': 328}}}, 360: {'index': {1: {'data': 201196, 'dynamic': 363, 'jid': 360, 'process': 'fwd_driver_partner', 'stack': 136, 'text': 88}}}, 361: {'index': {1: {'data': 533872, 'dynamic': 2637, 'jid': 361, 'process': 'ipv6_mfwd_partner', 'stack': 136, 'text': 836}}}, 362: {'index': {1: {'data': 932680, 'dynamic': 3880, 'jid': 362, 'process': 'arp', 'stack': 136, 'text': 728}}}, 363: {'index': {1: {'data': 202024, 'dynamic': 522, 'jid': 363, 'process': 'cepki', 'stack': 136, 'text': 96}}}, 364: {'index': {1: {'data': 1001736, 'dynamic': 4343, 'jid': 364, 'process': 'fib_mgr', 'stack': 136, 'text': 3580}}}, 365: {'index': {1: {'data': 269016, 'dynamic': 2344, 'jid': 365, 'process': 'pim_ma', 'stack': 136, 'text': 56}}}, 368: {'index': {1: {'data': 1002148, 'dynamic': 3111, 'jid': 368, 'process': 'raw_ip', 'stack': 136, 'text': 124}}}, 369: {'index': {1: {'data': 464272, 'dynamic': 625, 'jid': 369, 'process': 'ltrace_server', 'stack': 136, 'text': 40}}}, 371: {'index': {1: {'data': 200572, 'dynamic': 279, 'jid': 371, 'process': 'netio_debug_partner', 'stack': 136, 'text': 24}}}, 372: {'index': {1: {'data': 200120, 'dynamic': 259, 'jid': 372, 'process': 'pim_policy_reg_agent', 'stack': 136, 'text': 8}}}, 373: {'index': {1: {'data': 333240, 'dynamic': 1249, 'jid': 373, 'process': 'policymgr_rp', 'stack': 136, 'text': 592}}}, 375: {'index': {1: {'data': 200624, 'dynamic': 290, 'jid': 375, 'process': 'loopback_caps_partner', 'stack': 136, 'text': 32}}}, 376: {'index': {1: {'data': 467420, 'dynamic': 3815, 'jid': 376, 'process': 'eem_ed_sysmgr', 'stack': 136, 'text': 76}}}, 377: {'index': {1: {'data': 333636, 'dynamic': 843, 'jid': 377, 'process': 'mpls_io', 'stack': 136, 'text': 140}}}, 378: {'index': {1: {'data': 200120, 'dynamic': 258, 'jid': 378, 'process': 'ospfv3_policy_reg_agent', 'stack': 136, 'text': 8}}}, 380: {'index': {1: {'data': 333604, 'dynamic': 520, 'jid': 380, 'process': 'fhrp_output', 'stack': 136, 'text': 124}}}, 381: {'index': {1: {'data': 533872, 'dynamic': 2891, 'jid': 381, 'process': 'ipv4_mfwd_partner', 'stack': 136, 'text': 828}}}, 382: {'index': {1: {'data': 465388, 'dynamic': 538, 'jid': 382, 'process': 'packet', 'stack': 136, 'text': 132}}}, 383: {'index': {1: {'data': 333284, 'dynamic': 359, 'jid': 383, 'process': 'dumper', 'stack': 136, 'text': 40}}}, 384: {'index': {1: {'data': 200636, 'dynamic': 244, 'jid': 384, 'process': 'showd_server', 'stack': 136, 'text': 12}}}, 385: {'index': {1: {'data': 603424, 'dynamic': 3673, 'jid': 385, 'process': 'ipsec_mp', 'stack': 136, 'text': 592}}}, 388: {'index': {1: {'data': 729160, 'dynamic': 836, 'jid': 388, 'process': 'bcdl_agent', 'stack': 136, 'text': 176}}}, 389: {'index': {1: {'data': 729880, 'dynamic': 1066, 'jid': 389, 'process': 'bcdl_agent', 'stack': 136, 'text': 176}}}, 390: {'index': {1: {'data': 663828, 'dynamic': 1384, 'jid': 390, 'process': 'bcdl_agent', 'stack': 136, 'text': 176}}}, 391: {'index': {1: {'data': 795416, 'dynamic': 1063, 'jid': 391, 'process': 'bcdl_agent', 'stack': 136, 'text': 176}}}, 401: {'index': {1: {'data': 466148, 'dynamic': 579, 'jid': 401, 'process': 'es_acl_act_agent', 'stack': 136, 'text': 20}}}, 402: {'index': {1: {'data': 597352, 'dynamic': 1456, 'jid': 402, 'process': 'vi_config_replicator', 'stack': 136, 'text': 40}}}, 403: {'index': {1: {'data': 532624, 'dynamic': 3546, 'jid': 403, 'process': 'eem_ed_timer', 'stack': 136, 'text': 64}}}, 405: {'index': {1: {'data': 664196, 'dynamic': 2730, 'jid': 405, 'process': 'pm_collector', 'stack': 136, 'text': 732}}}, 406: {'index': {1: {'data': 868076, 'dynamic': 5739, 'jid': 406, 'process': 'ppp_ma', 'stack': 136, 'text': 1268}}}, 407: {'index': {1: {'data': 794684, 'dynamic': 1753, 'jid': 407, 'process': 'sysdb_shared_data_nc', 'stack': 136, 'text': 4}}}, 408: {'index': {1: {'data': 415316, 'dynamic': 16797, 'jid': 408, 'process': 'statsd_manager_l', 'stack': 136, 'text': 4}}}, 409: {'index': {1: {'data': 946780, 'dynamic': 16438, 'jid': 409, 'process': 'iedged', 'stack': 136, 'text': 1824}}}, 411: {'index': {1: {'data': 542460, 'dynamic': 17658, 'jid': 411, 'process': 'sysdb_mc', 'stack': 136, 'text': 388}}}, 412: {'index': {1: {'data': 1003624, 'dynamic': 5783, 'jid': 412, 'process': 'l2fib_mgr', 'stack': 136, 'text': 1808}}}, 413: {'index': {1: {'data': 401532, 'dynamic': 2851, 'jid': 413, 'process': 'aib', 'stack': 136, 'text': 256}}}, 414: {'index': {1: {'data': 266776, 'dynamic': 440, 'jid': 414, 'process': 'rmf_cli_edm', 'stack': 136, 'text': 32}}}, 415: {'index': {1: {'data': 399116, 'dynamic': 895, 'jid': 415, 'process': 'ether_sock', 'stack': 136, 'text': 28}}}, 416: {'index': {1: {'data': 200980, 'dynamic': 275, 'jid': 416, 'process': 'shconf-edm', 'stack': 136, 'text': 32}}}, 417: {'index': {1: {'data': 532108, 'dynamic': 3623, 'jid': 417, 'process': 'eem_ed_stats', 'stack': 136, 'text': 60}}}, 418: {'index': {1: {'data': 532288, 'dynamic': 2306, 'jid': 418, 'process': 'ipv4_ma', 'stack': 136, 'text': 540}}}, 419: {'index': {1: {'data': 689020, 'dynamic': 15522, 'jid': 419, 'process': 'sdr_invmgr', 'stack': 136, 'text': 144}}}, 420: {'index': {1: {'data': 466456, 'dynamic': 1661, 'jid': 420, 'process': 'http_client', 'stack': 136, 'text': 96}}}, 421: {'index': {1: {'data': 201152, 'dynamic': 285, 'jid': 421, 'process': 'pak_capture_partner', 'stack': 136, 'text': 16}}}, 422: {'index': {1: {'data': 200016, 'dynamic': 267, 'jid': 422, 'process': 'bag_schema_svr', 'stack': 136, 'text': 36}}}, 424: {'index': {1: {'data': 604932, 'dynamic': 8135, 'jid': 424, 'process': 'issudir', 'stack': 136, 'text': 212}}}, 425: {'index': {1: {'data': 466796, 'dynamic': 1138, 'jid': 425, 'process': 'l2snoop', 'stack': 136, 'text': 104}}}, 426: {'index': {1: {'data': 331808, 'dynamic': 444, 'jid': 426, 'process': 'ssm_process', 'stack': 136, 'text': 56}}}, 427: {'index': {1: {'data': 200120, 'dynamic': 245, 'jid': 427, 'process': 'media_server', 'stack': 136, 'text': 16}}}, 428: {'index': {1: {'data': 267340, 'dynamic': 432, 'jid': 428, 'process': 'ip_app', 'stack': 136, 'text': 48}}}, 429: {'index': {1: {'data': 269032, 'dynamic': 2344, 'jid': 429, 'process': 'pim6_ma', 'stack': 136, 'text': 56}}}, 431: {'index': {1: {'data': 200416, 'dynamic': 390, 'jid': 431, 'process': 'local_sock', 'stack': 136, 'text': 16}}}, 432: {'index': {1: {'data': 265704, 'dynamic': 269, 'jid': 432, 'process': 'crypto_monitor', 'stack': 136, 'text': 68}}}, 433: {'index': {1: {'data': 597624, 'dynamic': 1860, 'jid': 433, 'process': 'ema_server_sdr', 'stack': 136, 'text': 112}}}, 434: {'index': {1: {'data': 200120, 'dynamic': 259, 'jid': 434, 'process': 'isis_policy_reg_agent', 'stack': 136, 'text': 8}}}, 435: {'index': {1: {'data': 200120, 'dynamic': 261, 'jid': 435, 'process': 'eigrp_policy_reg_agent', 'stack': 136, 'text': 12}}}, 437: {'index': {1: {'data': 794096, 'dynamic': 776, 'jid': 437, 'process': 'cdm_rs', 'stack': 136, 'text': 80}}}, 1003: {'index': {1: {'data': 798196, 'dynamic': 3368, 'jid': 1003, 'process': 'eigrp', 'stack': 136, 'text': 936}}}, 1011: {'index': {1: {'data': 1006776, 'dynamic': 8929, 'jid': 1011, 'process': 'isis', 'stack': 136, 'text': 4888}}}, 1012: {'index': {1: {'data': 1006776, 'dynamic': 8925, 'jid': 1012, 'process': 'isis', 'stack': 136, 'text': 4888}}}, 1027: {'index': {1: {'data': 1012376, 'dynamic': 14258, 'jid': 1027, 'process': 'ospf', 'stack': 136, 'text': 2880}}}, 1046: {'index': {1: {'data': 804288, 'dynamic': 8673, 'jid': 1046, 'process': 'ospfv3', 'stack': 136, 'text': 1552}}}, 1066: {'index': {1: {'data': 333188, 'dynamic': 1084, 'jid': 1066, 'process': 'autorp_candidate_rp', 'stack': 136, 'text': 52}}}, 1067: {'index': {1: {'data': 532012, 'dynamic': 1892, 'jid': 1067, 'process': 'autorp_map_agent', 'stack': 136, 'text': 84}}}, 1071: {'index': {1: {'data': 998992, 'dynamic': 5498, 'jid': 1071, 'process': 'msdp', 'stack': 136, 'text': 484}}}, 1074: {'index': {1: {'data': 599436, 'dynamic': 1782, 'jid': 1074, 'process': 'rip', 'stack': 136, 'text': 296}}}, 1078: {'index': {1: {'data': 1045796, 'dynamic': 40267, 'jid': 1078, 'process': 'bgp', 'stack': 136, 'text': 2408}}}, 1093: {'index': {1: {'data': 668844, 'dynamic': 3577, 'jid': 1093, 'process': 'bpm', 'stack': 136, 'text': 716}}}, 1101: {'index': {1: {'data': 266776, 'dynamic': 602, 'jid': 1101, 'process': 'cdp_mgr', 'stack': 136, 'text': 24}}}, 1113: {'index': {1: {'data': 200096, 'dynamic': 251, 'jid': 1113, 'process': 'eigrp_uv', 'stack': 136, 'text': 48}}}, 1114: {'index': {1: {'data': 1084008, 'dynamic': 45594, 'jid': 1114, 'process': 'emsd', 'stack': 136, 'text': 10636}}}, 1128: {'index': {1: {'data': 200156, 'dynamic': 284, 'jid': 1128, 'process': 'isis_uv', 'stack': 136, 'text': 84}}}, 1130: {'index': {1: {'data': 599144, 'dynamic': 2131, 'jid': 1130, 'process': 'lldp_agent', 'stack': 136, 'text': 412}}}, 1135: {'index': {1: {'data': 1052648, 'dynamic': 24083, 'jid': 1135, 'process': 'netconf', 'stack': 136, 'text': 772}}}, 1136: {'index': {1: {'data': 600036, 'dynamic': 795, 'jid': 1136, 'process': 'netconf_agent_tty', 'stack': 136, 'text': 20}}}, 1139: {'index': {1: {'data': 200092, 'dynamic': 259, 'jid': 1139, 'process': 'ospf_uv', 'stack': 136, 'text': 48}}}, 1140: {'index': {1: {'data': 200092, 'dynamic': 258, 'jid': 1140, 'process': 'ospfv3_uv', 'stack': 136, 'text': 32}}}, 1147: {'index': {1: {'data': 808524, 'dynamic': 5098, 'jid': 1147, 'process': 'sdr_mgbl_proxy', 'stack': 136, 'text': 464}}}, 1221: {'index': {1: {'data': 200848, 'dynamic': 503, 'jid': 1221, 'process': 'ssh_conf_verifier', 'stack': 136, 'text': 32}}}, 1233: {'index': {1: {'data': 399212, 'dynamic': 1681, 'jid': 1233, 'process': 'mpls_static', 'stack': 136, 'text': 252}}}, 1234: {'index': {1: {'data': 464512, 'dynamic': 856, 'jid': 1234, 'process': 'lldp_mgr', 'stack': 136, 'text': 100}}}, 1235: {'index': {1: {'data': 665416, 'dynamic': 1339, 'jid': 1235, 'process': 'intf_mgbl', 'stack': 136, 'text': 212}}}, 1236: {'index': {1: {'data': 546924, 'dynamic': 17047, 'jid': 1236, 'process': 'statsd_manager_g', 'stack': 136, 'text': 4}}}, 1237: {'index': {1: {'data': 201996, 'dynamic': 1331, 'jid': 1237, 'process': 'ipv4_mfwd_ma', 'stack': 136, 'text': 144}}}, 1238: {'index': {1: {'data': 1015244, 'dynamic': 22504, 'jid': 1238, 'process': 'ipv4_rib', 'stack': 136, 'text': 1008}}}, 1239: {'index': {1: {'data': 201364, 'dynamic': 341, 'jid': 1239, 'process': 'ipv6_mfwd_ma', 'stack': 136, 'text': 136}}}, 1240: {'index': {1: {'data': 951448, 'dynamic': 26381, 'jid': 1240, 'process': 'ipv6_rib', 'stack': 136, 'text': 1160}}}, 1241: {'index': {1: {'data': 873952, 'dynamic': 11135, 'jid': 1241, 'process': 'mrib', 'stack': 136, 'text': 1536}}}, 1242: {'index': {1: {'data': 873732, 'dynamic': 11043, 'jid': 1242, 'process': 'mrib6', 'stack': 136, 'text': 1516}}}, 1243: {'index': {1: {'data': 800236, 'dynamic': 3444, 'jid': 1243, 'process': 'policy_repository', 'stack': 136, 'text': 472}}}, 1244: {'index': {1: {'data': 399440, 'dynamic': 892, 'jid': 1244, 'process': 'ipv4_mpa', 'stack': 136, 'text': 160}}}, 1245: {'index': {1: {'data': 399444, 'dynamic': 891, 'jid': 1245, 'process': 'ipv6_mpa', 'stack': 136, 'text': 160}}}, 1246: {'index': {1: {'data': 200664, 'dynamic': 261, 'jid': 1246, 'process': 'eth_gl_cfg', 'stack': 136, 'text': 20}}}, 1247: {'index': {1: {'data': 941936, 'dynamic': 13246, 'jid': 1247, 'process': 'igmp', 'stack': 144, 'text': 980}}}, 1248: {'index': {1: {'data': 267440, 'dynamic': 677, 'jid': 1248, 'process': 'ipv4_connected', 'stack': 136, 'text': 4}}}, 1249: {'index': {1: {'data': 267424, 'dynamic': 677, 'jid': 1249, 'process': 'ipv4_local', 'stack': 136, 'text': 4}}}, 1250: {'index': {1: {'data': 267436, 'dynamic': 680, 'jid': 1250, 'process': 'ipv6_connected', 'stack': 136, 'text': 4}}}, 1251: {'index': {1: {'data': 267420, 'dynamic': 681, 'jid': 1251, 'process': 'ipv6_local', 'stack': 136, 'text': 4}}}, 1252: {'index': {1: {'data': 940472, 'dynamic': 12973, 'jid': 1252, 'process': 'mld', 'stack': 136, 'text': 928}}}, 1253: {'index': {1: {'data': 1018740, 'dynamic': 22744, 'jid': 1253, 'process': 'pim', 'stack': 136, 'text': 4424}}}, 1254: {'index': {1: {'data': 1017788, 'dynamic': 22444, 'jid': 1254, 'process': 'pim6', 'stack': 136, 'text': 4544}}}, 1255: {'index': {1: {'data': 799148, 'dynamic': 4916, 'jid': 1255, 'process': 'bundlemgr_distrib', 'stack': 136, 'text': 2588}}}, 1256: {'index': {1: {'data': 999524, 'dynamic': 7871, 'jid': 1256, 'process': 'bfd', 'stack': 136, 'text': 1512}}}, 1257: {'index': {1: {'data': 268092, 'dynamic': 1903, 'jid': 1257, 'process': 'bgp_epe', 'stack': 136, 'text': 60}}}, 1258: {'index': {1: {'data': 268016, 'dynamic': 493, 'jid': 1258, 'process': 'domain_services', 'stack': 136, 'text': 136}}}, 1259: {'index': {1: {'data': 201184, 'dynamic': 272, 'jid': 1259, 'process': 'ethernet_stats_controller_edm', 'stack': 136, 'text': 32}}}, 1260: {'index': {1: {'data': 399868, 'dynamic': 874, 'jid': 1260, 'process': 'ftp_fs', 'stack': 136, 'text': 64}}}, 1261: {'index': {1: {'data': 206536, 'dynamic': 2468, 'jid': 1261, 'process': 'python_process_manager', 'stack': 136, 'text': 12}}}, 1262: {'index': {1: {'data': 200360, 'dynamic': 421, 'jid': 1262, 'process': 'tty_verifyd', 'stack': 136, 'text': 8}}}, 1263: {'index': {1: {'data': 265924, 'dynamic': 399, 'jid': 1263, 'process': 'ipv4_rump', 'stack': 136, 'text': 60}}}, 1264: {'index': {1: {'data': 265908, 'dynamic': 394, 'jid': 1264, 'process': 'ipv6_rump', 'stack': 136, 'text': 108}}}, 1265: {'index': {1: {'data': 729900, 'dynamic': 1030, 'jid': 1265, 'process': 'es_acl_mgr', 'stack': 136, 'text': 56}}}, 1266: {'index': {1: {'data': 530424, 'dynamic': 723, 'jid': 1266, 'process': 'rt_check_mgr', 'stack': 136, 'text': 104}}}, 1267: {'index': {1: {'data': 336304, 'dynamic': 2594, 'jid': 1267, 'process': 'pbr_ma', 'stack': 136, 'text': 184}}}, 1268: {'index': {1: {'data': 466552, 'dynamic': 2107, 'jid': 1268, 'process': 'qos_ma', 'stack': 136, 'text': 876}}}, 1269: {'index': {1: {'data': 334576, 'dynamic': 975, 'jid': 1269, 'process': 'vservice_mgr', 'stack': 136, 'text': 60}}}, 1270: {'index': {1: {'data': 1000676, 'dynamic': 5355, 'jid': 1270, 'process': 'mpls_ldp', 'stack': 136, 'text': 2952}}}, 1271: {'index': {1: {'data': 1002132, 'dynamic': 6985, 'jid': 1271, 'process': 'xtc_agent', 'stack': 136, 'text': 1948}}}, 1272: {'index': {1: {'data': 1017288, 'dynamic': 14858, 'jid': 1272, 'process': 'l2vpn_mgr', 'stack': 136, 'text': 5608}}}, 1273: {'index': {1: {'data': 424, 'dynamic': 0, 'jid': 1273, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 1274: {'index': {1: {'data': 202200, 'dynamic': 1543, 'jid': 1274, 'process': 'cmpp', 'stack': 136, 'text': 60}}}, 1275: {'index': {1: {'data': 334624, 'dynamic': 1555, 'jid': 1275, 'process': 'l2tp_mgr', 'stack': 136, 'text': 960}}}, 1276: {'index': {1: {'data': 223128, 'dynamic': 16781, 'jid': 1276, 'process': 'schema_server', 'stack': 136, 'text': 80}}}, 1277: {'index': {1: {'data': 670692, 'dynamic': 6660, 'jid': 1277, 'process': 'sdr_instmgr', 'stack': 136, 'text': 1444}}}, 1278: {'index': {1: {'data': 1004336, 'dynamic': 436, 'jid': 1278, 'process': 'snmppingd', 'stack': 136, 'text': 24}}}, 1279: {'index': {1: {'data': 200120, 'dynamic': 263, 'jid': 1279, 'process': 'ssh_backup_server', 'stack': 136, 'text': 100}}}, 1280: {'index': {1: {'data': 398960, 'dynamic': 835, 'jid': 1280, 'process': 'ssh_server', 'stack': 136, 'text': 228}}}, 1281: {'index': {1: {'data': 399312, 'dynamic': 1028, 'jid': 1281, 'process': 'tc_server', 'stack': 136, 'text': 240}}}, 1282: {'index': {1: {'data': 200636, 'dynamic': 281, 'jid': 1282, 'process': 'wanphy_proc', 'stack': 136, 'text': 12}}}, 67280: {'index': {1: {'data': 204, 'dynamic': 0, 'jid': 67280, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 67321: {'index': {1: {'data': 132, 'dynamic': 0, 'jid': 67321, 'process': 'sh', 'stack': 136, 'text': 1016}}}, 67322: {'index': {1: {'data': 204, 'dynamic': 0, 'jid': 67322, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 67338: {'index': {1: {'data': 40, 'dynamic': 0, 'jid': 67338, 'process': 'cgroup_oom', 'stack': 136, 'text': 8}}}, 67493: {'index': {1: {'data': 176, 'dynamic': 0, 'jid': 67493, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 67499: {'index': {1: {'data': 624, 'dynamic': 0, 'jid': 67499, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 67513: {'index': {1: {'data': 256, 'dynamic': 0, 'jid': 67513, 'process': 'inotifywait', 'stack': 136, 'text': 24}}}, 67514: {'index': {1: {'data': 636, 'dynamic': 0, 'jid': 67514, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 67563: {'index': {1: {'data': 8408, 'dynamic': 0, 'jid': 67563, 'process': 'dbus-daemon', 'stack': 136, 'text': 408}}}, 67582: {'index': {1: {'data': 440, 'dynamic': 0, 'jid': 67582, 'process': 'sshd', 'stack': 136, 'text': 704}}}, 67592: {'index': {1: {'data': 200, 'dynamic': 0, 'jid': 67592, 'process': 'rpcbind', 'stack': 136, 'text': 44}}}, 67686: {'index': {1: {'data': 244, 'dynamic': 0, 'jid': 67686, 'process': 'rngd', 'stack': 136, 'text': 20}}}, 67692: {'index': {1: {'data': 176, 'dynamic': 0, 'jid': 67692, 'process': 'syslogd', 'stack': 136, 'text': 44}}}, 67695: {'index': {1: {'data': 3912, 'dynamic': 0, 'jid': 67695, 'process': 'klogd', 'stack': 136, 'text': 28}}}, 67715: {'index': {1: {'data': 176, 'dynamic': 0, 'jid': 67715, 'process': 'xinetd', 'stack': 136, 'text': 156}}}, 67758: {'index': {1: {'data': 748, 'dynamic': 0, 'jid': 67758, 'process': 'crond', 'stack': 524, 'text': 56}}}, 68857: {'index': {1: {'data': 672, 'dynamic': 0, 'jid': 68857, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 68876: {'index': {1: {'data': 744, 'dynamic': 0, 'jid': 68876, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 68881: {'index': {1: {'data': 82976, 'dynamic': 0, 'jid': 68881, 'process': 'dev_inotify_hdlr', 'stack': 136, 'text': 12}}}, 68882: {'index': {1: {'data': 82976, 'dynamic': 0, 'jid': 68882, 'process': 'dev_inotify_hdlr', 'stack': 136, 'text': 12}}}, 68909: {'index': {1: {'data': 88312, 'dynamic': 0, 'jid': 68909, 'process': 'ds', 'stack': 136, 'text': 56}}}, 69594: {'index': {1: {'data': 199480, 'dynamic': 173, 'jid': 69594, 'process': 'tty_exec_launcher', 'stack': 136, 'text': 16}}}, 70487: {'index': {1: {'data': 200108, 'dynamic': 312, 'jid': 70487, 'process': 'tams_proc', 'stack': 136, 'text': 440}}}, 70709: {'index': {1: {'data': 200200, 'dynamic': 342, 'jid': 70709, 'process': 'tamd_proc', 'stack': 136, 'text': 32}}}, 73424: {'index': {1: {'data': 200808, 'dynamic': 0, 'jid': 73424, 'process': 'attestation_agent', 'stack': 136, 'text': 108}}}, 75962: {'index': {1: {'data': 206656, 'dynamic': 0, 'jid': 75962, 'process': 'pyztp2', 'stack': 136, 'text': 8}}}, 76021: {'index': {1: {'data': 1536, 'dynamic': 0, 'jid': 76021, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 76022: {'index': {1: {'data': 1784, 'dynamic': 0, 'jid': 76022, 'process': 'bash', 'stack': 136, 'text': 1016}}}, 76639: {'index': {1: {'data': 16480, 'dynamic': 0, 'jid': 76639, 'process': 'perl', 'stack': 136, 'text': 8}}}, 76665: {'index': {1: {'data': 487380, 'dynamic': 0, 'jid': 76665, 'process': 'pam_cli_agent', 'stack': 136, 'text': 1948}}}, 76768: {'index': {1: {'data': 24868, 'dynamic': 0, 'jid': 76768, 'process': 'perl', 'stack': 136, 'text': 8}}}, 76784: {'index': {1: {'data': 17356, 'dynamic': 0, 'jid': 76784, 'process': 'perl', 'stack': 136, 'text': 8}}}, 76802: {'index': {1: {'data': 16280, 'dynamic': 0, 'jid': 76802, 'process': 'perl', 'stack': 136, 'text': 8}}}, 77304: {'index': {1: {'data': 598100, 'dynamic': 703, 'jid': 77304, 'process': 'exec', 'stack': 136, 'text': 76}}}, 80488: {'index': {1: {'data': 172, 'dynamic': 0, 'jid': 80488, 'process': 'sleep', 'stack': 136, 'text': 32}}}, 80649: {'index': {1: {'data': 172, 'dynamic': 0, 'jid': 80649, 'process': 'sleep', 'stack': 136, 'text': 32}}}, 80788: {'index': {1: {'data': 1484, 'dynamic': 2, 'jid': 80788, 'process': 'sleep', 'stack': 136, 'text': 32}}}, 80791: {'index': {1: {'data': 420, 'dynamic': 0, 'jid': 80791, 'process': 'sh', 'stack': 136, 'text': 1016}}}, 80792: {'index': {1: {'data': 133912, 'dynamic': 194, 'jid': 80792, 'process': 'sh_proc_mem_cli', 'stack': 136, 'text': 12}}}, 80796: {'index': {1: {'data': 484, 'dynamic': 0, 'jid': 80796, 'process': 'sh', 'stack': 136, 'text': 1016}}}, 80797: {'index': {1: {'data': 133916, 'dynamic': 204, 'jid': 80797, 'process': 'sh_proc_memory', 'stack': 136, 'text': 12 } } } } }
#!/usr/bin/env python # # Copyright 2014 Tuenti Technologies S.L. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # class MergeStrategy(object): """ Defines an strategy to perform a merge operation, its arguments are the same as the ones of the merge method, plus an instance of repoman.Repository. """ def __init__(self, repository, local_branch=None, other_rev=None, other_branch_name=None): self.repository = repository self.local_branch = local_branch self.other_rev = other_rev self.other_branch_name = other_branch_name def perform(self): """ Performs the merge itself, applying the changes in the files it possible and raising in case of conflicts, this operation should leave the Repository object in a state with enough information to abort the merge. """ raise NotImplementedError("Abstract method") def abort(self): """ Resets the repository to the state before the perform. """ raise NotImplementedError("Abstract method") def commit(self): """ Writes the final commit if proceeds and returns it. """ raise NotImplementedError("Abstract method")
def primefactor(n): for i in range(2,n+1): if n%i==0: isprime=1 for j in range(2,int(i/2+1)): if i%j==0: isprime=0 break if isprime: print(i) n=315 primefactor(n)
# Copyright (c) 2011 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. { 'includes': [ '../../../build/common.gypi', ], 'variables': { 'common_sources': [ ], }, 'targets' : [ { 'target_name': 'nosys_lib', 'type': 'none', 'variables': { 'nlib_target': 'libnosys.a', 'build_glibc': 0, 'build_newlib': 1, 'build_pnacl_newlib': 1, }, 'sources': [ 'access.c', 'chmod.c', 'chown.c', 'endpwent.c', 'environ.c', 'execve.c', '_execve.c', 'fcntl.c', 'fchdir.c', 'fchmod.c', 'fchown.c', 'fdatasync.c', 'fork.c', 'fsync.c', 'ftruncate.c', 'get_current_dir_name.c', 'getegid.c', 'geteuid.c', 'getgid.c', 'getlogin.c', 'getrusage.c', 'getppid.c', 'getpwent.c', 'getpwnam.c', 'getpwnam_r.c', 'getpwuid.c', 'getpwuid_r.c', 'getuid.c', 'getwd.c', 'ioctl.c', 'issetugid.c', 'isatty.c', 'kill.c', 'lchown.c', 'link.c', 'llseek.c', 'lstat.c', 'pclose.c', 'pipe.c', 'popen.c', 'pselect.c', 'readlink.c', 'remove.c', 'rename.c', 'select.c', 'setegid.c', 'seteuid.c', 'setgid.c', 'setpwent.c', 'settimeofday.c', 'setuid.c', 'signal.c', 'sigprocmask.c', 'symlink.c', 'system.c', 'times.c', 'tmpfile.c', 'truncate.c', 'ttyname.c', 'ttyname_r.c', 'umask.c', 'utime.c', 'utimes.c', 'vfork.c', 'wait.c', 'waitpid.c', ], 'dependencies': [ '<(DEPTH)/native_client/tools.gyp:prep_toolchain', ], }, ], }
def is_leap(year): if ( year >= 1900 and year <=100000): leap = False if ( (year % 4 == 0) and (year % 400 == 0 or year % 100 != 0) ): leap = True return leap year = int(input()) print(is_leap(year))
# Copyright 2014 The Johns Hopkins University Applied Physics Laboratory # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. def format_capitalize(fqdn): return "".join([x.capitalize() for x in fqdn.split('.')]) def format_dash(fqdn): return fqdn.replace('.', '-') class AWSNameAccumulator(object): def __init__(self, initial_value, callback): self.acc = [initial_value] self.cb = callback def __repr__(self): """Display the partial AWSName so that it is easier to track down problems with json.dump""" return "<AWSNames().{}>".format('.'.join(self.acc)) def __getattr__(self, key): self.acc.append(key) if len(self.acc) == 2: return self.cb(*self.acc) else: return self def __getitem__(self, key): return self.__getattr__(key) def __dir__(self): rtn = [] # Assumes that the initial value is the resource name cfg = AWSNames.RESOURCES[self.acc[0]] if 'types' in cfg: rtn.extend(cfg['types']) if 'type' in cfg: rtn.append(cfg['type']) return rtn class AWSNames(object): def __init__(self, internal_domain, external_domain=None, external_format=None, ami_suffix=None): self.internal_domain = internal_domain self.external_domain = external_domain self.external_format = external_format self.ami_suffix = ami_suffix @classmethod def from_bosslet(cls, bosslet_config): return cls(bosslet_config.INTERNAL_DOMAIN, bosslet_config.EXTERNAL_DOMAIN, bosslet_config.EXTERNAL_FORMAT, bosslet_config.AMI_SUFFIX) @classmethod def from_lambda(cls, name): """ Instantiate AWSNames from the name of a lambda function. Used by lambdas so they can look up names of other resources. Args: name (str): Name of lambda function (ex: multiLambda-integration-boss) Returns: (AWSNames) """ # NOTE: This will only allow looking up internal resource names # external names or amis cannot be resolved # NOTE: Assume the format <lambda_name>-<internal_domain> # where <lambda_name> doesn't have a - (or '.') # Lambdas names can't have periods; restore proper name. dotted_name = name.replace('-', '.') domain = dotted_name.split('.', 1)[1] return cls(domain) def public_dns(self, name): if not self.external_domain: raise ValueError("external_domain not provided") if self.external_format: name = self.external_format.format(machine = name) return name + '.' + self.external_domain def __getattr__(self, key): return AWSNameAccumulator(key, self.build) def __getitem__(self, key): # For dynamically building names from input return self.__getattr__(key) def __dir__(self): rtn = ['RESOURCES', 'TYPES', 'public_dns', 'build', #'__getattr__', '__getitem__', 'internal_domain', 'external_domain', 'external_format', 'ami_suffix'] rtn.extend(self.RESOURCES.keys()) return rtn TYPES = { 'stack': format_capitalize, 'subnet': None, 'dns': None, # Internal DNS name, EC2 and ELB # XXX: maybe ec2, as it is an EC2 instance name 'lambda_': format_dash, # Need '_' as lambda is a keyword # XXX: not all lambdas used dashes 'rds': None, 'sns': format_dash, 'sqs': format_capitalize, 'sg': None, # Security Group 'rt': None, # Route Table 'gw': None, # Gateway 'ami': None, 'redis': None, # ElastiSearch Redis 'ddb': None, # DynamoDB 's3': None, # S3 Bucket 'sfn': format_capitalize, # StepFunction 'cw': format_dash, # CloudWatch Rule 'key': None, # KMS Key } RESOURCES = { # Ordered by name to make it easy to find an entry 'activities': {'types': ['dns', 'ami', 'stack']}, 'api': {'type': 'stack'}, 'auth': {'types': ['dns', 'ami', 'sg']}, 'auth_db': {'name': 'auth-db', 'type': 'rds'}, 'bastion': {'type': 'dns'}, 'backup': {'types': ['ami', 's3', 'stack']}, 'cache': {'name': 'cache', # Redis server to cache cuboids 'type': 'redis'}, 'cachedb': {'type': 'stack'}, 'cachemanager': {'name': 'cachemanager', 'types': ['dns', 'ami']}, 'cache_session': {'name': 'cache-session', # Redis server for Django sessions 'type': 'redis'}, 'cache_state': {'name': 'cache-state', 'type': 'redis'}, 'cache_throttle': {'name': 'cache-throttle', 'types': ['redis', 'lambda_', 'cw']}, 'cloudwatch': {'type': 'stack'}, 'consul_monitor': {'name': 'consulMonitor', 'types': 'lambda_'}, 'copycuboid': {'type': 'stack'}, 'copy_cuboid_dlq': {'name': 'copyCuboidDlq', 'type': 'sqs'}, 'copy_cuboid_lambda': {'name': 'copyCuboidLambda', 'type': 'lambda_'}, 'core': {'type': 'stack'}, 'cuboid_bucket': {'name': 'cuboids', 'type': 's3'}, 'cuboid_import_dlq': {'name': 'cuboidImportDlq', 'type': 'sqs'}, 'cuboid_import_lambda': {'name': 'cuboidImportLambda', 'type': 'lambda_'}, 'deadletter': {'name': 'Deadletter', 'type': 'sqs'}, 'default': {'type': 'rt'}, 'delete_bucket': {'name': 'delete', 'type': 's3'}, 'delete_collection': {'name': 'Delete.Collection', 'type': 'sfn'}, 'delete_coord_frame': {'name': 'Delete.CoordFrame', 'type': 'sfn'}, 'delete_cuboid': {'name': 'Delete.Cuboid', 'type': 'sfn'}, 'delete_eni': {'name': 'deleteENI', 'type': 'lambda_'}, 'delete_event_rule': {'name': 'deleteEventRule', 'type': 'dns'}, # XXX: rule type? 'delete_experiment': {'name': 'Delete.Experiment', 'type': 'sfn'}, 'delete_tile_index_entry': {'name': 'deleteTileEntryLambda', 'type': 'lambda_'}, 'delete_tile_objs': {'name': 'deleteTileObjsLambda', 'type': 'lambda_'}, 'dns': {'types': ['sns', 'lambda_']}, # This is for failed lambda executions during a downsample. The failed # executions get placed in dead letter queues created for each downsample # job. Each job has a separate queue for each resolution. 'downsample_dlq': {'name': 'downsample-dlq', 'types': ['sns', 'lambda_']}, 'downsample_queue': {'name': 'downsampleQueue', 'types': ['sqs']}, 'downsample_volume': {'name': 'downsample.volume', 'type': 'lambda_'}, 'dynamolambda': {'type': 'stack'}, 'dynamo_lambda': {'name': 'dynamoLambda', 'type': 'lambda_'}, 'endpoint_db': {'name': 'endpoint-db', 'types': ['rds', 'dns']}, 'endpoint_elb': {'name': 'elb', 'type': 'dns'}, # XXX: elb type? 'endpoint': {'types': ['dns', 'ami']}, 'external': {'type': 'subnet'}, 'https': {'type': 'sg'}, 'id_count_index': {'name': 'idCount', 'type': 'ddb'}, 'id_index': {'name': 'idIndex', 'type': 'ddb'}, 'idindexing': {'type': 'stack'}, 'index_batch_enqueue_cuboids': {'name': 'indexBatchEnqueueCuboidsLambda', 'type': 'lambda_'}, 'index_check_for_throttling': {'name': 'indexCheckForThrottlingLambda', 'type': 'lambda_'}, 'index_cuboids_keys': {'name': 'cuboidsKeys', 'type': 'sqs'}, 'index_cuboid_supervisor': {'name': 'Index.CuboidSupervisor', 'type': 'sfn'}, 'index_deadletter': {'name': 'indexDeadLetter', 'type': 'sqs'}, 'index_dequeue_cuboid_keys': {'name': 'indexDequeueCuboidsLambda', 'type': 'lambda_'}, 'index_dequeue_cuboids': {'name': 'Index.DequeueCuboids', 'type': 'sfn'}, 'index_enqueue_cuboids': {'name': 'Index.EnqueueCuboids', 'type': 'sfn'}, 'index_fanout_dequeue_cuboid_keys': {'name': 'indexFanoutDequeueCuboidsKeysLambda', 'type': 'lambda_'}, 'index_fanout_dequeue_cuboids': {'name': 'Index.FanoutDequeueCuboids', 'type': 'sfn'}, 'index_fanout_enqueue_cuboid_keys': {'name': 'indexFanoutEnqueueCuboidsKeysLambda', 'type': 'lambda_'}, 'index_fanout_enqueue_cuboids': {'name': 'Index.FanoutEnqueueCuboids', 'type': 'sfn'}, 'index_fanout_id_writer': {'name': 'indexFanoutIdWriterLambda', 'type': 'lambda_'}, 'index_fanout_id_writers': {'name': 'Index.FanoutIdWriters', 'type': 'sfn'}, 'index_find_cuboids': {'name': 'indexFindCuboidsLambda', 'types': ['lambda_', 'sfn']}, 'index_get_num_cuboid_keys_msgs': {'name': 'indexGetNumCuboidKeysMsgsLambda', 'type': 'lambda_'}, 'index_id_writer': {'name': 'Index.IdWriter', 'type': 'sfn'}, 'index_invoke_index_supervisor': {'name': 'indexInvokeIndexSupervisorLambda', 'type': 'lambda_'}, 'index_load_ids_from_s3': {'name': 'indexLoadIdsFromS3Lambda', 'type': 'lambda_'}, 'index_s3_writer': {'name': 'indexS3WriterLambda', 'type': 'lambda_'}, 'index_split_cuboids': {'name': 'indexSplitCuboidsLambda', 'type': 'lambda_'}, 'index_supervisor': {'name': 'Index.Supervisor', 'type': 'sfn'}, 'index_write_failed': {'name': 'indexWriteFailedLambda', 'type': 'lambda_'}, 'index_write_id': {'name': 'indexWriteIdLambda', 'type': 'lambda_'}, 'ingest_bucket': {'name': 'ingest', # Cuboid staging area for volumetric ingests 'type': 's3'}, 'ingest_cleanup_dlq': {'name': 'IngestCleanupDlq', 'type': 'sqs'}, 'ingest_lambda': {'name': 'IngestUpload', 'type': 'lambda_'}, 'ingest_queue_populate': {'name': 'Ingest.Populate', 'type': 'sfn'}, 'ingest_queue_upload': {'name': 'Ingest.Upload', 'type': 'sfn'}, 'internal': {'types': ['subnet', 'sg', 'rt']}, 'internet': {'types': ['rt', 'gw']}, 'meta': {'name': 'bossmeta', 'type': 'ddb'}, 'multi_lambda': {'name': 'multiLambda', 'type': 'lambda_'}, 'query_deletes': {'name': 'Query.Deletes', 'type': 'sfn'}, 'redis': {'type': 'stack'}, 'resolution_hierarchy': {'name': 'Resolution.Hierarchy', 'type': 'sfn'}, 'complete_ingest': {'name': 'Ingest.CompleteIngest', 'type': 'sfn'}, 's3flush': {'name': 'S3flush', 'type': 'sqs'}, 's3_index': {'name': 's3index', 'type': 'ddb'}, 'ssh': {'type': 'sg'}, 'start_sfn': {'name': 'startSfnLambda', 'type': 'lambda_'}, 'test': {'type': 'stack'}, 'tile_bucket': {'name': 'tiles', 'type': 's3'}, 'tile_index': {'name': 'tileindex', 'type': 'ddb'}, 'tile_ingest': {'name': 'tileIngestLambda', 'type': 'lambda_'}, 'tile_uploaded': {'name': 'tileUploadLambda', 'type': 'lambda_'}, 'trigger_dynamo_autoscale': {'name': 'triggerDynamoAutoscale', 'type': 'cw'}, 'vault_check': {'name': 'checkVault', 'type': 'cw'}, 'vault_monitor': {'name': 'vaultMonitor', 'type': 'lambda_'}, 'vault': {'types': ['dns', 'ami', 'ddb', 'key']}, 'volumetric_ingest_queue_upload': {'name': 'Ingest.Volumetric.Upload', 'type': 'sfn'}, 'volumetric_ingest_queue_upload_lambda': {'name': 'VolumetricIngestUpload', 'type': 'lambda_'}, } def build(self, name, resource_type): if resource_type not in self.TYPES: raise AttributeError("'{}' is not a valid resource type".format(resource_type)) if name not in self.RESOURCES: raise AttributeError("'{}' is not a valid resource name".format(name)) cfg = self.RESOURCES[name] if resource_type != cfg.get('type') and \ resource_type not in cfg.get('types', []): raise AttributeError("'{}' is not a valid resource type for '{}'".format(resource_type, name)) name = cfg.get('name', name) if self.TYPES[resource_type] is False: return name elif resource_type == 'ami': if not self.ami_suffix: raise ValueError("ami_suffix not provided") return name + self.ami_suffix else: fqdn = name + '.' + self.internal_domain transform = self.TYPES[resource_type] if transform: fqdn = transform(fqdn) return fqdn
# -*- coding: utf-8 -*- def count_days(y, m, d): return (365 * y + (y // 4) - (y // 100) + (y // 400) + ((306 * (m + 1)) // 10) + d - 429) def main(): y = int(input()) m = int(input()) d = int(input()) if m == 1 or m == 2: m += 12 y -= 1 print(count_days(2014, 5, 17) - count_days(y, m, d)) if __name__ == '__main__': main()
class CausalFactor: def __init__(self, id_: int, name: str, description: str): self.id_ = id_ self.name = name self.description = description class VehicleCausalFactor: def __init__(self): self.cf_driver = [] self.cf_fellow_passenger = [] self.cf_vehicle = [] @property def cf_driver(self): return self.cf_driver @cf_driver.setter def cf_driver(self, value: CausalFactor): self.cf_driver.append(value) @property def cf_fellow_passenger(self): return self.cf_fellow_passenger @cf_fellow_passenger.setter def cf_fellow_passenger(self, value: CausalFactor): self.cf_fellow_passenger.append(value) @property def cf_vehicle(self): return self.cf_vehicle @cf_vehicle.setter def cf_vehicle(self, value: CausalFactor): self.cf_vehicle.append(value) class SubScenario: def __init__(self): self.id_ = None self.name = None self.description = None class Scenario: def __init__(self): self.id_ = None self.name = None self.description = None self.sub_scenarios: [SubScenario] = [] @property def id_(self): return self.id_ @id_.setter def id_(self, value: int): self.id_ = value @property def name(self): return self.name @name.setter def name(self, value: str): self.name = value @property def description(self): return self.description @description.setter def description(self, value: str): self.description = value @property def sub_scenarios(self): return self.sub_scenarios @sub_scenarios.setter def sub_scenarios(self, value): self.sub_scenarios.append(value) class VehicleSettings: def __init__(self): self.id_ = None self.vehicle_causal_factor_id = None self.vehicle_causal_factor_value = None self.vehicle_causal_factor_description = None self.driver_causal_factor_id = None self.driver_causal_factor_value = None self.driver_causal_factor_description = None self.fellow_passenger_causal_factor_id = None self.fellow_passenger_causal_factor_value = None self.fellow_passenger_causal_factor_description = None @property def vehicle_causal_factor_id(self): return self.vehicle_causal_factor_id @vehicle_causal_factor_id.setter def vehicle_causal_factor_id(self, value): self.vehicle_causal_factor_id = value @property def vehicle_causal_factor_value(self): return self.vehicle_causal_factor_value @vehicle_causal_factor_value.setter def vehicle_causal_factor_value(self, value): self.vehicle_causal_factor_value = value @property def vehicle_causal_factor_description(self): return self.vehicle_causal_factor_description @vehicle_causal_factor_description.setter def vehicle_causal_factor_description(self, value): self.vehicle_causal_factor_description = value @property def driver_causal_factor_id(self): return self.driver_causal_factor_id @driver_causal_factor_id.setter def driver_causal_factor_id(self, value): self.driver_causal_factor_id = value @property def driver_causal_factor_value(self): return self.driver_causal_factor_value @driver_causal_factor_value.setter def driver_causal_factor_value(self, value): self.driver_causal_factor_value = value @property def driver_causal_factor_description(self): return self.driver_causal_factor_description @driver_causal_factor_description.setter def driver_causal_factor_description(self, value): self.driver_causal_factor_description = value @property def fellow_passenger_causal_factor_id(self): return self.fellow_passenger_causal_factor_id @fellow_passenger_causal_factor_id.setter def fellow_passenger_causal_factor_id(self, value): self.fellow_passenger_causal_factor_id = value @property def fellow_passenger_causal_factor_value(self): return self.fellow_passenger_causal_factor_value @fellow_passenger_causal_factor_value.setter def fellow_passenger_causal_factor_value(self, value): self.fellow_passenger_causal_factor_value = value @property def fellow_passenger_causal_factor_description(self): return self.fellow_passenger_causal_factor_description @fellow_passenger_causal_factor_description.setter def fellow_passenger_causal_factor_description(self, value): self.fellow_passenger_causal_factor_description = value class Scenarios: def __init__(self): self.scenario: [Scenario] = [] self.ego_settings = [] self.vehicle_settings: [VehicleSettings] = [] self.passenger_settings = [] @property def scenario(self): return self.scenario @scenario.setter def scenario(self, value: Scenario): self.scenario.append(value) @property def vehicle_settings(self): return self.vehicle_settings @vehicle_settings.setter def vehicle_settings(self, value: VehicleSettings): self.vehicle_settings.append(value)
class Account: """ Class that generates new instances of account credentials to be stored. """ def __init__(self, acc_nm, acc_uname, acc_pass): self.acc_nm=acc_nm self.acc_uname=acc_uname self.acc_pass=acc_pass
class Solution: def numJewelsInStones(self, J: str, S: str) -> int: result = 0 for i in set(J): result += S.count(i) return result
int16gid = lambda n: '-'.join(['{:04x}'.format(n >> (i << 4) & 0xFFFF) for i in range(0, 1)[::-1]]) int32gid = lambda n: '-'.join(['{:04x}'.format(n >> (i << 4) & 0xFFFF) for i in range(0, 2)[::-1]]) int48gid = lambda n: '-'.join(['{:04x}'.format(n >> (i << 4) & 0xFFFF) for i in range(0, 3)[::-1]]) int64gid = lambda n: '-'.join(['{:04x}'.format(n >> (i << 4) & 0xFFFF) for i in range(0, 4)[::-1]]) int2did = lambda n: int64gid(n) int2did_short = lambda n: int48gid(n) int2fleet_id = lambda n: int48gid(n) int2pid = lambda n: int32gid(n) int2vid = lambda n: int16gid(n) int2bid = lambda n: int16gid(n) gid_split = lambda val: val.split('--') def gid_join(elements): return '--'.join(elements) def fix_gid(gid, num_terms): elements = gid.split('-') if len(elements) < num_terms: # Prepend '0000' as needed to get proper format (in groups of '0000') extras = ['0000' for i in range(num_terms - len(elements))] elements = extras + elements elif len(elements) > num_terms: # Only keep right most terms elements = elements[(len(elements) - num_terms):] return'-'.join(elements) def formatted_dbid(bid, did): """Formatted Global Data Block ID: d--<block>-<device>""" # The old Deviuce ID was 4 4-hex blocks, but the new is only three. Remove the left side block if needed device_id_parts = did.split('-') if (len(device_id_parts) == 4): device_id_parts = device_id_parts[1:] elif (len(device_id_parts) < 3): extras = ['0000' for i in range(3 - len(device_id_parts))] device_id_parts = extras + device_id_parts return gid_join(['b', '-'.join([bid,] + device_id_parts)]) def formatted_gpid(pid): pid = fix_gid(pid, 2) return gid_join(['p', pid]) def formatted_gdid(did, bid='0000'): """Formatted Global Device ID: d--0000-0000-0000-0001""" # ID should only map did = '-'.join([bid, fix_gid(did, 3)]) return gid_join(['d', did]) def formatted_gvid(pid, vid, is_template=False): """ Formatted Global Variable ID: v--0000-0001--5000 (or ptv--0000-0001-5000 for Project Teamplate Variables) """ pid = fix_gid(pid, 2) if is_template: return gid_join(['ptv', pid, vid]) return gid_join(['v', pid, vid]) def formatted_gsid(pid, did, vid): """Formatted Global Stream ID: s--0000-0001--0000-0000-0000-0001--5000""" pid = fix_gid(pid, 2) did = fix_gid(did, 4) return gid_join(['s', pid, did, vid]) def formatted_gfid(pid, did, vid): """ Formatted Global Filter ID: f--0000-0001--0000-0000-0000-0001--5000 or if no device: f--0000-0001----5000 """ pid = fix_gid(pid, 2) if did: did = fix_gid(did, 4) else: did = '' return gid_join(['f', pid, did, vid]) def formatted_gtid(did, index): """ Formatted Global Streamer ID: t--0000-0000-0000-0001--0001 """ did = fix_gid(did, 4) return gid_join(['t', did, index]) def formatted_alias_id(id): """Formatted Global Alias ID: a--0000-0000-0000-0001""" return gid_join(['a', fix_gid(id, 4)]) def formatted_fleet_id(id): """Formatted Global Fleet ID: g--0000-0000-0001""" return gid_join(['g', fix_gid(id, 3)]) def gid2int(gid): elements = gid.split('-') hex_value = ''.join(elements) return int(hex_value, 16) def get_vid_from_gvid(gvid): parts = gid_split(gvid) return parts[2] def get_device_and_block_by_did(gid): parts = gid_split(gid) if parts[0] == 'd' or parts[0] == 'b': elements = parts[1].split('-') block_hex_value = elements[0] device_hex_value = ''.join(elements[1:]) return int(block_hex_value, 16), int(device_hex_value, 16) else: return None, None def get_device_slug_by_block_slug(block_slug): parts = gid_split(block_slug) return gid_join(['d', parts[1]])
######################################################## # Copyright (c) 2015-2017 by European Commission. # # All Rights Reserved. # ######################################################## extends("BaseKPI.py") """ Welfare (euro) --------------- Indexed by * scope * delivery point * test case The welfare for a given delivery point is the sum of its consumer surplus, its producer surplus, the border exchange surplus and half of the congestion rent for power transmission lines connected to the delivery point: .. math:: \\small welfare_{scope, dp, tc} = consumerSurplus_{scope, dp, tc} + producerSurplus_{scope, dp, tc} + exchangeSurplus_{scope, dp, tc} + \\frac{1}{2} \\sum_{transmission\ t \\in dp} congestionRent_{scope, t, tc} """ def computeIndicator(context, indexFilter, paramsIndicator, kpiDict): selectedScopes = indexFilter.filterIndexList(0, getScopes()) selectedDeliveryPoints = indexFilter.filterIndexList(1, getDeliveryPoints(context)) selectedTestCases = indexFilter.filterIndexList(2, context.getResultsIndexSet()) productionAssetsByScope = getAssetsByScope(context, selectedScopes, includedTechnologies = PRODUCTION_TYPES) transmissionAssetsByScope = getAssetsByScope(context, selectedScopes, includedTechnologies = TRANSMISSION_TYPES) flexibleAssetsByScope = getAssetsByScope(context, selectedScopes, includedTechnologies = FLEXIBLE_EXPORT_TYPES|FLEXIBLE_IMPORT_TYPES) # All energies : filter on techno (and interface) only selectedEnergies = Crystal.listEnergies(context) marginalCostDict = getMarginalCostDict(context, selectedScopes, selectedTestCases, selectedEnergies, selectedDeliveryPoints) producerSurplusDict = getProducerSurplusDict(context, selectedScopes, selectedTestCases, selectedDeliveryPoints, productionAssetsByScope, aggregation=True) exchangeSurplusDict = getExchangeSurplusDict(context, selectedScopes, selectedTestCases, selectedEnergies, selectedDeliveryPoints, flexibleAssetsByScope, aggregation=True) consumerSurplusDict = getConsumerSurplus(context, selectedScopes, selectedTestCases, selectedEnergies, selectedDeliveryPoints) #Init for (scope, dpName, energy, testCase) in marginalCostDict: kpiDict[scope, dpName, testCase] = 0 #Congestion Rent congestionRentDict = getCongestionRentByDP(context, selectedScopes, selectedTestCases, selectedEnergies, selectedDeliveryPoints, transmissionAssetsByScope) for (scope, dpName, energy, testCase) in congestionRentDict: kpiDict[scope, dpName, testCase] += congestionRentDict[scope, dpName, energy, testCase].getSumValue() #Surplus for index in marginalCostDict: indexKpi = (index[0], index[1], index[3]) #Consumer if index in consumerSurplusDict: kpiDict[indexKpi] += consumerSurplusDict[index].getSumValue() #Exchanges if index in exchangeSurplusDict: kpiDict[indexKpi] += exchangeSurplusDict[index].getSumValue() for indexKpi in producerSurplusDict: #Producer kpiDict[indexKpi] += producerSurplusDict[indexKpi].getSumValue() return kpiDict def get_indexing(context) : baseIndexList = [getScopesIndexing(), getDeliveryPointsIndexing(context), getTestCasesIndexing(context)] return baseIndexList IndicatorLabel = "Welfare" IndicatorUnit = u"\u20ac" IndicatorDeltaUnit = u"\u20ac" IndicatorDescription = "Welfare attached to a delivery point" IndicatorParameters = [] IndicatorIcon = "" IndicatorCategory = "Results>Welfare" IndicatorTags = "Power System, Power Markets"
class Indent: def __init__(self, left: int = None, top: int = None, right: int = None, bottom: int = None): self.left = left self.top = top self.right = right self.bottom = bottom
"""Top-level package for Indonesia Name and Address Preprocessing.""" __author__ = """Esha Indra""" __email__ = '[email protected]' __version__ = '0.2.7'
drink = input() sugar = input() drinks_count = int(input()) if drink == "Espresso": if sugar == "Without": price = 0.90 elif sugar == "Normal": price = 1 elif sugar == "Extra": price = 1.20 elif drink == "Cappuccino": if sugar == "Without": price = 1 elif sugar == "Normal": price = 1.20 elif sugar == "Extra": price = 1.60 elif drink == "Tea": if sugar == "Without": price = 0.50 elif sugar == "Normal": price = 0.60 elif sugar == "Extra": price = 0.70 total_price = drinks_count * price if sugar == "Without": total_price -= total_price * 0.35 if drink == "Espresso": if drinks_count >= 5: total_price -= total_price * 0.25 if total_price > 15: total_price -= total_price * 0.2 print(f"You bought {drinks_count} cups of {drink} for {total_price:.2f} lv.")
n = int(input()) arr = [int(e) for e in input().split()] ans = 0 for i in arr: if i % 2 == 0: ans += i / 4 else: ans += i * 3 print("{:.1f}".format(ans))
def aumento(preco=0, taxa=0): r = preco + (preco * taxa/100) return r def diminuir(preco=0, taxa=0): r = preco - (preco * taxa/100) return r def dobro(preco=0): r = preco * 2 return r def metade(preco=0): r = preco / 2 return r def moeda(preço, moeda='R$'): return f'{moeda}{preço:>.2f}'.replace('.', ',')
# Copyright 2019 Nicholas Kroeker # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. class Error(Exception): """Base error class for all `bz.formo` exceptions.""" class TimeoutError(Error): """Raised when a Formo component experiences a timeout."""
# This exercise should be done in the interpreter # Create a variable and assign it the string value of your first name, # assign your age to another variable (you are free to lie!), print out a message saying how old you are name = "John" age = 21 print("my name is", name, "and I am", age, "years old.") # Use the addition operator to add 10 to your age and print out a message saying how old you will be in 10 years time age += 10 print(name, "will be", age, "in 10 years.")
""" 三切分快速排序 """ def swap(src, i, j): src[i], src[j] = src[j], src[i] def three_quick_sort(src, low, high): if low >= high: return lt = low gt = high val = src[low] i = low + 1 while i <= gt: if src[i] == val: i += 1 elif src[i] < val: swap(src, lt, i) lt += 1 i += 1 else: swap(src, gt, i) gt -= 1 print(src) print('-----------') three_quick_sort(src, low, lt - 1) three_quick_sort(src, gt + 1, high) if __name__ == '__main__': a = [4, 5, 2, 4, 6, 8, 3, 4, 51] three_quick_sort(a, 0, len(a) - 1) print(a)
def divide(num1, num2): try: num1 / num2 except Exception as e: print(e) divide(1, 0)
class Automation(object): def __init__(self, productivity, cost,numberOfAutomations, lifeSpan): # self.annualHours = annualHours self.productivity = float(productivity) self.cost = float(cost) self.lifeSpan = float(lifeSpan) self.numberOfAutomations = float(numberOfAutomations) # self.failureRate = failureRate # self.annualCost = annualCost def Production(self): return self.productivity def Cost(self): return self.cost def LifeSpan(self): return self.lifeSpan def NumberOfAutomations(self): return self.numberOfAutomations
# coding=utf-8 DBcsvName = 'houseinfo_readable_withXY' with open(DBcsvName + '.csv', 'r', encoding='UTF-8') as f: lines = f.readlines() print(lines[0]) with open(DBcsvName + '_correct.csv', 'w', encoding='UTF-8') as fw: fw.write( "houseID" + "," + "title" + "," + "link" + "," + "community" + "," + "years" + "," + "housetype" + "," + "square" + "," + "direction" + "," + "floor" + "," + "taxtype" + "," + "totalPrice" + "," + "unitPrice" + "," + "followInfo" + "," + "decoration" + "," + "validdate" + "," + "coor_x,y") fw.write('\n') i = 1 for line in lines: if i > 12000: exit(-1) if line.count(',') == 16: fw.write(line.strip() + '\n') print("count: " + str(i)) i = i + 1
class Node(): def __init__(self, val, left, right): self.val = val self.left = left self.right = right def collect(node, data, depth = 0): if not node: return None if depth not in data: data[depth] = [] data[depth].append(node.val) collect(node.left, data, depth + 1) collect(node.right, data, depth + 1) return None def avgByDepth(node): data = {} result = [] collect(node, data) i = 0 while i in data: nums = data[i] avg = sum(nums) / len(nums) result.append(avg) i += 1 return result n8 = Node(2, False, False) n7 = Node(6, n8, False) n6 = Node(6, False, False) n5 = Node(2, False, n7) n4 = Node(10, False, False) n3 = Node(9, n6, False) n2 = Node(7, n4, n5) n1 = Node(4, n2, n3) finalResult = avgByDepth(n1) print(finalResult)
ques=input('Do you wish to find the Volume of Cube by 2D Method or via Side Method? Please enter either 2D or Side') if ques=='2D': print ('OK.') ba=int(input('Enter the Base Area of the Cube')) Height=int(input('Enter a Height measure')) v=ba*Height print ('Volume of the Cube is', v) elif ques=='Side': print ('OK.') side=int(input('Enter the measure of the Side')) v=side**3 print ('Volume of the Cube is', v) else: exit()
#!/usr/bin/env python3 class Solution: def fizzBuzz(self, n: int): res = [] for i in range(1, n+1): if i % 15 == 0: res.append('FizzBuzz') elif i % 3 == 0: res.append('Fizz') elif i % 5 == 0: res.append('Buzz') else: res.append('{i}'.format(i=i)) return res sol = Solution() print(sol.fizzBuzz(3)) print(sol.fizzBuzz(15)) print(sol.fizzBuzz(1)) print(sol.fizzBuzz(0))
#!/usr/bin/python3 accesses = {} with open('download.log') as f: for line in f: splitted_line = line.split(',') if len(splitted_line) != 2: continue [file_path, ip_addr] = splitted_line if file_path not in accesses: accesses[file_path] = [] if ip_addr not in accesses[file_path]: accesses[file_path].append(ip_addr) for file_path, ip_addr in accesses.items(): print(file_path + " " + str(len(ip_addr)))
''' This module contains all the configurations needed by the modules in the etl package ''' # import os # from definitions import ROOT_DIR TRANSFORMED_DATA_DB_CONFIG = { 'user': 'root', 'password': 'xxxxxxxxxxxx', 'host': '35.244.x.xxx', 'port': 3306, 'database': 'transformed_data' # 'raise_on_warnings': True --> raises exceptions on warnings, ex: for drop if exists, because it causes warnings in MySQL }
file_name = input('Enter file name: ') fn = open(file_name) count = 0 for line in fn: words = line.strip().split() try: if words[0] == 'From': print(words[1]) count += 1 except IndexError: pass print(f'There were {count} lines in the file with From as the first word')
# -*- coding: utf-8 -*- class GeneratorRegister(object): def __init__(self): self.generators = [] def register(self, obj): self.generators.append(obj) def generate(self, command=None): for generator in self.generators: if command is not None and command.verbosity > 1: command.stdout.write('\nGenerating ' + generator.__class__.__name__ + ' ', ending='') command.stdout.flush() generator.generate(command) generator.done()
class CoOccurrence: def __init__(self, entity: str, score: float, entity_type: str = None): self.entity = entity self.score = score self.entity_type = entity_type def __repr__(self): return f'{self.entity} - {self.entity_type} ({self.score})' def as_dict(self): d = dict(entity=self.entity, score=self.score, entity_type=self.entity_type) return {k: v for k, v in d.items() if v is not None}
year = int(input()) if year % 4 == 0 and not (year % 100 == 0): print("Leap") else: if year % 400 == 0: print("Leap") else: print("Ordinary")
class ChatRoom: def __init__(self): self.people = [] def broadcast(self, source, message): for p in self.people: if p.name != source: p.receive(source, message) def join(self, person): join_msg = f'{person.name} joins the chat' self.broadcast('room', join_msg) person.room = self self.people.append(person) def message(self, source, destination, message): for p in self.people: if p.name == destination: p.receive(source, message)
class LinkedList: def __init__(self): self.head = None def insert(self, value): self.head = Node(value, self.head) def append(self, value): new_node = Node(value) current = self.head if current == None: self.head = new_node elif current.next == None: self.head.next = new_node elif current.next: while current.next: current = current.next current.next = new_node def insert_before(self, key, value): new_node = Node(value) current = self.head if current == None: return 'Key not found.' elif self.head.value == key: new_node.next = self.head self.head = new_node while current.next: if current.next.value == key: new_node.next = current.next current.next = new_node return return 'Key not found.' def insert_after(self, key, value): new_node = Node(value) current = self.head if current == None: return 'Key not found.' if self.head.value == key: new_node.next = self.head.next self.head.next = new_node while current: if current.value == key: new_node.next = current.next current.next = new_node return current = current.next return 'Key not found.' def includes(self, key): if self.head == None: return False current = self.head while True: if current.value == key: return True if current.next: current = current.next else: return False def kth_from_end(self, k): if k < 0: raise ValueError elif k == 0: return self.head.value counter = 0 result = self.head current = self.head while current: current = current.next if current: counter += 1 if counter > k: result = result.next if counter <= k: raise ValueError else: return result.value def __str__(self): if self.head == None: return 'This linked list is empty' result = '' current = self.head while True: if current.next: result += f'{current.value}' current = current.next else: return result + f'{current.value}' class Node: def __init__(self, value, next=None): self.value = value self.next = next
# # Explore # - The Adventure Interpreter # # Copyright (C) 2006 Joe Peterson # class ItemContainer: def __init__(self): self.items = [] self.item_limit = None def has_no_items(self): return len(self.items) == 0 def has_item(self, item): return item in self.items def is_full(self): if self.item_limit == None or len(self.items) < self.item_limit: return False else: return True def expand_item_name(self, item): if item in self.items: return item for test_item in self.items: word_list = test_item.split() if len(word_list) > 1: if word_list[0] == item or word_list[-1] == item: return test_item return item def add_item(self, item, mayExpand): if not self.is_full() or mayExpand: self.items.append(item) return True else: return False def remove_item(self, item): if item in self.items: self.items.remove(item) return True else: return False
#!/usr/bin/python3 a = sum(range(100)) print(a)
WINDOW_TITLE = "ElectriPy" HEIGHT = 750 WIDTH = 750 RESIZABLE = True FPS = 40 DEFAULT_FORCE_VECTOR_SCALE_FACTOR = 22e32 DEFAULT_EF_VECTOR_SCALE_FACTOR = 2e14 DEFAULT_EF_BRIGHTNESS = 105 DEFAULT_SPACE_BETWEEN_EF_VECTORS = 20 MINIMUM_FORCE_VECTOR_NORM = 10 MINIMUM_ELECTRIC_FIELD_VECTOR_NORM = 15 KEYS = { "clear_screen": "r", "show_vector_components": "space", "show_electric_forces_vectors": "f", "show_electric_field_at_mouse_position": "m", "show_electric_field": "e", "increment_electric_field_brightness": "+", "decrement_electric_field_brightness": "-", "remove_last_charge_added": "z", "add_last_charge_removed": "y", } # Text settings: CHARGES_SIGN_FONT = "Arial" PROTON_SIGN_FONT_SIZE = 23 ELECTRON_SIGN_FONT_SIZE = 35 VECTOR_COMPONENTS_FONT = "Arial" VECTOR_COMPONENTS_FONT_SIZE = 13
# Copyright (c) 2016-2022 Kirill 'Kolyat' Kiselnikov # This file is the part of chainsyn, released under modified MIT license # See the file LICENSE.txt included in this distribution """Module with various processing patterns""" # DNA patterns dna = 'ATCG' dna_to_dna = { 'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C' } dna_to_rna = { 'A': 'U', 'T': 'A', 'C': 'G', 'G': 'C' } # RNA patterns rna = 'AUCG' rna_to_dna = { 'A': 'T', 'U': 'A', 'C': 'G', 'G': 'C' } rna_to_abc = { # Phenylalanine 'UUU': 'F', 'UUC': 'F', # Leucine 'UUA': 'L', 'UUG': 'L', 'CUU': 'L', 'CUC': 'L', 'CUA': 'L', 'CUG': 'L', # Serine 'UCU': 'S', 'UCC': 'S', 'UCA': 'S', 'UCG': 'S', 'AGU': 'S', 'AGC': 'S', # Proline 'CCU': 'P', 'CCC': 'P', 'CCA': 'P', 'CCG': 'P', # Histidine 'CAU': 'H', 'CAC': 'H', # Glutamine 'CAA': 'Q', 'CAG': 'Q', # Tyrosine 'UAU': 'Y', 'UAC': 'Y', # Stop codons 'UAA': '*', 'UAG': '*', 'UGA': '*', # Cysteine 'UGU': 'C', 'UGC': 'C', # Tryptophan 'UGG': 'W', # Arginine 'CGU': 'R', 'CGC': 'R', 'CGA': 'R', 'CGG': 'R', 'AGA': 'R', 'AGG': 'R', # Isoleucine 'AUU': 'I', 'AUC': 'I', 'AUA': 'I', # Methionine 'AUG': 'M', # Threonine 'ACU': 'T', 'ACC': 'T', 'ACA': 'T', 'ACG': 'T', # Asparagine 'AAU': 'N', 'AAC': 'N', # Lysine 'AAA': 'K', 'AAG': 'K', # Valine 'GUU': 'V', 'GUC': 'V', 'GUA': 'V', 'GUG': 'V', # Alanine 'GCU': 'A', 'GCC': 'A', 'GCA': 'A', 'GCG': 'A', # Aspartate 'GAU': 'D', 'GAC': 'D', # Glutamate 'GAA': 'E', 'GAG': 'E', # Glycine 'GGU': 'G', 'GGC': 'G', 'GGA': 'G', 'GGG': 'G' } # ABC patterns (ABC is amino acid 'alphabet') abc = 'ARNDCQEGHILKMFPSTWYV' abc_mass = { 'A': 71.03711, 'C': 103.00919, 'D': 115.02694, 'E': 129.04259, 'F': 147.06841, 'G': 57.02146, 'H': 137.05891, 'I': 113.08406, 'K': 128.09496, 'L': 113.08406, 'M': 131.04049, 'N': 114.04293, 'P': 97.05276, 'Q': 128.05858, 'R': 156.10111, 'S': 87.03203, 'T': 101.04768, 'V': 99.06841, 'W': 186.07931, 'Y': 163.06333, '*': 0 } abc_to_rna = { 'A': ('GCU', 'GCC', 'GCA', 'GCG'), 'R': ('CGU', 'CGC', 'CGA', 'CGG', 'AGA', 'AGG'), 'N': ('AAU', 'AAC'), 'D': ('GAU', 'GAC'), 'C': ('UGU', 'UGC'), 'Q': ('CAA', 'CAG'), 'E': ('GAA', 'GAG'), 'G': ('GGU', 'GGC', 'GGA', 'GGG'), 'H': ('CAU', 'CAC'), 'I': ('AUU', 'AUC', 'AUA'), 'L': ('UUA', 'UUG', 'CUU', 'CUC', 'CUA', 'CUG'), 'K': ('AAA', 'AAG'), 'M': ('AUG',), 'F': ('UUU', 'UUC'), 'P': ('CCU', 'CCC', 'CCA', 'CCG'), 'S': ('UCU', 'UCC', 'UCA', 'UCG', 'AGU', 'AGC'), 'T': ('ACU', 'ACC', 'ACA', 'ACG'), 'W': ('UGG',), 'Y': ('UAU', 'UAC'), 'V': ('GUU', 'GUC', 'GUA', 'GUG'), '*': ('UAA', 'UGA', 'UAG') }
""" The present module contains functions meant to help handling file paths, which must be provided as pathlib.Path objects. Library Pathlib represents file extensions as lists of suffixes starting with a '.' and it defines a file stem as a file name without the last suffix. In this module, however, a stem is a file name without the extension. """ def extension_to_str(path): """ Pathlib represents file extensions as lists of suffixes starting with a '.'. This method concatenates the suffixes that make the extension of the given path. Args: path (pathlib.Path): the path whose extension is needed Returns: str: the path's extension as one string """ return "".join(path.suffixes) def get_file_stem(path): """ Provides the stem of the file that a path points to. A file stem is a file name without the extension. Args: path (pathlib.Path): the file path whose stem is needed Returns: str: the file's stem """ file_stem = path.name suffixes = path.suffixes if len(suffixes) > 0: exten_index = file_stem.index(suffixes[0]) file_stem = file_stem[:exten_index] return file_stem def make_altered_name(path, before_stem=None, after_stem=None, extension=None): """ Creates a file name by adding a string to the beginning and/or the end of a file path's stem and appending an extension to the new stem. If before_stem and after_stem are None, the new stem is identical to path's stem. This function does not change the given path. Use make_altered_stem instead if you do not want to append an extension. Args: path (pathlib.Path): the file path that provides the original name before_stem (str): the string to add to the beginning of the path's stem. If it is None, nothing is added to the stem's beginning. Defaults to None. after_stem (str): the string to add to the end of the path's stem. If it is None, nothing is added to the stem's end. Defaults to None. extension (str): the extension to append to the new stem in order to make the name. Each suffix must be such as those returned by pathlib.Path's property suffixes. If None, the extension of argument path is appended. Defaults to None. Returns: str: a new file name with the specified additions """ stem = make_altered_stem(path, before_stem, after_stem) if extension is None: name = stem + extension_to_str(path) else: name = stem + extension return name def make_altered_path(path, before_stem=None, after_stem=None, extension=None): """ Creates a file path by adding a string to the beginning and/or the end of a file path's stem and appending an extension to the new stem. If before_stem and after_stem are None, the new stem is identical to path's stem. This function does not change the given path. Args: path (pathlib.Path): the file path of which an altered form is needed before_stem (str): the string to add to the beginning of the path's stem. If it is None, nothing is added to the stem's beginning. Defaults to None. after_stem (str): the string to add to the end of the path's stem. If it is None, nothing is added to the stem's end. Defaults to None. extension (str): the extension to append to the new stem in order to make the name. Each suffix must be such as those returned by pathlib.Path's property suffixes. If None, the extension of argument path is appended. Defaults to None. Returns: pathlib.Path: a new file path with the specified additions """ name = make_altered_name(path, before_stem, after_stem, extension) return path.parents[0]/name def make_altered_stem(path, before_stem=None, after_stem=None): """ Creates a file stem by adding a string to the beginning and/or the end of a file path's stem. If before_stem and after_stem are None, the path's stem is returned. This function does not change the given path. Use make_altered_name instead to append an extension. Args: path (pathlib.Path): the file path that provides the original stem before_stem (str): the string to add to the beginning of the path's stem. If it is None, nothing is added to the stem's beginning. Defaults to None. after_stem (str): the string to add to the end of the path's stem. If it is None, nothing is added to the stem's end. Defaults to None. Returns: str: a new file stem with the specified additions """ stem = get_file_stem(path) if before_stem is not None: stem = before_stem + stem if after_stem is not None: stem += after_stem return stem
# coding: utf-8 GROUP_RESPONSE = { "result": [ { "poll_type": "group_message", "value": { "content": [ [ "font", { "color": "000000", "name": "微软雅黑", "size": 10, "style": [0, 0, 0] } ], "赶快十条消息啊宝特", ], "from_uin": 2346434842, "group_code": 2346434842, "msg_id": 29820, "msg_type": 0, "send_uin": 3938506981, "time": 1458377223, "to_uin": 3155411624 } } ], "retcode": 0 }
# Multiples of 3 and 5 # Problem 1 # If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. # The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000 def solution(limit): s = 0 for x in range(1, limit): if x % 3 == 0: s = s + x elif x % 5 == 0: s = s + x return s def main(): limit = 1000 ans = solution(limit) print(ans) if __name__ == "__main__": main()
""" This question was asked by Zillow. You are given a 2-d matrix where each cell represents number of coins in that cell. Assuming we start at matrix[0][0], and can only move right or down, find the maximum number of coins you can collect by the bottom right corner. For example, in this matrix 0 3 1 1 2 0 0 4 1 5 3 1 The most we can collect is 0 + 2 + 1 + 5 + 3 + 1 = 12 coins. """ def collect_max_coins(matrix): def helper(row=0, col=0, curr_sum=0): if row>=len(matrix) or col>=len(matrix[0]): return 0 if row==len(matrix)-1 and col == len(matrix[0])-1: return curr_sum+matrix[row][col] return max(helper(row+1, col, curr_sum+matrix[row][col]), helper(row, col+1, curr_sum+matrix[row][col])) return helper() if __name__ == '__main__': matrix = [ [0, 3, 1, 1], [2, 0, 0, 4], [1, 5, 3, 1] ] print(collect_max_coins(matrix))
class Index: def set_index(self, index_name): self.index = index_name def mapping(self): return { self.doc_type:{ "properties":self.properties() } } def analysis(self): return { 'filter':{ 'spanish_stop':{ 'type':'stop', 'stopwords':'_spanish_', }, 'spanish_stemmer':{ 'type':'stemmer', 'language':'light_spanish' } }, 'analyzer':{ 'default':{ 'tokenizer':'standard', 'filter':[ 'lowercase', 'asciifolding', 'spanish_stemmer', 'spanish_stop' ] } } } class EventIndex(Index): index = "events" doc_type = "doc" def properties(self): props = { "id": { "type": "integer" }, "email": { "type": "keyword" }, "timestamp": { "type": "date", "format": "epoch_millis"}, } return props
""" A dictionary for enumering all stages of sleep """ SLEEP_STAGES = { 'LIGHT': 'LIGHT', 'DEEP': 'DEEP', 'REM': 'REM' } """ A dictionary for setting the mimimum known duration for the sleep stages """ MIN_STAGE_DURATION = { 'LIGHT': 15, 'DEEP': 30, 'REM': 8 } """ Topics we are subscribing/publishing to """ TOPIC = { 'START_TO_SLEEP' : "SmartSleep/StartSleeping", 'HEARTRATE': "SmartSleep/Heartrate" } """ A dictionary having the following format: age: [minimum hours of sleep, maximum hours of sleep] """ SLEEP_NEEDED = { '3': (10, 14), '5': (10, 13), '12': (9, 12), '18': (8, 10), '60': (7, 9), '100': (7, 8) }
''' Encontrar el valor repetido de ''' lista =[1,2,2,3,1,5,6,1] for number in lista: if lista.count(number) > 1: i = lista.index(number) print(i) lista_dos = ["a", "b", "a", "c", "c"] mylist = list(dict.fromkeys(lista_dos)) print(mylist) print("*"*10)
# 969. Pancake Sorting class Solution: def pancakeSort2(self, A): ans, n = [], len(A) B = sorted(range(1, n+1), key=lambda i: -A[i-1]) for i in B: for f in ans: if i <= f: i = f + 1 - i ans.extend([i, n]) n -= 1 return ans def pancakeSort(self, A): res = [] for x in range(len(A), 1, -1): i = A.index(x) res.extend([i+1, x]) A = A[:i:-1] + A[:i] return res sol = Solution() print(sol.pancakeSort2([3,2,4,1]))
## Logging logging_config = { 'console_log_enabled': True, 'console_log_level': 25, # SPECIAL 'console_fmt': '[%(asctime)s] %(message)s', 'console_datefmt': '%y-%m-%d %H:%M:%S', ## 'file_log_enabled': True, 'file_log_level': 15, # VERBOSE 'file_fmt': '%(asctime)s %(levelname)-8s %(name)s: %(message)s', 'file_datefmt': '%y-%m-%d %H:%M:%S', 'log_dir': 'logs', 'log_file': 'psict_{:%y%m%d_%H%M%S}', } ## Parameter value pre-processing and conversion parameter_pre_process = { "SQPG": { "pulse": { "o": { # Actual channel number is 1 more than the Labber lookup table specification 1: 0, 2: 1, 3: 2, 4: 3, }, # end o (Output) }, # end pulse }, # end SQPG } ## Iteration permissions outfile_iter_automatic = True outfile_iter_user_check = True ## Post-measurement script copy options script_copy_enabled = True # Copy the measurement script to the specified target directory script_copy_postfix = '_script' # postfixed to the script name after copying
# coding:utf-8 ''' @Copyright:LintCode @Author: taoleetju @Problem: http://www.lintcode.com/problem/find-minimum-in-rotated-sorted-array @Language: Python @Datetime: 15-12-14 03:26 ''' class Solution: # @param num: a rotated sorted array # @return: the minimum number in the array def findMin(self, num): p1 = 0 p2 = len(num)-1 pm = p1 while( num[p1] >= num[p2] ): if (p2 - p1) == 1: pm = p2 break else: pm = (p1+p2)/2 if num[pm] >= num[p1]: p1 = pm else: p2 = pm return num[pm]
nume1 = (input("Digite um numero")) nume2 = (input("Digite um numero")) nume3 = (input("Digite um numero")) nume4 = (input("Digite um numero")) nume5 = (input("Digite um numero")) lista_nova =[nume1,nume2,nume3,nume4,nume5] print("Sua lista ordenada numérica: ", sorted(lista_nova))
"""Kata: Fibonacci's FizzBuzz - return a list of the fibonacci sequence with the words 'Fizz', 'Buzz', and 'FizzBuzz' replacing certain integers. #1 Best Practices Solution by damjan. def fibs_fizz_buzz(n): a, b, out = 0, 1, [] for i in range(n): s = "Fizz"*(b % 3 == 0) + "Buzz"*(b % 5 == 0) out.append(s if s else b) a, b = b, a+b return out """ def fibs_fizz_buzz(n): seq = [1, 1] x = 2 if n == 1: return [1] while x <= n - 1: seq.append(seq[x - 1] + seq[x - 2]) x += 1 for idx, i in enumerate(seq): if i % 3 == 0 and i % 5 == 0: seq[idx] = 'FizzBuzz' elif i % 3 == 0: seq[idx] = 'Fizz' elif i % 5 == 0: seq[idx] = 'Buzz' return seq
# These constants are all possible fields in a message. ADDRESS_FAMILY = 'address_family' ADDRESS_FAMILY_IPv4 = 'ipv4' ADDRESS_FAMILY_IPv6 = 'ipv6' CITY = 'city' COUNTRY = 'country' RESPONSE_FORMAT = 'format' FORMAT_HTML = 'html' FORMAT_JSON = 'json' FORMAT_MAP = 'map' FORMAT_REDIRECT = 'redirect' FORMAT_BT = 'bt' VALID_FORMATS = [FORMAT_HTML, FORMAT_JSON, FORMAT_MAP, FORMAT_REDIRECT, FORMAT_BT] DEFAULT_RESPONSE_FORMAT = FORMAT_JSON HEADER_CITY = 'X-AppEngine-City' HEADER_COUNTRY = 'X-AppEngine-Country' HEADER_LAT_LONG = 'X-AppEngine-CityLatLong' LATITUDE = 'lat' LONGITUDE = 'lon' METRO = 'metro' POLICY = 'policy' POLICY_GEO = 'geo' POLICY_GEO_OPTIONS = 'geo_options' POLICY_METRO = 'metro' POLICY_RANDOM = 'random' POLICY_COUNTRY = 'country' POLICY_ALL = 'all' REMOTE_ADDRESS = 'ip' NO_IP_ADDRESS = 'off' STATUS = 'status' STATUS_IPv4 = 'status_ipv4' STATUS_IPv6 = 'status_ipv6' STATUS_OFFLINE = 'offline' STATUS_ONLINE = 'online' URL = 'url' USER_AGENT = 'User-Agent'
def f(): x = 5 def g(y): print (x + y) g(1) x = 6 g(1) x = 7 g(1) f()
# Python program to insert, delete and search in binary search tree using linked lists # A Binary Tree Node class Node: # Constructor to create a new node def __init__(self, key): self.key = key self.left = None self.right = None # A utility function to do inorder traversal of BST def inorder(root): if root is not None: inorder(root.left) print(root.key, end=', ') inorder(root.right) # A utility function to insert a # new node with given key in BST def insert(node, key): # If the tree is empty, return a new node if node is None: return Node(key) # Otherwise recur down the tree if key < node.key: node.left = insert(node.left, key) else: node.right = insert(node.right, key) # return the (unchanged) node pointer return node # Given a non-empty binary # search tree, return the node # with maximun key value # found in that tree. Note that the # entire tree does not need to be searched def maxValueNode(node): current = node # loop down to find the rightmost leaf while(current.right is not None): current = current.right return current # Given a binary search tree and a key, this function # delete the key and returns the new root def deleteNode(root, key): # Base Case if root is None: return root # If the key to be deleted # is smaller than the root's # key then it lies in left subtree if key < root.key: root.left = deleteNode(root.left, key) # If the kye to be delete # is greater than the root's key # then it lies in right subtree elif(key > root.key): root.right = deleteNode(root.right, key) # If key is same as root's key, then this is the node # to be deleted else: # Node with only one child or no child if root.left is None: temp = root.right root = None return temp elif root.right is None: temp = root.left root = None return temp # Node with two children: # Get the inorder predecessor # (largest in the left subtree) temp = maxValueNode(root.left) # Copy the inorder predecessor's # content to this node root.key = temp.key # Delete the inorder predecessor root.left = deleteNode(root.left, temp.key) return root # Given a binary search tree and a key, this function # returns whether the key exists in the tree or not def searchNode(root, key): if key == root.key: return True elif root.right == None and root.left == None: return False elif key > root.key and root.right != None: return searchNode(root.right, key) elif key < root.key and root.left != None: return searchNode(root.left, key) return False # Driver code # Lets create tree: # 4 # / \ # 2 6 # / \ / \ # 0 3 5 10 # / \ # 8 12 # / \ # 7 9 root = None root = insert(root, 4) root = insert(root, 2) root = insert(root, 6) root = insert(root, 10) root = insert(root, 8) root = insert(root, 0) root = insert(root, 3) root = insert(root, 5) root = insert(root, 7) root = insert(root, 9) root = insert(root, 12) print("Inorder traversal of the given tree") inorder(root) print("\nDelete 2") root = deleteNode(root, 2) print("Inorder traversal of the modified tree") inorder(root) print("\nDelete 3") root = deleteNode(root, 3) print("Inorder traversal of the modified tree") inorder(root) print("\nDelete 10") root = deleteNode(root, 10) print("Inorder traversal of the modified tree") inorder(root) print("\n12 exists in bst? : ", searchNode(root, 12)) # Output: # Inorder traversal of the given tree # 0, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, # Delete 2 # Inorder traversal of the modified tree # 0, 3, 4, 5, 6, 7, 8, 9, 10, 12, # Delete 3 # Inorder traversal of the modified tree # 0, 4, 5, 6, 7, 8, 9, 10, 12, # Delete 10 # Inorder traversal of the modified tree # 0, 4, 5, 6, 7, 8, 9, 12, # 12 exists in bst? : True
def keyword_argument_example(your_age, **kwargs): return your_age, kwargs ### Write your code below this line ### about_me = "Replace this string with the correct function call." ### Write your code above this line ### print(about_me)
s = 'Python is the most powerful language' words = s.split() print(words) # numbers = input().split() # 1 2 3 4 5 # for i in range(len(numbers)): # numbers[i] = int(numbers[i]) # print(numbers) ip = '192.168.1.24' numbers = ip.split('.') # указываем явно разделитель print(numbers) words = ['Python', 'is', 'the', 'most', 'powerful', 'language'] s = ' '.join(words) print(s) words = ['Мы', 'учим', 'язык', 'Python'] print('*'.join(words)) print('-'.join(words)) print('?'.join(words)) print('!'.join(words)) print('*****'.join(words)) print('abc'.join(words)) print('123'.join(words)) s = 'Python is the most powerful language' words1 = s.split() words2 = s.split(' ') print(words1) print(words2) # из комментариев n = [1, 2, 3] x = ''.join(str(i) for i in n) # при необходимости добавить список интов. print(x) # 123
""" Version management system. """ class Version: clsPrev = None #`Version` class that represents the previous version of `self`, or `None` if there is no previous `Version`. def __init__(self): pass def _initialize(self, obj): """ Initializes `obj` to match this version from scratch. `obj` may be modified in place, but regardless will be returned. By default, this will invoke `clsPrev._initialize` and use `self.update` to bring it to this version. However, subclasses may override this to initialize to a later version. """ if self.clsPrev is None: raise NotImplementedError() obj = self.clsPrev()._initialize(obj) return self.update(obj) def matches(self, obj): """ Returns `True` if `obj` matches this `Version`. """ return False def update(self, obj): """ Updates `obj` from a previous `Version` to this `Version`. `obj` may be modified in place, but regardless will be returned. """ v = self.version(obj) if v is self.__class__: #No update necessary. pass elif v is None: #Build from scratch. obj = self._initialize(obj) elif clsPrev is not None: obj = self.clsPrev().update(obj) obj = self._update(obj) assert self.matches(obj) return obj #Object def _update(self, obj): """ Internal implementation to be overridden by subclasses. Only gets called once `obj` is the same version as `self._prev`. `obj` may be modified in place, but regardless should be returned. """ raise NotImplementedError() def version(self, obj): """ Returns the `Version` matching `obj`, or `None` if no match was found. """ if self.matches(obj): return self.__class__ if self.clsPrev is None: return None return self.clsPrev().version(obj)