content
stringlengths
7
1.05M
# -*- mode: python; -*- # Return the pathname of the calling package. # (This is used to recover the directory name to pass to cc -I<dir>, when # choosing from among alternative header files for different platforms.) def pkg_path_name(): return "./" + Label(REPOSITORY_NAME + "//" + PACKAGE_NAME + ":nsync").workspace_root + "/" + PACKAGE_NAME
# Play = 'play' # Pass = 'pass' Draw = 'draw' Discard = 'discard' TutorDeck = 'tutor_deck' TutorDiscard = 'tutor_discard' Create = 'create' Shuffle = 'shuffle' Mill = 'mill' Top = 'top' # Resolve = 'resolve' # Win = 'win' # Lose = 'lose' # Tie = 'tie' # # Build = 'build' # Inspire = 'inspire' # Nourish = 'nourish' # # Meow = 'meow' # Yell = 'yell' # BoneSnap = 'bone_snap' # Bird = 'bird' # Drown = 'drown' # Fire = 'fire' # Reset = 'reset' # Crowd = 'crowd' # Sarcophagus = 'sarcophagus'
# -*- coding:utf8 -*- """ common settings FUTURE: read setting from a json file """ """ path configuration """ ICON_PATH = '../icons/' CACHE_PATH = '../cache/' DATA_PATH = '../data/' """ mode configuration """ DEBUG = True # 1 for debug PRODUCTION = False # 0 for Production Environment LOGFILE = CACHE_PATH + 'error.log' MODE = DEBUG """ theme configuration """ QSS_PATH = 'themes/default.qss' """ web_assets configuration """ HTML_PATH = 'web_assets/' PUBLIC_PATH = 'web_assets/public/' """ icon name """ PLAYLIST_FAVORITE = ICON_PATH + 'playlist_favorite.png' PLAYLIST_MINE = ICON_PATH + 'Format-Bullets-01-16.png' PLAYLIST_NORMAL = ICON_PATH + 'playlist_mine.png' WINDOW_ICON = ICON_PATH + 'FeelUOwn.png'
#!/usr/bin/env python # -*- coding: utf-8 -*- # ----------------------------------------------------------------------------- # # FreeType high-level python API - Copyright 2011-2012 Nicolas P. Rougier # Distributed under the terms of the new BSD license. # # ----------------------------------------------------------------------------- """ An enumeration used to specify character sets supported by charmaps. Used in the FT_Select_Charmap API function. FT_ENCODING_NONE The encoding value 0 is reserved. FT_ENCODING_UNICODE Corresponds to the Unicode character set. This value covers all versions of the Unicode repertoire, including ASCII and Latin-1. Most fonts include a Unicode charmap, but not all of them. For example, if you want to access Unicode value U+1F028 (and the font contains it), use value 0x1F028 as the input value for FT_Get_Char_Index. FT_ENCODING_MS_SYMBOL Corresponds to the Microsoft Symbol encoding, used to encode mathematical symbols in the 32..255 character code range. For more information, see 'http://www.ceviz.net/symbol.htm'. FT_ENCODING_SJIS Corresponds to Japanese SJIS encoding. More info at at 'http://langsupport.japanreference.com/encoding.shtml'. See note on multi-byte encodings below. FT_ENCODING_GB2312 Corresponds to an encoding system for Simplified Chinese as used used in mainland China. FT_ENCODING_BIG5 Corresponds to an encoding system for Traditional Chinese as used in Taiwan and Hong Kong. FT_ENCODING_WANSUNG Corresponds to the Korean encoding system known as Wansung. For more information see 'http://www.microsoft.com/typography/unicode/949.txt'. FT_ENCODING_JOHAB The Korean standard character set (KS C 5601-1992), which corresponds to MS Windows code page 1361. This character set includes all possible Hangeul character combinations. FT_ENCODING_ADOBE_LATIN_1 Corresponds to a Latin-1 encoding as defined in a Type 1 PostScript font. It is limited to 256 character codes. FT_ENCODING_ADOBE_STANDARD Corresponds to the Adobe Standard encoding, as found in Type 1, CFF, and OpenType/CFF fonts. It is limited to 256 character codes. FT_ENCODING_ADOBE_EXPERT Corresponds to the Adobe Expert encoding, as found in Type 1, CFF, and OpenType/CFF fonts. It is limited to 256 character codes. FT_ENCODING_ADOBE_CUSTOM Corresponds to a custom encoding, as found in Type 1, CFF, and OpenType/CFF fonts. It is limited to 256 character codes. FT_ENCODING_APPLE_ROMAN Corresponds to the 8-bit Apple roman encoding. Many TrueType and OpenType fonts contain a charmap for this encoding, since older versions of Mac OS are able to use it. FT_ENCODING_OLD_LATIN_2 This value is deprecated and was never used nor reported by FreeType. Don't use or test for it. """ def _FT_ENC_TAG(a, b, c, d): return (ord(a) << 24 | ord(b) << 16 | ord(c) << 8 | ord(d)) FT_ENCODINGS = {'FT_ENCODING_NONE': _FT_ENC_TAG('\0', '\0', '\0', '\0'), 'FT_ENCODING_MS_SYMBOL': _FT_ENC_TAG('s', 'y', 'm', 'b'), 'FT_ENCODING_UNICODE': _FT_ENC_TAG('u', 'n', 'i', 'c'), 'FT_ENCODING_SJIS': _FT_ENC_TAG('s', 'j', 'i', 's'), 'FT_ENCODING_GB2312': _FT_ENC_TAG('g', 'b', ' ', ' '), 'FT_ENCODING_BIG5': _FT_ENC_TAG('b', 'i', 'g', '5'), 'FT_ENCODING_WANSUNG': _FT_ENC_TAG('w', 'a', 'n', 's'), 'FT_ENCODING_JOHAB': _FT_ENC_TAG('j', 'o', 'h', 'a'), 'FT_ENCODING_ADOBE_STANDARD': _FT_ENC_TAG('A', 'D', 'O', 'B'), 'FT_ENCODING_ADOBE_EXPERT': _FT_ENC_TAG('A', 'D', 'B', 'E'), 'FT_ENCODING_ADOBE_CUSTOM': _FT_ENC_TAG('A', 'D', 'B', 'C'), 'FT_ENCODING_ADOBE_LATIN1': _FT_ENC_TAG('l', 'a', 't', '1'), 'FT_ENCODING_OLD_LATIN2': _FT_ENC_TAG('l', 'a', 't', '2'), 'FT_ENCODING_APPLE_ROMAN': _FT_ENC_TAG('a', 'r', 'm', 'n')} globals().update(FT_ENCODINGS)
start_text = '''Welcome to Hentai Manga DL Bot. Here you can Download all Hentai Mangas for Free. For many who donโ€™t know about Hentai, this is about Japanese anime and manga porn or cartoon porn. This great genre was born in Japan and its real meaning comes from perverse sexual desire or perverse sexual act since in the vast majority of porn manga we will find fabulous stories of forbidden and very erotic sex. Note : This Bot Is only for adults If Any Abuse About This Bot you can report @Yeageristbotsdev Use /help to know commands and how to use this bot''' help_text = '''List of commands: /nh : </nh <hentai code> The files provided are in multiple qualities to download just open file in chrome To report any Problems, Bugs, Suggestions go to @Yeageristbotsdev Note : This bot is only for adult'''
""" ะŸั€ะพัั‚ะตะนัˆะธะน ั‚ะตะปะตั„ะพะฝะฝั‹ะน ัะฟั€ะฐะฒะพั‡ะฝะธะบ. """ # ะ—ะฐะฒะพะดะธั‚ ะฟะตั€ะตะผะตะฝะฝัƒัŽ ัะฟั€ะฐะฒะพั‡ะฝะธะบะฐ catalog = {} def checked_input(values, type_, hello): """ะŸั€ะพะฒะตั€ัะตั‚ ะฒะฒะพะด ะฝะฐ ะฟั€ะธะฝะฐะดะปะตะถะฝะพัั‚ัŒ ะผะฝะพะถะตัั‚ะฒัƒ ะฟั€ะฐะฒะธะปัŒะฝั‹ั… ะฒะฐั€ะธะฐะฝั‚ะพะฒ""" inp = type_(input(hello)) if inp not in values: while inp not in values: print('Incorrect input, try again') inp = type_(input(hello)) return inp def add_number(name, number): """ะ”ะพะฑะฐะฒะปัะตั‚ ะธะผั ะฒ ัะฟั€ะฐะฒะพั‡ะฝะธะบ""" global catalog if name not in catalog: catalog[name] = [] catalog[name].append(number) def add_number_and_name(): """ะ—ะฐะฟั€ะฐัˆะธะฒะฐะตั‚ ัƒ ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั ะธะผั ะธ ะฝะพะผะตั€ ะดะปั ะดะพะฑะฐะฒะปะตะฝะธั ะฒ ัะฟั€ะฐะฒะพั‡ะฝะธะบ. ะ’ั‹ะทั‹ะฒะฐะตั‚ ั„ัƒะฝะบั†ะธัŽ ะดะพะฑะฐะฒะปะตะฝะธั. """ name = input('Type a name >') number = int(input('Type a number >')) add_number(name=name, number=number) def get_numbers(): """ะ—ะฐะฟั€ะฐัˆะธะฒะฐะตั‚ ัƒ ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั ะธะผั ะธ ะฟะพะบะฐะทั‹ะฒะฐะตั‚ ะฝะพะผะตั€ะฐ ะธะท ัะฟั€ะฐะฒะพั‡ะฝะธะบะฐ ะฟะพ ะฝะตะผัƒ. ะ•ัะปะธ ะธะผะตะฝะธ ะฝะตั‚ ะฒ ะฟั€ะฐะฒะพั‡ะฝะธะบะต, ัะพะพะฑั‰ะฐะตั‚ ะพะฑ ัั‚ะพะผ. """ name = input('Type a name >') if name in catalog: numbers = catalog[name] print('name', '\t', 'number') for num in numbers: print(name, '\t', num) else: print('{} not in catalog'.format(name)) def del_numbers(): """ะ—ะฐะฟั€ะฐัˆะธะฒะฐะตั‚ ัƒ ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั ะธะผั ะธ ัƒะดะฐะปัะตั‚ ะทะฐะฟะธััŒ ะพ ะฝะตะผ ะธะท ัะฟั€ะฐะฒะพั‡ะฝะธะบะฐ. ะ•ัะปะธ ะธะผะตะฝะธ ะฝะตั‚ ะฒ ะฟั€ะฐะฒะพั‡ะฝะธะบะต, ัะพะพะฑั‰ะฐะตั‚ ะพะฑ ัั‚ะพะผ.""" global catalog name = input('Type a name >') if name in catalog: catalog.pop(name) print(name, 'deleted') else: print('{} not in catalog'.format(name)) def main(): """ะ—ะฐะฟัƒัะบะฐะตั‚ ะฟั€ะพะณั€ะฐะผะผัƒ""" print(""" Hello! What are you want to do? 1 - add name and number 2 - show numbers by name 3 - delete numbers by name """) inp = checked_input([1,2,3], int, 'Type a digit >') if inp == 1: add_number_and_name() elif inp == 2: get_numbers() elif inp == 3: del_numbers() if __name__ == '__main__': main()
def Fibonacci_Tail(n, acc0= 0, acc1= 1): # Base-Case(s): F(0) = 0, F(1) = 1 if(n == 0): return acc0 if(n == 1): return acc1 # Recursion return Fibonacci_Tail(n-1, acc1, acc1+acc0) n = 0 while(n <= 10): get = Fibonacci_Tail(n) print(f"Fibonacci({n}) = {get}") n = n+1
# # PySNMP MIB module Juniper-Notification-Log-CONF (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/Juniper-Notification-Log-CONF # Produced by pysmi-0.3.4 at Mon Apr 29 19:52:48 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # ObjectIdentifier, OctetString, Integer = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "OctetString", "Integer") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") SingleValueConstraint, ConstraintsIntersection, ConstraintsUnion, ValueRangeConstraint, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "SingleValueConstraint", "ConstraintsIntersection", "ConstraintsUnion", "ValueRangeConstraint", "ValueSizeConstraint") juniAgents, = mibBuilder.importSymbols("Juniper-Agents", "juniAgents") AgentCapabilities, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "AgentCapabilities", "ModuleCompliance", "NotificationGroup") Integer32, ModuleIdentity, Counter32, IpAddress, TimeTicks, iso, MibIdentifier, Counter64, Gauge32, Unsigned32, Bits, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, ObjectIdentity = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "ModuleIdentity", "Counter32", "IpAddress", "TimeTicks", "iso", "MibIdentifier", "Counter64", "Gauge32", "Unsigned32", "Bits", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "ObjectIdentity") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") juniNotificationLogAgent = ModuleIdentity((1, 3, 6, 1, 4, 1, 4874, 5, 2, 56)) juniNotificationLogAgent.setRevisions(('2002-09-06 16:54', '2002-03-25 18:22',)) if mibBuilder.loadTexts: juniNotificationLogAgent.setLastUpdated('200209061654Z') if mibBuilder.loadTexts: juniNotificationLogAgent.setOrganization('Juniper Networks, Inc.') juniNotificationLogAgentV1 = AgentCapabilities((1, 3, 6, 1, 4, 1, 4874, 5, 2, 56, 1)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniNotificationLogAgentV1 = juniNotificationLogAgentV1.setProductRelease('Version 1 of the Notification Log component of the JUNOSe SNMP agent.\n This version of the Notification Log component is supported in JUNOSe\n 4.1 and subsequent system releases.') if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): juniNotificationLogAgentV1 = juniNotificationLogAgentV1.setStatus('current') mibBuilder.exportSymbols("Juniper-Notification-Log-CONF", PYSNMP_MODULE_ID=juniNotificationLogAgent, juniNotificationLogAgent=juniNotificationLogAgent, juniNotificationLogAgentV1=juniNotificationLogAgentV1)
# -*- coding: utf-8 -*- class Pessoa: """Implementaรงรฃo de uma classe que modela uma pessoa""" temDeficiencia = False # atributo de classe def __init__(self, *filhos, nome=None, idade=0): self.nome = nome self.idade = idade self.filhos = list(filhos) def cumprimentar(self): return f"Ola, meu nome รฉ {self.nome}" def __repr__(self): txtSaida = f"Meu nome รฉ {self.nome} e tenho {self.idade} anos" if self.filhos: txtSaida = txtSaida + f"\nTenho {len(self.filhos)} filhos:" for filho in self.filhos: txtSaida = txtSaida + f"\n==> {filho}" return txtSaida class Homem(Pessoa): def cumprimentar(self): return f"{super().cumprimentar()}. Aperto de mรฃo" if __name__ == '__main__': filhos = [('Arthur', 7), ('Alice', 0)] pai = Homem(nome='Adao Oliveira', idade=41) mae = Pessoa(nome='Poliana Carlos', idade=39) for filho in filhos: pai.filhos.append(Pessoa(nome=filho[0], idade=filho[1])) print(pai) # O atributo __dict__ lista todos os atributos de instancia de um objeto. # Imprimindo o objeto ANTES da criacao de um atributo de instancia print(pai.__dict__) # Criando um atributo booleano 'casado' no objeto 'pai' # (esse atributo nao existe em outros objetos da classe Pessoa pai.casado = True # Imprimindo novamente os atributos de instancia print(pai.__dict__) mae.filhos = pai.filhos.copy() mae.temDeficiencia = True print(mae) print(pai.__dict__) print(mae.__dict__) # teste print(pai.temDeficiencia) print(mae.temDeficiencia) print(pai.cumprimentar()) print(mae.cumprimentar())
# pylint: skip-file #- @A defines/binding ClassA #- @object ref vname("module.object", _, _, "pytd:__builtin__", _) #- ClassA.node/kind class class A(object): pass #- @B defines/binding ClassB #- @A ref ClassA #- ClassB.node/kind class class B(A): pass #- @Foo defines/binding ClassFoo #- @A ref ClassA #- @B ref ClassB #- ClassFoo.node/kind class class Foo(A, B): pass
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Oct 20 08:50:32 2019 @author: Giles """ ''' Question 1 Ask the user for two numbers between 1 and 100. Then count from the lower number to the higher number. Print the results to the screen. ''' ''' Question 2 Ask the user to input a string and then print it out to the screen in reverse order (use a for loop). ''' ''' Question 3 Ask the user for a number between 1 and 12 and then display a times table for that number. ''' ''' Question 4 Can you amend the solution to question 3 so that it just prints out all times tables between 1 and 12? (no need to ask user for input) ''' ''' Question 5 Ask the user to input a sequence of numbers. Then calculate the mean and print the result ''' ''' Question 6 Write code that will calculate 15 factorial. (factorial is product of positive ints up to a given number. e.g 5 factorial is 5x4x3x2x1) ''' ''' Question 7 Write code to calculate Fibonacci numbers. Create list containing first 20 Fibonacci numbers, (Fib numbers made by sum of preceeding two. Series starts 0 1 1 2 3 5 8 13 ....) ''' ''' Question 8 The previous question was the first to contain comments. Go back through the other questions in this file and add comments to the solutions. ''' ''' Question 9 ***** * **** * * * Can you draw this using python? (comment the solution code) ''' ''' Question 10 Write some code that will determine all odd and even numbers between 1 and 100. Put the odds in a list named odd and the evens in a list named even. '''
# -*- coding: utf-8 -*- # # Copyright (C) 2015-2016 Mateusz ลฤ…cki and Michaล‚ Startek. # # This file is part of IsoSpec. # # IsoSpec is free software: you can redistribute it and/or modify # it under the terms of the Simplified ("2-clause") BSD licence. # # IsoSpec is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. # # You should have received a copy of the Simplified BSD Licence # along with IsoSpec. If not, see <https://opensource.org/licenses/BSD-2-Clause>. # class SSummator: def __init__(self): self.partials = [] # sorted, non-overlapping partial sums def add(self, x): i = 0 for y in self.partials: if abs(x) < abs(y): x, y = y, x hi = x + y lo = y - (hi - x) if lo: self.partials[i] = lo i += 1 x = hi self.partials[i:] = [x] def get(self): return sum(self.partials) class Summator: def __init__(self, keep_partials = False): self.sum = 0.0 self.c = 0.0 self.keep_partials = keep_partials self.partials = [] def add(self, what): y = what - self.c t = self.sum + y c = (t - self.sum) - y self.sum = t if self.keep_partials: self.partials.append(self.sum) def get(self): return self.sum def get_partials(self): return self.partials class PosNegSummator: def __init__(self): self.pos = Summator() self.neg = Summator() def add(self, what): if what >= 0: self.pos.add(what) else: self.neg.add(-what) def get(self): return self.pos.get() - self.neg.get()
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Receipt View Created on Tue Aug 17 14:16:44 2021 Version: 1.0 Universidad Santo Tomรกs Tunja Simulation @author: Juana Valentina Mendoza Santamarรญa @author: Alix Ivonne Chaparro Vasquez presented to: Martha Susana Contreras Ortiz """ def showReceipt(): print("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| | | |") print("|โ–“โ–“| . . . . |โ–“โ–“|") print("| | o |\ /| o | | | |") print("| | ,,_o_ | \/ |. . .,-. . .-...-... . |.-. .-. .--. |.-. | |") print("| | c'' )? | || | | ) | ( ( || | | | ) | | |-.' | |") print("|โ–“โ–“| '''' ' '`--| |`-ยด-ยด ` --`|`-`|`--| '`-ยด `-ยด`-' `-' `- |โ–“โ–“|") print("| | ; | ._.'._.' ; | |") print("| | `-' ' `-' | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("|โ–“โ–“| โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ |โ–“โ–“|") print("| | โ–‘โ–‘ Do you want a receipt with your transaction? โ–‘โ–‘ | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 1. Yes โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 2. No โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("|โ–“โ–“| โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ |โ–“โ–“|") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| | RECEIPT | | CARD โ†“ | |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| โ”” โ”˜ |\____________\โ”€โ”€โ”€โ”€โ”€| |") print("| ||__|โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘|___| |") print("| โ””โ”€โ”€โ”€โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”€โ”€โ”€โ”˜ |") print("| |") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| |") print("โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜|\n") def showRemoveReceipt(): print("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| | | |") print("|โ–“โ–“| . . . . |โ–“โ–“|") print("| | o |\ /| o | | | |") print("| | ,,_o_ | \/ |. . .,-. . .-...-... . |.-. .-. .--. |.-. | |") print("| | c'' )? | || | | ) | ( ( || | | | ) | | |-.' | |") print("|โ–“โ–“| '''' ' '`--| |`-ยด-ยด ` --`|`-`|`--| '`-ยด `-ยด`-' `-' `- |โ–“โ–“|") print("| | ; | ._.'._.' ; | |") print("| | `-' ' `-' | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("|โ–“โ–“| โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ |โ–“โ–“|") print("| | โ–‘โ–‘ Please, remove your receipt. โ–‘โ–‘ | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("|โ–“โ–“| โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ |โ–“โ–“|") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| | RECEIPT | | CARD โ†“ | |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| โ”” / ---------- / โ”˜ |\____________\โ”€โ”€โ”€โ”€โ”€| |") print("| / ----------- / ||__|โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘|___| |") print("| / $ --- ---/ โ””โ”€โ”€โ”€โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”€โ”€โ”€โ”˜ |") print("| /____________ / |") print("| |") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| |") print("โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜|\n") def showRemoveCashAndReceipt(): print("โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| | | |") print("|โ–“โ–“| . . . . |โ–“โ–“|") print("| | o |\ /| o | | | |") print("| | ,,_o_ | \/ |. . .,-. . .-...-... . |.-. .-. .--. |.-. | |") print("| | c'' )? | || | | ) | ( ( || | | | ) | | |-.' | |") print("|โ–“โ–“| '''' ' '`--| |`-ยด-ยด ` --`|`-`|`--| '`-ยด `-ยด`-' `-' `- |โ–“โ–“|") print("| | ; | ._.'._.' ; | |") print("| | `-' ' `-' | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("|โ–“โ–“| โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ |โ–“โ–“|") print("| | โ–‘โ–‘ Please, remove your cash and receipt. โ–‘โ–‘ | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("|โ–“โ–“| โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ |โ–“โ–“|") print("| | โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ | |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| | RECEIPT | | CARD โ†“ | |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| โ”” / ---------- / โ”˜ |\____________\โ”€โ”€โ”€โ”€โ”€| |") print("| / ----------- / ||__|โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘|___| |") print("| / $ --- ---/ โ””โ”€โ”€โ”€โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜โ”€โ”€โ”€โ”˜ |") print("| /____________ / |") print("| |") print("| โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€|โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜|โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ |") print("| |") print("โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜|\n")
lista = [] print("Escolha uma das Opรงรตes abaixo:") def showOptions(): print(""" 0 - Sair do Programa 1 - Adicionar pessoa 2 - Listar pessoas 3 - Somar salรกrio dos homens 4 - Somar salรกrio das mulheres """) def adicionar(): nome = input('Informe o nome: ') sexo = input('informe o sexo, F para feminino ou M para masculino: ') salario = int(input('Informe o salario: ')) lista.append({'nome': nome, 'sexo': sexo, 'salario': salario}) def listar(): print(lista) def salario_homem(): salarioTotal = 0 for pessoa in lista: if pessoa['sexo'] == 'M': salarioTotal = salarioTotal + pessoa['salario'] print('Salario total dos homens: ', salarioTotal) def salario_mulher(): salarioTotal = 0 for pessoa in lista: if pessoa['sexo'] == 'F': salarioTotal = salarioTotal + pessoa['salario'] print('Salario total das Mulheres: ', salarioTotal) showOptions() while True: opcao = int(input("Digite a opรงรฃo desejada: ")) if not opcao == 0: if opcao == 1: adicionar() elif opcao == 2: listar() elif opcao == 3: salario_homem() elif opcao == 4: salario_mulher() else: print('Opรงรฃo invรกlida!') showOptions() else: break
'''Instructions You are going to use Dictionary Comprehension to create a dictionary called result that takes each word in the given sentence and calculates the number of letters in each word. Try Googling to find out how to convert a sentence into a list of words. Do NOT Create a dictionary directly. Try to use Dictionary Comprehension instead of a Loop. Example Output { 'What': 4, 'is': 2, 'the': 3, 'Airspeed': 8, 'Velocity': 8, 'of': 2, 'an': 2, 'Unladen': 7, 'Swallow?': 8 } ''' sentence = "What is the Airspeed Velocity of an Unladen Swallow?" # Don't change code above ๐Ÿ‘† # Write your code below: result = {word: len(word) for word in sentence.split()} print(result)
## A note on unneecssary complexity # We have gone through a few different standards on naming Julia's build artifacts. # The latest, as of this writing, is the `sf/consistent_distnames` branch on github, # and simplifies things relative to earlier versions. However, this buildbot needs # to be able to build/upload Julia versions of all reasonably recent versions. # `sf/consistent_distnames` should be merged before the 0.6 release, which means # that once the release _after_ 0.6 is out in the wild and 0.5 is put to rest, # we can safely remove anything that talks about non-`sf/consistent_distnames` # compatibility/workarounds. # Helper function to generate the necessary julia invocation to get metadata # about this build such as major/minor versions @util.renderer def make_julia_version_command(props_obj): command = [ "usr/bin/julia", "-e", "println(\"$(VERSION.major).$(VERSION.minor).$(VERSION.patch)\\n$(Base.GIT_VERSION_INFO.commit[1:10])\")" ] if is_windows(props_obj): command[0] += '.exe' return command # Parse out the full julia version generated by make_julia_version_command's command def parse_julia_version(return_code, stdout, stderr): lines = stdout.split('\n') return { "majmin": lines[0][:lines[0].rfind('.')], "version": lines[0].strip(), "shortcommit": lines[1].strip(), } def parse_git_log(return_code, stdout, stderr): lines = stdout.split('\n') return { "commitmessage": lines[0], "commitname": lines[1], "commitemail": lines[2], "authorname": lines[3], "authoremail": lines[4], } def gen_local_filename(props_obj): props = props_obj_to_dict(props_obj) # Get the output of the `make print-JULIA_BINARYDIST_FILENAME` step artifact = "{artifact_filename}".format(**props).strip() # First, see if we got a JULIA_BINARYDIST_FILENAME output if artifact[:26] == "JULIA_BINARYDIST_FILENAME=" and len(artifact) > 26: return artifact[26:] + ".{os_pkg_ext}".format(**props) else: # If not, use non-sf/consistent_distnames naming if is_mac(props_obj): return "contrib/mac/app/Julia-{version}-{shortcommit}.{os_pkg_ext}".format(**props) elif is_windows(props_obj): return "julia-{version}-{tar_arch}.{os_pkg_ext}".format(**props) elif is_freebsd(props_obj): return "julia-{shortcommit}-FreeBSD-{tar_arch}.{os_pkg_ext}".format(**props) else: # We made bad decisions in the past if props['tar_arch'] == "armv7l": return "julia-{shortcommit}-Linux-arm.{os_pkg_ext}".format(**props) return "julia-{shortcommit}-Linux-{tar_arch}.{os_pkg_ext}".format(**props) def gen_upload_filename(props_obj): props = props_obj_to_dict(props_obj) # We don't like "winnt" at the end of files, we use just "win" instead. props["os_name_file"] = props["os_name"] if props["os_name_file"] == "winnt": props["os_name_file"] = "win" return "julia-{shortcommit}-{os_name_file}{bits}.{os_pkg_ext}".format(**props) def gen_upload_path(props_obj, namespace=None): up_arch = props_obj.getProperty("up_arch") majmin = props_obj.getProperty("majmin") upload_filename = props_obj.getProperty("upload_filename") os = get_os_name(props_obj) if namespace is None: return "julialangnightlies/bin/%s/%s/%s/%s"%(os, up_arch, majmin, upload_filename) else: return "julialangnightlies/%s/bin/%s/%s/%s/%s"%(namespace, os, up_arch, majmin, upload_filename) def gen_latest_upload_path(props_obj, namespace=None): up_arch = props_obj.getProperty("up_arch") upload_filename = props_obj.getProperty("upload_filename") if upload_filename[:6] == "julia-": split_name = upload_filename.split("-") upload_filename = "julia-latest-%s"%(split_name[2]) os = get_os_name(props_obj) if namespace is None: return "julialangnightlies/bin/%s/%s/%s"%(os, up_arch, upload_filename) else: return "julialangnightlies/%s/bin/%s/%s/%s"%(namespace, os, up_arch, upload_filename) def gen_download_url(props_obj, namespace=None): base = 'https://s3.amazonaws.com' return '%s/%s'%(base, gen_upload_path(props_obj, namespace=namespace)) def gen_latest_download_url(props_obj): base = 'https://s3.amazonaws.com' return '%s/%s'%(base, gen_latest_upload_path(props_obj)) # This is a weird buildbot hack where we really want to parse the output of our # make command, but we also need access to our properties, which we can't get # from within an `extract_fn`. So we save the output from a previous # SetPropertyFromCommand invocation, then invoke a new command through this # @util.renderer nonsense. This function is supposed to return a new command # to be executed, but it has full access to all our properties, so we do all our # artifact filename parsing/munging here, then return ["true"] as the step # to be executed. @util.renderer def munge_artifact_filename(props_obj): # Generate our local and upload filenames local_filename = gen_local_filename(props_obj) upload_filename = gen_upload_filename(props_obj) props_obj.setProperty("local_filename", local_filename, "munge_artifact_filename") props_obj.setProperty("upload_filename", upload_filename, "munge_artifact_filename") return ["true"] @util.renderer def render_upload_command(props_obj): upload_path = gen_upload_path(props_obj, namespace="pretesting") upload_filename = props_obj.getProperty("upload_filename") return ["/bin/sh", "-c", "aws s3 cp --acl public-read /tmp/julia_package/%s s3://%s"%(upload_filename, upload_path)] @util.renderer def render_promotion_command(props_obj): src_path = gen_upload_path(props_obj, namespace="pretesting") dst_path = gen_upload_path(props_obj) return ["/bin/sh", "-c", "aws s3 cp --acl public-read s3://%s s3://%s"%(src_path, dst_path)] @util.renderer def render_latest_promotion_command(props_obj): src_path = gen_upload_path(props_obj, namespace="pretesting") dst_path = gen_latest_upload_path(props_obj) return ["/bin/sh", "-c", "aws s3 cp --acl public-read s3://%s s3://%s"%(src_path, dst_path)] @util.renderer def render_cleanup_pretesting_command(props_obj): del_path = gen_upload_path(props_obj, namespace="pretesting") return ["/bin/sh", "-c", "aws s3 rm s3://%s"%(del_path)] @util.renderer def render_download_url(props_obj): return gen_download_url(props_obj) @util.renderer def render_pretesting_download_url(props_obj): return gen_download_url(props_obj, namespace="pretesting") @util.renderer def render_make_app(props_obj): props = props_obj_to_dict(props_obj) new_way = "make {flags} app".format(**props) old_way = "make {flags} -C contrib/mac/app && mv contrib/mac/app/*.dmg {local_filename}".format(**props) # We emit a shell command that attempts to run `make app` (which is the nice # `sf/consistent_distnames` shortcut), and if that fails, it runs the steps # manually, which boil down to `make -C contrib/mac/app` and moving the # result to the top-level, where we can find it. We can remove this once # 0.6 is no longer being built. return [ "/bin/sh", "-c", "~/unlock_keychain.sh && (%s || (%s))"%(new_way, old_way) ] def build_download_julia_cmd(props_obj): download_url = props_obj.getProperty("download_url") # Build commands to download/install julia if is_mac(props_obj): # Download the .dmg cmd = "curl -L '%s' -o julia-installer.dmg && "%(download_url) # Mount it cmd += "hdiutil mount julia-installer.dmg && " # copy its `julia` folder contents here. cmd += "cp -Ra /Volumes/Julia-*/Julia-*.app/Contents/Resources/julia/* . && " # Unmount any and all Julia disk images cmd += "for j in /Volumes/Julia-*; do hdiutil unmount \"$j\"; done && " # Delete the .dmg cmd += "rm -f julia-installer.dmg" elif is_windows(props_obj): # Download the .exe cmd = "curl -L '%s' -o julia-installer.exe && "%(download_url) # Make it executable cmd += "chmod +x julia-installer.exe && " # Extract it into the current directory cmd += "./julia-installer.exe /S /D=$(cygpath -w $(pwd)) && " # Remove the .exe cmd += "rm -f julia-installer.exe" else: # Oh linux. Your simplicity always gets me cmd = "curl -L '%s' | tar --strip-components=1 -zxf -"%(download_url) return ["/bin/sh", "-c", cmd] @util.renderer def download_julia(props_obj, namespace=None): # If we already have an "url", use that, otherwise try to generate it: if not props_obj.hasProperty('download_url'): # Calculate upload_filename, add to properties, then get download url upload_filename = gen_upload_filename(props_obj) props_obj.setProperty("upload_filename", upload_filename, "download_julia") download_url = gen_download_url(props_obj) props_obj.setProperty("download_url", download_url, "download_julia") return build_download_julia_cmd(props_obj) def download_latest_julia(props_obj): # Fake `gen_upload_filename()` into giving us something like # `julia-latest-linux64.tar.gz` instead of a true shortcommit props_obj.setProperty("shortcommit", "latest", "download_latest_julia") upload_filename = gen_upload_filename(props_obj) props_obj.setProperty("upload_filename", upload_filename, "download_latest_julia") download_url = gen_latest_download_url(props_obj) props_obj.setProperty("download_url", download_url, "download_latest_julia") return build_download_julia_cmd(props_obj) @util.renderer def render_tester_name(props_obj): props = props_obj_to_dict(props_obj) return "Julia %s Testing"%(props['buildername'].replace('package_', ''))
""" Creating new user after checking all the input. the user will be added into the remote data source and input the login details into the login window """ def makeUser(self,name,pw,pw2,email): """Checking input is valid and not already exist in the current database before creating new user instance Args: name (string): username taken from user input, need to be more than 2 characters and less than 20 characters pw (string): password taken from user input, need to be more than 8 character and less than 20 characters pw2 (string): confirm password, need to be identical with password input email (string): email from user, need to have @ and valid email name """ self.destroy() pass
# -*- coding: utf-8 -*- """ 958. Check Completeness of a Binary Tree Given a binary tree, determine if it is a complete binary tree. Definition of a complete binary tree from Wikipedia: In a complete binary tree every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h. Note: The tree will have between 1 and 100 nodes. """ # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isCompleteTree(self, root): node_list = [root] pre_lvl_full = True while node_list: next_node_list = [] first_node = node_list[0] if first_node is None: for node in node_list[1:]: if node is not None: return False else: next_node_list.append(first_node.left) next_node_list.append(first_node.right) if not pre_lvl_full: return False pre_lvl_full = True for ind, node in enumerate(node_list[1:], start=1): if node is not None: if node_list[ind - 1] is None: return False else: next_node_list.append(node.left) next_node_list.append(node.right) else: pre_lvl_full = False node_list = next_node_list return True
# coding: utf-8 #Name : satoshi-2000 #Date : 2020/12/3 #Title: string ##### ๆ–‡ๅญ—ๅˆ— ##### #ๆ–‡ๅญ—ๅˆ—็ฝฎๆ› a = 'game' b = 'video' ex = 'You say hello and I say hello' #ๆ–‡ๅญ—ๆ•ฐ print(len(a)) #4 #้€ฃ็ต print(a + b) #gamevideo #็นฐใ‚Š่ฟ”ใ— print(a * 3) #gamegamegame #็ฝฎๆ› print(ex.replace('say','soy')) #You soy hello and I soy hello print(ex.replace('hello','hi')) #You say hi and I say hi #1ๆ–‡ๅญ—ใšใคๅ‡ฆ็† print(list(a)) #['g', 'a', 'm', 'e']
""" Faรงa um programa que pergunte a hora para o usuรกrio e, se baseando no horรกrio descrito, exiba a saudaรงรฃo apropriada. """ hora = input("Que horas sรฃo aรญ? ") if hora.isnumeric(): hora = int(hora) else: print("Por favor, digite somente nรบmeros.") if hora < 0 or hora > 23: print("Horรกrio invรกlido") elif hora <= 5: print(f"Ainda รฉ de madrugada, sรฃo {hora} horas, entรฃo podemos considerar boa noite!") elif hora >= 6 and hora <= 11: print(f"Bom dia! Agora sรฃo {hora} horas.") elif hora >= 12 and hora <= 17: print(f"Boa tarde! Agora sรฃo {hora} horas da tarde.") else: print(f"Boa noite! Agora sรฃo {hora} horas da noite.")
class Scope: """ Class to define the Scope object to be used during compilation of the whole program. """ def __init__(self, line_number, instructions): """ Constructor for the Scope object. :param line_number: The line the function is defined at :param instructions: The program to be compiled """ self._type = None self.__line_number = line_number self._instructions = instructions self.__length = len(self._instructions) - 2 # -2 To remove opening and closing line def get_type(self): """ Getter for the type of the scope. :return: The type of the scope as a TokenType """ return self._type def get_line_number(self): """ Getter for the line number the loop is declared at. :return: The line number the scope is declared at as an integer """ return self.__line_number def get_instructions(self): """ Getter for the list of instructions the scope performs. :return: The list of instructions as a 2D list """ return self._instructions def get_length(self): """ Getter for the length of the scope. :return: The length of the function as an integer """ return self.__length if __name__ == '__main__': print('Please save your instructions and run run.py') input('Press enter to close window . . . ')
try: num = float(input("Enter a number : ")) def real_nums(x): if x > 0: return "The number is POSITIVE" elif x == 0: return "The number is ZERO" elif x < 0: return "The number is NEGATIVE" else: return "Enter a valid number!" def even_or_odd(x): if x%2 == 0: if x == 0: return "Zero cannot be either positive or negative." else: return "The number is EVEN." elif x%2 != 0: return "The number is ODD." else: return "Enter a valid number!" x,y = real_nums(num), even_or_odd(num) print(x,y,sep=' & ') except: print("Enter a valid number!")
""" month picker simple case implementation in python """ class Case(object): """ class to return a month """ def what_month(self, num): """ returns the month Arguments: num {int} -- month Returns: string -- month """ method_name = "month_{}".format(num) method = getattr(self, method_name, lambda: "Invalid Input") return method() @staticmethod def month_1(): ''' jan ''' return "January" @staticmethod def month_2(): ''' feb ''' return "February" @staticmethod def month_3(): ''' mar ''' return "March" @staticmethod def month_4(): ''' apr ''' return "April" @staticmethod def month_5(): ''' may ''' return "May" @staticmethod def month_6(): ''' jun ''' return "June" @staticmethod def month_7(): ''' jul ''' return "July" @staticmethod def month_8(): ''' aug ''' return "August" @staticmethod def month_9(): ''' sep ''' return "Setember" @staticmethod def month_10(): ''' oct ''' return "October" @staticmethod def month_11(): ''' nov ''' return "November" @staticmethod def month_12(): ''' dec ''' return "December" if __name__ == "__main__": MY_MONTH = Case() print(MY_MONTH.what_month(input("Please Enter the Month Number: ")))
# Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. class BoolStr(object): """A custom boolean/string hybrid type for resource.props. Translates a given value to the desired type. """ def __init__(self, given): """A boolean parser. Interprets the given value as a boolean, ignoring whitespace and case. A TypeError is raised when interpreted as neither True nor False. """ expr = str(given).lower() if 'true' == expr: self.parsed = True elif 'false' == expr: self.parsed = False else: msg = 'Invalid as boolean: %s' % given raise ValueError(msg) def __bool__(self): return self.parsed __nonzero__ = __bool__ def __str__(self): return str(self.parsed)
""" Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is even. You may return any answer array that satisfies this condition. Example: Input: [4,2,5,7] Output: [4,5,2,7] Explanation: [4,7,2,5], [2,5,4,7], [2,7,4,5] would also have been accepted. Note: 1. 2 <= A.length <= 20000 2. A.length % 2 == 0 3. 0 <= A[i] <= 1000 """ #Difficulty: Easy #61 / 61 test cases passed. #Runtime: 212 ms #Memory Usage: 16.4 MB #Runtime: 212 ms, faster than 92.97% of Python3 online submissions for Sort Array By Parity II. #Memory Usage: 16.4 MB, less than 39.20% of Python3 online submissions for Sort Array By Parity II. class Solution: def sortArrayByParityII(self, A: List[int]) -> List[int]: even = 0 odd = 1 l = len(A) B = [None] * l for i in range(l): if A[i] % 2: B[odd] = A[i] odd += 2 else: B[even] = A[i] even += 2 return B
#Finding number of hansu which is under n def number_of_hansu(n): out = 0 digit_difference = 0 for i in range(1, n + 1): #Number under 100 is always hansu if i < 100: out += 1 else: #First digit difference digit_difference = digits(i)[1] - digits(i)[0] for j in range(len(digits(i)) - 1): #If digits are different if digits(i)[j + 1] - digits(i)[j] != digit_difference: break #If the number is hansu if j == len(digits(i)) - 2: out += 1 #Returning value return out #Finding digits of n def digits(n): digit = [] while n > 0: digit += [n % 10] n = n // 10 digit.reverse() return digit #Input part N = int(input()) answer = 0 #Applying algorithm answer = number_of_hansu(N) #Output part print(answer)
criteria = [ { 'name': 'Price', 'inc': "Two thousand dollars is a lot of Ramen.", 'just': "A high price tag will be a deal breaker no matter what." }, { 'name': 'User Rating', 'inc': "User ratings indicate reliability and general satisfaction of previous customers.", 'just': "This is the only way to determine quality without testing each laptop." }, { 'name': 'Weight', 'inc': "The last thing you want is to carry a dumbbell around campus.", 'just': "The cold, hard truth is you will spend more time carrying your laptop than using it." }, { 'name': 'Screen Size', 'inc': "You can Facebook and program at the same time!", 'just': "Being able to see multiple objects makes you far more effective." }, { 'name': 'Power', 'inc': "Some of your programs are computationally intensive with high memory usage.", 'just': "It is nice, but for the most part it doesn't make a difference in your life." }, { 'name': 'Storage', 'inc': "In some programs you will produce lots of data and waiting for it to save is boring. ", 'just': "Load and save time is relatively insignificant." }, { 'name': 'Battery Life', 'inc': "A laptop is useless if you can't use it on the go. But there are plenty of outlets on campus.", 'just': "The only time an outlet might not be available is during a lecture." } ] ranking = [ { 'name' : "HP Envy 15t Quad Edition", 'rank': 71.6 }, { 'name' : "Dell Inspiron i15RV-1435BLK", 'rank': 69.6 }, { 'name' : "Toshiba Satellite C55-A5245", 'rank': 69.1 }, { 'name' : "Lenovo IdeaPad U430", 'rank': 64.7 }, { 'name' : "MacBook Air 13\"", 'rank': 63.5 }, { 'name' : "MacBook Pro 13\" with Retina Display", 'rank': 62.9 }, { 'name' : "ASUS ROG 6750JM-DS71", 'rank': 57.7 } ] algorithm = [ { 'name': 'Price', 'weight': 30, 'formula': "img/price_formula.gif", 'assumption': "$2000 is likely the most a student will be willing to pay for a laptop." }, { 'name': 'User Rating', 'weight': 25, 'formula': "img/user_rating_formula.gif", 'assumption': "User Ratings are from 1 to 5." }, { 'name': 'Weight', 'weight': 20, 'formula': "img/weight_formula.gif", 'assumption': "10 pounds is the most a laptop should weigh to be reasonable for a student." }, { 'name': 'Screen Size', 'weight': 10, 'formula': "img/screen_size_formula.gif", 'assumption': "The largest reasonable laptop screen size is 17 inches." }, { 'name': 'Power', 'weight':7, 'formula': "img/power_formula.gif", 'assumption': "Quad core, 3 GHz, and 8Gb of RAM are reasonable limits for a student." }, { 'name': 'Storage', 'weight': 5, 'formula': "img/storage_formula.gif", 'assumption': "An SSD is roughly equivalent to a 10,000 rpm optical disk and 512 Gb is a reasonable upper bound on hard drive space." }, { 'name': 'Battery Life', 'weight': 3, 'formula': "img/battery_life_formula.gif", 'assumption': "15 hours is the largest reasonable battery life of a laptop." } ] breakdown = { 'row_headings': ["Price", "User Rating", "Weight", "Screen Size", "Power", "Storage", "Battery Life"], 'col_headings': ["HP Envy 15t Quad", "Dell Inspiron i15RV", "Toshiba Satellite C55", "Lenovo IdeaPad U430", "MacBook Air 13\"", "MacBook Pro 13\"", "ASUS ROG 6750JM"], 'rows': [ [19.5, 20.5, 8.8, 9.2, 5.6, 6.2, 1.9], [24.3, 20.0, 10.1, 9.2, 1.5, 3.8, 0.8], [23.7, 20.5, 9.2, 9.2, 1.9, 3.8, 0.8], [19.5, 19.0, 11.6, 8.2, 1.5, 3.8, 1.1], [15.8, 20.5, 14.1, 6.5, 1.2, 3.1, 2.4], [ 9.0, 23.5, 13.1, 7.8, 4.0, 3.8, 1.8], [10.5, 21.5, 0.2, 10.2, 8.4, 6.2, 0.7] ] } proscons = [ { 'name':'HP Envy 15t Quad Edition', 'url': 'http://ssl-product-images.www8-hp.com/digmedialib/prodimg/lowres/c03698047.png', 'pro': '15.6 inch screen\nSolid power\nFour Beats audio speakers ', 'con': 'Heavy\nNo SSD' }, { 'name':'Dell Inspiron i15RV-1435BLK', 'url': 'http://ecx.images-amazon.com/images/I/71qmqgZmp7L._SL1500_.jpg', 'pro': 'Inexpensive\n15.6 Inch Screen', 'con': 'Poor battery life\nNot very powerful\nNo SSD' }, { 'name':'Toshiba Satellite C55-A5245', 'url': 'https://www.laptopninja.org/wp-content/uploads/2014/03/Toshiba-Satellite-C55-A5245.jpg', 'pro': 'Inexpensive\n15.6 Inch Screen', 'con': 'Fairly heavy\nPoor battery life\nNo SSD' }, { 'name':'Lenovo IdeaPad U430', 'url': 'http://media.engadget.com/img/products/488/ah7w/ah7w-800.jpg', 'pro': 'Powerful\nTouch screen', 'con': 'No SSD' }, { 'name':'MacBook Air 13"', 'url': 'http://images.apple.com/macbook-air/images/techspecs_headline_13inch.jpg', 'pro': 'Weight\nSuper thin\nHas SSD', 'con': 'Expensive\nScreen Size' }, { 'name':'MacBook Pro 13" with Retina Display', 'url': 'http://cdn0.sbnation.com/products/large/7406/retina13.jpg?1382468345', 'pro': 'Retina display\nPowerful\nThin & light\nHas SSD', 'con': 'Expensive\nSmall Screen' }, { 'name':'ASUS ROG 6750JM-DS71', 'url': 'http://ecx.images-amazon.com/images/I/41eUTqGvDpL._SL160_SL150_.jpg', 'pro': 'Very powerful\n1 TB hard drive\nGaming', 'con': 'Extremely heavy\nVery poor battery life\nNo SSD' } ] specs = [ # Price Rating Weight ScreenSize Power RAM Hard Drive BL ["$702", 4.1, "5.6 lbs", "15.6\"", "4 cores 2.4 clock with 8Gb of RAM", "5400 rpm 1100 Gb", "9.5 hrs"], ["$379", 4.0, "4.9 lbs", "15.6\"", "2 cores 1.8 clock with 4Gb of RAM", "5400 rpm 500 Gb", "4 hrs"], ["$419", 4.1, "5.4 lbs", "15.6\"", "2 cores 2.3 clock with 4Gb of RAM", "5400 rpm 500 Gb", "4 hrs"], ["$699", 3.8, "4.2 lbs", "14.0\"", "2 cores 1.8 clock with 4Gb of RAM", "5400 rpm 500 Gb", "5.5 hrs"], ["$949", 4.1, "2.9 lbs", "11.0\"", "2 cores 1.4 clock with 4Gb of RAM", "10000 rpm 128 Gb", "12 hrs"], ["$1399", 4.7, "3.4 lbs", "13.3\"", "2 cores 2.4 clock with 8Gb of RAM", "10000 rpm 256 Gb", "9 hrs"], ["$1299", 4.3, "9.9 lbs", "17.3\"", "4 cores 2.4 clock with 12Gb of RAM", "5400 rpm 1000 Gb", "3.5 hrs"] ]
""" __init__.py Created by: Martin Sicho On: 4/27/20, 10:49 AM """
# # PySNMP MIB module A3COM-HUAWEI-DNS-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/A3COM-HUAWEI-DNS-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 16:49:29 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # h3cCommon, = mibBuilder.importSymbols("A3COM-HUAWEI-OID-MIB", "h3cCommon") Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, ValueSizeConstraint, ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueSizeConstraint", "ConstraintsIntersection", "SingleValueConstraint", "ValueRangeConstraint") InetAddressType, InetAddress = mibBuilder.importSymbols("INET-ADDRESS-MIB", "InetAddressType", "InetAddress") NotificationGroup, ModuleCompliance, ObjectGroup = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance", "ObjectGroup") TimeTicks, Integer32, Gauge32, IpAddress, Counter32, Bits, Unsigned32, ModuleIdentity, iso, MibIdentifier, ObjectIdentity, NotificationType, Counter64, MibScalar, MibTable, MibTableRow, MibTableColumn = mibBuilder.importSymbols("SNMPv2-SMI", "TimeTicks", "Integer32", "Gauge32", "IpAddress", "Counter32", "Bits", "Unsigned32", "ModuleIdentity", "iso", "MibIdentifier", "ObjectIdentity", "NotificationType", "Counter64", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn") RowStatus, DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "RowStatus", "DisplayString", "TextualConvention") h3cDns = ModuleIdentity((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97)) h3cDns.setRevisions(('2009-02-12 00:00',)) if mibBuilder.loadTexts: h3cDns.setLastUpdated('200902120000Z') if mibBuilder.loadTexts: h3cDns.setOrganization('Hangzhou H3C Tech. Co., Ltd.') h3cDnsObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1)) h3cDnsStaticSrvIpTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 1), ) if mibBuilder.loadTexts: h3cDnsStaticSrvIpTable.setStatus('current') h3cDnsStaticSrvIpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 1, 1), ).setIndexNames((0, "A3COM-HUAWEI-DNS-MIB", "h3cDnsStaticSrvIpType"), (0, "A3COM-HUAWEI-DNS-MIB", "h3cDnsStaticSrvIpAddr")) if mibBuilder.loadTexts: h3cDnsStaticSrvIpEntry.setStatus('current') h3cDnsStaticSrvIpType = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 1, 1, 1), InetAddressType()) if mibBuilder.loadTexts: h3cDnsStaticSrvIpType.setStatus('current') h3cDnsStaticSrvIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 1, 1, 2), InetAddress().subtype(subtypeSpec=ValueSizeConstraint(1, 64))) if mibBuilder.loadTexts: h3cDnsStaticSrvIpAddr.setStatus('current') h3cDnsStaticSrvIpPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 1, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cDnsStaticSrvIpPriority.setStatus('current') h3cDnsStaticSrvIpRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 1, 1, 4), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: h3cDnsStaticSrvIpRowStatus.setStatus('current') h3cDnsDynamicSrvIpTable = MibTable((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 2), ) if mibBuilder.loadTexts: h3cDnsDynamicSrvIpTable.setStatus('current') h3cDnsDynamicSrvIpEntry = MibTableRow((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 2, 1), ).setIndexNames((0, "A3COM-HUAWEI-DNS-MIB", "h3cDnsDynamicSrvIpType"), (0, "A3COM-HUAWEI-DNS-MIB", "h3cDnsDynamicSrvIpAddr")) if mibBuilder.loadTexts: h3cDnsDynamicSrvIpEntry.setStatus('current') h3cDnsDynamicSrvIpType = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 2, 1, 1), InetAddressType()) if mibBuilder.loadTexts: h3cDnsDynamicSrvIpType.setStatus('current') h3cDnsDynamicSrvIpAddr = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 2, 1, 2), InetAddress().subtype(subtypeSpec=ValueSizeConstraint(1, 64))) if mibBuilder.loadTexts: h3cDnsDynamicSrvIpAddr.setStatus('current') h3cDnsDynamicSrvIpPriority = MibTableColumn((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 1, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2147483647))).setMaxAccess("readonly") if mibBuilder.loadTexts: h3cDnsDynamicSrvIpPriority.setStatus('current') h3cDnsMIBConformance = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 2)) h3cDnsMIBCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 2, 1)) h3cDnsMIBCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 2, 1, 1)).setObjects(("A3COM-HUAWEI-DNS-MIB", "h3cDnsStaticSrvIpGroup"), ("A3COM-HUAWEI-DNS-MIB", "h3cDnsDynamicSrvIpGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cDnsMIBCompliance = h3cDnsMIBCompliance.setStatus('current') h3cDnsMIBGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 2, 2)) h3cDnsStaticSrvIpGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 2, 2, 1)).setObjects(("A3COM-HUAWEI-DNS-MIB", "h3cDnsStaticSrvIpPriority"), ("A3COM-HUAWEI-DNS-MIB", "h3cDnsStaticSrvIpRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cDnsStaticSrvIpGroup = h3cDnsStaticSrvIpGroup.setStatus('current') h3cDnsDynamicSrvIpGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 43, 45, 1, 10, 2, 97, 2, 2, 2)).setObjects(("A3COM-HUAWEI-DNS-MIB", "h3cDnsDynamicSrvIpPriority")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): h3cDnsDynamicSrvIpGroup = h3cDnsDynamicSrvIpGroup.setStatus('current') mibBuilder.exportSymbols("A3COM-HUAWEI-DNS-MIB", h3cDnsStaticSrvIpPriority=h3cDnsStaticSrvIpPriority, h3cDnsStaticSrvIpAddr=h3cDnsStaticSrvIpAddr, h3cDnsDynamicSrvIpPriority=h3cDnsDynamicSrvIpPriority, h3cDnsDynamicSrvIpGroup=h3cDnsDynamicSrvIpGroup, h3cDns=h3cDns, h3cDnsDynamicSrvIpType=h3cDnsDynamicSrvIpType, h3cDnsStaticSrvIpType=h3cDnsStaticSrvIpType, h3cDnsStaticSrvIpEntry=h3cDnsStaticSrvIpEntry, h3cDnsDynamicSrvIpEntry=h3cDnsDynamicSrvIpEntry, h3cDnsMIBConformance=h3cDnsMIBConformance, h3cDnsStaticSrvIpRowStatus=h3cDnsStaticSrvIpRowStatus, h3cDnsDynamicSrvIpTable=h3cDnsDynamicSrvIpTable, h3cDnsMIBCompliance=h3cDnsMIBCompliance, h3cDnsObjects=h3cDnsObjects, PYSNMP_MODULE_ID=h3cDns, h3cDnsStaticSrvIpTable=h3cDnsStaticSrvIpTable, h3cDnsStaticSrvIpGroup=h3cDnsStaticSrvIpGroup, h3cDnsMIBGroups=h3cDnsMIBGroups, h3cDnsDynamicSrvIpAddr=h3cDnsDynamicSrvIpAddr, h3cDnsMIBCompliances=h3cDnsMIBCompliances)
DEBUG = False PORT = 8080 PROPAGATE_EXCEPTIONS = True SQLALCHEMY_ECHO = False SQLALCHEMY_DATABASE_URI = "" SQLALCHEMY_POOL_SIZE = 15
class Workpiece: def __init__(self, id): self.id = id # self.status = "awaiting production" self.status = "awaiting next step" self.actual_quality = None self.source = None self.sink = None self.location = "wc_0" # Starting point. Location refers to workcell id. self.step_idx = None self.pos = None self.count_down = 0
def add_filters_to_legend(): pass def extend_data_from_recs(): pass def find_errors(): '''find errors such as restricted works, etc. where data needs to be entered manually''' pass
QWERTY_KEYMAP = bytearray.fromhex('000000000000000000000000760f00d4ffffffc7000000782c1e3420212224342627252e362d3738271e1f202122232425263333362e37381f0405060708090a0b0c0d0e0f101112131415161718191a1b1c1d2f3130232d350405060708090a0b0c0d0e0f101112131415161718191a1b1c1d2f313035') print(QWERTY_KEYMAP) print(type(QWERTY_KEYMAP))
# MIT License # # Copyright (c) [2018] [Victor Manuel Cajes Gonzalez - vcajes@gmail.com] # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. # possibles values for the BancardAPI environment class member ENVIRONMENT_SANDBOX = "sandbox" ENVIRONMENT_PRODUCTION = "production" # Currencies that Bancard allows for charging BANCARD_ALLOWED_CURRENCIES = ["PYG"] BANCARD_BASE_URL_SANDBOX = "https://vpos.infonet.com.py:8888" BANCARD_BASE_URL_PRODUCTION = "https://vpos.infonet.com.py" # Keys for the SANDBOX_URLS / PRODUCTION_URLS dictionaries ROLLBACK_KEY = "rollback" CHARGE_TOKEN_GENERATOR_KEY = "single_buy" PAYMENT_WEB_URL_KEY = "payment" CONFIRMATIONS_KEY = "confirmations" # Bancard WebService development (sandbox) environment endpoints BANCARD_SANDBOX_URLS = { ROLLBACK_KEY: "%s/vpos/api/0.3/single_buy/rollback" % BANCARD_BASE_URL_SANDBOX, CHARGE_TOKEN_GENERATOR_KEY: "%s/vpos/api/0.3/single_buy" % BANCARD_BASE_URL_SANDBOX, PAYMENT_WEB_URL_KEY: "%s/payment/single_buy?process_id=" % BANCARD_BASE_URL_SANDBOX, CONFIRMATIONS_KEY: "%s/vpos/api/0.3/single_buy/confirmations" % BANCARD_BASE_URL_SANDBOX, } # Bancard WebService production environment endpoints BANCARD_PRODUCTION_URLS = { ROLLBACK_KEY: "%s/vpos/api/0.3/single_buy/rollback" % BANCARD_BASE_URL_PRODUCTION, CHARGE_TOKEN_GENERATOR_KEY: "%s/vpos/api/0.3/single_buy" % BANCARD_BASE_URL_PRODUCTION, PAYMENT_WEB_URL_KEY: "%s/payment/single_buy?process_id=" % BANCARD_BASE_URL_PRODUCTION, CONFIRMATIONS_KEY: "%s/vpos/api/0.3/single_buy/confirmations" % BANCARD_BASE_URL_PRODUCTION, } # All the Bancard WebService endpoints for sandbox/production BANCARD_URLS = { ENVIRONMENT_SANDBOX: BANCARD_SANDBOX_URLS, ENVIRONMENT_PRODUCTION: BANCARD_PRODUCTION_URLS }
class APIError(Exception): """Base exception for errors raised by high-level websocket API.""" class MessageHandlerError(APIError): """Decoding or parsing a message failed.""" class RemoteMessageHandlerError(MessageHandlerError): """Raised for errors directly caused by messages from the client.""" class InternalMessageHandlerError(MessageHandlerError): """Raised for errors directly caused by messages from internal sources."""
def printadj(table,g): print(" ",end="") print(" ".join(table)) for i in table: strout = "" print(i,end=" : ") for j in table: l = g.get(i,None) if not l : strout+="0, " elif j in l: strout+="1, " else: strout+="0, " print(strout[:-2]) table = [] inp = input("Enter : ").split(",") g = dict() for i in inp: if g.get(i.split()[0],-1) == -1: g[i.split()[0]] = i.split()[1] else: g[i.split()[0]] += i.split()[1] if i.split()[0] not in table: table.append(i.split()[0]) if i.split()[1] not in table: table.append(i.split()[1]) table.sort() printadj(table,g)
""" Created on May 4 - 2019 ---Based on the 2-stage stochastic program structure ---Assumption: RHS is random ---read stoc file (.tim) ---save the distributoin of the random variables and return the ---random variables @author: Siavash Tabrizian - stabrizian@smu.edu """ class readtim: def __init__(self, name): self.name = name + ".tim" self.stage = list() self.stagenum = 0 ## Read the stoc file def readfile(self): with open(self.name, "r") as f: data = f.readlines() #go through the time file count = 0 for line in data: words = line.split() #print words if len(words) > 2: tmp = list() tmp.append(words[0]) tmp.append(words[1]) self.stage.append(tmp) count += 1 self.stagenum = count if count > 2: print ("ERROR: more than two stages")
class Solution: def twoSum(self, nums, target): for n in nums: print("n = {}".format(n)) indexN = nums.index(n) print("indexN = {}".format(indexN)) for p in nums[1:]: print("p = {}".format(p)) indexP = nums.index(p) print("indexP = {}".format(indexP)) if indexP == 0: continue else: if n + p == target: num1 = nums.index(n) num2 = nums.index(p) return [num1,num2] twoSum(0,[3, 3], 6)
''' Binary Seach works on only sorted collection. Time : O(log n) Space : O(1) ''' def binarySearch(arr, target): left = 0 right = len(arr)-1 while(left <= right): mid = (left + right) // 2 if(arr[mid] == target): return mid #if target is greater than mid then set left to min+1 elif(arr[mid]< target): left = mid+1 else: right = mid - 1 return -1 if __name__ == "__main__": arr = [10,11,12,13,14,15] target = 15 result = binarySearch(arr, target) #5 if result != -1: print("Result is present at index %d"% result) else: print("Element is not present in the list.")
""" 1436. Destination City You are given the array paths, where paths[i] = [cityAi, cityBi] means there exists a direct path going from cityAi to cityBi. Return the destination city, that is, the city without any path outgoing to another city. It is guaranteed that the graph of paths forms a line without any loop, therefore, there will be exactly one destination city. Example 1: Input: paths = [["London","New York"],["New York","Lima"],["Lima","Sao Paulo"]] Output: "Sao Paulo" Explanation: Starting at "London" city you will reach "Sao Paulo" city which is the destination city. Your trip consist of: "London" -> "New York" -> "Lima" -> "Sao Paulo". Example 2: Input: paths = [["B","C"],["D","B"],["C","A"]] Output: "A" Explanation: All possible trips are: "D" -> "B" -> "C" -> "A". "B" -> "C" -> "A". "C" -> "A". "A". Clearly the destination city is "A". Example 3: Input: paths = [["A","Z"]] Output: "Z" Constraints: 1 <= paths.length <= 100 paths[i].length == 2 1 <= cityAi.length, cityBi.length <= 10 cityAi != cityBi All strings consist of lowercase and uppercase English letters and the space character. """ class Solution: def destCity(self, paths: List[List[str]]): start, end = set(), set() for pth in paths: start.add(pth[0]) end.add(pth[1]) for des in end: if des not in start: return des
t=int(input()) for qwerty in range(t): #n,a,b,c=input().split() #n,a,b,c=int(n),int(a),int(b),int(c) #n=int(input()) arr1=list(map(int,input().split())) arr2=list(map(int,input().split())) n1,n2=len(arr1),len(arr2) arr3=[] i=0 j=0 k=0 while(i<n1 and j <n2): if(arr1[i]<arr2[j]): arr3.append(arr1[i]) i+=1 else: arr3.append(arr2[j]) j+=1 if(j!=n1): for k in range(j,n2): arr3.append(arr2[k]) elif(i!=n2): for k in range(i,n1): arr3.append(arr1[k]) print(arr3)
expected_output ={ "vrf": { "tn-L2-PBR:vrf-L2-PBR": { "address_family": { "ipv4": { "routes": { "192.168.1.0/24": { "route": "192.168.1.0/24", "active": True, "ubest": 1, "mbest": 0, "attached": True, "direct": True, "pervasive": True, "metric": 0, "route_preference": 1, "tag": 4294967294, "next_hop": { "next_hop_list": { 1: { "index": 1, "next_hop": "10.11.200.98", "source_protocol": "static", "best_ucast_nexthop": True, "updated": "02w00d", "next_hop_vrf": "overlay-1", "metric": 0, "route_preference": 1, } } }, "source_protocol": "static", }, "192.168.1.1/32": { "route": "192.168.1.1/32", "active": True, "ubest": 1, "mbest": 0, "attached": True, "pervasive": True, "metric": 0, "route_preference": 0, "next_hop": { "next_hop_list": { 1: { "index": 1, "next_hop": "192.168.1.1", "source_protocol": "local", "source_protocol_status": "local", "best_ucast_nexthop": True, "updated": "02w00d", "outgoing_interface": "Vlan60", "metric": 0, "route_preference": 0, } } }, "source_protocol": "local", "source_protocol_status": "local", }, "192.168.100.0/24": { "route": "192.168.100.0/24", "active": True, "ubest": 1, "mbest": 0, "attached": True, "direct": True, "pervasive": True, "metric": 0, "route_preference": 1, "tag": 4294967294, "next_hop": { "next_hop_list": { 1: { "index": 1, "next_hop": "10.11.200.98", "source_protocol": "static", "best_ucast_nexthop": True, "updated": "02w00d", "next_hop_vrf": "overlay-1", "metric": 0, "route_preference": 1, } } }, "source_protocol": "static", }, "192.168.100.1/32": { "route": "192.168.100.1/32", "active": True, "ubest": 1, "mbest": 0, "attached": True, "pervasive": True, "metric": 0, "route_preference": 0, "next_hop": { "next_hop_list": { 1: { "index": 1, "next_hop": "192.168.100.1", "source_protocol": "local", "source_protocol_status": "local", "best_ucast_nexthop": True, "updated": "02w00d", "outgoing_interface": "Vlan14", "metric": 0, "route_preference": 0, } } }, "source_protocol": "local", "source_protocol_status": "local", }, "192.168.254.0/24": { "route": "192.168.254.0/24", "active": True, "ubest": 1, "mbest": 0, "attached": True, "direct": True, "pervasive": True, "metric": 0, "route_preference": 1, "tag": 4294967294, "next_hop": { "next_hop_list": { 1: { "index": 1, "next_hop": "10.11.200.98", "source_protocol": "static", "best_ucast_nexthop": True, "updated": "02w00d", "next_hop_vrf": "overlay-1", "metric": 0, "route_preference": 1, } } }, "source_protocol": "static", }, "192.168.254.1/32": { "route": "192.168.254.1/32", "active": True, "ubest": 1, "mbest": 0, "attached": True, "pervasive": True, "metric": 0, "route_preference": 0, "next_hop": { "next_hop_list": { 1: { "index": 1, "next_hop": "192.168.254.1", "source_protocol": "local", "source_protocol_status": "local", "best_ucast_nexthop": True, "updated": "02w00d", "outgoing_interface": "Vlan39", "metric": 0, "route_preference": 0, } } }, "source_protocol": "local", "source_protocol_status": "local", }, } } } } } }
# Week 1 Exercise 1 # Orla Higgins, 2018-02-20 # A program that displays Fibonacci numbers. def fib(n): """This function returns the nth Fibonacci number.""" i = 0 j = 1 n = n - 1 while n >= 0: i, j = j, i + j n = n - 1 return i # Test the function with the following value. x = 16 ans = fib(x) print("Fibonacci number", x, "is", ans) # Comments on Discussions Board for Topic 1: # My name is Orla, so the first and last letter of my name (O + A = 15 + 1) give the number 16. The 16th Fibonacci number is 987. # Week 2 Exercise 2 # Orla Higgins, 2018-02-26 # A program that displays Fibonacci numbers using people's names. name = "Higgins" first = name[0] last = name[-1] firstno = ord(first) lastno = ord(last) x = firstno + lastno ans = fib(x) print("My surname is", name) print("The first letter", first, "is number", firstno) print("The last letter", last, "is number", lastno) print("Fibonacci number", x, "is", ans) # Comments on Discussions Board for Topic 2: # My surname is Higgins # The first letter H is number 72 # The last letter s is number 115 # Fibonacci number 187 is 538522340430300790495419781092981030533 # ord() is a built-in function of Python. Given a string representing one Unicode character, the function will return an integer representing the Unicode code point of that character in decimal form.
''' Fixed XOR Write a function that takes two equal-length buffers and produces their XOR combination. If your function works properly, then when you feed it the string: 1c0111001f010100061a024b53535009181c ... after hex decoding, and when XOR'd against: 686974207468652062756c6c277320657965 ... should produce: 746865206b696420646f6e277420706c6179 ''' buf1 = '1c0111001f010100061a024b53535009181c' buf2 = '686974207468652062756c6c277320657965' def bufferXOR(buffer1,buffer2,printflag=False): ''' takes two equal-length buffers and produces their XOR combination :param buffer1: either hex string or bytes :param buffer2: either hex string or bytes :param printflag: :return: XOR result in bytearray ''' # verify if length is the same try: byte1 = buffer1 byte2 = buffer2 if isinstance(buffer1,str): byte1= bytes.fromhex(buffer1) if isinstance(buffer2,str): byte2 = bytes.fromhex(buffer2) if len(byte1)!=len(byte2): print('Input error, len1 {} and len2 {} do not match'.format(len(byte1),len(byte2))) return '' XOR_bytes = bytearray(byte1) for i,b in enumerate(byte2): XOR_bytes[i]^=b # XOR_message = XOR_bytes.decode() if printflag: print('Buffer1 is: {}'.format(buffer1)) print('Buffer2 is: {}'.format(buffer2)) print('Hex is: {}'.format(XOR_bytes.hex())) # print('XOR buffer is: {}'.format(XOR_message)) return XOR_bytes except ValueError: print('Error hex conversion, verify validity of input') return bytearray(b'') if __name__=='__main__': bufferXOR(buf1,buf2,True)
CAPACITY = 100 class Heap: def __init__(self): self.heap_size = 0 self.heap = [0]*CAPACITY def insert(self, item): if self.heap_size == CAPACITY: return self.heap[self.heap_size] = item self.heap_size = self.heap_size + 1 self.fix_up(self.heap_size-1) def fix_up(self, index): parent_index = (index-1)//2 if index > 0 and self.heap[index] > self.heap[parent_index]: self.heap[index], self.heap[parent_index] = self.heap[parent_index], self.heap[index] self.fix_up(parent_index) def get_max(self): return self.heap[0] def poll(self): max_item = self.get_max() self.heap[0], self.heap[self.heap_size - 1] = self.heap[self.heap_size - 1], self.heap[0] self.heap_size = self.heap_size - 1 self.fix_down(0) return max_item def fix_down(self, index): index_left = 2 * index + 1 index_right = 2 * index + 2 largest_index = index if index_left < self.heap_size and self.heap[index_left] > self.heap[index]: largest_index = index_left if index_right < self.heap_size and self.heap[index_right] > self.heap[largest_index]: largest_index = index_right if index != largest_index: self.heap[index], self.heap[largest_index] = self.heap[largest_index], self.heap[index] self.fix_down(largest_index) def heap_sort(self): for _ in range(self.heap_size): max_item = self.poll() print(max_item, end=" ") heap = Heap() heap.insert(13) heap.insert(-2) heap.insert(0) heap.insert(8) heap.insert(1) heap.insert(-5) heap.insert(93) heap.insert(94) heap.insert(95) heap.insert(96) heap.insert(97) heap.insert(-50) heap.insert(-97) heap.heap_sort()
"""Class that stores the position information""" class FlPosition: """Stores the position information""" def __init__(self, position_data, column_labels, timestamps, conversion): self.position_data = position_data self.column_labels = column_labels self.timestamps = timestamps self.conversion = conversion
_base_ = '../_base_/datasets/coco_detection.py' data_root = 'data/egohands/' classes = ('myleft', 'myright', 'yourleft', 'yourright') # ใ‚ฏใƒฉใ‚นใƒฉใƒ™ใƒซ data = dict( train=dict( classes=classes, # COCOใƒ‡ใƒผใ‚ฟใ‚ปใƒƒใƒˆใฎใ‚ฏใƒฉใ‚นใ‚’ใ‚ชใƒผใƒใƒผใƒฉใ‚คใƒ‰ ann_file=data_root+'annotations/train.json', img_prefix=data_root+'train/'), val=dict( classes=classes, # COCOใƒ‡ใƒผใ‚ฟใ‚ปใƒƒใƒˆใฎใ‚ฏใƒฉใ‚นใ‚’ใ‚ชใƒผใƒใƒผใƒฉใ‚คใƒ‰ ann_file=data_root+'annotations/valid.json', img_prefix=data_root+'valid/'), test=dict( classes=classes, # COCOใƒ‡ใƒผใ‚ฟใ‚ปใƒƒใƒˆใฎใ‚ฏใƒฉใ‚นใ‚’ใ‚ชใƒผใƒใƒผใƒฉใ‚คใƒ‰ ann_file=data_root+'annotations/test.json', img_prefix=data_root+'test/') )
def HI(): print("=======================================") print("= = = =") print("= = =") print("= ====== = =") print("= = = = =") print("= = = = =") print("=======================================") HI()
def makeminutes(time): h, m = time.split(':') return int(h)*60+int(m) def check_buses(n, m, lines): cntbuses = [0]*(n+1) busbalance = [0]*(n+1) events = [] overnight = 0 for line in lines: cdep, deptime, carr, arrtime = line.split() cdep = int(cdep) carr = int(carr) deptime = makeminutes(deptime) arrtime = makeminutes(arrtime) if arrtime < deptime: overnight += 1 busbalance[cdep] -= 1 busbalance[carr] += 1 events.append((deptime, 1, cdep)) events.append((arrtime, -1, carr)) disbalance = False for i in range(n+1): if busbalance[i] != 0: disbalance = True if disbalance: return '-1' events.sort() for event in events: if event[1] == -1: cntbuses[event[2]] += 1 else: if cntbuses[event[2]] > 0: cntbuses[event[2]] -= 1 ans = 0 for i in range(n+1): ans += cntbuses[i] return str(ans+overnight) with open('input.txt') as file: lines = file.readlines() n, m = map(int, lines[0].split()) with open('output.txt', 'w') as file: file.write(check_buses(n, m, lines[1:]))
#!/usr/bin/env python class DataProcessingException(Exception): pass
def get_messages(text: str): result = dict() current_key = None for no, line in enumerate(text.split("\n")): line = line.strip() # ะ•ัะปะธ ัั‚ั€ะพะบะฐ ัะฒะปัะตั‚ัั ะบะพะผะผะตะฝั‚ะฐั€ะธะตะผ if line.startswith('#'): continue is_key = line.startswith(':') if not current_key: if not line: continue if not is_key: raise ValueError('File must start with key name. Line {}'.format(no)) if is_key: current_key = line[1:] result[current_key] = '' continue result[current_key] = (result[current_key] + '\n' + line).strip() return result
class Solution: def distinctSubseqII(self, S): res, end = 0, collections.Counter() for c in S: res, end[c] = res * 2 + 1 - end[c], res + 1 return res % (10**9 + 7)
inter_,gremio_ = input().split() inter = int(inter_) gremio = int(gremio_) a = 0 contador = 1 v_inter = 0 v_gremio = 0 empate = 0 if inter > gremio: v_inter += 1 elif inter == gremio: empate += 1 else: v_gremio += 1 while a == 0: print("Novo grenal (1-sim 2-nao)") cond = int(input()) if cond == 2: a = 1 else: inter_ = 0 gremio_ = 0 inter = 0 gremio = 0 inter_, gremio_ = input().split() inter = int(inter_) gremio = int(gremio_) contador += 1 if inter > gremio: v_inter += 1 elif inter == gremio: empate += 1 else: v_gremio += 1 print("%i grenais"%contador) print("Inter:%i"%v_inter) print("Gremio:%i"%v_gremio) print("Empates:%i"%empate) if inter > gremio: print("Inter venceu mais") else: print("Gremio venceu mais")
valor1 = float(input("Digite o primeiro valor: ")) dobro = valor1 *2 triplo = valor1 *3 raiz = valor1 **0.5 print("O dobro {} o triplo {} e a raiz quadrada {}".format(dobro,triplo,raiz))
#!/usr/bin/env python #----------------------------------------------------------------------- # tag.py # Author: Olivia Zhang, Zoe Barnswell, Lyra Katzman #----------------------------------------------------------------------- #----------------------------------------------------------------------- class Tag: # def __init__(self, tagID): self.tagID = tagID self.numArticles = 0
TARGET_URL = '/{tail:.*}' EXCLUDED_HEADERS = { # 'Accept-CH', # 'Accept-CH-Lifetime', # 'Cache-Control', # 'Content-Encoding', # 'Content-Security-Policy', # 'Content-Type', # 'Date', # 'Expires', # 'Last-Modified', # 'P3P', # 'Set-Cookie', 'Transfer-Encoding', 'X-Target-Url', 'Content-Length', # 'Host', # 'X-Content-Type-Options', # 'X-Frame-Options' }
# author: alex o def counting_sort_int(array, base, col): # initialise count array count_array = [0]*base # get the digit in position column and add them into "buckets" for elem in array: digit = elem // 10 ** (col) count_array[digit % base] += 1 # initialise position array position = [0]*base position[0] = 1 for i in range(1, base): position[i] = position[i - 1] + count_array[i - 1] # initialise output array output = [0]*len(array) # put back elements from initial array into output array for elem in array: output[position[elem // 10 ** (col) % base] - 1] = elem position[elem // 10 ** (col) % base] += 1 return output def radix_sort(arr): # O(MN), M = number of digits, N = counting sort # gets the maximum length of digits m = max(arr) for i in range(len(str(m))): arr = counting_sort_int(arr, 10, i) yield arr return arr
""" 121 / 121 test cases passed. Runtime: 32 ms Memory Usage: 14.9 MB """ class Solution: def countHillValley(self, nums: List[int]) -> int: stk = [nums[0], nums[1]] ans = 0 for num in nums[2:]: if num == stk[-1]: continue if stk[-2] < stk[-1] and stk[-1] > num: ans += 1 elif stk[-2] > stk[-1] and stk[-1] < num: ans += 1 stk.append(num) return ans
a = [] b = [] c = a a.append(1) b.append(2) c.append(3) print(f'{a=}, {b=}, {c=}') #print(a is c)
class Element: mass = 0.0 def __init__(self, params): self.mass = params["mass"] def molar_mass_kilograms(self): return self.mass / 1000 hydrogen = Element({"mass": 1.00794})
# Here I will attempt to count the occurences of a kmer in a patter def count_kmer(kmer, pattern): num_matches = 0 for num, _ in enumerate(kmer): window = kmer[num: (num+len(pattern))] if window == pattern: num_matches = num_matches + 1 return num_matches count_kmer("ACAACTATGCATACTATCGGGAACTATCCT", "ACTAT") #3 #problem set kmer_to_match = "GGAGGATTCTCCTGAAAAGGATTCAAGCGAGGATTCAAGATATCGCCGTACAGTAGGATTCTAACAGGATTCAGGATTCCTAGACCAAAAGGATTCGACTAGGATTCAGGATTCAGCAAGGATTCAGGATTCAGGATTCTTAGGATTCTGCAGGATTCAGGATTCGAGGATTCTGAGGATTCGCAAGCTCTAGGATTCAGGATTCTTAGGATTCAGGATTCAGAGGATTCAGGATTCAGGATTCGTATGAAAGGATTCCGGAGGATTCCGGGTAGGATTCAGGATTCAAGGATTCAAGGATTCAGGATTCAGGATTCCGAGGATTCAGGATTCGGAGGATTCTTAGGATTCCCAGGATTCACGGGCAGACCTAGGATTCAGGATTCGAAAGGATTCTTGAGGATTCAGGATTCAAAGGATTCCGAGGATTCTAGGATTCGAAGTACCGAGGATTCCCCAGGATTCATGTAGGATTCAGGATTCTAGGATTCGTACGAGGATTCAGGATTCCGTTCTAGGATTCCTTAGGATTCCAGGATTCAGGATTCGGAGGATTCAGAAGGATTCCAGGATTCCTCACAAAATAGGATTCGAGGATTCTAGAGGATTCGCAGGATTCTAAGGATTCATTGTCCAGGATTCTTAAGGATTCAGGATTCAGGATTCAGCCTAGGATTCAGGATTCGGAGGATTCATTCAGGATTCGATCGTGACAGAGGATTCACCAGGATTCTCAGGATTCTAGGATTCAGGATTCGAGGATTCTAGGATTCAAGGATTCAGGATTCGTTATTCACTGGGCAGGATTCAAGGATTCATAGGATTCAGACGCAGGATTCAGGATTCAGGATTCCAGGATTCTGTGAGGATTCATCGAAGGATTCATCCAATAGGATTCCTTTGAGGATTCTAGGATTCGGGCGACTTTAGCAGGATTCGGCCGAAGGATTCAGGATTCATGTTGGTCGCAGGATTCCGCATTTAGTATAGGATTCAGGATTCAGGATTCCGCAAGTTCTGAGGATTCGAGGATTCAGGATTC" pattern = "AGGATTCAG" count_kmer(kmer_to_match, pattern) #OK now I want to find the most frequent Kmer in the dataset def list_of_all_kmer_in_string(input_string, kmer_length): all_kmer = [] for num in range(0, len(input_string) - kmer_length): window = input_string[num: (num+kmer_length)] all_kmer.append(window) kmers_unique = list(set(all_kmer)) #this gives you unique kmers return kmers_unique test_new = list_of_all_kmer_in_string(kmer_to_match, 5) high_match = 0 for kmer in test_new: num_matches = count_kmer(kmer_to_match, kmer) if num_matches > high_match: freq_kmer = kmer high_match = num_matches # note that this is not efficient O^2 # instead it is better to use a frequency table. # so each KMER gets its own dictionary entry text = "GGAGGATTCTCCTGAAAAGGATTCAAGCGAGGATTCAAGATATCGCCGTACAGTAGGATTCTAACAGGATTCAGGATTCCTAGACCAAAAGGATTCGACTAGGATTCAGGATTCAGCAAGGATTCAGGATTCAGGATTCTTAGGATTCTGCAGGATTCAGGATTCGAGGATTCTGAGGATTCGCAAGCTCTAGGATTCAGGATTCTTAGGATTCAGGATTCAGAGGATTCAGGATTCAGGATTCGTATGAAAGGATTCCGGAGGATTCCGGGTAGGATTCAGGATTCAAGGATTCAAGGATTCAGGATTCAGGATTCCGAGGATTCAGGATTCGGAGGATTCTTAGGATTCCCAGGATTCACGGGCAGACCTAGGATTCAGGATTCGAAAGGATTCTTGAGGATTCAGGATTCAAAGGATTCCGAGGATTCTAGGATTCGAAGTACCGAGGATTCCCCAGGATTCATGTAGGATTCAGGATTCTAGGATTCGTACGAGGATTCAGGATTCCGTTCTAGGATTCCTTAGGATTCCAGGATTCAGGATTCGGAGGATTCAGAAGGATTCCAGGATTCCTCACAAAATAGGATTCGAGGATTCTAGAGGATTCGCAGGATTCTAAGGATTCATTGTCCAGGATTCTTAAGGATTCAGGATTCAGGATTCAGCCTAGGATTCAGGATTCGGAGGATTCATTCAGGATTCGATCGTGACAGAGGATTCACCAGGATTCTCAGGATTCTAGGATTCAGGATTCGAGGATTCTAGGATTCAAGGATTCAGGATTCGTTATTCACTGGGCAGGATTCAAGGATTCATAGGATTCAGACGCAGGATTCAGGATTCAGGATTCCAGGATTCTGTGAGGATTCATCGAAGGATTCATCCAATAGGATTCCTTTGAGGATTCTAGGATTCGGGCGACTTTAGCAGGATTCGGCCGAAGGATTCAGGATTCATGTTGGTCGCAGGATTCCGCATTTAGTATAGGATTCAGGATTCAGGATTCCGCAAGTTCTGAGGATTCGAGGATTCAGGATTC" def frequency_table(text, kmer_len): freq_map = {} nt = len(text) nk = kmer_len for i in range(0, nt-nk): pattern = text[i : i+nk] if not freq_map.get(pattern): freq_map[pattern] = 1 else: freq_map[pattern] = freq_map[pattern] + 1 return freq_map freq_map = frequency_table(text, 5) max(freq_map, key=freq_map.get) # this is the easy way to get the highest freq one test_pattern = "TATGCTAGGTCCAAGTCCAATATATGCTAGCTCTACGTCCAATATATGCTAGTCCAATAGTCTTCTTCCAATAGTCCAAGGTCTTCTCTCTACGGTCTTCTTATGCTAGCTCTACGCTCTACGTATGCTAGTCCAATACTCTACGTATGCTAGGTCCAAGGTCTTCTTATGCTAGGTCTTCTCTCTACGCTCTACGTATGCTAGTATGCTAGCTCTACGGTCCAAGCTCTACGTCCAATACTCTACGTATGCTAGGTCCAAGGTCTTCTGTCTTCTTCCAATATCCAATAGTCCAAGTATGCTAGGTCCAAGGTCTTCTGTCTTCTGTCCAAGGTCCAAGGTCCAAGCTCTACGGTCTTCTTATGCTAGCTCTACGTATGCTAGGTCCAAGTCCAATATCCAATATATGCTAGTCCAATATCCAATAGTCTTCTGTCTTCTCTCTACGCTCTACGGTCCAAGGTCCAAGTCCAATATATGCTAGGTCCAAGGTCTTCTTATGCTAGGTCTTCTTCCAATAGTCTTCTGTCCAAGTCCAATAGTCCAAGGTCTTCTGTCTTCTTATGCTAGTATGCTAGGTCTTCTTCCAATATCCAATATCCAATATCCAATAGTCCAAGCTCTACGTCCAATATATGCTAGTATGCTAGCTCTACGGTCCAAGTATGCTAGCTCTACGTCCAATAGTCTTCTTCCAATATATGCTAGCTCTACGGTCCAAGCTCTACGTCCAATAGTCTTCTTATGCTAGCTCTACGGTCCAAGGTCCAAGTATGCTAGGTCTTCTGTCCAAGTCCAATACTCTACGTATGCTAGGTCTTCTTATGCTAGGTCTTCTGTCTTCTCTCTACGGTCTTCTCTCTACGGTCTTCTCTCTACG" test_pattern_1 = "CTTCCCAAAGACTTCTCTGATGTAGCAAAGACTTCTCTCGCTTTGCCGGTCTCGAGGATGTAGCAAAGACTTCTCTAGACTTCTCTAGACTTCTCTCTTCCCAACTTCCCAAGTCTCGAGGATGTAGCAAGATGTAGCAACGCTTTGCCGCTTCCCAAGTCTCGAGAGACTTCTCTGTCTCGAGCTTCCCAACGCTTTGCCGGTCTCGAGGTCTCGAGCTTCCCAAGTCTCGAGCTTCCCAACGCTTTGCCGCTTCCCAAGTCTCGAGCTTCCCAACTTCCCAAGTCTCGAGGTCTCGAGCTTCCCAAAGACTTCTCTGTCTCGAGCTTCCCAAAGACTTCTCTCTTCCCAACGCTTTGCCGCTTCCCAACGCTTTGCCGGATGTAGCAAAGACTTCTCTCGCTTTGCCGCGCTTTGCCGGATGTAGCAAAGACTTCTCTAGACTTCTCTCTTCCCAACGCTTTGCCGAGACTTCTCTCTTCCCAAGATGTAGCAACGCTTTGCCGGTCTCGAGCGCTTTGCCGGATGTAGCAAGTCTCGAGCTTCCCAAGATGTAGCAAGTCTCGAGCGCTTTGCCGGATGTAGCAAAGACTTCTCTCTTCCCAAGTCTCGAGCTTCCCAAAGACTTCTCTAGACTTCTCTGTCTCGAGGATGTAGCAAGTCTCGAGCTTCCCAAAGACTTCTCTAGACTTCTCTAGACTTCTCTCTTCCCAACTTCCCAAGTCTCGAGGTCTCGAGGTCTCGAGGTCTCGAGGTCTCGAGGATGTAGCAACTTCCCAACTTCCCAAAGACTTCTCTAGACTTCTCTGATGTAGCAACTTCCCAACGCTTTGCCGGTCTCGAGAGACTTCTCTGATGTAGCAACTTCCCAAGATGTAGCAAGTCTCGAGGTCTCGAGCGCTTTGCCGGATGTAGCAAAGACTTCTCTAGACTTCTCTGATGTAGCAAGTCTCGAGGATGTAGCAAAGACTTCTCT" test_length = 11 freq_map = frequency_table(test_pattern_1, test_length) max_value = max(freq_map.values()) [k for k,v in freq_map.items() if v == max_value]
""" Problem Description: Cody was once understanding numbers, their squares and perfect squares from his teacher. A perfect square is a number that can be expressed as square of an integer. To check how much Cody understood the concept his teacher kept a test. He has to find the nearest perfect square of the given number N. Input: The first line of input consists of a single integer T denoting the number of test cases. The first line of each test case consists of single integer N. Output: For each test case print the nearest perfect square. Constraints: 1<=T<=100. 1<=N<=10^4. Sample Input: 2 1602 2 Sample Output: 40 1 """ t = int(input()) for i in range(t): n = int(input()) l = [] boo = True i = 1 while boo: i += 1 if i ** 2 <= n: l.append(i) else: l.append(i) boo = False if n == 2 or n == 1: print(1) elif l[-2] == n: print(n) else: if len(l) >= 3: print(l[-1]) if l[-1] ** 2 - n <= n - l[-2] ** 2 else print(l[-2])
#!/usr/bin/python # -*- coding:utf-8 -*- #Filename: range.py for i in [0, 1, 2, 3, 4, 5]: print (i ** 2) # >>> 0 # 1 # 4 # 9 # 16 # 25 for i in range(6): print (i ** 2)
if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) f = arr[0] p = -100000 for i in arr: if i>f: p=f f=i; elif i<f and i>p: p=i print(p)
# -*- coding:utf-8 -*- # ็”Ÿๆˆๅ™จ,nextๆ–นๆณ•่Žทๅ–ๅ…ƒ็ด ๅ€ผ g = (x*x for x in range(10)) for n in g : print(n) # ๆ–ๆณขๆ‹‰ๅฅ‘ๆ•ฐๅˆ—็”จๅˆ—่กจ็”Ÿๆˆๅผๅ†™ไธๅ‡บๆฅ,ไฝ†ๆ˜ฏ,็”จๅ‡ฝๆ•ฐๆŠŠๅฎƒๆ‰“ๅฐๅ‡บๆฅๅดๅพˆๅฎนๆ˜“ def fib(max) : n, a, b = 0, 0, 1 while n < max : print(b) a, b = b, a + b n = n + 1 return 'done' print(fib(6)) #fibๅ‡ฝๆ•ฐๅฎž้™…ไธŠๆ˜ฏๅฎšไน‰ไบ†ๆ–ๆณขๆ‹‰ๅฅ‘ๆ•ฐๅˆ—็š„ๆŽจ็ฎ—่ง„ๅˆ™,ๅฏไปฅไปŽ็ฌฌไธ€ไธชๅ…ƒ็ด ๅผ€ๅง‹,ๆŽจ็ฎ—ๅ‡บๅŽ็ปญไปปๆ„็š„ๅ…ƒ็ด ,่ฟ™็ง้€ป่พ‘ๅ…ถๅฎž้žๅธธ็ฑปไผผgenerator # ไนŸๅฐฑๆ˜ฏ่ฏด,ไธŠ้ข็š„ๅ‡ฝๆ•ฐๅ’Œgeneratorไป…ไธ€ๆญฅไน‹้ฅใ€‚่ฆๆŠŠfibๅ‡ฝๆ•ฐๅ˜ๆˆgenerator,ๅช้œ€่ฆๆŠŠprint(b)ๆ”นไธบyield b ๅฐฑๅฏไปฅไบ†: def fib1(max) : n, a, b = 0, 0, 1 while n < max : yield b a, b = b, a + b n = n + 1 return 'done' #!/usr/bin/env python3 # -*- coding: utf-8 -*- s = (x * x for x in range(5)) print(s) for x in s: print(x) def fib2(max): n, a, b = 0, 0, 1 while n < max: yield b a, b = b, a + b n = n + 1 return 'done' f = fib(10) print('fib(10):', f) for x in f: print(x) # call generator manually: g = fib(5) while 1: try: x = next(g) print('g:', x) except StopIteration as e: print('Generator return value:', e.value) break # ๆจ่พ‰ไธ‰่ง’ def triangles() : line = [1] while True : yield line line = [x + y for x, y in zip([0] + line, line + [0])] n = 0 for t in triangles() : print(t) n = n + 1 if n == 10 : break def triangle1() : L = [1] # ๅฎšไน‰Lไธบไธ€ไธชๅชๅŒ…ๅซไธ€ไธชๅ…ƒ็ด ็š„ๅˆ—่กจ while True : yield L # ๅฎšไน‰ไธบ็”Ÿๆˆๅ™จๅ‡ฝๆ•ฐ L = [1] + [L[n] + L[n-1] for n in range(1, len(L))] + [1] i = 0 for t in triangle1() : print(t) i = i + 1 if i == 10 : break
load( "//scala:scala_cross_version.bzl", _default_maven_server_urls = "default_maven_server_urls", ) load("//third_party/repositories:repositories.bzl", "repositories") def junit_repositories( maven_servers = _default_maven_server_urls(), fetch_sources = True): repositories( for_artifact_ids = [ "io_bazel_rules_scala_junit_junit", "io_bazel_rules_scala_org_hamcrest_hamcrest_core", ], fetch_sources = fetch_sources, maven_servers = maven_servers, ) native.bind( name = "io_bazel_rules_scala/dependency/junit/junit", actual = "@io_bazel_rules_scala_junit_junit//jar", ) native.bind( name = "io_bazel_rules_scala/dependency/hamcrest/hamcrest_core", actual = "@io_bazel_rules_scala_org_hamcrest_hamcrest_core//jar", )
"""Provide a decorator to register event handlers.""" def socketio_handler(event, namespace=None): """Register a socketio handler via decorator.""" def wrapper(func): """Decorate a ws event handler.""" # pylint: disable=protected-access func._ws_event = event func._ws_namespace = namespace return func return wrapper def partial_coro(func, *args, **keywords): """Return a partial coroutine.""" # https://docs.python.org/3/library/functools.html#functools.partial async def wrapper(*fargs, **fkeywords): """Wrap the coroutine function.""" newkeywords = keywords.copy() newkeywords.update(fkeywords) return await func(*args, *fargs, **newkeywords) wrapper.func = func wrapper.args = args wrapper.keywords = keywords return wrapper
class DynamicalSystem: def __init__(self, a1, b1, c1, alpha1, beta1, a2, b2, c2, alpha2, beta2): self.a1 = a1 self.b1 = b1 self.c1 = c1 self.alpha1 = alpha1 self.beta1 = beta1 self.a2 = a2 self.b2 = b2 self.c2 = c2 self.alpha2 = alpha2 self.beta2 = beta2 def eval(self, point, t): [x, y] = point x2 = x*x xy = x*y y2 = y*y dxdt = self.a1*x2 + self.b1*xy + self.c1*y2 + self.alpha1*x + self.beta1*y dydt = self.a2*x2 + self.b2*xy + self.c2*y2 + self.alpha2*x + self.beta2*y return [dxdt, dydt]
class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] def add_group(self, group): self.groups.append(group) def add_user(self, user): self.users.append(user) def get_groups(self): return self.groups def get_users(self): return self.users def get_name(self): return self.name def __repr__(self): return f"Group(name: {self.name},\n\tusers: {self.users},\n\tgroups:{self.groups})" """Checks if the user is in the group. If found, returns Ture, else, calls subgroups recursively.""" def is_user_in_group(user, group): if user in group.get_users(): return True for subgroup in group.get_groups(): #print("checking group-- ", subgroup.get_name()) return is_user_in_group(user, subgroup) return False """ verify the data """ def run_test_data(): parent = Group("parent") child = Group("child") sub_child = Group("subchild") sub_child_user = "sub_child_user" sub_child.add_user(sub_child_user) child.add_group(sub_child) parent.add_group(child) print("\nCheck if user in group - {}".format(is_user_in_group(sub_child_user, parent))) print("\nCheck if user in group - {}".format(is_user_in_group('youngqueenz',parent))) #Returns false cos sub_child_use doesn't exist print("\nCheck if user in group - {}".format(is_user_in_group('',parent))) #Returns false cos input is null print("\nParent Group:") print(parent) run_test_data()
#WAP to read two numbers from the keyboard and display the larger one on the screen. num1 = input("enter the number one") num2 = input("enter the number two") if(num1>num2): largest = num1 print("number is ", largest) else: largest = num2 print("number is ",largest)
__all__ = [ "bgl_preprocessor", "open_source_logs", ]
def minesweeper(matrix): row = len(matrix) col = len(matrix[0]) def neighbouring_squares(i, j): return sum( matrix[x][y] for x in range(i - 1, i + 2) if 0 <= x < row for y in range(j - 1, j + 2) if 0 <= y < col if i != x or j != y ) return [[neighbouring_squares(i, j) for j in range(col)] for i in range(row)]
ASSEMBLY_HUMAN = "Homo_sapiens.GRCh38.104" ASSEMBLY_MOUSE = "Mus_musculus.GRCm39.104" CELLTYPES = ["adventitial cell", "endothelial cell", "acinar cell", "pancreatic PP cell", "type B pancreatic cell"] CL_VERSION = "v2021-08-10"
'''https://leetcode.com/problems/design-add-and-search-words-data-structure/ 211. Design Add and Search Words Data Structure Medium 3595 150 Add to List Share Design a data structure that supports adding new words and finding if a string matches any previously added string. Implement the WordDictionary class: WordDictionary() Initializes the object. void addWord(word) Adds word to the data structure, it can be matched later. bool search(word) Returns true if there is any string in the data structure that matches word or false otherwise. word may contain dots '.' where dots can be matched with any letter. Example: Input ["WordDictionary","addWord","addWord","addWord","search","search","search","search"] [[],["bad"],["dad"],["mad"],["pad"],["bad"],[".ad"],["b.."]] Output [null,null,null,null,false,true,true,true] Explanation WordDictionary wordDictionary = new WordDictionary(); wordDictionary.addWord("bad"); wordDictionary.addWord("dad"); wordDictionary.addWord("mad"); wordDictionary.search("pad"); // return False wordDictionary.search("bad"); // return True wordDictionary.search(".ad"); // return True wordDictionary.search("b.."); // return True Constraints: 1 <= word.length <= 500 word in addWord consists lower-case English letters. word in search consist of '.' or lower-case English letters. At most 50000 calls will be made to addWord and search.''' class TrieNode(): def __init__(self): self.children = collections.defaultdict(TrieNode) self.isWord = False class WordDictionary: def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def addWord(self, word: str) -> None: """ Adds a word into the data structure. """ node = self.root for w in word: node = node.children[w] node.isWord = True def search(self, word: str) -> bool: """ Returns if the word is in the data structure. A word could contain the dot character '.' to represent any one letter. """ node = self.root self.res = False self.dfs(node, word) return self.res def dfs(self, node, word): if not word: if node.isWord: self.res = True return if word[0] == ".": for n in node.children.values(): self.dfs(n, word[1:]) else: node = node.children.get(word[0]) if not node: return self.dfs(node, word[1:]) # Your WordDictionary object will be instantiated and called as such: # obj = WordDictionary() # obj.addWord(word) # param_2 = obj.search(word)
"""Module that defines varios enums.""" class Enum: __names = {} @classmethod def name(cls, state): if not cls.__names: cls.__names = { value: key for key, value in cls.__dict__.items() if isinstance(value, int) } return cls.__names[state] class VivintDeviceAttributes(Enum): """Devine generic vivint device attributes for humans.""" DeviceType = 't' Id = '_id' Name = 'n' class AlarmPanelAttributes(VivintDeviceAttributes): """Define alarm panel's attributes for humans.""" Devices = 'd' PanelId = 'panid' PartitionId = 'parid' State = 's' class ArmedStates(Enum): """Define all possible alarm states.""" Disarmed = 0 ArmingAwayInExitDelay = 1 ArmingStayInExitDelay = 2 ArmedStay = 3 ArmedAway = 4 ArmedStayInEntryDelay = 5 ArmedAwayInEntryDelay = 6 Alarm = 7 AlarmFire = 8 Disabled = 11 WalkTest = 12 class CameraAttributes(VivintDeviceAttributes): """Define camera's attributes for humans.""" CameraIPAddress = 'caip' CameraPrivacy = 'cpri' CameraThumbnailDate = 'ctd' CaptureClipOnMotion = 'ccom' Online = 'ol' WirelessSignalStrenght = 'wiss' class DoorLockAttributes(VivintDeviceAttributes): """Define door lock's attributes for humans.""" BatteryLevel = 'bl' Id = '_id' LowBattery = 'lb' OperationCount = 'opc' OperationFaultCode = 'opfc' NodeOnline = 'nonl' State = 's' class DeviceTypes(Enum): """Vivint's supported device types.""" Camera = 'camera_device' DoorLock = 'door_lock_device' LightModule = 'multilevel_switch_device' Thermostat = 'thermostat_device' TouchPanel = 'primary_touch_link_device' WirelessSensor = 'wireless_sensor' class WirelessSensorAttributes(VivintDeviceAttributes): """Wireless Sensor's attributes for humans.""" BatteryLevel = 'bl' EquipmentCode = 'ec' IdBypassed = 'b' LowBattery = 'lb' SerialNumber = 'ser32' State = 's' class AuthUserAttributes(Enum): """AuthUser attributes.""" IdToken = 'id_token' IsReadOnly = 'is_read_only' KeepSignedIn = 'keep_signed_in' RelayServer = 'rs' Users = 'u' class UsersAttributes(Enum): DocumentSequence = 'DocumentSequence' Email = 'e' Ghome = 'ghome' GroupIds = 'grpid' Id = '_id' MessageBroadcastChannel = 'mbc' Name = 'n' PingId = 'pngid' RestrictedSystem = 'rsystem' SmarthomeSystem = 'smarthomesystem' Settings = 'stg' System = 'system' Timestamp = 'ts' class PubNumMessageAttributes(Enum): Data = 'da' Devices = 'd' Operation = 'op' PanelId = 'panid' PartitionId = 'parid' Type = 't'
test = { 'name': 'Question 1', 'points': 1, 'suites': [ { 'cases': [ { 'code': r""" >>> read_line('3') 3 >>> read_line('-123') -123 >>> read_line('1.25') 1.25 >>> read_line('true') True >>> read_line('(a)') Pair('a', nil) >>> read_line(')') SyntaxError """, 'hidden': False, 'locked': False }, { 'code': r""" >>> read_line(" (quote x) ") Pair('quote', Pair('x', nil)) >>> read_line(" 'x ") Pair('quote', Pair('x', nil)) >>> read_line(" (a b) ") Pair('a', Pair('b', nil)) >>> read_line(" '(a b) ") Pair('quote', Pair(Pair('a', Pair('b', nil)), nil)) >>> read_line(" '((a)) ") Pair('quote', Pair(Pair(Pair('a', nil), nil), nil)) """, 'hidden': False, 'locked': False }, { 'code': r""" >>> read_line("(a (b 'c))") Pair('a', Pair(Pair('b', Pair(Pair('quote', Pair('c', nil)), nil)), nil)) >>> read_line("(a (b '(c d)))") Pair('a', Pair(Pair('b', Pair(Pair('quote', Pair(Pair('c', Pair('d', nil)), nil)), nil)), nil)) >>> read_line("')") SyntaxError """, 'hidden': False, 'locked': False } ], 'scored': True, 'setup': r""" >>> from scheme_reader import * """, 'teardown': '', 'type': 'doctest' } ] }
CONFIG_DIR = '__config__' DATA_ROOT_DIR = '__data__' RESULTS_ROOT_DIR = '__results__' TB_DIR = '__runs__' WEIGHTS_DIR = '__weights__' NOISE_ROOT_DIR = "__noise__"
fruits_name_1 = "ใ‚Šใ‚“ใ”" fruits_num_1 = 2 fruits_name_2 = "ใฟใ‹ใ‚“" fruits_num_2 = 10 # [["ใ‚Šใ‚“ใ”", 2], ["ใฟใ‹ใ‚“", 10]]ใจใ„ใ†ๅ‡บๅŠ›ใซใชใ‚‹ใ‚ˆใ†ใซใ€fruitsใซๅค‰ๆ•ฐใ‚’ใƒชใ‚นใƒˆๅž‹ใซไปฃๅ…ฅใ—ใฆใใ ใ•ใ„ fruits = [[fruits_name_1, fruits_num_1], [fruits_name_2, fruits_num_2]] # ๅ‡บๅŠ› print(fruits)
# Map source standard name to command code # Note that the source names may be aliased in the device # The names that come back from the device in a feedback # message are the aliases ROTEL_RSP1570_SOURCES = { " CD": "SOURCE_CD", "TUNER": "SOURCE_TUNER", "TAPE": "SOURCE_TAPE", "VIDEO 1": "SOURCE_VIDEO_1", "VIDEO 2": "SOURCE_VIDEO_2", "VIDEO 3": "SOURCE_VIDEO_3", "VIDEO 4": "SOURCE_VIDEO_4", "VIDEO 5": "SOURCE_VIDEO_5", "MULTI": "SOURCE_MULTI_INPUT", }
class Test(object): """ @cvar some: some variable @type some: C{str} """ some = 'hello' def __init__(self): self.some1 = 10 def q(self, another): """ @param another: another variable @type another: C{str} """ pass
# ะ˜ั‰ะตะผ ะฒ ัะธัั‚ะตะผัƒ ะธัะฟะพะปัŒะทัƒั ะ›ะžะ“ะ˜ะงะ•ะกะšะžะ• ะ˜ login = 'username' password = '123456' login1 = input("ะ’ะฒะตะดะธั‚ะต ะธะผั ะฟะพะปัŒะทะพะฒะฐั‚ะตะปั: ") password1 = input("ะ’ะฒะตะดะธั‚ะต ะฟะฐั€ะพะปัŒ: ") if login1 == login and password1 == password: print('ะ’ั‹ ะฒะพัˆะปะธ ะฒ ัะธัั‚ะตะผัƒ!') else: print('ะะต ัƒะดะฐะตัŒัั ะฒะพะนั‚ะธ. ะŸะพะถะฐะปัƒะนัั‚ะฐ, ะฟั€ะพะฒะตั€ัŒั‚ะต ะฟั€ะฐะฒะธะปัŒะฝะพัั‚ัŒ ะฝะฐะฟะธัะฐะฝะธั ะปะพะณะธะฝะฐ ะธ ะฟะฐั€ะพะปั')
""" Implementation of Bubble Sort """ def bubble_sort(arr): for i in range(len(arr)): for j in range(len(arr) - i - 1): if j < arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j] print(arr) return arr test_arr_1 = [14, 78, 2587, 3, 687, 21] test_arr_2 = [85, 14, 36, 6 , 18, 55] bubble_sort(test_arr_1)
#!/usr/bin/env python3 # Print out all the codons for the sequence below in reading frame 1 # Use a 'for' loop dna = 'ATAGCGAATATCTCTCATGAGAGGGAA' ''' #for 1 frame for i in range(0, len(dna), 3): #range(start letter, lenth of seq, print 3 @ a time) codon = (dna[i:i+3]) print(codon) #f1 for i in range(1, len(dna)-2, 3): codon = (dna[i:i+3]) print(codon) ''' #for all frames step = 3 for f in range(46): #for number of ranges print('frame', f) for i in range(f, len(dna) -step +1, step): #generic: len(dna) -k +2 codon = dna[i:i+step] #define codon in case of loop print(codon) #for kmers. you can change k to any number to fit any window size k = 4 for i in range(0, len(dna) -k+1): kmer = dna [i:i+4] print(kmer) """ frame 0 ATA GCG AAT ATC TCT CAT GAG AGG GAA frame 1 TAG CGA ATA TCT CTC ATG AGA GGG """
""" Leetcode 12 - Interger to Roman https://leetcode.com/problems/integer-to-roman/ 1. Time: O(1) Memory: O(1) """ class Solution1: """ 1. MINE | Straight-Forward """ def int_to_roman(self, num): if num is None or num == 0: return '' int_roman_pairs = [(1000, 'M'), (900, 'CM'), (500, 'D'), (400, 'CD'), (100, 'C'), (90, 'XC'), (50, 'L'), (40, 'XL'), (10, 'X'), (9, 'IX'), (5, 'V'), (4, 'IV'), (1, 'I')] res = '' for value, roman in int_roman_pairs: if num >= value: res += num // value * roman num -= num // value * value elif num == 0: return res return res if __name__ == '__main__': num = 300 res = Solution1().int_to_roman(num) print(res)
# Copyright 2016 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. DEPS = [ 'chromium', 'depot_tools/bot_update', 'depot_tools/gclient', 'file', 'gsutil', 'recipe_engine/path', 'recipe_engine/properties', 'recipe_engine/python', 'recipe_engine/raw_io', 'recipe_engine/step', ] def linux_builder_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # get buildnumber step; no longer needed # Package DrMemory step api.step("Package Dr. Memory", ["ctest", "-VV", "-S", str(api.path["checkout"].join("package.cmake")) + ",build=0x" + build_properties["got_revision"][:7] + ";drmem_only"]) # find package file step; no longer necessary # upload drmemory build step api.gsutil.upload("DrMemory-Linux-*" + build_properties["got_revision"][ :7] + ".tar.gz", "chromium-drmemory-builds", "builds/") def linux_lucid_x64_drm_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # Dr. Memory ctest step api.step( "Dr. Memory ctest", ["ctest", "--timeout", "60", "-VV", "-S", str(api.path["checkout"].join("tests", "runsuite.cmake")) + ",drmemory_only;long;build=0x" + build_properties["got_revision"][:7] ]) # Prepare to pack test results step; null converted # Pack test results step api.step("Pack test results", ['7z', 'a', '-xr!*.pdb', "testlogs_r" + build_properties["got_revision"] + "_b" + str(build_properties["buildnumber"]) + ".7z", 'build_drmemory-dbg-32/logs', 'build_drmemory-dbg-32/Testing/Temporary', 'build_drmemory-rel-32/logs', 'build_drmemory-rel-32/Testing/Temporary', 'build_drmemory-dbg-64/logs', 'build_drmemory-dbg-64/Testing/Temporary', 'build_drmemory-rel-64/logs', 'build_drmemory-rel-64/Testing/Temporary', 'xml:results']) # upload drmemory test logs step api.gsutil.upload("testlogs_r" + build_properties["got_revision"] + "_b" + str(api.properties[ "buildnumber"]) + ".7z", "chromium-drmemory-builds", "testlogs/from_%s" % api.properties["buildername"]) def win_vista_x64_drm_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # clear tools directory step; null converted # update tools step; null converted # unpack tools step; generic ShellCommand converted api.step("unpack tools", [api.path["slave_build"].join('tools', 'buildbot', 'bot_tools', 'unpack.bat')], env={}, cwd=api.path[ "slave_build"].join('tools', 'buildbot', 'bot_tools')) # windows Dr. Memory ctest step api.step("Dr. Memory ctest", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'ctest', '--timeout', '60', '-VV', '-S', str(api.path["checkout"].join("tests", "runsuite.cmake")) + ",drmemory_only;long;build=" + str(build_properties["buildnumber"])]) # Checkout TSan tests step api.step("Checkout TSan tests", ['svn', 'checkout', '--force', 'http://data-race-test.googlecode.com/svn/trunk/', api.path["slave_build"].join("tsan")]) # Build TSan tests step api.step("Build TSan Tests", ['E:\\b\\build\\scripts\\slave\\drmemory\\build_env.bat', 'make', '-C', api.path["slave_build"].join("tsan", "unittest")], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools"), "CYGWIN": "nodosfilewarning"}) # Dr. Memory TSan test step api.step( "dbg full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg full nosyms TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Prepare to pack test results step; null converted # Pack test results step api.step("Pack test results", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"),'7z', 'a', '-xr!*.pdb', "testlogs_r" + build_properties["got_revision"] + "_b" + str(build_properties["buildnumber"]) + ".7z", 'build_drmemory-dbg-32/logs', 'build_drmemory-dbg-32/Testing/Temporary', 'build_drmemory-rel-32/logs', 'build_drmemory-rel-32/Testing/Temporary', 'build_drmemory-dbg-64/logs', 'build_drmemory-dbg-64/Testing/Temporary', 'build_drmemory-rel-64/logs', 'build_drmemory-rel-64/Testing/Temporary', 'xmlresults'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # upload drmemory test logs step api.gsutil.upload("testlogs_r" + build_properties["got_revision"] + "_b" + str(api.properties[ "buildnumber"]) + ".7z", "chromium-drmemory-builds", "testlogs/from_%s" % api.properties["buildername"]) def mac_mavericks_x64_DR_steps(api): build_properties = api.properties.legacy() # checkout DynamiRIO step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "dynamorio" soln.url = "https://github.com/DynamoRIO/dynamorio.git" api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # pre-commit suite step api.step("pre-commit suite", ['ctest', '--timeout', '120', '-VV', '-S', api.path[ "checkout"].join("suite", "runsuite.cmake")], cwd=api.path["slave_build"], ok_ret="all") def linux_cr_builder_steps(api): build_properties = api.properties.legacy() # update scripts step; implicitly run by recipe engine. # bot_update step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "src" soln.url = "https://chromium.googlesource.com/chromium/src.git" soln.custom_deps = {'src/third_party/WebKit/LayoutTests': None} soln.custom_vars = {'webkit_trunk': 'http://src.chromium.org/blink/trunk', 'googlecode_url': 'http://%s.googlecode.com/svn', 'nacl_trunk': 'http://src.chromium.org/native_client/trunk', 'sourceforge_url': 'https://svn.code.sf.net/p/%(repo)s/code', 'llvm_url': 'http://llvm.org/svn/llvm-project'} src_cfg.got_revision_mapping.update( {'src': 'got_revision', 'src/third_party/WebKit': 'got_webkit_revision', 'src/tools/swarming_client': 'got_swarming_client_revision', 'src/v8': 'got_v8_revision'}) api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # gclient revert step; made unnecessary by bot_update # gclient update step; made unnecessary by bot_update # gclient runhooks wrapper step env = {'CHROMIUM_GYP_SYNTAX_CHECK': '1', 'GYP_GENERATORS': 'ninja', 'DEPOT_TOOLS_UPDATE': '0', 'GYP_DEFINES': 'build_for_tool=drmemory component=shared_library', 'LANDMINES_VERBOSE': '1'} api.python("gclient runhooks wrapper", api.path["build"].join("scripts", "slave", "runhooks_wrapper.py"), env=env) # cleanup_temp step api.chromium.cleanup_temp() # compile.py step args = ['--target', 'Release', '--build-tool=ninja', '--compiler=goma', 'content_shell', 'base_unittests', 'browser_tests', 'crypto_unittests', 'ipc_tests', 'media_unittests', 'net_unittests', 'printing_unittests', 'remoting_unittests', 'sql_unittests', 'unit_tests', 'url_unittests'] if 'clobber' in api.properties: args.append("--clobber") api.python("compile", api.path["build"].join("scripts", "slave", "compile.py"), args=args) def mac_builder_DR_steps(api): build_properties = api.properties.legacy() # checkout DynamiRIO step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "dynamorio" soln.url = "https://github.com/DynamoRIO/dynamorio.git" api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # get buildnumber step; no longer needed # Package DynamoRIO step api.step("Package DynamoRIO", ["ctest", "-VV", "-S", str(api.path["checkout"].join("make", "package.cmake")) + ",build=0x" + build_properties["revision"][:7]]) # find package file step; no longer necessary # upload dynamorio package api.gsutil.upload("DynamoRIO-MacOS-*" + build_properties["got_revision"][ :7] + ".tar.gz", "chromium-dynamorio", "builds/") def win_xp_drm_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # clear tools directory step; null converted # update tools step; null converted # unpack tools step; generic ShellCommand converted api.step("unpack tools", [api.path["slave_build"].join('tools', 'buildbot', 'bot_tools', 'unpack.bat')], env={}, cwd=api.path[ "slave_build"].join('tools', 'buildbot', 'bot_tools')) # windows Dr. Memory ctest step api.step("Dr. Memory ctest", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'ctest', '--timeout', '60', '-VV', '-S', str(api.path["checkout"].join("tests", "runsuite.cmake")) + ",drmemory_only;long;build=" + str(build_properties["buildnumber"])]) # Checkout TSan tests step api.step("Checkout TSan tests", ['svn', 'checkout', '--force', 'http://data-race-test.googlecode.com/svn/trunk/', api.path["slave_build"].join("tsan")]) # Build TSan tests step api.step("Build TSan Tests", ['E:\\b\\build\\scripts\\slave\\drmemory\\build_env.bat', 'make', '-C', api.path["slave_build"].join("tsan", "unittest")], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools"), "CYGWIN": "nodosfilewarning"}) # Dr. Memory TSan test step api.step( "dbg full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg full nosyms TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Prepare to pack test results step; null converted # Pack test results step api.step("Pack test results", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), '7z', 'a', '-xr!*.pdb', "testlogs_r" + build_properties["got_revision"] + "_b" + str(build_properties["buildnumber"]) + ".7z", 'build_drmemory-dbg-32/logs', 'build_drmemory-dbg-32/Testing/Temporary', 'build_drmemory-rel-32/logs', 'build_drmemory-rel-32/Testing/Temporary', 'build_drmemory-dbg-64/logs', 'build_drmemory-dbg-64/Testing/Temporary', 'build_drmemory-rel-64/logs', 'build_drmemory-rel-64/Testing/Temporary', 'xmlresults'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # upload drmemory test logs step api.gsutil.upload("testlogs_r" + build_properties["got_revision"] + "_b" + str(api.properties[ "buildnumber"]) + ".7z", "chromium-drmemory-builds", "testlogs/from_%s" % api.properties["buildername"]) def mac_mavericks_x64_drm_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # Dr. Memory ctest step api.step( "Dr. Memory ctest", ["ctest", "--timeout", "60", "-VV", "-S", str(api.path["checkout"].join("tests", "runsuite.cmake")) + ",drmemory_only;long;build=0x" + build_properties["got_revision"][:7] ]) # Prepare to pack test results step; null converted # Pack test results step api.step("Pack test results", ['7z', 'a', '-xr!*.pdb', "testlogs_r" + build_properties["got_revision"] + "_b" + str(build_properties["buildnumber"]) + ".7z", 'build_drmemory-dbg-32/logs', 'build_drmemory-dbg-32/Testing/Temporary', 'build_drmemory-rel-32/logs', 'build_drmemory-rel-32/Testing/Temporary', 'xml:results']) # upload drmemory test logs step api.gsutil.upload("testlogs_r" + build_properties["got_revision"] + "_b" + str(api.properties[ "buildnumber"]) + ".7z", "chromium-drmemory-builds", "testlogs/from_%s" % api.properties["buildername"]) def linux_cr_steps(api): build_properties = api.properties.legacy() # checkout DynamiRIO step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "dynamorio" soln.url = "https://github.com/DynamoRIO/dynamorio.git" api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # Make the build directory step api.file.makedirs("makedirs", api.path["slave_build"].join("dynamorio")) api.file.makedirs("makedirs", api.path["slave_build"].join("dynamorio", "build")) # Configure release DynamoRIO step; generic ShellCommand converted api.step("Configure release DynamoRIO", [ 'cmake', '..', '-DDEBUG=OFF' ], env={}, cwd=api.path["slave_build"].join('dynamorio', 'build')) # Compile release DynamoRIO step; generic ShellCommand converted api.step("Compile release DynamoRIO", [ 'make', '-j5' ], env={}, cwd=api.path["slave_build"].join('dynamorio', 'build')) # don't follow python step; generic ShellCommand converted api.step("don't follow python", ['bin64/drconfig', '-reg', 'python', '-norun', '-v'], env={}, cwd=api.path["slave_build"].join('dynamorio', 'build')) # drmemory test step api.step("content_shell", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/content_shell', '--run-layout-test', 'file:///home/chrome-bot/bb.html'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("base_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/base_unittests', '--gtest_filter=-TraceEventTestFixture.TraceContinuousSampling'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("browser_tests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/browser_tests', '--gtest_filter=AutofillTest.BasicFormFill'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("crypto_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/crypto_unittests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("ipc_tests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/ipc_tests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("media_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/media_unittests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("net_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/net_unittests', '--gtest_filter=-CertDatabaseNSSTest.ImportCACertHierarchy*'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step( "printing_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/printing_unittests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step( "remoting_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/remoting_unittests', '--gtest_filter=' '-VideoFrameCapturerTest.Capture:DesktopProcessTest.DeathTest' ], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("sql_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/sql_unittests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("unit_tests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/unit_tests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) # drmemory test step api.step("url_unittests", ['xvfb-run', '-a', api.path["checkout"].join("build", "bin64", "drrun"), '-stderr_mask', '12', '--', '../../linux-cr-builder/build/src/out/Release/url_unittests'], env={'CHROME_DEVEL_SANDBOX': '/opt/chromium/chrome_sandbox'}, cwd=api.path["checkout"]) def win8_cr_builder_steps(api): build_properties = api.properties.legacy() # svnkill step; not necessary in recipes # update scripts step; implicitly run by recipe engine. # taskkill step api.python("taskkill", api.path["build"].join("scripts", "slave", "kill_processes.py")) # bot_update step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "src" soln.url = "https://chromium.googlesource.com/chromium/src.git" soln.custom_deps = {'src/third_party/WebKit/LayoutTests': None} soln.custom_vars = {'webkit_trunk': 'http://src.chromium.org/blink/trunk', 'googlecode_url': 'http://%s.googlecode.com/svn', 'nacl_trunk': 'http://src.chromium.org/native_client/trunk', 'sourceforge_url': 'https://svn.code.sf.net/p/%(repo)s/code', 'llvm_url': 'http://llvm.org/svn/llvm-project'} src_cfg.got_revision_mapping.update( {'src': 'got_revision', 'src/third_party/WebKit': 'got_webkit_revision', 'src/tools/swarming_client': 'got_swarming_client_revision', 'src/v8': 'got_v8_revision'}) api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # gclient revert step; made unnecessary by bot_update # gclient update step; made unnecessary by bot_update # gclient runhooks wrapper step env = {'CHROMIUM_GYP_SYNTAX_CHECK': '1', 'LANDMINES_VERBOSE': '1', 'DEPOT_TOOLS_UPDATE': '0', 'GYP_DEFINES': 'build_for_tool=drmemory component=shared_library'} api.python("gclient runhooks wrapper", api.path["build"].join("scripts", "slave", "runhooks_wrapper.py"), env=env) # cleanup_temp step api.chromium.cleanup_temp() # compile.py step args = ['--solution', 'all.sln', '--project', 'chromium_builder_dbg_drmemory_win', '--target', 'Debug'] if 'clobber' in api.properties: args.append("--clobber") api.step("compile", ["python_slave", api.path["build"].join( "scripts", "slave", "compile.py")] + args) def win8_cr_steps(api): build_properties = api.properties.legacy() # Download build step api.gsutil.download("chromium-drmemory-builds", "drmemory-windows-latest-sfx.exe", "drm-sfx.exe", cwd=api.path["slave_build"]) # Unpack the build step; generic ShellCommand converted api.step("Unpack the build", [ 'drm-sfx', '-ounpacked', '-y' ], env={}, cwd=api.path["slave_build"]) # Dr. Memory get revision step step_result = api.step("Get the revision number", [ 'unpacked\\bin\\drmemory', '-version' ], stdout=api.raw_io.output()) build_properties["got_revision"] = step_result.stdout.split()[3].\ split(".")[2] # Chromium 'url' tests step; generic ShellCommand converted api.step( "Chromium 'url' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'url', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'printing' tests step; generic ShellCommand converted api.step( "Chromium 'printing' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'printing', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'media' tests step; generic ShellCommand converted api.step( "Chromium 'media' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'media', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'sql' tests step; generic ShellCommand converted api.step( "Chromium 'sql' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'sql', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'crypto_unittests' tests step; generic ShellCommand converted api.step( "Chromium 'crypto_unittests' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'crypto_unittests', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'remoting' tests step; generic ShellCommand converted api.step( "Chromium 'remoting' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'remoting', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'ipc_tests' tests step; generic ShellCommand converted api.step( "Chromium 'ipc_tests' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'ipc_tests', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'base_unittests' tests step; generic ShellCommand converted api.step( "Chromium 'base_unittests' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'base_unittests', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'net' tests step; generic ShellCommand converted api.step( "Chromium 'net' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'net', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'unit' tests step; generic ShellCommand converted api.step( "Chromium 'unit' tests", ['..\\..\\win8-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'unit', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) def win7_cr_steps(api): build_properties = api.properties.legacy() # Download build step api.gsutil.download("chromium-drmemory-builds", "drmemory-windows-latest-sfx.exe", "drm-sfx.exe", cwd=api.path["slave_build"]) # Unpack the build step; generic ShellCommand converted api.step("Unpack the build", [ 'drm-sfx', '-ounpacked', '-y' ], env={}, cwd=api.path["slave_build"]) # Dr. Memory get revision step step_result = api.step("Get the revision number", [ 'unpacked\\bin\\drmemory', '-version' ], stdout=api.raw_io.output()) build_properties["got_revision"] = step_result.stdout.split()[3].\ split(".")[2] # Chromium 'url' tests step; generic ShellCommand converted api.step( "Chromium 'url' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'url', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'printing' tests step; generic ShellCommand converted api.step( "Chromium 'printing' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'printing', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'media' tests step; generic ShellCommand converted api.step( "Chromium 'media' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'media', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'sql' tests step; generic ShellCommand converted api.step( "Chromium 'sql' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'sql', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'crypto_unittests' tests step; generic ShellCommand converted api.step( "Chromium 'crypto_unittests' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'crypto_unittests', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'remoting' tests step; generic ShellCommand converted api.step( "Chromium 'remoting' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'remoting', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'ipc_tests' tests step; generic ShellCommand converted api.step( "Chromium 'ipc_tests' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'ipc_tests', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'base_unittests' tests step; generic ShellCommand converted api.step( "Chromium 'base_unittests' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'base_unittests', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'net' tests step; generic ShellCommand converted api.step( "Chromium 'net' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'net', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) # Chromium 'unit' tests step; generic ShellCommand converted api.step( "Chromium 'unit' tests", ['..\\..\\win7-cr-builder\\build\\src\\tools\\valgrind\\chrome_tests.bat', '-t', 'unit', '--tool', 'drmemory_light', '--keep_logs'], env={'DRMEMORY_COMMAND': 'unpacked/bin/drmemory.exe'}, cwd=api.path["slave_build"]) def win_8_x64_drm_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # clear tools directory step; null converted # update tools step; null converted # unpack tools step; generic ShellCommand converted api.step("unpack tools", [api.path["slave_build"].join('tools', 'buildbot', 'bot_tools', 'unpack.bat')], env={}, cwd=api.path[ "slave_build"].join('tools', 'buildbot', 'bot_tools')) # windows Dr. Memory ctest step api.step("Dr. Memory ctest", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'ctest', '--timeout', '60', '-VV', '-S', str(api.path["checkout"].join("tests", "runsuite.cmake")) + ",drmemory_only;long;build=" + str(build_properties["buildnumber"])]) # Checkout TSan tests step api.step("Checkout TSan tests", ['svn', 'checkout', '--force', 'http://data-race-test.googlecode.com/svn/trunk/', api.path["slave_build"].join("tsan")]) # Build TSan tests step api.step("Build TSan Tests", ['E:\\b\\build\\scripts\\slave\\drmemory\\build_env.bat', 'make', '-C', api.path["slave_build"].join("tsan", "unittest")], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools"), "CYGWIN": "nodosfilewarning"}) # Dr. Memory TSan test step api.step( "dbg full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg full nosyms TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Prepare to pack test results step; null converted # Pack test results step api.step("Pack test results", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), '7z', 'a', '-xr!*.pdb', "testlogs_r" + build_properties["got_revision"] + "_b" + str(build_properties["buildnumber"]) + ".7z", 'build_drmemory-dbg-32/logs', 'build_drmemory-dbg-32/Testing/Temporary', 'build_drmemory-rel-32/logs', 'build_drmemory-rel-32/Testing/Temporary', 'build_drmemory-dbg-64/logs', 'build_drmemory-dbg-64/Testing/Temporary', 'build_drmemory-rel-64/logs', 'build_drmemory-rel-64/Testing/Temporary', 'xmlresults'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # upload drmemory test logs step api.gsutil.upload("testlogs_r" + build_properties["got_revision"] + "_b" + str(api.properties[ "buildnumber"]) + ".7z", "chromium-drmemory-builds", "testlogs/from_%s" % api.properties["buildername"]) def win7_cr_builder_steps(api): build_properties = api.properties.legacy() # svnkill step; not necessary in recipes # update scripts step; implicitly run by recipe engine. # taskkill step api.python("taskkill", api.path["build"].join("scripts", "slave", "kill_processes.py")) # bot_update step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "src" soln.url = "https://chromium.googlesource.com/chromium/src.git" soln.custom_deps = {'src/third_party/WebKit/LayoutTests': None} soln.custom_vars = {'webkit_trunk': 'http://src.chromium.org/blink/trunk', 'googlecode_url': 'http://%s.googlecode.com/svn', 'nacl_trunk': 'http://src.chromium.org/native_client/trunk', 'sourceforge_url': 'https://svn.code.sf.net/p/%(repo)s/code', 'llvm_url': 'http://llvm.org/svn/llvm-project'} src_cfg.got_revision_mapping.update( {'src': 'got_revision', 'src/third_party/WebKit': 'got_webkit_revision', 'src/tools/swarming_client': 'got_swarming_client_revision', 'src/v8': 'got_v8_revision'}) api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # gclient revert step; made unnecessary by bot_update # gclient update step; made unnecessary by bot_update # gclient runhooks wrapper step env = {'CHROMIUM_GYP_SYNTAX_CHECK': '1', 'LANDMINES_VERBOSE': '1', 'DEPOT_TOOLS_UPDATE': '0', 'GYP_DEFINES': 'build_for_tool=drmemory component=shared_library'} api.python("gclient runhooks wrapper", api.path["build"].join("scripts", "slave", "runhooks_wrapper.py"), env=env) # cleanup_temp step api.chromium.cleanup_temp() # compile.py step args = ['--solution', 'all.sln', '--project', 'chromium_builder_dbg_drmemory_win', '--target', 'Debug'] if 'clobber' in api.properties: args.append("--clobber") api.step("compile", ["python_slave", api.path["build"].join( "scripts", "slave", "compile.py")] + args) def win_7_x64_drm_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # clear tools directory step; null converted # update tools step; null converted # unpack tools step; generic ShellCommand converted api.step("unpack tools", [api.path["slave_build"].join('tools', 'buildbot', 'bot_tools', 'unpack.bat')], env={}, cwd=api.path[ "slave_build"].join('tools', 'buildbot', 'bot_tools')) # windows Dr. Memory ctest step api.step("Dr. Memory ctest", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'ctest', '--timeout', '60', '-VV', '-S', str(api.path["checkout"].join("tests", "runsuite.cmake")) + ",drmemory_only;long;build=" + str(build_properties["buildnumber"])]) # Checkout TSan tests step api.step("Checkout TSan tests", ['svn', 'checkout', '--force', 'http://data-race-test.googlecode.com/svn/trunk/', api.path["slave_build"].join("tsan")]) # Build TSan tests step api.step("Build TSan Tests", ['E:\\b\\build\\scripts\\slave\\drmemory\\build_env.bat', 'make', '-C', api.path["slave_build"].join("tsan", "unittest")], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools"), "CYGWIN": "nodosfilewarning"}) # Dr. Memory TSan test step api.step( "dbg full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel full TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "rel light TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-rel-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "-light", "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Dr. Memory TSan test step api.step( "dbg full nosyms TSan tests", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'build_drmemory-dbg-32\\bin\\drmemory', '-dr_ops', '-msgbox_mask 0 -stderr_mask 15', '-results_to_stderr', '-batch', '-suppress', api.path["checkout"].join( "tests", "app_suite", "default-suppressions.txt"), "--", api.path["slave_build"].join("tsan", 'unittest', 'bin', 'racecheck_unittest-windows-x86-O0.exe'), '--gtest_filter=' '-PositiveTests.FreeVsRead:NegativeTests.WaitForMultiple*', '-147'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # Prepare to pack test results step; null converted # Pack test results step api.step("Pack test results", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), '7z', 'a', '-xr!*.pdb', "testlogs_r" + build_properties["got_revision"] + "_b" + str(build_properties["buildnumber"]) + ".7z", 'build_drmemory-dbg-32/logs', 'build_drmemory-dbg-32/Testing/Temporary', 'build_drmemory-rel-32/logs', 'build_drmemory-rel-32/Testing/Temporary', 'build_drmemory-dbg-64/logs', 'build_drmemory-dbg-64/Testing/Temporary', 'build_drmemory-rel-64/logs', 'build_drmemory-rel-64/Testing/Temporary', 'xmlresults'], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # upload drmemory test logs step api.gsutil.upload("testlogs_r" + build_properties["got_revision"] + "_b" + str(api.properties[ "buildnumber"]) + ".7z", "chromium-drmemory-builds", "testlogs/from_%s" % api.properties["buildername"]) def mac_builder_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # get buildnumber step; no longer needed # Package DrMemory step api.step("Package Dr. Memory", ["ctest", "-VV", "-S", str(api.path["checkout"].join("package.cmake")) + ",build=0x" + build_properties["got_revision"][:7] + ";drmem_only"]) # find package file step; no longer necessary # upload drmemory build step api.gsutil.upload("DrMemory-MacOS-*" + build_properties["got_revision"][ :7] + ".tar.gz", "chromium-drmemory-builds", "builds/") def win_builder_steps(api): build_properties = api.properties.legacy() # checkout DrMemory step src_cfg = api.gclient.make_config(GIT_MODE=True) soln = src_cfg.solutions.add() soln.name = "drmemory" soln.url = "https://github.com/DynamoRIO/drmemory.git" soln.custom_deps = {"drmemory/dynamorio": "https://github.com/DynamoRIO/dynamorio.git", "tools/buildbot": "https://github.com/DynamoRIO/buildbot.git"} api.gclient.c = src_cfg result = api.bot_update.ensure_checkout(force=True) build_properties.update(result.json.output.get("properties", {})) # clear tools directory step; null converted # update tools step; null converted # unpack tools step; generic ShellCommand converted api.step("unpack tools", [api.path["slave_build"].join('tools', 'buildbot', 'bot_tools', 'unpack.bat')], env={}, cwd=api.path[ "slave_build"].join('tools', 'buildbot', 'bot_tools')) # get buildnumber step; no longer needed # Package dynamorio step api.step("Package Dr. Memory", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), 'ctest', '-VV', '-S', str(api.path["checkout"].join("package.cmake")) + ",build=0x" + build_properties["got_revision"][:7] + ";drmem_only"], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}, cwd=api.path["slave_build"]) # Find package basename step step_result = api.step("Find package basename", ["dir", "/B", "DrMemory-Windows-*0x" + build_properties[ "got_revision"][:7] + ".zip"], stdout=api.raw_io.output(), cwd=api.path["slave_build"]) basename = step_result.stdout[:-4] # Delete prior sfx archive step api.step("Delete prior sfx archive", [ "del", basename + "-sfx.exe" ], cwd=api.path["slave_build"]) # Create sfx archive step api.step("create sfx archive", [api.path["build"].join("scripts", "slave", "drmemory", "build_env.bat"), "7z", "a", "-sfx", basename + "-sfx.exe", "build_drmemory-debug-32\\_CPack_Packages\\Windows\\ZIP\\" + basename + "\\*"], cwd=api.path["slave_build"], env={"BOTTOOLS": api.path["slave_build"].join("tools", "buildbot", "bot_tools")}) # upload latest build step api.step("copy locally", ["copy", basename + "-sfx.exe", "drmemory-windows-latest-sfx.exe"], cwd=api.path["slave_build"]) api.gsutil.upload("drmemory-windows-latest-sfx.exe", "chromium-drmemory-builds", "", cwd=api.path["slave_build"]) # upload drmemory build step api.gsutil.upload("DrMemory-Windows-*" + build_properties["got_revision"][ :7] + ".zip", "chromium-drmemory-builds", "builds/") dispatch_directory = { 'linux-builder': linux_builder_steps, 'linux-lucid_x64-drm': linux_lucid_x64_drm_steps, 'win-vista_x64-drm': win_vista_x64_drm_steps, 'mac-mavericks_x64-DR': mac_mavericks_x64_DR_steps, 'linux-cr-builder': linux_cr_builder_steps, 'mac-builder-DR': mac_builder_DR_steps, 'win-xp-drm': win_xp_drm_steps, 'mac-mavericks_x64-drm': mac_mavericks_x64_drm_steps, 'linux-cr': linux_cr_steps, 'win8-cr-builder': win8_cr_builder_steps, 'win8-cr': win8_cr_steps, 'win7-cr': win7_cr_steps, 'win-8_x64-drm': win_8_x64_drm_steps, 'win7-cr-builder': win7_cr_builder_steps, 'win-7_x64-drm': win_7_x64_drm_steps, 'mac-builder': mac_builder_steps, 'win-builder': win_builder_steps, } def RunSteps(api): if api.properties["buildername"] not in dispatch_directory: raise api.step.StepFailure("Builder unsupported by recipe.") else: dispatch_directory[api.properties["buildername"]](api) def GenTests(api): yield (api.test('linux_builder') + api.properties(mastername='client.drmemory') + api.properties(buildername='linux-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('linux_lucid_x64_drm') + api.properties(mastername='client.drmemory') + api.properties(buildername='linux-lucid_x64-drm') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win_vista_x64_drm') + api.properties(mastername='client.drmemory') + api.properties(buildername='win-vista_x64-drm') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('mac_mavericks_x64_DR') + api.properties(mastername='client.drmemory') + api.properties(buildername='mac-mavericks_x64-DR') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('linux_cr_builder') + api.properties(mastername='client.drmemory') + api.properties(buildername='linux-cr-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('linux_cr_builder_clobber') + api.properties(mastername='client.drmemory') + api.properties(buildername='linux-cr-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') + api.properties(clobber='') ) yield (api.test('mac_builder_DR') + api.properties(mastername='client.drmemory') + api.properties(buildername='mac-builder-DR') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win_xp_drm') + api.properties(mastername='client.drmemory') + api.properties(buildername='win-xp-drm') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('mac_mavericks_x64_drm') + api.properties(mastername='client.drmemory') + api.properties(buildername='mac-mavericks_x64-drm') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('linux_cr') + api.properties(mastername='client.drmemory') + api.properties(buildername='linux-cr') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win8_cr_builder') + api.properties(mastername='client.drmemory') + api.properties(buildername='win8-cr-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win8_cr_builder_clobber') + api.properties(mastername='client.drmemory') + api.properties(buildername='win8-cr-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') + api.properties(clobber='') ) yield (api.test('win8_cr') + api.properties(mastername='client.drmemory') + api.properties(buildername='win8-cr') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') + api.step_data("Get the revision number", stdout=api.raw_io.output("Dr. Memory version 1.9.16845" " -- build 178560794")) ) yield (api.test('win7_cr') + api.properties(mastername='client.drmemory') + api.properties(buildername='win7-cr') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') + api.step_data("Get the revision number", stdout=api.raw_io.output("Dr. Memory version 1.9.16845" " -- build 178560794")) ) yield (api.test('win_8_x64_drm') + api.properties(mastername='client.drmemory') + api.properties(buildername='win-8_x64-drm') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win7_cr_builder') + api.properties(mastername='client.drmemory') + api.properties(buildername='win7-cr-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win7_cr_builder_clobber') + api.properties(mastername='client.drmemory') + api.properties(buildername='win7-cr-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') + api.properties(clobber='') ) yield (api.test('win_7_x64_drm') + api.properties(mastername='client.drmemory') + api.properties(buildername='win-7_x64-drm') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('mac_builder') + api.properties(mastername='client.drmemory') + api.properties(buildername='mac-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') ) yield (api.test('win_builder') + api.properties(mastername='client.drmemory') + api.properties(buildername='win-builder') + api.properties(revision='123456789abcdef') + api.properties(got_revision='123456789abcdef') + api.properties(buildnumber=42) + api.properties(slavename='TestSlave') + api.step_data("Find package basename", stdout=api.raw_io.output("DrMemory-Windows-1.2.3-0x1234567.zip") )) yield (api.test('builder_not_in_dispatch_directory') + api.properties(mastername='client.drmemory') + api.properties(buildername='nonexistent_builder') + api.properties(slavename='TestSlave') )
#!/usr/bin/env python # Use generators to avoid crashed in memory when needed to interate on large set of data # Generators can be built with the syntax of list comprehensions but inside () names = ['Tim', 'Mark', 'Donna', 'Albert', 'Sara'] gen_a = (len(n) for n in names) print(next(gen_a)) print(next(gen_a)) # You define a generator function, using the yield keyword to return a value def my_generator(): names = ['Gianluca', 'Lisa', 'Sofia', 'Giulia'] for i in names: yield i # You define a generator iterator as an instance of the function gen = my_generator() # You call next to generate the next value print(next(gen)) print(next(gen)) # Being the generator an iterator you can use it in a for loop as well # notes that we keep generating from where we left for val in gen: print(val) # Remember: generators are used to generate the next value, # they allow you to iterate over values without having to load them # in memory. That's a key difference from a function where you # only get a chance to return all results all at the same time. # For example: # 1. when you read a file the built in mechanism is a generator # 2. the xrange uses a generator # yield: what it does is save the "state" of a generator function
sumIdade = 0 velho = 0 nome_velho = '' novo = 0 qtnd_20 = 0 for c in range(1, 5): print('-------- {}ยช pessoa --------' .format(c)) nome = str(input('Digite o nome da pessoa {}: ' .format(c))) .strip() idade = int(input('Digite em nรบmeros a idade de {}: '.format(nome))) sexo = input('Vocรช รฉ de qual sexo?\n[ M ] para masculino\n[ F ] para feminino\nDigite: ' .format(c)) .upper().strip() if sexo == 'M' or sexo == 'F': sumIdade += idade if sexo == 'M': if idade > velho: velho = idade nome_velho = nome else: if idade < 20: qtnd_20 += 1 else: print('\033[1;41mDigite M ou F!\033[m') break if sexo == 'M' or sexo == 'F': medIdade = sumIdade/c print('A mรฉdia de idade de todo o grupo รฉ de {:.1f} anos.' .format(medIdade)) print('O nome do homem mais velho รฉ {} com {} anos.' .format(nome_velho, velho)) print('Hรก {} mulheres com menos de 20 anos no grupo.' .format(qtnd_20)) else: ''
def largest_product(a_list): if len(a_list) == 0: return False column = 0 row = 0 big = a_list[0][0] * a_list[0][1] while column < len(a_list) - 1: if a_list[column][row] * a_list[column][row + 1] > big: big = a_list[column][row] * a_list[column][row + 1] if a_list[column][row] * a_list[column + 1][row] > big: big = a_list[column][row] * a_list[column + 1][row] if a_list[column][row] * a_list[column + 1][row + 1] > big: big = a_list[column][row] * a_list[column + 1][row + 1] if a_list[column + 1][row] * a_list[column + 1][row + 1]: big = a_list[column + 1][row] * a_list[column + 1][row + 1] if a_list[column][row + 1] * a_list[column + 1][row + 1]: a_list[column][row + 1] * a_list[column + 1][row + 1] column += 1 return big
### Dielectric class class Dielectric: ## Intialization function with all properties def __init__(self, pos_x, pos_y, width, height, eps_r): self.pos_x = pos_x self.pos_y = pos_y self.width = width self.height = height self.eps_r = eps_r ## String representation functions def __str__(self): return "x: {}, y: {}, w: {}, h: {}, eps_r: {}".format( self.pos_x, self.pos_y, self.width, self.height, self.eps_r ) def __repr__(self): return self.__str__()
""" drf ไธๅ…ผๅฎน็š„้…็ฝฎ้กน """ SCHEMA_COERCE_METHOD_NAMES = { 'retrieve': 'read', 'destroy': 'delete' } SCHEMA_COERCE_PATH_PK = True
def ceaser(message): ciphered = "" for c in message: if c.isalpha(): if c.isupper(): upper = True else: upper = False c = c.upper() place = ord(c) if place+13 > 90: place = (place+13 - 90) + 64 else: place = place + 13 if upper: ciphered += chr(place) else: ciphered += chr(place).lower() else: ciphered += c return ciphered
# # PySNMP MIB module CONV-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/CONV-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 18:11:06 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # OctetString, Integer, ObjectIdentifier = mibBuilder.importSymbols("ASN1", "OctetString", "Integer", "ObjectIdentifier") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint", "ConstraintsIntersection") Alias, cxConv = mibBuilder.importSymbols("CXProduct-SMI", "Alias", "cxConv") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") ObjectIdentity, iso, Bits, TimeTicks, Counter32, Counter64, Gauge32, MibIdentifier, MibScalar, MibTable, MibTableRow, MibTableColumn, IpAddress, Unsigned32, NotificationType, ModuleIdentity, Integer32 = mibBuilder.importSymbols("SNMPv2-SMI", "ObjectIdentity", "iso", "Bits", "TimeTicks", "Counter32", "Counter64", "Gauge32", "MibIdentifier", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "IpAddress", "Unsigned32", "NotificationType", "ModuleIdentity", "Integer32") TextualConvention, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "DisplayString") cxConvTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1), ) if mibBuilder.loadTexts: cxConvTable.setStatus('mandatory') cxConvEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1), ).setIndexNames((0, "CONV-MIB", "cxConvPort")) if mibBuilder.loadTexts: cxConvEntry.setStatus('mandatory') cxConvPort = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 1), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 65535))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxConvPort.setStatus('mandatory') cxConvPortAlias = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 2), Alias()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvPortAlias.setStatus('mandatory') cxConvRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("invalid", 1), ("valid", 2))).clone('valid')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvRowStatus.setStatus('mandatory') cxConvIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxConvIfIndex.setStatus('mandatory') cxConvState = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("on", 1), ("off", 2))).clone('on')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvState.setStatus('mandatory') cxConvCompression = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 6), Integer32()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvCompression.setStatus('mandatory') cxConvCompCompatibility = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("compatibleMemotec", 1), ("compatibleACC", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxConvCompCompatibility.setStatus('mandatory') cxFwkCircuitTable = MibTable((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2), ) if mibBuilder.loadTexts: cxFwkCircuitTable.setStatus('mandatory') cxFwkCircuitEntry = MibTableRow((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1), ).setIndexNames((0, "CONV-MIB", "cxFwkCircuitPort")) if mibBuilder.loadTexts: cxFwkCircuitEntry.setStatus('mandatory') cxFwkCircuitPort = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 1), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkCircuitPort.setStatus('mandatory') cxFwkCircuitState = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(256, 1, 2, 3, 4))).clone(namedValues=NamedValues(("idle", 256), ("opened", 1), ("closed", 2), ("opening", 3), ("openFailed", 4)))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkCircuitState.setStatus('mandatory') cxFwkCircuitRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("invalid", 1), ("valid", 2))).clone('valid')).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkCircuitRowStatus.setStatus('mandatory') cxFwkServiceType = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 4), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 256))).clone(namedValues=NamedValues(("frameRelay", 1), ("notSpecified", 256)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceType.setStatus('mandatory') cxFwkServiceProtocol = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("cls", 1), ("pvc", 2), ("svc", 3), ("char", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceProtocol.setStatus('mandatory') cxFwkServiceName = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 6), OctetString().subtype(subtypeSpec=ValueSizeConstraint(16, 16)).setFixedLength(16)).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkServiceName.setStatus('mandatory') cxFwkDestAddress = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 7), OctetString().subtype(subtypeSpec=ValueSizeConstraint(20, 20)).setFixedLength(20)).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkDestAddress.setStatus('mandatory') cxFwkDestAlias = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 8), Alias()).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkDestAlias.setStatus('mandatory') cxFwkServiceCircuitMdu = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 8192)).clone(1600)).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceCircuitMdu.setStatus('mandatory') cxFwkServiceCost = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 1000000))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceCost.setStatus('mandatory') cxFwkServiceCardId = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 16))).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkServiceCardId.setStatus('mandatory') cxFwkServiceSapId = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 12), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkServiceSapId.setStatus('mandatory') cxFwkServiceRouteRef = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 255))).setMaxAccess("readwrite") if mibBuilder.loadTexts: cxFwkServiceRouteRef.setStatus('mandatory') cxFwkStatsInternalErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 15), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsInternalErrors.setStatus('mandatory') cxFwkStatsRegistrationErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 16), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsRegistrationErrors.setStatus('mandatory') cxFwkStatsQueryErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 17), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsQueryErrors.setStatus('mandatory') cxFwkStatsOpenErrors = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 18), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsOpenErrors.setStatus('mandatory') cxFwkStatsResets = MibTableColumn((1, 3, 6, 1, 4, 1, 495, 2, 1, 6, 8, 2, 1, 19), Counter32()).setMaxAccess("readonly") if mibBuilder.loadTexts: cxFwkStatsResets.setStatus('mandatory') mibBuilder.exportSymbols("CONV-MIB", cxConvState=cxConvState, cxConvRowStatus=cxConvRowStatus, cxConvPortAlias=cxConvPortAlias, cxFwkServiceCardId=cxFwkServiceCardId, cxFwkStatsOpenErrors=cxFwkStatsOpenErrors, cxFwkDestAlias=cxFwkDestAlias, cxConvCompCompatibility=cxConvCompCompatibility, cxFwkStatsQueryErrors=cxFwkStatsQueryErrors, cxFwkServiceName=cxFwkServiceName, cxFwkServiceProtocol=cxFwkServiceProtocol, cxFwkDestAddress=cxFwkDestAddress, cxConvEntry=cxConvEntry, cxConvIfIndex=cxConvIfIndex, cxFwkServiceCircuitMdu=cxFwkServiceCircuitMdu, cxFwkServiceCost=cxFwkServiceCost, cxFwkCircuitPort=cxFwkCircuitPort, cxFwkStatsInternalErrors=cxFwkStatsInternalErrors, cxFwkServiceSapId=cxFwkServiceSapId, cxFwkCircuitTable=cxFwkCircuitTable, cxFwkStatsRegistrationErrors=cxFwkStatsRegistrationErrors, cxConvPort=cxConvPort, cxFwkCircuitEntry=cxFwkCircuitEntry, cxFwkCircuitState=cxFwkCircuitState, cxFwkCircuitRowStatus=cxFwkCircuitRowStatus, cxFwkServiceType=cxFwkServiceType, cxFwkStatsResets=cxFwkStatsResets, cxFwkServiceRouteRef=cxFwkServiceRouteRef, cxConvTable=cxConvTable, cxConvCompression=cxConvCompression)
# 268. Missing Number # Runtime: 132 ms, faster than 76.58% of Python3 online submissions for Missing Number. # Memory Usage: 15.5 MB, less than 51.40% of Python3 online submissions for Missing Number. class Solution: # Gauss' Formula def missingNumber(self, nums: list[int]) -> int: expected_sum = len(nums) * (len(nums) + 1) // 2 return expected_sum - sum(nums)
def redis_key(project_slug, key, *namespaces): """ Generates project dependent Redis key >>> redis_key('a', 'b') 'a:b' >>> redis_key('a', 'b', 'c', 'd') 'a:c:d:b' >>> redis_key('a', 1, 'c', None) 'a:c:1' """ l = [project_slug] if namespaces: l.extend(namespaces) l.append(key) return ':'.join(str(i)for i in l if i) class RedisMixin: project_slug = None @classmethod def redis_key(cls, key, namespace): return redis_key(cls.project_slug, key, namespace) @classmethod async def redis(cls, request, key, *, value=None, sadd=None, expire=None, default=None, namespace=None, smembers=False, srem=None, delete=False, connection=None): key = cls.redis_key(key, namespace) async def _redis(cache): if value: await cache.set(key, value) elif delete: await cache.delete(key) elif sadd: if isinstance(sadd, (list, tuple)): await cache.sadd(key, *sadd) else: await cache.sadd(key, sadd) elif smembers: v = await cache.smembers(key) return v or default elif srem: return await cache.srem(key, srem) elif not expire: return (await cache.get(key)) or default if expire: await cache.expire(key, int(expire)) if connection is not None: return await _redis(connection) else: async with request.app.redis.get() as connection: return await _redis(connection)
''' split, join, enumerate em python split: dividir uma string join: juntar uma string ou lista enumerate: enumerar elementos da lista #interavel ''' string = 'Brasil รฉ o paรญs do futebool, brasil รฉ o penta penta penta' lista_1 = string.split(' ') lista_2 = string.split(',') palavra_rep = '' contagem = 0 qtd = 0 for palavra in lista_1: # print(f'a palavra "{palavra}" aparece {string.count(palavra)}x na frase') qtd = string.count(palavra) if qtd > contagem: contagem = qtd palavra_rep = palavra print(f'A palavra mais repetida รฉ: {palavra_rep}, aparece {contagem}x') for valor in lista_2: print(valor.strip().capitalize()) # a funรงaรต strip remove os espaรงos no # inicio e fim de uma string print(lista_1) print(' '.join(lista_1)) # a funรงรฃo join transforma uma lista em string
#from time import sleep #for cont in range(10, -1, -1): # print(cont) # sleep(0.5) #for par in range(1, 51): # # outra forma de escreve: print(par) # if par % 2 == 0: # print(' {} '.format(par), end='') # sleep(0.2) #print('acabou') #for n in range(2, 51, 2): # # outra forma de escreve: print(par) # print(' {} '.format(n), end='') # sleep(0.2) #print('acabou') #soma = 0 #cont = 0 #for c in range(1, 501, 2): # if c % 3 == 0: # # print(c, end=' '), para extrair os numeros # cont = cont + 1 # outra sintaxe cont += 1 # soma = soma + c # outra sintaxe soma += c #print('a soma dos numeros e {} e contamos {} numeros'.format(soma, cont)) #num = int(input('digite o numero para ver sua tabuada: ')) #for c in range(1, 11): # print('{} x {:2} = {}'.format(num, c, num * c)) #soma = 0 #cont = 0 #for c in range(1, 7): # num = int(input(' digite o {}ยบ valor : '.format(c))) # if num % 2 == 0: # soma = soma + num # outra forma sintaxe, soma += num # cont = cont + 1 # outra forma sintaxe, cont += 1 #print('voce informou {} numeros pares e a soma foi {}'.format(cont, soma)) #primeiro = int(input('primeiro termo ')) #razao = int(input('razao ')) #ultimo = int(input('ultimo termo')) #ultimo = primeiro + (ultimo - 1)* razao #for c in range(primeiro, ultimo + razao, razao): # print('{} '.format(c), end=' -> ') #print('acabaou') #num = int(input('digite um numero :')) #tot = 0 #for c in range(1, num + 1): # if num % c == 0: # print('\033[33m', end=' ') # tot = tot + 1 # else: # print('\033[31m', end=' ') # print('{} '.format(c), end='') #print(' \n\033[mo numero {}, foi divisivel {} vezes'.format(num, tot)) #if tot == 2: # print(' E numero primo') #else: # print('E numero nao primo') #frase = str(input('digite a frase ')).strip().upper() #palavras = frase.split() #junto = ''.join(palavras) #print('vc digitou a frase : {} '.format(junto)) # forma 01 de resolver #inverso = '' #for letra in range(len(junto) -1, -1, -1): # inverso = inverso + junto[letra] # forma 02 de resolver #inverso = junto[::-1] #print('o inverso de {} e {} '.format(junto, inverso)) #if inverso == junto : # print('palidromo') #else: # print('nao e palidromo') #from datetime import date #atual = date.today().year #totmaior = 0 #totmenor = 0 #for pess in range(1, 8): # nasc = int(input('em que ano a {}ยช pessoa nasceu? '.format(pess))) # idade = atual - nasc # if idade >= 21: # totmaior = totmaior + 1 # else: # totmenor = totmenor + 1 #print('ao todo tivemos {} pessoas maiores de idade '.format(totmaior)) #print('ao todo tivemos {} pessoas menores de idade '.format(totmenor)) #maior = 0 #menor = 0 #for p in range(1, 6): # peso = float(input('peso da {}ยช pessoa: '.format(p))) # if p == 1: # maior = peso # menor = peso # else: # if peso > maior: # maior = peso # if peso < menor: # menor = peso #print('o maior peso lido foi: {} '.format(maior)) #print('o menor peso lido foi: {} '.format(menor)) somaidade = 0 mediaidade = 0 maioridadehomem = 0 nomevelho = '' totmulher20 = 0 for p in range (1, 5): print('-------{}ยช PESSOA ------'.format(p)) nome = str(input('nome: ')).strip() idade = int(input('idade: ')) sexo = str(input('sexo [M/F]: ')).strip() somaidade = somaidade + idade # ou somaidade += idade if p == 1 and sexo in 'Mm': maioridadehomem = idade nomevelho = nome if sexo in 'Mn' and idade > maioridadehomem: maioridadehomem = idade nomevelho = nome if sexo in 'Ff' and idade < 20: totmulher20 = totmulher20 + 1 mediaidade = somaidade / 4 print(' a media de idade do grupo e {} anos'.format(mediaidade)) print(' o homem mais velho tem {} anos e se chama {}'.format(maioridadehomem,nomevelho)) print(' ao todo sao {} mulheres menores de 20 anos'.format(totmulher20))
# coding=utf-8 # Author: Jianghan LI # Question: 094.Binary_Tree_Inorder_Traversal # Date: 2017-07-03 13:26 - 13:37, 0 wrong try # Complexity: O(N) # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): # Recursive solution is trivial def inorderTraversal(self, root): """ :type root: TreeNode :rtype: List[int] """ return self.inorderTraversal(root.left) + [root.val] + self.inorderTraversal(root.right) if root else [] # iteratively def inorderTraversal(self, root): stack = [] ret = [] cur = root while 1: while cur: stack.append(cur) cur = cur.left if not stack: break cur = stack.pop() ret.append(cur.val) cur = cur.right return ret # a little better, change condition def inorderTraversal(self, root): stack, ret, cur = [], [], root while cur or stack: while cur: stack.append(cur) cur = cur.left cur = stack.pop() ret.append(cur.val) cur = cur.right return ret # stack replaces recursion stack # cur replaces recursion input # ret repalces ruduced return value
# -*- coding: utf-8 -*- def pizza(): print("Pizzaaaaaaa") def nuggets(): print("Course de poussins!") def quiche(): print("Qui?") def croques(): print("Ma machine est partie...") def courgettes(): print("Non, pas de courgettes :'(") def choix_repas_moche(num_choix=4): """ Choix d'un repas en utilisant les if/else """ if num_choix == 1: pizza() if num_choix == 2: nuggets() if num_choix == 3: quiche() if num_choix == 4: courgettes() def choix_repas(num_choix=4): """ Choix d'un repas en utilisant les dictionnaires """ choix = {1: pizza, 2: nuggets, 3: quiche, 4: courgettes} return choix.get(num_choix, 4)() if __name__ == '__main__': choix_repas(1) choix_repas(2) choix_repas(3) choix_repas(4) choix_repas()
class Solution: def removeOuterParentheses(self, S: str) -> str: res = "" level = 0 start = 0 for i, c in enumerate(S): if c == "(": level += 1 if c == ")": level -= 1 if level == 0: res += S[start + 1 : i] start = i + 1 return res
class Linked_List: class __Node: def __init__(self, val): # declare and initialize the private attributes # for objects of the Node class. # TODO replace pass with your implementation self.val=val self.prev=None self.next=None def __init__(self): # declare and initialize the private attributes # for objects of the sentineled Linked_List class # TODO replace pass with your implementation self.__header = self.__Node(None) self.__trailer = self.__Node(None) self.__header.next = self.__trailer # trailer is after header self.__trailer.prev = self.__header # header is before trailer self.__size = 0 def __len__(self): # return the number of value-containing nodes in # this list. # TODO replace pass with your implementation ##??????SHOULD THIS WALK THROUGH return self.__size def append_element(self, val): # increase the size of the list by one, and add a # node containing val at the new tail position. this # is the only way to add items at the tail position. # TODO replace pass with your implementation new_node = Linked_List.__Node(val) self.__trailer.prev.next = new_node new_node.next=self.__trailer new_node.prev=self.__trailer.prev self.__trailer.prev = new_node self.__size = self.__size + 1 def insert_element_at(self, val, index): # assuming the head position (not the header node) # is indexed 0, add a node containing val at the # specified index. If the index is not a valid # position within the list, raise an IndexError # exception. This method cannot be used to add an # item at the tail position. # TODO replace pass with your implementation if index >= self.__size: raise IndexError if index < 0: raise IndexError new_node = Linked_List.__Node(val) current = self.__header for i in range(0, index): current = current.next new_node.next = current.next new_node.prev = current current.next = new_node new_node.next.prev = new_node self.__size = self.__size + 1 def remove_element_at(self, index): # assuming the head position (not the header node) # is indexed 0, remove and return the value stored # in the node at the specified index. If the index # is invalid, raise an IndexError exception. # TODO replace pass with your implementation if index >= self.__size: raise IndexError if index < 0: raise IndexError if self.__size == 0: raise IndexError current = self.__header for i in range(0, index): current = current.next valremoved=current.next.val current.next=current.next.next current.next.prev=current self.__size = self.__size - 1 return valremoved def get_element_at(self, index): # assuming the head position (not the header node) # is indexed 0, return the value stored in the node # at the specified index, but do not unlink it from # the list. If the specified index is invalid, raise # an IndexError exception. # TODO replace pass with your implementation if index >= self.__size: raise IndexError if index < 0: raise IndexError if self.__size == 0: raise IndexError current = self.__header for i in range(0, index): current = current.next return current.next.val #####CHECK CORRECT SYNTAX FOR THIS def rotate_left(self): # rotate the list left one position. Conceptual indices # should all decrease by one, except for the head, which # should become the tail. For example, if the list is # [ 5, 7, 9, -4 ], this method should alter it to # [ 7, 9, -4, 5 ]. This method should modify the list in # place and must not return a value. # TODO replace pass with your implementation. if self.__size==0: raise IndexError self.__trailer.prev.next = self.__header.next self.__header.next = self.__header.next.next self.__header.next.prev=self.__header self.__trailer.prev.next.prev=self.__trailer.prev self.__trailer.prev.next.next=self.__trailer self.__trailer.prev=self.__trailer.prev.next def __str__(self): # return a string representation of the list's # contents. An empty list should appear as [ ]. # A list with one element should appear as [ 5 ]. # A list with two elements should appear as [ 5, 7 ]. # You may assume that the values stored inside of the # node objects implement the __str__() method, so you # call str(val_object) on them to get their string # representations. # TODO replace pass with your implementation current = self.__header.next stringlist = list() stringlist.append("[") if self.__size==0: stringlist.append(" ") else: while(current != self.__trailer): element = str(current.val) stringlist.append(" " + element) if current.next != self.__trailer: stringlist.append(",") else: stringlist.append(" ") current = current.next stringlist.append("]") stringlist = "".join(stringlist) return stringlist def __iter__(self): # initialize a new attribute for walking through your list # TODO insert your initialization code before the return # statement. do not modify the return statement. self.__iter_index = 0 self.__current = self.__header return self def __next__(self): # using the attribute that you initialized in __iter__(), # fetch the next value and return it. If there are no more # values to fetch, raise a StopIteration exception. # TODO replace pass with your implementation if self.__iter_index == self.__size: raise StopIteration self.__current = self.__current.next self.__iter_index = self.__iter_index + 1 return self.__current.val if __name__ == '__main__': # Your test code should go here. Be sure to look at cases # when the list is empty, when it has one element, and when # it has several elements. Do the indexed methods raise exceptions # when given invalid indices? Do they position items # correctly when given valid indices? Does the string # representation of your list conform to the specified format? # Does removing an element function correctly regardless of that # element's location? Does a for loop iterate through your list # from head to tail? Your writeup should explain why you chose the # test cases. Leave all test cases in your code when submitting. # TODO replace pass with your tests list1 = Linked_List() list1.append_element(5) list1.append_element(6) list1.append_element(3) list1.append_element(-7) print("Original List:") print(list1.__str__()) print("Original Length:") print(list1.__len__()) ##Testing Insert-SHOULD WORK print("Testing Insert With Valid Index") try: list1.insert_element_at(-2, 0) except IndexError: print("Invalid index!!") print("New List:") print(list1.__str__()) print("New Length:") print(list1.__len__()) ##Testing Insert-SHOULD GIVE ERROR print("Testing Insert With Invalid Index") try: list1.insert_element_at(9,7) except IndexError: print("Invalid index!!") print(list1.__str__()) ##Testing Insert-SHOULD GIVE ERROR print("Testing Insert With Invalid Index") try: list1.insert_element_at(9,-1) except IndexError: print("Invalid index!!") print(list1.__str__()) ##Testing Remove-SHOULD WORK print("Testing Remove With Valid Index") try: list1.remove_element_at(2) except: print("Invalid index!!") print("New List:") print(list1.__str__()) print("New Length:") print(list1.__len__()) ##Testing Remove-SHOULD GIVE ERROR print("Testing Remove With Invalid Index") try: list1.remove_element_at(-1) except: print("Invalid index!!") print(list1.__str__()) ##Testing Remove-SHOULD GIVE ERROR print("Testing Remove With Invalid Index") try: list1.remove_element_at(10) except: print("Invalid index!!") print(list1.__str__()) ##Testing Get element at-SHOULD WORK print("Testing Get Element With Valid Index") try: list1.get_element_at(1) except: print("Invalid index!!") print(list1.get_element_at(1)) ##Testing Get element at-SHOULD GIVE ERROR print("Testing Get Element With Invalid Index") try: list1.get_element_at(-1) except: print("Invalid index!!") ##Testing Get element at-SHOULD GIVE ERROR print("Testing Get Element With Invalid Index") try: list1.get_element_at(19) except: print("Invalid index!!") print("Rotate Left Output") list1.rotate_left() print(list1.__str__()) print("Size:") print(list1.__len__()) print("Iterator:") for val in list1: print(val) ##empty list list2 = Linked_List() print("Original List:") print(list2.__str__()) print("Original Length:") print(list2.__len__()) ##testing insert-should give error print("Testing Insert With Invalid Index") try: list2.insert_element_at(9,0) except IndexError: print("Invalid index!!") print(list2.__str__()) ##testing remove-SHOULD GIVE ERROR print("Testing Remove With Invalid Index") try: list2.remove_element_at(1) except: print("Invalid index!!") print(list2.__str__()) ##Testing Get element at-SHOULD GIVE ERROR print("Testing Get Element With Invalid Index") try: list2.get_element_at(0) except: print("Invalid index!!") print(list2.__str__()) print("Trying an incorrect use of rotate left:") try: list2.rotate_left() except IndexError: print("Rotate left doesn't work on an empty list!") list2.append_element(2) list2.append_element(6) list2.append_element(8) print("New List:") print(list2.__str__()) print("New Length:") print(list2.__len__())