content
stringlengths
7
1.05M
extensions = ["sphinx-favicon"] master_doc = "index" exclude_patterns = ["_build"] html_theme = "basic" html_static_path = ["gfx"] favicons = [ { "sizes": "32x32", "static-file": "square.svg", }, { "sizes": "128x128", "static-file": "nested/triangle.svg", }, ]
lista = [] nome = str(input('Qual é o seu nome? ')) print(f'Olá, {nome} vamos começar...\n') while True: valor = int(input('Digite um valor: ')) if valor not in lista: print('Valor adicionado a lista') lista.append(valor) else: print('Esse valor já está na lista, não podemos adicionar valores repetidos') opcao = str(input('Quer inserir outro valor [S/N]? ').upper().strip()[0]) while opcao not in 'SN': opcao = str(input('Quer inserir outro valor [S/N]?').upper().strip()[0]) if opcao == 'N': print("\n========== PROGRAMA ENCERRADO ==========") break lista.sort() print(f'Opa {nome}, você inseriu {len(lista)} números a lista, que são -> {lista}')
acceptall = [ "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n", "Accept-Encoding: gzip, deflate\r\n", "Accept-Language: en-US,en;q=0.5\r\nAccept-Encoding: gzip, deflate\r\n", "Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Charset: iso-8859-1\r\nAccept-Encoding: gzip\r\n", "Accept: application/xml,application/xhtml+xml,text/html;q=0.9, text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Charset: iso-8859-1\r\n", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1\r\nAccept-Language: utf-8, iso-8859-1;q=0.5, *;q=0.1\r\nAccept-Charset: utf-8, iso-8859-1;q=0.5\r\n", "Accept: image/jpeg, application/x-ms-application, image/gif, application/xaml+xml, image/pjpeg, application/x-ms-xbap, application/x-shockwave-flash, application/msword, */*\r\nAccept-Language: en-US,en;q=0.5\r\n", "Accept: text/html, application/xhtml+xml, image/jxr, */*\r\nAccept-Encoding: gzip\r\nAccept-Charset: utf-8, iso-8859-1;q=0.5\r\nAccept-Language: utf-8, iso-8859-1;q=0.5, *;q=0.1\r\n", "Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1\r\nAccept-Encoding: gzip\r\nAccept-Language: en-US,en;q=0.5\r\nAccept-Charset: utf-8, iso-8859-1;q=0.5\r\n," "Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8\r\nAccept-Language: en-US,en;q=0.5\r\n", "Accept-Charset: utf-8, iso-8859-1;q=0.5\r\nAccept-Language: utf-8, iso-8859-1;q=0.5, *;q=0.1\r\n", "Accept: text/html, application/xhtml+xml", "Accept-Language: en-US,en;q=0.5\r\n", "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding: br;q=1.0, gzip;q=0.8, *;q=0.1\r\n", "Accept: text/plain;q=0.8,image/png,*/*;q=0.5\r\nAccept-Charset: iso-8859-1\r\n", ] referers = [ "https://www.google.com/search?q=", "https://check-host.net/", "https://www.facebook.com/", "https://www.youtube.com/", "https://www.fbi.com/", "https://www.bing.com/search?q=", "https://r.search.yahoo.com/", "https://www.cia.gov/index.html", "https://vk.com/profile.php?redirect=", "https://www.usatoday.com/search/results?q=", "https://help.baidu.com/searchResult?keywords=", "https://steamcommunity.com/market/search?q=", "https://www.ted.com/search?q=", "https://play.google.com/store/search?q=", "https://www.qwant.com/search?q=", "https://soda.demo.socrata.com/resource/4tka-6guv.json?$q=", "https://www.google.ad/search?q=", "https://www.google.ae/search?q=", "https://www.google.com.af/search?q=", "https://www.google.com.ag/search?q=", "https://www.google.com.ai/search?q=", "https://www.google.al/search?q=", "https://www.google.am/search?q=", "https://www.google.co.ao/search?q=", ] post_data = "" cookies = ""
# -*- coding: utf-8 -*- """Top-level package for Make Notebooks.""" __author__ = """Martin Skarzynski""" __version__ = '0.0.1'
# region headers # escript-template v20190605 / stephane.bourdeaud@nutanix.com # * author: Geluykens, Andy <Andy.Geluykens@pfizer.com> # * version: 2019/06/05 # task_name: RubrikGetSlaDomainId # description: This script gets the id of the specified Rubrik SLA domain. # endregion # region capture Calm macros username = '@@{rubrik.username}@@' username_secret = "@@{rubrik.secret}@@" api_server = "@@{rubrik_ip}@@" sla_domain = "@@{sla_domain}@@" # endregion # region Get Rubrik SLA domain ID api_server_port = "443" api_server_endpoint = "/api/v1/sla_domain?name={}".format(sla_domain) url = "https://{}:{}{}".format( api_server, api_server_port, api_server_endpoint ) method = "GET" headers = { 'Content-Type': 'application/json', 'Accept': 'application/json' } print("Making a {} API call to {}".format(method, url)) resp = urlreq( url, verb=method, auth='BASIC', user=username, passwd=username_secret, headers=headers, verify=False ) if resp.ok: json_resp = json.loads(resp.content) sla_domain_id = json_resp['data'][0]['id'] print("rubrik_sla_domain_id={}".format(sla_domain_id)) exit(0) else: print("Request failed") print("Headers: {}".format(headers)) print('Status code: {}'.format(resp.status_code)) print('Response: {}'.format(json.dumps(json.loads(resp.content), indent=4))) exit(1) # endregion
class Animal: def __init__(self, name): # Constructor of the class self.name = name def speak(self): # Abstract method, defined by convention only raise NotImplementedError("Subclass must implement abstract method") class Dog(Animal): def speak(self): return self.name+' says Woof!' class Cat(Animal): def speak(self): return self.name+' says Meow!' fido = Dog('Fido') isis = Cat('Isis') print(fido.speak()) print(isis.speak()) # In this example, the derived classes did not need their own __init__ methods # because the base class __init__ gets called automatically # if you do define an __init__ in the derived class, this will override the base #* Multiple inheritance class Computer: def __init__(self,battery): self.battery = battery class Mac(Computer): def __init__(self, OS="MacOS", HW="proprietary",battery="LiIon"): self.OS = OS self.HW = HW self.battery = battery def run_mac_os(self): print("MacOS is running now") def mac_charge(self): print("Chargig via USB C") class PC(Computer): def __init__(self, OS="Windows", HW="assembled", battery="LiAmber"): self.OS = OS self.HW = HW self.battery = battery def run_windows_os(self): print("Windows is running now") def pc_charge(self): print("Chargig via brick charger") class hackintosh(Mac,PC): def __init__(self,OS = "Linux", HW="Assembled and modified", battery="Combined"): Mac.__init__(self, OS, HW, battery="LiIon") PC.__init__(self,OS,HW,battery="LiAmber") hck1 = hackintosh() print(hck1.HW) print(hck1.OS) print(hck1.battery) hck1.mac_charge() hck1.run_mac_os() hck1.pc_charge() hck1.run_windows_os() #* Super keyword #* super() function provides a shortcut for calling base classes #* it automatically follows Method Resolution Order. class MyBaseClass: def __init__(self,x,y): self.x = x self.y = y class MyDerivedClass(MyBaseClass): def __init__(self,x,y,z): super().__init__(x,y) self.z = z
''' You are given a spreadsheet that contains a list of N athletes and their details (such as age, height, weight and so on). You are required to sort the data based on the Kth attribute and print the final resulting table. Follow the example given below for better understanding. image Note that K is indexed from 0 to M-1, where M is the number of attributes. Note: If two attributes are the same for different rows, for example, if two atheletes are of the same age, print the row that appeared first in the input. Input Format The first line contains N and M separated by a space. The next lines each contain M elements. The last line contains K. Output Format Print the lines of the sorted table. Each line should contain the space separated elements. Check the sample below for clarity. Sample Input 0 5 3 10 2 5 7 1 0 9 9 9 1 23 12 6 5 9 1 Sample Output 0 7 1 0 10 2 5 6 5 9 9 9 9 1 23 12 Explanation 0 The details are sorted based on the second attribute, since K is zero-indexed. ''' #!/bin/python3 def sortingCriteria(arr): return arr[k] def athleteSort(athleteList): # global? athleteList.sort(key=sortingCriteria) return athleteList if __name__ == '__main__': nm = input().rstrip().split() n = int(nm[0]) m = int(nm[1]) arr = [] for x in range(n): arr.append(list(map(int, input().rstrip().split()))) k = int(input().rstrip()) result = athleteSort(arr) for athlete in result: print(' '.join(map(str, athlete)))
print('====== DESAFIO 78 ======') lista = list() cont = 0 for c in range(1,3): lista.append(int(input('Digite um número: '))) print(f'O maior número digitado foi: {max(lista)} na posição {lista.index(max(lista))}') print(f'O menor número digitado foi: {min(lista)} na posição {lista.index(min(lista))}')
# Copyright 2019 BlueCat Networks. All rights reserved. # -*- coding: utf-8 -*- type = 'ui' sub_pages = [ { 'name' : 'cmdb_routers_page', 'title' : u'CMDB Routers', 'endpoint' : 'cmdb_routers/cmdb_routers_endpoint', 'description' : u'cmdb_routers' }, ]
input = """ #maxint=100. g(1,X):- #int(X). s(1). f(X) :- s(Y), g(Y,X), T=1+2. """ output = """ {f(0), f(1), f(10), f(100), f(11), f(12), f(13), f(14), f(15), f(16), f(17), f(18), f(19), f(2), f(20), f(21), f(22), f(23), f(24), f(25), f(26), f(27), f(28), f(29), f(3), f(30), f(31), f(32), f(33), f(34), f(35), f(36), f(37), f(38), f(39), f(4), f(40), f(41), f(42), f(43), f(44), f(45), f(46), f(47), f(48), f(49), f(5), f(50), f(51), f(52), f(53), f(54), f(55), f(56), f(57), f(58), f(59), f(6), f(60), f(61), f(62), f(63), f(64), f(65), f(66), f(67), f(68), f(69), f(7), f(70), f(71), f(72), f(73), f(74), f(75), f(76), f(77), f(78), f(79), f(8), f(80), f(81), f(82), f(83), f(84), f(85), f(86), f(87), f(88), f(89), f(9), f(90), f(91), f(92), f(93), f(94), f(95), f(96), f(97), f(98), f(99), g(1,0), g(1,1), g(1,10), g(1,100), g(1,11), g(1,12), g(1,13), g(1,14), g(1,15), g(1,16), g(1,17), g(1,18), g(1,19), g(1,2), g(1,20), g(1,21), g(1,22), g(1,23), g(1,24), g(1,25), g(1,26), g(1,27), g(1,28), g(1,29), g(1,3), g(1,30), g(1,31), g(1,32), g(1,33), g(1,34), g(1,35), g(1,36), g(1,37), g(1,38), g(1,39), g(1,4), g(1,40), g(1,41), g(1,42), g(1,43), g(1,44), g(1,45), g(1,46), g(1,47), g(1,48), g(1,49), g(1,5), g(1,50), g(1,51), g(1,52), g(1,53), g(1,54), g(1,55), g(1,56), g(1,57), g(1,58), g(1,59), g(1,6), g(1,60), g(1,61), g(1,62), g(1,63), g(1,64), g(1,65), g(1,66), g(1,67), g(1,68), g(1,69), g(1,7), g(1,70), g(1,71), g(1,72), g(1,73), g(1,74), g(1,75), g(1,76), g(1,77), g(1,78), g(1,79), g(1,8), g(1,80), g(1,81), g(1,82), g(1,83), g(1,84), g(1,85), g(1,86), g(1,87), g(1,88), g(1,89), g(1,9), g(1,90), g(1,91), g(1,92), g(1,93), g(1,94), g(1,95), g(1,96), g(1,97), g(1,98), g(1,99), s(1)} """
# coding=utf-8 # Copyright 2021 The Google Research Authors. # # 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. """MNIST Constants. These constants, specific to the MNIST dataset, are used across multiple places in this project. """ NUM_OUTPUTS = 10 # Using 80% of the train data for training and 20% for validation TRAIN_DATA_PERCENT = 80 TRAIN_VAL_SPLIT = (4, 1) NUM_TRAIN_EXAMPLES = 48000 IMAGE_EDGE_LENGTH = 28 NUM_FLATTEN_FEATURES = IMAGE_EDGE_LENGTH * IMAGE_EDGE_LENGTH
__title__ = "mathy_core" __version__ = "0.8.4" __summary__ = "Computer Algebra System for working with math expressions" __uri__ = "https://mathy.ai" __author__ = "Justin DuJardin" __email__ = "justin@dujardinconsulting.com" __license__ = "All rights reserved"
#!/usr/bin/env python3 theInput = """785 516 744 272 511 358 801 791 693 572 150 74 644 534 138 191 396 196 860 92 399 233 321 823 720 333 570 308 427 572 246 206 66 156 261 595 336 810 505 810 210 938 615 987 820 117 22 519 412 990 256 405 996 423 55 366 418 290 402 810 313 608 755 740 421 321 255 322 582 990 174 658 609 818 360 565 831 87 146 94 313 895 439 866 673 3 211 517 439 733 281 651 582 601 711 257 467 262 375 33 52 584 281 418 395 278 438 917 397 413 991 495 306 757 232 542 800 686 574 729 101 642 506 785 898 932 975 924 106 889 792 114 287 901 144 586 399 529 619 307 456 287 508 88 159 175 190 195 261 148 348 195 270 905 600 686 847 396 680 59 421 879 969 343 600 969 361 585 95 115 209 512 831 395 172 774 662 372 396 290 957 281 445 745 525 297 489 630 225 81 138 18 694 114 404 764 196 383 607 861 94 896 92 140 786 862 123 389 449 298 795 339 780 863 507 892 589 850 759 273 645 371 368 884 486 637 553 423 391 630 950 442 950 581 383 650 712 538 844 405 353 261 544 682 60 336 750 308 698 177 369 643 479 919 137 482 598 184 275 726 55 139 874 850 456 195 839 385 766 205 561 751 249 397 764 714 508 856 876 478 410 12 686 230 267 876 247 272 160 436 673 466 798 278 487 839 773 754 780 900 45 983 801 800 595 188 523 408 239 269 609 216 745 692 237 15 588 840 702 583 298 707 150 859 835 750 375 211 754 368 892 434 152 521 659 592 683 573 904 902 544 412 718 218 502 379 227 292 482 87 780 903 433 382 223 196 369 824 588 734 342 396 279 164 561 918 409 841 918 893 409 204 33 435 169 858 423 74 134 797 255 517 881 109 466 373 193 379 180 973 620 467 941 260 512 298 993 461 89 111 986 990 946 668 987 26 65 110 223 55 372 235 103 473 288 244 964 343 199 25 62 213 984 602 117 311 624 142 356 65 130 248 709 95 376 316 897 723 420 840 349 159 460 208 385 445 929 408 13 791 149 92 682 791 253 440 870 196 395 651 347 49 738 362 536 392 226 485 683 642 938 332 890 393 954 394 971 279 217 309 610 429 747 588 219 959 840 565 791 671 624 380 384 426 485 407 323 226 780 290 428 539 41 571 455 267 306 48 607 250 432 567 400 851 507 477 853 456 923 615 416 838 245 496 353 253 325 926 159 716 989 488 216 473 808 222 742 395 178 798 514 383 732 478 845 728 508 486 4 230 643 35 151 298 584 123 906 576 583 682 294 580 605 784 624 517 984 911 778 745 9 897 325 913 357 501 27 221 249 798 669 614 824 777 397 749 461 304 734 769 1 447 543 306 454 200 19 551 134 674 562 329 665 352 188 281 808 151 622 834 255 648 352 199 340 429 182 121 585 223 382 524 977 225 520 156 532 827 929 419 429 175 759 284 376 877 312 548 751 571 507 529 390 503 483 710 1 146 938 421 582 975 981 186 118 771 531 328 490 638 452 743 750 511 772 242 957 850 177 669 750 665 975 296 664 228 35 159 763 347 650 752 315 557 366 530 294 828 154 645 730 388 763 744 298 774 459 508 375 449 485 748 537 819 907 526 259 551 773 890 650 523 839 473 645 928 485 333 109 115 403 952 399 229 50 606 377 900 212 693 731 399 682 103 579 441 764 471 481 114 267 196 567 591 353 495 798 436 348 30 794 88 526 926 411 524 1 862 754 839 440 848 839 458 109 961 799 930 944 692 853 168 520 788 579 920 687 32 930 283 575 759 747 857 705 926 842 674 925 233 163 29 544 409 719 266 643 767 315 323 56 754 135 658 99 757 569 818 832 207 296 602 519 316 371 301 409 879 747 765 696 151 960 836 689 526 564 790 33 954 343 548 203 379 545 797 622 550 122 105 606 538 12 686 434 102 595 820 249 642 215 221 120 703 124 972 440 214 444 544 447 963 225 373 904 628 271 733 109 374 193 673 588 446 724 945 246 771 901 389 900 339 331 323 756 245 428 969 565 457 539 977 743 742 26 199 543 960 804 405 795 914 721 454 695 816 984 422 849 437 495 803 237 106 58 221 442 834 638 278 21 697 880 830 818 953 849 276 335 944 152 650 953 232 972 23 675 991 179 741 579 408 164 741 285 682 156 113 71 607 759 740 692 644 284 229 308 681 114 133 961 232 394 214 653 533 240 863 332 115 651 664 396 356 477 308 220 134 283 505 569 286 400 234 413 830 734 534 877 619 293 562 171 862 216 186 819 427 63 491 121 321 139 108 142 438 39 219 345 120 486 367 91 482 400 61 605 780 858 434 854 188 478 141 726 62 600 904 292 312 328 103 648 896 200 304 299 382 372 325 229 625 114 513 95 742 875 432 99 818 510 731 863 353 520 495 501 335 400 411 187 358 612 274 381 658 586 774 908 858 876 162 722 881 604 277 772 677 484 369 964 772 239 973 618 388 463 799 264 262 49 691 800 816 875 827 820 394 828 682 576 571 670 724 322 910 202 12 72 856 529 771 829 520 830 38 796 154 681 662 160 750 193 314 633 772 925 453 769 769 427 318 182 338 552 366 505 82 205 468 486 218 352 542 633 640 612 625 879 69 715 867 233 571 479 818 703 639 866 989 856 285 504 265 981 758 773 920 716 904 698 390 977 336 1 838 563 391 169 692 87 692 17 75 754 691 100 143 605 754 711 844 724 864 261 457 167 640 655 371 554 294 874 777 541 528 902 595 406 774 309 254 322 721 257 638 883 617 278 793 525 779 669 120 144 539 722 106 533 242 187 925 743 221 863 490 284 899 481 186 82 103 102 143 562 306 494 540 352 574 239 885 218 247 551 750 123 859 634 206 391 513 363 361 608 410 390 303 93 353 111 592 472 450 724 395 507 621 494 19 266 184 416 881 330 402 821 999 82 370 613 165 722 572 141 978 361 202 671 975 376 474 878 445 216 925 529 713 499 522 338 891 315 749 712 539 290 382 388 479 806 394 342 273 56 594 213 3 226 359 52 693 637 612 601 792 336 253 223 380 699 189 101 265 812 297 699 635 255 739 885 653 957 165 873 646 883 444 400 982 789 89 6 922 192 990 310 109 159 595 656 884 640 514 876 44 671 288 569 864 108 255 977 237 819 178 417 923 144 231 444 375 452 951 241 947 724 475 569 243 481 646 678 7 282 474 921 830 520 36 961 461 957 333 955 876 359 778 909 128 276 70 914 961 185 606 942 453 373 323 614 270 170 447 745 480 454 499 649 95 468 127 922 436 722 121 202 773 971 307 127 21 11 122 90 305 54 93 266 543 113 931 735 706 931 480 683 306 433 158 155 35 379 343 401 321 880 477 516 226 996 282 778 531 528 722 313 162 975 489 594 406 312 635 106 191 147 180 731 20 249 869 140 336 359 426 266 580 403 569 702 587 740 913 549 197 372 292 585 964 683 340 532 249 592 588 910 280 78 824 675 892 101 642 718 222 393 359 157 714 442 999 851 425 954 487 545 408 504 759 191 509 179 626 774 859 455 335 476 523 573 622 288 518 561 504 812 100 602 433 455 676 565 453 112 282 266 523 642 508 440 558 512 102 109 685 128 291 903 221 254 370 275 300 398 431 341 809 383 622 948 79 813 961 308 972 451 601 390 877 719 988 448 275 184 229 542 902 307 761 587 575 909 442 648 331 424 98 620 512 106 578 411 219 614 577 294 104 81 916 468 84 842 287 96 261 678 34 323 226 943 321 29 906 619 258 924 503 215 929 149 431 56 505 511 876 769 999 994 714 980 416 495 355 79 265 420 37 917 286 53 782 558 868 327 59 926 27 398 704 348 370 773 909 356 969 799 551 282 138 448 808 51 437 417 277 372 806 291 537 818 510 460 945 372 38 127 191 422 100 287 753 341 510 391 317 252 884 629 201 567 164 10 560 632 205 370 353 891 990 609 391 12 889 564 990 74 820 241 356 636 389 309 232 292 654 294 199 45 226 362 645 308 329 955 891 186 180 78 115 842 938 141 141 179 159 401 227 573 372 73 681 562 216 682 184 526 998 530 450 357 296 812 233 398 287 530 613 539 372 523 719 554 377 735 429 854 319 362 445 828 221 506 485 402 519 603 250 490 421 819 638 204 983 664 585 407 434 503 124 512 551 153 135 449 30 673 10 513 682 45 265 32 44 498 168 415 698 151 821 711 179 682 145 800 471 326 376 893 698 885 523 390 992 49 159 949 8 59 83 47 107 871 46 660 610 954 892 352 956 637 12 139 444 517 748 733 502 731 354 368 754 687 197 759 584 292 25 928 197 319 514 359 824 99 458 827 546 681 543 197 160 492 603 634 82 455 456 96 53 399 94 836 702 2 814 614 422 467 161 290 252 506 605 591 8 454 407 46 544 489 42 491 477 772 602 767 359 465 769 970 360 114 959 552 83 945 581 284 26 314 286 153 708 707 444 681 830 400 65 430 22 993 185 327 525 125 321 665 106 538 632 959 552 220 966 17 787 5 561 309 865 997 652 785 678 924 297 772 290 460 322 347 473 811 393 92 283 398 625 349 50 528 385 403 544 404 671 204 430 214 286 798 480 219 430 440 811 240 249 442 223 510 411 590 18 592 468 166 556 542 165 708 93 12 480 893 355 601 822 348 850 431 606 256 367 819 690 188 247 644 766 199 514 384 469 416 412 520 459 261 326 646 746 533 31 972 788 664 465 548 470 257 371 412 633 703 817 525 26 466 6 667 539 532 692 356 891 468 602 709 24 599 275 449 2 674 471 289 683 549 57 177 917 270 954 311 715 991 921 707 115 946 6 745 615 446 646 288 148 725 333 588 933 915 326 828 947 286 350 59 117 598 98 286 436 127 91 461 223 198 334 167 679 506 86 803 254 237 989 878 248 371 416 757 398 721 841 757 761 303 973 24 76 928 749 280 886 194 695 42 134 261 752 134 557 727 345 367 861 380 87 425 685 424 723 17 738 451 902 886 569 920 272 125 239 222 797 361 951 767 273 835 197 696 235 427 247 212 922 706 389 739 480 893 290 877 177 494 450 864 281 392 164 313 799 233 293 416 168 35 860 290 4 989 284 124 710 88 120 431 307 526 515 417 528 442 400 566 108 858 371 47 472 519 147 627 386 644 481 315 168 838 337 675 409 29 130 117 449 959 401 512 963 416 667 729 166 375 843 452 322 749 325 88 978 850 511 91 789 818 993 552 510 741 512 45 836 644 865 136 851 903 711 818 984 933 760 333 461 66 945 285 198 321 726 577 317 952 421 2 278 961 835 995 134 148 805 999 760 542 731 575 657 754 721 135 43 343 755 179 318 372 24 646 577 194 595 277 7 440 530 48 416 257 54 634 772 302 492 789 397 21 532 270 499 145 511 583 600 286 402 628 449 621 577 588 199 485 965 239 765 760 422 709 284 676 962 672 786 760 716 362 511 254 53 626 96 383 488 316 340 19 256 733 680 798 260 693 578 908 810 216 783 485 703 650 965 741 152 44 544 334 880 702 451 887 581 132 476 77 741 661 24 435 858 68 607 943 416 836 936 334 662 5 397 348 452 838 182 801 89 369 781 853 284 969 23 717 482 493 611 560 483 394 221 642 492 641 393 428 491 752 98 710 791 437 615 198 656 146 646 943 218 385 132 934 209 589 863 299 513 941 624 167 648 514 553 724 157 441 389 733 241 236 109 421 607 816 536 363 877 317 508 493 332 782 929 79 535 607 463 877 32 399 637 626 172 511 865 972 560 916 928 599 325 80 809 477 224 724 60 279 524 454 262 960 517 994 216 42 880 969 487 190 977 329 652 916 539 696 271 581 76 660 74 681 768 761 323 108 821 440 224 478 560 373 567 614 417 716 566 178 155 529 994 670 562 987 621 375 161 498 922 527 843 478 495 975 788 528 11 567 713 744 575 268 746 35 802 53 869 789 717 381 437 703 871 177 220 104 638 684 79 807 535 71 525 978 321 576 696 351 928 572 83 414 437 25 75 371 320 338 89 327 376 90 239 363 330 126 12 260 210 284 21 356 403 54 748 551 49 530 530 461 249 640 450 399 153 754 393 548 774 958 602 773 906 417 11 377 188 879 740 486 105 649 426 929 107 848 677 563 913 728 646 700 116 390 148 425 782 564 335 839 584 652 155 707 887 518 489 250 857 979 726 399 113 305 420 402 396 742 479 99 950 753 425 677 88 533 246 804 138 554 76 734 294 472 550 372 415 621 525 76 617 903 821 145 901 876 539 35 91 745 637 871 604 106 811 466 729 694 153 573 100 735 306 660 640 817 927 55 814 852 30 289 741 33 898 193 57 636 260 208 711 172 215 152 790 262 520 92 511 437 726 622 89 709 848 318 269 960 557 940 814 793 286 59 993 529 6 870 415 58 850 578 13 524 261 258 423 695 247 290 512 229 270 485 271 272 118 461 3 757 679 808 830 886 324 913 315 870 414 229 764 386 567 738 32 657 59 336 169 14 821 494 667 815 606 674 20 654 529 482 674 49 476 321 512 661 466 229 869 974 565 205 686 438 466 218 494 567 519 761 257 658 648 546 491 467 102 526 542 542 949 126 608 999 976 867 666 798 421 801 941 825 589 335 871 93 179 491 670 303 464 256 249 318 650 322 168 807 391 513 5 179 770 8 127 960 9 82 561 661 885 176 670 865 468 382 20 811 732 457 709 856 356 713 378 649 306 510 409 963 269 649 988 749 782 208 173 181 679 734 178 884 870 45 763 290 80 228 495 689 736 653 771 325 948 972 985 132 914 770 859 360 382 859 755 781 866 681 922 20 119 628 584 547 584 262 320 62 407 277 831 531 304 979 31 842 194 538 646 77 61 758 245 247 620 175 298 876 315 121 893 185 404 558 222 359 367 901 873 23 109 560 553 819 848 567 509 184 809 188 194 46 405 255 773 333 734 547 283 750 154 115 220 406 551 373 358 851 505 478 961 847 160 661 295 417 489 136 814 192 307 866 976 763 437 255 964 24 786 900 454 727 560 520 814 169 504 882 573 524 550 409 236 567 647 258 155 576 474 508 455 921 718 197 9 331 356 917 344 78 748 204 6 937 187 83 648 138 81 913 314 972 914 286 971 4 677 344 702 326 452 163 407 131 576 560 351 137 701 839 354 475 503 263 606 504 651 919 601 112 709 224 732 714 184 103 261 554 192 766 381 290 388 784 853 447 869 923 504 124 571 923 643 251 323 679 152 847 477 171 796 368 649 80 716 799 771 677 294 270 364 957 253 591 959 17 756 22 121 466 617 401 838 752 350 604 913 393 811 828 646 949 940 328 230 516 794 443 695 136 429 579 657 140 613 803 177 821 829 564 440 560 469 853 961 693 979 382 661 84 630 180 995 626 353 575 616 502 687 264 223 764 64 507 569 575 427 662 619 807 506 663 203 959 978 775 783 317 749 481 3 581 875 320 828 793 317 838 107 671 603 282 524 581 326 619 728 57 91 937 198 182 353 260 226 759 244 140 153 149 387 732 239 427 761 138 339 447 421 278 439 647 82 135 839 824 513 865 117 310 825 838 670 58 183 82 130 212 209 749 118 151 861 978 275 262 273 747 689 916 739 878 689 270 339 358 268 750 966 97 753 161 685 813 174 396 866 70 861 132 866 117 790 737 201 723 209 85 468 821 948 557 182 374 327 912 671 412 444 592 746 567 613 415 561 75 393 631 428 740 976 362 326 504 171 911 753 886 430 738 680 494 839 371 481 979 537 330 333 886 216 669 357 476 107 186 484 302 327 78 400 231 541 159 873 75 744 684 46 592 363 80 944 670 496 811 292 699 545 959 949 299 552 632 683 94 14 418 603 646 370 781 758 364 236 619 107 837 860 106 409 344 492 713 36 398 460 375 730 569 497 733 409 499 577 349 19 652 182 824 768 822 363 207 862 535 911 344 372 868 814 640 68 792 781 674 787 205 182 852 241 725 665 43 187 852 838 615 856 418 632 277 593 654 386 27 805 801 218 328 416 226 76 206 209 81 209 660 31 231 523 569 910 110 815 106 675 739 830 604 534 724 869 379 460 782 549 270 934 324 105 218 841 218 205 739 259 232 572 504 356 66 459 486 504 66 344 873 117 119 261 245 916 621 157 915 220 648 409 630 192 549 440 773 415 816 468 543 475 374 845 446 219 487 999 434 835 304 444 775 698 203 348 715 544 424 206 628 403 760 782 86 651 599 486 973 404 562 614 229 172 396 460 782 434 339 349 88 790 818 925 685 952 922 381 967 723 870 704 94 145 400 308 686 530 288 716 629 867 678 982 554 414 584 942 429 931 608 828 977 599 663 620 867 330 419 200 740 588 225 213 673 146 675 372 302 792 589 299 948 809 16 942 797 262 796 418 591 828 555 532 403 619 694 289 960 801 532 203 918 746 870 127 617 829 350 179 938 326 510 128 432 714 226 948 786 102 866 664 162 302 115 584 714 623 211 829 582 543 173 321 260 47 284 919 133 35 880 614 25 827 768 490 998 825 502 252 275 750 219 716 140 453 758 864 541 563 352 768 197 800 911 670 540 302 307 237 726 76 667 665 322 617 207 118 298 820 283 548 228 381 502 797 990 491 579 250 474 670 784 55 283 729 933 464 255 765 347 807 818 198 594 601 446 374 725 121 591 760 424 480 456 809 974 408 234 876 153 811 540 263 238 535 68 556 21 293 527 613 39 765 761 255 406 596 279 414 772 451 527 258 554 169 958 697 445 127 9 107 607 445 305 695 435 396 487 224 873 671 199 792 739 37 85 859 744 284 947 299 230 755 817 226 827 207 658 882 709 567 303 509 790 73 262 270 917 112 21 949 277 281 559 557 918 668 875 906 308 669 543 479 563 879 311 317 834 534 751 50 275 774 278 200 642 690 293 196 466 780 804 135 866 162 122 916 783 58 631 477 70 878 375 67 425 621 4 826 161 926 147 884 139 717 936 799 140 703 405 284 168 89 144 738 315 418 417 564 439 357 820 73 113 702 163 550 647 144 780 984 34 592 770 696 167 452 666 541 973 314 622 567 986 92 636 301 171 1 812 146 637 673 395 895 583 283 510 380 482 907 953 189 148 513 372 455 923 505 387 525 45 877 630 816 797 119 776 276 540 139 396 560 62 596 502 97 876 431 977 533 867 782 484 844 409 190 46 63 700 102 972 421 110 987 312 58 543 365 657 248 64 613 658 340 605 875 408 746 653 401 898 980 5 449 371 108 496 690 91 672 657 184 816 48 744 121 109 689 849 88 201 982 268 418 569 193 589 630 267 676 690 453 47 496 369 792 677 412 833 95 316 802 957 774 647 966 842 861 233 737 194 260 605 424 266 274 310 874 365 762 411 87 704 477 356 739 554 598 454 107 540 64 641 631 470 444 387 133 277 704 401 226 869 475 299 986 127 831 706 60 899 442 111 414 281 804 579 702 597 587 807 932 755 649 537 844 439 295 979 235 417 821 852 719 546 59 716 607 889 8 851 534 334 926 234 50 184 710 286 152 872 638 132 517 712 21 970 152 801 701 104 438 845 30 966 454 106 37 894 741 276 896 923 274 6 535 339 346 129 141 566 488 386 418 551 160 69 822 586 589 634 443 633 319 466 944 856 704 6 944 438 937 229 47 201 738 283 102 389 305 168 844 760 854 880 827 903 750 612 138 163 658 57 491 622 91 900 233 144 773 113 85 645 399 129 190 497 49 481 85 698 906 604 146 968 653 767 92 130 260 706 288 396 267 268 625 621 6 283 805 992 917 363 985 716 887 900 677 593 892 668 406 40 259 733 572 860 510 154 225 479 575 750 809 938 312 243 36 294 461 973 150 452 226 270 159 66 81 520 247 346 496 58 864 207 395 140 524 438 901 717 491 838 807 85 203 859 541 931 704 764 26 272 912 250 107 512 278 182 910 89 345 242 826 85 687 889 267 112 610 93 445 882 337 532 746 381 689 526 854 696 858 351 778 798 801 255 8 362 200 45 44 203 50 342 520 236 135 228 35 196 421 236 120 689 653 418 692 773 233 898 438 334 32 821 511 419 55 31 449 776 496 617 857 815 691 530 996 105 959 469 403 371 317 309 394 366 207 449 84 902 419 633 361 480 733 987 318 213 722 531 649 600 600 12 954 968 654 436 429 111 169 205 606 331 227 610 943 543 304 146 666 412 998 544 402 459 475 58 269 455 55 388 98 38 243 675 858 172 732 707 188 120 313 959 887 640 719 968 101 752 83 547 477 517 337 908 620 289 869 878 321 738 33 20 817 227 913 469 260 898 138 329 593 23 459 967 159 339 524 681 669 674 216 619 673 740 360 420 302 875 950 539 759 635 430 548 612 239 841 169 323 702 113 374 615 255 457 851 958 721 40 270 495 842 808 745 939 343 484 408 610 554 739 576 539 695 49 535 745 493 117 88 444 554 939 3 665 470 581 133 876 580 268 430 703 436 883 249 448 823 862 3 218 505 85 944 264 81 994 367 673 488 484 506 901 694 847 914 612 426 423 29 971 214 741 589 221 732 20 853 541 995 783 448 983 854 858 446 523 27 418 52 118 73 566 122 438 74 361 354 136 981 399 183 794 888 816 366 863 586 878 388 254 979 430 735 19 922 536 47 750 686 60 545 836 683 828 748 301 678 297 546 493 567 351 514 643 523 58 191 768 418 778 387 273 925 613 651 160 330 859 215 624 750 876 36 138 836 637 906 550 568 46 520 876 928 79 632 400 610 906 380 471 22 163 624 931 822 507 661 49 89 414 874 593 476 958 895 660 910 783 691 341 147 325 751 767 297 194 81 335 633 808 345 726 290 602 550 102 207 345 194 542 217 68 103 290 441 451 239 464 407 987 401 195 300 341 313 797 409 430 471 607 441 82 153 439 511 578 399 634 593 414 630 113 776 448 679 413 346 784 577 320 851 645 584 584 73 603 742 196 165 758 361 624 23 262 626 90 435 943 647 702 446 598 392 993 579 904 41 608 924 979 209 371 654 642 136 776 518 520 787 369 444 518 543 529 824 974 110 415 582 629 651 356 869 903 347 977 345 269 581 549 840 613 433 209 891 407 630 900 509 95 409 510 103 362 194 69 754""" theInput = theInput.split('\n') theInput2 = [i.split(' ') for i in theInput] totalPossible = 0 for triangle in theInput2: triangle.sort() print(triangle) if len(triangle) == 3: side1, side2, side3 = triangle else: nullStr, side1, side2, side3 = triangle if int(side1)+int(side2) > int(side3) and \ int(side1)+int(side3) > int(side2) and \ int(side2)+int(side3) > int(side1): totalPossible += 1 print(totalPossible)
# -*- coding: utf-8 -*- """Holder for shared Configuration""" def init(): """Holder for shared Configuration""" global config try: config except NameError: config = {}
#!/usr/bin/env python3 def validate_script(script): """ Validate compiled script """ assert type(script) == bytes # TODO - more validation
class ContactHelper: def __init__(self, app): self.app = app def open_contacts_page(self): wd = self.app.wd if not (wd.current_url.endswith("/group.php") and len (wd.find_elements_by_name("new"))) > 0: wd.find_element_by_link_text("home").click() def create(self, contact): wd = self.app.wd self.open_contacts_page() # init contact_add wd.find_element_by_link_text("add new").click() self.fill_contact_form(contact) wd.find_element_by_xpath("//div[@id='content']/form/input[21]").click() def change_field_value(self, field_name, text): wd = self.app.wd if text is not None: wd.find_element_by_name(field_name).click() wd.find_element_by_name(field_name).clear() wd.find_element_by_name(field_name).send_keys(text) def fill_contact_form(self, contact): wd = self.app.wd self.change_field_value("firstname", contact.name) self.change_field_value("middlename", contact.midname) self.change_field_value("lastname", contact.lastname) self.change_field_value("nickname", contact.nickname) self.change_field_value("company", contact.company) def test_select_first_contact(self): wd = self.app.wd self.open_contacts_page() # choose check box wd.find_element_by_name("selected[]").click() def test_del_first_contact(self): wd = self.app.wd self.open_contacts_page() # choose check box self.test_select_first_contact() wd.find_element_by_xpath("//div[@id='content']/form[2]/div[2]/input").click() wd.switch_to_alert().accept() def test_modify_first_contact(self, contact): wd = self.app.wd self.open_contacts_page() # choose first contact wd.find_element_by_xpath("//table[@id='maintable']/tbody/tr[2]/td[8]/a/img").click() # fill contact self.fill_contact_form(contact) # click submit wd.find_element_by_xpath("//div[@id='content']/form[1]/input[22]").click() def count(self): wd = self.app.wd self.open_contacts_page() return len(wd.find_elements_by_name("selected[]"))
lista = [] for c in range(0, 5): n = ' ' while n.isnumeric() == False: n = input('digite um número: ') if n.isnumeric() == False: print('o valor digitado não e um número') n = int(n) if c == 0 or n > lista[-1]: lista.append(n) print('adicionado para o final da lista') else: pos = 0 while pos < len(lista): if n <= lista[pos]: lista.insert(pos, n) print(f'adicionado para a posição {pos}') break pos = pos + 1 print(f'os valores digitados em ordem crescente: {lista}')
''' 使用多继承中,我们基本不会使用super()来调用 父类中的任何内容.除非每个父类中的变量和方法 都是独特的 ''' class Point(object): x = 0.0 y = 0.0 def __init__(self, x, y): self.x = x self.y = y print("Point constructor") def ToString(self): return "{X:" + str(self.x) + ",Y:" + str(self.y) + "}" class Size(object): width = 0.0 height = 0.0 def __init__(self, width, height): self.width = width self.height = height print("Size constructor") def ToString(self): return "{WIDTH=" + str(self.width) + \ ",HEIGHT=" + str(self.height) + "}" class Rectangle(Point, Size): def __init__(self, x, y, width, height): Point.__init__(self, x, y) Size.__init__(self, width, height) print("Rectangle constructor") self.x = 10 self.y = 20 def ToString(self): return Point.ToString(self) + "," + Size.ToString(self) r = Rectangle(250, 200, 40, 50) print(r.ToString())
# some sample PROJECT_NAME = "My Application" APPLICATION_SENTENCE = "Hello Django" # add apps into project read after settings.py # append application into lists # INSTALLED_APPS.append('my_application') # MIDDLEWARE.append('my_application.middleware.MyApplicationMiddleware') # add an application INSTALLED_APPS.append("myapplication.apps.MyapplicationConfig")
""" AAn isogram is a word that has no repeating letters, consecutive or non-consecutive. For example "something" and "brother" are isograms, where as "nothing" and "sister" are not. Below method compares the length of the string with the length (or size) of the set of the same string. The set of the string removes all duplicates, therefore if it is equal to the original string, then its an isogram """ # Function to check if string is an isogram def check_isogram(string_to_be_evaluated): if len(string_to_be_evaluated) == len(set(string_to_be_evaluated.lower())): return True return False if __name__ == '__main__': string_one = input("Enter string to check if it's an isogram:") is_isogram = check_isogram(string_one) if check_isogram: print("The string has no repeated letters and is therefore an Isogram.") else: print("The string is not an Isogram.")
__source__ = 'https://leetcode.com/problems/next-greater-element-i/' # Time: O(m + n) # Space: O(m + n) # # Description: 496. Next Greater Element I # # You are given two arrays (without duplicates) nums1 and nums2 where nums1's elements are subset of nums2. # Find all the next greater numbers for nums1's elements in the corresponding places of nums2. # # The Next Greater Number of a number x in nums1 is the first greater number to its right in nums2. # If it does not exist, output -1 for this number. # # Example 1: # Input: nums1 = [4,1,2], nums2 = [1,3,4,2]. # Output: [-1,3,-1] # Explanation: # For number 4 in the first array, you cannot find the next greater number for it in the second array, # so output -1. # For number 1 in the first array, the next greater number for it in the second array is 3. # For number 2 in the first array, there is no next greater number for it in the second array, # so output -1. # # Example 2: # Input: nums1 = [2,4], nums2 = [1,2,3,4]. # Output: [3,-1] # Explanation: # For number 2 in the first array, the next greater number for it in the second array is 3. # For number 4 in the first array, there is no next greater number for it in the second array, so output -1. # # Note: # All elements in nums1 and nums2 are unique. # The length of both nums1 and nums2 would not exceed 1000. # Related Topics # Stack # Similar Questions # Next Greater Element II Next Greater Element III # # 48ms 42.75% class Solution(object): def nextGreaterElement(self, findNums, nums): """ :type findNums: List[int] :type nums: List[int] :rtype: List[int] """ dict = {} st = [] res = [] for n in nums: while len(st) and st[-1] < n: dict[st.pop()] = n st.append(n) for x in findNums: res.append(dict.get(x, -1)) return res # 52ms 34.84% class Solution(object): def nextGreaterElement2(self, findNums, nums): return [next((y for y in nums[nums.index(x):] if y > x), -1) for x in findNums] Java = ''' Thought: https://leetcode.com/problems/next-greater-element-i/solution/ Key observation: Suppose we have a decreasing sequence followed by a greater number For example [5, 4, 3, 2, 1, 6] then the greater number 6 is the next greater element for all previous numbers in the sequence We use a stack to keep a decreasing sub-sequence, whenever we see a number x greater than stack.peek() we pop all elements less than x and for all the popped ones, their next greater element is x For example [9, 8, 7, 3, 2, 1, 6] The stack will first contain [9, 8, 7, 3, 2, 1] and then we see 6 which is greater than 1 so we pop 1 2 3 whose next greater element should be 6 # 5ms 84.38% class Solution { public int[] nextGreaterElement(int[] findNums, int[] nums) { Map<Integer, Integer> map = new HashMap<>(); Stack<Integer> stack = new Stack<>(); for ( int num : nums) { while(!stack.isEmpty() && stack.peek() < num) { map.put(stack.pop(), num); } stack.push(num); } for (int i = 0; i < findNums.length; i++) { findNums[i] = map.getOrDefault(findNums[i], -1); } return findNums; } } # 5ms 84.38% class Solution { public int[] nextGreaterElement(int[] findNums, int[] nums) { Stack < Integer > stack = new Stack < > (); HashMap < Integer, Integer > map = new HashMap < > (); int[] res = new int[findNums.length]; for (int i = 0; i < nums.length; i++) { while (!stack.empty() && nums[i] > stack.peek()) map.put(stack.pop(), nums[i]); stack.push(nums[i]); } while (!stack.empty()) map.put(stack.pop(), -1); for (int i = 0; i < findNums.length; i++) { res[i] = map.get(findNums[i]); } return res; } } # 4ms 91.96% class Solution { public int[] nextGreaterElement(int[] findNums, int[] nums) { if(findNums == null || nums == null || findNums.length > nums.length) return new int[0]; int[] res = new int[findNums.length]; Arrays.fill(res, -1); // key : nums[i], value : position / index Map<Integer, Integer> map = new HashMap<>(); for(int i = 0; i < nums.length; i++){ map.put(nums[i], i); } for(int i = 0; i < res.length; i++){ int startIndex = map.get(findNums[i]); for(int j = startIndex + 1; j < nums.length; j++){ if(nums[j] > findNums[i]){ res[i] = nums[j]; break; } } } return res; } } '''
__all__=["declare_reproducible"] def declare_reproducible(SEED = 123): ''' https://github.com/NVIDIA/framework-determinism/blob/master/pytorch.md ''' # or whatever you choose try : random.seed(SEED) # if you're using random except : pass try : np.random.seed(SEED) # if you're using numpy except : pass try : torch.manual_seed(SEED) # torch.cuda.manual_seed_all(SEED) is not required torch.backends.cudnn.deterministic = True torch.backends.cudnn.benchmark = False except : pass try : tf.set_random_seed(1234) except : pass declare_reproducible()
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': ':memory:' } } SECRET_KEY = 'supersecret' INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'nonrelated_inlines.tests.testapp' ] ROOT_URLCONF = 'nonrelated_inlines.tests.urls' MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware' ] TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'APP_DIRS': True, }]
class Solution: def buildTree(self, preorder, inorder): if not inorder: return None root_val = preorder[0] index = inorder.index(root_val) left_tree = self.buildTree(preorder[1:index + 1], inorder[:index]) right_tree = self.buildTree(preorder[index + 1:], inorder[index + 1:]) root = TreeNode(root_val) root.left = left_tree root.right = right_tree return root
num1 = int(input()) num2 = int(input()) print(f'X = {num1 + num2}')
def PeptideMasses(PeptideMassesSummaryFileName, PeptidesListFileLocation): # 'amino acid', monoisotopic residue mass, average residue mass AAResidueMassData = {'A':('Ala', 71.037114, 71.0779), 'C':('Cys', 103.009185, 103.1429), 'D':('Asp', 115.026943, 115.0874), 'E':('Glu', 129.042593, 129.114), 'F':('Phe', 147.068414, 147.1739), 'G':('Gly', 57.021464, 57.0513), 'H':('His', 137.058912, 137.1393), 'I':('Ile', 113.084064, 113.1576), 'K':('Lys', 128.094963, 128.1723), 'L':('Leu', 113.084064, 113.1576), 'M':('Met', 131.040485, 131.1961), 'N':('Asn', 114.042927, 114.1026), 'P':('Pro', 97.052764, 97.1152), 'Q':('Gln', 128.058578, 128.1292), 'R':('Arg', 156.101111, 156.1857), 'S':('Ser', 87.032028, 87.0773), 'T':('Thr', 101.047679, 101.1039), 'V':('Val', 99.068414, 99.1311), 'W':('Trp', 186.079313, 186.2099), 'Y':('Tyr', 163.06332, 163.1733), 'y':('D-Tyr', 163.06332, 163.1733), 'X':('HONH-Glu',144.05349, 144.1300), 'Z':('HONH-ASub',186.10044, 186.2110) } PeptidesListFile = open(PeptidesListFileLocation, 'r') Lines = PeptidesListFile.readlines() PeptidesListFile.close # print Lines PeptideMassesFile = open(PeptideMassesSummaryFileName, 'w') PeptideMassesFile.write('#' + ',' + 'peptide' + ',' + 'MI linear (Da)' + ',' + 'A linear (Da)' + ',' + 'MI cyclic (Da)' + ',' + 'A cyclic (Da)' + ',' + 'Ext 280nm (1/M*cm)''\n') PeptideNumber = 0 for Line in Lines: Peptide = Line.strip('\n') PeptideNumber += 1 LinearPeptideMIM = 17.02655 LinearPeptideAM = 17.0310 CysExt = 110.0 TrpExt = 5630.0 TyrExt = 1215.0 #uses the data from this paper http://www.ncbi.nlm.nih.gov/pmc/articles/PMC2143013/pdf/8563639.pdf #alternatively these data can be used http://www.rpgroup.caltech.edu/courses/aph162/2007/pdf/articles/Gill1989.pdf CysCount = 0 TrpCount = 0 TyrCount = 0 for i in range(len(Peptide)): LinearPeptideMIM += AAResidueMassData[Peptide[i]][1] LinearPeptideAM += AAResidueMassData[Peptide[i]][2] if Peptide[i] == 'C': CysCount += 1 elif Peptide[i] == 'W': TrpCount += 1 elif Peptide[i] == 'Y' or Peptide[i] == 'y': TyrCount += 1 CyclicPeptideMIM = LinearPeptideMIM + 42.01056 #print MICyclic CyclicPeptideAM = LinearPeptideAM + 42.0370 #print ACyclic PeptideExt = CysCount * CysExt + TrpCount *TrpExt + TyrCount * TyrExt # PeptideMassesFile.write(str(PeptideNumber) + ',' + Peptide + ',' + '{:.2f}'.format(LinearPeptideMIM) + ',' + '{:.2f}'.format(LinearPeptideAM) + ',' + '{:.2f}'.format(CyclicPeptideMIM) + ',' + '{:.2f}'.format(CyclicPeptideAM) + ',' + '{:.0f}'.format(PeptideExt) + '\n') PeptideMassesFile.close #_____________________________RUNNING THE FUNCTION_____________________________# #___PeptideMassesSummaryFileName, PeptidesListFileLocation___ PeptideMasses('CloneMasses Result Test.csv', '/Users/NikitaLoik/CloneSynthesis.txt')
""" Given a sequence of n integers a1, a2, ..., an, a 132 pattern is a subsequence ai, aj, ak such that i < j < k and ai < ak < aj. Design an algorithm that takes a list of n numbers as input and checks whether there is a 132 pattern in the list. Note: n will be less than 15,000. Example 1: Input: [1, 2, 3, 4] Output: False Explanation: There is no 132 pattern in the sequence. Example 2: Input: [3, 1, 4, 2] Output: True Explanation: There is a 132 pattern in the sequence: [1, 4, 2]. Example 3: Input: [-1, 3, 2, 0] Output: True Explanation: There are three 132 patterns in the sequence: [-1, 3, 2], [-1, 3, 0] and [-1, 2, 0]. Solution: 1. Brute Force O(n^3) 2. Better Brute Force O(n^2) 3. Monotonous Stack 站内元素都是单调递增或者单调递减 https://www.cnblogs.com/grandyang/p/8887985.html 维护一个单调栈和一个变量 third (第三个数字,中间值),栈中存放所有大于 third 的数字,也就是 second (第二个数字,最大值) 从后往前遍历,如果当前元素大于栈顶元素,说明栈顶元素非最大,将其退栈,赋给 third. 栈里存放的都是可以维持 second > third 的 second 值. 如果当前元素小于 third,并且栈非空,那么说明找到了 132 pattern. """ # Brute Force # Time: O(n^3) # Space: O(1) class Solution: def find132pattern(self, nums: List[int]) -> bool: l = len(nums) for i in range(l-2): for j in range(i+1, l-1): for k in range(j+1, l): if nums[i] < nums[k] < nums[j]: return True return False # Better Brute Force # Fix a number 'ai', two for loops # Time: O(n^2) # Space: O(1) class Solution: def find132pattern(self, nums: List[int]) -> bool: l = len(nums) mn = float('inf') for j in range(l-1): mn = min(mn, nums[j]) # mn, the smallest one, 'ai' if mn == nums[j]: continue for k in range(j+1, l): if mn < nums[k] < nums[j]: return True return False # Monotonous Stack # Time: O(N) # Space: O(N) at worst case class Solution: def find132pattern(self, nums: List[int]) -> bool: # 1 3 2 # i j k # ai < ak < aj l = len(nums) third = float('-inf') # aj stack = [] for i in range(l-1, -1, -1): # ai # why scan backwords? make sure third (aj) come from elements after ai if nums[i] < third: # third was updated, it means there is a number bigger than top of the stack, and the index of that number is prior to top of the stack (third) # we found ai < ak < aj return True while stack and nums[i] > stack[-1]: third = stack[-1] stack.pop() stack.append(nums[i]) return False
# Multiplying strings and accessing characters within them # You can print a string multiple times by... multiplying it! print("-" * 10) # Since strings are basically a list, you can also access characters # or ranges of characters by indexing into them name = "Phil Hinton" print(f"Name: {name}") # First character print(name[0])
# TWITTER ACCESS_KEY = (" ") ACCESS_SECRET = (" ") CONSUMER_KEY = (" ") CONSUMER_SECRET = (" ") BEARER_TOKEN = (" ") # TELEGRAM API_KEY = (" ") BOT_CHAT_ID = (" ") # DISCORD APPLICATION_ID = (" ") PUBLIC_KEY = (" ") CLIENT_ID = (" ") CLIENT_SECRET = (" ") TOKEN = (" ") invite_url = (" ") # tweets baixados tweets = [] # numero de tweets baixados number = 0
SESSION_EXPIRED = "Session expired. Please log in again." NETWORK_ERROR_MESSAGE = ( "Network error. Please check your connection and try again." ) AUTH_SERVER_ERROR = ( "A problem occured while trying to authenticate with divio.com. " "Please try again later" ) SERVER_ERROR = ( "A problem occured while trying to communicate with divio.com. " "Please try again later" ) AUTH_INVALID_TOKEN = "Login failed. Invalid token specified" RESOURCE_NOT_FOUND_ANONYMOUS = "Resource not found" RESOURCE_NOT_FOUND = "Resource not found. You are logged in as '{login}', please check if you have permissions to access the ressource" LOGIN_SUCCESSFUL = ( u"Welcome to Divio Cloud. You are now logged in as {greeting}" ) CONFIG_FILE_NOT_FOUND = u"Config file could not be not found at location: {}" FILE_NOT_FOUND = u"File could not be found: {}" INVALID_DB_SUBMITTED = ( "The database dump you have uploaded contains an error. " "Please check the file 'db_upload.log' for errors and try again" ) LOGIN_CHECK_SUCCESSFUL = ( "Authentication with server successful. You are logged in." ) LOGIN_CHECK_ERROR = ( "You are currently not logged in, " "please log in using `divio login`." ) PUSH_DB_WARNING = "\n".join( ( "WARNING", "=======", "\nYou are about to push your local database to the {stage} server on ", "the Divio Cloud. This will replace ALL data on the Divio Cloud {stage} ", "server with the data you are about to push, including (but not limited to):", " - User accounts", " - CMS Pages & Plugins", "\nYou will also lose any changes that have been made on the {stage} ", "server since you pulled its database to your local environment. ", "\nIt is recommended to go the project settings on control.divio.com", "and take a backup before restoring the database. You can find this ", 'action in the "Manage Project" section.', "\nPlease proceed with caution!", ) ) PUSH_MEDIA_WARNING = "\n".join( ( "WARNING", "=======", "\nYou are about to push your local media files to the {stage} server on ", "the Divio Cloud. This will replace ALL existing media files with the ", "ones you are about to push.", "\nYou will also lose any changes that have been made on the {stage} ", "server since you pulled its files to your local environment. ", "\nIt is recommended to go the project settings on control.divio.com", "and take a backup before restoring media files. You can find this ", 'action in the "Manage Project" section.', "\nPlease proceed with caution!", ) )
class FileType: CSV = 'csv' XLSX = 'xlsx' JSON = 'json' XML = 'xml'
# -*- coding: utf-8 -*- countries_data = [ { 'name': u'Afghanistan', 'alpha2': u'AF', 'alpha3': u'AFG', 'numeric': 4, 'independent': True, }, { 'name': u'Åland Islands', 'alpha2': u'AX', 'alpha3': u'ALA', 'numeric': 248, 'independent': False, }, { 'name': u'Albania', 'alpha2': u'AL', 'alpha3': u'ALB', 'numeric': 8, 'independent': True, }, { 'name': u'Algeria', 'alpha2': u'DZ', 'alpha3': u'DZA', 'numeric': 12, 'independent': True, }, { 'name': u'American Samoa', 'alpha2': u'AS', 'alpha3': u'ASM', 'numeric': 16, 'independent': False, }, { 'name': u'Andorra', 'alpha2': u'AD', 'alpha3': u'AND', 'numeric': 20, 'independent': True, }, { 'name': u'Angola', 'alpha2': u'AO', 'alpha3': u'AGO', 'numeric': 24, 'independent': True, }, { 'name': u'Anguilla', 'alpha2': u'AI', 'alpha3': u'AIA', 'numeric': 660, 'independent': False, }, { 'name': u'Antarctica', 'alpha2': u'AQ', 'alpha3': u'ATA', 'numeric': 10, 'independent': False, }, { 'name': u'Antigua and Barbuda', 'alpha2': u'AG', 'alpha3': u'ATG', 'numeric': 28, 'independent': True, }, { 'name': u'Argentina', 'alpha2': u'AR', 'alpha3': u'ARG', 'numeric': 32, 'independent': True, }, { 'name': u'Armenia', 'alpha2': u'AM', 'alpha3': u'ARM', 'numeric': 51, 'independent': True, }, { 'name': u'Aruba', 'alpha2': u'AW', 'alpha3': u'ABW', 'numeric': 533, 'independent': False, }, { 'name': u'Australia', 'alpha2': u'AU', 'alpha3': u'AUS', 'numeric': 36, 'independent': True, }, { 'name': u'Austria', 'alpha2': u'AT', 'alpha3': u'AUT', 'numeric': 40, 'independent': True, }, { 'name': u'Azerbaijan', 'alpha2': u'AZ', 'alpha3': u'AZE', 'numeric': 31, 'independent': True, }, { 'name': u'Bahamas', 'alpha2': u'BS', 'alpha3': u'BHS', 'numeric': 44, 'independent': True, }, { 'name': u'Bahrain', 'alpha2': u'BH', 'alpha3': u'BHR', 'numeric': 48, 'independent': True, }, { 'name': u'Bangladesh', 'alpha2': u'BD', 'alpha3': u'BGD', 'numeric': 50, 'independent': True, }, { 'name': u'Barbados', 'alpha2': u'BB', 'alpha3': u'BRB', 'numeric': 52, 'independent': True, }, { 'name': u'Belarus', 'alpha2': u'BY', 'alpha3': u'BLR', 'numeric': 112, 'independent': True, }, { 'name': u'Belgium', 'alpha2': u'BE', 'alpha3': u'BEL', 'numeric': 56, 'independent': True, }, { 'name': u'Belize', 'alpha2': u'BZ', 'alpha3': u'BLZ', 'numeric': 84, 'independent': True, }, { 'name': u'Benin', 'alpha2': u'BJ', 'alpha3': u'BEN', 'numeric': 204, 'independent': True, }, { 'name': u'Bermuda', 'alpha2': u'BM', 'alpha3': u'BMU', 'numeric': 60, 'independent': False, }, { 'name': u'Bhutan', 'alpha2': u'BT', 'alpha3': u'BTN', 'numeric': 64, 'independent': True, }, { 'name': u'Bolivia (Plurinational State of)', 'alpha2': u'BO', 'alpha3': u'BOL', 'numeric': 68, 'independent': True, }, { 'name': u'"Bonaire, Sint Eustatius and Saba"', 'alpha2': u'BQ', 'alpha3': u'BES', 'numeric': 535, 'independent': False, }, { 'name': u'Bosnia and Herzegovina', 'alpha2': u'BA', 'alpha3': u'BIH', 'numeric': 70, 'independent': True, }, { 'name': u'Botswana', 'alpha2': u'BW', 'alpha3': u'BWA', 'numeric': 72, 'independent': True, }, { 'name': u'Bouvet Island', 'alpha2': u'BV', 'alpha3': u'BVT', 'numeric': 74, 'independent': False, }, { 'name': u'Brazil', 'alpha2': u'BR', 'alpha3': u'BRA', 'numeric': 76, 'independent': True, }, { 'name': u'British Indian Ocean Territory', 'alpha2': u'IO', 'alpha3': u'IOT', 'numeric': 86, 'independent': False, }, { 'name': u'Brunei Darussalam', 'alpha2': u'BN', 'alpha3': u'BRN', 'numeric': 96, 'independent': True, }, { 'name': u'Bulgaria', 'alpha2': u'BG', 'alpha3': u'BGR', 'numeric': 100, 'independent': True, }, { 'name': u'Burkina Faso', 'alpha2': u'BF', 'alpha3': u'BFA', 'numeric': 854, 'independent': True, }, { 'name': u'Burundi', 'alpha2': u'BI', 'alpha3': u'BDI', 'numeric': 108, 'independent': True, }, { 'name': u'Cabo Verde', 'alpha2': u'CV', 'alpha3': u'CPV', 'numeric': 132, 'independent': True, }, { 'name': u'Cambodia', 'alpha2': u'KH', 'alpha3': u'KHM', 'numeric': 116, 'independent': True, }, { 'name': u'Cameroon', 'alpha2': u'CM', 'alpha3': u'CMR', 'numeric': 120, 'independent': True, }, { 'name': u'Canada', 'alpha2': u'CA', 'alpha3': u'CAN', 'numeric': 124, 'independent': True, }, { 'name': u'Cayman Islands', 'alpha2': u'KY', 'alpha3': u'CYM', 'numeric': 136, 'independent': True, }, { 'name': u'Central African Republic', 'alpha2': u'CF', 'alpha3': u'CAF', 'numeric': 140, 'independent': True, }, { 'name': u'Chad', 'alpha2': u'TD', 'alpha3': u'TCD', 'numeric': 148, 'independent': True, }, { 'name': u'Chile', 'alpha2': u'CL', 'alpha3': u'CHL', 'numeric': 152, 'independent': True, }, { 'name': u'China', 'alpha2': u'CN', 'alpha3': u'CHN', 'numeric': 156, 'independent': True, }, { 'name': u'Christmas Island', 'alpha2': u'CX', 'alpha3': u'CXR', 'numeric': 162, 'independent': False, }, { 'name': u'Cocos (Keeling) Islands', 'alpha2': u'CC', 'alpha3': u'CCK', 'numeric': 166, 'independent': False, }, { 'name': u'Colombia', 'alpha2': u'CO', 'alpha3': u'COL', 'numeric': 170, 'independent': True, }, { 'name': u'Comoros', 'alpha2': u'KM', 'alpha3': u'COM', 'numeric': 174, 'independent': True, }, { 'name': u'Congo', 'alpha2': u'CG', 'alpha3': u'COG', 'numeric': 178, 'independent': True, }, { 'name': u'Congo (Democratic Republic of the)', 'alpha2': u'CD', 'alpha3': u'COD', 'numeric': 180, 'independent': True, }, { 'name': u'Cook Islands', 'alpha2': u'CK', 'alpha3': u'COK', 'numeric': 184, 'independent': False, }, { 'name': u'Costa Rica', 'alpha2': u'CR', 'alpha3': u'CRI', 'numeric': 188, 'independent': True, }, { 'name': u'Côte d\'Ivoire', 'alpha2': u'CI', 'alpha3': u'CIV', 'numeric': 384, 'independent': True, }, { 'name': u'Croatia', 'alpha2': u'HR', 'alpha3': u'HRV', 'numeric': 191, 'independent': True, }, { 'name': u'Cuba', 'alpha2': u'CU', 'alpha3': u'CUB', 'numeric': 192, 'independent': True, }, { 'name': u'Curaçao', 'alpha2': u'CW', 'alpha3': u'CUW', 'numeric': 531, 'independent': False, }, { 'name': u'Cyprus', 'alpha2': u'CY', 'alpha3': u'CYP', 'numeric': 196, 'independent': True, }, { 'name': u'Czechia', 'alpha2': u'CZ', 'alpha3': u'CZE', 'numeric': 203, 'independent': True, }, { 'name': u'Denmark', 'alpha2': u'DK', 'alpha3': u'DNK', 'numeric': 208, 'independent': True, }, { 'name': u'Djibouti', 'alpha2': u'DJ', 'alpha3': u'DJI', 'numeric': 262, 'independent': True, }, { 'name': u'Dominica', 'alpha2': u'DM', 'alpha3': u'DMA', 'numeric': 212, 'independent': True, }, { 'name': u'Dominican Republic', 'alpha2': u'DO', 'alpha3': u'DOM', 'numeric': 214, 'independent': True, }, { 'name': u'Ecuador', 'alpha2': u'EC', 'alpha3': u'ECU', 'numeric': 218, 'independent': True, }, { 'name': u'Egypt', 'alpha2': u'EG', 'alpha3': u'EGY', 'numeric': 818, 'independent': True, }, { 'name': u'El Salvador', 'alpha2': u'SV', 'alpha3': u'SLV', 'numeric': 222, 'independent': True, }, { 'name': u'Equatorial Guinea', 'alpha2': u'GQ', 'alpha3': u'GNQ', 'numeric': 226, 'independent': True, }, { 'name': u'Eritrea', 'alpha2': u'ER', 'alpha3': u'ERI', 'numeric': 232, 'independent': True, }, { 'name': u'Estonia', 'alpha2': u'EE', 'alpha3': u'EST', 'numeric': 233, 'independent': True, }, { 'name': u'Ethiopia', 'alpha2': u'ET', 'alpha3': u'ETH', 'numeric': 231, 'independent': True, }, { 'name': u'Falkland Islands (Malvinas)', 'alpha2': u'FK', 'alpha3': u'FLK', 'numeric': 238, 'independent': False, }, { 'name': u'Faroe Islands', 'alpha2': u'FO', 'alpha3': u'FRO', 'numeric': 234, 'independent': False, }, { 'name': u'Fiji', 'alpha2': u'FJ', 'alpha3': u'FJI', 'numeric': 242, 'independent': True, }, { 'name': u'Finland', 'alpha2': u'FI', 'alpha3': u'FIN', 'numeric': 246, 'independent': True, }, { 'name': u'France', 'alpha2': u'FR', 'alpha3': u'FRA', 'numeric': 250, 'independent': True, }, { 'name': u'French Guiana', 'alpha2': u'GF', 'alpha3': u'GUF', 'numeric': 254, 'independent': False, }, { 'name': u'French Polynesia', 'alpha2': u'PF', 'alpha3': u'PYF', 'numeric': 258, 'independent': False, }, { 'name': u'French Southern Territories', 'alpha2': u'TF', 'alpha3': u'ATF', 'numeric': 260, 'independent': False, }, { 'name': u'Gabon', 'alpha2': u'GA', 'alpha3': u'GAB', 'numeric': 266, 'independent': True, }, { 'name': u'Gambia', 'alpha2': u'GM', 'alpha3': u'GMB', 'numeric': 270, 'independent': True, }, { 'name': u'Georgia', 'alpha2': u'GE', 'alpha3': u'GEO', 'numeric': 268, 'independent': True, }, { 'name': u'Germany', 'alpha2': u'DE', 'alpha3': u'DEU', 'numeric': 276, 'independent': True, }, { 'name': u'Ghana', 'alpha2': u'GH', 'alpha3': u'GHA', 'numeric': 288, 'independent': True, }, { 'name': u'Gibraltar', 'alpha2': u'GI', 'alpha3': u'GIB', 'numeric': 292, 'independent': True, }, { 'name': u'Greece', 'alpha2': u'GR', 'alpha3': u'GRC', 'numeric': 300, 'independent': True, }, { 'name': u'Greenland', 'alpha2': u'GL', 'alpha3': u'GRL', 'numeric': 304, 'independent': False, }, { 'name': u'Grenada', 'alpha2': u'GD', 'alpha3': u'GRD', 'numeric': 308, 'independent': True, }, { 'name': u'Guadeloupe', 'alpha2': u'GP', 'alpha3': u'GLP', 'numeric': 312, 'independent': False, }, { 'name': u'Guam', 'alpha2': u'GU', 'alpha3': u'GUM', 'numeric': 316, 'independent': False, }, { 'name': u'Guatemala', 'alpha2': u'GT', 'alpha3': u'GTM', 'numeric': 320, 'independent': True, }, { 'name': u'Guernsey', 'alpha2': u'GG', 'alpha3': u'GGY', 'numeric': 831, 'independent': False, }, { 'name': u'Guinea', 'alpha2': u'GN', 'alpha3': u'GIN', 'numeric': 324, 'independent': True, }, { 'name': u'Guinea-Bissau', 'alpha2': u'GW', 'alpha3': u'GNB', 'numeric': 624, 'independent': True, }, { 'name': u'Guyana', 'alpha2': u'GY', 'alpha3': u'GUY', 'numeric': 328, 'independent': True, }, { 'name': u'Haiti', 'alpha2': u'HT', 'alpha3': u'HTI', 'numeric': 332, 'independent': True, }, { 'name': u'Heard Island and McDonald Islands', 'alpha2': u'HM', 'alpha3': u'HMD', 'numeric': 334, 'independent': False, }, { 'name': u'Holy See', 'alpha2': u'VA', 'alpha3': u'VAT', 'numeric': 336, 'independent': True, }, { 'name': u'Honduras', 'alpha2': u'HN', 'alpha3': u'HND', 'numeric': 340, 'independent': True, }, { 'name': u'Hong Kong', 'alpha2': u'HK', 'alpha3': u'HKG', 'numeric': 344, 'independent': False, }, { 'name': u'Hungary', 'alpha2': u'HU', 'alpha3': u'HUN', 'numeric': 348, 'independent': True, }, { 'name': u'Iceland', 'alpha2': u'IS', 'alpha3': u'ISL', 'numeric': 352, 'independent': True, }, { 'name': u'India', 'alpha2': u'IN', 'alpha3': u'IND', 'numeric': 356, 'independent': True, }, { 'name': u'Indonesia', 'alpha2': u'ID', 'alpha3': u'IDN', 'numeric': 360, 'independent': True, }, { 'name': u'Iran (Islamic Republic of)', 'alpha2': u'IR', 'alpha3': u'IRN', 'numeric': 364, 'independent': True, }, { 'name': u'Iraq', 'alpha2': u'IQ', 'alpha3': u'IRQ', 'numeric': 368, 'independent': True, }, { 'name': u'Ireland', 'alpha2': u'IE', 'alpha3': u'IRL', 'numeric': 372, 'independent': True, }, { 'name': u'Isle of Man', 'alpha2': u'IM', 'alpha3': u'IMN', 'numeric': 833, 'independent': False, }, { 'name': u'Israel', 'alpha2': u'IL', 'alpha3': u'ISR', 'numeric': 376, 'independent': True, }, { 'name': u'Italy', 'alpha2': u'IT', 'alpha3': u'ITA', 'numeric': 380, 'independent': True, }, { 'name': u'Jamaica', 'alpha2': u'JM', 'alpha3': u'JAM', 'numeric': 388, 'independent': True, }, { 'name': u'Japan', 'alpha2': u'JP', 'alpha3': u'JPN', 'numeric': 392, 'independent': True, }, { 'name': u'Jersey', 'alpha2': u'JE', 'alpha3': u'JEY', 'numeric': 832, 'independent': False, }, { 'name': u'Jordan', 'alpha2': u'JO', 'alpha3': u'JOR', 'numeric': 400, 'independent': True, }, { 'name': u'Kazakhstan', 'alpha2': u'KZ', 'alpha3': u'KAZ', 'numeric': 398, 'independent': True, }, { 'name': u'Kenya', 'alpha2': u'KE', 'alpha3': u'KEN', 'numeric': 404, 'independent': True, }, { 'name': u'Kiribati', 'alpha2': u'KI', 'alpha3': u'KIR', 'numeric': 296, 'independent': True, }, { 'name': u'Korea (Democratic People\'s Republic of)', 'alpha2': u'KP', 'alpha3': u'PRK', 'numeric': 408, 'independent': True, }, { 'name': u'Korea (Republic of)', 'alpha2': u'KR', 'alpha3': u'KOR', 'numeric': 410, 'independent': True, }, { 'name': u'Kuwait', 'alpha2': u'KW', 'alpha3': u'KWT', 'numeric': 414, 'independent': True, }, { 'name': u'Kyrgyzstan', 'alpha2': u'KG', 'alpha3': u'KGZ', 'numeric': 417, 'independent': True, }, { 'name': u'Lao People\'s Democratic Republic', 'alpha2': u'LA', 'alpha3': u'LAO', 'numeric': 418, 'independent': True, }, { 'name': u'Latvia', 'alpha2': u'LV', 'alpha3': u'LVA', 'numeric': 428, 'independent': True, }, { 'name': u'Lebanon', 'alpha2': u'LB', 'alpha3': u'LBN', 'numeric': 422, 'independent': True, }, { 'name': u'Lesotho', 'alpha2': u'LS', 'alpha3': u'LSO', 'numeric': 426, 'independent': True, }, { 'name': u'Liberia', 'alpha2': u'LR', 'alpha3': u'LBR', 'numeric': 430, 'independent': True, }, { 'name': u'Libya', 'alpha2': u'LY', 'alpha3': u'LBY', 'numeric': 434, 'independent': True, }, { 'name': u'Liechtenstein', 'alpha2': u'LI', 'alpha3': u'LIE', 'numeric': 438, 'independent': True, }, { 'name': u'Lithuania', 'alpha2': u'LT', 'alpha3': u'LTU', 'numeric': 440, 'independent': True, }, { 'name': u'Luxembourg', 'alpha2': u'LU', 'alpha3': u'LUX', 'numeric': 442, 'independent': True, }, { 'name': u'Macao', 'alpha2': u'MO', 'alpha3': u'MAC', 'numeric': 446, 'independent': False, }, { 'name': u'Macedonia (the former Yugoslav Republic of)', 'alpha2': u'MK', 'alpha3': u'MKD', 'numeric': 807, 'independent': True, }, { 'name': u'Madagascar', 'alpha2': u'MG', 'alpha3': u'MDG', 'numeric': 450, 'independent': True, }, { 'name': u'Malawi', 'alpha2': u'MW', 'alpha3': u'MWI', 'numeric': 454, 'independent': True, }, { 'name': u'Malaysia', 'alpha2': u'MY', 'alpha3': u'MYS', 'numeric': 458, 'independent': True, }, { 'name': u'Maldives', 'alpha2': u'MV', 'alpha3': u'MDV', 'numeric': 462, 'independent': True, }, { 'name': u'Mali', 'alpha2': u'ML', 'alpha3': u'MLI', 'numeric': 466, 'independent': True, }, { 'name': u'Malta', 'alpha2': u'MT', 'alpha3': u'MLT', 'numeric': 470, 'independent': True, }, { 'name': u'Marshall Islands', 'alpha2': u'MH', 'alpha3': u'MHL', 'numeric': 584, 'independent': True, }, { 'name': u'Martinique', 'alpha2': u'MQ', 'alpha3': u'MTQ', 'numeric': 474, 'independent': False, }, { 'name': u'Mauritania', 'alpha2': u'MR', 'alpha3': u'MRT', 'numeric': 478, 'independent': True, }, { 'name': u'Mauritius', 'alpha2': u'MU', 'alpha3': u'MUS', 'numeric': 480, 'independent': True, }, { 'name': u'Mayotte', 'alpha2': u'YT', 'alpha3': u'MYT', 'numeric': 175, 'independent': False, }, { 'name': u'Mexico', 'alpha2': u'MX', 'alpha3': u'MEX', 'numeric': 484, 'independent': True, }, { 'name': u'Micronesia (Federated States of)', 'alpha2': u'FM', 'alpha3': u'FSM', 'numeric': 583, 'independent': True, }, { 'name': u'Moldova (Republic of)', 'alpha2': u'MD', 'alpha3': u'MDA', 'numeric': 498, 'independent': True, }, { 'name': u'Monaco', 'alpha2': u'MC', 'alpha3': u'MCO', 'numeric': 492, 'independent': True, }, { 'name': u'Mongolia', 'alpha2': u'MN', 'alpha3': u'MNG', 'numeric': 496, 'independent': True, }, { 'name': u'Montenegro', 'alpha2': u'ME', 'alpha3': u'MNE', 'numeric': 499, 'independent': True, }, { 'name': u'Montserrat', 'alpha2': u'MS', 'alpha3': u'MSR', 'numeric': 500, 'independent': False, }, { 'name': u'Morocco', 'alpha2': u'MA', 'alpha3': u'MAR', 'numeric': 504, 'independent': True, }, { 'name': u'Mozambique', 'alpha2': u'MZ', 'alpha3': u'MOZ', 'numeric': 508, 'independent': True, }, { 'name': u'Myanmar', 'alpha2': u'MM', 'alpha3': u'MMR', 'numeric': 104, 'independent': True, }, { 'name': u'Namibia', 'alpha2': u'NA', 'alpha3': u'NAM', 'numeric': 516, 'independent': True, }, { 'name': u'Nauru', 'alpha2': u'NR', 'alpha3': u'NRU', 'numeric': 520, 'independent': True, }, { 'name': u'Nepal', 'alpha2': u'NP', 'alpha3': u'NPL', 'numeric': 524, 'independent': True, }, { 'name': u'Netherlands', 'alpha2': u'NL', 'alpha3': u'NLD', 'numeric': 528, 'independent': True, }, { 'name': u'New Caledonia', 'alpha2': u'NC', 'alpha3': u'NCL', 'numeric': 540, 'independent': False, }, { 'name': u'New Zealand', 'alpha2': u'NZ', 'alpha3': u'NZL', 'numeric': 554, 'independent': True, }, { 'name': u'Nicaragua', 'alpha2': u'NI', 'alpha3': u'NIC', 'numeric': 558, 'independent': True, }, { 'name': u'Niger', 'alpha2': u'NE', 'alpha3': u'NER', 'numeric': 562, 'independent': True, }, { 'name': u'Nigeria', 'alpha2': u'NG', 'alpha3': u'NGA', 'numeric': 566, 'independent': True, }, { 'name': u'Niue', 'alpha2': u'NU', 'alpha3': u'NIU', 'numeric': 570, 'independent': False, }, { 'name': u'Norfolk Island', 'alpha2': u'NF', 'alpha3': u'NFK', 'numeric': 574, 'independent': False, }, { 'name': u'Northern Mariana Islands', 'alpha2': u'MP', 'alpha3': u'MNP', 'numeric': 580, 'independent': False, }, { 'name': u'Norway', 'alpha2': u'NO', 'alpha3': u'NOR', 'numeric': 578, 'independent': True, }, { 'name': u'Oman', 'alpha2': u'OM', 'alpha3': u'OMN', 'numeric': 512, 'independent': True, }, { 'name': u'Pakistan', 'alpha2': u'PK', 'alpha3': u'PAK', 'numeric': 586, 'independent': True, }, { 'name': u'Palau', 'alpha2': u'PW', 'alpha3': u'PLW', 'numeric': 585, 'independent': True, }, { 'name': u'"Palestine, State of"', 'alpha2': u'PS', 'alpha3': u'PSE', 'numeric': 275, 'independent': False, }, { 'name': u'Panama', 'alpha2': u'PA', 'alpha3': u'PAN', 'numeric': 591, 'independent': True, }, { 'name': u'Papua New Guinea', 'alpha2': u'PG', 'alpha3': u'PNG', 'numeric': 598, 'independent': True, }, { 'name': u'Paraguay', 'alpha2': u'PY', 'alpha3': u'PRY', 'numeric': 600, 'independent': True, }, { 'name': u'Peru', 'alpha2': u'PE', 'alpha3': u'PER', 'numeric': 604, 'independent': True, }, { 'name': u'Philippines', 'alpha2': u'PH', 'alpha3': u'PHL', 'numeric': 608, 'independent': True, }, { 'name': u'Pitcairn', 'alpha2': u'PN', 'alpha3': u'PCN', 'numeric': 612, 'independent': False, }, { 'name': u'Poland', 'alpha2': u'PL', 'alpha3': u'POL', 'numeric': 616, 'independent': True, }, { 'name': u'Portugal', 'alpha2': u'PT', 'alpha3': u'PRT', 'numeric': 620, 'independent': True, }, { 'name': u'Puerto Rico', 'alpha2': u'PR', 'alpha3': u'PRI', 'numeric': 630, 'independent': False, }, { 'name': u'Qatar', 'alpha2': u'QA', 'alpha3': u'QAT', 'numeric': 634, 'independent': True, }, { 'name': u'Réunion', 'alpha2': u'RE', 'alpha3': u'REU', 'numeric': 638, 'independent': False, }, { 'name': u'Romania', 'alpha2': u'RO', 'alpha3': u'ROU', 'numeric': 642, 'independent': True, }, { 'name': u'Russian Federation', 'alpha2': u'RU', 'alpha3': u'RUS', 'numeric': 643, 'independent': True, }, { 'name': u'Rwanda', 'alpha2': u'RW', 'alpha3': u'RWA', 'numeric': 646, 'independent': True, }, { 'name': u'Saint Barthélemy', 'alpha2': u'BL', 'alpha3': u'BLM', 'numeric': 652, 'independent': False, }, { 'name': u'"Saint Helena, Ascension and Tristan da Cunha"', 'alpha2': u'SH', 'alpha3': u'SHN', 'numeric': 654, 'independent': False, }, { 'name': u'Saint Kitts and Nevis', 'alpha2': u'KN', 'alpha3': u'KNA', 'numeric': 659, 'independent': True, }, { 'name': u'Saint Lucia', 'alpha2': u'LC', 'alpha3': u'LCA', 'numeric': 662, 'independent': True, }, { 'name': u'Saint Martin (French part)', 'alpha2': u'MF', 'alpha3': u'MAF', 'numeric': 663, 'independent': False, }, { 'name': u'Saint Pierre and Miquelon', 'alpha2': u'PM', 'alpha3': u'SPM', 'numeric': 666, 'independent': False, }, { 'name': u'Saint Vincent and the Grenadines', 'alpha2': u'VC', 'alpha3': u'VCT', 'numeric': 670, 'independent': True, }, { 'name': u'Samoa', 'alpha2': u'WS', 'alpha3': u'WSM', 'numeric': 882, 'independent': True, }, { 'name': u'San Marino', 'alpha2': u'SM', 'alpha3': u'SMR', 'numeric': 674, 'independent': True, }, { 'name': u'Sao Tome and Principe', 'alpha2': u'ST', 'alpha3': u'STP', 'numeric': 678, 'independent': True, }, { 'name': u'Saudi Arabia', 'alpha2': u'SA', 'alpha3': u'SAU', 'numeric': 682, 'independent': True, }, { 'name': u'Senegal', 'alpha2': u'SN', 'alpha3': u'SEN', 'numeric': 686, 'independent': True, }, { 'name': u'Serbia', 'alpha2': u'RS', 'alpha3': u'SRB', 'numeric': 688, 'independent': True, }, { 'name': u'Seychelles', 'alpha2': u'SC', 'alpha3': u'SYC', 'numeric': 690, 'independent': True, }, { 'name': u'Sierra Leone', 'alpha2': u'SL', 'alpha3': u'SLE', 'numeric': 694, 'independent': True, }, { 'name': u'Singapore', 'alpha2': u'SG', 'alpha3': u'SGP', 'numeric': 702, 'independent': True, }, { 'name': u'Sint Maarten (Dutch part)', 'alpha2': u'SX', 'alpha3': u'SXM', 'numeric': 534, 'independent': False, }, { 'name': u'Slovakia', 'alpha2': u'SK', 'alpha3': u'SVK', 'numeric': 703, 'independent': True, }, { 'name': u'Slovenia', 'alpha2': u'SI', 'alpha3': u'SVN', 'numeric': 705, 'independent': True, }, { 'name': u'Solomon Islands', 'alpha2': u'SB', 'alpha3': u'SLB', 'numeric': 90, 'independent': True, }, { 'name': u'Somalia', 'alpha2': u'SO', 'alpha3': u'SOM', 'numeric': 706, 'independent': True, }, { 'name': u'South Africa', 'alpha2': u'ZA', 'alpha3': u'ZAF', 'numeric': 710, 'independent': True, }, { 'name': u'South Georgia and the South Sandwich Islands', 'alpha2': u'GS', 'alpha3': u'SGS', 'numeric': 239, 'independent': False, }, { 'name': u'South Sudan', 'alpha2': u'SS', 'alpha3': u'SSD', 'numeric': 728, 'independent': True, }, { 'name': u'Spain', 'alpha2': u'ES', 'alpha3': u'ESP', 'numeric': 724, 'independent': True, }, { 'name': u'Sri Lanka', 'alpha2': u'LK', 'alpha3': u'LKA', 'numeric': 144, 'independent': True, }, { 'name': u'Sudan', 'alpha2': u'SD', 'alpha3': u'SDN', 'numeric': 729, 'independent': True, }, { 'name': u'Suriname', 'alpha2': u'SR', 'alpha3': u'SUR', 'numeric': 740, 'independent': True, }, { 'name': u'Svalbard and Jan Mayen', 'alpha2': u'SJ', 'alpha3': u'SJM', 'numeric': 744, 'independent': False, }, { 'name': u'Swaziland', 'alpha2': u'SZ', 'alpha3': u'SWZ', 'numeric': 748, 'independent': True, }, { 'name': u'Sweden', 'alpha2': u'SE', 'alpha3': u'SWE', 'numeric': 752, 'independent': True, }, { 'name': u'Switzerland', 'alpha2': u'CH', 'alpha3': u'CHE', 'numeric': 756, 'independent': True, }, { 'name': u'Syrian Arab Republic', 'alpha2': u'SY', 'alpha3': u'SYR', 'numeric': 760, 'independent': True, }, { 'name': u'"Taiwan, Province of China[a]"', 'alpha2': u'TW', 'alpha3': u'TWN', 'numeric': 158, 'independent': False, }, { 'name': u'Tajikistan', 'alpha2': u'TJ', 'alpha3': u'TJK', 'numeric': 762, 'independent': True, }, { 'name': u'"Tanzania, United Republic of"', 'alpha2': u'TZ', 'alpha3': u'TZA', 'numeric': 834, 'independent': True, }, { 'name': u'Thailand', 'alpha2': u'TH', 'alpha3': u'THA', 'numeric': 764, 'independent': True, }, { 'name': u'Timor-Leste', 'alpha2': u'TL', 'alpha3': u'TLS', 'numeric': 626, 'independent': True, }, { 'name': u'Togo', 'alpha2': u'TG', 'alpha3': u'TGO', 'numeric': 768, 'independent': True, }, { 'name': u'Tokelau', 'alpha2': u'TK', 'alpha3': u'TKL', 'numeric': 772, 'independent': False, }, { 'name': u'Tonga', 'alpha2': u'TO', 'alpha3': u'TON', 'numeric': 776, 'independent': True, }, { 'name': u'Trinidad and Tobago', 'alpha2': u'TT', 'alpha3': u'TTO', 'numeric': 780, 'independent': True, }, { 'name': u'Tunisia', 'alpha2': u'TN', 'alpha3': u'TUN', 'numeric': 788, 'independent': True, }, { 'name': u'Turkey', 'alpha2': u'TR', 'alpha3': u'TUR', 'numeric': 792, 'independent': True, }, { 'name': u'Turkmenistan', 'alpha2': u'TM', 'alpha3': u'TKM', 'numeric': 795, 'independent': True, }, { 'name': u'Turks and Caicos Islands', 'alpha2': u'TC', 'alpha3': u'TCA', 'numeric': 796, 'independent': False, }, { 'name': u'Tuvalu', 'alpha2': u'TV', 'alpha3': u'TUV', 'numeric': 798, 'independent': True, }, { 'name': u'Uganda', 'alpha2': u'UG', 'alpha3': u'UGA', 'numeric': 800, 'independent': True, }, { 'name': u'Ukraine', 'alpha2': u'UA', 'alpha3': u'UKR', 'numeric': 804, 'independent': True, }, { 'name': u'United Arab Emirates', 'alpha2': u'AE', 'alpha3': u'ARE', 'numeric': 784, 'independent': True, }, { 'name': u'United Kingdom of Great Britain and Northern Ireland', 'alpha2': u'GB', 'alpha3': u'GBR', 'numeric': 826, 'independent': True, }, { 'name': u'United States of America', 'alpha2': u'US', 'alpha3': u'USA', 'numeric': 840, 'independent': True, }, { 'name': u'United States Minor Outlying Islands', 'alpha2': u'UM', 'alpha3': u'UMI', 'numeric': 581, 'independent': False, }, { 'name': u'Uruguay', 'alpha2': u'UY', 'alpha3': u'URY', 'numeric': 858, 'independent': True, }, { 'name': u'Uzbekistan', 'alpha2': u'UZ', 'alpha3': u'UZB', 'numeric': 860, 'independent': True, }, { 'name': u'Vanuatu', 'alpha2': u'VU', 'alpha3': u'VUT', 'numeric': 548, 'independent': True, }, { 'name': u'Venezuela (Bolivarian Republic of)', 'alpha2': u'VE', 'alpha3': u'VEN', 'numeric': 862, 'independent': True, }, { 'name': u'Viet Nam', 'alpha2': u'VN', 'alpha3': u'VNM', 'numeric': 704, 'independent': True, }, { 'name': u'Virgin Islands (British)', 'alpha2': u'VG', 'alpha3': u'VGB', 'numeric': 92, 'independent': False, }, { 'name': u'Virgin Islands (U.S.)', 'alpha2': u'VI', 'alpha3': u'VIR', 'numeric': 850, 'independent': False, }, { 'name': u'Wallis and Futuna', 'alpha2': u'WF', 'alpha3': u'WLF', 'numeric': 876, 'independent': False, }, { 'name': u'Western Sahara', 'alpha2': u'EH', 'alpha3': u'ESH', 'numeric': 732, 'independent': False, }, { 'name': u'Yemen', 'alpha2': u'YE', 'alpha3': u'YEM', 'numeric': 887, 'independent': True, }, { 'name': u'Zambia', 'alpha2': u'ZM', 'alpha3': u'ZMB', 'numeric': 894, 'independent': True, }, { 'name': u'Zimbabwe', 'alpha2': u'ZW', 'alpha3': u'ZWE', 'numeric': 716, 'independent': True, }, ] def by_name(name): for country in countries_data: if name.lower() == country['name'].lower(): return country else: return None def by_alpha2(alpha2): for country in countries_data: if alpha2.lower() == country['alpha2'].lower(): return country else: return None def by_alpha3(alpha3): for country in countries_data: if alpha3.lower() == country['alpha3'].lower(): return country else: return None def by_numeric(numeric): for country in countries_data: if numeric == country['numeric']: return country else: return None
def test_eval_mode(wdriver): assert wdriver.execute_script("return window.rp.pyEval('1+1')") == 2 def test_exec_mode(wdriver): assert wdriver.execute_script("return window.rp.pyExec('1+1')") is None def test_exec_single_mode(wdriver): assert wdriver.execute_script("return window.rp.pyExecSingle('1+1')") == 2 stdout = wdriver.execute_script( """ let output = ""; save_output = function(text) {{ output += text }}; window.rp.pyExecSingle('1+1\\n2+2',{stdout: save_output}); return output; """ ) assert stdout == "2\n4\n"
# encoding: UTF-8 def remove_chinese(str): s = "" for w in str: if w >= u'\u4e00' and w <= u'\u9fa5': continue s += w return s def remove_non_numerical(s): f = '' for i in range(len(s)): try: f = float(s[:i+1]) except: return f return str(f)
# Link: https://leetcode.com/problems/search-in-rotated-sorted-array/ # Time: O(LogN) # Space: O(1) # As the given array is rotated sorted, binary search cannot be applied directly. def search(nums, target): start, end = 0, len(nums) - 1 while start <= end: mid = (start + end) // 2 if target == nums[mid]: return mid if nums[start] <= nums[mid]: # the array is sorted from start to mid. if nums[start] <= target < nums[mid]: # as the target lies between start and mid, reduce the search window. end = mid - 1 else: # if target does not lie between start and mid, search from (mid + 1) - end. start = mid + 1 else: # here the array is sorted from mid to end. if nums[mid] < target <= nums[end]: # as the target lies between mid and end, reduce the search window. start = mid + 1 else: # the target does not lie between mid and end, search from start - (mid - 1) end = mid - 1 return -1 def main(): nums = [3, 5, 1] target = 3 print(search(nums, target)) if __name__ == "__main__": main()
class Sequence: transcription_table = {'A':'U', 'T':'A', 'C':'G' , 'G':'C'} enz_dict = {'EcoRI':'GAATTC', 'EcoRV':'GATATC'} def __init__(self, seqstring): self.seqstring = seqstring.upper() def restriction(self, enz): try: enz_target = Sequence.enz_dict[enz] return self.seqstring.count(enz_target) except KeyError: return 0 def transcription(self): tt = "" for letter in self.seqstring: if letter in 'ATCG': tt += self.transcription_table[letter] return tt
''' URL: https://leetcode.com/problems/delete-node-in-a-linked-list/ Difficulty: Easy Description: Delete Node in a Linked List Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. Example 1: Input: head = [4,5,1,9], node = 5 Output: [4,1,9] Explanation: You are given the second node with value 5, the linked list should become 4 -> 1 -> 9 after calling your function. Example 2: Input: head = [4,5,1,9], node = 1 Output: [4,5,9] Explanation: You are given the third node with value 1, the linked list should become 4 -> 5 -> 9 after calling your function. Example 3: Input: head = [1,2,3,4], node = 3 Output: [1,2,4] Example 4: Input: head = [0,1], node = 0 Output: [1] Example 5: Input: head = [-3,5,-99], node = -3 Output: [5,-99] Constraints: The number of the nodes in the given list is in the range [2, 1000]. -1000 <= Node.val <= 1000 The value of each node in the list is unique. The node to be deleted is in the list and is not a tail node ''' # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def deleteNode(self, node): """ :type node: ListNode :rtype: void Do not return anything, modify node in-place instead. """ node.val = node.next.val node.next = node.next.next
class Messages: USERS_1 = 'Username already exists.' USERS_2 = 'Email already exists.' USERS_3 = 'Password and Confirm Password must be same.' USERS_4 = 'Username or Password is incorrect.' USERS_5 = 'Your email address is not verified.' TOKENS_1 = 'Token does not exist.' TOKENS_2 = 'User does not exist.' TOKENS_3 = 'Your email has been verified.'
class PageEffectiveImageMixin(object): def get_effective_image(self): if self.image: return self.image page = self.get_main_language_page() if page.specific.image: return page.specific.get_effective_image() return ''
#!/usr/bin/env python3 """Reads gamebits.txt and produces: - one list per table, in gamebitsN.txt - GameBit.h for import into Ghidra - a list of all known bits, in stdout """ tables = [ {'id':0, 'bits':[]}, {'id':1, 'bits':[]}, {'id':2, 'bits':[]}, {'id':3, 'bits':[]}, ] allBits = [] longestName = 4 # "Name" itself is 4 letters # read original file with open('gamebits.txt', 'rt') as file: for line in file: if not line.startswith('0'): continue line = line.split('|') bit = { 'id': int(line[0], 16), 'tbl': int(line[1]), 'unk': (int(line[2], 16), int(line[3], 16)), 'max': int(line[4], 16), 'name': line[5].strip(), 'note': line[6].strip(), } longestName = max(longestName, len(bit['name'])) allBits.append(bit) tables[bit['tbl']]['bits'].append(bit) namePad = ' ' * (longestName - 4) nameDash = '-' * (longestName - 4) # read dumps dumps = ( 'NewGame', 'Chap2', 'Chap3', 'Chap4', 'Chap5', 'EndGame', ) for dumpName in dumps: for line in open('gamebits%s.txt' % dumpName, 'rt'): if not line.startswith('\x1B[48;'): continue line = line.split('│') # not a '|' bitId = int(line[0].split('m')[1], 16) allBits[bitId][dumpName] = int(line[4]) # write files per table for table in tables: with open('gamebits%d.txt' % table['id'], 'wt') as file: file.write("Bit#|Name%s|??|?|MaxValue|NewGame |Chapter2|Chapter3|Chapter4|Chapter5|EndGame |Note\n" % namePad) file.write("----|----%s|--|-|--------|--------|--------|--------|--------|--------|--------|----\n" % nameDash) for bit in table['bits']: #if bit['note'] != '' or bit['name'] != '': file.write("%04X|%s|%02X|%X|%8X|%8X|%8X|%8X|%8X|%8X|%8X|%s\n" % ( bit['id'], bit['name'].ljust(longestName), bit['unk'][0], bit['unk'][1], bit['max'], bit['NewGame'], bit['Chap2'], bit['Chap3'], bit['Chap4'], bit['Chap5'], bit['EndGame'], bit['note'] )) # write known bits to stdout for table in tables: print("\n# Table %d" % table['id']) print("Bit#|Name%s|??|?|MaxValue|NewGame |Chapter2|Chapter3|Chapter4|Chapter5|EndGame |Note" % namePad) print("----|----%s|--|-|--------|--------|--------|--------|--------|--------|--------|----" % nameDash) for bit in table['bits']: if bit['note'] != '' or bit['name'] != '': print("%04X|%s|%02X|%X|%8X|%8X|%8X|%8X|%8X|%8X|%8X|%s" % ( bit['id'], bit['name'].ljust(longestName), bit['unk'][0], bit['unk'][1], bit['max'], bit['NewGame'], bit['Chap2'], bit['Chap3'], bit['Chap4'], bit['Chap5'], bit['EndGame'], bit['note'] ) ) # write GameBit.h with open('GameBit.h', 'wt') as file: file.write("typedef enum {\n") for bit in allBits: if bit['name'] != '': file.write("\t%s = 0x%04X,\n" % (bit['name'], bit['id'])) file.write('} GameBit;\n') # Ghidra is a butt file.write("typedef enum {\n") for bit in allBits: if bit['name'] != '': file.write("\t%s = 0x%04X,\n" % (bit['name'], bit['id'])) file.write('} GameBit16;\n')
# /home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser_tables.py # This file is automatically generated. Do not edit. _tabversion = '3.2' _lr_method = 'LALR' _lr_signature = '`\xa3O\x17\xd6C\xd4E2\xb5\xf60wIM\xd9' _lr_action_items = {'TAKING_TOK':([142,161,187,216,],[-66,188,-66,240,]),'LP_TOK':([18,32,43,65,73,85,88,95,111,112,124,125,128,132,144,150,158,162,165,170,171,179,180,181,182,183,184,185,189,192,193,196,197,199,204,205,206,207,210,212,214,218,219,220,224,225,226,231,233,234,235,236,238,239,244,245,251,253,254,255,257,258,260,266,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[32,43,65,65,43,65,43,111,43,43,-94,43,-79,43,-111,-32,43,43,192,43,43,-91,-51,-76,-50,-11,212,43,43,43,-38,43,43,226,231,43,-51,-50,43,43,-57,-33,-37,-36,-31,-21,43,43,-59,43,-108,255,43,43,-40,-34,266,43,-11,43,-11,-11,-30,43,-11,-60,-52,-25,-56,-16,-39,43,-53,-58,-61,43,-54,-63,-35,-55,43,-11,-65,-62,-64,]),'FOREACH_TOK':([61,],[79,]),'AS_TOK':([256,267,285,294,],[271,271,271,271,]),'ANONYMOUS_VAR_TOK':([32,43,65,66,73,85,88,100,106,111,112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,192,193,196,197,205,210,212,214,218,219,220,224,225,226,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[46,46,46,46,46,46,46,46,46,46,46,-94,46,-79,46,-111,-32,46,46,46,46,-91,-76,-11,46,46,46,-38,46,46,46,46,46,-57,-33,-37,-36,-31,-21,46,46,-59,46,-108,46,46,-40,-34,46,-11,46,-11,-11,-30,46,-11,-60,-52,-25,-56,-16,-39,46,-53,-58,-61,46,-54,-63,-35,-55,46,-11,-65,-62,-64,]),'NUMBER_TOK':([32,43,65,73,85,88,111,112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,192,193,196,197,205,210,212,214,218,219,220,224,225,226,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,272,273,274,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[44,44,44,44,44,44,44,44,-94,44,-79,44,-111,-32,44,44,44,44,-91,-76,-11,44,44,44,-38,44,44,44,44,44,-57,-33,-37,-36,-31,-21,44,44,-59,44,-108,44,44,-40,-34,44,-11,44,-11,-11,-30,44,-11,-60,-52,-25,288,-56,-16,-39,44,-53,-58,-61,44,-54,-63,-35,-55,44,-11,-65,-62,-64,]),'DEINDENT_TOK':([94,107,109,114,119,121,124,125,128,144,150,153,154,159,160,172,173,179,181,183,189,193,196,197,209,214,218,219,220,224,225,229,233,235,241,244,245,250,254,257,258,260,261,265,268,269,272,273,275,276,277,278,280,281,283,284,289,291,292,293,295,296,300,301,305,307,308,310,311,312,],[-104,118,-106,135,138,140,-94,143,-79,-111,-32,-90,173,-49,-48,-107,198,-91,-76,209,218,-38,224,225,-9,-57,-33,-37,-36,-31,-21,250,-59,-108,-85,-40,-34,-15,269,275,276,-30,278,-43,284,-60,-52,-25,-56,-16,291,-39,-41,293,-53,-58,-61,-86,300,-42,-54,-63,-35,-55,308,310,-65,-62,312,-64,]),'STEP_TOK':([256,267,285,294,],[274,274,274,274,]),'EXTENDING_TOK':([0,3,6,],[-22,-23,9,]),'ASSERT_TOK':([61,80,143,],[-101,97,-29,]),'INDENT_TOK':([33,37,39,58,59,60,62,77,96,113,122,139,141,145,151,152,157,160,168,194,200,208,213,215,227,232,262,273,287,298,299,303,],[-69,61,-69,75,76,-69,81,93,112,134,-10,-68,158,162,170,171,176,187,-70,222,-70,234,238,239,248,253,279,-67,297,-67,304,306,]),'.':([7,129,155,180,182,184,204,206,207,],[10,147,174,-51,-50,211,230,-51,-50,]),'!':([158,179,181,183,185,193,205,210,214,219,220,233,234,235,238,239,244,253,254,257,258,268,269,272,273,275,276,278,283,284,289,295,296,301,304,307,308,310,312,],[177,-91,-76,-11,177,-38,177,177,-57,-37,-36,-59,177,-108,177,177,-40,177,-11,-11,-11,-11,-60,-52,-25,-56,-16,-39,-53,-58,-61,-54,-63,-55,177,-11,-65,-62,-64,]),'IN_TOK':([44,46,48,49,50,52,53,54,55,56,67,99,103,104,127,129,136,137,146,180,182,],[-78,-75,-74,-89,-80,-88,-81,-116,-20,-84,-100,-117,-121,-120,-66,-87,-118,-119,163,-74,-87,]),'NOTANY_TOK':([112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,193,196,197,205,210,214,218,219,220,224,225,233,234,235,238,239,244,245,253,254,257,258,260,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[126,-94,126,-79,126,-111,-32,178,126,126,126,-91,-76,-11,178,126,-38,126,126,178,178,-57,-33,-37,-36,-31,-21,-59,178,-108,178,178,-40,-34,178,-11,-11,-11,-30,-11,-60,-52,-25,-56,-16,-39,126,-53,-58,-61,126,-54,-63,-35,-55,178,-11,-65,-62,-64,]),'WITHOUT_TOK':([17,],[30,]),'*':([43,65,85,88,],[66,66,100,106,]),',':([40,41,44,45,46,47,48,49,50,52,53,54,55,56,57,67,68,69,70,71,82,83,90,99,101,102,103,104,105,136,137,],[-98,63,-78,-87,-75,-96,-74,-89,-80,-88,-81,-116,-20,-84,73,-100,85,-97,-93,88,-115,85,-113,-117,-110,88,-121,-120,-114,-118,-119,]),'BC_EXTRAS_TOK':([11,16,21,140,],[19,-92,-109,-45,]),'CODE_TOK':([75,81,93,148,163,164,176,188,195,222,228,240,248,297,306,],[91,91,91,166,166,166,202,166,166,166,166,166,166,202,202,]),'REQUIRE_TOK':([225,276,],[246,290,]),'PATTERN_VAR_TOK':([32,43,65,66,73,85,88,100,106,111,112,124,125,128,132,144,150,158,162,170,171,177,179,181,183,185,189,192,193,196,197,205,210,211,212,214,218,219,220,224,225,226,230,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,271,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[48,48,48,48,48,48,48,48,48,48,48,-94,48,-79,48,-111,-32,180,48,48,48,206,-91,-76,-11,180,48,48,-38,48,48,180,180,206,48,-57,-33,-37,-36,-31,-21,48,206,48,-59,180,-108,180,180,-40,-34,180,-11,48,-11,-11,-30,48,-11,-60,286,-52,-25,-56,-16,-39,48,-53,-58,-61,48,-54,-63,-35,-55,180,-11,-65,-62,-64,]),'TRUE_TOK':([32,43,65,73,85,88,111,112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,192,193,196,197,205,210,212,214,218,219,220,224,225,226,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[49,49,49,49,49,49,49,49,-94,49,-79,49,-111,-32,49,49,49,49,-91,-76,-11,49,49,49,-38,49,49,49,49,49,-57,-33,-37,-36,-31,-21,49,49,-59,49,-108,49,49,-40,-34,49,-11,49,-11,-11,-30,49,-11,-60,-52,-25,-56,-16,-39,49,-53,-58,-61,49,-54,-63,-35,-55,49,-11,-65,-62,-64,]),'PLAN_EXTRAS_TOK':([11,16,21,22,118,140,],[-99,-92,-109,36,-12,-45,]),':':([12,20,],[23,23,]),'=':([44,46,48,49,50,52,53,54,55,56,67,99,103,104,127,129,136,137,146,180,182,],[-78,-75,-74,-89,-80,-88,-81,-116,-20,-84,-100,-117,-121,-120,-66,-87,-118,-119,164,-74,-87,]),'NOT_NL_TOK':([149,169,175,201,],[-66,195,-66,228,]),'$end':([2,4,5,11,13,14,15,16,21,22,25,26,27,29,35,38,72,118,135,138,140,198,],[0,-1,-2,-99,-95,-46,-6,-92,-109,-103,-4,-46,-112,-77,-47,-5,-3,-12,-13,-14,-45,-28,]),'PYTHON_TOK':([112,124,125,128,131,132,134,144,150,153,154,156,158,162,170,171,172,179,181,183,185,189,193,196,197,205,210,214,218,219,220,224,225,233,234,235,238,239,244,245,253,254,257,258,260,265,268,269,272,273,275,276,278,279,280,283,284,289,292,293,295,296,300,301,304,307,308,310,312,],[-44,-94,-44,-79,149,-44,-44,-111,-32,-90,-44,175,-44,-44,-44,-44,-107,-91,-76,-11,-44,-44,-38,-44,-44,-44,-44,-57,-33,-37,-36,-31,-21,-59,-44,-108,-44,-44,-40,-34,-44,-11,-11,-11,-30,-43,-11,-60,-52,-25,-56,-16,-39,-44,-41,-53,-58,-61,-44,-42,-54,-63,-35,-55,-44,-11,-65,-62,-64,]),'USE_TOK':([61,76,],[78,78,]),'WITH_TOK':([94,109,159,160,209,241,291,],[-104,120,-49,-48,-9,-85,-86,]),'FALSE_TOK':([32,43,65,73,85,88,111,112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,192,193,196,197,205,210,212,214,218,219,220,224,225,226,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[52,52,52,52,52,52,52,52,-94,52,-79,52,-111,-32,52,52,52,52,-91,-76,-11,52,52,52,-38,52,52,52,52,52,-57,-33,-37,-36,-31,-21,52,52,-59,52,-108,52,52,-40,-34,52,-11,52,-11,-11,-30,52,-11,-60,-52,-25,-56,-16,-39,52,-53,-58,-61,52,-54,-63,-35,-55,52,-11,-65,-62,-64,]),'CHECK_TOK':([0,112,124,125,128,130,132,144,150,158,162,170,171,179,181,183,185,189,193,196,197,205,210,214,218,219,220,224,225,233,234,235,238,239,244,245,253,254,257,258,260,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[1,-66,-94,-66,-79,148,-66,-111,-32,-66,-66,-66,-66,-91,-76,-11,-66,-66,-38,-66,-66,-66,-66,-57,-33,-37,-36,-31,-21,-59,-66,-108,-66,-66,-40,-34,-66,-11,-11,-11,-30,-11,-60,-52,-25,-56,-16,-39,-66,-53,-58,-61,-66,-54,-63,-35,-55,-66,-11,-65,-62,-64,]),'IDENTIFIER_TOK':([0,1,3,6,8,9,10,11,13,14,16,21,26,27,30,32,42,43,63,65,73,78,85,88,111,112,124,125,128,132,134,135,140,144,147,150,153,154,158,162,170,171,172,174,177,179,181,183,185,189,192,193,196,197,198,205,210,211,212,214,218,219,220,224,225,226,230,231,233,234,235,238,239,244,245,253,254,255,257,258,260,265,266,268,269,272,273,275,276,278,279,280,283,284,289,292,293,295,296,300,301,304,307,308,310,312,],[-22,7,-23,-24,12,17,18,20,-95,12,-92,-109,20,-112,40,45,-7,45,82,45,45,95,45,45,45,129,-94,129,-79,129,155,-13,-45,-111,165,-32,-90,155,182,129,129,129,-107,199,207,-91,-76,-11,182,129,45,-38,129,129,-28,182,182,207,45,-57,-33,-37,-36,-31,-21,45,207,45,-59,182,-108,182,182,-40,-34,182,-11,45,-11,-11,-30,-43,45,-11,-60,-52,-25,-56,-16,-39,129,-41,-53,-58,-61,129,-42,-54,-63,-35,-55,182,-11,-65,-62,-64,]),'NONE_TOK':([32,43,65,73,85,88,111,112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,192,193,196,197,205,210,212,214,218,219,220,224,225,226,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[55,55,55,55,55,55,55,55,-94,55,-79,55,-111,-32,55,55,55,55,-91,-76,-11,55,55,55,-38,55,55,55,55,55,-57,-33,-37,-36,-31,-21,55,55,-59,55,-108,55,55,-40,-34,55,-11,55,-11,-11,-30,55,-11,-60,-52,-25,-56,-16,-39,55,-53,-58,-61,55,-54,-63,-35,-55,55,-11,-65,-62,-64,]),'FORALL_TOK':([112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,193,196,197,205,210,214,218,219,220,224,225,233,234,235,238,239,244,245,253,254,257,258,260,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[133,-94,133,-79,133,-111,-32,186,133,133,133,-91,-76,-11,186,133,-38,133,133,186,186,-57,-33,-37,-36,-31,-21,-59,186,-108,186,186,-40,-34,186,-11,-11,-11,-30,-11,-60,-52,-25,-56,-16,-39,133,-53,-58,-61,133,-54,-63,-35,-55,186,-11,-65,-62,-64,]),'STRING_TOK':([32,43,65,73,85,88,111,112,124,125,128,132,144,150,158,162,170,171,179,181,183,185,189,192,193,196,197,205,210,212,214,218,219,220,224,225,226,231,233,234,235,238,239,244,245,253,254,255,257,258,260,266,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[56,56,56,56,56,56,56,56,-94,56,-79,56,-111,-32,56,56,56,56,-91,-76,-11,56,56,56,-38,56,56,56,56,56,-57,-33,-37,-36,-31,-21,56,56,-59,56,-108,56,56,-40,-34,56,-11,56,-11,-11,-30,56,-11,-60,-52,-25,-56,-16,-39,56,-53,-58,-61,56,-54,-63,-35,-55,56,-11,-65,-62,-64,]),'WHEN_TOK':([94,159,160,241,291,],[110,-49,-48,-85,-86,]),'FIRST_TOK':([112,124,125,128,132,144,150,158,162,170,171,177,179,181,183,185,189,193,196,197,205,210,214,218,219,220,224,225,233,234,235,238,239,244,245,253,254,257,258,260,268,269,272,273,275,276,278,279,283,284,289,292,295,296,300,301,304,307,308,310,312,],[132,-94,132,-79,132,-111,-32,185,132,132,132,205,-91,-76,-11,185,132,-38,132,132,185,185,-57,-33,-37,-36,-31,-21,-59,185,-108,185,185,-40,-34,185,-11,-11,-11,-30,-11,-60,-52,-25,-56,-16,-39,132,-53,-58,-61,132,-54,-63,-35,-55,185,-11,-65,-62,-64,]),'RP_TOK':([32,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,65,67,68,69,70,71,73,74,83,84,85,86,87,88,89,90,99,101,102,103,104,105,111,115,116,117,123,136,137,192,212,221,226,231,237,247,252,255,266,270,282,],[-102,67,-78,-87,-75,-96,-74,-89,-80,72,-88,-81,-116,-20,-84,-17,67,-100,-17,-97,-93,-17,-18,-82,-17,99,-18,103,104,-18,-26,-113,-117,-110,-17,-121,-120,-114,-102,136,137,-83,142,-118,-119,-102,-102,242,-102,-102,256,263,267,-102,-102,285,294,]),'FC_EXTRAS_TOK':([13,14,27,198,],[-95,28,-112,-28,]),'NL_TOK':([0,12,17,19,20,23,24,28,31,34,36,40,41,63,64,79,82,91,92,97,98,108,110,120,126,132,133,142,149,166,167,175,178,185,186,190,191,202,203,205,217,223,242,243,246,249,256,259,263,264,267,285,286,288,290,294,302,309,],[3,-19,-105,33,-19,-27,37,39,42,59,60,-98,-17,-18,-8,96,-115,-73,107,113,114,119,122,139,145,151,152,160,168,-71,193,200,208,213,215,219,220,-72,229,232,241,244,260,261,262,265,273,277,280,281,273,273,296,298,299,273,305,311,]),} _lr_action = { } for _k, _v in list(_lr_action_items.items()): for _x,_y in zip(_v[0],_v[1]): if not _x in _lr_action: _lr_action[_x] = { } _lr_action[_x][_k] = _y del _lr_action_items _lr_goto_items = {'inc_plan_vars':([183,254,257,258,268,307,],[210,210,210,210,210,210,]),'when_opt':([94,],[109,]),'bc_rules_opt':([14,26,],[25,38,]),'parent_opt':([6,],[8,]),'fc_extras':([14,],[26,]),'start_extra_statements':([33,39,60,],[58,62,77,]),'bc_rules':([8,14,26,],[11,11,11,]),'file':([0,],[4,]),'fc_premise':([112,125,132,162,170,171,189,196,197,279,292,],[124,144,150,124,124,124,144,144,144,124,144,]),'python_plan_code':([176,297,306,],[203,302,309,]),'bc_require_opt':([276,],[289,]),'plan_spec':([256,267,285,294,],[272,283,295,301,]),'goal':([78,],[94,]),'plan_extras_opt':([22,],[35,]),'pattern':([32,73,88,111,112,125,132,158,162,170,171,185,189,192,196,197,205,210,212,226,231,234,238,239,253,255,266,279,292,304,],[47,90,105,47,127,127,127,127,127,127,127,127,127,47,127,127,127,127,47,47,47,127,127,127,127,47,47,127,127,127,]),'top':([0,],[2,]),'bc_premise':([158,185,205,210,234,238,239,253,304,],[179,214,233,235,179,179,179,179,179,]),'assertion':([134,154,],[153,172,]),'name':([158,177,185,205,210,211,230,234,238,239,253,304,],[184,204,184,184,184,236,251,184,184,184,184,184,]),'data_list':([43,65,],[68,83,]),'start_python_plan_call':([273,298,],[287,303,]),'pattern_proper':([32,43,65,73,85,88,111,112,125,132,158,162,170,171,185,189,192,196,197,205,210,212,226,231,234,238,239,253,255,266,279,292,304,],[50,69,69,50,69,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,]),'python_goal':([0,],[5,]),'without_names':([30,],[41,]),'bc_extras_opt':([11,],[22,]),'start_python_statements':([139,],[157,]),'patterns_opt':([32,111,192,212,226,231,255,266,],[51,123,221,237,247,252,270,282,]),'fc_require_opt':([225,],[245,]),'python_premise':([112,125,132,158,162,170,171,185,189,196,197,205,210,234,238,239,253,279,292,304,],[128,128,128,181,128,128,128,181,128,128,128,181,181,181,181,181,181,128,128,181,]),'with_opt':([109,],[121,]),'variable':([32,43,65,66,73,85,88,100,106,111,112,125,132,158,162,170,171,185,189,192,196,197,205,210,212,226,231,234,238,239,253,255,266,279,292,304,],[53,53,53,84,53,53,53,115,117,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,53,]),'fc_rule':([8,14,],[13,27,]),'start_python_code':([112,125,127,132,142,149,158,162,170,171,175,185,187,189,196,197,205,210,234,238,239,253,279,292,304,],[130,130,146,130,161,169,130,130,130,130,201,130,216,130,130,130,130,130,130,130,130,130,130,130,130,]),'bc_premises':([158,234,238,239,253,304,],[183,254,257,258,268,307,]),'data':([32,43,65,73,85,88,111,112,125,132,158,162,170,171,185,189,192,196,197,205,210,212,226,231,234,238,239,253,255,266,279,292,304,],[54,70,70,54,101,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,54,]),'patterns_proper':([43,65,85,],[71,71,102,]),'check_nl':([112,125,132,134,154,158,162,170,171,185,189,196,197,205,210,234,238,239,253,279,292,304,],[131,131,131,156,156,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,131,]),'rest_opt':([71,102,],[87,116,]),'fc_rules':([8,],[14,]),'bc_rules_section':([8,14,26,],[15,29,29,]),'python_extras_code':([75,81,93,],[92,98,108,]),'nl_opt':([0,],[6,]),'python_rule_code':([148,163,164,188,195,222,228,240,248,],[167,190,191,217,223,243,249,259,264,]),'colon_opt':([12,20,],[24,34,]),'fc_premises':([112,162,170,171,279,],[125,189,196,197,292,]),'patterns':([32,111,192,212,226,231,255,266,],[57,57,57,57,57,57,57,57,]),'comma_opt':([41,57,68,71,83,102,],[64,74,86,89,86,89,]),'reset_plan_vars':([122,],[141,]),'taking':([142,],[159,]),'without_opt':([17,],[31,]),'foreach_opt':([61,],[80,]),'bc_rule':([8,11,14,26,],[16,21,16,16,]),'start_python_assertion':([168,200,],[194,227,]),'assertions':([134,],[154,]),} _lr_goto = { } for _k, _v in list(_lr_goto_items.items()): for _x,_y in zip(_v[0],_v[1]): if not _x in _lr_goto: _lr_goto[_x] = { } _lr_goto[_x][_k] = _y del _lr_goto_items _lr_productions = [ ("S' -> top","S'",1,None,None,None), ('top -> file','top',1,'p_top','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',40), ('top -> python_goal','top',1,'p_top','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',41), ('python_goal -> CHECK_TOK IDENTIFIER_TOK . IDENTIFIER_TOK LP_TOK patterns_opt RP_TOK','python_goal',7,'p_goal','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',46), ('file -> nl_opt parent_opt fc_rules bc_rules_opt','file',4,'p_file','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',51), ('file -> nl_opt parent_opt fc_rules fc_extras bc_rules_opt','file',5,'p_file_fc_extras','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',56), ('file -> nl_opt parent_opt bc_rules_section','file',3,'p_file_bc','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',61), ('parent_opt -> EXTENDING_TOK IDENTIFIER_TOK without_opt NL_TOK','parent_opt',4,'p_parent','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',72), ('without_opt -> WITHOUT_TOK without_names comma_opt','without_opt',3,'p_second','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',77), ('when_opt -> WHEN_TOK NL_TOK reset_plan_vars INDENT_TOK bc_premises DEINDENT_TOK','when_opt',6,'p_fourth','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',82), ('reset_plan_vars -> <empty>','reset_plan_vars',0,'p_reset_plan_vars','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',87), ('inc_plan_vars -> <empty>','inc_plan_vars',0,'p_inc_plan_vars','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',95), ('bc_extras_opt -> BC_EXTRAS_TOK NL_TOK start_extra_statements INDENT_TOK python_extras_code NL_TOK DEINDENT_TOK','bc_extras_opt',7,'p_fifth','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',103), ('fc_extras -> FC_EXTRAS_TOK NL_TOK start_extra_statements INDENT_TOK python_extras_code NL_TOK DEINDENT_TOK','fc_extras',7,'p_fifth','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',104), ('plan_extras_opt -> PLAN_EXTRAS_TOK NL_TOK start_extra_statements INDENT_TOK python_extras_code NL_TOK DEINDENT_TOK','plan_extras_opt',7,'p_fifth','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',105), ('with_opt -> WITH_TOK NL_TOK start_python_statements INDENT_TOK python_plan_code NL_TOK DEINDENT_TOK','with_opt',7,'p_fifth','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',106), ('bc_require_opt -> <empty>','bc_require_opt',0,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',111), ('comma_opt -> <empty>','comma_opt',0,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',112), ('comma_opt -> ,','comma_opt',1,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',113), ('colon_opt -> <empty>','colon_opt',0,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',114), ('data -> NONE_TOK','data',1,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',115), ('fc_require_opt -> <empty>','fc_require_opt',0,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',116), ('nl_opt -> <empty>','nl_opt',0,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',117), ('nl_opt -> NL_TOK','nl_opt',1,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',118), ('parent_opt -> <empty>','parent_opt',0,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',119), ('plan_spec -> NL_TOK','plan_spec',1,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',120), ('rest_opt -> comma_opt','rest_opt',1,'p_none','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',121), ('colon_opt -> :','colon_opt',1,'p_colon_deprication','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',126), ('fc_rule -> IDENTIFIER_TOK colon_opt NL_TOK INDENT_TOK foreach_opt ASSERT_TOK NL_TOK INDENT_TOK assertions DEINDENT_TOK DEINDENT_TOK','fc_rule',11,'p_fc_rule','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',134), ('foreach_opt -> FOREACH_TOK NL_TOK INDENT_TOK fc_premises DEINDENT_TOK','foreach_opt',5,'p_foreach','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',139), ('fc_premise -> IDENTIFIER_TOK . IDENTIFIER_TOK LP_TOK patterns_opt RP_TOK NL_TOK','fc_premise',7,'p_fc_premise','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',144), ('fc_premise -> FIRST_TOK NL_TOK INDENT_TOK fc_premises DEINDENT_TOK','fc_premise',5,'p_fc_first_1','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',149), ('fc_premise -> FIRST_TOK fc_premise','fc_premise',2,'p_fc_first_n','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',154), ('fc_premise -> NOTANY_TOK NL_TOK INDENT_TOK fc_premises DEINDENT_TOK','fc_premise',5,'p_fc_notany','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',159), ('fc_premise -> FORALL_TOK NL_TOK INDENT_TOK fc_premises DEINDENT_TOK fc_require_opt','fc_premise',6,'p_fc_forall','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',164), ('fc_require_opt -> REQUIRE_TOK NL_TOK INDENT_TOK fc_premises DEINDENT_TOK','fc_require_opt',5,'p_fc_require_opt','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',169), ('python_premise -> pattern start_python_code = python_rule_code NL_TOK','python_premise',5,'p_python_eq','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',174), ('python_premise -> pattern start_python_code IN_TOK python_rule_code NL_TOK','python_premise',5,'p_python_in','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',179), ('python_premise -> start_python_code CHECK_TOK python_rule_code NL_TOK','python_premise',4,'p_python_check','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',184), ('python_premise -> check_nl PYTHON_TOK NL_TOK start_python_assertion INDENT_TOK python_rule_code NL_TOK DEINDENT_TOK','python_premise',8,'p_python_block_n','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',189), ('python_premise -> check_nl PYTHON_TOK start_python_code NOT_NL_TOK python_rule_code NL_TOK','python_premise',6,'p_python_block_1','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',194), ('assertion -> IDENTIFIER_TOK . IDENTIFIER_TOK LP_TOK patterns_opt RP_TOK NL_TOK','assertion',7,'p_assertion','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',199), ('assertion -> check_nl PYTHON_TOK NL_TOK start_python_assertion INDENT_TOK python_rule_code NL_TOK DEINDENT_TOK','assertion',8,'p_python_assertion_n','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',204), ('assertion -> check_nl PYTHON_TOK start_python_code NOT_NL_TOK python_rule_code NL_TOK','assertion',6,'p_python_assertion_1','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',209), ('check_nl -> <empty>','check_nl',0,'p_check_nl','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',214), ('bc_rule -> IDENTIFIER_TOK colon_opt NL_TOK INDENT_TOK USE_TOK goal when_opt with_opt DEINDENT_TOK','bc_rule',9,'p_bc_rule','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',220), ('bc_rules_opt -> <empty>','bc_rules_opt',0,'p_empty_bc_rules_opt','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',225), ('bc_rules_section -> bc_rules bc_extras_opt plan_extras_opt','bc_rules_section',3,'p_bc_rules_section','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',230), ('goal -> IDENTIFIER_TOK LP_TOK patterns_opt RP_TOK NL_TOK','goal',5,'p_goal_no_taking','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',235), ('goal -> IDENTIFIER_TOK LP_TOK patterns_opt RP_TOK taking','goal',5,'p_goal_taking','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',240), ('name -> IDENTIFIER_TOK','name',1,'p_name_sym','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',245), ('name -> PATTERN_VAR_TOK','name',1,'p_name_pat_var','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',250), ('bc_premise -> name LP_TOK patterns_opt RP_TOK plan_spec','bc_premise',5,'p_bc_premise1','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',255), ('bc_premise -> ! name LP_TOK patterns_opt RP_TOK plan_spec','bc_premise',6,'p_bc_premise2','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',261), ('bc_premise -> name . name LP_TOK patterns_opt RP_TOK plan_spec','bc_premise',7,'p_bc_premise3','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',267), ('bc_premise -> ! name . name LP_TOK patterns_opt RP_TOK plan_spec','bc_premise',8,'p_bc_premise4','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',273), ('bc_premise -> FIRST_TOK NL_TOK INDENT_TOK bc_premises DEINDENT_TOK','bc_premise',5,'p_bc_first_1f','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',279), ('bc_premise -> FIRST_TOK bc_premise','bc_premise',2,'p_bc_first_nf','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',284), ('bc_premise -> ! FIRST_TOK NL_TOK INDENT_TOK bc_premises DEINDENT_TOK','bc_premise',6,'p_bc_first_1t','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',289), ('bc_premise -> ! FIRST_TOK bc_premise','bc_premise',3,'p_bc_first_nt','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',294), ('bc_premise -> NOTANY_TOK NL_TOK INDENT_TOK bc_premises DEINDENT_TOK','bc_premise',5,'p_bc_notany','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',299), ('bc_premise -> FORALL_TOK NL_TOK INDENT_TOK bc_premises DEINDENT_TOK bc_require_opt','bc_premise',6,'p_bc_forall','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',304), ('bc_require_opt -> REQUIRE_TOK NL_TOK INDENT_TOK bc_premises DEINDENT_TOK','bc_require_opt',5,'p_bc_require_opt','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',309), ('plan_spec -> AS_TOK PATTERN_VAR_TOK NL_TOK','plan_spec',3,'p_as','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',314), ('plan_spec -> STEP_TOK NUMBER_TOK NL_TOK start_python_plan_call INDENT_TOK python_plan_code NL_TOK DEINDENT_TOK','plan_spec',8,'p_step_code','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',319), ('plan_spec -> NL_TOK start_python_plan_call INDENT_TOK python_plan_code NL_TOK DEINDENT_TOK','plan_spec',6,'p_code','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',325), ('start_python_code -> <empty>','start_python_code',0,'p_start_python_code','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',330), ('start_python_plan_call -> <empty>','start_python_plan_call',0,'p_start_python_plan_call','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',336), ('start_python_statements -> <empty>','start_python_statements',0,'p_start_python_statements','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',342), ('start_extra_statements -> <empty>','start_extra_statements',0,'p_start_extra_statements','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',348), ('start_python_assertion -> <empty>','start_python_assertion',0,'p_start_python_assertion','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',354), ('python_rule_code -> CODE_TOK','python_rule_code',1,'p_python_rule_code','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',361), ('python_plan_code -> CODE_TOK','python_plan_code',1,'p_python_plan_code','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',366), ('python_extras_code -> CODE_TOK','python_extras_code',1,'p_python_extras_code','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',371), ('variable -> PATTERN_VAR_TOK','variable',1,'p_pattern_var','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',376), ('variable -> ANONYMOUS_VAR_TOK','variable',1,'p_anonymous_var','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',386), ('bc_premise -> python_premise','bc_premise',1,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',394), ('bc_rules_opt -> bc_rules_section','bc_rules_opt',1,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',395), ('data -> NUMBER_TOK','data',1,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',396), ('fc_premise -> python_premise','fc_premise',1,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',397), ('pattern -> pattern_proper','pattern',1,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',398), ('pattern_proper -> variable','pattern_proper',1,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',399), ('patterns_opt -> patterns comma_opt','patterns_opt',2,'p_first','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',400), ('rest_opt -> , * variable','rest_opt',3,'p_last','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',405), ('data -> STRING_TOK','data',1,'p_data_string','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',410), ('taking -> start_python_code TAKING_TOK python_rule_code NL_TOK','taking',4,'p_taking','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',421), ('taking -> NL_TOK INDENT_TOK start_python_code TAKING_TOK python_rule_code NL_TOK DEINDENT_TOK','taking',7,'p_taking2','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',426), ('data -> IDENTIFIER_TOK','data',1,'p_quoted_last','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',431), ('data -> FALSE_TOK','data',1,'p_false','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',439), ('data -> TRUE_TOK','data',1,'p_true','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',444), ('assertions -> assertion','assertions',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',449), ('bc_premises -> bc_premise','bc_premises',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',450), ('bc_rules -> bc_rule','bc_rules',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',451), ('data_list -> data','data_list',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',452), ('fc_premises -> fc_premise','fc_premises',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',453), ('fc_rules -> fc_rule','fc_rules',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',454), ('patterns -> pattern','patterns',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',455), ('patterns_proper -> pattern_proper','patterns_proper',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',456), ('without_names -> IDENTIFIER_TOK','without_names',1,'p_start_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',457), ('bc_extras_opt -> <empty>','bc_extras_opt',0,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',462), ('data -> LP_TOK RP_TOK','data',2,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',463), ('foreach_opt -> <empty>','foreach_opt',0,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',464), ('patterns_opt -> <empty>','patterns_opt',0,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',465), ('plan_extras_opt -> <empty>','plan_extras_opt',0,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',466), ('when_opt -> <empty>','when_opt',0,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',467), ('without_opt -> <empty>','without_opt',0,'p_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',468), ('with_opt -> <empty>','with_opt',0,'p_double_empty_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',473), ('assertions -> assertions assertion','assertions',2,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',478), ('bc_premises -> bc_premises inc_plan_vars bc_premise','bc_premises',3,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',479), ('bc_rules -> bc_rules bc_rule','bc_rules',2,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',480), ('data_list -> data_list , data','data_list',3,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',481), ('fc_premises -> fc_premises fc_premise','fc_premises',2,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',482), ('fc_rules -> fc_rules fc_rule','fc_rules',2,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',483), ('patterns -> patterns , pattern','patterns',3,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',484), ('patterns_proper -> patterns_proper , pattern','patterns_proper',3,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',485), ('without_names -> without_names , IDENTIFIER_TOK','without_names',3,'p_append_list','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',486), ('pattern -> data','pattern',1,'p_pattern','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',492), ('pattern_proper -> LP_TOK * variable RP_TOK','pattern_proper',4,'p_pattern_tuple1','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',499), ('pattern_proper -> LP_TOK data_list , * variable RP_TOK','pattern_proper',6,'p_pattern_tuple2','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',506), ('pattern_proper -> LP_TOK data_list , patterns_proper rest_opt RP_TOK','pattern_proper',6,'p_pattern_tuple3','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',518), ('pattern_proper -> LP_TOK patterns_proper rest_opt RP_TOK','pattern_proper',4,'p_pattern_tuple4','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',534), ('data -> LP_TOK data_list comma_opt RP_TOK','data',4,'p_tuple','/home/bruce/python/workareas/pyke-hg/r1_working/pyke/krb_compiler/krbparser.py',543), ]
def code_function(): #function begin############################################ global code code=""" `include "{0}_env.sv" class {0}_model_base_test extends uvm_test; `uvm_component_utils({0}_model_base_test) //--------------------------------------- // env instance //--------------------------------------- {0}_model_env env; //--------------------------------------- // constructor //--------------------------------------- function new(string name = "{0}_model_base_test",uvm_component parent=null); super.new(name,parent); endfunction : new //--------------------------------------- // build_phase //--------------------------------------- virtual function void build_phase(uvm_phase phase); super.build_phase(phase); // Create the env env = {0}_model_env::type_id::create("env", this); endfunction : build_phase //--------------------------------------- // end_of_elobaration phase //--------------------------------------- virtual function void end_of_elaboration(); //print's the topology print(); endfunction //--------------------------------------- // end_of_elobaration phase //--------------------------------------- function void report_phase(uvm_phase phase); uvm_report_server svr; super.report_phase(phase); svr = uvm_report_server::get_server(); if(svr.get_severity_count(UVM_FATAL)+svr.get_severity_count(UVM_ERROR)>0) begin `uvm_info(get_type_name(), "---------------------------------------", UVM_NONE) `uvm_info(get_type_name(), "---- TEST FAIL ----", UVM_NONE) `uvm_info(get_type_name(), "---------------------------------------", UVM_NONE) end else begin `uvm_info(get_type_name(), "---------------------------------------", UVM_NONE) `uvm_info(get_type_name(), "---- TEST PASS ----", UVM_NONE) `uvm_info(get_type_name(), "---------------------------------------", UVM_NONE) end endfunction endclass : {0}_model_base_test """.format(protocol_name) print(code) #function end############################################ fh=open("protocol.csv","r") for protocol_name in fh: protocol_name=protocol_name.strip("\n") fph=open('{0}_test.sv'.format(protocol_name),"w") code_function() fph.write(code)
# The next lines will make the Pixel Turtle and its heading invisible # and will clear the screen for light show hidePixel() hideHeading() clear() # Those are the colors for the light show colors = [white, red, yellow, green, cyan, blue, purple, white] # First we move to the top left corner moveTo(0, 0) # For each color we will make the Pixel Turtle make a stripe of that color for color in colors: setColor(color) # Walk 7 steps backward (since Pixel Turtle is facing up) backward(7) # Side step to the right move(1, 0) # Walk 7 steps forward forward(7) # Side step to the right move(1, 0) # Move back to the center of the screen moveTo(8, 4) # Set the Pixel Turtle color back to its original green setColor(green) # Make both the Pixel Turtle and its heading visible again showPixel() showHeading()
# Write a Python program to multiply two numbers entered by the user and display their product # for more info on this quiz, go to this url: http://www.programmr.com/multiply-two-numbers-1 def multiply_number(): print("Please enter two numbers") user_inputs = [] result = 1 for i in range(2): user_input = int(input("Enter a number: ")) user_inputs.append(user_input) for i in user_inputs: result = i * result return result print(multiply_number())
class Singleton(object): def __init__(self): self.x = 0 def foo(self): pass singleton = Singleton() ''' Python 的模块就是天然的单例模式,因为模块在第一次导入时,会生成 .pyc 文件, 当第二次导入时,就会直接加载 .pyc 文件,而不会再次执行模块代码。 因此,我们只需把相关的函数和数据定义在一个模块中,就可以获得一个单例对象了。 '''
personal_details = ('Sanjar', 22, 'India') print(personal_details) name, _, country = personal_details print(name, country)
print ("how old are you?.",) age=raw_input() print("How tall are you?.",) height=raw_input() print("How much do you weight?.",) weight=raw_input() print("So you're %r old,%r tall and %r heavy."%(age,height,weight))
""" Define directories and options, here as an example for modeling crime offences. Input file requirements: Input csv file must include one column labeled "region_id" which holds the ID number for each location and two columns "centroid_x" and "centroid_y" which hold the x and y coordinate for each location, respectively. If shapefiles need to be processed, the requirement are two input files, one containing the numbers for the the model feature data (e.g. demographic data) for each region, and another file that contains the shape file for each region. Both files are linked via same ID's named as "region_id". """ # Main input directory: data_path = "../data/" # Filename for main input csv file: fname_input = "results_DV_year11.csv" # # Polygon shapefiles of areas boundaries, only needed if coordinates not already calculated and in main input file: shape_filename = "abs/shape_files/SA2_2011_AUST.shp" # assumes in data_path directory, optional. shape_region = 'New South Wales' # set to None if no particular region exctracted and all shapedata should be included, optional. # If center coordinates already calculated, provide data in main file with two column names "centroid_x" and "centroid_y": # Filename for crime input data including crime numbers and demographic/environment features # main output directory outpath = "../testresults/" # specific output directory for result plots, maps and tables outmcmc = outpath # add any subdirectory if required ####### Define options for analysis and visualisation split_traintest = 0.1 # splits data in train and test data, provide fraction of test simulate = False # Creates simulated data with 2dim spatial coordinates and 2 features and then runs code on this data. calc_center = False # Calculates centroids from polygons and converts from Lat/Lng to cartesian with center coord below. # If calc_center = False, coordinates have to be provided in main input file [fname_input] # using the two column names "centroid_x" and "centroid_y" center_lat = -32.163333 # Latitude coordinate for spatial center for conversion into cartesian coordinates, e.g. NSW centroid center_lng = 147.016667 # Longitude coordinate for spatial center, e.g. NSW centroid create_maps = False # creates interactive html maps of crime results, not included for simulated data. # GP setup kernelname = 'expsquared' # choose from: 'expsquared', 'matern32' or 'rationalq' (Rational Quadratic) # MCMC setup; see emcee documentation for more details (http://dfm.io/emcee/current/) nwalkers = 100 # Number of walkers, recommended at least 2 * Nparameter + 1 (recommended more) niter = 500 # Number of iterations, recommended at least 500 nburn = 200 # Number of iterations, recommended at least 20% of niter, check sampler chains for convergence. nfold_cross = 1 # Number of x-fold for cross-validation for test-train sets; set to 1 for only one run #(Notes: test first with nfold-cross = 1; computational time ~ nfold_cross; also not all plotting availabable yet for nfold_cross>1) use_log = False # select false if input features need NOT to be converted into log-space. # Note that all input features will be normalized from 0 to 1, whether log-space enabled or not. ###### List of input features # use population number by area of region instead of just absolute population numbers? #pop_per_area = True target_name = 'log_crime_rate' # Identify features in data that should be used for linear regression # Names must match column names in header, replace names below accordingly: x_feature_names = ['Med_tot_hh_inc_wee_C2011', 'Med_mortg_rep_mon_C2011', 'Med_rent_weekly_C2011', 'C11_No_religion_Tot', 'C11_Tot_Sep_M', 'Med_age_persns_C2011', 'Percnt_Unemploy_C11_P', 'Brthplace_Elsewhere_2011_Ce_P', 'LSH_Eng_only_2011_Ce_P', 'C11_P_CL_C_I_II_Tot', 'C11_Tot_T', 'Tot_persons_C11_P'] # Optionally provide additional description names for features, replace names accordingly: x_feature_desc = ["Median Tot hhd inc weekly", "Median Mortgage Repay monthly", "Median Rent Weekly", "No Religion", "Male Separated", "Median Age Persons", "Percent Unemployment", "Birthplace Elsewhere", "English Speaking Only", "Education Level Cert12", "Family One Parent", "Population"] #######################################
x = list(input().lower()) y = list(input().lower()) for i,j in zip(x,y): if i>j: print("1") break elif i<j: print("-1") break else: print("0")
# def soma (a, b): # print(f'A = {a} e B = {b}') # s = a + b # print(f'A soma de A + B = {s}') # # # soma(4, 5) # def contador(* num): # tam = len(num) # print(f'Recebi os valores {num} e são ao todo {tam} números') # # # contador(1, 2, 3) # contador(4, 5, 1, 4, 5) # contador(9, 1, 8, 8, 7, 5, 6) def dobra(lst): pos = 0 while pos < len(lst): lst[pos] *= 2 pos += 1 valores = [6, 5, 9, 1, 0, 2] dobra(valores) print(valores)
fashion_mnist = tf.keras.datasets.fashion_mnist (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() class_names = ['T-shirt/top', 'Trouser', 'Pullover', 'Dress', 'Coat', 'Sandal', 'Shirt', 'Sneaker', 'Bag', 'Ankle boot'] (train_images, train_labels), (test_images, test_labels) = fashion_mnist.load_data() idxs = np.arange(len(test_labels)) grouped_idx = [idxs[test_labels==i] for i in range(test_labels.max()+1)] ims_idx = [idx[0] for idx in grouped_idx] cm = plt.get_cmap() fig, ax = plt.subplots(2, 6, figsize=(2*6, 2*2)) ax_idxs = [0,1,2,3,4, 6,7,8,9,10, ] axs = [ax_xy for ax_y in ax for ax_xy in ax_y] for i, (ax_idx, im_idx) in enumerate(zip(ax_idxs, ims_idx)): axi=axs[ax_idx] im = test_images[im_idx] im_class = test_labels[im_idx] axi.imshow(im, cmap='gray') axi.text(0, 27, f'{class_names[im_class]}', color='w', size=16) for axi in axs: for axy in [axi.get_xaxis(), axi.get_yaxis()]: axy.set_visible(False) axi.axis('off') axi = axs[5] plt.sca(axi) for i in range(10): plt.scatter([0], [15], c=[cm.colors[256*i//10]], s=200) plt.scatter([0], [15], c='w', s=180) fig.legend(class_names, fontsize=16) plt.tight_layout(0,1,1) # ==== mnist = tf.keras.datasets.mnist (train_images, train_labels), (test_images, test_labels) = mnist.load_data() class_names = [str(i) for i in range(10)] idxs = np.arange(len(test_labels)) grouped_idx = [idxs[test_labels==i] for i in range(test_labels.max()+1)] ims_idx = [idx[10] for idx in grouped_idx] cm = plt.get_cmap() fig, ax = plt.subplots(2, 6, figsize=(2*6, 2*2)) ax_idxs = [0,1,2,3,4, 6,7,8,9,10, ] axs = [ax_xy for ax_y in ax for ax_xy in ax_y] for i, (ax_idx, im_idx) in enumerate(zip(ax_idxs, ims_idx)): axi=axs[ax_idx] im = test_images[im_idx] im_class = test_labels[im_idx] axi.imshow(im, cmap='gray') axi.text(0, 27, f'{class_names[im_class]}', color='w', size=16) for axi in axs: for axy in [axi.get_xaxis(), axi.get_yaxis()]: axy.set_visible(False) axi.axis('off') axi = axs[5] plt.sca(axi) for i in range(10): plt.scatter([0], [15], c=[cm.colors[256*i//10]], s=200) plt.scatter([0], [15], c='w', s=280) fig.legend(class_names, fontsize=16) plt.tight_layout(0,1,1)
marksheet = [] scores = [] n = int(input()) for i in range(n): name = input() score = float(input()) marksheet += [[name, score]] scores += [score] li = sorted(set(scores))[1] for n, s in marksheet: if s == li: print(n)
def import_and_create_dictionary(filename): """This function is used to create an expense dictionary from a file Every line in the file should be in the format: key , value the key is a user's name and the value is an expense to update the user's total expense with. the value shld be a number, however it is possible that there s no value that the value is an invalid number or that the entire line is blank """ expenses = {} f = open(filename, "r") lines = f.readlines() for line in lines: # strip whitspaces from the beginning and the end of the line # split into a list append on comma seperator lst = line.strip().split(",") if len(lst) <= 1: continue key = lst[0].strip() value = lst[1].strip() try: # cast value to float value = float(value) # add new expenses amount to the current total expenses amount expenses[key] = expenses.get(key, 0 ) + value except: # otherwise go t top of for loop , to the next line in ist of lines continue f.close() return expenses def main(): expenses = import_and_create_dictionary('file.txt') print('expenses: ', expenses) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- def main(): n = int(input()) ans = set() for i in range(n): ai, bi = map(int, input().split()) if ai > bi: ans.add((bi, ai)) else: ans.add((ai, bi)) print(len(ans)) if __name__ == '__main__': main()
# vim: set ts=4 sw=4 et fileencoding=utf-8: '''Vim encoding mappings to Sublime Text''' ENCODING_MAP = { 'latin1': 'Western (Windows 1252)', 'koi8-r': 'Cyrillic (KOI8-R)', 'koi8-u': 'Cyrillic (KOI8-U)', 'macroman': 'Western (Mac Roman)', 'iso-8859-1': 'Western (ISO 8859-1)', 'iso-8859-2': 'Central European (ISO 8859-2)', 'iso-8859-3': 'Western (ISO 8859-3)', 'iso-8859-4': 'Baltic (ISO 8859-4)', 'iso-8859-5': 'Cyrillic (ISO 8859-5)', 'iso-8859-6': 'Arabic (ISO 8859-6)', 'iso-8859-7': 'Greek (ISO 8859-7)', 'iso-8859-8': 'Hebrew (ISO 8859-8)', 'iso-8859-9': 'Turkish (ISO 8859-9)', 'iso-8859-10': 'Nordic (ISO 8859-10)', 'iso-8859-13': 'Estonian (ISO 8859-13)', 'iso-8859-14': 'Celtic (ISO 8859-14)', 'iso-8859-15': 'Western (ISO 8859-15)', 'iso-8859-16': 'Romanian (ISO 8859-16)', 'cp437': 'DOS (CP 437)', 'cp737': None, 'cp775': None, 'cp850': None, 'cp852': None, 'cp855': None, 'cp857': None, 'cp860': None, 'cp861': None, 'cp862': None, 'cp863': None, 'cp865': None, 'cp866': 'Cyrillic (Windows 866)', 'cp869': None, 'cp874': None, 'cp1250': 'Central European (Windows 1250)', 'cp1251': 'Cyrillic (Windows 1251)', 'cp1252': 'Western (Windows 1252)', 'cp1253': 'Greek (Windows 1253)', 'cp1254': 'Turkish (Windows 1254)', 'cp1255': 'Hebrew (Windows 1255)', 'cp1256': 'Arabic (Windows 1256)', 'cp1257': 'Baltic (Windows 1257)', 'cp1258': 'Vietnamese (Windows 1258)', 'cp932': None, 'euc-jp': None, 'sjis ': None, 'cp949': None, 'euc-kr': None, 'cp936': None, 'euc-cn': None, 'cp950': None, 'big5': None, 'euc-tw': None, 'utf-8': 'utf-8', 'ucs-2le': 'utf-16 le', 'utf-16': 'utf-16 be', 'utf-16le': 'utf-16 le', 'ucs-4': None, 'ucs-4le': None }
""" Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = [1,1,1], k = 2 Output: 2 Solution: 1. Brute Force Enumerate all subarray 2. Accumulative Sum """ # Brute Force # Time: O(n^2) # Space: O(1) class Solution: def subarraySum(self, nums: List[int], k: int) -> int: n = len(nums) res = 0 for start in range(n): sum = 0 for end in range(start, n): sum += nums[end] if sum == k: res += 1 return res # Accumulative Sum # Time: O(n^2) # Space: O(n) class Solution: def subarraySum(self, nums: List[int], k: int) -> int: n = len(nums) res = 0 accumulative_sum = [0] s = 0 for num in nums: s += num accumulative_sum.append(s) for start in range(n): sum = 0 for end in range(start, n): if accumulative_sum[end+1] - accumulative_sum[start] == k: res += 1 return res # Hashtable (sum_i, number of occurences of sum_i) # check if sum_i - k has occured already, if it is, there is a match, we get the value of key: sum_i - k # Time: O(n) # Space: O(n) class Solution: def subarraySum(self, nums: List[int], k: int) -> int: n = len(nums) res = 0 s = 0 d = {0:1} # key: accmulative sum_i, value: number of occurence of sum_i for i in range(n): s += nums[i] if s - k in d: res += d[s-k] d[s] = d.get(s, 0) + 1 return res
# # PySNMP MIB module NNCEXTPVC-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/NNCEXTPVC-MIB # Produced by pysmi-0.3.4 at Mon Apr 29 20:13:11 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, Integer, OctetString = mibBuilder.importSymbols("ASN1", "ObjectIdentifier", "Integer", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ConstraintsIntersection, SingleValueConstraint, ValueRangeConstraint, ConstraintsUnion, ValueSizeConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "SingleValueConstraint", "ValueRangeConstraint", "ConstraintsUnion", "ValueSizeConstraint") InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex") nncExtensions, = mibBuilder.importSymbols("NNCGNI0001-SMI", "nncExtensions") ObjectGroup, ModuleCompliance, NotificationGroup = mibBuilder.importSymbols("SNMPv2-CONF", "ObjectGroup", "ModuleCompliance", "NotificationGroup") Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, Counter32, iso, MibIdentifier, TimeTicks, Counter64, ObjectIdentity, IpAddress, Unsigned32, NotificationType, ModuleIdentity, Bits, Gauge32 = mibBuilder.importSymbols("SNMPv2-SMI", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "Counter32", "iso", "MibIdentifier", "TimeTicks", "Counter64", "ObjectIdentity", "IpAddress", "Unsigned32", "NotificationType", "ModuleIdentity", "Bits", "Gauge32") DisplayString, RowStatus, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "RowStatus", "TextualConvention") nncExtPvc = ModuleIdentity((1, 3, 6, 1, 4, 1, 123, 3, 79)) if mibBuilder.loadTexts: nncExtPvc.setLastUpdated('200101261907Z') if mibBuilder.loadTexts: nncExtPvc.setOrganization('Alcatel Networks Corporation') nncExtPvcObjects = MibIdentifier((1, 3, 6, 1, 4, 1, 123, 3, 79, 1)) nncExtPvcGroups = MibIdentifier((1, 3, 6, 1, 4, 1, 123, 3, 79, 3)) nncExtPvcCompliances = MibIdentifier((1, 3, 6, 1, 4, 1, 123, 3, 79, 4)) nncCrPvpcTable = MibTable((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1), ) if mibBuilder.loadTexts: nncCrPvpcTable.setStatus('current') nncCrPvpcTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1), ).setIndexNames((0, "NNCEXTPVC-MIB", "nncCrPvpcSrcIfIndex"), (0, "NNCEXTPVC-MIB", "nncCrPvpcSrcVpi"), (0, "NNCEXTPVC-MIB", "nncCrPvpcDstIfIndex"), (0, "NNCEXTPVC-MIB", "nncCrPvpcDstVpi")) if mibBuilder.loadTexts: nncCrPvpcTableEntry.setStatus('current') nncCrPvpcSrcIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: nncCrPvpcSrcIfIndex.setStatus('current') nncCrPvpcSrcVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))) if mibBuilder.loadTexts: nncCrPvpcSrcVpi.setStatus('current') nncCrPvpcDstIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 3), InterfaceIndex()) if mibBuilder.loadTexts: nncCrPvpcDstIfIndex.setStatus('current') nncCrPvpcDstVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 4), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))) if mibBuilder.loadTexts: nncCrPvpcDstVpi.setStatus('current') nncCrPvpcCastType = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 5), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("p2p", 1), ("p2mp", 2))).clone('p2p')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcCastType.setStatus('current') nncCrPvpcFwdServiceCategory = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 6), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 6))).clone(namedValues=NamedValues(("cbr", 1), ("nrtvbr", 2), ("abr", 3), ("ubr", 4), ("rtvbr", 6))).clone('nrtvbr')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdServiceCategory.setStatus('current') nncCrPvpcBwdServiceCategory = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 6))).clone(namedValues=NamedValues(("cbr", 1), ("nrtvbr", 2), ("abr", 3), ("ubr", 4), ("rtvbr", 6))).clone('nrtvbr')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdServiceCategory.setStatus('current') nncCrPvpcFwdAbrDynTrfcIcr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 8), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdAbrDynTrfcIcr.setStatus('current') nncCrPvpcFwdAbrDynTrfcRif = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 9), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdAbrDynTrfcRif.setStatus('current') nncCrPvpcFwdAbrDynTrfcRdf = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdAbrDynTrfcRdf.setStatus('current') nncCrPvpcBwdAbrDynTrfcIcr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdAbrDynTrfcIcr.setStatus('current') nncCrPvpcBwdAbrDynTrfcRif = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdAbrDynTrfcRif.setStatus('current') nncCrPvpcBwdAbrDynTrfcRdf = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdAbrDynTrfcRdf.setStatus('current') nncCrPvpcSrcBillingFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 14), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcSrcBillingFlag.setStatus('current') nncCrPvpcDstBillingFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 15), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcDstBillingFlag.setStatus('current') nncCrPvpcFwdTmTrafficDescriptor = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("none", 0), ("tagAll", 1), ("p0Plus1", 2), ("p0Plus1SlashS0Plus1", 3), ("p0Plus1SlashS0", 4), ("p0Plus1SlashM0Plus1", 5))).clone('p0Plus1SlashS0Plus1')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmTrafficDescriptor.setStatus('current') nncCrPvpcFwdTmPolicingOption = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("none", 0), ("disabled", 1), ("tag", 2), ("discard", 3))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmPolicingOption.setStatus('current') nncCrPvpcFwdTmBucketOneRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 18), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmBucketOneRate.setStatus('current') nncCrPvpcFwdTmBucketOneCdvt = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 19), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 190000)).clone(250)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmBucketOneCdvt.setStatus('current') nncCrPvpcFwdTmBucketTwoRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 20), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmBucketTwoRate.setStatus('current') nncCrPvpcFwdTmBucketTwoMbs = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 21), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10000)).clone(32)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmBucketTwoMbs.setStatus('current') nncCrPvpcFwdTmCdv = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 22), Integer32().subtype(subtypeSpec=ValueRangeConstraint(250, 10000)).clone(10000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmCdv.setStatus('current') nncCrPvpcFwdTmClr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 7)).clone(7)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcFwdTmClr.setStatus('current') nncCrPvpcBwdTmTrafficDescriptor = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 24), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("none", 0), ("tagAll", 1), ("p0Plus1", 2), ("p0Plus1SlashS0Plus1", 3), ("p0Plus1SlashS0", 4), ("p0Plus1SlashM0Plus1", 5))).clone('p0Plus1SlashS0Plus1')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmTrafficDescriptor.setStatus('current') nncCrPvpcBwdTmPolicingOption = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 25), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("none", 0), ("disabled", 1), ("tag", 2), ("discard", 3))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmPolicingOption.setStatus('current') nncCrPvpcBwdTmBucketOneRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 26), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmBucketOneRate.setStatus('current') nncCrPvpcBwdTmBucketOneCdvt = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 27), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 190000)).clone(250)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmBucketOneCdvt.setStatus('current') nncCrPvpcBwdTmBucketTwoRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 28), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmBucketTwoRate.setStatus('current') nncCrPvpcBwdTmBucketTwoMbs = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 29), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10000)).clone(32)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmBucketTwoMbs.setStatus('current') nncCrPvpcBwdTmCdv = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 30), Integer32().subtype(subtypeSpec=ValueRangeConstraint(250, 10000)).clone(10000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmCdv.setStatus('current') nncCrPvpcBwdTmClr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 31), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 7)).clone(7)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcBwdTmClr.setStatus('current') nncCrPvpcSrcAlsConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 32), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcSrcAlsConfig.setStatus('current') nncCrPvpcDstAlsConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 33), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcDstAlsConfig.setStatus('current') nncCrPvpcCreator = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 34), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 9))).clone(namedValues=NamedValues(("unknown", 0), ("nmti", 1), ("nm5620", 2), ("snmp", 9)))).setMaxAccess("readonly") if mibBuilder.loadTexts: nncCrPvpcCreator.setStatus('current') nncCrPvpcRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 1, 1, 35), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvpcRowStatus.setStatus('current') nncCrPvccTable = MibTable((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2), ) if mibBuilder.loadTexts: nncCrPvccTable.setStatus('current') nncCrPvccTableEntry = MibTableRow((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1), ).setIndexNames((0, "NNCEXTPVC-MIB", "nncCrPvccSrcIfIndex"), (0, "NNCEXTPVC-MIB", "nncCrPvccSrcVpi"), (0, "NNCEXTPVC-MIB", "nncCrPvccSrcVci"), (0, "NNCEXTPVC-MIB", "nncCrPvccDstIfIndex"), (0, "NNCEXTPVC-MIB", "nncCrPvccDstVpi"), (0, "NNCEXTPVC-MIB", "nncCrPvccDstVci")) if mibBuilder.loadTexts: nncCrPvccTableEntry.setStatus('current') nncCrPvccSrcIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: nncCrPvccSrcIfIndex.setStatus('current') nncCrPvccSrcVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 2), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))) if mibBuilder.loadTexts: nncCrPvccSrcVpi.setStatus('current') nncCrPvccSrcVci = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 3), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))) if mibBuilder.loadTexts: nncCrPvccSrcVci.setStatus('current') nncCrPvccDstIfIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 4), InterfaceIndex()) if mibBuilder.loadTexts: nncCrPvccDstIfIndex.setStatus('current') nncCrPvccDstVpi = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 5), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 4095))) if mibBuilder.loadTexts: nncCrPvccDstVpi.setStatus('current') nncCrPvccDstVci = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 6), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 65535))) if mibBuilder.loadTexts: nncCrPvccDstVci.setStatus('current') nncCrPvccCastType = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 7), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("p2p", 1), ("p2mp", 2))).clone('p2p')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccCastType.setStatus('current') nncCrPvccFwdServiceCategory = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 8), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 6))).clone(namedValues=NamedValues(("cbr", 1), ("nrtvbr", 2), ("abr", 3), ("ubr", 4), ("rtvbr", 6))).clone('nrtvbr')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdServiceCategory.setStatus('current') nncCrPvccBwdServiceCategory = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 9), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4, 6))).clone(namedValues=NamedValues(("cbr", 1), ("nrtvbr", 2), ("abr", 3), ("ubr", 4), ("rtvbr", 6))).clone('nrtvbr')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdServiceCategory.setStatus('current') nncCrPvccFwdAbrDynTrfcIcr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 10), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdAbrDynTrfcIcr.setStatus('current') nncCrPvccFwdAbrDynTrfcRif = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 11), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdAbrDynTrfcRif.setStatus('current') nncCrPvccFwdAbrDynTrfcRdf = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 12), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdAbrDynTrfcRdf.setStatus('current') nncCrPvccBwdAbrDynTrfcIcr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 13), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdAbrDynTrfcIcr.setStatus('current') nncCrPvccBwdAbrDynTrfcRif = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 14), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdAbrDynTrfcRif.setStatus('current') nncCrPvccBwdAbrDynTrfcRdf = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 15), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 9)).clone(9)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdAbrDynTrfcRdf.setStatus('current') nncCrPvccSrcBillingFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 16), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccSrcBillingFlag.setStatus('current') nncCrPvccDstBillingFlag = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 17), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccDstBillingFlag.setStatus('current') nncCrPvccFwdTmTrafficDescriptor = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 18), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("none", 0), ("tagAll", 1), ("p0Plus1", 2), ("p0Plus1SlashS0Plus1", 3), ("p0Plus1SlashS0", 4), ("p0Plus1SlashM0Plus1", 5))).clone('p0Plus1SlashS0Plus1')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmTrafficDescriptor.setStatus('current') nncCrPvccFwdTmPolicingOption = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 19), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("none", 0), ("disabled", 1), ("tag", 2), ("discard", 3))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmPolicingOption.setStatus('current') nncCrPvccFwdTmBucketOneRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 20), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmBucketOneRate.setStatus('current') nncCrPvccFwdTmBucketOneCdvt = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 21), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 190000)).clone(250)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmBucketOneCdvt.setStatus('current') nncCrPvccFwdTmBucketTwoRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 22), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmBucketTwoRate.setStatus('current') nncCrPvccFwdTmBucketTwoMbs = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 23), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10000)).clone(32)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmBucketTwoMbs.setStatus('current') nncCrPvccFwdTmCdv = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 24), Integer32().subtype(subtypeSpec=ValueRangeConstraint(250, 10000)).clone(10000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmCdv.setStatus('current') nncCrPvccFwdTmClr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 25), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 7)).clone(7)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmClr.setStatus('current') nncCrPvccFwdTmFrameDiscard = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 26), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccFwdTmFrameDiscard.setStatus('current') nncCrPvccBwdTmTrafficDescriptor = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 27), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3, 4, 5))).clone(namedValues=NamedValues(("none", 0), ("tagAll", 1), ("p0Plus1", 2), ("p0Plus1SlashS0Plus1", 3), ("p0Plus1SlashS0", 4), ("p0Plus1SlashM0Plus1", 5))).clone('p0Plus1SlashS0Plus1')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmTrafficDescriptor.setStatus('current') nncCrPvccBwdTmPolicingOption = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 28), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 3))).clone(namedValues=NamedValues(("none", 0), ("disabled", 1), ("tag", 2), ("discard", 3))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmPolicingOption.setStatus('current') nncCrPvccBwdTmBucketOneRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 29), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmBucketOneRate.setStatus('current') nncCrPvccBwdTmBucketOneCdvt = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 30), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 190000)).clone(250)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmBucketOneCdvt.setStatus('current') nncCrPvccBwdTmBucketTwoRate = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 31), Integer32().subtype(subtypeSpec=ValueRangeConstraint(0, 2488320)).clone(1000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmBucketTwoRate.setStatus('current') nncCrPvccBwdTmBucketTwoMbs = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 32), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 10000)).clone(32)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmBucketTwoMbs.setStatus('current') nncCrPvccBwdTmCdv = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 33), Integer32().subtype(subtypeSpec=ValueRangeConstraint(250, 10000)).clone(10000)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmCdv.setStatus('current') nncCrPvccBwdTmClr = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 34), Integer32().subtype(subtypeSpec=ValueRangeConstraint(1, 7)).clone(7)).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmClr.setStatus('current') nncCrPvccBwdTmFrameDiscard = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 35), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccBwdTmFrameDiscard.setStatus('current') nncCrPvccSrcAlsConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 36), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccSrcAlsConfig.setStatus('current') nncCrPvccDstAlsConfig = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 37), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1))).clone(namedValues=NamedValues(("disabled", 0), ("enabled", 1))).clone('disabled')).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccDstAlsConfig.setStatus('current') nncCrPvccCreator = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 38), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(0, 1, 2, 9))).clone(namedValues=NamedValues(("unknown", 0), ("nmti", 1), ("nm5620", 2), ("snmp", 9)))).setMaxAccess("readonly") if mibBuilder.loadTexts: nncCrPvccCreator.setStatus('current') nncCrPvccRowStatus = MibTableColumn((1, 3, 6, 1, 4, 1, 123, 3, 79, 1, 2, 1, 39), RowStatus()).setMaxAccess("readcreate") if mibBuilder.loadTexts: nncCrPvccRowStatus.setStatus('current') nncCrPvpcGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 123, 3, 79, 3, 1)).setObjects(("NNCEXTPVC-MIB", "nncCrPvpcSrcIfIndex"), ("NNCEXTPVC-MIB", "nncCrPvpcSrcVpi"), ("NNCEXTPVC-MIB", "nncCrPvpcDstIfIndex"), ("NNCEXTPVC-MIB", "nncCrPvpcDstVpi"), ("NNCEXTPVC-MIB", "nncCrPvpcCastType"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdServiceCategory"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdServiceCategory"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdAbrDynTrfcIcr"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdAbrDynTrfcRif"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdAbrDynTrfcRdf"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdAbrDynTrfcIcr"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdAbrDynTrfcRif"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdAbrDynTrfcRdf"), ("NNCEXTPVC-MIB", "nncCrPvpcSrcBillingFlag"), ("NNCEXTPVC-MIB", "nncCrPvpcDstBillingFlag"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmTrafficDescriptor"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmPolicingOption"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmBucketOneRate"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmBucketOneCdvt"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmBucketTwoRate"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmBucketTwoMbs"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmCdv"), ("NNCEXTPVC-MIB", "nncCrPvpcFwdTmClr"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmTrafficDescriptor"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmPolicingOption"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmBucketOneRate"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmBucketOneCdvt"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmBucketTwoRate"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmBucketTwoMbs"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmCdv"), ("NNCEXTPVC-MIB", "nncCrPvpcBwdTmClr"), ("NNCEXTPVC-MIB", "nncCrPvpcSrcAlsConfig"), ("NNCEXTPVC-MIB", "nncCrPvpcDstAlsConfig"), ("NNCEXTPVC-MIB", "nncCrPvpcCreator"), ("NNCEXTPVC-MIB", "nncCrPvpcRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): nncCrPvpcGroup = nncCrPvpcGroup.setStatus('current') nncCrPvccGroup = ObjectGroup((1, 3, 6, 1, 4, 1, 123, 3, 79, 3, 2)).setObjects(("NNCEXTPVC-MIB", "nncCrPvccSrcIfIndex"), ("NNCEXTPVC-MIB", "nncCrPvccSrcVpi"), ("NNCEXTPVC-MIB", "nncCrPvccSrcVci"), ("NNCEXTPVC-MIB", "nncCrPvccDstIfIndex"), ("NNCEXTPVC-MIB", "nncCrPvccDstVpi"), ("NNCEXTPVC-MIB", "nncCrPvccDstVci"), ("NNCEXTPVC-MIB", "nncCrPvccCastType"), ("NNCEXTPVC-MIB", "nncCrPvccFwdServiceCategory"), ("NNCEXTPVC-MIB", "nncCrPvccBwdServiceCategory"), ("NNCEXTPVC-MIB", "nncCrPvccFwdAbrDynTrfcIcr"), ("NNCEXTPVC-MIB", "nncCrPvccFwdAbrDynTrfcRif"), ("NNCEXTPVC-MIB", "nncCrPvccFwdAbrDynTrfcRdf"), ("NNCEXTPVC-MIB", "nncCrPvccBwdAbrDynTrfcIcr"), ("NNCEXTPVC-MIB", "nncCrPvccBwdAbrDynTrfcRif"), ("NNCEXTPVC-MIB", "nncCrPvccBwdAbrDynTrfcRdf"), ("NNCEXTPVC-MIB", "nncCrPvccSrcBillingFlag"), ("NNCEXTPVC-MIB", "nncCrPvccDstBillingFlag"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmTrafficDescriptor"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmPolicingOption"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmBucketOneRate"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmBucketOneCdvt"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmBucketTwoRate"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmBucketTwoMbs"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmCdv"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmClr"), ("NNCEXTPVC-MIB", "nncCrPvccFwdTmFrameDiscard"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmTrafficDescriptor"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmPolicingOption"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmBucketOneRate"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmBucketOneCdvt"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmBucketTwoRate"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmBucketTwoMbs"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmCdv"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmClr"), ("NNCEXTPVC-MIB", "nncCrPvccBwdTmFrameDiscard"), ("NNCEXTPVC-MIB", "nncCrPvccSrcAlsConfig"), ("NNCEXTPVC-MIB", "nncCrPvccDstAlsConfig"), ("NNCEXTPVC-MIB", "nncCrPvccCreator"), ("NNCEXTPVC-MIB", "nncCrPvccRowStatus")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): nncCrPvccGroup = nncCrPvccGroup.setStatus('current') nncPvcCompliance = ModuleCompliance((1, 3, 6, 1, 4, 1, 123, 3, 79, 4, 1)).setObjects(("NNCEXTPVC-MIB", "nncCrPvpcGroup"), ("NNCEXTPVC-MIB", "nncCrPvccGroup")) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): nncPvcCompliance = nncPvcCompliance.setStatus('current') mibBuilder.exportSymbols("NNCEXTPVC-MIB", nncCrPvpcBwdTmClr=nncCrPvpcBwdTmClr, nncCrPvpcSrcBillingFlag=nncCrPvpcSrcBillingFlag, nncCrPvccDstIfIndex=nncCrPvccDstIfIndex, nncExtPvcGroups=nncExtPvcGroups, nncCrPvpcFwdAbrDynTrfcIcr=nncCrPvpcFwdAbrDynTrfcIcr, nncCrPvccFwdAbrDynTrfcIcr=nncCrPvccFwdAbrDynTrfcIcr, nncCrPvpcFwdServiceCategory=nncCrPvpcFwdServiceCategory, nncCrPvpcTableEntry=nncCrPvpcTableEntry, nncCrPvccCastType=nncCrPvccCastType, nncCrPvccBwdAbrDynTrfcRif=nncCrPvccBwdAbrDynTrfcRif, nncCrPvccBwdAbrDynTrfcIcr=nncCrPvccBwdAbrDynTrfcIcr, nncCrPvpcFwdTmBucketTwoMbs=nncCrPvpcFwdTmBucketTwoMbs, nncCrPvccCreator=nncCrPvccCreator, nncCrPvccFwdTmBucketTwoRate=nncCrPvccFwdTmBucketTwoRate, nncCrPvpcSrcIfIndex=nncCrPvpcSrcIfIndex, nncCrPvccBwdTmBucketTwoRate=nncCrPvccBwdTmBucketTwoRate, nncCrPvpcBwdAbrDynTrfcIcr=nncCrPvpcBwdAbrDynTrfcIcr, nncCrPvpcBwdTmBucketOneCdvt=nncCrPvpcBwdTmBucketOneCdvt, nncCrPvccFwdTmFrameDiscard=nncCrPvccFwdTmFrameDiscard, nncCrPvccDstVci=nncCrPvccDstVci, nncExtPvcObjects=nncExtPvcObjects, nncCrPvpcDstIfIndex=nncCrPvpcDstIfIndex, nncCrPvccTableEntry=nncCrPvccTableEntry, nncCrPvccSrcVci=nncCrPvccSrcVci, nncCrPvccRowStatus=nncCrPvccRowStatus, PYSNMP_MODULE_ID=nncExtPvc, nncCrPvccSrcVpi=nncCrPvccSrcVpi, nncCrPvccFwdTmBucketTwoMbs=nncCrPvccFwdTmBucketTwoMbs, nncCrPvccBwdTmFrameDiscard=nncCrPvccBwdTmFrameDiscard, nncCrPvpcFwdAbrDynTrfcRdf=nncCrPvpcFwdAbrDynTrfcRdf, nncCrPvccFwdTmCdv=nncCrPvccFwdTmCdv, nncCrPvpcDstAlsConfig=nncCrPvpcDstAlsConfig, nncCrPvpcBwdServiceCategory=nncCrPvpcBwdServiceCategory, nncCrPvpcFwdTmPolicingOption=nncCrPvpcFwdTmPolicingOption, nncPvcCompliance=nncPvcCompliance, nncCrPvpcBwdTmTrafficDescriptor=nncCrPvpcBwdTmTrafficDescriptor, nncCrPvccFwdTmTrafficDescriptor=nncCrPvccFwdTmTrafficDescriptor, nncCrPvccBwdTmBucketTwoMbs=nncCrPvccBwdTmBucketTwoMbs, nncCrPvccBwdTmPolicingOption=nncCrPvccBwdTmPolicingOption, nncCrPvccFwdTmBucketOneRate=nncCrPvccFwdTmBucketOneRate, nncCrPvccBwdAbrDynTrfcRdf=nncCrPvccBwdAbrDynTrfcRdf, nncCrPvccSrcBillingFlag=nncCrPvccSrcBillingFlag, nncCrPvccFwdTmBucketOneCdvt=nncCrPvccFwdTmBucketOneCdvt, nncCrPvccBwdTmBucketOneRate=nncCrPvccBwdTmBucketOneRate, nncCrPvpcTable=nncCrPvpcTable, nncCrPvpcDstBillingFlag=nncCrPvpcDstBillingFlag, nncCrPvpcFwdTmCdv=nncCrPvpcFwdTmCdv, nncCrPvccDstBillingFlag=nncCrPvccDstBillingFlag, nncCrPvccFwdAbrDynTrfcRdf=nncCrPvccFwdAbrDynTrfcRdf, nncExtPvc=nncExtPvc, nncExtPvcCompliances=nncExtPvcCompliances, nncCrPvccFwdTmClr=nncCrPvccFwdTmClr, nncCrPvpcDstVpi=nncCrPvpcDstVpi, nncCrPvpcBwdAbrDynTrfcRdf=nncCrPvpcBwdAbrDynTrfcRdf, nncCrPvpcSrcVpi=nncCrPvpcSrcVpi, nncCrPvpcFwdTmTrafficDescriptor=nncCrPvpcFwdTmTrafficDescriptor, nncCrPvccSrcIfIndex=nncCrPvccSrcIfIndex, nncCrPvpcFwdTmClr=nncCrPvpcFwdTmClr, nncCrPvccSrcAlsConfig=nncCrPvccSrcAlsConfig, nncCrPvccBwdTmClr=nncCrPvccBwdTmClr, nncCrPvpcCastType=nncCrPvpcCastType, nncCrPvpcFwdAbrDynTrfcRif=nncCrPvpcFwdAbrDynTrfcRif, nncCrPvccTable=nncCrPvccTable, nncCrPvpcRowStatus=nncCrPvpcRowStatus, nncCrPvpcBwdTmBucketTwoRate=nncCrPvpcBwdTmBucketTwoRate, nncCrPvccBwdServiceCategory=nncCrPvccBwdServiceCategory, nncCrPvpcGroup=nncCrPvpcGroup, nncCrPvccGroup=nncCrPvccGroup, nncCrPvpcBwdTmCdv=nncCrPvpcBwdTmCdv, nncCrPvccBwdTmCdv=nncCrPvccBwdTmCdv, nncCrPvpcBwdTmPolicingOption=nncCrPvpcBwdTmPolicingOption, nncCrPvpcFwdTmBucketOneRate=nncCrPvpcFwdTmBucketOneRate, nncCrPvpcBwdAbrDynTrfcRif=nncCrPvpcBwdAbrDynTrfcRif, nncCrPvpcFwdTmBucketTwoRate=nncCrPvpcFwdTmBucketTwoRate, nncCrPvpcBwdTmBucketTwoMbs=nncCrPvpcBwdTmBucketTwoMbs, nncCrPvccBwdTmBucketOneCdvt=nncCrPvccBwdTmBucketOneCdvt, nncCrPvccFwdAbrDynTrfcRif=nncCrPvccFwdAbrDynTrfcRif, nncCrPvccDstVpi=nncCrPvccDstVpi, nncCrPvccBwdTmTrafficDescriptor=nncCrPvccBwdTmTrafficDescriptor, nncCrPvccDstAlsConfig=nncCrPvccDstAlsConfig, nncCrPvpcSrcAlsConfig=nncCrPvpcSrcAlsConfig, nncCrPvpcBwdTmBucketOneRate=nncCrPvpcBwdTmBucketOneRate, nncCrPvpcCreator=nncCrPvpcCreator, nncCrPvpcFwdTmBucketOneCdvt=nncCrPvpcFwdTmBucketOneCdvt, nncCrPvccFwdServiceCategory=nncCrPvccFwdServiceCategory, nncCrPvccFwdTmPolicingOption=nncCrPvccFwdTmPolicingOption)
# The isBadVersion API is already defined for you. # def isBadVersion(version: int) -> int: class Solution: def firstBadVersion(self, n: int) -> int: start, end = 1, n while start < end: mid = start + (end - start) // 2 check = isBadVersion(mid) if check: end = mid else: start = mid + 1 return start
""" Pseudocode: exercises 23, 24, 25 Post-solution REVIEW: Too much detail, to be honest especially for someone who understands the fundamentals Ex 23: Exercise 23 – Your first loops Generate a list that contains at least 20 random integers. Write one loop that sums up all entries of the list. Write another loop that sums up only the entries of the list with even indices. Write a third loop that generates a new list that contains the values of the list in reverse order. Print out all three results # Generate number list import the random package randomlist = empty list for index in range of 0-25 number1, between 0 and 300, is generated number1 is appended to randomlist Loop is exited once whole list is read # Add numbers in list to sum, by changing its value on iterations set sum = 0 for index in randomlist sum += index print(sum) Take user input (integer) if input in list, just inform user of that for each element: If input bigger than list element, inform them of that then parse next element else if input smaller than list element, inform them of that then parse next element Exercise 24 – 3 while loops Write a program that uses while loops to finish the tasks below: - Searching for a specific number (e.g. 5) in an integer list of unknown length - Multiplying all elements of an integer list of unknown length - Printing out the contents of a string list of unknown length elementwise # Generate list of unknown length with random elements define empty list p for index in range between 1 and random integer between min1 and max1 append random number between min2 and max2 to p print p # 1st part - search for number get user input (number to scan for) start at 0th position set NumFound to False while reading position is lower than length of list: if reading position = user input print confirmation for user NumFound becomes True reading position += 1 if NumFound remains False, inform user # 2nd part - multiply list entries together call list using code from earlier (recommended not to have more than 7 elements and random numbers only between 1-10) set first parsing index (FPI) to 0 while FPI is less than list length: set second parsing index (SPI) to 0 while SPI is less than list length print(f'current entry {SPI} times last entry {FPI} = {SPI*FPI}') SPI +=1 # move reading frame for reading position FPI +=1 # move reading frame for reading position -1 # 3rd part - print contents of unknown list by element call list using code from earlier (STOPPED TO FOLLOW CHRISTOPH'S SOLUTION IN LESSON. It's much nicer to read, of course, so you can take this as an example of too much detail) """ # after that, moved onto definition of function (see pdf) """Create a program that defines functions for the four mathematical basic operations (+, -, * and /). Call the functions at least three times with different parameters."""
load("@bazel_skylib//lib:shell.bzl", "shell") _CONTENT_PREFIX = """#!/usr/bin/env bash set -euo pipefail """ def _multirun_impl(ctx): transitive_depsets = [] content = [_CONTENT_PREFIX] for command in ctx.attr.commands: defaultInfo = command[DefaultInfo] if defaultInfo.files_to_run == None: fail("%s is not executable" % command.label, attr = "commands") exe = defaultInfo.files_to_run.executable if exe == None: fail("%s does not have an executable file" % command.label, attr = "commands") default_runfiles = defaultInfo.default_runfiles if default_runfiles != None: transitive_depsets.append(default_runfiles.files) content.append("echo Running %s\n./%s $@\n" % (shell.quote(str(command.label)), shell.quote(exe.short_path))) out_file = ctx.actions.declare_file(ctx.label.name + ".bash") ctx.actions.write( output = out_file, content = "".join(content), is_executable = True, ) return [DefaultInfo( files = depset([out_file]), runfiles = ctx.runfiles( transitive_files = depset([], transitive = transitive_depsets), ), executable = out_file, )] _multirun = rule( implementation = _multirun_impl, attrs = { "commands": attr.label_list( allow_empty = True, # this is explicitly allowed - generated invocations may need to run 0 targets mandatory = True, allow_files = True, doc = "Targets to run in specified order", cfg = "target", ), }, executable = True, ) def multirun(**kwargs): tags = kwargs.get("tags", []) if "manual" not in tags: tags.append("manual") kwargs["tags"] = tags _multirun( **kwargs ) def _command_impl(ctx): transitive_depsets = [] defaultInfo = ctx.attr.command[DefaultInfo] default_runfiles = defaultInfo.default_runfiles if default_runfiles != None: transitive_depsets.append(default_runfiles.files) str_env = [ "%s=%s" % (k, shell.quote(v)) for k, v in ctx.attr.environment.items() ] str_unqouted_env = [ "%s=%s" % (k, v) for k, v in ctx.attr.raw_environment.items() ] str_args = [ "%s=%s" % (k, shell.quote(v)) for k, v in ctx.attr.arguments.items() ] command_elements = ["exec env"] + \ str_env + \ str_unqouted_env + \ ["./%s" % shell.quote(defaultInfo.files_to_run.executable.short_path)] + \ str_args + \ ["$@\n"] out_file = ctx.actions.declare_file(ctx.label.name + ".bash") ctx.actions.write( output = out_file, content = _CONTENT_PREFIX + " ".join(command_elements), is_executable = True, ) return [ DefaultInfo( files = depset([out_file]), runfiles = ctx.runfiles( transitive_files = depset([], transitive = transitive_depsets), ), executable = out_file, ), ] _command = rule( implementation = _command_impl, attrs = { "arguments": attr.string_dict( doc = "Dictionary of command line arguments", ), "environment": attr.string_dict( doc = "Dictionary of environment variables", ), "raw_environment": attr.string_dict( doc = "Dictionary of unqouted environment variables", ), "command": attr.label( mandatory = True, allow_files = True, executable = True, doc = "Target to run", cfg = "target", ), }, executable = True, ) def command(**kwargs): tags = kwargs.get("tags", []) if "manual" not in tags: tags.append("manual") kwargs["tags"] = tags _command( **kwargs )
current_petrol = 0 current_position = 0 n = int(input().strip()) for i in range(n): petrol, distance = map(int, input().strip().split(' ')) current_petrol += petrol if (current_petrol > distance): current_petrol -= distance else: current_petrol = 0 current_position = i print(current_position + 1)
APPNAME = 'assembly' APPAUTHOR = 'kbase' URL = 'http://kbase.us/services/assembly' AUTH_SERVICE = 'KBase' OAUTH_EXP_DAYS = 14 OAUTH_FILENAME = 'globus_oauth.prop'
PACKAGE = "python-ptrace" VERSION = "0.9" WEBSITE = "http://python-ptrace.readthedocs.org/" LICENSE = "GNU GPL v2"
def findmax(items): if len(items) == 0: return None m = items[0] i = 1 while i < len(items): if m < items[i]: m = items[i] i = i + 1 return m
# -*- coding: utf-8 -*- """ Model Map refurbishment_level table :author: Sergio Aparicio Vegas :version: 0.2 :date: 29 Nov 2017 """ __docformat__ = "restructuredtext" class RefurbishmentLevel(): """ Refurbishment level options """ def __init__(self): self.__id = 0 self.__level = "" def __str__(self): return "id:" + str(self.__id) + " level:" + self.__level @property def id(self): return self.__id @id.setter def id(self, val): self.__id = val @property def level(self): return self.__level @level.setter def level(self, val): self.__level = val
#!/usr/bin/python patch_size = [25, 31, 35] scale_factor = [1.15, 1.2, 1.3] num_levels = [4, 8, 10] max_dist = [35, 40, 45, 50] fp_runscript = open("/home/kivan/source/cv-stereo/scripts/egomotion_kitti_eval/run_validation_orb2.sh", 'w') fp_runscript.write("#!/bin/bash\n\n") cnt = 0 for i in range(len(patch_size)): for j in range(len(num_levels)): for k in range(len(scale_factor)): for l in range(len(max_dist)): cnt += 1 filepath = "/home/kivan/source/cv-stereo/config_files/experiments/kitti/validation/orb/validation_orb2_" + str(cnt) + ".txt" print(filepath) fp = open(filepath, 'w') fp.write("egomotion_method = EgomotionRansac\n") fp.write("ransac_iters = 1000\n") fp.write("ransac_threshold = 1.5\n") fp.write("loss_function_type = Squared\n") fp.write("use_weighting = false\n") fp.write("use_deformation_field = false\n") fp.write("tracker = StereoTrackerORB\n") fp.write("max_features = 5000\n") fp.write("max_xdiff = 100\n") fp.write("max_disparity = 160\n") fp.write("orb_patch_size = " + str(patch_size[i]) + "\n") fp.write("orb_num_levels = " + str(num_levels[j]) + "\n") fp.write("orb_scale_factor = " + str(scale_factor[k]) + "\n") fp.write("orb_max_dist_stereo = " + str(max_dist[l]) + "\n") fp.write("orb_max_dist_mono = " + str(max_dist[l]) + "\n") fp.write("use_bundle_adjustment = true\n") fp.write("bundle_adjuster = BundleAdjuster\n") fp.write("ba_num_frames = 6\n") fp.close() fp_runscript.write('./run_evaluation_i7.sh "' + filepath + '"\n') fp_runscript.close()
''' Com base na tabela abaixo, escreva um programa que leia o código de um item e a quantidade deste item. A seguir, calcule e mostre o valor da conta a pagar. <img src="https://resources.urionlinejudge.com.br/gallery/images/problems/UOJ_1038_en.png" alt="Price Table"> Entrada O arquivo de entrada contém dois valores inteiros correspondentes ao código e à quantidade de um item conforme tabela acima. Saída O arquivo de saída deve conter a mensagem "Total: R$ " seguido pelo valor a ser pago, com 2 casas após o ponto decimal. ''' valores = str(input()).split() cod = int(valores[0]) quant = int(valores[1]) if cod == 1: total = quant * 4.00 elif cod == 2: total = quant * 4.50 elif cod == 3: total = quant * 5.00 elif cod == 4: total = quant * 2.00 elif cod == 5: total = quant * 1.50 print('Total: R$ {:.2f}'.format(total))
# This program has been developed by students from the bachelor Computer Science at Utrecht University within the # Software and Game project course # ©Copyright Utrecht University Department of Information and Computing Sciences. """Contains test data.""" test_get_assignments_data = \ { "courses": [ { "assignments": [ { "cmid": 6, "name": "Learning basic loops", "duedate": 1573776060, }, { "cmid": 9, "name": "Learning booleans", "duedate": 1573776060, }, ] } ], "warnings": [] } test_get_assignments_check = \ [ { "cmid": 6, "name": "Learning basic loops", "duedate": 1573776060, }, { "cmid": 9, "name": "Learning booleans", "duedate": 1573776060, }, ] test_assignment_completion_check = \ { "statuses": [ { "cmid": 6, "state": 1 }, { "cmid": 9, "state": 0 } ], "warnings": [] } test_get_enrolled_users = \ [ { "id": 4, "username": "WS", "firstname": "Will", "lastname": "Smith", "fullname": "Will Smith", } ] test_inactivity_get_enrolled_users = \ [ { "id": 2 }, { "id": 3 }, { "id": 4 }, { "id": 5 } ] test_get_courses_by_id = \ { 'courses': [ { 'id': 2, 'fullname': 'BeginningCourse' } ] } test_get_courses_by_id_ended = \ { 'courses': [ { 'id': 2, 'fullname': 'No view course', 'displayname': 'No view course', 'shortname': 'nvc', 'categoryid': 1, 'categoryname': 'Miscellaneous', 'sortorder': 10001, 'summary': '', 'summaryformat': 1, 'summaryfiles': [], 'overviewfiles': [], 'contacts': [ {'id': 4, 'fullname': 'Saskia Restful Notificaties'}], 'enrollmentmethods': ['manual'], 'idnumber': '', 'format': 'topics', 'showgrades': 1, 'newsitems': 5, 'startdate': 1605740400, 'enddate': 1637276800, 'maxbytes': 0, 'showreports': 0, 'visible': 1, 'groupmode': 0, 'groupmodeforce': 0, 'defaultgroupingid': 0, 'enablecompletion': 1, 'completionnotify': 0, 'lang': '', 'theme': '', 'marker': 0, 'legacyfiles': 0, 'calendartype': '', 'timecreated': 1605708824, 'timemodified': 1605708824, 'requested': 0, 'cacherev': 1605801045, 'filters': [{'filter': 'displayh5p', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'activitynames', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mathjaxloader', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'emoticon', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'urltolink', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mediaplugin', 'localstate': 0, 'inheritedstate': 1}], 'courseformatoptions': [{'name': 'hiddensections', 'value': 0}, {'name': 'coursedisplay', 'value': 0}]}] } test_get_courses_by_id_live = \ { 'courses': [ { 'id': 2, 'fullname': 'No view course', 'displayname': 'No view course', 'shortname': 'nvc', 'categoryid': 1, 'categoryname': 'Miscellaneous', 'sortorder': 10001, 'summary': '', 'summaryformat': 1, 'summaryfiles': [], 'overviewfiles': [], 'contacts': [ {'id': 4, 'fullname': 'Saskia Restful Notificaties'}], 'enrollmentmethods': ['manual'], 'idnumber': '', 'format': 'topics', 'showgrades': 1, 'newsitems': 5, 'startdate': 1605740400, 'enddate': 1637276400, 'maxbytes': 0, 'showreports': 0, 'visible': 1, 'groupmode': 0, 'groupmodeforce': 0, 'defaultgroupingid': 0, 'enablecompletion': 1, 'completionnotify': 0, 'lang': '', 'theme': '', 'marker': 0, 'legacyfiles': 0, 'calendartype': '', 'timecreated': 1605708824, 'timemodified': 1605708824, 'requested': 0, 'cacherev': 1605801045, 'filters': [{'filter': 'displayh5p', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'activitynames', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mathjaxloader', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'emoticon', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'urltolink', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mediaplugin', 'localstate': 0, 'inheritedstate': 1}], 'courseformatoptions': [{'name': 'hiddensections', 'value': 0}, {'name': 'coursedisplay', 'value': 0}]}] } test_get_courses_by_id_young = \ { 'courses': [ { 'id': 2, 'fullname': 'No view course', 'displayname': 'No view course', 'shortname': 'nvc', 'categoryid': 1, 'categoryname': 'Miscellaneous', 'sortorder': 10001, 'summary': '', 'summaryformat': 1, 'summaryfiles': [], 'overviewfiles': [], 'contacts': [ {'id': 4, 'fullname': 'Saskia Restful Notificaties'}], 'enrollmentmethods': ['manual'], 'idnumber': '', 'format': 'topics', 'showgrades': 1, 'newsitems': 5, 'startdate': 1605740400, 'enddate': 1606487200, 'maxbytes': 0, 'showreports': 0, 'visible': 1, 'groupmode': 0, 'groupmodeforce': 0, 'defaultgroupingid': 0, 'enablecompletion': 1, 'completionnotify': 0, 'lang': '', 'theme': '', 'marker': 0, 'legacyfiles': 0, 'calendartype': '', 'timecreated': 1606400370, 'timemodified': 1605708824, 'requested': 0, 'cacherev': 1605801045, 'filters': [{'filter': 'displayh5p', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'activitynames', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mathjaxloader', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'emoticon', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'urltolink', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mediaplugin', 'localstate': 0, 'inheritedstate': 1}], 'courseformatoptions': [{'name': 'hiddensections', 'value': 0}, {'name': 'coursedisplay', 'value': 0}]}] } test_get_courses_by_id_old = \ { 'courses': [ { 'id': 2, 'fullname': 'No view course', 'displayname': 'No view course', 'shortname': 'nvc', 'categoryid': 1, 'categoryname': 'Miscellaneous', 'sortorder': 10001, 'summary': '', 'summaryformat': 1, 'summaryfiles': [], 'overviewfiles': [], 'contacts': [ {'id': 4, 'fullname': 'Saskia Restful Notificaties'}], 'enrollmentmethods': ['manual'], 'idnumber': '', 'format': 'topics', 'showgrades': 1, 'newsitems': 5, 'startdate': 1605740400, 'enddate': 1637276400, 'maxbytes': 0, 'showreports': 0, 'visible': 1, 'groupmode': 0, 'groupmodeforce': 0, 'defaultgroupingid': 0, 'enablecompletion': 1, 'completionnotify': 0, 'lang': '', 'theme': '', 'marker': 0, 'legacyfiles': 0, 'calendartype': '', 'timecreated': 1605708824, 'timemodified': 1605708824, 'requested': 0, 'cacherev': 1605801045, 'filters': [{'filter': 'displayh5p', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'activitynames', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mathjaxloader', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'emoticon', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'urltolink', 'localstate': 0, 'inheritedstate': 1}, {'filter': 'mediaplugin', 'localstate': 0, 'inheritedstate': 1}], 'courseformatoptions': [{'name': 'hiddensections', 'value': 0}, {'name': 'coursedisplay', 'value': 0}]}] } test_learning_locker_viewed_course = \ { "more": "", "statements": [ { "actor": { "name": "Admin User", "account": { "homePage": "http://127.0.0.1:80", "name": "2" }, "objectType": "Assistant" }, "verb": { "id": "http://id.tincanapi.com/verb/viewed", "display": { "en": "viewed" } }, "object": { "id": "http://127.0.0.1:80/course/view.php?id=2", "definition": { "type": "http://id.tincanapi.com/activitytype/lms/course", "name": { "en": "BeginningCourse" }, "extensions": { "https://w3id.org/learning-analytics/learning-management-system/short-id": "BC", "https://w3id.org/learning-analytics/learning-management-system/external-id": "7" } }, "objectType": "Activity" }, "timestamp": "2019-10-16T11:26:19+01:00", "context": { "platform": "Moodle", "language": "en", "extensions": { "http://lrs.learninglocker.net/define/extensions/info": { "http://moodle.org": "3.7.2 (Build: 20190909)", "https://github.com/xAPI-vle/moodle-logstore_xapi": "v4.4.0", "event_name": "\\core\\event\\course_viewed", "event_function": "\\src\\transformer\\events\\core\\course_viewed" } }, "contextActivities": { "grouping": [ { "id": "http://127.0.0.1:80", "definition": { "type": "http://id.tincanapi.com/activitytype/lms", "name": { "en": "\"New Site\"" } }, "objectType": "Activity" } ], "category": [ { "id": "http://moodle.org", "definition": { "type": "http://id.tincanapi.com/activitytype/source", "name": { "en": "Moodle" } }, "objectType": "Activity" } ] } }, "id": "c98c8522-3d43-4098-9b5d-812392458328", "stored": "2019-10-16T10:27:02.866Z", "authority": { "objectType": "Assistant", "name": "New Client", "mbox": "mailto:hello@learninglocker.net" }, "version": "1.0.0" } ] }
"""Automatically generated by oppfest. To update, run python3 -m script.oppfest """ # fmt: off MQTT = { "tasmota": [ "tasmota/discovery/#" ] }
class Queue: def __init__(self, size): if size <= 0: raise "Size must be 1 or greater." self.start = 0 self.end = 0 self.count = 0 self.size = size self.items = [None] * size def enqueue(self, data): if self.count >= self.size: raise "Queue is full." self.items[self.end] = data newEnd = self.end + 1 if newEnd >= self.size - 1: newEnd -= self.size self.end = newEnd self.count += 1 def dequeue(self): if self.count == 0: raise "Queue is empty." data = self.items[self.start] self.items[self.start] = None self.start += 1 self.count -= 1 if self.start >= self.size: self.start -= self.size return data def printQueue(self): for i in range(self.count): index = self.start + i if index >= self.size - 1: index -= self.size print(self.items[index], end="; ") print() queue = Queue(10) while True: print("1. Enqueue") print("2. Dequeue") print("3. Print queue") print("4. Exit") choice = int(input("Enter your choice: ")) if choice == 1: data = input("Enter data: ") queue.enqueue(data) elif choice == 2: print(queue.dequeue()) elif choice == 3: queue.printQueue() elif choice == 4: break else: print("Invalid choice.")
""" Zachary Cook Class representing a lab user. """ """ Class for a user. """ class User(): """ Constructor for the user. """ def __init__(self,id,maxSessionTime,accessType="UNAUTHORIZED"): self.id = id self.accessType = accessType self.maxSessionTime = maxSessionTime """ Returns the user's id. """ def getId(self): return self.id """ Returns the access type of the user. """ def getAccessType(self): return self.accessType """ Returns the max session time. """ def getSessionTime(self): return self.maxSessionTime
def dist_whittaker(datamtx, strict=True): """ returns whittaker distance (manhattan distance with sample normalization) btw rows. This script interfaces with Cogent for adding the extra metric in QIIME in beta_diversity.py dist(a,b) = 0.5*manhattan distance(ai/A, bi/B) where ai is each element of a, and A is the sum of all ai. 1 indicates complete similarity, 0 indicates complete dissimilarity. see for example: D9 p. 198 Legendre and Legendre Developments in Environmental Modeling Vol. 3 1983 this code added jzl 3/17/11 * comparisons are between rows (samples) * input: 2D numpy array. Limited support for non-2D arrays if strict==False * output: numpy 2D array float ('d') type. shape (inputrows, inputrows) for sane input data * two rows of all zeros returns 0 distance between them * if strict==True, raises ValueError if any of the input data is negative, not finite, or if the input data is not a rank 2 array (a matrix). * if strict==False, assumes input data is a matrix with nonnegative entries. If rank of input data is < 2, returns an empty 2d array (shape: (0, 0) ). If 0 rows or 0 colunms, also returns an empty 2d array. """ if strict: if not all(isfinite(datamtx)): raise ValueError("non finite number in input matrix") if any(datamtx<0.0): raise ValueError("negative value in input matrix") if rank(datamtx) != 2: raise ValueError("input matrix not 2D") numrows, numcols = shape(datamtx) else: try: numrows, numcols = shape(datamtx) except ValueError: return zeros((0,0),'d') if numrows == 0 or numcols == 0: return zeros((0,0),'d') dists = zeros((numrows,numrows),'d') for i in range(numrows): r1 = array(datamtx[i,:],'d') r1sum = sum(r1) for j in range(i): r2 = array(datamtx[j,:], 'd') r2sum = sum(r2) cur_d = 0.0 if r1sum > 0 and r2sum > 0: cur_d = 0.5*float(sum(abs(r1/r1sum - r2/r2sum))) dists[i][j] = dists[j][i] = cur_d return dists
# ----------------------------------------------------------------------------- # Staff Assistance Flow # ----------------------------------------------------------------------------- staff_assistance_customer_email_inputtext = "xpath=//*[@id='emailInput']" staff_assistance_company_input = "//*[@id='customerInput']" staff_assistance_company_dropdown = "xpath=//*[@id='customerInput']/div/div[2]/div" staff_assistance_company_select_button = "xpath=//button[contains(text(),'Done')]" staff_assistance_company_dropdown_option_01 = "xpath=//div[contains(@class,' css-1n7v3ny-option')]" staff_assistance_changed_company_dropdown_option_01 = "xpath=//div[contains(@class,' css-yt9ioa-option')]" staff_assistance_changed_company_dropdown_option_02 = "xpath=//div[contains(@class,' css-1n7v3ny-option')]" staff_assistance_header_banner_change_link = "xpath=//a[contains(text(),'Change')]" staff_assistance_email_address_label = "xpath=//*[contains(@data-testid,'currentAccountEmail')]" staff_assistance_currently_access_label = "xpath=//*[@id='gatsby-focus-wrapper']/div[4]/div/div/span" staff_assistance_company_email_label = "xpath=//*[contains(@data-testid,'companyEmail')]" staff_assistance_company_name_label = "xpath=//*[contains(@data-testid,'companyName')]" staff_assistance_header_text_label = "You are currently acting on behalf of" staff_assistance_customer_email_address_01 = "kumindu777+yellowms@gmail.com" staff_assistance_header_company_name_label_0101 = "Yellow NZ Advertising MS" staff_assistance_customer_email_address_02 = "kumindu777+yellowsa@gmail.com" staff_assistance_header_company_name_label_0201 = "Test Business Search Ads Go Live" staff_assistance_header_company_link = "xpath=//a[contains(@href, '/my-yellow/choose-customer')]" staff_assistance_customer_email_address_03 = "kumindu777+fingoo@gmail.com" staff_assistance_header_company_name_label_0301 = "Ian Charle Langdon" staff_assistance_header_company_name_label_0302 = "Sriwis Foods" staff_assistance_select_button = "//a[contains(text(),'Select')]"
# ------------------------------ # 187. Repeated DNA Sequences # # Description: # You are given two non-empty linked lists representing two non-negative integers. The most significant digit # comes first and each of their nodes contain a single digit. Add the two numbers and return it as a linked list. # # You may assume the two numbers do not contain any leading zero, except the number 0 itself. # Follow up: # What if you cannot modify the input lists? In other words, reversing the lists is not allowed. # # Example: # # Input: (7 -> 2 -> 4 -> 3) + (5 -> 6 -> 4) # Output: 7 -> 8 -> 0 -> 7 # # Version: 1.0 # 10/06/17 by Jianfa # ------------------------------ class Solution(object): def findRepeatedDnaSequences(self, s): """ :type s: str :rtype: List[str] """ s_len = len(s) s_dict = {} res = set() for i in range(s_len - 9): if s[i:i+10] in s_dict: res.add(s[i:i+10]) else: s_dict[s[i:i+10]] = 1 return list(set(res)) # Used for test if __name__ == "__main__": test = Solution() s = "AAAAAAAAAAA" res = test.addTwoNumbers(a4, b3) print(test.findRepeatedDnaSequences(s)) # ------------------------------ # Summary: # O(n) solution with O(n) space. # Key idea is to use set/dict to detect whether the string appears has appeared. # Another idea for saving space is to use int in replace of string. e.g. Let A for 1, C for 2, G for 3, T for 4. # Then a ten-unit string can be converted to a 10-digit integer and save the space. May use a large array to # imitate a hash map.
# Python Program To Copy An Image Into Another Files ''' Function Name : Copy An Image Into Another Files Function Date : 24 Sep 2020 Function Author : Prasad Dangare Input : -- Output : -- ''' # Open The File In Binary Modes f1 = open('new.jpg.png', 'rb') f2 = open('neww.jpg.jpg', 'wb') # Read Bytes From f1 And Write Into f2 bytes = f1.read() f2.write(bytes) # Close The File f1.close() f2.close()
# Oefening: Vraag de geboortedatum van de gebruiker en zeg de leeftijd. huidig_jaar = 2017 huidige_maand = 10 huidige_dag = 24 jaar = int(input("In welk jaar ben je geboren? ")) maand = int(input("En in welke maand? (getal) ")) # De dag moeten we pas weten als de geboortemaand deze maand is! # Je kan het hier natuurlijk ook al vragen als je wilt. leeftijd = huidig_jaar - jaar if (maand > huidige_maand): # De gebruiker is nog niet verjaard leeftijd -= 1 # hetzelfde als "leeftijd = leeftijd - 1" elif (maand == huidige_maand): dag = int(input("En welke dag? (getal) ")) if (dag > huidige_dag): leeftijd -= 1 elif (dag == huidige_dag): # leeftijd = leeftijd # Dat doet helemaal niets natuurlijk print("Gelukkige verjaardag!") # else: # Enkel (dag < huidige_dag) kan nog => # # De gebruiker is al verjaard deze maand! # leeftijd = leeftijd # Maar er hoeft niets veranderd te worden. # else: # De gebruiker is zeker al verjaard, # # want enkel maand < huidige_maand kan nog! # leeftijd = leeftijd # Maar we moeten niets aanpassen! print("Dan ben je " + str(leeftijd) + " jaar oud.") ## Oefeningen zonder oplossing (mail bij vragen!). # # Oefening: start met leeftijd = huidig_jaar - jaar - 1 en verhoog die # waarde wanneer nodig. Vergelijk de voorwaarden daar met die hier. # Wat is het verschil in de tekens? # # Nog een oefening: kijk de waarden die de gebruiker ingeeft na. # Zorg ervoor je geen dag kan invoeren die later komt dan vandaag. # Probeer dat zo onafhankelijk mogelijk te doen van de bovenstaande code. # # Nadenkoefening: kan je bovenstaande 2 voorwaarden in de vorige opdracht uitvoeren # zonder in de herhaling te vallen? (dat is geen uitdaging, maar een vraag!). # Als je toch iets mag aanpassen aan bovenstaande code, kan het dan? # Wat denk je dat de beste optie is?
# 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 NetworkApiMixin(object): def peer_list(self): """ GET /network/peers Use the Network APIs to retrieve information about the network of peer nodes comprising the blockchain network. ```golang message PeersMessage { repeated PeerEndpoint peers = 1; } message PeerEndpoint { PeerID ID = 1; string address = 2; enum Type { UNDEFINED = 0; VALIDATOR = 1; NON_VALIDATOR = 2; } Type type = 3; bytes pkiID = 4; } message PeerID { string name = 1; } ``` :return: json body of the network peers info """ res = self._get(self._url("/network/peers")) return self._result(res, True)
# Problem for Prof Charnesky's mid term review sheet at: # https://canvas.umd.umich.edu/courses/522665/pages/midterm-practice?module_item_id=9243802 # 1 Classes and Unit Test question # Given the following UML, write the class # Pizza # toppings : [] # slices : int # base_cost : float # price_per_topping : int # get_total_price() : int # Write a unit test for get_total_price() class Pizza: def __init__(self, toppings, slices, base_cost=2.5, price_per_topping=1): self._toppings = toppings self._slices = slices self._base_cost = base_cost self._price_per_topping = price_per_topping def get_total_price(self): return (self._base_cost + self._price_per_topping * (len(self._toppings))) * self._slices if __name__ == "__main__": nice = Pizza(['pineapple', 'ham', 'mushrooms'], 3) print(nice.get_total_price())
class Node: def __init__(self, value): self.value = value self.left = None self.right = None def insert(self, value): if self.value: if value < self.value: if self.left: self.left.insert(value) else: self.left = Node(value) else: if self.right: self.right.insert(value) else: self.right = Node(value) else: self.value = value def preorder(self): result = [] if not self: return result result.append(self.value) if self.left: result += self.left.preorder() if self.right: result += self.right.preorder() return result def inorder(self): result = [] if not self: return result if self.left: result += self.left.inorder() result.append(self.value) if self.right: result += self.right.inorder() return result def postorder(self): result = [] if not self: return result if self.left: result += self.left.postorder() if self.right: result += self.right.postorder() result.append(self.value) return result def create_bst(lst): root = Node(lst[0]) for i in lst[1:]: root.insert(i) return root
# -------------------------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- ACR_RESOURCE_PROVIDER = 'Microsoft.ContainerRegistry' ACR_RESOURCE_TYPE = ACR_RESOURCE_PROVIDER + '/registries' STORAGE_RESOURCE_TYPE = 'Microsoft.Storage/storageAccounts' WEBHOOK_RESOURCE_TYPE = ACR_RESOURCE_TYPE + '/webhooks' WEBHOOK_API_VERSION = '2017-06-01-preview' MANAGED_REGISTRY_API_VERSION = '2017-06-01-preview' MANAGED_REGISTRY_SKU = ['Managed_Basic', 'Managed_Standard', 'Managed_Premium']
class Settings: """ All Game Settings """ def __init__(self): self.screen_width = 1000 self.screen_height = 600 self.bg_color = (180, 255, 255) self.ship_speed = 1.25 self.ship_limit = 3 self.bullet_speed = 1 self.bullet_width = 3 self.bullet_height = 15 self.bullet_color = (60, 60, 60) self.bullet_allowed = 4 self.virus_speed = 0.50 self.fleet_drop_speed = 5 self.speed_upscale = 1.20 self.score_upscale = 1.25 self.initialize_dynamic_settings() self.fleet_direction = 1 def initialize_dynamic_settings(self): self.ship_speed = 1.25 self.bullet_speed = 1 self.virus_speed = 0.50 self.fleet_direction = 1 self.virus_points = 50 def increase_speed(self): #self.ship_speed *= self.speed_upscale self.bullet_speed *= self.speed_upscale self.virus_speed *= self.speed_upscale self.virus_points = int(self.virus_points * self.score_upscale)
total = 0 for num in range(101): total = total + num print (total)
''' script de aprovação de financiamento de casa ''' valor_casa = float(input('Qual o Valor da casa? R$')) salario = float(input('Qual o Seu salario mensal? R$')) tempo = int(input('Em Quantos Anos você vai pagar? ')) parcela_salario = ((salario/100) * 30) parcela_casa = valor_casa / (tempo * 12) if parcela_casa <= parcela_salario: print(f'APROVADO,por {tempo} Anos você pagara de parcelas de sua casa R${parcela_casa:.2f}') else: print('Infelizmente Seu Emprestimo foi Negado!')
# 抓捕异常 def try_except(): try: 3 / 0 except ZeroDivisionError as err: print("zero error: {0}".format(err)) finally: print("this is finally") print("try_except") # 抛出异常 def raise_study(): x = 10 if x > 5: raise Exception('x 不能大于 5。x 的值为: {}'.format(x)) # 如果你只想知道这是否抛出了一个异常,并不想去处理它,那么一个简单的 raise 语句就可以再次把它抛出。 try: raise NameError('HiThere') except NameError: print('An exception flew by!') raise # 自定义异常 def self_exception(): try: raise MyError(2 * 2) except MyError as e: print('My exception occurred, value:', e.value) # 自定义异常 class MyError(Exception): def __init__(self, value): self.value = value def __str__(self): return repr(self.value) if __name__ == '__main__': # try_except() # raise_study() self_exception()
def totalFruit(self, tree): count = {} i = res = 0 for j, v in enumerate(tree): count[v] = count.get(v, 0) + 1 while len(count) > 2: count[tree[i]] -= 1 if count[tree[i]] == 0: del count[tree[i]] i += 1 res = max(res, j - i + 1) return res
a, b = input().split() st = '' num_a = int(a) num_b = int(b) if num_a % 2 == 0 : answer = -num_a st += str(-num_a) else : answer = num_a st += str(num_a) if a == b : if int(a) % 2 == 0 : print("-", a, "=-", a, sep='') else : print(a, "=+", a, sep='') exit() while num_a != num_b : num_a += 1 if(num_a %2 == 0) : st += '-' + str(num_a) answer -= num_a else : st += '+' + str(num_a) answer += num_a st += '=' if (num_b - 1) % 2 == 0 : st += '+' + str(answer) else : st += str(answer) print(st)
result =1 i=1 while i<=100: result=result*i i=i+1 pass print("the factorial is {}".format(result))
class TOS(QTextEdit): tos_signal = pyqtSignal() error_signal = pyqtSignal(object) class Plugin(TrustedCoinPlugin): def __init__(self, parent, config, name): super().__init__(parent, config, name) @hook def on_new_window(self, window): wallet = window.wallet if not isinstance(wallet, self.wallet_class): return if wallet.can_sign_without_server(): msg = " ".join([_("This wallet was restored from seed, and it contains two master private keys."), _("Therefore, two-factor authentication is disabled.")]) action = lambda: window.show_message(msg) else: action = partial(self.settings_dialog, window) button = StatusBarButton(QIcon(":icons/trustedcoin-status.png"), _("TrustedCoin"), action) window.statusBar().addPermanentWidget(button) self.start_request_thread(window.wallet) def auth_dialog(self, window): d = WindowModalDialog(window, _("Authorization")) vbox = QVBoxLayout(d) pw = AmountEdit(None, is_int=True) msg = _("Please enter your Google Authenticator code") vbox.addWidget(QLabel(msg)) grid = QGridLayout() grid.setSpacing(8) grid.addWidget(QLabel(_("Code")), 1, 0) grid.addWidget(pw, 1, 1) vbox.addLayout(grid) msg = _("If you have lost your second factor, you need to restore your wallet from seed in order to request a new code.") label = QLabel(msg) label.setWordWrap(1) vbox.addWidget(label) vbox.addLayout(Buttons(CancelButton(d), OkButton(d))) if not d.exec_(): return return pw.get_amount() @hook def sign_tx(self, window, tx): wallet = window.wallet if not isinstance(wallet, self.wallet_class): return if not wallet.can_sign_without_server(): self.print_error("twofactor:sign_tx") auth_code = None if wallet.keystores["x3/"].get_tx_derivations(tx): auth_code = self.auth_dialog(window) else: self.print_error("twofactor: xpub3 not needed") window.wallet.auth_code = auth_code def waiting_dialog(self, window, on_finished=None): task = partial(self.request_billing_info, window.wallet) return WaitingDialog(window, "Getting billing information...", task, on_finished) @hook def abort_send(self, window): wallet = window.wallet if not isinstance(wallet, self.wallet_class): return if wallet.can_sign_without_server(): return if wallet.billing_info is None: return True return False def settings_dialog(self, window): self.waiting_dialog(window, partial(self.show_settings_dialog, window)) def show_settings_dialog(self, window, success): if not success: window.show_message(_("Server not reachable.")) return wallet = window.wallet d = WindowModalDialog(window, _("TrustedCoin Information")) d.setMinimumSize(500, 200) vbox = QVBoxLayout(d) hbox = QHBoxLayout() logo = QLabel() logo.setPixmap(QPixmap(":icons/trustedcoin-status.png")) msg = _("This wallet is protected by TrustedCoin's two-factor authentication.") + "<br/>" + _("For more information, visit") + ' <a href="https://api.trustedcoin.com/#/electrum-help">https://api.trustedcoin.com/#/electrum-help</a>' label = QLabel(msg) label.setOpenExternalLinks(1) hbox.addStretch(10) hbox.addWidget(logo) hbox.addStretch(10) hbox.addWidget(label) hbox.addStretch(10) vbox.addLayout(hbox) vbox.addStretch(10) msg = _("TrustedCoin charges a small fee to co-sign transactions. The fee depends on how many prepaid transactions you buy. An extra output is added to your transaction everytime you run out of prepaid transactions.") + "<br/>" label = QLabel(msg) label.setWordWrap(1) vbox.addWidget(label) vbox.addStretch(10) grid = QGridLayout() vbox.addLayout(grid) price_per_tx = wallet.price_per_tx n_prepay = wallet.num_prepay(self.config) i = 0 for k, v in sorted(price_per_tx.items()): if k == 1: continue grid.addWidget(QLabel("Pay every %d transactions:" % k), i, 0) grid.addWidget(QLabel(window.format_amount(v / k) + " " + window.base_unit() + "/tx"), i, 1) b = QRadioButton() b.setChecked(k == n_prepay) b.clicked.connect(lambda b, k=k: self.config.set_key("trustedcoin_prepay", k, True)) grid.addWidget(b, i, 2) i += 1 n = wallet.billing_info.get("tx_remaining", 0) grid.addWidget(QLabel(_("Your wallet has {} prepaid transactions.").format(n)), i, 0) vbox.addLayout(Buttons(CloseButton(d))) d.exec_() def on_buy(self, window, k, v, d): d.close() if window.pluginsdialog: window.pluginsdialog.close() wallet = window.wallet uri = "bitcoin:" + wallet.billing_info["billing_address"] + "?message=TrustedCoin %d Prepaid Transactions&amount=" % k + str(Decimal(v) / 100000000) wallet.is_billing = True window.pay_to_URI(uri) window.payto_e.setFrozen(True) window.message_e.setFrozen(True) window.amount_e.setFrozen(True) def accept_terms_of_use(self, window): vbox = QVBoxLayout() vbox.addWidget(QLabel(_("Terms of Service"))) tos_e = TOS() tos_e.setReadOnly(True) vbox.addWidget(tos_e) tos_received = False vbox.addWidget(QLabel(_("Please enter your e-mail address"))) email_e = QLineEdit() vbox.addWidget(email_e) next_button = window.next_button prior_button_text = next_button.text() next_button.setText(_("Accept")) def request_TOS(): try: tos = server.get_terms_of_service() except Exception as e: traceback.print_exc(file=sys.stderr) tos_e.error_signal.emit(_("Could not retrieve Terms of Service:") + "\n" + str(e)) return self.TOS = tos tos_e.tos_signal.emit() def on_result(): tos_e.setText(self.TOS) nonlocal tos_received tos_received = True set_enabled() def on_error(msg): window.show_error(str(msg)) window.terminate() def set_enabled(): valid_email = re.match(regexp, email_e.text()) is not None next_button.setEnabled(tos_received and valid_email) tos_e.tos_signal.connect(on_result) tos_e.error_signal.connect(on_error) t = Thread(target=request_TOS) t.setDaemon(True) t.start() regexp = r"[^@]+@[^@]+\.[^@]+" email_e.textChanged.connect(set_enabled) email_e.setFocus(True) window.exec_layout(vbox, next_enabled=False) next_button.setText(prior_button_text) return str(email_e.text()) def request_otp_dialog(self, window, _id, otp_secret): vbox = QVBoxLayout() if otp_secret is not None: uri = "otpauth://totp/%s?secret=%s" % ("trustedcoin.com", otp_secret) l = QLabel("Please scan the following QR code in Google Authenticator. You may as well use the following key: %s" % otp_secret) l.setWordWrap(True) vbox.addWidget(l) qrw = QRCodeWidget(uri) vbox.addWidget(qrw, 1) msg = _("Then, enter your Google Authenticator code:") else: label = QLabel("This wallet is already registered with Trustedcoin. " "To finalize wallet creation, please enter your Google Authenticator Code. ") label.setWordWrap(1) vbox.addWidget(label) msg = _("Google Authenticator code:") hbox = QHBoxLayout() hbox.addWidget(WWLabel(msg)) pw = AmountEdit(None, is_int=True) pw.setFocus(True) pw.setMaximumWidth(50) hbox.addWidget(pw) vbox.addLayout(hbox) cb_lost = QCheckBox(_("I have lost my Google Authenticator account")) cb_lost.setToolTip(_("Check this box to request a new secret. You will need to retype your seed.")) vbox.addWidget(cb_lost) cb_lost.setVisible(otp_secret is None) def set_enabled(): b = True if cb_lost.isChecked() else len(pw.text()) == 6 window.next_button.setEnabled(b) pw.textChanged.connect(set_enabled) cb_lost.toggled.connect(set_enabled) window.exec_layout(vbox, next_enabled=False, raise_on_cancel=False) return pw.get_amount(), cb_lost.isChecked()
# ! Desafio 56 # ! Crie um programa que leia o nome, idade e sexo de 4 pessoas. No final do programa, mostre: # ! A media de idade do grupo # ! Qual é o nome do homem mais velho # ! Quantas mulheres tem menos de 20 anos. SomaIdade = 0 MediaIdade = 0 MaiorIdade = 0 NomeVelho = '' totmulher20 = 0 for p in range(1, 5): print('---- {} º PESSOA ----'.format(p)) nome = str(input('Nome: ')).strip().capitalize() idade = int(input('Idade: ')) sexo = str(input('Sexo [M/F]: ')).strip() SomaIdade += idade if p == 1 and sexo in 'Mm': MaiorIdade = idade NomeVelho = nome if sexo in 'Mm' and idade > MaiorIdade: MaiorIdade = idade NomeVelho = nome if sexo in 'Ff' and idade < 20: totmulher20 +=1 MediaIdade = SomaIdade / 4 print('----- Calculando -----') print('A média de idade do grupo é de {} anos'.format(MediaIdade)) print('O homem mais velho é o {} com {} anos de idade'.format(NomeVelho, MaiorIdade)) print('Ao todo são {} mulheres com menos de 20 anos'.format(totmulher20))
# # PySNMP MIB module ZHONE-PHY-SONET-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/ZHONE-PHY-SONET-MIB # Produced by pysmi-0.3.4 at Wed May 1 15:47:49 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") ConstraintsUnion, ValueSizeConstraint, ValueRangeConstraint, ConstraintsIntersection, SingleValueConstraint = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsUnion", "ValueSizeConstraint", "ValueRangeConstraint", "ConstraintsIntersection", "SingleValueConstraint") InterfaceIndex, = mibBuilder.importSymbols("IF-MIB", "InterfaceIndex") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") Unsigned32, Bits, Counter32, Gauge32, MibIdentifier, ObjectIdentity, Counter64, NotificationType, Integer32, MibScalar, MibTable, MibTableRow, MibTableColumn, iso, IpAddress, ModuleIdentity, TimeTicks = mibBuilder.importSymbols("SNMPv2-SMI", "Unsigned32", "Bits", "Counter32", "Gauge32", "MibIdentifier", "ObjectIdentity", "Counter64", "NotificationType", "Integer32", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "iso", "IpAddress", "ModuleIdentity", "TimeTicks") TextualConvention, TruthValue, DisplayString = mibBuilder.importSymbols("SNMPv2-TC", "TextualConvention", "TruthValue", "DisplayString") sonetMediumEntry, sonetPathCurrentStatus, sonetSectionCurrentStatus, sonetLineCurrentStatus = mibBuilder.importSymbols("SONET-MIB", "sonetMediumEntry", "sonetPathCurrentStatus", "sonetSectionCurrentStatus", "sonetLineCurrentStatus") zhoneModules, zhoneSonet = mibBuilder.importSymbols("Zhone", "zhoneModules", "zhoneSonet") phySonet = ModuleIdentity((1, 3, 6, 1, 4, 1, 5504, 6, 16)) phySonet.setRevisions(('2004-08-18 11:47', '2003-07-10 13:30', '2002-03-26 14:30', '2001-09-12 15:08', '2001-07-19 18:00', '2001-02-22 11:35', '2000-12-19 15:23', '2000-12-18 16:20',)) if getattr(mibBuilder, 'version', (0, 0, 0)) > (4, 4, 0): if mibBuilder.loadTexts: phySonet.setRevisionsDescriptions(('1.03.04 - Add zhoneSonetErrorStatsTable.', '1.03.02 Add sonetPathStatusChange trap.', '1.03.01 Add sonetSectionStatusChange trap and sonetLineStatusChange trap.', 'V01.03.00 Changed names for valid values for sonetClockTransmitSource', 'V01.02.00 Add Sonet clock source change trap.', 'V01.01.00 - Add Sonet Medium Extension Table.', 'V01.00.01 - Add Zhone keywords.', 'V01.00.00 - Initial Release',)) if mibBuilder.loadTexts: phySonet.setLastUpdated('200408181330Z') if mibBuilder.loadTexts: phySonet.setOrganization('Zhone Technologies, Inc.') if mibBuilder.loadTexts: phySonet.setContactInfo(' Postal: Zhone Technologies, Inc. @ Zhone Way 7001 Oakport Street Oakland, CA 94621 USA Toll-Free: +1 877-ZHONE20 (+1 877-946-6320) Tel: +1-510-777-7000 Fax: +1-510-777-7001 E-mail: support@zhone.com') if mibBuilder.loadTexts: phySonet.setDescription('SONET physical MIB to configure and monitor SONET physical attributes. ') sonetClockTable = MibTable((1, 3, 6, 1, 4, 1, 5504, 5, 9, 1), ) if mibBuilder.loadTexts: sonetClockTable.setStatus('current') if mibBuilder.loadTexts: sonetClockTable.setDescription('MIB table for clock related configuration for SONET interfaces.') sonetClockEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5504, 5, 9, 1, 1), ) sonetMediumEntry.registerAugmentions(("ZHONE-PHY-SONET-MIB", "sonetClockEntry")) sonetClockEntry.setIndexNames(*sonetMediumEntry.getIndexNames()) if mibBuilder.loadTexts: sonetClockEntry.setStatus('current') if mibBuilder.loadTexts: sonetClockEntry.setDescription('An entry of the sonetClockEntry. sonetClockEntry is augmented to sonetMediumEntry defined in rfc2558.mib. Whenever a row is instantiated in the sonetMediumTable, a corresponding row will be instantiated in the sonetClockTable.') sonetClockExternalRecovery = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 1, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: sonetClockExternalRecovery.setStatus('current') if mibBuilder.loadTexts: sonetClockExternalRecovery.setDescription("This variable indicates if external clock recovery is enabled for this SONET interface. The default value is 'enabled'.") sonetClockTransmitSource = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 1, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2, 3, 4))).clone(namedValues=NamedValues(("loopTiming", 1), ("throughTiming", 2), ("localTiming", 3), ("external155MHz", 4)))).setMaxAccess("readwrite") if mibBuilder.loadTexts: sonetClockTransmitSource.setStatus('current') if mibBuilder.loadTexts: sonetClockTransmitSource.setDescription("This variable describes the SONET transmit clock source. Valid values are: loopTiming - transmit clock synthesized from the recovered receive clock. throughTiming - transmit clock is derived from the recovered receive clock of another SONET interface. localTiming - transmit clock synthesized from a local clock source or that an external clock is attached to the box containing the interface. external155MHz - transmit clock synthesized from an external 155.52 MHz source. The default value is 'loopTiming'. 'external155MHz' option is not valid for Sechtor 100.") sonetMediumExtTable = MibTable((1, 3, 6, 1, 4, 1, 5504, 5, 9, 2), ) if mibBuilder.loadTexts: sonetMediumExtTable.setStatus('current') if mibBuilder.loadTexts: sonetMediumExtTable.setDescription('This is an extenion of the standard Sonet MIB (RFC 2558).') sonetMediumExtEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5504, 5, 9, 2, 1), ) sonetMediumEntry.registerAugmentions(("ZHONE-PHY-SONET-MIB", "sonetMediumExtEntry")) sonetMediumExtEntry.setIndexNames(*sonetMediumEntry.getIndexNames()) if mibBuilder.loadTexts: sonetMediumExtEntry.setStatus('current') if mibBuilder.loadTexts: sonetMediumExtEntry.setDescription('Each row is an extension to the sonetMediumTable for Zhone specific fields. This row is created when the augmented sonetMediumEntry is created.') sonetMediumExtScrambleEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 2, 1, 1), TruthValue().clone('true')).setMaxAccess("readwrite") if mibBuilder.loadTexts: sonetMediumExtScrambleEnabled.setStatus('current') if mibBuilder.loadTexts: sonetMediumExtScrambleEnabled.setDescription('This field describes the enabled status of the Sonet Scramble mode. If this field is true(1) then Scramble mode is enabled, if this field is false(2) scramble mode is disable.') sonetMediumExtLineScrmEnabled = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 2, 1, 2), TruthValue().clone('true')).setMaxAccess("readwrite") if mibBuilder.loadTexts: sonetMediumExtLineScrmEnabled.setStatus('current') if mibBuilder.loadTexts: sonetMediumExtLineScrmEnabled.setDescription('This field describes the enabled status of the Line level Sonet Scramble mode. If this field is true(1), then Scramble mode is enabled. If this field is false(2), scramble mode is disable.') sonetTraps = ObjectIdentity((1, 3, 6, 1, 4, 1, 5504, 5, 9, 3)) if mibBuilder.loadTexts: sonetTraps.setStatus('current') if mibBuilder.loadTexts: sonetTraps.setDescription('All Zhone Sonet traps will be defined under this object identity.') sonetV2Traps = ObjectIdentity((1, 3, 6, 1, 4, 1, 5504, 5, 9, 3, 0)) if mibBuilder.loadTexts: sonetV2Traps.setStatus('current') if mibBuilder.loadTexts: sonetV2Traps.setDescription('This object identity adds a zero(0) for the next to last sub-identifier which should be used for new SNMPv2 Traps.') sonetClockTransmitSourceChange = NotificationType((1, 3, 6, 1, 4, 1, 5504, 5, 9, 3, 0, 1)).setObjects(("ZHONE-PHY-SONET-MIB", "sonetClockExternalRecovery"), ("ZHONE-PHY-SONET-MIB", "sonetClockTransmitSource")) if mibBuilder.loadTexts: sonetClockTransmitSourceChange.setStatus('current') if mibBuilder.loadTexts: sonetClockTransmitSourceChange.setDescription('A notification trap is sent when either sonetClockExternalRecovery or sonetClockTransmitSource is changed. The trap object is identified by the OID instance of sonetClockTransmitSource described in the OBJECTS clause.') sonetSectionStatusChange = NotificationType((1, 3, 6, 1, 4, 1, 5504, 5, 9, 3, 0, 2)).setObjects(("SONET-MIB", "sonetSectionCurrentStatus")) if mibBuilder.loadTexts: sonetSectionStatusChange.setStatus('current') if mibBuilder.loadTexts: sonetSectionStatusChange.setDescription('A notification trap is sent when there is a change in the sonet SECTION status. Currenly the following are supported: NO-DEFECT = 1 LOS = 2 LOF = 4 The trap object is identified by the OID instance of sonetSectionCurrentStatus described in the OBJECTS clause.') sonetLineStatusChange = NotificationType((1, 3, 6, 1, 4, 1, 5504, 5, 9, 3, 0, 3)).setObjects(("SONET-MIB", "sonetLineCurrentStatus")) if mibBuilder.loadTexts: sonetLineStatusChange.setStatus('current') if mibBuilder.loadTexts: sonetLineStatusChange.setDescription('A notification trap is sent when there is a change in the sonet LINE status. Currenly the following are supported: NO-DEFECT = 1 AIS = 2 RDI = 4 The trap object is identified by the OID instance of sonetLineCurrentStatus described in the OBJECTS clause.') sonetPathStatusChange = NotificationType((1, 3, 6, 1, 4, 1, 5504, 5, 9, 3, 0, 4)).setObjects(("SONET-MIB", "sonetPathCurrentStatus")) if mibBuilder.loadTexts: sonetPathStatusChange.setStatus('current') if mibBuilder.loadTexts: sonetPathStatusChange.setDescription('A notification trap is sent when there is a change in the sonetPathCurrentStatus. Currenly the following are supported: 1 sonetPathNoDefect 2 sonetPathSTSLOP 4 sonetPathSTSAIS 8 sonetPathSTSRDI 16 sonetPathUnequipped 32 sonetPathSignalLabelMismatch The trap object is identified by the OID instance of sonetPathCurrentStatus described in the OBJECTS clause.') zhoneSonetErrorStatsTable = MibTable((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6), ) if mibBuilder.loadTexts: zhoneSonetErrorStatsTable.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsTable.setDescription('Description.') zhoneSonetErrorStatsEntry = MibTableRow((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1), ).setIndexNames((0, "ZHONE-PHY-SONET-MIB", "zhoneSonetErrorStatsIndex")) if mibBuilder.loadTexts: zhoneSonetErrorStatsEntry.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsEntry.setDescription('Description.') zhoneSonetErrorStatsIndex = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 1), InterfaceIndex()) if mibBuilder.loadTexts: zhoneSonetErrorStatsIndex.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsIndex.setDescription('Description.') zhoneSonetErrorStatsLineFebeCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 2), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsLineFebeCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsLineFebeCount.setDescription('Number of RLOP far-end block errors (FEBE).') zhoneSonetErrorStatsPathFebeCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 3), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsPathFebeCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsPathFebeCount.setDescription('Number of RPOP far-end block errors (FEBE).') zhoneSonetErrorStatsLineBipCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 4), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsLineBipCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsLineBipCount.setDescription('Number of Receive Line Overhead Processor (RLOP) BIP-8 errors. The RLOP is responsible for line-level alarms and for monitoring performance.') zhoneSonetErrorStatsSectionBipCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 5), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsSectionBipCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsSectionBipCount.setDescription('Number of Receive Section Overhead Processor (RSOP) bit-interleaved parity (BIP)-8 errors. The RSOP synchronizes and descrambles frames and provides section-level alarms and performance monitoring.') zhoneSonetErrorStatsPathBipCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 6), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsPathBipCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsPathBipCount.setDescription('Number of Receive Path Overhead Processor (RPOP) BIP-8 errors. The RSOP interprets pointers and extracts path overhead and the synchronous payload envelope. It is also responsible for path-level alarms and for monitoring performance.') zhoneSonetErrorStatsOofCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 7), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsOofCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsOofCount.setDescription('Near end is out of frame. False indicates that the line is up and in frame.') zhoneSonetErrorStatsRxCellCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 8), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsRxCellCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsRxCellCount.setDescription('Receive ATM Cell Processor (RACP) receive cell count.') zhoneSonetErrorStatsTxCellCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 9), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsTxCellCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsTxCellCount.setDescription('Transmit ATM Cell Processor (TACP) transmit cell count.') zhoneSonetErrorStatsHecCorrectedCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 10), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsHecCorrectedCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsHecCorrectedCount.setDescription('Number of corrected HEC cells.') zhoneSonetErrorStatsHecUncorrectedCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 11), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsHecUncorrectedCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsHecUncorrectedCount.setDescription('Number of uncorrected dropped HEC cells.') zhoneSonetErrorStatsCellFifoOverflowCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 12), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsCellFifoOverflowCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsCellFifoOverflowCount.setDescription('Number of cells dropped because of first in, first out (FIFO) overflow.') zhoneSonetErrorStatsLocdCount = MibTableColumn((1, 3, 6, 1, 4, 1, 5504, 5, 9, 6, 1, 13), Integer32()).setMaxAccess("readonly") if mibBuilder.loadTexts: zhoneSonetErrorStatsLocdCount.setStatus('current') if mibBuilder.loadTexts: zhoneSonetErrorStatsLocdCount.setDescription('Loss of cell delineation.') mibBuilder.exportSymbols("ZHONE-PHY-SONET-MIB", sonetLineStatusChange=sonetLineStatusChange, zhoneSonetErrorStatsPathBipCount=zhoneSonetErrorStatsPathBipCount, zhoneSonetErrorStatsSectionBipCount=zhoneSonetErrorStatsSectionBipCount, sonetTraps=sonetTraps, zhoneSonetErrorStatsPathFebeCount=zhoneSonetErrorStatsPathFebeCount, zhoneSonetErrorStatsRxCellCount=zhoneSonetErrorStatsRxCellCount, sonetMediumExtEntry=sonetMediumExtEntry, sonetMediumExtTable=sonetMediumExtTable, sonetClockEntry=sonetClockEntry, sonetSectionStatusChange=sonetSectionStatusChange, sonetClockExternalRecovery=sonetClockExternalRecovery, sonetClockTransmitSource=sonetClockTransmitSource, sonetMediumExtLineScrmEnabled=sonetMediumExtLineScrmEnabled, zhoneSonetErrorStatsHecCorrectedCount=zhoneSonetErrorStatsHecCorrectedCount, zhoneSonetErrorStatsTable=zhoneSonetErrorStatsTable, zhoneSonetErrorStatsIndex=zhoneSonetErrorStatsIndex, zhoneSonetErrorStatsLineFebeCount=zhoneSonetErrorStatsLineFebeCount, phySonet=phySonet, sonetV2Traps=sonetV2Traps, sonetMediumExtScrambleEnabled=sonetMediumExtScrambleEnabled, zhoneSonetErrorStatsEntry=zhoneSonetErrorStatsEntry, zhoneSonetErrorStatsLineBipCount=zhoneSonetErrorStatsLineBipCount, PYSNMP_MODULE_ID=phySonet, zhoneSonetErrorStatsHecUncorrectedCount=zhoneSonetErrorStatsHecUncorrectedCount, sonetPathStatusChange=sonetPathStatusChange, sonetClockTransmitSourceChange=sonetClockTransmitSourceChange, sonetClockTable=sonetClockTable, zhoneSonetErrorStatsCellFifoOverflowCount=zhoneSonetErrorStatsCellFifoOverflowCount, zhoneSonetErrorStatsOofCount=zhoneSonetErrorStatsOofCount, zhoneSonetErrorStatsLocdCount=zhoneSonetErrorStatsLocdCount, zhoneSonetErrorStatsTxCellCount=zhoneSonetErrorStatsTxCellCount)
### SATISFACTORY RESPONSE ## Not found code OK = 200 OK_NOCONTENT = 204 ### CLIENT ERROR ## Not found code NOT_FOUND = 404 UNAUTHORIZED = 401 ### SERVER ERROR ## Internal server error INTERNAL_ERROR = 500
""" Time complexity O(n) """ # Search for maximum number l = [2, 4, 5, 1, 80, 5, 99] maximum = l[0] for item in l: if item > maximum: maximum = item print(maximum)
# DESCRIPTION # Return the root node of a binary search tree that matches the given preorder traversal. # It's guaranteed that for the given test cases there is always possible to find a # binary search tree with the given requirements. # EXAMPLE # Input: [8,5,1,7,10,12] # Output: [8,5,10,1,7,null,12] # 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 bstFromPreorder(self, preorder: List[int]) -> TreeNode: ''' Time: O(N), Must iterate over every element of the list Space: O(N), max space needed for recursive stack ''' self.index = 0 return self.bst_build(preorder, float('inf')) def bst_build(self, preorder, limit): # if we have run out of numbers in list # or the curr val is larger than the limit if self.index >= len(preorder) or preorder[self.index] > limit: return None root = TreeNode(preorder[self.index]) # inc to move with the list self.index += 1 # must not be larger than the parent value root.left = self.bst_build(preorder, root.val) # must not be larger than the parents limit root.right = self.bst_build(preorder, limit) return root
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None ## mergesort class Solution(object): def sortList(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.next: return head p,s,f = None, head, head while f and f.next: p,s,f = s,s.next,f.next.next p.next=None return self.merge(self.sortList(head), self.sortList(s)) def merge(self, h1, h2): res=res0=ListNode(0) while h1 or h2: if h1 and h2: if h1.val<=h2.val: res.next = h1 res = res.next h1 = h1.next res.next = None else: res.next = h2 res = res.next h2 = h2.next res.next = None elif h1: res.next = h1 h1 = None else: res.next = h2 h2 = None return res0.next
def find_floor(brackets: str) -> int: return sum(1 if c == '(' else -1 for c in brackets) def find_basement_entry(brackets: str) -> int: return [n + 1 for n in range(len(brackets)) if find_floor(brackets[:n + 1]) == -1][0] if __name__ == '__main__': with open('input') as f: bracket_text = f.read() print(f'Part 1: {find_floor(bracket_text)}') print(f'Part 2: {find_basement_entry(bracket_text)}')
result = [ None, 6, ['a', 'b', 'c', {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}], {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}, {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}, ['a', 'b', 'c', {'uu': 5.6, 'oo': [Ellipsis], 'ii': {Ellipsis}}], None, 6 ] def is_equal(a, b, message): comparable_a = [ a[0], a[1], [a[2][0], a[2][1], a[2][2], {'uu': a[2][3]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}], {'uu': a[3]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}, {'uu': a[4]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}, [a[5][0], a[5][1], a[5][2], {'uu': a[5][3]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}], a[6], a[7] ] comparable_b = [ b[0], b[1], [b[2][0], b[2][1], b[2][2], {'uu': b[2][3]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}], {'uu': b[3]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}, {'uu': b[4]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}, [b[5][0], b[5][1], b[5][2], {'uu': b[5][3]['uu'], 'oo': [Ellipsis], 'ii': [Ellipsis]}], b[6], b[7] ] if len(a) != len(b): raise AssertionError(message + ': Array length differs') non_recursive_a = [a[0], a[1], a[-2], a[-1]] non_recursive_b = [b[0], b[1], b[-2], b[-1]] if non_recursive_a != non_recursive_b: raise AssertionError(message + ': non-recursive part differs') if comparable_a != comparable_b: raise AssertionError(message + ': recursive part differs')
p1, p2 = map(int, input().split()) m = (p1 + p2) / 2 if m >= 7: print(f'{m} - Aprovado', end='') elif m < 5: print(f'{m} - Reprovado', end='') else: print(f'{m} - De Recuperacao', end='')
"""680. Valid Palindrome II https://leetcode.com/problems/valid-palindrome-ii/ """ class Solution: def validPalindrome(self, s: str) -> bool: def helper(i: int, j: int, flag: bool) -> bool: while i < j: if s[i] == s[j]: i += 1 j -= 1 elif not flag: return False else: return helper(i + 1, j, False) or helper(i, j - 1, False) return True return helper(0, len(s) - 1, True)
# # PySNMP MIB module RADIUS-ACCOUNTING-MIB (http://snmplabs.com/pysmi) # ASN.1 source file:///Users/davwang4/Dev/mibs.snmplabs.com/asn1/RADIUS-ACCOUNTING-MIB # Produced by pysmi-0.3.4 at Wed May 1 14:44:47 2019 # On host DAVWANG4-M-1475 platform Darwin version 18.5.0 by user davwang4 # Using Python version 3.7.3 (default, Mar 27 2019, 09:23:15) # Integer, ObjectIdentifier, OctetString = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString") NamedValues, = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues") ValueRangeConstraint, ConstraintsUnion, SingleValueConstraint, ValueSizeConstraint, ConstraintsIntersection = mibBuilder.importSymbols("ASN1-REFINEMENT", "ValueRangeConstraint", "ConstraintsUnion", "SingleValueConstraint", "ValueSizeConstraint", "ConstraintsIntersection") dlink_common_mgmt, = mibBuilder.importSymbols("DLINK-ID-REC-MIB", "dlink-common-mgmt") NotificationGroup, ModuleCompliance = mibBuilder.importSymbols("SNMPv2-CONF", "NotificationGroup", "ModuleCompliance") IpAddress, Gauge32, Counter32, iso, ObjectIdentity, TimeTicks, MibScalar, MibTable, MibTableRow, MibTableColumn, MibIdentifier, Integer32, ModuleIdentity, Bits, NotificationType, Counter64, Unsigned32 = mibBuilder.importSymbols("SNMPv2-SMI", "IpAddress", "Gauge32", "Counter32", "iso", "ObjectIdentity", "TimeTicks", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "MibIdentifier", "Integer32", "ModuleIdentity", "Bits", "NotificationType", "Counter64", "Unsigned32") DisplayString, TextualConvention = mibBuilder.importSymbols("SNMPv2-TC", "DisplayString", "TextualConvention") swRadiusAccountMGMTMIB = ModuleIdentity((1, 3, 6, 1, 4, 1, 171, 12, 55)) if mibBuilder.loadTexts: swRadiusAccountMGMTMIB.setLastUpdated('0712200000Z') if mibBuilder.loadTexts: swRadiusAccountMGMTMIB.setOrganization('D-Link Corp.') if mibBuilder.loadTexts: swRadiusAccountMGMTMIB.setContactInfo('http://support.dlink.com') if mibBuilder.loadTexts: swRadiusAccountMGMTMIB.setDescription('The structure of RADIUS accounting for the proprietary enterprise.') radiusAccountCtrl = MibIdentifier((1, 3, 6, 1, 4, 1, 171, 12, 55, 1)) accountingShellState = MibScalar((1, 3, 6, 1, 4, 1, 171, 12, 55, 1, 1), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite") if mibBuilder.loadTexts: accountingShellState.setStatus('current') if mibBuilder.loadTexts: accountingShellState.setDescription('Specifies the status of the RADIUS accounting service for shell events.') accountingSystemState = MibScalar((1, 3, 6, 1, 4, 1, 171, 12, 55, 1, 2), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite") if mibBuilder.loadTexts: accountingSystemState.setStatus('current') if mibBuilder.loadTexts: accountingSystemState.setDescription('Specifies the status of the RADIUS accounting service for system events.') accountingNetworkState = MibScalar((1, 3, 6, 1, 4, 1, 171, 12, 55, 1, 3), Integer32().subtype(subtypeSpec=ConstraintsUnion(SingleValueConstraint(1, 2))).clone(namedValues=NamedValues(("enabled", 1), ("disabled", 2))).clone('disabled')).setMaxAccess("readwrite") if mibBuilder.loadTexts: accountingNetworkState.setStatus('current') if mibBuilder.loadTexts: accountingNetworkState.setDescription('Specifies the status of the RADIUS accounting service for 802.1x port access control.') mibBuilder.exportSymbols("RADIUS-ACCOUNTING-MIB", accountingShellState=accountingShellState, accountingSystemState=accountingSystemState, PYSNMP_MODULE_ID=swRadiusAccountMGMTMIB, radiusAccountCtrl=radiusAccountCtrl, swRadiusAccountMGMTMIB=swRadiusAccountMGMTMIB, accountingNetworkState=accountingNetworkState)
#!/usr/bin/env python3 # # --- Day 19: Beacon Scanner --- # # As your probe drifted down through this area, it released an assortment # of beacons and scanners into the water. It's difficult to navigate in the # pitch black open waters of the ocean trench, but if you can build a map # of the trench using data from the scanners, you should be able to safely # reach the bottom. # # The beacons and scanners float motionless in the water; they're designed # to maintain the same position for long periods of time. Each scanner is # capable of detecting all beacons in a large cube centered on the scanner; # beacons that are at most 1000 units away from the scanner in each of the # three axes (x, y, and z) have their precise position determined relative # to the scanner. However, scanners cannot detect other scanners. The submarin # has automatically summarized the relative positions of beacons detected # by each scanner (your puzzle input). # # For example, if a scanner is at x,y,z coordinates 500,0,-500 and there are # beacons at -500,1000,-1500 and 1501,0,-500, the scanner could report that # the first beacon is at -1000,1000,-1000 (relative to the scanner) but would # not detect the second beacon at all. # # Unfortunately, while each scanner can report the positions of all detected # beacons relative to itself, the scanners do not know their own position. # You'll need to determine the positions of the beacons and scanners yourself. # # The scanners and beacons map a single contiguous 3d region. This region can # be reconstructed by finding pairs of scanners that have overlapping detection # regions such that there are at least 12 beacons that both scanners detect # within the overlap. By establishing 12 common beacons, you can precisely # determine where the scanners are relative to each other, allowing you # to reconstruct the beacon map one scanner at a time. # # For a moment, consider only two dimensions. Suppose you have the following # scanner reports: # --- scanner 0 --- # 0,2 # 4,1 # 3,3 # # --- scanner 1 --- # -1,-1 # -5,0 # -2,1 # # Drawing x increasing rightward, y increasing upward, scanners as S, # and beacons as B, scanner 0 detects this: # ...B. # B.... # ....B # S.... # # Scanner 1 detects this: # ...B.. # B....S # ....B. # # For this example, assume scanners only need 3 overlapping beacons. Then, # the beacons visible to both scanners overlap to produce the following # complete map: # ...B.. # B....S # ....B. # S..... # # Unfortunately, there's a second problem: the scanners also don't know their # rotation or facing direction. Due to magnetic alignment, each scanner is # rotated some integer number of 90-degree turns around all of the x, y, and z # axes. That is, one scanner might call a direction positive x, while another # scanner might call that direction negative y. Or, two scanners might agree # on which direction is positive x, but one scanner might be upside-down from # the perspective of the other scanner. In total, each scanner could be in any # of 24 different orientations: facing positive or negative x, y, or z, and # considering any of four directions "up" from that facing. # # For example, here is an arrangement of beacons as seen from a scanner in the # same position but in different orientations: # --- scanner 0 --- # -1,-1,1 # -2,-2,2 # -3,-3,3 # -2,-3,1 # 5,6,-4 # 8,0,7 # # --- scanner 0 --- # 1,-1,1 # 2,-2,2 # 3,-3,3 # 2,-1,3 # -5,4,-6 # -8,-7,0 # # --- scanner 0 --- # -1,-1,-1 # -2,-2,-2 # -3,-3,-3 # -1,-3,-2 # 4,6,5 # -7,0,8 # # --- scanner 0 --- # 1,1,-1 # 2,2,-2 # 3,3,-3 # 1,3,-2 # -4,-6,5 # 7,0,8 # # --- scanner 0 --- # 1,1,1 # 2,2,2 # 3,3,3 # 3,1,2 # -6,-4,-5 # 0,7,-8 # # By finding pairs of scanners that both see at least 12 of the same beacons, # you can assemble the entire map. For example, consider the following report: # --- scanner 0 --- # 404,-588,-901 # 528,-643,409 # -838,591,734 # 390,-675,-793 # -537,-823,-458 # -485,-357,347 # -345,-311,381 # -661,-816,-575 # -876,649,763 # -618,-824,-621 # 553,345,-567 # 474,580,667 # -447,-329,318 # -584,868,-557 # 544,-627,-890 # 564,392,-477 # 455,729,728 # -892,524,684 # -689,845,-530 # 423,-701,434 # 7,-33,-71 # 630,319,-379 # 443,580,662 # -789,900,-551 # 459,-707,401 # # --- scanner 1 --- # 686,422,578 # 605,423,415 # 515,917,-361 # -336,658,858 # 95,138,22 # -476,619,847 # -340,-569,-846 # 567,-361,727 # -460,603,-452 # 669,-402,600 # 729,430,532 # -500,-761,534 # -322,571,750 # -466,-666,-811 # -429,-592,574 # -355,545,-477 # 703,-491,-529 # -328,-685,520 # 413,935,-424 # -391,539,-444 # 586,-435,557 # -364,-763,-893 # 807,-499,-711 # 755,-354,-619 # 553,889,-390 # # --- scanner 2 --- # 649,640,665 # 682,-795,504 # -784,533,-524 # -644,584,-595 # -588,-843,648 # -30,6,44 # -674,560,763 # 500,723,-460 # 609,671,-379 # -555,-800,653 # -675,-892,-343 # 697,-426,-610 # 578,704,681 # 493,664,-388 # -671,-858,530 # -667,343,800 # 571,-461,-707 # -138,-166,112 # -889,563,-600 # 646,-828,498 # 640,759,510 # -630,509,768 # -681,-892,-333 # 673,-379,-804 # -742,-814,-386 # 577,-820,562 # # --- scanner 3 --- # -589,542,597 # 605,-692,669 # -500,565,-823 # -660,373,557 # -458,-679,-417 # -488,449,543 # -626,468,-788 # 338,-750,-386 # 528,-832,-391 # 562,-778,733 # -938,-730,414 # 543,643,-506 # -524,371,-870 # 407,773,750 # -104,29,83 # 378,-903,-323 # -778,-728,485 # 426,699,580 # -438,-605,-362 # -469,-447,-387 # 509,732,623 # 647,635,-688 # -868,-804,481 # 614,-800,639 # 595,780,-596 # # --- scanner 4 --- # 727,592,562 # -293,-554,779 # 441,611,-461 # -714,465,-776 # -743,427,-804 # -660,-479,-426 # 832,-632,460 # 927,-485,-438 # 408,393,-506 # 466,436,-512 # 110,16,151 # -258,-428,682 # -393,719,612 # -211,-452,876 # 808,-476,-593 # -575,615,604 # -485,667,467 # -680,325,-822 # -627,-443,-432 # 872,-547,-609 # 833,512,582 # 807,604,487 # 839,-516,451 # 891,-625,532 # -652,-548,-490 # 30,-46,-14 # # Because all coordinates are relative, in this example, all "absolute" # positions will be expressed relative to scanner 0 (using the orientation # of scanner 0 and as if scanner 0 is at coordinates 0,0,0). # # Scanners 0 and 1 have overlapping detection cubes; the 12 beacons they both # detect (relative to scanner 0) are at the following coordinates: # -618,-824,-621 # -537,-823,-458 # -447,-329,318 # 404,-588,-901 # 544,-627,-890 # 528,-643,409 # -661,-816,-575 # 390,-675,-793 # 423,-701,434 # -345,-311,381 # 459,-707,401 # -485,-357,347 # # These same 12 beacons (in the same order) but from the perspective # of scanner 1 are: # 686,422,578 # 605,423,415 # 515,917,-361 # -336,658,858 # -476,619,847 # -460,603,-452 # 729,430,532 # -322,571,750 # -355,545,-477 # 413,935,-424 # -391,539,-444 # 553,889,-390 # # Because of this, scanner 1 must be at 68,-1246,-43 (relative to scanner 0). # # Scanner 4 overlaps with scanner 1; the 12 beacons they both detect # (relative to scanner 0) are: # 459,-707,401 # -739,-1745,668 # -485,-357,347 # 432,-2009,850 # 528,-643,409 # 423,-701,434 # -345,-311,381 # 408,-1815,803 # 534,-1912,768 # -687,-1600,576 # -447,-329,318 # -635,-1737,486 # # So, scanner 4 is at -20,-1133,1061 (relative to scanner 0). # # Following this process, scanner 2 must be at 1105,-1205,1229 (relative # to scanner 0) and scanner 3 must be at -92,-2380,-20 (relative to scanner 0). # # The full list of beacons (relative to scanner 0) is: # -892,524,684 # -876,649,763 # -838,591,734 # -789,900,-551 # -739,-1745,668 # -706,-3180,-659 # -697,-3072,-689 # -689,845,-530 # -687,-1600,576 # -661,-816,-575 # -654,-3158,-753 # -635,-1737,486 # -631,-672,1502 # -624,-1620,1868 # -620,-3212,371 # -618,-824,-621 # -612,-1695,1788 # -601,-1648,-643 # -584,868,-557 # -537,-823,-458 # -532,-1715,1894 # -518,-1681,-600 # -499,-1607,-770 # -485,-357,347 # -470,-3283,303 # -456,-621,1527 # -447,-329,318 # -430,-3130,366 # -413,-627,1469 # -345,-311,381 # -36,-1284,1171 # -27,-1108,-65 # 7,-33,-71 # 12,-2351,-103 # 26,-1119,1091 # 346,-2985,342 # 366,-3059,397 # 377,-2827,367 # 390,-675,-793 # 396,-1931,-563 # 404,-588,-901 # 408,-1815,803 # 423,-701,434 # 432,-2009,850 # 443,580,662 # 455,729,728 # 456,-540,1869 # 459,-707,401 # 465,-695,1988 # 474,580,667 # 496,-1584,1900 # 497,-1838,-617 # 527,-524,1933 # 528,-643,409 # 534,-1912,768 # 544,-627,-890 # 553,345,-567 # 564,392,-477 # 568,-2007,-577 # 605,-1665,1952 # 612,-1593,1893 # 630,319,-379 # 686,-3108,-505 # 776,-3184,-501 # 846,-3110,-434 # 1135,-1161,1235 # 1243,-1093,1063 # 1660,-552,429 # 1693,-557,386 # 1735,-437,1738 # 1749,-1800,1813 # 1772,-405,1572 # 1776,-675,371 # 1779,-442,1789 # 1780,-1548,337 # 1786,-1538,337 # 1847,-1591,415 # 1889,-1729,1762 # 1994,-1805,1792 # # In total, there are 79 beacons. # # Assemble the full map of beacons. How many beacons are there? # # # --- Solution --- # # We start by reading the input file and splitting it by single empty line. # Then for each entry we drop the first line (header with scanner identifier) # and map remaining to list of integers (the coordinates). Then we produce # a set of all possible rotations about X, Y and Z axes – for this we implement # the rotation equations from the matrix forms and other helper functions. # Ultimately this set gives us all unique transformations we can perform: # how to remap the indexes and flip the axes. For example a tuple: ((1, 0, 2), # (-1, 1, -1)) describes we should put Y (1) as first index, X (0) as second, # Z (2) as third and invert the first and last element in final vector. # Next we take a single set of readings from scanners and we treat it as our # base with origin/reference point (0, 0, 0). Then in a loop, as long as there # are some unmapped scanners, we attempt to find a transformations that will # cause some readings to overlap in at least 12 points. To find a mapping for # a given scanner, we consider all possible rotations of a scanner beacon # readings and then we compute the translation vectors between each rotated # beacon position and each already mapped (known/recognized/unique) beacon. # Finally for each of translations we produce a set of translated beacons # positions and we get an intersection of this set and our set of already # mapped beacons (i.e. we find a list of all common elements between two sets) # – if there are at least 12 common elements, we found the proper translation # that allows us to join the sets and recognize new beacons positions by simply # adding two sets (an union operation). In the end we remove the just mapped # scanner from the list and start this procedure again for all remaining # scanners, every time with a bigger set of identified unique beacons. # As an answer, we print the length of generated set after there are no more # unmapped scanners. # INPUT_FILE = 'input.txt' def sin(angle): angle %= 360 if angle == 0 or angle == 180: return 0 elif angle == 90: return 1 elif angle == 270: return -1 raise ValueError('Only the multiples of the right angle are supported.') def cos(angle): return sin(angle + 90) def rotation_x(angle, vec): return [ vec[0], cos(angle) * vec[1] + -sin(angle) * vec[2], sin(angle) * vec[1] + cos(angle) * vec[2], ] def rotation_y(angle, vec): return [ cos(angle) * vec[0] + sin(angle) * vec[2], vec[1], -sin(angle) * vec[0] + cos(angle) * vec[2], ] def rotation_z(angle, vec): return [ cos(angle) * vec[0] + -sin(angle) * vec[1], sin(angle) * vec[0] + cos(angle) * vec[1], vec[2], ] def rotation_xyz(angle_x, angle_y, angle_z, vec): return rotation_z(angle_z, rotation_y(angle_y, rotation_x(angle_x, vec))) def abs(value): if value >= 0: return value else: return -value def sign(value): if value >= 0: return 1 elif value < 0: return -1 def main(): with open(INPUT_FILE, 'r') as file: scanners = file.read().strip().split('\n\n') for i, scanner in enumerate(scanners): scanners[i] = [tuple(map(int, line.split(','))) for line in scanner.split('\n')[1:]] rotations = set() transformations = set() for angle1 in [0, 90, 180, 270]: for angle2 in [0, 90, 180, 270]: for angle3 in [0, 90, 180, 270]: vec = rotation_xyz(angle1, angle2, angle3, [1, 2, 3]) rotations.add(tuple(vec)) for transformation in rotations: indexes = tuple([abs(component) - 1 for component in transformation]) signs = tuple([sign(component) for component in transformation]) transformations.add((indexes, signs)) known = set(scanners.pop(0)) # first scanner is our origin point (0, 0, 0) while scanners: matched = False for scanner in scanners: for transformation in transformations: indexes, signs = transformation nx, ny, nz = indexes s1, s2, s3 = signs rotated = [(s1 * beacon[nx], s2 * beacon[ny], s3 * beacon[nz]) for beacon in scanner] for reading in known: for beacon in rotated: dx, dy, dz = [b_i - r_i for b_i, r_i in zip(beacon, reading)] translated = set([(x - dx, y - dy, z - dz) for candidate in rotated for x, y, z in [candidate]]) common_points = known.intersection(translated) if len(common_points) >= 12: known = known.union(translated) matched = True break if matched: break if matched: break if matched: break if matched: scanners.remove(scanner) else: print('Went through all, no match – something is wrong!') break print(len(known)) if __name__ == '__main__': main()