content
stringlengths
7
1.05M
''' 2 film olucak %50 şanslı İlk filmin 50 kışlık yeri ikincinin 80 kişilik yeri var İlkinin bileti 5 TL İkinci 14 TL İlk gişe Her 10 kişide ilkinin bileti %6 pahalanıyor ama 20 kişide bir %40 ücretsiz bilet şansı İkinci gişe Her 10 bilette %4 pahalanıyor ama 6 bilette bir %50 şansla menü kazanıyorsun (12tl gider artışı) Üstüne satılan bilet no ilk gisedeki biletin karesi ise 2 kat pahalı olmalı En sonda toplam kâr zarar ve istatistikler paylaşılsın printlensin ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- 130 kişi 14ten 1380TL 5ten 650TL '''
"""https://github.com/biocommons/hgvs/issues/525""" def test_525(parser, am38): """https://github.com/biocommons/hgvs/issues/525""" # simple test case hgvs = "NM_000551.3:c.3_4insTAG" # insert stop in phase at AA 2 var_c = parser.parse_hgvs_variant(hgvs) var_p = am38.c_to_p(var_c) assert str(var_p) == "NP_000542.1:p.(Pro2Ter)" # variant reported in issue hgvs = "NM_001256125.1:c.1015_1016insAGGGACTGGGCGGGGCCATGGTCT" var_c = parser.parse_hgvs_variant(hgvs) var_p = am38.c_to_p(var_c) assert str(var_p) == "NP_001243054.2:p.(Trp339Ter)"
description = 'Slit ZB0 using Beckhoff controllers' group = 'lowlevel' includes = ['zz_absoluts'] instrument_values = configdata('instrument.values') showcase_values = configdata('cf_showcase.showcase_values') optic_values = configdata('cf_optic.optic_values') tango_base = instrument_values['tango_base'] code_base = instrument_values['code_base'] index = 4 devices = dict( # zb0_a = device('nicos.devices.generic.Axis', # description = 'zb0 axis', # motor = 'zb0_motor', # precision = 0.02, # maxtries = 3, # lowlevel = True, # ), zb0 = device(code_base + 'slits.SingleSlit', # length: 13 mm description = 'zb0, singleslit', motor = 'zb0_motor', nok_start = 4121.5, nok_end = 4134.5, nok_gap = 1, masks = { 'slit': 0, 'point': 0, 'gisans': -110 * optic_values['gisans_scale'], }, unit = 'mm', ), # zb0_temp = device(code_base + 'beckhoff.nok.BeckhoffTemp', # description = 'Temperatur for ZB0 Motor', # tangodevice = tango_base + 'optic/io/modbus', # address = 0x3020+index*10, # word address # abslimits = (-1000, 1000), # lowlevel = showcase_values['hide_temp'], # ), # zb0_analog = device(code_base + 'beckhoff.nok.BeckhoffPoti', # description = 'Poti for ZB0 no ref', # tangodevice = tango_base + 'optic/io/modbus', # address = 0x3020+index*10, # word address # abslimits = (-1000, 1000), # poly = [-176.49512271969755, 0.00794154091586989], # lowlevel = True or showcase_values['hide_poti'], # ), # zb0_acc = device(code_base + 'nok_support.MotorEncoderDifference', # description = 'calc error Motor and poti', # motor = 'zb0_motor', # analog = 'zb0_analog', # lowlevel = True or showcase_values['hide_acc'], # unit = 'mm' # ), )
# Given an integer n, return true if it is possible to represent n as the sum of distinct powers of three. Otherwise, return false. # An integer y is a power of three if there exists an integer x such that y == 3x. def checkPowersOfThree(n): while n > 0: if n % 3 > 1: return False n //= 3 return True print(checkPowersOfThree(12)) print(checkPowersOfThree(21)) print(checkPowersOfThree(91)) print(checkPowersOfThree(100))
#!/usr/bin/python3.4 # -*- coding: utf-8 -*- """ This app calculates the accuracy of shots on goal in football Author: Alexander A. Laurence Last modified: January 2019 Website: www.celestial.tokyo """ # number of shots that didn't hit the goal shots_offTarget = input("How many shots did not hit the target? ") print("Ok, so %s shots failed to the target." % shots_offTarget) # number of shots that hit the goal shots_onTarget = input("How many shots hit the target? ") print("Ok, so %s shots hit the target." % shots_offTarget) # the percentage accuracy shot_accuracy = (shots_onTarget / (shots_onTarget + shots_offTarget))*100 print("That means your shot accuracy was %s." % shot_accuracy)
""" # Implementation of all_keys function. * It will return all the keys present in the object. * It will also return the nested keys at all levels. """ __all__ = ["all_keys"] def _recursive_items(dictionary): """This function will accept the dictionary and iterate over it and yield all the keys Args: dictionary (dict): dictionary to iterate Yields: string: key in dictionary object. """ for key, value in dictionary.items(): yield key if isinstance(value, dict): yield from _recursive_items(value) elif isinstance(value, list): for item in value: if isinstance(item, dict): yield from _recursive_items(item) else: yield key def all_keys(obj): """This function will accept one param and return all keys * It will return all the keys in the object Args: obj (dict): dictionary object Returns: set: set of all the keys """ key_from_obj = set() for key in _recursive_items(dictionary=obj): key_from_obj.add(key) return key_from_obj
def longest_increasing_subsequency(l: List) -> int: result = end = 0 for i in range(len(l)): if i > 0 and l[i - 1] >= l[i]: end = i result = max(result, i - end+1) return result print(longest_increasing_subsequency([3,5,7,2,1])) print(longest_increasing_subsequency([2,2,2,2])) print(longest_increasing_subsequency([])) print(longest_increasing_subsequency([2,2,3,4,4]))
""" Created on 3 Mar. 2018 @author: oliver """ class LineClassifier(object): """ classdocs """ def __init__(self, classification_description, line_collection): """ Constructor """ self._descr = classification_description self._collection = line_collection def classify_file(self, f): assert f or not f
train_data_path = "data/chunked/train/train_*" valid_data_path = "data/chunked/valid/valid_*" test_data_path = "data/chunked/test/test_*" vocab_path = "data/vocab" # Hyperparameters hidden_dim = 512 emb_dim = 256 batch_size = 200 max_enc_steps = 55 #99% of the articles are within length 55 max_dec_steps = 15 #99% of the titles are within length 15 beam_size = 4 min_dec_steps= 3 vocab_size = 50000 lr = 0.001 rand_unif_init_mag = 0.02 trunc_norm_init_std = 1e-4 eps = 1e-12 max_iterations = 500000 save_model_path = "data/saved_models" intra_encoder = True intra_decoder = True
""" Write a program to solve the following problem: You have two jugs: a 4-gallon jug and a 3-gallon jug. Neither of the jugs have markings on them. There is a pump that can be used to fill the jugs with water. How can you get exactly two gallons of water in the 4-gallon jug? """ def recursive_jugs(big_jug, little_jug, amt): """Displays how to get amt when given a big jug and little jug without markings :big_jug: TODO :little_jug: TODO :amt: TODO :returns: TODO """ if little_jug == amt: print(f"Little jug:{little_jug} equals target:{amt}") return "Dump big jug and fill with remainder in little jug" else: print("Dump big jug") print("Fill big jug with little jug") big = little_jug print(f"Big jug:{big}") print("Refill little jug and put into big jug") little = little_jug - (big_jug % little_jug) # big = big_jug print(f"Little jug:{little}") return recursive_jugs(big, little, amt) if __name__ == "__main__": print(recursive_jugs(4, 3, 2))
#!/usr/bin/env python3 #coding:utf-8 class LNode(object): def __init__(self, x=None): self.val = x self.next = None def intersect(head1, head2): """ 方法功能:判断两个无环链表是否相交,若相交,则找出该结点 输入参数:head1 与 head2 分别为两个链表的头结点 返回值:若相交,返回该结点;若不相交,则返回 None """ if head1 is None or head1.next is None or head2 is None or head2.next is None: return None set_hash = set() cur = head1.next while cur: set_hash.add(cur) cur = cur.next cur = head2.next while cur: if cur in set_hash: return cur cur = cur.next return None def constructLinkedList(nums): """ 方法功能:创建单链表 输入参数:nums: 作为链表结点的数据 返回值:head: 链表头结点;tail: 链表尾结点 """ head = LNode() cur = head for num in nums: tmp = LNode() tmp.val = num cur.next = tmp cur = tmp tail = cur return head, tail # 直接返回 (head, cur) 也行,不过这样直观一点 def printLinkedList(head): """ 打印单链表 """ print("head->", end='') cur = head.next while cur: print(cur.val, end="->") cur = cur.next print("None") return None if __name__ == "__main__": head1, tail1 = constructLinkedList([1, 2, 3, 4]) head2, tail2 = constructLinkedList([5, 6, 7]) head3, tail3 = constructLinkedList([8, 9, 10]) # tail3 没有用 tail1.next = head3.next tail2.next = head3.next print("head1:", end=' ') printLinkedList(head1) print("\nhead2:", end=' ') printLinkedList(head2) """ head1->1->2->3->4 \ ->8->9->10->None / head2->5->6->7- """ ans = intersect(head1, head2) if ans: print(f"Two linked lists cross. The intersection value is {ans.val}.") else: print("non-intersect!")
# from https://github.com/pyca/bcrypt/blob/3.1.7/tests/test_bcrypt.py # # Copyright 2013 Donald Stufft # # 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. [ ( b"Kk4DQuMMfZL9o", b"$2b$04$cVWp4XaNU8a4v1uMRum2SO", b"$2b$04$cVWp4XaNU8a4v1uMRum2SO026BWLIoQMD/TXg5uZV.0P.uO8m3YEm", ), ( b"9IeRXmnGxMYbs", b"$2b$04$pQ7gRO7e6wx/936oXhNjrO", b"$2b$04$pQ7gRO7e6wx/936oXhNjrOUNOHL1D0h1N2IDbJZYs.1ppzSof6SPy", ), ( b"xVQVbwa1S0M8r", b"$2b$04$SQe9knOzepOVKoYXo9xTte", b"$2b$04$SQe9knOzepOVKoYXo9xTteNYr6MBwVz4tpriJVe3PNgYufGIsgKcW", ), ( b"Zfgr26LWd22Za", b"$2b$04$eH8zX.q5Q.j2hO1NkVYJQO", b"$2b$04$eH8zX.q5Q.j2hO1NkVYJQOM6KxntS/ow3.YzVmFrE4t//CoF4fvne", ), ( b"Tg4daC27epFBE", b"$2b$04$ahiTdwRXpUG2JLRcIznxc.", b"$2b$04$ahiTdwRXpUG2JLRcIznxc.s1.ydaPGD372bsGs8NqyYjLY1inG5n2", ), ( b"xhQPMmwh5ALzW", b"$2b$04$nQn78dV0hGHf5wUBe0zOFu", b"$2b$04$nQn78dV0hGHf5wUBe0zOFu8n07ZbWWOKoGasZKRspZxtt.vBRNMIy", ), ( b"59je8h5Gj71tg", b"$2b$04$cvXudZ5ugTg95W.rOjMITu", b"$2b$04$cvXudZ5ugTg95W.rOjMITuM1jC0piCl3zF5cmGhzCibHZrNHkmckG", ), ( b"wT4fHJa2N9WSW", b"$2b$04$YYjtiq4Uh88yUsExO0RNTu", b"$2b$04$YYjtiq4Uh88yUsExO0RNTuEJ.tZlsONac16A8OcLHleWFjVawfGvO", ), ( b"uSgFRnQdOgm4S", b"$2b$04$WLTjgY/pZSyqX/fbMbJzf.", b"$2b$04$WLTjgY/pZSyqX/fbMbJzf.qxCeTMQOzgL.CimRjMHtMxd/VGKojMu", ), ( b"tEPtJZXur16Vg", b"$2b$04$2moPs/x/wnCfeQ5pCheMcu", b"$2b$04$2moPs/x/wnCfeQ5pCheMcuSJQ/KYjOZG780UjA/SiR.KsYWNrC7SG", ), ( b"vvho8C6nlVf9K", b"$2b$04$HrEYC/AQ2HS77G78cQDZQ.", b"$2b$04$HrEYC/AQ2HS77G78cQDZQ.r44WGcruKw03KHlnp71yVQEwpsi3xl2", ), ( b"5auCCY9by0Ruf", b"$2b$04$vVYgSTfB8KVbmhbZE/k3R.", b"$2b$04$vVYgSTfB8KVbmhbZE/k3R.ux9A0lJUM4CZwCkHI9fifke2.rTF7MG", ), ( b"GtTkR6qn2QOZW", b"$2b$04$JfoNrR8.doieoI8..F.C1O", b"$2b$04$JfoNrR8.doieoI8..F.C1OQgwE3uTeuardy6lw0AjALUzOARoyf2m", ), ( b"zKo8vdFSnjX0f", b"$2b$04$HP3I0PUs7KBEzMBNFw7o3O", b"$2b$04$HP3I0PUs7KBEzMBNFw7o3O7f/uxaZU7aaDot1quHMgB2yrwBXsgyy", ), ( b"I9VfYlacJiwiK", b"$2b$04$xnFVhJsTzsFBTeP3PpgbMe", b"$2b$04$xnFVhJsTzsFBTeP3PpgbMeMREb6rdKV9faW54Sx.yg9plf4jY8qT6", ), ( b"VFPO7YXnHQbQO", b"$2b$04$WQp9.igoLqVr6Qk70mz6xu", b"$2b$04$WQp9.igoLqVr6Qk70mz6xuRxE0RttVXXdukpR9N54x17ecad34ZF6", ), ( b"VDx5BdxfxstYk", b"$2b$04$xgZtlonpAHSU/njOCdKztO", b"$2b$04$xgZtlonpAHSU/njOCdKztOPuPFzCNVpB4LGicO4/OGgHv.uKHkwsS", ), ( b"dEe6XfVGrrfSH", b"$2b$04$2Siw3Nv3Q/gTOIPetAyPr.", b"$2b$04$2Siw3Nv3Q/gTOIPetAyPr.GNj3aO0lb1E5E9UumYGKjP9BYqlNWJe", ), ( b"cTT0EAFdwJiLn", b"$2b$04$7/Qj7Kd8BcSahPO4khB8me", b"$2b$04$7/Qj7Kd8BcSahPO4khB8me4ssDJCW3r4OGYqPF87jxtrSyPj5cS5m", ), ( b"J8eHUDuxBB520", b"$2b$04$VvlCUKbTMjaxaYJ.k5juoe", b"$2b$04$VvlCUKbTMjaxaYJ.k5juoecpG/7IzcH1AkmqKi.lIZMVIOLClWAk.", ), ( b"U*U", b"$2a$05$CCCCCCCCCCCCCCCCCCCCC.", b"$2a$05$CCCCCCCCCCCCCCCCCCCCC.E5YPO9kmyuRGyh0XouQYb4YMJKvyOeW", ), ( b"U*U*", b"$2a$05$CCCCCCCCCCCCCCCCCCCCC.", b"$2a$05$CCCCCCCCCCCCCCCCCCCCC.VGOzA784oUp/Z0DY336zx7pLYAy0lwK", ), ( b"U*U*U", b"$2a$05$XXXXXXXXXXXXXXXXXXXXXO", b"$2a$05$XXXXXXXXXXXXXXXXXXXXXOAcXxm9kjPGEMsLznoKqmqw7tc8WCx4a", ), ( b"0123456789abcdefghijklmnopqrstuvwxyz" b"ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" #b"chars after 72 are ignored" , b"$2a$05$abcdefghijklmnopqrstuu", b"$2a$05$abcdefghijklmnopqrstuu5s2v8.iXieOjg/.AySBTTZIIVFJeBui", ), ( b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" b"\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" #b"chars after 72 are ignored as usual" , b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.", b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.swQOIzjOiJ9GHEPuhEkvqrUyvWhEMx6" ), ( b"\xa3", b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.", b"$2a$05$/OK.fbVrR/bpIqNJ5ianF.Sa7shbm4.OzKpvFnX1pQLmQW96oUlCq" ), ]
question_data = [ { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In the 1988 film "Akira", Tetsuo ends up destroying Tokyo.", "correct_answer": "True", "incorrect_answers": [ "False" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "Studio Ghibli is a Japanese animation studio responsible for the films "Wolf Children" and "The Boy and the Beast".", "correct_answer": "False", "incorrect_answers": [ "True" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In Kill La Kill, the weapon of the main protagonist is a katana. ", "correct_answer": "False", "incorrect_answers": [ "True" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "No Game No Life first aired in 2014.", "correct_answer": "True", "incorrect_answers": [ "False" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In the "Melancholy of Haruhi Suzumiya" series, the narrator goes by the nickname Kyon.", "correct_answer": "True", "incorrect_answers": [ "False" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In Pokémon, Ash's Pikachu refuses to go into a pokeball.", "correct_answer": "True", "incorrect_answers": [ "False" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In the "Toaru Kagaku no Railgun" anime, espers can only reach a maximum of level 6 in their abilities.", "correct_answer": "False", "incorrect_answers": [ "True" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "Kiznaiver is an adaptation of a manga.", "correct_answer": "False", "incorrect_answers": [ "True" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In the "To Love-Ru" series, Golden Darkness is sent to kill Lala Deviluke.", "correct_answer": "False", "incorrect_answers": [ "True" ] }, { "category": "Entertainment: Japanese Anime & Manga", "type": "boolean", "difficulty": "easy", "question": "In Chobits, Hideki found Chii in his apartment.", "correct_answer": "False", "incorrect_answers": [ "True" ] } ]
class EOLError(ValueError): """ Signals that the buffer is reading after the end of a line.""" class EOFError(ValueError): """ Signals that the buffer is reading after the end of the text.""" class TextBuffer: def __init__(self, text=None): self.load(text) def reset(self): self.line = 0 self.column = 0 def load(self, text): self.text = text self.lines = text.split('\n') if text else [] self.reset() @property def current_line(self): try: return self.lines[self.line] except IndexError: raise EOFError( "EOF reading line {}".format(self.line) ) @property def current_char(self): try: return self.current_line[self.column] except IndexError: raise EOLError( "EOL reading column {} at line {}".format( self.column, self.line ) ) @property def next_char(self): try: return self.current_line[self.column + 1] except IndexError: raise EOLError( "EOL reading column {} at line {}".format( self.column, self.line ) ) @property def tail(self): return self.current_line[self.column:] @property def position(self): return (self.line, self.column) def newline(self): self.line += 1 self.column = 0 def skip(self, steps=1): self.column += steps def goto(self, line, column=0): self.line, self.column = line, column
def do_helm(s): if not s.command_available('helm'): # https://docs.helm.sh/using_helm/#installing-the-helm-client s.send('curl https://raw.githubusercontent.com/helm/helm/master/scripts/get | bash') s.send('helm init') s.send('kubectl get pods --namespace kube-system')
tuplas=("inacio","python","udemy") print(tuplas) print(tuplas[0]) print(tuplas[1]) print(tuplas[2]) print(tuplas[0:2]) print(tuplas+tuplas) print(tuplas*5) print(4 in tuplas) print("udemy" in tuplas) lista=[1,2,4,"inacio"] print(lista) tuplas2=lista print(tuplas2)
print('Conversor de moedas') print('e = Euros') print('d = Dollar') print('m = Pesos Mexicanos') print('a = Pesos Argentinos') print('l = Libras') moeda = input('Qual a moeda?: ') reais = float(input('Quantos em reais você gostaria de converter? ')) if reais <0: print('Quantidade inválida') elif moeda == 'e': print(reais*0.2132196162, 'Euros') elif moeda == 'd': print(reais*0.24630541871, 'Dólares') elif moeda == 'm': print(reais*4.7619047619, 'Pesos Mexicanos') elif moeda == 'a': print(reais*9.0909090909, 'Pesos Argentinos') elif reais == 'l': print(moeda*0,20366598778, 'Libras') else: print('Moeda inválida')
for char in "Hello, world!": for _ in range(0, ord(char)): print("+", end = "") print("[", end = "") print()
def read_settings_sql(cluster_descr, host_type): for settings_descr in cluster_descr.settings_list: if settings_descr.settings_type != host_type: continue yield from settings_descr.read_sql() # vi:ts=4:sw=4:et
input = """ 1 2 0 0 1 3 0 0 1 4 0 0 1 5 0 0 1 6 0 0 1 7 0 0 1 8 0 0 1 9 0 0 1 10 0 0 1 11 0 0 1 12 0 0 1 13 0 0 1 14 0 0 1 15 0 0 1 16 0 0 1 17 0 0 1 18 0 0 1 19 0 0 1 20 0 0 1 21 0 0 1 22 0 0 1 23 0 0 1 24 0 0 1 25 0 0 1 26 0 0 1 27 0 0 1 28 0 0 1 29 0 0 1 30 0 0 1 31 0 0 1 32 0 0 1 33 0 0 1 34 0 0 1 35 0 0 1 36 0 0 1 37 0 0 1 38 0 0 1 39 0 0 1 40 0 0 1 41 0 0 1 42 0 0 1 43 0 0 1 44 0 0 1 45 0 0 1 46 0 0 1 47 0 0 1 48 0 0 1 49 0 0 1 50 0 0 1 51 0 0 1 52 0 0 1 53 0 0 1 54 0 0 1 55 0 0 1 56 0 0 1 57 0 0 1 58 0 0 1 59 0 0 1 60 0 0 1 61 0 0 1 62 0 0 1 63 0 0 1 64 0 0 1 65 0 0 1 66 0 0 1 67 0 0 1 68 0 0 1 69 0 0 1 70 0 0 1 71 0 0 1 72 0 0 1 73 0 0 1 74 0 0 1 75 0 0 1 76 0 0 1 77 0 0 1 78 0 0 1 79 0 0 1 80 0 0 1 81 0 0 1 82 0 0 1 83 0 0 1 84 0 0 1 85 0 0 1 86 2 1 87 88 1 87 2 1 86 88 1 88 0 0 1 89 2 1 90 91 1 90 2 1 89 91 1 91 0 0 1 92 2 1 93 94 1 93 2 1 92 94 1 94 0 0 1 95 2 1 96 97 1 96 2 1 95 97 1 97 0 0 1 98 2 1 99 100 1 99 2 1 98 100 1 100 0 0 1 101 2 1 102 103 1 102 2 1 101 103 1 103 0 0 1 104 2 1 105 106 1 105 2 1 104 106 1 106 0 0 1 107 2 1 108 109 1 108 2 1 107 109 1 109 0 0 1 110 2 1 111 112 1 111 2 1 110 112 1 112 0 0 1 113 2 1 114 115 1 114 2 1 113 115 1 115 0 0 1 116 2 1 117 118 1 117 2 1 116 118 1 118 0 0 1 119 2 1 120 121 1 120 2 1 119 121 1 121 0 0 1 122 2 1 123 124 1 123 2 1 122 124 1 124 0 0 1 125 2 1 126 127 1 126 2 1 125 127 1 127 0 0 1 128 2 1 129 130 1 129 2 1 128 130 1 130 0 0 1 131 2 1 132 133 1 132 2 1 131 133 1 133 0 0 1 134 2 1 135 136 1 135 2 1 134 136 1 136 0 0 1 137 2 1 138 139 1 138 2 1 137 139 1 139 0 0 1 140 2 1 141 142 1 141 2 1 140 142 1 142 0 0 1 143 2 1 144 145 1 144 2 1 143 145 1 145 0 0 1 146 2 1 147 148 1 147 2 1 146 148 1 148 0 0 1 149 2 1 150 151 1 150 2 1 149 151 1 151 0 0 1 152 2 1 153 154 1 153 2 1 152 154 1 154 0 0 1 155 2 1 156 157 1 156 2 1 155 157 1 157 0 0 1 158 2 1 159 160 1 159 2 1 158 160 1 160 0 0 1 161 2 1 162 163 1 162 2 1 161 163 1 163 0 0 1 164 2 1 165 166 1 165 2 1 164 166 1 166 0 0 1 167 2 1 168 169 1 168 2 1 167 169 1 169 0 0 1 170 2 1 171 172 1 171 2 1 170 172 1 172 0 0 1 173 2 1 174 175 1 174 2 1 173 175 1 175 0 0 1 176 2 1 177 178 1 177 2 1 176 178 1 178 0 0 1 179 2 1 180 181 1 180 2 1 179 181 1 181 0 0 1 182 2 1 183 184 1 183 2 1 182 184 1 184 0 0 1 185 2 1 186 187 1 186 2 1 185 187 1 187 0 0 1 188 2 1 189 190 1 189 2 1 188 190 1 190 0 0 1 191 2 1 192 193 1 192 2 1 191 193 1 193 0 0 1 194 2 1 195 196 1 195 2 1 194 196 1 196 0 0 1 197 2 1 198 199 1 198 2 1 197 199 1 199 0 0 1 200 2 1 201 202 1 201 2 1 200 202 1 202 0 0 1 203 2 1 204 205 1 204 2 1 203 205 1 205 0 0 1 206 2 1 207 208 1 207 2 1 206 208 1 208 0 0 1 209 2 1 210 211 1 210 2 1 209 211 1 211 0 0 1 212 2 1 213 214 1 213 2 1 212 214 1 214 0 0 1 215 2 1 216 217 1 216 2 1 215 217 1 217 0 0 1 218 2 1 219 220 1 219 2 1 218 220 1 220 0 0 1 221 2 1 222 223 1 222 2 1 221 223 1 223 0 0 1 224 2 1 225 226 1 225 2 1 224 226 1 226 0 0 1 227 2 1 228 229 1 228 2 1 227 229 1 229 0 0 1 230 2 1 231 232 1 231 2 1 230 232 1 232 0 0 1 233 2 1 234 235 1 234 2 1 233 235 1 235 0 0 1 236 2 1 237 238 1 237 2 1 236 238 1 238 0 0 1 239 2 1 240 241 1 240 2 1 239 241 1 241 0 0 1 242 2 1 243 244 1 243 2 1 242 244 1 244 0 0 1 245 2 1 246 247 1 246 2 1 245 247 1 247 0 0 1 248 2 1 249 250 1 249 2 1 248 250 1 250 0 0 1 251 2 1 252 253 1 252 2 1 251 253 1 253 0 0 1 254 2 1 255 256 1 255 2 1 254 256 1 256 0 0 1 257 2 1 258 259 1 258 2 1 257 259 1 259 0 0 1 260 2 1 261 262 1 261 2 1 260 262 1 262 0 0 1 263 2 1 264 265 1 264 2 1 263 265 1 265 0 0 1 266 2 1 267 268 1 267 2 1 266 268 1 268 0 0 1 269 2 1 270 271 1 270 2 1 269 271 1 271 0 0 1 272 2 1 273 274 1 273 2 1 272 274 1 274 0 0 1 275 2 1 276 277 1 276 2 1 275 277 1 277 0 0 1 278 2 1 279 280 1 279 2 1 278 280 1 280 0 0 1 281 2 1 282 283 1 282 2 1 281 283 1 283 0 0 1 284 2 1 285 286 1 285 2 1 284 286 1 286 0 0 1 287 2 1 288 289 1 288 2 1 287 289 1 289 0 0 1 290 1 0 110 1 291 1 0 113 1 292 1 0 116 1 293 1 0 107 1 290 2 0 293 89 1 294 2 0 293 92 1 295 2 0 293 95 1 296 2 0 293 98 1 297 2 0 293 101 1 292 2 0 293 104 1 298 2 0 293 86 1 293 2 0 290 119 1 295 2 0 290 131 1 291 2 0 290 128 1 299 2 0 290 125 1 298 2 0 290 122 1 290 2 0 291 161 1 299 2 0 291 164 1 300 2 0 291 167 1 292 2 0 291 170 1 298 2 0 291 158 1 293 2 0 292 278 1 294 2 0 292 287 1 291 2 0 292 284 1 298 2 0 292 281 1 290 2 0 298 110 1 291 2 0 298 113 1 292 2 0 298 116 1 293 2 0 298 107 1 290 2 0 299 143 1 300 2 0 299 152 1 295 2 0 299 149 1 301 2 0 299 155 1 291 2 0 299 146 1 296 2 0 294 197 1 297 2 0 294 200 1 292 2 0 294 203 1 293 2 0 294 194 1 290 2 0 295 209 1 302 2 0 295 212 1 299 2 0 295 215 1 303 2 0 295 218 1 296 2 0 295 221 1 301 2 0 295 224 1 293 2 0 295 206 1 299 2 0 300 227 1 301 2 0 300 236 1 304 2 0 300 233 1 291 2 0 300 230 1 293 2 0 296 239 1 297 2 0 296 251 1 295 2 0 296 248 1 294 2 0 296 245 1 302 2 0 296 242 1 293 2 0 297 269 1 296 2 0 297 275 1 294 2 0 297 272 1 303 2 0 302 134 1 296 2 0 302 140 1 295 2 0 302 137 1 300 2 0 304 176 1 301 2 0 304 179 1 303 2 0 304 173 1 304 2 0 303 185 1 295 2 0 303 188 1 301 2 0 303 191 1 302 2 0 303 182 1 299 2 0 301 254 1 300 2 0 301 266 1 295 2 0 301 263 1 303 2 0 301 260 1 304 2 0 301 257 1 1 2 0 89 86 1 1 2 0 92 86 1 1 2 0 95 86 1 1 2 0 98 86 1 1 2 0 101 86 1 1 2 0 104 86 1 1 2 0 92 89 1 1 2 0 95 89 1 1 2 0 98 89 1 1 2 0 101 89 1 1 2 0 104 89 1 1 2 0 86 89 1 1 2 0 89 92 1 1 2 0 95 92 1 1 2 0 98 92 1 1 2 0 101 92 1 1 2 0 104 92 1 1 2 0 86 92 1 1 2 0 89 95 1 1 2 0 92 95 1 1 2 0 98 95 1 1 2 0 101 95 1 1 2 0 104 95 1 1 2 0 86 95 1 1 2 0 89 98 1 1 2 0 92 98 1 1 2 0 95 98 1 1 2 0 101 98 1 1 2 0 104 98 1 1 2 0 86 98 1 1 2 0 89 101 1 1 2 0 92 101 1 1 2 0 95 101 1 1 2 0 98 101 1 1 2 0 104 101 1 1 2 0 86 101 1 1 2 0 89 104 1 1 2 0 92 104 1 1 2 0 95 104 1 1 2 0 98 104 1 1 2 0 101 104 1 1 2 0 86 104 1 1 2 0 110 107 1 1 2 0 113 107 1 1 2 0 116 107 1 1 2 0 113 110 1 1 2 0 116 110 1 1 2 0 107 110 1 1 2 0 110 113 1 1 2 0 116 113 1 1 2 0 107 113 1 1 2 0 110 116 1 1 2 0 113 116 1 1 2 0 107 116 1 1 2 0 131 119 1 1 2 0 128 119 1 1 2 0 125 119 1 1 2 0 122 119 1 1 2 0 119 122 1 1 2 0 131 122 1 1 2 0 128 122 1 1 2 0 125 122 1 1 2 0 119 125 1 1 2 0 131 125 1 1 2 0 128 125 1 1 2 0 122 125 1 1 2 0 119 128 1 1 2 0 131 128 1 1 2 0 125 128 1 1 2 0 122 128 1 1 2 0 119 131 1 1 2 0 128 131 1 1 2 0 125 131 1 1 2 0 122 131 1 1 2 0 140 134 1 1 2 0 137 134 1 1 2 0 134 137 1 1 2 0 140 137 1 1 2 0 134 140 1 1 2 0 137 140 1 1 2 0 152 143 1 1 2 0 149 143 1 1 2 0 155 143 1 1 2 0 146 143 1 1 2 0 143 146 1 1 2 0 152 146 1 1 2 0 149 146 1 1 2 0 155 146 1 1 2 0 143 149 1 1 2 0 152 149 1 1 2 0 155 149 1 1 2 0 146 149 1 1 2 0 143 152 1 1 2 0 149 152 1 1 2 0 155 152 1 1 2 0 146 152 1 1 2 0 143 155 1 1 2 0 152 155 1 1 2 0 149 155 1 1 2 0 146 155 1 1 2 0 161 158 1 1 2 0 164 158 1 1 2 0 167 158 1 1 2 0 170 158 1 1 2 0 164 161 1 1 2 0 167 161 1 1 2 0 170 161 1 1 2 0 158 161 1 1 2 0 161 164 1 1 2 0 167 164 1 1 2 0 170 164 1 1 2 0 158 164 1 1 2 0 161 167 1 1 2 0 164 167 1 1 2 0 170 167 1 1 2 0 158 167 1 1 2 0 161 170 1 1 2 0 164 170 1 1 2 0 167 170 1 1 2 0 158 170 1 1 2 0 176 173 1 1 2 0 179 173 1 1 2 0 179 176 1 1 2 0 173 176 1 1 2 0 176 179 1 1 2 0 173 179 1 1 2 0 185 182 1 1 2 0 188 182 1 1 2 0 191 182 1 1 2 0 188 185 1 1 2 0 191 185 1 1 2 0 182 185 1 1 2 0 185 188 1 1 2 0 191 188 1 1 2 0 182 188 1 1 2 0 185 191 1 1 2 0 188 191 1 1 2 0 182 191 1 1 2 0 197 194 1 1 2 0 200 194 1 1 2 0 203 194 1 1 2 0 200 197 1 1 2 0 203 197 1 1 2 0 194 197 1 1 2 0 197 200 1 1 2 0 203 200 1 1 2 0 194 200 1 1 2 0 197 203 1 1 2 0 200 203 1 1 2 0 194 203 1 1 2 0 209 206 1 1 2 0 212 206 1 1 2 0 215 206 1 1 2 0 218 206 1 1 2 0 221 206 1 1 2 0 224 206 1 1 2 0 212 209 1 1 2 0 215 209 1 1 2 0 218 209 1 1 2 0 221 209 1 1 2 0 224 209 1 1 2 0 206 209 1 1 2 0 209 212 1 1 2 0 215 212 1 1 2 0 218 212 1 1 2 0 221 212 1 1 2 0 224 212 1 1 2 0 206 212 1 1 2 0 209 215 1 1 2 0 212 215 1 1 2 0 218 215 1 1 2 0 221 215 1 1 2 0 224 215 1 1 2 0 206 215 1 1 2 0 209 218 1 1 2 0 212 218 1 1 2 0 215 218 1 1 2 0 221 218 1 1 2 0 224 218 1 1 2 0 206 218 1 1 2 0 209 221 1 1 2 0 212 221 1 1 2 0 215 221 1 1 2 0 218 221 1 1 2 0 224 221 1 1 2 0 206 221 1 1 2 0 209 224 1 1 2 0 212 224 1 1 2 0 215 224 1 1 2 0 218 224 1 1 2 0 221 224 1 1 2 0 206 224 1 1 2 0 236 227 1 1 2 0 233 227 1 1 2 0 230 227 1 1 2 0 227 230 1 1 2 0 236 230 1 1 2 0 233 230 1 1 2 0 227 233 1 1 2 0 236 233 1 1 2 0 230 233 1 1 2 0 227 236 1 1 2 0 233 236 1 1 2 0 230 236 1 1 2 0 251 239 1 1 2 0 248 239 1 1 2 0 245 239 1 1 2 0 242 239 1 1 2 0 239 242 1 1 2 0 251 242 1 1 2 0 248 242 1 1 2 0 245 242 1 1 2 0 239 245 1 1 2 0 251 245 1 1 2 0 248 245 1 1 2 0 242 245 1 1 2 0 239 248 1 1 2 0 251 248 1 1 2 0 245 248 1 1 2 0 242 248 1 1 2 0 239 251 1 1 2 0 248 251 1 1 2 0 245 251 1 1 2 0 242 251 1 1 2 0 266 254 1 1 2 0 263 254 1 1 2 0 260 254 1 1 2 0 257 254 1 1 2 0 254 257 1 1 2 0 266 257 1 1 2 0 263 257 1 1 2 0 260 257 1 1 2 0 254 260 1 1 2 0 266 260 1 1 2 0 263 260 1 1 2 0 257 260 1 1 2 0 254 263 1 1 2 0 266 263 1 1 2 0 260 263 1 1 2 0 257 263 1 1 2 0 254 266 1 1 2 0 263 266 1 1 2 0 260 266 1 1 2 0 257 266 1 1 2 0 275 269 1 1 2 0 272 269 1 1 2 0 269 272 1 1 2 0 275 272 1 1 2 0 269 275 1 1 2 0 272 275 1 1 2 0 287 278 1 1 2 0 284 278 1 1 2 0 281 278 1 1 2 0 278 281 1 1 2 0 287 281 1 1 2 0 284 281 1 1 2 0 278 284 1 1 2 0 287 284 1 1 2 0 281 284 1 1 2 0 278 287 1 1 2 0 284 287 1 1 2 0 281 287 1 1 2 0 281 86 1 1 2 0 158 86 1 1 2 0 122 86 1 1 2 0 110 89 1 1 2 0 143 89 1 1 2 0 161 89 1 1 2 0 209 89 1 1 2 0 287 92 1 1 2 0 272 92 1 1 2 0 245 92 1 1 2 0 263 95 1 1 2 0 248 95 1 1 2 0 149 95 1 1 2 0 137 95 1 1 2 0 188 95 1 1 2 0 131 95 1 1 2 0 275 98 1 1 2 0 197 98 1 1 2 0 221 98 1 1 2 0 140 98 1 1 2 0 200 101 1 1 2 0 251 101 1 1 2 0 116 104 1 1 2 0 170 104 1 1 2 0 203 104 1 1 2 0 278 107 1 1 2 0 269 107 1 1 2 0 239 107 1 1 2 0 194 107 1 1 2 0 206 107 1 1 2 0 119 107 1 1 2 0 143 110 1 1 2 0 161 110 1 1 2 0 209 110 1 1 2 0 89 110 1 1 2 0 284 113 1 1 2 0 230 113 1 1 2 0 146 113 1 1 2 0 128 113 1 1 2 0 170 116 1 1 2 0 203 116 1 1 2 0 104 116 1 1 2 0 107 119 1 1 2 0 278 119 1 1 2 0 269 119 1 1 2 0 239 119 1 1 2 0 194 119 1 1 2 0 206 119 1 1 2 0 86 122 1 1 2 0 281 122 1 1 2 0 158 122 1 1 2 0 164 125 1 1 2 0 254 125 1 1 2 0 227 125 1 1 2 0 215 125 1 1 2 0 113 128 1 1 2 0 284 128 1 1 2 0 230 128 1 1 2 0 146 128 1 1 2 0 95 131 1 1 2 0 263 131 1 1 2 0 248 131 1 1 2 0 149 131 1 1 2 0 137 131 1 1 2 0 188 131 1 1 2 0 173 134 1 1 2 0 260 134 1 1 2 0 218 134 1 1 2 0 95 137 1 1 2 0 263 137 1 1 2 0 248 137 1 1 2 0 149 137 1 1 2 0 188 137 1 1 2 0 131 137 1 1 2 0 98 140 1 1 2 0 275 140 1 1 2 0 197 140 1 1 2 0 221 140 1 1 2 0 110 143 1 1 2 0 161 143 1 1 2 0 209 143 1 1 2 0 89 143 1 1 2 0 113 146 1 1 2 0 284 146 1 1 2 0 230 146 1 1 2 0 128 146 1 1 2 0 95 149 1 1 2 0 263 149 1 1 2 0 248 149 1 1 2 0 137 149 1 1 2 0 188 149 1 1 2 0 131 149 1 1 2 0 167 152 1 1 2 0 266 152 1 1 2 0 176 152 1 1 2 0 179 155 1 1 2 0 236 155 1 1 2 0 191 155 1 1 2 0 224 155 1 1 2 0 86 158 1 1 2 0 281 158 1 1 2 0 122 158 1 1 2 0 110 161 1 1 2 0 143 161 1 1 2 0 209 161 1 1 2 0 89 161 1 1 2 0 254 164 1 1 2 0 227 164 1 1 2 0 215 164 1 1 2 0 125 164 1 1 2 0 266 167 1 1 2 0 176 167 1 1 2 0 152 167 1 1 2 0 116 170 1 1 2 0 203 170 1 1 2 0 104 170 1 1 2 0 260 173 1 1 2 0 218 173 1 1 2 0 134 173 1 1 2 0 167 176 1 1 2 0 266 176 1 1 2 0 152 176 1 1 2 0 236 179 1 1 2 0 191 179 1 1 2 0 224 179 1 1 2 0 155 179 1 1 2 0 212 182 1 1 2 0 242 182 1 1 2 0 257 185 1 1 2 0 233 185 1 1 2 0 95 188 1 1 2 0 263 188 1 1 2 0 248 188 1 1 2 0 149 188 1 1 2 0 137 188 1 1 2 0 131 188 1 1 2 0 179 191 1 1 2 0 236 191 1 1 2 0 224 191 1 1 2 0 155 191 1 1 2 0 107 194 1 1 2 0 278 194 1 1 2 0 269 194 1 1 2 0 239 194 1 1 2 0 206 194 1 1 2 0 119 194 1 1 2 0 98 197 1 1 2 0 275 197 1 1 2 0 221 197 1 1 2 0 140 197 1 1 2 0 251 200 1 1 2 0 101 200 1 1 2 0 116 203 1 1 2 0 170 203 1 1 2 0 104 203 1 1 2 0 107 206 1 1 2 0 278 206 1 1 2 0 269 206 1 1 2 0 239 206 1 1 2 0 194 206 1 1 2 0 119 206 1 1 2 0 110 209 1 1 2 0 143 209 1 1 2 0 161 209 1 1 2 0 89 209 1 1 2 0 242 212 1 1 2 0 182 212 1 1 2 0 164 215 1 1 2 0 254 215 1 1 2 0 227 215 1 1 2 0 125 215 1 1 2 0 173 218 1 1 2 0 260 218 1 1 2 0 134 218 1 1 2 0 98 221 1 1 2 0 275 221 1 1 2 0 197 221 1 1 2 0 140 221 1 1 2 0 179 224 1 1 2 0 236 224 1 1 2 0 191 224 1 1 2 0 155 224 1 1 2 0 164 227 1 1 2 0 254 227 1 1 2 0 215 227 1 1 2 0 125 227 1 1 2 0 113 230 1 1 2 0 284 230 1 1 2 0 146 230 1 1 2 0 128 230 1 1 2 0 185 233 1 1 2 0 257 233 1 1 2 0 179 236 1 1 2 0 191 236 1 1 2 0 224 236 1 1 2 0 155 236 1 1 2 0 107 239 1 1 2 0 278 239 1 1 2 0 269 239 1 1 2 0 194 239 1 1 2 0 206 239 1 1 2 0 119 239 1 1 2 0 212 242 1 1 2 0 182 242 1 1 2 0 92 245 1 1 2 0 287 245 1 1 2 0 272 245 1 1 2 0 95 248 1 1 2 0 263 248 1 1 2 0 149 248 1 1 2 0 137 248 1 1 2 0 188 248 1 1 2 0 131 248 1 1 2 0 200 251 1 1 2 0 101 251 1 1 2 0 164 254 1 1 2 0 227 254 1 1 2 0 215 254 1 1 2 0 125 254 1 1 2 0 185 257 1 1 2 0 233 257 1 1 2 0 173 260 1 1 2 0 218 260 1 1 2 0 134 260 1 1 2 0 95 263 1 1 2 0 248 263 1 1 2 0 149 263 1 1 2 0 137 263 1 1 2 0 188 263 1 1 2 0 131 263 1 1 2 0 167 266 1 1 2 0 176 266 1 1 2 0 152 266 1 1 2 0 107 269 1 1 2 0 278 269 1 1 2 0 239 269 1 1 2 0 194 269 1 1 2 0 206 269 1 1 2 0 119 269 1 1 2 0 92 272 1 1 2 0 287 272 1 1 2 0 245 272 1 1 2 0 98 275 1 1 2 0 197 275 1 1 2 0 221 275 1 1 2 0 140 275 1 1 2 0 107 278 1 1 2 0 269 278 1 1 2 0 239 278 1 1 2 0 194 278 1 1 2 0 206 278 1 1 2 0 119 278 1 1 2 0 86 281 1 1 2 0 158 281 1 1 2 0 122 281 1 1 2 0 113 284 1 1 2 0 230 284 1 1 2 0 146 284 1 1 2 0 128 284 1 1 2 0 92 287 1 1 2 0 272 287 1 1 2 0 245 287 1 1 1 1 293 1 1 1 1 293 1 1 1 1 293 1 1 1 1 293 1 1 1 1 293 1 1 1 1 293 1 1 1 1 293 1 1 1 1 298 1 1 1 1 298 1 1 1 1 298 1 1 1 1 298 1 1 1 1 290 1 1 1 1 290 1 1 1 1 290 1 1 1 1 290 1 1 1 1 290 1 1 1 1 302 1 1 1 1 302 1 1 1 1 302 1 1 1 1 299 1 1 1 1 299 1 1 1 1 299 1 1 1 1 299 1 1 1 1 299 1 1 1 1 291 1 1 1 1 291 1 1 1 1 291 1 1 1 1 291 1 1 1 1 291 1 1 1 1 304 1 1 1 1 304 1 1 1 1 304 1 1 1 1 303 1 1 1 1 303 1 1 1 1 303 1 1 1 1 303 1 1 1 1 294 1 1 1 1 294 1 1 1 1 294 1 1 1 1 294 1 1 1 1 295 1 1 1 1 295 1 1 1 1 295 1 1 1 1 295 1 1 1 1 295 1 1 1 1 295 1 1 1 1 295 1 1 1 1 300 1 1 1 1 300 1 1 1 1 300 1 1 1 1 300 1 1 1 1 296 1 1 1 1 296 1 1 1 1 296 1 1 1 1 296 1 1 1 1 296 1 1 1 1 301 1 1 1 1 301 1 1 1 1 301 1 1 1 1 301 1 1 1 1 301 1 1 1 1 297 1 1 1 1 297 1 1 1 1 297 1 1 1 1 292 1 1 1 1 292 1 1 1 1 292 1 1 1 1 292 0 71 vertex(0) 72 vertex(1) 73 vertex(2) 74 vertex(3) 75 vertex(4) 76 vertex(5) 77 vertex(6) 78 vertex(7) 79 vertex(8) 80 vertex(9) 81 vertex(10) 82 vertex(11) 83 vertex(12) 84 vertex(13) 85 vertex(14) 3 arc(0,1) 4 arc(0,2) 5 arc(0,8) 6 arc(0,9) 7 arc(0,11) 8 arc(0,13) 9 arc(0,14) 10 arc(1,0) 11 arc(1,2) 12 arc(1,5) 13 arc(1,14) 14 arc(2,0) 15 arc(2,1) 16 arc(2,4) 17 arc(2,5) 18 arc(2,9) 19 arc(3,7) 20 arc(3,9) 21 arc(3,11) 22 arc(4,2) 23 arc(4,5) 24 arc(4,9) 25 arc(4,10) 26 arc(4,12) 27 arc(5,1) 28 arc(5,2) 29 arc(5,4) 30 arc(5,10) 31 arc(5,14) 32 arc(6,7) 33 arc(6,10) 34 arc(6,12) 35 arc(7,3) 36 arc(7,6) 37 arc(7,9) 38 arc(7,12) 39 arc(8,0) 40 arc(8,11) 41 arc(8,13) 42 arc(8,14) 43 arc(9,0) 44 arc(9,2) 45 arc(9,3) 46 arc(9,4) 47 arc(9,7) 48 arc(9,11) 49 arc(9,12) 50 arc(10,4) 51 arc(10,5) 52 arc(10,6) 53 arc(10,12) 54 arc(11,0) 55 arc(11,3) 56 arc(11,8) 57 arc(11,9) 58 arc(11,13) 59 arc(12,4) 60 arc(12,6) 61 arc(12,7) 62 arc(12,9) 63 arc(12,10) 64 arc(13,0) 65 arc(13,8) 66 arc(13,11) 67 arc(14,0) 68 arc(14,1) 69 arc(14,5) 70 arc(14,8) 290 reached(2) 291 reached(5) 292 reached(14) 293 reached(0) 294 reached(8) 295 reached(9) 296 reached(11) 297 reached(13) 298 reached(1) 299 reached(4) 300 reached(10) 301 reached(12) 302 reached(3) 303 reached(7) 304 reached(6) 87 out_hm(0,1) 90 out_hm(0,2) 93 out_hm(0,8) 96 out_hm(0,9) 99 out_hm(0,11) 102 out_hm(0,13) 105 out_hm(0,14) 108 out_hm(1,0) 111 out_hm(1,2) 114 out_hm(1,5) 117 out_hm(1,14) 120 out_hm(2,0) 123 out_hm(2,1) 126 out_hm(2,4) 129 out_hm(2,5) 132 out_hm(2,9) 135 out_hm(3,7) 138 out_hm(3,9) 141 out_hm(3,11) 144 out_hm(4,2) 147 out_hm(4,5) 150 out_hm(4,9) 153 out_hm(4,10) 156 out_hm(4,12) 159 out_hm(5,1) 162 out_hm(5,2) 165 out_hm(5,4) 168 out_hm(5,10) 171 out_hm(5,14) 174 out_hm(6,7) 177 out_hm(6,10) 180 out_hm(6,12) 183 out_hm(7,3) 186 out_hm(7,6) 189 out_hm(7,9) 192 out_hm(7,12) 195 out_hm(8,0) 198 out_hm(8,11) 201 out_hm(8,13) 204 out_hm(8,14) 207 out_hm(9,0) 210 out_hm(9,2) 213 out_hm(9,3) 216 out_hm(9,4) 219 out_hm(9,7) 222 out_hm(9,11) 225 out_hm(9,12) 228 out_hm(10,4) 231 out_hm(10,5) 234 out_hm(10,6) 237 out_hm(10,12) 240 out_hm(11,0) 243 out_hm(11,3) 246 out_hm(11,8) 249 out_hm(11,9) 252 out_hm(11,13) 255 out_hm(12,4) 258 out_hm(12,6) 261 out_hm(12,7) 264 out_hm(12,9) 267 out_hm(12,10) 270 out_hm(13,0) 273 out_hm(13,8) 276 out_hm(13,11) 279 out_hm(14,0) 282 out_hm(14,1) 285 out_hm(14,5) 288 out_hm(14,8) 86 in_hm(0,1) 89 in_hm(0,2) 92 in_hm(0,8) 95 in_hm(0,9) 98 in_hm(0,11) 101 in_hm(0,13) 104 in_hm(0,14) 107 in_hm(1,0) 110 in_hm(1,2) 113 in_hm(1,5) 116 in_hm(1,14) 119 in_hm(2,0) 122 in_hm(2,1) 125 in_hm(2,4) 128 in_hm(2,5) 131 in_hm(2,9) 134 in_hm(3,7) 137 in_hm(3,9) 140 in_hm(3,11) 143 in_hm(4,2) 146 in_hm(4,5) 149 in_hm(4,9) 152 in_hm(4,10) 155 in_hm(4,12) 158 in_hm(5,1) 161 in_hm(5,2) 164 in_hm(5,4) 167 in_hm(5,10) 170 in_hm(5,14) 173 in_hm(6,7) 176 in_hm(6,10) 179 in_hm(6,12) 182 in_hm(7,3) 185 in_hm(7,6) 188 in_hm(7,9) 191 in_hm(7,12) 194 in_hm(8,0) 197 in_hm(8,11) 200 in_hm(8,13) 203 in_hm(8,14) 206 in_hm(9,0) 209 in_hm(9,2) 212 in_hm(9,3) 215 in_hm(9,4) 218 in_hm(9,7) 221 in_hm(9,11) 224 in_hm(9,12) 227 in_hm(10,4) 230 in_hm(10,5) 233 in_hm(10,6) 236 in_hm(10,12) 239 in_hm(11,0) 242 in_hm(11,3) 245 in_hm(11,8) 248 in_hm(11,9) 251 in_hm(11,13) 254 in_hm(12,4) 257 in_hm(12,6) 260 in_hm(12,7) 263 in_hm(12,9) 266 in_hm(12,10) 269 in_hm(13,0) 272 in_hm(13,8) 275 in_hm(13,11) 278 in_hm(14,0) 281 in_hm(14,1) 284 in_hm(14,5) 287 in_hm(14,8) 2 start(1) 0 B+ 0 B- 1 0 1 """ output = """ {start(1), arc(0,1), arc(0,2), arc(0,8), arc(0,9), arc(0,11), arc(0,13), arc(0,14), arc(1,0), arc(1,2), arc(1,5), arc(1,14), arc(2,0), arc(2,1), arc(2,4), arc(2,5), arc(2,9), arc(3,7), arc(3,9), arc(3,11), arc(4,2), arc(4,5), arc(4,9), arc(4,10), arc(4,12), arc(5,1), arc(5,2), arc(5,4), arc(5,10), arc(5,14), arc(6,7), arc(6,10), arc(6,12), arc(7,3), arc(7,6), arc(7,9), arc(7,12), arc(8,0), arc(8,11), arc(8,13), arc(8,14), arc(9,0), arc(9,2), arc(9,3), arc(9,4), arc(9,7), arc(9,11), arc(9,12), arc(10,4), arc(10,5), arc(10,6), arc(10,12), arc(11,0), arc(11,3), arc(11,8), arc(11,9), arc(11,13), arc(12,4), arc(12,6), arc(12,7), arc(12,9), arc(12,10), arc(13,0), arc(13,8), arc(13,11), arc(14,0), arc(14,1), arc(14,5), arc(14,8), vertex(0), vertex(1), vertex(2), vertex(3), vertex(4), vertex(5), vertex(6), vertex(7), vertex(8), vertex(9), vertex(10), vertex(11), vertex(12), vertex(13), vertex(14), reached(2), reached(5), reached(14), reached(0), reached(8), reached(9), reached(11), reached(13), reached(1), reached(4), reached(10), reached(12), reached(3), reached(7), reached(6)} """
"""This module provides Scala-like functional pattern matching in Python.""" __version__ = '0.1.3-dev' __author__ = 'Martin Blech' __copyright__ = '2012, ' + __author__ __license__ = 'MIT'
"""Rules for importing a Python toolchain from Nixpkgs. """ load("@bazel_skylib//lib:versions.bzl", "versions") load( "@rules_nixpkgs_core//:nixpkgs.bzl", "nixpkgs_package", ) load( "@rules_nixpkgs_core//:util.bzl", "ensure_constraints", "label_string", ) def _nixpkgs_python_toolchain_impl(repository_ctx): exec_constraints, target_constraints = ensure_constraints(repository_ctx) repository_ctx.file("BUILD.bazel", executable = False, content = """ load("@bazel_tools//tools/python:toolchain.bzl", "py_runtime_pair") py_runtime_pair( name = "py_runtime_pair", py2_runtime = {python2_runtime}, py3_runtime = {python3_runtime}, ) toolchain( name = "toolchain", toolchain = ":py_runtime_pair", toolchain_type = "@bazel_tools//tools/python:toolchain_type", exec_compatible_with = {exec_constraints}, target_compatible_with = {target_constraints}, ) """.format( python2_runtime = label_string(repository_ctx.attr.python2_runtime), python3_runtime = label_string(repository_ctx.attr.python3_runtime), exec_constraints = exec_constraints, target_constraints = target_constraints, )) _nixpkgs_python_toolchain = repository_rule( _nixpkgs_python_toolchain_impl, attrs = { # Using attr.string instead of attr.label, so that the repository rule # does not explicitly depend on the nixpkgs_package instances. This is # necessary, so that builds don't fail on platforms without nixpkgs. "python2_runtime": attr.string(), "python3_runtime": attr.string(), "exec_constraints": attr.string_list(), "target_constraints": attr.string_list(), }, ) def _python_nix_file_content(attribute_path, bin_path, version): add_shebang = versions.is_at_least("4.2.0", versions.get()) return """ with import <nixpkgs> {{ config = {{}}; overlays = []; }}; let addShebang = {add_shebang}; interpreterPath = "${{{attribute_path}}}/{bin_path}"; shebangLine = interpreter: writers.makeScriptWriter {{ inherit interpreter; }} "shebang" ""; in runCommand "bazel-nixpkgs-python-toolchain" {{ executable = false; # Pointless to do this on a remote machine. preferLocalBuild = true; allowSubstitutes = false; }} '' n=$out/BUILD.bazel mkdir -p "$(dirname "$n")" cat >>$n <<EOF py_runtime( name = "runtime", interpreter_path = "${{interpreterPath}}", python_version = "{version}", ${{lib.optionalString addShebang '' stub_shebang = "$(cat ${{shebangLine interpreterPath}})", ''}} visibility = ["//visibility:public"], ) EOF '' """.format( add_shebang = "true" if add_shebang else "false", attribute_path = attribute_path, bin_path = bin_path, version = version, ) def nixpkgs_python_configure( name = "nixpkgs_python_toolchain", python2_attribute_path = None, python2_bin_path = "bin/python", python3_attribute_path = "python3", python3_bin_path = "bin/python", repository = None, repositories = {}, nix_file_deps = None, nixopts = [], fail_not_supported = True, quiet = False, exec_constraints = None, target_constraints = None): """Define and register a Python toolchain provided by nixpkgs. Creates `nixpkgs_package`s for Python 2 or 3 `py_runtime` instances and a corresponding `py_runtime_pair` and `toolchain`. The toolchain is automatically registered and uses the constraint: ``` "@io_tweag_rules_nixpkgs//nixpkgs/constraints:support_nix" ``` Args: name: The name-prefix for the created external repositories. python2_attribute_path: The nixpkgs attribute path for python2. python2_bin_path: The path to the interpreter within the package. python3_attribute_path: The nixpkgs attribute path for python3. python3_bin_path: The path to the interpreter within the package. repository: See [`nixpkgs_package`](#nixpkgs_package-repository). repositories: See [`nixpkgs_package`](#nixpkgs_package-repositories). nix_file_deps: See [`nixpkgs_package`](#nixpkgs_package-nix_file_deps). nixopts: See [`nixpkgs_package`](#nixpkgs_package-nixopts). fail_not_supported: See [`nixpkgs_package`](#nixpkgs_package-fail_not_supported). quiet: See [`nixpkgs_package`](#nixpkgs_package-quiet). exec_constraints: Constraints for the execution platform. target_constraints: Constraints for the target platform. """ python2_specified = python2_attribute_path and python2_bin_path python3_specified = python3_attribute_path and python3_bin_path if not python2_specified and not python3_specified: fail("At least one of python2 or python3 has to be specified.") kwargs = dict( repository = repository, repositories = repositories, nix_file_deps = nix_file_deps, nixopts = nixopts, fail_not_supported = fail_not_supported, quiet = quiet, ) python2_runtime = None if python2_attribute_path: python2_runtime = "@%s_python2//:runtime" % name nixpkgs_package( name = name + "_python2", nix_file_content = _python_nix_file_content( attribute_path = python2_attribute_path, bin_path = python2_bin_path, version = "PY2", ), **kwargs ) python3_runtime = None if python3_attribute_path: python3_runtime = "@%s_python3//:runtime" % name nixpkgs_package( name = name + "_python3", nix_file_content = _python_nix_file_content( attribute_path = python3_attribute_path, bin_path = python3_bin_path, version = "PY3", ), **kwargs ) _nixpkgs_python_toolchain( name = name, python2_runtime = python2_runtime, python3_runtime = python3_runtime, exec_constraints = exec_constraints, target_constraints = target_constraints, ) native.register_toolchains("@%s//:toolchain" % name)
# Use this file to configure your DNA Center via REST APIs # Replace all values below with your production DNA Center information # DNA Parameters DNA_FQDN = "dna.fqdn" DNA_PORT = "443" DNA_USER = "admin" DNA_PASS = "password" DNA_SWITCHES = ["switch1", "switch2", "switch3"] # DNA API Calls DNA_AUTH_API = "/dna/system/api/v1/auth/token" DNA_DEVICE_API = "/dna/intent/api/v1/network-device" DNA_INTERFACE_API = "/api/v1/interface/network-device/"
x = 42 y = 3/4 z = int('7') a = float(5) name = "David" print(type(x)) print(type(y)) print(type(z)) print(type(a)) print(type(name)) rent = 2000 per_day = rent / 30 print(per_day) greeting = "My name is" print(greeting, name) print(greeting, name, f"My rent is {rent}") help(greeting)
# -*- coding: utf-8 -*- # @Time : 2021/5/24 11:00 PM # @Author: lixiaomeng_someday # @Email : 131xxxx119@163.com # @File : FS_01_algorithm.py """ name: fast slow pointers analysis: 在快速和慢速指针的方法,也被称为兔&龟算法,是一个指针算法使用两个指针以不同的速度移动, 其通过阵列(或序列/链表)通过以不同的速度移动(例如,在循环的LinkedList中), 该算法证明两个指针必然会合。一旦两个指针都处于循环循环中,则快速指针应捕获慢速指针。 """
def hello(): """ say hello only """ print('hello') def hi(): print("hi")
class Solution: def trapRainWater(self, heightMap): """ :type heightMap: List[List[int]] :rtype: int """ if not any(heightMap): return 0 heap = [] m, n = len(heightMap), len(heightMap[0]) seen = [[False] * n for _ in range(m)] for i, row in enumerate(heightMap): for j, height in enumerate(row): if i == 0 or j == 0 or i == m - 1 or j == n - 1: seen[i][j] = True heapq.heappush(heap, (height, i, j)) ans = 0 while heap: height, i, j = heapq.heappop(heap) for newi, newj in (i - 1, j), (i + 1, j), (i, j - 1), (i, j + 1): if 0 <= newi < m and 0 <= newj < n and not seen[newi][newj]: seen[newi][newj] = True ans += max(0, height - heightMap[newi][newj]) heapq.heappush(heap, (max(heightMap[newi][newj], height), newi, newj)) return ans
"""HacsFrontend.""" class HacsFrontend: """HacsFrontend.""" version_running: bool = None version_available: bool = None version_expected: bool = None update_pending: bool = False
class Solution: def intToRoman(self, num: int) -> str: roman = {} roman[1000] = 'M' roman[900] = 'CM' roman[500] = 'D' roman[400] = 'CD' roman[100] = 'C' roman[90] = 'XC' roman[50] = 'L' roman[40] = 'XL' roman[10] = 'X' roman[9] = 'IX' roman[5] = 'V' roman[4] = 'IV' roman[1] = 'I' res = '' num_list = list(roman.keys()) num_list.sort(reverse = True) for i in num_list: while num >= i: num -= i res += roman[i] return res
""" 32 - Escreva um programa que leia o código do produto escolhido do cardápio de uma lanchonete e a quantidade. O programa deve calcular o valor a ser pago por aquele lanche. Considere que a cada execução somente será calculado um pedido. O cardápio da lanchonete segue o padrão abaixo: ESPECIFICAÇÃO | CÓDIGO | PREÇO ---------------------------------------- Cachorro-Quente | 100 | 1.20 Bauru Simples | 101 | 1.30 Bauru com ovo | 102 | 1.50 Hamburguer | 103 | 1.20 Cheeseburguer | 104 | 1.70 Suco | 105 | 2.20 Refrigerante | 106 | 1.00 """ codigo = int(input("Digite o código do cardápio: ")) quantidade = int(input("Digite a quantidade desejada: ")) if codigo == 100: calculo = quantidade * 1.20 print(f'Você pediu {quantidade} Cachorro-Quente(s), valor a pagar {calculo}') elif codigo == 101: calculo = quantidade * 1.30 print(f'Você pediu {quantidade} Bauru(s) Simples, valor a pagar {calculo}') elif codigo == 102: calculo = quantidade * 1.50 print(f'Você pediu {quantidade} Bauru(s) com Ovo, valor a pagar {calculo}') elif codigo == 103: calculo = quantidade * 1.20 print(f'Você pediu {quantidade} Hamburguer(s), valor a pagar {calculo}') elif codigo == 104: calculo = quantidade * 1.70 print(f'Você pediu {quantidade} Cheeseburguer(s), valor a ser pago {calculo}') elif codigo == 105: calculo = quantidade * 2.20 print(f'Você pediu {quantidade} Suco(s), valor a ser pago {calculo}') elif codigo == 106: calculo = quantidade * 1.00 print(f'Você pediu {quantidade} Refrigerante(s), valor a ser pago {calculo}') else: print('Código não cadastrado, por favor tente novamente. Obrigada!')
# -*- coding: utf-8 -*-# #------------------------------------------------------------------------------- # PROJECT_NAME: design_pattern # Name: singleton.py # Author: 9824373 # Date: 2020-08-14 22:41 # Contact: 9824373@qq.com # Version: V1.0 # Description: 单例模式 #------------------------------------------------------------------------------- class singleton(object): _instance = None def __new__(cls, *args, **kwargs): if not cls._instance: cls._instance = object.__new__(cls) return cls._instance def __init__(self,name,age,edu): self.name = name self.age = age self.edu = edu if __name__ == '__main__': a = singleton('zhan',24,'famale') b = singleton('zhang',20,'male') print(a) print(b) print(a.name,a.age,a.edu) print(b.name,b.age,b.edu)
# from .latexrun import __version__ = "0.1.0" __all__ = []
def memberGraph(): return { "nodes": [ { "id": 1, "label": "mbudiselicbuda", "shape": "circularImage", "image": "https://avatars.githubusercontent.com/u/4950251?s=88&v=4", "title": "Ovo je njonjo", "size": 100, "borderWidth": 10, "color": {"border": "green"}, }, {"id": 2, "label": "mbudiselicbuda", "shape": "ellipse", "borderWidth": 5, "color": {"border": "green"}}, {"id": 3, "label": "mbudiselicbuda", "shape": "database"}, {"id": 4, "label": "mbudiselicbuda", "image": "https://avatars.githubusercontent.com/u/4950251?s=88&v=4"}, {"id": 5, "label": "mbudiselicbuda", "shape": "diamond"}, {"id": 6, "label": "mbudiselicbuda", "shape": "dot"}, {"id": 7, "label": "mbudiselicbuda", "shape": "square"}, {"id": 8, "label": "mbudiselicbuda", "shape": "triangle"}, ], "edges": [ {"from": 1, "to": 2}, {"from": 2, "to": 3, 2: "to"}, {"from": 3, "to": 2, "arrows": "to"}, {"from": 2, "to": 4}, {"from": 2, "to": 5}, {"from": 5, "to": 6}, {"from": 5, "to": 7}, {"from": 6, "to": 8}, ], } def usernames(): return { "usernames": [ { "username": "Gitbuda", }, { "username": "afico", }, { "username": "jmrden", }, { "username": "jmatak", }, { "username": "cofi", }, ] } def userDetails(): return { "username": "Gitbuda", "firstName": "Marko", "lastName": "Budiselic", "love": 10.2, "avatar": "https://avatars.githubusercontent.com/u/4950251?s=88&v=4", "community": "Feature, not bug", "importance": 50.5, "company": "Memgraph", "githubAccount": "https://github.com/gitbuda", "twitterAccount": "https://twitter.com/mbudiselicbuda", "twitterUsername": "twitterBuda", "githubUsername": "gitBuda", } def activities(): return { "activities": [ { "username": "Gitbuda", "action": "PR_MAKE", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda2", "action": "PR_MAKE2", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda3", "action": "PR_MAKE3", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda", "action": "PR_MAKE", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda2", "action": "PR_MAKE2", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda3", "action": "PR_MAKE3", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda", "action": "PR_MAKE", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda2", "action": "PR_MAKE2", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda3", "action": "PR_MAKE3", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda", "action": "PR_MAKE", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda2", "action": "PR_MAKE2", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, { "username": "Gitbuda3", "action": "PR_MAKE3", "description": "This guy made a PR!", "date": "2020-01-01T08:00:00", }, ] }
delimiter = "|" eol = "\r\n" """ Header fields for json string """ field_market_data_request = "ReqMktData" field_position_data_request = "ReqPositionUpdates" field_account_data_request = "ReqAccountUpdates" field_order_data_request = "ReqOrderUpates" field_send_limit_order = "SendLimitOrder" field_send_market_order = "SendMarketOrder" field_contract_id = "ContractId" field_is_buy = "IsBuy" field_price = "Price" field_qty = "Qty" field_data_command = "DataCommand" # Returned command field
""" Q212 Word Search II See also: Q079 Given a 2D board and a list of words from the dictionary, find all words in the board. Each word must be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those horizontally or vertically neighboring. The same letter cell may not be used more than once in a word. Example: Input: board = [ ['o','a','a','n'], ['e','t','a','e'], ['i','h','k','r'], ['i','f','l','v'] ] words = ["oath","pea","eat","rain"] Output: ["eat","oath"] Note: All inputs are consist of lowercase letters a-z. The values of words are distinct. """
def solve(arr): arr.sort() s = 0 for i in range(0, len(arr), 2): s += arr[i] return s
#! /usr/bin/python3.5 ### INSTRUCTIONS ### # instruction: ([chars list], has parameter, "representation in WIL") CHARS = 0 PARAM = 1 WIL = 2 STACK_INSTRUCTIONS = [ (['S'], True, 'push' ), (['L', 'S'], False, 'dup' ), (['T', 'S'], True, 'copy' ), (['L', 'T'], False, 'swap' ), (['L', 'L'], False, 'pop' ), (['T', 'L'], True, 'slide') ] ARITH_INSTRUCTIONS = [ (['S', 'S'], False, 'add'), (['S', 'T'], False, 'sub'), (['S', 'L'], False, 'mul'), (['T', 'S'], False, 'div'), (['T', 'T'], False, 'mod') ] HEAP_INSTRUCTIONS = [ (['S'], False, 'store'), (['T'], False, 'retri') ] FLOW_INSTRUCTIONS = [ (['S', 'S'], True, 'label' ), (['S', 'T'], True, 'call' ), (['S', 'L'], True, 'jmp' ), (['T', 'S'], True, 'jmpz' ), (['T', 'T'], True, 'jmpneg'), (['T', 'L'], False, 'ret' ), (['L', 'L'], False, 'end' ) ] IO_INSTRUCTIONS = [ (['S', 'S'], False, 'outc'), (['S', 'T'], False, 'outi'), (['T', 'S'], False, 'inc' ), (['T', 'T'], False, 'ini' ) ] ### !INSTRUCTIONS ### class Character(object): def __init__(self, char): self.char = char self.sons = { } self.is_leaf = True self.has_param = False self.wil_representation = None def add(self, chars, has_param, wil_representation): if len(chars) == 0: self.has_param = has_param self.wil_representation = wil_representation return if len(self.sons) == 0: self.is_leaf = False if chars[0] not in self.sons: self.sons[chars[0]] = Character(chars[0]) if len(chars) == 1: self.sons[chars[0]].has_param = has_param self.sons[chars[0]].wil_representation = wil_representation return self.sons[chars[0]].add(chars[1:], has_param, wil_representation) #returns a tuple (is_leaf, has_param, representation) def has_reached_leaf(self, chars): if len(chars) == 0: if self.is_leaf: return (True, self.has_param, self.wil_representation) return (False, None, None) if self.is_leaf: if len(chars) != 0: raise Exception('Syntax error: character {} is strange. Instruction "{}" should be over.'.format(self.char, self.wil_representation)) return (True, self.has_param, self.wil_representation) return self.sons[chars[0]].has_reached_leaf(chars[1:]) class Ast(object): def __init__(self, instructions): self.sons = { } for ins in instructions: c = ins[CHARS][0] if c not in self.sons: self.sons[c] = Character(c) self.sons[c].add(ins[CHARS][1:], ins[PARAM], ins[WIL]) def has_reached_leaf(self, chars): c = chars[0] return self.sons[c].has_reached_leaf(chars[1:]) class StackAst(Ast): def __init__(self): Ast.__init__(self, STACK_INSTRUCTIONS) class ArithmeticAst(Ast): def __init__(self): Ast.__init__(self, ARITH_INSTRUCTIONS) class HeapAst(Ast): def __init__(self): Ast.__init__(self, HEAP_INSTRUCTIONS) class FlowAst(Ast): def __init__(self): Ast.__init__(self, FLOW_INSTRUCTIONS) class IOAst(Ast): def __init__(self): Ast.__init__(self, IO_INSTRUCTIONS) StackAst = StackAst() ArithAst = ArithmeticAst() HeapAst = HeapAst() FlowAst = FlowAst() IOAst = IOAst() if __name__ == '__main__': pass
rows = 11 for i in range(0, rows): for j in range(0, i + 1): print(i * j, end= ' ') print()
''' leetcode 64. Minimum Path Sum 从左上角出发,到矩阵右下角,返回所有路径中的最小和 Input: 3 3 1 3 1 1 5 1 4 2 1 Output: 7 ''' m = int(input()) n = int(input()) matrix = [] for i in range(m): matrix.append(list(map(int,input().split()))) # print(matrix) for i in range(1,n): matrix[0][i] += matrix[0][i-1] for j in range(1,m): matrix[j][0] += matrix[j-1][0] for i in range(1,m): for j in range(1,n): matrix[i][j] += min(matrix[i-1][j],matrix[i][j-1]) print(matrix[-1][-1])
strings = input().split(", ") l = [(i, len(i)) for i in strings] print(', '.join([' -> '.join(map(str, m)) for m in l])) # #Решение на 1 ред: # # print(', '.join([' -> '.join(map(str, m)) for m in [(i, len(i)) for i in input().split(", ")]]))
class Mobile: def __init__(self): print("Mobile features: Camera, Phone, Applications") class Samsung(Mobile): def __init__(self): print("Samsung Company") super().__init__() class Samsung_Prime(Samsung): def __init__(self): print("Samsung latest Mobile") super().__init__()
x = int(input()) print(x // 60) # получение целой части от деления, чтобы определить часы print(x % 60) # остаток от деления, чтобы определить минуты
# operações básicas primeiro_valor = input('Primeiro valor: ') if primeiro_valor.isnumeric is False: print(f'{primeiro_valor} não é um número válido') exit() operacao = input('Operação: ') segundo_valor = input('Segundo valor: ') if segundo_valor.isnumeric is False: print(f'{segundo_valor} não é um número válido') exit() primeiro_valor = int(primeiro_valor) segundo_valor = int(segundo_valor) etiqueta = '' resultado = 0 if operacao == '+': resultado = primeiro_valor + segundo_valor etiqueta = 'soma' elif operacao == '-': resultado = primeiro_valor - segundo_valor etiqueta = 'substração' elif operacao == '*': resultado = primeiro_valor * segundo_valor etiqueta = 'Multiplicação' elif operacao == '/': resultado = primeiro_valor / segundo_valor etiqueta = 'Divisão' elif operacao == '**': resultado = primeiro_valor ** segundo_valor etiqueta = 'Potencia' elif operacao == '%': resultado = primeiro_valor % segundo_valor etiqueta = 'modulo' else: print('Operaçõa não reconhecida') exit() print(f'{etiqueta} entre {primeiro_valor} e {segundo_valor} = {resultado}')
#========================example 1====================== #check a number if it can perfectly divide by n^2+1 fx = lambda n: (n**2+1)%5==0 k=int(input("please enter a number: ")) print(fx(k)) #========================example 2====================== findMax = lambda x,y: max(x,y) print(findMax(100,200))
class Err(Exception): """ Prints Project Error. * `error_origin`: (str) to specify from where the error comes. * `info_list` : (list) list of strings to print as message: each list item starts at a new line. """ def __init__(self, error_origin, info_list): Exception.__init__(self, error_origin, info_list) self.__error_origin = error_origin self.__info_list = '\n'.join(info_list) self.__txt = ''' ======================================================================== PyLCONF-ERROR: generated in <{}> {} ======================================================================== '''.format(self.__error_origin, self.__info_list) print(self.__txt) class SectionErr(Exception): """ Prints Project Section Error. * `error_origin`: (str) to specify from where the error comes. * `section_format`: (str) the format of the section. * `section_name`: (str) the name of the section. * `section_line`: (str) the line of the section. * `info_list` : (list) list of strings to print as message: each list item starts at a new line. """ def __init__(self, error_origin, section_format, section_name, section_line, info_list): Exception.__init__(self, error_origin, info_list) self.__error_origin = error_origin self.__section_format = section_format self.__section_name = section_name self.__section_line = section_line self.__info_list = '\n'.join(info_list) self.__txt = ''' ======================================================================== PyLCONF-ERROR: generated in <{}> LCONF-Section-Format: <{}> LCONF-Section-Name: <{}> {} LCONF-Section-Line: <{}> ======================================================================== '''.format(self.__error_origin, self.__section_format, self.__section_name, self.__info_list, self.__section_line) print(self.__txt) class MethodDeactivatedErr(Exception): """ Prints an own raised Deactivated Error. """ def __init__(self): Exception.__init__(self, 'Method is deactivated.') self.__txt = ''' ======================================================================== LCONF-MethodDeactivated ERROR: Method is deactivated. ======================================================================== ''' print(self.__txt)
class Snake: def __init__(self, SCREEN_LENGTH, MIDDLE_SCREEN): self.screen = SCREEN_LENGTH self.middle_screen = MIDDLE_SCREEN self.position = [self.middle_screen, self.middle_screen] self.body = [[self.middle_screen, self.middle_screen], [self.middle_screen - 10 , self.middle_screen], [self.middle_screen - 20, self.middle_screen]] self.direction = "RIGHT" def change_direction_to(self, direction): if direction == "RIGHT" and not self.direction == "LEFT": self.direction = "RIGHT" if direction == "LEFT" and not self.direction == "RIGHT": self.direction = "LEFT" if direction == "UP" and not self.direction == "DOWN": self.direction = "UP" if direction == "DOWN" and not self.direction == "UP": self.direction = "DOWN" def move(self): if self.direction == "RIGHT": self.position[0] += 20 if self.direction == "LEFT": self.position[0] -= 20 if self.direction == "UP": self.position[1] -= 20 if self.direction == "DOWN": self.position[1] += 20 self.body.insert(0, list(self.position)) def eat(self, food_pos): if self.position == food_pos: return 1 else: self.body.pop() return 0 def check_collision(self): if self.position[0] > self.screen - 10 or self.position[0] < 0: return 1 elif self.position[1] > self.screen - 10 or self.position[1] < 0: return 1 for bodyPart in self.body[1:]: if self.position == bodyPart: return 1 return 0 def get_head(self): return self.position def get_body(self): return self.body
def fourSum(nums, target): def threeSum(nums, target): if len(nums) < 3: return [] res = set() for i, n in enumerate(nums): l = i + 1 r = len(nums) - 1 t = target - n while l < r: if nums[l] + nums[r] > t: r -= 1 elif nums[l] + nums[r] < t: l += 1 else: res.add((n, nums[l], nums[r])) l += 1 r -= 1 return list(map(list, res)) results = [] nums.sort() for i in range(len(nums)-3): if i == 0 or nums[i] != nums[i-1]: threeSumResult = threeSum(nums[i+1:], target-nums[i]) print(threeSumResult) for item in threeSumResult: results.append([nums[i]] + item) return results nums = [1,0,-1,0,-2,2] print(fourSum(nums, 0))
class Solution(object): def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ result = [] i, j = 0, 0 nums1 = sorted(nums1) nums2 = sorted(nums2) while i < len(nums1) and j < len(nums2): left = nums1[i] right = nums2[j] if left > right: j += 1 elif left < right: i += 1 else: result.append(left) i += 1 j += 1 return result
x = 1 while x < 20: # Tant que i est inférieure à 20 if x % 3 == 0: x += 4 # On ajoute 4 à i print("On incrémente x de 4") if x == 7: continue # On retourne au while sans exécuter les autres lignes print("x n'était pas égale à 7 mais à",x,"c'est pour ça qu'on est là\n") print("La variable x =", x) x += 1 # Dans le cas classique on ajoute juste 1 à x print("\nallez aurevoir", x)
class Shift: def __init__(self, id, ansvar, tid_fra, tid_til, antall_timer, weight, sted, antrekk): self.id = id self.responsibility = ansvar self.time_from = tid_fra self.time_to = tid_til self.hours = antall_timer self.weight = weight self.allocated = False self.place = sted self.outfit = antrekk def __str__(self): return "id: {}, responsibility id: {}, dato: {}, starttid: {}, sluttid: {}".format( self.id, self.responsibility, self.date_from, self.time_from, self.time_to)
''' The UndoController receives command objects (both simple and compound) from the Controllers It keeps a history list of operations The UI tells it when to call these stored commands ''' class UndoController: def __init__(self): # # History list of operations for undo/redo # self._operations = [] self._index = -1 self._duringCallback = False def recordOperation(self, cascadedOp): if self._duringCallback == True: return ''' No redos after a new operation ''' self._operations = self._operations[0:self._index + 1] ''' Add the new cascaded operation ''' self._operations.append(cascadedOp) self._index += 1 def undo(self): if self._index < 0: return False self._duringCallback = True self._operations[self._index].undo() self._duringCallback = False self._index -= 1 return True def redo(self): if self._index + 1 >= len(self._operations): return False self._duringCallback = True self._index += 1 self._operations[self._index].redo() self._duringCallback = False return True class FunctionCall: def __init__(self, functionRef, *parameters): self._functionRef = functionRef self._parameters = parameters def call(self): self._functionRef(*self._parameters) """ Represents a non-compound Command object """ class Operation: def __init__(self, functionDo, functionUndo): self._functionDo = functionDo self._functionUndo = functionUndo def undo(self): self._functionUndo.call() def redo(self): self._functionDo.call() """ Represents a compound Command object """ class CascadedOperation: def __init__(self, op=None): self._operations = [] if op != None: self.add(op) def add(self, op): self._operations.append(op) def undo(self): for i in range(len(self._operations) - 1, -1, -1): self._operations[i].undo() def redo(self): for i in range(len(self._operations) - 1, -1, -1): self._operations[i].redo()
# 回收站选址 def st191202(): n=int(input()) dians=[] num=[0,0,0,0,0] for i in range(n): dians.append(list(map(int, input().split()))) # print(dians) for dian in dians: x = dian[0] y = dian[1] temp = 0 #当前点四个对角垃圾数 if [x, y + 1] in dians and [x, y - 1] in dians and [x + 1, y] in dians and [x - 1, y] in dians: if [x + 1, y + 1] in dians: temp += 1 if [x + 1, y - 1] in dians: temp += 1 if [x - 1, y + 1] in dians: temp += 1 if [x - 1, y - 1] in dians: temp += 1 if temp == 0: num[0] += 1 elif temp == 1: num[1] += 1 elif temp == 2: num[2] += 1 elif temp == 3: num[3] += 1 elif temp == 4: num[4] += 1 for i in num: print(i) if __name__ == '__main__': st191202()
BZX = Contract.from_abi("BZX", "0xfe4F0eb0A1Ad109185c9AaDE64C48ff8e928e54B", interface.IBZx.abi) TOKEN_REGISTRY = Contract.from_abi("TOKEN_REGISTRY", "0x5a6f1e81334C63DE0183A4a3864bD5CeC4151c27", TokenRegistry.abi) list = TOKEN_REGISTRY.getTokens(0, 100) for l in list: iTokenTemp = Contract.from_abi("iTokenTemp", l[0], LoanTokenLogicStandard.abi) globals()[iTokenTemp.symbol()] = iTokenTemp underlyingTemp = Contract.from_abi("underlyingTemp", l[1], TestToken.abi) globals()[underlyingTemp.symbol()] = underlyingTemp CHEF = Contract.from_abi("CHEF", "0xd39Ff512C3e55373a30E94BB1398651420Ae1D43", MasterChef_Polygon.abi) PGOV = Contract.from_abi("PGOV", "0xd5d84e75f48E75f01fb2EB6dFD8eA148eE3d0FEb", GovToken.abi) PGOV_MATIC_LP = Contract.from_abi("PGOV", "0xC698b8a1391F88F497A4EF169cA85b492860b502", interface.ERC20.abi) HELPER = Contract.from_abi("HELPER", "0xCc0fD6AA1F92e18D103A7294238Fdf558008725a", HelperImpl.abi) PRICE_FEED = Contract.from_abi("PRICE_FEED", BZX.priceFeeds(), abi = PriceFeeds.abi) SUSHI_ROUTER = Contract.from_abi("router", "0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506", interface.IPancakeRouter02.abi)
# -*- coding: utf-8 -*- """ __author__ = "Jani Yli-Kantola" __copyright__ = "" __credits__ = ["Harri Hirvonsalo", "Aleksi Palomäki"] __license__ = "MIT" __version__ = "1.3.0" __maintainer__ = "Jani Yli-Kantola" __contact__ = "https://github.com/HIIT/mydata-stack" __status__ = "Development" """ schema_account_new = { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {}, "id": "http://example.com/example.json", "properties": { "data": { "properties": { "attributes": { "properties": { "firstname": { "maxLength": 250, "minLength": 3, "pattern": "[a-zA-Z]+", "type": "string" }, "lastname": { "maxLength": 250, "minLength": 3, "pattern": "[a-zA-Z]+", "type": "string" }, "password": { "maxLength": 20, "minLength": 4, "pattern": "[a-zA-Z0-9!#¤%&/()=?+_-]+", "type": "string" }, "username": { "maxLength": 250, "minLength": 3, "pattern": "[a-zA-Z0-9!#¤%&/()=?+_-]+", "type": "string" } }, "required": [ "username", "lastname", "password", "firstname" ], "type": "object" }, "type": { "maxLength": 250, "minLength": 3, "pattern": "[a-zA-Z0-9!#¤%&/()=?+_-]+", "type": "string" } }, "required": [ "attributes", "type" ], "type": "object" } }, "required": [ "data" ], "type": "object" } schema_account_info = { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": {}, "id": "http://example.com/example.json", "properties": { "data": { "properties": { "attributes": { "properties": { "avatar": { "type": "string" }, "firstname": { "type": "string" }, "lastname": { "type": "string" } }, "type": "object" }, "id": { "type": "string" }, "type": { "type": "string" } }, "required": [ "attributes", "type", "id" ], "type": "object" } }, "required": [ "data" ], "type": "object" }
class StoredAttachmentsManager: PROVIDER_ID_FIELD = 'id' URL_FIELD = 'url' CAPTION_FIELD = 'content' CREDIT_FIELD = 'excerpt' items_collection = 'attachments' response_collection = 'imported_images' original_key_fields = ['id', 'url'] # item = {i: original_item[i] for i in self.original_key_fields} # def __init__(self, roar_id, attachments_source): def __init__(self, db): self.db = db def get_image_info_by_id(self, attachment_id): item = self.db[self.response_collection].find_one({'id': attachment_id}) if item: return item['response'] raise KeyError() def get_image_info_by_url(self, url): item = self.db[self.response_collection].find_one({'url': url}) if item: return item['response'] raise KeyError() def get_caption_and_credit(self, attachment_id): # return (caption, credit) item = self.db[self.items_collection].find_one({'id': attachment_id}) return (item['content'] or '', item['excerpt'] or '') class WpAuthorsManager: author_key_field = 'login' author_id_field = 'id' response_collection = 'imported_authors' def __init__(self, db): self.db = db def get_by_key(self, author_key): item = self.db[self.response_collection].find_one({'login': author_key}) if item: return item['response'] raise KeyError() class WpSectionsManager: URL_FIELD = 'url' TITLE_FIELD = 'title' STATUS_FIELD = 'status' # optional response_collection = 'imported_sections' # def __init__(self, roar_id, sections_source): def __init__(self, db): self.db = db self.url_mapping = {} items = self.db[self.response_collection].find({}) self.sections_map = { item[self.URL_FIELD]: item['response']['id'] for item in items } def get_by_slug(self, slug): return self.sections_map[slug]
class EventException(BaseException): pass class EventCancelled(EventException): def __init__(self, evt): EventException.__init__(self) self.evt = evt class EventDeferred(EventException): pass class EventData(object): """Object passed into emitted events Attributes ---------- name : str Name of event source : Emitter Source of event data : object Data passed in cancelled : bool Whether this event should continue to propagate. Use Event.cancel() to cancel an event errors : list List of exceptions this event has encountered success : Bool Whether this event has successfully executed deferred : Bool If True, this is the second time this function is called Methods ------- cancel Cancel this event if cancellable """ def __init__(self, name, source, data=None, cancellable=True): self.name = name self.source = source self.data = data self.cancelled = False self.cancellable = cancellable self.errors = [] self.deferred = False def cancel(self): """Cancel this event if possible This halts the active callback """ if self.cancellable: self.cancelled = True raise EventCancelled(self) def defer(self): """Call the current callback again later. This will cause all lines before the defer to run again, so please use at the start of the file. Examples -------- >>> emitter = Emitter() >>> @emitter.on('some_event') def my_func1(evt): evt.defer() print('Callback #1 called!') >>> @emitter.on('some_event') def my_func2(evt): print('Callback #2 called!') >>> emitter.fire('some_event') Callback #2 called! Callback #1 called! """ if not self.deferred: raise EventDeferred def add_error(self, err): """Adds an error to the list of errors this event came across Parameters ---------- err : Exception """ self.errors.append(err) @property def success(self): """Whether or not this event has successfully executed""" return not self.cancelled and not self.errors
# https://www.hackerrank.com/challenges/acm-icpc-team def union(p1, p2): return [t1 | t2 for t1, t2 in zip(p1, p2)] def acm_icpc_team(persons): max_t, max_qty = 0, 0 for i, p1 in enumerate(persons): for j, p2 in enumerate(persons[(i + 1):], i + 1): t = sum(union(p1, p2)) if t == max_t: max_qty += 1 elif t > max_t: max_t, max_qty = t, 1 return max_t, max_qty n, m = [int(x) for x in input().split(' ')] persons = [[int(x) for x in list(input())] for p in range(n)] print("%d\n%d" % (acm_icpc_team(persons)))
# Sets are unordered collection of objects # Creating Sets sets = {1, 2, 3, 4, 5} print(sets) print(type(sets)) hs = {1, 1.0, "Hello", True, (1, 2, 3)} print(hs) # We can't add duplicate elements in sets s = {1, 2, 3, 4, 2, 43, 2, 3, 4, 1} print(s) # create an empty set se = set() print(type(se)) # We can't declare empty set using curly braces se1 = {} print(type(se1)) # Adding some data into sets """1. add()""" m_set = {1, 3, 4, 5} print("set before adding", m_set) m_set.add(6) print("After adding single element", m_set) """2. Update()""" m_set.update([2, 7, 8]) print("Updated using list", m_set) m_set.update({9, 10, 11}) print("Updated using set", m_set) # Deleting items from set """1. discard()""" m_set.discard(10) print(m_set) """2.remove()""" m_set.remove(2) print(m_set) """3.pop()""" m_set.pop() print(m_set) """4.clear()""" m_set.clear() print(m_set) # Operations in sets A = {1, 2, 3, 4, 5} B = {6, 7, 8, 9, 0, 4, 1, 3} print("Set-A declaration", A) print("Set-B declaration", B) """1. Set Union""" print("union of A,B", A | B) print("union of A,B", B.union(A)) """2. Intersection""" print("Intersection of A,B", A & B) print("Intersection of A,B", A.intersection(B)) """3. Difference""" print("Difference btw A,B", A - B) print("Difference btw A,B", A.difference(B)) """4. Symmetric Difference""" print("Symmetric-Difference btw A,B", A ^ B) print("Symmetric-Difference btw A,B", A.symmetric_difference(B)) """ <<<<<<< HEAD 5. isdisjoint(value) Determines whether or not two sets have any elements in common returns True if x1 and x2 have no items in common """ x1 = {"foo", "bar", "baz"} x2 = {"baz", "qux", "cux"} print(x1.isdisjoint(x2)) print(x1.isdisjoint(x2 - {"baz"})) """ 6. x1.issubset(x2) / x1 <= x2 returns True if x1 is usbset of x2 and viceversa """ num1 = {2, 3, 4} print(num1.issubset({1, 2, 3, 4, 5, 6, 7, 8, 9})) print(num1 <= {2, 3, 4}) print(num1 < {2, 3, 4}) """ 7. issuperset() superset is reverse of subset returns true if x1 is superset of x2 """ print(x1.issuperset({"foo"})) print(x1 >= {"foo"}) print(x1 > {"foo", "bar", "baz"}) """ 8. intersection_update() or &= updates the current set with common elements btw both of them """ x1.intersection_update(x2) print(x1) """ 9. difference_update() or -= modify set by difference """ x1.difference_update(x2) print(x1) """ 10. symmetric_difference_update() or ^= update x1, retining elements found in either x1 or x2 but not in both """ x1.symmetric_difference_update(x2) print(x1) """ Frozen Sets Python provides another built-in type called a frozenset, which is in all respects exactly like a set, except that a frozenset is immutable. You can perform non-modifying operations on a frozenset. """ fs = frozenset(["foo", "bar", "zoo"]) print("The frozen set is {}".format(fs)) print("Length of frozen set is {}".format(fs)) # intersectioin operation with frozenset print("The intersection operation results: ", fs & {"baz", "qux", "quux"}) # restrictions with frozenset """ >>> fs.add('quz') Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'frozenset' object has no attribute 'add' >>> fs.pop() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'frozenset' object has no attribute 'pop' >>> fs.clear() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'frozenset' object has no attribute 'clear' """ # Frozensets and Augmented Assignment """ Python does not perform augmented assignments on frozensets in place. The statement x &= s is effectively equivalent to x = x & s. It isn’t modifying the original x. It is reassigning x to a new object, and the object x originally referenced is gone. """ f = frozenset(["foo", "bar", "baz"]) print("Originally created frozenset memory id : {}".format(id(f))) # augmented assignment f &= s print("ID of f after augemented assignment is {}".format(id(f))) # Creating dict with frozensets """As sets are unhashable we can't use them to create dict obj but as frozenset are immutable we can use them as keys and other iterable obj as keys""" x = frozenset({1, 2, 3}) y = frozenset({"a", "b", "c"}) d = {x: "foo", y: "bar"} print("The newly created dict obj is {}".format(d))
# Challenge 10 : Create a function named reversed_list() that takes two lists of the same size as parameters named lst1 and lst2. # The function should return True if lst1 is the same as lst2 reversed. # The function should return False otherwise. # Date : Sun 07 Jun 2020 09:43:32 AM IST def reversed_list(lst1, lst2): for index in range(len(lst1)): if lst1[index] != lst2[len(lst2) - 1 - index]: return False return True print(reversed_list([1, 2, 3], [3, 2, 1])) print(reversed_list([1, 5, 3], [3, 2, 1]))
@tf_export('compat.path_to_str') def path_to_str(path): r"""Converts input which is a `PathLike` object to `str` type. Converts from any python constant representation of a `PathLike` object to a string. If the input is not a `PathLike` object, simply returns the input. Args: path: An object that can be converted to path representation. Returns: A `str` object. Usage: In case a simplified `str` version of the path is needed from an `os.PathLike` object Examples: ```python $ tf.compat.path_to_str('C:\XYZ\tensorflow\./.././tensorflow') 'C:\XYZ\tensorflow\./.././tensorflow' # Windows OS $ tf.compat.path_to_str(Path('C:\XYZ\tensorflow\./.././tensorflow')) 'C:\XYZ\tensorflow\..\tensorflow' # Windows OS $ tf.compat.path_to_str(Path('./corpus')) 'corpus' # Linux OS $ tf.compat.path_to_str('./.././Corpus') './.././Corpus' # Linux OS $ tf.compat.path_to_str(Path('./.././Corpus')) '../Corpus' # Linux OS $ tf.compat.path_to_str(Path('./..////../')) '../..' # Linux OS ``` """ if hasattr(path, '__fspath__'): path = as_str_any(path.__fspath__()) return path
__theme_meta__ = { 'author': "Baseline Core Team", 'title': "Baseline 2015", 'url': "https://github.com/loftylabs/baseline/", 'version': "0.1a", 'description': "The default Baseline theme.", }
#Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. # #The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ l=[] for i in s: if i in '[({': l.append(i) elif len(l) and ord(i)<ord(l[-1])+3: l.pop() else: return False return not len(l)
class Cache(dict): # this class has some retarded methods like add_key but only i use it so not much of a problem @classmethod def from_dict(cls, other: dict): return cls(other) def insert(self, key, value): # this method allows you to do something like add_key([1, 2, 3], 4) and it would add 1, 2 and 3 keys # with the 4 value this would indeed fuck up the create_opposite_copy method by overriding keys # for example, {1: 2, 3: 4, 10: 9, 11: 9} would try to turn into {2: 1, 4: 3, 9: 10, 9: 11} and end up # deleting the 9: 10 key value pair if isinstance(key, list): for actual in key: self[actual] = value else: self[key] = value return self add_key = insert def delete(self, key): if key in self: del self[key] return self raise RuntimeError(f"Key {key} is not in cache") def get_or_create(self, key, value=None): """Return the value of the given key if found else create new key and return the value""" if key in self.keys(): return self[key] # key doesnt exist so create it return self.add_key(key, value) def contains(self, key) -> bool: return key in self.keys() has = contains def reverse(self): """ Create a copy of the current dict with its keys and values reversed. For example, doing.... ``Cache({1: 2}).create_opposite_copy()`` would return ``Cache({2: 1})`` Gets fucked up when multiple values are the same. """ new = {value: key for key, value in self.items()} return create_new_cache(new) def __str__(self): return f"Cache({super().__str__()})" def create_new_cache(initial_data: dict = None): return Cache() if not initial_data else Cache.from_dict(initial_data)
''' Write a function that takes a non-empty array of distinct integers, and an integer representing a target sum. If any two numbers in the array sum upto the target sum, return the two numbers Else, return an empty array. ''' # Prompt: # Distinct & non-empty integer array # Returns two integers - any order # Return empty ARRAY else # No doubling; # At most one pair of numbers summing up to target only def twoNumberSum(array, targetSum): for i in range(0, len(array)-1): for j in range(i+1, len(array)): if array[i] + array[j] == targetSum: return [array[i], array[j]] else: return [] def twoNumSumHash(array, targetSum): # create hash table myHashTable = {} for i in range(0, len(array)): if targetSum - array[i] in myHashTable: return [array[i], targetSum - array[i]] else: myHashTable[array[i]] = True return [] def twoNumSumLeftRight(array, targetSum): array.sort() leftPointer = 0 rightPointer = len(array) - 1 while leftPointer < rightPointer: if array[leftPointer] + array[rightPointer] > targetSum: rightPointer -=1 elif array[leftPointer] + array[rightPointer] < targetSum: leftPointer +=1 else: return [array[leftPointer], array[rightPointer]] return [] def main(): # Time Complexity - O(N^2), Space complexity - O(1) x = twoNumberSum([1, 4, -3, 5, 7], 9) print(x) # Time Complexity - O(N), Space complexity - O(N) y = twoNumSumHash([1, 4, -3, 5, 7], 9) print(y) # Time Complexity - O(N logN), Space complexity - O(1) z = twoNumSumLeftRight([3, 5, -1, -2, 7, 4, 10], 9) print(z) if __name__== "__main__": main()
# Sets - A set is an unordered collection of items. # Creating Sets set_nums = {9, 10, 1, 4, 3, 2, 5, 0} set_empty = {} set_names = {'John', 'Kim', 'Kelly', 'Dora', False} # all (True if all items are true or empty set) print(" all - ".center(30, "-")) print('set_nums : ', all(set_nums)) print('set_nums2 : ', all(set_empty)) # any (True if any of the items is true) print(" any - ".center(30, "-")) print('set_nums : ', any(set_nums)) print('set_nums2 : ', any(set_empty)) # len print(" len - ".center(30, "-")) print(len(set_nums)) # max print(" max - ".center(30, "-")) print(max(set_nums)) # min print(" min - ".center(30, "-")) print(min(set_nums)) # sorted print(" sorted - ".center(30, "-")) print(sorted(set_nums)) print(sorted(set_nums, reverse = True)) # sum print(" sum - ".center(30, "-")) print(sum(set_nums))
"""Pika specific exceptions""" class AMQPError(Exception): def __repr__(self): return '%s: An unspecified AMQP error has occurred; %s' % ( self.__class__.__name__, self.args) class AMQPConnectionError(AMQPError): def __repr__(self): if len(self.args) == 2: return '{}: ({}) {}'.format(self.__class__.__name__, self.args[0], self.args[1]) else: return '{}: {}'.format(self.__class__.__name__, self.args) class ConnectionOpenAborted(AMQPConnectionError): """Client closed connection while opening.""" pass class StreamLostError(AMQPConnectionError): """Stream (TCP) connection lost.""" pass class IncompatibleProtocolError(AMQPConnectionError): def __repr__(self): return ('%s: The protocol returned by the server is not supported: %s' % (self.__class__.__name__, self.args,)) class AuthenticationError(AMQPConnectionError): def __repr__(self): return ('%s: Server and client could not negotiate use of the %s ' 'authentication mechanism' % (self.__class__.__name__, self.args[0])) class ProbableAuthenticationError(AMQPConnectionError): def __repr__(self): return ( '%s: Client was disconnected at a connection stage indicating a ' 'probable authentication error: %s' % (self.__class__.__name__, self.args,)) class ProbableAccessDeniedError(AMQPConnectionError): def __repr__(self): return ( '%s: Client was disconnected at a connection stage indicating a ' 'probable denial of access to the specified virtual host: %s' % (self.__class__.__name__, self.args,)) class NoFreeChannels(AMQPConnectionError): def __repr__(self): return '%s: The connection has run out of free channels' % ( self.__class__.__name__) class ConnectionWrongStateError(AMQPConnectionError): """Connection is in wrong state for the requested operation.""" def __repr__(self): if self.args: return super(ConnectionWrongStateError, self).__repr__() else: return ('%s: The connection is in wrong state for the requested ' 'operation.' % (self.__class__.__name__)) class ConnectionClosed(AMQPConnectionError): def __init__(self, reply_code, reply_text): """ :param int reply_code: reply-code that was used in user's or broker's `Connection.Close` method. NEW in v1.0.0 :param str reply_text: reply-text that was used in user's or broker's `Connection.Close` method. Human-readable string corresponding to `reply_code`. NEW in v1.0.0 """ super(ConnectionClosed, self).__init__(int(reply_code), str(reply_text)) def __repr__(self): return '{}: ({}) {!r}'.format(self.__class__.__name__, self.reply_code, self.reply_text) @property def reply_code(self): """ NEW in v1.0.0 :rtype: int """ return self.args[0] @property def reply_text(self): """ NEW in v1.0.0 :rtype: str """ return self.args[1] class ConnectionClosedByBroker(ConnectionClosed): """Connection.Close from broker.""" pass class ConnectionClosedByClient(ConnectionClosed): """Connection was closed at request of Pika client.""" pass class ConnectionBlockedTimeout(AMQPConnectionError): """RabbitMQ-specific: timed out waiting for connection.unblocked.""" pass class AMQPHeartbeatTimeout(AMQPConnectionError): """Connection was dropped as result of heartbeat timeout.""" pass class AMQPChannelError(AMQPError): def __repr__(self): return '{}: {!r}'.format(self.__class__.__name__, self.args) class ChannelWrongStateError(AMQPChannelError): """Channel is in wrong state for the requested operation.""" pass class ChannelClosed(AMQPChannelError): """The channel closed by client or by broker """ def __init__(self, reply_code, reply_text): """ :param int reply_code: reply-code that was used in user's or broker's `Channel.Close` method. One of the AMQP-defined Channel Errors. NEW in v1.0.0 :param str reply_text: reply-text that was used in user's or broker's `Channel.Close` method. Human-readable string corresponding to `reply_code`; NEW in v1.0.0 """ super(ChannelClosed, self).__init__(int(reply_code), str(reply_text)) def __repr__(self): return '{}: ({}) {!r}'.format(self.__class__.__name__, self.reply_code, self.reply_text) @property def reply_code(self): """ NEW in v1.0.0 :rtype: int """ return self.args[0] @property def reply_text(self): """ NEW in v1.0.0 :rtype: str """ return self.args[1] class ChannelClosedByBroker(ChannelClosed): """`Channel.Close` from broker; may be passed as reason to channel's on-closed callback of non-blocking connection adapters or raised by `BlockingConnection`. NEW in v1.0.0 """ pass class ChannelClosedByClient(ChannelClosed): """Channel closed by client upon receipt of `Channel.CloseOk`; may be passed as reason to channel's on-closed callback of non-blocking connection adapters, but not raised by `BlockingConnection`. NEW in v1.0.0 """ pass class DuplicateConsumerTag(AMQPChannelError): def __repr__(self): return ('%s: The consumer tag specified already exists for this ' 'channel: %s' % (self.__class__.__name__, self.args[0])) class ConsumerCancelled(AMQPChannelError): def __repr__(self): return '%s: Server cancelled consumer' % (self.__class__.__name__) class UnroutableError(AMQPChannelError): """Exception containing one or more unroutable messages returned by broker via Basic.Return. Used by BlockingChannel. In publisher-acknowledgements mode, this is raised upon receipt of Basic.Ack from broker; in the event of Basic.Nack from broker, `NackError` is raised instead """ def __init__(self, messages): """ :param messages: sequence of returned unroutable messages :type messages: sequence of `blocking_connection.ReturnedMessage` objects """ super(UnroutableError, self).__init__( "%s unroutable message(s) returned" % (len(messages))) self.messages = messages def __repr__(self): return '%s: %i unroutable messages returned by broker' % ( self.__class__.__name__, len(self.messages)) class NackError(AMQPChannelError): """This exception is raised when a message published in publisher-acknowledgements mode is Nack'ed by the broker. Used by BlockingChannel. """ def __init__(self, messages): """ :param messages: sequence of returned unroutable messages :type messages: sequence of `blocking_connection.ReturnedMessage` objects """ super(NackError, self).__init__( "%s message(s) NACKed" % (len(messages))) self.messages = messages def __repr__(self): return '%s: %i unroutable messages returned by broker' % ( self.__class__.__name__, len(self.messages)) class InvalidChannelNumber(AMQPError): def __repr__(self): return '%s: An invalid channel number has been specified: %s' % ( self.__class__.__name__, self.args[0]) class ProtocolSyntaxError(AMQPError): def __repr__(self): return '%s: An unspecified protocol syntax error occurred' % ( self.__class__.__name__) class UnexpectedFrameError(ProtocolSyntaxError): def __repr__(self): return '%s: Received a frame out of sequence: %r' % ( self.__class__.__name__, self.args[0]) class ProtocolVersionMismatch(ProtocolSyntaxError): def __repr__(self): return '%s: Protocol versions did not match: %r vs %r' % ( self.__class__.__name__, self.args[0], self.args[1]) class BodyTooLongError(ProtocolSyntaxError): def __repr__(self): return ('%s: Received too many bytes for a message delivery: ' 'Received %i, expected %i' % (self.__class__.__name__, self.args[0], self.args[1])) class InvalidFrameError(ProtocolSyntaxError): def __repr__(self): return '%s: Invalid frame received: %r' % (self.__class__.__name__, self.args[0]) class InvalidFieldTypeException(ProtocolSyntaxError): def __repr__(self): return '%s: Unsupported field kind %s' % (self.__class__.__name__, self.args[0]) class UnsupportedAMQPFieldException(ProtocolSyntaxError): def __repr__(self): return '%s: Unsupported field kind %s' % (self.__class__.__name__, type(self.args[1])) class MethodNotImplemented(AMQPError): pass class ChannelError(Exception): def __repr__(self): return '%s: An unspecified error occurred with the Channel' % ( self.__class__.__name__) class InvalidMinimumFrameSize(ProtocolSyntaxError): """ DEPRECATED; pika.connection.Parameters.frame_max property setter now raises the standard `ValueError` exception when the value is out of bounds. """ def __repr__(self): return '%s: AMQP Minimum Frame Size is 4096 Bytes' % ( self.__class__.__name__) class InvalidMaximumFrameSize(ProtocolSyntaxError): """ DEPRECATED; pika.connection.Parameters.frame_max property setter now raises the standard `ValueError` exception when the value is out of bounds. """ def __repr__(self): return '%s: AMQP Maximum Frame Size is 131072 Bytes' % ( self.__class__.__name__) class ReentrancyError(Exception): """The requested operation would result in unsupported recursion or reentrancy. Used by BlockingConnection/BlockingChannel """ class ShortStringTooLong(AMQPError): def __repr__(self): return ('%s: AMQP Short String can contain up to 255 bytes: ' '%.300s' % (self.__class__.__name__, self.args[0])) class DuplicateGetOkCallback(ChannelError): def __repr__(self): return ('%s: basic_get can only be called again after the callback for ' 'the previous basic_get is executed' % self.__class__.__name__)
def square(number): """ return the square """ return number ** 2 print(square(5))
# Copyright 2014 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. { 'variables': { 'chromium_code': 1, }, 'targets': [ { 'target_name': 'athena_main_lib', 'type': 'static_library', 'dependencies': [ '../athena.gyp:athena_lib', '../athena.gyp:athena_content_lib', '../athena.gyp:athena_content_support_lib', '../resources/athena_resources.gyp:athena_resources', # debug_widow.cc depends on this. Remove this once debug_window # is removed. '../../ash/ash_resources.gyp:ash_resources', '../../chromeos/chromeos.gyp:power_manager_proto', '../../components/components.gyp:component_metrics_proto', '../../components/components.gyp:history_core_browser', # infobars_test_support is required to declare some symbols used in the # search_engines and its dependencies. See crbug.com/386171 # TODO(mukai): declare those symbols for Athena. '../../components/components.gyp:infobars_test_support', '../../components/components.gyp:omnibox', '../../components/components.gyp:search_engines', '../../skia/skia.gyp:skia', '../../ui/app_list/app_list.gyp:app_list', '../../ui/chromeos/ui_chromeos.gyp:ui_chromeos', '../../ui/native_theme/native_theme.gyp:native_theme', '../../ui/views/views.gyp:views', '../../url/url.gyp:url_lib', ], 'include_dirs': [ '../..', ], 'sources': [ 'athena_launcher.cc', 'athena_launcher.h', 'debug/debug_window.cc', 'debug/debug_window.h', 'debug/network_selector.cc', 'debug/network_selector.h', 'url_search_provider.cc', 'url_search_provider.h', 'placeholder.cc', 'placeholder.h', ], }, { 'target_name': 'athena_main', 'type': 'executable', 'dependencies': [ '../../ui/accessibility/accessibility.gyp:ax_gen', '../resources/athena_resources.gyp:athena_pak', '../../extensions/shell/app_shell.gyp:app_shell_lib', 'athena_main_lib', ], 'include_dirs': [ '../..', ], 'sources': [ 'athena_app_window_controller.cc', 'athena_app_window_controller.h', 'athena_main.cc', ], } ], # targets }
"""Tests that a failed pytest properly displays the call stack. Uses the output from running pytest with pytest_plugin_failing_test.py. Regression test for #381. """ def test_failed_testresult_stacktrace(): with open('testresult.txt') as f: contents = f.read() # before the fix, a triple question mark has been displayed # instead of the stacktrace assert contents print('contents', contents) assert '???' not in contents assert 'AttributeError' not in contents assert 'def test_fs(fs):' in contents
''' Given a string s consisting of small English letters, find and return the first instance of a non-repeating character in it. If there is no such character, return '_'. Example For s = "abacabad", the output should be first_not_repeating_character(s) = 'c'. There are 2 non-repeating characters in the string: 'c' and 'd'. Return c since it appears in the string first. For s = "abacabaabacaba", the output should be first_not_repeating_character(s) = '_'. There are no characters in this string that do not repeat. [execution time limit] 4 seconds (py3) [input] string s A string that contains only lowercase English letters. [output] char The first non-repeating character in s of '_' if there are no characters that do not repeat. ''' def first_not_repeating_character(s): # create a dict with key of letter, value of increments of how many time the letters appear # add the order of the character to a list # loop through letter order, find the len of 1 in the dict # return that letter letter_order = [] dict = {} for letter in s: if letter in dict: dict[letter] += 1 else: dict[letter] = 1 letter_order.append(letter) print(dict) print(letter_order) for letter in letter_order: if dict[letter] == 1: return letter return "_" ''' Time complexity: O(n+n) ~ O(n) Space complexity: O(n) ''' print(first_not_repeating_character("abacabad")) print(first_not_repeating_character("abacabaabacaba"))
{ "targets": [ { "target_name": "binding-helloworld", "sources": [ "src/cpp/binding-helloworld.cc" ] }, { "target_name": "binding-fibonacci", "sources": [ "src/cpp/binding-fibonacci.cc" ] } ] }
{ "targets": [{ "include_dirs" : [ "<!(node -e \"require('nan')\")" ], "defines": [ "PSAPI_VERSION=1", "METRO_APPS=1" ], "libraries": ["-lPsapi"], "target_name": "whoisopen", "sources": ["src/whoisopen.cc"] }] }
# The read4 API is already defined for you. # @param buf, a list of characters # @return an integer # def read4(buf): class Solution(object): def __init__(self): self.queue = collections.deque() def read(self, buf, n): """ :type buf: Destination buffer (List[str]) :type n: Maximum number of characters to read (int) :rtype: The number of characters read (int) """ buf4 = [""] * 4 i = 0 while True: l = read4(buf4) self.queue.extend(buf4[:l]) need = min(len(self.queue), n - i) for j in range(need): buf[i] = self.queue.popleft() i += 1 if not need: break return i
""" Defines the Union-Find (or Disjoint Set) data structure. A disjoint set is made up of a number of elements contained within another number of sets. Initially, elements are put in their own set, but sets may be merged using the `unite` operation. We can check if two elements are in the same seet by comparing their `root`s. If they are identical, the two elements are in the same set. All operations can be completed in O(a(n)) where `n` is the number of elements, and `a` the inverse ackermann function. a(n) grows so slowly that it might as well be constant for any conceivable `n`. """ class Union: """ A Union-Find data structure. Consider the following sequence of events: Starting with the elements 1, 2, 3, and 4: {1} {2} {3} {4} Initally they all live in their own sets, which means that `root(1) != root(3)`, however, if we call `unite(1, 3)` we would then have the following: {1,3} {2} {4} Now we have `root(1) == root(3)`, but it is still the case that `root(1) != root(2)`. We may call `unite(2, 4)` and end up with: {1,3} {2,4} Again we have `root(1) != root(2)`. But after `unite(3, 4)` we end up with: {1,2,3,4} which results in `root(1) == root(2)`. """ def __init__(self): self.parents = {} self.size = {} self.count = 0 def add(self, element): """ Add a new set containing the single element """ self.parents[element] = element self.size[element] = 1 self.count += 1 def root(self, element): """ Find the root element which represents the set of a given element. That is, all elements that are in the same set will return the same root element. """ while element != self.parents[element]: self.parents[element] = self.parents[self.parents[element]] element = self.parents[element] return element def unite(self, element1, element2): """ Finds the sets which contains the two elements and merges them into a single set. """ root1, root2 = self.root(element1), self.root(element2) if root1 == root2: return if self.size[root1] > self.size[root2]: root1, root2 = root2, root1 self.parents[root1] = root2 self.size[root2] += self.size[root1] self.count -= 1 def num_islands(positions): """ Given a list of positions to operate, count the number of islands after each addLand operation. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water. Given a 3x3 grid, positions = [[0,0], [0,1], [1,2], [2,1]]. Initially, the 2d grid grid is filled with water. (Assume 0 represents water and 1 represents land). 0 0 0 0 0 0 0 0 0 Operation #1: addLand(0, 0) turns the water at grid[0][0] into a land. 1 0 0 0 0 0 Number of islands = 1 0 0 0 Operation #2: addLand(0, 1) turns the water at grid[0][1] into a land. 1 1 0 0 0 0 Number of islands = 1 0 0 0 Operation #3: addLand(1, 2) turns the water at grid[1][2] into a land. 1 1 0 0 0 1 Number of islands = 2 0 0 0 Operation #4: addLand(2, 1) turns the water at grid[2][1] into a land. 1 1 0 0 0 1 Number of islands = 3 0 1 0 """ ans = [] islands = Union() for position in map(tuple, positions): islands.add(position) for delta in (0, 1), (0, -1), (1, 0), (-1, 0): adjacent = (position[0] + delta[0], position[1] + delta[1]) if adjacent in islands.parents: islands.unite(position, adjacent) ans += [islands.count] return ans
#!/usr/bin/env python """ Drop, create table statements generators from 'SqlTable' objects. """ __author__ = "Yaroslav Litvinov" __copyright__ = "Copyright 2016, Rackspace Inc." __email__ = "yaroslav.litvinov@rackspace.com" INDEX_ID_IDXS = 'a' INDEX_ID_PARENT_IDXS = 'b' INDEX_ID_ONLY = 'c' def generate_drop_table_statement(table, psql_schema_name, table_name_prefix): """ return drop table statement. params: table -- 'SqlTable' object psql_schema_name -- schema name in postgres where to drop table table_name_prefix -- table prefix, like 'yyyxxx_'""" if len(psql_schema_name): psql_schema_name += '.' query = 'DROP TABLE IF EXISTS %s"%s%s";' \ % (psql_schema_name, table_name_prefix, table.table_name) return query def generate_create_table_statement(table, psql_schema_name, table_name_prefix): """ return create table statement. params: table -- 'SqlTable' object psql_schema_name -- schema name in postgres where to create table table_name_prefix -- table prefix, like 'yyyxxx_'""" override_types = {'INT': 'INTEGER', 'STRING': 'TEXT', 'TIMESTAMP': 'TIMESTAMP WITH TIME ZONE', 'DOUBLE': 'FLOAT8', 'TINYINT': 'INT2'} cols = [] for colname in table.sql_column_names: sqlcol = table.sql_columns[colname] if sqlcol.typo in override_types.keys(): typo = override_types[sqlcol.typo] else: typo = sqlcol.typo cols.append('"%s" %s' % (sqlcol.name, typo)) if len(psql_schema_name) and psql_schema_name.find('.') == -1: psql_schema_name += '.' query = 'CREATE TABLE IF NOT EXISTS %s"%s%s" (%s);' \ % (psql_schema_name, table_name_prefix, table.table_name, ', '.join(cols)) return query def generate_create_index_statement(table, psql_schema_name, table_name_prefix, index_type): """ return create table index statement. params: table -- 'SqlTable' object psql_schema_name -- schema name in postgres where to create table table_name_prefix -- table prefix, like 'yyyxxx_'""" psql_index_columns = [] # add 'table internal indexes' to postgres indexes list # if table is not a root table if table.root.parent: for parent_idx_node in table.idx_nodes(): # if idx is related to own table if table.root.long_alias() == parent_idx_node.long_alias(): if index_type is INDEX_ID_IDXS: psql_index_columns.append('"idx"') else: if index_type is INDEX_ID_IDXS or \ index_type is INDEX_ID_PARENT_IDXS: alias = parent_idx_node.long_alias() psql_index_columns.append('"'+alias+'_idx"') # add super parent id id_node = table.root.super_parent().get_id_node() if index_type is INDEX_ID_IDXS or \ index_type is INDEX_ID_ONLY or \ index_type is INDEX_ID_PARENT_IDXS: if table.root.parent: psql_index_columns.append('"'+id_node.long_alias()+'"') else: psql_index_columns.append('"'+id_node.short_alias()+'"') # formate query if len(psql_schema_name) and psql_schema_name.find('.') == -1: psql_schema_name += '.' psql_index_columns.sort() # to have a determenistic order query = 'CREATE INDEX "i{type}_{prefix}{table}" \ ON {schema}"{prefix}{table}" ({index_columns});'.\ format(schema=psql_schema_name, prefix=table_name_prefix, table=table.table_name, index_columns=', '.join(psql_index_columns), type=str(index_type)) return query
def arr_mult(A,B): new = [] # Iterate over the rows of A. for i in range(len(A)): # Create a new row to insert into the product. newrow = [] # Iterate over the columns of B. # len(B[0]) returns the length of the first row # (the number of columns). for j in range(len(B[0])): # Initialize an empty total. tot = 0 # Multiply the elements of the row of A with # the column of B and sum the products. for k in range(len(B)): tot += A[i][k] * B[k][j] # Insert the value into the new row of the product. newrow.append(tot) # Insert the new row into the product. new.append(newrow) return new
""" File: rocket.py Name: Fangching Su ----------------------- This program should implement a console program that draws ASCII art - a rocket. The size of rocket is determined by a constant defined as SIZE at top of the file. Output format should match what is shown in the sample run in the Assignment 2 Handout. """ # CONSTANT SIZE = 9 def main(): """ TODO: call each function """ head() belt() upper() lower() belt() head() # head part def head(): # run size times for i in range(1, SIZE+1): # separate two for loop # left part for j in range(-SIZE+i, i+1): # judge when to print '/' if j > 0: print("/", end="") else: print(" ", end="") # right part for k in range(1, i+1): print("\\", end="") print() # belt part def belt(): print("+",end="") # judge need to print how many '=' for i in range(0, SIZE*2): print("=", end="") print("+") # upper part def upper(): # print SIZE line "|" for i in range(1, SIZE+1): print("|", end="") # separate two for loop # left part for j in range(-SIZE+i+1, i+1): # judge when to print '/\' if j > 0: print("/", end="") print("\\",end="") else: print(".", end="") # right part for k in range(i, SIZE): print(".", end="") print("|") # lower part def lower(): # print SIZE line "|" for i in range(1, SIZE + 1): print("|", end="") # separate two for loop # left part for j in range(-SIZE+i, i): if j > 0: print(".", end="") # right part for k in range(-SIZE+i, i): # judge when to print '\/' if k < 1: print("\\", end="") print("/", end="") else: print(".", end="") print("|") ###### DO NOT EDIT CODE BELOW THIS LINE ###### if __name__ == "__main__": main()
print('Exercício Python #015 - Aluguel de Carros') a8 = float(input('Quantos dias o carro ficou alugado? ')) b8 = float(input('Quantos Km ele andou? ')) c8 = (a8 * 60) + (b8 * 0.15) print(' Sendo {:.0f} dias e {} Km rodados, o valor do aluguel será R$ {}'.format(a8, b8, c8))
def pandigital_generator(): for perm in itertools.permutations(range(0,10)): if perm[0] != 0: yield functools.reduce(lambda x,y: x*10 + y, perm) def prime_generator(): yield 2 yield 3 yield 5 yield 7 yield 11 yield 13 yield 17 def has_p043_property(n): n_str = str(n) primes = prime_generator() return all(int(n_str[d:d+3]) % next(primes) == 0 for d in range(1, 8)) def solve_p043(): return sum(p for p in pandigital_generator() if has_p043_property(p))
n1 = float(input('Primeira nota: ')) n2 = float(input('Segunda nota: ')) media = (n1 + n2) / 2 print('Tirando {:.1f} e {:.1f}, a media do aluno é {:.1f}'.format(n1, n2, media)) if 7 > media >= 5: print('O Aluno está em Recuperação!!') elif media < 5: print('O Aluno está Reprovado!') elif media >= 7: print('O aluno está Aprovado!!!')
class PluginBase: instances = [] def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) cls.instances.append(cls()) def hello() -> list: results = [] for i in PluginBase.instances: results.append(i.hello()) return results class PluginA(PluginBase): def hello(self) -> str: return "hello from A" class PluginB(PluginBase): def hello(self) -> str: return "hello from B" for p in PluginBase.hello(): print(p) print('----------------------SECOND EXPERIMENT--------') class FancyPluginBase: instances = [] def __init_subclass__(cls, **kwargs): super().__init_subclass__(**kwargs) cls.instances.append(cls()) @staticmethod def accept(value: any) -> list: if type(value) == list: return value else: return [value] def dispatch(type: any = None) -> list: return [r for i in FancyPluginBase.instances for r in FancyPluginBase.accept(i.respond_to(type))] def respond_to(self, type: any = None) -> any: return [] class First(FancyPluginBase): def respond_to(self, type: any = None) -> any: return 'from first' class Second(FancyPluginBase): def respond_to(self, type: any = None) -> any: return ['from second'] class Third(FancyPluginBase): pass for p in FancyPluginBase.dispatch(): print(p)
def write_table_row(key, value): row = f"<tr><td>{key}</td><td>{value}</td></tr>" return row def write_doc_entry(idx, domain): fields = domain.get("fields") doc_entry = f'<tr><th colspan="2">Link {idx}</th></tr>' doc_entry += write_table_row( "URL", f"<a target=\"_blank\" rel=\"noopener noreferrer\" href=\"//www.{fields.get('url')}\">{fields.get('url')}</a>", ) doc_entry += write_table_row("Kontext", fields.get("context")) doc_entry += write_table_row("", "") return doc_entry def write_domain_table(domain_group): domain_table = "<table><style>th, td { padding-left: 15px; text-align: left; vertical-align: top;}</style>" for i, domain in enumerate(domain_group.get("children", [])): domain_table += write_doc_entry(i + 1, domain) domain_table += "</table>" return domain_table
# https://www.codewars.com/kata/how-good-are-you-really def better_than_average(class_points, your_points): counter = 0 sum = 0 output = True for i in class_points: sum += i counter += 1 if sum / counter >= your_points: output = False return output
# -*- coding: utf-8 -*- """ Model Map table building_use :author: Sergio Aparicio Vegas :version: 0.1 :date: 14 Sep. 2017 """ __docformat__ = "restructuredtext" class BuildingUse(): """ DB Entity building_use to Python object BuildingUse """ def __init__(self): self.__id = 0 self.__use = "" self.__non_office = True self.__floor_height = 0.0 self.__description = "" self.__associated_icon_file = "" def __str__(self): return "id:" + str(self.id) + " use:" + str(self.use) + " non_office:" + str(self.non_office) + " floor_height:" + str(self.floor_height) + " description:" + str(self.description) @property def id(self): return self.__id @id.setter def id(self, val): self.__id = val @property def use(self): return self.__use @use.setter def use(self, val): self.__use = val @property def non_office(self): return self.__non_office @non_office.setter def non_office(self, val): self.__non_office = bool(val) @property def floor_height(self): return self.__floor_height @floor_height.setter def floor_height(self, val): self.__floor_height = float(val.replace(",",".")) if isinstance(val,str) else float(val) @property def description(self): return self.__description @description.setter def description(self, val): self.__description = val @property def associated_icon_file(self): return self.__associated_icon_file @associated_icon_file.setter def associated_icon_file(self, val): self.__associated_icon_file = val
''' Given the head of a singly linked list, reverse the list, and return the reversed list. Example 1: Input: head = [1,2,3,4,5] Output: [5,4,3,2,1] Example 2: Input: head = [1,2] Output: [2,1] Example 3: Input: head = [] Output: [] Constraints: The number of nodes in the list is the range [0, 5000]. -5000 <= Node.val <= 5000 Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? ''' #iterative approach class Solution: def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: prev = None while head is not None: temp = head.next head.next = prev prev = head head = temp return prev #recursive approach class Solution: def reverseList(self, head: Optional[ListNode]) -> Optional[ListNode]: if head==None or head.next==None: return head return self.helper(head) def helper(self, head): if head==None or head.next==None: return head else: prev = self.helper(head.next) head.next.next = head head.next = None return prev
def dig_str(n): lista = [] st = str(n) for i in range(len(st)): lista.append(st[i]) return(sorted(lista)) def comparador_de_digitos(x,y): if dig_str(x) == dig_str(y): return(1) else: return(0) N = 1 while(True): if comparador_de_digitos(N, 2 * N) == 1 and comparador_de_digitos(N, 3 * N) == 1 and comparador_de_digitos(N, 4 * N) == 1 and comparador_de_digitos(N, 5 * N) == 1 and comparador_de_digitos(N, 6 * N) == 1: print(N) break else: N += 1
''' Author : MiKueen Level : Medium Problem Statement : Coin Change 2 You are given coins of different denominations and a total amount of money. Write a function to compute the number of combinations that make up that amount. You may assume that you have infinite number of each kind of coin. Example 1: Input: amount = 5, coins = [1, 2, 5] Output: 4 Explanation: there are four ways to make up the amount: 5=5 5=2+2+1 5=2+1+1+1 5=1+1+1+1+1 Example 2: Input: amount = 3, coins = [2] Output: 0 Explanation: the amount of 3 cannot be made up just with coins of 2. Example 3: Input: amount = 10, coins = [10] Output: 1 Note: You can assume that 0 <= amount <= 5000 1 <= coin <= 5000 the number of coins is less than 500 the answer is guaranteed to fit into signed 32-bit integer ''' class Solution: def change(self, amount: int, coins: List[int]) -> int: dp = [1] + [0] * amount for coin in coins: for j in range(coin, amount+1): dp[j] += dp[j-coin] return dp[-1]
gitdownloads = { "opsxcq": ("exploit-CVE-2017-7494", "exploit-CVE-2016-10033"), "t0kx": ("exploit-CVE-2016-9920"), "helmL64": "https://get.helm.sh/helm-v3.7.0-linux-amd64.tar.gz", "helmW64": "https://get.helm.sh/helm-v3.7.0-windows-amd64.zip" } helmchartrepos = { "gitlab": "helm repo add gitlab https://charts.gitlab.io/", "ingress-nginx": "helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx", "prometheus": "helm repo add prometheus-community https://prometheus-community.github.io/helm-charts", "gitlab-omnibus": "https://artifacthub.io/packages/helm/slamdev/gitlab-omnibus" } helchartinstalls = { "prometheus-community" : "helm install [RELEASE_NAME] prometheus-community/kube-prometheus-stack" } #for pi raspipulls= { "opevpn" : "cambarts/openvpn", "webgoat" : "cambarts/webgoat-8.0-rpi", "bwapp" : "cambarts/arm-bwapp", "dvwa" : "cambarts/arm-dvwa", "LAMPstack" : "cambarts/arm-lamp" } #for pi rpiruns = { "bwapp" : '-d -p 80:80 cambarts/arm-bwapp', "dvwa" : '-d -p 80:80 -p 3306:3306 -e MYSQL_PASS="password" cambarts/dvwa', "webgoat" : "-d -p 80:80 -p cambarts/webgoat-8.0-rpi", "nginx" : "-d nginx", }
''' Kattis - primematrix Constructive problem, first we find a set of distinct positive integers that sum to a prime number such that the maximum number is minimised. Then the matrix can be constructed by printing all lexicographical rotations of the set of numbers. To find this set of numbers, given the bounds of the task, it is sufficient to do the following: 1. Assume our set is 1..n 2. Find the smallest prime >= sum(1..n) 3. replace zero or one of the n numbers with n+1 such that the sum is equal to the prime Time: O(n), Space: O(n) ''' _sieve_size = 0 bs = [] primes = [] def sieve(upperbound=1277): # Smallest prime larger than sum(1..50) is 1277 global _sieve_size, bs, primes _sieve_size = upperbound+1 bs = [True] * 10000010 bs[0] = bs[1] = False for i in range(2, _sieve_size): if bs[i]: for j in range(i*i, _sieve_size, i): bs[j] = False primes.append(i) sieve() n, b = map(int, input().split()) init_sum = (n*(n+1))//2 for p in primes: if (p >= init_sum): target_prime = p break nums = [] if (target_prime != init_sum): diff = target_prime - init_sum x = n+1 - diff for i in range(1, n+2): if (i != x): nums.append(i) else: nums = [i for i in range(1, n+1)] if (nums[-1] > b): print("impossible") else: for _ in range(n): print(" ".join(map(str, nums))) nums.append(nums[0]) nums.pop(0)
""" File: hailstone.py Name: Peter Lin ----------------------- This program should implement a console program that simulates the execution of the Hailstone sequence, defined by Douglas Hofstadter. Output format should match what is shown in the sample run in the Assignment 2 Handout. """ def main(): """ define variable a as the times we count Count step by step to complete Hailstone sequence. """ print('This program computes Hailstone sequences.') print() n = int(input('Enter a number: ')) a = 0 while True: if n % 2 == 0: print(str(n) + ' is even, so I take half: ' + str(n // 2)) n //= 2 a += 1 else: if n == 1: break else: print(str(n) + ' is odd, so I make 3n+1: ' + str(3 * n + 1)) n = n * 3 + 1 a += 1 print('It took ' + str(a) + ' steps to reach 1.') ###### DO NOT EDIT CODE BELOW THIS LINE ###### if __name__ == "__main__": main()
def validate_password(password: str): if len(password)<8: return False for i in password: if i.isdigit(): return True return False
# Common test data used by multiple tests AUTH_ARGS = { 'client_id': 'cats', 'client_secret': 'opposable thumbs', 'access_token': 'paw', 'refresh_token': 'teeth', }
{ "targets": [ { "target_name": "itt", "sources": [ "itt-addon.cc" ], "include_dirs": [ "include", "C:\\Program Files (x86)\\IntelSWTools\\VTune Profiler 2020\\include" ], "libraries": [ "C:\\Program Files (x86)\\IntelSWTools\\VTune Profiler 2020\\lib64\\libittnotify.lib" ] } ] }
class Solution: def maxAreaOfIsland(self, grid): """ :type grid: List[List[int]] :rtype: int """ ans = 0 if not grid: return ans ans = 0 def dfs(grid, r, c): if grid[r][c] == 0: return 0 grid[r][c] = 0 ds = [(1, 0), (-1, 0), (0, 1), (0, -1)] s = 1 for delr, delc in ds: if 0 <= r + delr < len(grid) and 0 <= c + delc < len(grid[0]): s += dfs(grid, r + delr, c + delc) return s for r in range(len(grid)): for c in range(len(grid[0])): if grid[r][c] == 1: tmp = dfs(grid, r, c) # print(tmp) ans = max(tmp, ans) # print(ans) return ans def maxAreaOfIslandRec(self, grid): seen = set() def area(r, c): if not (0 <= r < len(grid) and 0 <= c < len(grid[0]) and (r, c) not in seen and grid[r][c]): return 0 seen.add((r, c)) return (1 + area(r + 1, c) + area(r - 1, c) + area(r, c - 1) + area(r, c + 1)) return max(area(r, c) for r in range(len(grid)) for c in range(len(grid[0]))) def maxAreaOfIslandIter(self, grid): seen = set() ans = 0 for r0, row in enumerate(grid): for c0, val in enumerate(row): if val and (r0, c0) not in seen: shape = 0 stack = [(r0, c0)] seen.add((r0, c0)) while stack: r, c = stack.pop() shape += 1 for nr, nc in ((r - 1, c), (r + 1, c), (r, c - 1), (r, c + 1)): if (0 <= nr < len(grid) and 0 <= nc < len(grid[0]) and grid[nr][nc] and (nr, nc) not in seen): stack.append((nr, nc)) seen.add((nr, nc)) ans = max(ans, shape) return ans solver = Solution() solver.maxAreaOfIsland( [[0,0,1,0,0,0,0,1,0,0,0,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,1,1,0,1,0,0,0,0,0,0,0,0], [0,1,0,0,1,1,0,0,1,0,1,0,0], [0,1,0,0,1,1,0,0,1,1,1,0,0], [0,0,0,0,0,0,0,0,0,0,1,0,0], [0,0,0,0,0,0,0,1,1,1,0,0,0], [0,0,0,0,0,0,0,1,1,0,0,0,0]] )
ranges ={ 'temp':{'min':1,'max':45},#Temperature 'soc':{'min':20,'max':80},#state of Charge 'charge_rate':{'min':0,'max':0.8},#state of Charge } test_report=[] test_case_id=0 def append_list(src_list,dst_list): for x in src_list: dst_list.append(x) def min_range_test(value,range_min): result=False #Test step pass->Normal behavior test_step='\t\tTeststep::Passed ->Actual value:'+str(value)+' is greater than Min Range:'+str(range_min) if value < range_min: test_step='\t\tTeststep::Failed ->Actual value:'+str(value)+' is less than Min Range:'+str(range_min) result=True #Test step failed->abnormal behavior return test_step,result def max_range_test(value,range_max): result=False #Test step pass->Normal behavior test_step='\t\tTeststep::Passed ->Actual value:'+str(value)+' is less than Max Range:'+str(range_max) if value > range_max: test_step='\t\tTeststep::Failed ->Actual value:'+str(value)+' is greater than Max Range:'+str(range_max) result=True #Test step failed->abnormal behavior return test_step,result def collect_abnormals(abnormals,test_case_report,attribute_name,attribute_value,attribute_range): result=False #Test attribute is within Min and Max range->Normal behavior test_step_min,min_range_result=min_range_test(attribute_value,attribute_range['min'])#test for min range test_step_max,max_range_result=max_range_test(attribute_value,attribute_range['max'])#test for max range if min_range_result or max_range_result: result=True #Test attribute is not within Min and Max range->abnormal behavior abnormals.append(attribute_name) return [test_step_min,test_step_max],result def report_abnormals_attribute(attribute_report): abnormals=[] test_case_report=[] for attribute in attribute_report: report='\tTest Attribute['+attribute+']::->Passed'#Test attribute is within Min and Max range->Normal behavior test_step,result=collect_abnormals(abnormals,test_case_report,attribute,attribute_report[attribute],ranges[attribute]) if result==True: report='\tTest Attribute['+attribute+']::->Failed' #Test attribute is not within Min and Max range->abnormal behavior test_case_report.append(report) append_list(test_step,test_case_report) return test_case_report,abnormals def test_abnormals_attribute(battery_report): global test_case_id test_case_id+=1 test_case='Test Case ID['+str(test_case_id)+"]->Passed" test_step,abnormals=report_abnormals_attribute(battery_report) if(len(abnormals)!=0): test_case='Test Case ID::['+str(test_case_id)+"]->Failed" test_report.append(test_case) append_list(test_step,test_report) #assert(len(abnormals)==0) if __name__ == '__main__': test_input_battery_report_1 ={ 'temp':25, 'soc':70, 'charge_rate':0.7 } test_input_battery_report_2 ={ 'temp':0, 'soc':85, 'charge_rate':0.9 } test_abnormals_attribute(test_input_battery_report_1) test_abnormals_attribute(test_input_battery_report_2) test_abnormals_attribute(test_input_battery_report_1) for line in test_report: print(line)
class SomeClass: def __init__(self, name='lin'): self.name = name # def get_name(self): # return self.name def get_name_new(): return self.name
""" Exercise Python 069: Crie um programa que leia a idade e o sexo de várias pessoas. A cada pessoa cadastrada, o programa deverá perguntar se o usuário quer ou não continuar. No final, mostre: A) quantas pessoas tem mais de 18 anos. B) quantos homens foram cadastrados. C) quantas mulheres tem menos de 20 anos. """ peoplesMore18 = 0 mens = 0 womensLess18 = 0 while True: print('-' * 50) print('REGISTER A PERSON') print('-' * 50) go = ' ' sex = ' ' year = int(input('Year: ')) while sex not in 'MF': sex = str(input('Sex[M/F]: ')).strip().upper() if year >= 18: peoplesMore18 += 1 if sex == 'M': mens += 1 if sex == 'F' and year < 20: womensLess18 += 1 while go not in 'YN': go = str(input('Do you want to continue?[y/n] ')).strip().upper() if go == 'N': break print('\nTotal peoples with more 18 years old: {}'.format(peoplesMore18)) print('Total mens registered: {}'.format(mens)) print('Total womens registered with less 20 years old: {}'.format(womensLess18))
# ___ ___ # | _ \ | _ \ # ___ __ __ || || ||_|| #_\/_ | | ||__| __ || || |___/ _\/_ # /\ | |__|| || || | _ \ /\ # ||_|| ||_|| # |___/ |___/ # __version__ = '2.0.7'
x = 10 y = 1 color = 'blue' first_name = 'Julian' last_name = 'Henao' # < > <= <= == if x < 30: print('X is less than 30') else: print('X is greater than 30') if color == 'red': print('The color is red') else: print('Any color') if color == 'yellow': print('The color is yellow') elif color == 'blue': print('The color is blue') else: print('Any color') if first_name == 'Julian': if last_name == 'Henao': print('Tu eres Julian Henao') else: print('Tu no eres Julian Henao') # and, or, not if x > 2 and x < 100: print('x is greater than 2 and less than 100') if x < 2 or x > 100: print('x is less than 2 or greater than 100') if not(x == y): print('x is not equal y')
class Solution(object): def numIdenticalPairs(self, nums): """ :type nums: List[int] :rtype: int """ count = 0 for i in range(len(nums)): for j in range(len(nums)): if nums[i] == nums[j] and i < j: count += 1 return count #using hashMap class Solution: def numIdenticalPairs(self, nums: List[int]) -> int: hashMap = {} res = 0 for number in nums: if number in hashMap: res += hashMap[number] hashMap[number] += 1 else: hashMap[number] = 1 return res